From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from verein.lst.de ([213.95.11.211]:50827 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750770AbcFVH7S (ORCPT ); Wed, 22 Jun 2016 03:59:18 -0400 Date: Wed, 22 Jun 2016 09:52:17 +0200 From: Christoph Hellwig To: "Martin K. Petersen" Cc: Christoph Hellwig , axboe@fb.com, shli@fb.com, snitzer@redhat.com, sitsofe@yahoo.com, linux-block@vger.kernel.org Subject: Re: [PATCH] block: introduce BLKDEV_DISCARD_ZERO to fix zeroout Message-ID: <20160622075217.GA31610@lst.de> References: <1466418523-22552-1-git-send-email-hch@lst.de> <20160621124059.GC1689@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: Sender: linux-block-owner@vger.kernel.org List-Id: linux-block@vger.kernel.org On Tue, Jun 21, 2016 at 10:02:10PM -0400, Martin K. Petersen wrote: > In 9082e87bfbf8 ("block: remove struct bio_batch") you changed the error > return for blkdev_issue_write_same() to look like the one for discard: > > - if (bb.error) > - return bb.error; > - return ret; > + if (bio) > + ret = submit_bio_wait(REQ_WRITE | REQ_WRITE_SAME, bio); > + return ret != -EOPNOTSUPP ? ret : 0; > > It's not a problem for SCSI since I'd be returning -EREMOTEIO. But if a > stacking driver returns -EOPNOTSUPP in response to a WRITE SAME request > we'll get data corruption. Oh, I see what you mean, but I disagree with the analysis. Unlike discard outside the zeroout path, write same is a data integrity operation. Just like in the zero out case turning an EOPNOTSUPP into 0 will get you data corruption, as the caller will see a successful return for an operation that did not actually write data to disk. Same is true for writing the actual zeroes in __blkdev_issue_zeroout. Re stacking drivers and discard / write same: why does blk_set_stacking_limits set discard_zeroes_data to 1 and max_write_same_sectors to UINT_MAX? These seem like inherently dangerous defaults.