From: Josef Bacik <josef@toxicpanda.com>
To: Goffredo Baroncelli <kreijack@libero.it>
Cc: linux-btrfs@vger.kernel.org,
Zygo Blaxell <ce3g8jdj@umail.furryterror.org>,
David Sterba <dsterba@suse.cz>,
Sinnamohideen Shafeeq <shafeeqs@panasas.com>,
Paul Jones <paul@pauljones.id.au>, Boris Burkov <boris@bur.io>,
Goffredo Baroncelli <kreijack@inwind.it>
Subject: Re: [PATCH 2/5] btrfs: export the device allocation_hint property in sysfs
Date: Tue, 22 Mar 2022 14:05:18 -0400 [thread overview]
Message-ID: <YjoP3lreFX3eA4Ic@localhost.localdomain> (raw)
In-Reply-To: <aa62c61a0a9858d010d7d3ec67019332bd20d801.1646589622.git.kreijack@inwind.it>
On Sun, Mar 06, 2022 at 07:14:40PM +0100, Goffredo Baroncelli wrote:
> From: Goffredo Baroncelli <kreijack@inwind.it>
>
> Export the device allocation_hint property via
> /sys/fs/btrfs/<uuid>/devinfo/<devid>/allocation_hint
>
> Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
> ---
> fs/btrfs/sysfs.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index 17389a42a3ab..59d92a385a96 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -1578,6 +1578,36 @@ static ssize_t btrfs_devinfo_error_stats_show(struct kobject *kobj,
> }
> BTRFS_ATTR(devid, error_stats, btrfs_devinfo_error_stats_show);
>
> +
> +struct allocation_hint_name_t {
> + const char *name;
> + const u64 value;
> +} allocation_hint_name[] = {
> + { "DATA_PREFERRED", BTRFS_DEV_ALLOCATION_HINT_DATA_PREFERRED },
> + { "METADATA_PREFERRED", BTRFS_DEV_ALLOCATION_HINT_METADATA_PREFERRED },
> + { "DATA_ONLY", BTRFS_DEV_ALLOCATION_HINT_DATA_ONLY },
> + { "METADATA_ONLY", BTRFS_DEV_ALLOCATION_HINT_METADATA_ONLY },
> +};
> +
The ktest robot complained about this, but also we don't need to be this clever,
also it looks better to have the flags first with standard tabbing.
struct allocation_hint_name {
const u64 val;
const char *name;
};
static struct allocation_hint_name allocation_hints[] = {
{ BTRFS_DEV_ALLOCATION_HINT_DATA_PREFERRED, "DATA_PREFERRED" },
{ BTRFS_DEV_ALLOCATION_HINT_METADATA_PREFERRED, "METADATA_PREFERRED" },
...
};
> +static ssize_t btrfs_devinfo_allocation_hint_show(struct kobject *kobj,
> + struct kobj_attribute *a, char *buf)
> +{
> + int i;
> + struct btrfs_device *device = container_of(kobj, struct btrfs_device,
> + devid_kobj);
> +
> + for (i = 0 ; i < ARRAY_SIZE(allocation_hint_name) ; i++) {
> + if ((device->type & BTRFS_DEV_ALLOCATION_HINT_MASK) !=
> + allocation_hint_name[i].value)
> + continue;
> +
> + return scnprintf(buf, PAGE_SIZE, "%s\n",
> + allocation_hint_name[i].name);
> + }
> + return scnprintf(buf, PAGE_SIZE, "<UNKNOWN>\n");
Since we have fs'es that won't use this you should just spit out "NONE".
Thanks,
Josef
next prev parent reply other threads:[~2022-03-22 18:05 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 18:14 [PATCH 0/5][V12] btrfs: allocation_hint Goffredo Baroncelli
2022-03-06 18:14 ` [PATCH 1/5] btrfs: add flags to give an hint to the chunk allocator Goffredo Baroncelli
2022-03-22 17:51 ` Josef Bacik
2022-03-22 17:56 ` Josef Bacik
2022-03-22 18:49 ` Goffredo Baroncelli
2022-04-06 19:32 ` Goffredo Baroncelli
2022-03-23 3:26 ` Zygo Blaxell
2022-03-22 19:52 ` Josef Bacik
2022-03-22 20:25 ` Goffredo Baroncelli
2022-03-23 2:56 ` Zygo Blaxell
2022-03-24 19:05 ` Goffredo Baroncelli
2022-03-25 14:59 ` Josef Bacik
2022-03-25 18:55 ` Goffredo Baroncelli
2022-03-06 18:14 ` [PATCH 2/5] btrfs: export the device allocation_hint property in sysfs Goffredo Baroncelli
2022-03-08 13:25 ` kernel test robot
2022-03-22 18:05 ` Josef Bacik [this message]
2022-03-22 19:02 ` Goffredo Baroncelli
2022-03-06 18:14 ` [PATCH 3/5] btrfs: change the device allocation_hint property via sysfs Goffredo Baroncelli
2022-03-22 19:19 ` Josef Bacik
2022-03-22 19:52 ` Goffredo Baroncelli
2022-03-06 18:14 ` [PATCH 4/5] btrfs: add allocation_hint mode Goffredo Baroncelli
2022-03-22 19:47 ` Josef Bacik
2022-03-22 20:56 ` Goffredo Baroncelli
2022-03-06 18:14 ` [PATCH 5/5] btrfs: rename dev_item->type to dev_item->flags Goffredo Baroncelli
2022-03-21 20:29 ` [PATCH 0/5][V12] btrfs: allocation_hint Goffredo Baroncelli
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=YjoP3lreFX3eA4Ic@localhost.localdomain \
--to=josef@toxicpanda.com \
--cc=boris@bur.io \
--cc=ce3g8jdj@umail.furryterror.org \
--cc=dsterba@suse.cz \
--cc=kreijack@inwind.it \
--cc=kreijack@libero.it \
--cc=linux-btrfs@vger.kernel.org \
--cc=paul@pauljones.id.au \
--cc=shafeeqs@panasas.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.