Skip to content

Commit f079ab0

Browse files
committed
Merge tag 'iomap-5.17' of git://git.infradead.org/users/willy/linux
Pull iomap updates from Matthew Wilcox: "Convert xfs/iomap to use folios. This should be all that is needed for XFS to use large folios. There is no code in this pull request to create large folios, but no additional changes should be needed to XFS or iomap once they are created. Usually this would have come from Darrick, and we had intended that it would come that route. Between the holidays and various things which Darrick needed to work on, he asked if I could send things directly. There weren't any other iomap patches pending for this release, which probably also played a role" * tag 'iomap-5.17' of git://git.infradead.org/users/willy/linux: (26 commits) iomap: Inline __iomap_zero_iter into its caller xfs: Support large folios iomap: Support large folios in invalidatepage iomap: Convert iomap_migrate_page() to use folios iomap: Convert iomap_add_to_ioend() to take a folio iomap: Simplify iomap_do_writepage() iomap: Simplify iomap_writepage_map() iomap,xfs: Convert ->discard_page to ->discard_folio iomap: Convert iomap_write_end_inline to take a folio iomap: Convert iomap_write_begin() and iomap_write_end() to folios iomap: Convert __iomap_zero_iter to use a folio iomap: Allow iomap_write_begin() to be called with the full length iomap: Convert iomap_page_mkwrite to use a folio iomap: Convert readahead and readpage to use a folio iomap: Convert iomap_read_inline_data to take a folio iomap: Use folio offsets instead of page offsets iomap: Convert bio completions to use folios iomap: Pass the iomap_page into iomap_set_range_uptodate iomap: Add iomap_invalidate_folio iomap: Convert iomap_releasepage to use a folio ...
2 parents 6020c20 + 4d7bd0e commit f079ab0

File tree

9 files changed

+389
-295
lines changed

9 files changed

+389
-295
lines changed

Documentation/core-api/kernel-api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ Accounting Framework
279279
Block Devices
280280
=============
281281

282+
.. kernel-doc:: include/linux/bio.h
282283
.. kernel-doc:: block/blk-core.c
283284
:export:
284285

block/bio.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,28 @@ int bio_add_page(struct bio *bio, struct page *page,
10351035
}
10361036
EXPORT_SYMBOL(bio_add_page);
10371037

1038+
/**
1039+
* bio_add_folio - Attempt to add part of a folio to a bio.
1040+
* @bio: BIO to add to.
1041+
* @folio: Folio to add.
1042+
* @len: How many bytes from the folio to add.
1043+
* @off: First byte in this folio to add.
1044+
*
1045+
* Filesystems that use folios can call this function instead of calling
1046+
* bio_add_page() for each page in the folio. If @off is bigger than
1047+
* PAGE_SIZE, this function can create a bio_vec that starts in a page
1048+
* after the bv_page. BIOs do not support folios that are 4GiB or larger.
1049+
*
1050+
* Return: Whether the addition was successful.
1051+
*/
1052+
bool bio_add_folio(struct bio *bio, struct folio *folio, size_t len,
1053+
size_t off)
1054+
{
1055+
if (len > UINT_MAX || off > UINT_MAX)
1056+
return 0;
1057+
return bio_add_page(bio, &folio->page, len, off) > 0;
1058+
}
1059+
10381060
void __bio_release_pages(struct bio *bio, bool mark_dirty)
10391061
{
10401062
struct bvec_iter_all iter_all;

fs/buffer.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,34 +1969,34 @@ iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh,
19691969
}
19701970
}
19711971

1972-
int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
1972+
int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
19731973
get_block_t *get_block, const struct iomap *iomap)
19741974
{
19751975
unsigned from = pos & (PAGE_SIZE - 1);
19761976
unsigned to = from + len;
1977-
struct inode *inode = page->mapping->host;
1977+
struct inode *inode = folio->mapping->host;
19781978
unsigned block_start, block_end;
19791979
sector_t block;
19801980
int err = 0;
19811981
unsigned blocksize, bbits;
19821982
struct buffer_head *bh, *head, *wait[2], **wait_bh=wait;
19831983

1984-
BUG_ON(!PageLocked(page));
1984+
BUG_ON(!folio_test_locked(folio));
19851985
BUG_ON(from > PAGE_SIZE);
19861986
BUG_ON(to > PAGE_SIZE);
19871987
BUG_ON(from > to);
19881988

1989-
head = create_page_buffers(page, inode, 0);
1989+
head = create_page_buffers(&folio->page, inode, 0);
19901990
blocksize = head->b_size;
19911991
bbits = block_size_bits(blocksize);
19921992

1993-
block = (sector_t)page->index << (PAGE_SHIFT - bbits);
1993+
block = (sector_t)folio->index << (PAGE_SHIFT - bbits);
19941994

19951995
for(bh = head, block_start = 0; bh != head || !block_start;
19961996
block++, block_start=block_end, bh = bh->b_this_page) {
19971997
block_end = block_start + blocksize;
19981998
if (block_end <= from || block_start >= to) {
1999-
if (PageUptodate(page)) {
1999+
if (folio_test_uptodate(folio)) {
20002000
if (!buffer_uptodate(bh))
20012001
set_buffer_uptodate(bh);
20022002
}
@@ -2016,20 +2016,20 @@ int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
20162016

20172017
if (buffer_new(bh)) {
20182018
clean_bdev_bh_alias(bh);
2019-
if (PageUptodate(page)) {
2019+
if (folio_test_uptodate(folio)) {
20202020
clear_buffer_new(bh);
20212021
set_buffer_uptodate(bh);
20222022
mark_buffer_dirty(bh);
20232023
continue;
20242024
}
20252025
if (block_end > to || block_start < from)
2026-
zero_user_segments(page,
2026+
folio_zero_segments(folio,
20272027
to, block_end,
20282028
block_start, from);
20292029
continue;
20302030
}
20312031
}
2032-
if (PageUptodate(page)) {
2032+
if (folio_test_uptodate(folio)) {
20332033
if (!buffer_uptodate(bh))
20342034
set_buffer_uptodate(bh);
20352035
continue;
@@ -2050,14 +2050,15 @@ int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
20502050
err = -EIO;
20512051
}
20522052
if (unlikely(err))
2053-
page_zero_new_buffers(page, from, to);
2053+
page_zero_new_buffers(&folio->page, from, to);
20542054
return err;
20552055
}
20562056

20572057
int __block_write_begin(struct page *page, loff_t pos, unsigned len,
20582058
get_block_t *get_block)
20592059
{
2060-
return __block_write_begin_int(page, pos, len, get_block, NULL);
2060+
return __block_write_begin_int(page_folio(page), pos, len, get_block,
2061+
NULL);
20612062
}
20622063
EXPORT_SYMBOL(__block_write_begin);
20632064

fs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static inline int emergency_thaw_bdev(struct super_block *sb)
3737
/*
3838
* buffer.c
3939
*/
40-
int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
40+
int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
4141
get_block_t *get_block, const struct iomap *iomap);
4242

4343
/*

0 commit comments

Comments
 (0)