* [PATCH V3 1/3] block/loop: don't hijack error number
2017-10-04 14:52 [PATCH V3 0/3] block/loop: handle discard/zeroout error Shaohua Li
@ 2017-10-04 14:52 ` Shaohua Li
2017-10-04 14:52 ` [PATCH V3 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES Shaohua Li
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Shaohua Li @ 2017-10-04 14:52 UTC (permalink / raw)
To: linux-block; +Cc: ming.lei, axboe, Shaohua Li
From: Shaohua Li <shli@fb.com>
If the bio returns -EOPNOTSUPP, we shouldn't hijack it and return -EIO
Signed-off-by: Shaohua Li <shli@fb.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/loop.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index bc8e615..6aa739f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -460,7 +460,7 @@ static void lo_complete_rq(struct request *rq)
zero_fill_bio(bio);
}
- blk_mq_end_request(rq, cmd->ret < 0 ? BLK_STS_IOERR : BLK_STS_OK);
+ blk_mq_end_request(rq, errno_to_blk_status(cmd->ret));
}
static void lo_rw_aio_do_completion(struct loop_cmd *cmd)
@@ -478,7 +478,7 @@ static void lo_rw_aio_complete(struct kiocb *iocb, long ret, long ret2)
if (cmd->css)
css_put(cmd->css);
- cmd->ret = ret;
+ cmd->ret = ret > 0 ? 0 : ret;
lo_rw_aio_do_completion(cmd);
}
@@ -1719,7 +1719,7 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
failed:
/* complete non-aio request */
if (!cmd->use_aio || ret) {
- cmd->ret = ret ? -EIO : 0;
+ cmd->ret = ret;
blk_mq_complete_request(cmd->rq);
}
}
--
2.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH V3 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES
2017-10-04 14:52 [PATCH V3 0/3] block/loop: handle discard/zeroout error Shaohua Li
2017-10-04 14:52 ` [PATCH V3 1/3] block/loop: don't hijack error number Shaohua Li
@ 2017-10-04 14:52 ` Shaohua Li
2017-10-04 14:52 ` [PATCH V3 3/3] block: don't print message for discard error Shaohua Li
2017-10-19 5:13 ` [PATCH V3 0/3] block/loop: handle discard/zeroout error Shaohua Li
3 siblings, 0 replies; 6+ messages in thread
From: Shaohua Li @ 2017-10-04 14:52 UTC (permalink / raw)
To: linux-block; +Cc: ming.lei, axboe, Shaohua Li
From: Shaohua Li <shli@fb.com>
REQ_OP_WRITE_ZEROES really means zero the data. And in blkdev_fallocate,
FALLOC_FL_ZERO_RANGE will retry but FALLOC_FL_PUNCH_HOLE not, even loop
request doesn't have BLKDEV_ZERO_NOFALLBACK set.
Signed-off-by: Shaohua Li <shli@fb.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/loop.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 6aa739f..7269341 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -426,6 +426,9 @@ static int lo_discard(struct loop_device *lo, struct request *rq, loff_t pos)
int mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
int ret;
+ if (req_op(rq) == REQ_OP_WRITE_ZEROES)
+ mode = FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE;
+
if ((!file->f_op->fallocate) || lo->lo_encrypt_key_size) {
ret = -EOPNOTSUPP;
goto out;
--
2.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH V3 3/3] block: don't print message for discard error
2017-10-04 14:52 [PATCH V3 0/3] block/loop: handle discard/zeroout error Shaohua Li
2017-10-04 14:52 ` [PATCH V3 1/3] block/loop: don't hijack error number Shaohua Li
2017-10-04 14:52 ` [PATCH V3 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES Shaohua Li
@ 2017-10-04 14:52 ` Shaohua Li
2017-10-07 4:48 ` Ming Lei
2017-10-19 5:13 ` [PATCH V3 0/3] block/loop: handle discard/zeroout error Shaohua Li
3 siblings, 1 reply; 6+ messages in thread
From: Shaohua Li @ 2017-10-04 14:52 UTC (permalink / raw)
To: linux-block; +Cc: ming.lei, axboe, Shaohua Li
From: Shaohua Li <shli@fb.com>
discard error isn't fatal, don't flood discard error messages.
Suggested-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Shaohua Li <shli@fb.com>
---
block/blk-core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/blk-core.c b/block/blk-core.c
index 14f7674..adb064a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3090,6 +3090,8 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
rq->__data_len = bio->bi_iter.bi_size;
rq->bio = rq->biotail = bio;
+ if (bio_op(bio) == REQ_OP_DISCARD)
+ rq->rq_flags |= RQF_QUIET;
if (bio->bi_disk)
rq->rq_disk = bio->bi_disk;
}
--
2.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V3 0/3] block/loop: handle discard/zeroout error
2017-10-04 14:52 [PATCH V3 0/3] block/loop: handle discard/zeroout error Shaohua Li
` (2 preceding siblings ...)
2017-10-04 14:52 ` [PATCH V3 3/3] block: don't print message for discard error Shaohua Li
@ 2017-10-19 5:13 ` Shaohua Li
3 siblings, 0 replies; 6+ messages in thread
From: Shaohua Li @ 2017-10-19 5:13 UTC (permalink / raw)
To: linux-block; +Cc: ming.lei, axboe, Shaohua Li
On Wed, Oct 04, 2017 at 07:52:42AM -0700, Shaohua Li wrote:
> From: Shaohua Li <shli@fb.com>
>
> Fix some problems when setting up loop device with a block device as back file
> and create/mount ext4 in the loop device.
Jens,
can you look at these patches?
Thanks,
Shaohua
>
> Thanks,
> Shaohua
>
> Shaohua Li (3):
> block/loop: don't hijack error number
> block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES
> block: don't print message for discard error
>
> block/blk-core.c | 2 ++
> drivers/block/loop.c | 9 ++++++---
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> --
> 2.9.5
>
^ permalink raw reply [flat|nested] 6+ messages in thread