Thread (8 messages) 8 messages, 2 authors, 2017-09-07

Re: [PATCH V2 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES

From: Ming Lei <tom.leiming@gmail.com>
Date: 2017-09-07 09:05:35

On Thu, Sep 7, 2017 at 8:13 AM, Shaohua Li [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Shaohua Li <redacted>

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 <redacted>
---
 drivers/block/loop.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 715b762..8934e25 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
Looks fine,

      Reviewed-by: Ming Lei [off-list ref]


-- 
Ming Lei
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help