ceph: fix deadlock or deadcode of misusing dget()
[platform/kernel/linux-starfive.git] / fs / ceph / caps.c
index 14215ec..7f7e5f5 100644 (file)
@@ -4780,12 +4780,14 @@ int ceph_encode_dentry_release(void **p, struct dentry *dentry,
                               struct inode *dir,
                               int mds, int drop, int unless)
 {
-       struct dentry *parent = NULL;
        struct ceph_mds_request_release *rel = *p;
        struct ceph_dentry_info *di = ceph_dentry(dentry);
        int force = 0;
        int ret;
 
+       /* This shouldn't happen */
+       BUG_ON(!dir);
+
        /*
         * force an record for the directory caps if we have a dentry lease.
         * this is racy (can't take i_ceph_lock and d_lock together), but it
@@ -4795,14 +4797,9 @@ int ceph_encode_dentry_release(void **p, struct dentry *dentry,
        spin_lock(&dentry->d_lock);
        if (di->lease_session && di->lease_session->s_mds == mds)
                force = 1;
-       if (!dir) {
-               parent = dget(dentry->d_parent);
-               dir = d_inode(parent);
-       }
        spin_unlock(&dentry->d_lock);
 
        ret = ceph_encode_inode_release(p, dir, mds, drop, unless, force);
-       dput(parent);
 
        spin_lock(&dentry->d_lock);
        if (ret && di->lease_session && di->lease_session->s_mds == mds) {