gfs2: Fix initialisation of args for remount
PATCH 1/1 gfs2: Fix initialisation of args for remount
When gfs2 was converted to use fs_context, the initialisation of the mount args structure to the currently active args was lost with the removal of gfs2_remount_fs(), so the checks of the new args on remount became checks against the default values instead of the current ones. This caused unexpected remount behaviour and test failures (xfstests generic/294, generic/306 and generic/452).
Reinstate the args initialisation, this time in gfs2_init_fs_context() and conditional upon fc->purpose, as that's the only time we get control before the mount args are parsed in the remount process.
---
fs/gfs2/ops_fstype.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
fs/gfs2/ops_fstype.c +11 -6
@@ -1544,13 +1544,18 @@ static int gfs2_init_fs_context(struct fs_context *fc)if (args ==NULL )return -ENOMEM ; - args->ar_quota =GFS2_QUOTA_DEFAULT ; - args->ar_data =GFS2_DATA_DEFAULT ; - args->ar_commit =30 ; - args->ar_statfs_quantum =30 ; - args->ar_quota_quantum =60 ; - args->ar_errors =GFS2_ERRORS_DEFAULT ; +if (fc->purpose ==FS_CONTEXT_FOR_RECONFIGURE ) { +struct gfs2_sbd *sdp = fc->root->d_sb->s_fs_info; + *args = sdp->sd_args; + }else { + args->ar_quota =GFS2_QUOTA_DEFAULT ; + args->ar_data =GFS2_DATA_DEFAULT ; + args->ar_commit =30 ; + args->ar_statfs_quantum =30 ; + args->ar_quota_quantum =60 ; + args->ar_errors =GFS2_ERRORS_DEFAULT ; + } fc->fs_private = args; fc->ops = &gfs2_context_ops;return 0 ;
Signature · 1 line
2.21.0
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: Fix initialisation of args for remount
Quoted 26 lines · Andrew Price
When gfs2 was converted to use
fs_context, the initialisation of the mount args structure to the currently active args was lost with the removal ofgfs2_remount_fs(), so the checks of the new args on remount became checks against the default values instead of the current ones. This caused unexpected remount behaviour and test failures (xfstests generic/294, generic/306 and generic/452).Reinstate the args initialisation, this time in
gfs2_init_fs_context()and conditional uponfc->purpose, as that's the only time we get control before the mount args are parsed in the remount process.Fixes 1f52aa08d12f ("gfs2: Convert gfs2 to fs_context")Signed-off-by Andrew Price <[email protected]>---
fs/gfs2/ops_fstype.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)fs/gfs2/ops_fstype.c +0
-0@@ -1544,13 +1544,18 @@ static int gfs2_init_fs_context(struct fs_context *fc)if (args ==NULL )return -ENOMEM ;
fs/gfs2/ops_fstype.c static int gfs2_init_fs_context(struct fs_context *fc) · line 1550
Quoted 10 lines
fs/gfs2/ops_fstype.c +3
-6- args->ar_quota =GFS2_QUOTA_DEFAULT ; - args->ar_data =GFS2_DATA_DEFAULT ; - args->ar_commit =30 ; - args->ar_statfs_quantum =30 ; - args->ar_quota_quantum =60 ; - args->ar_errors =GFS2_ERRORS_DEFAULT ; +if (fc->purpose ==FS_CONTEXT_FOR_RECONFIGURE ) { +struct gfs2_sbd *sdp = fc->root->d_sb->s_fs_info; + *args = sdp->sd_args;
Since we're fully overwriting args here, shouldn't we use kmalloc to allocate args above ...
fs/gfs2/ops_fstype.c static int gfs2_init_fs_context(struct fs_context *fc) · line 1551
Quoted 1 line
fs/gfs2/ops_fstype.c +1
-0+ }else {
... and memset it to 0 in this case?
Quoted 11 lines
fs/gfs2/ops_fstype.c +7
-1+ args->ar_quota =GFS2_QUOTA_DEFAULT ; + args->ar_data =GFS2_DATA_DEFAULT ; + args->ar_commit =30 ; + args->ar_statfs_quantum =30 ; + args->ar_quota_quantum =60 ; + args->ar_errors =GFS2_ERRORS_DEFAULT ; + } fc->fs_private = args; fc->ops = &gfs2_context_ops;return 0 ; --
Quoted 2 lines
2.21.0
Thanks,
Andreas
PATCH v2 1/1 gfs2: Fix initialisation of args for remount
When gfs2 was converted to use fs_context, the initialisation of the mount args structure to the currently active args was lost with the removal of gfs2_remount_fs(), so the checks of the new args on remount became checks against the default values instead of the current ones. This caused unexpected remount behaviour and test failures (xfstests generic/294, generic/306 and generic/452).
Reinstate the args initialisation, this time in gfs2_init_fs_context() and conditional upon fc->purpose, as that's the only time we get control before the mount args are parsed in the remount process.
---
v2: Switch to kmalloc and only zero the args struct in the normal mount case. (Thanks, Andreas.)
fs/gfs2/ops_fstype.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
fs/gfs2/ops_fstype.c +13 -7
@@ -1540,17 +1540,23 @@ static int gfs2_init_fs_context(struct fs_context *fc) {struct gfs2_args *args; - args =kzalloc (sizeof (*args),GFP_KERNEL ); + args =kmalloc (sizeof (*args),GFP_KERNEL );if (args ==NULL )return -ENOMEM ; - args->ar_quota =GFS2_QUOTA_DEFAULT ; - args->ar_data =GFS2_DATA_DEFAULT ; - args->ar_commit =30 ; - args->ar_statfs_quantum =30 ; - args->ar_quota_quantum =60 ; - args->ar_errors =GFS2_ERRORS_DEFAULT ; +if (fc->purpose ==FS_CONTEXT_FOR_RECONFIGURE ) { +struct gfs2_sbd *sdp = fc->root->d_sb->s_fs_info; + *args = sdp->sd_args; + }else { +memset (args,0 ,sizeof (*args)); + args->ar_quota =GFS2_QUOTA_DEFAULT ; + args->ar_data =GFS2_DATA_DEFAULT ; + args->ar_commit =30 ; + args->ar_statfs_quantum =30 ; + args->ar_quota_quantum =60 ; + args->ar_errors =GFS2_ERRORS_DEFAULT ; + } fc->fs_private = args; fc->ops = &gfs2_context_ops;return 0 ;
Signature · 1 line
2.21.0