Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide
[deliverable/linux.git] / fs / ceph / dir.c
index fd11fb231a2ea796e86eae933265a488ad6774e5..fadc243dfb284b90a63961f4a48c372f483c1142 100644 (file)
@@ -38,7 +38,7 @@ int ceph_init_dentry(struct dentry *dentry)
        if (dentry->d_fsdata)
                return 0;
 
-       di = kmem_cache_alloc(ceph_dentry_cachep, GFP_KERNEL | __GFP_ZERO);
+       di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
        if (!di)
                return -ENOMEM;          /* oh well */
 
@@ -68,23 +68,6 @@ out_unlock:
        return 0;
 }
 
-struct inode *ceph_get_dentry_parent_inode(struct dentry *dentry)
-{
-       struct inode *inode = NULL;
-
-       if (!dentry)
-               return NULL;
-
-       spin_lock(&dentry->d_lock);
-       if (!IS_ROOT(dentry)) {
-               inode = d_inode(dentry->d_parent);
-               ihold(inode);
-       }
-       spin_unlock(&dentry->d_lock);
-       return inode;
-}
-
-
 /*
  * for readdir, we encode the directory frag and offset within that
  * frag into f_pos.
@@ -624,6 +607,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
        struct ceph_mds_client *mdsc = fsc->mdsc;
        struct ceph_mds_request *req;
        int op;
+       int mask;
        int err;
 
        dout("lookup %p dentry %p '%pd'\n",
@@ -666,8 +650,12 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
                return ERR_CAST(req);
        req->r_dentry = dget(dentry);
        req->r_num_caps = 2;
-       /* we only need inode linkage */
-       req->r_args.getattr.mask = cpu_to_le32(CEPH_STAT_CAP_INODE);
+
+       mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
+       if (ceph_security_xattr_wanted(dir))
+               mask |= CEPH_CAP_XATTR_SHARED;
+       req->r_args.getattr.mask = cpu_to_le32(mask);
+
        req->r_locked_dir = dir;
        err = ceph_mdsc_do_request(mdsc, NULL, req);
        err = ceph_handle_snapdir(req, dentry, err);
@@ -1095,6 +1083,7 @@ static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry)
 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
 {
        int valid = 0;
+       struct dentry *parent;
        struct inode *dir;
 
        if (flags & LOOKUP_RCU)
@@ -1103,7 +1092,8 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
        dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry,
             dentry, d_inode(dentry), ceph_dentry(dentry)->offset);
 
-       dir = ceph_get_dentry_parent_inode(dentry);
+       parent = dget_parent(dentry);
+       dir = d_inode(parent);
 
        /* always trust cached snapped dentries, snapdir dentry */
        if (ceph_snap(dir) != CEPH_NOSNAP) {
@@ -1121,13 +1111,48 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
                        valid = 1;
        }
 
+       if (!valid) {
+               struct ceph_mds_client *mdsc =
+                       ceph_sb_to_client(dir->i_sb)->mdsc;
+               struct ceph_mds_request *req;
+               int op, mask, err;
+
+               op = ceph_snap(dir) == CEPH_SNAPDIR ?
+                       CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_LOOKUP;
+               req = ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS);
+               if (!IS_ERR(req)) {
+                       req->r_dentry = dget(dentry);
+                       req->r_num_caps = 2;
+
+                       mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
+                       if (ceph_security_xattr_wanted(dir))
+                               mask |= CEPH_CAP_XATTR_SHARED;
+                       req->r_args.getattr.mask = mask;
+
+                       req->r_locked_dir = dir;
+                       err = ceph_mdsc_do_request(mdsc, NULL, req);
+                       if (err == 0 || err == -ENOENT) {
+                               if (dentry == req->r_dentry) {
+                                       valid = !d_unhashed(dentry);
+                               } else {
+                                       d_invalidate(req->r_dentry);
+                                       err = -EAGAIN;
+                               }
+                       }
+                       ceph_mdsc_put_request(req);
+                       dout("d_revalidate %p lookup result=%d\n",
+                            dentry, err);
+               }
+       }
+
        dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid");
        if (valid) {
                ceph_dentry_lru_touch(dentry);
        } else {
                ceph_dir_clear_complete(dir);
        }
-       iput(dir);
+
+       dput(parent);
        return valid;
 }
 
This page took 0.038361 seconds and 5 git commands to generate.