From patchwork Mon Nov 9 10:56:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 7582451 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 5D24FC05C6 for ; Mon, 9 Nov 2015 10:57:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8634E206A1 for ; Mon, 9 Nov 2015 10:57:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 942652069D for ; Mon, 9 Nov 2015 10:57:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752772AbbKIK5u (ORCPT ); Mon, 9 Nov 2015 05:57:50 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:51055 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752702AbbKIK5o (ORCPT ); Mon, 9 Nov 2015 05:57:44 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tA9AvhXJ014201 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 9 Nov 2015 10:57:44 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id tA9AvhYV012107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 9 Nov 2015 10:57:43 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id tA9AvhDn020389 for ; Mon, 9 Nov 2015 10:57:43 GMT Received: from arch2.sg.oracle.com (/10.186.101.93) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Nov 2015 02:57:43 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 09/15] btrfs: block incompatible optional features at scan Date: Mon, 9 Nov 2015 18:56:23 +0800 Message-Id: <1447066589-3835-10-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1447066589-3835-1-git-send-email-anand.jain@oracle.com> References: <1447066589-3835-1-git-send-email-anand.jain@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.2 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 For the matter of completeness we need to check if the device being scanned has features that are known to the kernel. As of now if it doesn't - the mount will fails, then what is the point in having those devices added to the btrfs_fs_devices list at device_list_add(). So block those devices at scan. Which means the original block at open_ctee() won't reach in case of device with unsupported feature. But I am leaving that code as it is. without deleting. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b52197b..fcc9e57 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -976,6 +976,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, u64 transid; u64 total_devices; u64 bytenr; + u64 features; /* * we would like to check all the supers, but that would make @@ -996,6 +997,15 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, if (btrfs_read_disk_super(bdev, bytenr, &page, &disk_super)) goto error_bdev_put; + features = btrfs_super_incompat_flags(disk_super) & + ~BTRFS_FEATURE_INCOMPAT_SUPP; + if (features) { + printk(KERN_ERR \ + "BTRFS: couldn't scan, unsupported optional features (%Lx)\n", + features); + ret = -EOPNOTSUPP; + goto error_disk_super; + } devid = btrfs_stack_device_id(&disk_super->dev_item); transid = btrfs_super_generation(disk_super); total_devices = btrfs_super_num_devices(disk_super); @@ -1010,6 +1020,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, if (!ret && fs_devices_ret) (*fs_devices_ret)->total_devices = total_devices; +error_disk_super: btrfs_release_disk_super(page); error_bdev_put: