nfsd: Fix error cleanup path in nfsd_rename()
authorJan Kara <jack@suse.cz>
Mon, 18 Mar 2024 16:32:09 +0000 (17:32 +0100)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 22 Mar 2024 13:52:00 +0000 (09:52 -0400)
Commit a8b0026847b8 ("rename(): avoid a deadlock in the case of parents
having no common ancestor") added an error bail out path. However this
path does not drop the remount protection that has been acquired. Fix
the cleanup path to properly drop the remount protection.

Fixes: a8b0026847b8 ("rename(): avoid a deadlock in the case of parents having no common ancestor")
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/vfs.c

index 6a4c506038e00d3903908adb22737a3d97a8467f..daf5221ef922606cc378ecc178a8411a7256aaa8 100644 (file)
@@ -1853,7 +1853,7 @@ retry:
        trap = lock_rename(tdentry, fdentry);
        if (IS_ERR(trap)) {
                err = (rqstp->rq_vers == 2) ? nfserr_acces : nfserr_xdev;
-               goto out;
+               goto out_want_write;
        }
        err = fh_fill_pre_attrs(ffhp);
        if (err != nfs_ok)
@@ -1923,6 +1923,7 @@ retry:
        }
 out_unlock:
        unlock_rename(tdentry, fdentry);
+out_want_write:
        fh_drop_write(ffhp);
 
        /*