ceph: all allocation functions should get gfp_mask
[safe/jmp/linux-2.6] / fs / ceph / xattr.c
index 1a48a55..68aeebc 100644 (file)
@@ -3,10 +3,12 @@
 #include "decode.h"
 
 #include <linux/xattr.h>
+#include <linux/slab.h>
 
 static bool ceph_is_valid_xattr(const char *name)
 {
-       return !strncmp(name, XATTR_SECURITY_PREFIX,
+       return !strncmp(name, "ceph.", 5) ||
+              !strncmp(name, XATTR_SECURITY_PREFIX,
                        XATTR_SECURITY_PREFIX_LEN) ||
               !strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) ||
               !strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
@@ -75,14 +77,14 @@ static size_t ceph_vxattrcb_rctime(struct ceph_inode_info *ci, char *val,
 }
 
 static struct ceph_vxattr_cb ceph_dir_vxattrs[] = {
-       { true, "user.ceph.dir.entries", ceph_vxattrcb_entries},
-       { true, "user.ceph.dir.files", ceph_vxattrcb_files},
-       { true, "user.ceph.dir.subdirs", ceph_vxattrcb_subdirs},
-       { true, "user.ceph.dir.rentries", ceph_vxattrcb_rentries},
-       { true, "user.ceph.dir.rfiles", ceph_vxattrcb_rfiles},
-       { true, "user.ceph.dir.rsubdirs", ceph_vxattrcb_rsubdirs},
-       { true, "user.ceph.dir.rbytes", ceph_vxattrcb_rbytes},
-       { true, "user.ceph.dir.rctime", ceph_vxattrcb_rctime},
+       { true, "ceph.dir.entries", ceph_vxattrcb_entries},
+       { true, "ceph.dir.files", ceph_vxattrcb_files},
+       { true, "ceph.dir.subdirs", ceph_vxattrcb_subdirs},
+       { true, "ceph.dir.rentries", ceph_vxattrcb_rentries},
+       { true, "ceph.dir.rfiles", ceph_vxattrcb_rfiles},
+       { true, "ceph.dir.rsubdirs", ceph_vxattrcb_rsubdirs},
+       { true, "ceph.dir.rbytes", ceph_vxattrcb_rbytes},
+       { true, "ceph.dir.rctime", ceph_vxattrcb_rctime},
        { true, NULL, NULL }
 };
 
@@ -106,7 +108,7 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
 }
 
 static struct ceph_vxattr_cb ceph_file_vxattrs[] = {
-       { true, "user.ceph.layout", ceph_vxattrcb_layout},
+       { true, "ceph.layout", ceph_vxattrcb_layout},
        { NULL, NULL }
 };
 
@@ -185,12 +187,6 @@ static int __set_xattr(struct ceph_inode_info *ci,
                ci->i_xattrs.names_size -= xattr->name_len;
                ci->i_xattrs.vals_size -= xattr->val_len;
        }
-       if (!xattr) {
-               pr_err("__set_xattr ENOMEM on %p %llx.%llx xattr %s=%s\n",
-                      &ci->vfs_inode, ceph_vinop(&ci->vfs_inode), name,
-                      xattr->val);
-               return -ENOMEM;
-       }
        ci->i_xattrs.names_size += name_len;
        ci->i_xattrs.vals_size += val_len;
        if (val)
@@ -482,7 +478,8 @@ void __ceph_build_xattrs_blob(struct ceph_inode_info *ci)
                ci->i_xattrs.prealloc_blob->vec.iov_len =
                        dest - ci->i_xattrs.prealloc_blob->vec.iov_base;
 
-               ceph_buffer_put(ci->i_xattrs.blob);
+               if (ci->i_xattrs.blob)
+                       ceph_buffer_put(ci->i_xattrs.blob);
                ci->i_xattrs.blob = ci->i_xattrs.prealloc_blob;
                ci->i_xattrs.prealloc_blob = NULL;
                ci->i_xattrs.dirty = false;
@@ -572,7 +569,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
             ci->i_xattrs.version, ci->i_xattrs.index_version);
 
        if (__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 1) &&
-           (ci->i_xattrs.index_version > ci->i_xattrs.version)) {
+           (ci->i_xattrs.index_version >= ci->i_xattrs.version)) {
                goto list_xattr;
        } else {
                spin_unlock(&inode->i_lock);
@@ -620,7 +617,7 @@ out:
 static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
                              const char *value, size_t size, int flags)
 {
-       struct ceph_client *client = ceph_client(dentry->d_sb);
+       struct ceph_client *client = ceph_sb_to_client(dentry->d_sb);
        struct inode *inode = dentry->d_inode;
        struct ceph_inode_info *ci = ceph_inode(inode);
        struct inode *parent_inode = dentry->d_parent->d_inode;
@@ -639,7 +636,7 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
                        return -ENOMEM;
                err = -ENOMEM;
                for (i = 0; i < nr_pages; i++) {
-                       pages[i] = alloc_page(GFP_NOFS);
+                       pages[i] = __page_cache_alloc(GFP_NOFS);
                        if (!pages[i]) {
                                nr_pages = i;
                                goto out;
@@ -655,8 +652,10 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
        /* do request */
        req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETXATTR,
                                       USE_AUTH_MDS);
-       if (IS_ERR(req))
-               return PTR_ERR(req);
+       if (IS_ERR(req)) {
+               err = PTR_ERR(req);
+               goto out;
+       }
        req->r_inode = igrab(inode);
        req->r_inode_drop = CEPH_CAP_XATTR_SHARED;
        req->r_num_caps = 1;
@@ -743,11 +742,12 @@ retry:
 
                spin_unlock(&inode->i_lock);
                dout(" preaallocating new blob size=%d\n", required_blob_size);
-               blob = ceph_buffer_new_alloc(required_blob_size, GFP_NOFS);
+               blob = ceph_buffer_new(required_blob_size, GFP_NOFS);
                if (!blob)
                        goto out;
                spin_lock(&inode->i_lock);
-               ceph_buffer_put(ci->i_xattrs.prealloc_blob);
+               if (ci->i_xattrs.prealloc_blob)
+                       ceph_buffer_put(ci->i_xattrs.prealloc_blob);
                ci->i_xattrs.prealloc_blob = blob;
                goto retry;
        }
@@ -774,7 +774,7 @@ out:
 
 static int ceph_send_removexattr(struct dentry *dentry, const char *name)
 {
-       struct ceph_client *client = ceph_client(dentry->d_sb);
+       struct ceph_client *client = ceph_sb_to_client(dentry->d_sb);
        struct ceph_mds_client *mdsc = &client->mdsc;
        struct inode *inode = dentry->d_inode;
        struct inode *parent_inode = dentry->d_parent->d_inode;