From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aserp2120.oracle.com ([141.146.126.78]:48332 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751329AbeAJFOb (ORCPT ); Wed, 10 Jan 2018 00:14:31 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0A5C7Gq182447 for ; Wed, 10 Jan 2018 05:14:30 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2fd84kgj93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 10 Jan 2018 05:14:30 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w0A5EUIk023008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Jan 2018 05:14:30 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w0A5ETQ6001370 for ; Wed, 10 Jan 2018 05:14:29 GMT From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/6] btrfs: cleanup btrfs_free_stale_device() usage Date: Wed, 10 Jan 2018 13:15:18 +0800 Message-Id: <20180110051523.3681-2-anand.jain@oracle.com> In-Reply-To: <20180110051523.3681-1-anand.jain@oracle.com> References: <20180110051523.3681-1-anand.jain@oracle.com> Sender: linux-btrfs-owner@vger.kernel.org List-ID: We call btrfs_free_stale_device() only when we alloc a new struct btrfs_device (ret=1), so move it closer to where we alloc the new device. Also drop the comments. Signed-off-by: Anand Jain Reviewed-by: Josef Bacik --- fs/btrfs/volumes.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index d393808071d5..25b91776d036 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -782,6 +782,7 @@ static noinline int device_list_add(const char *path, ret = 1; device->fs_devices = fs_devices; + btrfs_free_stale_device(device); } else if (!device->name || strcmp(device->name->str, path)) { /* * When FS is already mounted. @@ -840,13 +841,6 @@ static noinline int device_list_add(const char *path, if (!fs_devices->opened) device->generation = found_transid; - /* - * if there is new btrfs on an already registered device, - * then remove the stale device entry. - */ - if (ret > 0) - btrfs_free_stale_device(device); - *fs_devices_ret = fs_devices; return ret; -- 2.7.0