瀏覽代碼

ceph: do not assume r_old_dentry[_dir] always set together

Do not assume that r_old_dentry implies that r_old_dentry_dir is also
true.  Separate out the ref cleanup and make the debugs dump behave when
it is NULL.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Yan, Zheng <zheng.z.yan@intel.com>
Sage Weil 12 年之前
父節點
當前提交
844d87c332
共有 2 個文件被更改,包括 6 次插入4 次删除
  1. 2 1
      fs/ceph/debugfs.c
  2. 4 3
      fs/ceph/mds_client.c

+ 2 - 1
fs/ceph/debugfs.c

@@ -102,7 +102,8 @@ static int mdsc_show(struct seq_file *s, void *p)
 				path = NULL;
 				path = NULL;
 			spin_lock(&req->r_old_dentry->d_lock);
 			spin_lock(&req->r_old_dentry->d_lock);
 			seq_printf(s, " #%llx/%.*s (%s)",
 			seq_printf(s, " #%llx/%.*s (%s)",
-			   ceph_ino(req->r_old_dentry_dir),
+				   req->r_old_dentry_dir ?
+				   ceph_ino(req->r_old_dentry_dir) : 0,
 				   req->r_old_dentry->d_name.len,
 				   req->r_old_dentry->d_name.len,
 				   req->r_old_dentry->d_name.name,
 				   req->r_old_dentry->d_name.name,
 				   path ? path : "");
 				   path ? path : "");

+ 4 - 3
fs/ceph/mds_client.c

@@ -528,7 +528,9 @@ void ceph_mdsc_release_request(struct kref *kref)
 		iput(req->r_target_inode);
 		iput(req->r_target_inode);
 	if (req->r_dentry)
 	if (req->r_dentry)
 		dput(req->r_dentry);
 		dput(req->r_dentry);
-	if (req->r_old_dentry) {
+	if (req->r_old_dentry)
+		dput(req->r_old_dentry);
+	if (req->r_old_dentry_dir) {
 		/*
 		/*
 		 * track (and drop pins for) r_old_dentry_dir
 		 * track (and drop pins for) r_old_dentry_dir
 		 * separately, since r_old_dentry's d_parent may have
 		 * separately, since r_old_dentry's d_parent may have
@@ -537,7 +539,6 @@ void ceph_mdsc_release_request(struct kref *kref)
 		 */
 		 */
 		ceph_put_cap_refs(ceph_inode(req->r_old_dentry_dir),
 		ceph_put_cap_refs(ceph_inode(req->r_old_dentry_dir),
 				  CEPH_CAP_PIN);
 				  CEPH_CAP_PIN);
-		dput(req->r_old_dentry);
 		iput(req->r_old_dentry_dir);
 		iput(req->r_old_dentry_dir);
 	}
 	}
 	kfree(req->r_path1);
 	kfree(req->r_path1);
@@ -2053,7 +2054,7 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
 		ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN);
 		ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN);
 	if (req->r_locked_dir)
 	if (req->r_locked_dir)
 		ceph_get_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
 		ceph_get_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
-	if (req->r_old_dentry)
+	if (req->r_old_dentry_dir)
 		ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
 		ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
 				  CEPH_CAP_PIN);
 				  CEPH_CAP_PIN);