Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iomap: share code between iomap_dio_bio_end_io and iomap_finish_ioend_direct

Refactor the two per-bio completion handlers to share common code using
a new helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Tested-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
e2fcff5b 2631c946

+19 -23
+19 -23
fs/iomap/direct-io.c
··· 211 211 iomap_dio_complete_work(&dio->aio.work); 212 212 } 213 213 214 - void iomap_dio_bio_end_io(struct bio *bio) 214 + static void __iomap_dio_bio_end_io(struct bio *bio, bool inline_completion) 215 215 { 216 216 struct iomap_dio *dio = bio->bi_private; 217 217 bool should_dirty = (dio->flags & IOMAP_DIO_DIRTY); 218 218 219 - if (bio->bi_status) 220 - iomap_dio_set_error(dio, blk_status_to_errno(bio->bi_status)); 221 - 222 - if (atomic_dec_and_test(&dio->ref)) 219 + if (atomic_dec_and_test(&dio->ref)) { 220 + /* 221 + * Avoid another context switch for the completion when already 222 + * called from the ioend completion workqueue. 223 + */ 224 + if (inline_completion) 225 + dio->flags &= ~IOMAP_DIO_COMP_WORK; 223 226 iomap_dio_done(dio); 227 + } 224 228 225 229 if (should_dirty) { 226 230 bio_check_pages_dirty(bio); ··· 233 229 bio_put(bio); 234 230 } 235 231 } 232 + 233 + void iomap_dio_bio_end_io(struct bio *bio) 234 + { 235 + struct iomap_dio *dio = bio->bi_private; 236 + 237 + if (bio->bi_status) 238 + iomap_dio_set_error(dio, blk_status_to_errno(bio->bi_status)); 239 + __iomap_dio_bio_end_io(bio, false); 240 + } 236 241 EXPORT_SYMBOL_GPL(iomap_dio_bio_end_io); 237 242 238 243 u32 iomap_finish_ioend_direct(struct iomap_ioend *ioend) 239 244 { 240 245 struct iomap_dio *dio = ioend->io_bio.bi_private; 241 - bool should_dirty = (dio->flags & IOMAP_DIO_DIRTY); 242 246 u32 vec_count = ioend->io_bio.bi_vcnt; 243 247 244 248 if (ioend->io_error) 245 249 iomap_dio_set_error(dio, ioend->io_error); 246 - 247 - if (atomic_dec_and_test(&dio->ref)) { 248 - /* 249 - * Try to avoid another context switch for the completion given 250 - * that we are already called from the ioend completion 251 - * workqueue. 252 - */ 253 - dio->flags &= ~IOMAP_DIO_COMP_WORK; 254 - iomap_dio_done(dio); 255 - } 256 - 257 - if (should_dirty) { 258 - bio_check_pages_dirty(&ioend->io_bio); 259 - } else { 260 - bio_release_pages(&ioend->io_bio, false); 261 - bio_put(&ioend->io_bio); 262 - } 250 + __iomap_dio_bio_end_io(&ioend->io_bio, true); 263 251 264 252 /* 265 253 * Return the number of bvecs completed as even direct I/O completions