overlay: Display redirect_dir mount option when it is set automatically
PATCH 1/1 overlay: Display redirect_dir mount option when it is set automatically
[Why]
Currently, if metacopy is enabled via a module param/kernel config, then the setting for redirect_dir is overriden, unless passed as a mount option specifically. Despite this overriding, the redirect_dir option is not printed when displaying the mount options (see /proc/mounts), so it is hard for a user to know that it has happened.
[How]
A bit of code that does the overriding based on the mount options was setting redirect_dir, but not updating the redirect_mode string. By adding that update, the information is now printed (and the config struct has the correct information in all places).
--- fs/overlayfs/super.c | 3 +++ 1 file changed, 3 insertions(+)
fs/overlayfs/super.c +3 -0
@@ -598,6 +598,9 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config) config->metacopy = false; }else {/* Automatically enable redirect otherwise. */ +pr_info ("overlayfs: enabling redirect_dir due to implicit metacopy=%d\n" , + config->metacopy); + config->redirect_mode ="on" ; config->redirect_follow = config->redirect_dir = true; } }
Signature · 1 line
2.21.0
Amir Goldstein
maintainerQuoted 2 lines · Matt Coffin
[Why]
The why and how are very important, but please loose the annotations.
Quoted 11 lines
Currently, if metacopy is enabled via a module param/kernel config, then the setting for
redirect_diris overriden, unless passed as a mount option specifically. Despite this overriding, theredirect_diroption is not printed when displaying the mount options (see/proc/mounts), so it is hard for a user to know that it has happened.[How]
A bit of code that does the overriding based on the mount options was settingredirect_dir, but not updating theredirect_modestring. By adding that update, the information is now printed (and the config struct has the correct information in all places).
You need to Sign-off your patch.
Please run ./scripts/checkpatch.pl before posting
It will tell you that and so will:
https://github.com/torvalds/linux/blob/master/Documentation/process/submitting-patches.rst
fs/overlayfs/super.c static int ovl_parse_opt(char *opt, struct ovl_config *config) · line 601
Quoted 13 lines
--- fs/overlayfs/super.c | 3 +++ 1 file changed, 3 insertions(+)fs/overlayfs/super.c +1
-0@@ -598,6 +598,9 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config) config->metacopy = false; }else {/* Automatically enable redirect otherwise. */ + pr_info("overlayfs: enabling redirect_dir due to implicit metacopy=%d\n",
...metacopy=on\n"
We know the value and better display to user in mount option format.
fs/overlayfs/super.c static int ovl_parse_opt(char *opt, struct ovl_config *config) · line 603
Quoted 2 lines
fs/overlayfs/super.c +2
-0+ config->metacopy); + config->redirect_mode ="on" ;
I'm afraid that string is allocated:
kfree(config->redirect_mode);
config->redirect_mode = kstrdup("on", GFP_KERNEL);
if (!config->redirect_mode)
return -ENOMEM;Better wrap that up in a helper ovl_set_redirect_mode("on").
Thanks,
Amir.