]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/nfsd/nfs4recover.c
nfsd: Push mnt_want_write() outside of i_mutex
[mirror_ubuntu-jammy-kernel.git] / fs / nfsd / nfs4recover.c
index 5ff0b7b9fc08f22f39cc1f2d83062baceb773bdc..43295d45cc2b553e2afda4d11d7b2d429b8676ef 100644 (file)
@@ -154,6 +154,10 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
        if (status < 0)
                return;
 
+       status = mnt_want_write_file(rec_file);
+       if (status)
+               return;
+
        dir = rec_file->f_path.dentry;
        /* lock the parent */
        mutex_lock(&dir->d_inode->i_mutex);
@@ -173,11 +177,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
                 * as well be forgiving and just succeed silently.
                 */
                goto out_put;
-       status = mnt_want_write_file(rec_file);
-       if (status)
-               goto out_put;
        status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU);
-       mnt_drop_write_file(rec_file);
 out_put:
        dput(dentry);
 out_unlock:
@@ -189,6 +189,7 @@ out_unlock:
                                " (err %d); please check that %s exists"
                                " and is writeable", status,
                                user_recovery_dirname);
+       mnt_drop_write_file(rec_file);
        nfs4_reset_creds(original_cred);
 }