From 00dc417fa3e763345b34ccb6034d72de76eea0a1 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 3 Oct 2008 17:32:11 -0400 Subject: ocfs2: fiemap support Plug ocfs2 into ->fiemap. Some portions of ocfs2_get_clusters() had to be refactored so that the extent cache can be skipped in favor of going directly to the on-disk records. This makes it easier for us to determine which extent is the last one in the btree. Also, I'm not sure we want to be caching fiemap lookups anyway as they're not directly related to data read/write. Signed-off-by: Mark Fasheh Signed-off-by: "Theodore Ts'o" Cc: ocfs2-devel@oss.oracle.com Cc: linux-fsdevel@vger.kernel.org --- fs/ocfs2/extent_map.c | 346 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 293 insertions(+), 53 deletions(-) (limited to 'fs/ocfs2/extent_map.c') diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index c58668a326f..aed268e80b4 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -25,6 +25,7 @@ #include #include #include +#include #define MLOG_MASK_PREFIX ML_EXTENT_MAP #include @@ -32,6 +33,7 @@ #include "ocfs2.h" #include "alloc.h" +#include "dlmglue.h" #include "extent_map.h" #include "inode.h" #include "super.h" @@ -282,6 +284,51 @@ out: kfree(new_emi); } +static int ocfs2_last_eb_is_empty(struct inode *inode, + struct ocfs2_dinode *di) +{ + int ret, next_free; + u64 last_eb_blk = le64_to_cpu(di->i_last_eb_blk); + struct buffer_head *eb_bh = NULL; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *el; + + ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), last_eb_blk, + &eb_bh, OCFS2_BH_CACHED, inode); + if (ret) { + mlog_errno(ret); + goto out; + } + + eb = (struct ocfs2_extent_block *) eb_bh->b_data; + el = &eb->h_list; + + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + ret = -EROFS; + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + goto out; + } + + if (el->l_tree_depth) { + ocfs2_error(inode->i_sb, + "Inode %lu has non zero tree depth in " + "leaf block %llu\n", inode->i_ino, + (unsigned long long)eb_bh->b_blocknr); + ret = -EROFS; + goto out; + } + + next_free = le16_to_cpu(el->l_next_free_rec); + + if (next_free == 0 || + (next_free == 1 && ocfs2_is_empty_extent(&el->l_recs[0]))) + ret = 1; + +out: + brelse(eb_bh); + return ret; +} + /* * Return the 1st index within el which contains an extent start * larger than v_cluster. @@ -373,42 +420,28 @@ out: return ret; } -int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, - u32 *p_cluster, u32 *num_clusters, - unsigned int *extent_flags) +static int ocfs2_get_clusters_nocache(struct inode *inode, + struct buffer_head *di_bh, + u32 v_cluster, unsigned int *hole_len, + struct ocfs2_extent_rec *ret_rec, + unsigned int *is_last) { - int ret, i; - unsigned int flags = 0; - struct buffer_head *di_bh = NULL; - struct buffer_head *eb_bh = NULL; + int i, ret, tree_height, len; struct ocfs2_dinode *di; - struct ocfs2_extent_block *eb; + struct ocfs2_extent_block *uninitialized_var(eb); struct ocfs2_extent_list *el; struct ocfs2_extent_rec *rec; - u32 coff; - - if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { - ret = -ERANGE; - mlog_errno(ret); - goto out; - } - - ret = ocfs2_extent_map_lookup(inode, v_cluster, p_cluster, - num_clusters, extent_flags); - if (ret == 0) - goto out; + struct buffer_head *eb_bh = NULL; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), OCFS2_I(inode)->ip_blkno, - &di_bh, OCFS2_BH_CACHED, inode); - if (ret) { - mlog_errno(ret); - goto out; - } + memset(ret_rec, 0, sizeof(*ret_rec)); + if (is_last) + *is_last = 0; di = (struct ocfs2_dinode *) di_bh->b_data; el = &di->id2.i_list; + tree_height = le16_to_cpu(el->l_tree_depth); - if (el->l_tree_depth) { + if (tree_height > 0) { ret = ocfs2_find_leaf(inode, el, v_cluster, &eb_bh); if (ret) { mlog_errno(ret); @@ -431,46 +464,143 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, i = ocfs2_search_extent_list(el, v_cluster); if (i == -1) { /* - * A hole was found. Return some canned values that - * callers can key on. If asked for, num_clusters will - * be populated with the size of the hole. + * Holes can be larger than the maximum size of an + * extent, so we return their lengths in a seperate + * field. */ - *p_cluster = 0; - if (num_clusters) { + if (hole_len) { ret = ocfs2_figure_hole_clusters(inode, el, eb_bh, - v_cluster, - num_clusters); + v_cluster, &len); if (ret) { mlog_errno(ret); goto out; } + + *hole_len = len; } - } else { - rec = &el->l_recs[i]; + goto out_hole; + } - BUG_ON(v_cluster < le32_to_cpu(rec->e_cpos)); + rec = &el->l_recs[i]; - if (!rec->e_blkno) { - ocfs2_error(inode->i_sb, "Inode %lu has bad extent " - "record (%u, %u, 0)", inode->i_ino, - le32_to_cpu(rec->e_cpos), - ocfs2_rec_clusters(el, rec)); - ret = -EROFS; - goto out; + BUG_ON(v_cluster < le32_to_cpu(rec->e_cpos)); + + if (!rec->e_blkno) { + ocfs2_error(inode->i_sb, "Inode %lu has bad extent " + "record (%u, %u, 0)", inode->i_ino, + le32_to_cpu(rec->e_cpos), + ocfs2_rec_clusters(el, rec)); + ret = -EROFS; + goto out; + } + + *ret_rec = *rec; + + /* + * Checking for last extent is potentially expensive - we + * might have to look at the next leaf over to see if it's + * empty. + * + * The first two checks are to see whether the caller even + * cares for this information, and if the extent is at least + * the last in it's list. + * + * If those hold true, then the extent is last if any of the + * additional conditions hold true: + * - Extent list is in-inode + * - Extent list is right-most + * - Extent list is 2nd to rightmost, with empty right-most + */ + if (is_last) { + if (i == (le16_to_cpu(el->l_next_free_rec) - 1)) { + if (tree_height == 0) + *is_last = 1; + else if (eb->h_blkno == di->i_last_eb_blk) + *is_last = 1; + else if (eb->h_next_leaf_blk == di->i_last_eb_blk) { + ret = ocfs2_last_eb_is_empty(inode, di); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + if (ret == 1) + *is_last = 1; + } } + } + +out_hole: + ret = 0; +out: + brelse(eb_bh); + return ret; +} + +static void ocfs2_relative_extent_offsets(struct super_block *sb, + u32 v_cluster, + struct ocfs2_extent_rec *rec, + u32 *p_cluster, u32 *num_clusters) + +{ + u32 coff = v_cluster - le32_to_cpu(rec->e_cpos); + + *p_cluster = ocfs2_blocks_to_clusters(sb, le64_to_cpu(rec->e_blkno)); + *p_cluster = *p_cluster + coff; + + if (num_clusters) + *num_clusters = le16_to_cpu(rec->e_leaf_clusters) - coff; +} + +int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, + u32 *p_cluster, u32 *num_clusters, + unsigned int *extent_flags) +{ + int ret; + unsigned int uninitialized_var(hole_len), flags = 0; + struct buffer_head *di_bh = NULL; + struct ocfs2_extent_rec rec; - coff = v_cluster - le32_to_cpu(rec->e_cpos); + if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { + ret = -ERANGE; + mlog_errno(ret); + goto out; + } - *p_cluster = ocfs2_blocks_to_clusters(inode->i_sb, - le64_to_cpu(rec->e_blkno)); - *p_cluster = *p_cluster + coff; + ret = ocfs2_extent_map_lookup(inode, v_cluster, p_cluster, + num_clusters, extent_flags); + if (ret == 0) + goto out; - if (num_clusters) - *num_clusters = ocfs2_rec_clusters(el, rec) - coff; + ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), OCFS2_I(inode)->ip_blkno, + &di_bh, OCFS2_BH_CACHED, inode); + if (ret) { + mlog_errno(ret); + goto out; + } - flags = rec->e_flags; + ret = ocfs2_get_clusters_nocache(inode, di_bh, v_cluster, &hole_len, + &rec, NULL); + if (ret) { + mlog_errno(ret); + goto out; + } - ocfs2_extent_map_insert_rec(inode, rec); + if (rec.e_blkno == 0ULL) { + /* + * A hole was found. Return some canned values that + * callers can key on. If asked for, num_clusters will + * be populated with the size of the hole. + */ + *p_cluster = 0; + if (num_clusters) { + *num_clusters = hole_len; + } + } else { + ocfs2_relative_extent_offsets(inode->i_sb, v_cluster, &rec, + p_cluster, num_clusters); + flags = rec.e_flags; + + ocfs2_extent_map_insert_rec(inode, &rec); } if (extent_flags) @@ -478,7 +608,6 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, out: brelse(di_bh); - brelse(eb_bh); return ret; } @@ -521,3 +650,114 @@ int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, out: return ret; } + +static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh, + struct fiemap_extent_info *fieinfo, + u64 map_start) +{ + int ret; + unsigned int id_count; + struct ocfs2_dinode *di; + u64 phys; + u32 flags = FIEMAP_EXTENT_DATA_INLINE|FIEMAP_EXTENT_LAST; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + di = (struct ocfs2_dinode *)di_bh->b_data; + id_count = le16_to_cpu(di->id2.i_data.id_count); + + if (map_start < id_count) { + phys = oi->ip_blkno << inode->i_sb->s_blocksize_bits; + phys += offsetof(struct ocfs2_dinode, id2.i_data.id_data); + + ret = fiemap_fill_next_extent(fieinfo, 0, phys, id_count, + flags); + if (ret < 0) + return ret; + } + + return 0; +} + +#define OCFS2_FIEMAP_FLAGS (FIEMAP_FLAG_SYNC) + +int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, + u64 map_start, u64 map_len) +{ + int ret, is_last; + u32 mapping_end, cpos; + unsigned int hole_size; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + u64 len_bytes, phys_bytes, virt_bytes; + struct buffer_head *di_bh = NULL; + struct ocfs2_extent_rec rec; + + ret = fiemap_check_flags(fieinfo, OCFS2_FIEMAP_FLAGS); + if (ret) + return ret; + + ret = ocfs2_inode_lock(inode, &di_bh, 0); + if (ret) { + mlog_errno(ret); + goto out; + } + + down_read(&OCFS2_I(inode)->ip_alloc_sem); + + /* + * Handle inline-data separately. + */ + if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { + ret = ocfs2_fiemap_inline(inode, di_bh, fieinfo, map_start); + goto out_unlock; + } + + cpos = map_start >> osb->s_clustersize_bits; + mapping_end = ocfs2_clusters_for_bytes(inode->i_sb, + map_start + map_len); + mapping_end -= cpos; + is_last = 0; + while (cpos < mapping_end && !is_last) { + u32 fe_flags; + + ret = ocfs2_get_clusters_nocache(inode, di_bh, cpos, + &hole_size, &rec, &is_last); + if (ret) { + mlog_errno(ret); + goto out; + } + + if (rec.e_blkno == 0ULL) { + cpos += hole_size; + continue; + } + + fe_flags = 0; + if (rec.e_flags & OCFS2_EXT_UNWRITTEN) + fe_flags |= FIEMAP_EXTENT_UNWRITTEN; + if (is_last) + fe_flags |= FIEMAP_EXTENT_LAST; + len_bytes = (u64)le16_to_cpu(rec.e_leaf_clusters) << osb->s_clustersize_bits; + phys_bytes = le64_to_cpu(rec.e_blkno) << osb->sb->s_blocksize_bits; + virt_bytes = (u64)le32_to_cpu(rec.e_cpos) << osb->s_clustersize_bits; + + ret = fiemap_fill_next_extent(fieinfo, virt_bytes, phys_bytes, + len_bytes, fe_flags); + if (ret) + break; + + cpos = le32_to_cpu(rec.e_cpos)+ le16_to_cpu(rec.e_leaf_clusters); + } + + if (ret > 0) + ret = 0; + +out_unlock: + brelse(di_bh); + + up_read(&OCFS2_I(inode)->ip_alloc_sem); + + ocfs2_inode_unlock(inode, 0); +out: + + return ret; +} -- cgit v1.2.3-70-g09d2 From f56654c435c06f2b2bd5751889b1a08a3add7d6c Mon Sep 17 00:00:00 2001 From: Tao Ma Date: Mon, 18 Aug 2008 17:38:48 +0800 Subject: ocfs2: Add extent tree operation for xattr value btrees Add some thin wrappers around ocfs2_insert_extent() for each of the 3 different btree types, ocfs2_inode_insert_extent(), ocfs2_xattr_value_insert_extent() and ocfs2_xattr_tree_insert_extent(). The last is for the xattr index btree, which will be used in a followup patch. All the old callers in file.c etc will call ocfs2_dinode_insert_extent(), while the other two handle the xattr issue. And the init of extent tree are handled by these functions. When storing xattr value which is too large, we will allocate some clusters for it and here ocfs2_extent_list and ocfs2_extent_rec will also be used. In order to re-use the b-tree operation code, a new parameter named "private" is added into ocfs2_extent_tree and it is used to indicate the root of ocfs2_exent_list. The reason is that we can't deduce the root from the buffer_head now. It may be in an inode, an ocfs2_xattr_block or even worse, in any place in an ocfs2_xattr_bucket. Signed-off-by: Tao Ma Signed-off-by: Mark Fasheh --- fs/ocfs2/Makefile | 3 +- fs/ocfs2/alloc.c | 184 +++++++++++++++++++++------ fs/ocfs2/alloc.h | 42 ++++--- fs/ocfs2/aops.c | 5 +- fs/ocfs2/cluster/masklog.c | 1 + fs/ocfs2/cluster/masklog.h | 1 + fs/ocfs2/dir.c | 11 +- fs/ocfs2/extent_map.c | 60 +++++++++ fs/ocfs2/extent_map.h | 4 + fs/ocfs2/file.c | 9 +- fs/ocfs2/suballoc.c | 5 +- fs/ocfs2/suballoc.h | 3 +- fs/ocfs2/xattr.c | 305 +++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 569 insertions(+), 64 deletions(-) create mode 100644 fs/ocfs2/xattr.c (limited to 'fs/ocfs2/extent_map.c') diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index f6956de56fd..af63980319c 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -34,7 +34,8 @@ ocfs2-objs := \ symlink.o \ sysfile.o \ uptodate.o \ - ver.o + ver.o \ + xattr.o \ ocfs2_stackglue-objs := stackglue.o ocfs2_stack_o2cb-objs := stack_o2cb.o diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index cacfc118b71..e45421fee20 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -78,6 +78,7 @@ struct ocfs2_extent_tree { struct ocfs2_extent_tree_operations *eops; struct buffer_head *root_bh; struct ocfs2_extent_list *root_el; + void *private; }; static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, @@ -136,9 +137,50 @@ static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = { .sanity_check = ocfs2_dinode_sanity_check, }; +static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, + u64 blkno) +{ + struct ocfs2_xattr_value_root *xv = + (struct ocfs2_xattr_value_root *)et->private; + + xv->xr_last_eb_blk = cpu_to_le64(blkno); +} + +static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) +{ + struct ocfs2_xattr_value_root *xv = + (struct ocfs2_xattr_value_root *) et->private; + + return le64_to_cpu(xv->xr_last_eb_blk); +} + +static void ocfs2_xattr_value_update_clusters(struct inode *inode, + struct ocfs2_extent_tree *et, + u32 clusters) +{ + struct ocfs2_xattr_value_root *xv = + (struct ocfs2_xattr_value_root *)et->private; + + le32_add_cpu(&xv->xr_clusters, clusters); +} + +static int ocfs2_xattr_value_sanity_check(struct inode *inode, + struct ocfs2_extent_tree *et) +{ + return 0; +} + +static struct ocfs2_extent_tree_operations ocfs2_xattr_et_ops = { + .set_last_eb_blk = ocfs2_xattr_value_set_last_eb_blk, + .get_last_eb_blk = ocfs2_xattr_value_get_last_eb_blk, + .update_clusters = ocfs2_xattr_value_update_clusters, + .sanity_check = ocfs2_xattr_value_sanity_check, +}; + static struct ocfs2_extent_tree* ocfs2_new_extent_tree(struct buffer_head *bh, - enum ocfs2_extent_tree_type et_type) + enum ocfs2_extent_tree_type et_type, + void *private) { struct ocfs2_extent_tree *et; @@ -149,12 +191,16 @@ static struct ocfs2_extent_tree* et->type = et_type; get_bh(bh); et->root_bh = bh; + et->private = private; - /* current we only support dinode extent. */ - BUG_ON(et->type != OCFS2_DINODE_EXTENT); if (et_type == OCFS2_DINODE_EXTENT) { et->root_el = &((struct ocfs2_dinode *)bh->b_data)->id2.i_list; et->eops = &ocfs2_dinode_et_ops; + } else if (et_type == OCFS2_XATTR_VALUE_EXTENT) { + struct ocfs2_xattr_value_root *xv = + (struct ocfs2_xattr_value_root *) private; + et->root_el = &xv->xr_list; + et->eops = &ocfs2_xattr_et_ops; } return et; @@ -495,7 +541,8 @@ struct ocfs2_merge_ctxt { int ocfs2_num_free_extents(struct ocfs2_super *osb, struct inode *inode, struct buffer_head *root_bh, - enum ocfs2_extent_tree_type type) + enum ocfs2_extent_tree_type type, + void *private) { int retval; struct ocfs2_extent_list *el = NULL; @@ -517,6 +564,12 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, if (fe->i_last_eb_blk) last_eb_blk = le64_to_cpu(fe->i_last_eb_blk); el = &fe->id2.i_list; + } else if (type == OCFS2_XATTR_VALUE_EXTENT) { + struct ocfs2_xattr_value_root *xv = + (struct ocfs2_xattr_value_root *) private; + + last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk); + el = &xv->xr_list; } if (last_eb_blk) { @@ -4209,33 +4262,25 @@ out: * * The caller needs to update fe->i_clusters */ -int ocfs2_insert_extent(struct ocfs2_super *osb, - handle_t *handle, - struct inode *inode, - struct buffer_head *root_bh, - u32 cpos, - u64 start_blk, - u32 new_clusters, - u8 flags, - struct ocfs2_alloc_context *meta_ac, - enum ocfs2_extent_tree_type et_type) +static int ocfs2_insert_extent(struct ocfs2_super *osb, + handle_t *handle, + struct inode *inode, + struct buffer_head *root_bh, + u32 cpos, + u64 start_blk, + u32 new_clusters, + u8 flags, + struct ocfs2_alloc_context *meta_ac, + struct ocfs2_extent_tree *et) { int status; int uninitialized_var(free_records); struct buffer_head *last_eb_bh = NULL; struct ocfs2_insert_type insert = {0, }; struct ocfs2_extent_rec rec; - struct ocfs2_extent_tree *et = NULL; BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL); - et = ocfs2_new_extent_tree(root_bh, et_type); - if (!et) { - status = -ENOMEM; - mlog_errno(status); - goto bail; - } - mlog(0, "add %u clusters at position %u to inode %llu\n", new_clusters, cpos, (unsigned long long)OCFS2_I(inode)->ip_blkno); @@ -4287,9 +4332,68 @@ bail: if (last_eb_bh) brelse(last_eb_bh); + mlog_exit(status); + return status; +} + +int ocfs2_dinode_insert_extent(struct ocfs2_super *osb, + handle_t *handle, + struct inode *inode, + struct buffer_head *root_bh, + u32 cpos, + u64 start_blk, + u32 new_clusters, + u8 flags, + struct ocfs2_alloc_context *meta_ac) +{ + int status; + struct ocfs2_extent_tree *et = NULL; + + et = ocfs2_new_extent_tree(root_bh, OCFS2_DINODE_EXTENT, NULL); + if (!et) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + status = ocfs2_insert_extent(osb, handle, inode, root_bh, + cpos, start_blk, new_clusters, + flags, meta_ac, et); + if (et) ocfs2_free_extent_tree(et); - mlog_exit(status); +bail: + return status; +} + +int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb, + handle_t *handle, + struct inode *inode, + struct buffer_head *root_bh, + u32 cpos, + u64 start_blk, + u32 new_clusters, + u8 flags, + struct ocfs2_alloc_context *meta_ac, + void *private) +{ + int status; + struct ocfs2_extent_tree *et = NULL; + + et = ocfs2_new_extent_tree(root_bh, OCFS2_XATTR_VALUE_EXTENT, private); + if (!et) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + status = ocfs2_insert_extent(osb, handle, inode, root_bh, + cpos, start_blk, new_clusters, + flags, meta_ac, et); + + if (et) + ocfs2_free_extent_tree(et); +bail: return status; } @@ -4311,7 +4415,8 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, struct ocfs2_alloc_context *data_ac, struct ocfs2_alloc_context *meta_ac, enum ocfs2_alloc_restarted *reason_ret, - enum ocfs2_extent_tree_type type) + enum ocfs2_extent_tree_type type, + void *private) { int status = 0; int free_extents; @@ -4325,7 +4430,8 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, if (mark_unwritten) flags = OCFS2_EXT_UNWRITTEN; - free_extents = ocfs2_num_free_extents(osb, inode, root_bh, type); + free_extents = ocfs2_num_free_extents(osb, inode, root_bh, type, + private); if (free_extents < 0) { status = free_extents; mlog_errno(status); @@ -4372,9 +4478,16 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, block = ocfs2_clusters_to_blocks(osb->sb, bit_off); mlog(0, "Allocating %u clusters at block %u for inode %llu\n", num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno); - status = ocfs2_insert_extent(osb, handle, inode, root_bh, - *logical_offset, block, num_bits, - flags, meta_ac, type); + if (type == OCFS2_DINODE_EXTENT) + status = ocfs2_dinode_insert_extent(osb, handle, inode, root_bh, + *logical_offset, block, + num_bits, flags, meta_ac); + else + status = ocfs2_xattr_value_insert_extent(osb, handle, + inode, root_bh, + *logical_offset, + block, num_bits, flags, + meta_ac, private); if (status < 0) { mlog_errno(status); goto leave; @@ -4655,7 +4768,8 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, handle_t *handle, u32 cpos, u32 len, u32 phys, struct ocfs2_alloc_context *meta_ac, struct ocfs2_cached_dealloc_ctxt *dealloc, - enum ocfs2_extent_tree_type et_type) + enum ocfs2_extent_tree_type et_type, + void *private) { int ret, index; u64 start_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys); @@ -4676,7 +4790,7 @@ int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, goto out; } - et = ocfs2_new_extent_tree(root_bh, et_type); + et = ocfs2_new_extent_tree(root_bh, et_type, private); if (!et) { ret = -ENOMEM; mlog_errno(ret); @@ -4964,7 +5078,8 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, u32 cpos, u32 len, handle_t *handle, struct ocfs2_alloc_context *meta_ac, struct ocfs2_cached_dealloc_ctxt *dealloc, - enum ocfs2_extent_tree_type et_type) + enum ocfs2_extent_tree_type et_type, + void *private) { int ret, index; u32 rec_range, trunc_range; @@ -4973,7 +5088,7 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, struct ocfs2_path *path = NULL; struct ocfs2_extent_tree *et = NULL; - et = ocfs2_new_extent_tree(root_bh, et_type); + et = ocfs2_new_extent_tree(root_bh, et_type, private); if (!et) { ret = -ENOMEM; mlog_errno(ret); @@ -6608,9 +6723,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, * this proves to be false, we could always re-build * the in-inode data from our pages. */ - ret = ocfs2_insert_extent(osb, handle, inode, di_bh, - 0, block, 1, 0, - NULL, OCFS2_DINODE_EXTENT); + ret = ocfs2_dinode_insert_extent(osb, handle, inode, di_bh, + 0, block, 1, 0, NULL); if (ret) { mlog_errno(ret); goto out_commit; diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index 5e090c5d849..ec7baeb2ea7 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h @@ -28,19 +28,29 @@ enum ocfs2_extent_tree_type { OCFS2_DINODE_EXTENT = 0, + OCFS2_XATTR_VALUE_EXTENT, }; struct ocfs2_alloc_context; -int ocfs2_insert_extent(struct ocfs2_super *osb, - handle_t *handle, - struct inode *inode, - struct buffer_head *root_bh, - u32 cpos, - u64 start_blk, - u32 new_clusters, - u8 flags, - struct ocfs2_alloc_context *meta_ac, - enum ocfs2_extent_tree_type et_type); +int ocfs2_dinode_insert_extent(struct ocfs2_super *osb, + handle_t *handle, + struct inode *inode, + struct buffer_head *root_bh, + u32 cpos, + u64 start_blk, + u32 new_clusters, + u8 flags, + struct ocfs2_alloc_context *meta_ac); +int ocfs2_xattr_value_insert_extent(struct ocfs2_super *osb, + handle_t *handle, + struct inode *inode, + struct buffer_head *root_bh, + u32 cpos, + u64 start_blk, + u32 new_clusters, + u8 flags, + struct ocfs2_alloc_context *meta_ac, + void *private); enum ocfs2_alloc_restarted { RESTART_NONE = 0, RESTART_TRANS, @@ -57,22 +67,26 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, struct ocfs2_alloc_context *data_ac, struct ocfs2_alloc_context *meta_ac, enum ocfs2_alloc_restarted *reason_ret, - enum ocfs2_extent_tree_type type); + enum ocfs2_extent_tree_type type, + void *private); struct ocfs2_cached_dealloc_ctxt; int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, handle_t *handle, u32 cpos, u32 len, u32 phys, struct ocfs2_alloc_context *meta_ac, struct ocfs2_cached_dealloc_ctxt *dealloc, - enum ocfs2_extent_tree_type et_type); + enum ocfs2_extent_tree_type et_type, + void *private); int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, u32 cpos, u32 len, handle_t *handle, struct ocfs2_alloc_context *meta_ac, struct ocfs2_cached_dealloc_ctxt *dealloc, - enum ocfs2_extent_tree_type et_type); + enum ocfs2_extent_tree_type et_type, + void *private); int ocfs2_num_free_extents(struct ocfs2_super *osb, struct inode *inode, struct buffer_head *root_bh, - enum ocfs2_extent_tree_type et_type); + enum ocfs2_extent_tree_type et_type, + void *private); /* * how many new metadata chunks would an allocation need at maximum? diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index e7acd286790..530b1ff599c 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -1279,7 +1279,7 @@ static int ocfs2_write_cluster(struct address_space *mapping, ret = ocfs2_mark_extent_written(inode, wc->w_di_bh, wc->w_handle, cpos, 1, phys, meta_ac, &wc->w_dealloc, - OCFS2_DINODE_EXTENT); + OCFS2_DINODE_EXTENT, NULL); if (ret < 0) { mlog_errno(ret); goto out; @@ -1721,7 +1721,8 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, ret = ocfs2_lock_allocators(inode, wc->w_di_bh, &di->id2.i_list, clusters_to_alloc, extents_to_split, - &data_ac, &meta_ac); + &data_ac, &meta_ac, + OCFS2_DINODE_EXTENT, NULL); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index 23c732f2752..d8a0cb92cef 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c @@ -109,6 +109,7 @@ static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = { define_mask(CONN), define_mask(QUORUM), define_mask(EXPORT), + define_mask(XATTR), define_mask(ERROR), define_mask(NOTICE), define_mask(KTHREAD), diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h index 597e064bb94..57670c68047 100644 --- a/fs/ocfs2/cluster/masklog.h +++ b/fs/ocfs2/cluster/masklog.h @@ -112,6 +112,7 @@ #define ML_CONN 0x0000000004000000ULL /* net connection management */ #define ML_QUORUM 0x0000000008000000ULL /* net connection quorum */ #define ML_EXPORT 0x0000000010000000ULL /* ocfs2 export operations */ +#define ML_XATTR 0x0000000020000000ULL /* ocfs2 extended attributes */ /* bits that are infrequently given and frequently matched in the high word */ #define ML_ERROR 0x0000000100000000ULL /* sent to KERN_ERR */ #define ML_NOTICE 0x0000000200000000ULL /* setn to KERN_NOTICE */ diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index d17c34b0ac6..5426a02c12b 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -1305,8 +1305,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, * This should never fail as our extent list is empty and all * related blocks have been journaled already. */ - ret = ocfs2_insert_extent(osb, handle, dir, di_bh, 0, blkno, len, 0, - NULL, OCFS2_DINODE_EXTENT); + ret = ocfs2_dinode_insert_extent(osb, handle, dir, di_bh, 0, blkno, + len, 0, NULL); if (ret) { mlog_errno(ret); goto out_commit; @@ -1337,8 +1337,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, } blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off); - ret = ocfs2_insert_extent(osb, handle, dir, di_bh, 1, blkno, - len, 0, NULL, OCFS2_DINODE_EXTENT); + ret = ocfs2_dinode_insert_extent(osb, handle, dir, di_bh, 1, + blkno, len, 0, NULL); if (ret) { mlog_errno(ret); goto out_commit; @@ -1482,7 +1482,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, spin_unlock(&OCFS2_I(dir)->ip_lock); num_free_extents = ocfs2_num_free_extents(osb, dir, parent_fe_bh, - OCFS2_DINODE_EXTENT); + OCFS2_DINODE_EXTENT, + NULL); if (num_free_extents < 0) { status = num_free_extents; mlog_errno(status); diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index aed268e80b4..a7b1cfa735b 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -551,6 +551,66 @@ static void ocfs2_relative_extent_offsets(struct super_block *sb, *num_clusters = le16_to_cpu(rec->e_leaf_clusters) - coff; } +int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster, + u32 *p_cluster, u32 *num_clusters, + struct ocfs2_extent_list *el) +{ + int ret = 0, i; + struct buffer_head *eb_bh = NULL; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_rec *rec; + u32 coff; + + if (el->l_tree_depth) { + ret = ocfs2_find_leaf(inode, el, v_cluster, &eb_bh); + if (ret) { + mlog_errno(ret); + goto out; + } + + eb = (struct ocfs2_extent_block *) eb_bh->b_data; + el = &eb->h_list; + + if (el->l_tree_depth) { + ocfs2_error(inode->i_sb, + "Inode %lu has non zero tree depth in " + "xattr leaf block %llu\n", inode->i_ino, + (unsigned long long)eb_bh->b_blocknr); + ret = -EROFS; + goto out; + } + } + + i = ocfs2_search_extent_list(el, v_cluster); + if (i == -1) { + ret = -EROFS; + mlog_errno(ret); + goto out; + } else { + rec = &el->l_recs[i]; + BUG_ON(v_cluster < le32_to_cpu(rec->e_cpos)); + + if (!rec->e_blkno) { + ocfs2_error(inode->i_sb, "Inode %lu has bad extent " + "record (%u, %u, 0) in xattr", inode->i_ino, + le32_to_cpu(rec->e_cpos), + ocfs2_rec_clusters(el, rec)); + ret = -EROFS; + goto out; + } + coff = v_cluster - le32_to_cpu(rec->e_cpos); + *p_cluster = ocfs2_blocks_to_clusters(inode->i_sb, + le64_to_cpu(rec->e_blkno)); + *p_cluster = *p_cluster + coff; + if (num_clusters) + *num_clusters = ocfs2_rec_clusters(el, rec) - coff; + } +out: + if (eb_bh) + brelse(eb_bh); + return ret; +} + int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster, u32 *num_clusters, unsigned int *extent_flags) diff --git a/fs/ocfs2/extent_map.h b/fs/ocfs2/extent_map.h index 1b97490e1ea..1c4aa8b06f3 100644 --- a/fs/ocfs2/extent_map.h +++ b/fs/ocfs2/extent_map.h @@ -53,4 +53,8 @@ int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 map_start, u64 map_len); +int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster, + u32 *p_cluster, u32 *num_clusters, + struct ocfs2_extent_list *el); + #endif /* _EXTENT_MAP_H */ diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 7bb4fde7005..89d8541f85b 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -515,7 +515,7 @@ int ocfs2_add_inode_data(struct ocfs2_super *osb, clusters_to_add, mark_unwritten, fe_bh, el, handle, data_ac, meta_ac, reason_ret, - OCFS2_DINODE_EXTENT); + OCFS2_DINODE_EXTENT, NULL); } static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start, @@ -565,7 +565,7 @@ restart_all: clusters_to_add); status = ocfs2_lock_allocators(inode, bh, &fe->id2.i_list, clusters_to_add, 0, &data_ac, - &meta_ac); + &meta_ac, OCFS2_DINODE_EXTENT, NULL); if (status) { mlog_errno(status); goto leave; @@ -1237,7 +1237,8 @@ static int __ocfs2_remove_inode_range(struct inode *inode, struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; ret = ocfs2_lock_allocators(inode, di_bh, &di->id2.i_list, - 0, 1, NULL, &meta_ac); + 0, 1, NULL, &meta_ac, + OCFS2_DINODE_EXTENT, NULL); if (ret) { mlog_errno(ret); return ret; @@ -1268,7 +1269,7 @@ static int __ocfs2_remove_inode_range(struct inode *inode, } ret = ocfs2_remove_extent(inode, di_bh, cpos, len, handle, meta_ac, - dealloc, OCFS2_DINODE_EXTENT); + dealloc, OCFS2_DINODE_EXTENT, NULL); if (ret) { mlog_errno(ret); goto out_commit; diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index b642c825fb7..bb774d70d26 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -1909,7 +1909,8 @@ int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *root_bh, struct ocfs2_extent_list *root_el, u32 clusters_to_add, u32 extents_to_split, struct ocfs2_alloc_context **data_ac, - struct ocfs2_alloc_context **meta_ac) + struct ocfs2_alloc_context **meta_ac, + enum ocfs2_extent_tree_type type, void *private) { int ret = 0, num_free_extents; unsigned int max_recs_needed = clusters_to_add + 2 * extents_to_split; @@ -1922,7 +1923,7 @@ int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *root_bh, BUG_ON(clusters_to_add != 0 && data_ac == NULL); num_free_extents = ocfs2_num_free_extents(osb, inode, root_bh, - OCFS2_DINODE_EXTENT); + type, private); if (num_free_extents < 0) { ret = num_free_extents; mlog_errno(ret); diff --git a/fs/ocfs2/suballoc.h b/fs/ocfs2/suballoc.h index a3e531e62df..9e026c8afee 100644 --- a/fs/ocfs2/suballoc.h +++ b/fs/ocfs2/suballoc.h @@ -166,5 +166,6 @@ int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *root_bh, struct ocfs2_extent_list *root_el, u32 clusters_to_add, u32 extents_to_split, struct ocfs2_alloc_context **data_ac, - struct ocfs2_alloc_context **meta_ac); + struct ocfs2_alloc_context **meta_ac, + enum ocfs2_extent_tree_type type, void *private); #endif /* _CHAINALLOC_H_ */ diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c new file mode 100644 index 00000000000..9604a4cd02b --- /dev/null +++ b/fs/ocfs2/xattr.c @@ -0,0 +1,305 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * xattr.c + * + * Copyright (C) 2008 Oracle. All rights reserved. + * + * This program 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; either + * version 2 of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#define MLOG_MASK_PREFIX ML_XATTR +#include + +#include "ocfs2.h" +#include "alloc.h" +#include "dlmglue.h" +#include "file.h" +#include "inode.h" +#include "journal.h" +#include "ocfs2_fs.h" +#include "suballoc.h" +#include "uptodate.h" +#include "buffer_head_io.h" + +static int ocfs2_xattr_extend_allocation(struct inode *inode, + u32 clusters_to_add, + struct buffer_head *xattr_bh, + struct ocfs2_xattr_value_root *xv) +{ + int status = 0; + int restart_func = 0; + int credits = 0; + handle_t *handle = NULL; + struct ocfs2_alloc_context *data_ac = NULL; + struct ocfs2_alloc_context *meta_ac = NULL; + enum ocfs2_alloc_restarted why; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_extent_list *root_el = &xv->xr_list; + u32 prev_clusters, logical_start = le32_to_cpu(xv->xr_clusters); + + mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); + +restart_all: + + status = ocfs2_lock_allocators(inode, xattr_bh, root_el, + clusters_to_add, 0, &data_ac, + &meta_ac, OCFS2_XATTR_VALUE_EXTENT, xv); + if (status) { + mlog_errno(status); + goto leave; + } + + credits = ocfs2_calc_extend_credits(osb->sb, root_el, clusters_to_add); + handle = ocfs2_start_trans(osb, credits); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto leave; + } + +restarted_transaction: + status = ocfs2_journal_access(handle, inode, xattr_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + prev_clusters = le32_to_cpu(xv->xr_clusters); + status = ocfs2_add_clusters_in_btree(osb, + inode, + &logical_start, + clusters_to_add, + 0, + xattr_bh, + root_el, + handle, + data_ac, + meta_ac, + &why, + OCFS2_XATTR_VALUE_EXTENT, + xv); + if ((status < 0) && (status != -EAGAIN)) { + if (status != -ENOSPC) + mlog_errno(status); + goto leave; + } + + status = ocfs2_journal_dirty(handle, xattr_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + clusters_to_add -= le32_to_cpu(xv->xr_clusters) - prev_clusters; + + if (why != RESTART_NONE && clusters_to_add) { + if (why == RESTART_META) { + mlog(0, "restarting function.\n"); + restart_func = 1; + } else { + BUG_ON(why != RESTART_TRANS); + + mlog(0, "restarting transaction.\n"); + /* TODO: This can be more intelligent. */ + credits = ocfs2_calc_extend_credits(osb->sb, + root_el, + clusters_to_add); + status = ocfs2_extend_trans(handle, credits); + if (status < 0) { + /* handle still has to be committed at + * this point. */ + status = -ENOMEM; + mlog_errno(status); + goto leave; + } + goto restarted_transaction; + } + } + +leave: + if (handle) { + ocfs2_commit_trans(osb, handle); + handle = NULL; + } + if (data_ac) { + ocfs2_free_alloc_context(data_ac); + data_ac = NULL; + } + if (meta_ac) { + ocfs2_free_alloc_context(meta_ac); + meta_ac = NULL; + } + if ((!status) && restart_func) { + restart_func = 0; + goto restart_all; + } + + return status; +} + +static int __ocfs2_remove_xattr_range(struct inode *inode, + struct buffer_head *root_bh, + struct ocfs2_xattr_value_root *xv, + u32 cpos, u32 phys_cpos, u32 len, + struct ocfs2_cached_dealloc_ctxt *dealloc) +{ + int ret; + u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct inode *tl_inode = osb->osb_tl_inode; + handle_t *handle; + struct ocfs2_alloc_context *meta_ac = NULL; + + ret = ocfs2_lock_allocators(inode, root_bh, &xv->xr_list, + 0, 1, NULL, &meta_ac, + OCFS2_XATTR_VALUE_EXTENT, xv); + if (ret) { + mlog_errno(ret); + return ret; + } + + mutex_lock(&tl_inode->i_mutex); + + if (ocfs2_truncate_log_needs_flush(osb)) { + ret = __ocfs2_flush_truncate_log(osb); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + } + + handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); + mlog_errno(ret); + goto out; + } + + ret = ocfs2_journal_access(handle, inode, root_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (ret) { + mlog_errno(ret); + goto out_commit; + } + + ret = ocfs2_remove_extent(inode, root_bh, cpos, len, handle, meta_ac, + dealloc, OCFS2_XATTR_VALUE_EXTENT, xv); + if (ret) { + mlog_errno(ret); + goto out_commit; + } + + le32_add_cpu(&xv->xr_clusters, -len); + + ret = ocfs2_journal_dirty(handle, root_bh); + if (ret) { + mlog_errno(ret); + goto out_commit; + } + + ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len); + if (ret) + mlog_errno(ret); + +out_commit: + ocfs2_commit_trans(osb, handle); +out: + mutex_unlock(&tl_inode->i_mutex); + + if (meta_ac) + ocfs2_free_alloc_context(meta_ac); + + return ret; +} + +static int ocfs2_xattr_shrink_size(struct inode *inode, + u32 old_clusters, + u32 new_clusters, + struct buffer_head *root_bh, + struct ocfs2_xattr_value_root *xv) +{ + int ret = 0; + u32 trunc_len, cpos, phys_cpos, alloc_size; + u64 block; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_cached_dealloc_ctxt dealloc; + + ocfs2_init_dealloc_ctxt(&dealloc); + + if (old_clusters <= new_clusters) + return 0; + + cpos = new_clusters; + trunc_len = old_clusters - new_clusters; + while (trunc_len) { + ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos, + &alloc_size, &xv->xr_list); + if (ret) { + mlog_errno(ret); + goto out; + } + + if (alloc_size > trunc_len) + alloc_size = trunc_len; + + ret = __ocfs2_remove_xattr_range(inode, root_bh, xv, cpos, + phys_cpos, alloc_size, + &dealloc); + if (ret) { + mlog_errno(ret); + goto out; + } + + block = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); + ocfs2_remove_xattr_clusters_from_cache(inode, block, + alloc_size); + cpos += alloc_size; + trunc_len -= alloc_size; + } + +out: + ocfs2_schedule_truncate_log_flush(osb, 1); + ocfs2_run_deallocs(osb, &dealloc); + + return ret; +} + +static int ocfs2_xattr_value_truncate(struct inode *inode, + struct buffer_head *root_bh, + struct ocfs2_xattr_value_root *xv, + int len) +{ + int ret; + u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len); + u32 old_clusters = le32_to_cpu(xv->xr_clusters); + + if (new_clusters == old_clusters) + return 0; + + if (new_clusters > old_clusters) + ret = ocfs2_xattr_extend_allocation(inode, + new_clusters - old_clusters, + root_bh, xv); + else + ret = ocfs2_xattr_shrink_size(inode, + old_clusters, new_clusters, + root_bh, xv); + + return ret; +} -- cgit v1.2.3-70-g09d2 From 31d33073ca38603dea705dae45e094a64ca062d6 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Thu, 9 Oct 2008 17:20:30 -0700 Subject: ocfs2: Require an inode for ocfs2_read_block(s)(). Now that synchronous readers are using ocfs2_read_blocks_sync(), all callers of ocfs2_read_blocks() are passing an inode. Use it unconditionally. Since it's there, we don't need to pass the ocfs2_super either. Signed-off-by: Joel Becker Signed-off-by: Mark Fasheh --- fs/ocfs2/alloc.c | 30 +++++++++---------- fs/ocfs2/aops.c | 10 +++---- fs/ocfs2/buffer_head_io.c | 35 ++++++++-------------- fs/ocfs2/buffer_head_io.h | 18 +++++------- fs/ocfs2/dir.c | 12 ++++---- fs/ocfs2/dlmglue.c | 9 +++--- fs/ocfs2/extent_map.c | 12 ++++---- fs/ocfs2/file.c | 12 ++++---- fs/ocfs2/inode.c | 6 ++-- fs/ocfs2/journal.c | 2 +- fs/ocfs2/localalloc.c | 8 ++--- fs/ocfs2/namei.c | 5 ++-- fs/ocfs2/resize.c | 4 +-- fs/ocfs2/slot_map.c | 5 ++-- fs/ocfs2/suballoc.c | 17 +++++------ fs/ocfs2/symlink.c | 5 ++-- fs/ocfs2/xattr.c | 74 ++++++++++++++++++++++------------------------- 17 files changed, 116 insertions(+), 148 deletions(-) (limited to 'fs/ocfs2/extent_map.c') diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 052c4cf7db9..a164e09491f 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -705,8 +705,8 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, last_eb_blk = ocfs2_et_get_last_eb_blk(et); if (last_eb_blk) { - retval = ocfs2_read_block(osb, last_eb_blk, - &eb_bh, OCFS2_BH_CACHED, inode); + retval = ocfs2_read_block(inode, last_eb_blk, + &eb_bh, OCFS2_BH_CACHED); if (retval < 0) { mlog_errno(retval); goto bail; @@ -1176,8 +1176,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb, brelse(bh); bh = NULL; - status = ocfs2_read_block(osb, blkno, &bh, OCFS2_BH_CACHED, - inode); + status = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto bail; @@ -1541,8 +1540,7 @@ static int __ocfs2_find_path(struct inode *inode, brelse(bh); bh = NULL; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno, - &bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -4296,9 +4294,9 @@ static int ocfs2_figure_insert_type(struct inode *inode, * ocfs2_figure_insert_type() and ocfs2_add_branch() * may want it later. */ - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh, - OCFS2_BH_CACHED, inode); + OCFS2_BH_CACHED); if (ret) { mlog_exit(ret); goto out; @@ -4764,9 +4762,9 @@ static int __ocfs2_mark_extent_written(struct inode *inode, if (path->p_tree_depth) { struct ocfs2_extent_block *eb; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), - &last_eb_bh, OCFS2_BH_CACHED, inode); + &last_eb_bh, OCFS2_BH_CACHED); if (ret) { mlog_exit(ret); goto out; @@ -4923,9 +4921,9 @@ static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et, depth = path->p_tree_depth; if (depth > 0) { - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), - &last_eb_bh, OCFS2_BH_CACHED, inode); + &last_eb_bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); goto out; @@ -5592,8 +5590,8 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, goto bail; } - status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &bh, - OCFS2_BH_CACHED, inode); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh, + OCFS2_BH_CACHED); if (status < 0) { iput(inode); mlog_errno(status); @@ -6991,8 +6989,8 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb, ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc); if (fe->id2.i_list.l_tree_depth) { - status = ocfs2_read_block(osb, le64_to_cpu(fe->i_last_eb_blk), - &last_eb_bh, OCFS2_BH_CACHED, inode); + status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk), + &last_eb_bh, OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 98e16fb49e4..f232a0e3c30 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -68,9 +68,8 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, goto bail; } - status = ocfs2_read_block(OCFS2_SB(inode->i_sb), - OCFS2_I(inode)->ip_blkno, - &bh, OCFS2_BH_CACHED, inode); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, + &bh, OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto bail; @@ -260,13 +259,12 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page) { int ret; struct buffer_head *di_bh = NULL; - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); BUG_ON(!PageLocked(page)); BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); - ret = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &di_bh, - OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh, + OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c index ca4ab7ce85b..718dbe5607c 100644 --- a/fs/ocfs2/buffer_head_io.c +++ b/fs/ocfs2/buffer_head_io.c @@ -170,22 +170,20 @@ bail: return status; } -int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr, - struct buffer_head *bhs[], int flags, - struct inode *inode) +int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, + struct buffer_head *bhs[], int flags) { int status = 0; - struct super_block *sb; int i, ignore_cache = 0; struct buffer_head *bh; - mlog_entry("(block=(%llu), nr=(%d), flags=%d, inode=%p)\n", - (unsigned long long)block, nr, flags, inode); + mlog_entry("(inode=%p, block=(%llu), nr=(%d), flags=%d)\n", + inode, (unsigned long long)block, nr, flags); - BUG_ON((flags & OCFS2_BH_READAHEAD) && - (!inode || !(flags & OCFS2_BH_CACHED))); + BUG_ON(!inode); + BUG_ON((flags & OCFS2_BH_READAHEAD) && !(flags & OCFS2_BH_CACHED)); - if (osb == NULL || osb->sb == NULL || bhs == NULL) { + if (bhs == NULL) { status = -EINVAL; mlog_errno(status); goto bail; @@ -204,19 +202,12 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr, goto bail; } - sb = osb->sb; - - if (flags & OCFS2_BH_CACHED && !inode) - flags &= ~OCFS2_BH_CACHED; - - if (inode) - mutex_lock(&OCFS2_I(inode)->ip_io_mutex); + mutex_lock(&OCFS2_I(inode)->ip_io_mutex); for (i = 0 ; i < nr ; i++) { if (bhs[i] == NULL) { - bhs[i] = sb_getblk(sb, block++); + bhs[i] = sb_getblk(inode->i_sb, block++); if (bhs[i] == NULL) { - if (inode) - mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); + mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); status = -EIO; mlog_errno(status); goto bail; @@ -347,11 +338,9 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr, /* Always set the buffer in the cache, even if it was * a forced read, or read-ahead which hasn't yet * completed. */ - if (inode) - ocfs2_set_buffer_uptodate(inode, bh); + ocfs2_set_buffer_uptodate(inode, bh); } - if (inode) - mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); + mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n", (unsigned long long)block, nr, diff --git a/fs/ocfs2/buffer_head_io.h b/fs/ocfs2/buffer_head_io.h index 71646b470ac..fd0d774ac35 100644 --- a/fs/ocfs2/buffer_head_io.h +++ b/fs/ocfs2/buffer_head_io.h @@ -31,21 +31,19 @@ void ocfs2_end_buffer_io_sync(struct buffer_head *bh, int uptodate); -static inline int ocfs2_read_block(struct ocfs2_super *osb, +static inline int ocfs2_read_block(struct inode *inode, u64 off, struct buffer_head **bh, - int flags, - struct inode *inode); + int flags); int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, struct inode *inode); -int ocfs2_read_blocks(struct ocfs2_super *osb, +int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, struct buffer_head *bhs[], - int flags, - struct inode *inode); + int flags); int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, unsigned int nr, struct buffer_head *bhs[]); @@ -55,9 +53,8 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, #define OCFS2_BH_CACHED 1 #define OCFS2_BH_READAHEAD 8 -static inline int ocfs2_read_block(struct ocfs2_super * osb, u64 off, - struct buffer_head **bh, int flags, - struct inode *inode) +static inline int ocfs2_read_block(struct inode *inode, u64 off, + struct buffer_head **bh, int flags) { int status = 0; @@ -67,8 +64,7 @@ static inline int ocfs2_read_block(struct ocfs2_super * osb, u64 off, goto bail; } - status = ocfs2_read_blocks(osb, off, 1, bh, - flags, inode); + status = ocfs2_read_blocks(inode, off, 1, bh, flags); bail: return status; diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 3614651dcdb..828437ca91b 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -188,8 +188,8 @@ static struct buffer_head *ocfs2_find_entry_id(const char *name, struct ocfs2_dinode *di; struct ocfs2_inline_data *data; - ret = ocfs2_read_block(OCFS2_SB(dir->i_sb), OCFS2_I(dir)->ip_blkno, - &di_bh, OCFS2_BH_CACHED, dir); + ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh, + OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -417,8 +417,8 @@ static inline int ocfs2_delete_entry_id(handle_t *handle, struct ocfs2_dinode *di; struct ocfs2_inline_data *data; - ret = ocfs2_read_block(OCFS2_SB(dir->i_sb), OCFS2_I(dir)->ip_blkno, - &di_bh, OCFS2_BH_CACHED, dir); + ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, + &di_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -596,8 +596,8 @@ static int ocfs2_dir_foreach_blk_id(struct inode *inode, struct ocfs2_inline_data *data; struct ocfs2_dir_entry *de; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), OCFS2_I(inode)->ip_blkno, - &di_bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, + &di_bh, OCFS2_BH_CACHED); if (ret) { mlog(ML_ERROR, "Unable to read inode block for dir %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index eae3d643a5e..3b2cd0f8721 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -2024,8 +2024,8 @@ static int ocfs2_inode_lock_update(struct inode *inode, } else { /* Boo, we have to go to disk. */ /* read bh, cast, ocfs2_refresh_inode */ - status = ocfs2_read_block(OCFS2_SB(inode->i_sb), oi->ip_blkno, - bh, OCFS2_BH_CACHED, inode); + status = ocfs2_read_block(inode, oi->ip_blkno, + bh, OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto bail_refresh; @@ -2086,11 +2086,10 @@ static int ocfs2_assign_bh(struct inode *inode, return 0; } - status = ocfs2_read_block(OCFS2_SB(inode->i_sb), + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, ret_bh, - OCFS2_BH_CACHED, - inode); + OCFS2_BH_CACHED); if (status < 0) mlog_errno(status); diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index a7b1cfa735b..5b482214bb7 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -293,8 +293,8 @@ static int ocfs2_last_eb_is_empty(struct inode *inode, struct ocfs2_extent_block *eb; struct ocfs2_extent_list *el; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), last_eb_blk, - &eb_bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, last_eb_blk, + &eb_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -382,9 +382,9 @@ static int ocfs2_figure_hole_clusters(struct inode *inode, if (le64_to_cpu(eb->h_next_leaf_blk) == 0ULL) goto no_more_extents; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, le64_to_cpu(eb->h_next_leaf_blk), - &next_eb_bh, OCFS2_BH_CACHED, inode); + &next_eb_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -631,8 +631,8 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, if (ret == 0) goto out; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), OCFS2_I(inode)->ip_blkno, - &di_bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, + &di_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 408d5a66591..7a809be54e8 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -545,8 +545,8 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start, */ BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb)); - status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &bh, - OCFS2_BH_CACHED, inode); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh, + OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto leave; @@ -1132,8 +1132,7 @@ static int ocfs2_write_remove_suid(struct inode *inode) struct buffer_head *bh = NULL; struct ocfs2_inode_info *oi = OCFS2_I(inode); - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), - oi->ip_blkno, &bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, oi->ip_blkno, &bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); goto out; @@ -1159,9 +1158,8 @@ static int ocfs2_allocate_unwritten_extents(struct inode *inode, struct buffer_head *di_bh = NULL; if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), - OCFS2_I(inode)->ip_blkno, &di_bh, - OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, + &di_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 52229703394..6ec31b92a47 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -461,8 +461,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, } if (can_lock) - status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0, - inode); + status = ocfs2_read_block(inode, args->fi_blkno, &bh, 0); else status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh); if (status < 0) { @@ -1166,8 +1165,7 @@ struct buffer_head *ocfs2_bread(struct inode *inode, goto fail; } - tmperr = ocfs2_read_block(OCFS2_SB(inode->i_sb), p_blkno, &bh, - readflags, inode); + tmperr = ocfs2_read_block(inode, p_blkno, &bh, readflags); if (tmperr < 0) goto fail; diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 10c51b562be..9854fb7315b 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -1134,7 +1134,7 @@ static int ocfs2_read_journal_inode(struct ocfs2_super *osb, } SET_INODE_JOURNAL(inode); - status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, bh, 0, inode); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh, 0); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 1c4f0645fb3..b77b67bb277 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -248,8 +248,8 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb) goto bail; } - status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, - &alloc_bh, 0, inode); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, + &alloc_bh, 0); if (status < 0) { mlog_errno(status); goto bail; @@ -459,8 +459,8 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, mutex_lock(&inode->i_mutex); - status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, - &alloc_bh, 0, inode); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, + &alloc_bh, 0); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 7d0dd5c95eb..e5fc9345dd3 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -1752,10 +1752,9 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); - status = ocfs2_read_block(osb, + status = ocfs2_read_block(orphan_dir_inode, OCFS2_I(orphan_dir_inode)->ip_blkno, - &orphan_dir_bh, OCFS2_BH_CACHED, - orphan_dir_inode); + &orphan_dir_bh, OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto leave; diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c index 472d854796c..92dcd935056 100644 --- a/fs/ocfs2/resize.c +++ b/fs/ocfs2/resize.c @@ -332,8 +332,8 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters) lgd_blkno = ocfs2_which_cluster_group(main_bm_inode, first_new_cluster - 1); - ret = ocfs2_read_block(osb, lgd_blkno, &group_bh, OCFS2_BH_CACHED, - main_bm_inode); + ret = ocfs2_read_block(main_bm_inode, lgd_blkno, &group_bh, + OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); goto out_unlock; diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index bb5ff8939bf..82d986bff7f 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -150,8 +150,7 @@ int ocfs2_refresh_slot_info(struct ocfs2_super *osb) * be !NULL. Thus, ocfs2_read_blocks() will ignore blocknr. If * this is not true, the read of -1 (UINT64_MAX) will fail. */ - ret = ocfs2_read_blocks(osb, -1, si->si_blocks, si->si_bh, 0, - si->si_inode); + ret = ocfs2_read_blocks(si->si_inode, -1, si->si_blocks, si->si_bh, 0); if (ret == 0) { spin_lock(&osb->osb_lock); ocfs2_update_slot_info(si); @@ -404,7 +403,7 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb, (unsigned long long)blkno); bh = NULL; /* Acquire a fresh bh */ - status = ocfs2_read_block(osb, blkno, &bh, 0, si->si_inode); + status = ocfs2_read_block(si->si_inode, blkno, &bh, 0); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 08d8844a3c2..f0056b7d435 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -1172,8 +1172,8 @@ static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, struct ocfs2_group_desc *gd; struct inode *alloc_inode = ac->ac_inode; - ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno, - &group_bh, OCFS2_BH_CACHED, alloc_inode); + ret = ocfs2_read_block(alloc_inode, gd_blkno, + &group_bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); return ret; @@ -1242,9 +1242,9 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, bits_wanted, chain, (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno); - status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), + status = ocfs2_read_block(alloc_inode, le64_to_cpu(cl->cl_recs[chain].c_blkno), - &group_bh, OCFS2_BH_CACHED, alloc_inode); + &group_bh, OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto bail; @@ -1272,9 +1272,9 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, next_group = le64_to_cpu(bg->bg_next_group); prev_group_bh = group_bh; group_bh = NULL; - status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), + status = ocfs2_read_block(alloc_inode, next_group, &group_bh, - OCFS2_BH_CACHED, alloc_inode); + OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto bail; @@ -1777,7 +1777,6 @@ int ocfs2_free_suballoc_bits(handle_t *handle, { int status = 0; u32 tmp_used; - struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb); struct ocfs2_dinode *fe = (struct ocfs2_dinode *) alloc_bh->b_data; struct ocfs2_chain_list *cl = &fe->id2.i_chain; struct buffer_head *group_bh = NULL; @@ -1796,8 +1795,8 @@ int ocfs2_free_suballoc_bits(handle_t *handle, (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count, (unsigned long long)bg_blkno, start_bit); - status = ocfs2_read_block(osb, bg_blkno, &group_bh, OCFS2_BH_CACHED, - alloc_inode); + status = ocfs2_read_block(alloc_inode, bg_blkno, &group_bh, + OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index c6c94b55774..8788dc26316 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c @@ -84,11 +84,10 @@ static char *ocfs2_fast_symlink_getlink(struct inode *inode, mlog_entry_void(); - status = ocfs2_read_block(OCFS2_SB(inode->i_sb), + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh, - OCFS2_BH_CACHED, - inode); + OCFS2_BH_CACHED); if (status < 0) { mlog_errno(status); link = ERR_PTR(status); diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 8f522f2f84a..63037bd7892 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -537,9 +537,9 @@ static int ocfs2_xattr_block_list(struct inode *inode, if (!di->i_xattr_loc) return ret; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), - &blk_bh, OCFS2_BH_CACHED, inode); + &blk_bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); return ret; @@ -672,8 +672,8 @@ static int ocfs2_xattr_get_value_outside(struct inode *inode, blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); /* Copy ocfs2_xattr_value */ for (i = 0; i < num_clusters * bpc; i++, blkno++) { - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno, - &bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, blkno, + &bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -764,9 +764,9 @@ static int ocfs2_xattr_block_get(struct inode *inode, memset(&xs->bucket, 0, sizeof(xs->bucket)); - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), - &blk_bh, OCFS2_BH_CACHED, inode); + &blk_bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); return ret; @@ -922,8 +922,8 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode, blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); for (i = 0; i < num_clusters * bpc; i++, blkno++) { - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno, - &bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, blkno, + &bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out_commit; @@ -1514,8 +1514,8 @@ static int ocfs2_xattr_free_block(struct inode *inode, u64 blk, bg_blkno; u16 bit; - ret = ocfs2_read_block(osb, block, &blk_bh, - OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, block, &blk_bh, + OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); goto out; @@ -1773,9 +1773,9 @@ static int ocfs2_xattr_block_find(struct inode *inode, if (!di->i_xattr_loc) return ret; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), - &blk_bh, OCFS2_BH_CACHED, inode); + &blk_bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); return ret; @@ -2216,9 +2216,9 @@ static int ocfs2_find_xe_in_bucket(struct inode *inode, break; } - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_block(inode, header_bh->b_blocknr + block_off, - &name_bh, OCFS2_BH_CACHED, inode); + &name_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); break; @@ -2269,8 +2269,7 @@ static int ocfs2_xattr_bucket_find(struct inode *inode, u32 last_hash; u64 blkno; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), p_blkno, - &bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, p_blkno, &bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -2286,8 +2285,7 @@ static int ocfs2_xattr_bucket_find(struct inode *inode, blkno = p_blkno + bucket * blk_per_bucket; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno, - &bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -2359,10 +2357,9 @@ static int ocfs2_xattr_bucket_find(struct inode *inode, * If we have found the xattr enty, read all the blocks in * this bucket. */ - ret = ocfs2_read_blocks(OCFS2_SB(inode->i_sb), - xs->bucket.bhs[0]->b_blocknr + 1, + ret = ocfs2_read_blocks(inode, xs->bucket.bhs[0]->b_blocknr + 1, blk_per_bucket - 1, &xs->bucket.bhs[1], - OCFS2_BH_CACHED, inode); + OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -2438,9 +2435,8 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode, clusters, blkno); for (i = 0; i < num_buckets; i++, blkno += blk_per_bucket) { - ret = ocfs2_read_blocks(OCFS2_SB(inode->i_sb), - blkno, blk_per_bucket, - bucket.bhs, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, + bucket.bhs, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -2705,10 +2701,10 @@ static int ocfs2_xattr_update_xattr_search(struct inode *inode, if (!xs->not_found) { if (OCFS2_XATTR_BUCKET_SIZE != blocksize) { - ret = ocfs2_read_blocks(OCFS2_SB(inode->i_sb), + ret = ocfs2_read_blocks(inode, xs->bucket.bhs[0]->b_blocknr + 1, blk_per_bucket - 1, &xs->bucket.bhs[1], - OCFS2_BH_CACHED, inode); + OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); return ret; @@ -2913,8 +2909,8 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode, if (!bhs) return -ENOMEM; - ret = ocfs2_read_blocks(osb, blkno, blk_per_bucket, bhs, - OCFS2_BH_CACHED, inode); + ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, bhs, + OCFS2_BH_CACHED); if (ret) goto out; @@ -3114,8 +3110,8 @@ static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode, goto out; } - ret = ocfs2_read_block(osb, prev_blkno, - &old_bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, prev_blkno, + &old_bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); brelse(new_bh); @@ -3168,9 +3164,9 @@ static int ocfs2_read_xattr_bucket(struct inode *inode, u16 i, blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); if (!new) - return ocfs2_read_blocks(OCFS2_SB(inode->i_sb), blkno, + return ocfs2_read_blocks(inode, blkno, blk_per_bucket, bhs, - OCFS2_BH_CACHED, inode); + OCFS2_BH_CACHED); for (i = 0; i < blk_per_bucket; i++) { bhs[i] = sb_getblk(inode->i_sb, blkno + i); @@ -3485,7 +3481,7 @@ static int ocfs2_cp_xattr_cluster(struct inode *inode, ocfs2_journal_dirty(handle, first_bh); /* update the new bucket header. */ - ret = ocfs2_read_block(osb, to_blk_start, &bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, to_blk_start, &bh, OCFS2_BH_CACHED); if (ret < 0) { mlog_errno(ret); goto out; @@ -3872,8 +3868,8 @@ static int ocfs2_add_new_xattr_bucket(struct inode *inode, goto out; } - ret = ocfs2_read_block(osb, p_blkno, - &first_bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, p_blkno, + &first_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -4115,10 +4111,10 @@ static int ocfs2_xattr_set_entry_in_bucket(struct inode *inode, (unsigned long long)xs->bucket.bhs[0]->b_blocknr); if (!xs->bucket.bhs[1]) { - ret = ocfs2_read_blocks(osb, + ret = ocfs2_read_blocks(inode, xs->bucket.bhs[0]->b_blocknr + 1, blk_per_bucket - 1, &xs->bucket.bhs[1], - OCFS2_BH_CACHED, inode); + OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; @@ -4224,8 +4220,8 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode, BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize); value_blk += header_bh->b_blocknr; - ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), value_blk, - &value_bh, OCFS2_BH_CACHED, inode); + ret = ocfs2_read_block(inode, value_blk, + &value_bh, OCFS2_BH_CACHED); if (ret) { mlog_errno(ret); goto out; -- cgit v1.2.3-70-g09d2 From 0fcaa56a2a020dd6f90c202b7084e6f4cbedb6c2 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Thu, 9 Oct 2008 17:20:31 -0700 Subject: ocfs2: Simplify ocfs2_read_block() More than 30 callers of ocfs2_read_block() pass exactly OCFS2_BH_CACHED. Only six pass a different flag set. Rather than have every caller care, let's make ocfs2_read_block() take no flags and always do a cached read. The remaining six places can call ocfs2_read_blocks() directly. Signed-off-by: Joel Becker Signed-off-by: Mark Fasheh --- fs/ocfs2/alloc.c | 25 ++++++++++--------------- fs/ocfs2/aops.c | 6 ++---- fs/ocfs2/buffer_head_io.h | 7 +++---- fs/ocfs2/dir.c | 9 +++------ fs/ocfs2/dlmglue.c | 8 ++------ fs/ocfs2/extent_map.c | 8 +++----- fs/ocfs2/file.c | 7 +++---- fs/ocfs2/inode.c | 4 ++-- fs/ocfs2/journal.c | 2 +- fs/ocfs2/localalloc.c | 8 ++++---- fs/ocfs2/namei.c | 2 +- fs/ocfs2/resize.c | 3 +-- fs/ocfs2/slot_map.c | 2 +- fs/ocfs2/suballoc.c | 11 ++++------- fs/ocfs2/symlink.c | 5 +---- fs/ocfs2/xattr.c | 42 ++++++++++++++---------------------------- 16 files changed, 55 insertions(+), 94 deletions(-) (limited to 'fs/ocfs2/extent_map.c') diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index a164e09491f..0cc2deb9394 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -706,7 +706,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, if (last_eb_blk) { retval = ocfs2_read_block(inode, last_eb_blk, - &eb_bh, OCFS2_BH_CACHED); + &eb_bh); if (retval < 0) { mlog_errno(retval); goto bail; @@ -1176,7 +1176,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb, brelse(bh); bh = NULL; - status = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); + status = ocfs2_read_block(inode, blkno, &bh); if (status < 0) { mlog_errno(status); goto bail; @@ -1540,7 +1540,7 @@ static int __ocfs2_find_path(struct inode *inode, brelse(bh); bh = NULL; - ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, blkno, &bh); if (ret) { mlog_errno(ret); goto out; @@ -4294,9 +4294,7 @@ static int ocfs2_figure_insert_type(struct inode *inode, * ocfs2_figure_insert_type() and ocfs2_add_branch() * may want it later. */ - ret = ocfs2_read_block(inode, - ocfs2_et_get_last_eb_blk(et), &bh, - OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh); if (ret) { mlog_exit(ret); goto out; @@ -4762,9 +4760,8 @@ static int __ocfs2_mark_extent_written(struct inode *inode, if (path->p_tree_depth) { struct ocfs2_extent_block *eb; - ret = ocfs2_read_block(inode, - ocfs2_et_get_last_eb_blk(et), - &last_eb_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), + &last_eb_bh); if (ret) { mlog_exit(ret); goto out; @@ -4921,9 +4918,8 @@ static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et, depth = path->p_tree_depth; if (depth > 0) { - ret = ocfs2_read_block(inode, - ocfs2_et_get_last_eb_blk(et), - &last_eb_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), + &last_eb_bh); if (ret < 0) { mlog_errno(ret); goto out; @@ -5590,8 +5586,7 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, goto bail; } - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh, - OCFS2_BH_CACHED); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); if (status < 0) { iput(inode); mlog_errno(status); @@ -6990,7 +6985,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb, if (fe->id2.i_list.l_tree_depth) { status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk), - &last_eb_bh, OCFS2_BH_CACHED); + &last_eb_bh); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index f232a0e3c30..c22543b3342 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -68,8 +68,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, goto bail; } - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, - &bh, OCFS2_BH_CACHED); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); if (status < 0) { mlog_errno(status); goto bail; @@ -263,8 +262,7 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page) BUG_ON(!PageLocked(page)); BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); - ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh, - OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/buffer_head_io.h b/fs/ocfs2/buffer_head_io.h index fd0d774ac35..a2ef9e5f8bf 100644 --- a/fs/ocfs2/buffer_head_io.h +++ b/fs/ocfs2/buffer_head_io.h @@ -33,8 +33,7 @@ void ocfs2_end_buffer_io_sync(struct buffer_head *bh, static inline int ocfs2_read_block(struct inode *inode, u64 off, - struct buffer_head **bh, - int flags); + struct buffer_head **bh); int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, @@ -54,7 +53,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, #define OCFS2_BH_READAHEAD 8 static inline int ocfs2_read_block(struct inode *inode, u64 off, - struct buffer_head **bh, int flags) + struct buffer_head **bh) { int status = 0; @@ -64,7 +63,7 @@ static inline int ocfs2_read_block(struct inode *inode, u64 off, goto bail; } - status = ocfs2_read_blocks(inode, off, 1, bh, flags); + status = ocfs2_read_blocks(inode, off, 1, bh, OCFS2_BH_CACHED); bail: return status; diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 828437ca91b..459e6b8467d 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -188,8 +188,7 @@ static struct buffer_head *ocfs2_find_entry_id(const char *name, struct ocfs2_dinode *di; struct ocfs2_inline_data *data; - ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh, - OCFS2_BH_CACHED); + ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh); if (ret) { mlog_errno(ret); goto out; @@ -417,8 +416,7 @@ static inline int ocfs2_delete_entry_id(handle_t *handle, struct ocfs2_dinode *di; struct ocfs2_inline_data *data; - ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, - &di_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh); if (ret) { mlog_errno(ret); goto out; @@ -596,8 +594,7 @@ static int ocfs2_dir_foreach_blk_id(struct inode *inode, struct ocfs2_inline_data *data; struct ocfs2_dir_entry *de; - ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, - &di_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); if (ret) { mlog(ML_ERROR, "Unable to read inode block for dir %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 3b2cd0f8721..ec684426034 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -2024,8 +2024,7 @@ static int ocfs2_inode_lock_update(struct inode *inode, } else { /* Boo, we have to go to disk. */ /* read bh, cast, ocfs2_refresh_inode */ - status = ocfs2_read_block(inode, oi->ip_blkno, - bh, OCFS2_BH_CACHED); + status = ocfs2_read_block(inode, oi->ip_blkno, bh); if (status < 0) { mlog_errno(status); goto bail_refresh; @@ -2086,10 +2085,7 @@ static int ocfs2_assign_bh(struct inode *inode, return 0; } - status = ocfs2_read_block(inode, - OCFS2_I(inode)->ip_blkno, - ret_bh, - OCFS2_BH_CACHED); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, ret_bh); if (status < 0) mlog_errno(status); diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index 5b482214bb7..2baedac5823 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -293,8 +293,7 @@ static int ocfs2_last_eb_is_empty(struct inode *inode, struct ocfs2_extent_block *eb; struct ocfs2_extent_list *el; - ret = ocfs2_read_block(inode, last_eb_blk, - &eb_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, last_eb_blk, &eb_bh); if (ret) { mlog_errno(ret); goto out; @@ -384,7 +383,7 @@ static int ocfs2_figure_hole_clusters(struct inode *inode, ret = ocfs2_read_block(inode, le64_to_cpu(eb->h_next_leaf_blk), - &next_eb_bh, OCFS2_BH_CACHED); + &next_eb_bh); if (ret) { mlog_errno(ret); goto out; @@ -631,8 +630,7 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, if (ret == 0) goto out; - ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, - &di_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 7a809be54e8..8d3225a7807 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -545,8 +545,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start, */ BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb)); - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh, - OCFS2_BH_CACHED); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); if (status < 0) { mlog_errno(status); goto leave; @@ -1132,7 +1131,7 @@ static int ocfs2_write_remove_suid(struct inode *inode) struct buffer_head *bh = NULL; struct ocfs2_inode_info *oi = OCFS2_I(inode); - ret = ocfs2_read_block(inode, oi->ip_blkno, &bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, oi->ip_blkno, &bh); if (ret < 0) { mlog_errno(ret); goto out; @@ -1159,7 +1158,7 @@ static int ocfs2_allocate_unwritten_extents(struct inode *inode, if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, - &di_bh, OCFS2_BH_CACHED); + &di_bh); if (ret) { mlog_errno(ret); goto out; diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 6ec31b92a47..c5ee9e3cf80 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -461,7 +461,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, } if (can_lock) - status = ocfs2_read_block(inode, args->fi_blkno, &bh, 0); + status = ocfs2_read_blocks(inode, args->fi_blkno, 1, &bh, 0); else status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh); if (status < 0) { @@ -1165,7 +1165,7 @@ struct buffer_head *ocfs2_bread(struct inode *inode, goto fail; } - tmperr = ocfs2_read_block(inode, p_blkno, &bh, readflags); + tmperr = ocfs2_read_blocks(inode, p_blkno, 1, &bh, readflags); if (tmperr < 0) goto fail; diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 9854fb7315b..d161fe5e3bd 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -1134,7 +1134,7 @@ static int ocfs2_read_journal_inode(struct ocfs2_super *osb, } SET_INODE_JOURNAL(inode); - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh, 0); + status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, bh, 0); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index b77b67bb277..3ea740d15fe 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -248,8 +248,8 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb) goto bail; } - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, - &alloc_bh, 0); + status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, + &alloc_bh, 0); if (status < 0) { mlog_errno(status); goto bail; @@ -459,8 +459,8 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, mutex_lock(&inode->i_mutex); - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, - &alloc_bh, 0); + status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, + &alloc_bh, 0); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index e5fc9345dd3..485a6aa0ad3 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -1754,7 +1754,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, status = ocfs2_read_block(orphan_dir_inode, OCFS2_I(orphan_dir_inode)->ip_blkno, - &orphan_dir_bh, OCFS2_BH_CACHED); + &orphan_dir_bh); if (status < 0) { mlog_errno(status); goto leave; diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c index 92dcd935056..ffd48db229a 100644 --- a/fs/ocfs2/resize.c +++ b/fs/ocfs2/resize.c @@ -332,8 +332,7 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters) lgd_blkno = ocfs2_which_cluster_group(main_bm_inode, first_new_cluster - 1); - ret = ocfs2_read_block(main_bm_inode, lgd_blkno, &group_bh, - OCFS2_BH_CACHED); + ret = ocfs2_read_block(main_bm_inode, lgd_blkno, &group_bh); if (ret < 0) { mlog_errno(ret); goto out_unlock; diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index 82d986bff7f..357d3fe18c3 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -403,7 +403,7 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb, (unsigned long long)blkno); bh = NULL; /* Acquire a fresh bh */ - status = ocfs2_read_block(si->si_inode, blkno, &bh, 0); + status = ocfs2_read_blocks(si->si_inode, blkno, 1, &bh, 0); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index f0056b7d435..c5ff18b46b5 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -1172,8 +1172,7 @@ static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, struct ocfs2_group_desc *gd; struct inode *alloc_inode = ac->ac_inode; - ret = ocfs2_read_block(alloc_inode, gd_blkno, - &group_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(alloc_inode, gd_blkno, &group_bh); if (ret < 0) { mlog_errno(ret); return ret; @@ -1244,7 +1243,7 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, status = ocfs2_read_block(alloc_inode, le64_to_cpu(cl->cl_recs[chain].c_blkno), - &group_bh, OCFS2_BH_CACHED); + &group_bh); if (status < 0) { mlog_errno(status); goto bail; @@ -1273,8 +1272,7 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, prev_group_bh = group_bh; group_bh = NULL; status = ocfs2_read_block(alloc_inode, - next_group, &group_bh, - OCFS2_BH_CACHED); + next_group, &group_bh); if (status < 0) { mlog_errno(status); goto bail; @@ -1795,8 +1793,7 @@ int ocfs2_free_suballoc_bits(handle_t *handle, (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count, (unsigned long long)bg_blkno, start_bit); - status = ocfs2_read_block(alloc_inode, bg_blkno, &group_bh, - OCFS2_BH_CACHED); + status = ocfs2_read_block(alloc_inode, bg_blkno, &group_bh); if (status < 0) { mlog_errno(status); goto bail; diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index 8788dc26316..cbd03dfdc7b 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c @@ -84,10 +84,7 @@ static char *ocfs2_fast_symlink_getlink(struct inode *inode, mlog_entry_void(); - status = ocfs2_read_block(inode, - OCFS2_I(inode)->ip_blkno, - bh, - OCFS2_BH_CACHED); + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh); if (status < 0) { mlog_errno(status); link = ERR_PTR(status); diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 63037bd7892..c25780a70df 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -537,9 +537,7 @@ static int ocfs2_xattr_block_list(struct inode *inode, if (!di->i_xattr_loc) return ret; - ret = ocfs2_read_block(inode, - le64_to_cpu(di->i_xattr_loc), - &blk_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh); if (ret < 0) { mlog_errno(ret); return ret; @@ -672,8 +670,7 @@ static int ocfs2_xattr_get_value_outside(struct inode *inode, blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); /* Copy ocfs2_xattr_value */ for (i = 0; i < num_clusters * bpc; i++, blkno++) { - ret = ocfs2_read_block(inode, blkno, - &bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, blkno, &bh); if (ret) { mlog_errno(ret); goto out; @@ -764,9 +761,7 @@ static int ocfs2_xattr_block_get(struct inode *inode, memset(&xs->bucket, 0, sizeof(xs->bucket)); - ret = ocfs2_read_block(inode, - le64_to_cpu(di->i_xattr_loc), - &blk_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh); if (ret < 0) { mlog_errno(ret); return ret; @@ -922,8 +917,7 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode, blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); for (i = 0; i < num_clusters * bpc; i++, blkno++) { - ret = ocfs2_read_block(inode, blkno, - &bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, blkno, &bh); if (ret) { mlog_errno(ret); goto out_commit; @@ -1514,8 +1508,7 @@ static int ocfs2_xattr_free_block(struct inode *inode, u64 blk, bg_blkno; u16 bit; - ret = ocfs2_read_block(inode, block, &blk_bh, - OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, block, &blk_bh); if (ret < 0) { mlog_errno(ret); goto out; @@ -1773,9 +1766,7 @@ static int ocfs2_xattr_block_find(struct inode *inode, if (!di->i_xattr_loc) return ret; - ret = ocfs2_read_block(inode, - le64_to_cpu(di->i_xattr_loc), - &blk_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh); if (ret < 0) { mlog_errno(ret); return ret; @@ -2216,9 +2207,8 @@ static int ocfs2_find_xe_in_bucket(struct inode *inode, break; } - ret = ocfs2_read_block(inode, - header_bh->b_blocknr + block_off, - &name_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, header_bh->b_blocknr + block_off, + &name_bh); if (ret) { mlog_errno(ret); break; @@ -2269,7 +2259,7 @@ static int ocfs2_xattr_bucket_find(struct inode *inode, u32 last_hash; u64 blkno; - ret = ocfs2_read_block(inode, p_blkno, &bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, p_blkno, &bh); if (ret) { mlog_errno(ret); goto out; @@ -2285,7 +2275,7 @@ static int ocfs2_xattr_bucket_find(struct inode *inode, blkno = p_blkno + bucket * blk_per_bucket; - ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, blkno, &bh); if (ret) { mlog_errno(ret); goto out; @@ -2898,7 +2888,6 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode, u64 blkno = bucket->bhs[0]->b_blocknr; u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); u16 xh_free_start; - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); size_t blocksize = inode->i_sb->s_blocksize; handle_t *handle; struct buffer_head **bhs; @@ -3110,8 +3099,7 @@ static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode, goto out; } - ret = ocfs2_read_block(inode, prev_blkno, - &old_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, prev_blkno, &old_bh); if (ret < 0) { mlog_errno(ret); brelse(new_bh); @@ -3481,7 +3469,7 @@ static int ocfs2_cp_xattr_cluster(struct inode *inode, ocfs2_journal_dirty(handle, first_bh); /* update the new bucket header. */ - ret = ocfs2_read_block(inode, to_blk_start, &bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, to_blk_start, &bh); if (ret < 0) { mlog_errno(ret); goto out; @@ -3868,8 +3856,7 @@ static int ocfs2_add_new_xattr_bucket(struct inode *inode, goto out; } - ret = ocfs2_read_block(inode, p_blkno, - &first_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, p_blkno, &first_bh); if (ret) { mlog_errno(ret); goto out; @@ -4220,8 +4207,7 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode, BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize); value_blk += header_bh->b_blocknr; - ret = ocfs2_read_block(inode, value_blk, - &value_bh, OCFS2_BH_CACHED); + ret = ocfs2_read_block(inode, value_blk, &value_bh); if (ret) { mlog_errno(ret); goto out; -- cgit v1.2.3-70-g09d2