Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp718656imm; Thu, 13 Sep 2018 06:47:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaSPKIdlxZD2c87skKaUjkeYcWAf5l0k9TUoCkzY2K2vLfqsDuZFL5HoWQDMAZDgEbqksWy X-Received: by 2002:a63:f849:: with SMTP id v9-v6mr7263912pgj.71.1536846421307; Thu, 13 Sep 2018 06:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846421; cv=none; d=google.com; s=arc-20160816; b=PRfcsNf85NsPB62c22cIeyDUQPnmDkhQ3z9yKSL4ZobVp80g/UiBSDhe+7KXY//IJ3 PKgOYIoKoqM+wByLwV9rUC2+6CpLrO9MK2ZJy5royD1/QMKvB5HnlyRjCXSQCGqdQeQF I+kOwTmwUca+upBGh4T3n+UYsmmBA/3A/E4/8oBFgUV2412EJ7tTI4HihjRUwmaoliJn LGR32lAqpYHdqp3DLNmAJz6W1NarWQ80BDIc6rm/NGKolsAEunZU8TpkK1buG8zIiHHP AG85gx+uZsUC/qjOHGWTvuEeNQ8SUyjezO77C/bO6Oe5LKmD50UeV6tnQSgOgUpwjcdm PoSw== 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=Pbk70ucShRA3twU1zWf8hA5OVcFWubPDIWCTwANCgxw=; b=uCbyhEiK0Lrq8sC6+d/kkcen779BrTmZyhQciK9BEn/5gKq44tWhaEFh/oK8OFi2BJ 1lIR7y4n8Xx8t+8elcyfJrn4tZSGBnqeegSDbFJGWOb/KHG8UjXayRAK/78xdx2NC9+0 iz7UJVq+KYKErSoHMADh0lhm8l62kw/qJzx7bNDP+ca+Ac21dEtFb8OklgHrCG1FNXun ry3T40EqtZDiP02s4tOp83CgsoEAT0AXVHE7wx3jdVByL4AZc00PXlF+vLPli5TBwWTq qv9wOlw7u03PQHmoM6ulacneydpfIQQYFrIp2OAbKSwTgHSQi0jFmTeV9VrUM+PoxpOz 6apA== 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 h7-v6si4264029plr.98.2018.09.13.06.46.46; Thu, 13 Sep 2018 06:47:01 -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 S1730317AbeIMS4J (ORCPT + 99 others); Thu, 13 Sep 2018 14:56:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60892 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729859AbeIMS4I (ORCPT ); Thu, 13 Sep 2018 14:56:08 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 134BED19; Thu, 13 Sep 2018 13:46:34 +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.14 081/115] btrfs: replace: Reset on-disk dev stats value after replace Date: Thu, 13 Sep 2018 15:31:41 +0200 Message-Id: <20180913131828.561050497@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@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.14-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 @@ -589,6 +589,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