Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:54458 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753165AbdHQTfR (ORCPT ); Thu, 17 Aug 2017 15:35:17 -0400 Date: Thu, 17 Aug 2017 21:35:13 +0200 From: Lukas Czerner To: "Martin K. Petersen" Cc: Christoph Hellwig , linux-fsdevel@vger.kernel.org, axboe@kernel.dk Subject: Re: [PATCH] block: reintroduce discard_zeroes_data sysfs file and BLKDISCARDZEROES Message-ID: <20170817193513.qa3gmsjc657vzedb@rh_laptop> References: <1502889581-19483-1-git-send-email-lczerner@redhat.com> <20170816151803.GB18932@lst.de> <20170816154845.y5kcq3ssbp7efduy@rh_laptop> <20170817074744.blcsel6w2ctbjjd4@rh_laptop> <20170817081711.GA24626@lst.de> <20170817084143.dimlwgkmk2ywsy7v@rh_laptop> <20170817095242.GA29150@lst.de> <20170817133557.dm2mybjrxpbzagyg@rh_laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Aug 17, 2017 at 01:47:13PM -0400, Martin K. Petersen wrote: > data in mkfs.ext4 > > to make sure that inode tables are zeroed after discard. > > The point is that you shouldn't have an if (discard_zeroes_data) > conditional in the first place. > > - If you need to dellocate a block range and you don't care about its > contents in the future, use BLKDISCARD / FL_PUNCH_HOLE. > > - If you need to zero a block range, use BLKZEROOUT / FL_ZERO_RANGE. > > So the mkfs usage model should essentially be: > > - DISCARD the entire partition/device block range > > - ZEROOUT the inode tables and other areas where you need zeroes on > future reads Yeah, that's what needs to be done generally, although as I said there are devices where after DISCARD we will read zeroes. Comments in __blkdev_issue_zeroout() even says it will unmap. In that case the discard or zeroout will be redundant and it can take quite some time on bigger devices. -Lukas > > And that should be the approach regardless of whether your device is a > disk drive, an SSD, an NVMe device a SCSI array or whatever. DISCARD old > contents, ZEROOUT the pieces you care about. No conditionals or trying > to do things differently based on device capabilities. > > -- > Martin K. Petersen Oracle Linux Engineering