linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <dsterba@suse.cz>, <linux-btrfs@vger.kernel.org>,
	Karel Zak <kzak@redhat.com>
Subject: Re: [PATCH RFC] btrfs: Add ctime/mtime update for btrfs device add/remove.
Date: Wed, 4 Jun 2014 13:51:39 +0800	[thread overview]
Message-ID: <538EB3EB.2080309@cn.fujitsu.com> (raw)
In-Reply-To: <20140529124308.GA29992@twin.jikos.cz>


-------- Original Message --------
Subject: Re: [PATCH RFC] btrfs: Add ctime/mtime update for btrfs device 
add/remove.
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2014年05月29日 20:43
> On Wed, Apr 16, 2014 at 05:02:32PM +0800, Qu Wenruo wrote:
>> @@ -1704,10 +1720,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
>>   
>>   	ret = 0;
>>   
>> -	/* Notify udev that device has changed */
>> -	if (bdev)
>> +	if (bdev) {
>> +		/* Notify udev that device has changed */
>>   		btrfs_kobject_uevent(bdev, KOBJ_CHANGE);
>>   
>> +		/* Update ctime/mtime for device path for libblkid */
>> +		update_dev_time(device_path);
> The change on the device comes after the uevent notification, is it
> possible that the event is delivered and processed before the device
> times are updated? I would say so.
If I understand the udev thing right, uevent notification is sent to 
udevd and udevd process the notification.
For btrfs_rm_device(), it will send KOBJ_CHANGE uevent to udevd, and 
udevd will *update* the ctime/mtime in /dev.

But the problems is, there is a time lag between uevent sending and 
udevd updating the ctime/mtime,
which makes the ctime/mtime updating later than next 'btrfs dev scan' 
commands.
Since the ctime/mtime is not changed, libblkid used by 'btrfs dev scan' 
will still consider the removed disk as btrfs,
causing the bug I reported.

IMO the best method to deal the bug is to wait udevd processing the 
uevent, but unfortunately, we can't even guarantee
that there is a udevd processing the uevent(like some embedded system 
without udevd).

So I use update_dev_time() as a workaround, which provide a completely 
synchronize method to update device file ctime/mtime.
And even the uevent is processed before the update_dev_time(), it makes 
no harm except a new ctime/mtime.

Thanks,
Qu
>
>> +	}
>> +
>>   error_brelse:
>>   	brelse(bh);
>>   	if (bdev)


  parent reply	other threads:[~2014-06-04  5:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-16  9:02 [PATCH RFC] btrfs: Add ctime/mtime update for btrfs device add/remove Qu Wenruo
2014-05-29 12:43 ` David Sterba
2014-05-30  1:27   ` Qu Wenruo
2014-06-04  5:51   ` Qu Wenruo [this message]
2014-05-30  7:51 ` Anand Jain
2014-05-30  7:53   ` Anand Jain
2014-05-30  8:43   ` Qu Wenruo

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=538EB3EB.2080309@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=dsterba@suse.cz \
    --cc=kzak@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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).