Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3060325pxa; Sat, 8 Aug 2020 08:19:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQnAyiHYgexMG1vom6ficH+/7UpfmhyEoDTujiQAaT/06/gtAguPrNgA/djqP44gEfW82y X-Received: by 2002:a50:9fc9:: with SMTP id c67mr13912297edf.69.1596899973200; Sat, 08 Aug 2020 08:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596899973; cv=none; d=google.com; s=arc-20160816; b=a3onZuEVpv01bwFRcviFb+n6ZLLgxer/0rdqBuxn5dLwkg8xnPsTc5x8jpLre0seVR aF1oL2DH4Z1WU7KBkQu8Psmo67uT4ZGlM4rIwchroNUnQonJ+4XsQqFnhATuJo4135oA M1M62DczI4rUtTwQYh/TuNQLOBNGaRJogdrATvriuKav5ZegZOHWBs16yGOgOySLSinN DXABJb4+UbyXtAxsxwYOJ8o55CemfiCgzWGcsKa06N0oSNmO6yLss6Gq9BQuXdUL3d6u ECCKwVMJrDqtYfdY+J9RY2Gj1ubked2aVeWCC8IielKftO3tJGnhYVqywvCpiji1NqgJ q0Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qJwp4wnUgXLTGVssPheYmOVZwxMatcOK9tqEBP4dMLE=; b=Kk2ETTrIMu1wob6puSQxCQ6J2GlVVwZh2hCJskdJW35LSG9SgcUcJxqdB9ZZNfwlaV Z4vRuKtvqCsSRwHkHQwaC89hQhCCXAlPL1v7mOp83a12bsKgD7UjQKRnzUP0Hl+Tgqm+ UFiGlIc/dEfLPMh6OrnnnGVbpWxl+8cU5SsHb+PMeSzXH6TNqesYmjTdIve6vIyPLsWA /ZR3LUeGi64L/K6wPsYNhEYBU9vsGsKERY4WMkY3hFQiw0CzxQNSoatKHDbeMGn7NE7T 902CC/q5Q4JR6aZtWJzL68ZJSzRW2TjTZDvYD7jAcR2fuQLIzn8A/ws+6Qb0ebHI8RjX rKbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si8330203eda.255.2020.08.08.08.18.52; Sat, 08 Aug 2020 08:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726248AbgHHPSW (ORCPT + 99 others); Sat, 8 Aug 2020 11:18:22 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:59997 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726233AbgHHPST (ORCPT ); Sat, 8 Aug 2020 11:18:19 -0400 Received: from callcc.thunk.org (pool-96-230-252-158.bstnma.fios.verizon.net [96.230.252.158]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 078FI1iI007523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 8 Aug 2020 11:18:02 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 8BEB4420263; Sat, 8 Aug 2020 11:18:01 -0400 (EDT) Date: Sat, 8 Aug 2020 11:18:01 -0400 From: tytso@mit.edu To: Wang Shilong Cc: Ext4 Developers List , Wang Shilong , Shuichi Ihara , Andreas Dilger Subject: Re: [PATCH v3 1/2] ext4: introduce EXT4_BG_WAS_TRIMMED to optimize trim Message-ID: <20200808151801.GA284779@mit.edu> References: <1592831677-13945-1-git-send-email-wangshilong1991@gmail.com> <20200806044703.GC7657@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sat, Aug 08, 2020 at 09:29:50AM +0800, Wang Shilong wrote: > > I suppose the question is whether the sysadmin really wants unused > > blocks to be discarded, either to not leak blocks in some kind of > > thin-provisioned storage device, or if the sysadmin is depending on > > the discard for some kind of security/privacy application (because > > they know that a particular storage device actually has reliable, > > secure discards), and how does that get balanced with sysadmins think > > performance of fstrim is more important, especially if the device is > > really slow at doing discard. > > Yup, that is good point, for our case, fstrim could take hours to complete > as it needs extra IO for disk arrays, so we really want repeated fstrim. > > So what do you think extra mount option or a feature bit in the superblock. > In default, we still keep ext4 in previous behavior, but once turned > on it, we have this optimized "inaccurate" optimizations. So what I was thinking was we could define a new flag which would be set in es->s_flags in the on-disk superblock: #define EXT2_FLAGS_PERSISTENT_TRIM_TRACKING 0x0008 If this flag is set, then the EXT4_BG_WAS_TRIMMED flags will be honored; otherwise, they will be ignored when FITRIM is executed and the block group will be unconditionally trimmed. The advantage of doing this way is that we don't need to allocate a new feature bit, and older versions of e2fsck won't have heartburn over seeing a feature bit it doesn't understand. I also suspect this is something that the system administrator will either always want enabled or disabled, so it's better to make it be a tunable to be set via tune2fs. The other thing we could do is to define a new variant of the FITRIM ioctl which will also force the unconditional trimming of the block groups, so that an administrator can force trim all of the block groups without needing to mess with mounting and unmounting the superblock. What do you think? - Ted