From: Anand Jain <Anand.Jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/3 RFC] btrfs: total_devices should count replacing devices
Date: Fri, 7 Mar 2014 23:48:38 +0800 [thread overview]
Message-ID: <1394207319-13252-2-git-send-email-Anand.Jain@oracle.com> (raw)
In-Reply-To: <1394207319-13252-1-git-send-email-Anand.Jain@oracle.com>
ioctl(BTRFS_IOC_FS_INFO) returns num_devices which does not
count seed device. num_devices is used to calculate
the number of slots during the ioctl(BTRFS_IOC_DEV_INFO)
but ioctl(BTRFS_IOC_DEV_INFO) would count seed devices as well.
Due to this miss match btrfs_progs get_fs_info() hits the bug..
get_fs_info()
::
BUG_ON(ndevs >= fi_args->num_devices);
what I notice is total_devices should be returned by the
ioctl(BTRFS_IOC_FS_INFO)), however total_devices does not
count (transient) replacing device but num_devices does.
first, num_devices which appears to be a subset of
total_devices helps to count the number of devices
under a FSID which excludes the seed devices but
includes the transient replacing device.
total_devices which includes seed devices is as of
now does not count the tansient replacing device,
which IMO is a bug or the implementation details
are not clear enough to state the role of num_devices
and total_devices.
The user land on the otherhand would want to know
all the devices that would come out of probe
against a FSID
As of now in this patch I am making the ioctl.c local
changes (instead of asking replace thread to update
total_devices) to include replacing device.
Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
---
fs/btrfs/ioctl.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 5036f9d..ec7d5c6 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2510,6 +2510,7 @@ static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg)
struct btrfs_device *next;
struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
int ret = 0;
+ int dev_replace_running = 0;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -2518,8 +2519,18 @@ static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg)
if (!fi_args)
return -ENOMEM;
+ btrfs_dev_replace_lock(&root->fs_info->dev_replace);
+ if (btrfs_dev_replace_is_ongoing(&root->fs_info->dev_replace))
+ dev_replace_running = 1;
+
+ btrfs_dev_replace_unlock(&root->fs_info->dev_replace);
+
mutex_lock(&fs_devices->device_list_mutex);
- fi_args->num_devices = fs_devices->num_devices;
+ if (dev_replace_running)
+ fi_args->num_devices = fs_devices->total_devices + 1;
+ else
+ fi_args->num_devices = fs_devices->total_devices;
+
memcpy(&fi_args->fsid, root->fs_info->fsid, sizeof(fi_args->fsid));
list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
--
1.8.5.3
next prev parent reply other threads:[~2014-03-07 15:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 15:48 [PATCH 1/3 v2 RFC] btrfs: total_devices vs num_devices Anand Jain
2014-03-07 15:48 ` Anand Jain [this message]
2014-05-13 9:17 ` [PATCH 2/3 RFC] btrfs: total_devices should count replacing devices Wang Shilong
2014-05-14 8:30 ` Anand Jain
2014-05-16 14:11 ` Anand Jain
2014-03-07 15:48 ` [PATCH 3/3 RFC] btrfs: show_devname should not consider seed disk Anand Jain
2014-03-10 1:58 ` [PATCH 1/3 v2 RFC] btrfs: total_devices vs num_devices 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=1394207319-13252-2-git-send-email-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;
as well as URLs for NNTP newsgroup(s).