提交 b349feb3 编写于 作者: C Christoph Hellwig 提交者: NeilBrown

raid5-cache: refactor bio allocation

Split out a helper to allocate a bio for log writes.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NShaohua Li <shli@fb.com>
Signed-off-by: NNeilBrown <neilb@suse.com>
上级 22581f58
......@@ -276,11 +276,25 @@ static void r5l_submit_current_io(struct r5l_log *log)
}
}
static struct bio *r5l_bio_alloc(struct r5l_log *log, struct r5l_io_unit *io)
{
struct bio *bio = bio_kmalloc(GFP_NOIO | __GFP_NOFAIL, BIO_MAX_PAGES);
bio->bi_rw = WRITE;
bio->bi_bdev = log->rdev->bdev;
bio->bi_iter.bi_sector = log->log_start;
bio->bi_end_io = r5l_log_endio;
bio->bi_private = io;
bio_list_add(&io->bios, bio);
atomic_inc(&io->pending_io);
return bio;
}
static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
{
struct r5l_io_unit *io;
struct r5l_meta_block *block;
struct bio *bio;
io = r5l_alloc_io_unit(log);
......@@ -294,17 +308,8 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
io->meta_offset = sizeof(struct r5l_meta_block);
io->seq = log->seq;
bio = bio_kmalloc(GFP_NOIO | __GFP_NOFAIL, BIO_MAX_PAGES);
io->current_bio = bio;
bio->bi_rw = WRITE;
bio->bi_bdev = log->rdev->bdev;
bio->bi_iter.bi_sector = log->log_start;
bio_add_page(bio, io->meta_page, PAGE_SIZE, 0);
bio->bi_end_io = r5l_log_endio;
bio->bi_private = io;
bio_list_add(&io->bios, bio);
atomic_inc(&io->pending_io);
io->current_bio = r5l_bio_alloc(log, io);
bio_add_page(io->current_bio, io->meta_page, PAGE_SIZE, 0);
log->seq++;
log->log_start = r5l_ring_add(log, log->log_start, BLOCK_SECTORS);
......@@ -358,19 +363,9 @@ static void r5l_append_payload_page(struct r5l_log *log, struct page *page)
struct r5l_io_unit *io = log->current_io;
alloc_bio:
if (!io->current_bio) {
struct bio *bio;
bio = bio_kmalloc(GFP_NOIO | __GFP_NOFAIL, BIO_MAX_PAGES);
bio->bi_rw = WRITE;
bio->bi_bdev = log->rdev->bdev;
bio->bi_iter.bi_sector = log->log_start;
bio->bi_end_io = r5l_log_endio;
bio->bi_private = io;
bio_list_add(&io->bios, bio);
atomic_inc(&io->pending_io);
io->current_bio = bio;
}
if (!io->current_bio)
io->current_bio = r5l_bio_alloc(log, io);
if (!bio_add_page(io->current_bio, page, PAGE_SIZE, 0)) {
io->current_bio = NULL;
goto alloc_bio;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册