From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D864CCFA04 for ; Mon, 3 Nov 2025 01:49:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:Message-ID:In-Reply-To:Date:From:To:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:References:List-Owner; bh=mNVzVtEFCkA+ILVckNRTlHZugOwDMLwn+d0jXvjyP1E=; b=TDXjDR3AszfqmSILVV352d9d+W I5Rjm3bZIcYRSYXKM74mCGCNvawZv33raB07w5rbtTaVz6KqyVcdLNcE6ZDpDdVovnmbmjIzY496v vcJmJ2KLWI3tABjY+A9C4z+DTxJcdhOetYNckLvNHiLIrK2qtFVhndK7ucfY1rfqmC9Q=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vFjgz-0002wd-L1; Mon, 03 Nov 2025 01:49:09 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vFjgx-0002wV-TO for linux-f2fs-devel@lists.sourceforge.net; Mon, 03 Nov 2025 01:49:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :Message-ID:In-Reply-To:Date:From:Cc:To:Subject:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WmeC/8ZZQQkT4nDLFEB2O/tMWzlCDcbJzq8WmRi9EUE=; b=HU5zIdSqRIWhl0VXuNL0IGKXA6 geSw2nXhivbaqIxO/EDHfUwS1hyNbeLEq03mqeKnVC44pt0w5VQxgF2I84hJHbnMq0aAoOKSpQ+2m eoU2NX9f3qWQ0IY4OsfB6BXaUoelDgicvT+ZkCcZrH5U9qxUfETD19UPkpiDBfTgUHxg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:From:Cc:To:Subject:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WmeC/8ZZQQkT4nDLFEB2O/tMWzlCDcbJzq8WmRi9EUE=; b=PkaDq8wyGt83wCToD7SLAWNmd6 uTSUyAmw4HajBi67M6LmNG4gIVrzlE43aqgBjLR/798cfN/h1tBDE9M2gL6t7gbLdaezM7iFuAUvC sUeN3JlU6bKqnXjQNH2VEUGTzfgWYrCxqfGdY0+7WzBsAxcLzwl0t3w+dWLch5ApU5cg=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vFjgw-0007LV-MN for linux-f2fs-devel@lists.sourceforge.net; Mon, 03 Nov 2025 01:49:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 1CC7660282; Mon, 3 Nov 2025 01:48:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E594C4CEFB; Mon, 3 Nov 2025 01:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1762134535; bh=K+l6n/WGoGMMfGGoVu3pTyL0SCoEaujvnY6f8Mgxr6Q=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=KtkocYiudfdwgI/CFG913fw8BISy5rIXVHZqBo1KPWpdkr2pw40zlsnytuRqQNhQO obVTAHRaUdZCKa6jxOzRFdvTsA5dcFU2iry0YCfW4Qd9rrEMgLD/U1roxcWqrmXPtE yV1CbG0txjBpoxKP2suSUY8eufgHue0K9ZdvNSzE= To: adilger.kernel@dilger.ca, agruenba@redhat.com, akpm@linux-foundation.org, anna@kernel.org, axboe@kernel.dk, brauner@kernel.org, chao@kernel.org, djwong@kernel.org, dlemoal@kernel.org, gregkh@linuxfoundation.org, hare@suse.de, hch@infradead.org, hch@lst.de, idryomov@gmail.com, jaegeuk@kernel.org, jlayton@kernel.org, johannes.thumshirn@wdc.com, konishi.ryusuke@gmail.com, linux-f2fs-devel@lists.sourceforge.net, linux-mm@kvack.org, mcgrof@kernel.org, miklos@szeredi.hu, mngyadam@amazon.de, mszeredi@redhat.com, nagy@khwaternagy.com, trond.myklebust@hammerspace.com, tytso@mit.edu, viro@zeniv.linux.org.uk, willy@infradead.org, xiubli@redhat.com From: Date: Mon, 03 Nov 2025 10:46:56 +0900 In-Reply-To: <20251021070353.96705-3-mngyadam@amazon.de> Message-ID: <2025110356-unabashed-boat-8cee@gregkh> MIME-Version: 1.0 X-stable: commit X-Patchwork-Hint: ignore X-Headers-End: 1vFjgw-0007LV-MN Subject: [f2fs-dev] Patch "filemap: add a kiocb_invalidate_pages helper" has been added to the 6.1-stable tree X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable-commits@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This is a note to let you know that I've just added the patch titled filemap: add a kiocb_invalidate_pages helper to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: filemap-add-a-kiocb_invalidate_pages-helper.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From stable+bounces-188296-greg=kroah.com@vger.kernel.org Tue Oct 21 16:11:59 2025 From: Mahmoud Adam Date: Tue, 21 Oct 2025 09:03:36 +0200 Subject: filemap: add a kiocb_invalidate_pages helper To: Cc: , , Christoph Hellwig , Damien Le Moal , Hannes Reinecke , "Darrick J. Wong" , Al Viro , Andreas Gruenbacher , "Anna Schumaker" , Chao Yu , Christian Brauner , Ilya Dryomov , Jaegeuk Kim , Jens Axboe , Johannes Thumshirn , Matthew Wilcox , "Miklos Szeredi" , Miklos Szeredi , "Theodore Ts'o" , Trond Myklebust , Xiubo Li , Andrew Morton , "Jeff Layton" , Andreas Dilger , Christoph Hellwig , Ryusuke Konishi , Luis Chamberlain , , , , , , , , , , Message-ID: <20251021070353.96705-3-mngyadam@amazon.de> From: Christoph Hellwig commit e003f74afbd2feadbb9ffbf9135e2d2fb5d320a5 upstream. Factor out a helper that calls filemap_write_and_wait_range and invalidate_inode_pages2_range for the range covered by a write kiocb or returns -EAGAIN if the kiocb is marked as nowait and there would be pages to write or invalidate. Link: https://lkml.kernel.org/r/20230601145904.1385409-6-hch@lst.de Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Acked-by: Darrick J. Wong Cc: Al Viro Cc: Andreas Gruenbacher Cc: Anna Schumaker Cc: Chao Yu Cc: Christian Brauner Cc: Ilya Dryomov Cc: Jaegeuk Kim Cc: Jens Axboe Cc: Johannes Thumshirn Cc: Matthew Wilcox Cc: Miklos Szeredi Cc: Miklos Szeredi Cc: Theodore Ts'o Cc: Trond Myklebust Cc: Xiubo Li Signed-off-by: Andrew Morton Signed-off-by: Mahmoud Adam Signed-off-by: Greg Kroah-Hartman --- include/linux/pagemap.h | 1 + mm/filemap.c | 48 ++++++++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 20 deletions(-) --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -30,6 +30,7 @@ static inline void invalidate_remote_ino int invalidate_inode_pages2(struct address_space *mapping); int invalidate_inode_pages2_range(struct address_space *mapping, pgoff_t start, pgoff_t end); +int kiocb_invalidate_pages(struct kiocb *iocb, size_t count); int write_inode_now(struct inode *, int sync); int filemap_fdatawrite(struct address_space *); int filemap_flush(struct address_space *); --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2839,6 +2839,33 @@ put_folios: } EXPORT_SYMBOL_GPL(filemap_read); +int kiocb_invalidate_pages(struct kiocb *iocb, size_t count) +{ + struct address_space *mapping = iocb->ki_filp->f_mapping; + loff_t pos = iocb->ki_pos; + loff_t end = pos + count - 1; + int ret; + + if (iocb->ki_flags & IOCB_NOWAIT) { + /* we could block if there are any pages in the range */ + if (filemap_range_has_page(mapping, pos, end)) + return -EAGAIN; + } else { + ret = filemap_write_and_wait_range(mapping, pos, end); + if (ret) + return ret; + } + + /* + * After a write we want buffered reads to be sure to go to disk to get + * the new data. We invalidate clean cached page from the region we're + * about to write. We do this *before* the write so that we can return + * without clobbering -EIOCBQUEUED from ->direct_IO(). + */ + return invalidate_inode_pages2_range(mapping, pos >> PAGE_SHIFT, + end >> PAGE_SHIFT); +} + /** * generic_file_read_iter - generic filesystem read routine * @iocb: kernel I/O control block @@ -3737,30 +3764,11 @@ generic_file_direct_write(struct kiocb * write_len = iov_iter_count(from); end = (pos + write_len - 1) >> PAGE_SHIFT; - if (iocb->ki_flags & IOCB_NOWAIT) { - /* If there are pages to writeback, return */ - if (filemap_range_has_page(file->f_mapping, pos, - pos + write_len - 1)) - return -EAGAIN; - } else { - written = filemap_write_and_wait_range(mapping, pos, - pos + write_len - 1); - if (written) - goto out; - } - - /* - * After a write we want buffered reads to be sure to go to disk to get - * the new data. We invalidate clean cached page from the region we're - * about to write. We do this *before* the write so that we can return - * without clobbering -EIOCBQUEUED from ->direct_IO(). - */ - written = invalidate_inode_pages2_range(mapping, - pos >> PAGE_SHIFT, end); /* * If a page can not be invalidated, return 0 to fall back * to buffered write. */ + written = kiocb_invalidate_pages(iocb, write_len); if (written) { if (written == -EBUSY) return 0; Patches currently in stable-queue which might be from mngyadam@amazon.de are queue-6.1/block-fix-race-between-set_blocksize-and-read-paths.patch queue-6.1/filemap-add-a-kiocb_invalidate_pages-helper.patch queue-6.1/fs-factor-out-a-direct_write_fallback-helper.patch queue-6.1/direct_write_fallback-on-error-revert-the-ki_pos-update-from-buffered-write.patch queue-6.1/filemap-update-ki_pos-in-generic_perform_write.patch queue-6.1/filemap-add-a-kiocb_invalidate_post_direct_write-helper.patch queue-6.1/nilfs2-fix-deadlock-warnings-caused-by-lock-dependency-in-init_nilfs.patch queue-6.1/block-open-code-__generic_file_write_iter-for-blkdev-writes.patch _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel