linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()
@ 2017-10-12  9:00 Anand Jain
  2017-10-16 14:45 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Anand Jain @ 2017-10-12  9:00 UTC (permalink / raw)
  To: linux-btrfs

That was only an extra check to tackle few bugs around this
area, now its save to remove it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 332e00e72b86..0a5251a34d58 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2015,16 +2015,12 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_fs_info *fs_info,
 	}
 
 	btrfs_close_bdev(srcdev);
-
 	call_rcu(&srcdev->rcu, free_device);
 
 	/*
-	 * unless fs_devices is seed fs, num_devices shouldn't go
-	 * zero
+	 * If this is no devs we rather delete the fs_devices
+	 * which is true in case of single device seeding fs.
 	 */
-	BUG_ON(!fs_devices->num_devices && !fs_devices->seeding);
-
-	/* if this is no devs we rather delete the fs_devices */
 	if (!fs_devices->num_devices) {
 		struct btrfs_fs_devices *tmp_fs_devices;
 
-- 
2.13.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()
  2017-10-12  9:00 [PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev() Anand Jain
@ 2017-10-16 14:45 ` David Sterba
  2017-10-16 22:53   ` [PATCH v2] " Anand Jain
  2017-10-16 23:32   ` [PATCH] " Anand Jain
  0 siblings, 2 replies; 4+ messages in thread
From: David Sterba @ 2017-10-16 14:45 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Thu, Oct 12, 2017 at 05:00:41PM +0800, Anand Jain wrote:
> That was only an extra check to tackle few bugs around this
> area, now its save to remove it.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/volumes.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 332e00e72b86..0a5251a34d58 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -2015,16 +2015,12 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_fs_info *fs_info,
>  	}
>  
>  	btrfs_close_bdev(srcdev);
> -
>  	call_rcu(&srcdev->rcu, free_device);
>  
>  	/*
> -	 * unless fs_devices is seed fs, num_devices shouldn't go
> -	 * zero
> +	 * If this is no devs we rather delete the fs_devices
> +	 * which is true in case of single device seeding fs.

Can you please rephrase the first part of the comment? I'm not sure I
understand what it's trying to say.

>  	 */
> -	BUG_ON(!fs_devices->num_devices && !fs_devices->seeding);

I think we could still keep the check as an ASSERT.

> -
> -	/* if this is no devs we rather delete the fs_devices */
>  	if (!fs_devices->num_devices) {
>  		struct btrfs_fs_devices *tmp_fs_devices;
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()
  2017-10-16 14:45 ` David Sterba
@ 2017-10-16 22:53   ` Anand Jain
  2017-10-16 23:32   ` [PATCH] " Anand Jain
  1 sibling, 0 replies; 4+ messages in thread
From: Anand Jain @ 2017-10-16 22:53 UTC (permalink / raw)
  To: linux-btrfs

Use ASSERT instead of BUG_ON.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
V2: Accepts David suggestion to keep the check as ASSERT.
    Adds more comments to explain the context.

 fs/btrfs/volumes.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 93afc7d49d4d..94a9e69e844b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2015,19 +2015,20 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_fs_info *fs_info,
 	}
 
 	btrfs_close_bdev(srcdev);
-
 	call_rcu(&srcdev->rcu, free_device);
 
-	/*
-	 * unless fs_devices is seed fs, num_devices shouldn't go
-	 * zero
-	 */
-	BUG_ON(!fs_devices->num_devices && !fs_devices->seeding);
-
 	/* if this is no devs we rather delete the fs_devices */
 	if (!fs_devices->num_devices) {
 		struct btrfs_fs_devices *tmp_fs_devices;
 
+		/*
+		 * In a mounted FS, num_devices can't be zero unless
+		 * its a seed. Where in case of seed device being replaced,
+		 * the replace target added to the sprout FS, so there
+		 * will be no more device left under the seed FS.
+		 */
+		ASSERT(fs_devices->seeding);
+
 		tmp_fs_devices = fs_info->fs_devices;
 		while (tmp_fs_devices) {
 			if (tmp_fs_devices->seed == fs_devices) {
-- 
2.13.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev()
  2017-10-16 14:45 ` David Sterba
  2017-10-16 22:53   ` [PATCH v2] " Anand Jain
@ 2017-10-16 23:32   ` Anand Jain
  1 sibling, 0 replies; 4+ messages in thread
From: Anand Jain @ 2017-10-16 23:32 UTC (permalink / raw)
  To: dsterba, linux-btrfs



On 10/16/2017 10:45 PM, David Sterba wrote:
> On Thu, Oct 12, 2017 at 05:00:41PM +0800, Anand Jain wrote:
>> That was only an extra check to tackle few bugs around this
>> area, now its save to remove it.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   fs/btrfs/volumes.c | 8 ++------
>>   1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
>> index 332e00e72b86..0a5251a34d58 100644
>> --- a/fs/btrfs/volumes.c
>> +++ b/fs/btrfs/volumes.c
>> @@ -2015,16 +2015,12 @@ void btrfs_rm_dev_replace_free_srcdev(struct btrfs_fs_info *fs_info,
>>   	}
>>   
>>   	btrfs_close_bdev(srcdev);
>> -
>>   	call_rcu(&srcdev->rcu, free_device);
>>   
>>   	/*
>> -	 * unless fs_devices is seed fs, num_devices shouldn't go
>> -	 * zero
>> +	 * If this is no devs we rather delete the fs_devices
>> +	 * which is true in case of single device seeding fs.
> 
> Can you please rephrase the first part of the comment? I'm not sure I
> understand what it's trying to say.
> 
>>   	 */
>> -	BUG_ON(!fs_devices->num_devices && !fs_devices->seeding);
> 
> I think we could still keep the check as an ASSERT.

  OK. I have fixed these in V2.

Thanks, Anand

>> -
>> -	/* if this is no devs we rather delete the fs_devices */
>>   	if (!fs_devices->num_devices) {
>>   		struct btrfs_fs_devices *tmp_fs_devices;
>>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-16 23:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-12  9:00 [PATCH] btrfs: remove BUG_ON in btrfs_rm_dev_replace_free_srcdev() Anand Jain
2017-10-16 14:45 ` David Sterba
2017-10-16 22:53   ` [PATCH v2] " Anand Jain
2017-10-16 23:32   ` [PATCH] " Anand Jain

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).