From 85dc7878c6c2277de2eda2c4d1b11ea5c5b1068a Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Mon, 31 May 2010 18:55:43 +0300 Subject: exofs: Remove superfluous dependency on buffer_head and writeback exofs_releasepage && exofs_invalidatepage are never called. Leave the WARN_ONs but remove any code. Remove the cleanup other stale #includes. Signed-off-by: Boaz Harrosh --- fs/exofs/inode.c | 9 ++------- fs/exofs/super.c | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'fs') diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 4bb6ef822e46..fbf9f34554e0 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c @@ -32,9 +32,6 @@ */ #include -#include -#include -#include #include "exofs.h" @@ -759,15 +756,13 @@ static int exofs_releasepage(struct page *page, gfp_t gfp) { EXOFS_DBGMSG("page 0x%lx\n", page->index); WARN_ON(1); - return try_to_free_buffers(page); + return 0; } static void exofs_invalidatepage(struct page *page, unsigned long offset) { - EXOFS_DBGMSG("page_has_buffers=>%d\n", page_has_buffers(page)); + EXOFS_DBGMSG("page 0x%lx offset 0x%lx\n", page->index, offset); WARN_ON(1); - - block_invalidatepage(page, offset); } const struct address_space_operations exofs_aops = { diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 03149b9a5178..50cb1745e29c 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c @@ -31,7 +31,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include -- cgit v1.2.3 From b2848349296f3428850eb34c3a52d586f48d4b04 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Mon, 31 May 2010 18:02:39 +0300 Subject: exofs: exofs_file_fsync and exofs_file_flush correctness As per Christoph advise: no need to call filemap_write_and_wait(). In exofs all metadata is at the inode so just writing the inode is all is needed. ->fsync implies this must be done synchronously. But now exofs_file_fsync can not be used by exofs_file_flush. vfs_fsync() should do that job correctly. FIXME: remove the sb_sync and fix that sb_update better. Signed-off-by: Boaz Harrosh --- fs/exofs/file.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'fs') diff --git a/fs/exofs/file.c b/fs/exofs/file.c index fef6899be397..aa1fd1a372cf 100644 --- a/fs/exofs/file.c +++ b/fs/exofs/file.c @@ -30,9 +30,6 @@ * along with exofs; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include - #include "exofs.h" static int exofs_release_file(struct inode *inode, struct file *filp) @@ -40,19 +37,27 @@ static int exofs_release_file(struct inode *inode, struct file *filp) return 0; } +/* exofs_file_fsync - flush the inode to disk + * + * Note, in exofs all metadata is written as part of inode, regardless. + * The writeout is synchronous + */ static int exofs_file_fsync(struct file *filp, int datasync) { int ret; - struct address_space *mapping = filp->f_mapping; - struct inode *inode = mapping->host; + struct inode *inode = filp->f_mapping->host; + struct writeback_control wbc = { + .sync_mode = WB_SYNC_ALL, + .nr_to_write = 0, /* metadata-only; caller takes care of data */ + }; struct super_block *sb; - ret = filemap_write_and_wait(mapping); - if (ret) - return ret; + if (!(inode->i_state & I_DIRTY)) + return 0; + if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) + return 0; - /* sync the inode attributes */ - ret = write_inode_now(inode, 1); + ret = sync_inode(inode, &wbc); /* This is a good place to write the sb */ /* TODO: Sechedule an sb-sync on create */ @@ -65,9 +70,9 @@ static int exofs_file_fsync(struct file *filp, int datasync) static int exofs_flush(struct file *file, fl_owner_t id) { - exofs_file_fsync(file, 1); + int ret = vfs_fsync(file, 0); /* TODO: Flush the OSD target */ - return 0; + return ret; } const struct file_operations exofs_file_operations = { -- cgit v1.2.3 From 6e31609b1dcd595d7e4676ce62323532b29e8999 Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Thu, 29 Jul 2010 17:08:13 +0300 Subject: exofs: Remove useless optimization We used to compact all used devices in an IO to the beginning of the device array in an io_state. And keep a last device used so in later loops we don't iterate on all device slots. This does not prevent us from checking if slots are empty since in reads we only read from a single mirror and jump to the next mirror-set. This optimization is marginal, and needlessly complicates the code. Specially when we will later want to support raid/456 with same abstract code. So remove the distinction between "dev" and "comp". Only "dev" is used both as the device used and as the index (component) in the device array. [Note that now the io_state->dev member is redundant but I keep it because I might want to optimize by only IOing a single group, though keeping a group_width*mirrors devices in io_state, we now keep num-devices in each io_state] Signed-off-by: Boaz Harrosh --- fs/exofs/ios.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'fs') diff --git a/fs/exofs/ios.c b/fs/exofs/ios.c index 4337cad7777b..5bb47373c7e0 100644 --- a/fs/exofs/ios.c +++ b/fs/exofs/ios.c @@ -392,20 +392,19 @@ static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, } static int _prepare_one_group(struct exofs_io_state *ios, u64 length, - struct _striping_info *si, unsigned first_comp) + struct _striping_info *si) { unsigned stripe_unit = ios->layout->stripe_unit; unsigned mirrors_p1 = ios->layout->mirrors_p1; unsigned devs_in_group = ios->layout->group_width * mirrors_p1; unsigned dev = si->dev; unsigned first_dev = dev - (dev % devs_in_group); - unsigned comp = first_comp + (dev - first_dev); unsigned max_comp = ios->numdevs ? ios->numdevs - mirrors_p1 : 0; unsigned cur_pg = ios->pages_consumed; int ret = 0; while (length) { - struct exofs_per_dev_state *per_dev = &ios->per_dev[comp]; + struct exofs_per_dev_state *per_dev = &ios->per_dev[dev]; unsigned cur_len, page_off = 0; if (!per_dev->length) { @@ -424,11 +423,8 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length, cur_len = stripe_unit; } - if (max_comp < comp) - max_comp = comp; - - dev += mirrors_p1; - dev = (dev % devs_in_group) + first_dev; + if (max_comp < dev) + max_comp = dev; } else { cur_len = stripe_unit; } @@ -440,8 +436,8 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length, if (unlikely(ret)) goto out; - comp += mirrors_p1; - comp = (comp % devs_in_group) + first_comp; + dev += mirrors_p1; + dev = (dev % devs_in_group) + first_dev; length -= cur_len; } @@ -457,7 +453,6 @@ static int _prepare_for_striping(struct exofs_io_state *ios) struct _striping_info si; unsigned devs_in_group = ios->layout->group_width * ios->layout->mirrors_p1; - unsigned first_comp = 0; int ret = 0; _calc_stripe_info(ios, ios->offset, &si); @@ -482,7 +477,7 @@ static int _prepare_for_striping(struct exofs_io_state *ios) if (length < si.group_length) si.group_length = length; - ret = _prepare_one_group(ios, si.group_length, &si, first_comp); + ret = _prepare_one_group(ios, si.group_length, &si); if (unlikely(ret)) goto out; @@ -496,9 +491,6 @@ static int _prepare_for_striping(struct exofs_io_state *ios) si.dev = (si.dev - (si.dev % devs_in_group)) + devs_in_group; si.dev %= ios->layout->s_numdevs; - - first_comp += devs_in_group; - first_comp %= ios->layout->s_numdevs; } out: -- cgit v1.2.3 From 5002dd18c5940ce63b917d84f2b852c3b96009bb Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Mon, 2 Aug 2010 20:06:46 +0300 Subject: exofs: Fix groups code when num_devices is not divisible by group_width There is a bug when num_devices is not divisible by group_width * mirrors. We would not return to the proper device and offset when looping on to the next group. The fix makes code simpler actually. Signed-off-by: Boaz Harrosh --- fs/exofs/ios.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'fs') diff --git a/fs/exofs/ios.c b/fs/exofs/ios.c index 5bb47373c7e0..5a1960500c8a 100644 --- a/fs/exofs/ios.c +++ b/fs/exofs/ios.c @@ -305,8 +305,6 @@ int exofs_check_io(struct exofs_io_state *ios, u64 *resid) struct _striping_info { u64 obj_offset; u64 group_length; - u64 total_group_length; - u64 Major; unsigned dev; unsigned unit_off; }; @@ -343,8 +341,6 @@ static void _calc_stripe_info(struct exofs_io_state *ios, u64 file_offset, (M * group_depth * stripe_unit); si->group_length = T - H; - si->total_group_length = T; - si->Major = M; } static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg, @@ -450,17 +446,15 @@ out: static int _prepare_for_striping(struct exofs_io_state *ios) { u64 length = ios->length; + u64 offset = ios->offset; struct _striping_info si; - unsigned devs_in_group = ios->layout->group_width * - ios->layout->mirrors_p1; int ret = 0; - _calc_stripe_info(ios, ios->offset, &si); - if (!ios->pages) { if (ios->kern_buff) { struct exofs_per_dev_state *per_dev = &ios->per_dev[0]; + _calc_stripe_info(ios, ios->offset, &si); per_dev->offset = si.obj_offset; per_dev->dev = si.dev; @@ -474,6 +468,8 @@ static int _prepare_for_striping(struct exofs_io_state *ios) } while (length) { + _calc_stripe_info(ios, offset, &si); + if (length < si.group_length) si.group_length = length; @@ -481,16 +477,8 @@ static int _prepare_for_striping(struct exofs_io_state *ios) if (unlikely(ret)) goto out; + offset += si.group_length; length -= si.group_length; - - si.group_length = si.total_group_length; - si.unit_off = 0; - ++si.Major; - si.obj_offset = si.Major * ios->layout->stripe_unit * - ios->layout->group_depth; - - si.dev = (si.dev - (si.dev % devs_in_group)) + devs_in_group; - si.dev %= ios->layout->s_numdevs; } out: -- cgit v1.2.3