From patchwork Fri Mar 31 16:33:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "hch@lst.de" X-Patchwork-Id: 9656787 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 503E060349 for ; Fri, 31 Mar 2017 16:35:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4354A28574 for ; Fri, 31 Mar 2017 16:35:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38587286E0; Fri, 31 Mar 2017 16:35:06 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 EC60328574 for ; Fri, 31 Mar 2017 16:35:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933526AbdCaQfB (ORCPT ); Fri, 31 Mar 2017 12:35:01 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:41337 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933395AbdCaQd4 (ORCPT ); Fri, 31 Mar 2017 12:33:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sJTyd6wpANd2FZX47M5Wmxsnf4CyA3289WKWc4wrchU=; b=Ff9Uena/dbMieMiVMrXMOYnfR 8lBSpJHF6qJAojb9QaMD4FK2qpdTkC+VJrbJPu1WxlCT5vgeToOx5fRKTiIBUkDtdFy1uim8gczqR QrZfdOymvjj3gfOYcQZrxjQ5hsUAf6MX2Z++M99gSHRGbkfncq/gtEtb+qhKKgHAyPPUUdCSu1gtu q38O0O+Kw/Wxy3vGNH7lXXRnJD7lLy6shFo25YmbpZQF2ic73F4YWKlTLkQBSEVPhfkXrBFrylII9 xnqczMugUkO8tijoRDgL5Y1gBW5qQKtRMuWHLsl5exwlqi58gzSorEIEVKemTIP2Vevw0fqmP6m5O l/DlFCBwg==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1ctzUm-0003sG-Ry; Fri, 31 Mar 2017 16:33:53 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, agk@redhat.com, snitzer@redhat.com, shli@kernel.org, philipp.reisner@linbit.com, lars.ellenberg@linbit.com Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com, linux-raid@vger.kernel.org Subject: [PATCH 13/25] block_dev: use blkdev_issue_zerout for hole punches Date: Fri, 31 Mar 2017 18:33:01 +0200 Message-Id: <20170331163313.31821-14-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170331163313.31821-1-hch@lst.de> References: <20170331163313.31821-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 This gets us support for non-discard efficient write of zeroes (e.g. NVMe) and prepare for removing the discard_zeroes_data flag. Also remove a pointless discard support check, which is done in blkdev_issue_discard already. Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- fs/block_dev.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 2f704c3a816f..e405d8e58e31 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -2069,7 +2069,6 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, loff_t len) { struct block_device *bdev = I_BDEV(bdev_file_inode(file)); - struct request_queue *q = bdev_get_queue(bdev); struct address_space *mapping; loff_t end = start + len - 1; loff_t isize; @@ -2108,15 +2107,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, GFP_KERNEL, BLKDEV_ZERO_NOUNMAP); break; case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE: - /* Only punch if the device can do zeroing discard. */ - if (!blk_queue_discard(q) || !q->limits.discard_zeroes_data) - return -EOPNOTSUPP; - error = blkdev_issue_discard(bdev, start >> 9, len >> 9, - GFP_KERNEL, 0); + error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9, + GFP_KERNEL, BLKDEV_ZERO_NOFALLBACK); break; case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE: - if (!blk_queue_discard(q)) - return -EOPNOTSUPP; error = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL, 0); break;