All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3]block/loop: handle discard/zeroout error
@ 2017-08-30 19:17 Shaohua Li
  2017-08-30 19:17 ` [PATCH 1/3] block/loop: don't hijack error number Shaohua Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shaohua Li @ 2017-08-30 19:17 UTC (permalink / raw)
  To: linux-block; +Cc: Kernel-team, axboe

Fix some problems when setting up loop device with a block device as back file
and create/mount ext4 in the loop device.

BTW: blkdev_issue_zeroout retries if we immediately find the device doesn't
support zeroout, but it doesn't retry if submit_bio_wait returns -EOPNOTSUPP.
Is this correct behavior?

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/loop: suppress discard IO error message

 drivers/block/loop.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

-- 
2.9.5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] block/loop: don't hijack error number
  2017-08-30 19:17 [PATCH 0/3]block/loop: handle discard/zeroout error Shaohua Li
@ 2017-08-30 19:17 ` Shaohua Li
  2017-08-30 19:17 ` [PATCH 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES Shaohua Li
  2017-08-30 19:17 ` [PATCH 3/3] block/loop: suppress discard IO error message Shaohua Li
  2 siblings, 0 replies; 4+ messages in thread
From: Shaohua Li @ 2017-08-30 19:17 UTC (permalink / raw)
  To: linux-block; +Cc: Kernel-team, axboe

If the bio returns -EOPNOTSUPP, we shouldn't hijack it and return -EIO

Signed-off-by: Shaohua Li <shli@fb.com>
---
 drivers/block/loop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ef83349..054dccc 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -464,7 +464,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_complete(struct kiocb *iocb, long ret, long ret2)
@@ -1725,7 +1725,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] 4+ messages in thread

* [PATCH 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES
  2017-08-30 19:17 [PATCH 0/3]block/loop: handle discard/zeroout error Shaohua Li
  2017-08-30 19:17 ` [PATCH 1/3] block/loop: don't hijack error number Shaohua Li
@ 2017-08-30 19:17 ` Shaohua Li
  2017-08-30 19:17 ` [PATCH 3/3] block/loop: suppress discard IO error message Shaohua Li
  2 siblings, 0 replies; 4+ messages in thread
From: Shaohua Li @ 2017-08-30 19:17 UTC (permalink / raw)
  To: linux-block; +Cc: Kernel-team, axboe

REQ_OP_WRITE_ZEROES really means zero the data. And the 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>
---
 drivers/block/loop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 054dccc..a30aa45 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -430,6 +430,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] 4+ messages in thread

* [PATCH 3/3] block/loop: suppress discard IO error message
  2017-08-30 19:17 [PATCH 0/3]block/loop: handle discard/zeroout error Shaohua Li
  2017-08-30 19:17 ` [PATCH 1/3] block/loop: don't hijack error number Shaohua Li
  2017-08-30 19:17 ` [PATCH 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES Shaohua Li
@ 2017-08-30 19:17 ` Shaohua Li
  2 siblings, 0 replies; 4+ messages in thread
From: Shaohua Li @ 2017-08-30 19:17 UTC (permalink / raw)
  To: linux-block; +Cc: Kernel-team, axboe

We don't know if fallocate really supports FALLOC_FL_PUNCH_HOLE till
fallocate is called. If it doesn't support, loop will return
-EOPNOTSUPP and we seee a lot of error message printed by
blk_update_request. Failure for discard IO isn't a problem, so we just
return 0 in loop which will suppress the IO error message

Signed-off-by: Shaohua Li <shli@fb.com>
---
 drivers/block/loop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index a30aa45..15f51e3 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -441,6 +441,9 @@ static int lo_discard(struct loop_device *lo, struct request *rq, loff_t pos)
 	ret = file->f_op->fallocate(file, mode, pos, blk_rq_bytes(rq));
 	if (unlikely(ret && ret != -EINVAL && ret != -EOPNOTSUPP))
 		ret = -EIO;
+
+	if (req_op(rq) == REQ_OP_DISCARD && ret == -EOPNOTSUPP)
+		ret = 0;
  out:
 	return ret;
 }
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-30 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30 19:17 [PATCH 0/3]block/loop: handle discard/zeroout error Shaohua Li
2017-08-30 19:17 ` [PATCH 1/3] block/loop: don't hijack error number Shaohua Li
2017-08-30 19:17 ` [PATCH 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES Shaohua Li
2017-08-30 19:17 ` [PATCH 3/3] block/loop: suppress discard IO error message Shaohua Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.