From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 8/8] btrfs: sysfs: Add bdi link to the fsid dir
Date: Thu, 2 Jul 2020 15:23:35 +0300 [thread overview]
Message-ID: <20200702122335.9117-9-nborisov@suse.com> (raw)
In-Reply-To: <20200702122335.9117-1-nborisov@suse.com>
Since BTRFS uses a private bdi it makes sense to create a link to this
bdi under /sys/fs/btrfs/<UUID>/bdi. This allows size of read ahead to
be controlled. Without this patch it's not possible to uniquely identify
which bdi pertains to which btrfs filesystem in the fase of multiple
btrfs filesystem.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.h | 2 ++
fs/btrfs/sysfs.c | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 4dd478b4fe3a..eb61f89e9e85 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -928,6 +928,8 @@ struct btrfs_fs_info {
u32 sectorsize;
u32 stripesize;
+ bool bdi_link_created;
+
/* Block groups and devices containing active swapfiles. */
spinlock_t swapfile_pins_lock;
struct rb_root swapfile_pins;
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 5885abe57c3e..e167ec584627 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -937,8 +937,13 @@ void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
{
+ struct kobject *fsid_kobj = &fs_info->fs_devices->fsid_kobj;
+
btrfs_reset_fs_info_ptr(fs_info);
+ if (fs_info->bdi_link_created)
+ sysfs_remove_link(fsid_kobj, "bdi");
+
if (fs_info->space_info_kobj) {
sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs);
kobject_del(fs_info->space_info_kobj);
@@ -958,8 +963,8 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
}
#endif
addrm_unknown_feature_attrs(fs_info, false);
- sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group);
- sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs);
+ sysfs_remove_group(fsid_kobj, &btrfs_feature_attr_group);
+ sysfs_remove_files(fsid_kobj, btrfs_attrs);
btrfs_sysfs_remove_devices_dir(fs_info->fs_devices, NULL);
}
@@ -1410,6 +1415,13 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
if (error)
goto failure;
+ error = sysfs_create_link(fsid_kobj, &fs_info->sb->s_bdi->dev->kobj,
+ "bdi");
+ if (error)
+ goto failure;
+
+ fs_info->bdi_link_created = true;
+
#ifdef CONFIG_BTRFS_DEBUG
fs_info->debug_kobj = kobject_create_and_add("debug", fsid_kobj);
if (!fs_info->debug_kobj) {
--
2.17.1
next prev parent reply other threads:[~2020-07-02 13:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 12:23 [PATCH 0/7] Corrupt counter improvement Nikolay Borisov
2020-07-02 12:23 ` [PATCH 1/8] btrfs: Make get_state_failrec return failrec directly Nikolay Borisov
2020-07-02 13:07 ` Josef Bacik
2020-07-02 13:25 ` David Sterba
2020-07-02 12:23 ` [PATCH 2/8] btrfs: Streamline btrfs_get_io_failure_record logic Nikolay Borisov
2020-07-02 13:13 ` Josef Bacik
2020-07-02 12:23 ` [PATCH 3/8] btrfs: Record btrfs_device directly btrfs_io_bio Nikolay Borisov
2020-07-02 13:14 ` Josef Bacik
2020-07-02 13:16 ` Johannes Thumshirn
2020-07-03 8:14 ` [PATCH v2] " Nikolay Borisov
2020-07-03 13:06 ` Johannes Thumshirn
2020-07-02 12:23 ` [PATCH 4/8] btrfs: Don't check for btrfs_device::bdev in btrfs_end_bio Nikolay Borisov
2020-07-02 13:15 ` Josef Bacik
2020-07-02 12:23 ` [PATCH 5/8] btrfs: Increment device corruption error in case of checksum error Nikolay Borisov
2020-07-02 13:18 ` Josef Bacik
2020-07-02 13:21 ` Johannes Thumshirn
2020-07-02 14:44 ` Nikolay Borisov
2020-07-02 12:23 ` [PATCH 6/8] btrfs: Remove needless ASSERT Nikolay Borisov
2020-07-02 13:19 ` Josef Bacik
2020-07-02 13:26 ` Johannes Thumshirn
2020-07-02 12:23 ` [PATCH 7/8] btrfs: Increment corrupt device counter during compressed read Nikolay Borisov
2020-07-02 13:21 ` Josef Bacik
2020-07-02 13:28 ` Johannes Thumshirn
2020-07-02 12:23 ` Nikolay Borisov [this message]
2020-07-02 13:25 ` [PATCH 8/8] btrfs: sysfs: Add bdi link to the fsid dir Josef Bacik
2020-07-02 13:36 ` David Sterba
2020-07-02 14:41 ` Nikolay Borisov
2020-07-03 8:13 ` [PATCH v2] " Nikolay Borisov
2020-07-05 11:39 ` Anand Jain
2020-07-03 15:32 ` [PATCH 0/7] Corrupt counter improvement David Sterba
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=20200702122335.9117-9-nborisov@suse.com \
--to=nborisov@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