Unverified Commit 97edbc02 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Christian Brauner
Browse files

buffer: Convert block_write_end() to take a folio



All callers now have a folio, so pass it in instead of converting
from a folio to a page and back to a folio again.  Saves a call
to compound_head().

Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent c4c9c89c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ static int blkdev_write_end(struct file *file, struct address_space *mapping,
{
	struct folio *folio = page_folio(page);
	int ret;
	ret = block_write_end(file, mapping, pos, len, copied, page, fsdata);
	ret = block_write_end(file, mapping, pos, len, copied, folio, fsdata);

	folio_unlock(folio);
	folio_put(folio);
+2 −3
Original line number Diff line number Diff line
@@ -2247,9 +2247,8 @@ EXPORT_SYMBOL(block_write_begin);

int block_write_end(struct file *file, struct address_space *mapping,
			loff_t pos, unsigned len, unsigned copied,
			struct page *page, void *fsdata)
			struct folio *folio, void *fsdata)
{
	struct folio *folio = page_folio(page);
	size_t start = pos - folio_pos(folio);

	if (unlikely(copied < len)) {
@@ -2288,7 +2287,7 @@ int generic_write_end(struct file *file, struct address_space *mapping,
	loff_t old_size = inode->i_size;
	bool i_size_changed = false;

	copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
	copied = block_write_end(file, mapping, pos, len, copied, folio, fsdata);

	/*
	 * No need to use i_size_read() here, the i_size cannot change under us
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ static void ext2_commit_chunk(struct folio *folio, loff_t pos, unsigned len)
	struct inode *dir = mapping->host;

	inode_inc_iversion(dir);
	block_write_end(NULL, mapping, pos, len, len, &folio->page, NULL);
	block_write_end(NULL, mapping, pos, len, len, folio, NULL);

	if (pos+len > dir->i_size) {
		i_size_write(dir, pos+len);
+2 −2
Original line number Diff line number Diff line
@@ -1315,7 +1315,7 @@ static int ext4_write_end(struct file *file,
		return ext4_write_inline_data_end(inode, pos, len, copied,
						  folio);

	copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
	copied = block_write_end(file, mapping, pos, len, copied, folio, fsdata);
	/*
	 * it's important to update i_size while still holding folio lock:
	 * page writeout could otherwise come in and zero beyond i_size.
@@ -3029,7 +3029,7 @@ static int ext4_da_do_write_end(struct address_space *mapping,
	 * flag, which all that's needed to trigger page writeback.
	 */
	copied = block_write_end(NULL, mapping, pos, len, copied,
			&folio->page, NULL);
			folio, NULL);
	new_i_size = pos + copied;

	/*
+1 −1
Original line number Diff line number Diff line
@@ -900,7 +900,7 @@ static bool iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len,
		size_t bh_written;

		bh_written = block_write_end(NULL, iter->inode->i_mapping, pos,
					len, copied, &folio->page, NULL);
					len, copied, folio, NULL);
		WARN_ON_ONCE(bh_written != copied && bh_written != 0);
		return bh_written == copied;
	}
Loading