Skip to content

Commit 465e5e6

Browse files
Panky-codesakpm00
authored andcommitted
fs/buffer: add folio_set_bh helper
Patch series "convert create_page_buffers to folio_create_buffers". One of the first kernel panic we hit when we try to increase the block size > 4k is inside create_page_buffers()[1]. Even though buffer.c function do not support large folios (folios > PAGE_SIZE) at the moment, these changes are required when we want to remove that constraint. This patch (of 4): The folio version of set_bh_page(). This is required to convert create_page_buffers() to folio_create_buffers() later in the series. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Pankaj Raghav <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Luis Chamberlain <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 760aee0 commit 465e5e6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

fs/buffer.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,21 @@ void set_bh_page(struct buffer_head *bh,
14851485
}
14861486
EXPORT_SYMBOL(set_bh_page);
14871487

1488+
void folio_set_bh(struct buffer_head *bh, struct folio *folio,
1489+
unsigned long offset)
1490+
{
1491+
bh->b_folio = folio;
1492+
BUG_ON(offset >= folio_size(folio));
1493+
if (folio_test_highmem(folio))
1494+
/*
1495+
* This catches illegal uses and preserves the offset:
1496+
*/
1497+
bh->b_data = (char *)(0 + offset);
1498+
else
1499+
bh->b_data = folio_address(folio) + offset;
1500+
}
1501+
EXPORT_SYMBOL(folio_set_bh);
1502+
14881503
/*
14891504
* Called when truncating a buffer on a page completely.
14901505
*/

include/linux/buffer_head.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ void mark_buffer_write_io_error(struct buffer_head *bh);
196196
void touch_buffer(struct buffer_head *bh);
197197
void set_bh_page(struct buffer_head *bh,
198198
struct page *page, unsigned long offset);
199+
void folio_set_bh(struct buffer_head *bh, struct folio *folio,
200+
unsigned long offset);
199201
bool try_to_free_buffers(struct folio *);
200202
struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
201203
bool retry);

0 commit comments

Comments
 (0)