From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: update devid after replace
Date: Wed, 15 Jan 2020 16:22:50 +0800 [thread overview]
Message-ID: <20200115082250.3064-1-anand.jain@oracle.com> (raw)
In-Reply-To: <20200114183958.GJ3929@twin.jikos.cz>
During the replace the target device temporarily assumes devid 0 before
assigning the devid of the soruce device.
In btrfs_dev_replace_finishing() we remove source sysfs devid using
the function btrfs_sysfs_remove_devices_attr(), so after that call
kobject_rename() to update the devid in the sysfs.
This adds and calls btrfs_sysfs_update_devid() helper function to update
the device id.
This patch must be squashed with the patch
[PATCH v4] btrfs: sysfs, add devid/dev_state kobject and attribute
or its variant.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
David,
I couldn't find the patch-series..
[PATCH 0/4] btrfs, sysfs cleanup and add dev_state
in your misc-next. And I believe there were changes like
function rename and attribute list reorder in your workspace. So I am
sending a fix-patch which must be squashed to the patch v4 4/4.
With this patch, the test case btrfs/064 runs fine. And volume group
tests are still running.
fs/btrfs/dev-replace.c | 1 +
fs/btrfs/sysfs.c | 11 +++++++++++
fs/btrfs/sysfs.h | 1 +
3 files changed, 13 insertions(+)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 9a29d6de9017..ccdb486bd4c3 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -707,6 +707,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
/* replace the sysfs entry */
btrfs_sysfs_remove_devices_attr(fs_info->fs_devices, src_device);
+ btrfs_sysfs_update_devid(tgt_device);
btrfs_rm_dev_replace_free_srcdev(src_device);
/* write back the superblocks */
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 0b615d99cedd..22971268e5b6 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -1189,6 +1189,17 @@ int btrfs_sysfs_remove_devices_attr(struct btrfs_fs_devices *fs_devices,
return 0;
}
+void btrfs_sysfs_update_devid(struct btrfs_device *device)
+{
+ char tmp[64];
+
+ snprintf(tmp, sizeof(tmp), "%llu", device->devid);
+
+ if (kobject_rename(&device->devid_kobj, tmp))
+ btrfs_warn(device->fs_devices->fs_info,
+ "sysfs: failed to update devid");
+}
+
static ssize_t btrfs_sysfs_writeable_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index 9d97b3c8db4e..ccf33eaf9e59 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -34,5 +34,6 @@ void btrfs_sysfs_add_block_group_type(struct btrfs_block_group *cache);
int btrfs_sysfs_add_space_info_type(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info);
void btrfs_sysfs_remove_space_info(struct btrfs_space_info *space_info);
+void btrfs_sysfs_update_devid(struct btrfs_device *device);
#endif
--
2.23.0
next prev parent reply other threads:[~2020-01-15 8:23 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-05 11:27 [PATCH 0/4] btrfs, sysfs cleanup and add dev_state Anand Jain
2019-12-05 11:27 ` [PATCH 1/4] btrfs: sysfs, use btrfs_sysfs_remove_fsid in fail return in add_fsid Anand Jain
2019-12-05 11:27 ` [PATCH 2/4] btrfs: sysfs, add UUID/devinfo kobject Anand Jain
2020-01-14 18:32 ` David Sterba
2020-02-03 10:40 ` Anand Jain
2019-12-05 11:27 ` [PATCH v2 3/4] btrfs: sysfs, rename device_link add,remove functions Anand Jain
2019-12-05 11:27 ` [PATCH 4/4] btrfs: sysfs, add devid/dev_state kobject and attribute Anand Jain
2019-12-05 14:10 ` David Sterba
2019-12-05 14:38 ` Anand Jain
2019-12-05 14:21 ` David Sterba
2019-12-05 14:38 ` Anand Jain
2019-12-05 15:14 ` David Sterba
2019-12-06 13:49 ` Anand Jain
2019-12-09 14:05 ` Anand Jain
2019-12-09 18:31 ` David Sterba
2019-12-13 16:43 ` David Sterba
2019-12-13 17:02 ` David Sterba
2019-12-14 0:26 ` Anand Jain
2020-01-06 16:00 ` David Sterba
2019-12-09 14:06 ` [PATCH v2 " Anand Jain
2019-12-19 10:41 ` [PATCH v3 " Anand Jain
2020-01-06 11:38 ` [PATCH v4] " Anand Jain
2020-01-09 15:20 ` [PATCH v4 4/4] " David Sterba
2020-01-10 1:03 ` Anand Jain
2019-12-05 15:00 ` [PATCH 0/4] btrfs, sysfs cleanup and add dev_state David Sterba
2019-12-06 13:46 ` Anand Jain
2019-12-09 14:09 ` Anand Jain
2019-12-09 22:48 ` Anand Jain
2019-12-10 16:41 ` David Sterba
2020-01-14 18:39 ` David Sterba
2020-01-15 8:22 ` Anand Jain [this message]
2020-01-15 16:17 ` [PATCH] btrfs: update devid after replace David Sterba
2020-01-20 19:10 ` 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=20200115082250.3064-1-anand.jain@oracle.com \
--to=anand.jain@oracle.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