Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp734038imm; Thu, 13 Sep 2018 07:01:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaZ6/Z2Gm0AtEUh/xAxv2Syk26IqE5ZM4+Scv9KpP/5NqTJcnu/dOrfExhK3SVyzlhene7q X-Received: by 2002:a62:6948:: with SMTP id e69-v6mr7660644pfc.166.1536847269840; Thu, 13 Sep 2018 07:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847269; cv=none; d=google.com; s=arc-20160816; b=ie7n9lpkIkMNhfL2x1yOV19GYEuKyTjulqvHYMfXPXRYy61RfypaEhMi8M9JWVS/c1 vZfgNq5UgnI5GYVZbqe62SxS8EZOY7rAF2J2DiGzu7KW3aoArVACMsfEr7YYDGv/2LHR A1R3A/Pfkp7ucCnDmgXBYex/7Wzhy0SAdvqCQ0kl3CNHpB3GnmAJQGMX5YHvI8AcjZBj G2oMNaZY2t2Z9Vj4S8MQXt+kXT3GHMNYQkr1J9W5aDZPx0cIeWVIkNxMnDiJYMkQ3Iff uyNmOv2dzVhTcl663QzHrOymK5HFTAOdklpnVKWpKiG2ZpjMsNPVHVf3X3FUbdey+lkl zsPw== 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=YtxM2doJOEHZLIFeFOaiHLR7j4L3dG9OCmt+tPB80CU=; b=lyfU/atb/vIyV4HelkHiOFGqb9KlrMlwbDwtQdr8UU0C3v/1WD8Qf1NCwRovG/2mxJ KfBlo13ifeVmHny8QipaoQGAZx88+OrQMt+YY8yszckSSxRZjSbwsxqhq22Wx1DOW6xM JwqahVQN971OedMTLhDqmDcgc3XYlroMuO0AXJJnfxvI3Ai8TbT1QzAteNuNR5obhTS4 u5MOdEOM1OGmKKVPBVCHZuWYetclq4LWZIOfR8pGdpamVo6TiByIyWVzPrPYLt0Hb3/y kVOyzkxQkL6dmh4eAMCG2C3K29xudwEp2Qw0Wzpv3V9KW2grnZ9GD/S26ANlnkp5FpLM d85w== 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 g185-v6si3772280pgc.151.2018.09.13.07.00.53; Thu, 13 Sep 2018 07:01:09 -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 S1731647AbeIMTK0 (ORCPT + 99 others); Thu, 13 Sep 2018 15:10:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34954 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727760AbeIMTKZ (ORCPT ); Thu, 13 Sep 2018 15:10:25 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C80E5D19; Thu, 13 Sep 2018 14:00:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Misono Tomohiro , David Sterba , Sasha Levin Subject: [PATCH 4.18 134/197] btrfs: replace: Reset on-disk dev stats value after replace Date: Thu, 13 Sep 2018 15:31:23 +0200 Message-Id: <20180913131846.920472528@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: Misono Tomohiro [ Upstream commit 1e7e1f9e3aba00c9b9c323bfeeddafe69ff21ff6 ] on-disk devs stats value is updated in btrfs_run_dev_stats(), which is called during commit transaction, if device->dev_stats_ccnt is not zero. Since current replace operation does not touch dev_stats_ccnt, on-disk dev stats value is not updated. Therefore "btrfs device stats" may return old device's value after umount/mount (Example: See "btrfs ins dump-t -t DEV $DEV" after btrfs/100 finish). Fix this by just incrementing dev_stats_ccnt in btrfs_dev_replace_finishing() when replace is succeeded and this will update the values. Signed-off-by: Misono Tomohiro Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/dev-replace.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -677,6 +677,12 @@ static int btrfs_dev_replace_finishing(s btrfs_rm_dev_replace_unblocked(fs_info); /* + * Increment dev_stats_ccnt so that btrfs_run_dev_stats() will + * update on-disk dev stats value during commit transaction + */ + atomic_inc(&tgt_device->dev_stats_ccnt); + + /* * this is again a consistent state where no dev_replace procedure * is running, the target device is part of the filesystem, the * source device is not part of the filesystem anymore and its 1st