Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp367784pxb; Mon, 25 Oct 2021 09:49:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcnXXRh8G8uXpCBdCEMUXwKQKOfn413BV1YcwosLW4+m77s7473FAJeMElkNAYTm2v30IM X-Received: by 2002:a05:6402:141:: with SMTP id s1mr27907296edu.317.1635180543360; Mon, 25 Oct 2021 09:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635180543; cv=none; d=google.com; s=arc-20160816; b=ZCeGQw1Fc9MXD8SYiJAFNw+THJ76NbgPsHcpr5O6HdFWJHUpdRIfFvznaAzFCf3JgI pFibo4HJlMA/TPvP7VNt8qL5nCDtMuFN2NnN66CKn2lxJthD1zKLkhUok/dwnquD3Uf2 lW1mfJlEx38dI63K9IBDpz92OehE2c73v2p8Rk56QafGB4wA1Q5qptvL0HSQDAVMhpZN i2pGyMtdZ9UFTLPGX5+lGGtiIlF5qFgeQBx/MB8DeMEmvnT+Bpn2D0YfGlJDCtmxFKoG pp+ub9MnXtV1Gu/ka/jf3i1/eZ5jGzXrVEU1b98yNRKs4mqI4oEsZS7z3S3BHC97ElPv ouEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=6M3pBtKrq21SJ8NcjfpnAzk60UNTxnFTq/K8855bQ6A=; b=QKBadNBuaBgyYHG6DZXHcMo5E3oefn2Ii6BANYhYD9y+JK/qolUbNhQ2lu9qo2JNI5 VGxHhkfPJ5pXUL6lF719FPUVegpRjICspMVIYu5Km8Pp61mW2jmRSxr3MnhUVHW7cHvK Ex4MC9Ei3oeyH1TDbSXlTLss3RH6RA0z7Z4Sw0lgQwGfKsGE1+z+mnqWq7BjllIqJsD/ bcMztYhYzBLfz5zu7Ti51Qq3NMJcDRISDgpHLvMKQVDSbRuenv0HnaM4X1cgxoIFetjv llE/EPw42jp8YT0POsLnnzR+YNv3Gr6QMJ7kD7RgN5r4Guy07NXTJLGKQlQPK9Os+OuM 9tFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dilger-ca.20210112.gappssmtp.com header.s=20210112 header.b="i/hizxmA"; 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 z5si3355059edd.390.2021.10.25.09.48.32; Mon, 25 Oct 2021 09:49:03 -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=@dilger-ca.20210112.gappssmtp.com header.s=20210112 header.b="i/hizxmA"; 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 S233910AbhJYQuL (ORCPT + 99 others); Mon, 25 Oct 2021 12:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233257AbhJYQuL (ORCPT ); Mon, 25 Oct 2021 12:50:11 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAD49C061745 for ; Mon, 25 Oct 2021 09:47:48 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id s24so4346491plp.0 for ; Mon, 25 Oct 2021 09:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dilger-ca.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=6M3pBtKrq21SJ8NcjfpnAzk60UNTxnFTq/K8855bQ6A=; b=i/hizxmAR/0q4eRm77UkNYmfLntZh4Z5awWHHSCpQ9i79D/vf6wsLuyj9yKqo5cYn1 If8m3PeyOLmPfODvubLs1Cx27LJpeErScMHjnmLmMFnV10MikrlMq8zMt5BnZFr4qdna jjebBU9m8e3CglKOC/QqcZYCVJroKMGo0/v8HoyeUHcpp2UsUrIgE2ZIgs+V1+pmhmBP Psv1fOVVIb2vW9V8zxtgN9Wsox4MGD3SQxnQDBhd3AkkGV8yJoIAF8TZTlC6U6QuFkIn 1XpS3QUKzkBtU0DaCQe6MAiua5qSna++NvY7xmeaxoZ759okNMpdikuuvP4AG5e1EVh8 dC8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=6M3pBtKrq21SJ8NcjfpnAzk60UNTxnFTq/K8855bQ6A=; b=y98kr5imVmh5YPMM5Wu5tvuDpU6ws7J4lwYejE+826LIPz6C8QII7g1PLOvNa8lZSq Xuac9GGv65ZsFEScB7QywPIS0e5acVFJKektWGyxTxHzAjJpnSSfr1sLwqchTUckyS7W iHRjvrEDxOtYMKQccwNP6wcnkwwghfJAbQEfyJGfdJS5wKv8zk7WbRHHfCYOywxe4Rw7 k7HecKm2CEb80XF5AEXDxfV10lA0UGU72CO/mb+FgykbOZ473w4Aa4CUIRJ1YIfhxGQ6 IpSUUbGVuUnxujM/gZlPlev6kSNV4goAakH6MyT+KaqAoWJoo7ajFNaHY8cBWzKvlm+R OM4g== X-Gm-Message-State: AOAM531dr65qQGpjsLYCbWAnZnOkrEcFjaD5neo6A1nmPAxiL+Vtsgxb RPp7AA0IMmpeOJvcMFZ9pdzenw== X-Received: by 2002:a17:90a:5b09:: with SMTP id o9mr29856611pji.171.1635180468449; Mon, 25 Oct 2021 09:47:48 -0700 (PDT) Received: from smtpclient.apple (S01061cabc081bf83.cg.shawcable.net. [70.77.221.9]) by smtp.gmail.com with ESMTPSA id e7sm6919473pgk.90.2021.10.25.09.47.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Oct 2021 09:47:47 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andreas Dilger Mime-Version: 1.0 (1.0) Subject: Re: How to force EXT4_MB_GRP_CLEAR_TRIMMED on a live ext4? Date: Mon, 25 Oct 2021 10:47:46 -0600 Message-Id: <97FC9914-F57C-4D96-8C24-5B6AE7C6FE71@dilger.ca> References: <1635175743.26818.15.camel@guerby.net> Cc: Lukas Czerner , linux-ext4@vger.kernel.org In-Reply-To: <1635175743.26818.15.camel@guerby.net> To: Laurent GUERBY X-Mailer: iPhone Mail (18H17) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Oct 25, 2021, at 09:29, Laurent GUERBY wrote: >=20 > =EF=BB=BFOn Mon, 2021-10-25 at 11:42 +0200, Lukas Czerner wrote: >>> On Sat, Oct 23, 2021 at 12:24:40PM +0200, Laurent GUERBY wrote: >>>=20 >>> I did end up creating dummy files to fill the filesystem and then >>> removing them, but this is far less efficient than what a >>> filesystem >>> tool could do. >>=20 >> Yeah, that's bad. The information is stored in the buddy cache in >> memory >> and AFAIK is only dropped on unmount. I'll have to think about how to >> clear either the cache or selectively just the flag. >>=20 >> What would be more convenient way of doing this for you, -o remount, >> or >> using let's say tune2fs ? I am not promising anything yet, but I'll >> think >> about how to implement it. >>=20 >>=20 >> Meanwhile other than umount/mount, or actually writing to the dummy >> files, >> you can try to use fallocate to allocate all the remaining space in >> the >> file system and subsequently removing it. That should be more >> efficient, >> but don't forget to sync after remove to make sure the space is >> released >> before you call fstrim. >=20 > Thanks for the advice on fallocate! It does work and is very fast. It would be enough to allocate and free a block in each group (128MB) of the filesystem. That can't be controlled directly by fallocate(), but indirectly via the "goal inode", but if fallocate() if all free space is= fast enough it may not be worth the effort.=20 > I would prefer a specific tune2fs as remount forcing this TRIM cache > clearing behaviour might be unwanted. >=20 >> You could also force fsck on ro file system and use -E discard to >> trim the >> free space but I can't say I recommend it. This would have a danger to corrupt the mounted filesystem, so should not be allowed when doing a read-only e2fsck. The bitmaps that e2fsck is using for the trim may be stale if the filesystem is modified since the start of the run, which may be a long time in some cases (minutes, hours). Cheers, Andreas=