From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org, josef@toxicpanda.com, dsterba@suse.com
Subject: Re: [PATCH v9 3/3] btrfs: create read policy sysfs attribute, pid
Date: Mon, 26 Oct 2020 18:57:50 +0100 [thread overview]
Message-ID: <20201026175750.GT6756@twin.jikos.cz> (raw)
In-Reply-To: <abd366082eeb8b289cd420cb04528a687a250433.1603347462.git.anand.jain@oracle.com>
On Thu, Oct 22, 2020 at 03:43:37PM +0800, Anand Jain wrote:
> Add
>
> /sys/fs/btrfs/UUID/read_policy
>
> attribute so that the read policy for the raid1, raid1c34 and raid10 can
> be tuned.
>
> When this attribute is read, it shall show all available policies, with
> active policy being with in [ ]. The read_policy attribute can be written
> using one of the items listed in there.
>
> For example:
> $cat /sys/fs/btrfs/UUID/read_policy
> [pid]
> $echo pid > /sys/fs/btrfs/UUID/read_policy
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v9: fix C coding style, static const char*
> v5:
> Title rename: old: btrfs: sysfs, add read_policy attribute
> Uses the btrfs_strmatch() helper (BTRFS_READ_POLICY_NAME_MAX dropped).
> Use the table for the policy names.
> Rename len to ret.
> Use a simple logic to prefix space in btrfs_read_policy_show()
> Reviewed-by: Josef Bacik <josef@toxicpanda.com> dropped.
>
> v4:-
> v3: rename [by_pid] to [pid]
> v2: v2: check input len before strip and kstrdup
>
> fs/btrfs/sysfs.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index 5ea262d289c6..e23ae3643527 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -883,6 +883,54 @@ static int btrfs_strmatch(const char *given, const char *golden)
> return -EINVAL;
> }
>
> +static const char * const btrfs_read_policy_name[] = { "pid" };
> +
> +static ssize_t btrfs_read_policy_show(struct kobject *kobj,
> + struct kobj_attribute *a, char *buf)
> +{
> + int i;
> + ssize_t ret = 0;
> + struct btrfs_fs_devices *fs_devices = to_fs_devs(kobj);
> +
> + for (i = 0; i < BTRFS_NR_READ_POLICY; i++) {
> + if (fs_devices->read_policy == i)
> + ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s[%s]",
All snprintf have been upgraded to scnprintf as it does have sane
behaviour when the buffer is not large enough.
> + (ret == 0 ? "" : " "),
> + btrfs_read_policy_name[i]);
> + else
> + ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s%s",
> + (ret == 0 ? "" : " "),
> + btrfs_read_policy_name[i]);
> + }
> +
> + ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
> +
> + return ret;
> +}
next prev parent reply other threads:[~2020-10-26 17:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 7:43 [PATCH v9 0/3] readmirror feature (read_policy sysfs and in-memory only approach) Anand Jain
2020-10-22 7:43 ` [PATCH v9 1/3] btrfs: add btrfs_strmatch helper Anand Jain
2020-10-23 11:12 ` Christoph Hellwig
2020-10-27 13:25 ` Anand Jain
2020-10-26 17:52 ` David Sterba
2020-10-27 13:19 ` Anand Jain
2020-10-27 18:00 ` David Sterba
2020-10-22 7:43 ` [PATCH v9 2/3] btrfs: create read policy framework Anand Jain
2020-10-22 7:43 ` [PATCH v9 3/3] btrfs: create read policy sysfs attribute, pid Anand Jain
2020-10-26 17:57 ` David Sterba [this message]
2020-10-28 12:37 ` Anand Jain
2020-10-23 17:04 ` [PATCH v9 0/3] readmirror feature (read_policy sysfs and in-memory only approach) David Sterba
2020-10-27 1:52 ` Anand Jain
2020-10-27 18:02 ` David Sterba
2020-10-28 12:06 ` Anand Jain
2020-10-26 14:01 ` Josef Bacik
2020-10-28 4:25 ` [PATCH v10 " Anand Jain
2020-10-28 4:25 ` [PATCH v10 1/3] btrfs: add btrfs_strmatch helper Anand Jain
2020-10-28 4:25 ` [PATCH v10 2/3] btrfs: create read policy framework Anand Jain
2020-10-28 4:25 ` [PATCH v10 3/3] btrfs: create read policy sysfs attribute, pid Anand Jain
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=20201026175750.GT6756@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.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