Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp58268ybp; Thu, 3 Oct 2019 10:08:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwxHfWytZjgRIDI+SxhzwTWgNyjfRGX2qCBnGxEMwgV15eJXruDyE9vlwO70jhuDzFHYVn X-Received: by 2002:a17:906:7a55:: with SMTP id i21mr8655651ejo.206.1570122522563; Thu, 03 Oct 2019 10:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122522; cv=none; d=google.com; s=arc-20160816; b=07GkjI811wwBPGvp+Nqwcp4DNLVXehAtJdFqqPq8boTZYwQ48yldht6ngCbIx9ew2E N5OGPbL0maUXT8q94iooKYnSPWiC1dh6Ier/Opw5182bHutv1mbDeNUb3kLBqXG+mzvl 2wrM2ALwjRwMOg+qbtb+YhNvjhKcS4FryDb9zp6nOIJz2ipPYuOpJMaRpWLiCZsRQZ+V aGsiVOQ8ybUcPjUBzAuSMg5/fu7EwI735ChHtEPBrtZXDoxrjsMS7xSrbdjY9hmgMQHN ja5a44VK2cu8rEGIykUjFzcafqau5HqRCDn7lG9pu4EB9aLASU/oZgt8PYC2iXZYyFEw g/aA== 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:dkim-signature; bh=9S3BUmAVudNCr71RTr+XtC+RulD6ZNkWhjTEZMEIDEI=; b=j2h9dpmgbWf4/qsk9EcyHrDI5U0DwDBF93Sv4o8Y3CwjLeGRLfWe6kfl6jpM36Isb5 B6xTSuqTotx1LiXSe9s7HBSu5GWHqZln4+i6iena/C6dwYXGtLUXJze6t6V6Dy8vhwzI 0BQFw1W0hJWLGHJLzOEUAxDbcsNJ+h7ETJCpORAsl3Ps5rBZIVT4HwEk0CLbBWvWcqN+ XsJU04an6217I5y/zYcF4RPC7UYaLOqOfZ9Fi8rCe6m3NoiXXYnqqR21OWLE3bCB3fTK RViNd2xLH6vMEOH/Ik2HmCH9j8C8Qe/tba+Ba+smRMFmyiLXSBA29xTY6qysvIET44Ph k14A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uYefEM7B; 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 l2si1588111ejh.389.2019.10.03.10.08.17; Thu, 03 Oct 2019 10:08:42 -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; dkim=pass header.i=@kernel.org header.s=default header.b=uYefEM7B; 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 S2404619AbfJCQhg (ORCPT + 99 others); Thu, 3 Oct 2019 12:37:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:46926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404598AbfJCQhe (ORCPT ); Thu, 3 Oct 2019 12:37:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4B785222D1; Thu, 3 Oct 2019 16:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120653; bh=gYWn98+W0iMOhxY6UExOkZpfeZsrH6d61rogCQgFSzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uYefEM7B1H9/R64N8p07u8Pci4h6GyrWbyqg9tF+MYWxLtWHf1yqr32gmOYrZbQQa bQsQYEjokRohdJtbiXd152RVG874mvomtOx+wu6qsV+5Mj2R5f6dVPEKc5LgRwN1dQ wDeRLtIP1+MNvRbaHgSUy9LNdqYxZ2YxK5ezGnP4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Dennis Zhou , David Sterba Subject: [PATCH 5.2 285/313] btrfs: adjust dirty_metadata_bytes after writeback failure of extent buffer Date: Thu, 3 Oct 2019 17:54:23 +0200 Message-Id: <20191003154601.153892981@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Dennis Zhou commit eb5b64f142504a597d67e2109d603055ff765e52 upstream. Before, if a eb failed to write out, we would end up triggering a BUG_ON(). As of f4340622e0226 ("btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up"), we no longer BUG_ON(), so we should make life consistent and add back the unwritten bytes to dirty_metadata_bytes. Fixes: f4340622e022 ("btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up") CC: stable@vger.kernel.org # 5.2+ Reviewed-by: Filipe Manana Signed-off-by: Dennis Zhou Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent_io.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3708,12 +3708,21 @@ err_unlock: static void set_btree_ioerr(struct page *page) { struct extent_buffer *eb = (struct extent_buffer *)page->private; + struct btrfs_fs_info *fs_info; SetPageError(page); if (test_and_set_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) return; /* + * If we error out, we should add back the dirty_metadata_bytes + * to make it consistent. + */ + fs_info = eb->fs_info; + percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, + eb->len, fs_info->dirty_metadata_batch); + + /* * If writeback for a btree extent that doesn't belong to a log tree * failed, increment the counter transaction->eb_write_errors. * We do this because while the transaction is running and before it's