From patchwork Fri Feb 5 07:10:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiangyiwen X-Patchwork-Id: 8232081 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0BD50BEEED for ; Fri, 5 Feb 2016 07:10:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CE6620357 for ; Fri, 5 Feb 2016 07:10:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5501E20395 for ; Fri, 5 Feb 2016 07:10:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbcBEHKz (ORCPT ); Fri, 5 Feb 2016 02:10:55 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:47113 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752164AbcBEHKz (ORCPT ); Fri, 5 Feb 2016 02:10:55 -0500 Received: from 172.24.1.50 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.50]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DAZ26007; Fri, 05 Feb 2016 15:10:48 +0800 (CST) Received: from [127.0.0.1] (10.177.16.168) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Fri, 5 Feb 2016 15:10:47 +0800 To: , CC: "Martin K. Petersen" , =?UTF-8?B?THVrw6HFoSBDemVybmVy?= From: jiangyiwen Subject: [PATCH] block: do not return -EOPNOTSUPP only when issue a discard request Message-ID: <56B44AF6.2090003@huawei.com> Date: Fri, 5 Feb 2016 15:10:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-Originating-IP: [10.177.16.168] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.56B44AFB.000A, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 49b8f0f7f000acbe9aa6823d3bf71398 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.2 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 8af1954d172a("blkdev: Do not return -EOPNOTSUPP if discard is supported") only solve the situation of discard, because When applications issue a discard request to device, they can't expect deterministic behaviour. However, WRITE SAME should not ignore error with EOPNOTSUPP, because if applications issue WRITE SAME requests to device, it should return deterministic results to applications according to the T10 standard, or else it will cause an inconsistent state between upper layer and bottom layer. So ignoring error with EOPNOTSUPP only in discard situation. Signed-off-by: Yiwen Jiang Reviewed-by: Lukas Czerner Reviewed-by: Martin K. Petersen --- block/blk-lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 9ebf653..e4f02f1 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -19,7 +19,9 @@ static void bio_batch_end_io(struct bio *bio) { struct bio_batch *bb = bio->bi_private; - if (bio->bi_error && bio->bi_error != -EOPNOTSUPP) + /* ignore -EOPNOTSUPP only when issue a discard request */ + if (bio->bi_error && (!(bio->bi_rw & REQ_DISCARD) || + (bio->bi_error != -EOPNOTSUPP))) bb->error = bio->bi_error; if (atomic_dec_and_test(&bb->done)) complete(bb->wait);