linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfsd/blocklayout: Make sure calculate signature/designator length aligned
@ 2016-07-14  4:01 Kinglong Mee
  2016-07-14 18:51 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: Kinglong Mee @ 2016-07-14  4:01 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: linux-nfs, Kinglong Mee


Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfsd/blocklayoutxdr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/blocklayoutxdr.c b/fs/nfsd/blocklayoutxdr.c
index 6c3b316..d72467e 100644
--- a/fs/nfsd/blocklayoutxdr.c
+++ b/fs/nfsd/blocklayoutxdr.c
@@ -43,7 +43,7 @@ nfsd4_block_encode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)
 
 	switch (b->type) {
 	case PNFS_BLOCK_VOLUME_SIMPLE:
-		len = 4 + 4 + 8 + 4 + b->simple.sig_len;
+		len = 4 + 4 + 8 + 4 + (XDR_QUADLEN(b->simple.sig_len) << 2);
 		p = xdr_reserve_space(xdr, len);
 		if (!p)
 			return -ETOOSMALL;
@@ -54,7 +54,7 @@ nfsd4_block_encode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)
 		p = xdr_encode_opaque(p, b->simple.sig, b->simple.sig_len);
 		break;
 	case PNFS_BLOCK_VOLUME_SCSI:
-		len = 4 + 4 + 4 + 4 + b->scsi.designator_len + 8;
+		len = 4 + 4 + 4 + 4 + (XDR_QUADLEN(b->scsi.designator_len) << 2) + 8;
 		p = xdr_reserve_space(xdr, len);
 		if (!p)
 			return -ETOOSMALL;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfsd/blocklayout: Make sure calculate signature/designator length aligned
  2016-07-14  4:01 [PATCH] nfsd/blocklayout: Make sure calculate signature/designator length aligned Kinglong Mee
@ 2016-07-14 18:51 ` J. Bruce Fields
  0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2016-07-14 18:51 UTC (permalink / raw)
  To: Kinglong Mee; +Cc: linux-nfs

Looks to me like sig_len and designator_len can only be multiples of 4,
so there's no change in behavior here.

But, it's probably safer to do this anyway.  I'll apply with a note in
the changelog.

--b.

On Thu, Jul 14, 2016 at 12:01:17PM +0800, Kinglong Mee wrote:
> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  fs/nfsd/blocklayoutxdr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/blocklayoutxdr.c b/fs/nfsd/blocklayoutxdr.c
> index 6c3b316..d72467e 100644
> --- a/fs/nfsd/blocklayoutxdr.c
> +++ b/fs/nfsd/blocklayoutxdr.c
> @@ -43,7 +43,7 @@ nfsd4_block_encode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)
>  
>  	switch (b->type) {
>  	case PNFS_BLOCK_VOLUME_SIMPLE:
> -		len = 4 + 4 + 8 + 4 + b->simple.sig_len;
> +		len = 4 + 4 + 8 + 4 + (XDR_QUADLEN(b->simple.sig_len) << 2);
>  		p = xdr_reserve_space(xdr, len);
>  		if (!p)
>  			return -ETOOSMALL;
> @@ -54,7 +54,7 @@ nfsd4_block_encode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)
>  		p = xdr_encode_opaque(p, b->simple.sig, b->simple.sig_len);
>  		break;
>  	case PNFS_BLOCK_VOLUME_SCSI:
> -		len = 4 + 4 + 4 + 4 + b->scsi.designator_len + 8;
> +		len = 4 + 4 + 4 + 4 + (XDR_QUADLEN(b->scsi.designator_len) << 2) + 8;
>  		p = xdr_reserve_space(xdr, len);
>  		if (!p)
>  			return -ETOOSMALL;
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-14 18:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-14  4:01 [PATCH] nfsd/blocklayout: Make sure calculate signature/designator length aligned Kinglong Mee
2016-07-14 18:51 ` J. Bruce Fields

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).