linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: refactor btrfs_free_stale_device() to get device list delete
Date: Sat, 18 Nov 2017 21:50:14 +0800	[thread overview]
Message-ID: <ec2c9e78-a9e1-aa7b-43d2-2d8c73489781@oracle.com> (raw)
In-Reply-To: <4a9afb0a-f6a5-d9b7-6846-f915d496d20c@suse.com>



On 11/16/2017 09:59 PM, Nikolay Borisov wrote:
> 
> 
> On 13.11.2017 07:44, Anand Jain wrote:
>> We need to delete a device from the dev_list, so refactor
>> btrfs_free_stale_device() for delete_device_from_list().
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   fs/btrfs/volumes.c | 27 +++++++++++++++++----------
>>   1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
>> index 8bac1cf17048..8ead85dba6f5 100644
>> --- a/fs/btrfs/volumes.c
>> +++ b/fs/btrfs/volumes.c
>> @@ -546,6 +546,22 @@ static void pending_bios_fn(struct btrfs_work *work)
>>   	run_scheduled_bios(device);
>>   }
>>   
>> +void delete_device_from_list(struct btrfs_device *dev)
> 
> In this patch and the other one this function is used only in volume.c
> so make static.

  Right. Will do.

> Also if it relies on some particular lock being held why
> not add lockdep_assert_held(xxx) as a means of documenting that ?

  Actually, btrfs_free_stale_device() should be holding device_list_mutex
  but it didn't so I would like to fix it separately. So here I shall
  create a new function instead of peal from btrfs_free_stale_device(),
  which I think btrfs_free_stale_device() can use it later.

Thanks, Anand

>> +{
>> +	struct btrfs_fs_devices *fs_devs;
>> +	fs_devs = dev->fs_devices;
>> +
>> +	if (fs_devs->num_devices == 1) {
>> +		btrfs_sysfs_remove_fsid(fs_devs);
>> +		list_del(&fs_devs->list);
>> +		free_fs_devices(fs_devs);
>> +	} else {
>> +		fs_devs->num_devices--;
>> +		list_del(&dev->dev_list);
>> +		rcu_string_free(dev->name);
>> +		kfree(dev);
>> +	}
>> +}
>>   
>>   void btrfs_free_stale_device(struct btrfs_device *cur_dev)
>>   {
>> @@ -586,16 +602,7 @@ void btrfs_free_stale_device(struct btrfs_device *cur_dev)
>>   
>>   		if (!del) {
>>   			/* delete the stale device */
>> -			if (fs_devs->num_devices == 1) {
>> -				btrfs_sysfs_remove_fsid(fs_devs);
>> -				list_del(&fs_devs->list);
>> -				free_fs_devices(fs_devs);
>> -			} else {
>> -				fs_devs->num_devices--;
>> -				list_del(&dev->dev_list);
>> -				rcu_string_free(dev->name);
>> -				kfree(dev);
>> -			}
>> +			delete_device_from_list(dev);
>>   			break;
>>   		}
>>   	}
>>
> --
> 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
> 

  reply	other threads:[~2017-11-18 13:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-13  5:44 [PATCH 0/2] Add cli and ioctl to ignore a scanned device Anand Jain
2017-11-13  5:44 ` [PATCH 1/2] btrfs: refactor btrfs_free_stale_device() to get device list delete Anand Jain
2017-11-16 13:59   ` Nikolay Borisov
2017-11-18 13:50     ` Anand Jain [this message]
2017-11-13  5:44 ` [PATCH 2/2] btrfs: introduce feature to ignore a btrfs device Anand Jain
2017-11-16 14:03   ` Nikolay Borisov
2017-11-18 13:50     ` Anand Jain
2017-11-16 14:11   ` Nikolay Borisov
2017-11-18 13:50     ` Anand Jain
2017-11-18 14:28       ` Nikolay Borisov
2017-11-20  8:21         ` Anand Jain
2017-11-13  5:45 ` [PATCH] btrfs-progs: add 'btrfs device ignore' cli Anand Jain
2017-11-18 14:03 ` [PATCH v2 1/2] btrfs: add function to device list delete Anand Jain
2017-11-18 14:03   ` [PATCH v2 2/2] btrfs: introduce feature to ignore a btrfs device Anand Jain
2017-11-20  8:23   ` [PATCH v2 1/2] btrfs: add function to device list delete Anand Jain
2017-11-20  8:38 ` [PATCH v3 " Anand Jain
2017-11-20  8:38   ` [PATCH v3 2/2] btrfs: introduce feature to ignore a btrfs 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=ec2c9e78-a9e1-aa7b-43d2-2d8c73489781@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.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).