From patchwork Wed May 4 00:38:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 9008881 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 925629F1C1 for ; Wed, 4 May 2016 00:38:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C77E72037E for ; Wed, 4 May 2016 00:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EABE020377 for ; Wed, 4 May 2016 00:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756865AbcEDAiI (ORCPT ); Tue, 3 May 2016 20:38:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48822 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756849AbcEDAiI (ORCPT ); Tue, 3 May 2016 20:38:08 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22FCB8112B; Wed, 4 May 2016 00:38:07 +0000 (UTC) Received: from localhost (vpn-49-116.rdu2.redhat.com [10.10.49.116]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u440c4QI005010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 May 2016 20:38:05 -0400 From: Mike Snitzer To: axboe@fb.com Cc: Christoph Hellwig , linux-block@vger.kernel.org, Ming Lin , Mike Snitzer Subject: [PATCH] block: allow early return of -EOPNOTSUPP from blkdev_issue_discard Date: Tue, 3 May 2016 20:38:03 -0400 Message-Id: <1462322283-72777-1-git-send-email-snitzer@redhat.com> In-Reply-To: <1460832928-15514-3-git-send-email-hch@lst.de> References: <1460832928-15514-3-git-send-email-hch@lst.de> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 38f25255330 ("block: add __blkdev_issue_discard") incorrectly disallowed the return of -EOPNOTSUPP if the device didn't support discard (or secure discard). Fixes: 38f25255330 ("block: add __blkdev_issue_discard") Signed-off-by: Mike Snitzer --- block/blk-lib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index ccbce2b..23d7f30 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -109,11 +109,14 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, blk_start_plug(&plug); ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, type, &bio); - if (!ret && bio) + if (!ret && bio) { ret = submit_bio_wait(type, bio); + if (ret == -EOPNOTSUPP) + ret = 0; + } blk_finish_plug(&plug); - return ret != -EOPNOTSUPP ? ret : 0; + return ret; } EXPORT_SYMBOL(blkdev_issue_discard);