From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com
Subject: [PATCH resend 2/4] btrfs: sysfs, add UUID/devinfo kobject
Date: Mon, 3 Feb 2020 19:00:10 +0800 [thread overview]
Message-ID: <20200203110012.5954-3-anand.jain@oracle.com> (raw)
In-Reply-To: <20200203110012.5954-1-anand.jain@oracle.com>
Preparatory patch creates kobject /sys/fs/btrfs/UUID/devinfo to hold
btrfs_fs_devices::dev_state attribute.
This is being added in the mount context, that means we don't see
UUID/devinfo before the mount (yet).
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/sysfs.c | 15 +++++++++++++++
fs/btrfs/volumes.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 8def038dc2bd..58ef2c04e5be 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -901,6 +901,12 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
{
+ if (fs_devs->devinfo_kobj) {
+ kobject_del(fs_devs->devinfo_kobj);
+ kobject_put(fs_devs->devinfo_kobj);
+ fs_devs->devinfo_kobj = NULL;
+ }
+
if (fs_devs->devices_kobj) {
kobject_del(fs_devs->devices_kobj);
kobject_put(fs_devs->devices_kobj);
@@ -1260,6 +1266,15 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs)
return -ENOMEM;
}
+ fs_devs->devinfo_kobj = kobject_create_and_add("devinfo",
+ &fs_devs->fsid_kobj);
+ if (!fs_devs->devinfo_kobj) {
+ btrfs_err(fs_devs->fs_info,
+ "failed to init sysfs devinfo kobject");
+ btrfs_sysfs_remove_fsid(fs_devs);
+ return -ENOMEM;
+ }
+
return 0;
}
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 9c7d4fe5c39a..98535f1e208e 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -254,6 +254,7 @@ struct btrfs_fs_devices {
/* sysfs kobjects */
struct kobject fsid_kobj;
struct kobject *devices_kobj;
+ struct kobject *devinfo_kobj;
struct completion kobj_unregister;
};
--
2.23.0
next prev parent reply other threads:[~2020-02-03 11:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-03 11:00 [PATCH 0/4 RESEND 1-3/4 v5 4/4] btrfs, sysfs cleanup and add dev_state Anand Jain
2020-02-03 11:00 ` [PATCH resend 1/4] btrfs: sysfs, use btrfs_sysfs_remove_fsid in fail return in add_fsid Anand Jain
2020-02-03 11:00 ` Anand Jain [this message]
2020-02-03 11:00 ` [PATCH resend v2 3/4] btrfs: sysfs, rename device_link add,remove functions Anand Jain
2020-02-03 11:00 ` [PATCH v5 4/4] btrfs: sysfs, add devid/dev_state kobject and device attribute Anand Jain
2020-02-03 17:16 ` [PATCH 0/4 RESEND 1-3/4 v5 4/4] btrfs, sysfs cleanup and add dev_state David Sterba
2020-02-06 6:31 ` Anand Jain
2020-02-06 14:11 ` David Sterba
2020-02-11 4:46 ` Anand Jain
2020-02-11 19:29 ` David Sterba
2020-02-12 9:29 ` 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=20200203110012.5954-3-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--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