From patchwork Tue May 10 14:09:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 9058301 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 964B5BF440 for ; Tue, 10 May 2016 14:09:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8880820142 for ; Tue, 10 May 2016 14:09:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69FFA200E5 for ; Tue, 10 May 2016 14:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752481AbcEJOJr (ORCPT ); Tue, 10 May 2016 10:09:47 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:36019 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752458AbcEJOJp (ORCPT ); Tue, 10 May 2016 10:09:45 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4AE9en6022975 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 10 May 2016 14:09:41 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u4AE9eOG005791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 10 May 2016 14:09:40 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u4AE9eBR018604; Tue, 10 May 2016 14:09:40 GMT Received: from arch2.sg.oracle.com (/10.186.101.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 May 2016 07:09:39 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, yauhen.kharuzhy@zavadatar.com Subject: [PATCH 07/13] btrfs: add check not to mount a spare device Date: Tue, 10 May 2016 22:09:26 +0800 Message-Id: <1462889372-5274-9-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1462889372-5274-1-git-send-email-anand.jain@oracle.com> References: <1462889372-5274-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anand Jain Spare devices can be scanned but shouldn't be mountable. Signed-off-by: Anand Jain Tested-by: Austin S. Hemmelgarn Tested-by: Yauhen Kharuzhy --- fs/btrfs/disk-io.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 65c9f19d8017..e9fca3bc7e42 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2811,6 +2811,14 @@ int open_ctree(struct super_block *sb, goto fail_alloc; } + if (btrfs_super_incompat_flags(disk_super) & + BTRFS_FEATURE_INCOMPAT_SPARE_DEV) { + /*You can only scan a spare device but not mount*/ + printk(KERN_ERR "BTRFS: You can't mount a spare device\n"); + err = -ENOTSUPP; + goto fail_alloc; + } + /* * Needn't use the lock because there is no other task which will * update the flag.