diff mbox

[V2,3/3] block/loop: suppress discard IO error message

Message ID 93626ad390557b27c872bb8325485c9d56cc4e06.1504742003.git.shli@fb.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shaohua Li Sept. 7, 2017, 12:13 a.m. UTC
From: Shaohua Li <shli@fb.com>

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 see a lot of error message printed by blk_update_request. Failure
for discard IO isn't a big 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(+)

Comments

Ming Lei Sept. 7, 2017, 9:16 a.m. UTC | #1
On Thu, Sep 7, 2017 at 8:13 AM, Shaohua Li <shli@kernel.org> wrote:
> From: Shaohua Li <shli@fb.com>
>
> 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 see a lot of error message printed by blk_update_request. Failure
> for discard IO isn't a big problem, so we just return 0 in loop which
> will suppress the IO error message.

Setting RQF_QUIET for discard IO should be more clean for suppressing error,
and upper layer can get the failure notification too.
Shaohua Li Sept. 7, 2017, 9:52 p.m. UTC | #2
On Thu, Sep 07, 2017 at 05:16:21PM +0800, Ming Lei wrote:
> On Thu, Sep 7, 2017 at 8:13 AM, Shaohua Li <shli@kernel.org> wrote:
> > From: Shaohua Li <shli@fb.com>
> >
> > 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 see a lot of error message printed by blk_update_request. Failure
> > for discard IO isn't a big problem, so we just return 0 in loop which
> > will suppress the IO error message.
> 
> Setting RQF_QUIET for discard IO should be more clean for suppressing error,
> and upper layer can get the failure notification too.

Hmm, forgot why I didn't do this, did consider it before. Probably because
nobody check the return value of discard request. Probably we should skip the
error message for all discard IO in block layer.

I'll repost a patch to fix this issue.

Thanks,
Shaohua
diff mbox

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 8934e25..9d4545f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -437,6 +437,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;
 }