* [RFC] A way to tell if all the devices in a file system are available @ 2012-06-21 20:10 Josef Bacik 2012-06-21 20:10 ` [PATCH] Btrfs: add DEVICE_READY ioctl Josef Bacik ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Josef Bacik @ 2012-06-21 20:10 UTC (permalink / raw) To: linux-btrfs, harald 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Btrfs: add DEVICE_READY ioctl 2012-06-21 20:10 [RFC] A way to tell if all the devices in a file system are available Josef Bacik @ 2012-06-21 20:10 ` Josef Bacik 2012-06-22 18:12 ` Goffredo Baroncelli 2012-06-21 20:10 ` [PATCH] Btrfs-progs: add btrfs device ready command Josef Bacik ` (2 subsequent siblings) 3 siblings, 1 reply; 9+ messages in thread From: Josef Bacik @ 2012-06-21 20:10 UTC (permalink / raw) To: linux-btrfs, harald 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@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 @@ -363,5 +363,6 @@ 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 @@ -1458,6 +1458,13 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, ret = btrfs_scan_one_device(vol->name, FMODE_READ, &btrfs_fs_type, &fs_devices); break; + case BTRFS_IOC_DEVICES_READY: + ret = btrfs_scan_one_device(vol->name, FMODE_READ, + &btrfs_fs_type, &fs_devices); + if (ret) + break; + ret = !(fs_devices->num_devices == fs_devices->total_devices); + break; } kfree(vol); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3f292cf..a505627 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -429,6 +429,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) mutex_init(&fs_devices->device_list_mutex); fs_devices->latest_devid = orig->latest_devid; fs_devices->latest_trans = orig->latest_trans; + fs_devices->total_devices = orig->total_devices; memcpy(fs_devices->fsid, orig->fsid, sizeof(fs_devices->fsid)); /* We have held the volume lock, it is safe to get the devices. */ @@ -739,6 +740,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, int ret; u64 devid; u64 transid; + u64 total_devices; flags |= FMODE_EXCL; bdev = blkdev_get_by_path(path, flags, holder); @@ -760,6 +762,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, disk_super = (struct btrfs_super_block *)bh->b_data; devid = btrfs_stack_device_id(&disk_super->dev_item); transid = btrfs_super_generation(disk_super); + total_devices = btrfs_super_num_devices(disk_super); if (disk_super->label[0]) printk(KERN_INFO "device label %s ", disk_super->label); else @@ -767,7 +770,8 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, printk(KERN_CONT "devid %llu transid %llu %s\n", (unsigned long long)devid, (unsigned long long)transid, path); ret = device_list_add(path, disk_super, devid, fs_devices_ret); - + if (!ret && fs_devices_ret) + (*fs_devices_ret)->total_devices = total_devices; brelse(bh); error_close: mutex_unlock(&uuid_mutex); @@ -1433,6 +1437,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) list_del_rcu(&device->dev_list); device->fs_devices->num_devices--; + device->fs_devices->total_devices--; if (device->missing) root->fs_info->fs_devices->missing_devices--; @@ -1550,6 +1555,7 @@ static int btrfs_prepare_sprout(struct btrfs_root *root) fs_devices->seeding = 0; fs_devices->num_devices = 0; fs_devices->open_devices = 0; + fs_devices->total_devices = 0; fs_devices->seed = seed_devices; generate_random_uuid(fs_devices->fsid); @@ -1749,6 +1755,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) root->fs_info->fs_devices->num_devices++; root->fs_info->fs_devices->open_devices++; root->fs_info->fs_devices->rw_devices++; + root->fs_info->fs_devices->total_devices++; if (device->can_discard) root->fs_info->fs_devices->num_can_discard++; root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 74366f2..a3c5d5c 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -126,6 +126,7 @@ struct btrfs_fs_devices { u64 missing_devices; u64 total_rw_bytes; u64 num_can_discard; + u64 total_devices; struct block_device *latest_bdev; /* all of the devices in the FS, protected by a mutex -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Btrfs: add DEVICE_READY ioctl 2012-06-21 20:10 ` [PATCH] Btrfs: add DEVICE_READY ioctl Josef Bacik @ 2012-06-22 18:12 ` Goffredo Baroncelli 2012-07-17 11:53 ` David Sterba 0 siblings, 1 reply; 9+ messages in thread From: Goffredo Baroncelli @ 2012-06-22 18:12 UTC (permalink / raw) To: Josef Bacik; +Cc: linux-btrfs, harald 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@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 > @@ -363,5 +363,6 @@ 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 help, like btrfs_generic_ioctl. Anyway, I suggest to return not a boolean value but a pair of integers: both the number of devices registered and the total number of devices. Better would be the dev-id found and the dev-id missing. This could help a lot the diagnostic of mount problem. Finally I am starting to think that we should definitely switch to a /sys/btrfs style of interface think something like: /sys/btrfs/<fs-uuid>/<dev-uuid>/present size space-occuped number-of-error [...] /sys/btrfs/<fs-uuid>/<subvolume-id>/read-only compressed raid-mode path [...] /sys/btrfs/<fs-uuid>/label mounted read-only compressed raid-mode [...] > #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 > @@ -1458,6 +1458,13 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, > ret = btrfs_scan_one_device(vol->name, FMODE_READ, > &btrfs_fs_type, &fs_devices); > break; > + case BTRFS_IOC_DEVICES_READY: > + ret = btrfs_scan_one_device(vol->name, FMODE_READ, > + &btrfs_fs_type, &fs_devices); > + if (ret) > + break; > + ret = !(fs_devices->num_devices == fs_devices->total_devices); > + break; > } > > kfree(vol); > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 3f292cf..a505627 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -429,6 +429,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) > mutex_init(&fs_devices->device_list_mutex); > fs_devices->latest_devid = orig->latest_devid; > fs_devices->latest_trans = orig->latest_trans; > + fs_devices->total_devices = orig->total_devices; > memcpy(fs_devices->fsid, orig->fsid, sizeof(fs_devices->fsid)); > > /* We have held the volume lock, it is safe to get the devices. */ > @@ -739,6 +740,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, > int ret; > u64 devid; > u64 transid; > + u64 total_devices; > > flags |= FMODE_EXCL; > bdev = blkdev_get_by_path(path, flags, holder); > @@ -760,6 +762,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, > disk_super = (struct btrfs_super_block *)bh->b_data; > devid = btrfs_stack_device_id(&disk_super->dev_item); > transid = btrfs_super_generation(disk_super); > + total_devices = btrfs_super_num_devices(disk_super); > if (disk_super->label[0]) > printk(KERN_INFO "device label %s ", disk_super->label); > else > @@ -767,7 +770,8 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, > printk(KERN_CONT "devid %llu transid %llu %s\n", > (unsigned long long)devid, (unsigned long long)transid, path); > ret = device_list_add(path, disk_super, devid, fs_devices_ret); > - > + if (!ret && fs_devices_ret) > + (*fs_devices_ret)->total_devices = total_devices; > brelse(bh); > error_close: > mutex_unlock(&uuid_mutex); > @@ -1433,6 +1437,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) > list_del_rcu(&device->dev_list); > > device->fs_devices->num_devices--; > + device->fs_devices->total_devices--; > > if (device->missing) > root->fs_info->fs_devices->missing_devices--; > @@ -1550,6 +1555,7 @@ static int btrfs_prepare_sprout(struct btrfs_root *root) > fs_devices->seeding = 0; > fs_devices->num_devices = 0; > fs_devices->open_devices = 0; > + fs_devices->total_devices = 0; > fs_devices->seed = seed_devices; > > generate_random_uuid(fs_devices->fsid); > @@ -1749,6 +1755,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) > root->fs_info->fs_devices->num_devices++; > root->fs_info->fs_devices->open_devices++; > root->fs_info->fs_devices->rw_devices++; > + root->fs_info->fs_devices->total_devices++; > if (device->can_discard) > root->fs_info->fs_devices->num_can_discard++; > root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; > diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h > index 74366f2..a3c5d5c 100644 > --- a/fs/btrfs/volumes.h > +++ b/fs/btrfs/volumes.h > @@ -126,6 +126,7 @@ struct btrfs_fs_devices { > u64 missing_devices; > u64 total_rw_bytes; > u64 num_can_discard; > + u64 total_devices; > struct block_device *latest_bdev; > > /* all of the devices in the FS, protected by a mutex ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Btrfs: add DEVICE_READY ioctl 2012-06-22 18:12 ` Goffredo Baroncelli @ 2012-07-17 11:53 ` David Sterba 2012-07-17 17:17 ` Goffredo Baroncelli 0 siblings, 1 reply; 9+ messages in thread From: David Sterba @ 2012-07-17 11:53 UTC (permalink / raw) To: kreijack; +Cc: Josef Bacik, linux-btrfs, harald 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@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 > > @@ -363,5 +363,6 @@ 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 > help, like btrfs_generic_ioctl. > > Anyway, I suggest to return not a boolean value but a pair of integers: > both the number of devices registered and the total number of devices. > Better would be the dev-id found and the dev-id missing. This could help > a lot the diagnostic of mount problem. I thought that this could be implemented in a more generic way, something like a DEVICE_QUERY, where we can get all sorts of details about the particular device. And if the device is not already discovered and cached, then the query would simply indicate this. > 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. 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. > think something like: > > /sys/btrfs/<fs-uuid>/<dev-uuid>/present > size > space-occuped > number-of-error > [...] > > /sys/btrfs/<fs-uuid>/<subvolume-id>/read-only > compressed > raid-mode > path > [...] > > /sys/btrfs/<fs-uuid>/label > mounted > read-only > compressed > raid-mode > [...] That's a good start for a discussion. david ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Btrfs: add DEVICE_READY ioctl 2012-07-17 11:53 ` David Sterba @ 2012-07-17 17:17 ` Goffredo Baroncelli 0 siblings, 0 replies; 9+ messages in thread From: Goffredo Baroncelli @ 2012-07-17 17:17 UTC (permalink / raw) To: Josef Bacik, linux-btrfs, harald 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 >> [...] >> >> /sys/btrfs/<fs-uuid>/<subvolume-id>/read-only >> compressed >> raid-mode >> path >> [...] >> >> /sys/btrfs/<fs-uuid>/label >> mounted >> read-only >> compressed >> raid-mode >> [...] > > That's a good start for a discussion. > > > david > . > ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Btrfs-progs: add btrfs device ready command 2012-06-21 20:10 [RFC] A way to tell if all the devices in a file system are available Josef Bacik 2012-06-21 20:10 ` [PATCH] Btrfs: add DEVICE_READY ioctl Josef Bacik @ 2012-06-21 20:10 ` Josef Bacik 2012-06-22 17:20 ` Goffredo Baroncelli 2012-06-22 10:33 ` [RFC] A way to tell if all the devices in a file system are available Harald Hoyer 2012-07-10 17:35 ` Harald Hoyer 3 siblings, 1 reply; 9+ messages in thread From: Josef Bacik @ 2012-06-21 20:10 UTC (permalink / raw) To: linux-btrfs, harald 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@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 @@ -246,11 +246,46 @@ 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; + int ret; + + if (check_argc_min(argc, 2)) + usage(cmd_ready_dev_usage); + + fd = open("/dev/btrfs-control", O_RDWR); + if (fd < 0) { + perror("failed to open /dev/btrfs-control"); + return 10; + } + + strncpy(args.name, argv[argc - 1], BTRFS_PATH_NAME_MAX); + ret = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args); + if (ret < 0) { + fprintf(stderr, "ERROR: unable to determine if the device '%s'" + " is ready for mounting - %s\n", argv[argc - 1], + strerror(errno)); + ret = 1; + } + + close(fd); + return ret; +} + const struct cmd_group device_cmd_group = { device_cmd_group_usage, NULL, { { "add", cmd_add_dev, cmd_add_dev_usage, NULL, 0 }, { "delete", cmd_rm_dev, cmd_rm_dev_usage, NULL, 0 }, { "scan", cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 }, + { "ready", cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 }, { 0, 0, 0, 0, 0 } } }; diff --git a/ioctl.h b/ioctl.h index f2e5d8d..e5f8a94 100644 --- a/ioctl.h +++ b/ioctl.h @@ -330,5 +330,7 @@ struct btrfs_ioctl_logical_ino_args { struct btrfs_ioctl_ino_path_args) #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \ struct btrfs_ioctl_ino_path_args) +#define BTRFS_IOC_DEVICES_READY _IOW(BTRFS_IOCTL_MAGIC, 54, \ + struct btrfs_ioctl_vol_args) #endif -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Btrfs-progs: add btrfs device ready command 2012-06-21 20:10 ` [PATCH] Btrfs-progs: add btrfs device ready command Josef Bacik @ 2012-06-22 17:20 ` Goffredo Baroncelli 0 siblings, 0 replies; 9+ messages in thread From: Goffredo Baroncelli @ 2012-06-22 17:20 UTC (permalink / raw) To: Josef Bacik; +Cc: linux-btrfs, harald 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@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 > @@ -246,11 +246,46 @@ static int cmd_scan_dev(int argc, char **argv) > return 0; > } > > +static const char * const cmd_ready_dev_usage[] = { > + "btrfs device ready <device>", What about btrfs device check-volume <device> > + "Check device to see if it has all of it's devices in cache for mounting", I suggest: Check if all the devices of the volume which owns <device> are registered. > + NULL > +}; > + > +static int cmd_ready_dev(int argc, char **argv) > +{ > + struct btrfs_ioctl_vol_args args; > + int fd; > + int ret; > + > + if (check_argc_min(argc, 2)) > + usage(cmd_ready_dev_usage); > + > + fd = open("/dev/btrfs-control", O_RDWR); > + if (fd < 0) { > + perror("failed to open /dev/btrfs-control"); > + return 10; > + } > + > + strncpy(args.name, argv[argc - 1], BTRFS_PATH_NAME_MAX); > + ret = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args); > + if (ret < 0) { > + fprintf(stderr, "ERROR: unable to determine if the device '%s'" > + " is ready for mounting - %s\n", argv[argc - 1], > + strerror(errno)); > + ret = 1; > + } > + > + close(fd); > + return ret; > +} > + > const struct cmd_group device_cmd_group = { > device_cmd_group_usage, NULL, { > { "add", cmd_add_dev, cmd_add_dev_usage, NULL, 0 }, > { "delete", cmd_rm_dev, cmd_rm_dev_usage, NULL, 0 }, > { "scan", cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 }, > + { "ready", cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 }, > { 0, 0, 0, 0, 0 } > } > }; > diff --git a/ioctl.h b/ioctl.h > index f2e5d8d..e5f8a94 100644 > --- a/ioctl.h > +++ b/ioctl.h > @@ -330,5 +330,7 @@ struct btrfs_ioctl_logical_ino_args { > struct btrfs_ioctl_ino_path_args) > #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \ > struct btrfs_ioctl_ino_path_args) > +#define BTRFS_IOC_DEVICES_READY _IOW(BTRFS_IOCTL_MAGIC, 54, \ > + struct btrfs_ioctl_vol_args) > > #endif ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC] A way to tell if all the devices in a file system are available 2012-06-21 20:10 [RFC] A way to tell if all the devices in a file system are available Josef Bacik 2012-06-21 20:10 ` [PATCH] Btrfs: add DEVICE_READY ioctl Josef Bacik 2012-06-21 20:10 ` [PATCH] Btrfs-progs: add btrfs device ready command Josef Bacik @ 2012-06-22 10:33 ` Harald Hoyer 2012-07-10 17:35 ` Harald Hoyer 3 siblings, 0 replies; 9+ messages in thread From: Harald Hoyer @ 2012-06-22 10:33 UTC (permalink / raw) To: Josef Bacik; +Cc: linux-btrfs 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! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC] A way to tell if all the devices in a file system are available 2012-06-21 20:10 [RFC] A way to tell if all the devices in a file system are available Josef Bacik ` (2 preceding siblings ...) 2012-06-22 10:33 ` [RFC] A way to tell if all the devices in a file system are available Harald Hoyer @ 2012-07-10 17:35 ` Harald Hoyer 3 siblings, 0 replies; 9+ messages in thread From: Harald Hoyer @ 2012-07-10 17:35 UTC (permalink / raw) To: Josef Bacik; +Cc: linux-btrfs 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? ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-07-17 17:17 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-21 20:10 [RFC] A way to tell if all the devices in a file system are available Josef Bacik 2012-06-21 20:10 ` [PATCH] Btrfs: add DEVICE_READY ioctl Josef Bacik 2012-06-22 18:12 ` Goffredo Baroncelli 2012-07-17 11:53 ` David Sterba 2012-07-17 17:17 ` Goffredo Baroncelli 2012-06-21 20:10 ` [PATCH] Btrfs-progs: add btrfs device ready command Josef Bacik 2012-06-22 17:20 ` Goffredo Baroncelli 2012-06-22 10:33 ` [RFC] A way to tell if all the devices in a file system are available Harald Hoyer 2012-07-10 17:35 ` Harald Hoyer
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).