From patchwork Wed Sep 14 23:04:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976605 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 3CC3AC6FA86 for ; Wed, 14 Sep 2022 23:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbiINXFD (ORCPT ); Wed, 14 Sep 2022 19:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbiINXE7 (ORCPT ); Wed, 14 Sep 2022 19:04:59 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA451B49A for ; Wed, 14 Sep 2022 16:04:55 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id j8so2000331qvt.13 for ; Wed, 14 Sep 2022 16:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=UADlMrHDNH0hUq4O5HDQdynvEN6RLY8d64k8+p/9VPU=; b=oagoNLRq81qG1Rcl0RFQaGqgrSlgGv/t9JgsI3gilv/5p0uIDGrcJkoE+b/A7YkYni HuoUEUju7xpxMCoAj8OJLX9D5yUu6TQOnCtN3BoS8368j7rQhW1mTBY4JiJCRwjFEWn6 SzMgrDFDFdB0daCmcdBknM/JGGp1X+Bf66y/8k5Z7ATMSMQOlGm7aZpV8ZS8T0dSlq5p n09qWl4hCIs1Dtt8vquORiRsL3/0kKQdOBVnC+PFzTQJlB3D3X4CoWJcZfbJMsUH6Jrz BZ1FZQb8Caea5euwKOrW3eTaS1pV7BHFJH3BtZ96BFvtczbzp1r7WMzV+PMWnF7NjRcp 5sTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=UADlMrHDNH0hUq4O5HDQdynvEN6RLY8d64k8+p/9VPU=; b=1UKeiAkWwaV3+Km+EkHaGbGDwRvgbw3GvNeFqL2/ATzhhUDpYLsf1e2xSNLT3oEXJl uBD24Q7z3b2hamsFw6ML0jlgvem9NLNXOxtD9JpZFGc3/KG43dN6vmANvg9ek0Mr1w6k 0XK/ilbzeidU7ZlLXTsPdcAqVqA4jOzEmNC94IFcxzka6kfCMgYXbQzAgI5xO3ojDswx QemYMeaaWXaKdVI1Po5S1Z08UopCsiXAlOG6jG9nEyvbU/V3i1HR1whGZohSafZYbRNK wpm+segcFk+HFLP24DGO+3ANnkT/hF1SBViqUVESwX6tvh3M00Rfr5lZ3iSKgSmLdwGS 02QQ== X-Gm-Message-State: ACgBeo32HYAdgzTJjfPzq2KLHnKYoTZC1GKJDFwdN+A9rzZKKBdItjsg eSw2+RY5PURN2X6G6/4KL8ETz92KVmVNyQ== X-Google-Smtp-Source: AA6agR6tnuVPDiPuuvj2bNEzBO/VDKujeZBfx5c9j0gCvFJQSd04Am8gxFcXbe2ZActAircc1Rp2+g== X-Received: by 2002:ad4:5dea:0:b0:4ac:6ffc:74b2 with SMTP id jn10-20020ad45dea000000b004ac6ffc74b2mr31032138qvb.78.1663196694478; Wed, 14 Sep 2022 16:04:54 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id h185-20020a37b7c2000000b006b9264191b5sm2649204qkf.32.2022.09.14.16.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:04:54 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 01/15] btrfs: move btrfs_caching_type to block-group.h Date: Wed, 14 Sep 2022 19:04:37 -0400 Message-Id: <84da2b1e0670313091a6ff604c105b09f3f18879.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is a block group related definition, move it into block-group.h. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/block-group.h | 7 +++++++ fs/btrfs/ctree.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index e34cb80ffb25..558fa0a21fb4 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -57,6 +57,13 @@ enum btrfs_block_group_flags { BLOCK_GROUP_FLAG_ZONED_DATA_RELOC, }; +enum btrfs_caching_type { + BTRFS_CACHE_NO, + BTRFS_CACHE_STARTED, + BTRFS_CACHE_FINISHED, + BTRFS_CACHE_ERROR, +}; + struct btrfs_caching_control { struct list_head list; struct mutex mutex; diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8271b3dccf16..725c187d5c4b 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -180,13 +180,6 @@ struct btrfs_free_cluster { struct list_head block_group_list; }; -enum btrfs_caching_type { - BTRFS_CACHE_NO, - BTRFS_CACHE_STARTED, - BTRFS_CACHE_FINISHED, - BTRFS_CACHE_ERROR, -}; - /* * Tree to record all locked full stripes of a RAID5/6 block group */ From patchwork Wed Sep 14 23:04:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976606 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 62A29ECAAD3 for ; Wed, 14 Sep 2022 23:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbiINXFE (ORCPT ); Wed, 14 Sep 2022 19:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiINXFA (ORCPT ); Wed, 14 Sep 2022 19:05:00 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E1113CCB for ; Wed, 14 Sep 2022 16:04:57 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id y2so9577760qkl.11 for ; Wed, 14 Sep 2022 16:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=elbwdiugwDNmnfD9IJQXpsoDFQkYkBw7C+z9JZrCvqg=; b=UwBct/kQ3gUHDWg/6DSTG0lu9NlxP3k5D6VV8f7TOfItyrwbaGHw6yJQu5hW6u6Blg Oma/bG96L1qGuHy7Pv6JTP3iZgc8mA9LJ5ZX8puB4vZs2qd30bZzh5jezCQg+5imKmK+ 7GGHpZBlVrIygM1PMUKxh5Qhi49yVokCKhhzf0AZSm41c7Q5BOdWGgtZ9XRgWLeWppTl K50ZGey6yHOkuUv8YaVG8uAjgcjcTrP/gl53dBKXfxz5XwfRuHu9n+v7G9SpprSroWp6 tfYJEJSN505kmPesf2GsgoKcLp022SFVS+Ev38aOF9oNWHNCxyjNe6SfmIh2k5tzDBPg Tibg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=elbwdiugwDNmnfD9IJQXpsoDFQkYkBw7C+z9JZrCvqg=; b=BdbQUhGrSBhP2ST8uHabE26WGBzvP9JPmO00RHorD1E0gyPe1zv2MFVM891T+g7N64 d/Ygu1lIojKe4Bcz7fV9LeaFnVAoVP1S0i3m3xBIUC2qlF7eum0unmH1ECn3/XgEHt92 AiiNQ7E70qPTvvJNYNL+Kb9aCMDJ9s0XAsRYI5EP0U3yLltlopIA2rrV75viUZLI3RTt uVHu4t1PMwRaREW7SLnJtT6lBG1P5KTItEehhVksp33VuNPIP+ucZGJxlIUbmRlYEfa8 hwO7PPNXASWCJh4J0dTF+eba5iXJ7m9Pt+6VLFKt3jUenIvcuQBaSA3Ugo4/IePy9mle ovqQ== X-Gm-Message-State: ACgBeo1Eg1c4Hs6UZlR24WlGIPSq3izCwUm7eR5qFxfKjMJWGdUOmS4e NMW0mcftKV5A4+4Oh2sF56Rxu97Xa8Bg8Q== X-Google-Smtp-Source: AA6agR53rgdiU+0YmMLLjetG9SGEYrPc4UBRpdDyENNJj9s2UMpnpHsWIZwWGwXWBfsPXUXhpv9Vbg== X-Received: by 2002:a05:620a:2891:b0:6bc:5c73:9728 with SMTP id j17-20020a05620a289100b006bc5c739728mr27979319qkp.178.1663196695933; Wed, 14 Sep 2022 16:04:55 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id bs14-20020a05620a470e00b006b58d8f6181sm2761480qkb.72.2022.09.14.16.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:04:55 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 02/15] btrfs: move btrfs_full_stripe_locks_tree into block-group.h Date: Wed, 14 Sep 2022 19:04:38 -0400 Message-Id: <6f4bd25183fd8844b5592259971ed4e060d9018c.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is actually embedded in struct btrfs_block_group, so move this definition to block-group.h, and then open-code the init of the tree where we init the rest of the block group instead of using a helper. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/block-group.c | 3 ++- fs/btrfs/block-group.h | 8 ++++++++ fs/btrfs/ctree.h | 14 -------------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 20da92ae5c6b..e21382a13fe4 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1940,7 +1940,8 @@ static struct btrfs_block_group *btrfs_create_block_group_cache( btrfs_init_free_space_ctl(cache, cache->free_space_ctl); atomic_set(&cache->frozen, 0); mutex_init(&cache->free_space_lock); - btrfs_init_full_stripe_locks_tree(&cache->full_stripe_locks_root); + cache->full_stripe_locks_root.root = RB_ROOT; + mutex_init(&cache->full_stripe_locks_root.lock); return cache; } diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index 558fa0a21fb4..6c970a486b68 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -76,6 +76,14 @@ struct btrfs_caching_control { /* Once caching_thread() finds this much free space, it will wake up waiters. */ #define CACHING_CTL_WAKE_UP SZ_2M +/* + * Tree to record all locked full stripes of a RAID5/6 block group + */ +struct btrfs_full_stripe_locks_tree { + struct rb_root root; + struct mutex lock; +}; + struct btrfs_block_group { struct btrfs_fs_info *fs_info; struct inode *inode; diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 725c187d5c4b..12d626e78182 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -180,14 +180,6 @@ struct btrfs_free_cluster { struct list_head block_group_list; }; -/* - * Tree to record all locked full stripes of a RAID5/6 block group - */ -struct btrfs_full_stripe_locks_tree { - struct rb_root root; - struct mutex lock; -}; - /* Discard control. */ /* * Async discard uses multiple lists to differentiate the discard filter @@ -1944,12 +1936,6 @@ int btrfs_scrub_cancel(struct btrfs_fs_info *info); int btrfs_scrub_cancel_dev(struct btrfs_device *dev); int btrfs_scrub_progress(struct btrfs_fs_info *fs_info, u64 devid, struct btrfs_scrub_progress *progress); -static inline void btrfs_init_full_stripe_locks_tree( - struct btrfs_full_stripe_locks_tree *locks_root) -{ - locks_root->root = RB_ROOT; - mutex_init(&locks_root->lock); -} /* dev-replace.c */ void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info); From patchwork Wed Sep 14 23:04:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976607 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 7EE52C6FA82 for ; Wed, 14 Sep 2022 23:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbiINXFF (ORCPT ); Wed, 14 Sep 2022 19:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiINXFA (ORCPT ); Wed, 14 Sep 2022 19:05:00 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C520318367 for ; Wed, 14 Sep 2022 16:04:58 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id j8so2000406qvt.13 for ; Wed, 14 Sep 2022 16:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=BcGA3Wmzbvy7Fkoup35RJ0w5yvuuEpFxyRZfOKD8KU8=; b=N8zIkAIh/GO2wd63i9In+XMS0I8BI30dfYDVa0YABorSDjKqH8zVPrStxPlhpjaxlN iseaO23qakgIjGnNqTU3YrxPUPOz0j2IYyNO2dy+4v5OdjquM629hGFEWqfxZHn6SiUg DxVwtPBc7xPLroL6sVAZVwbutqyAag4tKXo09dILOk0h5L/IpnUVxxa0TXY6QDsaeI98 nmBqX5cJhYCxcZy/EMLMlrbThtaWkvsJ/GlrSGb9TNKfSsGPg1TxdeFii9MOadgsoeND iEtM8JbCm0f2UuyYuDGJO/n7W/rs+jxSVYJ62ozKL2Bjp0uTCs45tsqElYqr6imEkWJ1 rpSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=BcGA3Wmzbvy7Fkoup35RJ0w5yvuuEpFxyRZfOKD8KU8=; b=lhNaHqPMAhJGYyhaheeIxnaQ67uL/5j1N3JDDwGd49B0DGHZ1MXvbRko1z8LEev+XG HJo6NFggYAn/6aPEGqiMQAMN5cBV4wdSN7EMwnPO6fOW6Y2mGSfioIE5LsGmA/ghAVkT Tge1Ptyy/pr4O4PjOk7TyK5YnRN72psoqx8vj2+AAaQXUqmJ0rzagBfmiwLYMPJKQwLb 89v0zfknQ5TnKqkmxcJGXNCkVzvxV74HO9gXlvnjDg009035oSjzK5H6JhOjg4zYpQZx Q0zz2l32IkfK/4jt0GDNg095AW9r3rKCp2Tv3wHtNS9MHBfVSaMkQDPR7GYz7qAjiOFK mumw== X-Gm-Message-State: ACgBeo0fVSBz6w3kenA8sLqCkQeLf2VEWzt/B4Vdco6tNIew60l3qY7Z AZheGLY44msyLt+45UMIqnBG01UZV/7MQg== X-Google-Smtp-Source: AA6agR5hY5ouAd09oMNuPthqrHyPbONak8/E2kJt8JkUqYqPskvnlWvSKwtqDG4Im/wI5Czjs5FI2g== X-Received: by 2002:a05:6214:1cc9:b0:496:aa2c:c927 with SMTP id g9-20020a0562141cc900b00496aa2cc927mr33673044qvd.15.1663196697377; Wed, 14 Sep 2022 16:04:57 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id e12-20020ac8670c000000b0035bb6298526sm2436395qtp.17.2022.09.14.16.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:04:56 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 03/15] btrfs: move btrfs_init_async_reclaim_work prototype to space-info.h Date: Wed, 14 Sep 2022 19:04:39 -0400 Message-Id: <57fcc1acc5720b8edf4b3d6bc2df224a8e196d4d.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The code for this helper is in space-info.c, move the prototype to space-info.h. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 2 -- fs/btrfs/space-info.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 12d626e78182..0c5a6ea2eeb3 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -211,8 +211,6 @@ struct btrfs_discard_ctl { atomic64_t discard_bytes_saved; }; -void btrfs_init_async_reclaim_work(struct btrfs_fs_info *fs_info); - /* fs_info */ struct reloc_control; struct btrfs_device; diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index 729820582fa7..6e2947688c53 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -217,5 +217,6 @@ static inline void btrfs_space_info_free_bytes_may_use( int btrfs_reserve_data_bytes(struct btrfs_fs_info *fs_info, u64 bytes, enum btrfs_reserve_flush_enum flush); void btrfs_dump_space_info_for_trans_abort(struct btrfs_fs_info *fs_info); +void btrfs_init_async_reclaim_work(struct btrfs_fs_info *fs_info); #endif /* BTRFS_SPACE_INFO_H */ From patchwork Wed Sep 14 23:04:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976609 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 7472FC6FA82 for ; Wed, 14 Sep 2022 23:05:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbiINXFI (ORCPT ); Wed, 14 Sep 2022 19:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbiINXFC (ORCPT ); Wed, 14 Sep 2022 19:05:02 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E9E230F4D for ; Wed, 14 Sep 2022 16:05:00 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id d1so12959881qvs.0 for ; Wed, 14 Sep 2022 16:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=6/+FvguIdqol8RCnWn5nWzFmHS/lrZsutBVOa6sDSgY=; b=kU35khlAdRfQA6H+PH7F9vJlnR7OWiEX24vo7iuEKl8Z/KLSJd29oCEDcyeA9pGH/Q kUtT5W9qN1cyLq4CnIqhlN/ULcza4bHL+6TxSVmyxlkGhX8J8vyKQiZ2SWojaFJ8K+mC At+HMfMA/JLtjLmbW32CRoW89Yik3P83lfPdpFk4XjL4oEwn/FSd6r4KPKG5dsvS2qJE 2ljnA82lcvMNgrkFEbFO8JXssaEit2ymZeK4om+Dr2jAc/pZ6qf5jMMtjWIk46pxLAOR GoJtaiLbvUbwc9ML/BUse00b2Z3Bgf7T2CUoSM0zMDIejYxOC3j9PRr8zoBdG0t7+wL5 T/UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6/+FvguIdqol8RCnWn5nWzFmHS/lrZsutBVOa6sDSgY=; b=0/G8WWrUXXVo5fp29aFtCaCHDfSijR+dMUZCy4kNQqS+tklPuhCO/kvO2+ZXd6+DwW 4XdxI4Alo4L1X9+YqJDfW/j0MPIYK41HmoQ/LBoATJ8PifP10UtQdrjGVfDLLvBREPbJ ORfq0C89kQ8/1KkDPzVGRV9ok2XS//C3TPnqg1A/cI4B5qAdHvRINf0d3byAZ+3D2iLN 1oCkgXUiZwdQy3tkE2IbEw3o+fVWU8ooN8FuNQYbJPkywN6vdbVUBmKCPPxwV8Z3YYvv k2s8Gdn+mz5UpDHLdBNtyho5YBiwDwr603gGlqQ8WcNeu3oMx0Rr+rTG+hT8vQObQL2U q8Rw== X-Gm-Message-State: ACgBeo1PdOgA8S1RlMmRoYU4pYZnWQk7YLpQqKM6yyXzHZ2QMUt1tiQS f7DONVsm0bKigp/5jtiLsaYnWAPncxfJpg== X-Google-Smtp-Source: AA6agR5nBYVv1+IDgmXWs291SvPTax+voUoehkRKz4q0xOqCVjqtODI9GnCGY0QsMK0Anja8C+lFRQ== X-Received: by 2002:a0c:8081:0:b0:496:7822:c55a with SMTP id 1-20020a0c8081000000b004967822c55amr34201792qvb.87.1663196698963; Wed, 14 Sep 2022 16:04:58 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id az31-20020a05620a171f00b006af0ce13499sm2934228qkb.115.2022.09.14.16.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:04:58 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 04/15] btrfs: move btrfs_pinned_by_swapfile prototype into volumes.h Date: Wed, 14 Sep 2022 19:04:40 -0400 Message-Id: <4cddba7a242f71c09a9cedd03fe726482ab90c5f.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is defined in volumes.c, move the prototype into volumes.h. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 2 -- fs/btrfs/volumes.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0c5a6ea2eeb3..36a473f05831 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -243,8 +243,6 @@ struct btrfs_swapfile_pin { int bg_extent_count; }; -bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr); - /* * Exclusive operations (device replace, resize, device add/remove, balance) */ diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 96a7b437ff20..db4cf51134fd 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -731,4 +731,5 @@ const char *btrfs_bg_type_to_raid_name(u64 flags); int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info); bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical); unsigned long btrfs_chunk_item_size(int num_stripes); +bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr); #endif From patchwork Wed Sep 14 23:04:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976608 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 C0412ECAAD3 for ; Wed, 14 Sep 2022 23:05:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbiINXFH (ORCPT ); Wed, 14 Sep 2022 19:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbiINXFC (ORCPT ); Wed, 14 Sep 2022 19:05:02 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972A533A1B for ; Wed, 14 Sep 2022 16:05:01 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id ay9so1655881qtb.0 for ; Wed, 14 Sep 2022 16:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=PldtfrkpRWo3KxAk3gI6jAkacJ64+J8f9MtlJI3vk6k=; b=nTGiFrdksDb3ClwPn66k6/YMJdocQvakp4IdnXfOVJe5G3IvlGhbPmz760LurSdDmJ pcLajH3X3uNHlwKepTSf/rcW1o+WRHJEwhF4E7qjBU1iGfjpC7oFexlRKlnF/JE1IYmJ 6W4NbfcihZejSB38GTBg87x8s0n6DU/ZMTzctXl59iesEzLRUQW8m4ppGuOa+w76oBMs FKgM92SrGHxEbpgHvJquGD416yDNyOGU+bevgTHoI1JkE4hQtQ/0IpX+HV8ZybWE3UxE yBgV45FGH+cPLjGkRvVyX8mVU9YBydKyGS9umLzavHBRFXRt03IfY9LEPJXmgnpLggzt hh5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=PldtfrkpRWo3KxAk3gI6jAkacJ64+J8f9MtlJI3vk6k=; b=qL7IVt05SMxrMo/dY65PHaeykvt+jCki3Wu50Y6neva/kndVdVjGvLdfL1cffglYDo pJ23YAYEcoARQtGCOiO47X/eZf30GVdi81F7OLIbQ3XOut5ZDwM8eInAgtbOuaWfmf3g sMgfpolsg8nb74sbdnAMb7ED1H7NimK1KJEJJdvvQD+JY9Y/E6+D+DLyejym06GMkpG6 GcyMbLwQ5pvwOeI681vzs/2b+0yNNJN7QoqEHHUkZi4CiIcw2GYPrgvw925Rckmf3691 13b/hEV8ooZiNgcK0kQeyyUdnswIdUz7fIs4nhEdVd+TggQ8kJPcwyzke6m+//ygyCKw d5Ig== X-Gm-Message-State: ACgBeo2jZxryfq+1YoIahTbbj6njLG0R8Ha8+R8C7j856u74o9bxSB4Z XMx8Np4tv30mZaavaEdqITKKnQ6U7IaO6A== X-Google-Smtp-Source: AA6agR4i7RZSaLXWurlomwUvl81uojKHP835YuxCrOHOjgyizOF6I+ME3bJBVfNCU6QQoHGBxoA49g== X-Received: by 2002:ac8:7c44:0:b0:344:5653:df43 with SMTP id o4-20020ac87c44000000b003445653df43mr35064981qtv.359.1663196700444; Wed, 14 Sep 2022 16:05:00 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id o17-20020a05620a2a1100b006ce9e880c6fsm1173207qkp.111.2022.09.14.16.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:04:59 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 05/15] btrfs: remove temporary btrfs_map_token declaration in ctree.h Date: Wed, 14 Sep 2022 19:04:41 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This was added while I was moving this code to its new home, it can be removed now. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 36a473f05831..a790c58b4c73 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -46,8 +46,6 @@ struct btrfs_ref; struct btrfs_bio; struct btrfs_ioctl_encoded_io_args; -struct btrfs_map_token; - #define BTRFS_OLDEST_GENERATION 0ULL #define BTRFS_EMPTY_DIR_SIZE 0 From patchwork Wed Sep 14 23:04:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976610 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 51844ECAAD3 for ; Wed, 14 Sep 2022 23:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbiINXFK (ORCPT ); Wed, 14 Sep 2022 19:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbiINXFE (ORCPT ); Wed, 14 Sep 2022 19:05:04 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E39062E68E for ; Wed, 14 Sep 2022 16:05:02 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id k12so12049039qkj.8 for ; Wed, 14 Sep 2022 16:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=Dv8DgU+7UxG1m3f3Lr8paJvfeq9zC1Hm5GVzJFlxd4Q=; b=iWhYQ/QN6FmOZETdOIGIRJHvFdfC04zvpGLiIO3I91reJRFLm6Y1CgvPpqRopn2yJO Nf4e2bZ/1ebF2VJYjH8x/XNhiZxIGHvcthGb+NIA4rrgqZmQ+QSHczRfqXsg3uTlXcZa O1NBltrKhoczDCUg8WJN6ov/Fu3ibmpufFf8XuwhBQRnmI5DEzyVkkfS37GVF75jUejj BjwOt3e8g2mpEU8QO3rxTK48NOxSqhefH/1m+YfYKfQutq+oxA1s+BLAhJOhl6XZCLNN 5YgkM4o0RJV1ta8pAKmIx7QuTa+dvS3D2uclB4C5hfgF87yGShpz6MqwcuFqAthYsK+8 3dOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Dv8DgU+7UxG1m3f3Lr8paJvfeq9zC1Hm5GVzJFlxd4Q=; b=TvI6mwwVTlZg7sym3nVIyX9dNJk+9+uj3BZ4JL1Z7rsHO+RQ/o6SATB56uQfwYOx7d PDrn9kxOSStk2jItse1wnqYnIkVUhjQfKRWaprpJkW6BLwv4fwWEXKgah84DkAlep82L gubcEwhEWniXdx370bR5hoAoOmPhPj1u2mZwQ1uZXwbQMxeKCXHUbdk+Xt+3F+uvzbdo 0IUqDMgFwC00hr6n7DJYN+wKwvoaTqgFD9tWjOVHIZT7vwnCLH9+MR5uYn8Wg8DSeXF9 IzeV7K7ttbVT+WBnokQMZkz2NZMMMrX70/fDCwEDZ9o/Kznov7XTveMhe9NY7tttu0rz QLew== X-Gm-Message-State: ACgBeo1KI7erQqxXq7B5XUyPnfBZzuQwIbds38sg8sYw5OWGIeoKDn5C i+FthiH1D4v9UCshEJe4YOjOLJEF+c/6og== X-Google-Smtp-Source: AA6agR70NI9xO6W5MQRTOZXDUtsNSInIFqGr/exGRCu3f3Cblu0dArgrlc3U8fP3LKapcIhdftWXZA== X-Received: by 2002:a05:620a:b0c:b0:6ce:61a2:3f20 with SMTP id t12-20020a05620a0b0c00b006ce61a23f20mr8255452qkg.551.1663196701647; Wed, 14 Sep 2022 16:05:01 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id g13-20020ac8774d000000b00339163a06fcsm2338782qtu.6.2022.09.14.16.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:01 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 06/15] btrfs: move static_assert() for btrfs_super_block into fs.c Date: Wed, 14 Sep 2022 19:04:42 -0400 Message-Id: <6b462dc4d7ceffe2ba9141f46bf28350be7c7f4a.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We shouldn't have static_assert()'s in header files in general, but especially since btrfs_super_block isn't defined in ctree.h. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 1 - fs/btrfs/fs.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index a790c58b4c73..3cb4e0aca058 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -56,7 +56,6 @@ struct btrfs_ioctl_encoded_io_args; #define BTRFS_SUPER_INFO_OFFSET SZ_64K #define BTRFS_SUPER_INFO_SIZE 4096 -static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); /* * The reserved space at the beginning of each device. diff --git a/fs/btrfs/fs.c b/fs/btrfs/fs.c index a95d86679d14..c54ee0f943ce 100644 --- a/fs/btrfs/fs.c +++ b/fs/btrfs/fs.c @@ -106,3 +106,5 @@ int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag) disk_super = fs_info->super_copy; return !!(btrfs_super_compat_ro_flags(disk_super) & flag); } + +static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); From patchwork Wed Sep 14 23:04:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976611 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 5D341C6FA86 for ; Wed, 14 Sep 2022 23:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229901AbiINXFL (ORCPT ); Wed, 14 Sep 2022 19:05:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbiINXFF (ORCPT ); Wed, 14 Sep 2022 19:05:05 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6021233A1B for ; Wed, 14 Sep 2022 16:05:04 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id s13so12906975qvq.10 for ; Wed, 14 Sep 2022 16:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=Rcw64DFDCoMCM3XgBo2XyHZt4i3K7pFq0lg53ulW630=; b=3taJUPa6OGRlFd4ryl8/oXZkLWmpu2KmyBjJVbQgVjS16noJTih++bbUGo4QYwkZ7b WkMC/ahN3dKKym0mMWNRxAGCAUaqHM/08R1LKEzmYD1kGVmJh9fc0rgAGqNYf8xwzSUK v1oEjXXAl/1y6V/rFdITKCUB249fWOFlDhm2hxohmif9n/hNfz7rzBp1E+hpWV6mkrPI Abk/BMvoKcKXWZ0totRtp08AKjBdZhFvDgMf6bIHhZn3kroTGrR+SJyU+5UJO5mXCRbk kBerJ1ggPXzNDH8CRY2P4hJxWiAYGauXkfeq7vSiz574mxLp4vNICrptQ5Sj4LoIszE1 j3gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Rcw64DFDCoMCM3XgBo2XyHZt4i3K7pFq0lg53ulW630=; b=0ESzP46O/BsjKKgagcE1X42gJlxv8ebdDJX1SmfYVloREQlAe3dkjq7gy20+fbZvcA UBjnn0tf/xRHSclpln68NrWdsE5mwjabcShQ1bDhiUaSCREE4EkTAcoCKyQsSNZIhOjk xMPNj91Ot3/3BkMS9UktniTcgbvrpAxfvhhFDv+YS4fYHvtehmL34CdjitKUZU7NECPO hEg4FTobQ6qj6D78sjR7ZvEgH7KeEQc1+sM4YD32kKf3/s+koU80dI8Bm5WzolJ8Hd8B 5ht99YGHqV4gdewTe7rRWMes+F3uyU4HuoM1ZwLf+TLOi2DyBd6E9maYRQ+MFXKHbzQt CPiA== X-Gm-Message-State: ACgBeo0r8RDpbauwWd9PwWARBkT2QsEWfrr/7gJkEi7+F5p1nBmRP5kN OHxoUXzgBzkBS+TOn73xhkDkt09AohRbRg== X-Google-Smtp-Source: AA6agR6ygBCbO7iJ9HlwilzF8muq4vBxkAfs3bU3ioyBIeKmVwETTTbE4JoRI9HtZw0WNCsL4nfVVg== X-Received: by 2002:a05:6214:23cc:b0:496:fa7b:2503 with SMTP id hr12-20020a05621423cc00b00496fa7b2503mr32980780qvb.38.1663196702939; Wed, 14 Sep 2022 16:05:02 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id u13-20020a05620a430d00b006b953a7929csm2886241qko.73.2022.09.14.16.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:02 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 07/15] btrfs: move btrfs_swapfile_pin into volumes.h Date: Wed, 14 Sep 2022 19:04:43 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This isn't a great spot for this, but one of the swapfile helper functions is in volumes.c, so move the struct to volumes.h. In the future when we have better separation of code there will be a more natural spot for this. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain --- fs/btrfs/ctree.h | 25 ------------------------- fs/btrfs/volumes.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 3cb4e0aca058..b9e848a22290 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -215,31 +215,6 @@ struct btrfs_fs_devices; struct btrfs_balance_control; struct btrfs_delayed_root; -/* - * Block group or device which contains an active swapfile. Used for preventing - * unsafe operations while a swapfile is active. - * - * These are sorted on (ptr, inode) (note that a block group or device can - * contain more than one swapfile). We compare the pointer values because we - * don't actually care what the object is, we just need a quick check whether - * the object exists in the rbtree. - */ -struct btrfs_swapfile_pin { - struct rb_node node; - void *ptr; - struct inode *inode; - /* - * If true, ptr points to a struct btrfs_block_group. Otherwise, ptr - * points to a struct btrfs_device. - */ - bool is_block_group; - /* - * Only used when 'is_block_group' is true and it is the number of - * extents used by a swapfile for this block group ('ptr' field). - */ - int bg_extent_count; -}; - /* * Exclusive operations (device replace, resize, device add/remove, balance) */ diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index db4cf51134fd..2bf7dbe739fd 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -180,6 +180,31 @@ struct btrfs_device { u64 scrub_speed_max; }; +/* + * Block group or device which contains an active swapfile. Used for preventing + * unsafe operations while a swapfile is active. + * + * These are sorted on (ptr, inode) (note that a block group or device can + * contain more than one swapfile). We compare the pointer values because we + * don't actually care what the object is, we just need a quick check whether + * the object exists in the rbtree. + */ +struct btrfs_swapfile_pin { + struct rb_node node; + void *ptr; + struct inode *inode; + /* + * If true, ptr points to a struct btrfs_block_group. Otherwise, ptr + * points to a struct btrfs_device. + */ + bool is_block_group; + /* + * Only used when 'is_block_group' is true and it is the number of + * extents used by a swapfile for this block group ('ptr' field). + */ + int bg_extent_count; +}; + /* * If we read those variants at the context of their own lock, we needn't * use the following helpers, reading them directly is safe. From patchwork Wed Sep 14 23:04:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976612 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 3832FC6FA82 for ; Wed, 14 Sep 2022 23:05:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbiINXFN (ORCPT ); Wed, 14 Sep 2022 19:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbiINXFG (ORCPT ); Wed, 14 Sep 2022 19:05:06 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD4012F64F for ; Wed, 14 Sep 2022 16:05:04 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id ay9so1655960qtb.0 for ; Wed, 14 Sep 2022 16:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=hZBQPQVAYJOitHUk4v87PNBF/5fF24yOlf/HPSTLkPw=; b=0lF2ick5HUvgcFC13yNSzo0Y+bM6bNJ1Gdgw7gOuGF9Iz7g3l+TAEKk3mwQ7EoXpFF /8LSFvS9ccPLXunFh4vojMeJvlfB9bJ0k0TBD1ubTbtD01FOmIjtxzkpj2nSZ6XmcN3D yJW/flmGa9YHzSYPEtDTaTdOrwL4dwJ3cG14NGb/xz7UP4s4nk6nuLSGElFCxPChAke3 An4cBiZflRB3OCc4fYir/1BcBc9DO9dHwWkrVLA/M3c0OfbUxxQCKhAn60blQXLbTFlZ 3WMCsHd4Ypn8YkrbYqxKpqNPFbnVhWOaQB9JF78/AA7DxahZB7CbacafS8cVAoB20gXK tL7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=hZBQPQVAYJOitHUk4v87PNBF/5fF24yOlf/HPSTLkPw=; b=ap383N87bomiW6m1NK396SF+mnookwy0cD/qj2KGOAj7AyE6sXtklKjhAmGyFqdSwO 3F+2IPtnRLrETrtAFiFkGjAIJRQ/5Sehyy81E3NlM+sFNOAMAiORlW3c2mleOW0kNr02 /mBwRy/mq67GtG5MKUxFTLUjB1bON9S4x7hFjiNXwnb7MF3cm52XoC89Q30TGTi0XHDM 3wczG3XMaAeL/joOaJbLF09K0un29KHwXYzMTNg0aqqDeBJRg0miDC3L4DSaDc9LXiQi yMkdPXOoNG4rjoj8Xf15Eir9KvjV5SOat1Ixc+vVT05Veqx8fjDVhw7ojQLQRE2O+i3X dXgw== X-Gm-Message-State: ACgBeo1pZOUZ5RVX2SBhNcu7ECB3WaSdZ/ucMzGRmA1+d+DktLfF3ZwL +b6Gsg4Rn/mTXJ/CNRo1DG9sPun58y9amA== X-Google-Smtp-Source: AA6agR6N5Yth1CAM50J0TL0lWpcdZn1FKupgcPiG9XXYki7nysnD/XWnw849N3P+kKYXR9oZrxKMlg== X-Received: by 2002:a05:622a:58f:b0:35b:6813:75e9 with SMTP id c15-20020a05622a058f00b0035b681375e9mr25195084qtb.650.1663196704186; Wed, 14 Sep 2022 16:05:04 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id x4-20020a05620a12a400b006ce40fbb8f6sm2686309qki.21.2022.09.14.16.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:03 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 08/15] btrfs: move fs_info struct declarations to the top of ctree.h Date: Wed, 14 Sep 2022 19:04:44 -0400 Message-Id: <9506fef3a36ca9a740283dbf1df1f2d884cb732a.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In order to make it more straightforward to move the fs_info struct and it's related structures, move the struct declarations to the top of ctree.h. This will make it easier to clean up after the fact. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index b9e848a22290..05eb0e994e68 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -46,6 +46,13 @@ struct btrfs_ref; struct btrfs_bio; struct btrfs_ioctl_encoded_io_args; +/* fs_info */ +struct reloc_control; +struct btrfs_device; +struct btrfs_fs_devices; +struct btrfs_balance_control; +struct btrfs_delayed_root; + #define BTRFS_OLDEST_GENERATION 0ULL #define BTRFS_EMPTY_DIR_SIZE 0 @@ -208,13 +215,6 @@ struct btrfs_discard_ctl { atomic64_t discard_bytes_saved; }; -/* fs_info */ -struct reloc_control; -struct btrfs_device; -struct btrfs_fs_devices; -struct btrfs_balance_control; -struct btrfs_delayed_root; - /* * Exclusive operations (device replace, resize, device add/remove, balance) */ From patchwork Wed Sep 14 23:04:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976613 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 D1720ECAAD3 for ; Wed, 14 Sep 2022 23:05:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbiINXFP (ORCPT ); Wed, 14 Sep 2022 19:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbiINXFH (ORCPT ); Wed, 14 Sep 2022 19:05:07 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAC7A52474 for ; Wed, 14 Sep 2022 16:05:06 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id s18so9388380qtx.6 for ; Wed, 14 Sep 2022 16:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=N0Y2NjGVx1M5k9ysaQXO1ixQEq994ktrFFEEMHup4HY=; b=dNlAnzdXurizh/YxdfBEQDpNuhUBsTxxcyoeSZwUyom/m+TWGCAw5xc7NxKn7xaZit qewAEew9bO7qJDBLETxa+Q3zuDBTv3lMj6UXxl2Xp9oFqUWtdB5UUkmJn3czVbpOMs83 pHaJ7W68YhNMDi2B62lAQkdN/t+jFYs+4QNnB/i7rF5ooxWg166kuFrQ14O9HLAuqnmy m4pRHPpSwJKqsXN2vwYXitEuGe8MiRX5tPNplF75I1Qy72QAiUHwUgOz/h/f6AnC4q1v fEQU1iPb9X5UqTtnCpQ1I/BSUuRVM5f+mzaM6L7tKQVJE7uHw1Yioc2HtwlTiY6wKY/R d/lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=N0Y2NjGVx1M5k9ysaQXO1ixQEq994ktrFFEEMHup4HY=; b=RBJ+qg2grcInsi/9KAhHyrDPPjvcFn9CXvOuCsCWhkcOz4oyRloNcgEGeaPT79Lai+ AgunaFYBVlLNb6sBB9tLoiTgdntWIhZ6TG1S8NrGlfn3xhOyiIgZVNW2XDRmbwDyikDG Ks9vPuU8Dt2voIynLHHjJlnJEWIX+S5X6IEBzW4XfhpOG4tOwYuIB2So68MRi5I93jPZ C8ozR7Tl11YVRavZ5uCMG8V9IxixfP1BZnjVEBvmv39P+eM03bhc4/nIyPOHFl9a8dqM gjau0bCO9mme+VtVXpFJLBJX/nWeB7IAA1qbRsA3+R+buUR7ulQw5j8pytExyLjIQzRD FCmw== X-Gm-Message-State: ACgBeo0MM7nmeufjBzsI0nlCPxF9UHDeCPT6jU4Rq8aEduG2vXBXrA0c qg6ZUglr08V8raCGYCivyzgwivQK8JwMHw== X-Google-Smtp-Source: AA6agR4tIPj02HzUKQwURbFbRuIGml4wzY6tKaTlgXfdqA9PXYKtQ9Bt3KZkQetxxqq5K6gwoojNKA== X-Received: by 2002:a05:622a:13cc:b0:342:fa43:95ac with SMTP id p12-20020a05622a13cc00b00342fa4395acmr34917691qtk.508.1663196705594; Wed, 14 Sep 2022 16:05:05 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id m5-20020a05620a24c500b006bb366779a4sm3298840qkn.6.2022.09.14.16.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:05 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 09/15] btrfs: move btrfs_csum_ptr to inode.c Date: Wed, 14 Sep 2022 19:04:45 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This helper is only used in inode.c, move it locally to that file instead of defining it in ctree.h. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 8 -------- fs/btrfs/inode.c | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 05eb0e994e68..0da52e8b78e9 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1173,14 +1173,6 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb, enum btrfs_inline_ref_type is_data); u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset); -static inline u8 *btrfs_csum_ptr(const struct btrfs_fs_info *fs_info, u8 *csums, - u64 offset) -{ - u64 offset_in_sectors = offset >> fs_info->sectorsize_bits; - - return csums + offset_in_sectors * fs_info->csum_size; -} - /* * Take the number of bytes to be checksummed and figure out how many leaves * it would require to store the csums for that many bytes. diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ca6fa9b01785..62dc3dcf835b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3459,6 +3459,14 @@ int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page, return 0; } +static inline u8 *btrfs_csum_ptr(const struct btrfs_fs_info *fs_info, u8 *csums, + u64 offset) +{ + u64 offset_in_sectors = offset >> fs_info->sectorsize_bits; + + return csums + offset_in_sectors * fs_info->csum_size; +} + /* * check_data_csum - verify checksum of one sector of uncompressed data * @inode: inode From patchwork Wed Sep 14 23:04:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976614 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 7566EC6FA82 for ; Wed, 14 Sep 2022 23:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbiINXFQ (ORCPT ); Wed, 14 Sep 2022 19:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbiINXFJ (ORCPT ); Wed, 14 Sep 2022 19:05:09 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B39F353D15 for ; Wed, 14 Sep 2022 16:05:07 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id d1so12960064qvs.0 for ; Wed, 14 Sep 2022 16:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=LczUm8qKTKLmPFseBTPdZnhgQ3Aq3my6qTDiSm79yvg=; b=8MYlr2c8vzMzXFUhL/JyVWjGU+v7N1q95sqndjWRwVWfGjEkYL2p3LDF3vZmULIQLC 0tfgeAk7FeVLEE8jB5hjGrId15NBzus3BoG9+g2tno9x0UopF8wS5vPElEcUxOWl/B0Y dj5g3O2zhFRXu4Krp0XVindKokEyORfMkSeOG5SYRJfrSxUFcJHA31RzNcGMZlXtyJSz 3vYcF9pigei8nRIN/mJipupQPY/LSyYZuxY+BFpAJxN7M+Jzx6MVwItQ1OZN0zMPLyE0 xSCXOM8sMtez1NNs+31fM2EEp6L3sTXbDCJBqrkuQwSWndQpOA6aY9widqbdeCPnZ8CJ edtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=LczUm8qKTKLmPFseBTPdZnhgQ3Aq3my6qTDiSm79yvg=; b=KLSfMYHWq3bAym6aFCHNY5M+aGMcb+yPTbv38N+tOKhxYjSPUORK67DqVdQ1GwhPAr dscWuml3TbeNHBVcQ0kvDegQ2SW6f375k7sSeCjkiuVxL5niFZ9mTfzUYK80ThJkRVTI ONKFnhZvXWH/ZTdb0gp3fqIKrK4P6VbbVdcF0u7KR6BMBZV/UXP05IqXbeWCm6Z+uHP9 7QWoiEdLPdNoVpraOL/yzH94elXQjAIGOaQzSeO2hQ7FGbU2ysPjyH5EhPCYvN4xEWgx VjcbpX/CmCF3cjLv+BDhv9zkotwiXCTAQwzDAZcVT0IHi3VnSYluYcDc3hQc+rGnG+Uk 3SCA== X-Gm-Message-State: ACgBeo2NdzIrrQAkoHLmyOKFBB/q0SGYcvcYQhC4yF+7y6cSI3PMC36n wIojGLzHvsSjDTay3pluMf1UlMc3e8mPiw== X-Google-Smtp-Source: AA6agR7zTvIzPy36eDaUswx3ohxDCpax9+2sMbGbSkwlpEgbizmLPi/qvbXNXPWr00C/8cDQxLhJ3g== X-Received: by 2002:a0c:8dc9:0:b0:473:14fe:7c4e with SMTP id u9-20020a0c8dc9000000b0047314fe7c4emr33092189qvb.44.1663196706976; Wed, 14 Sep 2022 16:05:06 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id bi17-20020a05620a319100b006b999c1030bsm2759435qkb.52.2022.09.14.16.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:06 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 10/15] btrfs: move the fs_info related helpers closer to fs_info in ctree.h Date: Wed, 14 Sep 2022 19:04:46 -0400 Message-Id: <40ff0ebb4b409b881b7e4cd2e051b07acb05ff40.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is purely cosmetic, to make it straightforward to copy and paste the definition and helpers from ctree.h into fs.h. These are helpers that act directly on the fs_info, and were scattered throughout ctree.h. Move them directly below the fs_info definition to make it easier to move them later. This includes the exclop prototypes, which shares an enum that's used in struct btrfs_fs_info as well. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 187 ++++++++++++++++++++++++----------------------- 1 file changed, 94 insertions(+), 93 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0da52e8b78e9..57d53ec3cdd0 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -126,8 +126,7 @@ struct btrfs_path { */ unsigned int search_for_extension:1; }; -#define BTRFS_MAX_EXTENT_ITEM_SIZE(r) ((BTRFS_LEAF_DATA_SIZE(r->fs_info) >> 4) - \ - sizeof(struct btrfs_item)) + struct btrfs_dev_replace { u64 replace_state; /* see #define above */ time64_t time_started; /* seconds since 1-Jan-1970 */ @@ -705,6 +704,99 @@ static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb) return sb->s_fs_info; } +/* + * Take the number of bytes to be checksummed and figure out how many leaves + * it would require to store the csums for that many bytes. + */ +static inline u64 btrfs_csum_bytes_to_leaves( + const struct btrfs_fs_info *fs_info, u64 csum_bytes) +{ + const u64 num_csums = csum_bytes >> fs_info->sectorsize_bits; + + return DIV_ROUND_UP_ULL(num_csums, fs_info->csums_per_leaf); +} + +/* + * Use this if we would be adding new items, as we could split nodes as we cow + * down the tree. + */ +static inline u64 btrfs_calc_insert_metadata_size(struct btrfs_fs_info *fs_info, + unsigned num_items) +{ + return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * 2 * num_items; +} + +/* + * Doing a truncate or a modification won't result in new nodes or leaves, just + * what we need for COW. + */ +static inline u64 btrfs_calc_metadata_size(struct btrfs_fs_info *fs_info, + unsigned num_items) +{ + return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * num_items; +} + +static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_fs_info *info) +{ + return info->nodesize - sizeof(struct btrfs_header); +} + +static inline u32 BTRFS_MAX_ITEM_SIZE(const struct btrfs_fs_info *info) +{ + return BTRFS_LEAF_DATA_SIZE(info) - sizeof(struct btrfs_item); +} + +static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info) +{ + return BTRFS_LEAF_DATA_SIZE(info) / sizeof(struct btrfs_key_ptr); +} + +#define BTRFS_FILE_EXTENT_INLINE_DATA_START \ + (offsetof(struct btrfs_file_extent_item, disk_bytenr)) +static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info) +{ + return BTRFS_MAX_ITEM_SIZE(info) - + BTRFS_FILE_EXTENT_INLINE_DATA_START; +} + +static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info) +{ + return BTRFS_MAX_ITEM_SIZE(info) - sizeof(struct btrfs_dir_item); +} + +#define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \ + ((bytes) >> (fs_info)->sectorsize_bits) + +#define BTRFS_MAX_EXTENT_ITEM_SIZE(r) ((BTRFS_LEAF_DATA_SIZE(r->fs_info) >> 4) - \ + sizeof(struct btrfs_item)) + +static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info) +{ + return fs_info->zone_size > 0; +} + +/* + * Count how many fs_info->max_extent_size cover the @size + */ +static inline u32 count_max_extents(struct btrfs_fs_info *fs_info, u64 size) +{ +#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS + if (!fs_info) + return div_u64(size + BTRFS_MAX_EXTENT_SIZE - 1, BTRFS_MAX_EXTENT_SIZE); +#endif + + return div_u64(size + fs_info->max_extent_size - 1, fs_info->max_extent_size); +} + +bool btrfs_exclop_start(struct btrfs_fs_info *fs_info, + enum btrfs_exclusive_operation type); +bool btrfs_exclop_start_try_lock(struct btrfs_fs_info *fs_info, + enum btrfs_exclusive_operation type); +void btrfs_exclop_start_unlock(struct btrfs_fs_info *fs_info); +void btrfs_exclop_finish(struct btrfs_fs_info *fs_info); +void btrfs_exclop_balance(struct btrfs_fs_info *fs_info, + enum btrfs_exclusive_operation op); + /* * The state of btrfs root */ @@ -1097,39 +1189,6 @@ struct btrfs_file_private { void *filldir_buf; }; - -static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_fs_info *info) -{ - - return info->nodesize - sizeof(struct btrfs_header); -} - -static inline u32 BTRFS_MAX_ITEM_SIZE(const struct btrfs_fs_info *info) -{ - return BTRFS_LEAF_DATA_SIZE(info) - sizeof(struct btrfs_item); -} - -static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info) -{ - return BTRFS_LEAF_DATA_SIZE(info) / sizeof(struct btrfs_key_ptr); -} - -#define BTRFS_FILE_EXTENT_INLINE_DATA_START \ - (offsetof(struct btrfs_file_extent_item, disk_bytenr)) -static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info) -{ - return BTRFS_MAX_ITEM_SIZE(info) - - BTRFS_FILE_EXTENT_INLINE_DATA_START; -} - -static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info) -{ - return BTRFS_MAX_ITEM_SIZE(info) - sizeof(struct btrfs_dir_item); -} - -#define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \ - ((bytes) >> (fs_info)->sectorsize_bits) - static inline u32 btrfs_crc32c(u32 crc, const void *address, unsigned length) { return crc32c(crc, address, length); @@ -1173,37 +1232,6 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb, enum btrfs_inline_ref_type is_data); u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset); -/* - * Take the number of bytes to be checksummed and figure out how many leaves - * it would require to store the csums for that many bytes. - */ -static inline u64 btrfs_csum_bytes_to_leaves( - const struct btrfs_fs_info *fs_info, u64 csum_bytes) -{ - const u64 num_csums = csum_bytes >> fs_info->sectorsize_bits; - - return DIV_ROUND_UP_ULL(num_csums, fs_info->csums_per_leaf); -} - -/* - * Use this if we would be adding new items, as we could split nodes as we cow - * down the tree. - */ -static inline u64 btrfs_calc_insert_metadata_size(struct btrfs_fs_info *fs_info, - unsigned num_items) -{ - return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * 2 * num_items; -} - -/* - * Doing a truncate or a modification won't result in new nodes or leaves, just - * what we need for COW. - */ -static inline u64 btrfs_calc_metadata_size(struct btrfs_fs_info *fs_info, - unsigned num_items) -{ - return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * num_items; -} int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info, u64 start, u64 num_bytes); @@ -1737,15 +1765,6 @@ void btrfs_get_block_group_info(struct list_head *groups_list, struct btrfs_ioctl_space_info *space); void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info, struct btrfs_ioctl_balance_args *bargs); -bool btrfs_exclop_start(struct btrfs_fs_info *fs_info, - enum btrfs_exclusive_operation type); -bool btrfs_exclop_start_try_lock(struct btrfs_fs_info *fs_info, - enum btrfs_exclusive_operation type); -void btrfs_exclop_start_unlock(struct btrfs_fs_info *fs_info); -void btrfs_exclop_finish(struct btrfs_fs_info *fs_info); -void btrfs_exclop_balance(struct btrfs_fs_info *fs_info, - enum btrfs_exclusive_operation op); - /* file.c */ int __init btrfs_auto_defrag_init(void); @@ -1943,24 +1962,6 @@ static inline int btrfs_get_verity_descriptor(struct inode *inode, void *buf, void btrfs_test_destroy_inode(struct inode *inode); #endif -static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info) -{ - return fs_info->zone_size > 0; -} - -/* - * Count how many fs_info->max_extent_size cover the @size - */ -static inline u32 count_max_extents(struct btrfs_fs_info *fs_info, u64 size) -{ -#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS - if (!fs_info) - return div_u64(size + BTRFS_MAX_EXTENT_SIZE - 1, BTRFS_MAX_EXTENT_SIZE); -#endif - - return div_u64(size + fs_info->max_extent_size - 1, fs_info->max_extent_size); -} - static inline bool btrfs_is_data_reloc_root(const struct btrfs_root *root) { return root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID; From patchwork Wed Sep 14 23:04:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976615 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 65C1FC6FA86 for ; Wed, 14 Sep 2022 23:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbiINXFS (ORCPT ); Wed, 14 Sep 2022 19:05:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiINXFL (ORCPT ); Wed, 14 Sep 2022 19:05:11 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF3F52474 for ; Wed, 14 Sep 2022 16:05:09 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id ml1so12941049qvb.1 for ; Wed, 14 Sep 2022 16:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=HDEw59ltZBkoDH4sKgc0vOCz52d8GCWhQ8m8mD8RpKo=; b=IE54N4NSwh0nbHZyGhb1t6MmOKP80teQJ0qGACCfI0CPI3rh5i2Oeq/Dg0QoaQ2N47 DKItxAby8jAnGbBv5Yoj8YuIJD+Yqh5jHU4IkDVjEyTtDD9sazertHEHEj6aP7VXahZj PhstAkWcxZB30EpIYl4+bLw2HQJNG1dwBoI7/NSUBhixaYHDY8+PS8GED6D6dzxF+DIc 5JvTzXWMz58WCBW6bzwm9b0wkCyy2Q5WJgWt7Aavy1qv+MGvQROhkzW20fS246Um3TFK IXQM+hkCVJr7KXqs5JqbEAI+UXNQlt7BNxqtrYX3a/5BmMMl68emW8Hj3hKZwQm9AhWG Xfqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HDEw59ltZBkoDH4sKgc0vOCz52d8GCWhQ8m8mD8RpKo=; b=EQfsPDKM9I7+Hyqknmi2Uvp9tgD+X/zUk2tPEmYeLWBa0p5vpoec9V9JVjJjIxMU/H 7nhBnvUOulGn1+00dayIFhEj9vtFEPGQsTyogF9Xfdznv6OJtZtp+eXU0RK6tmD+DHYf z1WHHVfNWuMTXwFIYI/KaRXzbaimKhV69GbrDVRlccx23iHZJOgggzlqnbASUMvVOqM6 Zbnw4ZvGgfhfI2PVOSuc/l4hZDy19cJvr/0FdTpRfiYJLAYXxsC1dfLuhSePkYUUqDMG 0T7SEJyAKJ804ptSWsmwSq5H5Dd63RTFJArvHwQHxc5vrDY7UqsjoxM0ZReYIPbYkB8B 0GDQ== X-Gm-Message-State: ACgBeo0D4k6gGk/CzhuuiJ65CeOTVwvnqWS+cXl/7KeS0ys8aK2+ZRnZ rIsN1En7cNSdR/DrxPjQ8RIa/0AGPjCkYw== X-Google-Smtp-Source: AA6agR7qRt29IZj8qNbaX/LKecFMgT/JPL8TT9CKWhB/fkaSjMQJUzMVsWKP1YbkLttjtCiEb71Inw== X-Received: by 2002:a05:6214:b6a:b0:4ac:6e54:457c with SMTP id ey10-20020a0562140b6a00b004ac6e54457cmr30936226qvb.122.1663196708317; Wed, 14 Sep 2022 16:05:08 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id j15-20020a05620a410f00b006b5df4d2c81sm3139503qko.94.2022.09.14.16.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:07 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 11/15] btrfs: move btrfs_ordered_sum_size into file-item.c Date: Wed, 14 Sep 2022 19:04:47 -0400 Message-Id: <7d20c1fad6d774c24413fd43af0c204b53adb814.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is defined in ordered-data.h, but is only used in file-item.c. Move this to file-item.c as it doesn't need to be global. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/file-item.c | 12 ++++++++++++ fs/btrfs/ordered-data.h | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 7bd6e1b91495..615e65b15463 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -132,6 +132,18 @@ static inline u32 max_ordered_sum_bytes(struct btrfs_fs_info *fs_info, return ncsums * fs_info->sectorsize; } +/* + * calculates the total size you need to allocate for an ordered sum + * structure spanning 'bytes' in the file + */ +static inline int btrfs_ordered_sum_size(struct btrfs_fs_info *fs_info, + unsigned long bytes) +{ + int num_sectors = (int)DIV_ROUND_UP(bytes, fs_info->sectorsize); + + return sizeof(struct btrfs_ordered_sum) + num_sectors * fs_info->csum_size; +} + int btrfs_insert_hole_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid, u64 pos, u64 num_bytes) diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 87792f85e2c4..ac6b8ef133aa 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -160,18 +160,6 @@ struct btrfs_ordered_extent { struct block_device *bdev; }; -/* - * calculates the total size you need to allocate for an ordered sum - * structure spanning 'bytes' in the file - */ -static inline int btrfs_ordered_sum_size(struct btrfs_fs_info *fs_info, - unsigned long bytes) -{ - int num_sectors = (int)DIV_ROUND_UP(bytes, fs_info->sectorsize); - - return sizeof(struct btrfs_ordered_sum) + num_sectors * fs_info->csum_size; -} - static inline void btrfs_ordered_inode_tree_init(struct btrfs_ordered_inode_tree *t) { From patchwork Wed Sep 14 23:04:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976616 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 55BC5ECAAD3 for ; Wed, 14 Sep 2022 23:05:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbiINXFT (ORCPT ); Wed, 14 Sep 2022 19:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbiINXFM (ORCPT ); Wed, 14 Sep 2022 19:05:12 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3EED5208E for ; Wed, 14 Sep 2022 16:05:10 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id c19so10149606qkm.7 for ; Wed, 14 Sep 2022 16:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=IJ8ywYZKmUwHnTrQRqY8oE7rBMDhidpHtuV4magLbVE=; b=MGiCSMWeQBTy+5F1IycbP/TXZp73zr4Vud1uV/jGV9H6BH+QUNLWTN24jtIYEZv7Dx 0xEv3IBwI0fDl37J5QquO69jc+qh3PsJodK5vpgnPn4EPYzkUE+t9QyKULKUN2nas+OO hv6Xp5Hne8nIzmVLX8sbaUeNTXw9zwiVKrsCQUmwQ3G41T2f0U1bDh3F7WeflVPadZ2v ipNXAIShZDT9xYon6Oc6BU4VD9YUrNuLTCMZ11IaEllrm5VLVTSFbCPmS4OKVMTMmcui pAJpBALQOOeb+7FmvCGZZMqOq/r2r/Z3411U6l/xL1h0iniyW/yLpuIIEHGP+9zcwNEX otSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=IJ8ywYZKmUwHnTrQRqY8oE7rBMDhidpHtuV4magLbVE=; b=37UyBcK0LiiRw6d3++RIYmQBNc4RxWTqqwrkt0GkAXJlPvHCjZQKaD2WjW8YDCx/Ys 5zl7rUvYDNh3oANnsLOfU5kZW0ya7hVoW5BJAjlP5W8mXAcAH32QzSYwd/9woZ9+YB3w eDEGC2NTxEy82CTUpr1XhIdQFhGEUM0fz9lpz7+8PI23mzkqVuqV4TtIKBXcSo2JwUnC CpydGV9cOoWEygUG22YVqzWcNU6iecKK0E45NzPiXutI29ETibUPGeOGNOtf/VjzOKGD v2r9LfYGjjjArxWAOCmzGVRrLLTKMmuPiIx/y6a2xr5FV1GsjaEijji+dQZfKwPdDfQd SkdA== X-Gm-Message-State: ACgBeo0pVSXLoJR6i+1lAcQL2tPizZ1fSKhEGG3tWKHx4crMbta/9Dj9 GK2ybQ8ytJZxjkqM3R4ErsHQ7yvuKqVMfg== X-Google-Smtp-Source: AA6agR5+ymwzKOHSkDNHJ16QZGRTQf7NMCpbPZDXLAsyww9k+5LMWq/Z3qsKsm8LYOHsFK9z6ClgDQ== X-Received: by 2002:a05:620a:489a:b0:6ce:4014:5455 with SMTP id ea26-20020a05620a489a00b006ce40145455mr11853841qkb.716.1663196709575; Wed, 14 Sep 2022 16:05:09 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id u16-20020a05620a0c5000b006bbe7ded98csm2739565qki.112.2022.09.14.16.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:09 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 12/15] btrfs: delete btrfs_inode_sectorsize helper Date: Wed, 14 Sep 2022 19:04:48 -0400 Message-Id: <030e2b0b061a8ae57037f810ae3bfb2b4c9b0f4d.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is defined in btrfs_inode.h, and dereferences btrfs_root and btrfs_fs_info, both of which aren't defined in btrfs_inode.h. Additionally, in many places we already have root or fs_info, so this helper often makes the code harder to read. So delete the helper and simply open code it in the few places that we use it. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/btrfs_inode.h | 5 ----- fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/file.c | 11 +++++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 890c9f979a3d..b24f78145fa6 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -251,11 +251,6 @@ struct btrfs_inode { struct inode vfs_inode; }; -static inline u32 btrfs_inode_sectorsize(const struct btrfs_inode *inode) -{ - return inode->root->fs_info->sectorsize; -} - static inline struct btrfs_inode *BTRFS_I(const struct inode *inode) { return container_of(inode, struct btrfs_inode, vfs_inode); diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index b1d57727be02..f5eb6c66911c 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3925,8 +3925,8 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, goto out; } - lockstart = round_down(start, btrfs_inode_sectorsize(inode)); - lockend = round_up(start + len, btrfs_inode_sectorsize(inode)); + lockstart = round_down(start, root->fs_info->sectorsize); + lockend = round_up(start + len, root->fs_info->sectorsize); prev_extent_end = lockstart; lock_extent(&inode->io_tree, lockstart, lockend, &cached_state); diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index c395bf8e7522..c418468428ad 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3010,9 +3010,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len) if (ret) goto out_only_mutex; - lockstart = round_up(offset, btrfs_inode_sectorsize(BTRFS_I(inode))); - lockend = round_down(offset + len, - btrfs_inode_sectorsize(BTRFS_I(inode))) - 1; + lockstart = round_up(offset, fs_info->sectorsize); + lockend = round_down(offset + len, fs_info->sectorsize) - 1; same_block = (BTRFS_BYTES_TO_BLKS(fs_info, offset)) == (BTRFS_BYTES_TO_BLKS(fs_info, offset + len - 1)); /* @@ -3214,7 +3213,7 @@ enum { static int btrfs_zero_range_check_range_boundary(struct btrfs_inode *inode, u64 offset) { - const u64 sectorsize = btrfs_inode_sectorsize(inode); + const u64 sectorsize = inode->root->fs_info->sectorsize; struct extent_map *em; int ret; @@ -3244,7 +3243,7 @@ static int btrfs_zero_range(struct inode *inode, struct extent_changeset *data_reserved = NULL; int ret; u64 alloc_hint = 0; - const u64 sectorsize = btrfs_inode_sectorsize(BTRFS_I(inode)); + const u64 sectorsize = fs_info->sectorsize; u64 alloc_start = round_down(offset, sectorsize); u64 alloc_end = round_up(offset + len, sectorsize); u64 bytes_to_reserve = 0; @@ -3430,7 +3429,7 @@ static long btrfs_fallocate(struct file *file, int mode, u64 data_space_reserved = 0; u64 qgroup_reserved = 0; struct extent_map *em; - int blocksize = btrfs_inode_sectorsize(BTRFS_I(inode)); + int blocksize = BTRFS_I(inode)->root->fs_info->sectorsize; int ret; /* Do not allow fallocate in ZONED mode */ From patchwork Wed Sep 14 23:04:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976618 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 5123FC6FA82 for ; Wed, 14 Sep 2022 23:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiINXFV (ORCPT ); Wed, 14 Sep 2022 19:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbiINXFN (ORCPT ); Wed, 14 Sep 2022 19:05:13 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D175208E for ; Wed, 14 Sep 2022 16:05:12 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id c19so10149645qkm.7 for ; Wed, 14 Sep 2022 16:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=lDeKs++bIBWyKbnlwC68WUE/KZoeEZt0DgP2cAcds2U=; b=IBv7+KaDCEcfS/EQuVVsEP+4CKwl5y0oXsSv9eJ0gt5MB5D2WuwnJDOO8uHY3qgRJi 6N6S3RK+Badv2kfykccZLmPovgIGx8sx6aA1x4bz8GEp1nM4cUTQ/NYltY15F5Iywzs7 7RWW5ZacjvRiTJLZ9UjIOD/yTfyfiN/5i0M3cq/ahNI+aCGna3wy1UlCOEJSmKPdFcIj +fr/ZzIzgrcNN2hu9eFMQfdqSivyG0jEFgFpZWMUWbU2csx6ehJ4VBjHu7lGzq1GooRe Wv+IN+rq7oPareaQA4tuu3bbxiezS6+HMkpUT8vCcbY/3BylraiRI2IRQsPLNTJ7dp6u Rljg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=lDeKs++bIBWyKbnlwC68WUE/KZoeEZt0DgP2cAcds2U=; b=IS90PXnBpgWEglbwXn+hqAOIwyK5EmAiWugDgwTFGpGeNx0L52SSgbwcUUzGblAJn1 OoHG3zBWDF4Cp5HnR9f+Ov7MlrMVKaRqt/EfQd0EEddz8HtDrHP/UdyWyt+yIu0Fw9ty JoWhhEZaJzfMUbX77TjB0PYjPymd8aW8sI2X2ZDkdRwV8Qt6jaHEZ2GwERq1BrGvIajy 1O1Ef9tFkp2FpBkDYuoJ3/fu2Odq0Jj11Djm7BLLeP772nxf6CMbg1Xq0ya5+WR2RX5C UUxI61rMFpJbjWNKXtt+EjDjRvjrc/Wryv8XfpLEWdvdY8yZR9FXe/arssAxUbIw01D7 Rk+Q== X-Gm-Message-State: ACgBeo3K8Lh7Yvm8/yR8TKNgTiP9CGxdQPH8eF+51Pwf4pMjfmeILWBK i1otymqR8Cb19Q5nFTkDDUfQGXgSe4R50Q== X-Google-Smtp-Source: AA6agR6QbO8O9WlW79Gg+1ooDP/d8bx0W5QopELTbQmih5yrQnDjj0QMihWBjFXY1JtHwFEWMm+x3g== X-Received: by 2002:a37:ef0d:0:b0:6bb:4ec8:b312 with SMTP id j13-20020a37ef0d000000b006bb4ec8b312mr27929926qkk.249.1663196711544; Wed, 14 Sep 2022 16:05:11 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id o9-20020ac85a49000000b0035c11fd1b49sm2566040qta.80.2022.09.14.16.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:10 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 13/15] btrfs: delete btrfs_insert_inode_hash helper Date: Wed, 14 Sep 2022 19:04:49 -0400 Message-Id: <36293c3f222b706b007147efbba1f793793ae0cd.1663196541.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This exists to insert the btree_inode in the super blocks inode hash table. Since it's only used for the btree inode move the code to where we use it in disk-io.c and remove the helper. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/btrfs_inode.h | 7 ------- fs/btrfs/disk-io.c | 4 +++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index b24f78145fa6..44edc6a3db6b 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -268,13 +268,6 @@ static inline unsigned long btrfs_inode_hash(u64 objectid, return (unsigned long)h; } -static inline void btrfs_insert_inode_hash(struct inode *inode) -{ - unsigned long h = btrfs_inode_hash(inode->i_ino, BTRFS_I(inode)->root); - - __insert_inode_hash(inode, h); -} - #if BITS_PER_LONG == 32 /* diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 124c210c4e02..0f925b896fca 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2227,6 +2227,8 @@ static void btrfs_init_balance(struct btrfs_fs_info *fs_info) static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info) { struct inode *inode = fs_info->btree_inode; + unsigned long hash = btrfs_inode_hash(BTRFS_BTREE_INODE_OBJECTID, + fs_info->tree_root); inode->i_ino = BTRFS_BTREE_INODE_OBJECTID; set_nlink(inode, 1); @@ -2248,7 +2250,7 @@ static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info) BTRFS_I(inode)->location.type = 0; BTRFS_I(inode)->location.offset = 0; set_bit(BTRFS_INODE_DUMMY, &BTRFS_I(inode)->runtime_flags); - btrfs_insert_inode_hash(inode); + __insert_inode_hash(inode, hash); } static void btrfs_init_dev_replace_locks(struct btrfs_fs_info *fs_info) From patchwork Wed Sep 14 23:04:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976617 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 2A043C6FA86 for ; Wed, 14 Sep 2022 23:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbiINXFV (ORCPT ); Wed, 14 Sep 2022 19:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbiINXFO (ORCPT ); Wed, 14 Sep 2022 19:05:14 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B85925A819 for ; Wed, 14 Sep 2022 16:05:13 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id s13so12907244qvq.10 for ; Wed, 14 Sep 2022 16:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=YkYpwOZ3ipijD5TV2M7lqztPnS1fiH1tauIgb8biVpQ=; b=j+w7r+/sncW5MKWNRf4ANBc5DEoB/wVZ0oy0pnavHNztMxI8o6a+pNdlXPAvMZ5+bw VPugZ0jtaCw3i+dUzbTJFb9fRQmB5cziniXtD4+gX1rc2WZesjpS0exT8y2DLaGBWhY6 f2jzeYL8510EjBGogdcWzW97mZFOKBnEJ0HPhiunU9VbVtVM00hoA9pdLgMOSE/MV6gE hro7nXzibC+ulAaHySxaJGYBe8UYPR361rHRtUBL5JxN9euRks69svizitzrv0BdpRoQ 6Uyn9LI1fUd6w4osyRsSeUm65DJnrsN2j8SWJWLXi/2CfTX8EHkDQrgq4L8SB7nzcm0H dXAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YkYpwOZ3ipijD5TV2M7lqztPnS1fiH1tauIgb8biVpQ=; b=p/5B4K4Cy7bBAtnJkAsVpC07y8vFrV3EAeullxH3avhs/5dcFvQMWHdUASnIa3RcZM IVffQMbWCKoyoR97HpLwbLzUnkFA01ORvOLa7hm3xANa+qTSGRtOLpoCPJo/qFJQVmz/ 2qYpu7Dd99lxfV2aoSiO5THy2oGCjuK2nYz/6ycAI0N7t/q+U4ZQYT55JZIBR7z5H40s /Ja7PT0axFwLUA/yhukCA3dCa0rXOZXQKGJzUOgYYpFkiRgCG/tx2WIGOok9ZIghSRxy ZsS6Y0YuAE9JETJ2uCGeZlPOJ7xKpt/LMQ8eT3JSLLS50dRaHVcoJfjXYOVZoo9RA+PJ dbGA== X-Gm-Message-State: ACgBeo0LzlpZXb2FY2ie29R5mT7yDkreJAEKHZ95eO/bJzMP41C2MKBC 0xOMgFpP+l9w84jxdhY9PbGsoDiC0Z4ckg== X-Google-Smtp-Source: AA6agR6J8ujVQXfZM/6t3KVP3GpS4BRxU9L2LLDMMBNlA5M8vfLckynlcJhsx63bTDSi/UxDSCSxSg== X-Received: by 2002:a05:6214:20e3:b0:4a7:618d:44d8 with SMTP id 3-20020a05621420e300b004a7618d44d8mr33820963qvk.47.1663196713028; Wed, 14 Sep 2022 16:05:13 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id d21-20020ac86695000000b0035bbb0fe90bsm2360895qtp.47.2022.09.14.16.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:12 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 14/15] btrfs: use a runtime flag to indicate an inode is a free space inode Date: Wed, 14 Sep 2022 19:04:50 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We always check the root of an inode as well as it's inode number to determine if it's a free space inode. This is problematic as the helper is in a header file where it doesn't have the fs_info definition. To avoid this and make the check a little cleaner simply add a flag to the runtime_flags to indicate that the inode is a free space inode, set that when we create the inode, and then change the helper to check for this flag. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/btrfs_inode.h | 10 +++------- fs/btrfs/inode.c | 5 +++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 44edc6a3db6b..530a0ebfab3f 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -65,6 +65,8 @@ enum { * on the same file. */ BTRFS_INODE_VERITY_IN_PROGRESS, + /* Set when this inode is a free space inode. */ + BTRFS_INODE_FREE_SPACE_INODE, }; /* in memory btrfs inode */ @@ -301,13 +303,7 @@ static inline void btrfs_i_size_write(struct btrfs_inode *inode, u64 size) static inline bool btrfs_is_free_space_inode(struct btrfs_inode *inode) { - struct btrfs_root *root = inode->root; - - if (root == root->fs_info->tree_root && - btrfs_ino(inode) != BTRFS_BTREE_INODE_OBJECTID) - return true; - - return false; + return test_bit(BTRFS_INODE_FREE_SPACE_INODE, &inode->runtime_flags); } static inline bool is_data_inode(struct inode *inode) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 62dc3dcf835b..1f38d9b98132 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5731,6 +5731,11 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p) BTRFS_I(inode)->location.offset = 0; BTRFS_I(inode)->root = btrfs_grab_root(args->root); BUG_ON(args->root && !BTRFS_I(inode)->root); + + if (args->root && args->root == args->root->fs_info->tree_root && + args->ino != BTRFS_BTREE_INODE_OBJECTID) + set_bit(BTRFS_INODE_FREE_SPACE_INODE, + &BTRFS_I(inode)->runtime_flags); return 0; } From patchwork Wed Sep 14 23:04:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976619 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 8495DC6FA8A for ; Wed, 14 Sep 2022 23:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229921AbiINXFX (ORCPT ); Wed, 14 Sep 2022 19:05:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiINXFQ (ORCPT ); Wed, 14 Sep 2022 19:05:16 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7601D5019C for ; Wed, 14 Sep 2022 16:05:15 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id y2so12377224qtv.5 for ; Wed, 14 Sep 2022 16:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=obqgsjuuQyDcinAsjpgqKHw8Na5YVFKdP9e3Fam5DnM=; b=hBuTHVDur/oRx33hLdraEytECL/JTN2bZhv9xhOuYJjbOsueTKp04ZkBe2Mh/XmI+W HGX7PHBHk19aw84W/kcsaUf8yRLR1pO8TEErWdPVCJQy/lEfQuCeEZPwMQA6qFatFn8J 5tcarE49cQ5nPQHZJ7rWvifk9cBjBk3oDQDivRCHxrRVlCTJBgEhvLjb6FdwzHDKmKWM f2BnZW/MXaPJNDpXrLINpnEgpmOQytrptAO6Og3aawdyQDjQ/XRM1xurisIOYEVp6vJH 8DA3BXBdoy7p50re/o6ua3/I4r2Oeo+XIqsU+GoL6Tc6TfxgKiilcU8q2aoKr9jNDjJP OL5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=obqgsjuuQyDcinAsjpgqKHw8Na5YVFKdP9e3Fam5DnM=; b=7GDuJqF9eh/6A5NQMRQOGvuBoI9fJWpwIKafQXM+U8rNFp1fmmIUxPFsH4o99xMLo9 6wVteny2S6cFBScWhWHfi6NUTq0m2m3aW5+hDMPg0unkiGJYvkMSSRjf7D0vs1gaK+Ov dbOmgmMn7wFuaNhpo4mj4si4L0HzxO1TgZNbh7TUo1c7zdpzJ7EdlVEVm6UuNJeM4/LO 8riFqDm5+z74DA8CY9oB8UB9/BbrUsN3Zow8GMHdRmcDqFLKQW/fRMtVLT940Ukn3GuU qpFxmmfiEPwjzKrTqxTBPeQuvkgAd0kLKHs1XEn91nf4Fb6bsOUMJy6P6vl0mndbM96N RrOw== X-Gm-Message-State: ACgBeo0fhnFy6cCHjUe5+OO58gaPPqjiDnKsBuIMdjqmqzWwDttmeohi G6hMB2oK36LStMpgaDRk+lBp6slfP1ijkg== X-Google-Smtp-Source: AA6agR7VY46TZ24JV7/26Q2LtmiLkIb2Aa4gPPsXLgIHaMJO5QENLHObwNRsjC7u/vRbvy94ugeIsw== X-Received: by 2002:ac8:7d90:0:b0:35b:afd3:20aa with SMTP id c16-20020ac87d90000000b0035bafd320aamr17537694qtd.252.1663196714635; Wed, 14 Sep 2022 16:05:14 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id h1-20020a05620a244100b006cbcdc6efedsm2846755qkn.41.2022.09.14.16.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 16:05:14 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 15/15] btrfs: add struct declarations in dev-replace.h Date: Wed, 14 Sep 2022 19:04:51 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org dev-replace.h just has function prototypes for device replace, however if you happen to include it in the wrong order you'll get compile errors because of different structures not being defined. Since these are just pointer args to functions we can declare them at the top in order to reduce the pain of using the header. Signed-off-by: Josef Bacik Reviewed-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/dev-replace.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/dev-replace.h b/fs/btrfs/dev-replace.h index 3911049a5f23..6084b313056a 100644 --- a/fs/btrfs/dev-replace.h +++ b/fs/btrfs/dev-replace.h @@ -7,6 +7,10 @@ #define BTRFS_DEV_REPLACE_H struct btrfs_ioctl_dev_replace_args; +struct btrfs_fs_info; +struct btrfs_trans_handle; +struct btrfs_dev_replace; +struct btrfs_block_group; int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info); int btrfs_run_dev_replace(struct btrfs_trans_handle *trans);