Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp641505ybm; Wed, 27 May 2020 04:35:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL2qLtTKwsW5TWh8Ko9l4mtgXXZZRbiXaGGP4qzDRU71cFKva7QfYJ70q0eDjFbTJ6/Sjw X-Received: by 2002:a05:6402:30b4:: with SMTP id df20mr23497833edb.158.1590579333624; Wed, 27 May 2020 04:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590579333; cv=none; d=google.com; s=arc-20160816; b=wNM0OjgUdPx9h9GfCkDciRwzh9MDrRSPXniKmVBqFKEzMWr3ZmjEFqqZifJBesRh6u FxP0HQXyglnIdGKGHSbeUDHGSnVKtjOEw2jD8XCQxAmHWskNsGvjpn/79NFOSiQpx4NE 55jQfuQHgP4Zz77boCqhfgoSp8FKtl1N96Yf6MQ8abHTTfOo1xCNWnzWxHIBxQZx9StS y0UlI1kXC8qpOpSqShNJBuqWb6WTYSUeiM2439nXnk0ZDbrTp8ebE+l9LxWNGz222slq clYutavhlU0ZJXJDi4jD8KasNVpaHWp1q61wu7ygVG7uBRjIy/WQPad57Phtk1oJa+1s uAEQ== 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 :dkim-signature; bh=JKhlMLe/B6ecqLXqArPD6M4EfIBBxVpXqlMN3JPR+es=; b=Y1F17/cLqqUsrlOJhlSbBt/i/LRc1SXKlARJAlzQsUcpoZTr8TKDo3Y2rWqilfH8Lm FwcEIzFM5TBaqA141rcycYW69cLAJ0D1bn8gIwrRpRrznv6NqwbpCDd12ANDnya6J1RJ rkPCpE9wGwBpEmqMk8JOw495Kp9Oh3Q/wCaqLspjuKScuDMfM7YFO47tPsk2ol24sQH5 LLjZfjtWQp3N+ZnebhLn4Msx09KHJRPGnjXrqIOqqp9BBeJNfh1o9Iod83MgZxlQbSnV Yl3iJsuEsSPYVZ7xlm/UsIh/X8/4g2iTG5MLDmbeMQZQUUP9j7YRYdjK8Xnv9UjgmH49 Hebw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XJYYovmC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pj21si1660698ejb.713.2020.05.27.04.35.08; Wed, 27 May 2020 04:35: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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XJYYovmC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729079AbgE0J6D (ORCPT + 99 others); Wed, 27 May 2020 05:58:03 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:25609 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725822AbgE0J6C (ORCPT ); Wed, 27 May 2020 05:58:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590573481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JKhlMLe/B6ecqLXqArPD6M4EfIBBxVpXqlMN3JPR+es=; b=XJYYovmCcL7yh6u7T26Gu7rxpiJ47oEadPBuUy5URIq3ZDDBC54G5uEfJt1fJtPhR4J4a4 UD8pHvc7+NRFy79Y8BRwgV+2bgtMvXKmY/kcu2/WELgx41scnnSFxWZMlZNoTV0fmJ4MAp U2Y4DYTj4WZ9PPD/TFoOacs+ahq3H6M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-mt7u66drOhSWNOBns8J7Eg-1; Wed, 27 May 2020 05:57:59 -0400 X-MC-Unique: mt7u66drOhSWNOBns8J7Eg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09AE0EC1A3; Wed, 27 May 2020 09:57:58 +0000 (UTC) Received: from work (unknown [10.40.194.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C05C19D82; Wed, 27 May 2020 09:57:56 +0000 (UTC) Date: Wed, 27 May 2020 11:57:51 +0200 From: Lukas Czerner To: Reindl Harald Cc: Wang Shilong , linux-ext4@vger.kernel.org, Wang Shilong , Shuichi Ihara , Andreas Dilger Subject: Re: [PATCH] ext4: introduce EXT4_BG_WAS_TRIMMED to optimize trim Message-ID: <20200527095751.7vt74n7grfre6wit@work> References: <1590565130-23773-1-git-send-email-wangshilong1991@gmail.com> <20200527091938.647363ekmnz7av7y@work> <520b260b-13e9-4c62-eaeb-c44215b14089@thelounge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <520b260b-13e9-4c62-eaeb-c44215b14089@thelounge.net> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, May 27, 2020 at 11:32:02AM +0200, Reindl Harald wrote: > > > Am 27.05.20 um 11:19 schrieb Lukas Czerner: > > On Wed, May 27, 2020 at 04:38:50PM +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. > > would that also fix the issue that *way too much* is trimmed all the > time, no matter if it's a thin provisioned vmware disk or a phyiscal > RAID10 with SSD no, the mechanism remains the same, but the proposal is to make it pesisten across re-mounts. > > no way of 315 MB deletes within 2 hours or so on a system with just 485M > used The reason is that we're working on block group granularity. So if you have almost free block group, and you free some blocks from it, the flag gets freed and next time you run fstrim it'll trim all the free space in the group. Then again if you free some blocks from the group, the flags gets cleared again ... But I don't think this is a problem at all. Certainly not worth tracking free/trimmed extents to solve it. > > [root@firewall:~]$ fstrim -av > /boot: 0 B (0 bytes) trimmed on /dev/sda1 > /: 315.2 MiB (330522624 bytes) trimmed on /dev/sdb1 The solution is to run fstrim less often, that's the whole point of the fstrim. If you need to run it more often, then you probably want to use -o discard mount option. -Lukas > > [root@firewall:~]$ df > Filesystem Type Size Used Avail Use% Mounted on > /dev/sdb1 ext4 5.8G 463M 5.4G 8% / > /dev/sda1 ext4 485M 42M 440M 9% /boot >