From patchwork Wed Aug 30 19:17:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 9930677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7644B603B4 for ; Wed, 30 Aug 2017 19:17:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 666DC28765 for ; Wed, 30 Aug 2017 19:17:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B5342877B; Wed, 30 Aug 2017 19:17:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1309F28775 for ; Wed, 30 Aug 2017 19:17:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750975AbdH3TRX (ORCPT ); Wed, 30 Aug 2017 15:17:23 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:42230 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750890AbdH3TRV (ORCPT ); Wed, 30 Aug 2017 15:17:21 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.21/8.16.0.21) with SMTP id v7UJGvDR003702 for ; Wed, 30 Aug 2017 12:17:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=K7MEm2tNcQZPAQrE9iMdOJ6Lnpdj1rfVioXjn0aliwg=; b=BFnupUMVcpMCWd+9POuTTxak0/Iq35w1BM89cEJ4rwKAcm4EW8BLZKOEjr72oz4xLCQQ DXH5opI7T5oqab1ZYsGxMas1L/cIuVPdNf6v6KR+Gfq1kQcJk8rcdD4ZFrIgxLWo4E+f hsgWDSX+TGL4gfvwNpKAsmFnAQbwUVg3GnM= Received: from mail.thefacebook.com ([199.201.64.23]) by m0001303.ppops.net with ESMTP id 2cnywks06r-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:17:21 -0700 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB09.TheFacebook.com (192.168.16.19) with Microsoft SMTP Server id 14.3.319.2; Wed, 30 Aug 2017 12:17:20 -0700 X-ThriftRelayHost: devbig638.prn2.facebook.com Received: by devbig638.prn2.facebook.com (Postfix, from userid 11222) id 3C47342408DE; Wed, 30 Aug 2017 12:17:19 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Shaohua Li Smtp-Origin-Hostname: devbig638.prn2.facebook.com To: CC: , Smtp-Origin-Cluster: prn2c22 Subject: [PATCH 2/3] block/loop: use FALLOC_FL_ZERO_RANGE for REQ_OP_WRITE_ZEROES Date: Wed, 30 Aug 2017 12:17:17 -0700 Message-ID: X-Mailer: git-send-email 2.9.5 In-Reply-To: References: X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_08:, , signatures=0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;