diff options
| author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2026-05-28 20:31:46 +0300 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-06-04 11:28:10 +0300 |
| commit | 15dfe154126743baaf3be669cdec893f3f174118 (patch) | |
| tree | 6a9e0cb90c77839104f3556ddf63500ec7ff5a60 | |
| parent | ac75b922bb67cc8edb52006c9346dc0ca91d04c8 (diff) | |
| download | linux-15dfe154126743baaf3be669cdec893f3f174118.tar.xz | |
buffer: Change calling convention for end_buffer_read_sync()
Unify end_buffer_read_sync() and __end_buffer_read_notouch()
by requiring the caller put the refcount on the buffer. The only caller
is in the gfs2_meta_read() path, and there we can put the refcount
after locking the buffer.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20260528173150.1093780-34-willy@infradead.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
| -rw-r--r-- | fs/buffer.c | 28 | ||||
| -rw-r--r-- | fs/gfs2/meta_io.c | 2 |
2 files changed, 10 insertions, 20 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index ccda92920175..db604c0e54d4 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -157,15 +157,15 @@ bool bio_endio_bh(struct bio *bio, struct buffer_head **bhp) } EXPORT_SYMBOL(bio_endio_bh); -/* - * End-of-IO handler helper function which does not touch the bh after - * unlocking it. - * Note: unlock_buffer() sort-of does touch the bh after unlocking it, but - * a race there is benign: unlock_buffer() only use the bh's address for - * hashing after unlocking the buffer, so it doesn't actually touch the bh - * itself. +/** + * end_buffer_read_sync - Handle buffer reads finishing + * @bh: The buffer. + * @uptodate: True if the read was successful. + * + * If a buffer is read through a mechanism that isn't bh_submit(), you + * can call this function to finish the read. */ -static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate) +void end_buffer_read_sync(struct buffer_head *bh, int uptodate) { if (uptodate) { set_buffer_uptodate(bh); @@ -175,16 +175,6 @@ static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate) } unlock_buffer(bh); } - -/* - * Default synchronous end-of-IO handler.. Just mark it up-to-date and - * unlock the buffer. - */ -void end_buffer_read_sync(struct buffer_head *bh, int uptodate) -{ - put_bh(bh); - __end_buffer_read_notouch(bh, uptodate); -} EXPORT_SYMBOL(end_buffer_read_sync); /** @@ -198,7 +188,7 @@ void bh_end_read(struct bio *bio) { struct buffer_head *bh; bool uptodate = bio_endio_bh(bio, &bh); - __end_buffer_read_notouch(bh, uptodate); + end_buffer_read_sync(bh, uptodate); } EXPORT_SYMBOL(bh_end_read); diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 4895bb010cfb..a87cfbf0df38 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -286,10 +286,10 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, lock_buffer(bh); if (buffer_uptodate(bh)) { unlock_buffer(bh); - brelse(bh); } else { bhs[num++] = bh; } + brelse(bh); } gfs2_submit_bhs(REQ_OP_READ | REQ_META | REQ_PRIO, bhs, num); |
