Skip to content

Commit d6e80d4

Browse files
committed
NFSD: Do the grace period check in ->proc_layoutget
RFC 8881 Section 18.43.3 states: > If the metadata server is in a grace period, and does not persist > layouts and device ID to device address mappings, then it MUST > return NFS4ERR_GRACE (see Section 8.4.2.1). Jeff observed that this suggests the grace period check is better done by the individual layout type implementations, because checking for the server grace period is unnecessary for some layout types. Suggested-by: Jeff Layton <[email protected]> Link: https://lore.kernel.org/linux-nfs/7h5p5ktyptyt37u6jhpbjfd5u6tg44lriqkdc7iz7czeeabrvo@ijgxz27dw4sg/T/#t Signed-off-by: Chuck Lever <[email protected]>
1 parent eafdd7e commit d6e80d4

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

fs/nfsd/blocklayout.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919

2020
static __be32
21-
nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
22-
struct nfsd4_layoutget *args)
21+
nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
22+
const struct svc_fh *fhp, struct nfsd4_layoutget *args)
2323
{
2424
struct nfsd4_layout_seg *seg = &args->lg_seg;
2525
struct super_block *sb = inode->i_sb;
@@ -29,6 +29,9 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
2929
u32 device_generation = 0;
3030
int error;
3131

32+
if (locks_in_grace(SVC_NET(rqstp)))
33+
return nfserr_grace;
34+
3235
if (seg->offset & (block_size - 1)) {
3336
dprintk("pnfsd: I/O misaligned\n");
3437
goto out_layoutunavailable;

fs/nfsd/flexfilelayout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#define NFSDDBG_FACILITY NFSDDBG_PNFS
2121

2222
static __be32
23-
nfsd4_ff_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
24-
struct nfsd4_layoutget *args)
23+
nfsd4_ff_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
24+
const struct svc_fh *fhp, struct nfsd4_layoutget *args)
2525
{
2626
struct nfsd4_layout_seg *seg = &args->lg_seg;
2727
u32 device_generation = 0;

fs/nfsd/nfs4proc.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,6 @@ 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);
24392438
struct nfsd4_layoutget *lgp = &u->layoutget;
24402439
struct svc_fh *current_fh = &cstate->current_fh;
24412440
const struct nfsd4_layout_ops *ops;
@@ -2487,10 +2486,6 @@ nfsd4_layoutget(struct svc_rqst *rqstp,
24872486
if (lgp->lg_seg.length == 0)
24882487
goto out;
24892488

2490-
nfserr = nfserr_grace;
2491-
if (locks_in_grace(net))
2492-
goto out;
2493-
24942489
nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lgp->lg_sid,
24952490
true, lgp->lg_layout_type, &ls);
24962491
if (nfserr) {
@@ -2502,7 +2497,7 @@ nfsd4_layoutget(struct svc_rqst *rqstp,
25022497
if (atomic_read(&ls->ls_stid.sc_file->fi_lo_recalls))
25032498
goto out_put_stid;
25042499

2505-
nfserr = ops->proc_layoutget(d_inode(current_fh->fh_dentry),
2500+
nfserr = ops->proc_layoutget(rqstp, d_inode(current_fh->fh_dentry),
25062501
current_fh, lgp);
25072502
if (nfserr)
25082503
goto out_put_stid;

fs/nfsd/pnfs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ struct nfsd4_layout_ops {
2929
__be32 (*encode_getdeviceinfo)(struct xdr_stream *xdr,
3030
const struct nfsd4_getdeviceinfo *gdevp);
3131

32-
__be32 (*proc_layoutget)(struct inode *, const struct svc_fh *fhp,
33-
struct nfsd4_layoutget *lgp);
32+
__be32 (*proc_layoutget)(struct svc_rqst *rqstp, struct inode *inode,
33+
const struct svc_fh *fhp, struct nfsd4_layoutget *lgp);
3434
__be32 (*encode_layoutget)(struct xdr_stream *xdr,
3535
const struct nfsd4_layoutget *lgp);
3636

0 commit comments

Comments
 (0)