From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0096.outbound.protection.outlook.com ([104.47.40.96]:44736 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727725AbeH3WMQ (ORCPT ); Thu, 30 Aug 2018 18:12:16 -0400 From: Sasha Levin To: "stable@vger.kernel.org" CC: Anand Jain , David Sterba , Sasha Levin Subject: [PATCH AUTOSEL 4.18 106/113] btrfs: fix in-memory value of total_devices after seed device deletion Date: Thu, 30 Aug 2018 18:08:30 +0000 Message-ID: <20180830180714.36167-40-alexander.levin@microsoft.com> References: <20180830180714.36167-1-alexander.levin@microsoft.com> In-Reply-To: <20180830180714.36167-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Anand Jain [ Upstream commit b4993e64f78a9605b45252fa9ba385c88a1f4ce9 ] In case of deleting the seed device the %cur_devices (seed) and the %fs_devices (parent) are different. Now, as the parent fs_devices::total_devices also maintains the total number of devices including the seed device, so decrement its in-memory value for the successful seed delete. We are already updating its corresponding on-disk btrfs_super_block::number_devices value. Signed-off-by: Anand Jain Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/volumes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 93765f17a454..fca57c1f077c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2029,6 +2029,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, co= nst char *device_path, =20 cur_devices->num_devices--; cur_devices->total_devices--; + /* Update total_devices of the parent fs_devices if it's seed */ + if (cur_devices !=3D fs_devices) + fs_devices->total_devices--; =20 if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)) cur_devices->missing_devices--; --=20 2.17.1