From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org, lists@colorremedies.com
Subject: Re: [PATCH v2] btrfs: ioctl BTRFS_IOC_FS_INFO and BTRFS_IOC_DEV_INFO miss-matched with slots
Date: Thu, 4 Sep 2014 11:58:12 +0200 [thread overview]
Message-ID: <20140904095812.GA5636@twin.jikos.cz> (raw)
In-Reply-To: <1408351099-4721-2-git-send-email-anand.jain@oracle.com>
On Mon, Aug 18, 2014 at 04:38:18PM +0800, Anand Jain wrote:
> ioctl BTRFS_IOC_FS_INFO return num_devices which does _not_ include seed
> device, But the following ioctl BTRFS_IOC_DEV_INFO counts and gets seed
> disk when probed. So in the userland we hit a count-slot missmatch
> bug..
> get_fs_info()
> ::
> BUG_ON(ndevs >= fi_args->num_devices);
> which hits this bug when we have mounted a seed device.
>
> So to fix this problem here in this patch ioctl BTRFS_IOC_FS_INFO
> will provide total_devices instead of num_devices.
The ioctl is very unclear what the 'num_device' actually means.
> This would fix the problem partly. Partly because ealier num_devices
> included the replacing device but now total_device does not include
> the replacing device. Getting a count which includes a transient device
> is rather too in efficient/wrong indeed, because there can be a race
> condition where in the time between ioctl BTRFS_IOC_FS_INFO to
> BTRFS_IOC_DEV_INFO the replace device operation might have been
> completed. So to fix this problem its better that user land btrfs-progs
> probes replacing device (at devid 0) separately.
>
> v2:
> Agree with Wang's comment. Its better to show seed disks under the
> sprout fs, so that user can establish mapping of seed to sprout devices.
>
> So here I am making BTRFS_IOC_FS_INFO to return the total_devices
> which would count the seed devices (but not the replacing device).
This is even more confusing. I think we need to add another member to
the ioctl struct to reflect the number of regular devices (num_devices)
and the true total number of devices including seeding and replaced
devices. The difference should be accompanied by a flag that would say
if there's a seeding or replace in progress.
There are some backward compatibility concerns. Setting num_devices to
total_devices changes semantics of the ioctl, so I think it should stay
as is for now, but the BUG_ON can be removed and replaced by code that
reallocates the buffer or allocates a few more items in advance.
next prev parent reply other threads:[~2014-09-04 9:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-16 3:08 [PATCH] make 'btrfs filesystem show' to work when seeding Anand Jain
2014-08-16 3:08 ` [PATCH] btrfs: ioctl BTRFS_IOC_FS_INFO and BTRFS_IOC_DEV_INFO miss-matched with slots Anand Jain
2014-08-16 3:08 ` [PATCH] btrfs-progs: do a separate probe for _transient_ replacing device As mentioned in the kernel patch " Anand Jain
2014-08-18 8:38 ` [PATCH v2] make 'btrfs filesystem show' to work when seeding Anand Jain
2014-08-18 8:38 ` [PATCH v2] btrfs: ioctl BTRFS_IOC_FS_INFO and BTRFS_IOC_DEV_INFO miss-matched with slots Anand Jain
2014-09-04 9:58 ` David Sterba [this message]
2014-09-04 12:02 ` Anand Jain
2014-10-17 1:58 ` Gui Hecheng
2014-10-20 8:17 ` Anand Jain
2014-10-29 10:39 ` Anand Jain
2014-08-18 8:38 ` [PATCH v2] btrfs-progs: do a separate probe for transient replacing device 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=20140904095812.GA5636@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=lists@colorremedies.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 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).