Skip to contentSkip to conversation

erofs: fix blksize < PAGE_SIZE for file-backed mounts

PATCH Superseded Hongzhen Luo 2 participants 3 messages Oct 15, 2024 EROFS file system

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 erofs: fix blksize < PAGE_SIZE for file-backed mounts

Adjust sb->s_blocksize{,_bits} directly for file-backed mounts when the fs block size is smaller than PAGE_SIZE.

Previously, EROFS used sb_set_blocksize(), which caused a panic if bdev-backed mounts is not used.

Fixes fb176750266a ("erofs: add file-backed mount support")

---
v3: Fix trivial typos.
v2: https://lore.kernel.org/linux-erofs/[email protected]/
v1: https://lore.kernel.org/linux-erofs/[email protected]/

---
 fs/erofs/super.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/erofs/super.c +5 -1
index 320d586c3896..ca45dfb17d7c 100644
@@ -631,7 +631,11 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
 			errorfc(fc, "unsupported blksize for fscache mode");
 			return -EINVAL;
 		}
-		if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
+
+		if (erofs_is_fileio_mode(sbi)) {
+			sb->s_blocksize = (1 << sbi->blkszbits);
+			sb->s_blocksize_bits = sbi->blkszbits;
+		} else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
 			errorfc(fc, "failed to set erofs blksize");
 			return -EINVAL;
 		}
Signature · 1 line
2.43.5
#1 lore raw
Quoted 21 lines · Hongzhen Luo

Adjust sb->s_blocksize{,_bits} directly for file-backed mounts when the fs block size is smaller than PAGE_SIZE.

Previously, EROFS used sb_set_blocksize(), which caused a panic if bdev-backed mounts is not used.

Fixes fb176750266a ("erofs: add file-backed mount support")

---
v3: Fix trivial typos.
v2: https://lore.kernel.org/linux-erofs/[email protected]/
v1: https://lore.kernel.org/linux-erofs/[email protected]/

---
  fs/erofs/super.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
fs/erofs/super.c +0 -0
index 320d586c3896..ca45dfb17d7c 100644

fs/erofs/super.c static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) · line 636

Quoted 7 lines
fs/erofs/super.c +3 -1
@@ -631,7 +631,11 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
  			errorfc(fc, "unsupported blksize for fscache mode");
  			return -EINVAL;
  		}
-		if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
+
+		if (erofs_is_fileio_mode(sbi)) {
+			sb->s_blocksize = (1 << sbi->blkszbits);

Why needing parentheses here?

Thanks,
Gao Xiang

Quoted 5 lines
fs/erofs/super.c +2 -0
+			sb->s_blocksize_bits = sbi->blkszbits;
+		} else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
  			errorfc(fc, "failed to set erofs blksize");
  			return -EINVAL;
  		}
#2 lore raw
Quoted 35 lines · Gao Xiang
Quoted 21 lines · Hongzhen Luo

Adjust sb->s_blocksize{,_bits} directly for file-backed mounts when the fs block size is smaller than PAGE_SIZE.

Previously, EROFS used sb_set_blocksize(), which caused a panic if bdev-backed mounts is not used.

Fixes fb176750266a ("erofs: add file-backed mount support")

---
v3: Fix trivial typos.
v2: https://lore.kernel.org/linux-erofs/[email protected]/
v1: https://lore.kernel.org/linux-erofs/[email protected]/
---
  fs/erofs/super.c | 6 +++++-

  1 file changed, 5 insertions(+), 1 deletion(-)
fs/erofs/super.c +0 -0
index 320d586c3896..ca45dfb17d7c 100644

fs/erofs/super.c static int erofs_fc_fill_super(struct · line 637

Quoted 8 lines
fs/erofs/super.c +3 -1
@@ -631,7 +631,11 @@ static int erofs_fc_fill_super(struct 
 super_block *sb, struct fs_context *fc)
               errorfc(fc, "unsupported blksize for fscache mode");
               return -EINVAL;
           }
-        if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
+
+        if (erofs_is_fileio_mode(sbi)) {
+            sb->s_blocksize = (1 << sbi->blkszbits);

Why needing parentheses here?

Quoted 2 lines

Thanks,
Gao Xiang

I will resend a version without the parentheses soon.

---

Thanks,

Hongzhen

Quoted 6 lines
Quoted 6 lines
fs/erofs/super.c +2 -0
+            sb->s_blocksize_bits = sbi->blkszbits;
+        } else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
               errorfc(fc, "failed to set erofs blksize");
               return -EINVAL;

          }