All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: present consistent fsid, regardless of arch endianness
@ 2017-10-23 16:23 Jeff Layton
  2017-10-23 16:33 ` Jeff Layton
  2017-10-23 16:49 ` Sage Weil
  0 siblings, 2 replies; 3+ messages in thread
From: Jeff Layton @ 2017-10-23 16:23 UTC (permalink / raw)
  To: zyan; +Cc: sage, idryomov, ceph-devel

From: Jeff Layton <jlayton@redhat.com>

Since its inception, ceph has presented the fsid as an opaque value
without any sort of endianness conversion. This means that the value
presented is different on architectures of different endianness.

While the value that should be stuffed into f_fsid is poorly-defined,
I think it would be best to strive for consistency here between
architectures, and clients (we need to present this properly to the
userland client as well).

Change ceph_statfs to convert the opaque words to host-endian before
doing the xor. The value will change between reboots on big-endian
architectures, but it should not change on little-endian ones.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/ceph/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index e4082afedcb1..fe9fbb3f13f7 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -84,8 +84,9 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_ffree = -1;
 	buf->f_namelen = NAME_MAX;
 
-	/* leave fsid little-endian, regardless of host endianness */
-	fsid = *(u64 *)(&monmap->fsid) ^ *((u64 *)&monmap->fsid + 1);
+	/* Must convert the fsid, for consistent values across arches */
+	fsid = le64_to_cpu(*(__le64 *)(&monmap->fsid)) ^
+	       le64_to_cpu(*((__le64 *)&monmap->fsid + 1));
 	buf->f_fsid.val[0] = fsid & 0xffffffff;
 	buf->f_fsid.val[1] = fsid >> 32;
 
-- 
2.13.6


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

* Re: [PATCH] ceph: present consistent fsid, regardless of arch endianness
  2017-10-23 16:23 [PATCH] ceph: present consistent fsid, regardless of arch endianness Jeff Layton
@ 2017-10-23 16:33 ` Jeff Layton
  2017-10-23 16:49 ` Sage Weil
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2017-10-23 16:33 UTC (permalink / raw)
  To: zyan; +Cc: sage, idryomov, ceph-devel

On Mon, 2017-10-23 at 12:23 -0400, Jeff Layton wrote:
> From: Jeff Layton <jlayton@redhat.com>
> 
> Since its inception, ceph has presented the fsid as an opaque value
> without any sort of endianness conversion. This means that the value
> presented is different on architectures of different endianness.
> 
> While the value that should be stuffed into f_fsid is poorly-defined,
> I think it would be best to strive for consistency here between
> architectures, and clients (we need to present this properly to the
> userland client as well).
> 
> Change ceph_statfs to convert the opaque words to host-endian before
> doing the xor. The value will change between reboots on big-endian
> architectures, but it should not change on little-endian ones.
> 

I should probably have sent this as an RFC, and that last sentence was
poorly worded. Let me try again:

"On an upgrade, a big-endian box may see a different fsid than it did
 before, but little-endian arches should see no change with this patch."


> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  fs/ceph/super.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index e4082afedcb1..fe9fbb3f13f7 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -84,8 +84,9 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
>  	buf->f_ffree = -1;
>  	buf->f_namelen = NAME_MAX;
>  
> -	/* leave fsid little-endian, regardless of host endianness */
> -	fsid = *(u64 *)(&monmap->fsid) ^ *((u64 *)&monmap->fsid + 1);
> +	/* Must convert the fsid, for consistent values across arches */
> +	fsid = le64_to_cpu(*(__le64 *)(&monmap->fsid)) ^
> +	       le64_to_cpu(*((__le64 *)&monmap->fsid + 1));
>  	buf->f_fsid.val[0] = fsid & 0xffffffff;
>  	buf->f_fsid.val[1] = fsid >> 32;
>  

-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH] ceph: present consistent fsid, regardless of arch endianness
  2017-10-23 16:23 [PATCH] ceph: present consistent fsid, regardless of arch endianness Jeff Layton
  2017-10-23 16:33 ` Jeff Layton
@ 2017-10-23 16:49 ` Sage Weil
  1 sibling, 0 replies; 3+ messages in thread
From: Sage Weil @ 2017-10-23 16:49 UTC (permalink / raw)
  To: Jeff Layton; +Cc: zyan, idryomov, ceph-devel

On Mon, 23 Oct 2017, Jeff Layton wrote:
> From: Jeff Layton <jlayton@redhat.com>
> 
> Since its inception, ceph has presented the fsid as an opaque value
> without any sort of endianness conversion. This means that the value
> presented is different on architectures of different endianness.
> 
> While the value that should be stuffed into f_fsid is poorly-defined,
> I think it would be best to strive for consistency here between
> architectures, and clients (we need to present this properly to the
> userland client as well).
> 
> Change ceph_statfs to convert the opaque words to host-endian before
> doing the xor. The value will change between reboots on big-endian
> architectures, but it should not change on little-endian ones.
> 
> Signed-off-by: Jeff Layton <jlayton@redhat.com>

Yeah, sounds good!

Reviewed-by: Sage Weil <sage@redhat.com>

> ---
>  fs/ceph/super.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index e4082afedcb1..fe9fbb3f13f7 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -84,8 +84,9 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
>  	buf->f_ffree = -1;
>  	buf->f_namelen = NAME_MAX;
>  
> -	/* leave fsid little-endian, regardless of host endianness */
> -	fsid = *(u64 *)(&monmap->fsid) ^ *((u64 *)&monmap->fsid + 1);
> +	/* Must convert the fsid, for consistent values across arches */
> +	fsid = le64_to_cpu(*(__le64 *)(&monmap->fsid)) ^
> +	       le64_to_cpu(*((__le64 *)&monmap->fsid + 1));
>  	buf->f_fsid.val[0] = fsid & 0xffffffff;
>  	buf->f_fsid.val[1] = fsid >> 32;
>  
> -- 
> 2.13.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

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

end of thread, other threads:[~2017-10-23 16:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-23 16:23 [PATCH] ceph: present consistent fsid, regardless of arch endianness Jeff Layton
2017-10-23 16:33 ` Jeff Layton
2017-10-23 16:49 ` Sage Weil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.