Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp936082ybi; Wed, 19 Jun 2019 10:22:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2WDz92Nixsb9WoENmw7DJmJKWe2KnOoJ+fYj5ePE57CEpUn1ZZ0/xQQRQcGA3YpTYGfYl X-Received: by 2002:a17:902:8d95:: with SMTP id v21mr98613615plo.225.1560964967369; Wed, 19 Jun 2019 10:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560964967; cv=none; d=google.com; s=arc-20160816; b=iK2TEpTbSlbl66r1Xjfmhv7tXDF+CchUJeN+FzEZZU4MFxcedC4vkpp5M2lChy+c+t JdQ7baDplc6tRPCX2qr0/gIWDRU3adCORfyJybMyuB94eFUQLrwylE2enDjaWTAIj8NF rucqFkE/qTUTug2smNOgCxTVJUVszHgq+J3qj9om4JjMDy89G0Iiy7lisbu45J8tl00k oTmYNm71CkyaEYJmfaK+H4B5PCBCU+wFeBGhGv+Yi9bEAQlJZ1LhMME+62iYupsfphid Kqqtyy2k514cClTwZrHn5T/I2PRo/xJv6ZPPVmSI3ABhgNYAK61Cd/ht7L2o6j7MBmFw EAEA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E3jskMxg6mXOnAk1TRm40OOCGhyEHDf4Luejh67p06E=; b=uVavRAWjEtOosNsZN+iMA51zX/+Ez+A8qUtLp3cQB+8B4Ok0l4pw9UgnzPXNjxHyN8 G03uijbkXuKsBQMCoNaaP59W94mVHrBYIUxjKbz1gvXSvKlEhITzJZuIUfqR40uIu+Bw Z1AFTUBjo2pl2IpgzMGW4LvjqkiM0ApO7RyuDexP6hR8d6Zbc7sWP7OA3kCMIY5roVC4 4ReQgjBRfSrLX9oUHxw1WpXWSJPj9BgGP4Qz+ddmfBPKbOnDit2SLjcc8rEhRhfhnGM4 /741p+mhegr/vCk+E3SAmTuPmsJQxaUYtOJLpy/fx/HDq39tKO4mg8e0qiHWIIJ5+E4W gaoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XJUjnADz; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si643329pgb.445.2019.06.19.10.22.33; Wed, 19 Jun 2019 10:22:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=@chromium.org header.s=google header.b=XJUjnADz; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729681AbfFSRWX (ORCPT + 99 others); Wed, 19 Jun 2019 13:22:23 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:39317 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730068AbfFSRWX (ORCPT ); Wed, 19 Jun 2019 13:22:23 -0400 Received: by mail-io1-f68.google.com with SMTP id r185so308204iod.6 for ; Wed, 19 Jun 2019 10:22:23 -0700 (PDT) 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=E3jskMxg6mXOnAk1TRm40OOCGhyEHDf4Luejh67p06E=; b=XJUjnADzObWPEkqAra7JZG2MqVf6jOIl2xtoUl1SDnE0wuok4jfWhzqw1sqdOy1MdG ukIsu9ZRYZ7Odf66ee9EScvXI8+ziKIaEoU1vAYC/d16vXG5k7/dNvwAB5MjWlb1v9J5 LJYYWKu+nb0iK/BWTUe5n9zeCPnxh/3JNBMQ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E3jskMxg6mXOnAk1TRm40OOCGhyEHDf4Luejh67p06E=; b=buSLazojhPWC/Wy70kAa/fHEADym3ZUG5lGEzhsUMR8n7Bj/hD1gjXQgzydCUpPuTR qBA33KSini0A2/+CeAiNVdKyeWxCJpMACdniHOyZY5q5W4Iyp5yCKI71/YYSs3BUb4DO gPcNcvS0zrE4F086/WTDM5++sW3i8ScNtJVcs35wquGKVNh9CqovEhZqrZaT9N4mAYHk 1V+xYU9cZgqXJtHHGTM1ajH5IZBVohIlZBiZsxsE7GjkCXMndtU71rzj9FolvWPsHBAk TtbLyYrW5zArHLfYlfa/GtXHUQrldPU2v8DrAeFPXNo3ZpxvIC2uGEFdo+Wif7EsRLak KaVg== X-Gm-Message-State: APjAAAV9t4iUVDMnNfSf2G3z4AEdhYFg1ch2DcRWlj0B48sfY5dl5Bzx A3sEu5zJOXlvZdmlsv1fqHSvDA== X-Received: by 2002:a02:cd82:: with SMTP id l2mr11507623jap.96.1560964942675; Wed, 19 Jun 2019 10:22:22 -0700 (PDT) Received: from localhost ([2620:15c:183:200:855f:8919:84a7:4794]) by smtp.gmail.com with ESMTPSA id y17sm17889989ioa.40.2019.06.19.10.22.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 10:22:22 -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 Subject: [PATCH 1/3] mm: add filemap_fdatawait_range_keep_errors() Date: Wed, 19 Jun 2019 11:21:54 -0600 Message-Id: <20190619172156.105508-2-zwisler@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190619172156.105508-1-zwisler@google.com> References: <20190619172156.105508-1-zwisler@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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 -- 2.22.0.410.gd8fdbe21b5-goog