ocfs2: drop the unwanted null byte in dentry lock name
PATCH 1/1 ocfs2: drop the unwanted null byte in dentry lock name
Dentry lock name is made up of the type 'N', the parent blkno and its blkno represented as a binary value.
Now there is a null byte between parent blkno and the binary blkno value, so drop it.
--- fs/ocfs2/dlm/dlmdebug.c | 2 +- fs/ocfs2/dlmglue.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/ocfs2/dlm/dlmdebug.c +1 -1
@@ -257,7 +257,7 @@ static int stringify_lockname(const char *lockname, int locklen, char *buf,#define OCFS2_DENTRY_LOCK_INO_START 18if (*lockname =='N' ) {memcpy ((__be64 *)&inode_blkno_be, - (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START ], + (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START -1 ],sizeof (__be64)); out += snprintf(buf + out, len - out, "%.*s%08x", OCFS2_DENTRY_LOCK_INO_START - 1, lockname,
fs/ocfs2/dlmglue.c +2 -2
@@ -586,7 +586,7 @@ static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) {__be64 inode_blkno_be; -memcpy (&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START ], +memcpy (&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START -1 ],sizeof (__be64));return be64_to_cpu (inode_blkno_be);
@@ -631,7 +631,7 @@ void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl,BUG_ON (len != (OCFS2_DENTRY_LOCK_INO_START -1 )); -memcpy (&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START ], &inode_blkno_be, +memcpy (&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START -1 ], &inode_blkno_be,sizeof (__be64)); ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres,
Signature · 1 line
1.8.4.3
PATCH 1/1 ocfs2: drop the unwanted null byte in dentry lock name
Quoted 4 lines · On Wed, 27 Nov 2013 17:05:00 +0800 Joseph Qi <[email protected]> wrote:
Dentry lock name is made up of the type 'N', the parent blkno and its blkno represented as a binary value.
Now there is a null byte between parent blkno and the binary blkno value, so drop it.
Geeze.
What are the runtime effects of this change?
fs/ocfs2/dlm/dlmdebug.c static int stringify_lockname(const char *lockname, int locklen, char *buf, · line 260
Quoted 8 lines
fs/ocfs2/dlm/dlmdebug.c +1
-1@@ -257,7 +257,7 @@ static int stringify_lockname(const char *lockname, int locklen, char *buf,#define OCFS2_DENTRY_LOCK_INO_START 18if (*lockname =='N' ) { memcpy((__be64 *)&inode_blkno_be, - (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START], + (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START - 1],
And what's up with all the CrazyCasting? &inode_blkno_be is *already* __be64* and the second arg to memcpy is `const void *', so the cast there is also unneeded.
fs/ocfs2/dlmglue.c static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) · line 589
Quoted 13 lines
fs/ocfs2/dlm/dlmdebug.c +0
-0sizeof(__be64)); out += snprintf(buf + out, len - out, "%.*s%08x", OCFS2_DENTRY_LOCK_INO_START - 1, lockname,fs/ocfs2/dlmglue.c +1
-1@@ -586,7 +586,7 @@ static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) {__be64 inode_blkno_be; - memcpy(&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], + memcpy(&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START - 1],
Like that.
Quoted 14 lines
fs/ocfs2/dlmglue.c +1
-1sizeof(__be64));return be64_to_cpu (inode_blkno_be);@@ -631,7 +631,7 @@ void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl,BUG_ON (len != (OCFS2_DENTRY_LOCK_INO_START -1 )); -memcpy (&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START ], &inode_blkno_be, +memcpy (&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START -1 ], &inode_blkno_be,sizeof (__be64)); ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres,Signature · 1 line
1.8.4.3
PATCH 1/1 ocfs2: drop the unwanted null byte in dentry lock name
Quoted 11 lines · Andrew Morton
Quoted 4 lines · On Wed, 27 Nov 2013 17:05:00 +0800 Joseph Qi <[email protected]> wrote:
Dentry lock name is made up of the type 'N', the parent blkno and its blkno represented as a binary value.
Now there is a null byte between parent blkno and the binary blkno value, so drop it.Geeze.
What are the runtime effects of this change?
If the null byte exists, it is obviously we cannot print the full dentry lock name using '%s'.
But the fact is, the blkno is stuffed with binary value, it may also contain null bytes, so we still cannot get the full dentry lock name in the message.
Maybe we should also distinguish dentry lock and other lockres when print lock name. But this makes the code malformed.
Quoted 46 lines
fs/ocfs2/dlm/dlmdebug.c static int stringify_lockname(const char *lockname, int locklen, char *buf, · line 260
Quoted 8 lines
fs/ocfs2/dlm/dlmdebug.c +1
-1@@ -257,7 +257,7 @@ static int stringify_lockname(const char *lockname, int locklen, char *buf,#define OCFS2_DENTRY_LOCK_INO_START 18if (*lockname =='N' ) { memcpy((__be64 *)&inode_blkno_be, - (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START], + (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START - 1],And what's up with all the CrazyCasting?
&inode_blkno_beis *already* __be64* and the second arg to memcpy is `const void *', so the cast there is also unneeded.fs/ocfs2/dlmglue.c static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) · line 589
Quoted 13 lines
fs/ocfs2/dlm/dlmdebug.c +0
-0sizeof(__be64)); out += snprintf(buf + out, len - out, "%.*s%08x", OCFS2_DENTRY_LOCK_INO_START - 1, lockname,fs/ocfs2/dlmglue.c +1
-1@@ -586,7 +586,7 @@ static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) {__be64 inode_blkno_be; - memcpy(&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], + memcpy(&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START - 1],Like that.
Quoted 14 lines
fs/ocfs2/dlmglue.c +1
-1sizeof(__be64));return be64_to_cpu (inode_blkno_be);@@ -631,7 +631,7 @@ void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl,BUG_ON (len != (OCFS2_DENTRY_LOCK_INO_START -1 )); -memcpy (&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START ], &inode_blkno_be, +memcpy (&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START -1 ], &inode_blkno_be,sizeof (__be64)); ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres,Signature · 1 line
1.8.4.3.
PATCH 1/1 ocfs2: drop the unwanted null byte in dentry lock name
In reply to Andrew MortonQuoted 10 lines · Andrew Morton
Quoted 4 lines · On Wed, 27 Nov 2013 17:05:00 +0800 Joseph Qi <[email protected]> wrote:
Dentry lock name is made up of the type 'N', the parent blkno and its blkno represented as a binary value.
Now there is a null byte between parent blkno and the binary blkno value, so drop it.Geeze.
What are the runtime effects of this change?
This will change the over-the-wire protocol, so big NACK for this patch please. Some of the lock names are binary and have been forever now. We have a limited amount of space in the name and some lock types would have names too long if we stringified every field.
--Mark
--
Mark Fasheh
PATCH 1/1 ocfs2: drop the unwanted null byte in dentry lock name
Quoted 10 lines · Mark Fasheh
Quoted 9 lines · Andrew Morton
Quoted 4 lines · On Wed, 27 Nov 2013 17:05:00 +0800 Joseph Qi <[email protected]> wrote:
Dentry lock name is made up of the type 'N', the parent blkno and its blkno represented as a binary value.
Now there is a null byte between parent blkno and the binary blkno value, so drop it.Geeze.
Quoted 8 lines
Quoted 1 line
What are the runtime effects of this change?
This will change the over-the-wire protocol, so big NACK for this patch please. Some of the lock names are binary and have been forever now. We have a limited amount of space in the name and some lock types would have names too long if we stringified every field.
--Mark
What do you mean by change the over-the-wire protocol?
In my opinion, the only thing we should do is to make buildup and parse consistent.
But if the new version is mixed mounted with the old, it may have problem because of the changed protocol.
Quoted 4 lines
--
Mark Fasheh
PATCH 1/1 ocfs2: drop the unwanted null byte in dentry lock name
Quoted 19 lines · Joseph Qi
Quoted 10 lines · Mark Fasheh
Quoted 9 lines · Andrew Morton
Quoted 4 lines · On Wed, 27 Nov 2013 17:05:00 +0800 Joseph Qi <[email protected]> wrote:
Dentry lock name is made up of the type 'N', the parent blkno and its blkno represented as a binary value.
Now there is a null byte between parent blkno and the binary blkno value, so drop it.Geeze.
Quoted 8 lines
Quoted 1 line
What are the runtime effects of this change?
This will change the over-the-wire protocol, so big NACK for this patch please. Some of the lock names are binary and have been forever now. We have a limited amount of space in the name and some lock types would have names too long if we stringified every field.
--Mark
Quoted 5 lines
What do you mean by change the over-the-wire protocol?
In my opinion, the only thing we should do is to make buildup and parse consistent.
But if the new version is mixed mounted with the old, it may have problem because of the changed protocol.
That's exactly what "change the over-the-wire protocol" means - "new" and old versions of the file will not be able to communicate. This is unacceptable and will anger our users.
We don't make changes like that just to clean up fields.
--Mark
--
Mark Fasheh