Skip to content

Commit bb0a55b

Browse files
J. Bruce Fieldschucklever
authored andcommitted
nfs: don't allow reexport reclaims
In the reexport case, nfsd is currently passing along locks with the reclaim bit set. The client sends a new lock request, which is granted if there's currently no conflict--even if it's possible a conflicting lock could have been briefly held in the interim. We don't currently have any way to safely grant reclaim, so for now let's just deny them all. I'm doing this by passing the reclaim bit to nfs and letting it fail the call, with the idea that eventually the client might be able to do something more forgiving here. Signed-off-by: J. Bruce Fields <[email protected]> Acked-by: Anna Schumaker <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent b840be2 commit bb0a55b

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

fs/nfs/file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
806806

807807
nfs_inc_stats(inode, NFSIOS_VFSLOCK);
808808

809+
if (fl->fl_flags & FL_RECLAIM)
810+
return -ENOGRACE;
811+
809812
/* No mandatory locks over NFS */
810813
if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
811814
goto out_err;

fs/nfsd/nfs4state.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6903,6 +6903,9 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
69036903
if (!locks_in_grace(net) && lock->lk_reclaim)
69046904
goto out;
69056905

6906+
if (lock->lk_reclaim)
6907+
fl_flags |= FL_RECLAIM;
6908+
69066909
fp = lock_stp->st_stid.sc_file;
69076910
switch (lock->lk_type) {
69086911
case NFS4_READW_LT:

fs/nfsd/nfsproc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ nfserrno (int errno)
881881
{ nfserr_serverfault, -ENFILE },
882882
{ nfserr_io, -EUCLEAN },
883883
{ nfserr_perm, -ENOKEY },
884+
{ nfserr_no_grace, -ENOGRACE},
884885
};
885886
int i;
886887

include/linux/errno.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */
3232
#define EIOCBQUEUED 529 /* iocb queued, will get completion event */
3333
#define ERECALLCONFLICT 530 /* conflict with recalled state */
34+
#define ENOGRACE 531 /* NFS file lock reclaim refused */
3435

3536
#endif

include/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ static inline struct file *get_file(struct file *f)
997997
#define FL_UNLOCK_PENDING 512 /* Lease is being broken */
998998
#define FL_OFDLCK 1024 /* lock is "owned" by struct file */
999999
#define FL_LAYOUT 2048 /* outstanding pNFS layout */
1000+
#define FL_RECLAIM 4096 /* reclaiming from a reboot server */
10001001

10011002
#define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE)
10021003

0 commit comments

Comments
 (0)