NFSv4.1: allow zero fh array in filelayout decode layout
Subsystems (2)
PATCH 1/2 NFSv4.1: allow zero fh array in filelayout decode layout
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>
cc [email protected] [2.6.39]
--- fs/nfs/nfs4filelayout.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
fs/nfs/nfs4filelayout.c +8 -5
@@ -551,13 +551,16 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, __func__, nfl_util, fl->num_fh, fl->first_stripe_index, fl->pattern_offset); -if (!fl->num_fh) +if (fl->num_fh <0 || fl->num_fh > +max (NFS4_PNFS_MAX_STRIPE_CNT ,NFS4_PNFS_MAX_MULTI_CNT )) goto out_err; - fl->fh_array =kzalloc (fl->num_fh *sizeof (struct nfs_fh *), - gfp_flags); -if (!fl->fh_array) - goto out_err; +if (fl->num_fh >0 ) { + fl->fh_array =kzalloc (fl->num_fh *sizeof (struct nfs_fh *), + gfp_flags); +if (!fl->fh_array) + goto out_err; + }for (i =0 ; i < fl->num_fh; i++) {/* Do we want to use a mempool here? */
Signature · 1 line
1.7.3.1
PATCH 2/2 NFSv4.1: File layout only supports whole file layouts
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>
--- fs/nfs/nfs4filelayout.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
fs/nfs/nfs4filelayout.c +6 -0
@@ -427,6 +427,12 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo,dprintk ("--> %s\n" , __func__); +if (fl->generic_hdr.pls_range.offset !=0 || + fl->generic_hdr.pls_range.length !=NFS4_MAX_UINT64 ) { +dprintk ("%s Only whole file layouts supported. Use MDS.\n" , + __func__); + goto out; + }if (fl->pattern_offset > lgr->range.offset) {dprintk ("%s pattern_offset %lld too large\n" , __func__, fl->pattern_offset);
Signature · 1 line
1.7.3.1
Quoted 13 lines · On 2011-06-13 16:11, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>cc [email protected] [2.6.39]--- fs/nfs/nfs4filelayout.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)fs/nfs/nfs4filelayout.c +0
-0
fs/nfs/nfs4filelayout.c filelayout_decode_layout(struct pnfs_layout_hdr *flo, · line 554
Quoted 5 lines
fs/nfs/nfs4filelayout.c +1
-1@@ -551,13 +551,16 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, __func__, nfl_util, fl->num_fh, fl->first_stripe_index, fl->pattern_offset); -if (!fl->num_fh) + if (fl->num_fh < 0 || fl->num_fh >
num_fh is unsigned so checking for < 0 is not really needed.
Benny
Quoted 16 lines
fs/nfs/nfs4filelayout.c +7
-4+ max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT)) goto out_err; - fl->fh_array =kzalloc (fl->num_fh *sizeof (struct nfs_fh *), - gfp_flags); -if (!fl->fh_array) - goto out_err; +if (fl->num_fh >0 ) { + fl->fh_array =kzalloc (fl->num_fh *sizeof (struct nfs_fh *), + gfp_flags); +if (!fl->fh_array) + goto out_err; + }for (i =0 ; i < fl->num_fh; i++) {/* Do we want to use a mempool here? */