[Ocfs2-tools-devel] [PATCH v3] debugfs.ocfs2: encode 'M' lockname with generation only for sysfile

piaojun piaojun at huawei.com
Fri Sep 9 00:23:02 PDT 2016


I got the wrong lockname 'M000000000000000001a90276b7f60a' by encoding
the inode of a regular file. So I could not resolve lockres info by
'dlm_locks' command of debugfs.ocfs2. The right lockname should be
'M000000000000000001a90200000000' with no generation at tail. We need
encode 'M' lockname with generation only for sysfile.

Signed-off-by: Jun Piao <piaojun at huawei.com>
---
 debugfs.ocfs2/commands.c | 4 +++-
 libocfs2/lockid.c        | 4 ----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index 3d5518a..4e4ea7f 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -1673,7 +1673,9 @@ static void do_encode_lockres(char **args)
 				blkno);
 			return;
 		}
-		gen = inode->i_generation;
+
+		if (inode->i_flags & OCFS2_SYSTEM_FL)
+			gen = inode->i_generation;
 	}
 
 	ret = ocfs2_encode_lockres(type, blkno, gen, 0, lock);
diff --git a/libocfs2/lockid.c b/libocfs2/lockid.c
index d46e24e..ddc93b2 100644
--- a/libocfs2/lockid.c
+++ b/libocfs2/lockid.c
@@ -65,10 +65,6 @@ errcode_t ocfs2_encode_lockres(enum ocfs2_lock_type type, uint64_t blkno,
 	if (type >= OCFS2_NUM_LOCK_TYPES)
 		return OCFS2_ET_INVALID_LOCKRES;
 
-	blkno = (type == OCFS2_LOCK_TYPE_RENAME) ? 0 : blkno;
-	generation = ((type == OCFS2_LOCK_TYPE_SUPER) ||
-		      (type == OCFS2_LOCK_TYPE_RENAME)) ? 0 : generation;
-
 	if (type != OCFS2_LOCK_TYPE_DENTRY) {
 		snprintf(lockres, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016"PRIx64"%08x",
 			 ocfs2_lock_type_char(type), OCFS2_LOCK_ID_PAD,
-- 
1.8.4.3




More information about the Ocfs2-tools-devel mailing list