nilfs2: convert to use the new mount API
PATCH v3 1/1 nilfs2: convert to use the new mount API
Convert nilfs2 to use the new mount API.
---
Sorry for the delay on resend, other work got in the way... This all paged out a bit but I think I addressed all of the review items. Thanks!
V3:
- Add identifiers to nilfs_store_magic() prototype
- switch Opt_snapshot to use fsparam_u64 vs. fsparam_u32
- add error message for invalid cp=0 case
- remove early sb->s_flags change in nilfs2_reconfigure()
- un-split error message string in nilfs_get_tree()
fs/nilfs2/nilfs.h +2 -2
@@ -335,8 +335,8 @@ void __nilfs_error(struct super_block *sb, const char *function,extern struct nilfs_super_block *nilfs_read_super_block (struct super_block *,u64 ,int ,struct buffer_head **); -extern int nilfs_store_magic_and_option (struct super_block *, -struct nilfs_super_block *,char *); +extern int nilfs_store_magic (struct super_block *sb, +struct nilfs_super_block *sbp);extern int nilfs_check_feature_compatibility (struct super_block *,struct nilfs_super_block *); extern void nilfs_set_log_cursor(struct nilfs_super_block *,
fs/nilfs2/super.c +156 -214
523 lines not on this page · raw message
fs/nilfs2/the_nilfs.c +2 -2
@@ -668,7 +668,7 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,* Return Value: On success, 0 is returned. On error, a negative error * code is returned. */ -int init_nilfs (struct the_nilfs *nilfs,struct super_block *sb,char *data) +int init_nilfs (struct the_nilfs *nilfs,struct super_block *sb) {struct nilfs_super_block *sbp;int blocksize;
@@ -686,7 +686,7 @@ int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data)if (err) goto out; - err =nilfs_store_magic_and_option (sb, sbp, data); + err =nilfs_store_magic (sb, sbp);if (err) goto failed_sbh;
fs/nilfs2/the_nilfs.h +1 -5
@@ -219,10 +219,6 @@ THE_NILFS_FNS(PURGING, purging)#define nilfs_set_opt (nilfs, opt) \ ((nilfs)->ns_mount_opt |= NILFS_MOUNT_##opt)#define nilfs_test_opt (nilfs, opt) ((nilfs)->ns_mount_opt & NILFS_MOUNT_##opt) -#define nilfs_write_opt (nilfs, mask, opt) \ - ((nilfs)->ns_mount_opt = \ - (((nilfs)->ns_mount_opt & ~NILFS_MOUNT_##mask) | \ - NILFS_MOUNT_##opt)) \/** * struct nilfs_root - nilfs root object
@@ -276,7 +272,7 @@ static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs)void nilfs_set_last_segment (struct the_nilfs *,sector_t ,u64 ,__u64 );struct the_nilfs *alloc_nilfs (struct super_block *sb);void destroy_nilfs (struct the_nilfs *nilfs); -int init_nilfs (struct the_nilfs *nilfs,struct super_block *sb,char *data); +int init_nilfs (struct the_nilfs *nilfs,struct super_block *sb);int load_nilfs (struct the_nilfs *nilfs,struct super_block *sb);unsigned long nilfs_nrsvsegs (struct the_nilfs *nilfs,unsigned long nsegs);void nilfs_set_nsegments (struct the_nilfs *nilfs,unsigned long nsegs);
Ryusuke Konishi
maintainerQuoted 10 lines · Eric Sandeen
Convert nilfs2 to use the new mount API.
Signed-off-by Eric Sandeen <[email protected]>---
Sorry for the delay on resend, other work got in the way... This all paged out a bit but I think I addressed all of the review items. Thanks!
Quoted 7 lines
V3:
- Add identifiers tonilfs_store_magic()prototype
- switchOpt_snapshotto usefsparam_u64vs.fsparam_u32
- add error message for invalid cp=0 case
- remove earlysb->s_flagschange innilfs2_reconfigure()
- un-split error message string innilfs_get_tree()
Thank you for the revised patch!
...
Review
Quoted 13 lines
(quoted diff) +13
-0+ case Opt_snapshot: + if (is_remount) { + struct super_block *sb = fc->root->d_sb; + + nilfs_err(sb, + "\"%s\" option is invalid for remount", + param->key); + return -EINVAL; + } + if (result.uint_64 == 0) { + nilfs_err(NULL, + "invalid option \"cp=0\": invalid checkpoint number 0"); + return -EINVAL;
At first glance, I wondered why the nilfs_err() super_block instance argument was NULL here, but I see, it can only be used by remount..
...
Quoted 10 lines
(quoted diff) +1
-1@@ -1172,7 +1157,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) "couldn't remount RDWR because of unsupported optional features (%llx)", (unsigned long long)features); err = -EROFS; - goto restore_opts; + goto ignore_opts; } sb->s_flags &= ~SB_RDONLY;
Review static int nilfs_remount(struct super_block *sb, int *flags, char *data) · line 1173
Quoted 10 lines
(quoted diff) +1
-1@@ -1180,130 +1165,56 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) root = NILFS_I(d_inode(sb->s_root))->i_root; err = nilfs_attach_log_writer(sb, root); if (err) - goto restore_opts; + goto ignore_opts; down_write(&nilfs->ns_sem); nilfs_setup_super(sb, true); up_write(&nilfs->ns_sem); }
There is still an issue where the SB_RDONLY flag on sb->s_flags is not repaired in the error path of nilfs_attach_log_writer().
This seems to be the only essential issue remaining, so I can add the following fix (safer one - drop the SB_RDONLY flag for nilfs_attach_log_writer, call it, and repair the flag if it fails), and send it upstream.
Is this okay? Please let me know if you have any opinions.
fs/nilfs2/super.c +3 -1
@@ -1164,8 +1164,10 @@ static int nilfs_reconfigure(struct fs_context *fc) root =NILFS_I (d_inode (sb->s_root))->i_root; err =nilfs_attach_log_writer (sb, root); -if (err) +if (err) { + sb->s_flags |=SB_RDONLY ; goto ignore_opts; + }down_write (&nilfs->ns_sem);nilfs_setup_super (sb, true);
Thanks,
Ryusuke Konishi
Quoted 7 lines · Ryusuke Konishi
Quoted 4 lines · Eric Sandeen
Convert nilfs2 to use the new mount API.
Signed-off-by Eric Sandeen <[email protected]>
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ if (result.uint_64 == 0) { + nilfs_err(NULL, + "invalid option \"cp=0\": invalid checkpoint number 0"); + return -EINVAL;At first glance, I wondered why the
nilfs_err()super_blockinstance argument was NULL here, but I see, it can only be used by remount..
Yup that's right, no sb yet on initial parsing. Hopefully the message is ok this way. There is also an option to emit mount option errors through the API, but nothing is listening for that yet.
Quoted 37 lines
...
Quoted 10 lines
fs/nilfs2/super.c +1
-1@@ -1172,7 +1157,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)"couldn't remount RDWR because of unsupported optional features (%llx)" , (unsigned long long)features); err = -EROFS ; - goto restore_opts; + goto ignore_opts; } sb->s_flags &= ~SB_RDONLY ;fs/nilfs2/super.c static int nilfs_remount(struct super_block *sb, int *flags, char *data) · line 1173
Quoted 10 lines
fs/nilfs2/super.c +1
-1@@ -1180,130 +1165,56 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) root =NILFS_I (d_inode (sb->s_root))->i_root; err =nilfs_attach_log_writer (sb, root);if (err) - goto restore_opts; + goto ignore_opts;down_write (&nilfs->ns_sem);nilfs_setup_super (sb, true);up_write (&nilfs->ns_sem); }There is still an issue where the
SB_RDONLYflag onsb->s_flagsis not repaired in the error path ofnilfs_attach_log_writer().This seems to be the only essential issue remaining, so I can add the following fix (safer one - drop the
SB_RDONLYflag fornilfs_attach_log_writer, call it, and repair the flag if it fails), and send it upstream.
Is this okay? Please let me know if you have any opinions.fs/nilfs2/super.c +0
-0@@ -1164,8 +1164,10 @@ static int nilfs_reconfigure(struct fs_context *fc)
fs/nilfs2/super.c static int nilfs_reconfigure(struct fs_context *fc) · line 1173
Quoted 10 lines
fs/nilfs2/super.c +3
-1root =NILFS_I (d_inode (sb->s_root))->i_root; err =nilfs_attach_log_writer (sb, root); -if (err) +if (err) { + sb->s_flags |=SB_RDONLY ; goto ignore_opts; + }down_write (&nilfs->ns_sem);nilfs_setup_super (sb, true);
Oh, I'm sorry I missed that :( Yes, I think that looks fine. Thank you.
-Eric
Quoted 4 lines
Thanks,
Ryusuke Konishi
Ryusuke Konishi
maintainerQuoted 14 lines · Eric Sandeen
Quoted 12 lines · Ryusuke Konishi
Quoted 10 lines · Eric Sandeen
Convert nilfs2 to use the new mount API.
Signed-off-by Eric Sandeen <[email protected]>(quoted diff) +4
-0+ if (result.uint_64 == 0) { + nilfs_err(NULL, + "invalid option \"cp=0\": invalid checkpoint number 0"); + return -EINVAL;
Quoted 6 lines
Quoted 2 lines
At first glance, I wondered why the
nilfs_err()super_blockinstance argument was NULL here, but I see, it can only be used by remount..Yup that's right, no sb yet on initial parsing. Hopefully the message is ok this way. There is also an option to emit mount option errors through the API, but nothing is listening for that yet.
The above implementation is fine (the original nilfs_parse_snapshot_option() also does not output the device name, so nothing is lost). I just found it interesting.
Quoted 46 lines
Quoted 46 lines
...
Quoted 10 lines
fs/nilfs2/super.c +1
-1@@ -1172,7 +1157,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)"couldn't remount RDWR because of unsupported optional features (%llx)" , (unsigned long long)features); err = -EROFS ; - goto restore_opts; + goto ignore_opts; } sb->s_flags &= ~SB_RDONLY ;fs/nilfs2/super.c static int nilfs_remount(struct super_block *sb, int *flags, char *data) · line 1173
Quoted 10 lines
fs/nilfs2/super.c +1
-1@@ -1180,130 +1165,56 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) root =NILFS_I (d_inode (sb->s_root))->i_root; err =nilfs_attach_log_writer (sb, root);if (err) - goto restore_opts; + goto ignore_opts;down_write (&nilfs->ns_sem);nilfs_setup_super (sb, true);up_write (&nilfs->ns_sem); }There is still an issue where the
SB_RDONLYflag onsb->s_flagsis not repaired in the error path ofnilfs_attach_log_writer().This seems to be the only essential issue remaining, so I can add the following fix (safer one - drop the
SB_RDONLYflag fornilfs_attach_log_writer, call it, and repair the flag if it fails), and send it upstream.
Is this okay? Please let me know if you have any opinions.fs/nilfs2/super.c +3
-1@@ -1164,8 +1164,10 @@ static int nilfs_reconfigure(struct fs_context *fc) root =NILFS_I (d_inode (sb->s_root))->i_root; err =nilfs_attach_log_writer (sb, root); -if (err) +if (err) { + sb->s_flags |=SB_RDONLY ; goto ignore_opts; + }
Quoted 6 lines
fs/nilfs2/super.c static int nilfs_reconfigure(struct fs_context *fc) · line 1173
Quoted 2 lines
fs/nilfs2/super.c +0
-0down_write (&nilfs->ns_sem);nilfs_setup_super (sb, true);Oh, I'm sorry I missed that :( Yes, I think that looks fine. Thank you.
-Eric
Good.
Well, I'll continue testing, so I'll keep this patch for now and let you know if anything happens.
I would like to send it to the -mm tree as soon as possible.
Thank you!
Ryusuke Konishi
Quoted 6 lines
Quoted 5 lines
Thanks,
Ryusuke Konishi