[Ocfs2-tools-devel] [PATCH v2] debugfs.ocfs2: encode lockname with generation only for specific lock types
Joseph Qi
joseph.qi at huawei.com
Thu Sep 8 23:41:31 PDT 2016
Hi Jun,
Please see my comments below.
On 2016/9/9 13:24, piaojun wrote:
> 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
> make lockname corresponding to the kernel code. 'W', 'F', 'T' and 'M'
> lock of sysfile has generation at tail.
>
> Signed-off-by: Jun Piao <piaojun at huawei.com>
> ---
> debugfs.ocfs2/commands.c | 4 +++-
> libocfs2/lockid.c | 6 ++++--
> 2 files changed, 7 insertions(+), 3 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;
Fine, looks good to me.
> }
>
> ret = ocfs2_encode_lockres(type, blkno, gen, 0, lock);
> diff --git a/libocfs2/lockid.c b/libocfs2/lockid.c
> index d46e24e..76e6a9a 100644
> --- a/libocfs2/lockid.c
> +++ b/libocfs2/lockid.c
> @@ -66,8 +66,10 @@ errcode_t ocfs2_encode_lockres(enum ocfs2_lock_type type, uint64_t blkno,
> 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;
> + generation = ((type == OCFS2_LOCK_TYPE_META) ||
> + (type == OCFS2_LOCK_TYPE_RW) ||
> + (type == OCFS2_LOCK_TYPE_FLOCK) ||
> + (type == OCFS2_LOCK_TYPE_REFCOUNT)) ? generation : 0;
I don't think this is necessary. In fact, I'd rather delete the obscure
generation assignment and let caller pass the right value.
Thanks,
Joseph
>
> if (type != OCFS2_LOCK_TYPE_DENTRY) {
> snprintf(lockres, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016"PRIx64"%08x",
>
More information about the Ocfs2-tools-devel
mailing list