2008-10-27 23:37:02 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2005, 2006
|
2009-06-14 21:23:09 +07:00
|
|
|
* Avishay Traeger (avishay@gmail.com)
|
2008-10-27 23:37:02 +07:00
|
|
|
* Copyright (C) 2008, 2009
|
|
|
|
* Boaz Harrosh <bharrosh@panasas.com>
|
|
|
|
*
|
|
|
|
* Copyrights for code taken from ext2:
|
|
|
|
* Copyright (C) 1992, 1993, 1994, 1995
|
|
|
|
* Remy Card (card@masi.ibp.fr)
|
|
|
|
* Laboratoire MASI - Institut Blaise Pascal
|
|
|
|
* Universite Pierre et Marie Curie (Paris VI)
|
|
|
|
* from
|
|
|
|
* linux/fs/minix/inode.c
|
|
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
|
|
*
|
|
|
|
* This file is part of exofs.
|
|
|
|
*
|
|
|
|
* exofs is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation. Since it is based on ext2, and the only
|
|
|
|
* valid version of GPL for the Linux kernel is version 2, the only valid
|
|
|
|
* version of GPL for exofs is version 2.
|
|
|
|
*
|
|
|
|
* exofs is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with exofs; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-10-27 23:37:02 +07:00
|
|
|
|
|
|
|
#include "exofs.h"
|
|
|
|
|
2009-11-01 23:28:14 +07:00
|
|
|
#define EXOFS_DBGMSG2(M...) do {} while (0)
|
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
unsigned exofs_max_io_pages(struct ore_layout *layout,
|
2010-10-08 01:28:18 +07:00
|
|
|
unsigned expected_pages)
|
|
|
|
{
|
2012-08-02 18:59:57 +07:00
|
|
|
unsigned pages = min_t(unsigned, expected_pages,
|
|
|
|
layout->max_io_length / PAGE_SIZE);
|
2010-10-08 01:28:18 +07:00
|
|
|
|
|
|
|
return pages;
|
|
|
|
}
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
struct page_collect {
|
|
|
|
struct exofs_sb_info *sbi;
|
|
|
|
struct inode *inode;
|
|
|
|
unsigned expected_pages;
|
2011-08-07 09:26:31 +07:00
|
|
|
struct ore_io_state *ios;
|
2008-10-28 00:31:34 +07:00
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
struct page **pages;
|
|
|
|
unsigned alloc_pages;
|
2008-10-28 00:31:34 +07:00
|
|
|
unsigned nr_pages;
|
|
|
|
unsigned long length;
|
|
|
|
loff_t pg_first; /* keep 64bit also in 32-arches */
|
2010-10-08 00:37:51 +07:00
|
|
|
bool read_4_write; /* This means two things: that the read is sync
|
|
|
|
* And the pages should not be unlocked.
|
|
|
|
*/
|
2011-10-12 20:42:07 +07:00
|
|
|
struct page *that_locked_page;
|
2008-10-28 00:31:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void _pcol_init(struct page_collect *pcol, unsigned expected_pages,
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
struct inode *inode)
|
2008-10-28 00:31:34 +07:00
|
|
|
{
|
|
|
|
struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
|
|
|
|
|
|
|
|
pcol->sbi = sbi;
|
|
|
|
pcol->inode = inode;
|
|
|
|
pcol->expected_pages = expected_pages;
|
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
pcol->ios = NULL;
|
2010-01-28 23:24:06 +07:00
|
|
|
pcol->pages = NULL;
|
|
|
|
pcol->alloc_pages = 0;
|
2008-10-28 00:31:34 +07:00
|
|
|
pcol->nr_pages = 0;
|
|
|
|
pcol->length = 0;
|
|
|
|
pcol->pg_first = -1;
|
2010-10-08 00:37:51 +07:00
|
|
|
pcol->read_4_write = false;
|
2011-10-12 20:42:07 +07:00
|
|
|
pcol->that_locked_page = NULL;
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void _pcol_reset(struct page_collect *pcol)
|
|
|
|
{
|
|
|
|
pcol->expected_pages -= min(pcol->nr_pages, pcol->expected_pages);
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
pcol->pages = NULL;
|
|
|
|
pcol->alloc_pages = 0;
|
2008-10-28 00:31:34 +07:00
|
|
|
pcol->nr_pages = 0;
|
|
|
|
pcol->length = 0;
|
|
|
|
pcol->pg_first = -1;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
pcol->ios = NULL;
|
2011-10-12 20:42:07 +07:00
|
|
|
pcol->that_locked_page = NULL;
|
2008-10-28 00:31:34 +07:00
|
|
|
|
|
|
|
/* this is probably the end of the loop but in writes
|
|
|
|
* it might not end here. don't be left with nothing
|
|
|
|
*/
|
|
|
|
if (!pcol->expected_pages)
|
2012-08-02 18:59:57 +07:00
|
|
|
pcol->expected_pages =
|
|
|
|
exofs_max_io_pages(&pcol->sbi->layout, ~0);
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pcol_try_alloc(struct page_collect *pcol)
|
|
|
|
{
|
2010-10-08 01:28:18 +07:00
|
|
|
unsigned pages;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
/* TODO: easily support bio chaining */
|
2010-10-08 01:28:18 +07:00
|
|
|
pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages);
|
2010-01-28 23:24:06 +07:00
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
for (; pages; pages >>= 1) {
|
2010-01-28 23:24:06 +07:00
|
|
|
pcol->pages = kmalloc(pages * sizeof(struct page *),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (likely(pcol->pages)) {
|
|
|
|
pcol->alloc_pages = pages;
|
2008-10-28 00:31:34 +07:00
|
|
|
return 0;
|
2010-01-28 23:24:06 +07:00
|
|
|
}
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
EXOFS_ERR("Failed to kmalloc expected_pages=%u\n",
|
2008-10-28 00:31:34 +07:00
|
|
|
pcol->expected_pages);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pcol_free(struct page_collect *pcol)
|
|
|
|
{
|
2010-01-28 23:24:06 +07:00
|
|
|
kfree(pcol->pages);
|
|
|
|
pcol->pages = NULL;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
|
|
|
|
if (pcol->ios) {
|
2011-08-07 09:26:31 +07:00
|
|
|
ore_put_io_state(pcol->ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
pcol->ios = NULL;
|
|
|
|
}
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pcol_add_page(struct page_collect *pcol, struct page *page,
|
|
|
|
unsigned len)
|
|
|
|
{
|
2010-01-28 23:24:06 +07:00
|
|
|
if (unlikely(pcol->nr_pages >= pcol->alloc_pages))
|
2008-10-28 00:31:34 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
pcol->pages[pcol->nr_pages++] = page;
|
2008-10-28 00:31:34 +07:00
|
|
|
pcol->length += len;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-27 11:00:32 +07:00
|
|
|
enum {PAGE_WAS_NOT_IN_IO = 17};
|
2008-10-28 00:31:34 +07:00
|
|
|
static int update_read_page(struct page *page, int ret)
|
|
|
|
{
|
2011-08-27 11:00:32 +07:00
|
|
|
switch (ret) {
|
|
|
|
case 0:
|
2008-10-28 00:31:34 +07:00
|
|
|
/* Everything is OK */
|
|
|
|
SetPageUptodate(page);
|
|
|
|
if (PageError(page))
|
|
|
|
ClearPageError(page);
|
2011-08-27 11:00:32 +07:00
|
|
|
break;
|
|
|
|
case -EFAULT:
|
2008-10-28 00:31:34 +07:00
|
|
|
/* In this case we were trying to read something that wasn't on
|
|
|
|
* disk yet - return a page full of zeroes. This should be OK,
|
|
|
|
* because the object should be empty (if there was a write
|
|
|
|
* before this read, the read would be waiting with the page
|
|
|
|
* locked */
|
|
|
|
clear_highpage(page);
|
|
|
|
|
|
|
|
SetPageUptodate(page);
|
|
|
|
if (PageError(page))
|
|
|
|
ClearPageError(page);
|
|
|
|
EXOFS_DBGMSG("recovered read error\n");
|
2011-08-27 11:00:32 +07:00
|
|
|
/* fall through */
|
|
|
|
case PAGE_WAS_NOT_IN_IO:
|
|
|
|
ret = 0; /* recovered error */
|
|
|
|
break;
|
|
|
|
default:
|
2008-10-28 00:31:34 +07:00
|
|
|
SetPageError(page);
|
2011-08-27 11:00:32 +07:00
|
|
|
}
|
2008-10-28 00:31:34 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_write_page(struct page *page, int ret)
|
|
|
|
{
|
2011-08-27 11:00:32 +07:00
|
|
|
if (unlikely(ret == PAGE_WAS_NOT_IN_IO))
|
|
|
|
return; /* don't pass start don't collect $200 */
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
if (ret) {
|
|
|
|
mapping_set_error(page->mapping, ret);
|
|
|
|
SetPageError(page);
|
|
|
|
}
|
|
|
|
end_page_writeback(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called at the end of reads, to optionally unlock pages and update their
|
|
|
|
* status.
|
|
|
|
*/
|
2010-10-13 23:55:43 +07:00
|
|
|
static int __readpages_done(struct page_collect *pcol)
|
2008-10-28 00:31:34 +07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u64 good_bytes;
|
|
|
|
u64 length = 0;
|
2011-09-28 17:25:50 +07:00
|
|
|
int ret = ore_check_io(pcol->ios, NULL);
|
2008-10-28 00:31:34 +07:00
|
|
|
|
2011-08-27 11:00:32 +07:00
|
|
|
if (likely(!ret)) {
|
2008-10-28 00:31:34 +07:00
|
|
|
good_bytes = pcol->length;
|
2011-08-27 11:00:32 +07:00
|
|
|
ret = PAGE_WAS_NOT_IN_IO;
|
|
|
|
} else {
|
2011-09-28 17:25:50 +07:00
|
|
|
good_bytes = 0;
|
2011-08-27 11:00:32 +07:00
|
|
|
}
|
2008-10-28 00:31:34 +07:00
|
|
|
|
2009-12-16 00:34:17 +07:00
|
|
|
EXOFS_DBGMSG2("readpages_done(0x%lx) good_bytes=0x%llx"
|
2008-10-28 00:31:34 +07:00
|
|
|
" length=0x%lx nr_pages=%u\n",
|
|
|
|
pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
|
|
|
|
pcol->nr_pages);
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
for (i = 0; i < pcol->nr_pages; i++) {
|
|
|
|
struct page *page = pcol->pages[i];
|
2008-10-28 00:31:34 +07:00
|
|
|
struct inode *inode = page->mapping->host;
|
|
|
|
int page_stat;
|
|
|
|
|
|
|
|
if (inode != pcol->inode)
|
|
|
|
continue; /* osd might add more pages at end */
|
|
|
|
|
|
|
|
if (likely(length < good_bytes))
|
|
|
|
page_stat = 0;
|
|
|
|
else
|
|
|
|
page_stat = ret;
|
|
|
|
|
2009-11-01 23:28:14 +07:00
|
|
|
EXOFS_DBGMSG2(" readpages_done(0x%lx, 0x%lx) %s\n",
|
2008-10-28 00:31:34 +07:00
|
|
|
inode->i_ino, page->index,
|
|
|
|
page_stat ? "bad_bytes" : "good_bytes");
|
|
|
|
|
|
|
|
ret = update_read_page(page, page_stat);
|
2010-10-13 23:55:43 +07:00
|
|
|
if (!pcol->read_4_write)
|
2008-10-28 00:31:34 +07:00
|
|
|
unlock_page(page);
|
2010-01-28 23:24:06 +07:00
|
|
|
length += PAGE_SIZE;
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
pcol_free(pcol);
|
2009-12-16 00:34:17 +07:00
|
|
|
EXOFS_DBGMSG2("readpages_done END\n");
|
2008-10-28 00:31:34 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* callback of async reads */
|
2011-08-07 09:26:31 +07:00
|
|
|
static void readpages_done(struct ore_io_state *ios, void *p)
|
2008-10-28 00:31:34 +07:00
|
|
|
{
|
|
|
|
struct page_collect *pcol = p;
|
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
__readpages_done(pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
atomic_dec(&pcol->sbi->s_curr_pending);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
kfree(pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void _unlock_pcol_pages(struct page_collect *pcol, int ret, int rw)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
for (i = 0; i < pcol->nr_pages; i++) {
|
|
|
|
struct page *page = pcol->pages[i];
|
2008-10-28 00:31:34 +07:00
|
|
|
|
|
|
|
if (rw == READ)
|
|
|
|
update_read_page(page, ret);
|
|
|
|
else
|
|
|
|
update_write_page(page, ret);
|
|
|
|
|
|
|
|
unlock_page(page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 15:55:51 +07:00
|
|
|
static int _maybe_not_all_in_one_io(struct ore_io_state *ios,
|
|
|
|
struct page_collect *pcol_src, struct page_collect *pcol)
|
|
|
|
{
|
|
|
|
/* length was wrong or offset was not page aligned */
|
|
|
|
BUG_ON(pcol_src->nr_pages < ios->nr_pages);
|
|
|
|
|
|
|
|
if (pcol_src->nr_pages > ios->nr_pages) {
|
|
|
|
struct page **src_page;
|
|
|
|
unsigned pages_less = pcol_src->nr_pages - ios->nr_pages;
|
|
|
|
unsigned long len_less = pcol_src->length - ios->length;
|
|
|
|
unsigned i;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* This IO was trimmed */
|
|
|
|
pcol_src->nr_pages = ios->nr_pages;
|
|
|
|
pcol_src->length = ios->length;
|
|
|
|
|
|
|
|
/* Left over pages are passed to the next io */
|
|
|
|
pcol->expected_pages += pages_less;
|
|
|
|
pcol->nr_pages = pages_less;
|
|
|
|
pcol->length = len_less;
|
|
|
|
src_page = pcol_src->pages + pcol_src->nr_pages;
|
|
|
|
pcol->pg_first = (*src_page)->index;
|
|
|
|
|
|
|
|
ret = pcol_try_alloc(pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
for (i = 0; i < pages_less; ++i)
|
|
|
|
pcol->pages[i] = *src_page++;
|
|
|
|
|
|
|
|
EXOFS_DBGMSG("Length was adjusted nr_pages=0x%x "
|
|
|
|
"pages_less=0x%x expected_pages=0x%x "
|
|
|
|
"next_offset=0x%llx next_len=0x%lx\n",
|
|
|
|
pcol_src->nr_pages, pages_less, pcol->expected_pages,
|
|
|
|
pcol->pg_first * PAGE_SIZE, pcol->length);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
static int read_exec(struct page_collect *pcol)
|
2008-10-28 00:31:34 +07:00
|
|
|
{
|
|
|
|
struct exofs_i_info *oi = exofs_i(pcol->inode);
|
2011-08-07 09:26:31 +07:00
|
|
|
struct ore_io_state *ios;
|
2008-10-28 00:31:34 +07:00
|
|
|
struct page_collect *pcol_copy = NULL;
|
|
|
|
int ret;
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
if (!pcol->pages)
|
2008-10-28 00:31:34 +07:00
|
|
|
return 0;
|
|
|
|
|
2010-11-17 01:09:58 +07:00
|
|
|
if (!pcol->ios) {
|
2011-09-28 15:39:59 +07:00
|
|
|
int ret = ore_get_rw_state(&pcol->sbi->layout, &oi->oc, true,
|
2010-11-17 01:09:58 +07:00
|
|
|
pcol->pg_first << PAGE_CACHE_SHIFT,
|
|
|
|
pcol->length, &pcol->ios);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ios = pcol->ios;
|
2010-01-28 23:24:06 +07:00
|
|
|
ios->pages = pcol->pages;
|
2008-10-28 00:31:34 +07:00
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
if (pcol->read_4_write) {
|
2011-08-07 09:26:31 +07:00
|
|
|
ore_read(pcol->ios);
|
2010-10-13 23:55:43 +07:00
|
|
|
return __readpages_done(pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
|
|
|
|
if (!pcol_copy) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcol_copy = *pcol;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->done = readpages_done;
|
|
|
|
ios->private = pcol_copy;
|
2011-09-28 15:55:51 +07:00
|
|
|
|
|
|
|
/* pages ownership was passed to pcol_copy */
|
|
|
|
_pcol_reset(pcol);
|
|
|
|
|
|
|
|
ret = _maybe_not_all_in_one_io(ios, pcol_copy, pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
EXOFS_DBGMSG2("read_exec(0x%lx) offset=0x%llx length=0x%llx\n",
|
|
|
|
pcol->inode->i_ino, _LLU(ios->offset), _LLU(ios->length));
|
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ret = ore_read(ios);
|
2008-10-28 00:31:34 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
atomic_inc(&pcol->sbi->s_curr_pending);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2012-11-30 21:03:31 +07:00
|
|
|
if (!pcol_copy) /* Failed before ownership transfer */
|
|
|
|
pcol_copy = pcol;
|
|
|
|
_unlock_pcol_pages(pcol_copy, ret, READ);
|
|
|
|
pcol_free(pcol_copy);
|
2008-10-28 00:31:34 +07:00
|
|
|
kfree(pcol_copy);
|
2012-11-30 21:03:31 +07:00
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readpage_strip is called either directly from readpage() or by the VFS from
|
|
|
|
* within read_cache_pages(), to add one more page to be read. It will try to
|
|
|
|
* collect as many contiguous pages as posible. If a discontinuity is
|
|
|
|
* encountered, or it runs out of resources, it will submit the previous segment
|
|
|
|
* and will start a new collection. Eventually caller must submit the last
|
|
|
|
* segment if present.
|
|
|
|
*/
|
|
|
|
static int readpage_strip(void *data, struct page *page)
|
|
|
|
{
|
|
|
|
struct page_collect *pcol = data;
|
|
|
|
struct inode *inode = pcol->inode;
|
|
|
|
struct exofs_i_info *oi = exofs_i(inode);
|
|
|
|
loff_t i_size = i_size_read(inode);
|
|
|
|
pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
|
|
|
|
size_t len;
|
|
|
|
int ret;
|
|
|
|
|
2012-02-20 15:46:12 +07:00
|
|
|
BUG_ON(!PageLocked(page));
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
/* FIXME: Just for debugging, will be removed */
|
|
|
|
if (PageUptodate(page))
|
|
|
|
EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino,
|
|
|
|
page->index);
|
|
|
|
|
2011-10-12 20:42:07 +07:00
|
|
|
pcol->that_locked_page = page;
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
if (page->index < end_index)
|
|
|
|
len = PAGE_CACHE_SIZE;
|
|
|
|
else if (page->index == end_index)
|
|
|
|
len = i_size & ~PAGE_CACHE_MASK;
|
|
|
|
else
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
if (!len || !obj_created(oi)) {
|
|
|
|
/* this will be out of bounds, or doesn't exist yet.
|
|
|
|
* Current page is cleared and the request is split
|
|
|
|
*/
|
|
|
|
clear_highpage(page);
|
|
|
|
|
|
|
|
SetPageUptodate(page);
|
|
|
|
if (PageError(page))
|
|
|
|
ClearPageError(page);
|
|
|
|
|
2010-10-08 00:37:51 +07:00
|
|
|
if (!pcol->read_4_write)
|
|
|
|
unlock_page(page);
|
2010-11-22 23:02:45 +07:00
|
|
|
EXOFS_DBGMSG("readpage_strip(0x%lx) empty page len=%zx "
|
|
|
|
"read_4_write=%d index=0x%lx end_index=0x%lx "
|
|
|
|
"splitting\n", inode->i_ino, len,
|
|
|
|
pcol->read_4_write, page->index, end_index);
|
2008-10-28 00:31:34 +07:00
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
return read_exec(pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
try_again:
|
|
|
|
|
|
|
|
if (unlikely(pcol->pg_first == -1)) {
|
|
|
|
pcol->pg_first = page->index;
|
|
|
|
} else if (unlikely((pcol->pg_first + pcol->nr_pages) !=
|
|
|
|
page->index)) {
|
|
|
|
/* Discontinuity detected, split the request */
|
2010-10-13 23:55:43 +07:00
|
|
|
ret = read_exec(pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
goto fail;
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
if (!pcol->pages) {
|
2008-10-28 00:31:34 +07:00
|
|
|
ret = pcol_try_alloc(pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len != PAGE_CACHE_SIZE)
|
|
|
|
zero_user(page, len, PAGE_CACHE_SIZE - len);
|
|
|
|
|
2009-11-01 23:28:14 +07:00
|
|
|
EXOFS_DBGMSG2(" readpage_strip(0x%lx, 0x%lx) len=0x%zx\n",
|
2008-10-28 00:31:34 +07:00
|
|
|
inode->i_ino, page->index, len);
|
|
|
|
|
|
|
|
ret = pcol_add_page(pcol, page, len);
|
|
|
|
if (ret) {
|
2009-11-01 23:28:14 +07:00
|
|
|
EXOFS_DBGMSG2("Failed pcol_add_page pages[i]=%p "
|
2008-10-28 00:31:34 +07:00
|
|
|
"this_len=0x%zx nr_pages=%u length=0x%lx\n",
|
|
|
|
page, len, pcol->nr_pages, pcol->length);
|
|
|
|
|
|
|
|
/* split the request, and start again with current page */
|
2010-10-13 23:55:43 +07:00
|
|
|
ret = read_exec(pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
/* SetPageError(page); ??? */
|
|
|
|
unlock_page(page);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exofs_readpages(struct file *file, struct address_space *mapping,
|
|
|
|
struct list_head *pages, unsigned nr_pages)
|
|
|
|
{
|
|
|
|
struct page_collect pcol;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
_pcol_init(&pcol, nr_pages, mapping->host);
|
|
|
|
|
|
|
|
ret = read_cache_pages(mapping, pages, readpage_strip, &pcol);
|
|
|
|
if (ret) {
|
|
|
|
EXOFS_ERR("read_cache_pages => %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-09-28 15:55:51 +07:00
|
|
|
ret = read_exec(&pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
return ret;
|
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
return read_exec(&pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
static int _readpage(struct page *page, bool read_4_write)
|
2008-10-28 00:31:34 +07:00
|
|
|
{
|
|
|
|
struct page_collect pcol;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
_pcol_init(&pcol, 1, page->mapping->host);
|
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
pcol.read_4_write = read_4_write;
|
2008-10-28 00:31:34 +07:00
|
|
|
ret = readpage_strip(&pcol, page);
|
|
|
|
if (ret) {
|
|
|
|
EXOFS_ERR("_readpage => %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-10-13 23:55:43 +07:00
|
|
|
return read_exec(&pcol);
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't need the file
|
|
|
|
*/
|
|
|
|
static int exofs_readpage(struct file *file, struct page *page)
|
|
|
|
{
|
|
|
|
return _readpage(page, false);
|
|
|
|
}
|
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
/* Callback for osd_write. All writes are asynchronous */
|
2011-08-07 09:26:31 +07:00
|
|
|
static void writepages_done(struct ore_io_state *ios, void *p)
|
2008-10-28 00:31:34 +07:00
|
|
|
{
|
|
|
|
struct page_collect *pcol = p;
|
|
|
|
int i;
|
|
|
|
u64 good_bytes;
|
|
|
|
u64 length = 0;
|
2011-09-28 17:25:50 +07:00
|
|
|
int ret = ore_check_io(ios, NULL);
|
2008-10-28 00:31:34 +07:00
|
|
|
|
|
|
|
atomic_dec(&pcol->sbi->s_curr_pending);
|
|
|
|
|
2011-08-27 11:00:32 +07:00
|
|
|
if (likely(!ret)) {
|
2008-10-28 00:31:34 +07:00
|
|
|
good_bytes = pcol->length;
|
2011-08-27 11:00:32 +07:00
|
|
|
ret = PAGE_WAS_NOT_IN_IO;
|
|
|
|
} else {
|
2011-09-28 17:25:50 +07:00
|
|
|
good_bytes = 0;
|
2011-08-27 11:00:32 +07:00
|
|
|
}
|
2008-10-28 00:31:34 +07:00
|
|
|
|
2009-12-16 00:34:17 +07:00
|
|
|
EXOFS_DBGMSG2("writepages_done(0x%lx) good_bytes=0x%llx"
|
2008-10-28 00:31:34 +07:00
|
|
|
" length=0x%lx nr_pages=%u\n",
|
|
|
|
pcol->inode->i_ino, _LLU(good_bytes), pcol->length,
|
|
|
|
pcol->nr_pages);
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
for (i = 0; i < pcol->nr_pages; i++) {
|
|
|
|
struct page *page = pcol->pages[i];
|
2008-10-28 00:31:34 +07:00
|
|
|
struct inode *inode = page->mapping->host;
|
|
|
|
int page_stat;
|
|
|
|
|
|
|
|
if (inode != pcol->inode)
|
|
|
|
continue; /* osd might add more pages to a bio */
|
|
|
|
|
|
|
|
if (likely(length < good_bytes))
|
|
|
|
page_stat = 0;
|
|
|
|
else
|
|
|
|
page_stat = ret;
|
|
|
|
|
|
|
|
update_write_page(page, page_stat);
|
|
|
|
unlock_page(page);
|
2009-11-01 23:28:14 +07:00
|
|
|
EXOFS_DBGMSG2(" writepages_done(0x%lx, 0x%lx) status=%d\n",
|
2008-10-28 00:31:34 +07:00
|
|
|
inode->i_ino, page->index, page_stat);
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
length += PAGE_SIZE;
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
pcol_free(pcol);
|
|
|
|
kfree(pcol);
|
2009-12-16 00:34:17 +07:00
|
|
|
EXOFS_DBGMSG2("writepages_done END\n");
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
2011-10-12 20:42:07 +07:00
|
|
|
static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate)
|
|
|
|
{
|
|
|
|
struct page_collect *pcol = priv;
|
|
|
|
pgoff_t index = offset / PAGE_SIZE;
|
|
|
|
|
|
|
|
if (!pcol->that_locked_page ||
|
|
|
|
(pcol->that_locked_page->index != index)) {
|
2012-07-20 19:50:27 +07:00
|
|
|
struct page *page;
|
|
|
|
loff_t i_size = i_size_read(pcol->inode);
|
2011-10-12 20:42:07 +07:00
|
|
|
|
2012-07-20 19:50:27 +07:00
|
|
|
if (offset >= i_size) {
|
|
|
|
*uptodate = true;
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_DBGMSG2("offset >= i_size index=0x%lx\n", index);
|
2012-07-20 19:50:27 +07:00
|
|
|
return ZERO_PAGE(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
page = find_get_page(pcol->inode->i_mapping, index);
|
2011-10-12 20:42:07 +07:00
|
|
|
if (!page) {
|
|
|
|
page = find_or_create_page(pcol->inode->i_mapping,
|
|
|
|
index, GFP_NOFS);
|
|
|
|
if (unlikely(!page)) {
|
|
|
|
EXOFS_DBGMSG("grab_cache_page Failed "
|
|
|
|
"index=0x%llx\n", _LLU(index));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
unlock_page(page);
|
|
|
|
}
|
|
|
|
if (PageDirty(page) || PageWriteback(page))
|
|
|
|
*uptodate = true;
|
|
|
|
else
|
|
|
|
*uptodate = PageUptodate(page);
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_DBGMSG2("index=0x%lx uptodate=%d\n", index, *uptodate);
|
2011-10-12 20:42:07 +07:00
|
|
|
return page;
|
|
|
|
} else {
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_DBGMSG2("YES that_locked_page index=0x%lx\n",
|
2011-10-12 20:42:07 +07:00
|
|
|
pcol->that_locked_page->index);
|
|
|
|
*uptodate = true;
|
|
|
|
return pcol->that_locked_page;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __r4w_put_page(void *priv, struct page *page)
|
|
|
|
{
|
|
|
|
struct page_collect *pcol = priv;
|
|
|
|
|
2012-07-20 19:50:27 +07:00
|
|
|
if ((pcol->that_locked_page != page) && (ZERO_PAGE(0) != page)) {
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_DBGMSG2("index=0x%lx\n", page->index);
|
2011-10-12 20:42:07 +07:00
|
|
|
page_cache_release(page);
|
|
|
|
return;
|
|
|
|
}
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_DBGMSG2("that_locked_page index=0x%lx\n",
|
2012-07-20 19:50:27 +07:00
|
|
|
ZERO_PAGE(0) == page ? -1 : page->index);
|
2011-10-12 20:42:07 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct _ore_r4w_op _r4w_op = {
|
|
|
|
.get_page = &__r4w_get_page,
|
|
|
|
.put_page = &__r4w_put_page,
|
|
|
|
};
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
static int write_exec(struct page_collect *pcol)
|
|
|
|
{
|
|
|
|
struct exofs_i_info *oi = exofs_i(pcol->inode);
|
2011-08-07 09:26:31 +07:00
|
|
|
struct ore_io_state *ios;
|
2008-10-28 00:31:34 +07:00
|
|
|
struct page_collect *pcol_copy = NULL;
|
|
|
|
int ret;
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
if (!pcol->pages)
|
2008-10-28 00:31:34 +07:00
|
|
|
return 0;
|
|
|
|
|
2010-11-17 01:09:58 +07:00
|
|
|
BUG_ON(pcol->ios);
|
2011-09-28 15:39:59 +07:00
|
|
|
ret = ore_get_rw_state(&pcol->sbi->layout, &oi->oc, false,
|
2010-11-17 01:09:58 +07:00
|
|
|
pcol->pg_first << PAGE_CACHE_SHIFT,
|
|
|
|
pcol->length, &pcol->ios);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto err;
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
|
|
|
|
if (!pcol_copy) {
|
2010-10-22 12:17:17 +07:00
|
|
|
EXOFS_ERR("write_exec: Failed to kmalloc(pcol)\n");
|
2008-10-28 00:31:34 +07:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcol_copy = *pcol;
|
|
|
|
|
2010-11-17 01:09:58 +07:00
|
|
|
ios = pcol->ios;
|
2010-01-28 23:24:06 +07:00
|
|
|
ios->pages = pcol_copy->pages;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->done = writepages_done;
|
2011-10-12 20:42:07 +07:00
|
|
|
ios->r4w = &_r4w_op;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->private = pcol_copy;
|
|
|
|
|
2011-09-28 15:55:51 +07:00
|
|
|
/* pages ownership was passed to pcol_copy */
|
|
|
|
_pcol_reset(pcol);
|
|
|
|
|
|
|
|
ret = _maybe_not_all_in_one_io(ios, pcol_copy, pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
EXOFS_DBGMSG2("write_exec(0x%lx) offset=0x%llx length=0x%llx\n",
|
|
|
|
pcol->inode->i_ino, _LLU(ios->offset), _LLU(ios->length));
|
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ret = ore_write(ios);
|
2008-10-28 00:31:34 +07:00
|
|
|
if (unlikely(ret)) {
|
2011-08-07 09:26:31 +07:00
|
|
|
EXOFS_ERR("write_exec: ore_write() Failed\n");
|
2008-10-28 00:31:34 +07:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
atomic_inc(&pcol->sbi->s_curr_pending);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2012-11-30 21:03:31 +07:00
|
|
|
if (!pcol_copy) /* Failed before ownership transfer */
|
|
|
|
pcol_copy = pcol;
|
|
|
|
_unlock_pcol_pages(pcol_copy, ret, WRITE);
|
|
|
|
pcol_free(pcol_copy);
|
2008-10-28 00:31:34 +07:00
|
|
|
kfree(pcol_copy);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* writepage_strip is called either directly from writepage() or by the VFS from
|
|
|
|
* within write_cache_pages(), to add one more page to be written to storage.
|
|
|
|
* It will try to collect as many contiguous pages as possible. If a
|
|
|
|
* discontinuity is encountered or it runs out of resources it will submit the
|
|
|
|
* previous segment and will start a new collection.
|
|
|
|
* Eventually caller must submit the last segment if present.
|
|
|
|
*/
|
|
|
|
static int writepage_strip(struct page *page,
|
|
|
|
struct writeback_control *wbc_unused, void *data)
|
|
|
|
{
|
|
|
|
struct page_collect *pcol = data;
|
|
|
|
struct inode *inode = pcol->inode;
|
|
|
|
struct exofs_i_info *oi = exofs_i(inode);
|
|
|
|
loff_t i_size = i_size_read(inode);
|
|
|
|
pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
|
|
|
|
size_t len;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
BUG_ON(!PageLocked(page));
|
|
|
|
|
|
|
|
ret = wait_obj_created(oi);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (page->index < end_index)
|
|
|
|
/* in this case, the page is within the limits of the file */
|
|
|
|
len = PAGE_CACHE_SIZE;
|
|
|
|
else {
|
|
|
|
len = i_size & ~PAGE_CACHE_MASK;
|
|
|
|
|
|
|
|
if (page->index > end_index || !len) {
|
|
|
|
/* in this case, the page is outside the limits
|
|
|
|
* (truncate in progress)
|
|
|
|
*/
|
|
|
|
ret = write_exec(pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto fail;
|
|
|
|
if (PageError(page))
|
|
|
|
ClearPageError(page);
|
|
|
|
unlock_page(page);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
EXOFS_DBGMSG("writepage_strip(0x%lx, 0x%lx) "
|
|
|
|
"outside the limits\n",
|
|
|
|
inode->i_ino, page->index);
|
2008-10-28 00:31:34 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try_again:
|
|
|
|
|
|
|
|
if (unlikely(pcol->pg_first == -1)) {
|
|
|
|
pcol->pg_first = page->index;
|
|
|
|
} else if (unlikely((pcol->pg_first + pcol->nr_pages) !=
|
|
|
|
page->index)) {
|
|
|
|
/* Discontinuity detected, split the request */
|
|
|
|
ret = write_exec(pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto fail;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
|
|
|
|
EXOFS_DBGMSG("writepage_strip(0x%lx, 0x%lx) Discontinuity\n",
|
|
|
|
inode->i_ino, page->index);
|
2008-10-28 00:31:34 +07:00
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
2010-01-28 23:24:06 +07:00
|
|
|
if (!pcol->pages) {
|
2008-10-28 00:31:34 +07:00
|
|
|
ret = pcol_try_alloc(pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2009-11-01 23:28:14 +07:00
|
|
|
EXOFS_DBGMSG2(" writepage_strip(0x%lx, 0x%lx) len=0x%zx\n",
|
2008-10-28 00:31:34 +07:00
|
|
|
inode->i_ino, page->index, len);
|
|
|
|
|
|
|
|
ret = pcol_add_page(pcol, page, len);
|
|
|
|
if (unlikely(ret)) {
|
2009-12-16 00:34:17 +07:00
|
|
|
EXOFS_DBGMSG2("Failed pcol_add_page "
|
2008-10-28 00:31:34 +07:00
|
|
|
"nr_pages=%u total_length=0x%lx\n",
|
|
|
|
pcol->nr_pages, pcol->length);
|
|
|
|
|
|
|
|
/* split the request, next loop will start again */
|
|
|
|
ret = write_exec(pcol);
|
|
|
|
if (unlikely(ret)) {
|
2010-10-22 12:17:17 +07:00
|
|
|
EXOFS_DBGMSG("write_exec failed => %d", ret);
|
2008-10-28 00:31:34 +07:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUG_ON(PageWriteback(page));
|
|
|
|
set_page_writeback(page);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
EXOFS_DBGMSG("Error: writepage_strip(0x%lx, 0x%lx)=>%d\n",
|
|
|
|
inode->i_ino, page->index, ret);
|
2008-10-28 00:31:34 +07:00
|
|
|
set_bit(AS_EIO, &page->mapping->flags);
|
|
|
|
unlock_page(page);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exofs_writepages(struct address_space *mapping,
|
|
|
|
struct writeback_control *wbc)
|
|
|
|
{
|
|
|
|
struct page_collect pcol;
|
|
|
|
long start, end, expected_pages;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
start = wbc->range_start >> PAGE_CACHE_SHIFT;
|
|
|
|
end = (wbc->range_end == LLONG_MAX) ?
|
|
|
|
start + mapping->nrpages :
|
|
|
|
wbc->range_end >> PAGE_CACHE_SHIFT;
|
|
|
|
|
|
|
|
if (start || end)
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
expected_pages = end - start + 1;
|
2008-10-28 00:31:34 +07:00
|
|
|
else
|
|
|
|
expected_pages = mapping->nrpages;
|
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
if (expected_pages < 32L)
|
|
|
|
expected_pages = 32L;
|
|
|
|
|
2009-12-16 00:34:17 +07:00
|
|
|
EXOFS_DBGMSG2("inode(0x%lx) wbc->start=0x%llx wbc->end=0x%llx "
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
"nrpages=%lu start=0x%lx end=0x%lx expected_pages=%ld\n",
|
2008-10-28 00:31:34 +07:00
|
|
|
mapping->host->i_ino, wbc->range_start, wbc->range_end,
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
mapping->nrpages, start, end, expected_pages);
|
2008-10-28 00:31:34 +07:00
|
|
|
|
|
|
|
_pcol_init(&pcol, expected_pages, mapping->host);
|
|
|
|
|
|
|
|
ret = write_cache_pages(mapping, wbc, writepage_strip, &pcol);
|
2011-09-28 15:55:51 +07:00
|
|
|
if (unlikely(ret)) {
|
2008-10-28 00:31:34 +07:00
|
|
|
EXOFS_ERR("write_cache_pages => %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-09-28 15:55:51 +07:00
|
|
|
ret = write_exec(&pcol);
|
|
|
|
if (unlikely(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (wbc->sync_mode == WB_SYNC_ALL) {
|
|
|
|
return write_exec(&pcol); /* pump the last reminder */
|
|
|
|
} else if (pcol.nr_pages) {
|
|
|
|
/* not SYNC let the reminder join the next writeout */
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < pcol.nr_pages; i++) {
|
|
|
|
struct page *page = pcol.pages[i];
|
|
|
|
|
|
|
|
end_page_writeback(page);
|
|
|
|
set_page_dirty(page);
|
|
|
|
unlock_page(page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
2011-10-12 20:42:07 +07:00
|
|
|
/*
|
2008-10-28 00:31:34 +07:00
|
|
|
static int exofs_writepage(struct page *page, struct writeback_control *wbc)
|
|
|
|
{
|
|
|
|
struct page_collect pcol;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
_pcol_init(&pcol, 1, page->mapping->host);
|
|
|
|
|
|
|
|
ret = writepage_strip(page, NULL, &pcol);
|
|
|
|
if (ret) {
|
|
|
|
EXOFS_ERR("exofs_writepage => %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return write_exec(&pcol);
|
|
|
|
}
|
2011-10-12 20:42:07 +07:00
|
|
|
*/
|
2010-06-09 22:23:18 +07:00
|
|
|
/* i_mutex held using inode->i_size directly */
|
|
|
|
static void _write_failed(struct inode *inode, loff_t to)
|
|
|
|
{
|
|
|
|
if (to > inode->i_size)
|
2013-09-13 05:13:56 +07:00
|
|
|
truncate_pagecache(inode, inode->i_size);
|
2010-06-09 22:23:18 +07:00
|
|
|
}
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
int exofs_write_begin(struct file *file, struct address_space *mapping,
|
|
|
|
loff_t pos, unsigned len, unsigned flags,
|
|
|
|
struct page **pagep, void **fsdata)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct page *page;
|
|
|
|
|
|
|
|
page = *pagep;
|
|
|
|
if (page == NULL) {
|
|
|
|
ret = simple_write_begin(file, mapping, pos, len, flags, pagep,
|
|
|
|
fsdata);
|
|
|
|
if (ret) {
|
2010-10-22 12:17:17 +07:00
|
|
|
EXOFS_DBGMSG("simple_write_begin failed\n");
|
2010-06-09 22:23:18 +07:00
|
|
|
goto out;
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
page = *pagep;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read modify write */
|
|
|
|
if (!PageUptodate(page) && (len != PAGE_CACHE_SIZE)) {
|
2010-11-22 23:02:45 +07:00
|
|
|
loff_t i_size = i_size_read(mapping->host);
|
|
|
|
pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
|
|
|
|
size_t rlen;
|
|
|
|
|
|
|
|
if (page->index < end_index)
|
|
|
|
rlen = PAGE_CACHE_SIZE;
|
|
|
|
else if (page->index == end_index)
|
|
|
|
rlen = i_size & ~PAGE_CACHE_MASK;
|
|
|
|
else
|
|
|
|
rlen = 0;
|
|
|
|
|
|
|
|
if (!rlen) {
|
|
|
|
clear_highpage(page);
|
|
|
|
SetPageUptodate(page);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
ret = _readpage(page, true);
|
|
|
|
if (ret) {
|
|
|
|
/*SetPageError was done by _readpage. Is it ok?*/
|
|
|
|
unlock_page(page);
|
2010-11-22 23:02:45 +07:00
|
|
|
EXOFS_DBGMSG("__readpage failed\n");
|
2008-10-28 00:31:34 +07:00
|
|
|
}
|
|
|
|
}
|
2010-06-09 22:23:18 +07:00
|
|
|
out:
|
|
|
|
if (unlikely(ret))
|
|
|
|
_write_failed(mapping->host, pos + len);
|
2008-10-28 00:31:34 +07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exofs_write_begin_export(struct file *file,
|
|
|
|
struct address_space *mapping,
|
|
|
|
loff_t pos, unsigned len, unsigned flags,
|
|
|
|
struct page **pagep, void **fsdata)
|
|
|
|
{
|
|
|
|
*pagep = NULL;
|
|
|
|
|
|
|
|
return exofs_write_begin(file, mapping, pos, len, flags, pagep,
|
|
|
|
fsdata);
|
|
|
|
}
|
|
|
|
|
2009-12-27 22:01:42 +07:00
|
|
|
static int exofs_write_end(struct file *file, struct address_space *mapping,
|
|
|
|
loff_t pos, unsigned len, unsigned copied,
|
|
|
|
struct page *page, void *fsdata)
|
|
|
|
{
|
|
|
|
struct inode *inode = mapping->host;
|
|
|
|
/* According to comment in simple_write_end i_mutex is held */
|
|
|
|
loff_t i_size = inode->i_size;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = simple_write_end(file, mapping,pos, len, copied, page, fsdata);
|
2010-06-09 22:23:18 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
_write_failed(inode, pos + len);
|
|
|
|
|
|
|
|
/* TODO: once simple_write_end marks inode dirty remove */
|
2009-12-27 22:01:42 +07:00
|
|
|
if (i_size != inode->i_size)
|
|
|
|
mark_inode_dirty(inode);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-03-22 16:23:40 +07:00
|
|
|
static int exofs_releasepage(struct page *page, gfp_t gfp)
|
|
|
|
{
|
|
|
|
EXOFS_DBGMSG("page 0x%lx\n", page->index);
|
|
|
|
WARN_ON(1);
|
2010-05-31 22:55:43 +07:00
|
|
|
return 0;
|
2010-03-22 16:23:40 +07:00
|
|
|
}
|
|
|
|
|
2013-05-22 10:17:23 +07:00
|
|
|
static void exofs_invalidatepage(struct page *page, unsigned int offset,
|
|
|
|
unsigned int length)
|
2010-03-22 16:23:40 +07:00
|
|
|
{
|
2013-05-22 10:17:23 +07:00
|
|
|
EXOFS_DBGMSG("page 0x%lx offset 0x%x length 0x%x\n",
|
|
|
|
page->index, offset, length);
|
2010-03-22 16:23:40 +07:00
|
|
|
WARN_ON(1);
|
|
|
|
}
|
|
|
|
|
2014-01-14 04:45:43 +07:00
|
|
|
|
|
|
|
/* TODO: Should be easy enough to do proprly */
|
|
|
|
static ssize_t exofs_direct_IO(int rw, struct kiocb *iocb,
|
2014-03-05 09:27:34 +07:00
|
|
|
struct iov_iter *iter, loff_t offset)
|
2014-01-14 04:45:43 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-28 00:31:34 +07:00
|
|
|
const struct address_space_operations exofs_aops = {
|
|
|
|
.readpage = exofs_readpage,
|
|
|
|
.readpages = exofs_readpages,
|
2011-10-12 20:42:07 +07:00
|
|
|
.writepage = NULL,
|
2008-10-28 00:31:34 +07:00
|
|
|
.writepages = exofs_writepages,
|
|
|
|
.write_begin = exofs_write_begin_export,
|
2009-12-27 22:01:42 +07:00
|
|
|
.write_end = exofs_write_end,
|
2010-03-22 16:23:40 +07:00
|
|
|
.releasepage = exofs_releasepage,
|
|
|
|
.set_page_dirty = __set_page_dirty_nobuffers,
|
|
|
|
.invalidatepage = exofs_invalidatepage,
|
|
|
|
|
|
|
|
/* Not implemented Yet */
|
|
|
|
.bmap = NULL, /* TODO: use osd's OSD_ACT_READ_MAP */
|
2014-01-14 04:45:43 +07:00
|
|
|
.direct_IO = exofs_direct_IO,
|
2010-03-22 16:23:40 +07:00
|
|
|
|
|
|
|
/* With these NULL has special meaning or default is not exported */
|
|
|
|
.get_xip_mem = NULL,
|
|
|
|
.migratepage = NULL,
|
|
|
|
.launder_page = NULL,
|
|
|
|
.is_partially_uptodate = NULL,
|
|
|
|
.error_remove_page = NULL,
|
2008-10-28 00:31:34 +07:00
|
|
|
};
|
|
|
|
|
2008-10-27 23:37:02 +07:00
|
|
|
/******************************************************************************
|
|
|
|
* INODE OPERATIONS
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test whether an inode is a fast symlink.
|
|
|
|
*/
|
|
|
|
static inline int exofs_inode_is_fast_symlink(struct inode *inode)
|
|
|
|
{
|
|
|
|
struct exofs_i_info *oi = exofs_i(inode);
|
|
|
|
|
|
|
|
return S_ISLNK(inode->i_mode) && (oi->i_data[0] != 0);
|
|
|
|
}
|
|
|
|
|
2010-06-09 22:23:18 +07:00
|
|
|
static int _do_truncate(struct inode *inode, loff_t newsize)
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
{
|
|
|
|
struct exofs_i_info *oi = exofs_i(inode);
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
|
|
|
|
|
2011-09-28 15:39:59 +07:00
|
|
|
ret = ore_truncate(&sbi->layout, &oi->oc, (u64)newsize);
|
2010-06-09 22:23:18 +07:00
|
|
|
if (likely(!ret))
|
|
|
|
truncate_setsize(inode, newsize);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_DBGMSG2("(0x%lx) size=0x%llx ret=>%d\n",
|
2010-06-09 22:23:18 +07:00
|
|
|
inode->i_ino, newsize, ret);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-10-27 23:37:02 +07:00
|
|
|
/*
|
2010-06-09 22:23:18 +07:00
|
|
|
* Set inode attributes - update size attribute on OSD if needed,
|
|
|
|
* otherwise just call generic functions.
|
2008-10-27 23:37:02 +07:00
|
|
|
*/
|
|
|
|
int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
|
|
|
|
{
|
|
|
|
struct inode *inode = dentry->d_inode;
|
|
|
|
int error;
|
|
|
|
|
2010-06-09 22:23:18 +07:00
|
|
|
/* if we are about to modify an object, and it hasn't been
|
|
|
|
* created yet, wait
|
|
|
|
*/
|
|
|
|
error = wait_obj_created(exofs_i(inode));
|
|
|
|
if (unlikely(error))
|
|
|
|
return error;
|
|
|
|
|
2008-10-27 23:37:02 +07:00
|
|
|
error = inode_change_ok(inode, iattr);
|
2010-06-09 22:23:18 +07:00
|
|
|
if (unlikely(error))
|
2008-10-27 23:37:02 +07:00
|
|
|
return error;
|
|
|
|
|
2010-06-04 16:30:02 +07:00
|
|
|
if ((iattr->ia_valid & ATTR_SIZE) &&
|
|
|
|
iattr->ia_size != i_size_read(inode)) {
|
2010-06-09 22:23:18 +07:00
|
|
|
error = _do_truncate(inode, iattr->ia_size);
|
|
|
|
if (unlikely(error))
|
2010-06-04 16:30:02 +07:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
setattr_copy(inode, iattr);
|
|
|
|
mark_inode_dirty(inode);
|
|
|
|
return 0;
|
2008-10-27 23:37:02 +07:00
|
|
|
}
|
2008-10-28 20:38:12 +07:00
|
|
|
|
2010-01-28 16:58:08 +07:00
|
|
|
static const struct osd_attr g_attr_inode_file_layout = ATTR_DEF(
|
|
|
|
EXOFS_APAGE_FS_DATA,
|
|
|
|
EXOFS_ATTR_INODE_FILE_LAYOUT,
|
|
|
|
0);
|
|
|
|
static const struct osd_attr g_attr_inode_dir_layout = ATTR_DEF(
|
|
|
|
EXOFS_APAGE_FS_DATA,
|
|
|
|
EXOFS_ATTR_INODE_DIR_LAYOUT,
|
|
|
|
0);
|
|
|
|
|
2008-10-28 20:38:12 +07:00
|
|
|
/*
|
exofs: RAID0 support
We now support striping over mirror devices. Including variable sized
stripe_unit.
Some limits:
* stripe_unit must be a multiple of PAGE_SIZE
* stripe_unit * stripe_count is maximum upto 32-bit (4Gb)
Tested RAID0 over mirrors, RAID0 only, mirrors only. All check.
Design notes:
* I'm not using a vectored raid-engine mechanism yet. Following the
pnfs-objects-layout data-map structure, "Mirror" is just a private
case of "group_width" == 1, and RAID0 is a private case of
"Mirrors" == 1. The performance lose of the general case over the
particular special case optimization is totally negligible, also
considering the extra code size.
* In general I added a prepare_stripes() stage that divides the
to-be-io pages to the participating devices, the previous
exofs_ios_write/read, now becomes _write/read_mirrors and a new
write/read upper layer loops on all devices calling
_write/read_mirrors. Effectively the prepare_stripes stage is the all
secret.
Also truncate need fixing to accommodate for striping.
* In a RAID0 arrangement, in a regular usage scenario, if all inode
layouts will start at the same device, the small files fill up the
first device and the later devices stay empty, the farther the device
the emptier it is.
To fix that, each inode will start at a different stripe_unit,
according to it's obj_id modulus number-of-stripe-units. And
will then span all stripe-units in the same incrementing order
wrapping back to the beginning of the device table. We call it
a stripe-units moving window.
Special consideration was taken to keep all devices in a mirror
arrangement identical. So a broken osd-device could just be cloned
from one of the mirrors and no FS scrubbing is needed. (We do that
by rotating stripe-unit at a time and not a single device at a time.)
TODO:
We no longer verify object_length == inode->i_size in exofs_iget.
(since i_size is stripped on multiple objects now).
I should introduce a multiple-device attribute reading, and use
it in exofs_iget.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2010-02-01 18:35:51 +07:00
|
|
|
* Read the Linux inode info from the OSD, and return it as is. In exofs the
|
|
|
|
* inode info is in an application specific page/attribute of the osd-object.
|
2008-10-28 20:38:12 +07:00
|
|
|
*/
|
|
|
|
static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
|
exofs: RAID0 support
We now support striping over mirror devices. Including variable sized
stripe_unit.
Some limits:
* stripe_unit must be a multiple of PAGE_SIZE
* stripe_unit * stripe_count is maximum upto 32-bit (4Gb)
Tested RAID0 over mirrors, RAID0 only, mirrors only. All check.
Design notes:
* I'm not using a vectored raid-engine mechanism yet. Following the
pnfs-objects-layout data-map structure, "Mirror" is just a private
case of "group_width" == 1, and RAID0 is a private case of
"Mirrors" == 1. The performance lose of the general case over the
particular special case optimization is totally negligible, also
considering the extra code size.
* In general I added a prepare_stripes() stage that divides the
to-be-io pages to the participating devices, the previous
exofs_ios_write/read, now becomes _write/read_mirrors and a new
write/read upper layer loops on all devices calling
_write/read_mirrors. Effectively the prepare_stripes stage is the all
secret.
Also truncate need fixing to accommodate for striping.
* In a RAID0 arrangement, in a regular usage scenario, if all inode
layouts will start at the same device, the small files fill up the
first device and the later devices stay empty, the farther the device
the emptier it is.
To fix that, each inode will start at a different stripe_unit,
according to it's obj_id modulus number-of-stripe-units. And
will then span all stripe-units in the same incrementing order
wrapping back to the beginning of the device table. We call it
a stripe-units moving window.
Special consideration was taken to keep all devices in a mirror
arrangement identical. So a broken osd-device could just be cloned
from one of the mirrors and no FS scrubbing is needed. (We do that
by rotating stripe-unit at a time and not a single device at a time.)
TODO:
We no longer verify object_length == inode->i_size in exofs_iget.
(since i_size is stripped on multiple objects now).
I should introduce a multiple-device attribute reading, and use
it in exofs_iget.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2010-02-01 18:35:51 +07:00
|
|
|
struct exofs_fcb *inode)
|
2008-10-28 20:38:12 +07:00
|
|
|
{
|
|
|
|
struct exofs_sb_info *sbi = sb->s_fs_info;
|
2010-01-28 16:58:08 +07:00
|
|
|
struct osd_attr attrs[] = {
|
|
|
|
[0] = g_attr_inode_data,
|
|
|
|
[1] = g_attr_inode_file_layout,
|
|
|
|
[2] = g_attr_inode_dir_layout,
|
|
|
|
};
|
2011-08-07 09:26:31 +07:00
|
|
|
struct ore_io_state *ios;
|
2010-01-28 16:58:08 +07:00
|
|
|
struct exofs_on_disk_inode_layout *layout;
|
2008-10-28 20:38:12 +07:00
|
|
|
int ret;
|
|
|
|
|
2011-09-28 15:39:59 +07:00
|
|
|
ret = ore_get_io_state(&sbi->layout, &oi->oc, &ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
if (unlikely(ret)) {
|
2011-08-07 09:26:31 +07:00
|
|
|
EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
return ret;
|
2008-10-28 20:38:12 +07:00
|
|
|
}
|
|
|
|
|
2011-09-28 15:39:59 +07:00
|
|
|
attrs[1].len = exofs_on_disk_inode_layout_size(sbi->oc.numdevs);
|
|
|
|
attrs[2].len = exofs_on_disk_inode_layout_size(sbi->oc.numdevs);
|
2010-01-28 16:58:08 +07:00
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->in_attr = attrs;
|
|
|
|
ios->in_attr_len = ARRAY_SIZE(attrs);
|
2008-10-28 20:38:12 +07:00
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ret = ore_read(ios);
|
2010-02-09 16:43:21 +07:00
|
|
|
if (unlikely(ret)) {
|
|
|
|
EXOFS_ERR("object(0x%llx) corrupted, return empty file=>%d\n",
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
_LLU(oi->one_comp.obj.id), ret);
|
2010-02-09 16:43:21 +07:00
|
|
|
memset(inode, 0, sizeof(*inode));
|
|
|
|
inode->i_mode = 0040000 | (0777 & ~022);
|
|
|
|
/* If object is lost on target we might as well enable it's
|
|
|
|
* delete.
|
|
|
|
*/
|
2014-01-14 21:05:52 +07:00
|
|
|
ret = 0;
|
2008-10-28 20:38:12 +07:00
|
|
|
goto out;
|
2010-02-09 16:43:21 +07:00
|
|
|
}
|
2008-10-28 20:38:12 +07:00
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ret = extract_attr_from_ios(ios, &attrs[0]);
|
2008-10-28 20:38:12 +07:00
|
|
|
if (ret) {
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_ERR("%s: extract_attr 0 of inode failed\n", __func__);
|
2008-10-28 20:38:12 +07:00
|
|
|
goto out;
|
|
|
|
}
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
WARN_ON(attrs[0].len != EXOFS_INO_ATTR_SIZE);
|
|
|
|
memcpy(inode, attrs[0].val_ptr, EXOFS_INO_ATTR_SIZE);
|
2008-10-28 20:38:12 +07:00
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ret = extract_attr_from_ios(ios, &attrs[1]);
|
2010-01-28 16:58:08 +07:00
|
|
|
if (ret) {
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_ERR("%s: extract_attr 1 of inode failed\n", __func__);
|
2010-01-28 16:58:08 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (attrs[1].len) {
|
|
|
|
layout = attrs[1].val_ptr;
|
|
|
|
if (layout->gen_func != cpu_to_le16(LAYOUT_MOVING_WINDOW)) {
|
|
|
|
EXOFS_ERR("%s: unsupported files layout %d\n",
|
|
|
|
__func__, layout->gen_func);
|
|
|
|
ret = -ENOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = extract_attr_from_ios(ios, &attrs[2]);
|
|
|
|
if (ret) {
|
2014-01-14 21:26:13 +07:00
|
|
|
EXOFS_ERR("%s: extract_attr 2 of inode failed\n", __func__);
|
2010-01-28 16:58:08 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (attrs[2].len) {
|
|
|
|
layout = attrs[2].val_ptr;
|
|
|
|
if (layout->gen_func != cpu_to_le16(LAYOUT_MOVING_WINDOW)) {
|
|
|
|
EXOFS_ERR("%s: unsupported meta-data layout %d\n",
|
|
|
|
__func__, layout->gen_func);
|
|
|
|
ret = -ENOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-28 20:38:12 +07:00
|
|
|
out:
|
2011-08-07 09:26:31 +07:00
|
|
|
ore_put_io_state(ios);
|
2008-10-28 20:38:12 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-05 00:40:29 +07:00
|
|
|
static void __oi_init(struct exofs_i_info *oi)
|
|
|
|
{
|
|
|
|
init_waitqueue_head(&oi->i_wq);
|
|
|
|
oi->i_flags = 0;
|
|
|
|
}
|
2008-10-28 20:38:12 +07:00
|
|
|
/*
|
|
|
|
* Fill in an inode read from the OSD and set it up for use
|
|
|
|
*/
|
|
|
|
struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
|
|
|
|
{
|
|
|
|
struct exofs_i_info *oi;
|
|
|
|
struct exofs_fcb fcb;
|
|
|
|
struct inode *inode;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
inode = iget_locked(sb, ino);
|
|
|
|
if (!inode)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
if (!(inode->i_state & I_NEW))
|
|
|
|
return inode;
|
|
|
|
oi = exofs_i(inode);
|
2009-08-05 00:40:29 +07:00
|
|
|
__oi_init(oi);
|
2011-09-28 15:39:59 +07:00
|
|
|
exofs_init_comps(&oi->oc, &oi->one_comp, sb->s_fs_info,
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
exofs_oi_objno(oi));
|
2008-10-28 20:38:12 +07:00
|
|
|
|
|
|
|
/* read the inode from the osd */
|
exofs: RAID0 support
We now support striping over mirror devices. Including variable sized
stripe_unit.
Some limits:
* stripe_unit must be a multiple of PAGE_SIZE
* stripe_unit * stripe_count is maximum upto 32-bit (4Gb)
Tested RAID0 over mirrors, RAID0 only, mirrors only. All check.
Design notes:
* I'm not using a vectored raid-engine mechanism yet. Following the
pnfs-objects-layout data-map structure, "Mirror" is just a private
case of "group_width" == 1, and RAID0 is a private case of
"Mirrors" == 1. The performance lose of the general case over the
particular special case optimization is totally negligible, also
considering the extra code size.
* In general I added a prepare_stripes() stage that divides the
to-be-io pages to the participating devices, the previous
exofs_ios_write/read, now becomes _write/read_mirrors and a new
write/read upper layer loops on all devices calling
_write/read_mirrors. Effectively the prepare_stripes stage is the all
secret.
Also truncate need fixing to accommodate for striping.
* In a RAID0 arrangement, in a regular usage scenario, if all inode
layouts will start at the same device, the small files fill up the
first device and the later devices stay empty, the farther the device
the emptier it is.
To fix that, each inode will start at a different stripe_unit,
according to it's obj_id modulus number-of-stripe-units. And
will then span all stripe-units in the same incrementing order
wrapping back to the beginning of the device table. We call it
a stripe-units moving window.
Special consideration was taken to keep all devices in a mirror
arrangement identical. So a broken osd-device could just be cloned
from one of the mirrors and no FS scrubbing is needed. (We do that
by rotating stripe-unit at a time and not a single device at a time.)
TODO:
We no longer verify object_length == inode->i_size in exofs_iget.
(since i_size is stripped on multiple objects now).
I should introduce a multiple-device attribute reading, and use
it in exofs_iget.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2010-02-01 18:35:51 +07:00
|
|
|
ret = exofs_get_inode(sb, oi, &fcb);
|
2008-10-28 20:38:12 +07:00
|
|
|
if (ret)
|
|
|
|
goto bad_inode;
|
|
|
|
|
|
|
|
set_obj_created(oi);
|
|
|
|
|
|
|
|
/* copy stuff from on-disk struct to in-memory struct */
|
|
|
|
inode->i_mode = le16_to_cpu(fcb.i_mode);
|
2012-02-11 02:11:19 +07:00
|
|
|
i_uid_write(inode, le32_to_cpu(fcb.i_uid));
|
|
|
|
i_gid_write(inode, le32_to_cpu(fcb.i_gid));
|
2011-10-28 19:13:29 +07:00
|
|
|
set_nlink(inode, le16_to_cpu(fcb.i_links_count));
|
2008-10-28 20:38:12 +07:00
|
|
|
inode->i_ctime.tv_sec = (signed)le32_to_cpu(fcb.i_ctime);
|
|
|
|
inode->i_atime.tv_sec = (signed)le32_to_cpu(fcb.i_atime);
|
|
|
|
inode->i_mtime.tv_sec = (signed)le32_to_cpu(fcb.i_mtime);
|
|
|
|
inode->i_ctime.tv_nsec =
|
|
|
|
inode->i_atime.tv_nsec = inode->i_mtime.tv_nsec = 0;
|
|
|
|
oi->i_commit_size = le64_to_cpu(fcb.i_size);
|
|
|
|
i_size_write(inode, oi->i_commit_size);
|
|
|
|
inode->i_blkbits = EXOFS_BLKSHIFT;
|
|
|
|
inode->i_generation = le32_to_cpu(fcb.i_generation);
|
|
|
|
|
|
|
|
oi->i_dir_start_lookup = 0;
|
|
|
|
|
|
|
|
if ((inode->i_nlink == 0) && (inode->i_mode == 0)) {
|
|
|
|
ret = -ESTALE;
|
|
|
|
goto bad_inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
|
|
|
|
if (fcb.i_data[0])
|
|
|
|
inode->i_rdev =
|
|
|
|
old_decode_dev(le32_to_cpu(fcb.i_data[0]));
|
|
|
|
else
|
|
|
|
inode->i_rdev =
|
|
|
|
new_decode_dev(le32_to_cpu(fcb.i_data[1]));
|
|
|
|
} else {
|
|
|
|
memcpy(oi->i_data, fcb.i_data, sizeof(fcb.i_data));
|
|
|
|
}
|
|
|
|
|
2010-10-08 01:28:18 +07:00
|
|
|
inode->i_mapping->backing_dev_info = sb->s_bdi;
|
2008-10-28 20:38:12 +07:00
|
|
|
if (S_ISREG(inode->i_mode)) {
|
|
|
|
inode->i_op = &exofs_file_inode_operations;
|
|
|
|
inode->i_fop = &exofs_file_operations;
|
|
|
|
inode->i_mapping->a_ops = &exofs_aops;
|
|
|
|
} else if (S_ISDIR(inode->i_mode)) {
|
|
|
|
inode->i_op = &exofs_dir_inode_operations;
|
|
|
|
inode->i_fop = &exofs_dir_operations;
|
|
|
|
inode->i_mapping->a_ops = &exofs_aops;
|
|
|
|
} else if (S_ISLNK(inode->i_mode)) {
|
|
|
|
if (exofs_inode_is_fast_symlink(inode))
|
|
|
|
inode->i_op = &exofs_fast_symlink_inode_operations;
|
|
|
|
else {
|
|
|
|
inode->i_op = &exofs_symlink_inode_operations;
|
|
|
|
inode->i_mapping->a_ops = &exofs_aops;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
inode->i_op = &exofs_special_inode_operations;
|
|
|
|
if (fcb.i_data[0])
|
|
|
|
init_special_inode(inode, inode->i_mode,
|
|
|
|
old_decode_dev(le32_to_cpu(fcb.i_data[0])));
|
|
|
|
else
|
|
|
|
init_special_inode(inode, inode->i_mode,
|
|
|
|
new_decode_dev(le32_to_cpu(fcb.i_data[1])));
|
|
|
|
}
|
|
|
|
|
|
|
|
unlock_new_inode(inode);
|
|
|
|
return inode;
|
|
|
|
|
|
|
|
bad_inode:
|
|
|
|
iget_failed(inode);
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
int __exofs_wait_obj_created(struct exofs_i_info *oi)
|
|
|
|
{
|
|
|
|
if (!obj_created(oi)) {
|
2010-10-16 15:14:01 +07:00
|
|
|
EXOFS_DBGMSG("!obj_created\n");
|
2008-10-28 20:38:12 +07:00
|
|
|
BUG_ON(!obj_2bcreated(oi));
|
|
|
|
wait_event(oi->i_wq, obj_created(oi));
|
2010-10-16 15:14:01 +07:00
|
|
|
EXOFS_DBGMSG("wait_event done\n");
|
2008-10-28 20:38:12 +07:00
|
|
|
}
|
|
|
|
return unlikely(is_bad_inode(&oi->vfs_inode)) ? -EIO : 0;
|
|
|
|
}
|
2011-02-03 22:53:25 +07:00
|
|
|
|
2008-10-28 20:38:12 +07:00
|
|
|
/*
|
|
|
|
* Callback function from exofs_new_inode(). The important thing is that we
|
|
|
|
* set the obj_created flag so that other methods know that the object exists on
|
|
|
|
* the OSD.
|
|
|
|
*/
|
2011-08-07 09:26:31 +07:00
|
|
|
static void create_done(struct ore_io_state *ios, void *p)
|
2008-10-28 20:38:12 +07:00
|
|
|
{
|
|
|
|
struct inode *inode = p;
|
|
|
|
struct exofs_i_info *oi = exofs_i(inode);
|
|
|
|
struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
|
|
|
|
int ret;
|
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ret = ore_check_io(ios, NULL);
|
|
|
|
ore_put_io_state(ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
|
2008-10-28 20:38:12 +07:00
|
|
|
atomic_dec(&sbi->s_curr_pending);
|
|
|
|
|
|
|
|
if (unlikely(ret)) {
|
2010-10-22 12:17:17 +07:00
|
|
|
EXOFS_ERR("object=0x%llx creation failed in pid=0x%llx",
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
_LLU(exofs_oi_objno(oi)),
|
|
|
|
_LLU(oi->one_comp.obj.partition));
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
/*TODO: When FS is corrupted creation can fail, object already
|
|
|
|
* exist. Get rid of this asynchronous creation, if exist
|
|
|
|
* increment the obj counter and try the next object. Until we
|
|
|
|
* succeed. All these dangling objects will be made into lost
|
|
|
|
* files by chkfs.exofs
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
set_obj_created(oi);
|
2008-10-28 20:38:12 +07:00
|
|
|
|
|
|
|
wake_up(&oi->i_wq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up a new inode and create an object for it on the OSD
|
|
|
|
*/
|
2011-07-26 14:07:49 +07:00
|
|
|
struct inode *exofs_new_inode(struct inode *dir, umode_t mode)
|
2008-10-28 20:38:12 +07:00
|
|
|
{
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
struct super_block *sb = dir->i_sb;
|
|
|
|
struct exofs_sb_info *sbi = sb->s_fs_info;
|
2008-10-28 20:38:12 +07:00
|
|
|
struct inode *inode;
|
|
|
|
struct exofs_i_info *oi;
|
2011-08-07 09:26:31 +07:00
|
|
|
struct ore_io_state *ios;
|
2008-10-28 20:38:12 +07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
inode = new_inode(sb);
|
|
|
|
if (!inode)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
oi = exofs_i(inode);
|
2009-08-05 00:40:29 +07:00
|
|
|
__oi_init(oi);
|
2008-10-28 20:38:12 +07:00
|
|
|
|
|
|
|
set_obj_2bcreated(oi);
|
|
|
|
|
2010-10-08 01:28:18 +07:00
|
|
|
inode->i_mapping->backing_dev_info = sb->s_bdi;
|
2010-03-04 21:31:48 +07:00
|
|
|
inode_init_owner(inode, dir, mode);
|
2008-10-28 20:38:12 +07:00
|
|
|
inode->i_ino = sbi->s_nextid++;
|
|
|
|
inode->i_blkbits = EXOFS_BLKSHIFT;
|
|
|
|
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
|
|
|
|
oi->i_commit_size = inode->i_size = 0;
|
|
|
|
spin_lock(&sbi->s_next_gen_lock);
|
|
|
|
inode->i_generation = sbi->s_next_generation++;
|
|
|
|
spin_unlock(&sbi->s_next_gen_lock);
|
|
|
|
insert_inode_hash(inode);
|
|
|
|
|
2011-09-28 15:39:59 +07:00
|
|
|
exofs_init_comps(&oi->oc, &oi->one_comp, sb->s_fs_info,
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
exofs_oi_objno(oi));
|
2011-02-03 22:53:25 +07:00
|
|
|
exofs_sbi_write_stats(sbi); /* Make sure new sbi->s_nextid is on disk */
|
|
|
|
|
2008-10-28 20:38:12 +07:00
|
|
|
mark_inode_dirty(inode);
|
|
|
|
|
2011-09-28 15:39:59 +07:00
|
|
|
ret = ore_get_io_state(&sbi->layout, &oi->oc, &ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
if (unlikely(ret)) {
|
2011-08-07 09:26:31 +07:00
|
|
|
EXOFS_ERR("exofs_new_inode: ore_get_io_state failed\n");
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
return ERR_PTR(ret);
|
2008-10-28 20:38:12 +07:00
|
|
|
}
|
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->done = create_done;
|
|
|
|
ios->private = inode;
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ret = ore_create(ios);
|
2008-10-28 20:38:12 +07:00
|
|
|
if (ret) {
|
2011-08-07 09:26:31 +07:00
|
|
|
ore_put_io_state(ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
return ERR_PTR(ret);
|
2008-10-28 20:38:12 +07:00
|
|
|
}
|
|
|
|
atomic_inc(&sbi->s_curr_pending);
|
|
|
|
|
|
|
|
return inode;
|
|
|
|
}
|
2008-10-28 21:11:41 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* struct to pass two arguments to update_inode's callback
|
|
|
|
*/
|
|
|
|
struct updatei_args {
|
|
|
|
struct exofs_sb_info *sbi;
|
|
|
|
struct exofs_fcb fcb;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback function from exofs_update_inode().
|
|
|
|
*/
|
2011-08-07 09:26:31 +07:00
|
|
|
static void updatei_done(struct ore_io_state *ios, void *p)
|
2008-10-28 21:11:41 +07:00
|
|
|
{
|
|
|
|
struct updatei_args *args = p;
|
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ore_put_io_state(ios);
|
2008-10-28 21:11:41 +07:00
|
|
|
|
|
|
|
atomic_dec(&args->sbi->s_curr_pending);
|
|
|
|
|
|
|
|
kfree(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write the inode to the OSD. Just fill up the struct, and set the attribute
|
|
|
|
* synchronously or asynchronously depending on the do_sync flag.
|
|
|
|
*/
|
|
|
|
static int exofs_update_inode(struct inode *inode, int do_sync)
|
|
|
|
{
|
|
|
|
struct exofs_i_info *oi = exofs_i(inode);
|
|
|
|
struct super_block *sb = inode->i_sb;
|
|
|
|
struct exofs_sb_info *sbi = sb->s_fs_info;
|
2011-08-07 09:26:31 +07:00
|
|
|
struct ore_io_state *ios;
|
2008-10-28 21:11:41 +07:00
|
|
|
struct osd_attr attr;
|
|
|
|
struct exofs_fcb *fcb;
|
|
|
|
struct updatei_args *args;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
args = kzalloc(sizeof(*args), GFP_KERNEL);
|
2009-12-16 00:34:17 +07:00
|
|
|
if (!args) {
|
2010-10-22 12:17:17 +07:00
|
|
|
EXOFS_DBGMSG("Failed kzalloc of args\n");
|
2008-10-28 21:11:41 +07:00
|
|
|
return -ENOMEM;
|
2009-12-16 00:34:17 +07:00
|
|
|
}
|
2008-10-28 21:11:41 +07:00
|
|
|
|
|
|
|
fcb = &args->fcb;
|
|
|
|
|
|
|
|
fcb->i_mode = cpu_to_le16(inode->i_mode);
|
2012-02-11 02:11:19 +07:00
|
|
|
fcb->i_uid = cpu_to_le32(i_uid_read(inode));
|
|
|
|
fcb->i_gid = cpu_to_le32(i_gid_read(inode));
|
2008-10-28 21:11:41 +07:00
|
|
|
fcb->i_links_count = cpu_to_le16(inode->i_nlink);
|
|
|
|
fcb->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
|
|
|
|
fcb->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
|
|
|
|
fcb->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
|
|
|
|
oi->i_commit_size = i_size_read(inode);
|
|
|
|
fcb->i_size = cpu_to_le64(oi->i_commit_size);
|
|
|
|
fcb->i_generation = cpu_to_le32(inode->i_generation);
|
|
|
|
|
|
|
|
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
|
|
|
|
if (old_valid_dev(inode->i_rdev)) {
|
|
|
|
fcb->i_data[0] =
|
|
|
|
cpu_to_le32(old_encode_dev(inode->i_rdev));
|
|
|
|
fcb->i_data[1] = 0;
|
|
|
|
} else {
|
|
|
|
fcb->i_data[0] = 0;
|
|
|
|
fcb->i_data[1] =
|
|
|
|
cpu_to_le32(new_encode_dev(inode->i_rdev));
|
|
|
|
fcb->i_data[2] = 0;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
memcpy(fcb->i_data, oi->i_data, sizeof(fcb->i_data));
|
|
|
|
|
2011-09-28 15:39:59 +07:00
|
|
|
ret = ore_get_io_state(&sbi->layout, &oi->oc, &ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
if (unlikely(ret)) {
|
2011-08-07 09:26:31 +07:00
|
|
|
EXOFS_ERR("%s: ore_get_io_state failed.\n", __func__);
|
2008-10-28 21:11:41 +07:00
|
|
|
goto free_args;
|
|
|
|
}
|
|
|
|
|
|
|
|
attr = g_attr_inode_data;
|
|
|
|
attr.val_ptr = fcb;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->out_attr_len = 1;
|
|
|
|
ios->out_attr = &attr;
|
2008-10-28 21:11:41 +07:00
|
|
|
|
2010-10-16 15:14:01 +07:00
|
|
|
wait_obj_created(oi);
|
2008-10-28 21:11:41 +07:00
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
if (!do_sync) {
|
2008-10-28 21:11:41 +07:00
|
|
|
args->sbi = sbi;
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->done = updatei_done;
|
|
|
|
ios->private = args;
|
|
|
|
}
|
2008-10-28 21:11:41 +07:00
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ret = ore_write(ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
if (!do_sync && !ret) {
|
2008-10-28 21:11:41 +07:00
|
|
|
atomic_inc(&sbi->s_curr_pending);
|
|
|
|
goto out; /* deallocation in updatei_done */
|
|
|
|
}
|
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ore_put_io_state(ios);
|
2008-10-28 21:11:41 +07:00
|
|
|
free_args:
|
|
|
|
kfree(args);
|
|
|
|
out:
|
2009-12-16 00:34:17 +07:00
|
|
|
EXOFS_DBGMSG("(0x%lx) do_sync=%d ret=>%d\n",
|
|
|
|
inode->i_ino, do_sync, ret);
|
2008-10-28 21:11:41 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-03-05 15:21:37 +07:00
|
|
|
int exofs_write_inode(struct inode *inode, struct writeback_control *wbc)
|
2008-10-28 21:11:41 +07:00
|
|
|
{
|
2010-11-25 17:47:15 +07:00
|
|
|
/* FIXME: fix fsync and use wbc->sync_mode == WB_SYNC_ALL */
|
|
|
|
return exofs_update_inode(inode, 1);
|
2008-10-28 21:11:41 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback function from exofs_delete_inode() - don't have much cleaning up to
|
|
|
|
* do.
|
|
|
|
*/
|
2011-08-07 09:26:31 +07:00
|
|
|
static void delete_done(struct ore_io_state *ios, void *p)
|
2008-10-28 21:11:41 +07:00
|
|
|
{
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
struct exofs_sb_info *sbi = p;
|
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ore_put_io_state(ios);
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
|
2008-10-28 21:11:41 +07:00
|
|
|
atomic_dec(&sbi->s_curr_pending);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called when the refcount of an inode reaches zero. We remove the object
|
|
|
|
* from the OSD here. We make sure the object was created before we try and
|
|
|
|
* delete it.
|
|
|
|
*/
|
2010-06-07 22:42:26 +07:00
|
|
|
void exofs_evict_inode(struct inode *inode)
|
2008-10-28 21:11:41 +07:00
|
|
|
{
|
|
|
|
struct exofs_i_info *oi = exofs_i(inode);
|
|
|
|
struct super_block *sb = inode->i_sb;
|
|
|
|
struct exofs_sb_info *sbi = sb->s_fs_info;
|
2011-08-07 09:26:31 +07:00
|
|
|
struct ore_io_state *ios;
|
2008-10-28 21:11:41 +07:00
|
|
|
int ret;
|
|
|
|
|
2014-04-04 04:47:49 +07:00
|
|
|
truncate_inode_pages_final(&inode->i_data);
|
2008-10-28 21:11:41 +07:00
|
|
|
|
2010-06-09 22:23:18 +07:00
|
|
|
/* TODO: should do better here */
|
2010-06-07 22:42:26 +07:00
|
|
|
if (inode->i_nlink || is_bad_inode(inode))
|
2008-10-28 21:11:41 +07:00
|
|
|
goto no_delete;
|
|
|
|
|
|
|
|
inode->i_size = 0;
|
2012-05-03 19:48:02 +07:00
|
|
|
clear_inode(inode);
|
2008-10-28 21:11:41 +07:00
|
|
|
|
2010-10-16 15:14:01 +07:00
|
|
|
/* if we are deleting an obj that hasn't been created yet, wait.
|
|
|
|
* This also makes sure that create_done cannot be called with an
|
|
|
|
* already evicted inode.
|
|
|
|
*/
|
|
|
|
wait_obj_created(oi);
|
|
|
|
/* ignore the error, attempt a remove anyway */
|
2010-06-09 22:23:18 +07:00
|
|
|
|
|
|
|
/* Now Remove the OSD objects */
|
2011-09-28 15:39:59 +07:00
|
|
|
ret = ore_get_io_state(&sbi->layout, &oi->oc, &ios);
|
2010-06-09 22:23:18 +07:00
|
|
|
if (unlikely(ret)) {
|
2011-08-07 09:26:31 +07:00
|
|
|
EXOFS_ERR("%s: ore_get_io_state failed\n", __func__);
|
2010-06-09 22:23:18 +07:00
|
|
|
return;
|
2008-10-28 21:11:41 +07:00
|
|
|
}
|
|
|
|
|
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2009-11-08 19:54:08 +07:00
|
|
|
ios->done = delete_done;
|
|
|
|
ios->private = sbi;
|
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info,
single pid, and a single device-table, global to the filesystem. Then passing
a credential and object_id info at the io_state level, private for each
inode. It would also devise this contraption of rotating the device table
view for each inode->ino to spread out the device usage.
This is not compatible with the pnfs-objects standard, demanding that
each inode can have it's own layout-info, device-table, and each object
component it's own pid, oid and creds.
So: Bring exofs raid engine to be usable for generic pnfs-objects use by:
* Define an exofs_comp structure that holds obj_id and credential info.
* Break up exofs_layout struct to an exofs_components structure that holds a
possible array of exofs_comp and the array of devices + the size of the
arrays.
* Add a "comps" parameter to get_io_state() that specifies the ids creds
and device array to use for each IO.
This enables to keep the layout global, but the device-table view, creds
and IDs at the inode level. It only adds two 64bit to each inode, since
some of these members already existed in another form.
* ios raid engine now access layout-info and comps-info through the passed
pointers. Everything is pre-prepared by caller for generic access of
these structures and arrays.
At the exofs Level:
* Super block holds an exofs_components struct that holds the device
array, previously in layout. The devices there are in device-table
order. The device-array is twice bigger and repeats the device-table
twice so now each inode's device array can point to a random device
and have a round-robin view of the table, making it compatible to
previous exofs versions.
* Each inode has an exofs_components struct that is initialized at
load time, with it's own view of the device table IDs and creds.
When doing IO this gets passed to the io_state together with the
layout.
While preforming this change. Bugs where found where credentials with the
wrong IDs where used to access the different SB objects (super.c). As well
as some dead code. It was never noticed because the target we use does not
check the credentials.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
2011-08-06 05:06:04 +07:00
|
|
|
|
2011-08-07 09:26:31 +07:00
|
|
|
ret = ore_remove(ios);
|
2008-10-28 21:11:41 +07:00
|
|
|
if (ret) {
|
2011-08-07 09:26:31 +07:00
|
|
|
EXOFS_ERR("%s: ore_remove failed\n", __func__);
|
|
|
|
ore_put_io_state(ios);
|
2008-10-28 21:11:41 +07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
atomic_inc(&sbi->s_curr_pending);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
no_delete:
|
2012-05-03 19:48:02 +07:00
|
|
|
clear_inode(inode);
|
2008-10-28 21:11:41 +07:00
|
|
|
}
|