From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF646280035; Mon, 13 Oct 2025 02:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760324369; cv=none; b=t21Iz8f6xx2HIQDCNsXvKE9ip7PwlD5MSFTITn6RSvWVnqzpCJRfaTNkp7I56q5Ry9IN6eBr4efsfPX7olpREiecqANJV1EBphOEqBvYxUaW3+mihAY/pK5wdsf2+sEEcoXBoqmB1pfBwacW3bvtqXzym2xhL3xFEn/EcmkdWeI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760324369; c=relaxed/simple; bh=o1yW/Q2NmNe05rs0fDT6NT8czHim4gAe5aDI0pMlBs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TKMzkDbCAl6LdlpzY5/bnKSD5BtjOKNTFlaO8etVhkTBIjfDAZZ0GeV61ruMAcFwH1QZb0kPuOWyIFkugSjCkAQbebJfMYeFkZCUiL5WiiVGFBRaHBrSVryCXeJnanJ9Ek/ImttzI45gb4fpWPfOlZwtFVVxgo8NG+va8PFS7Zk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=RKhYVfWS; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="RKhYVfWS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=MI0vHZhtJ1k9QEFLwQMKaIXmWsfgPbtlLeEIYHV3Ov4=; b=RKhYVfWS0EBFO0UM80v8hmdBKl ns8TwelL0DUYkZ0VBMaapzQENCJI2kHbtG+DjRkof8h4NJr9WSA+QCcmAbPr4mW3dmx+vueab6G2H mZV5g3rbo1tspoHLUCyUmxiOI3NVvsu7oJY9FPQZm3tYn4vR2Rt8Gb5HWYGSth0+5KyYIYr3Pf4vg kI590qr0NMriRzuTJBxKtLPxkdVlw4VRgV6PiFIZiHP1sDutUc4V273JL5CylFxsOdPl4/CcihQB+ X1GxQSe6FFBfj+RQXF2KvIufIejJtnkYax8vKi7lf1gplPU8+tYEuw3LoX38gWSLgkhBt0pJWRKPs PP4yuq1A==; Received: from [220.85.59.196] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v88mR-0000000C8QN-3xsq; Mon, 13 Oct 2025 02:59:24 +0000 From: Christoph Hellwig To: "Matthew Wilcox (Oracle)" , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , Chris Mason , David Sterba , Mark Fasheh , Joel Becker , Joseph Qi Cc: Alexander Viro , Christian Brauner , Josef Bacik , Jan Kara , linux-block@vger.kernel.org, v9fs@lists.linux.dev, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/10] mm: remove __filemap_fdatawrite_range Date: Mon, 13 Oct 2025 11:58:04 +0900 Message-ID: <20251013025808.4111128-10-hch@lst.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251013025808.4111128-1-hch@lst.de> References: <20251013025808.4111128-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Use filemap_fdatawrite_range and filemap_fdatawrite_range_kick instead of the low-level __filemap_fdatawrite_range that requires the caller to know the internals of the writeback_control structure and remove __filemap_fdatawrite_range now that it is trivial and only two callers would be left. Signed-off-by: Christoph Hellwig --- fs/fs-writeback.c | 6 +++--- fs/sync.c | 11 +++++------ include/linux/pagemap.h | 2 -- mm/fadvise.c | 3 +-- mm/filemap.c | 25 +++++++------------------ 5 files changed, 16 insertions(+), 31 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 2b35e80037fe..8b002ab18103 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -807,9 +807,9 @@ static void wbc_attach_and_unlock_inode(struct writeback_control *wbc, * @wbc: writeback_control of interest * @inode: target inode * - * This function is to be used by __filemap_fdatawrite_range(), which is an - * alternative entry point into writeback code, and first ensures @inode is - * associated with a bdi_writeback and attaches it to @wbc. + * This function is to be used by filemap_fdatawrite*(), which write back data + * from arbitrary threads instead of the main writeback thread to ensure @inode + * is associated with a bdi_writeback and attached to @wbc. */ void wbc_attach_fdatawrite_inode(struct writeback_control *wbc, struct inode *inode) diff --git a/fs/sync.c b/fs/sync.c index 2955cd4c77a3..6d8b04e04c3c 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -280,14 +280,13 @@ int sync_file_range(struct file *file, loff_t offset, loff_t nbytes, } if (flags & SYNC_FILE_RANGE_WRITE) { - int sync_mode = WB_SYNC_NONE; - if ((flags & SYNC_FILE_RANGE_WRITE_AND_WAIT) == SYNC_FILE_RANGE_WRITE_AND_WAIT) - sync_mode = WB_SYNC_ALL; - - ret = __filemap_fdatawrite_range(mapping, offset, endbyte, - sync_mode); + ret = filemap_fdatawrite_range(mapping, offset, + endbyte); + else + ret = filemap_fdatawrite_range_kick(mapping, offset, + endbyte); if (ret < 0) goto out; } diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 742ba1dd3990..664f23f2330a 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -55,8 +55,6 @@ static inline int filemap_fdatawait(struct address_space *mapping) bool filemap_range_has_page(struct address_space *, loff_t lstart, loff_t lend); int filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart, loff_t lend); -int __filemap_fdatawrite_range(struct address_space *mapping, - loff_t start, loff_t end, int sync_mode); int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, loff_t end); int filemap_check_errors(struct address_space *mapping); diff --git a/mm/fadvise.c b/mm/fadvise.c index 588fe76c5a14..f1be619f0e58 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -111,8 +111,7 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) spin_unlock(&file->f_lock); break; case POSIX_FADV_DONTNEED: - __filemap_fdatawrite_range(mapping, offset, endbyte, - WB_SYNC_NONE); + filemap_fdatawrite_range_kick(mapping, offset, endbyte); /* * First and last FULL page! Partial pages are deliberately diff --git a/mm/filemap.c b/mm/filemap.c index 26b692dbf091..ec19ed127de2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -392,32 +392,23 @@ static int __filemap_fdatawrite(struct address_space *mapping, loff_t start, } /** - * __filemap_fdatawrite_range - start writeback on mapping dirty pages in range + * filemap_fdatawrite_range - start writeback on mapping dirty pages in range * @mapping: address space structure to write * @start: offset in bytes where the range starts * @end: offset in bytes where the range ends (inclusive) - * @sync_mode: enable synchronous operation * * Start writeback against all of a mapping's dirty pages that lie * within the byte offsets inclusive. * - * If sync_mode is WB_SYNC_ALL then this is a "data integrity" operation, as - * opposed to a regular memory cleansing writeback. The difference between - * these two operations is that if a dirty page/buffer is encountered, it must - * be waited upon, and not just skipped over. + * This is a data integrity operation that waits upon dirty or in writeback + * pages. * * Return: %0 on success, negative error code otherwise. */ -int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start, - loff_t end, int sync_mode) -{ - return __filemap_fdatawrite(mapping, start, end, sync_mode, NULL); -} - int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, loff_t end) { - return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL); + return __filemap_fdatawrite(mapping, start, end, WB_SYNC_ALL, NULL); } EXPORT_SYMBOL(filemap_fdatawrite_range); @@ -441,7 +432,7 @@ EXPORT_SYMBOL(filemap_fdatawrite); int filemap_fdatawrite_range_kick(struct address_space *mapping, loff_t start, loff_t end) { - return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_NONE); + return __filemap_fdatawrite(mapping, start, end, WB_SYNC_NONE, NULL); } EXPORT_SYMBOL_GPL(filemap_fdatawrite_range_kick); @@ -689,8 +680,7 @@ int filemap_write_and_wait_range(struct address_space *mapping, return 0; if (mapping_needs_writeback(mapping)) { - err = __filemap_fdatawrite_range(mapping, lstart, lend, - WB_SYNC_ALL); + err = filemap_fdatawrite_range(mapping, lstart, lend); /* * Even if the above returned error, the pages may be * written partially (e.g. -ENOSPC), so we wait for it. @@ -792,8 +782,7 @@ int file_write_and_wait_range(struct file *file, loff_t lstart, loff_t lend) return 0; if (mapping_needs_writeback(mapping)) { - err = __filemap_fdatawrite_range(mapping, lstart, lend, - WB_SYNC_ALL); + err = filemap_fdatawrite_range(mapping, lstart, lend); /* See comment of filemap_write_and_wait() */ if (err != -EIO) __filemap_fdatawait_range(mapping, lstart, lend); -- 2.47.3