Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp734483imm; Thu, 13 Sep 2018 07:01:27 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdad0GxtLET6MvRecSW8bEYYxgekgsARcnbyU4cP0lozTT3kEH462/eiN1XbPV3pMUegu13u X-Received: by 2002:a63:6881:: with SMTP id d123-v6mr7261187pgc.298.1536847287141; Thu, 13 Sep 2018 07:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847287; cv=none; d=google.com; s=arc-20160816; b=fi0noKlVXFOlg9omENH3w0LoLarQU5B2Mq9eibAGyt3uPa2YyTviZ90oUETfE7ocFM lEI3uuzMVfvKoQxOrqglFTUOFGbFiLHmO0f/EVLPm463CBYrtDeipsCKrQZXO//AeqHS p3algKPTWuDL3A6c8fnbT7j8nPAy25doC/esmX4/cnxWxd6RCj/FT+W2RPxY51ckoc7C 0hTDSoPoXnJ1/7ApDJd+pzG/l3bLFNTuEh0IhyPAtJRg700GRJH5u35NBOWihXR0FeHG Lz8S6oGiDHhBqSW1aXfouTbVS62f8W6iQ4D9p1IRdZm/MylDLOvsgoVu0G8/RMFGfDvx tIxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=JTuY/MCZc5882GVLRGs36mRw31BHJoYKbWzeN2yvmK4=; b=Q09aUYWVdqOpcAP1EdbPYqXYi51hPF7lq0h+jkMGGErPZX3Ji8Kq+MHfvrCWmz0Csq KQvY3hEDMYqpQIgM7x+KXKwbgMv+Gpwws7zdmTqQrCY6kmlLw5OnO986a2EyDsPvCeXM yuwS1tlyNLvRrGiOaZb8HdQZSOQ6iHHlj6JwGPL/NtEOodvIiFhtsITGleOi89agc6pR Gv/lOujxvTF9e+zWbj4ZkndDN75QCzhp3DZ4jUli4yZvYhq1WQqFulh7/ob/uAIxbfrj lOf9ljo/X8XkoMC6SLHgq85O51/lKgzoOQy36Zvscuwk1DppyTeS/+yCdGHANWF9nMZO VWYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k20-v6si4425886pgb.115.2018.09.13.07.01.11; Thu, 13 Sep 2018 07:01:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731362AbeIMTKo (ORCPT + 99 others); Thu, 13 Sep 2018 15:10:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34968 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727760AbeIMTKn (ORCPT ); Thu, 13 Sep 2018 15:10:43 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 271B2D1C; Thu, 13 Sep 2018 14:01:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , David Sterba , Sasha Levin Subject: [PATCH 4.18 135/197] btrfs: fix in-memory value of total_devices after seed device deletion Date: Thu, 13 Sep 2018 15:31:24 +0200 Message-Id: <20180913131846.960060104@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2029,6 +2029,9 @@ int btrfs_rm_device(struct btrfs_fs_info cur_devices->num_devices--; cur_devices->total_devices--; + /* Update total_devices of the parent fs_devices if it's seed */ + if (cur_devices != fs_devices) + fs_devices->total_devices--; if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)) cur_devices->missing_devices--;