diff options
author | Gao Xiang <gaoxiang25@huawei.com> | 2019-03-25 11:40:09 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-03-26 05:51:17 +0900 |
commit | 14a56ec65bab351a3e1535882f15a6af21912cac (patch) | |
tree | 8af07e8df2d60d33f44c03e0902932970abcf09c /drivers/staging/erofs/data.c | |
parent | d61fbb6b163494219335a25812dab9acb291c4b6 (diff) |
staging: erofs: support IO read error injection
Used to simulate disk IO read error for testing fatal
error tolerance.
Here are the details,
1) use bio->bi_private to indicate super_block
for non-compressed bios since some (mainly meta)
pages can be of the corresponding bdev inode;
2) get super_block dynamically for compressed bios,
therefore it could not inject bios full of staging
pages, yet it doesn't affect the normal usage.
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/erofs/data.c')
-rw-r--r-- | drivers/staging/erofs/data.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 526e0dbea5b5..0714061ba888 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -17,11 +17,17 @@ static inline void read_endio(struct bio *bio) { + struct super_block *const sb = bio->bi_private; int i; struct bio_vec *bvec; - const blk_status_t err = bio->bi_status; + blk_status_t err = bio->bi_status; struct bvec_iter_all iter_all; + if (time_to_inject(EROFS_SB(sb), FAULT_READ_IO)) { + erofs_show_injection_info(FAULT_READ_IO); + err = BLK_STS_IOERR; + } + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; @@ -63,7 +69,7 @@ repeat: if (!PageUptodate(page)) { struct bio *bio; - bio = erofs_grab_bio(sb, blkaddr, 1, read_endio, nofail); + bio = erofs_grab_bio(sb, blkaddr, 1, sb, read_endio, nofail); if (IS_ERR(bio)) { DBG_BUGON(nofail); err = PTR_ERR(bio); @@ -188,7 +194,8 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, unsigned int nblocks, bool ra) { - struct inode *inode = mapping->host; + struct inode *const inode = mapping->host; + struct super_block *const sb = inode->i_sb; erofs_off_t current_block = (erofs_off_t)page->index; int err; @@ -280,9 +287,8 @@ submit_bio_retry: if (nblocks > BIO_MAX_PAGES) nblocks = BIO_MAX_PAGES; - bio = erofs_grab_bio(inode->i_sb, - blknr, nblocks, read_endio, false); - + bio = erofs_grab_bio(sb, blknr, nblocks, sb, + read_endio, false); if (IS_ERR(bio)) { err = PTR_ERR(bio); bio = NULL; |