From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752585AbcBCJzH (ORCPT ); Wed, 3 Feb 2016 04:55:07 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:39797 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbcBCJzE (ORCPT ); Wed, 3 Feb 2016 04:55:04 -0500 From: jiangyiwen To: , CC: , , =?UTF-8?B?THVrw6HFoSBDemVybmVy?= , , "Qijiang (Joseph, Euler)" Subject: [dm-devel] [PATCH] block: do not return -EOPNOTSUPP only when issue a discard request Message-ID: <56B1CE5C.10201@huawei.com> Date: Wed, 3 Feb 2016 17:54:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.16.168] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.56B1CE6E.004A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 97b8c49be2fe16516ba04b2131548fd9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- 1.8.4.3