erofs: Fallback to normal access if DAX is not supported on extra device
PATCH 1/1 erofs: Fallback to normal access if DAX is not supported on extra device
If using multiple devices, we should check if the extra device support DAX instead of checking the primary device when deciding if to use DAX to access a file.
If an extra device does not support DAX we should fallback to normal access otherwise the data on that device will be inaccessible.
--- fs/erofs/super.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
fs/erofs/super.c +14 -9
@@ -174,6 +174,11 @@ 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 ;
@@ -210,8 +215,13 @@ static int erofs_scan_devices(struct super_block *sb, ondisk_extradevs, sbi->devs->extra_devices);return -EINVAL ; } -if (!ondisk_extradevs) +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 (!sbi->devs->extra_devices && !erofs_is_fscache_mode (sb)) sbi->devs->flatdev = true;
@@ -671,14 +681,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)return invalfc (fc,"cannot use fsoffset in fscache mode" ); } -if (test_opt (&sbi->opt,DAX_ALWAYS )) { -if (!sbi->dif0.dax_dev) { -errorfc (fc,"DAX unsupported by block device. Turning off DAX." ); -clear_opt (&sbi->opt,DAX_ALWAYS ); - }else if (sbi->blkszbits !=PAGE_SHIFT ) { -errorfc (fc,"unsupported blocksize for DAX" ); -clear_opt (&sbi->opt,DAX_ALWAYS ); - } +if (test_opt (&sbi->opt,DAX_ALWAYS ) && sbi->blkszbits !=PAGE_SHIFT ) { +errorfc (fc,"unsupported blocksize for DAX" ); +clear_opt (&sbi->opt,DAX_ALWAYS ); } sb->s_time_gran =1 ;
Signature · 1 line
2.43.0
Hi Yuezhang,
Quoted 20 lines · Yuezhang Mo
If using multiple devices, we should check if the extra device support DAX instead of checking the primary device when deciding if to use DAX to access a file.
If an extra device does not support DAX we should fallback to normal access otherwise the data on that device will be inaccessible.
Signed-off-by Yuezhang Mo <[email protected]>Reviewed-by Friendy Su <[email protected]>Reviewed-by Jacky Cao <[email protected]>Reviewed-by Daniel Palmer <[email protected]>--- fs/erofs/super.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)fs/erofs/super.c +0
-0
fs/erofs/super.c static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb, · line 179
Quoted 6 lines
fs/erofs/super.c +3
-0@@ -174,6 +174,11 @@ 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);
The patch itself looks good to me, yes, I don't think out a reasonable way to enable partial DAX for multiple devices.
So it'd better to just disable such case.
Just a nitpick, it would be better to align dif->path to the following char of ( in the line above.
Also if it's possible, please remove the unnecessary comment ("/* handle multiple devices */") above erofs_scan_devices() together since:
- it was obvious and it might be not inaccurrate;
- it now handles some primary device stuff too.
Thanks,
Gao XIang
Quoted 36 lines · Gao Xiang
Quoted 20 lines · Yuezhang Mo
If using multiple devices, we should check if the extra device support DAX instead of checking the primary device when deciding if to use DAX to access a file.
If an extra device does not support DAX we should fallback to normal access otherwise the data on that device will be inaccessible.
Signed-off-by Yuezhang Mo <[email protected]>Reviewed-by Friendy Su <[email protected]>Reviewed-by Jacky Cao <[email protected]>Reviewed-by Daniel Palmer <[email protected]>--- fs/erofs/super.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)fs/erofs/super.c +0
-0fs/erofs/super.c static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb, · line 179
Quoted 6 lines
fs/erofs/super.c +3
-0@@ -174,6 +174,11 @@ 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);The patch itself looks good to me, yes, I don't think out a reasonable way to enable partial DAX for multiple devices.
So it'd better to just disable such case.
Just a nitpick, it would be better to align
dif->pathto the following char of(in the line above.
Quoted 6 lines
Also if it's possible, please remove the unnecessary comment ("/* handle multiple devices */") above
erofs_scan_devices()together since:- it was obvious and it might be not inaccurrate;
- it now handles some primary device stuff too.
Thanks for your comments.
I fixed the indentation alignment of dif->path and removed the unnecessary comment in the v2 patch.
Quoted 50 lines · Yuezhang Mo
If using multiple devices, we should check if the extra device support DAX instead of checking the primary device when deciding if to use DAX to access a file.
If an extra device does not support DAX we should fallback to normal access otherwise the data on that device will be inaccessible.
Signed-off-by Yuezhang Mo <[email protected]>Reviewed-by Friendy Su <[email protected]>Reviewed-by Jacky Cao <[email protected]>Reviewed-by Daniel Palmer <[email protected]>--- fs/erofs/super.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)fs/erofs/super.c +11
-1@@ -174,6 +174,11 @@ 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 ;@@ -210,8 +215,13 @@ static int erofs_scan_devices(struct super_block *sb, ondisk_extradevs, sbi->devs->extra_devices);return -EINVAL ; } -if (!ondisk_extradevs) +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 (!sbi->devs->extra_devices && !erofs_is_fscache_mode (sb)) sbi->devs->flatdev = true;@@ -671,14 +681,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)return invalfc (fc,"cannot use fsoffset in fscache mode" ); }
fs/erofs/super.c static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) · line 685
Quoted 10 lines
fs/erofs/super.c +2
-8-if (test_opt (&sbi->opt,DAX_ALWAYS )) { -if (!sbi->dif0.dax_dev) { -errorfc (fc,"DAX unsupported by block device. Turning off DAX." ); -clear_opt (&sbi->opt,DAX_ALWAYS ); - }else if (sbi->blkszbits !=PAGE_SHIFT ) { -errorfc (fc,"unsupported blocksize for DAX" ); -clear_opt (&sbi->opt,DAX_ALWAYS ); - } +if (test_opt (&sbi->opt,DAX_ALWAYS ) && sbi->blkszbits !=PAGE_SHIFT ) { +errorfc (fc,"unsupported blocksize for DAX" );
How about using the info log? Can we consider using infofc in this case?
Thanks,
Hongbo
Quoted 4 lines
fs/erofs/super.c +1
-0+clear_opt (&sbi->opt,DAX_ALWAYS ); } sb->s_time_gran =1 ;
Hi Hongbo,
Quoted 1 line · Hongbo Li
...
Quoted 8 lines
Quoted 6 lines
- } else if (
sbi->blkszbits!=PAGE_SHIFT) {
-errorfc(fc, "unsupported blocksize for DAX");
-clear_opt(&sbi->opt, DAX_ALWAYS);
- }
+ if (test_opt(&sbi->opt, DAX_ALWAYS)&&sbi->blkszbits!=PAGE_SHIFT) { +errorfc(fc, "unsupported blocksize for DAX");How about using the info log? Can we consider using infofc in this case?
I think you suggestion sounds better, but how about sending to the original author?
Thanks,
Gao Xiang