Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755216AbbGPBMM (ORCPT ); Wed, 15 Jul 2015 21:12:12 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:56446 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755117AbbGPBMG (ORCPT ); Wed, 15 Jul 2015 21:12:06 -0400 From: Kamal Mostafa To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Omar Sandoval , Chris Mason , Kamal Mostafa Subject: [PATCH 3.19.y-ckt 251/251] Btrfs: lock superblock before remounting for rw subvol Date: Wed, 15 Jul 2015 18:09:32 -0700 Message-Id: <1437008972-9140-252-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437008972-9140-1-git-send-email-kamal@canonical.com> References: <1437008972-9140-1-git-send-email-kamal@canonical.com> X-Extended-Stable: 3.19 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1946 Lines: 61 3.19.8-ckt4 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Omar Sandoval commit 773cd04ec1911abb33cf9538b65f55b76cad5d92 upstream. Since commit 0723a0473fb4 ("btrfs: allow mounting btrfs subvolumes with different ro/rw options"), when mounting a subvolume read/write when another subvolume has previously been mounted read-only, we first do a remount. However, this should be done with the superblock locked, as per sync_filesystem(): /* * We need to be protected against the filesystem going from * r/o to r/w or vice versa. */ WARN_ON(!rwsem_is_locked(&sb->s_umount)); This WARN_ON can easily be hit with: mkfs.btrfs -f /dev/vdb mount /dev/vdb /mnt btrfs subvol create /mnt/vol1 btrfs subvol create /mnt/vol2 umount /mnt mount -oro,subvol=/vol1 /dev/vdb /mnt mount -orw,subvol=/vol2 /dev/vdb /mnt2 Fixes: 0723a0473fb4 ("btrfs: allow mounting btrfs subvolumes with different ro/rw options") Reviewed-by: David Sterba Signed-off-by: Omar Sandoval Signed-off-by: Chris Mason Signed-off-by: Kamal Mostafa --- fs/btrfs/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 6f49b28..a25cb5b 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1205,7 +1205,9 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags, return ERR_CAST(mnt); } + down_write(&mnt->mnt_sb->s_umount); r = btrfs_remount(mnt->mnt_sb, &flags, NULL); + up_write(&mnt->mnt_sb->s_umount); if (r < 0) { /* FIXME: release vfsmount mnt ??*/ kfree(newargs); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/