From: Josef Bacik <josef@toxicpanda.com>
To: kreijack@inwind.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>
Subject: Re: [PATCH 0/7][V11] btrfs: allocation_hint
Date: Tue, 1 Mar 2022 10:07:08 -0500 [thread overview]
Message-ID: <Yh42nDUquZIqVMC0@localhost.localdomain> (raw)
In-Reply-To: <c7fc88cd-a1e5-eb74-d89d-e0a79404f6bf@libero.it>
On Mon, Feb 28, 2022 at 10:01:35PM +0100, Goffredo Baroncelli wrote:
> Hi Josef,
>
> On 28/02/2022 18.04, Josef Bacik wrote:
> > On Wed, Jan 26, 2022 at 09:32:07PM +0100, Goffredo Baroncelli wrote:
> > > From: Goffredo Baroncelli <kreijack@inwind.it>
> > >
> > > Hi all,
> > >
> [...
>
> > > In V11 I added a new 'feature' file /sys/fs/btrfs/features/allocation_hint
> > > to help the detection of the allocation_hint feature.
> > >
> >
> > Sorry Goffredo I dropped the ball on this, lets try and get this shit nailed
> > down and done so we can get it merged. The code overall looks good, I just have
> > two things I want changed
> >
> > 1. The sysfs file should use a string, not a magic number. Think how
> > /sys/block/<dev>/queue/scheduler works. You echo "metadata_only" >
> > allocation_hint, you cat allocation_hint and it says "none" or
> > "metadata_only". If you want to be fancy you can do exactly like
> > queue/scheduler and show the list of options with [] around the selected
> > option.
>
> Ok.
> >
> > 2. I hate the major_minor thing, can you do similar to what we do for devices/
> > and symlink the correct device sysfs directory under devid?
> >
> Ok, do you have any suggestion for the name ? what about bdev ?
>
You literally just add a link to the device kobj to the devid kobj. If you look
at btrfs_sysfs_add_device(), you would do something like this (completely
untested and uncompiled)
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 17389a42a3ab..cc570078bf7d 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -1450,8 +1450,10 @@ void btrfs_sysfs_remove_device(struct btrfs_device *device)
devices_kobj = device->fs_info->fs_devices->devices_kobj;
ASSERT(devices_kobj);
- if (device->bdev)
+ if (device->bdev) {
sysfs_remove_link(devices_kobj, bdev_kobj(device->bdev)->name);
+ sysfs_remove_link(&device->devid_kobj, bdev_kobj(device->bdev)->name);
+ }
if (device->devid_kobj.state_initialized) {
kobject_del(&device->devid_kobj);
@@ -1628,10 +1630,23 @@ int btrfs_sysfs_add_device(struct btrfs_device *device)
nofs_flag = memalloc_nofs_save();
+ init_completion(&device->kobj_unregister);
+ ret = kobject_init_and_add(&device->devid_kobj, &devid_ktype,
+ devinfo_kobj, "%llu", device->devid);
+ if (ret) {
+ kobject_put(&device->devid_kobj);
+ btrfs_warn(device->fs_info,
+ "devinfo init for devid %llu failed: %d",
+ device->devid, ret);
+ }
+
if (device->bdev) {
struct kobject *disk_kobj = bdev_kobj(device->bdev);
ret = sysfs_create_link(devices_kobj, disk_kobj, disk_kobj->name);
+ if (!ret)
+ ret = sysfs_create_link(device->devid_kobj, disk_kobj,
+ disk_kobj->name);
if (ret) {
btrfs_warn(device->fs_info,
"creating sysfs device link for devid %llu failed: %d",
@@ -1640,16 +1655,6 @@ int btrfs_sysfs_add_device(struct btrfs_device *device)
}
}
- init_completion(&device->kobj_unregister);
- ret = kobject_init_and_add(&device->devid_kobj, &devid_ktype,
- devinfo_kobj, "%llu", device->devid);
- if (ret) {
- kobject_put(&device->devid_kobj);
- btrfs_warn(device->fs_info,
- "devinfo init for devid %llu failed: %d",
- device->devid, ret);
- }
-
out:
memalloc_nofs_restore(nofs_flag);
return ret;
next prev parent reply other threads:[~2022-03-01 15:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 20:32 [PATCH 0/7][V11] btrfs: allocation_hint Goffredo Baroncelli
2022-01-26 20:32 ` [PATCH 1/7] btrfs: add flags to give an hint to the chunk allocator Goffredo Baroncelli
2022-01-26 20:32 ` [PATCH 2/7] btrfs: export the device allocation_hint property in sysfs Goffredo Baroncelli
2022-01-26 20:32 ` [PATCH 3/7] btrfs: change the device allocation_hint property via sysfs Goffredo Baroncelli
2022-01-26 20:32 ` [PATCH 4/7] btrfs: add allocation_hint mode Goffredo Baroncelli
2022-01-26 20:32 ` [PATCH 5/7] btrfs: rename dev_item->type to dev_item->flags Goffredo Baroncelli
2022-01-26 20:32 ` [PATCH 6/7] btrfs: add major and minor to sysfs Goffredo Baroncelli
2022-01-26 20:32 ` [PATCH 7/7] Add /sys/fs/btrfs/features/allocation_hint Goffredo Baroncelli
2022-02-15 18:49 ` [PATCH 0/7][V11] btrfs: allocation_hint Goffredo Baroncelli
2022-02-16 0:22 ` Qu Wenruo
2022-02-16 3:28 ` Zygo Blaxell
2022-02-16 4:43 ` Paul Jones
2022-02-25 20:18 ` Boris Burkov
2022-02-28 17:04 ` Josef Bacik
2022-02-28 21:01 ` Goffredo Baroncelli
2022-03-01 15:07 ` Josef Bacik [this message]
2022-03-01 18:55 ` Goffredo Baroncelli
2022-03-01 21:43 ` Josef Bacik
2022-03-02 19:30 ` Goffredo Baroncelli
2022-03-02 21:23 ` Josef Bacik
2022-03-03 19:01 ` Goffredo Baroncelli
2022-03-04 14:56 ` Josef Bacik
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=Yh42nDUquZIqVMC0@localhost.localdomain \
--to=josef@toxicpanda.com \
--cc=boris@bur.io \
--cc=ce3g8jdj@umail.furryterror.org \
--cc=dsterba@suse.cz \
--cc=kreijack@inwind.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.