ceph: present consistent fsid, regardless of arch endianness
PATCH 1/1 ceph: present consistent fsid, regardless of arch endianness
From: Jeff Layton <[email protected]>
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.
--- fs/ceph/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ceph/super.c +3 -2
@@ -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 ;
Signature · 1 line
2.13.6
Quoted 6 lines · Jeff Layton
From: Jeff Layton <[email protected]>
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.
Quoted 9 lines
While the value that should be stuffed into
f_fsidis 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_statfsto 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."
Quoted 21 lines
Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/ceph/super.c +3
-2@@ -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 ;
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 11 lines · Jeff Layton
From: Jeff Layton <[email protected]>
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_fsidis 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).
Quoted 5 lines
Change
ceph_statfsto 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 <[email protected]>
Yeah, sounds good!
Quoted 29 lines
--- fs/ceph/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/ceph/super.c +3
-2@@ -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 ;Signature · 6 lines
2.13.6 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html