All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: dump: add some superblock fields display
@ 2023-06-06  3:55 Guo Xuenan via Linux-erofs
  2023-06-06  5:27 ` Gao Xiang
  0 siblings, 1 reply; 6+ messages in thread
From: Guo Xuenan via Linux-erofs @ 2023-06-06  3:55 UTC (permalink / raw)
  To: hsiangkao, chao, linux-erofs; +Cc: jack.qiu

dump.erofs show compression algothrims and sb_exslots,
and update feature information.

th current super block info displayed as follows:
Filesystem magic number:                      0xE0F5E1E2
Filesystem blocks:                            4637
Filesystem inode metadata start block:        0
Filesystem shared xattr metadata start block: 0
Filesystem root nid:                          37
Filesystem compr_algs:                        lz4 lzma
Filesystem sb_extslots:                       0
Filesystem inode count:                       36
Filesystem created:                           Tue Jun  6 10:23:02 2023
Filesystem features:                          sb_csum mtime lz4_0padding compr_cfgs big_pcluster
Filesystem UUID:                              not available

Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
---
 dump/main.c              | 34 +++++++++++++++++++++++++++++++++-
 include/erofs/internal.h |  1 +
 lib/super.c              |  5 +++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/dump/main.c b/dump/main.c
index efbc82b..20e1456 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -93,13 +93,25 @@ struct erofsdump_feature {
 static struct erofsdump_feature feature_lists[] = {
 	{ true, EROFS_FEATURE_COMPAT_SB_CHKSUM, "sb_csum" },
 	{ true, EROFS_FEATURE_COMPAT_MTIME, "mtime" },
-	{ false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "0padding" },
+	{ false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "lz4_0padding" },
+	{ false, EROFS_FEATURE_INCOMPAT_COMPR_CFGS, "compr_cfgs" },
 	{ false, EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER, "big_pcluster" },
 	{ false, EROFS_FEATURE_INCOMPAT_CHUNKED_FILE, "chunked_file" },
 	{ false, EROFS_FEATURE_INCOMPAT_DEVICE_TABLE, "device_table" },
 	{ false, EROFS_FEATURE_INCOMPAT_ZTAILPACKING, "ztailpacking" },
 	{ false, EROFS_FEATURE_INCOMPAT_FRAGMENTS, "fragments" },
 	{ false, EROFS_FEATURE_INCOMPAT_DEDUPE, "dedupe" },
+	{ false, EROFS_FEATURE_INCOMPAT_XATTR_PREFIXES, "xattr_prefixes" },
+};
+
+struct available_alg {
+	int type;
+	const char *name;
+};
+
+static struct available_alg compr_cfgs[] = {
+	{ Z_EROFS_COMPRESSION_LZ4, "lz4" },
+	{ Z_EROFS_COMPRESSION_LZMA, "lzma" },
 };
 
 static int erofsdump_readdir(struct erofs_dir_context *ctx);
@@ -590,6 +602,17 @@ static void erofsdump_print_statistic(void)
 	erofsdump_filetype_distribution(file_types, OTHERFILETYPE);
 }
 
+static void erofsdump_show_comprcfgs(void)
+{
+	int i = 0;
+
+	for (; i < ARRAY_SIZE(compr_cfgs); i++) {
+		if (sbi.available_compr_algs & (1 << compr_cfgs[i].type))
+			fprintf(stdout, "%s ", compr_cfgs[i].name);
+	}
+	fprintf(stdout, "\n");
+}
+
 static void erofsdump_show_superblock(void)
 {
 	time_t time = sbi.build_time;
@@ -609,6 +632,15 @@ static void erofsdump_show_superblock(void)
 	if (erofs_sb_has_fragments() && sbi.packed_nid > 0)
 		fprintf(stdout, "Filesystem packed nid:                        %llu\n",
 			sbi.packed_nid | 0ULL);
+	if (erofs_sb_has_compr_cfgs()) {
+		fprintf(stdout, "Filesystem compr_algs:                        ");
+		erofsdump_show_comprcfgs();
+	} else {
+		fprintf(stdout, "Filesystem lz4_max_dist:                      %u\n",
+		sbi.lz4_max_distance | 0U);
+	}
+	fprintf(stdout, "Filesystem sb_extslots:                       %u\n",
+			sbi.extslots | 0U);
 	fprintf(stdout, "Filesystem inode count:                       %llu\n",
 			sbi.inos | 0ULL);
 	fprintf(stdout, "Filesystem created:                           %s",
diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 370cfac..a404008 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -74,6 +74,7 @@ struct erofs_sb_info {
 	u32 feature_incompat;
 	u64 build_time;
 	u32 build_time_nsec;
+	u8 extslots;
 
 	unsigned char islotbits;
 	unsigned char blkszbits;
diff --git a/lib/super.c b/lib/super.c
index 5f70686..f511b7d 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -105,11 +105,16 @@ int erofs_read_superblock(void)
 	sbi.packed_nid = le64_to_cpu(dsb->packed_nid);
 	sbi.inos = le64_to_cpu(dsb->inos);
 	sbi.checksum = le32_to_cpu(dsb->checksum);
+	sbi.extslots = dsb->sb_extslots;
 
 	sbi.build_time = le64_to_cpu(dsb->build_time);
 	sbi.build_time_nsec = le32_to_cpu(dsb->build_time_nsec);
 
 	memcpy(&sbi.uuid, dsb->uuid, sizeof(dsb->uuid));
+	if (erofs_sb_has_compr_cfgs())
+		sbi.available_compr_algs = le16_to_cpu(dsb->u1.available_compr_algs);
+	else
+		sbi.lz4_max_distance = le16_to_cpu(dsb->u1.lz4_max_distance);
 	return erofs_init_devices(&sbi, dsb);
 }
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: dump: add some superblock fields display
  2023-06-06  3:55 [PATCH] erofs-utils: dump: add some superblock fields display Guo Xuenan via Linux-erofs
@ 2023-06-06  5:27 ` Gao Xiang
  2023-06-06  7:05   ` Guo Xuenan via Linux-erofs
  2023-06-06  7:28   ` Guo Xuenan
  0 siblings, 2 replies; 6+ messages in thread
From: Gao Xiang @ 2023-06-06  5:27 UTC (permalink / raw)
  To: Guo Xuenan, chao, linux-erofs; +Cc: jack.qiu

Hi Xuenan,

On 2023/6/6 11:55, Guo Xuenan wrote:
> dump.erofs show compression algothrims and sb_exslots,

			     ^ algorithms and sb_extslots

> and update feature information.
> 
> th current super block info displayed as follows:

The proposed super block info is shown as below:

> Filesystem magic number:                      0xE0F5E1E2
> Filesystem blocks:                            4637
> Filesystem inode metadata start block:        0
> Filesystem shared xattr metadata start block: 0
> Filesystem root nid:                          37
> Filesystem compr_algs:                        lz4 lzma
> Filesystem sb_extslots:                       0
> Filesystem inode count:                       36
> Filesystem created:                           Tue Jun  6 10:23:02 2023
> Filesystem features:                          sb_csum mtime lz4_0padding compr_cfgs big_pcluster
> Filesystem UUID:                              not available
> 
> Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
> ---
>   dump/main.c              | 34 +++++++++++++++++++++++++++++++++-
>   include/erofs/internal.h |  1 +
>   lib/super.c              |  5 +++++
>   3 files changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/dump/main.c b/dump/main.c
> index efbc82b..20e1456 100644
> --- a/dump/main.c
> +++ b/dump/main.c
> @@ -93,13 +93,25 @@ struct erofsdump_feature {
>   static struct erofsdump_feature feature_lists[] = {
>   	{ true, EROFS_FEATURE_COMPAT_SB_CHKSUM, "sb_csum" },
>   	{ true, EROFS_FEATURE_COMPAT_MTIME, "mtime" },
> -	{ false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "0padding" },
> +	{ false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "lz4_0padding" },

Better to keep it as is (see kernel code.)

> +	{ false, EROFS_FEATURE_INCOMPAT_COMPR_CFGS, "compr_cfgs" },
>   	{ false, EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER, "big_pcluster" },
>   	{ false, EROFS_FEATURE_INCOMPAT_CHUNKED_FILE, "chunked_file" },
>   	{ false, EROFS_FEATURE_INCOMPAT_DEVICE_TABLE, "device_table" },
>   	{ false, EROFS_FEATURE_INCOMPAT_ZTAILPACKING, "ztailpacking" },
>   	{ false, EROFS_FEATURE_INCOMPAT_FRAGMENTS, "fragments" },
>   	{ false, EROFS_FEATURE_INCOMPAT_DEDUPE, "dedupe" },
> +	{ false, EROFS_FEATURE_INCOMPAT_XATTR_PREFIXES, "xattr_prefixes" },
> +};
> +
> +struct available_alg {
> +	int type;
> +	const char *name;
> +};

Could we use lib/compressor.c instead?

Thanks,
Gao Xiang

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: dump: add some superblock fields display
  2023-06-06  5:27 ` Gao Xiang
@ 2023-06-06  7:05   ` Guo Xuenan via Linux-erofs
  2023-06-06  7:28   ` Guo Xuenan
  1 sibling, 0 replies; 6+ messages in thread
From: Guo Xuenan via Linux-erofs @ 2023-06-06  7:05 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs

Hi Xiang,

On 2023/6/6 13:27, Gao Xiang wrote:
> Hi Xuenan,
>
> On 2023/6/6 11:55, Guo Xuenan wrote:
>> dump.erofs show compression algothrims and sb_exslots,
>
>                  ^ algorithms and sb_extslots
>
sorry :P
>> and update feature information.
>>
>> th current super block info displayed as follows:
>
> The proposed super block info is shown as below:
>
>> Filesystem magic number:                      0xE0F5E1E2
>> Filesystem blocks:                            4637
>> Filesystem inode metadata start block:        0
>> Filesystem shared xattr metadata start block: 0
>> Filesystem root nid:                          37
>> Filesystem compr_algs:                        lz4 lzma
>> Filesystem sb_extslots:                       0
>> Filesystem inode count:                       36
>> Filesystem created:                           Tue Jun  6 10:23:02 2023
>> Filesystem features:                          sb_csum mtime 
>> lz4_0padding compr_cfgs big_pcluster
>> Filesystem UUID:                              not available
>>
>> Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
>> ---
>>   dump/main.c              | 34 +++++++++++++++++++++++++++++++++-
>>   include/erofs/internal.h |  1 +
>>   lib/super.c              |  5 +++++
>>   3 files changed, 39 insertions(+), 1 deletion(-)
>>
>> diff --git a/dump/main.c b/dump/main.c
>> index efbc82b..20e1456 100644
>> --- a/dump/main.c
>> +++ b/dump/main.c
>> @@ -93,13 +93,25 @@ struct erofsdump_feature {
>>   static struct erofsdump_feature feature_lists[] = {
>>       { true, EROFS_FEATURE_COMPAT_SB_CHKSUM, "sb_csum" },
>>       { true, EROFS_FEATURE_COMPAT_MTIME, "mtime" },
>> -    { false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "0padding" },
>> +    { false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "lz4_0padding" },
>
> Better to keep it as is (see kernel code.)
>
Okay, will fix it in v2
>> +    { false, EROFS_FEATURE_INCOMPAT_COMPR_CFGS, "compr_cfgs" },
>>       { false, EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER, "big_pcluster" },
>>       { false, EROFS_FEATURE_INCOMPAT_CHUNKED_FILE, "chunked_file" },
>>       { false, EROFS_FEATURE_INCOMPAT_DEVICE_TABLE, "device_table" },
>>       { false, EROFS_FEATURE_INCOMPAT_ZTAILPACKING, "ztailpacking" },
>>       { false, EROFS_FEATURE_INCOMPAT_FRAGMENTS, "fragments" },
>>       { false, EROFS_FEATURE_INCOMPAT_DEDUPE, "dedupe" },
>> +    { false, EROFS_FEATURE_INCOMPAT_XATTR_PREFIXES, "xattr_prefixes" },
>> +};
>> +
>> +struct available_alg {
>> +    int type;
>> +    const char *name;
>> +};
>
> Could we use lib/compressor.c instead?
>
Take a look at the currently implemented interface, compressor.c define
different compressors for mkfs.erofs, but for dump.erofs we don't care
about that much, we only show compression algothrims name  the image

Best regards
Xuenan.
> Thanks,
> Gao Xiang
>

-- 
Guo Xuenan [OS Kernel Lab]
-----------------------------
Email: guoxuenan@huawei.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: dump: add some superblock fields display
  2023-06-06  5:27 ` Gao Xiang
  2023-06-06  7:05   ` Guo Xuenan via Linux-erofs
@ 2023-06-06  7:28   ` Guo Xuenan
  2023-06-06  7:58     ` Gao Xiang
  1 sibling, 1 reply; 6+ messages in thread
From: Guo Xuenan @ 2023-06-06  7:28 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs

Hi Xiang,

On 2023/6/6 13:27, Gao Xiang wrote:
> Hi Xuenan,
>
> On 2023/6/6 11:55, Guo Xuenan wrote:
>> dump.erofs show compression algothrims and sb_exslots,
>
>                  ^ algorithms and sb_extslots
>
sorry :P
>> and update feature information.
>>
>> th current super block info displayed as follows:
>
> The proposed super block info is shown as below:
>
>> Filesystem magic number:                      0xE0F5E1E2
>> Filesystem blocks:                            4637
>> Filesystem inode metadata start block:        0
>> Filesystem shared xattr metadata start block: 0
>> Filesystem root nid:                          37
>> Filesystem compr_algs:                        lz4 lzma
>> Filesystem sb_extslots:                       0
>> Filesystem inode count:                       36
>> Filesystem created:                           Tue Jun  6 10:23:02 2023
>> Filesystem features:                          sb_csum mtime 
>> lz4_0padding compr_cfgs big_pcluster
>> Filesystem UUID:                              not available
>>
>> Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
>> ---
>>   dump/main.c              | 34 +++++++++++++++++++++++++++++++++-
>>   include/erofs/internal.h |  1 +
>>   lib/super.c              |  5 +++++
>>   3 files changed, 39 insertions(+), 1 deletion(-)
>>
>> diff --git a/dump/main.c b/dump/main.c
>> index efbc82b..20e1456 100644
>> --- a/dump/main.c
>> +++ b/dump/main.c
>> @@ -93,13 +93,25 @@ struct erofsdump_feature {
>>   static struct erofsdump_feature feature_lists[] = {
>>       { true, EROFS_FEATURE_COMPAT_SB_CHKSUM, "sb_csum" },
>>       { true, EROFS_FEATURE_COMPAT_MTIME, "mtime" },
>> -    { false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "0padding" },
>> +    { false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "lz4_0padding" },
>
> Better to keep it as is (see kernel code.)
>
Okay, will fix it in v2
>> +    { false, EROFS_FEATURE_INCOMPAT_COMPR_CFGS, "compr_cfgs" },
>>       { false, EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER, "big_pcluster" },
>>       { false, EROFS_FEATURE_INCOMPAT_CHUNKED_FILE, "chunked_file" },
>>       { false, EROFS_FEATURE_INCOMPAT_DEVICE_TABLE, "device_table" },
>>       { false, EROFS_FEATURE_INCOMPAT_ZTAILPACKING, "ztailpacking" },
>>       { false, EROFS_FEATURE_INCOMPAT_FRAGMENTS, "fragments" },
>>       { false, EROFS_FEATURE_INCOMPAT_DEDUPE, "dedupe" },
>> +    { false, EROFS_FEATURE_INCOMPAT_XATTR_PREFIXES, "xattr_prefixes" },
>> +};
>> +
>> +struct available_alg {
>> +    int type;
>> +    const char *name;
>> +};
>
> Could we use lib/compressor.c instead?
>
Take a look at the currently implemented interface, and I notice that
compressor.c define different compressors for mkfs.erofs, but for
dump.erofs we don't need care about that much, we only show compression
  algothrims name of the image. It seems that it cannot be reused.
> Thanks,
> Gao Xiang
>

-- 
Guo Xuenan [OS Kernel Lab]
-----------------------------
Email: guoxuenan@huawei.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: dump: add some superblock fields display
  2023-06-06  7:28   ` Guo Xuenan
@ 2023-06-06  7:58     ` Gao Xiang
  2023-06-06  8:39       ` Guo Xuenan
  0 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2023-06-06  7:58 UTC (permalink / raw)
  To: Guo Xuenan, linux-erofs



On 2023/6/6 15:28, Guo Xuenan wrote:

...

>>> +
>>> +struct available_alg {
>>> +    int type;
>>> +    const char *name;
>>> +};
>>
>> Could we use lib/compressor.c instead?
>>
> Take a look at the currently implemented interface, and I notice that
> compressor.c define different compressors for mkfs.erofs, but for
> dump.erofs we don't need care about that much, we only show compression
>   algothrims name of the image. It seems that it cannot be reused.

Please help add erofsfsck_ prefix to available_cfg like
erofsfsck_available_cfg.

Anyway, that is still not quite clean if you take a look at
erofs_get_compress_algorithm_id() if lib/compress.c.

We could address this later.

Thanks,
Gao Xiang

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs-utils: dump: add some superblock fields display
  2023-06-06  7:58     ` Gao Xiang
@ 2023-06-06  8:39       ` Guo Xuenan
  0 siblings, 0 replies; 6+ messages in thread
From: Guo Xuenan @ 2023-06-06  8:39 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs


On 2023/6/6 15:58, Gao Xiang wrote:
>
>
> On 2023/6/6 15:28, Guo Xuenan wrote:
>
> ...
>
>>>> +
>>>> +struct available_alg {
>>>> +    int type;
>>>> +    const char *name;
>>>> +};
>>>
>>> Could we use lib/compressor.c instead?
>>>
>> Take a look at the currently implemented interface, and I notice that
>> compressor.c define different compressors for mkfs.erofs, but for
>> dump.erofs we don't need care about that much, we only show compression
>>   algothrims name of the image. It seems that it cannot be reused.
>
> Please help add erofsfsck_ prefix to available_cfg like
> erofsfsck_available_cfg.
>
> Anyway, that is still not quite clean if you take a look at
> erofs_get_compress_algorithm_id() if lib/compress.c.
>
Okay, I will  reorganize the code here,  try to address it and send v2 
later.
> We could address this later.
>
> Thanks,
> Gao Xiang

-- 
Guo Xuenan [Confused at thirty]
-----------------------------
Email: guoxuenan@huaweicloud.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-06  8:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06  3:55 [PATCH] erofs-utils: dump: add some superblock fields display Guo Xuenan via Linux-erofs
2023-06-06  5:27 ` Gao Xiang
2023-06-06  7:05   ` Guo Xuenan via Linux-erofs
2023-06-06  7:28   ` Guo Xuenan
2023-06-06  7:58     ` Gao Xiang
2023-06-06  8:39       ` Guo Xuenan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.