Skip to content

Commit

Permalink
Merge tag 'for-5.19-rc3-tag' of git:https://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/kdave/linux

Pull btrfs fixes from David Sterba:

 - print more error messages for invalid mount option values

 - prevent remount with v1 space cache for subpage filesystem

 - fix hang during unmount when block group reclaim task is running

* tag 'for-5.19-rc3-tag' of git:https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: add error messages to all unrecognized mount options
  btrfs: prevent remounting to v1 space cache for subpage mount
  btrfs: fix hang during unmount when block group reclaim task is running
  • Loading branch information
torvalds committed Jun 21, 2022
2 parents cb78d1b + e3a4167 commit ff872b7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
13 changes: 11 additions & 2 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4632,6 +4632,17 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
int ret;

set_bit(BTRFS_FS_CLOSING_START, &fs_info->flags);

/*
* We may have the reclaim task running and relocating a data block group,
* in which case it may create delayed iputs. So stop it before we park
* the cleaner kthread otherwise we can get new delayed iputs after
* parking the cleaner, and that can make the async reclaim task to hang
* if it's waiting for delayed iputs to complete, since the cleaner is
* parked and can not run delayed iputs - this will make us hang when
* trying to stop the async reclaim task.
*/
cancel_work_sync(&fs_info->reclaim_bgs_work);
/*
* We don't want the cleaner to start new transactions, add more delayed
* iputs, etc. while we're closing. We can't use kthread_stop() yet
Expand Down Expand Up @@ -4672,8 +4683,6 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
cancel_work_sync(&fs_info->async_data_reclaim_work);
cancel_work_sync(&fs_info->preempt_reclaim_work);

cancel_work_sync(&fs_info->reclaim_bgs_work);

/* Cancel or finish ongoing discard work */
btrfs_discard_cleanup(fs_info);

Expand Down
47 changes: 40 additions & 7 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
compress_force = false;
no_compress++;
} else {
btrfs_err(info, "unrecognized compression value %s",
args[0].from);
ret = -EINVAL;
goto out;
}
Expand Down Expand Up @@ -821,8 +823,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
case Opt_thread_pool:
ret = match_int(&args[0], &intarg);
if (ret) {
btrfs_err(info, "unrecognized thread_pool value %s",
args[0].from);
goto out;
} else if (intarg == 0) {
btrfs_err(info, "invalid value 0 for thread_pool");
ret = -EINVAL;
goto out;
}
Expand Down Expand Up @@ -883,8 +888,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
break;
case Opt_ratio:
ret = match_int(&args[0], &intarg);
if (ret)
if (ret) {
btrfs_err(info, "unrecognized metadata_ratio value %s",
args[0].from);
goto out;
}
info->metadata_ratio = intarg;
btrfs_info(info, "metadata ratio %u",
info->metadata_ratio);
Expand All @@ -901,6 +909,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
btrfs_set_and_info(info, DISCARD_ASYNC,
"turning on async discard");
} else {
btrfs_err(info, "unrecognized discard mode value %s",
args[0].from);
ret = -EINVAL;
goto out;
}
Expand Down Expand Up @@ -933,6 +943,8 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
btrfs_set_and_info(info, FREE_SPACE_TREE,
"enabling free space tree");
} else {
btrfs_err(info, "unrecognized space_cache value %s",
args[0].from);
ret = -EINVAL;
goto out;
}
Expand Down Expand Up @@ -1014,8 +1026,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
break;
case Opt_check_integrity_print_mask:
ret = match_int(&args[0], &intarg);
if (ret)
if (ret) {
btrfs_err(info,
"unrecognized check_integrity_print_mask value %s",
args[0].from);
goto out;
}
info->check_integrity_print_mask = intarg;
btrfs_info(info, "check_integrity_print_mask 0x%x",
info->check_integrity_print_mask);
Expand All @@ -1030,22 +1046,28 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
goto out;
#endif
case Opt_fatal_errors:
if (strcmp(args[0].from, "panic") == 0)
if (strcmp(args[0].from, "panic") == 0) {
btrfs_set_opt(info->mount_opt,
PANIC_ON_FATAL_ERROR);
else if (strcmp(args[0].from, "bug") == 0)
} else if (strcmp(args[0].from, "bug") == 0) {
btrfs_clear_opt(info->mount_opt,
PANIC_ON_FATAL_ERROR);
else {
} else {
btrfs_err(info, "unrecognized fatal_errors value %s",
args[0].from);
ret = -EINVAL;
goto out;
}
break;
case Opt_commit_interval:
intarg = 0;
ret = match_int(&args[0], &intarg);
if (ret)
if (ret) {
btrfs_err(info, "unrecognized commit_interval value %s",
args[0].from);
ret = -EINVAL;
goto out;
}
if (intarg == 0) {
btrfs_info(info,
"using default commit interval %us",
Expand All @@ -1059,8 +1081,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
break;
case Opt_rescue:
ret = parse_rescue_options(info, args[0].from);
if (ret < 0)
if (ret < 0) {
btrfs_err(info, "unrecognized rescue value %s",
args[0].from);
goto out;
}
break;
#ifdef CONFIG_BTRFS_DEBUG
case Opt_fragment_all:
Expand Down Expand Up @@ -1985,6 +2010,14 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
if (ret)
goto restore;

/* V1 cache is not supported for subpage mount. */
if (fs_info->sectorsize < PAGE_SIZE && btrfs_test_opt(fs_info, SPACE_CACHE)) {
btrfs_warn(fs_info,
"v1 space cache is not supported for page size %lu with sectorsize %u",
PAGE_SIZE, fs_info->sectorsize);
ret = -EINVAL;
goto restore;
}
btrfs_remount_begin(fs_info, old_opts, *flags);
btrfs_resize_thread_pool(fs_info,
fs_info->thread_pool_size, old_thread_pool_size);
Expand Down

0 comments on commit ff872b7

Please sign in to comment.