From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2D91C433F5 for ; Sat, 23 Oct 2021 10:30:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A682C6101C for ; Sat, 23 Oct 2021 10:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbhJWKci (ORCPT ); Sat, 23 Oct 2021 06:32:38 -0400 Received: from mx1.tetaneutral.net ([91.224.149.83]:46766 "EHLO mx1.tetaneutral.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbhJWKch (ORCPT ); Sat, 23 Oct 2021 06:32:37 -0400 X-Greylist: delayed 332 seconds by postgrey-1.27 at vger.kernel.org; Sat, 23 Oct 2021 06:32:37 EDT Received: by mx1.tetaneutral.net (Postfix, from userid 109) id 7F5568C0D4; Sat, 23 Oct 2021 12:24:45 +0200 (CEST) Received: from lgnuc (ip165.tetaneutral.net [IPv6:2a03:7220:8080:a500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.tetaneutral.net (Postfix) with ESMTPS id 8C9B88C0CC for ; Sat, 23 Oct 2021 12:24:41 +0200 (CEST) Message-ID: <1634984680.26818.10.camel@guerby.net> Subject: How to force EXT4_MB_GRP_CLEAR_TRIMMED on a live ext4? From: Laurent GUERBY To: linux-ext4@vger.kernel.org Date: Sat, 23 Oct 2021 12:24:40 +0200 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi, When using fstrim on an ext4 filesystem trim are not issued for EXT4_MB_GRP_WAS_TRIMMED space which is a useful optimization. Is there a way to force a complete trim on a mounted ext4 filesystem?  My (limited) understanding of the code is that EXT4_MB_GRP_CLEAR_TRIMMED should be called to do so. My use case is having live migrated a virtual machine root disk from one storage to another, the target supporting trim, but since fstrim in the VM post migration does mostly nothing (assumes most space was trimmed) I cannot release space to the new storage. I tried mount -o remount but without effect. e2fsprogs don't seem to have an option/tool to do this either. I've seen suggestion that rebooting will do the job but the whole point of live migration is to avoid reboot :). 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. Thanks in advance for your help, Sincerely, Laurent