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 X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A452C433E2 for ; Thu, 3 Sep 2020 21:43:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E7C0206D4 for ; Thu, 3 Sep 2020 21:43:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="oR5ydt/A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728491AbgICVn2 (ORCPT ); Thu, 3 Sep 2020 17:43:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727804AbgICVn1 (ORCPT ); Thu, 3 Sep 2020 17:43:27 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87B45C061244 for ; Thu, 3 Sep 2020 14:43:27 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id w16so4556009qkj.7 for ; Thu, 03 Sep 2020 14:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TjHHYmIBA2d3NmlsQp/oEei/WnENPX18h1dgLpIvfCI=; b=oR5ydt/AcP3nUDRTskpWjE6uIZTEd/LnPGWafRm3rBI9br851PmYKi8HfvE/qtIwjX rFMRGVC1URByIWIQABaPN5rk4a4GhNnTKaUN2g3MOy1Tm5VPcKrg7hR89Bi4CUDeuiXu DiJwHbyYVFiC2LscWdRyswBXnc1jAtFGRCmWXEFErwZdDwk1F3Z7xKLwN+LE4FmhWH0L hVr0tuY/fxDQqsLIyciGQ+9TvD5OaZbFvoHE2/6Ce7gp8bVNVS1DsEqslWgI/sySuEsa coBaciQ0qpKdCqHFYBOXeT3YyvpYJwjgV+z/IsplWqnpqVoFQil9tuDC0Wv4i0tlZi3Y dBaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TjHHYmIBA2d3NmlsQp/oEei/WnENPX18h1dgLpIvfCI=; b=ViLLypQ0JE/074K0tz68N5L9QIPirbj0CwwrievyTSPV8ZXc+JA9jryZSG3nImtyAe gCVjki7+NZDGcNtyBlAkpIUKvqVHU/Jrdqs9QjnS43yZCrogv04bUX58JCUQgxMY92S3 WO1IKCi+4ewRs4GPPUPL0QCCB3gzz8Dxj7dVek7OJwa9b2sIV5i6dHEdbE9km6qNVrDo vOjT6TYwXGHkJR+vzLV1NLbnJHio5qKOrEJBvYLGSrQZZK/McvPeeM+qpQgPkNNiKrbr F07Um8lDTIQFKnqP46qHPEHv3Jxvw6eJEgJrAEFIMPdSJCie1uxrsJZpwRwDSIHyaRU0 7Drg== X-Gm-Message-State: AOAM532SZUJigPLTy9yCYfnF/OhRMGfHqapcZlt9406m1Tw5oKjsLK3H l4fWgJn6OdvUjKLbrTk9sCusRQ== X-Google-Smtp-Source: ABdhPJw0xaOFkoAfMDM5j9N3q+NGAl7La8VUkY4kGF9W40JPt56FiCDThxT9E65ptsV5xmudOf4f8Q== X-Received: by 2002:a05:620a:4090:: with SMTP id f16mr4969469qko.402.1599169406527; Thu, 03 Sep 2020 14:43:26 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:11c1::11a2? ([2620:10d:c091:480::1:9e05]) by smtp.gmail.com with ESMTPSA id j88sm867068qte.96.2020.09.03.14.43.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2020 14:43:25 -0700 (PDT) Subject: Re: [PATCH 2/2] btrfs: remove free space items when creating free space tree To: Boris Burkov , Dave Sterba , Chris Mason Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com References: From: Josef Bacik Message-ID: Date: Thu, 3 Sep 2020 17:43:25 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 9/3/20 4:33 PM, Boris Burkov wrote: > When the file system transitions from space cache v1 to v2 it removes > the old cached data, but does not remove the FREE_SPACE items nor the > free space inodes they point to. This doesn't cause any issues besides > being a bit inefficient, since these items no longer do anything useful. > > To fix it, as part of populating the free space tree, destroy each block > group's free space item and free space inode. This code is lifted from > the existing code for removing them when removing the block group. > > Furthermore, cache_save_setup is called unconditionally from transaction > commit on dirty block groups, so we must also stop creating these items > when we are not using SPACE_CACHE. > > References: https://github.com/btrfs/btrfs-todo/issues/5 > Signed-off-by: Boris Burkov > --- > fs/btrfs/block-group.c | 42 ++++--------------------------- > fs/btrfs/free-space-cache.c | 49 ++++++++++++++++++++++++++++++++++++- > fs/btrfs/free-space-cache.h | 2 ++ > fs/btrfs/free-space-tree.c | 3 +++ > 4 files changed, 58 insertions(+), 38 deletions(-) > > > + if (!btrfs_test_opt(fs_info, SPACE_CACHE)) > + return 0; > + This is functionally unrelated, so it needs to be it's own patch. > /* > * If this block group is smaller than 100 megs don't bother caching the > * block group. > diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c > index 8759f5a1d6a0..52612d99a842 100644 > --- a/fs/btrfs/free-space-cache.c > +++ b/fs/btrfs/free-space-cache.c > @@ -207,6 +207,54 @@ int create_free_space_inode(struct btrfs_trans_handle *trans, > ino, block_group->start); > } > > +int remove_free_space_inode(struct btrfs_trans_handle *trans, > + struct btrfs_block_group *block_group) > +{ It's public, lets call this btrfs_remove_free_space_inode(). > @@ -2806,7 +2854,6 @@ void btrfs_remove_free_space_cache(struct btrfs_block_group *block_group) > __btrfs_remove_free_space_cache_locked(ctl); > btrfs_discard_update_discardable(block_group, ctl); > spin_unlock(&ctl->tree_lock); > - > } Thou shall not change random whitespace that's not anywhere near the code you're modifying. Thanks, Josef