Merge branch 'master' into for-2.6.35
[safe/jmp/linux-2.6] / fs / ceph / dir.c
index 89ce3ba..ea8ee2e 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/spinlock.h>
 #include <linux/fs_struct.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #include "super.h"
@@ -170,11 +171,11 @@ more:
        spin_lock(&inode->i_lock);
        spin_lock(&dcache_lock);
 
+       last = dentry;
+
        if (err < 0)
                goto out_unlock;
 
-       last = dentry;
-
        p = p->prev;
        filp->f_pos++;
 
@@ -288,8 +289,10 @@ more:
                        CEPH_MDS_OP_LSSNAP : CEPH_MDS_OP_READDIR;
 
                /* discard old result, if any */
-               if (fi->last_readdir)
+               if (fi->last_readdir) {
                        ceph_mdsc_put_request(fi->last_readdir);
+                       fi->last_readdir = NULL;
+               }
 
                /* requery frag tree, as the frag topology may have changed */
                frag = ceph_choose_frag(ceph_inode(inode), frag, NULL, NULL);
@@ -309,7 +312,7 @@ more:
                req->r_readdir_offset = fi->next_offset;
                req->r_args.readdir.frag = cpu_to_le32(frag);
                req->r_args.readdir.max_entries = cpu_to_le32(max_entries);
-               req->r_num_caps = max_entries;
+               req->r_num_caps = max_entries + 1;
                err = ceph_mdsc_do_request(mdsc, NULL, req);
                if (err < 0) {
                        ceph_mdsc_put_request(req);
@@ -486,6 +489,7 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
                struct inode *inode = ceph_get_snapdir(parent);
                dout("ENOENT on snapdir %p '%.*s', linking to snapdir %p\n",
                     dentry, dentry->d_name.len, dentry->d_name.name, inode);
+               BUG_ON(!d_unhashed(dentry));
                d_add(dentry, inode);
                err = 0;
        }
@@ -920,8 +924,6 @@ static int dentry_lease_is_valid(struct dentry *dentry)
                                di->lease_renew_after = 0;
                                di->lease_renew_from = jiffies;
                        }
-               } else {
-                       __ceph_mdsc_drop_dentry_lease(dentry);
                }
        }
        spin_unlock(&dentry->d_lock);
@@ -1137,9 +1139,9 @@ void ceph_dentry_lru_add(struct dentry *dn)
 {
        struct ceph_dentry_info *di = ceph_dentry(dn);
        struct ceph_mds_client *mdsc;
-       dout("dentry_lru_add %p %p\t%.*s\n",
-                       di, dn, dn->d_name.len, dn->d_name.name);
 
+       dout("dentry_lru_add %p %p '%.*s'\n", di, dn,
+            dn->d_name.len, dn->d_name.name);
        if (di) {
                mdsc = &ceph_client(dn->d_sb)->mdsc;
                spin_lock(&mdsc->dentry_lru_lock);
@@ -1153,9 +1155,9 @@ void ceph_dentry_lru_touch(struct dentry *dn)
 {
        struct ceph_dentry_info *di = ceph_dentry(dn);
        struct ceph_mds_client *mdsc;
-       dout("dentry_lru_touch %p %p\t%.*s\n",
-                       di, dn, dn->d_name.len, dn->d_name.name);
 
+       dout("dentry_lru_touch %p %p '%.*s'\n", di, dn,
+            dn->d_name.len, dn->d_name.name);
        if (di) {
                mdsc = &ceph_client(dn->d_sb)->mdsc;
                spin_lock(&mdsc->dentry_lru_lock);
@@ -1169,8 +1171,8 @@ void ceph_dentry_lru_del(struct dentry *dn)
        struct ceph_dentry_info *di = ceph_dentry(dn);
        struct ceph_mds_client *mdsc;
 
-       dout("dentry_lru_del %p %p\t%.*s\n",
-                       di, dn, dn->d_name.len, dn->d_name.name);
+       dout("dentry_lru_del %p %p '%.*s'\n", di, dn,
+            dn->d_name.len, dn->d_name.name);
        if (di) {
                mdsc = &ceph_client(dn->d_sb)->mdsc;
                spin_lock(&mdsc->dentry_lru_lock);