* [RFC PATCH 0/2] Kernel space btrfs missing device detection. @ 2014-05-06 6:33 Qu Wenruo 2014-05-06 6:33 ` [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl Qu Wenruo ` (2 more replies) 0 siblings, 3 replies; 12+ messages in thread From: Qu Wenruo @ 2014-05-06 6:33 UTC (permalink / raw) To: linux-btrfs; +Cc: Anand Jain Original btrfs will not detection any missing device since there is no notification mechanism for fs layer to detect missing device in block layer. However we don't really need to notify fs layer upon dev remove, probing in dev_info/rm_dev ioctl is good enough since they are the only two ioctls caring about missing device. This patchset will do ioctl time missing dev detection and return device missing status in dev_info ioctl using a new member in btrfs_ioctl_dev_info_args with a backward compatible method. Cc: Anand Jain <Anand.Jain@oracle.com> Qu Wenruo (2): btrfs: Add missing device check in dev_info/rm_dev ioctl btrfs: Add new member of btrfs_ioctl_dev_info_args. fs/btrfs/ioctl.c | 4 ++++ fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- fs/btrfs/volumes.h | 2 ++ include/uapi/linux/btrfs.h | 5 ++++- 4 files changed, 34 insertions(+), 2 deletions(-) -- 1.9.2 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-06 6:33 [RFC PATCH 0/2] Kernel space btrfs missing device detection Qu Wenruo @ 2014-05-06 6:33 ` Qu Wenruo 2014-05-07 8:00 ` Anand Jain 2014-05-21 3:47 ` Anand Jain 2014-05-06 6:33 ` [RFC PATCH 2/2] btrfs: Add new member of btrfs_ioctl_dev_info_args Qu Wenruo 2014-05-06 18:10 ` [RFC PATCH 0/2] Kernel space btrfs missing device detection Goffredo Baroncelli 2 siblings, 2 replies; 12+ messages in thread From: Qu Wenruo @ 2014-05-06 6:33 UTC (permalink / raw) To: linux-btrfs; +Cc: Anand Jain Old btrfs can't find a missing btrfs device since there is no mechanism for block layer to inform fs layer. But we can use a workaround that only check status(by using request_queue->queue_flags) of every device in a btrfs filesystem when calling dev_info/rm_dev ioctl, since other ioctls do not really cares about missing device. Cc: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> --- fs/btrfs/ioctl.c | 1 + fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- fs/btrfs/volumes.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 0401397..7680a40 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2606,6 +2606,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) goto out; } + btrfs_check_dev_missing(root, dev, 1); di_args->devid = dev->devid; di_args->bytes_used = dev->bytes_used; di_args->total_bytes = dev->total_bytes; diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index d241130a..c7d7908 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1548,9 +1548,10 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) * is held. */ list_for_each_entry(tmp, devices, dev_list) { + btrfs_check_dev_missing(root, tmp, 0); if (tmp->in_fs_metadata && !tmp->is_tgtdev_for_dev_replace && - !tmp->bdev) { + (!tmp->bdev || tmp->missing)) { device = tmp; break; } @@ -6300,3 +6301,25 @@ int btrfs_scratch_superblock(struct btrfs_device *device) return 0; } + +/* If need_lock is set, uuid_mutex will be used */ +int btrfs_check_dev_missing(struct btrfs_root *root, struct btrfs_device *dev, + int need_lock) +{ + struct request_queue *q; + + if (unlikely(!dev || !dev->bdev || !dev->bdev->bd_queue)) + return -ENOENT; + q = dev->bdev->bd_queue; + + if (need_lock) + mutex_lock(&uuid_mutex); + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags) || + test_bit(QUEUE_FLAG_DYING, &q->queue_flags)) { + dev->missing = 1; + root->fs_info->fs_devices->missing_devices++; + } + if (need_lock) + mutex_unlock(&uuid_mutex); + return 0; +} diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 80754f9..47a44af 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -356,6 +356,8 @@ unsigned long btrfs_full_stripe_len(struct btrfs_root *root, int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, struct btrfs_root *extent_root, u64 chunk_offset, u64 chunk_size); +int btrfs_check_dev_missing(struct btrfs_root *root, struct btrfs_device *dev, + int need_lock); static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, int index) { -- 1.9.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-06 6:33 ` [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl Qu Wenruo @ 2014-05-07 8:00 ` Anand Jain 2014-05-07 8:02 ` Qu Wenruo 2014-05-21 3:12 ` Qu Wenruo 2014-05-21 3:47 ` Anand Jain 1 sibling, 2 replies; 12+ messages in thread From: Anand Jain @ 2014-05-07 8:00 UTC (permalink / raw) To: Qu Wenruo; +Cc: linux-btrfs Thanks for working on this. I am running some tests will let you know. Anand On 05/06/2014 02:33 PM, Qu Wenruo wrote: > Old btrfs can't find a missing btrfs device since there is no > mechanism for block layer to inform fs layer. > > But we can use a workaround that only check status(by using > request_queue->queue_flags) of every device in a btrfs > filesystem when calling dev_info/rm_dev ioctl, since other ioctls > do not really cares about missing device. > > Cc: Anand Jain <Anand.Jain@oracle.com> > Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> > --- > fs/btrfs/ioctl.c | 1 + > fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- > fs/btrfs/volumes.h | 2 ++ > 3 files changed, 27 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 0401397..7680a40 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -2606,6 +2606,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) > goto out; > } > > + btrfs_check_dev_missing(root, dev, 1); > di_args->devid = dev->devid; > di_args->bytes_used = dev->bytes_used; > di_args->total_bytes = dev->total_bytes; > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index d241130a..c7d7908 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -1548,9 +1548,10 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) > * is held. > */ > list_for_each_entry(tmp, devices, dev_list) { > + btrfs_check_dev_missing(root, tmp, 0); > if (tmp->in_fs_metadata && > !tmp->is_tgtdev_for_dev_replace && > - !tmp->bdev) { > + (!tmp->bdev || tmp->missing)) { > device = tmp; > break; > } > @@ -6300,3 +6301,25 @@ int btrfs_scratch_superblock(struct btrfs_device *device) > > return 0; > } > + > +/* If need_lock is set, uuid_mutex will be used */ > +int btrfs_check_dev_missing(struct btrfs_root *root, struct btrfs_device *dev, > + int need_lock) > +{ > + struct request_queue *q; > + > + if (unlikely(!dev || !dev->bdev || !dev->bdev->bd_queue)) > + return -ENOENT; > + q = dev->bdev->bd_queue; > + > + if (need_lock) > + mutex_lock(&uuid_mutex); > + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags) || > + test_bit(QUEUE_FLAG_DYING, &q->queue_flags)) { > + dev->missing = 1; > + root->fs_info->fs_devices->missing_devices++; > + } > + if (need_lock) > + mutex_unlock(&uuid_mutex); > + return 0; > +} > diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h > index 80754f9..47a44af 100644 > --- a/fs/btrfs/volumes.h > +++ b/fs/btrfs/volumes.h > @@ -356,6 +356,8 @@ unsigned long btrfs_full_stripe_len(struct btrfs_root *root, > int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, > struct btrfs_root *extent_root, > u64 chunk_offset, u64 chunk_size); > +int btrfs_check_dev_missing(struct btrfs_root *root, struct btrfs_device *dev, > + int need_lock); > static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, > int index) > { > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-07 8:00 ` Anand Jain @ 2014-05-07 8:02 ` Qu Wenruo 2014-05-21 3:12 ` Qu Wenruo 1 sibling, 0 replies; 12+ messages in thread From: Qu Wenruo @ 2014-05-07 8:02 UTC (permalink / raw) To: Anand Jain; +Cc: linux-btrfs -------- Original Message -------- Subject: Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl From: Anand Jain <Anand.Jain@oracle.com> To: Qu Wenruo <quwenruo@cn.fujitsu.com> Date: 2014年05月07日 16:00 > > > Thanks for working on this. > I am running some tests will let you know. > > Anand > Thanks for your tests. I have only check the scsi_device/X:X:X:X/device/delete interface to remove the device, so if you have some other device remove tests, that would be much nicer. Thanks, Qu > > On 05/06/2014 02:33 PM, Qu Wenruo wrote: >> Old btrfs can't find a missing btrfs device since there is no >> mechanism for block layer to inform fs layer. >> >> But we can use a workaround that only check status(by using >> request_queue->queue_flags) of every device in a btrfs >> filesystem when calling dev_info/rm_dev ioctl, since other ioctls >> do not really cares about missing device. >> >> Cc: Anand Jain <Anand.Jain@oracle.com> >> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> >> --- >> fs/btrfs/ioctl.c | 1 + >> fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- >> fs/btrfs/volumes.h | 2 ++ >> 3 files changed, 27 insertions(+), 1 deletion(-) >> >> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >> index 0401397..7680a40 100644 >> --- a/fs/btrfs/ioctl.c >> +++ b/fs/btrfs/ioctl.c >> @@ -2606,6 +2606,7 @@ static long btrfs_ioctl_dev_info(struct >> btrfs_root *root, void __user *arg) >> goto out; >> } >> >> + btrfs_check_dev_missing(root, dev, 1); >> di_args->devid = dev->devid; >> di_args->bytes_used = dev->bytes_used; >> di_args->total_bytes = dev->total_bytes; >> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >> index d241130a..c7d7908 100644 >> --- a/fs/btrfs/volumes.c >> +++ b/fs/btrfs/volumes.c >> @@ -1548,9 +1548,10 @@ int btrfs_rm_device(struct btrfs_root *root, >> char *device_path) >> * is held. >> */ >> list_for_each_entry(tmp, devices, dev_list) { >> + btrfs_check_dev_missing(root, tmp, 0); >> if (tmp->in_fs_metadata && >> !tmp->is_tgtdev_for_dev_replace && >> - !tmp->bdev) { >> + (!tmp->bdev || tmp->missing)) { >> device = tmp; >> break; >> } >> @@ -6300,3 +6301,25 @@ int btrfs_scratch_superblock(struct >> btrfs_device *device) >> >> return 0; >> } >> + >> +/* If need_lock is set, uuid_mutex will be used */ >> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >> btrfs_device *dev, >> + int need_lock) >> +{ >> + struct request_queue *q; >> + >> + if (unlikely(!dev || !dev->bdev || !dev->bdev->bd_queue)) >> + return -ENOENT; >> + q = dev->bdev->bd_queue; >> + >> + if (need_lock) >> + mutex_lock(&uuid_mutex); >> + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags) || >> + test_bit(QUEUE_FLAG_DYING, &q->queue_flags)) { >> + dev->missing = 1; >> + root->fs_info->fs_devices->missing_devices++; >> + } >> + if (need_lock) >> + mutex_unlock(&uuid_mutex); >> + return 0; >> +} >> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h >> index 80754f9..47a44af 100644 >> --- a/fs/btrfs/volumes.h >> +++ b/fs/btrfs/volumes.h >> @@ -356,6 +356,8 @@ unsigned long btrfs_full_stripe_len(struct >> btrfs_root *root, >> int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, >> struct btrfs_root *extent_root, >> u64 chunk_offset, u64 chunk_size); >> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >> btrfs_device *dev, >> + int need_lock); >> static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, >> int index) >> { >> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-07 8:00 ` Anand Jain 2014-05-07 8:02 ` Qu Wenruo @ 2014-05-21 3:12 ` Qu Wenruo 2014-05-21 3:54 ` Anand Jain 1 sibling, 1 reply; 12+ messages in thread From: Qu Wenruo @ 2014-05-21 3:12 UTC (permalink / raw) To: Anand Jain; +Cc: linux-btrfs I'm sorry to bother your but it has been about 2 weeks after your last reply. Is there any problem? Thanks, Qu -------- Original Message -------- Subject: Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl From: Anand Jain <Anand.Jain@oracle.com> To: Qu Wenruo <quwenruo@cn.fujitsu.com> Date: 2014年05月07日 16:00 > > > Thanks for working on this. > I am running some tests will let you know. > > Anand > > > On 05/06/2014 02:33 PM, Qu Wenruo wrote: >> Old btrfs can't find a missing btrfs device since there is no >> mechanism for block layer to inform fs layer. >> >> But we can use a workaround that only check status(by using >> request_queue->queue_flags) of every device in a btrfs >> filesystem when calling dev_info/rm_dev ioctl, since other ioctls >> do not really cares about missing device. >> >> Cc: Anand Jain <Anand.Jain@oracle.com> >> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> >> --- >> fs/btrfs/ioctl.c | 1 + >> fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- >> fs/btrfs/volumes.h | 2 ++ >> 3 files changed, 27 insertions(+), 1 deletion(-) >> >> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >> index 0401397..7680a40 100644 >> --- a/fs/btrfs/ioctl.c >> +++ b/fs/btrfs/ioctl.c >> @@ -2606,6 +2606,7 @@ static long btrfs_ioctl_dev_info(struct >> btrfs_root *root, void __user *arg) >> goto out; >> } >> >> + btrfs_check_dev_missing(root, dev, 1); >> di_args->devid = dev->devid; >> di_args->bytes_used = dev->bytes_used; >> di_args->total_bytes = dev->total_bytes; >> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >> index d241130a..c7d7908 100644 >> --- a/fs/btrfs/volumes.c >> +++ b/fs/btrfs/volumes.c >> @@ -1548,9 +1548,10 @@ int btrfs_rm_device(struct btrfs_root *root, >> char *device_path) >> * is held. >> */ >> list_for_each_entry(tmp, devices, dev_list) { >> + btrfs_check_dev_missing(root, tmp, 0); >> if (tmp->in_fs_metadata && >> !tmp->is_tgtdev_for_dev_replace && >> - !tmp->bdev) { >> + (!tmp->bdev || tmp->missing)) { >> device = tmp; >> break; >> } >> @@ -6300,3 +6301,25 @@ int btrfs_scratch_superblock(struct >> btrfs_device *device) >> >> return 0; >> } >> + >> +/* If need_lock is set, uuid_mutex will be used */ >> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >> btrfs_device *dev, >> + int need_lock) >> +{ >> + struct request_queue *q; >> + >> + if (unlikely(!dev || !dev->bdev || !dev->bdev->bd_queue)) >> + return -ENOENT; >> + q = dev->bdev->bd_queue; >> + >> + if (need_lock) >> + mutex_lock(&uuid_mutex); >> + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags) || >> + test_bit(QUEUE_FLAG_DYING, &q->queue_flags)) { >> + dev->missing = 1; >> + root->fs_info->fs_devices->missing_devices++; >> + } >> + if (need_lock) >> + mutex_unlock(&uuid_mutex); >> + return 0; >> +} >> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h >> index 80754f9..47a44af 100644 >> --- a/fs/btrfs/volumes.h >> +++ b/fs/btrfs/volumes.h >> @@ -356,6 +356,8 @@ unsigned long btrfs_full_stripe_len(struct >> btrfs_root *root, >> int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, >> struct btrfs_root *extent_root, >> u64 chunk_offset, u64 chunk_size); >> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >> btrfs_device *dev, >> + int need_lock); >> static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, >> int index) >> { >> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-21 3:12 ` Qu Wenruo @ 2014-05-21 3:54 ` Anand Jain 2014-05-21 4:15 ` Qu Wenruo 0 siblings, 1 reply; 12+ messages in thread From: Anand Jain @ 2014-05-21 3:54 UTC (permalink / raw) To: Qu Wenruo; +Cc: linux-btrfs Hi Qu, Thanks for checking with me. sorry for the delay. The preliminary RFC patch which was sent and mentioned in the other emails took time more than expected. Further on top of your check_missing patch I am writing code to to handle disk reappear. I should be sending them all soon. Thanks, Anand On 21/05/14 11:12, Qu Wenruo wrote: > > I'm sorry to bother your but it has been about 2 weeks after your last > reply. > > Is there any problem? > > Thanks, > Qu > -------- Original Message -------- > Subject: Re: [RFC PATCH 1/2] btrfs: Add missing device check in > dev_info/rm_dev ioctl > From: Anand Jain <Anand.Jain@oracle.com> > To: Qu Wenruo <quwenruo@cn.fujitsu.com> > Date: 2014年05月07日 16:00 >> >> >> Thanks for working on this. >> I am running some tests will let you know. >> >> Anand >> >> >> On 05/06/2014 02:33 PM, Qu Wenruo wrote: >>> Old btrfs can't find a missing btrfs device since there is no >>> mechanism for block layer to inform fs layer. >>> >>> But we can use a workaround that only check status(by using >>> request_queue->queue_flags) of every device in a btrfs >>> filesystem when calling dev_info/rm_dev ioctl, since other ioctls >>> do not really cares about missing device. >>> >>> Cc: Anand Jain <Anand.Jain@oracle.com> >>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> >>> --- >>> fs/btrfs/ioctl.c | 1 + >>> fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- >>> fs/btrfs/volumes.h | 2 ++ >>> 3 files changed, 27 insertions(+), 1 deletion(-) >>> >>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >>> index 0401397..7680a40 100644 >>> --- a/fs/btrfs/ioctl.c >>> +++ b/fs/btrfs/ioctl.c >>> @@ -2606,6 +2606,7 @@ static long btrfs_ioctl_dev_info(struct >>> btrfs_root *root, void __user *arg) >>> goto out; >>> } >>> >>> + btrfs_check_dev_missing(root, dev, 1); >>> di_args->devid = dev->devid; >>> di_args->bytes_used = dev->bytes_used; >>> di_args->total_bytes = dev->total_bytes; >>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >>> index d241130a..c7d7908 100644 >>> --- a/fs/btrfs/volumes.c >>> +++ b/fs/btrfs/volumes.c >>> @@ -1548,9 +1548,10 @@ int btrfs_rm_device(struct btrfs_root *root, >>> char *device_path) >>> * is held. >>> */ >>> list_for_each_entry(tmp, devices, dev_list) { >>> + btrfs_check_dev_missing(root, tmp, 0); >>> if (tmp->in_fs_metadata && >>> !tmp->is_tgtdev_for_dev_replace && >>> - !tmp->bdev) { >>> + (!tmp->bdev || tmp->missing)) { >>> device = tmp; >>> break; >>> } >>> @@ -6300,3 +6301,25 @@ int btrfs_scratch_superblock(struct >>> btrfs_device *device) >>> >>> return 0; >>> } >>> + >>> +/* If need_lock is set, uuid_mutex will be used */ >>> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >>> btrfs_device *dev, >>> + int need_lock) >>> +{ >>> + struct request_queue *q; >>> + >>> + if (unlikely(!dev || !dev->bdev || !dev->bdev->bd_queue)) >>> + return -ENOENT; >>> + q = dev->bdev->bd_queue; >>> + >>> + if (need_lock) >>> + mutex_lock(&uuid_mutex); >>> + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags) || >>> + test_bit(QUEUE_FLAG_DYING, &q->queue_flags)) { >>> + dev->missing = 1; >>> + root->fs_info->fs_devices->missing_devices++; >>> + } >>> + if (need_lock) >>> + mutex_unlock(&uuid_mutex); >>> + return 0; >>> +} >>> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h >>> index 80754f9..47a44af 100644 >>> --- a/fs/btrfs/volumes.h >>> +++ b/fs/btrfs/volumes.h >>> @@ -356,6 +356,8 @@ unsigned long btrfs_full_stripe_len(struct >>> btrfs_root *root, >>> int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, >>> struct btrfs_root *extent_root, >>> u64 chunk_offset, u64 chunk_size); >>> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >>> btrfs_device *dev, >>> + int need_lock); >>> static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, >>> int index) >>> { >>> > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-21 3:54 ` Anand Jain @ 2014-05-21 4:15 ` Qu Wenruo 2014-05-21 18:26 ` Brendan Hide 0 siblings, 1 reply; 12+ messages in thread From: Qu Wenruo @ 2014-05-21 4:15 UTC (permalink / raw) To: Anand Jain; +Cc: linux-btrfs -------- Original Message -------- Subject: Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl From: Anand Jain <Anand.Jain@oracle.com> To: Qu Wenruo <quwenruo@cn.fujitsu.com> Date: 2014年05月21日 11:54 > > Hi Qu, > > Thanks for checking with me. sorry for the delay. The > preliminary RFC patch which was sent and mentioned in > the other emails took time more than expected. > Thanks for the commenting, it seems that my RFC patches can only deal with btrfs fi show but not sysfs things. > Further on top of your check_missing patch I am writing > code to to handle disk reappear. I should be sending them > all soon. Disk reappear problem is also reproduce here. I am intersting about how will your patch to deal with. Is your patch going to check super genertion to determing previously missing device and wipe reappeared superblock?(Wang mentioned it in the mail in Jan.) IMO the reappear disk problem can also be resolved by not swap tgtdev->uuid and srcdev->uuid, which means tgtdev will not use the same uuid of srcdev. Thanks, Qu > > Thanks, Anand > > > On 21/05/14 11:12, Qu Wenruo wrote: >> >> I'm sorry to bother your but it has been about 2 weeks after your last >> reply. >> >> Is there any problem? >> >> Thanks, >> Qu >> -------- Original Message -------- >> Subject: Re: [RFC PATCH 1/2] btrfs: Add missing device check in >> dev_info/rm_dev ioctl >> From: Anand Jain <Anand.Jain@oracle.com> >> To: Qu Wenruo <quwenruo@cn.fujitsu.com> >> Date: 2014年05月07日 16:00 >>> >>> >>> Thanks for working on this. >>> I am running some tests will let you know. >>> >>> Anand >>> >>> >>> On 05/06/2014 02:33 PM, Qu Wenruo wrote: >>>> Old btrfs can't find a missing btrfs device since there is no >>>> mechanism for block layer to inform fs layer. >>>> >>>> But we can use a workaround that only check status(by using >>>> request_queue->queue_flags) of every device in a btrfs >>>> filesystem when calling dev_info/rm_dev ioctl, since other ioctls >>>> do not really cares about missing device. >>>> >>>> Cc: Anand Jain <Anand.Jain@oracle.com> >>>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> >>>> --- >>>> fs/btrfs/ioctl.c | 1 + >>>> fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- >>>> fs/btrfs/volumes.h | 2 ++ >>>> 3 files changed, 27 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c >>>> index 0401397..7680a40 100644 >>>> --- a/fs/btrfs/ioctl.c >>>> +++ b/fs/btrfs/ioctl.c >>>> @@ -2606,6 +2606,7 @@ static long btrfs_ioctl_dev_info(struct >>>> btrfs_root *root, void __user *arg) >>>> goto out; >>>> } >>>> >>>> + btrfs_check_dev_missing(root, dev, 1); >>>> di_args->devid = dev->devid; >>>> di_args->bytes_used = dev->bytes_used; >>>> di_args->total_bytes = dev->total_bytes; >>>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c >>>> index d241130a..c7d7908 100644 >>>> --- a/fs/btrfs/volumes.c >>>> +++ b/fs/btrfs/volumes.c >>>> @@ -1548,9 +1548,10 @@ int btrfs_rm_device(struct btrfs_root *root, >>>> char *device_path) >>>> * is held. >>>> */ >>>> list_for_each_entry(tmp, devices, dev_list) { >>>> + btrfs_check_dev_missing(root, tmp, 0); >>>> if (tmp->in_fs_metadata && >>>> !tmp->is_tgtdev_for_dev_replace && >>>> - !tmp->bdev) { >>>> + (!tmp->bdev || tmp->missing)) { >>>> device = tmp; >>>> break; >>>> } >>>> @@ -6300,3 +6301,25 @@ int btrfs_scratch_superblock(struct >>>> btrfs_device *device) >>>> >>>> return 0; >>>> } >>>> + >>>> +/* If need_lock is set, uuid_mutex will be used */ >>>> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >>>> btrfs_device *dev, >>>> + int need_lock) >>>> +{ >>>> + struct request_queue *q; >>>> + >>>> + if (unlikely(!dev || !dev->bdev || !dev->bdev->bd_queue)) >>>> + return -ENOENT; >>>> + q = dev->bdev->bd_queue; >>>> + >>>> + if (need_lock) >>>> + mutex_lock(&uuid_mutex); >>>> + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags) || >>>> + test_bit(QUEUE_FLAG_DYING, &q->queue_flags)) { >>>> + dev->missing = 1; >>>> + root->fs_info->fs_devices->missing_devices++; >>>> + } >>>> + if (need_lock) >>>> + mutex_unlock(&uuid_mutex); >>>> + return 0; >>>> +} >>>> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h >>>> index 80754f9..47a44af 100644 >>>> --- a/fs/btrfs/volumes.h >>>> +++ b/fs/btrfs/volumes.h >>>> @@ -356,6 +356,8 @@ unsigned long btrfs_full_stripe_len(struct >>>> btrfs_root *root, >>>> int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, >>>> struct btrfs_root *extent_root, >>>> u64 chunk_offset, u64 chunk_size); >>>> +int btrfs_check_dev_missing(struct btrfs_root *root, struct >>>> btrfs_device *dev, >>>> + int need_lock); >>>> static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, >>>> int index) >>>> { >>>> >> >> -- >> To unsubscribe from this list: send the line "unsubscribe >> linux-btrfs" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-21 4:15 ` Qu Wenruo @ 2014-05-21 18:26 ` Brendan Hide 0 siblings, 0 replies; 12+ messages in thread From: Brendan Hide @ 2014-05-21 18:26 UTC (permalink / raw) To: Qu Wenruo, Anand Jain; +Cc: linux-btrfs On 2014/05/21 06:15 AM, Qu Wenruo wrote: > [snip] >> Further on top of your check_missing patch I am writing >> code to to handle disk reappear. I should be sending them >> all soon. > Disk reappear problem is also reproduce here. > > I am intersting about how will your patch to deal with. > Is your patch going to check super genertion to determing previously > missing device and > wipe reappeared superblock?(Wang mentioned it in the mail in Jan.) With md we have the bitmap feature that helps prevent resynchronising the entire disk when doing a "re-add". Wiping the superblock is *better* than what we currently have (corruption) - but hopefully the end goal is to be able to have it re-add *without* introducing corruption. > > IMO the reappear disk problem can also be resolved by not swap > tgtdev->uuid and srcdev->uuid, > which means tgtdev will not use the same uuid of srcdev. > > Thanks, > Qu >> >> Thanks, Anand >> -- __________ Brendan Hide http://swiftspirit.co.za/ http://www.webafrica.co.za/?AFF1E97 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl 2014-05-06 6:33 ` [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl Qu Wenruo 2014-05-07 8:00 ` Anand Jain @ 2014-05-21 3:47 ` Anand Jain 1 sibling, 0 replies; 12+ messages in thread From: Anand Jain @ 2014-05-21 3:47 UTC (permalink / raw) To: Qu Wenruo, linux-btrfs Hi Qu, Either we need to determine missing disk when disk disappear or when we hit by -ENODEV during IO. Discovering the same at the time when "user" run 'btrfs fi show' or 'btrfs dev del', is just "not correct". You might use interface as proposed here. [PATCH RFC] btrfs: revamp /sys/fs/btrfs/<fsid>/devices further to this I will be sending another patch which will call the above sysfs interlace when we get the kobject notification when disk disappear. On 05/06/2014 02:33 PM, Qu Wenruo wrote: > Old btrfs can't find a missing btrfs device since there is no > mechanism for block layer to inform fs layer. > > But we can use a workaround that only check status(by using > request_queue->queue_flags) of every device in a btrfs > filesystem when calling dev_info/rm_dev ioctl, since other ioctls > do not really cares about missing device. > Cc: Anand Jain <Anand.Jain@oracle.com> > Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> > --- > fs/btrfs/ioctl.c | 1 + > fs/btrfs/volumes.c | 25 ++++++++++++++++++++++++- > fs/btrfs/volumes.h | 2 ++ > 3 files changed, 27 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 0401397..7680a40 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -2606,6 +2606,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) > goto out; > } > > + btrfs_check_dev_missing(root, dev, 1); > di_args->devid = dev->devid; > di_args->bytes_used = dev->bytes_used; > di_args->total_bytes = dev->total_bytes; > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index d241130a..c7d7908 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -1548,9 +1548,10 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) > * is held. > */ > list_for_each_entry(tmp, devices, dev_list) { > + btrfs_check_dev_missing(root, tmp, 0); > if (tmp->in_fs_metadata && > !tmp->is_tgtdev_for_dev_replace && > - !tmp->bdev) { > + (!tmp->bdev || tmp->missing)) { > device = tmp; > break; > } > @@ -6300,3 +6301,25 @@ int btrfs_scratch_superblock(struct btrfs_device *device) > > return 0; > } > + > +/* If need_lock is set, uuid_mutex will be used */ > +int btrfs_check_dev_missing(struct btrfs_root *root, struct btrfs_device *dev, > + int need_lock) > +{ > + struct request_queue *q; > + > + if (unlikely(!dev || !dev->bdev || !dev->bdev->bd_queue)) > + return -ENOENT; > + q = dev->bdev->bd_queue; > + > + if (need_lock) > + mutex_lock(&uuid_mutex); > + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags) || > + test_bit(QUEUE_FLAG_DYING, &q->queue_flags)) { > + dev->missing = 1; > + root->fs_info->fs_devices->missing_devices++; > + } > + if (need_lock) > + mutex_unlock(&uuid_mutex); > + return 0; > +} > diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h > index 80754f9..47a44af 100644 > --- a/fs/btrfs/volumes.h > +++ b/fs/btrfs/volumes.h > @@ -356,6 +356,8 @@ unsigned long btrfs_full_stripe_len(struct btrfs_root *root, > int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, > struct btrfs_root *extent_root, > u64 chunk_offset, u64 chunk_size); > +int btrfs_check_dev_missing(struct btrfs_root *root, struct btrfs_device *dev, > + int need_lock); > static inline void btrfs_dev_stat_inc(struct btrfs_device *dev, > int index) > { > ^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFC PATCH 2/2] btrfs: Add new member of btrfs_ioctl_dev_info_args. 2014-05-06 6:33 [RFC PATCH 0/2] Kernel space btrfs missing device detection Qu Wenruo 2014-05-06 6:33 ` [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl Qu Wenruo @ 2014-05-06 6:33 ` Qu Wenruo 2014-05-06 18:10 ` [RFC PATCH 0/2] Kernel space btrfs missing device detection Goffredo Baroncelli 2 siblings, 0 replies; 12+ messages in thread From: Qu Wenruo @ 2014-05-06 6:33 UTC (permalink / raw) To: linux-btrfs; +Cc: Anand Jain Add flags member for btrfs_ioctl_dev_info_args to preset missing btrfs devices. The new member is added in the original padding area so the ioctl API is not affected but user headers needs to be updated. Cc: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> --- fs/btrfs/ioctl.c | 3 +++ include/uapi/linux/btrfs.h | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 7680a40..1920f24 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2610,6 +2610,9 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) di_args->devid = dev->devid; di_args->bytes_used = dev->bytes_used; di_args->total_bytes = dev->total_bytes; + di_args->flags = BTRFS_IOCTL_DEV_INFO_FLAG_SET; + if (dev->missing) + di_args->flags |= BTRFS_IOCTL_DEV_INFO_MISSING; memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); if (dev->name) { struct rcu_string *name; diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h index b4d6909..5eb1f03 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h @@ -168,12 +168,15 @@ struct btrfs_ioctl_dev_replace_args { __u64 spare[64]; }; +#define BTRFS_IOCTL_DEV_INFO_MISSING (1ULL<<0) +#define BTRFS_IOCTL_DEV_INFO_FLAG_SET (1ULL<<63) struct btrfs_ioctl_dev_info_args { __u64 devid; /* in/out */ __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */ __u64 bytes_used; /* out */ __u64 total_bytes; /* out */ - __u64 unused[379]; /* pad to 4k */ + __u64 flags; /* out */ + __u64 unused[378]; /* pad to 4k */ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ }; -- 1.9.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 0/2] Kernel space btrfs missing device detection. 2014-05-06 6:33 [RFC PATCH 0/2] Kernel space btrfs missing device detection Qu Wenruo 2014-05-06 6:33 ` [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl Qu Wenruo 2014-05-06 6:33 ` [RFC PATCH 2/2] btrfs: Add new member of btrfs_ioctl_dev_info_args Qu Wenruo @ 2014-05-06 18:10 ` Goffredo Baroncelli 2014-05-07 1:48 ` Qu Wenruo 2 siblings, 1 reply; 12+ messages in thread From: Goffredo Baroncelli @ 2014-05-06 18:10 UTC (permalink / raw) To: Qu Wenruo, linux-btrfs; +Cc: Anand Jain Hi, instead of extending the BTRFS_IOCTL_DEV_INFO ioctl, why do not add a field under /sys/fs/btrfs/<UUID>/ ? Something like /sys/fs/btrfs/<UUID>/missing_device BR G.Baroncelli On 05/06/2014 08:33 AM, Qu Wenruo wrote: > Original btrfs will not detection any missing device since there is > no notification mechanism for fs layer to detect missing device in > block layer. > > However we don't really need to notify fs layer upon dev remove, > probing in dev_info/rm_dev ioctl is good enough since they are the > only two ioctls caring about missing device. > > This patchset will do ioctl time missing dev detection and return > device missing status in dev_info ioctl using a new member in > btrfs_ioctl_dev_info_args with a backward compatible method. > > Cc: Anand Jain <Anand.Jain@oracle.com> Qu Wenruo (2): btrfs: Add > missing device check in dev_info/rm_dev ioctl btrfs: Add new member > of btrfs_ioctl_dev_info_args. > > fs/btrfs/ioctl.c | 4 ++++ fs/btrfs/volumes.c | 25 > ++++++++++++++++++++++++- fs/btrfs/volumes.h | 2 ++ > include/uapi/linux/btrfs.h | 5 ++++- 4 files changed, 34 > insertions(+), 2 deletions(-) > -- gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it> Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 0/2] Kernel space btrfs missing device detection. 2014-05-06 18:10 ` [RFC PATCH 0/2] Kernel space btrfs missing device detection Goffredo Baroncelli @ 2014-05-07 1:48 ` Qu Wenruo 0 siblings, 0 replies; 12+ messages in thread From: Qu Wenruo @ 2014-05-07 1:48 UTC (permalink / raw) To: kreijack, linux-btrfs; +Cc: Anand Jain -------- Original Message -------- Subject: Re: [RFC PATCH 0/2] Kernel space btrfs missing device detection. From: Goffredo Baroncelli <kreijack@libero.it> To: Qu Wenruo <quwenruo@cn.fujitsu.com>, linux-btrfs@vger.kernel.org Date: 2014年05月07日 02:10 > Hi, > > instead of extending the BTRFS_IOCTL_DEV_INFO ioctl, why do not add a field under /sys/fs/btrfs/<UUID>/ ? Something like /sys/fs/btrfs/<UUID>/missing_device > > BR > G.Baroncelli I think that is also a good idea. I'll try to add it later. Thanks Qu > > On 05/06/2014 08:33 AM, Qu Wenruo wrote: >> Original btrfs will not detection any missing device since there is >> no notification mechanism for fs layer to detect missing device in >> block layer. >> >> However we don't really need to notify fs layer upon dev remove, >> probing in dev_info/rm_dev ioctl is good enough since they are the >> only two ioctls caring about missing device. >> >> This patchset will do ioctl time missing dev detection and return >> device missing status in dev_info ioctl using a new member in >> btrfs_ioctl_dev_info_args with a backward compatible method. >> >> Cc: Anand Jain <Anand.Jain@oracle.com> Qu Wenruo (2): btrfs: Add >> missing device check in dev_info/rm_dev ioctl btrfs: Add new member >> of btrfs_ioctl_dev_info_args. >> >> fs/btrfs/ioctl.c | 4 ++++ fs/btrfs/volumes.c | 25 >> ++++++++++++++++++++++++- fs/btrfs/volumes.h | 2 ++ >> include/uapi/linux/btrfs.h | 5 ++++- 4 files changed, 34 >> insertions(+), 2 deletions(-) >> > ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-05-21 18:26 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-05-06 6:33 [RFC PATCH 0/2] Kernel space btrfs missing device detection Qu Wenruo 2014-05-06 6:33 ` [RFC PATCH 1/2] btrfs: Add missing device check in dev_info/rm_dev ioctl Qu Wenruo 2014-05-07 8:00 ` Anand Jain 2014-05-07 8:02 ` Qu Wenruo 2014-05-21 3:12 ` Qu Wenruo 2014-05-21 3:54 ` Anand Jain 2014-05-21 4:15 ` Qu Wenruo 2014-05-21 18:26 ` Brendan Hide 2014-05-21 3:47 ` Anand Jain 2014-05-06 6:33 ` [RFC PATCH 2/2] btrfs: Add new member of btrfs_ioctl_dev_info_args Qu Wenruo 2014-05-06 18:10 ` [RFC PATCH 0/2] Kernel space btrfs missing device detection Goffredo Baroncelli 2014-05-07 1:48 ` Qu Wenruo
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).