]> Gentwo Git Trees - linux/.git/commitdiff
erofs: correct FSDAX detection
authorGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 17 Nov 2025 11:57:29 +0000 (19:57 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 24 Nov 2025 06:16:30 +0000 (14:16 +0800)
The detection of the primary device is skipped incorrectly
if the multiple or flattened feature is enabled.

It also fixes the FSDAX misdetection for non-block extra blobs.

Fixes: c6993c4cb918 ("erofs: Fallback to normal access if DAX is not supported on extra device")
Reported-and-tested-by: syzbot+31b8fb02cb8a25bd5e78@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/r/691af9f6.a70a0220.3124cb.0097.GAE@google.com
Cc: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/super.c

index f3f8d8c066e4e68c797f02d1974c953a7170a06a..cd8ff98c29384f0e0495499a89516a4f689d00c7 100644 (file)
@@ -174,15 +174,15 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
                if (!erofs_is_fileio_mode(sbi)) {
                        dif->dax_dev = fs_dax_get_by_bdev(file_bdev(file),
                                        &dif->dax_part_off, NULL, NULL);
-                       if (!dif->dax_dev && test_opt(&sbi->opt, DAX_ALWAYS)) {
-                               erofs_info(sb, "DAX unsupported by %s. Turning off DAX.",
-                                          dif->path);
-                               clear_opt(&sbi->opt, DAX_ALWAYS);
-                       }
                } else if (!S_ISREG(file_inode(file)->i_mode)) {
                        fput(file);
                        return -EINVAL;
                }
+               if (!dif->dax_dev && test_opt(&sbi->opt, DAX_ALWAYS)) {
+                       erofs_info(sb, "DAX unsupported by %s. Turning off DAX.",
+                                  dif->path);
+                       clear_opt(&sbi->opt, DAX_ALWAYS);
+               }
                dif->file = file;
        }
 
@@ -215,13 +215,13 @@ static int erofs_scan_devices(struct super_block *sb,
                          ondisk_extradevs, sbi->devs->extra_devices);
                return -EINVAL;
        }
-       if (!ondisk_extradevs) {
-               if (test_opt(&sbi->opt, DAX_ALWAYS) && !sbi->dif0.dax_dev) {
-                       erofs_info(sb, "DAX unsupported by block device. Turning off DAX.");
-                       clear_opt(&sbi->opt, DAX_ALWAYS);
-               }
-               return 0;
+
+       if (test_opt(&sbi->opt, DAX_ALWAYS) && !sbi->dif0.dax_dev) {
+               erofs_info(sb, "DAX unsupported by block device. Turning off DAX.");
+               clear_opt(&sbi->opt, DAX_ALWAYS);
        }
+       if (!ondisk_extradevs)
+               return 0;
 
        if (!sbi->devs->extra_devices && !erofs_is_fscache_mode(sb))
                sbi->devs->flatdev = true;