Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2050913ybi; Thu, 20 Jun 2019 08:19:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgwYtNWSTw5bMd10Wehvbv8qBTEw3x4RZ1q0BtdBoMot/de6F6dXlvnMJqX579+qRjBSmU X-Received: by 2002:a17:902:7883:: with SMTP id q3mr123923824pll.89.1561043963820; Thu, 20 Jun 2019 08:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561043963; cv=none; d=google.com; s=arc-20160816; b=O78jmQtvi9geFI4paNgQYeOAX6TxJovcvkE3R06+2kun8eWfaC9wnvRW6GQ7f0qOFv ++nasnioIIUNkk7Abb33V1T2NQh1IE7nRuuSv7bhG4yHC+S7dQRztYJ+qbqdRtHjyoav Lv3pph6sKBz8ATggbjqGGD1htkxnD5OjeknQG1+HsrU8wb9q5aYXm1Ou0Wh5saEIUE3v UKA9752UNG/GnGjRmPUW51yXoajupsFKMA+9Fq2QW1ubA/1I8GpfqJldH6EIZfdlNgtd H6P+YRlTPFGFX46U5eJ+avgMoI+jiRik2XOzZ6kq3+415Jo7piVccFmY5QAGBIo1/pe5 IaIA== 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=LbaJcyWYnbCa5ezoro66saapuXs/2zff7F4rgt4jO/0=; b=hguMWOsdvqH3MkQk+CwAzqplCtwXV2QWOCpr2DKzYgxVcmi+d5CSYtItVZSlMspNj5 0Gv8/icHUId0XyPQNKpCVV7YJw6AYlelNLB0n0LPRN6wpbYSPAMlMsDSqiUd8qEpKoOZ i8BG0fZ/RxQ3s7IZJa+MbuC1jSKXxn9Z4ucLyYZoCheL0DkpbXGaG6u/aAaQAHfYtRRU /Gt2jvVAC2FTORwkABpFm/rQL8i2cFbHVSuzL9TClYNsO5RYaWFo4sgiJImKiV5IxT4u sCS+ogM0EEOPS3cyri5P89uK+tNg2FeuCdqsnMO0b/gYXEEZ5416/u5sC9h1vgfP/7pB GeTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Vgb6ZSxZ; 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; 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 x9si26101plo.98.2019.06.20.08.19.07; Thu, 20 Jun 2019 08:19:23 -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=@chromium.org header.s=google header.b=Vgb6ZSxZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732062AbfFTPS4 (ORCPT + 99 others); Thu, 20 Jun 2019 11:18:56 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:39898 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731967AbfFTPSw (ORCPT ); Thu, 20 Jun 2019 11:18:52 -0400 Received: by mail-io1-f65.google.com with SMTP id r185so4976614iod.6 for ; Thu, 20 Jun 2019 08:18:52 -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=LbaJcyWYnbCa5ezoro66saapuXs/2zff7F4rgt4jO/0=; b=Vgb6ZSxZHxs/uF5rGy6wsIsWX1oNvwsVPTCFF0NCmLRH7xlP6b3yhvsiikpiDNYTsl fFr9zFv5G8yh1I0ISPt9HhTsz4g31G0pXdVQ66gHrsaLY66H8TVJlwYnY/EZ4IHox7rw WGi3kTBfRbg/0MwUa03341kI9jQ6Pm0dIf7m4= 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=LbaJcyWYnbCa5ezoro66saapuXs/2zff7F4rgt4jO/0=; b=AVdP4NwUA996mFlW1/JMgynZi3/TA+sy8LxP/jIjbL0D4NvYKUP5FTO9Id0dVx8EIE MSesMW2CsHy9cSSSxYsktRFJj0fog3bN8KzMmi5Y5mCOhX1cCXR1fqQWZjQuqbfZwV56 9KIfRILDfmcKckJ8gcFK34HVszUUz1khZM1SI+09a+a7+EHfiZ5vZzkdAv9Au//MnbRf barqnXJuRqGF+flN7xnvwO6iurxj9M+i+Ss7ew7zIJVhcWWV6fSz6yRa9I+n0GjqKFmP oEuoSMfSAX4adC9SN9puUJv45VF7EKpx4aA81vnIgKtiEg2q64iCa2sJ6Md6qQbB0vUc ga9w== X-Gm-Message-State: APjAAAXCSft51KzxH+YbF9gYHpJTKZfknSIQjDNAzR1PEXdo2Z3mI4Eq XKFWH5UDt1nBWXgBlRkoiD4zZXzyTTs= 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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 -- 2.22.0.410.gd8fdbe21b5-goog