ceph: use common helper for aborted dir request invalidation
authorSage Weil <sage@newdream.net>
Fri, 14 May 2010 17:02:57 +0000 (10:02 -0700)
committerSage Weil <sage@newdream.net>
Mon, 17 May 2010 22:25:40 +0000 (15:25 -0700)
We invalidate I_COMPLETE and dentry leases in two places: on aborted mds
request and on request replay.  Use common helper to avoid duplicate code.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/inode.c
fs/ceph/mds_client.c
fs/ceph/mds_client.h

index 1bcf98bd02550f2b7ee125dbe11fc8cf51ee7ed0..a81b8b662c7b42c5ed3dce0aea14e11ec1753da3 100644 (file)
@@ -941,21 +941,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
 
        if (!rinfo->head->is_target && !rinfo->head->is_dentry) {
                dout("fill_trace reply is empty!\n");
-               if (rinfo->head->result == 0 && req->r_locked_dir) {
-                       struct ceph_inode_info *ci =
-                               ceph_inode(req->r_locked_dir);
-                       dout(" clearing %p complete (empty trace)\n",
-                            req->r_locked_dir);
-                       spin_lock(&req->r_locked_dir->i_lock);
-                       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
-                       ci->i_release_count++;
-                       spin_unlock(&req->r_locked_dir->i_lock);
-
-                       if (req->r_dentry)
-                               ceph_invalidate_dentry_lease(req->r_dentry);
-                       if (req->r_old_dentry)
-                               ceph_invalidate_dentry_lease(req->r_old_dentry);
-               }
+               if (rinfo->head->result == 0 && req->r_locked_dir)
+                       ceph_invalidate_dir_request(req);
                return 0;
        }
 
index 40dd437a26a9dfd701cb07dd48ea0351e74f2a73..5c17ab44d02d673416f3033b81133e7a6371eb5d 100644 (file)
@@ -1794,22 +1794,8 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
                mutex_unlock(&req->r_fill_mutex);
 
                if (req->r_locked_dir &&
-                   (req->r_op & CEPH_MDS_OP_WRITE)) {
-                       struct ceph_inode_info *ci =
-                               ceph_inode(req->r_locked_dir);
-
-                       dout("aborted, clearing I_COMPLETE on %p, leases\n",
-                            req->r_locked_dir);
-                       spin_lock(&req->r_locked_dir->i_lock);
-                       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
-                       ci->i_release_count++;
-                       spin_unlock(&req->r_locked_dir->i_lock);
-
-                       if (req->r_dentry)
-                               ceph_invalidate_dentry_lease(req->r_dentry);
-                       if (req->r_old_dentry)
-                               ceph_invalidate_dentry_lease(req->r_old_dentry);
-               }
+                   (req->r_op & CEPH_MDS_OP_WRITE))
+                       ceph_invalidate_dir_request(req);
        } else {
                err = req->r_err;
        }
@@ -1820,6 +1806,27 @@ out:
        return err;
 }
 
+/*
+ * Invalidate dir I_COMPLETE, dentry lease state on an aborted MDS
+ * namespace request.
+ */
+void ceph_invalidate_dir_request(struct ceph_mds_request *req)
+{
+       struct inode *inode = req->r_locked_dir;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       dout("invalidate_dir_request %p (I_COMPLETE, lease(s))\n", inode);
+       spin_lock(&inode->i_lock);
+       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
+       ci->i_release_count++;
+       spin_unlock(&inode->i_lock);
+
+       if (req->r_dentry)
+               ceph_invalidate_dentry_lease(req->r_dentry);
+       if (req->r_old_dentry)
+               ceph_invalidate_dentry_lease(req->r_old_dentry);
+}
+
 /*
  * Handle mds reply.
  *
index 141a265bda750f5bec2c5e002af6444bf01fd538..d9936c4f12122a6a670a198a8a50249d06c27543 100644 (file)
@@ -303,6 +303,8 @@ extern void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc,
                                    struct inode *inode,
                                    struct dentry *dn, int mask);
 
+extern void ceph_invalidate_dir_request(struct ceph_mds_request *req);
+
 extern struct ceph_mds_request *
 ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode);
 extern void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc,