Skip to content

Commit db155b7

Browse files
sbashirochucklever
authored andcommitted
NFSD: Disallow layoutget during grace period
When the server is recovering from a reboot and is in a grace period, any operation that may result in deletion or reallocation of block extents should not be allowed. See RFC 8881, section 18.43.3. If multiple clients write data to the same file, rebooting the server during writing may result in file corruption. In the worst case, the exported XFS may also become corrupted. Observed this behavior while testing pNFS block volume setup. Co-developed-by: Konstantin Evtushenko <[email protected]> Signed-off-by: Konstantin Evtushenko <[email protected]> Signed-off-by: Sergey Bashirov <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 6c15463 commit db155b7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,7 @@ static __be32
24352435
nfsd4_layoutget(struct svc_rqst *rqstp,
24362436
struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
24372437
{
2438+
struct net *net = SVC_NET(rqstp);
24382439
struct nfsd4_layoutget *lgp = &u->layoutget;
24392440
struct svc_fh *current_fh = &cstate->current_fh;
24402441
const struct nfsd4_layout_ops *ops;
@@ -2486,6 +2487,10 @@ nfsd4_layoutget(struct svc_rqst *rqstp,
24862487
if (lgp->lg_seg.length == 0)
24872488
goto out;
24882489

2490+
nfserr = nfserr_grace;
2491+
if (locks_in_grace(net))
2492+
goto out;
2493+
24892494
nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lgp->lg_sid,
24902495
true, lgp->lg_layout_type, &ls);
24912496
if (nfserr) {

0 commit comments

Comments
 (0)