Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2681953pxa; Fri, 7 Aug 2020 18:31:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGwhub52MYGkA23rai1PrlROwIZxOdeTHeQalzciHzGkQx9FWchunI0m6tsIA7He7JI5MO X-Received: by 2002:aa7:c915:: with SMTP id b21mr11777594edt.17.1596850271835; Fri, 07 Aug 2020 18:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596850271; cv=none; d=google.com; s=arc-20160816; b=UiGgTClQAKM0Qr8gfYwVDSRUL8LTZyDBMDEFXbLWvUtrCY796zXjfueAwJIV1BtlYG x89SjUGmW8ax0FHvlmQoddY+OKJUASVm5wDqPo/dae/PjmQicWYCxJEsPfo0434t3/+D 2JyCcgFpw2lW3uTVncvhLphO5iJOjcULiSsEWEVpcHs5lgEP0AMeQbfZIDJlminoSPky FaYcCPkDSsgW5AdwZLIeTo+UBq0g+/ayl82LEb0uSO3i/2mOjAot1c5hIcpe8qfpu7FX sF/K1Xvs2e3QAQjsKdA/z0mzchtQVwYTKfuRZIBJJ6aCkN+2XtrcEw8iuvwPOSaScava Iz2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zDeJEkJ/8S3OE+Trl+Xe+daUwGAfoKP4kwo+HhNBbNI=; b=hZr650qe63OtoZq/qWAUAXWMlRbV4npCaqkrtbNoMbYcWKOV0U0rY+K4hNIEn8IQts XXkPsaPDQPADYf8PcrBHqnhc6cL0zKK3pr4xnGBrLfj82P5gtnVnJxr51/eBl+O61B/z udYrhcgxV4R1VfuhgeYEzmLkVt2ABqMAx8Bv7clVZyyay5sOwjM7VfQ666Hr8z3IO1nm FqSo77okzXDLUksStS7ZumDLt9pvS1/q7UAXuxOVCaP/gSkBSElcUt4061AejfPGxWYq V1AKNx9b/5O/uUkfupC5udfSOT9S30jEDbrMsgYKWNz2me3jUv8d8WHQfTPHkPR7XRrn 3D9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CAskl4+z; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q26si6460440eja.259.2020.08.07.18.30.27; Fri, 07 Aug 2020 18:31:11 -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=@gmail.com header.s=20161025 header.b=CAskl4+z; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726159AbgHHBa0 (ORCPT + 99 others); Fri, 7 Aug 2020 21:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgHHBa0 (ORCPT ); Fri, 7 Aug 2020 21:30:26 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA91C061756 for ; Fri, 7 Aug 2020 18:30:26 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id k20so3385715wmi.5 for ; Fri, 07 Aug 2020 18:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zDeJEkJ/8S3OE+Trl+Xe+daUwGAfoKP4kwo+HhNBbNI=; b=CAskl4+zmznwyjQuLEbwegDTyir+ypI5GFFwhOCOCB1f61uDbY36uj/RDiDouyfzPJ 62OkZMQ30fnRuwzTpkRMb0IwGgl4fHfSLfyuixr9K6k41cvDYQHS7pmHFoEb4G48b4ce 3/OeyQIo1AiQ7t07K4NslT/LKu2CcUKUpAHFg81ptMLpuvdlQSYyc84OO/eVFwO+Y+Yc si22noqlgbxWtkHfbrwOMV1YEKdtYmFyfuQcEgUxVutF17P1zWgUPeAr5EQKrULmu9ap /4NC923wrfeQzuY61vk7z/PdaGzZhoS8e+TLvLMUQlsJvNp27HU8B9G9k3b/s8qnFXnm HI9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zDeJEkJ/8S3OE+Trl+Xe+daUwGAfoKP4kwo+HhNBbNI=; b=Uq/+6k/+8RU9b/X25nx3Sxbwrh+QpexaOWHmnceVhw2GHcNuAHgf3pvYObztGuDJOG vaolmC2qGAL+QLNz2GY/w5gKKacy/ze6ROcOxiphMxfoYADxtLmongIy2lU9FD74UJit SQ8GX/g2KTLtYW2PJ6PfXGI4ARC+ijhISXszr2Lvb8jMm0OFDiLa3H/39yXg4F1pINjd e8T9///d+OB4KdhrVyvoCli9J7Dsu6V0uO6hCJKB/jZxk+akV89zHWNuzIzWNiTq3xoS vHobXc16w2lCayRPpER/1ox07e5iqwU1kblajNQs0iG4QTbuoeIpGSmqk0X8hUqT2WBX ePyg== X-Gm-Message-State: AOAM5326pQYPF9ccAWG/iX8K/n/Q3hUCu9XGZddyyPvWwJL0ujVAwCBT Z+cMSdW8vl0zSAx3BBc3Tu7wDg2602NLjqI+TjvmM0xdePY= X-Received: by 2002:a1c:dd06:: with SMTP id u6mr15736847wmg.39.1596850224710; Fri, 07 Aug 2020 18:30:24 -0700 (PDT) MIME-Version: 1.0 References: <1592831677-13945-1-git-send-email-wangshilong1991@gmail.com> <20200806044703.GC7657@mit.edu> In-Reply-To: <20200806044703.GC7657@mit.edu> From: Wang Shilong Date: Sat, 8 Aug 2020 09:29:50 +0800 Message-ID: Subject: Re: [PATCH v3 1/2] ext4: introduce EXT4_BG_WAS_TRIMMED to optimize trim To: "Theodore Ts'o" Cc: Ext4 Developers List , Wang Shilong , Shuichi Ihara , Andreas Dilger Content-Type: text/plain; charset="UTF-8" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Aug 6, 2020 at 12:47 PM wrote: > > 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. Yup, i thought something like this, this might not be accurate, but this won't cause some data corruptions etc, and trying to write data which was not trimmed in advance, SSD will do erase finally. And i sent e2fsprogs support which could clear all block groups EXT4_BG_WAS_TRIMMED flags, but it needs umounted state of course. And for our case, when admin running fstrim on filesystem, usually there are few IO for filesystem, so most of case, it might be fine. > > 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. 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. Thank you! Shilong > > - Ted