Josef Bacik | 21 Jun 2012 22:10
Favicon

[RFC] A way to tell if all the devices in a file system are available

Harald Hoyer has had this as a feature request for ages and I've finally gotten
around to hacking something up.  This is probably going to get bikeshedded to
death, bring it on, I'm not married to any of the behaviors in these patches, I
just want to get the ball rolling so we can have something in place for 3.6.

Basically all I've done is saved how many devices the super block thinks we have
into the fs_devices struct whenever we scan a device.  Then all we have to do
for the IOCTL is compare how many devices the fs_devices struct has in it to how
many we think we need.

The command itself just spits out 0 for yay we're ready and 1 for boo no we're
not.  This makes it easier for Harald to do his multi-device btrfs support in
dracut.  Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Josef Bacik | 21 Jun 2012 22:10
Favicon

[PATCH] Btrfs-progs: add btrfs device ready command

This command will be used by things like dracut that wish to know very
simply if all of the devices have been added to the kernel cache yet for the
device to be fully mounted.  This keeps initrd's from constantly having to
try to mount the file system until it succeeds every time a device is added
to the system.  Thanks,

Signed-off-by: Josef Bacik <jbacik <at> fusionio.com>
---
 cmds-device.c |   35 +++++++++++++++++++++++++++++++++++
 ioctl.h       |    2 ++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index db625a6..fccf870 100644
--- a/cmds-device.c
+++ b/cmds-device.c
 <at>  <at>  -246,11 +246,46  <at>  <at>  static int cmd_scan_dev(int argc, char **argv)
 	return 0;
 }

+static const char * const cmd_ready_dev_usage[] = {
+	"btrfs device ready <device>",
+	"Check device to see if it has all of it's devices in cache for mounting",
+	NULL
+};
+
+static int cmd_ready_dev(int argc, char **argv)
+{
+	struct	btrfs_ioctl_vol_args args;
+	int	fd;
(Continue reading)

Goffredo Baroncelli | 22 Jun 2012 19:20
Picon
Favicon

Re: [PATCH] Btrfs-progs: add btrfs device ready command

On 06/21/2012 10:10 PM, Josef Bacik wrote:
> This command will be used by things like dracut that wish to know very
> simply if all of the devices have been added to the kernel cache yet for the
> device to be fully mounted.  This keeps initrd's from constantly having to
> try to mount the file system until it succeeds every time a device is added
> to the system.  Thanks,
> 

Please Josef, when you submit a patch to btrfs-progs that adds a new
command pay attention to update the man page too.

Se below my other syggestions:

Thanks
G.Baroncelli

> Signed-off-by: Josef Bacik <jbacik <at> fusionio.com>
> ---
>  cmds-device.c |   35 +++++++++++++++++++++++++++++++++++
>  ioctl.h       |    2 ++
>  2 files changed, 37 insertions(+), 0 deletions(-)
> 
> diff --git a/cmds-device.c b/cmds-device.c
> index db625a6..fccf870 100644
> --- a/cmds-device.c
> +++ b/cmds-device.c
>  <at>  <at>  -246,11 +246,46  <at>  <at>  static int cmd_scan_dev(int argc, char **argv)
>  	return 0;
>  }
>  
(Continue reading)

Josef Bacik | 21 Jun 2012 22:10
Favicon

[PATCH] Btrfs: add DEVICE_READY ioctl

This will be used in conjunction with btrfs device ready <dev>.  This is
needed for initrd's to have a nice and lightweight way to tell if all of the
devices needed for a file system are in the cache currently.  This keeps
them from having to do mount+sleep loops waiting for devices to show up.
Thanks,

Signed-off-by: Josef Bacik <jbacik <at> fusionio.com>
---
 fs/btrfs/ioctl.h   |    3 ++-
 fs/btrfs/super.c   |    7 +++++++
 fs/btrfs/volumes.c |    9 ++++++++-
 fs/btrfs/volumes.h |    1 +
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
index 497c530..34317cf 100644
--- a/fs/btrfs/ioctl.h
+++ b/fs/btrfs/ioctl.h
 <at>  <at>  -363,5 +363,6  <at>  <at>  struct btrfs_ioctl_get_dev_stats {
 				      struct btrfs_ioctl_get_dev_stats)
 #define BTRFS_IOC_GET_AND_RESET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 53, \
 					struct btrfs_ioctl_get_dev_stats)
-
+#define BTRFS_IOC_DEVICES_READY _IOW(BTRFS_IOCTL_MAGIC, 54, \
+				     struct btrfs_ioctl_vol_args)
 #endif
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 23fc7e8..347ccd8 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
(Continue reading)

Goffredo Baroncelli | 22 Jun 2012 20:12
Picon
Favicon

Re: [PATCH] Btrfs: add DEVICE_READY ioctl

On 06/21/2012 10:10 PM, Josef Bacik wrote:
> This will be used in conjunction with btrfs device ready <dev>.  This is
> needed for initrd's to have a nice and lightweight way to tell if all of the
> devices needed for a file system are in the cache currently.  This keeps
> them from having to do mount+sleep loops waiting for devices to show up.
> Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik <at> fusionio.com>
> ---
>  fs/btrfs/ioctl.h   |    3 ++-
>  fs/btrfs/super.c   |    7 +++++++
>  fs/btrfs/volumes.c |    9 ++++++++-
>  fs/btrfs/volumes.h |    1 +
>  4 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
> index 497c530..34317cf 100644
> --- a/fs/btrfs/ioctl.h
> +++ b/fs/btrfs/ioctl.h
>  <at>  <at>  -363,5 +363,6  <at>  <at>  struct btrfs_ioctl_get_dev_stats {
>  				      struct btrfs_ioctl_get_dev_stats)
>  #define BTRFS_IOC_GET_AND_RESET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 53, \
>  					struct btrfs_ioctl_get_dev_stats)
> -
> +#define BTRFS_IOC_DEVICES_READY _IOW(BTRFS_IOCTL_MAGIC, 54, \
> +				     struct btrfs_ioctl_vol_args)

What is the purpose of the ioctl args ? This could confuses the user (as
programmer). However IIRC for the other ioctls without argument the same
policy was applied.Maybe a better name than btrfs_ioctl_vol_args would
(Continue reading)

David Sterba | 17 Jul 2012 13:53
Picon

Re: [PATCH] Btrfs: add DEVICE_READY ioctl

On Fri, Jun 22, 2012 at 08:12:52PM +0200, Goffredo Baroncelli wrote:
> On 06/21/2012 10:10 PM, Josef Bacik wrote:
> > This will be used in conjunction with btrfs device ready <dev>.  This is
> > needed for initrd's to have a nice and lightweight way to tell if all of the
> > devices needed for a file system are in the cache currently.  This keeps
> > them from having to do mount+sleep loops waiting for devices to show up.
> > Thanks,
> > 
> > Signed-off-by: Josef Bacik <jbacik <at> fusionio.com>
> > ---
> >  fs/btrfs/ioctl.h   |    3 ++-
> >  fs/btrfs/super.c   |    7 +++++++
> >  fs/btrfs/volumes.c |    9 ++++++++-
> >  fs/btrfs/volumes.h |    1 +
> >  4 files changed, 18 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
> > index 497c530..34317cf 100644
> > --- a/fs/btrfs/ioctl.h
> > +++ b/fs/btrfs/ioctl.h
> >  <at>  <at>  -363,5 +363,6  <at>  <at>  struct btrfs_ioctl_get_dev_stats {
> >  				      struct btrfs_ioctl_get_dev_stats)
> >  #define BTRFS_IOC_GET_AND_RESET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 53, \
> >  					struct btrfs_ioctl_get_dev_stats)
> > -
> > +#define BTRFS_IOC_DEVICES_READY _IOW(BTRFS_IOCTL_MAGIC, 54, \
> > +				     struct btrfs_ioctl_vol_args)
> 
> What is the purpose of the ioctl args ? This could confuses the user (as
> programmer). However IIRC for the other ioctls without argument the same
(Continue reading)

Goffredo Baroncelli | 17 Jul 2012 19:17
Picon

Re: [PATCH] Btrfs: add DEVICE_READY ioctl

On 07/17/2012 01:53 PM, David Sterba wrote:
> On Fri, Jun 22, 2012 at 08:12:52PM +0200, Goffredo Baroncelli wrote:
>> On 06/21/2012 10:10 PM, Josef Bacik wrote:
>>> This will be used in conjunction with btrfs device ready <dev>.  This is
[....]
> 
>> Finally I am starting to think that we should definitely switch to a
>> /sys/btrfs style of interface
> 
> I'm all for a sysfs interface, having an ioctl way of retrieving
> information is good, but not practical for use from scripting languages,
> namely for writing tests.

Moreover a sysfs interface is more extensible for further enanchement

> 
> There are some guys working on the sysfs patches, I did preliminary
> reviews. The first step is to bring back the core sysfs support (mostly
> done iirc) and then exporting various information.
> I'll check what's the status.

Great, are there public patches, I am interested in contributing

> 
>> think something like:
>>
>> /sys/btrfs/≤fs-uuid>/<dev-uuid>/present
>>                                size
>>                                space-occuped
>>                                number-of-error
(Continue reading)

Harald Hoyer | 22 Jun 2012 12:33
Picon
Favicon
Gravatar

Re: [RFC] A way to tell if all the devices in a file system are available

On 06/21/2012 10:10 PM, Josef Bacik wrote:
> Harald Hoyer has had this as a feature request for ages and I've finally gotten
> around to hacking something up.  This is probably going to get bikeshedded to
> death, bring it on, I'm not married to any of the behaviors in these patches, I
> just want to get the ball rolling so we can have something in place for 3.6.
> 
> Basically all I've done is saved how many devices the super block thinks we have
> into the fs_devices struct whenever we scan a device.  Then all we have to do
> for the IOCTL is compare how many devices the fs_devices struct has in it to how
> many we think we need.
> 
> The command itself just spits out 0 for yay we're ready and 1 for boo no we're
> not.  This makes it easier for Harald to do his multi-device btrfs support in
> dracut.  Thanks,
> 
> Josef
> 

Exactly what I need! Thanks! Would be really usefu!

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Harald Hoyer | 10 Jul 2012 19:35
Picon
Favicon
Gravatar

Re: [RFC] A way to tell if all the devices in a file system are available

Am 21.06.2012 22:10, schrieb Josef Bacik:
> Harald Hoyer has had this as a feature request for ages and I've finally gotten
> around to hacking something up.  This is probably going to get bikeshedded to
> death, bring it on, I'm not married to any of the behaviors in these patches, I
> just want to get the ball rolling so we can have something in place for 3.6.
> 
> Basically all I've done is saved how many devices the super block thinks we have
> into the fs_devices struct whenever we scan a device.  Then all we have to do
> for the IOCTL is compare how many devices the fs_devices struct has in it to how
> many we think we need.
> 
> The command itself just spits out 0 for yay we're ready and 1 for boo no we're
> not.  This makes it easier for Harald to do his multi-device btrfs support in
> dracut.  Thanks,
> 
> Josef
> 

any news on this?

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane