Message ID | d2ceb45ef504bb78ba19725fc55eff327ff9f3ed.1504120418.git.shli@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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;
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(+)