Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1083202pxa; Wed, 5 Aug 2020 22:07:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4On+uRGVobVTwrrXGTMrajan7SxWyLa/wDRUWEvbNRGRSoxb1A3x1IBahR5S1QjaBHEt6 X-Received: by 2002:a17:906:7715:: with SMTP id q21mr2560920ejm.251.1596690443365; Wed, 05 Aug 2020 22:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596690443; cv=none; d=google.com; s=arc-20160816; b=fKdFYbnnsUTBE2x5pdjenVhgmopS+yBxIiNR5PIMHoIAWSj1rJ/zCuB7BPUtrb7/0l FSsVAUtqMR0P+wlKXnS5RPcr8qQ5iH7LZVZpJAUf81MokUwSNENgOE8PJFh4fynzJQ9l ofYG8sYHyYMZZv0HPW6ytxnj3KVbqR8vWnZEG4ivXJxQ3qwLG9mIazBF/57pTPkU1zjt djJMEHbUh2yJKClJGbW8boMxUcqvbMZxl9S+XO9ZVrn7XmAyTDqDYqyt3bQFL5W8yTFS DSrTssBE5e9ekzhtejJuTtFNBwtxf+TZADVB6/xvDNx8u+q6v2XAuzDHFcnt8sNsbajc 0D+g== 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=Im3ASxlq5/ky/sOmxJKugMJnxi9Ut0ZVK1k+eXFm9BQ=; b=tpQ+q+Vlc5wqCqvF/PP2WQhtLoaQ+HeifIt4iV1Dy8bTIsOjfWY+WDIwb9tj6wexyg 9CHADajVGFl4vsA4BPDkGo80YszODx9nHZcGxN3ip6EvTGsttQ11Mk7XQUO0DIUKlVgc sMWf/b0jm/kmE5ONrllMsWUx8LV6zwGRCpzDXfa6IoAsw4Hp6gVnwwU7KDh8EIUKlvM5 DD7HP7Yc4rTlxL1pcxyNcQ+n37uaP/P76/nFkUWPT6MdjV5x68zcQv97wSk52lSHAoDk qQgibjlNuT9sSWpIaRn+e5qwrJ5PspBCSKrhYW1Vl9lyv1RK6H+pUTt30OGQspwQQ9cy V0DA== 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 y15si2364055edu.119.2020.08.05.22.06.45; Wed, 05 Aug 2020 22:07:23 -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 S1726446AbgHFErM (ORCPT + 99 others); Thu, 6 Aug 2020 00:47:12 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:44156 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726225AbgHFErM (ORCPT ); Thu, 6 Aug 2020 00:47:12 -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 0764l3lb020269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Aug 2020 00:47:04 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 89DD4420263; Thu, 6 Aug 2020 00:47:03 -0400 (EDT) Date: Thu, 6 Aug 2020 00:47:03 -0400 From: tytso@mit.edu To: Wang Shilong Cc: linux-ext4@vger.kernel.org, Wang Shilong , Shuichi Ihara , Andreas Dilger Subject: Re: [PATCH v3 1/2] ext4: introduce EXT4_BG_WAS_TRIMMED to optimize trim Message-ID: <20200806044703.GC7657@mit.edu> References: <1592831677-13945-1-git-send-email-wangshilong1991@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1592831677-13945-1-git-send-email-wangshilong1991@gmail.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Jun 22, 2020 at 10:14:36PM +0900, Wang Shilong wrote: > From: Wang Shilong > > Currently WAS_TRIMMED flag is not persistent, whenever filesystem was > remounted, fstrim need walk all block groups again, the problem with > this is FSTRIM could be slow on very large LUN SSD based filesystem. > > To avoid this kind of problem, we introduce a block group flag > EXT4_BG_WAS_TRIMMED, the side effect of this is we need introduce > extra one block group dirty write after trimming block group. > > And When clearing TRIMMED flag, block group will be journalled > anyway, so it won't introduce any overhead. This persistent flag will not be accurate if there are blocks that were freed in the block group in the same transaction, before EXT4_BG_WAS_TRIMMED flag is set. That's because we can't trim (or reuse) a block which has been released until the transaction has committed, since if we crash before it is commited, the file unlink or truncate will not have happened, and so we can't trash the block until after the deallocation has been freed. This problem is also there with a non-persistent flag, granted; but when the file system is unmounted and remounted, we will eventually trim the block via a fstrim. When we make the flag persistent, the problem becomes worse, since it might mean that there are some blocks that have been released, that might never get discarded. 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. - Ted