From patchwork Fri Sep 3 14:44:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12474525 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 7469DC433FE for ; Fri, 3 Sep 2021 14:45:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FFCF610FA for ; Fri, 3 Sep 2021 14:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349033AbhICOqB (ORCPT ); Fri, 3 Sep 2021 10:46:01 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12649 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235394AbhICOqB (ORCPT ); Fri, 3 Sep 2021 10:46:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1630680301; x=1662216301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zPl1Kb2xxD/sV+r0/CoOpxRrM5fVBtpaOd7IzKRg3xM=; b=JnMcn8NPKm0hTV93730NZSJTUMwIqVh4mzqyZ0ptfDTmG7cN3XzaNOG2 z9zAP5qOhdPntDs5RCCcmr3NXhJT+Dez76Ag+W7+QQvOQwR87I+WkZrUp 94ODTcaTQTIvLNWnCt/1GiKM6EaE9XdoLWnziZe8Yk/Uhc8O5i19SjQko 1LBRa/gWXAit9nFeURWeWPs9r6MWfy3H6Akl5J1Un+1/uYDCZx9JPsX2i 7T/dmEDNRV0zujYfQ6KYyO9niY5tBAjnzN+KYh0xn/ltUtY1841bsaeAB S/CaPCSlA0Vt6XNmeek8b4S0GizMXb1N7aRZCAdRr5wLrtxlAca96XRdJ g==; X-IronPort-AV: E=Sophos;i="5.85,265,1624291200"; d="scan'208";a="179681170" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2021 22:45:01 +0800 IronPort-SDR: vL+upddS3mWY5JeioF2r97ddU57UZkAkP0Pq+SVrV0N0pj34EGRqQdN5JbY3BAWkp1Ku+CBt56 YuxPc+zMcONec8wYamYCz+qAxkXdk5KOjY+XRWTs4v9HriQmdy997aZy735vS1H3CjppN9R3ET rChFkzBuK3OkDTeiSzXVyJdvIKbh9VLoIqHotzgcvE912Ku9VzoTsBa5tDbnlAoDDO1p31Qeol +1IsrGspIrKTn9R5g4rZC6s/Qn4RwBt3ANtRZ3PMcR1r/nhP8YC6p3kvEM1sobX4ltuyyTKdp2 vFy8S2eTjiIKSoAz4Y+pQUcC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 07:20:04 -0700 IronPort-SDR: kJkw5r0V31+MehgenUHj3qhcZhS5j/VqHOupNfRcDcayJSSdWGT9LSErEsfvVJpMeQgPfPsAbW UVLm0Uaas5olvPEbDaaD8sax/0qPIu4FfTSHclJsZ8qbvsitjCunR1enQzqyiIqN6BtgL07NWk DlkW6AGi1agrlfcsJAQkm6Pz1OkCdQQeyQGWKvvQS67QvX+39aX6RWshmpe6uVIruAUa+i9DZL nBdtCxlJ1rWQLS2R3SPqMRRs5mlUUH8k/olZAHu6OeMT0VfslFVBw/Lh1zB/kYSx2cglhEyhAA pLY= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2021 07:45:00 -0700 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org, Filipe Manana , Damien Le Moal , Naohiro Aota Subject: [PATCH 1/6] btrfs: introduce btrfs_is_data_reloc_root Date: Fri, 3 Sep 2021 23:44:42 +0900 Message-Id: <9f8e2c5add21ca257c7b5df8e86c87c2de9b672e.1630679569.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org There are several places in our codebase where we check if a root is the root of the data reloc tree and subsequent patches will introduce more. Factor out the check into a small helper function instead of open coding it multiple times. Signed-off-by: Johannes Thumshirn Reviewed-by: Naohiro Aota --- fs/btrfs/ctree.h | 5 +++++ fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/inode.c | 19 ++++++++----------- fs/btrfs/relocation.c | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 38870ae46cbb..8cc0b29e24ee 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3846,6 +3846,11 @@ static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info) return fs_info->zoned != 0; } +static inline bool btrfs_is_data_reloc_root(const struct btrfs_root *root) +{ + return root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID; +} + /* * We use page status Private2 to indicate there is an ordered extent with * unfinished IO. diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 41ea50f48cfe..9a6be409c1d6 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1500,7 +1500,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev) goto fail; if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && - root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) { + !btrfs_is_data_reloc_root(root)) { set_bit(BTRFS_ROOT_SHAREABLE, &root->state); btrfs_check_and_init_root_item(&root->root_item); } diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 7d03ffa04bce..239e09f7239a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2376,7 +2376,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset, out: btrfs_free_path(path); - if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID) + if (btrfs_is_data_reloc_root(root)) WARN_ON(ret > 0); return ret; } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0517f31a3bed..8e1a46e9c63e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1150,7 +1150,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, * fails during the stage where it updates the bytenr of file extent * items. */ - if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID) + if (btrfs_is_data_reloc_root(root)) min_alloc_size = num_bytes; else min_alloc_size = fs_info->sectorsize; @@ -1186,8 +1186,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, if (ret) goto out_drop_extent_cache; - if (root->root_key.objectid == - BTRFS_DATA_RELOC_TREE_OBJECTID) { + if (btrfs_is_data_reloc_root(root)) { ret = btrfs_reloc_clone_csums(inode, start, cur_alloc_size); /* @@ -1503,8 +1502,7 @@ static int fallback_to_cow(struct btrfs_inode *inode, struct page *locked_page, int *page_started, unsigned long *nr_written) { const bool is_space_ino = btrfs_is_free_space_inode(inode); - const bool is_reloc_ino = (inode->root->root_key.objectid == - BTRFS_DATA_RELOC_TREE_OBJECTID); + const bool is_reloc_ino = btrfs_is_data_reloc_root(inode->root); const u64 range_bytes = end + 1 - start; struct extent_io_tree *io_tree = &inode->io_tree; u64 range_start = start; @@ -1866,8 +1864,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, btrfs_dec_nocow_writers(fs_info, disk_bytenr); nocow = false; - if (root->root_key.objectid == - BTRFS_DATA_RELOC_TREE_OBJECTID) + if (btrfs_is_data_reloc_root(root)) /* * Error handled later, as we must prevent * extent_clear_unlock_delalloc() in error handler @@ -2206,7 +2203,7 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode, if (btrfs_is_testing(fs_info)) return; - if (root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID && + if (!btrfs_is_data_reloc_root(root) && do_list && !(state->state & EXTENT_NORESERVE) && (*bits & EXTENT_CLEAR_DATA_RESV)) btrfs_free_reserved_data_space_noquota(fs_info, len); @@ -2531,7 +2528,7 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio, goto mapit; } else if (async && !skip_sum) { /* csum items have already been cloned */ - if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID) + if (btrfs_is_data_reloc_root(root)) goto mapit; /* we're doing a write, do the async checksumming */ ret = btrfs_wq_submit_bio(inode, bio, mirror_num, bio_flags, @@ -3307,7 +3304,7 @@ unsigned int btrfs_verify_data_csum(struct btrfs_io_bio *io_bio, u32 bio_offset, u64 file_offset = pg_off + page_offset(page); int ret; - if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID && + if (btrfs_is_data_reloc_root(root) && test_range_bit(io_tree, file_offset, file_offset + sectorsize - 1, EXTENT_NODATASUM, 1, NULL)) { @@ -4008,7 +4005,7 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans, * without delay */ if (!btrfs_is_free_space_inode(inode) - && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID + && !btrfs_is_data_reloc_root(root) && !test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags)) { btrfs_update_root_times(trans, root); diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 63d2b22cf438..3c9c0aab7fc3 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4391,7 +4391,7 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans, return 0; BUG_ON(rc->stage == UPDATE_DATA_PTRS && - root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID); + btrfs_is_data_reloc_root(root)); level = btrfs_header_level(buf); if (btrfs_header_generation(buf) <= From patchwork Fri Sep 3 14:44:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12474529 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 30941C433F5 for ; Fri, 3 Sep 2021 14:45:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08ADC610F7 for ; Fri, 3 Sep 2021 14:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349337AbhICOqK (ORCPT ); Fri, 3 Sep 2021 10:46:10 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12649 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235394AbhICOqD (ORCPT ); Fri, 3 Sep 2021 10:46:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1630680303; x=1662216303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m6hv/4OZ8G39pKgWlH6xAh3CAio0uFL5AWu7lFvujPA=; b=nOI5YWLbZPZSKdovrxEfYCH1id7M/Er+2hLLngMATeGs4LeOR9J0gqR2 nDyre/muVBm4e6sHvJamcthJ8R995ZTakRF4oniXl0reJFexxWd+YCThE kn0HzYZzYAwV7I7B8AP2SrxZrarPKBpPVRpFOd5svNPHAF5inqHyNhRk5 p/6b2tpjxoAxgQ+Yqw1QUvI+jJN6e0b2J+jgVRA58B0ffWurCnbj6KVHN 7TvT3a+BTkU08LUjhseAmD9xDKjcmJHMBqSTW9REgBh288eT35LBVpgdK 1ZWX/ZK5gNuqUqY3DqaAgLv2JTBCt2Z9ftc5b2Tp848ZN9ih1D44QfF1M Q==; X-IronPort-AV: E=Sophos;i="5.85,265,1624291200"; d="scan'208";a="179681175" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2021 22:45:03 +0800 IronPort-SDR: DDZMHebLY343daH7yGrFH/TnrAwS5l8HziZchwbDMhzTjShsjIZSikc9gNcHbNayWvskuWzz6c qF3XYnAG42yVa9TLMQZftTY8RzKtZQkYYGjCDk3shcbdZ025FH5M109zAz9s8MnYtiI/Coo3Rv 6sX8RQzyVz6uTsQj4csvhps64CuMfuveAgSNhYJ7x9abej2/U88wFh06dsNaTg6+4pZhsZe6cg N6sX/3pDCsaQMm0ATPS/fhUFKHDQL92V34sjMNmQhMBrgTPAYiwJRV2Zl0drmhePtT+UzrRloe Nu95peQybbeLiwJjEbnmIOQ6 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 07:20:06 -0700 IronPort-SDR: mbC7fmBfMEyUjlJCohFMf6JaIGDw22JaqT7txuMHC74usGKHpAPE1h1EIzotpqFbdKsNG58wAy p8eRbsJ+Q8MIOyitJ5WtCBvA1n28gudr4Y08REXhCRLYB50rMriNGBh+lDaWZpqhUzuOQP35qk g96AkeuM2x2opSPuSnzNKhQspLXlNGRyiBAXEgt8/0mONOwMVcmYmsK6kM1Keq7K8U1KWrDg+6 nvx9Skp3iLhs6c0MDPx3NH7nsbDzwz3apsx+1m4yhG4X5nm61ReWnbo6iAbiRaSUNjXc1IQhBw SYw= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2021 07:45:02 -0700 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org, Filipe Manana , Damien Le Moal , Naohiro Aota Subject: [PATCH 2/6] btrfs: zoned: add a dedicated data relocation block group Date: Fri, 3 Sep 2021 23:44:43 +0900 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Relocation in a zoned filesystem can fail with a transaction abort with error -22 (EINVAL). This happens because the relocation code assumes that the extents we relocated the data to have the same size the source extents had and ensures this by preallocating the extents. But in a zoned filesystem we currently can't preallocate the extents as this would break the sequential write required rule. Therefore it can happen that the writeback process kicks in while we're still adding pages to a delallocation range and starts writing out dirty pages. This then creates destination extents that are smaller than the source extents, triggering the following safety check in get_new_location(): 1034 if (num_bytes != btrfs_file_extent_disk_num_bytes(leaf, fi)) { 1035 ret = -EINVAL; 1036 goto out; 1037 } Temporarily create a dedicated block group for the relocation process, so no non-relocation data writes can interfere with the relocation writes. This is needed that we can switch the relocation process on a zoned filesystem from the REQ_OP_ZONE_APPEND writing we use for data to a scheme like in a non-zoned filesystem using REQ_OP_WRITE and preallocation. Fixes: 32430c614844 ("btrfs: zoned: enable relocation on a zoned filesystem") Signed-off-by: Johannes Thumshirn Reviewed-by: Naohiro Aota --- fs/btrfs/block-group.c | 1 + fs/btrfs/ctree.h | 2 ++ fs/btrfs/disk-io.c | 1 + fs/btrfs/extent-tree.c | 50 ++++++++++++++++++++++++++++++++++++++++-- fs/btrfs/zoned.h | 9 ++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 1302bf8d0be1..46fdef7bbe20 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -903,6 +903,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, spin_unlock(&cluster->refill_lock); btrfs_clear_treelog_bg(block_group); + btrfs_clear_data_reloc_bg(block_group); path = btrfs_alloc_path(); if (!path) { diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8cc0b29e24ee..344ba70315d8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1017,6 +1017,8 @@ struct btrfs_fs_info { struct mutex zoned_meta_io_lock; spinlock_t treelog_bg_lock; u64 treelog_bg; + spinlock_t relocation_bg_lock; + u64 data_reloc_bg; spinlock_t zone_active_bgs_lock; struct list_head zone_active_bgs; diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 9a6be409c1d6..5541bc6fe8a7 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2885,6 +2885,7 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info) spin_lock_init(&fs_info->unused_bgs_lock); spin_lock_init(&fs_info->treelog_bg_lock); spin_lock_init(&fs_info->zone_active_bgs_lock); + spin_lock_init(&fs_info->relocation_bg_lock); rwlock_init(&fs_info->tree_mod_log_lock); mutex_init(&fs_info->unused_bg_unpin_mutex); mutex_init(&fs_info->reclaim_bgs_lock); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 239e09f7239a..644791150631 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3497,6 +3497,9 @@ struct find_free_extent_ctl { /* Allocation is called for tree-log */ bool for_treelog; + /* Allocation is called for data relocation */ + bool for_data_reloc; + /* RAID index, converted from flags */ int index; @@ -3758,6 +3761,7 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, u64 avail; u64 bytenr = block_group->start; u64 log_bytenr; + u64 data_reloc_bytenr; int ret = 0; bool skip; @@ -3775,6 +3779,18 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, if (skip) return 1; + /* + * Do not allow non-relocation blocks in the dedicated relocation block + * group, and vice versa. + */ + spin_lock(&fs_info->relocation_bg_lock); + data_reloc_bytenr = fs_info->data_reloc_bg; + skip = data_reloc_bytenr && + ((ffe_ctl->for_data_reloc && bytenr != data_reloc_bytenr) || + (!ffe_ctl->for_data_reloc && bytenr == data_reloc_bytenr)); + spin_unlock(&fs_info->relocation_bg_lock); + if (skip) + return 1; /* Check RO and no space case before trying to activate it */ spin_lock(&block_group->lock); if (block_group->ro || @@ -3790,10 +3806,14 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, spin_lock(&space_info->lock); spin_lock(&block_group->lock); spin_lock(&fs_info->treelog_bg_lock); + spin_lock(&fs_info->relocation_bg_lock); ASSERT(!ffe_ctl->for_treelog || block_group->start == fs_info->treelog_bg || fs_info->treelog_bg == 0); + ASSERT(!ffe_ctl->for_data_reloc || + block_group->start == fs_info->data_reloc_bg || + fs_info->data_reloc_bg == 0); if (block_group->ro) { ret = 1; @@ -3810,6 +3830,16 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, goto out; } + /* + * Do not allow currently used block group to be the data relocation + * dedicated block group. + */ + if (ffe_ctl->for_data_reloc && !fs_info->data_reloc_bg && + (block_group->used || block_group->reserved)) { + ret = 1; + goto out; + } + WARN_ON_ONCE(block_group->alloc_offset > block_group->zone_capacity); avail = block_group->zone_capacity - block_group->alloc_offset; if (avail < num_bytes) { @@ -3828,6 +3858,9 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, if (ffe_ctl->for_treelog && !fs_info->treelog_bg) fs_info->treelog_bg = block_group->start; + if (ffe_ctl->for_data_reloc && !fs_info->data_reloc_bg) + fs_info->data_reloc_bg = block_group->start; + ffe_ctl->found_offset = start + block_group->alloc_offset; block_group->alloc_offset += num_bytes; spin_lock(&ctl->tree_lock); @@ -3844,6 +3877,9 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, out: if (ret && ffe_ctl->for_treelog) fs_info->treelog_bg = 0; + if (ret && ffe_ctl->for_data_reloc) + fs_info->data_reloc_bg = 0; + spin_unlock(&fs_info->relocation_bg_lock); spin_unlock(&fs_info->treelog_bg_lock); spin_unlock(&block_group->lock); spin_unlock(&space_info->lock); @@ -4112,6 +4148,12 @@ static int prepare_allocation(struct btrfs_fs_info *fs_info, ffe_ctl->hint_byte = fs_info->treelog_bg; spin_unlock(&fs_info->treelog_bg_lock); } + if (ffe_ctl->for_data_reloc) { + spin_lock(&fs_info->relocation_bg_lock); + if (fs_info->data_reloc_bg) + ffe_ctl->hint_byte = fs_info->data_reloc_bg; + spin_unlock(&fs_info->relocation_bg_lock); + } return 0; default: BUG(); @@ -4245,6 +4287,8 @@ static noinline int find_free_extent(struct btrfs_root *root, if (unlikely(block_group->ro)) { if (ffe_ctl->for_treelog) btrfs_clear_treelog_bg(block_group); + if (ffe_ctl->for_data_reloc) + btrfs_clear_data_reloc_bg(block_group); continue; } @@ -4438,6 +4482,7 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, u64 flags; int ret; bool for_treelog = (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID); + bool for_data_reloc = (btrfs_is_data_reloc_root(root) && is_data); flags = get_alloc_profile_by_root(root, is_data); again: @@ -4451,6 +4496,7 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, ffe_ctl.delalloc = delalloc; ffe_ctl.hint_byte = hint_byte; ffe_ctl.for_treelog = for_treelog; + ffe_ctl.for_data_reloc = for_data_reloc; ret = find_free_extent(root, ins, &ffe_ctl); if (!ret && !is_data) { @@ -4470,8 +4516,8 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, sinfo = btrfs_find_space_info(fs_info, flags); btrfs_err(fs_info, - "allocation failed flags %llu, wanted %llu tree-log %d", - flags, num_bytes, for_treelog); + "allocation failed flags %llu, wanted %llu tree-log %d, relocation: %d", + flags, num_bytes, for_treelog, for_data_reloc); if (sinfo) btrfs_dump_space_info(fs_info, sinfo, num_bytes, 1); diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index 9c512402d7f4..1cf87bb1db08 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -347,4 +347,13 @@ static inline void btrfs_clear_treelog_bg(struct btrfs_block_group *bg) spin_unlock(&fs_info->treelog_bg_lock); } +static inline void btrfs_clear_data_reloc_bg(struct btrfs_block_group *bg) +{ + struct btrfs_fs_info *fs_info = bg->fs_info; + + spin_lock(&fs_info->relocation_bg_lock); + if (fs_info->data_reloc_bg == bg->start) + fs_info->data_reloc_bg = 0; + spin_unlock(&fs_info->relocation_bg_lock); +} #endif From patchwork Fri Sep 3 14:44:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12474531 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 2AD54C4332F for ; Fri, 3 Sep 2021 14:45:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15C96610E5 for ; Fri, 3 Sep 2021 14:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349511AbhICOqL (ORCPT ); Fri, 3 Sep 2021 10:46:11 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12660 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349117AbhICOqE (ORCPT ); Fri, 3 Sep 2021 10:46:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1630680305; x=1662216305; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tzgn+SA0Zz64WeFuI5q51Qn+YevhCFkQh2yR2wqnG8I=; b=L81VuRBjw14GiXhainGAtCdy9Rz8AGtrXsMwUFXXvtf+EAQlcICU69vR WnkmJrABGc1t4fC1+YRpm6T7Yqr+FfZk0ZdSRqgctN/jcy1Opd3LsAkqw w5xQBBuQDgsV4zaYuBSqEK2Kd3EwrX7URTmOpM0G2aHMJBFINv4QEqtwe cp9XVFPciz7TJEnYRJxf+XFOTIhEW8x0zHzGrg7WgjOuIINVO/a3n5D6w RRcwZUpHLHdZ6vPY4BGrXAEMjUnn3htakyTq8aiSwRmdn8jT/SipeEWcQ k6SNHM5Y3GDBBmTDojuYSKPEsZGZb4WMuYeFk5nqh4p8zlidT7DcVjga/ A==; X-IronPort-AV: E=Sophos;i="5.85,265,1624291200"; d="scan'208";a="179681178" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2021 22:45:05 +0800 IronPort-SDR: 11Z5kH52JT0dykkyLdJUp6qcBzXPloVF7L0rqf6UExjyXQBjieDp94t6kUA+fFq4C9S2iCjyG/ twJ8ENHqw7eTTdasPQuFPfntP6X1PMtt/j4NH8YsqUFW6DuKv9UOy4KrTX1V0Y6HNdrL1JSA4y UCvRhNCplQXmtRbAEEzjIirhL1LYflSrbt1c2TJgM9nGwF4S/Y1jB7/xLI6ESISCqnmFvZnaX0 lEovAAtlch9yE5bZvY73kxEevaVW5C173dvBGBoqp+dMm7FRz/GVd1iLH0IdOv1VId3navgd6Y 10xrWLHwNdjfqJEdnQ10gIMj Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 07:20:07 -0700 IronPort-SDR: ZOSrjFcjgY+RqoPoSMbhUWjEPaL2x4h4UwTYIdfkOrmZp/l/qypL2PpTxEQzKtRqEC0kU6nlNs dMvEYHqSy2ZU2v4vpQZx8NYTE5l9CjbQ2I1yC7Tv7jq0y/Iu113QRA1uFk+x4uQ9YOTY/ogMgp +pQnHJQUtXaey0Jdv6SWwHfNdhYl2w9LHC0dQtA0OIPbAUmrKX0G7XVdK4IqY2U6R4yhcDMBTD cL3b069qO7JEL1Nbv8G3rNUKMHPrYWwbZvJ8Z4G4JlmA9if9nT+LxIzJDFCHIVZqWx2oyHsn7u ELE= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2021 07:45:03 -0700 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org, Filipe Manana , Damien Le Moal , Naohiro Aota Subject: [PATCH 3/6] btrfs: zoned: use regular writes for relocation Date: Fri, 3 Sep 2021 23:44:44 +0900 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that we have a dedicated block group for relocation, we can use REQ_OP_WRITE instead of REQ_OP_ZONE_APPEND for writing out the data on relocation. Signed-off-by: Johannes Thumshirn Reviewed-by: Naohiro Aota --- fs/btrfs/zoned.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 28a06c2d80ad..be82823c9b16 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1490,6 +1490,9 @@ bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start) if (!is_data_inode(&inode->vfs_inode)) return false; + if (btrfs_is_data_reloc_root(inode->root)) + return false; + cache = btrfs_lookup_block_group(fs_info, start); ASSERT(cache); if (!cache) From patchwork Fri Sep 3 14:44:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12474527 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 AAC47C433EF for ; Fri, 3 Sep 2021 14:45:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 885F6610F9 for ; Fri, 3 Sep 2021 14:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349508AbhICOqK (ORCPT ); Fri, 3 Sep 2021 10:46:10 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12664 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349170AbhICOqG (ORCPT ); Fri, 3 Sep 2021 10:46:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1630680306; x=1662216306; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o1pPTApODhfhCGNE4ZarZZKzoOD7rJELNlvXKjukYnE=; b=eKKsLt/dx++F2eCNu9SFYeAA2WqpvR1RYtMU3pzTutWx4yucLUIt6yr7 OovJrD2jI6oqutljsc6moMYBQncKxiKmMIzXXQitUuaOKrb0WqXDqzmjO TBrCNZdXroWLubxvp6ra4L1nGLoR6hotS1v30hZvuMv2GVB9v2Wzp7P6H j1Skbj/1ueKtyVH8PICvHS507ACsDCf7HOjB1hW1nMmhgCwvNB/fQ1L/G K5pJffu8sBgoDD00tvLFCIeR5rDL2gn7vVEpVp7ycmpQvZ/CzKy0wEQJ+ J0NeFWW44I1w/pJ5oQkLe629g0gaEVvXUr3bkD2jxXpe/ZpJDB7gCi1L0 A==; X-IronPort-AV: E=Sophos;i="5.85,265,1624291200"; d="scan'208";a="179681181" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2021 22:45:06 +0800 IronPort-SDR: AEcgke1srxoXV0HsEUW2SIvR4I0UfIUagGSbIUXAaHFz8W/TGqRFWiRx1vsdI6HnYdfLRpyuuV zczS9hvZSqO2gs5YG8EWJMDgw0muyowbntQUDb76eA6lkAlaK0VRfJs5OMVweI4Jp0QjHJsHKy ydiyxQWcUv2mKBk0IpyuJysNK/jkIuBAevf88EipAGX41R4SD+mLCwHt0UdDeCEfhTFfZXxpJ0 uEwtIP9W/ahT1+x1yyDiTgpFw81S1FH3M6tmEaRY6JH7zNWkCuz0hYLSamCdFabnb13IAFIyZJ Ma2cPI4707lkW4NtrROBSdWW Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 07:20:09 -0700 IronPort-SDR: ccHBJGN60IVW9esFzJkjuZ5pFgmS29S5xnHSFZbAfMdKe5hyZrEZmW2fU2Ro5r0eVx/7bxVxpR z9OE1J8MKNtuiyilpLQ5cr+Bx8DkwJ6OdCv8omN5Q4aM8ip3NAs4u/rjFNUM2OGSPBlBdUiEJR RfcQwTCmv58kXlHC3is+XWgaxYOTLOUsxq3TP7irHEb8vW7gsF2wyi862iZF0GxoqgAr+AoHiS +AlxI84N8NyP2usqW40GYx8U51kFwQ5xzpaKqgmkSlByyCiPyZ6XeWCLOaVVwzJFOVOQH4daVM 75g= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2021 07:45:05 -0700 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org, Filipe Manana , Damien Le Moal , Naohiro Aota Subject: [PATCH 4/6] btrfs: check for relocation inodes on zoned btrfs in should_nocow Date: Fri, 3 Sep 2021 23:44:45 +0900 Message-Id: <4ab859fbb26ec582130b8064621cac9de1100baf.1630679569.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Prepare for allowing preallocation for relocation inodes. Signed-off-by: Johannes Thumshirn Reviewed-by: Naohiro Aota --- fs/btrfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8e1a46e9c63e..5f4c8e12ebcc 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1944,7 +1944,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page const bool zoned = btrfs_is_zoned(inode->root->fs_info); if (should_nocow(inode, start, end)) { - ASSERT(!zoned); + ASSERT(!zoned || + (zoned && btrfs_is_data_reloc_root(inode->root))); ret = run_delalloc_nocow(inode, locked_page, start, end, page_started, nr_written); } else if (!inode_can_compress(inode) || From patchwork Fri Sep 3 14:44:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12474533 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 1215CC433FE for ; Fri, 3 Sep 2021 14:45:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB857610F7 for ; Fri, 3 Sep 2021 14:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349513AbhICOqL (ORCPT ); Fri, 3 Sep 2021 10:46:11 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12649 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349217AbhICOqH (ORCPT ); Fri, 3 Sep 2021 10:46:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1630680308; x=1662216308; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wLfeO5bWCLkRRy8IvRP5oFdgttxSgpU6ArkEPp/BnLI=; b=dKNPOH0zKpXvc8MrQl51MUi7+4UodzxgXZBtu7ilwDg9U9cqOzRnzisn nP5HRhhnWmf7y8hEp1wR0Fq2w5Z1/sWFhpTS0PPcgQ70wDVtIG4g+KZHS yBOU22TeQz4Lj1j7S/BwyQUdOknIWp6/wUzSRJ5fN49JTeukpeTuGGIrk fdVE8hXVe+mepQPrQogYf3ulwDWyjrgS3ta1odWiAy0QaYmTiMn9iiFxm xM12pXjZNsOuRgUnc6YHfzp0A4AR08RsE8d42e8/8qdC9F+V99753kljm LiLCAt17KRNf/nW9xsTM4pDgCD7wHudvyJ4U3JZB7na745CoGM3N/adCp g==; X-IronPort-AV: E=Sophos;i="5.85,265,1624291200"; d="scan'208";a="179681185" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2021 22:45:08 +0800 IronPort-SDR: W/+YXL1NKamFLcu/OlTrUdH6ce8WHMzBMQ0A2RrtgaXeVPlYwKL6woeqJG9cUXqCNX9TkYnIml cm99hy+hm4tbAwxSJ9I1kIAYl8wKwXwhtiOWPObEeDv5YXSV//s344d0lx6+Z/5Ppc36cG7vlT pSwoXgHOdFFTzx4Kr258xSmobOCfdjpYo9baaYJVc9wAKkNPj7V7C/ZlE8wpxy4OI/Wh7H787v jIuE8dg2o7XrM2po76NnXR/IiQ8wnocU3MNNEPOM4nmsu6vHJW79PsbpSc19n+Gk1+c4Y0Z7HL MmjD8ua3v1kkhC/dntqXA+mH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 07:20:10 -0700 IronPort-SDR: LjMB1ZXBr7hp0yoCxDIhprpEUE6zwFuvYaPDVZABGxcKQzA2Tswr1iWM1vyc968HVc76ibLnvs 74UPOaT/1saL8VFeiZWKUiDKAORNXezZFoEDbC3nwidG9dquHvzoK3ZDThJPPku8y8FHTzExwD nD6BXzF/kenKGMMfDLK0Uvwiq5WSmoW4w5Gy6lz9XQXzu160CSrOE1HpBmov6MOic+PxmDTNAv EJ0HQLpr3ofvOFpOizSaTVrNhveM85B3OYkZue4VypMlkOBGBkuWnvKs9WeM9dYyx+cdu+abk0 1P8= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2021 07:45:06 -0700 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org, Filipe Manana , Damien Le Moal , Naohiro Aota Subject: [PATCH 5/6] btrfs: zoned: allow preallocation for relocation inodes Date: Fri, 3 Sep 2021 23:44:46 +0900 Message-Id: <51f7e2a92f41d5c45861aedf5f518a94e57b0559.1630679569.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that we use a dedicated block group and regular WRITEs for data relocation, we can preallocate the space needed for a relocated inode, just like regular btrfs does as well. Essentially this reverts commit 32430c614844 ("btrfs: zoned: enable relocation on a zoned filesystem") as it is not needed anymore. Signed-off-by: Johannes Thumshirn --- fs/btrfs/relocation.c | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 3c9c0aab7fc3..6f668bc01cd1 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2853,31 +2853,6 @@ static noinline_for_stack int prealloc_file_extent_cluster( if (ret) return ret; - /* - * On a zoned filesystem, we cannot preallocate the file region. - * Instead, we dirty and fiemap_write the region. - */ - if (btrfs_is_zoned(inode->root->fs_info)) { - struct btrfs_root *root = inode->root; - struct btrfs_trans_handle *trans; - - end = cluster->end - offset + 1; - trans = btrfs_start_transaction(root, 1); - if (IS_ERR(trans)) - return PTR_ERR(trans); - - inode->vfs_inode.i_ctime = current_time(&inode->vfs_inode); - i_size_write(&inode->vfs_inode, end); - ret = btrfs_update_inode(trans, root, inode); - if (ret) { - btrfs_abort_transaction(trans, ret); - btrfs_end_transaction(trans); - return ret; - } - - return btrfs_end_transaction(trans); - } - btrfs_inode_lock(&inode->vfs_inode, 0); for (nr = 0; nr < cluster->nr; nr++) { start = cluster->boundary[nr] - offset; @@ -3085,7 +3060,6 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra, static int relocate_file_extent_cluster(struct inode *inode, struct file_extent_cluster *cluster) { - struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); u64 offset = BTRFS_I(inode)->index_cnt; unsigned long index; unsigned long last_index; @@ -3115,8 +3089,6 @@ static int relocate_file_extent_cluster(struct inode *inode, for (index = (cluster->start - offset) >> PAGE_SHIFT; index <= last_index && !ret; index++) ret = relocate_one_page(inode, ra, cluster, &cluster_nr, index); - if (btrfs_is_zoned(fs_info) && !ret) - ret = btrfs_wait_ordered_range(inode, 0, (u64)-1); if (ret == 0) WARN_ON(cluster_nr != cluster->nr); out: @@ -3771,12 +3743,8 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans, struct btrfs_path *path; struct btrfs_inode_item *item; struct extent_buffer *leaf; - u64 flags = BTRFS_INODE_NOCOMPRESS | BTRFS_INODE_PREALLOC; int ret; - if (btrfs_is_zoned(trans->fs_info)) - flags &= ~BTRFS_INODE_PREALLOC; - path = btrfs_alloc_path(); if (!path) return -ENOMEM; @@ -3791,7 +3759,8 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans, btrfs_set_inode_generation(leaf, item, 1); btrfs_set_inode_size(leaf, item, 0); btrfs_set_inode_mode(leaf, item, S_IFREG | 0600); - btrfs_set_inode_flags(leaf, item, flags); + btrfs_set_inode_flags(leaf, item, BTRFS_INODE_NOCOMPRESS | + BTRFS_INODE_PREALLOC); btrfs_mark_buffer_dirty(leaf); out: btrfs_free_path(path); From patchwork Fri Sep 3 14:44:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12474535 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 9F9B7C433EF for ; Fri, 3 Sep 2021 14:45:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 862DE610E5 for ; Fri, 3 Sep 2021 14:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349515AbhICOqM (ORCPT ); Fri, 3 Sep 2021 10:46:12 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:12660 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349135AbhICOqJ (ORCPT ); Fri, 3 Sep 2021 10:46:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1630680310; x=1662216310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Ohw8+ybSIjVsjs5LzNsaXBrxLTuHbJ9sIJFja805HI=; b=Ybk6+y7s53MB2iR58aprpx45JqW3XPvOXczg7MK+RMV7nam4i5u/XVhv 4gMXDvVaElKeu9NnWYo3i9PWC1d975YdBjSq/FPFOshcWgazbFdUR1RV4 0WVIHegcRlTkjwasbXluQPAjLnNglcaDQ1/8yaN9NSlVeoEMzozj7vSWS IFX3ofDIZNMcAQPe9fRkMu6a80ZHpwqiycwSUSTn7QHCy7o8hK4vWwjnZ /jbYSiVKvjK4gt3SbqCao8TN9mvJukrUAd66ywb1Zx5apTY0Y2zT1++nP elGuLW4jkI4U4NHxdOae4RRZXagvWs+9UGPipRwmO88BxWA70IU4msRor w==; X-IronPort-AV: E=Sophos;i="5.85,265,1624291200"; d="scan'208";a="179681189" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2021 22:45:10 +0800 IronPort-SDR: 1lQk6pd0v+EGDQG1zpJYcN+s0Mo/RPYM7TnYQi8a3SxhV8oXZzgcBFLwVpRszPgjuv5I5WzQI7 /IzhgoFNOp/J7m0b8zlrEK4Ef640hjAUGHtXUicP1xM0YuOgRvbUvhLWLdR7t/6qTZ79QWCGqo OG4bxIxlx/cRiAlJyQ7E0+CZRJhyGykkyafvrIdZ1rtNJvMvSoRNuJrwYcG4YUtANB7g5SqUH7 2kgqVoQBitlZ9a/QOBHceTJ+wqRWSe+8Q9jHn60w0/rzXJ+M8Xrf/91Xy0CeMTIELDhqairjq7 0qSITCVd5NDw0WW3EI0p4vey Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 07:20:12 -0700 IronPort-SDR: Am02pkSW4UFvIuJEFHD/qmYeCH6jxeszT5E1QTPI+9ui15jC4U0h456ddzwGT5hS5xt6Pxt9Gy ctUsTlioknOmTygiHDRGsSidLYjNROP20Semi5rPok5gZbH12Q2llfpU6it5z71l2lVdep7jfl 1IPAymEY3iIqvfcJpmBGr4DJESG3Dpw/lns0oFS7Uh1G8sEpdsgGMQgZUZzwSAdmMJCEoVZTkw oF77xICqDoLIZD/OwrSVFno+hpMta3JB5dWn2tKJ/W2pdr34RxHT18jpR3QaBlnI0LPmpf144s 4ow= WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2021 07:45:08 -0700 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org, Filipe Manana , Damien Le Moal , Naohiro Aota Subject: [PATCH 6/6] btrfs: rename setup_extent_mapping in relocation code Date: Fri, 3 Sep 2021 23:44:47 +0900 Message-Id: <87ead9c989e3d09804d9d210f16075a4930eab07.1630679569.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In btrfs we have two functions called setup_extent_mapping, one in the extent_map code and one in the relocation code. While both are private to their respective implementation, this can still be confusing for the reader. So rename the version in relocation.c to setup_relocation_extent_mapping. No functional change otherwise. Signed-off-by: Johannes Thumshirn --- fs/btrfs/relocation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 6f668bc01cd1..bf93e11b6d4e 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2880,8 +2880,8 @@ static noinline_for_stack int prealloc_file_extent_cluster( } static noinline_for_stack -int setup_extent_mapping(struct inode *inode, u64 start, u64 end, - u64 block_start) +int setup_relocation_extent_mapping(struct inode *inode, u64 start, u64 end, + u64 block_start) { struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; struct extent_map *em; @@ -3080,7 +3080,7 @@ static int relocate_file_extent_cluster(struct inode *inode, file_ra_state_init(ra, inode->i_mapping); - ret = setup_extent_mapping(inode, cluster->start - offset, + ret = setup_relocation_extent_mapping(inode, cluster->start - offset, cluster->end - offset, cluster->start); if (ret) goto out;