From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp1040.oracle.com ([156.151.31.81]:21609 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752112AbcFWMx1 (ORCPT ); Thu, 23 Jun 2016 08:53:27 -0400 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, holger@applied-asynchrony.com, clm@fb.com, xiaolong.ye@intel.com Subject: [PATCH v3 2/2] btrfs: make sure device is synced before return Date: Thu, 23 Jun 2016 20:54:07 +0800 Message-Id: <1466686447-7780-1-git-send-email-anand.jain@oracle.com> In-Reply-To: <1465901726-15490-2-git-send-email-anand.jain@oracle.com> References: <1465901726-15490-2-git-send-email-anand.jain@oracle.com> Sender: linux-btrfs-owner@vger.kernel.org List-ID: An inconsistent behavior due to stale reads from the disk was reported mail-archive.com/linux-btrfs@vger.kernel.org/msg54188.html This patch will make sure devices are synced before return in the unmount thread. Signed-off-by: Anand Jain --- v2: Also to make sure bdev_closing is set it needs rcu_barrier(), restored rcu_barrier(). v3: Removed the complicated timed-wait on blkdev_put code, but make synced and invalidated before umount is returned. So sorry that I have to change the title of this patch as well (was: btrfs: wait for bdev put). fs/btrfs/volumes.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 604daf315669..f741ade130a4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -870,6 +870,11 @@ static void btrfs_close_one_device(struct btrfs_device *device) if (device->missing) fs_devices->missing_devices--; + if (device->bdev && device->writeable) { + sync_blockdev(device->bdev); + invalidate_bdev(device->bdev); + } + new_device = btrfs_alloc_device(NULL, &device->devid, device->uuid); BUG_ON(IS_ERR(new_device)); /* -ENOMEM */ -- 2.7.0