[3.11.y.z extended stable] Patch "btrfs: Add ctime/mtime update for btrfs device add/remove." has been added to staging queue
Luis Henriques
luis.henriques at canonical.com
Thu Jul 10 11:17:37 UTC 2014
This is a note to let you know that I have just added a patch titled
btrfs: Add ctime/mtime update for btrfs device add/remove.
to the linux-3.11.y-queue branch of the 3.11.y.z extended stable tree
which can be found at:
http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.11.y-queue
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 3.11.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
Thanks.
-Luis
------
>From a63e8b23a4f901b1d8fbc83be8e28d334fb79332 Mon Sep 17 00:00:00 2001
From: Qu Wenruo <quwenruo at cn.fujitsu.com>
Date: Wed, 16 Apr 2014 17:02:32 +0800
Subject: btrfs: Add ctime/mtime update for btrfs device add/remove.
commit 5a1972bd9fd4b2fb1bac8b7a0b636d633d8717e3 upstream.
Btrfs will send uevent to udev inform the device change,
but ctime/mtime for the block device inode is not udpated, which cause
libblkid used by btrfs-progs unable to detect device change and use old
cache, causing 'btrfs dev scan; btrfs dev rmove; btrfs dev scan' give an
error message.
Reported-by: Tsutomu Itoh <t-itoh at jp.fujitsu.com>
Cc: Karel Zak <kzak at redhat.com>
Signed-off-by: Qu Wenruo <quwenruo at cn.fujitsu.com>
Signed-off-by: Chris Mason <clm at fb.com>
Cc: David Sterba <dsterba at suse.cz>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
fs/btrfs/volumes.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index feb93fc9863d..cacdb3effa35 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1403,6 +1403,22 @@ out:
return ret;
}
+/*
+ * Function to update ctime/mtime for a given device path.
+ * Mainly used for ctime/mtime based probe like libblkid.
+ */
+static void update_dev_time(char *path_name)
+{
+ struct file *filp;
+
+ filp = filp_open(path_name, O_RDWR, 0);
+ if (!filp)
+ return;
+ file_update_time(filp);
+ filp_close(filp, NULL);
+ return;
+}
+
static int btrfs_rm_dev_item(struct btrfs_root *root,
struct btrfs_device *device)
{
@@ -1649,10 +1665,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);
+ }
+
error_brelse:
brelse(bh);
if (bdev)
@@ -2096,6 +2116,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
ret = btrfs_commit_transaction(trans, root);
}
+ /* Update ctime/mtime for libblkid */
+ update_dev_time(device_path);
return ret;
error_trans:
--
1.9.1
More information about the kernel-team
mailing list