Skip to content

Commit ebe4f3f

Browse files
committed
erofs: correct FSDAX detection
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: c6993c4 ("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>
1 parent 6a23ae0 commit ebe4f3f

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

fs/erofs/super.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
174174
if (!erofs_is_fileio_mode(sbi)) {
175175
dif->dax_dev = fs_dax_get_by_bdev(file_bdev(file),
176176
&dif->dax_part_off, NULL, NULL);
177-
if (!dif->dax_dev && test_opt(&sbi->opt, DAX_ALWAYS)) {
178-
erofs_info(sb, "DAX unsupported by %s. Turning off DAX.",
179-
dif->path);
180-
clear_opt(&sbi->opt, DAX_ALWAYS);
181-
}
182177
} else if (!S_ISREG(file_inode(file)->i_mode)) {
183178
fput(file);
184179
return -EINVAL;
185180
}
181+
if (!dif->dax_dev && test_opt(&sbi->opt, DAX_ALWAYS)) {
182+
erofs_info(sb, "DAX unsupported by %s. Turning off DAX.",
183+
dif->path);
184+
clear_opt(&sbi->opt, DAX_ALWAYS);
185+
}
186186
dif->file = file;
187187
}
188188

@@ -215,13 +215,13 @@ static int erofs_scan_devices(struct super_block *sb,
215215
ondisk_extradevs, sbi->devs->extra_devices);
216216
return -EINVAL;
217217
}
218-
if (!ondisk_extradevs) {
219-
if (test_opt(&sbi->opt, DAX_ALWAYS) && !sbi->dif0.dax_dev) {
220-
erofs_info(sb, "DAX unsupported by block device. Turning off DAX.");
221-
clear_opt(&sbi->opt, DAX_ALWAYS);
222-
}
223-
return 0;
218+
219+
if (test_opt(&sbi->opt, DAX_ALWAYS) && !sbi->dif0.dax_dev) {
220+
erofs_info(sb, "DAX unsupported by block device. Turning off DAX.");
221+
clear_opt(&sbi->opt, DAX_ALWAYS);
224222
}
223+
if (!ondisk_extradevs)
224+
return 0;
225225

226226
if (!sbi->devs->extra_devices && !erofs_is_fscache_mode(sb))
227227
sbi->devs->flatdev = true;

0 commit comments

Comments
 (0)