FAILED: patch "[PATCH] NFSD: Define a proc_layoutcommit for the FlexFiles layout" failed to apply to 6.17-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.17-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.17.y
git checkout FETCH_HEAD
git cherry-pick -x 4b47a8601b71ad98833b447d465592d847b4dc77
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025102049-comic-carpentry-952e@gregkh' --subject-prefix 'PATCH 6.17.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4b47a8601b71ad98833b447d465592d847b4dc77 Mon Sep 17 00:00:00 2001
From: Chuck Lever <[email protected]>
Date: Thu, 11 Sep 2025 11:12:06 -0400
Subject: [PATCH] NFSD: Define a proc_layoutcommit for the FlexFiles layout
type
Avoid a crash if a pNFS client should happen to send a LAYOUTCOMMIT operation on a FlexFiles layout.
fs/nfsd/flexfilelayout.c +8 -0
@@ -125,6 +125,13 @@ nfsd4_ff_proc_getdeviceinfo(struct super_block *sb, struct svc_rqst *rqstp,return 0 ; } +static __be32 +nfsd4_ff_proc_layoutcommit (struct inode *inode,struct svc_rqst *rqstp, +struct nfsd4_layoutcommit *lcp) +{ +return nfs_ok; +} +const struct nfsd4_layout_ops ff_layout_ops = { .notify_types =NOTIFY_DEVICEID4_DELETE |NOTIFY_DEVICEID4_CHANGE ,
@@ -133,4 +140,5 @@ const struct nfsd4_layout_ops ff_layout_ops = { .encode_getdeviceinfo = nfsd4_ff_encode_getdeviceinfo, .proc_layoutget = nfsd4_ff_proc_layoutget, .encode_layoutget = nfsd4_ff_encode_layoutget, + .proc_layoutcommit = nfsd4_ff_proc_layoutcommit, };
Sasha Levin
maintainerPATCH 1/3 NFSD: Rework encoding and decoding of nfsd4_deviceid
From: Sergey Bashirov <[email protected]>
[ Upstream commit 832738e4b325b742940761e10487403f9aad13e8 ]
Compilers may optimize the layout of C structures, so we should not rely on sizeof struct and memcpy to encode and decode XDR structures. The byte order of the fields should also be taken into account.
This patch adds the correct functions to handle the deviceid4 structure and removes the pad field, which is currently not used by NFSD, from the runtime state. The server's byte order is preserved because the deviceid4 blob on the wire is only used as a cookie by the client.
Stable-dep-of: 4b47a8601b71 ("NFSD: Define a proc_layoutcommit for the FlexFiles layout type")
--- fs/nfsd/blocklayoutxdr.c | 7 ++----- fs/nfsd/flexfilelayoutxdr.c | 3 +-- fs/nfsd/nfs4layouts.c | 1 - fs/nfsd/nfs4xdr.c | 14 +------------- fs/nfsd/xdr4.h | 36 +++++++++++++++++++++++++++++++++++- 5 files changed, 39 insertions(+), 22 deletions(-)
fs/nfsd/blocklayoutxdr.c +2 -5
@@ -29,8 +29,7 @@ nfsd4_block_encode_layoutget(struct xdr_stream *xdr, *p++ =cpu_to_be32 (len); *p++ =cpu_to_be32 (1 );/* we always return a single extent */ - p =xdr_encode_opaque_fixed (p, &b->vol_id, -sizeof (struct nfsd4_deviceid )); + p =svcxdr_encode_deviceid4 (p, &b->vol_id); p =xdr_encode_hyper (p, b->foff); p =xdr_encode_hyper (p, b->len); p =xdr_encode_hyper (p, b->soff);
@@ -156,9 +155,7 @@ nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,for (i =0 ; i < nr_iomaps; i++) {struct pnfs_block_extent bex; -memcpy (&bex.vol_id, p,sizeof (struct nfsd4_deviceid )); - p +=XDR_QUADLEN (sizeof (struct nfsd4_deviceid )); - + p =svcxdr_decode_deviceid4 (p, &bex.vol_id); p =xdr_decode_hyper (p, &bex.foff);if (bex.foff & (block_size -1 )) { goto fail;
fs/nfsd/flexfilelayoutxdr.c +1 -2
@@ -54,8 +54,7 @@ nfsd4_ff_encode_layoutget(struct xdr_stream *xdr, *p++ =cpu_to_be32 (1 );/* single mirror */ *p++ =cpu_to_be32 (1 );/* single data server */ - p =xdr_encode_opaque_fixed (p, &fl->deviceid, -sizeof (struct nfsd4_deviceid )); + p =svcxdr_encode_deviceid4 (p, &fl->deviceid); *p++ =cpu_to_be32 (1 );/* efficiency */
fs/nfsd/nfs4layouts.c +0 -1
@@ -120,7 +120,6 @@ nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct svc_fh *fhp, id->fsid_idx = fhp->fh_export->ex_devid_map->idx; id->generation = device_generation; - id->pad =0 ;return 0 ; }
fs/nfsd/nfs4xdr.c +1 -13
@@ -588,18 +588,6 @@ nfsd4_decode_state_owner4(struct nfsd4_compoundargs *argp, }#ifdef CONFIG_NFSD_PNFS -static __be32 -nfsd4_decode_deviceid4 (struct nfsd4_compoundargs *argp, -struct nfsd4_deviceid *devid) -{ -__be32 *p; - - p =xdr_inline_decode (argp->xdr,NFS4_DEVICEID4_SIZE ); -if (!p) -return nfserr_bad_xdr; -memcpy (devid, p,sizeof (*devid)); -return nfs_ok; -} static __be32 nfsd4_decode_layoutupdate4(struct nfsd4_compoundargs *argp,
@@ -1784,7 +1772,7 @@ nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp,__be32 status;memset (gdev,0 ,sizeof (*gdev)); - status =nfsd4_decode_deviceid4 (argp, &gdev->gd_devid); + status =nfsd4_decode_deviceid4 (argp->xdr, &gdev->gd_devid);if (status)return status;if (xdr_stream_decode_u32 (argp->xdr, &gdev->gd_layout_type) <0 )
fs/nfsd/xdr4.h +35 -1
@@ -595,9 +595,43 @@ struct nfsd4_reclaim_complete {struct nfsd4_deviceid {u64 fsid_idx;u32 generation; -u32 pad; }; +static inline __be32 * +svcxdr_encode_deviceid4 (__be32 *p,const struct nfsd4_deviceid *devid) +{ +__be64 *q = (__be64 *)p; + + *q = (__force __be64 )devid->fsid_idx; + p +=2 ; + *p++ = (__force __be32 )devid->generation; + *p++ = xdr_zero; +return p; +} + +static inline __be32 * +svcxdr_decode_deviceid4 (__be32 *p,struct nfsd4_deviceid *devid) +{ +__be64 *q = (__be64 *)p; + + devid->fsid_idx = (__force u64)(*q); + p +=2 ; + devid->generation = (__force u32)(*p++); + p++;/* NFSD does not use the remaining octets */ +return p; +} + +static inline __be32 +nfsd4_decode_deviceid4 (struct xdr_stream *xdr,struct nfsd4_deviceid *devid) +{ +__be32 *p =xdr_inline_decode (xdr,NFS4_DEVICEID4_SIZE ); + +if (unlikely (!p)) +return nfserr_bad_xdr; +svcxdr_decode_deviceid4 (p, devid); +return nfs_ok; +} +struct nfsd4_layout_seg {u32 iomode;u64 offset;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/3 NFSD: Implement large extent array support in pNFS
From: Sergey Bashirov <[email protected]>
[ Upstream commit f963cf2b91a30b5614c514f3ad53ca124cb65280 ]
When pNFS client in the block or scsi layout mode sends layoutcommit to MDS, a variable length array of modified extents is supplied within the request. This patch allows the server to accept such extent arrays if they do not fit within single memory page.
The issue can be reproduced when writing to a 1GB file using FIO with O_DIRECT, 4K block and large I/O depth without preallocation of the file. In this case, the server returns NFSERR_BADXDR to the client.
Stable-dep-of: 4b47a8601b71 ("NFSD: Define a proc_layoutcommit for the FlexFiles layout type")
--- fs/nfsd/blocklayout.c | 20 ++++++---- fs/nfsd/blocklayoutxdr.c | 83 +++++++++++++++++++++++++++------------- fs/nfsd/blocklayoutxdr.h | 4 +- fs/nfsd/nfs4proc.c | 2 +- fs/nfsd/nfs4xdr.c | 11 +++--- fs/nfsd/pnfs.h | 1 + fs/nfsd/xdr4.h | 3 +- 7 files changed, 78 insertions(+), 46 deletions(-)
fs/nfsd/blocklayout.c +12 -8
@@ -173,16 +173,18 @@ nfsd4_block_proc_getdeviceinfo(struct super_block *sb, }static __be32 -nfsd4_block_proc_layoutcommit (struct inode *inode, +nfsd4_block_proc_layoutcommit (struct inode *inode,struct svc_rqst *rqstp,struct nfsd4_layoutcommit *lcp) {struct iomap *iomaps;int nr_iomaps;__be32 nfserr; - nfserr =nfsd4_block_decode_layoutupdate (lcp->lc_up_layout, - lcp->lc_up_len, &iomaps, &nr_iomaps, -i_blocksize (inode)); + rqstp->rq_arg = lcp->lc_up_layout; +svcxdr_init_decode (rqstp); + + nfserr =nfsd4_block_decode_layoutupdate (&rqstp->rq_arg_stream, + &iomaps, &nr_iomaps,i_blocksize (inode));if (nfserr != nfs_ok)return nfserr;
@@ -313,16 +315,18 @@ nfsd4_scsi_proc_getdeviceinfo(struct super_block *sb,return nfserrno (nfsd4_block_get_device_info_scsi (sb, clp, gdp)); }static __be32 -nfsd4_scsi_proc_layoutcommit (struct inode *inode, +nfsd4_scsi_proc_layoutcommit (struct inode *inode,struct svc_rqst *rqstp,struct nfsd4_layoutcommit *lcp) {struct iomap *iomaps;int nr_iomaps;__be32 nfserr; - nfserr =nfsd4_scsi_decode_layoutupdate (lcp->lc_up_layout, - lcp->lc_up_len, &iomaps, &nr_iomaps, -i_blocksize (inode)); + rqstp->rq_arg = lcp->lc_up_layout; +svcxdr_init_decode (rqstp); + + nfserr =nfsd4_scsi_decode_layoutupdate (&rqstp->rq_arg_stream, + &iomaps, &nr_iomaps,i_blocksize (inode));if (nfserr != nfs_ok)return nfserr;
fs/nfsd/blocklayoutxdr.c +56 -27
163 lines not on this page · raw message
fs/nfsd/blocklayoutxdr.h +2 -2
@@ -54,9 +54,9 @@ __be32 nfsd4_block_encode_getdeviceinfo(struct xdr_stream *xdr, const struct nfsd4_getdeviceinfo *gdp);__be32 nfsd4_block_encode_layoutget (struct xdr_stream *xdr,const struct nfsd4_layoutget *lgp); -__be32 nfsd4_block_decode_layoutupdate (__be32 *p,u32 len, +__be32 nfsd4_block_decode_layoutupdate (struct xdr_stream *xdr,struct iomap **iomapp,int *nr_iomapsp,u32 block_size); -__be32 nfsd4_scsi_decode_layoutupdate (__be32 *p,u32 len, +__be32 nfsd4_scsi_decode_layoutupdate (struct xdr_stream *xdr,struct iomap **iomapp,int *nr_iomapsp,u32 block_size);#endif /* _NFSD_BLOCKLAYOUTXDR_H */
fs/nfsd/nfs4proc.c +1 -1
@@ -2555,7 +2555,7 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp, lcp->lc_size_chg = false; } - nfserr = ops->proc_layoutcommit (inode, lcp); + nfserr = ops->proc_layoutcommit (inode, rqstp, lcp);nfs4_put_stid (&ls->ls_stid); out:return nfserr;
fs/nfsd/nfs4xdr.c +5 -6
@@ -593,6 +593,8 @@ static __be32 nfsd4_decode_layoutupdate4(struct nfsd4_compoundargs *argp, struct nfsd4_layoutcommit *lcp) { + u32 len; +if (xdr_stream_decode_u32 (argp->xdr, &lcp->lc_layout_type) <0 )return nfserr_bad_xdr;if (lcp->lc_layout_type <LAYOUT_NFSV4_1_FILES )
@@ -600,13 +602,10 @@ nfsd4_decode_layoutupdate4(struct nfsd4_compoundargs *argp,if (lcp->lc_layout_type >=LAYOUT_TYPE_MAX )return nfserr_bad_xdr; -if (xdr_stream_decode_u32 (argp->xdr, &lcp->lc_up_len) <0 ) +if (xdr_stream_decode_u32 (argp->xdr, &len) <0 ) +return nfserr_bad_xdr; +if (!xdr_stream_subsegment (argp->xdr, &lcp->lc_up_layout, len))return nfserr_bad_xdr; -if (lcp->lc_up_len >0 ) { - lcp->lc_up_layout =xdr_inline_decode (argp->xdr, lcp->lc_up_len); -if (!lcp->lc_up_layout) -return nfserr_bad_xdr; - }return nfs_ok; }
fs/nfsd/pnfs.h +1 -0
@@ -35,6 +35,7 @@ struct nfsd4_layout_ops { const struct nfsd4_layoutget *lgp);__be32 (*proc_layoutcommit)(struct inode *inode, +struct svc_rqst *rqstp,struct nfsd4_layoutcommit *lcp); void (*fence_client)(struct nfs4_layout_stateid *ls,
fs/nfsd/xdr4.h +1 -2
@@ -664,8 +664,7 @@ struct nfsd4_layoutcommit {u64 lc_last_wr;/* request */ struct timespec64 lc_mtime;/* request */ u32 lc_layout_type;/* request */ -u32 lc_up_len;/* layout length */ -void *lc_up_layout;/* decoded by callback */ +struct xdr_buf lc_up_layout;/* decoded by callback */ bool lc_size_chg;/* response */ u64 lc_newsize;/* response */ };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 3/3 NFSD: Define a proc_layoutcommit for the FlexFiles layout type
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit 4b47a8601b71ad98833b447d465592d847b4dc77 ]
Avoid a crash if a pNFS client should happen to send a LAYOUTCOMMIT operation on a FlexFiles layout.
--- fs/nfsd/flexfilelayout.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/nfsd/flexfilelayout.c +8 -0
@@ -125,6 +125,13 @@ nfsd4_ff_proc_getdeviceinfo(struct super_block *sb, struct svc_rqst *rqstp,return 0 ; } +static __be32 +nfsd4_ff_proc_layoutcommit (struct inode *inode,struct svc_rqst *rqstp, +struct nfsd4_layoutcommit *lcp) +{ +return nfs_ok; +} +const struct nfsd4_layout_ops ff_layout_ops = { .notify_types =NOTIFY_DEVICEID4_DELETE |NOTIFY_DEVICEID4_CHANGE ,
@@ -133,4 +140,5 @@ const struct nfsd4_layout_ops ff_layout_ops = { .encode_getdeviceinfo = nfsd4_ff_encode_getdeviceinfo, .proc_layoutget = nfsd4_ff_proc_layoutget, .encode_layoutget = nfsd4_ff_encode_layoutget, + .proc_layoutcommit = nfsd4_ff_proc_layoutcommit, };
Signature · 1 line
2.51.0