From patchwork Thu May 4 11:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13231041 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58D66C7EE21 for ; Thu, 4 May 2023 11:04:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbjEDLEn (ORCPT ); Thu, 4 May 2023 07:04:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230162AbjEDLEg (ORCPT ); Thu, 4 May 2023 07:04:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A523B19A2 for ; Thu, 4 May 2023 04:04:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3D1A46129B for ; Thu, 4 May 2023 11:04:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30A18C433D2 for ; Thu, 4 May 2023 11:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683198271; bh=EGjOFHkl+N/3kWIxZlYhT0VaaVBTvY8BXBsDAEi4bRs=; h=From:To:Subject:Date:From; b=H1GvN6kqRhLM4er+jGfFU5IhKiWDzjAf4iDdHHkp+m1cAcsQ0wwujuRE4fHhOZNGO z1jyKNTG4B4cNsaxjUgrTIeE20In2tmzBBUVKibR1awsAtoL+eOu3BxCv5dwKuHkBj h8eAlR7ES79x06HrfqmIJKdbACM/DI+FUwk5HDZ3MWPxMxrDKYvo+mco6ZtXBJSfl/ xOqSnV2iYTRm4YjroylXWwJ2UT97MCrassRdiSL0aFQ67C4/gaVUNWSm0TBuDzZcT+ x1WemJKVC0F1TMvomyZhRuF76QZnuq+GgjCX6BUoXyPInc27tAFODgsMnCJc7JDw/m Ryu6xA8ZuBo9A== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 0/9] btrfs: some free space cache fixes and updates Date: Thu, 4 May 2023 12:04:17 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana Several updates to the free space cache code (most of it to the in memory data structure, shared between the free space cache and the free space tree). A bug fix, some cleanups, minor optimizations and adding several asserts to verify we are holding the necessary lock(s) when udpating the in memory space cache - this was motivated by an attempt to debug an invalid memory access when manipulating the in memory free space cache, as I suspected we had some code path not taking a required lock before manipulating the in memory red black tree of free space entries. Filipe Manana (9): btrfs: fix space cache inconsistency after error loading it from disk btrfs: avoid extra memory allocation when copying free space cache btrfs: avoid searching twice for previous node when merging free space entries btrfs: use precomputed end offsets at do_trimming() btrfs: simplify arguments to tree_insert_offset() btrfs: assert proper locks are held at tree_insert_offset() btrfs: assert tree lock is held when searching for free space entries btrfs: assert tree lock is held when linking free space btrfs: assert tree lock is held when removing free space entries fs/btrfs/free-space-cache.c | 111 +++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 39 deletions(-)