1 From: Tiger Yang <tiger.yang@oracle.com>
2 Date: Fri, 14 Nov 2008 11:16:53 +0800
3 Subject: ocfs2: add ocfs2_xattr_get_nolock
6 This function does the work of ocfs2_xattr_get under an open lock.
8 Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
9 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
11 fs/ocfs2/xattr.c | 40 ++++++++++++++++++++++++++++------------
12 fs/ocfs2/xattr.h | 2 ++
13 2 files changed, 30 insertions(+), 12 deletions(-)
15 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
16 index 2cab0d6..ba9b870 100644
17 --- a/fs/ocfs2/xattr.c
18 +++ b/fs/ocfs2/xattr.c
19 @@ -925,12 +925,8 @@ cleanup:
25 - * Copy an extended attribute into the buffer provided.
26 - * Buffer is NULL to compute the size of buffer required.
28 -static int ocfs2_xattr_get(struct inode *inode,
29 +int ocfs2_xattr_get_nolock(struct inode *inode,
30 + struct buffer_head *di_bh,
34 @@ -938,7 +934,6 @@ static int ocfs2_xattr_get(struct inode *inode,
37 struct ocfs2_dinode *di = NULL;
38 - struct buffer_head *di_bh = NULL;
39 struct ocfs2_inode_info *oi = OCFS2_I(inode);
40 struct ocfs2_xattr_search xis = {
41 .not_found = -ENODATA,
42 @@ -953,11 +948,6 @@ static int ocfs2_xattr_get(struct inode *inode,
43 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
46 - ret = ocfs2_inode_lock(inode, &di_bh, 0);
51 xis.inode_bh = xbs.inode_bh = di_bh;
52 di = (struct ocfs2_dinode *)di_bh->b_data;
54 @@ -968,6 +958,32 @@ static int ocfs2_xattr_get(struct inode *inode,
55 ret = ocfs2_xattr_block_get(inode, name_index, name, buffer,
57 up_read(&oi->ip_xattr_sem);
64 + * Copy an extended attribute into the buffer provided.
65 + * Buffer is NULL to compute the size of buffer required.
67 +static int ocfs2_xattr_get(struct inode *inode,
74 + struct buffer_head *di_bh = NULL;
76 + ret = ocfs2_inode_lock(inode, &di_bh, 0);
81 + ret = ocfs2_xattr_get_nolock(inode, di_bh, name_index,
82 + name, buffer, buffer_size);
84 ocfs2_inode_unlock(inode, 0);
87 diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
88 index 188ef6b..86aa10f 100644
89 --- a/fs/ocfs2/xattr.h
90 +++ b/fs/ocfs2/xattr.h
91 @@ -43,6 +43,8 @@ extern struct xattr_handler ocfs2_xattr_security_handler;
92 extern struct xattr_handler *ocfs2_xattr_handlers[];
94 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
95 +int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
96 + const char *, void *, size_t);
97 int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
99 int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,