forked from mirrors/linux
		
	iomap: make buffered writes work with RWF_DONTCACHE
Add iomap buffered write support for RWF_DONTCACHE. If RWF_DONTCACHE is set for a write, mark the folios being written as uncached. Then writeback completion will drop the pages. The write_iter handler simply kicks off writeback for the pages, and writeback completion will take care of the rest. Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> Link: https://lore.kernel.org/r/20250204184047.356762-2-axboe@kernel.dk Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
		
							parent
							
								
									2014c95afe
								
							
						
					
					
						commit
						b2cd5ae693
					
				
					 4 changed files with 12 additions and 0 deletions
				
			
		|  | @ -352,6 +352,11 @@ operations: | ||||||
|    ``IOMAP_NOWAIT`` is often set on behalf of ``IOCB_NOWAIT`` or |    ``IOMAP_NOWAIT`` is often set on behalf of ``IOCB_NOWAIT`` or | ||||||
|    ``RWF_NOWAIT``. |    ``RWF_NOWAIT``. | ||||||
| 
 | 
 | ||||||
|  |  * ``IOMAP_DONTCACHE`` is set when the caller wishes to perform a | ||||||
|  |    buffered file I/O and would like the kernel to drop the pagecache | ||||||
|  |    after the I/O completes, if it isn't already being used by another | ||||||
|  |    thread. | ||||||
|  | 
 | ||||||
| If it is necessary to read existing file contents from a `different | If it is necessary to read existing file contents from a `different | ||||||
| <https://lore.kernel.org/all/20191008071527.29304-9-hch@lst.de/>`_ | <https://lore.kernel.org/all/20191008071527.29304-9-hch@lst.de/>`_ | ||||||
| device or address range on a device, the filesystem should return that | device or address range on a device, the filesystem should return that | ||||||
|  |  | ||||||
|  | @ -131,6 +131,8 @@ These ``struct kiocb`` flags are significant for buffered I/O with iomap: | ||||||
| 
 | 
 | ||||||
|  * ``IOCB_NOWAIT``: Turns on ``IOMAP_NOWAIT``. |  * ``IOCB_NOWAIT``: Turns on ``IOMAP_NOWAIT``. | ||||||
| 
 | 
 | ||||||
|  |  * ``IOCB_DONTCACHE``: Turns on ``IOMAP_DONTCACHE``. | ||||||
|  | 
 | ||||||
| Internal per-Folio State | Internal per-Folio State | ||||||
| ------------------------ | ------------------------ | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -603,6 +603,8 @@ struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len) | ||||||
| 
 | 
 | ||||||
| 	if (iter->flags & IOMAP_NOWAIT) | 	if (iter->flags & IOMAP_NOWAIT) | ||||||
| 		fgp |= FGP_NOWAIT; | 		fgp |= FGP_NOWAIT; | ||||||
|  | 	if (iter->flags & IOMAP_DONTCACHE) | ||||||
|  | 		fgp |= FGP_DONTCACHE; | ||||||
| 	fgp |= fgf_set_order(len); | 	fgp |= fgf_set_order(len); | ||||||
| 
 | 
 | ||||||
| 	return __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, | 	return __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, | ||||||
|  | @ -1034,6 +1036,8 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, | ||||||
| 
 | 
 | ||||||
| 	if (iocb->ki_flags & IOCB_NOWAIT) | 	if (iocb->ki_flags & IOCB_NOWAIT) | ||||||
| 		iter.flags |= IOMAP_NOWAIT; | 		iter.flags |= IOMAP_NOWAIT; | ||||||
|  | 	if (iocb->ki_flags & IOCB_DONTCACHE) | ||||||
|  | 		iter.flags |= IOMAP_DONTCACHE; | ||||||
| 
 | 
 | ||||||
| 	while ((ret = iomap_iter(&iter, ops)) > 0) | 	while ((ret = iomap_iter(&iter, ops)) > 0) | ||||||
| 		iter.processed = iomap_write_iter(&iter, i); | 		iter.processed = iomap_write_iter(&iter, i); | ||||||
|  |  | ||||||
|  | @ -183,6 +183,7 @@ struct iomap_folio_ops { | ||||||
| #define IOMAP_DAX		0 | #define IOMAP_DAX		0 | ||||||
| #endif /* CONFIG_FS_DAX */ | #endif /* CONFIG_FS_DAX */ | ||||||
| #define IOMAP_ATOMIC		(1 << 9) | #define IOMAP_ATOMIC		(1 << 9) | ||||||
|  | #define IOMAP_DONTCACHE		(1 << 10) | ||||||
| 
 | 
 | ||||||
| struct iomap_ops { | struct iomap_ops { | ||||||
| 	/*
 | 	/*
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Jens Axboe
						Jens Axboe