From patchwork Wed Nov 13 10:27:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11241649 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 635FC1850 for ; Wed, 13 Nov 2019 10:27:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44173222C6 for ; Wed, 13 Nov 2019 10:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbfKMK1i (ORCPT ); Wed, 13 Nov 2019 05:27:38 -0500 Received: from mx2.suse.de ([195.135.220.15]:48184 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726340AbfKMK1i (ORCPT ); Wed, 13 Nov 2019 05:27:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F1E2BB507; Wed, 13 Nov 2019 10:27:36 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Qu Wenru , Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH v2 1/7] btrfs: decrement number of open devices after closing the device not before Date: Wed, 13 Nov 2019 11:27:22 +0100 Message-Id: <20191113102728.8835-2-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191113102728.8835-1-jthumshirn@suse.de> References: <20191113102728.8835-1-jthumshirn@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In btrfs_close_one_device we're decrementing the number of open devices before we're calling btrfs_close_bdev(). As there is no intermediate exit between these points in this function it is technically OK to do so, but it a) is a bit harder to understand and b) further refactoring to implement proper error handling in btrfs_close_one_device() will change the layout of the function. Move both operations closer together and move the decrement step after btrfs_close_bdev(). Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 22a5bd991e47..5ee26e7fca32 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1067,9 +1067,6 @@ static void btrfs_close_one_device(struct btrfs_device *device) struct btrfs_device *new_device; struct rcu_string *name; - if (device->bdev) - fs_devices->open_devices--; - if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) && device->devid != BTRFS_DEV_REPLACE_DEVID) { list_del_init(&device->dev_alloc_list); @@ -1080,6 +1077,8 @@ static void btrfs_close_one_device(struct btrfs_device *device) fs_devices->missing_devices--; btrfs_close_bdev(device); + if (device->bdev) + fs_devices->open_devices--; new_device = btrfs_alloc_device(NULL, &device->devid, device->uuid); From patchwork Wed Nov 13 10:27:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11241661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 009C714ED for ; Wed, 13 Nov 2019 10:27:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D6224222C6 for ; Wed, 13 Nov 2019 10:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727403AbfKMK1p (ORCPT ); Wed, 13 Nov 2019 05:27:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:48192 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726422AbfKMK1i (ORCPT ); Wed, 13 Nov 2019 05:27:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F251FB5F9; Wed, 13 Nov 2019 10:27:36 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Qu Wenru , Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH v2 2/7] btrfs: handle device allocation failure in btrfs_close_one_device() Date: Wed, 13 Nov 2019 11:27:23 +0100 Message-Id: <20191113102728.8835-3-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191113102728.8835-1-jthumshirn@suse.de> References: <20191113102728.8835-1-jthumshirn@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In btrfs_close_one_device() we're allocating a new device and if this fails we BUG(). Move the allocation to the top of the function and return an error in case it failed. The BUG_ON() is temporarily moved to close_fs_devices(), the caller of btrfs_close_one_device() as further work is pending to untangle this. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5ee26e7fca32..0a2a73907563 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1061,12 +1061,17 @@ static void btrfs_close_bdev(struct btrfs_device *device) blkdev_put(device->bdev, device->mode); } -static void btrfs_close_one_device(struct btrfs_device *device) +static int btrfs_close_one_device(struct btrfs_device *device) { struct btrfs_fs_devices *fs_devices = device->fs_devices; struct btrfs_device *new_device; struct rcu_string *name; + new_device = btrfs_alloc_device(NULL, &device->devid, + device->uuid); + if (IS_ERR(new_device)) + goto err_close_device; + if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) && device->devid != BTRFS_DEV_REPLACE_DEVID) { list_del_init(&device->dev_alloc_list); @@ -1080,10 +1085,6 @@ static void btrfs_close_one_device(struct btrfs_device *device) if (device->bdev) fs_devices->open_devices--; - new_device = btrfs_alloc_device(NULL, &device->devid, - device->uuid); - BUG_ON(IS_ERR(new_device)); /* -ENOMEM */ - /* Safe because we are under uuid_mutex */ if (device->name) { name = rcu_string_strdup(device->name->str, GFP_NOFS); @@ -1096,18 +1097,32 @@ static void btrfs_close_one_device(struct btrfs_device *device) synchronize_rcu(); btrfs_free_device(device); + + return 0; + +err_close_device: + btrfs_close_bdev(device); + if (device->bdev) { + fs_devices->open_devices--; + btrfs_sysfs_rm_device_link(fs_devices, device); + device->bdev = NULL; + } + + return -ENOMEM; } static int close_fs_devices(struct btrfs_fs_devices *fs_devices) { struct btrfs_device *device, *tmp; + int ret; if (--fs_devices->opened > 0) return 0; mutex_lock(&fs_devices->device_list_mutex); list_for_each_entry_safe(device, tmp, &fs_devices->devices, dev_list) { - btrfs_close_one_device(device); + ret = btrfs_close_one_device(device); + BUG_ON(ret); /* -ENOMEM */ } mutex_unlock(&fs_devices->device_list_mutex); From patchwork Wed Nov 13 10:27:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11241659 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F37FC1850 for ; Wed, 13 Nov 2019 10:27:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D470922459 for ; Wed, 13 Nov 2019 10:27:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727394AbfKMK1n (ORCPT ); Wed, 13 Nov 2019 05:27:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:48200 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726613AbfKMK1i (ORCPT ); Wed, 13 Nov 2019 05:27:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0AFDCB5FA; Wed, 13 Nov 2019 10:27:37 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Qu Wenru , Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH v2 3/7] btrfs: handle allocation failure in strdup Date: Wed, 13 Nov 2019 11:27:24 +0100 Message-Id: <20191113102728.8835-4-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191113102728.8835-1-jthumshirn@suse.de> References: <20191113102728.8835-1-jthumshirn@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Gracefully handle allocation failures in btrfs_close_one_device()'s rcu_string_strdup() instead of crashing the machine. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0a2a73907563..e5864ca3bb3b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1064,7 +1064,7 @@ static void btrfs_close_bdev(struct btrfs_device *device) static int btrfs_close_one_device(struct btrfs_device *device) { struct btrfs_fs_devices *fs_devices = device->fs_devices; - struct btrfs_device *new_device; + struct btrfs_device *new_device = NULL; struct rcu_string *name; new_device = btrfs_alloc_device(NULL, &device->devid, @@ -1072,6 +1072,15 @@ static int btrfs_close_one_device(struct btrfs_device *device) if (IS_ERR(new_device)) goto err_close_device; + /* Safe because we are under uuid_mutex */ + if (device->name) { + name = rcu_string_strdup(device->name->str, GFP_NOFS); + if (!name) + goto err_free_device; + + rcu_assign_pointer(new_device->name, name); + } + if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) && device->devid != BTRFS_DEV_REPLACE_DEVID) { list_del_init(&device->dev_alloc_list); @@ -1085,13 +1094,6 @@ static int btrfs_close_one_device(struct btrfs_device *device) if (device->bdev) fs_devices->open_devices--; - /* Safe because we are under uuid_mutex */ - if (device->name) { - name = rcu_string_strdup(device->name->str, GFP_NOFS); - BUG_ON(!name); /* -ENOMEM */ - rcu_assign_pointer(new_device->name, name); - } - list_replace_rcu(&device->dev_list, &new_device->dev_list); new_device->fs_devices = device->fs_devices; @@ -1100,6 +1102,10 @@ static int btrfs_close_one_device(struct btrfs_device *device) return 0; +err_free_device: + if (new_device) + btrfs_free_device(new_device); + err_close_device: btrfs_close_bdev(device); if (device->bdev) { From patchwork Wed Nov 13 10:27:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11241657 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57B0E15AB for ; Wed, 13 Nov 2019 10:27:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 384EF22459 for ; Wed, 13 Nov 2019 10:27:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727372AbfKMK1n (ORCPT ); Wed, 13 Nov 2019 05:27:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:48238 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727229AbfKMK1j (ORCPT ); Wed, 13 Nov 2019 05:27:39 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 18174B2C3; Wed, 13 Nov 2019 10:27:37 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Qu Wenru , Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH v2 4/7] btrfs: handle error return of close_fs_devices() Date: Wed, 13 Nov 2019 11:27:25 +0100 Message-Id: <20191113102728.8835-5-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191113102728.8835-1-jthumshirn@suse.de> References: <20191113102728.8835-1-jthumshirn@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org close_fs_devices() will be able to return an error instead of crashing after the following patch. Prepare btrfs_close_devices() for this. Signed-off-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e5864ca3bb3b..be1fd935edf7 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1143,10 +1143,10 @@ static int close_fs_devices(struct btrfs_fs_devices *fs_devices) int btrfs_close_devices(struct btrfs_fs_devices *fs_devices) { struct btrfs_fs_devices *seed_devices = NULL; - int ret; + int err, err2 = 0; mutex_lock(&uuid_mutex); - ret = close_fs_devices(fs_devices); + err = close_fs_devices(fs_devices); if (!fs_devices->opened) { seed_devices = fs_devices->seed; fs_devices->seed = NULL; @@ -1156,10 +1156,13 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices) while (seed_devices) { fs_devices = seed_devices; seed_devices = fs_devices->seed; - close_fs_devices(fs_devices); + err2 = close_fs_devices(fs_devices); free_fs_devices(fs_devices); } - return ret; + + if (err2) + return err2; + return err; } static int open_fs_devices(struct btrfs_fs_devices *fs_devices, From patchwork Wed Nov 13 10:27:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11241651 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E2AE18B6 for ; Wed, 13 Nov 2019 10:27:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79E16222C6 for ; Wed, 13 Nov 2019 10:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727222AbfKMK1j (ORCPT ); Wed, 13 Nov 2019 05:27:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:48198 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726597AbfKMK1i (ORCPT ); Wed, 13 Nov 2019 05:27:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 10753B5FB; Wed, 13 Nov 2019 10:27:37 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Qu Wenru , Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH v2 5/7] btrfs: remove final BUG_ON() in close_fs_devices() Date: Wed, 13 Nov 2019 11:27:26 +0100 Message-Id: <20191113102728.8835-6-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191113102728.8835-1-jthumshirn@suse.de> References: <20191113102728.8835-1-jthumshirn@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that the preparation work is done, remove the temporary BUG_ON() in close_fs_devices() and return an error instead. Signed-off-by: Johannes Thumshirn --- Changes to v1: - btrfs_fs_devices::seeding is a 'boolean' flags and no counter, don't decrement it (Qu) --- fs/btrfs/volumes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index be1fd935edf7..25e4608e20f1 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1128,7 +1128,11 @@ static int close_fs_devices(struct btrfs_fs_devices *fs_devices) mutex_lock(&fs_devices->device_list_mutex); list_for_each_entry_safe(device, tmp, &fs_devices->devices, dev_list) { ret = btrfs_close_one_device(device); - BUG_ON(ret); /* -ENOMEM */ + if (ret) { + mutex_unlock(&fs_devices->device_list_mutex); + return ret; + } + fs_devices->opened--; } mutex_unlock(&fs_devices->device_list_mutex); From patchwork Wed Nov 13 10:27:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11241655 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C86B314ED for ; Wed, 13 Nov 2019 10:27:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A961E22459 for ; Wed, 13 Nov 2019 10:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727348AbfKMK1k (ORCPT ); Wed, 13 Nov 2019 05:27:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:48240 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726597AbfKMK1k (ORCPT ); Wed, 13 Nov 2019 05:27:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 18AB9B52C; Wed, 13 Nov 2019 10:27:37 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Qu Wenru , Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH v2 6/7] btrfs: change btrfs_fs_devices::seeing to bool Date: Wed, 13 Nov 2019 11:27:27 +0100 Message-Id: <20191113102728.8835-7-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191113102728.8835-1-jthumshirn@suse.de> References: <20191113102728.8835-1-jthumshirn@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org struct btrfs_fs_devices::seeding currently is declared as an integer variable but only used as a boolean. Change the variable definition to bool and update to code touching it to set 'true' and 'false'. Signed-off-by: Johannes Thumshirn Reviewed-by: Anand Jain --- fs/btrfs/volumes.c | 8 ++++---- fs/btrfs/volumes.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 25e4608e20f1..ce9c6fa3a32c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -634,7 +634,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, } clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); - fs_devices->seeding = 1; + fs_devices->seeding = true; } else { if (bdev_read_only(bdev)) clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); @@ -1139,7 +1139,7 @@ static int close_fs_devices(struct btrfs_fs_devices *fs_devices) WARN_ON(fs_devices->open_devices); WARN_ON(fs_devices->rw_devices); fs_devices->opened = 0; - fs_devices->seeding = 0; + fs_devices->seeding = false; return 0; } @@ -2297,7 +2297,7 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info) list_splice_init(&fs_devices->alloc_list, &seed_devices->alloc_list); mutex_unlock(&fs_info->chunk_mutex); - fs_devices->seeding = 0; + fs_devices->seeding = false; fs_devices->num_devices = 0; fs_devices->open_devices = 0; fs_devices->missing_devices = 0; @@ -6681,7 +6681,7 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_fs_info *fs_info, if (IS_ERR(fs_devices)) return fs_devices; - fs_devices->seeding = 1; + fs_devices->seeding = true; fs_devices->opened = 1; return fs_devices; } diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 46987a2da786..8e9513b3fe9d 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -243,7 +243,7 @@ struct btrfs_fs_devices { struct list_head alloc_list; struct btrfs_fs_devices *seed; - int seeding; + bool seeding; int opened; From patchwork Wed Nov 13 10:27:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11241653 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAB6114ED for ; Wed, 13 Nov 2019 10:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CACBC222C1 for ; Wed, 13 Nov 2019 10:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727341AbfKMK1k (ORCPT ); Wed, 13 Nov 2019 05:27:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:48246 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727247AbfKMK1j (ORCPT ); Wed, 13 Nov 2019 05:27:39 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1B855B5FD; Wed, 13 Nov 2019 10:27:37 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Qu Wenru , Linux BTRFS Mailinglist , Johannes Thumshirn Subject: [PATCH v2 7/7] btrfs: change btrfs_fs_devices::rotating to bool Date: Wed, 13 Nov 2019 11:27:28 +0100 Message-Id: <20191113102728.8835-8-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191113102728.8835-1-jthumshirn@suse.de> References: <20191113102728.8835-1-jthumshirn@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org struct btrfs_fs_devices::rotating currently is declared as an integer variable but only used as a boolean. Change the variable definition to bool and update to code touching it to set 'true' and 'false'. Signed-off-by: Johannes Thumshirn Reviewed-by: Anand Jain --- fs/btrfs/volumes.c | 6 +++--- fs/btrfs/volumes.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ce9c6fa3a32c..6d3bfea2e2d5 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -644,7 +644,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, q = bdev_get_queue(bdev); if (!blk_queue_nonrot(q)) - fs_devices->rotating = 1; + fs_devices->rotating = true; device->bdev = bdev; clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state); @@ -2301,7 +2301,7 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info) fs_devices->num_devices = 0; fs_devices->open_devices = 0; fs_devices->missing_devices = 0; - fs_devices->rotating = 0; + fs_devices->rotating = false; fs_devices->seed = seed_devices; generate_random_uuid(fs_devices->fsid); @@ -2496,7 +2496,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path atomic64_add(device->total_bytes, &fs_info->free_chunk_space); if (!blk_queue_nonrot(q)) - fs_devices->rotating = 1; + fs_devices->rotating = true; orig_super_total_bytes = btrfs_super_total_bytes(fs_info->super_copy); btrfs_set_super_total_bytes(fs_info->super_copy, diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 8e9513b3fe9d..fc1b564b9cfe 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -250,7 +250,7 @@ struct btrfs_fs_devices { /* set when we find or add a device that doesn't have the * nonrot flag set */ - int rotating; + bool rotating; struct btrfs_fs_info *fs_info; /* sysfs kobjects */