Skip to contentSkip to conversation

ocfs2: return f_fsid info in ocfs2_statfs()

PATCH New Coly Li 4 participants 9 messages Jan 15, 2009 – Jan 16, 2009 OCFS2

lore
Share & tools
lore

Coly Li

author
#0 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

Currently f_fsid of struct kstatfs returned from ocfs2_statfs() is undefined (at least it should be filled with 0). Since in some conditions, f_fsid value might be used as (f_fsid, ino) pare to uniquely identify a file, ocfs2 should return a defined unique f_fsid value from ocfs2_statfs().

This patch uses uuid_hash as a unique ID to initiate f_fsid value, the 32bits width is enough for ocfs2 membership so far.

---
 fs/ocfs2/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/super.c +2 -0
index 43ed113..fdab98a 100644
@@ -1425,6 +1425,8 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_bavail = buf->f_bfree;
 	buf->f_files = numbits;
 	buf->f_ffree = freebits;
+	buf->f_fsid.val[0] = osb->uuid_hash & 0xFFFFFFFFUL;
+	buf->f_fsid.val[1] = 0;
 
 	brelse(bh);
 
Signature · 2 lines
Coly Li
SuSE Labs
#1 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

Wondering whether this id needs to be endian consistent. For failover nfs setups maybe.

Quoted 26 lines · Coly Li

Currently f_fsid of struct kstatfs returned from ocfs2_statfs() is undefined (at least it should be filled with 0). Since in some conditions, f_fsid value might be used as (f_fsid, ino) pare to uniquely identify a file, ocfs2 should return a defined unique f_fsid value from ocfs2_statfs().

This patch uses uuid_hash as a unique ID to initiate f_fsid value, the 32bits width is enough for ocfs2 membership so far.

---
 fs/ocfs2/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/super.c +2 -0
index 43ed113..fdab98a 100644
@@ -1425,6 +1425,8 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_bavail = buf->f_bfree;
 	buf->f_files = numbits;
 	buf->f_ffree = freebits;
+	buf->f_fsid.val[0] = osb->uuid_hash & 0xFFFFFFFFUL;
+	buf->f_fsid.val[1] = 0;
 
 	brelse(bh);
 
author
#2 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

Sunil Mushran Wrote:

Quoted 2 lines

Wondering whether this id needs to be endian consistent. For failover nfs setups maybe.

IMHO, It is. Because osb->uuid_hash is fetched by:

        osb->uuid_hash = le32_to_cpu(di->id2.i_super.s_uuid_hash);

CMIIW, It should work in nfs failover.

Quoted 34 lines
Quoted 31 lines · Coly Li

Currently f_fsid of struct kstatfs returned from ocfs2_statfs() is undefined (at least it should be
filled with 0). Since in some conditions, f_fsid value might be used as (f_fsid, ino) pare to
uniquely identify a file, ocfs2 should return a defined unique f_fsid value from ocfs2_statfs().

This patch uses uuid_hash as a unique ID to initiate f_fsid value, the 32bits width is enough for
ocfs2 membership so far.

---
 fs/ocfs2/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/super.c +2 -0
index 43ed113..fdab98a 100644
@@ -1425,6 +1425,8 @@ static int ocfs2_statfs(struct dentry *dentry,
 struct kstatfs *buf)
     buf->f_bavail = buf->f_bfree;
     buf->f_files = numbits;
     buf->f_ffree = freebits;
+    buf->f_fsid.val[0] = osb->uuid_hash & 0xFFFFFFFFUL;
+    buf->f_fsid.val[1] = 0;
 
     brelse(bh);
Signature · 2 lines
Coly Li
SuSE Labs
#3 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

It's worse. As far as I can see, the s_uuid_hash is never populated. So we have two problems. The second issue is urgent as we are using it in xattr.

Quoted 47 lines · Coly Li

Sunil Mushran Wrote:

Quoted 3 lines

Wondering whether this id needs to be endian consistent. For failover nfs setups maybe.

IMHO, It is. Because osb->uuid_hash is fetched by:

        osb->uuid_hash = le32_to_cpu(di->id2.i_super.s_uuid_hash);

CMIIW, It should work in nfs failover.

Quoted 34 lines
Quoted 32 lines · Coly Li

Currently f_fsid of struct kstatfs returned from ocfs2_statfs() is undefined (at least it should be
filled with 0). Since in some conditions, f_fsid value might be used as (f_fsid, ino) pare to
uniquely identify a file, ocfs2 should return a defined unique f_fsid value from ocfs2_statfs().

This patch uses uuid_hash as a unique ID to initiate f_fsid value, the 32bits width is enough for
ocfs2 membership so far.

---
 fs/ocfs2/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/super.c +2 -0
index 43ed113..fdab98a 100644
@@ -1425,6 +1425,8 @@ static int ocfs2_statfs(struct dentry *dentry,
 struct kstatfs *buf)
     buf->f_bavail = buf->f_bfree;
     buf->f_files = numbits;
     buf->f_ffree = freebits;
+    buf->f_fsid.val[0] = osb->uuid_hash & 0xFFFFFFFFUL;
+    buf->f_fsid.val[1] = 0;
 
     brelse(bh);
#4 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

Quoted 3 lines · Sunil Mushran

It's worse. As far as I can see, the s_uuid_hash is never populated. So we have two problems. The second issue is urgent as we are using it in xattr.

Well, mkfs.ocfs2/tunefs.ocfs2 is supposed to populate it s_uuid_hash based on the *original* uuid of the file system. We don't dynamically calculate it because uuid might change due to a clone operation, which would then break the hashing of that particular file system.

Since s_uuid_hash is feature specific, I think perhaps we should just use some part of the uuid, which is always populated. For this, I think we could do the same as the o2cb dlm key (which has to also be pretty unique) - crc32_le(uuid).

	--Mark

--
Mark Fasheh

#5 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

Quoted 4 lines · Mark Fasheh

Well, mkfs.ocfs2/tunefs.ocfs2 is supposed to populate it s_uuid_hash based on the *original* uuid of the file system. We don't dynamically calculate it because uuid might change due to a clone operation, which would then break the hashing of that particular file system.

OK. I missed that bit.

Quoted 4 lines

Since s_uuid_hash is feature specific, I think perhaps we should just use some part of the uuid, which is always populated. For this, I think we could do the same as the o2cb dlm key (which has to also be pretty unique) - crc32_le(uuid)

I was thinking the same.

author
#8 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

In reply to Sunil Mushran

Sunil Mushran Wrote:

Quoted 4 lines

It's worse. As far as I can see, the s_uuid_hash is never populated. So we have two problems. The second issue is urgent as we are using it in xattr.

Thanks for pointing out this :)
I have updated the patch and sent out as v4.

Quoted 12 lines
Quoted 11 lines · Coly Li

Sunil Mushran Wrote:

Quoted 3 lines

Wondering whether this id needs to be endian consistent. For failover nfs setups maybe.

IMHO, It is. Because osb->uuid_hash is fetched by:

        osb->uuid_hash = le32_to_cpu(di->id2.i_super.s_uuid_hash);

CMIIW, It should work in nfs failover.

[snip]

Signature · 2 lines
Coly Li
SuSE Labs
author
#7 lore raw

PATCH 1/1 ocfs2: return f_fsid info in ocfs2_statfs()

In reply to Sunil Mushran

Sunil Mushran Wrote:

Quoted 11 lines
Quoted 7 lines · Mark Fasheh

Well, mkfs.ocfs2/tunefs.ocfs2 is supposed to populate it s_uuid_hash based
on the *original* uuid of the file system. We don't dynamically calculate it
because uuid might change due to a clone operation, which would then break
the hashing of that particular file system.

OK. I missed that bit.

Quoted 7 lines
Quoted 5 lines

Since s_uuid_hash is feature specific, I think perhaps we should just use some part of the uuid, which is always populated. For this, I think we could
do the same as the o2cb dlm key (which has to also be pretty unique) - crc32_le(uuid)

I was thinking the same.

Now I use crc32_le(osb->uuid_str) to generate fsid value. osb->uuid_str is string representation of s_uuid. Since uuid_str is byte-by-byte, the f_fsid value should be endian consistent.

Would you please to review the v4 patch once more ?

Thanks for your comments.

Signature · 2 lines
Coly Li
SuSE Labs