From patchwork Mon Nov 9 10:56:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 7582481 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 647E5C05C6 for ; Mon, 9 Nov 2015 10:57:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D8A120697 for ; Mon, 9 Nov 2015 10:57:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42605206AD for ; Mon, 9 Nov 2015 10:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752818AbbKIK5z (ORCPT ); Mon, 9 Nov 2015 05:57:55 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:51081 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751574AbbKIK5s (ORCPT ); Mon, 9 Nov 2015 05:57:48 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tA9AvlOJ014227 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 9 Nov 2015 10:57:47 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id tA9AvlDj004853 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 9 Nov 2015 10:57:47 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 tA9Avl9k020396 for ; Mon, 9 Nov 2015 10:57:47 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:46 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 12/15] btrfs: support btrfs dev scan for spare device Date: Mon, 9 Nov 2015 18:56:26 +0800 Message-Id: <1447066589-3835-13-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: aserv0022.oracle.com [141.146.126.234] 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 When the user or system calls the BTRFS_IOC_SCAN_DEV, ioctl this patch will make sure it is added to the device list and set it as spare. This operation will be same when BTRFS_IOC_DEVICES_READY as well since BTRFS_IOC_DEVICES_READY ioctl has been doing that by legacy. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 4 ++++ fs/btrfs/volumes.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index fcc9e57..28f549d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -526,6 +526,10 @@ static noinline int device_list_add(const char *path, if (IS_ERR(fs_devices)) return PTR_ERR(fs_devices); + if (btrfs_super_incompat_flags(disk_super) & + BTRFS_FEATURE_INCOMPAT_SPARE_DEV) + fs_devices->spare = 1; + list_add(&fs_devices->list, &fs_uuids); device = NULL; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 827371e..3d995b7 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -278,6 +278,8 @@ struct btrfs_fs_devices { struct kobject fsid_kobj; struct kobject *device_dir_kobj; struct completion kobj_unregister; + + int spare; }; #define BTRFS_BIO_INLINE_CSUM_SIZE 64