Skip to content

Commit 536da2a

Browse files
Matthew Wilcox (Oracle)Andreas Gruenbacher
authored andcommitted
gfs2: Convert gfs2_end_log_write_bh() to work on a folio
gfs2_end_log_write() has to handle bios which consist of both pages which belong to folios and pages which were allocated from a mempool and do not belong to a folio. It would be cleaner to have separate endio handlers which handle each type, but it's not clear to me whether that's even possible. This patch is slightly forward-looking in that page_folio() cannot currently return NULL, but it will return NULL in the future for pages which do not belong to a folio. This was the last user of page_has_buffers(), so remove it. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 4082976 commit 536da2a

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

fs/gfs2/lops.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ u64 gfs2_log_bmap(struct gfs2_jdesc *jd, unsigned int lblock)
157157
/**
158158
* gfs2_end_log_write_bh - end log write of pagecache data with buffers
159159
* @sdp: The superblock
160-
* @bvec: The bio_vec
160+
* @folio: The folio
161+
* @offset: The first byte within the folio that completed
162+
* @size: The number of bytes that completed
161163
* @error: The i/o status
162164
*
163165
* This finds the relevant buffers and unlocks them and sets the
@@ -166,17 +168,13 @@ u64 gfs2_log_bmap(struct gfs2_jdesc *jd, unsigned int lblock)
166168
* that is pinned in the pagecache.
167169
*/
168170

169-
static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp,
170-
struct bio_vec *bvec,
171-
blk_status_t error)
171+
static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, struct folio *folio,
172+
size_t offset, size_t size, blk_status_t error)
172173
{
173174
struct buffer_head *bh, *next;
174-
struct page *page = bvec->bv_page;
175-
unsigned size;
176175

177-
bh = page_buffers(page);
178-
size = bvec->bv_len;
179-
while (bh_offset(bh) < bvec->bv_offset)
176+
bh = folio_buffers(folio);
177+
while (bh_offset(bh) < offset)
180178
bh = bh->b_this_page;
181179
do {
182180
if (error)
@@ -186,7 +184,7 @@ static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp,
186184
size -= bh->b_size;
187185
brelse(bh);
188186
bh = next;
189-
} while(bh && size);
187+
} while (bh && size);
190188
}
191189

192190
/**
@@ -203,7 +201,6 @@ static void gfs2_end_log_write(struct bio *bio)
203201
{
204202
struct gfs2_sbd *sdp = bio->bi_private;
205203
struct bio_vec *bvec;
206-
struct page *page;
207204
struct bvec_iter_all iter_all;
208205

209206
if (bio->bi_status) {
@@ -217,9 +214,12 @@ static void gfs2_end_log_write(struct bio *bio)
217214
}
218215

219216
bio_for_each_segment_all(bvec, bio, iter_all) {
220-
page = bvec->bv_page;
221-
if (page_has_buffers(page))
222-
gfs2_end_log_write_bh(sdp, bvec, bio->bi_status);
217+
struct page *page = bvec->bv_page;
218+
struct folio *folio = page_folio(page);
219+
220+
if (folio && folio_buffers(folio))
221+
gfs2_end_log_write_bh(sdp, folio, bvec->bv_offset,
222+
bvec->bv_len, bio->bi_status);
223223
else
224224
mempool_free(page, gfs2_page_pool);
225225
}

include/linux/buffer_head.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ static inline unsigned long bh_offset(const struct buffer_head *bh)
182182
BUG_ON(!PagePrivate(page)); \
183183
((struct buffer_head *)page_private(page)); \
184184
})
185-
#define page_has_buffers(page) PagePrivate(page)
186185
#define folio_buffers(folio) folio_get_private(folio)
187186

188187
void buffer_check_dirty_writeback(struct folio *folio,

0 commit comments

Comments
 (0)