From patchwork Tue Mar 29 14:22: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: 8687591 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 2FDF1C0554 for ; Tue, 29 Mar 2016 14:23:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F546201FE for ; Tue, 29 Mar 2016 14:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 967DA20328 for ; Tue, 29 Mar 2016 14:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932304AbcC2OW6 (ORCPT ); Tue, 29 Mar 2016 10:22:58 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:25184 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932289AbcC2OWz (ORCPT ); Tue, 29 Mar 2016 10:22:55 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2TEMpl3003198 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Mar 2016 14:22:51 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u2TEMojw017807 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Mar 2016 14:22:51 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u2TEMo8R001698; Tue, 29 Mar 2016 14:22:50 GMT Received: from arch2.sg.oracle.com (/10.186.101.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 Mar 2016 07:22:50 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: clm@fb.com, dsterba@suse.cz Subject: [PATCH 09/12] btrfs: support btrfs dev scan for spare device Date: Tue, 29 Mar 2016 22:22:26 +0800 Message-Id: <1459261349-32206-10-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1459261349-32206-1-git-send-email-anand.jain@oracle.com> References: <1459261349-32206-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] 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.9 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 a662701d4f22..26ae4fd39ce7 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -604,6 +604,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 ccc716b3c419..6b3b730c2727 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -276,6 +276,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