From patchwork Thu Jun 20 15:18:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 11007129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE9DE14E5 for ; Thu, 20 Jun 2019 15:18:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFE8A27861 for ; Thu, 20 Jun 2019 15:18:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B394628306; Thu, 20 Jun 2019 15:18:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ABDA27861 for ; Thu, 20 Jun 2019 15:18:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 358848E0003; Thu, 20 Jun 2019 11:18:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3312F8E0001; Thu, 20 Jun 2019 11:18:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 222DE8E0003; Thu, 20 Jun 2019 11:18:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by kanga.kvack.org (Postfix) with ESMTP id F11D68E0001 for ; Thu, 20 Jun 2019 11:18:52 -0400 (EDT) Received: by mail-io1-f71.google.com with SMTP id u25so5621379iol.23 for ; Thu, 20 Jun 2019 08:18:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LbaJcyWYnbCa5ezoro66saapuXs/2zff7F4rgt4jO/0=; b=XQXYkkbcz/Sr4PquS6+0ouT9qUplzlO1BnKa3KwkjtP1wQJyLGaoRtfIhLhhmbuB6i 4WCMCyXv6xJSeFjCYXd+OA1fz3KtkdIA+YNNWzozMSrRZMIvG050y4OH8GWat01KBtkw AswTiammMjN5hoZGiCVwVqxX2h3ryuN5wgxwZOHsn7b5FdnI/GigesPY4JQSOxyqHVQK noPsgyd2iooL5zyhX43KKVqM+Jq05FAP56YhHnEKxTQE1V7/N82wvVWtbSYUTpTMPBAp NhXYH3XENUBeJUeOklxVN1Fvhjkofe96YDBcVZ72qcA8dEdWdGvSvkaoUr17M/+Qxiiz BCNQ== X-Gm-Message-State: APjAAAU0imij2c4eL5zByIM+JIvfrOM4inm5CsQo5sbbQ1API9WaH6XR 3wmVjY+bI7ecxj3jgN/gH3a9r52vz0ehojzIsfJ5SJ2AKFErfUzozOAxk9ntNYg3esq2Avuz3zF lVU0ZgtmB/XH5nZYsD/imI6zrumMPjZewQAe4O/Rr9c/QlXITlgPG5hHf+ykOCB43Qw== X-Received: by 2002:a5e:a712:: with SMTP id b18mr19413092iod.220.1561043932711; Thu, 20 Jun 2019 08:18:52 -0700 (PDT) X-Received: by 2002:a5e:a712:: with SMTP id b18mr19413046iod.220.1561043932079; Thu, 20 Jun 2019 08:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561043932; cv=none; d=google.com; s=arc-20160816; b=M1JLtrGD7CA6BQnP3TQl9I5b1LHlAfw8OcRzqJOrXYl201P4w3QWG0z1iT8+zbGsYI MhDqscm+InTPVkkaWUs+bo6jm+LD6Yw/vaojQYBwwx+9qdo9vAawwgY29RBcKEecs+Og d5lDvjSPhQTOIhj4pnfwNgziVh+FvSlQjS/tQb4ZAzSRhwxj02B81ezwcMVU7VPpRJek YEx47RvOeYE3i2WzfU0ERKUohM9QFeeyctGTVkSWFk1T1lRN4Vvj/+M2+pfFYlCCT0dt rRU2zB5WM9fTBlU83aDZhD4h6XdlETfJobz9PVW/cF0Xu0doTkdPAOnpF8gY68v8OSyV 9IQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=LbaJcyWYnbCa5ezoro66saapuXs/2zff7F4rgt4jO/0=; b=Eh5SZDhnjKUV9of6pyFFRJH79qdLy+HARjWmvJVomefMJ0GQAE08HdA1ImX7Y1WGjG Uioq2iw96bfeDc25V6Yk6nTPgSYtSk1lzgdTlpbgWEmCuhUtRM8DWS0c2fRGDG1HMYFl UG7/x089IlyTRBPpq84tJFeSZeac6gMe38hDZHoY/OtFZ8kq9Q3eLQ/yBiMtmtM9jy8o MpVP49sQao6B1/D/1cxm6veM8apgJ5RyyzA2gMtdB+l3e/Otm8h3TNzOazCMHKW4uwfX e3SU7Km5mq7owOvbNCivqAbFZOmPj2nzNxA2YfXryiswv9AVsj4B9vewopC08o612/ua soNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Vgb6ZSxZ; spf=pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=zwisler@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s10sor17203136iol.79.2019.06.20.08.18.52 for (Google Transport Security); Thu, 20 Jun 2019 08:18:52 -0700 (PDT) Received-SPF: pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Vgb6ZSxZ; spf=pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=zwisler@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LbaJcyWYnbCa5ezoro66saapuXs/2zff7F4rgt4jO/0=; b=Vgb6ZSxZHxs/uF5rGy6wsIsWX1oNvwsVPTCFF0NCmLRH7xlP6b3yhvsiikpiDNYTsl fFr9zFv5G8yh1I0ISPt9HhTsz4g31G0pXdVQ66gHrsaLY66H8TVJlwYnY/EZ4IHox7rw WGi3kTBfRbg/0MwUa03341kI9jQ6Pm0dIf7m4= X-Google-Smtp-Source: APXvYqzN4QF7VO7txjKK/zwdz7+tEgOtdahmqqRfrztYneRm16nQeJy7GrQuF3sgTYRsfdJ7IOKEpw== X-Received: by 2002:a6b:bf01:: with SMTP id p1mr50911675iof.181.1561043931856; Thu, 20 Jun 2019 08:18:51 -0700 (PDT) Received: from localhost ([2620:15c:183:200:855f:8919:84a7:4794]) by smtp.gmail.com with ESMTPSA id l2sm108135ioh.20.2019.06.20.08.18.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 08:18:51 -0700 (PDT) From: Ross Zwisler X-Google-Original-From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , "Theodore Ts'o" , Alexander Viro , Andreas Dilger , Jan Kara , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Fletcher Woodruff , Justin TerAvest , Jan Kara , stable@vger.kernel.org Subject: [PATCH v2 1/3] mm: add filemap_fdatawait_range_keep_errors() Date: Thu, 20 Jun 2019 09:18:37 -0600 Message-Id: <20190620151839.195506-2-zwisler@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190620151839.195506-1-zwisler@google.com> References: <20190620151839.195506-1-zwisler@google.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In the spirit of filemap_fdatawait_range() and filemap_fdatawait_keep_errors(), introduce filemap_fdatawait_range_keep_errors() which both takes a range upon which to wait and does not clear errors from the address space. Signed-off-by: Ross Zwisler Reviewed-by: Jan Kara Cc: stable@vger.kernel.org --- include/linux/fs.h | 2 ++ mm/filemap.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index f7fdfe93e25d3..79fec8a8413f4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2712,6 +2712,8 @@ extern int filemap_flush(struct address_space *); extern int filemap_fdatawait_keep_errors(struct address_space *mapping); extern int filemap_fdatawait_range(struct address_space *, loff_t lstart, loff_t lend); +extern int filemap_fdatawait_range_keep_errors(struct address_space *mapping, + loff_t start_byte, loff_t end_byte); static inline int filemap_fdatawait(struct address_space *mapping) { diff --git a/mm/filemap.c b/mm/filemap.c index df2006ba0cfa5..e87252ca0835a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -553,6 +553,28 @@ int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte, } EXPORT_SYMBOL(filemap_fdatawait_range); +/** + * filemap_fdatawait_range_keep_errors - wait for writeback to complete + * @mapping: address space structure to wait for + * @start_byte: offset in bytes where the range starts + * @end_byte: offset in bytes where the range ends (inclusive) + * + * Walk the list of under-writeback pages of the given address space in the + * given range and wait for all of them. Unlike filemap_fdatawait_range(), + * this function does not clear error status of the address space. + * + * Use this function if callers don't handle errors themselves. Expected + * call sites are system-wide / filesystem-wide data flushers: e.g. sync(2), + * fsfreeze(8) + */ +int filemap_fdatawait_range_keep_errors(struct address_space *mapping, + loff_t start_byte, loff_t end_byte) +{ + __filemap_fdatawait_range(mapping, start_byte, end_byte); + return filemap_check_and_keep_errors(mapping); +} +EXPORT_SYMBOL(filemap_fdatawait_range_keep_errors); + /** * file_fdatawait_range - wait for writeback to complete * @file: file pointing to address space structure to wait for From patchwork Thu Jun 20 15:18:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 11007133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6291112C for ; Thu, 20 Jun 2019 15:18:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 966A627861 for ; Thu, 20 Jun 2019 15:18:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A7A328306; Thu, 20 Jun 2019 15:18:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF5C627861 for ; Thu, 20 Jun 2019 15:18:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37FC28E0001; Thu, 20 Jun 2019 11:18:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 332658E0005; Thu, 20 Jun 2019 11:18:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BB4E8E0001; Thu, 20 Jun 2019 11:18:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by kanga.kvack.org (Postfix) with ESMTP id ED0888E0001 for ; Thu, 20 Jun 2019 11:18:54 -0400 (EDT) Received: by mail-io1-f72.google.com with SMTP id v11so5693015iop.7 for ; Thu, 20 Jun 2019 08:18:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yst8MNat78gyvUv+78J2l6JrkJnYsEpCBtbxbwsO9x8=; b=Mn/mIyOhWIXgeC0yyMi6ZioGievuBMXUjoRxgwXfbT5JxUCbFiG8AMaG8erPvdGeR1 Y55+9InGm0uO/nk7acqd5FdaT3eKWqwNQsQN0Zm6DPLIdIhDCB/qZ2Y4HSc2IlTyg1Jy Uky2Q5T0T4WD50pqAhlCRnuo4ZDlGYtQk4gZ/xis4jiHF7Oh5l2lzJXTgb+fXH8C5504 zrdre5/FVa+lq70WbfU1yprzTGJNBjY1KlmwFeSKmV7SyBDQTC/yo1DWY2t2c20gS+fE XrrfacESR1G6gMhAro8UiFfNZt8epRs10DEo0KOJaPXNeJCkuB3xNrdzczoLPBwmUV/Y US+Q== X-Gm-Message-State: APjAAAU4tiDf6C87QDFizAX3JMaBeV4hkPX1KTITBZdFtlLf8g2iuULg i4sDbBrn2Unz9GGqfchi4fcb/bpt2AgkFuyjLYgMDvZWmmB9uPoUobAFSwfalJA6D12fBhHzmgP AUvNLKlTW90AsaMIuDDu5VfE5AsH8b8lvg9ulavC8lh9uIJMeJSVS4XiKukdX6b6+uQ== X-Received: by 2002:a6b:6611:: with SMTP id a17mr13506957ioc.179.1561043934700; Thu, 20 Jun 2019 08:18:54 -0700 (PDT) X-Received: by 2002:a6b:6611:: with SMTP id a17mr13506882ioc.179.1561043933696; Thu, 20 Jun 2019 08:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561043933; cv=none; d=google.com; s=arc-20160816; b=SDDfn1MNOoK0w087G6NLLEOJIs4ztbBiAQZcloKL578NMRr7vI76+DMUxywArcsEeR AXr0sczNXw6HH/utu6DZAdaOErMQmra3u895A/WmkSDdPXbuYhhi8BTyhaMsphNt4f25 vAC4x3qHy+mjNj+nJEPn2O471+/cMxqF5mgZa+Ru3e9L6s2oqbwc7gh/75CNwg36Q0QS 3QS9fyEHQKd0n7qzlYD0ZZjz0FanitkgHYV8fsrQIG8KI4rgCD85v6wJIcaQbwukpeqz 4gHExVVCO120Bgk31BEatFO+pon60y2xKV+ZkzT8CkKkWDORTZif1pG/FnktHPhDWRzc QXpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=yst8MNat78gyvUv+78J2l6JrkJnYsEpCBtbxbwsO9x8=; b=AFXbSiPS6AQ6fTOWFzQng7uBWgNZzpoMWAJ+wd3tSmEB7dgyIqw2HpblJDX5Sk3sXs Vp8Vy4wSO+6BB03HfV3YzQtzHo7TQ0LIiE0sTLBYzh84rd5hBowu+0l7Wz7dEi6NoA7O 81A3LutF3NIPnMwD3iXvR7wKgKK2H79o0ZAuv37YV/kkwUurnp7+HweSArJlqcBbWFg0 usglG+yXFW7d3Pnl53is8iGI8oGCV6NwEesgQLwu1KWG/E5ZRuIp8aqT5TUDGTdg0ola 7b0gf8L4aQpinx0F+ouTE78I9tSRJPn1Ac1OoE3dVYfddcz/N8Og00+XBwaORmD72W1C yW9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OxCTA6+F; spf=pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=zwisler@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b2sor17992348iog.90.2019.06.20.08.18.53 for (Google Transport Security); Thu, 20 Jun 2019 08:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OxCTA6+F; spf=pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=zwisler@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yst8MNat78gyvUv+78J2l6JrkJnYsEpCBtbxbwsO9x8=; b=OxCTA6+FCqpeGgc5w46hByG+mh3eFlESmcXTfAhJaFakhTREe6TJQM8tjn3mlgPh1K xsh3D9ct0UrnDTrifSZyN/u0Ewvrl8JwH48Y/Q/cZQ76A8rELcDwwT5/BKBouEf0v92z gYcrSBsg/5vCi7lfjsz6nZjac5lq/RTlEDKJo= X-Google-Smtp-Source: APXvYqxBEO4SmFYY60o3fT/y9Z8WeHnCefsDa+T4fidYk/4ZoCsyv9qbjJKjrbbvjiqri/qJpiWGwQ== X-Received: by 2002:a6b:7f0b:: with SMTP id l11mr91998488ioq.282.1561043933293; Thu, 20 Jun 2019 08:18:53 -0700 (PDT) Received: from localhost ([2620:15c:183:200:855f:8919:84a7:4794]) by smtp.gmail.com with ESMTPSA id o7sm36082ioo.81.2019.06.20.08.18.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 08:18:52 -0700 (PDT) From: Ross Zwisler X-Google-Original-From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , "Theodore Ts'o" , Alexander Viro , Andreas Dilger , Jan Kara , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Fletcher Woodruff , Justin TerAvest , Jan Kara , stable@vger.kernel.org Subject: [PATCH v2 2/3] jbd2: introduce jbd2_inode dirty range scoping Date: Thu, 20 Jun 2019 09:18:38 -0600 Message-Id: <20190620151839.195506-3-zwisler@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190620151839.195506-1-zwisler@google.com> References: <20190620151839.195506-1-zwisler@google.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Currently both journal_submit_inode_data_buffers() and journal_finish_inode_data_buffers() operate on the entire address space of each of the inodes associated with a given journal entry. The consequence of this is that if we have an inode where we are constantly appending dirty pages we can end up waiting for an indefinite amount of time in journal_finish_inode_data_buffers() while we wait for all the pages under writeback to be written out. The easiest way to cause this type of workload is do just dd from /dev/zero to a file until it fills the entire filesystem. This can cause journal_finish_inode_data_buffers() to wait for the duration of the entire dd operation. We can improve this situation by scoping each of the inode dirty ranges associated with a given transaction. We do this via the jbd2_inode structure so that the scoping is contained within jbd2 and so that it follows the lifetime and locking rules for that structure. This allows us to limit the writeback & wait in journal_submit_inode_data_buffers() and journal_finish_inode_data_buffers() respectively to the dirty range for a given struct jdb2_inode, keeping us from waiting forever if the inode in question is still being appended to. Signed-off-by: Ross Zwisler Reviewed-by: Jan Kara Cc: stable@vger.kernel.org --- fs/jbd2/commit.c | 23 ++++++++++++++------ fs/jbd2/journal.c | 2 ++ fs/jbd2/transaction.c | 49 ++++++++++++++++++++++++------------------- include/linux/jbd2.h | 22 +++++++++++++++++++ 4 files changed, 69 insertions(+), 27 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index efd0ce9489ae9..668f9021cf115 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -187,14 +187,15 @@ static int journal_wait_on_commit_record(journal_t *journal, * use writepages() because with dealyed allocation we may be doing * block allocation in writepages(). */ -static int journal_submit_inode_data_buffers(struct address_space *mapping) +static int journal_submit_inode_data_buffers(struct address_space *mapping, + loff_t dirty_start, loff_t dirty_end) { int ret; struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, .nr_to_write = mapping->nrpages * 2, - .range_start = 0, - .range_end = i_size_read(mapping->host), + .range_start = dirty_start, + .range_end = dirty_end, }; ret = generic_writepages(mapping, &wbc); @@ -218,6 +219,9 @@ static int journal_submit_data_buffers(journal_t *journal, spin_lock(&journal->j_list_lock); list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { + loff_t dirty_start = jinode->i_dirty_start; + loff_t dirty_end = jinode->i_dirty_end; + if (!(jinode->i_flags & JI_WRITE_DATA)) continue; mapping = jinode->i_vfs_inode->i_mapping; @@ -230,7 +234,8 @@ static int journal_submit_data_buffers(journal_t *journal, * only allocated blocks here. */ trace_jbd2_submit_inode_data(jinode->i_vfs_inode); - err = journal_submit_inode_data_buffers(mapping); + err = journal_submit_inode_data_buffers(mapping, dirty_start, + dirty_end); if (!ret) ret = err; spin_lock(&journal->j_list_lock); @@ -257,12 +262,16 @@ static int journal_finish_inode_data_buffers(journal_t *journal, /* For locking, see the comment in journal_submit_data_buffers() */ spin_lock(&journal->j_list_lock); list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { + loff_t dirty_start = jinode->i_dirty_start; + loff_t dirty_end = jinode->i_dirty_end; + if (!(jinode->i_flags & JI_WAIT_DATA)) continue; jinode->i_flags |= JI_COMMIT_RUNNING; spin_unlock(&journal->j_list_lock); - err = filemap_fdatawait_keep_errors( - jinode->i_vfs_inode->i_mapping); + err = filemap_fdatawait_range_keep_errors( + jinode->i_vfs_inode->i_mapping, dirty_start, + dirty_end); if (!ret) ret = err; spin_lock(&journal->j_list_lock); @@ -282,6 +291,8 @@ static int journal_finish_inode_data_buffers(journal_t *journal, &jinode->i_transaction->t_inode_list); } else { jinode->i_transaction = NULL; + jinode->i_dirty_start = 0; + jinode->i_dirty_end = 0; } } spin_unlock(&journal->j_list_lock); diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 43df0c943229c..288b8e7cf21c7 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2574,6 +2574,8 @@ void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode) jinode->i_next_transaction = NULL; jinode->i_vfs_inode = inode; jinode->i_flags = 0; + jinode->i_dirty_start = 0; + jinode->i_dirty_end = 0; INIT_LIST_HEAD(&jinode->i_list); } diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 8ca4fddc705fe..990e7b5062e74 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -2565,7 +2565,7 @@ void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh) * File inode in the inode list of the handle's transaction */ static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode, - unsigned long flags) + unsigned long flags, loff_t start_byte, loff_t end_byte) { transaction_t *transaction = handle->h_transaction; journal_t *journal; @@ -2577,26 +2577,17 @@ static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode, jbd_debug(4, "Adding inode %lu, tid:%d\n", jinode->i_vfs_inode->i_ino, transaction->t_tid); - /* - * First check whether inode isn't already on the transaction's - * lists without taking the lock. Note that this check is safe - * without the lock as we cannot race with somebody removing inode - * from the transaction. The reason is that we remove inode from the - * transaction only in journal_release_jbd_inode() and when we commit - * the transaction. We are guarded from the first case by holding - * a reference to the inode. We are safe against the second case - * because if jinode->i_transaction == transaction, commit code - * cannot touch the transaction because we hold reference to it, - * and if jinode->i_next_transaction == transaction, commit code - * will only file the inode where we want it. - */ - if ((jinode->i_transaction == transaction || - jinode->i_next_transaction == transaction) && - (jinode->i_flags & flags) == flags) - return 0; - spin_lock(&journal->j_list_lock); jinode->i_flags |= flags; + + if (jinode->i_dirty_end) { + jinode->i_dirty_start = min(jinode->i_dirty_start, start_byte); + jinode->i_dirty_end = max(jinode->i_dirty_end, end_byte); + } else { + jinode->i_dirty_start = start_byte; + jinode->i_dirty_end = end_byte; + } + /* Is inode already attached where we need it? */ if (jinode->i_transaction == transaction || jinode->i_next_transaction == transaction) @@ -2631,12 +2622,28 @@ static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode, int jbd2_journal_inode_add_write(handle_t *handle, struct jbd2_inode *jinode) { return jbd2_journal_file_inode(handle, jinode, - JI_WRITE_DATA | JI_WAIT_DATA); + JI_WRITE_DATA | JI_WAIT_DATA, 0, LLONG_MAX); } int jbd2_journal_inode_add_wait(handle_t *handle, struct jbd2_inode *jinode) { - return jbd2_journal_file_inode(handle, jinode, JI_WAIT_DATA); + return jbd2_journal_file_inode(handle, jinode, JI_WAIT_DATA, 0, + LLONG_MAX); +} + +int jbd2_journal_inode_ranged_write(handle_t *handle, + struct jbd2_inode *jinode, loff_t start_byte, loff_t length) +{ + return jbd2_journal_file_inode(handle, jinode, + JI_WRITE_DATA | JI_WAIT_DATA, start_byte, + start_byte + length - 1); +} + +int jbd2_journal_inode_ranged_wait(handle_t *handle, struct jbd2_inode *jinode, + loff_t start_byte, loff_t length) +{ + return jbd2_journal_file_inode(handle, jinode, JI_WAIT_DATA, + start_byte, start_byte + length - 1); } /* diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 5c04181b7c6d8..0e0393e7f41a4 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -451,6 +451,22 @@ struct jbd2_inode { * @i_flags: Flags of inode [j_list_lock] */ unsigned long i_flags; + + /** + * @i_dirty_start: + * + * Offset in bytes where the dirty range for this inode starts. + * [j_list_lock] + */ + loff_t i_dirty_start; + + /** + * @i_dirty_end: + * + * Inclusive offset in bytes where the dirty range for this inode + * ends. [j_list_lock] + */ + loff_t i_dirty_end; }; struct jbd2_revoke_table_s; @@ -1397,6 +1413,12 @@ extern int jbd2_journal_force_commit(journal_t *); extern int jbd2_journal_force_commit_nested(journal_t *); extern int jbd2_journal_inode_add_write(handle_t *handle, struct jbd2_inode *inode); extern int jbd2_journal_inode_add_wait(handle_t *handle, struct jbd2_inode *inode); +extern int jbd2_journal_inode_ranged_write(handle_t *handle, + struct jbd2_inode *inode, loff_t start_byte, + loff_t length); +extern int jbd2_journal_inode_ranged_wait(handle_t *handle, + struct jbd2_inode *inode, loff_t start_byte, + loff_t length); extern int jbd2_journal_begin_ordered_truncate(journal_t *journal, struct jbd2_inode *inode, loff_t new_size); extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode); From patchwork Thu Jun 20 15:18:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 11007135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1357112C for ; Thu, 20 Jun 2019 15:19:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E216D27861 for ; Thu, 20 Jun 2019 15:19:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D668028306; Thu, 20 Jun 2019 15:19:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 570AE27861 for ; Thu, 20 Jun 2019 15:19:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 554338E0006; Thu, 20 Jun 2019 11:18:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 508778E0005; Thu, 20 Jun 2019 11:18:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37E718E0006; Thu, 20 Jun 2019 11:18:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by kanga.kvack.org (Postfix) with ESMTP id 190508E0005 for ; Thu, 20 Jun 2019 11:18:56 -0400 (EDT) Received: by mail-io1-f71.google.com with SMTP id n4so5741245ioc.0 for ; Thu, 20 Jun 2019 08:18:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8qPSgW/MPmMfMRbYOSrZE2Wb0C0QAL6xUVu8BnMULPU=; b=RddU6aWC95odzwH0SUiqSLtG4AsKWQU0UUYQOCyM1cDKbu3fTphEnl0wXVpypPENbG GlwDgekEqv63IOiIwGbHogP9zYcBS0nlYL2etZSjSPHAvxxIBPUAC8ssDVLZtbqg6koN 0MHEUeoo7jxf9qJ0lA8nVKEegXv/6QtqUYIRytGulnLYcrcHJUForv21fY7W+RC3Piht mXpnG3GnKhXWo4Rlu7HXw1MgmPQi1oQzj8LKhJcltIcgb2I59jcXTbq4DIqnT8kNfyXk gU5BzeNEX+/Y8jvVx7IxX/d8c4Fl+xGP0TdJ7sYlZrtfjTk/lEN9SCV6aQo5miWcPXrQ aY6Q== X-Gm-Message-State: APjAAAXOMD6tihxGH3tamilAoITG7+SdRdrWuzUIc7uknfzCBufrKBJZ CwV7AP1XflZvwIVJ+n60CLnIQXvEHFfam5uxxqigRyc9W3n07o/rGb8/3dcInrXh8L3rMcsReA6 lu6zwuMuVitlrGdN/1JooEO51AKKImsYJFQSN6wDKXEjFfqtniAi7gE/niTAhuKE8dg== X-Received: by 2002:a02:5502:: with SMTP id e2mr18433963jab.87.1561043935803; Thu, 20 Jun 2019 08:18:55 -0700 (PDT) X-Received: by 2002:a02:5502:: with SMTP id e2mr18433910jab.87.1561043935129; Thu, 20 Jun 2019 08:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561043935; cv=none; d=google.com; s=arc-20160816; b=Spo6WgrxhVem3MFCpBsSDI8X8+lcHKMkQWa39kB312gCZ3BgzLpE6iAAmglQGVHLZ+ hXZ5AA+ktgPR/JE3tzP6LKKLdhHaNItoY5N2Zy9LuBAJf1yXzLJgwOTRNaWykDg7l89j Bh9RX/z+6mpjd+1ea8/N7vo8H7aTY9W9hdG1kkOlq221EbsdA0FHxwTIOj2+VdPPU/nD kEckwW7PM7zHZMkZuPF5oZ66nzWKzIpL1JZESlYUAGeMGP5SBG/XDk0o0LHGDTKzTKXy 5U6B5crHz/EyAzhlZSu3uQxpqHW5zBh8mkAtnO7B5SJR58EOSz60S4mLxdqYL7WwhPNd CaYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8qPSgW/MPmMfMRbYOSrZE2Wb0C0QAL6xUVu8BnMULPU=; b=BT/kwSpJfPmQOlcjnC0yVY1wUN9fha6FECjH+aJPmF8ZhnxTUbLLNkX4w+lQCMFtE5 MOTQIWw64cvXuzw+L2jWnjbTPZmywVhAtbupJ6foc+frKLNqKFuMrc86QTNQSa2erCI2 S387HVzibNAcqxpJHvf69JflljSaSvC/VZoi50Bt9KAekqnhE/JnxKgcH2bk+pm+fIK2 LAwrk+sstBCV3hlxkurP6xWAGP26xBaz9+5n21dl913ZfgZUPnprHwPPKQQzrn8mrQLS raTzJ1VeBHgL9ZbRf1gLIKVzQDJNr9+B2RznBfvxyxpeLRBj5VofrB20ovxyzZ/YpOv/ N6uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E18fnBvQ; spf=pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=zwisler@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a24sor17186778iod.40.2019.06.20.08.18.55 for (Google Transport Security); Thu, 20 Jun 2019 08:18:55 -0700 (PDT) Received-SPF: pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E18fnBvQ; spf=pass (google.com: domain of zwisler@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=zwisler@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8qPSgW/MPmMfMRbYOSrZE2Wb0C0QAL6xUVu8BnMULPU=; b=E18fnBvQxeTWGcLPU7yJtnVUsZk1M7260uW49AWUEQwpDTLXW4zaL81bfOBaOIKkJe izk337ElLT6ixdEAM82Alqqvi8RTCa5t/m7TIIGM2CTO/X/MhLTAbXsdT4WaLEPQzOwi 5M/ks9JI6LULaQnx5ORxgNivEqZfrhzLXyxFY= X-Google-Smtp-Source: APXvYqyKoB4ShJDQDvXm8iMpldDQ7RBFe5iQW/R6q5N6coubvTjfHUDrQI1UrGttuBMzscYMvKWwFg== X-Received: by 2002:a5d:8794:: with SMTP id f20mr30867938ion.128.1561043934904; Thu, 20 Jun 2019 08:18:54 -0700 (PDT) Received: from localhost ([2620:15c:183:200:855f:8919:84a7:4794]) by smtp.gmail.com with ESMTPSA id e22sm51531iob.66.2019.06.20.08.18.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 08:18:54 -0700 (PDT) From: Ross Zwisler X-Google-Original-From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , "Theodore Ts'o" , Alexander Viro , Andreas Dilger , Jan Kara , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Fletcher Woodruff , Justin TerAvest , Jan Kara , stable@vger.kernel.org Subject: [PATCH v2 3/3] ext4: use jbd2_inode dirty range scoping Date: Thu, 20 Jun 2019 09:18:39 -0600 Message-Id: <20190620151839.195506-4-zwisler@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190620151839.195506-1-zwisler@google.com> References: <20190620151839.195506-1-zwisler@google.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Use the newly introduced jbd2_inode dirty range scoping to prevent us from waiting forever when trying to complete a journal transaction. Signed-off-by: Ross Zwisler Reviewed-by: Jan Kara Cc: stable@vger.kernel.org --- fs/ext4/ext4_jbd2.h | 12 ++++++------ fs/ext4/inode.c | 13 ++++++++++--- fs/ext4/move_extent.c | 3 ++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index 75a5309f22315..ef8fcf7d0d3b3 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h @@ -361,20 +361,20 @@ static inline int ext4_journal_force_commit(journal_t *journal) } static inline int ext4_jbd2_inode_add_write(handle_t *handle, - struct inode *inode) + struct inode *inode, loff_t start_byte, loff_t length) { if (ext4_handle_valid(handle)) - return jbd2_journal_inode_add_write(handle, - EXT4_I(inode)->jinode); + return jbd2_journal_inode_ranged_write(handle, + EXT4_I(inode)->jinode, start_byte, length); return 0; } static inline int ext4_jbd2_inode_add_wait(handle_t *handle, - struct inode *inode) + struct inode *inode, loff_t start_byte, loff_t length) { if (ext4_handle_valid(handle)) - return jbd2_journal_inode_add_wait(handle, - EXT4_I(inode)->jinode); + return jbd2_journal_inode_ranged_wait(handle, + EXT4_I(inode)->jinode, start_byte, length); return 0; } diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c7f77c6430085..27fec5c594459 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -731,10 +731,16 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, !(flags & EXT4_GET_BLOCKS_ZERO) && !ext4_is_quota_file(inode) && ext4_should_order_data(inode)) { + loff_t start_byte = + (loff_t)map->m_lblk << inode->i_blkbits; + loff_t length = (loff_t)map->m_len << inode->i_blkbits; + if (flags & EXT4_GET_BLOCKS_IO_SUBMIT) - ret = ext4_jbd2_inode_add_wait(handle, inode); + ret = ext4_jbd2_inode_add_wait(handle, inode, + start_byte, length); else - ret = ext4_jbd2_inode_add_write(handle, inode); + ret = ext4_jbd2_inode_add_write(handle, inode, + start_byte, length); if (ret) return ret; } @@ -4085,7 +4091,8 @@ static int __ext4_block_zero_page_range(handle_t *handle, err = 0; mark_buffer_dirty(bh); if (ext4_should_order_data(inode)) - err = ext4_jbd2_inode_add_write(handle, inode); + err = ext4_jbd2_inode_add_write(handle, inode, from, + length); } unlock: diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 1083a9f3f16a1..c7ded4e2adff5 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -390,7 +390,8 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, /* Even in case of data=writeback it is reasonable to pin * inode to transaction, to prevent unexpected data loss */ - *err = ext4_jbd2_inode_add_write(handle, orig_inode); + *err = ext4_jbd2_inode_add_write(handle, orig_inode, + (loff_t)orig_page_offset << PAGE_SHIFT, replaced_size); unlock_pages: unlock_page(pagep[0]);