Linux block layer
 help / color / mirror / Atom feed
From: Shaohua Li <shli@kernel.org>
To: linux-block@vger.kernel.org
Cc: ming.lei@redhat.com, axboe@kernel.dk, Shaohua Li <shli@fb.com>
Subject: [PATCH V3 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES
Date: Wed,  4 Oct 2017 07:52:44 -0700	[thread overview]
Message-ID: <b2a8123d49958e882ea0fb0be6573adbf40be5f7.1507072136.git.shli@fb.com> (raw)
In-Reply-To: <cover.1507072136.git.shli@fb.com>
In-Reply-To: <cover.1507072136.git.shli@fb.com>

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

  parent reply	other threads:[~2017-10-04 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-10-04 14:52 ` [PATCH V3 3/3] block: don't print message for discard error 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2a8123d49958e882ea0fb0be6573adbf40be5f7.1507072136.git.shli@fb.com \
    --to=shli@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=shli@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox