aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTiger Yang <tiger.yang@oracle.com>2008-11-13 22:16:53 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:34:20 -0500
commit4e3e9d027f63488e676bf7700ec515a192e54f69 (patch)
tree5726c86a7460dcb8acbc9effe3236050105495da /fs
parent534eadddc1de8754a227202c0e747af4973f82ce (diff)
ocfs2: add ocfs2_xattr_get_nolock
This function does the work of ocfs2_xattr_get under an open lock. Signed-off-by: Tiger Yang <tiger.yang@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/xattr.c40
-rw-r--r--fs/ocfs2/xattr.h2
2 files changed, 30 insertions, 12 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 2cab0d6615f9..ba9b870a5dda 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -925,12 +925,8 @@ cleanup:
925 return ret; 925 return ret;
926} 926}
927 927
928/* ocfs2_xattr_get() 928int ocfs2_xattr_get_nolock(struct inode *inode,
929 * 929 struct buffer_head *di_bh,
930 * Copy an extended attribute into the buffer provided.
931 * Buffer is NULL to compute the size of buffer required.
932 */
933static int ocfs2_xattr_get(struct inode *inode,
934 int name_index, 930 int name_index,
935 const char *name, 931 const char *name,
936 void *buffer, 932 void *buffer,
@@ -938,7 +934,6 @@ static int ocfs2_xattr_get(struct inode *inode,
938{ 934{
939 int ret; 935 int ret;
940 struct ocfs2_dinode *di = NULL; 936 struct ocfs2_dinode *di = NULL;
941 struct buffer_head *di_bh = NULL;
942 struct ocfs2_inode_info *oi = OCFS2_I(inode); 937 struct ocfs2_inode_info *oi = OCFS2_I(inode);
943 struct ocfs2_xattr_search xis = { 938 struct ocfs2_xattr_search xis = {
944 .not_found = -ENODATA, 939 .not_found = -ENODATA,
@@ -953,11 +948,6 @@ static int ocfs2_xattr_get(struct inode *inode,
953 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) 948 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
954 ret = -ENODATA; 949 ret = -ENODATA;
955 950
956 ret = ocfs2_inode_lock(inode, &di_bh, 0);
957 if (ret < 0) {
958 mlog_errno(ret);
959 return ret;
960 }
961 xis.inode_bh = xbs.inode_bh = di_bh; 951 xis.inode_bh = xbs.inode_bh = di_bh;
962 di = (struct ocfs2_dinode *)di_bh->b_data; 952 di = (struct ocfs2_dinode *)di_bh->b_data;
963 953
@@ -968,6 +958,32 @@ static int ocfs2_xattr_get(struct inode *inode,
968 ret = ocfs2_xattr_block_get(inode, name_index, name, buffer, 958 ret = ocfs2_xattr_block_get(inode, name_index, name, buffer,
969 buffer_size, &xbs); 959 buffer_size, &xbs);
970 up_read(&oi->ip_xattr_sem); 960 up_read(&oi->ip_xattr_sem);
961
962 return ret;
963}
964
965/* ocfs2_xattr_get()
966 *
967 * Copy an extended attribute into the buffer provided.
968 * Buffer is NULL to compute the size of buffer required.
969 */
970static int ocfs2_xattr_get(struct inode *inode,
971 int name_index,
972 const char *name,
973 void *buffer,
974 size_t buffer_size)
975{
976 int ret;
977 struct buffer_head *di_bh = NULL;
978
979 ret = ocfs2_inode_lock(inode, &di_bh, 0);
980 if (ret < 0) {
981 mlog_errno(ret);
982 return ret;
983 }
984 ret = ocfs2_xattr_get_nolock(inode, di_bh, name_index,
985 name, buffer, buffer_size);
986
971 ocfs2_inode_unlock(inode, 0); 987 ocfs2_inode_unlock(inode, 0);
972 988
973 brelse(di_bh); 989 brelse(di_bh);
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
index 188ef6ba6836..86aa10ffe3f3 100644
--- a/fs/ocfs2/xattr.h
+++ b/fs/ocfs2/xattr.h
@@ -43,6 +43,8 @@ extern struct xattr_handler ocfs2_xattr_security_handler;
43extern struct xattr_handler *ocfs2_xattr_handlers[]; 43extern struct xattr_handler *ocfs2_xattr_handlers[];
44 44
45ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); 45ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
46int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
47 const char *, void *, size_t);
46int ocfs2_xattr_set(struct inode *, int, const char *, const void *, 48int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
47 size_t, int); 49 size_t, int);
48int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *, 50int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,