]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ocfs2: add ocfs2_xattr_get_nolock
authorTiger Yang <tiger.yang@oracle.com>
Fri, 14 Nov 2008 03:16:53 +0000 (11:16 +0800)
committerMark Fasheh <mfasheh@suse.com>
Mon, 5 Jan 2009 16:34:20 +0000 (08:34 -0800)
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>
fs/ocfs2/xattr.c
fs/ocfs2/xattr.h

index 2cab0d6615f92457638f4db0e667464c0ba3d865..ba9b870a5dda30fd092c6809f5ee9fd01218ebb4 100644 (file)
@@ -925,12 +925,8 @@ cleanup:
        return ret;
 }
 
-/* ocfs2_xattr_get()
- *
- * Copy an extended attribute into the buffer provided.
- * Buffer is NULL to compute the size of buffer required.
- */
-static int ocfs2_xattr_get(struct inode *inode,
+int ocfs2_xattr_get_nolock(struct inode *inode,
+                          struct buffer_head *di_bh,
                           int name_index,
                           const char *name,
                           void *buffer,
@@ -938,7 +934,6 @@ static int ocfs2_xattr_get(struct inode *inode,
 {
        int ret;
        struct ocfs2_dinode *di = NULL;
-       struct buffer_head *di_bh = NULL;
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
        struct ocfs2_xattr_search xis = {
                .not_found = -ENODATA,
@@ -953,11 +948,6 @@ static int ocfs2_xattr_get(struct inode *inode,
        if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
                ret = -ENODATA;
 
-       ret = ocfs2_inode_lock(inode, &di_bh, 0);
-       if (ret < 0) {
-               mlog_errno(ret);
-               return ret;
-       }
        xis.inode_bh = xbs.inode_bh = di_bh;
        di = (struct ocfs2_dinode *)di_bh->b_data;
 
@@ -968,6 +958,32 @@ static int ocfs2_xattr_get(struct inode *inode,
                ret = ocfs2_xattr_block_get(inode, name_index, name, buffer,
                                            buffer_size, &xbs);
        up_read(&oi->ip_xattr_sem);
+
+       return ret;
+}
+
+/* ocfs2_xattr_get()
+ *
+ * Copy an extended attribute into the buffer provided.
+ * Buffer is NULL to compute the size of buffer required.
+ */
+static int ocfs2_xattr_get(struct inode *inode,
+                          int name_index,
+                          const char *name,
+                          void *buffer,
+                          size_t buffer_size)
+{
+       int ret;
+       struct buffer_head *di_bh = NULL;
+
+       ret = ocfs2_inode_lock(inode, &di_bh, 0);
+       if (ret < 0) {
+               mlog_errno(ret);
+               return ret;
+       }
+       ret = ocfs2_xattr_get_nolock(inode, di_bh, name_index,
+                                    name, buffer, buffer_size);
+
        ocfs2_inode_unlock(inode, 0);
 
        brelse(di_bh);
index 188ef6ba6836f105a0c4bed6561b0e06a2e8690b..86aa10ffe3f37c0db8471dd3444a02c4458d71ca 100644 (file)
@@ -43,6 +43,8 @@ extern struct xattr_handler ocfs2_xattr_security_handler;
 extern struct xattr_handler *ocfs2_xattr_handlers[];
 
 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
+int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
+                          const char *, void *, size_t);
 int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
                    size_t, int);
 int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,