diff options
author | Christoph Hellwig <hch@lst.de> | 2017-06-03 03:38:06 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-06-09 11:27:32 -0400 |
commit | 4e4cbee93d56137ebff722be022cae5f70ef84fb (patch) | |
tree | 4fa7345155599fc6bdd653fca8c5224ddf90a5be /fs/btrfs/inode.c | |
parent | fc17b6534eb8395f0b3133eb31d87deec32c642b (diff) |
block: switch bios to blk_status_t
Replace bi_error with a new bi_status to allow for a clear conversion.
Note that device mapper overloaded bi_error with a private value, which
we'll have to keep arround at least for now and thus propagate to a
proper blk_status_t value.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 758b2666885e..ea7cae1003eb 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -842,13 +842,12 @@ retry: | |||
842 | NULL, EXTENT_LOCKED | EXTENT_DELALLOC, | 842 | NULL, EXTENT_LOCKED | EXTENT_DELALLOC, |
843 | PAGE_UNLOCK | PAGE_CLEAR_DIRTY | | 843 | PAGE_UNLOCK | PAGE_CLEAR_DIRTY | |
844 | PAGE_SET_WRITEBACK); | 844 | PAGE_SET_WRITEBACK); |
845 | ret = btrfs_submit_compressed_write(inode, | 845 | if (btrfs_submit_compressed_write(inode, |
846 | async_extent->start, | 846 | async_extent->start, |
847 | async_extent->ram_size, | 847 | async_extent->ram_size, |
848 | ins.objectid, | 848 | ins.objectid, |
849 | ins.offset, async_extent->pages, | 849 | ins.offset, async_extent->pages, |
850 | async_extent->nr_pages); | 850 | async_extent->nr_pages)) { |
851 | if (ret) { | ||
852 | struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; | 851 | struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; |
853 | struct page *p = async_extent->pages[0]; | 852 | struct page *p = async_extent->pages[0]; |
854 | const u64 start = async_extent->start; | 853 | const u64 start = async_extent->start; |
@@ -1901,11 +1900,11 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset, | |||
1901 | * At IO completion time the cums attached on the ordered extent record | 1900 | * At IO completion time the cums attached on the ordered extent record |
1902 | * are inserted into the btree | 1901 | * are inserted into the btree |
1903 | */ | 1902 | */ |
1904 | static int __btrfs_submit_bio_start(struct inode *inode, struct bio *bio, | 1903 | static blk_status_t __btrfs_submit_bio_start(struct inode *inode, |
1905 | int mirror_num, unsigned long bio_flags, | 1904 | struct bio *bio, int mirror_num, unsigned long bio_flags, |
1906 | u64 bio_offset) | 1905 | u64 bio_offset) |
1907 | { | 1906 | { |
1908 | int ret = 0; | 1907 | blk_status_t ret = 0; |
1909 | 1908 | ||
1910 | ret = btrfs_csum_one_bio(inode, bio, 0, 0); | 1909 | ret = btrfs_csum_one_bio(inode, bio, 0, 0); |
1911 | BUG_ON(ret); /* -ENOMEM */ | 1910 | BUG_ON(ret); /* -ENOMEM */ |
@@ -1920,16 +1919,16 @@ static int __btrfs_submit_bio_start(struct inode *inode, struct bio *bio, | |||
1920 | * At IO completion time the cums attached on the ordered extent record | 1919 | * At IO completion time the cums attached on the ordered extent record |
1921 | * are inserted into the btree | 1920 | * are inserted into the btree |
1922 | */ | 1921 | */ |
1923 | static int __btrfs_submit_bio_done(struct inode *inode, struct bio *bio, | 1922 | static blk_status_t __btrfs_submit_bio_done(struct inode *inode, |
1924 | int mirror_num, unsigned long bio_flags, | 1923 | struct bio *bio, int mirror_num, unsigned long bio_flags, |
1925 | u64 bio_offset) | 1924 | u64 bio_offset) |
1926 | { | 1925 | { |
1927 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 1926 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
1928 | int ret; | 1927 | blk_status_t ret; |
1929 | 1928 | ||
1930 | ret = btrfs_map_bio(fs_info, bio, mirror_num, 1); | 1929 | ret = btrfs_map_bio(fs_info, bio, mirror_num, 1); |
1931 | if (ret) { | 1930 | if (ret) { |
1932 | bio->bi_error = ret; | 1931 | bio->bi_status = ret; |
1933 | bio_endio(bio); | 1932 | bio_endio(bio); |
1934 | } | 1933 | } |
1935 | return ret; | 1934 | return ret; |
@@ -1939,14 +1938,14 @@ static int __btrfs_submit_bio_done(struct inode *inode, struct bio *bio, | |||
1939 | * extent_io.c submission hook. This does the right thing for csum calculation | 1938 | * extent_io.c submission hook. This does the right thing for csum calculation |
1940 | * on write, or reading the csums from the tree before a read | 1939 | * on write, or reading the csums from the tree before a read |
1941 | */ | 1940 | */ |
1942 | static int btrfs_submit_bio_hook(struct inode *inode, struct bio *bio, | 1941 | static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio, |
1943 | int mirror_num, unsigned long bio_flags, | 1942 | int mirror_num, unsigned long bio_flags, |
1944 | u64 bio_offset) | 1943 | u64 bio_offset) |
1945 | { | 1944 | { |
1946 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 1945 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
1947 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1946 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1948 | enum btrfs_wq_endio_type metadata = BTRFS_WQ_ENDIO_DATA; | 1947 | enum btrfs_wq_endio_type metadata = BTRFS_WQ_ENDIO_DATA; |
1949 | int ret = 0; | 1948 | blk_status_t ret = 0; |
1950 | int skip_sum; | 1949 | int skip_sum; |
1951 | int async = !atomic_read(&BTRFS_I(inode)->sync_writers); | 1950 | int async = !atomic_read(&BTRFS_I(inode)->sync_writers); |
1952 | 1951 | ||
@@ -1991,8 +1990,8 @@ mapit: | |||
1991 | ret = btrfs_map_bio(fs_info, bio, mirror_num, 0); | 1990 | ret = btrfs_map_bio(fs_info, bio, mirror_num, 0); |
1992 | 1991 | ||
1993 | out: | 1992 | out: |
1994 | if (ret < 0) { | 1993 | if (ret) { |
1995 | bio->bi_error = ret; | 1994 | bio->bi_status = ret; |
1996 | bio_endio(bio); | 1995 | bio_endio(bio); |
1997 | } | 1996 | } |
1998 | return ret; | 1997 | return ret; |
@@ -8037,7 +8036,7 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) | |||
8037 | struct bio_vec *bvec; | 8036 | struct bio_vec *bvec; |
8038 | int i; | 8037 | int i; |
8039 | 8038 | ||
8040 | if (bio->bi_error) | 8039 | if (bio->bi_status) |
8041 | goto end; | 8040 | goto end; |
8042 | 8041 | ||
8043 | ASSERT(bio->bi_vcnt == 1); | 8042 | ASSERT(bio->bi_vcnt == 1); |
@@ -8116,7 +8115,7 @@ static void btrfs_retry_endio(struct bio *bio) | |||
8116 | int ret; | 8115 | int ret; |
8117 | int i; | 8116 | int i; |
8118 | 8117 | ||
8119 | if (bio->bi_error) | 8118 | if (bio->bi_status) |
8120 | goto end; | 8119 | goto end; |
8121 | 8120 | ||
8122 | uptodate = 1; | 8121 | uptodate = 1; |
@@ -8141,8 +8140,8 @@ end: | |||
8141 | bio_put(bio); | 8140 | bio_put(bio); |
8142 | } | 8141 | } |
8143 | 8142 | ||
8144 | static int __btrfs_subio_endio_read(struct inode *inode, | 8143 | static blk_status_t __btrfs_subio_endio_read(struct inode *inode, |
8145 | struct btrfs_io_bio *io_bio, int err) | 8144 | struct btrfs_io_bio *io_bio, blk_status_t err) |
8146 | { | 8145 | { |
8147 | struct btrfs_fs_info *fs_info; | 8146 | struct btrfs_fs_info *fs_info; |
8148 | struct bio_vec *bvec; | 8147 | struct bio_vec *bvec; |
@@ -8184,7 +8183,7 @@ try_again: | |||
8184 | io_bio->mirror_num, | 8183 | io_bio->mirror_num, |
8185 | btrfs_retry_endio, &done); | 8184 | btrfs_retry_endio, &done); |
8186 | if (ret) { | 8185 | if (ret) { |
8187 | err = ret; | 8186 | err = errno_to_blk_status(ret); |
8188 | goto next; | 8187 | goto next; |
8189 | } | 8188 | } |
8190 | 8189 | ||
@@ -8211,8 +8210,8 @@ next: | |||
8211 | return err; | 8210 | return err; |
8212 | } | 8211 | } |
8213 | 8212 | ||
8214 | static int btrfs_subio_endio_read(struct inode *inode, | 8213 | static blk_status_t btrfs_subio_endio_read(struct inode *inode, |
8215 | struct btrfs_io_bio *io_bio, int err) | 8214 | struct btrfs_io_bio *io_bio, blk_status_t err) |
8216 | { | 8215 | { |
8217 | bool skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; | 8216 | bool skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; |
8218 | 8217 | ||
@@ -8232,7 +8231,7 @@ static void btrfs_endio_direct_read(struct bio *bio) | |||
8232 | struct inode *inode = dip->inode; | 8231 | struct inode *inode = dip->inode; |
8233 | struct bio *dio_bio; | 8232 | struct bio *dio_bio; |
8234 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); | 8233 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); |
8235 | int err = bio->bi_error; | 8234 | blk_status_t err = bio->bi_status; |
8236 | 8235 | ||
8237 | if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) | 8236 | if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) |
8238 | err = btrfs_subio_endio_read(inode, io_bio, err); | 8237 | err = btrfs_subio_endio_read(inode, io_bio, err); |
@@ -8243,11 +8242,11 @@ static void btrfs_endio_direct_read(struct bio *bio) | |||
8243 | 8242 | ||
8244 | kfree(dip); | 8243 | kfree(dip); |
8245 | 8244 | ||
8246 | dio_bio->bi_error = bio->bi_error; | 8245 | dio_bio->bi_status = bio->bi_status; |
8247 | dio_end_io(dio_bio); | 8246 | dio_end_io(dio_bio); |
8248 | 8247 | ||
8249 | if (io_bio->end_io) | 8248 | if (io_bio->end_io) |
8250 | io_bio->end_io(io_bio, err); | 8249 | io_bio->end_io(io_bio, blk_status_to_errno(err)); |
8251 | bio_put(bio); | 8250 | bio_put(bio); |
8252 | } | 8251 | } |
8253 | 8252 | ||
@@ -8299,20 +8298,20 @@ static void btrfs_endio_direct_write(struct bio *bio) | |||
8299 | struct bio *dio_bio = dip->dio_bio; | 8298 | struct bio *dio_bio = dip->dio_bio; |
8300 | 8299 | ||
8301 | __endio_write_update_ordered(dip->inode, dip->logical_offset, | 8300 | __endio_write_update_ordered(dip->inode, dip->logical_offset, |
8302 | dip->bytes, !bio->bi_error); | 8301 | dip->bytes, !bio->bi_status); |
8303 | 8302 | ||
8304 | kfree(dip); | 8303 | kfree(dip); |
8305 | 8304 | ||
8306 | dio_bio->bi_error = bio->bi_error; | 8305 | dio_bio->bi_status = bio->bi_status; |
8307 | dio_end_io(dio_bio); | 8306 | dio_end_io(dio_bio); |
8308 | bio_put(bio); | 8307 | bio_put(bio); |
8309 | } | 8308 | } |
8310 | 8309 | ||
8311 | static int __btrfs_submit_bio_start_direct_io(struct inode *inode, | 8310 | static blk_status_t __btrfs_submit_bio_start_direct_io(struct inode *inode, |
8312 | struct bio *bio, int mirror_num, | 8311 | struct bio *bio, int mirror_num, |
8313 | unsigned long bio_flags, u64 offset) | 8312 | unsigned long bio_flags, u64 offset) |
8314 | { | 8313 | { |
8315 | int ret; | 8314 | blk_status_t ret; |
8316 | ret = btrfs_csum_one_bio(inode, bio, offset, 1); | 8315 | ret = btrfs_csum_one_bio(inode, bio, offset, 1); |
8317 | BUG_ON(ret); /* -ENOMEM */ | 8316 | BUG_ON(ret); /* -ENOMEM */ |
8318 | return 0; | 8317 | return 0; |
@@ -8321,7 +8320,7 @@ static int __btrfs_submit_bio_start_direct_io(struct inode *inode, | |||
8321 | static void btrfs_end_dio_bio(struct bio *bio) | 8320 | static void btrfs_end_dio_bio(struct bio *bio) |
8322 | { | 8321 | { |
8323 | struct btrfs_dio_private *dip = bio->bi_private; | 8322 | struct btrfs_dio_private *dip = bio->bi_private; |
8324 | int err = bio->bi_error; | 8323 | blk_status_t err = bio->bi_status; |
8325 | 8324 | ||
8326 | if (err) | 8325 | if (err) |
8327 | btrfs_warn(BTRFS_I(dip->inode)->root->fs_info, | 8326 | btrfs_warn(BTRFS_I(dip->inode)->root->fs_info, |
@@ -8351,7 +8350,7 @@ static void btrfs_end_dio_bio(struct bio *bio) | |||
8351 | if (dip->errors) { | 8350 | if (dip->errors) { |
8352 | bio_io_error(dip->orig_bio); | 8351 | bio_io_error(dip->orig_bio); |
8353 | } else { | 8352 | } else { |
8354 | dip->dio_bio->bi_error = 0; | 8353 | dip->dio_bio->bi_status = 0; |
8355 | bio_endio(dip->orig_bio); | 8354 | bio_endio(dip->orig_bio); |
8356 | } | 8355 | } |
8357 | out: | 8356 | out: |
@@ -8368,14 +8367,14 @@ static struct bio *btrfs_dio_bio_alloc(struct block_device *bdev, | |||
8368 | return bio; | 8367 | return bio; |
8369 | } | 8368 | } |
8370 | 8369 | ||
8371 | static inline int btrfs_lookup_and_bind_dio_csum(struct inode *inode, | 8370 | static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode, |
8372 | struct btrfs_dio_private *dip, | 8371 | struct btrfs_dio_private *dip, |
8373 | struct bio *bio, | 8372 | struct bio *bio, |
8374 | u64 file_offset) | 8373 | u64 file_offset) |
8375 | { | 8374 | { |
8376 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); | 8375 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); |
8377 | struct btrfs_io_bio *orig_io_bio = btrfs_io_bio(dip->orig_bio); | 8376 | struct btrfs_io_bio *orig_io_bio = btrfs_io_bio(dip->orig_bio); |
8378 | int ret; | 8377 | blk_status_t ret; |
8379 | 8378 | ||
8380 | /* | 8379 | /* |
8381 | * We load all the csum data we need when we submit | 8380 | * We load all the csum data we need when we submit |
@@ -8406,7 +8405,7 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, | |||
8406 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 8405 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
8407 | struct btrfs_dio_private *dip = bio->bi_private; | 8406 | struct btrfs_dio_private *dip = bio->bi_private; |
8408 | bool write = bio_op(bio) == REQ_OP_WRITE; | 8407 | bool write = bio_op(bio) == REQ_OP_WRITE; |
8409 | int ret; | 8408 | blk_status_t ret; |
8410 | 8409 | ||
8411 | if (async_submit) | 8410 | if (async_submit) |
8412 | async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers); | 8411 | async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers); |
@@ -8649,7 +8648,7 @@ free_ordered: | |||
8649 | * callbacks - they require an allocated dip and a clone of dio_bio. | 8648 | * callbacks - they require an allocated dip and a clone of dio_bio. |
8650 | */ | 8649 | */ |
8651 | if (io_bio && dip) { | 8650 | if (io_bio && dip) { |
8652 | io_bio->bi_error = -EIO; | 8651 | io_bio->bi_status = BLK_STS_IOERR; |
8653 | bio_endio(io_bio); | 8652 | bio_endio(io_bio); |
8654 | /* | 8653 | /* |
8655 | * The end io callbacks free our dip, do the final put on io_bio | 8654 | * The end io callbacks free our dip, do the final put on io_bio |
@@ -8668,7 +8667,7 @@ free_ordered: | |||
8668 | unlock_extent(&BTRFS_I(inode)->io_tree, file_offset, | 8667 | unlock_extent(&BTRFS_I(inode)->io_tree, file_offset, |
8669 | file_offset + dio_bio->bi_iter.bi_size - 1); | 8668 | file_offset + dio_bio->bi_iter.bi_size - 1); |
8670 | 8669 | ||
8671 | dio_bio->bi_error = -EIO; | 8670 | dio_bio->bi_status = BLK_STS_IOERR; |
8672 | /* | 8671 | /* |
8673 | * Releases and cleans up our dio_bio, no need to bio_put() | 8672 | * Releases and cleans up our dio_bio, no need to bio_put() |
8674 | * nor bio_endio()/bio_io_error() against dio_bio. | 8673 | * nor bio_endio()/bio_io_error() against dio_bio. |