mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
md: simplify sync_page_io
Use an on-stack bio and biovec for the single page synchronous I/O. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Song Liu <song@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Acked-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
a78f18da66
commit
32637385b8
@ -1021,29 +1021,29 @@ int md_super_wait(struct mddev *mddev)
|
||||
int sync_page_io(struct md_rdev *rdev, sector_t sector, int size,
|
||||
struct page *page, int op, int op_flags, bool metadata_op)
|
||||
{
|
||||
struct bio *bio = md_bio_alloc_sync(rdev->mddev);
|
||||
int ret;
|
||||
struct bio bio;
|
||||
struct bio_vec bvec;
|
||||
|
||||
bio_init(&bio, &bvec, 1);
|
||||
|
||||
if (metadata_op && rdev->meta_bdev)
|
||||
bio_set_dev(bio, rdev->meta_bdev);
|
||||
bio_set_dev(&bio, rdev->meta_bdev);
|
||||
else
|
||||
bio_set_dev(bio, rdev->bdev);
|
||||
bio_set_op_attrs(bio, op, op_flags);
|
||||
bio_set_dev(&bio, rdev->bdev);
|
||||
bio.bi_opf = op | op_flags;
|
||||
if (metadata_op)
|
||||
bio->bi_iter.bi_sector = sector + rdev->sb_start;
|
||||
bio.bi_iter.bi_sector = sector + rdev->sb_start;
|
||||
else if (rdev->mddev->reshape_position != MaxSector &&
|
||||
(rdev->mddev->reshape_backwards ==
|
||||
(sector >= rdev->mddev->reshape_position)))
|
||||
bio->bi_iter.bi_sector = sector + rdev->new_data_offset;
|
||||
bio.bi_iter.bi_sector = sector + rdev->new_data_offset;
|
||||
else
|
||||
bio->bi_iter.bi_sector = sector + rdev->data_offset;
|
||||
bio_add_page(bio, page, size, 0);
|
||||
bio.bi_iter.bi_sector = sector + rdev->data_offset;
|
||||
bio_add_page(&bio, page, size, 0);
|
||||
|
||||
submit_bio_wait(bio);
|
||||
submit_bio_wait(&bio);
|
||||
|
||||
ret = !bio->bi_status;
|
||||
bio_put(bio);
|
||||
return ret;
|
||||
return !bio.bi_status;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sync_page_io);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user