diff options
author | David Sterba <dsterba@suse.com> | 2016-02-26 09:38:30 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-02-26 09:38:30 -0500 |
commit | 23c1a966f2525e71f895bf349a5ae9e5d7bdd67f (patch) | |
tree | cdbe7b2a556b4789c2c61b9dc1bffe864654edde | |
parent | 67d605fec1d406f6a0272be39686801d389f59c9 (diff) | |
parent | fed8f166ebf3afb8b91a1fd73d706788e07a91ef (diff) |
Merge branch 'foreign/qu/norecovery-v7' into for-chris-4.6
-rw-r--r-- | Documentation/filesystems/btrfs.txt | 19 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 6 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 15 | ||||
-rw-r--r-- | fs/btrfs/super.c | 45 |
4 files changed, 67 insertions, 18 deletions
diff --git a/Documentation/filesystems/btrfs.txt b/Documentation/filesystems/btrfs.txt index c772b47e7ef0..6593d2e415c5 100644 --- a/Documentation/filesystems/btrfs.txt +++ b/Documentation/filesystems/btrfs.txt | |||
@@ -168,10 +168,23 @@ Options with (*) are default options and will not show in the mount options. | |||
168 | notreelog | 168 | notreelog |
169 | Enable/disable the tree logging used for fsync and O_SYNC writes. | 169 | Enable/disable the tree logging used for fsync and O_SYNC writes. |
170 | 170 | ||
171 | recovery | 171 | nologreplay |
172 | Enable autorecovery attempts if a bad tree root is found at mount time. | 172 | Disable the log tree replay at mount time to prevent filesystem |
173 | Currently this scans a list of several previous tree roots and tries to | 173 | from getting modified. |
174 | Must be used with 'ro' mount option. | ||
175 | A filesystem mounted with this option cannot transition to a | ||
176 | read-write mount via remount,rw - the filesystem must be unmounted | ||
177 | and mounted back again if read-write access is desired. | ||
178 | |||
179 | usebackuproot | ||
180 | Enable attempts to use backup tree roots if a bad tree root is found at | ||
181 | mount time. | ||
182 | Currently this scans a list of 4 previous tree roots and tries to | ||
174 | use the first readable. | 183 | use the first readable. |
184 | And since the mount option doesn't affect any behavior after mount, | ||
185 | it won't be shown in mount info. | ||
186 | Prior to 4.6, this was done by 'recovery' option that has been | ||
187 | deprecated, but will work. | ||
175 | 188 | ||
176 | rescan_uuid_tree | 189 | rescan_uuid_tree |
177 | Force check and rebuild procedure of the UUID tree. This should not | 190 | Force check and rebuild procedure of the UUID tree. This should not |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 3fb3b787aa5e..6af1211d4ee9 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2274,7 +2274,7 @@ struct btrfs_ioctl_defrag_range_args { | |||
2274 | #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) | 2274 | #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) |
2275 | #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) | 2275 | #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) |
2276 | #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) | 2276 | #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) |
2277 | #define BTRFS_MOUNT_RECOVERY (1 << 18) | 2277 | #define BTRFS_MOUNT_USEBACKUPROOT (1 << 18) |
2278 | #define BTRFS_MOUNT_SKIP_BALANCE (1 << 19) | 2278 | #define BTRFS_MOUNT_SKIP_BALANCE (1 << 19) |
2279 | #define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20) | 2279 | #define BTRFS_MOUNT_CHECK_INTEGRITY (1 << 20) |
2280 | #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) | 2280 | #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21) |
@@ -2283,6 +2283,7 @@ struct btrfs_ioctl_defrag_range_args { | |||
2283 | #define BTRFS_MOUNT_FRAGMENT_DATA (1 << 24) | 2283 | #define BTRFS_MOUNT_FRAGMENT_DATA (1 << 24) |
2284 | #define BTRFS_MOUNT_FRAGMENT_METADATA (1 << 25) | 2284 | #define BTRFS_MOUNT_FRAGMENT_METADATA (1 << 25) |
2285 | #define BTRFS_MOUNT_FREE_SPACE_TREE (1 << 26) | 2285 | #define BTRFS_MOUNT_FREE_SPACE_TREE (1 << 26) |
2286 | #define BTRFS_MOUNT_NOLOGREPLAY (1 << 27) | ||
2286 | 2287 | ||
2287 | #define BTRFS_DEFAULT_COMMIT_INTERVAL (30) | 2288 | #define BTRFS_DEFAULT_COMMIT_INTERVAL (30) |
2288 | #define BTRFS_DEFAULT_MAX_INLINE (8192) | 2289 | #define BTRFS_DEFAULT_MAX_INLINE (8192) |
@@ -4187,7 +4188,8 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info); | |||
4187 | ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); | 4188 | ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); |
4188 | 4189 | ||
4189 | /* super.c */ | 4190 | /* super.c */ |
4190 | int btrfs_parse_options(struct btrfs_root *root, char *options); | 4191 | int btrfs_parse_options(struct btrfs_root *root, char *options, |
4192 | unsigned long new_flags); | ||
4191 | int btrfs_sync_fs(struct super_block *sb, int wait); | 4193 | int btrfs_sync_fs(struct super_block *sb, int wait); |
4192 | 4194 | ||
4193 | #ifdef CONFIG_PRINTK | 4195 | #ifdef CONFIG_PRINTK |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 40690e90beee..294c77729df3 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -2751,7 +2751,7 @@ int open_ctree(struct super_block *sb, | |||
2751 | */ | 2751 | */ |
2752 | fs_info->compress_type = BTRFS_COMPRESS_ZLIB; | 2752 | fs_info->compress_type = BTRFS_COMPRESS_ZLIB; |
2753 | 2753 | ||
2754 | ret = btrfs_parse_options(tree_root, options); | 2754 | ret = btrfs_parse_options(tree_root, options, sb->s_flags); |
2755 | if (ret) { | 2755 | if (ret) { |
2756 | err = ret; | 2756 | err = ret; |
2757 | goto fail_alloc; | 2757 | goto fail_alloc; |
@@ -3030,8 +3030,9 @@ retry_root_backup: | |||
3030 | if (ret) | 3030 | if (ret) |
3031 | goto fail_trans_kthread; | 3031 | goto fail_trans_kthread; |
3032 | 3032 | ||
3033 | /* do not make disk changes in broken FS */ | 3033 | /* do not make disk changes in broken FS or nologreplay is given */ |
3034 | if (btrfs_super_log_root(disk_super) != 0) { | 3034 | if (btrfs_super_log_root(disk_super) != 0 && |
3035 | !btrfs_test_opt(tree_root, NOLOGREPLAY)) { | ||
3035 | ret = btrfs_replay_log(fs_info, fs_devices); | 3036 | ret = btrfs_replay_log(fs_info, fs_devices); |
3036 | if (ret) { | 3037 | if (ret) { |
3037 | err = ret; | 3038 | err = ret; |
@@ -3147,6 +3148,12 @@ retry_root_backup: | |||
3147 | 3148 | ||
3148 | fs_info->open = 1; | 3149 | fs_info->open = 1; |
3149 | 3150 | ||
3151 | /* | ||
3152 | * backuproot only affect mount behavior, and if open_ctree succeeded, | ||
3153 | * no need to keep the flag | ||
3154 | */ | ||
3155 | btrfs_clear_opt(fs_info->mount_opt, USEBACKUPROOT); | ||
3156 | |||
3150 | return 0; | 3157 | return 0; |
3151 | 3158 | ||
3152 | fail_qgroup: | 3159 | fail_qgroup: |
@@ -3201,7 +3208,7 @@ fail: | |||
3201 | return err; | 3208 | return err; |
3202 | 3209 | ||
3203 | recovery_tree_root: | 3210 | recovery_tree_root: |
3204 | if (!btrfs_test_opt(tree_root, RECOVERY)) | 3211 | if (!btrfs_test_opt(tree_root, USEBACKUPROOT)) |
3205 | goto fail_tree_roots; | 3212 | goto fail_tree_roots; |
3206 | 3213 | ||
3207 | free_root_pointers(fs_info, 0); | 3214 | free_root_pointers(fs_info, 0); |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d41e09fe8e38..bf75200c6f86 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -303,7 +303,8 @@ enum { | |||
303 | Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree, | 303 | Opt_check_integrity_print_mask, Opt_fatal_errors, Opt_rescan_uuid_tree, |
304 | Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, | 304 | Opt_commit_interval, Opt_barrier, Opt_nodefrag, Opt_nodiscard, |
305 | Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, | 305 | Opt_noenospc_debug, Opt_noflushoncommit, Opt_acl, Opt_datacow, |
306 | Opt_datasum, Opt_treelog, Opt_noinode_cache, | 306 | Opt_datasum, Opt_treelog, Opt_noinode_cache, Opt_usebackuproot, |
307 | Opt_nologreplay, Opt_norecovery, | ||
307 | #ifdef CONFIG_BTRFS_DEBUG | 308 | #ifdef CONFIG_BTRFS_DEBUG |
308 | Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all, | 309 | Opt_fragment_data, Opt_fragment_metadata, Opt_fragment_all, |
309 | #endif | 310 | #endif |
@@ -335,6 +336,8 @@ static const match_table_t tokens = { | |||
335 | {Opt_noacl, "noacl"}, | 336 | {Opt_noacl, "noacl"}, |
336 | {Opt_notreelog, "notreelog"}, | 337 | {Opt_notreelog, "notreelog"}, |
337 | {Opt_treelog, "treelog"}, | 338 | {Opt_treelog, "treelog"}, |
339 | {Opt_nologreplay, "nologreplay"}, | ||
340 | {Opt_norecovery, "norecovery"}, | ||
338 | {Opt_flushoncommit, "flushoncommit"}, | 341 | {Opt_flushoncommit, "flushoncommit"}, |
339 | {Opt_noflushoncommit, "noflushoncommit"}, | 342 | {Opt_noflushoncommit, "noflushoncommit"}, |
340 | {Opt_ratio, "metadata_ratio=%d"}, | 343 | {Opt_ratio, "metadata_ratio=%d"}, |
@@ -352,7 +355,8 @@ static const match_table_t tokens = { | |||
352 | {Opt_inode_cache, "inode_cache"}, | 355 | {Opt_inode_cache, "inode_cache"}, |
353 | {Opt_noinode_cache, "noinode_cache"}, | 356 | {Opt_noinode_cache, "noinode_cache"}, |
354 | {Opt_no_space_cache, "nospace_cache"}, | 357 | {Opt_no_space_cache, "nospace_cache"}, |
355 | {Opt_recovery, "recovery"}, | 358 | {Opt_recovery, "recovery"}, /* deprecated */ |
359 | {Opt_usebackuproot, "usebackuproot"}, | ||
356 | {Opt_skip_balance, "skip_balance"}, | 360 | {Opt_skip_balance, "skip_balance"}, |
357 | {Opt_check_integrity, "check_int"}, | 361 | {Opt_check_integrity, "check_int"}, |
358 | {Opt_check_integrity_including_extent_data, "check_int_data"}, | 362 | {Opt_check_integrity_including_extent_data, "check_int_data"}, |
@@ -373,7 +377,8 @@ static const match_table_t tokens = { | |||
373 | * reading in a new superblock is parsed here. | 377 | * reading in a new superblock is parsed here. |
374 | * XXX JDM: This needs to be cleaned up for remount. | 378 | * XXX JDM: This needs to be cleaned up for remount. |
375 | */ | 379 | */ |
376 | int btrfs_parse_options(struct btrfs_root *root, char *options) | 380 | int btrfs_parse_options(struct btrfs_root *root, char *options, |
381 | unsigned long new_flags) | ||
377 | { | 382 | { |
378 | struct btrfs_fs_info *info = root->fs_info; | 383 | struct btrfs_fs_info *info = root->fs_info; |
379 | substring_t args[MAX_OPT_ARGS]; | 384 | substring_t args[MAX_OPT_ARGS]; |
@@ -393,8 +398,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
393 | else if (cache_gen) | 398 | else if (cache_gen) |
394 | btrfs_set_opt(info->mount_opt, SPACE_CACHE); | 399 | btrfs_set_opt(info->mount_opt, SPACE_CACHE); |
395 | 400 | ||
401 | /* | ||
402 | * Even the options are empty, we still need to do extra check | ||
403 | * against new flags | ||
404 | */ | ||
396 | if (!options) | 405 | if (!options) |
397 | goto out; | 406 | goto check; |
398 | 407 | ||
399 | /* | 408 | /* |
400 | * strsep changes the string, duplicate it because parse_options | 409 | * strsep changes the string, duplicate it because parse_options |
@@ -606,6 +615,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
606 | btrfs_clear_and_info(root, NOTREELOG, | 615 | btrfs_clear_and_info(root, NOTREELOG, |
607 | "enabling tree log"); | 616 | "enabling tree log"); |
608 | break; | 617 | break; |
618 | case Opt_norecovery: | ||
619 | case Opt_nologreplay: | ||
620 | btrfs_set_and_info(root, NOLOGREPLAY, | ||
621 | "disabling log replay at mount time"); | ||
622 | break; | ||
609 | case Opt_flushoncommit: | 623 | case Opt_flushoncommit: |
610 | btrfs_set_and_info(root, FLUSHONCOMMIT, | 624 | btrfs_set_and_info(root, FLUSHONCOMMIT, |
611 | "turning on flush-on-commit"); | 625 | "turning on flush-on-commit"); |
@@ -696,8 +710,12 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
696 | "disabling auto defrag"); | 710 | "disabling auto defrag"); |
697 | break; | 711 | break; |
698 | case Opt_recovery: | 712 | case Opt_recovery: |
699 | btrfs_info(root->fs_info, "enabling auto recovery"); | 713 | btrfs_warn(root->fs_info, |
700 | btrfs_set_opt(info->mount_opt, RECOVERY); | 714 | "'recovery' is deprecated, use 'usebackuproot' instead"); |
715 | case Opt_usebackuproot: | ||
716 | btrfs_info(root->fs_info, | ||
717 | "trying to use backup root at mount time"); | ||
718 | btrfs_set_opt(info->mount_opt, USEBACKUPROOT); | ||
701 | break; | 719 | break; |
702 | case Opt_skip_balance: | 720 | case Opt_skip_balance: |
703 | btrfs_set_opt(info->mount_opt, SKIP_BALANCE); | 721 | btrfs_set_opt(info->mount_opt, SKIP_BALANCE); |
@@ -792,6 +810,15 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
792 | break; | 810 | break; |
793 | } | 811 | } |
794 | } | 812 | } |
813 | check: | ||
814 | /* | ||
815 | * Extra check for current option against current flag | ||
816 | */ | ||
817 | if (btrfs_test_opt(root, NOLOGREPLAY) && !(new_flags & MS_RDONLY)) { | ||
818 | btrfs_err(root->fs_info, | ||
819 | "nologreplay must be used with ro mount option"); | ||
820 | ret = -EINVAL; | ||
821 | } | ||
795 | out: | 822 | out: |
796 | if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE) && | 823 | if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE) && |
797 | !btrfs_test_opt(root, FREE_SPACE_TREE) && | 824 | !btrfs_test_opt(root, FREE_SPACE_TREE) && |
@@ -1202,6 +1229,8 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) | |||
1202 | seq_puts(seq, ",ssd"); | 1229 | seq_puts(seq, ",ssd"); |
1203 | if (btrfs_test_opt(root, NOTREELOG)) | 1230 | if (btrfs_test_opt(root, NOTREELOG)) |
1204 | seq_puts(seq, ",notreelog"); | 1231 | seq_puts(seq, ",notreelog"); |
1232 | if (btrfs_test_opt(root, NOLOGREPLAY)) | ||
1233 | seq_puts(seq, ",nologreplay"); | ||
1205 | if (btrfs_test_opt(root, FLUSHONCOMMIT)) | 1234 | if (btrfs_test_opt(root, FLUSHONCOMMIT)) |
1206 | seq_puts(seq, ",flushoncommit"); | 1235 | seq_puts(seq, ",flushoncommit"); |
1207 | if (btrfs_test_opt(root, DISCARD)) | 1236 | if (btrfs_test_opt(root, DISCARD)) |
@@ -1228,8 +1257,6 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) | |||
1228 | seq_puts(seq, ",inode_cache"); | 1257 | seq_puts(seq, ",inode_cache"); |
1229 | if (btrfs_test_opt(root, SKIP_BALANCE)) | 1258 | if (btrfs_test_opt(root, SKIP_BALANCE)) |
1230 | seq_puts(seq, ",skip_balance"); | 1259 | seq_puts(seq, ",skip_balance"); |
1231 | if (btrfs_test_opt(root, RECOVERY)) | ||
1232 | seq_puts(seq, ",recovery"); | ||
1233 | #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY | 1260 | #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY |
1234 | if (btrfs_test_opt(root, CHECK_INTEGRITY_INCLUDING_EXTENT_DATA)) | 1261 | if (btrfs_test_opt(root, CHECK_INTEGRITY_INCLUDING_EXTENT_DATA)) |
1235 | seq_puts(seq, ",check_int_data"); | 1262 | seq_puts(seq, ",check_int_data"); |
@@ -1685,7 +1712,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) | |||
1685 | } | 1712 | } |
1686 | } | 1713 | } |
1687 | 1714 | ||
1688 | ret = btrfs_parse_options(root, data); | 1715 | ret = btrfs_parse_options(root, data, *flags); |
1689 | if (ret) { | 1716 | if (ret) { |
1690 | ret = -EINVAL; | 1717 | ret = -EINVAL; |
1691 | goto restore; | 1718 | goto restore; |