summaryrefslogtreecommitdiff
path: root/linux/blkdev.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-03-01 01:45:15 -0900
committerKent Overstreet <kent.overstreet@gmail.com>2017-03-09 09:14:11 -0900
commita17f7bcec7ed810a247c24e56229af8f43a9a6ae (patch)
tree1b2d60b21661bd2991324e3efaa83b3cdd87a783 /linux/blkdev.c
parent171ee48e57be78f4e95954c99851553fa523bf91 (diff)
cmd_migrate
Diffstat (limited to 'linux/blkdev.c')
-rw-r--r--linux/blkdev.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/linux/blkdev.c b/linux/blkdev.c
index 0bae9b0d..93459d0b 100644
--- a/linux/blkdev.c
+++ b/linux/blkdev.c
@@ -20,8 +20,14 @@ int submit_bio_wait(struct bio *bio)
ssize_t ret;
unsigned i;
- if (bio->bi_opf & REQ_PREFLUSH)
- fdatasync(bio->bi_bdev->bd_fd);
+ if (bio->bi_opf & REQ_PREFLUSH) {
+ ret = fdatasync(bio->bi_bdev->bd_fd);
+ if (ret) {
+ fprintf(stderr, "fsync error: %s\n",
+ strerror(errno));
+ return -EIO;
+ }
+ }
i = 0;
bio_for_each_segment(bv, bio, iter)
@@ -49,10 +55,22 @@ int submit_bio_wait(struct bio *bio)
BUG();
}
- if (bio->bi_opf & REQ_FUA)
- fdatasync(bio->bi_bdev->bd_fd);
+ if (ret != bio->bi_iter.bi_size) {
+ fprintf(stderr, "IO error: %li (%s)\n",
+ ret, strerror(errno));
+ return -EIO;
+ }
- return ret == bio->bi_iter.bi_size ? 0 : -EIO;
+ if (bio->bi_opf & REQ_FUA) {
+ ret = fdatasync(bio->bi_bdev->bd_fd);
+ if (ret) {
+ fprintf(stderr, "fsync error: %s\n",
+ strerror(errno));
+ return -EIO;
+ }
+ }
+
+ return 0;
}
void generic_make_request(struct bio *bio)