Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3786739ybi; Mon, 29 Jul 2019 12:36:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6GBAvNJ8YC4VjthMB9WdtRdZXi0HJxEYIkX+Cj1mbflVGt9MibhPN8BmoOmppfpD7uFJW X-Received: by 2002:a17:90a:206a:: with SMTP id n97mr113533014pjc.10.1564428981792; Mon, 29 Jul 2019 12:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428981; cv=none; d=google.com; s=arc-20160816; b=laYj1r7aZG5cYVj7P2wHPKuIe8SjO+TFCUOOIK6olfx2z/wfZ0ILCXM0vZEb6ArEJQ 3H/dK/9sXcZ01uEUXHcWxxXhSloJISDEqsPUzwaz97yj+t8I/LOoQf+io1vRARqJLbOx 6nphg2G1mvQ7TQL/d2LdjQZh1ABO9X5UqChFYFz+GWc74qebXjQr+89k+S705otcW5Ti x4gUEmzHhDD+RWyYqxu0472/Db9AeslGNW2eBkLZmM3DYigQ4Q6HVJrL2WO4kt6UM/hT PtLUTgqDNC9eeIFSzwX5omqCfoy4yOMOUqEp8wfEkzr2QJyBsWoM0tBkh5SALCyXVqhf l2fA== 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=NlSbqqONQOv/qwn+lYL2Su7AKe9CFA6koD94ZINgYQo=; b=QNS/JXnVWNlLueemxwJDC77IrOyTY5vjaE3TQvrUOaABuk+99TtGGFFJlOwaDdtgbH 1mlhjajnySFaFRZreCmMuxJU9lL7q9dh3pg08kpwMla+/sX/X2gz1LkkacuZ3f1r9Mbq a2WAs7EggUjv4L11vCOQUJwHEN8olBn7e8qP0iHPd/ELL5uXCrRPu8Opz5dGWXTeZsFO zn7zHMOm0cOMPaMc7+oOMhlJFDa3jxmavaFrKdYvuejZGQYc/BgJGDJPjsd4vhmI60ys 5M08YNdL6NiwBNJlu/fC6tXcnmx/kVQUcExJBl9mT71Y+EZzq7O6aTowtHE/i8dnTVC8 rV2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NA+l6CFW; 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 24si14780698pfn.144.2019.07.29.12.36.07; Mon, 29 Jul 2019 12:36:21 -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=NA+l6CFW; 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 S2388436AbfG2Te1 (ORCPT + 99 others); Mon, 29 Jul 2019 15:34:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:48812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388336AbfG2TeY (ORCPT ); Mon, 29 Jul 2019 15:34:24 -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 3F7D32070B; Mon, 29 Jul 2019 19:34:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428863; bh=FRTWK1UW7JCfMIwKadFY/C0ZNh5/pNuZbIf5M2pQ2sY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NA+l6CFWFvjYkooNF84rAOZKh8YaiOyMvCf9LrZGAG5vG0DupOQ0CM6ELdIwVdvhU H48B5+516EbkcWwrkwruaVBdJcJwcP9bCMwSBrC/2dNu29bO1GFx8sqDZrdtBzCWBv 0HHEevKqEXac2X0Z0HDvrXWfPsqyPHXzcmVY76y4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ross Zwisler , Theodore Tso , Jan Kara Subject: [PATCH 4.14 210/293] mm: add filemap_fdatawait_range_keep_errors() Date: Mon, 29 Jul 2019 21:21:41 +0200 Message-Id: <20190729190840.547311068@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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: Ross Zwisler commit aa0bfcd939c30617385ffa28682c062d78050eba upstream. 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 Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- include/linux/fs.h | 2 ++ mm/filemap.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2580,6 +2580,8 @@ extern int filemap_flush(struct address_ 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) { --- a/mm/filemap.c +++ b/mm/filemap.c @@ -464,6 +464,28 @@ int filemap_fdatawait_range(struct addre 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 * @start_byte: offset in bytes where the range starts