Skip to contentSkip to conversation

erofs-utils: lib: relax erofs_write_device_table() device table check

PATCH Superseded Jonathan Calmels 3 participants 6 messages Feb 12 – Feb 13 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: relax erofs_write_device_table() device table check

Avoid returning an error in erofs_write_device_table() if a new device slot table hasn't been allocated. Rationale is to allow erofs_importer_flush_all() to succeed when dealing with images with pre-existing device slots.

---
 lib/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/super.c +1 -1
index a203f96..d38396f 100644
@@ -392,7 +392,7 @@ int erofs_write_device_table(struct erofs_sb_info *sbi)
 	if (!sbi->extra_devices)
 		goto out;
 	if (!bh)
-		return -EINVAL;
+		goto out;
 
 	pos = erofs_btell(bh, false);
 	if (pos == EROFS_NULL_ADDR) {
Signature · 1 line
2.53.0
#1 lore raw

Hi Jonathan,

Quoted 6 lines · Jonathan Calmels

Avoid returning an error in erofs_write_device_table() if a new device slot table hasn't been allocated. Rationale is to allow erofs_importer_flush_all() to succeed when dealing with images with pre-existing device slots.

Thanks for the patch, could you elaborate how to use this?

A detailed command line usage would be better.

(Also honestly I will try to release erofs-utils 1.9 in
a few days for the upcoming ubuntu LTS, so I have to finish erofs fsmerge feature for compression layout after the version is released...)

Thanks,
Gao Xiang

Quoted 17 lines
---
  lib/super.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/super.c +1 -1
index a203f96..d38396f 100644
@@ -392,7 +392,7 @@ int erofs_write_device_table(struct erofs_sb_info *sbi)
  	if (!sbi->extra_devices)
  		goto out;
  	if (!bh)
-		return -EINVAL;
+		goto out;
 
  	pos = erofs_btell(bh, false);
  	if (pos == EROFS_NULL_ADDR) {
#2 lore raw
Quoted 17 lines · Gao Xiang

External email: Use caution opening links or attachments

Hi Jonathan,

Quoted 6 lines · Jonathan Calmels

Avoid returning an error in erofs_write_device_table() if a new device slot table hasn't been allocated. Rationale is to allow erofs_importer_flush_all() to succeed when dealing with images with pre-existing device slots.

Thanks for the patch, could you elaborate how to use this?

A detailed command line usage would be better.

Quoted 7 lines

(Also honestly I will try to release erofs-utils 1.9 in
a few days for the upcoming ubuntu LTS, so I have to finish erofs fsmerge feature for compression layout after the version is released...)

Thanks,
Gao Xiang

I'm relying on the library not the CLI, I think the equivalent would be:

mkfs.erofs -Efragments,noinline_data,ztailpacking a.erofs a/ mkfs.erofs -Efragments,noinline_data,ztailpacking b.erofs b/ mkfs.erofs merged.erofs a.erofs b.erofs
mkfs.erofs --incremental=data merged.erofs c/

It does seem to work as expected after the patch, but let me know if I missed anything.

Thanks

Quoted 18 lines
Quoted 17 lines
---
  lib/super.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/super.c +1 -1
index a203f96..d38396f 100644
@@ -392,7 +392,7 @@ int erofs_write_device_table(struct erofs_sb_info *sbi)
      if (!sbi->extra_devices)
              goto out;
      if (!bh)
-             return -EINVAL;
+             goto out;
 
      pos = erofs_btell(bh, false);
      if (pos == EROFS_NULL_ADDR) {
#3 lore raw
Quoted 4 lines · Jonathan Calmels
Quoted 3 lines · Gao Xiang

External email: Use caution opening links or attachments

Thanks for the patch, could you elaborate how to use this?

...

Quoted 7 lines

I'm relying on the library not the CLI, I think the equivalent would be:

mkfs.erofs -Efragments,noinline_data,ztailpacking a.erofs a/ mkfs.erofs -Efragments,noinline_data,ztailpacking b.erofs b/ mkfs.erofs merged.erofs a.erofs b.erofs
mkfs.erofs --incremental=data merged.erofs c/

Could you document this in the commit message?

I think it makes sense, also lacks of -z
if -Efragments is specified.

Quoted 11 lines
Quoted 11 lines

lib/super.c int erofs_write_device_table(struct erofs_sb_info *sbi) · line 395

Quoted 11 lines
lib/super.c +1 -1
index a203f96..d38396f 100644
@@ -392,7 +392,7 @@ int erofs_write_device_table(struct erofs_sb_info *sbi)
      if (!sbi->extra_devices)
              goto out;
      if (!bh)
-             return -EINVAL;
+             goto out;

How about updating to the following instead for now?

        if (!sbi->extra_devices)
                goto out;
-       if (!bh)
+       if (!bh) {
+               if (erofs_sb_has_device_table(sbi))
+                       return 0;
                return -EINVAL;

+ }

        pos = erofs_btell(bh, false);
        if (pos == NULL_ADDR_UL) {

Thanks,
Gao Xiang

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
lib/super.c +0 -0
      pos = erofs_btell(bh, false);
      if (pos == EROFS_NULL_ADDR) {
#4 lore raw

PATCH v2 1/1 erofs-utils: lib: relax erofs_write_device_table() device table check

In reply to Jonathan Calmels

Avoid returning an error in erofs_write_device_table() if a new device slot table hasn't been allocated. Rationale is to allow erofs_importer_flush_all() to succeed when dealing with images with pre-existing device slots.

This effectively allows the following:

mkfs.erofs -Enoinline_data a.erofs a/
mkfs.erofs -Enoinline_data b.erofs b/
mkfs.erofs merged.erofs a.erofs b.erofs
mkfs.erofs --incremental=data merged.erofs c/

---
 lib/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/super.c +1 -1
index a203f96..d38396f 100644
@@ -392,7 +392,7 @@ int erofs_write_device_table(struct erofs_sb_info *sbi)
 	if (!sbi->extra_devices)
 		goto out;
 	if (!bh)
-		return -EINVAL;
+		goto out;
 
 	pos = erofs_btell(bh, false);
 	if (pos == EROFS_NULL_ADDR) {
Signature · 1 line
2.53.0
#5 lore raw

PATCH v3 1/1 erofs-utils: lib: relax erofs_write_device_table() device table check

In reply to Jonathan Calmels

Avoid returning an error in erofs_write_device_table() if a new device slot table hasn't been allocated. Rationale is to allow erofs_importer_flush_all() to succeed when dealing with images with pre-existing device slots.

This effectively allows the following:

mkfs.erofs -Enoinline_data a.erofs a/
mkfs.erofs -Enoinline_data b.erofs b/
mkfs.erofs merged.erofs a.erofs b.erofs
mkfs.erofs --incremental=data merged.erofs c/

---
 lib/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/super.c +4 -1
index a203f96..4a0bb3c 100644
@@ -391,8 +391,11 @@ int erofs_write_device_table(struct erofs_sb_info *sbi)
 
 	if (!sbi->extra_devices)
 		goto out;
-	if (!bh)
+	if (!bh) {
+		if (erofs_sb_has_device_table(sbi))
+			return 0;
 		return -EINVAL;
+	}
 
 	pos = erofs_btell(bh, false);
 	if (pos == EROFS_NULL_ADDR) {
Signature · 1 line
2.53.0