public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: Jim Schutt <jaschut@sandia.gov>
Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] ceph: add missing cpu_to_le32() calls when encoding a reconnect capability
Date: Wed, 15 May 2013 11:43:44 -0500	[thread overview]
Message-ID: <5193BB40.4000501@inktank.com> (raw)
In-Reply-To: <1368635894-114707-3-git-send-email-jaschut@sandia.gov>

On 05/15/2013 11:38 AM, Jim Schutt wrote:
> In his review, Alex Elder mentioned that he hadn't checked that num_fcntl_locks
> and num_flock_locks were properly decoded on the server side, from a le32
> over-the-wire type to a cpu type.  I checked, and AFAICS it is done; those
> interested can consult Locker::_do_cap_update() in src/mds/Locker.cc and
> src/include/encoding.h in the Ceph server code (git://github.com/ceph/ceph).
> 
> I also checked the server side for flock_len decoding, and I believe that
> also happens correctly, by virtue of having been declared __le32 in
> struct ceph_mds_cap_reconnect, in src/include/ceph_fs.h.
> 
> Signed-off-by: Jim Schutt <jaschut@sandia.gov>

Looks good, but I'd like to get someone else to confirm
the other end is doing it right (i.e., expecting little
endian values).

Reviewed-by: Alex Elder <elder@inktank.com>

> ---
>  fs/ceph/locks.c      |    7 +++++--
>  fs/ceph/mds_client.c |    2 +-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
> index ffc86cb..4518313 100644
> --- a/fs/ceph/locks.c
> +++ b/fs/ceph/locks.c
> @@ -206,10 +206,12 @@ int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist,
>  	int err = 0;
>  	int seen_fcntl = 0;
>  	int seen_flock = 0;
> +	__le32 nlocks;
>  
>  	dout("encoding %d flock and %d fcntl locks", num_flock_locks,
>  	     num_fcntl_locks);
> -	err = ceph_pagelist_append(pagelist, &num_fcntl_locks, sizeof(u32));
> +	nlocks = cpu_to_le32(num_fcntl_locks);
> +	err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
>  	if (err)
>  		goto fail;
>  	for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
> @@ -229,7 +231,8 @@ int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist,
>  			goto fail;
>  	}
>  
> -	err = ceph_pagelist_append(pagelist, &num_flock_locks, sizeof(u32));
> +	nlocks = cpu_to_le32(num_flock_locks);
> +	err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
>  	if (err)
>  		goto fail;
>  	for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 4f22671..d9ca152 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -2485,7 +2485,7 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
>  			lock_flocks();
>  			ceph_count_locks(inode, &num_fcntl_locks,
>  					 &num_flock_locks);
> -			rec.v2.flock_len = (2*sizeof(u32) +
> +			rec.v2.flock_len = cpu_to_le32(2*sizeof(u32) +
>  					    (num_fcntl_locks+num_flock_locks) *
>  					    sizeof(struct ceph_filelock));
>  			unlock_flocks();
> 


  reply	other threads:[~2013-05-15 16:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15 16:38 [PATCH v2 0/3] ceph: fix might_sleep while atomic Jim Schutt
2013-05-15 16:38 ` [PATCH v2 1/3] ceph: fix up comment for ceph_count_locks() as to which lock to hold Jim Schutt
2013-05-15 16:42   ` Alex Elder
2013-05-15 16:38 ` [PATCH v2 2/3] ceph: add missing cpu_to_le32() calls when encoding a reconnect capability Jim Schutt
2013-05-15 16:43   ` Alex Elder [this message]
2013-05-16  0:10     ` Sage Weil
2013-05-15 16:38 ` [PATCH v2 3/3] ceph: ceph_pagelist_append might sleep while atomic Jim Schutt
2013-05-15 16:49   ` Alex Elder
2013-05-15 16:53     ` Jim Schutt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5193BB40.4000501@inktank.com \
    --to=elder@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=jaschut@sandia.gov \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox