diff options
author | Michal Marek <mmarek@suse.cz> | 2010-08-20 11:53:08 (GMT) |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-08-20 11:53:08 (GMT) |
commit | e981b060767b3c4ac9393ad8d2558d648e35dfcb (patch) | |
tree | 9c05eaec3072be3645dda61d35085d152b9d5954 /fs/exofs | |
parent | 3c955b407a084810f57260d61548cc92c14bc627 (diff) | |
parent | da5cabf80e2433131bf0ed8993abc0f7ea618c73 (diff) | |
download | linux-e981b060767b3c4ac9393ad8d2558d648e35dfcb.tar.xz |
Merge commit 'v2.6.36-rc1' into kbuild/rc-fixes
Diffstat (limited to 'fs/exofs')
-rw-r--r-- | fs/exofs/exofs.h | 3 | ||||
-rw-r--r-- | fs/exofs/file.c | 30 | ||||
-rw-r--r-- | fs/exofs/inode.c | 136 | ||||
-rw-r--r-- | fs/exofs/ios.c | 46 | ||||
-rw-r--r-- | fs/exofs/super.c | 3 |
5 files changed, 87 insertions, 131 deletions
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h index 22721b2..2dc925f 100644 --- a/fs/exofs/exofs.h +++ b/fs/exofs/exofs.h @@ -256,7 +256,6 @@ static inline int exofs_oi_read(struct exofs_i_info *oi, } /* inode.c */ -void exofs_truncate(struct inode *inode); int exofs_setattr(struct dentry *, struct iattr *); int exofs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, @@ -264,7 +263,7 @@ int exofs_write_begin(struct file *file, struct address_space *mapping, extern struct inode *exofs_iget(struct super_block *, unsigned long); struct inode *exofs_new_inode(struct inode *, int); extern int exofs_write_inode(struct inode *, struct writeback_control *wbc); -extern void exofs_delete_inode(struct inode *); +extern void exofs_evict_inode(struct inode *); /* dir.c: */ int exofs_add_link(struct dentry *, struct inode *); diff --git a/fs/exofs/file.c b/fs/exofs/file.c index fef6899..68cb23e 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 <linux/buffer_head.h> - #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 = { @@ -86,6 +91,5 @@ const struct file_operations exofs_file_operations = { }; const struct inode_operations exofs_file_inode_operations = { - .truncate = exofs_truncate, .setattr = exofs_setattr, }; diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 4bb6ef8..eb7368e 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c @@ -32,9 +32,6 @@ */ #include <linux/slab.h> -#include <linux/writeback.h> -#include <linux/buffer_head.h> -#include <scsi/scsi_device.h> #include "exofs.h" @@ -697,6 +694,13 @@ static int exofs_writepage(struct page *page, struct writeback_control *wbc) return write_exec(&pcol); } +/* i_mutex held using inode->i_size directly */ +static void _write_failed(struct inode *inode, loff_t to) +{ + if (to > inode->i_size) + truncate_pagecache(inode, to, inode->i_size); +} + int exofs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) @@ -710,7 +714,7 @@ int exofs_write_begin(struct file *file, struct address_space *mapping, fsdata); if (ret) { EXOFS_DBGMSG("simple_write_begin faild\n"); - return ret; + goto out; } page = *pagep; @@ -725,6 +729,9 @@ int exofs_write_begin(struct file *file, struct address_space *mapping, EXOFS_DBGMSG("__readpage_filler faild\n"); } } +out: + if (unlikely(ret)) + _write_failed(mapping->host, pos + len); return ret; } @@ -750,6 +757,10 @@ static int exofs_write_end(struct file *file, struct address_space *mapping, int ret; ret = simple_write_end(file, mapping,pos, len, copied, page, fsdata); + if (unlikely(ret)) + _write_failed(inode, pos + len); + + /* TODO: once simple_write_end marks inode dirty remove */ if (i_size != inode->i_size) mark_inode_dirty(inode); return ret; @@ -759,15 +770,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 = { @@ -808,87 +817,55 @@ static inline int exofs_inode_is_fast_symlink(struct inode *inode) return S_ISLNK(inode->i_mode) && (oi->i_data[0] != 0); } -/* - * get_block_t - Fill in a buffer_head - * An OSD takes care of block allocation so we just fake an allocation by - * putting in the inode's sector_t in the buffer_head. - * TODO: What about the case of create==0 and @iblock does not exist in the - * object? - */ -static int exofs_get_block(struct inode *inode, sector_t iblock, - struct buffer_head *bh_result, int create) -{ - map_bh(bh_result, inode->i_sb, iblock); - return 0; -} - const struct osd_attr g_attr_logical_length = ATTR_DEF( OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8); -static int _do_truncate(struct inode *inode) +static int _do_truncate(struct inode *inode, loff_t newsize) { struct exofs_i_info *oi = exofs_i(inode); - loff_t isize = i_size_read(inode); int ret; inode->i_mtime = inode->i_ctime = CURRENT_TIME; - nobh_truncate_page(inode->i_mapping, isize, exofs_get_block); + ret = exofs_oi_truncate(oi, (u64)newsize); + if (likely(!ret)) + truncate_setsize(inode, newsize); - ret = exofs_oi_truncate(oi, (u64)isize); - EXOFS_DBGMSG("(0x%lx) size=0x%llx\n", inode->i_ino, isize); + EXOFS_DBGMSG("(0x%lx) size=0x%llx ret=>%d\n", + inode->i_ino, newsize, ret); return ret; } /* - * Truncate a file to the specified size - all we have to do is set the size - * attribute. We make sure the object exists first. - */ -void exofs_truncate(struct inode *inode) -{ - struct exofs_i_info *oi = exofs_i(inode); - int ret; - - if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) - || S_ISLNK(inode->i_mode))) - return; - if (exofs_inode_is_fast_symlink(inode)) - return; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) - return; - - /* if we are about to truncate an object, and it hasn't been - * created yet, wait - */ - if (unlikely(wait_obj_created(oi))) - goto fail; - - ret = _do_truncate(inode); - if (ret) - goto fail; - -out: - mark_inode_dirty(inode); - return; -fail: - make_bad_inode(inode); - goto out; -} - -/* - * Set inode attributes - just call generic functions. + * Set inode attributes - update size attribute on OSD if needed, + * otherwise just call generic functions. */ int exofs_setattr(struct dentry *dentry, struct iattr *iattr) { struct inode *inode = dentry->d_inode; int error; + /* 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; + error = inode_change_ok(inode, iattr); - if (error) + if (unlikely(error)) return error; - error = inode_setattr(inode, iattr); - return error; + if ((iattr->ia_valid & ATTR_SIZE) && + iattr->ia_size != i_size_read(inode)) { + error = _do_truncate(inode, iattr->ia_size); + if (unlikely(error)) + return error; + } + + setattr_copy(inode, iattr); + mark_inode_dirty(inode); + return 0; } static const struct osd_attr g_attr_inode_file_layout = ATTR_DEF( @@ -1325,7 +1302,7 @@ static void delete_done(struct exofs_io_state *ios, void *p) * from the OSD here. We make sure the object was created before we try and * delete it. */ -void exofs_delete_inode(struct inode *inode) +void exofs_evict_inode(struct inode *inode) { struct exofs_i_info *oi = exofs_i(inode); struct super_block *sb = inode->i_sb; @@ -1335,30 +1312,27 @@ void exofs_delete_inode(struct inode *inode) truncate_inode_pages(&inode->i_data, 0); - if (is_bad_inode(inode)) + /* TODO: should do better here */ + if (inode->i_nlink || is_bad_inode(inode)) goto no_delete; - mark_inode_dirty(inode); - exofs_update_inode(inode, inode_needs_sync(inode)); - inode->i_size = 0; - if (inode->i_blocks) - exofs_truncate(inode); + end_writeback(inode); - clear_inode(inode); + /* if we are deleting an obj that hasn't been created yet, wait */ + if (!obj_created(oi)) { + BUG_ON(!obj_2bcreated(oi)); + wait_event(oi->i_wq, obj_created(oi)); + /* ignore the error attempt a remove anyway */ + } + /* Now Remove the OSD objects */ ret = exofs_get_io_state(&sbi->layout, &ios); if (unlikely(ret)) { EXOFS_ERR("%s: exofs_get_io_state failed\n", __func__); return; } - /* if we are deleting an obj that hasn't been created yet, wait */ - if (!obj_created(oi)) { - BUG_ON(!obj_2bcreated(oi)); - wait_event(oi->i_wq, obj_created(oi)); - } - ios->obj.id = exofs_oi_objno(oi); ios->done = delete_done; ios->private = sbi; @@ -1374,5 +1348,5 @@ void exofs_delete_inode(struct inode *inode) return; no_delete: - clear_inode(inode); + end_writeback(inode); } diff --git a/fs/exofs/ios.c b/fs/exofs/ios.c index 4337cad..6550bf7 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, @@ -392,20 +388,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 +419,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 +432,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; } @@ -454,18 +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; - unsigned first_comp = 0; 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; @@ -479,26 +468,17 @@ 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; - 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; + 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; - - first_comp += devs_in_group; - first_comp %= ios->layout->s_numdevs; } out: @@ -599,7 +579,7 @@ static int _sbi_write_mirror(struct exofs_io_state *ios, int cur_comp) } else { bio = master_dev->bio; /* FIXME: bio_set_dir() */ - bio->bi_rw |= (1 << BIO_RW); + bio->bi_rw |= REQ_WRITE; } osd_req_write(or, &ios->obj, per_dev->offset, bio, diff --git a/fs/exofs/super.c b/fs/exofs/super.c index 03149b9..047e92f 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 <linux/smp_lock.h> #include <linux/string.h> #include <linux/parser.h> #include <linux/vfs.h> @@ -743,7 +742,7 @@ static const struct super_operations exofs_sops = { .alloc_inode = exofs_alloc_inode, .destroy_inode = exofs_destroy_inode, .write_inode = exofs_write_inode, - .delete_inode = exofs_delete_inode, + .evict_inode = exofs_evict_inode, .put_super = exofs_put_super, .write_super = exofs_write_super, .sync_fs = exofs_sync_fs, |