From: Roman Mamedov <rm@romanrm.net>
To: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: auto enable discard=async when possible
Date: Wed, 27 Jul 2022 23:47:58 +0500 [thread overview]
Message-ID: <20220727234758.33232508@nvm> (raw)
In-Reply-To: <20220727150158.GT13489@suse.cz>
On Wed, 27 Jul 2022 17:01:58 +0200
David Sterba <dsterba@suse.com> wrote:
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1503,6 +1503,7 @@ enum {
> BTRFS_MOUNT_DISCARD_ASYNC = (1UL << 28),
> BTRFS_MOUNT_IGNOREBADROOTS = (1UL << 29),
> BTRFS_MOUNT_IGNOREDATACSUMS = (1UL << 30),
> + BTRFS_MOUNT_NODISCARD = (1UL << 31),
> };
>
> #define BTRFS_DEFAULT_COMMIT_INTERVAL (30)
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 3fac429cf8a4..8f8e33219d4d 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3767,6 +3767,20 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
> btrfs_set_and_info(fs_info, SSD, "enabling ssd optimizations");
> }
>
> + /*
> + * For devices supporting discard turn on discard=async automatically,
> + * unless it's already set or disabled. This could be turned off by
> + * nodiscard for the same mount.
> + */
> + if (!(btrfs_test_opt(fs_info, DISCARD_SYNC) ||
> + btrfs_test_opt(fs_info, DISCARD_ASYNC) ||
> + btrfs_test_opt(fs_info, NODISCARD)) &&
> + fs_info->fs_devices->discardable) {
> + btrfs_set_and_info(fs_info, DISCARD_ASYNC,
> + "auto enabling discard=async");
> + btrfs_clear_opt(fs_info->mount_opt, NODISCARD);
Spaces are used in the above line instead of a 2nd TAB.
Also I am probably clueless, but it seems the condition just checked that
NODISCARD was not set, so what is the purpose of also clearing it?
Thanks
--
With respect,
Roman
next prev parent reply other threads:[~2022-07-27 19:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 15:01 [PATCH] btrfs: auto enable discard=async when possible David Sterba
2022-07-27 18:46 ` Boris Burkov
2022-07-27 18:47 ` Roman Mamedov [this message]
2022-07-28 11:57 ` David Sterba
2022-08-06 7:29 ` Neal Gompa
2022-11-06 5:08 ` Wang Yugui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220727234758.33232508@nvm \
--to=rm@romanrm.net \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox