Skip to content

Commit 25f12e4

Browse files
konisakpm00
authored andcommitted
nilfs2: convert segment buffer to be folio-based
Patch series "nilfs2: Finish folio conversion". This series converts all remaining page structure references in nilfs2 to folio-based, except for nilfs_copy_buffer function, which was converted to use folios in advance for cross-fs page flags cleanup. This prioritizes folio conversion, and does not include buffer head reference reduction, nor does it support for block sizes larger than the system page size. The first eight patches in this series mainly convert each of the nilfs2-specific metadata implementations to use folios. The last four patches, by Matthew Wilcox, eliminate aops writepage callbacks and convert the remaining page structure references to folio-based. This part reflects some corrections to the patch series posted by Matthew. This patch (of 12): In the segment buffer (log buffer) implementation, two parts of the block buffer, CRC calculation and bio preparation, are still page-based, so convert them to folio-based. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ryusuke Konishi <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 3ad563b commit 25f12e4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

fs/nilfs2/segbuf.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ static void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
205205
{
206206
struct buffer_head *bh;
207207
struct nilfs_segment_summary *raw_sum;
208-
void *kaddr;
209208
u32 crc;
210209

211210
bh = list_entry(segbuf->sb_segsum_buffers.next, struct buffer_head,
@@ -220,9 +219,13 @@ static void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
220219
crc = crc32_le(crc, bh->b_data, bh->b_size);
221220
}
222221
list_for_each_entry(bh, &segbuf->sb_payload_buffers, b_assoc_buffers) {
223-
kaddr = kmap_local_page(bh->b_page);
224-
crc = crc32_le(crc, kaddr + bh_offset(bh), bh->b_size);
225-
kunmap_local(kaddr);
222+
size_t offset = offset_in_folio(bh->b_folio, bh->b_data);
223+
unsigned char *from;
224+
225+
/* Do not support block sizes larger than PAGE_SIZE */
226+
from = kmap_local_folio(bh->b_folio, offset);
227+
crc = crc32_le(crc, from, bh->b_size);
228+
kunmap_local(from);
226229
}
227230
raw_sum->ss_datasum = cpu_to_le32(crc);
228231
}
@@ -374,7 +377,7 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
374377
struct nilfs_write_info *wi,
375378
struct buffer_head *bh)
376379
{
377-
int len, err;
380+
int err;
378381

379382
BUG_ON(wi->nr_vecs <= 0);
380383
repeat:
@@ -385,8 +388,8 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
385388
(wi->nilfs->ns_blocksize_bits - 9);
386389
}
387390

388-
len = bio_add_page(wi->bio, bh->b_page, bh->b_size, bh_offset(bh));
389-
if (len == bh->b_size) {
391+
if (bio_add_folio(wi->bio, bh->b_folio, bh->b_size,
392+
offset_in_folio(bh->b_folio, bh->b_data))) {
390393
wi->end++;
391394
return 0;
392395
}

0 commit comments

Comments
 (0)