[pnfs] [PATCH 1/1] pnfs: Ensure file layout stripe_unit multiple of r/w-size
Benny Halevy
bhalevy at panasas.com
Wed May 14 20:47:38 EDT 2008
On May. 14, 2008, 14:07 -0700, seattleplus at gmail.com wrote:
> From: Dean Hildebrand <dhildeb at rock3.almaden.ibm.com>
>
>
> Signed-off-by: Dean Hildebrand <dhildeb at rock3.almaden.ibm.com>
> ---
> fs/nfs/nfs4filelayout.c | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
> index 89f98a2..d04d808 100644
> --- a/fs/nfs/nfs4filelayout.c
> +++ b/fs/nfs/nfs4filelayout.c
> @@ -412,6 +412,7 @@ filelayout_free_layout(struct pnfs_layout_type *layoutid)
> * is wrong.
> * 2) pattern_offset is ignored and must == 0 which is wrong;
> * 3) the pattern_offset needs to be a mutliple of the stripe unit.
> + * 4) stripe unit is multiple of ds_rsize and ds_wsize
> */
>
> static int
> @@ -421,6 +422,9 @@ filelayout_check_layout(struct pnfs_layout_type *lo,
> struct nfs4_filelayout_segment *fl = LSEG_LD_DATA(lseg);
> struct nfs4_pnfs_dev_item *dev;
> int status = -EINVAL;
> + struct nfs_server *nfss = NFS_SERVER(PNFS_INODE(lo));
> + u64 tmp1, tmp2;
> + u32 rrem, wrem;
>
> dprintk("--> %s\n", __func__);
> dev = nfs4_pnfs_device_item_get(FILE_MT(lo->inode), NFS_FH(lo->inode),
> @@ -444,6 +448,16 @@ filelayout_check_layout(struct pnfs_layout_type *lo,
> __func__, fl->pattern_offset);
> goto out;
> }
> +
> + tmp1 = fl->stripe_unit;
> + tmp2 = fl->stripe_unit;
> + rrem = do_div(tmp1, nfss->ds_rsize);
> + wrem = do_div(tmp2, nfss->ds_wsize);
Is (fl->stripe_unit % nfss->ds_rsize || fl->stripe_unit % nfss->ds_wsize)
that much less efficient?
I'd use do_div as an optimization only if I'm interested both in the
division and modulo results, but if only one of them is needed like in this
case, simple arithmetics are more appropriate.
Benny
> + if (rrem || wrem) {
> + dprintk("%s Stripe unit (%u) not aligned rsize %u wsize %u\n",
> + __func__, fl->stripe_unit, nfss->ds_rsize, nfss->ds_wsize);
> + goto out;
> + }
> status = 0;
> out:
> dprintk("--> %s returns %d\n", __func__, status);
More information about the pNFS
mailing list