Commit 7ba13abb authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle)
Browse files

fs: Turn block_invalidatepage into block_invalidate_folio



Remove special-casing of a NULL invalidatepage, since there is no
more block_invalidatepage.

Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Tested-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tested-by: Mike Marshall <hubcap@omnibond.com> # orangefs
Tested-by: David Howells <dhowells@redhat.com> # afs
parent d82354f6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -430,6 +430,7 @@ static int blkdev_writepages(struct address_space *mapping,

const struct address_space_operations def_blk_aops = {
	.set_page_dirty	= __set_page_dirty_buffers,
	.invalidate_folio = block_invalidate_folio,
	.readpage	= blkdev_readpage,
	.readahead	= blkdev_readahead,
	.writepage	= blkdev_writepage,
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)

static const struct address_space_operations adfs_aops = {
	.set_page_dirty	= __set_page_dirty_buffers,
	.invalidate_folio = block_invalidate_folio,
	.readpage	= adfs_readpage,
	.writepage	= adfs_writepage,
	.write_begin	= adfs_write_begin,
+2 −0
Original line number Diff line number Diff line
@@ -454,6 +454,7 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block)

const struct address_space_operations affs_aops = {
	.set_page_dirty	= __set_page_dirty_buffers,
	.invalidate_folio = block_invalidate_folio,
	.readpage = affs_readpage,
	.writepage = affs_writepage,
	.write_begin = affs_write_begin,
@@ -835,6 +836,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,

const struct address_space_operations affs_aops_ofs = {
	.set_page_dirty	= __set_page_dirty_buffers,
	.invalidate_folio = block_invalidate_folio,
	.readpage = affs_readpage_ofs,
	//.writepage = affs_writepage_ofs,
	.write_begin = affs_write_begin_ofs,
+1 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ static sector_t bfs_bmap(struct address_space *mapping, sector_t block)

const struct address_space_operations bfs_aops = {
	.set_page_dirty	= __set_page_dirty_buffers,
	.invalidate_folio = block_invalidate_folio,
	.readpage	= bfs_readpage,
	.writepage	= bfs_writepage,
	.write_begin	= bfs_write_begin,
+18 −19
Original line number Diff line number Diff line
@@ -1482,41 +1482,40 @@ static void discard_buffer(struct buffer_head * bh)
}

/**
 * block_invalidatepage - invalidate part or all of a buffer-backed page
 *
 * @page: the page which is affected
 * block_invalidate_folio - Invalidate part or all of a buffer-backed folio.
 * @folio: The folio which is affected.
 * @offset: start of the range to invalidate
 * @length: length of the range to invalidate
 *
 * block_invalidatepage() is called when all or part of the page has become
 * block_invalidate_folio() is called when all or part of the folio has been
 * invalidated by a truncate operation.
 *
 * block_invalidatepage() does not have to release all buffers, but it must
 * block_invalidate_folio() does not have to release all buffers, but it must
 * ensure that no dirty buffer is left outside @offset and that no I/O
 * is underway against any of the blocks which are outside the truncation
 * point.  Because the caller is about to free (and possibly reuse) those
 * blocks on-disk.
 */
void block_invalidatepage(struct page *page, unsigned int offset,
			  unsigned int length)
void block_invalidate_folio(struct folio *folio, size_t offset, size_t length)
{
	struct buffer_head *head, *bh, *next;
	unsigned int curr_off = 0;
	unsigned int stop = length + offset;
	size_t curr_off = 0;
	size_t stop = length + offset;

	BUG_ON(!PageLocked(page));
	if (!page_has_buffers(page))
		goto out;
	BUG_ON(!folio_test_locked(folio));

	/*
	 * Check for overflow
	 */
	BUG_ON(stop > PAGE_SIZE || stop < length);
	BUG_ON(stop > folio_size(folio) || stop < length);

	head = folio_buffers(folio);
	if (!head)
		return;

	head = page_buffers(page);
	bh = head;
	do {
		unsigned int next_off = curr_off + bh->b_size;
		size_t next_off = curr_off + bh->b_size;
		next = bh->b_this_page;

		/*
@@ -1535,16 +1534,16 @@ void block_invalidatepage(struct page *page, unsigned int offset,
	} while (bh != head);

	/*
	 * We release buffers only if the entire page is being invalidated.
	 * We release buffers only if the entire folio is being invalidated.
	 * The get_block cached value has been unconditionally invalidated,
	 * so real IO is not possible anymore.
	 */
	if (length == PAGE_SIZE)
		try_to_release_page(page, 0);
	if (length == folio_size(folio))
		filemap_release_folio(folio, 0);
out:
	return;
}
EXPORT_SYMBOL(block_invalidatepage);
EXPORT_SYMBOL(block_invalidate_folio);


/*
Loading