Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFSv4.1 support for NFS4_RESULT_PRESERVER_UNLINKED

In 4.1+, the server is allowed to set a flag
NFS4_RESULT_PRESERVE_UNLINKED in reply to the OPEN, that tells
the client that it does not need to do a silly rename of an
opened file when it's being removed.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Olga Kornievskaia and committed by
Trond Myklebust
43245eca 46442b85

+12 -2
+8 -2
fs/nfs/dir.c
··· 1419 1419 if (flags & LOOKUP_REVAL) 1420 1420 goto out_force; 1421 1421 out: 1422 - return (inode->i_nlink == 0) ? -ESTALE : 0; 1422 + if (inode->i_nlink > 0 || 1423 + (inode->i_nlink == 0 && 1424 + test_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(inode)->flags))) 1425 + return 0; 1426 + else 1427 + return -ESTALE; 1423 1428 out_force: 1424 1429 if (flags & LOOKUP_RCU) 1425 1430 return -ECHILD; ··· 2335 2330 2336 2331 trace_nfs_unlink_enter(dir, dentry); 2337 2332 spin_lock(&dentry->d_lock); 2338 - if (d_count(dentry) > 1) { 2333 + if (d_count(dentry) > 1 && !test_bit(NFS_INO_PRESERVE_UNLINKED, 2334 + &NFS_I(d_inode(dentry))->flags)) { 2339 2335 spin_unlock(&dentry->d_lock); 2340 2336 /* Start asynchronous writeout of the inode */ 2341 2337 write_inode_now(d_inode(dentry), 0);
+2
fs/nfs/nfs4proc.c
··· 3050 3050 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); 3051 3051 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK) 3052 3052 set_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags); 3053 + if (opendata->o_res.rflags & NFS4_OPEN_RESULT_PRESERVE_UNLINKED) 3054 + set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags); 3053 3055 3054 3056 dentry = opendata->dentry; 3055 3057 if (d_really_is_negative(dentry)) {
+1
include/linux/nfs_fs.h
··· 277 277 #define NFS_INO_STALE (1) /* possible stale inode */ 278 278 #define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */ 279 279 #define NFS_INO_INVALIDATING (3) /* inode is being invalidated */ 280 + #define NFS_INO_PRESERVE_UNLINKED (4) /* preserve file if removed while open */ 280 281 #define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */ 281 282 #define NFS_INO_FORCE_READDIR (7) /* force readdirplus */ 282 283 #define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */
+1
include/uapi/linux/nfs4.h
··· 45 45 46 46 #define NFS4_OPEN_RESULT_CONFIRM 0x0002 47 47 #define NFS4_OPEN_RESULT_LOCKTYPE_POSIX 0x0004 48 + #define NFS4_OPEN_RESULT_PRESERVE_UNLINKED 0x0008 48 49 #define NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK 0x0020 49 50 50 51 #define NFS4_SHARE_ACCESS_MASK 0x000F