aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-20 21:43:07 -0400
committerMark Fasheh <mfasheh@suse.com>2008-11-10 12:51:46 -0500
commit54f443f4e7265a1333886dbace31cb6eb1991c72 (patch)
tree8fe34fa35399022dcd6d8c8d6e3fdb7df1b18f9f /fs
parenteb6ff2397d1fdfc6a7629c99896338e5b5c508e5 (diff)
ocfs2: Don't repeat ocfs2_xattr_block_find()
ocfs2_xattr_block_get() looks up the xattr in a startlingly familiar way; it's identical to the function ocfs2_xattr_block_find(). Let's just use the later in the former. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/xattr.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index fb450200bc88..74d1faba23bb 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -111,6 +111,10 @@ static int ocfs2_xattr_bucket_get_name_value(struct inode *inode,
111 int *block_off, 111 int *block_off,
112 int *new_offset); 112 int *new_offset);
113 113
114static int ocfs2_xattr_block_find(struct inode *inode,
115 int name_index,
116 const char *name,
117 struct ocfs2_xattr_search *xs);
114static int ocfs2_xattr_index_block_find(struct inode *inode, 118static int ocfs2_xattr_index_block_find(struct inode *inode,
115 struct buffer_head *root_bh, 119 struct buffer_head *root_bh,
116 int name_index, 120 int name_index,
@@ -760,46 +764,20 @@ static int ocfs2_xattr_block_get(struct inode *inode,
760 size_t buffer_size, 764 size_t buffer_size,
761 struct ocfs2_xattr_search *xs) 765 struct ocfs2_xattr_search *xs)
762{ 766{
763 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data;
764 struct buffer_head *blk_bh = NULL;
765 struct ocfs2_xattr_block *xb; 767 struct ocfs2_xattr_block *xb;
766 struct ocfs2_xattr_value_root *xv; 768 struct ocfs2_xattr_value_root *xv;
767 size_t size; 769 size_t size;
768 int ret = -ENODATA, name_offset, name_len, block_off, i; 770 int ret = -ENODATA, name_offset, name_len, block_off, i;
769 771
770 if (!di->i_xattr_loc)
771 return ret;
772
773 memset(&xs->bucket, 0, sizeof(xs->bucket)); 772 memset(&xs->bucket, 0, sizeof(xs->bucket));
774 773
775 ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh); 774 ret = ocfs2_xattr_block_find(inode, name_index, name, xs);
776 if (ret < 0) { 775 if (ret) {
777 mlog_errno(ret); 776 mlog_errno(ret);
778 return ret;
779 }
780
781 xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
782 if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
783 ret = -EIO;
784 goto cleanup; 777 goto cleanup;
785 } 778 }
786 779
787 xs->xattr_bh = blk_bh; 780 xb = (struct ocfs2_xattr_block *)xs->xattr_bh->b_data;
788
789 if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) {
790 xs->header = &xb->xb_attrs.xb_header;
791 xs->base = (void *)xs->header;
792 xs->end = (void *)(blk_bh->b_data) + blk_bh->b_size;
793 xs->here = xs->header->xh_entries;
794
795 ret = ocfs2_xattr_find_entry(name_index, name, xs);
796 } else
797 ret = ocfs2_xattr_index_block_find(inode, blk_bh,
798 name_index,
799 name, xs);
800
801 if (ret)
802 goto cleanup;
803 size = le64_to_cpu(xs->here->xe_value_size); 781 size = le64_to_cpu(xs->here->xe_value_size);
804 if (buffer) { 782 if (buffer) {
805 ret = -ERANGE; 783 ret = -ERANGE;
@@ -838,7 +816,8 @@ cleanup:
838 brelse(xs->bucket.bhs[i]); 816 brelse(xs->bucket.bhs[i]);
839 memset(&xs->bucket, 0, sizeof(xs->bucket)); 817 memset(&xs->bucket, 0, sizeof(xs->bucket));
840 818
841 brelse(blk_bh); 819 brelse(xs->xattr_bh);
820 xs->xattr_bh = NULL;
842 return ret; 821 return ret;
843} 822}
844 823