From patchwork Mon Dec 12 07:37:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13070800 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 5708CC4332F for ; Mon, 12 Dec 2022 07:37:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbiLLHhf (ORCPT ); Mon, 12 Dec 2022 02:37:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbiLLHhe (ORCPT ); Mon, 12 Dec 2022 02:37:34 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098C664D2 for ; Sun, 11 Dec 2022 23:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Me7RKZNCcECkhaNBjKn+o71sy9uj7DrAlf0KT6cZiYs=; b=zHZtbI9Ypt+kMQMIXvJTvwhB1U UNWvHkJVDAhH2TeWxel0TP4Pv3nTek6EydYme2RE4XXlnO7Q77q1flxDsXCEOVwwkw4fzJ+Ch3QBZ +63DDeQ7h5u08WaM9sEw34o6t9QuJ588Cpcbw4YFoyE5y8AfwRM+36ab7F7/SV9WLk56lUhvF1yk6 N1tr8PZ9svuGtt0K3VgFMz6eTGakBMFUqFHNa8MtwZJZhsmHPCVNcvLDk7eTFnea6cts22Unw4HDl KEEruYDKrCJYHkhdBba/t3HRrXk4uopUiVwgcdOKMsVSYgAeNoEPJNZqaR8qNojaa5QB7PUXAfFAY yeyvVG4Q==; Received: from [2001:4bb8:192:2f53:34e0:118:ce10:200c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4dNS-009WFc-19; Mon, 12 Dec 2022 07:37:30 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Naohiro Aota , linux-btrfs@vger.kernel.org Subject: [PATCH 1/7] btrfs: use file_offset to limit bios size in calc_bio_boundaries Date: Mon, 12 Dec 2022 08:37:18 +0100 Message-Id: <20221212073724.12637-2-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221212073724.12637-1-hch@lst.de> References: <20221212073724.12637-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_ordered_extent->disk_bytenr can be rewritten by the zoned I/O completion handler, and thus in general is not a good idea to limit I/O size. But the maximum bio size calculation can easily be done using the file_offset fields in the btrfs_ordered_extent and btrfs_bio structures, so switch to that instead. Signed-off-by: Christoph Hellwig Reviewed-by: Josef Bacik --- fs/btrfs/extent_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index a65a1629d3356d..1fcb55e549717f 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -944,8 +944,8 @@ static void calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, ordered = btrfs_lookup_ordered_extent(inode, file_offset); if (ordered) { bio_ctrl->len_to_oe_boundary = min_t(u32, U32_MAX, - ordered->disk_bytenr + - ordered->disk_num_bytes - logical); + ordered->file_offset + + ordered->disk_num_bytes - file_offset); btrfs_put_ordered_extent(ordered); return; } From patchwork Mon Dec 12 07:37:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13070801 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 A197DC4332F for ; Mon, 12 Dec 2022 07:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231293AbiLLHhk (ORCPT ); Mon, 12 Dec 2022 02:37:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbiLLHhj (ORCPT ); Mon, 12 Dec 2022 02:37:39 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5D52B6 for ; Sun, 11 Dec 2022 23:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=BRXLbrUTGO4IESfi+Dj5Cd6/whGZVlGR1rlfCWBzv0g=; b=HvytvH/w7pC6FOE25v99FVds0q iuml0Wk5wAh5XLMKfML8vDOGQrVGuWXYwdNYrcH2wNbeOS9FlcirPYOtZ5iw4BuwtMUy9Zn6GoWof tJtSLEqo/PrPGlVqoddjnIH8eojShsG6D3sHKbIRLLk5aW7fBluw2a1LxyR6Udu6vg32bqa2XF/Eh k7MlU17j7z67tMRctLqa0+T+U3PGVPe8yv7ztAqufZGO3Kyp0h597kSCHzEJG6sDGdsSt6Nm5BRR5 U1kSoQjmXY1s5tK5xRDea3/n2c75+OcT2CAYAfs1kanPn3oIABZnsulkMAq1Ci+VJ3c7apMm3vyJO +DyB1aQg==; Received: from [2001:4bb8:192:2f53:34e0:118:ce10:200c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4dNU-009WLW-OG; Mon, 12 Dec 2022 07:37:33 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Naohiro Aota , linux-btrfs@vger.kernel.org Subject: [PATCH 2/7] btrfs; rename the disk_bytenr in strut btrfs_ordered_extent Date: Mon, 12 Dec 2022 08:37:19 +0100 Message-Id: <20221212073724.12637-3-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221212073724.12637-1-hch@lst.de> References: <20221212073724.12637-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Rename the disk_bytenr field to logical to make it clear it holds a btrfs logical address. Signed-off-by: Christoph Hellwig Reviewed-by: Josef Bacik --- fs/btrfs/inode.c | 18 +++++++++--------- fs/btrfs/ordered-data.c | 10 +++++----- fs/btrfs/ordered-data.h | 2 +- fs/btrfs/relocation.c | 2 +- fs/btrfs/zoned.c | 4 ++-- include/trace/events/btrfs.h | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 373b7281f5c7dd..3a3a3e0e9484c6 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2667,9 +2667,9 @@ blk_status_t btrfs_extract_ordered_extent(struct btrfs_bio *bbio) goto out; } - ordered_end = ordered->disk_bytenr + ordered->disk_num_bytes; + ordered_end = ordered->logical + ordered->disk_num_bytes; /* bio must be in one ordered extent */ - if (WARN_ON_ONCE(start < ordered->disk_bytenr || end > ordered_end)) { + if (WARN_ON_ONCE(start < ordered->logical || end > ordered_end)) { ret = -EINVAL; goto out; } @@ -2681,7 +2681,7 @@ blk_status_t btrfs_extract_ordered_extent(struct btrfs_bio *bbio) } file_len = ordered->num_bytes; - pre = start - ordered->disk_bytenr; + pre = start - ordered->logical; post = ordered_end - end; ret = btrfs_split_ordered_extent(ordered, pre, post); @@ -3094,7 +3094,7 @@ static int insert_ordered_extent_file_extent(struct btrfs_trans_handle *trans, memset(&stack_fi, 0, sizeof(stack_fi)); btrfs_set_stack_file_extent_type(&stack_fi, BTRFS_FILE_EXTENT_REG); - btrfs_set_stack_file_extent_disk_bytenr(&stack_fi, oe->disk_bytenr); + btrfs_set_stack_file_extent_disk_bytenr(&stack_fi, oe->logical); btrfs_set_stack_file_extent_disk_num_bytes(&stack_fi, oe->disk_num_bytes); btrfs_set_stack_file_extent_offset(&stack_fi, oe->offset); @@ -3165,7 +3165,7 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) /* A valid bdev implies a write on a sequential zone */ if (ordered_extent->bdev) { btrfs_rewrite_logical_zoned(ordered_extent); - btrfs_zone_finish_endio(fs_info, ordered_extent->disk_bytenr, + btrfs_zone_finish_endio(fs_info, ordered_extent->logical, ordered_extent->disk_num_bytes); } @@ -3220,7 +3220,7 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ordered_extent->file_offset, ordered_extent->file_offset + logical_len); - btrfs_zoned_release_data_reloc_bg(fs_info, ordered_extent->disk_bytenr, + btrfs_zoned_release_data_reloc_bg(fs_info, ordered_extent->logical, ordered_extent->disk_num_bytes); } else { BUG_ON(root == fs_info->tree_root); @@ -3228,7 +3228,7 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) if (!ret) { clear_reserved_extent = false; btrfs_release_delalloc_bytes(fs_info, - ordered_extent->disk_bytenr, + ordered_extent->logical, ordered_extent->disk_num_bytes); } } @@ -3312,11 +3312,11 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) */ if (ret && btrfs_test_opt(fs_info, DISCARD_SYNC)) btrfs_discard_extent(fs_info, - ordered_extent->disk_bytenr, + ordered_extent->logical, ordered_extent->disk_num_bytes, NULL); btrfs_free_reserved_extent(fs_info, - ordered_extent->disk_bytenr, + ordered_extent->logical, ordered_extent->disk_num_bytes, 1); } } diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 4bed0839b64033..72e1acd4624169 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -199,7 +199,7 @@ int btrfs_add_ordered_extent(struct btrfs_inode *inode, u64 file_offset, entry->file_offset = file_offset; entry->num_bytes = num_bytes; entry->ram_bytes = ram_bytes; - entry->disk_bytenr = disk_bytenr; + entry->logical = disk_bytenr; entry->disk_num_bytes = disk_num_bytes; entry->offset = offset; entry->bytes_left = num_bytes; @@ -642,8 +642,8 @@ u64 btrfs_wait_ordered_extents(struct btrfs_root *root, u64 nr, ordered = list_first_entry(&splice, struct btrfs_ordered_extent, root_extent_list); - if (range_end <= ordered->disk_bytenr || - ordered->disk_bytenr + ordered->disk_num_bytes <= range_start) { + if (range_end <= ordered->logical || + ordered->logical + ordered->disk_num_bytes <= range_start) { list_move_tail(&ordered->root_extent_list, &skipped); cond_resched_lock(&root->ordered_extent_lock); continue; @@ -1098,7 +1098,7 @@ static int clone_ordered_extent(struct btrfs_ordered_extent *ordered, u64 pos, struct inode *inode = ordered->inode; struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; u64 file_offset = ordered->file_offset + pos; - u64 disk_bytenr = ordered->disk_bytenr + pos; + u64 disk_bytenr = ordered->logical + pos; unsigned long flags = ordered->flags & BTRFS_ORDERED_TYPE_FLAGS; /* @@ -1133,7 +1133,7 @@ int btrfs_split_ordered_extent(struct btrfs_ordered_extent *ordered, u64 pre, tree->last = NULL; ordered->file_offset += pre; - ordered->disk_bytenr += pre; + ordered->logical += pre; ordered->num_bytes -= (pre + post); ordered->disk_num_bytes -= (pre + post); ordered->bytes_left -= (pre + post); diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 89f82b78f590f3..71f200b14a9369 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -96,7 +96,7 @@ struct btrfs_ordered_extent { */ u64 num_bytes; u64 ram_bytes; - u64 disk_bytenr; + u64 logical; u64 disk_num_bytes; u64 offset; diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 31ec4a7658ce6f..798e0e01490dd8 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4379,7 +4379,7 @@ int btrfs_reloc_clone_csums(struct btrfs_inode *inode, u64 file_pos, u64 len) * disk_len vs real len like with real inodes since it's all * disk length. */ - new_bytenr = ordered->disk_bytenr + sums->bytenr - disk_bytenr; + new_bytenr = ordered->logical + sums->bytenr - disk_bytenr; sums->bytenr = new_bytenr; btrfs_add_ordered_sum(ordered, sums); diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 0b769dc8bcdac0..e8681615324dcb 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1678,7 +1678,7 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered) struct extent_map_tree *em_tree; struct extent_map *em; struct btrfs_ordered_sum *sum; - u64 orig_logical = ordered->disk_bytenr; + u64 orig_logical = ordered->logical; u64 *logical = NULL; int nr, stripe_len; @@ -1697,7 +1697,7 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered) if (orig_logical == *logical) goto out; - ordered->disk_bytenr = *logical; + ordered->logical = *logical; em_tree = &inode->extent_tree; write_lock(&em_tree->lock); diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index 0bce0b4ff2faf3..58ea7be57b010e 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -536,7 +536,7 @@ DECLARE_EVENT_CLASS(btrfs__ordered_extent, TP_fast_assign_btrfs(inode->root->fs_info, __entry->ino = btrfs_ino(inode); __entry->file_offset = ordered->file_offset; - __entry->start = ordered->disk_bytenr; + __entry->start = ordered->logical; __entry->len = ordered->num_bytes; __entry->disk_len = ordered->disk_num_bytes; __entry->bytes_left = ordered->bytes_left; From patchwork Mon Dec 12 07:37:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13070802 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 64515C4332F for ; Mon, 12 Dec 2022 07:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbiLLHhu (ORCPT ); Mon, 12 Dec 2022 02:37:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbiLLHhr (ORCPT ); Mon, 12 Dec 2022 02:37:47 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B09F12D for ; Sun, 11 Dec 2022 23:37:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=CxnT7Y4V4DrHvXRFoQV257AwL1XL2xGi3H4FcRFCrHk=; b=OyBMCCGHrUPp87oFAdIhpZOszw XVZVUTlxofHv4Sh0vRiAzxDwJn/25KUCSZBxv0d+jhoRzHmRLXqxGGudsaF/3mWpgbdOLwFwtLmtM MMIMyDKNV4tOnjSHcGVHP7ZR7+W8W8seriDmnBITybagIwNF3l4iRK9khefHeXedFf3376nBiAwOJ a4UtDkNMBJ5AeyPiK60RDQFDWjJ5DDXYagNCYGd/4lhLgUf2ulbrgCLGR0NKDMdwZ1ZmH1FgWCYzk u0o2M4RRI6pcxfOnsEjIJCBn0qPeRat7ds+2sOF//8Xcd1VOh0h1wsArp92WrI2AvWcUl9tBekfJq IezWEjrQ==; Received: from [2001:4bb8:192:2f53:34e0:118:ce10:200c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4dNX-009WNP-Cj; Mon, 12 Dec 2022 07:37:35 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Naohiro Aota , linux-btrfs@vger.kernel.org Subject: [PATCH 3/7] btrfs: set bbio->file_offset in alloc_new_bio Date: Mon, 12 Dec 2022 08:37:20 +0100 Message-Id: <20221212073724.12637-4-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221212073724.12637-1-hch@lst.de> References: <20221212073724.12637-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Instead of digging into the bio_vec in submit_one_bio, set file_offset at bio allocation time from the provided parameter. This also ensures that the file_offset is available all the time when building up the bio payload. Signed-off-by: Christoph Hellwig --- fs/btrfs/extent_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 1fcb55e549717f..3d1bcc71ee9998 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -130,8 +130,6 @@ static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl) /* Caller should ensure the bio has at least some range added */ ASSERT(bio->bi_iter.bi_size); - btrfs_bio(bio)->file_offset = page_offset(bv->bv_page) + bv->bv_offset; - if (!is_data_inode(inode)) bio->bi_opf |= REQ_META; @@ -973,6 +971,7 @@ static void alloc_new_bio(struct btrfs_inode *inode, bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT; else bio->bi_iter.bi_sector = (disk_bytenr + offset) >> SECTOR_SHIFT; + btrfs_bio(bio)->file_offset = file_offset; bio_ctrl->bio = bio; bio_ctrl->compress_type = compress_type; calc_bio_boundaries(bio_ctrl, inode, file_offset); From patchwork Mon Dec 12 07:37:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13070803 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 B5478C4167B for ; Mon, 12 Dec 2022 07:37:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbiLLHhv (ORCPT ); Mon, 12 Dec 2022 02:37:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbiLLHhs (ORCPT ); Mon, 12 Dec 2022 02:37:48 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F3AABED for ; Sun, 11 Dec 2022 23:37:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=eO1r9qp8kPsqndud5zFZ+eXXTfL0NqkF3YnolJIUgzw=; b=Oc8KXd3KvLHlrCqWihVElbMmGD cetZKiojzXnaBHwkWh54setEq2d/zDxM0lvD0jU61Db+kRCwTggOiPv444kjTwHt+Dr5rqGFmwMZ0 twKh6IKE2Lmp+kMBMoZTlq1pXPOKV6gjJT4SUiiE4BZTsO4tVbvKEYWyfiTCifrTUH7oNWS8GsChk Zr5gA+fvzMVoOVmPApWhlnPLNy3I9Q+aKSrXTjnd5AMJFqyazrahFk56xx00VpDbLO3fqjGR0tYpM vV4yVh3rFmJH2jyAvX2bMxSR72Ba7R6IYvHXJwAfk5kEhYfCzV9v8SNBStjRrC+WQWn4FXnw/EkfC rHxrjTwA==; Received: from [2001:4bb8:192:2f53:34e0:118:ce10:200c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4dNa-009WPj-6Z; Mon, 12 Dec 2022 07:37:43 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Naohiro Aota , linux-btrfs@vger.kernel.org Subject: [PATCH 4/7] btrfs: pass a btrfs_bio to btrfs_use_append Date: Mon, 12 Dec 2022 08:37:21 +0100 Message-Id: <20221212073724.12637-5-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221212073724.12637-1-hch@lst.de> References: <20221212073724.12637-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org struct btrfs_bio has all the information needed for btrfs_use_append, so pass that instead of a btrfs_inode and file_offset. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- fs/btrfs/bio.c | 2 +- fs/btrfs/extent_io.c | 3 +-- fs/btrfs/zoned.c | 4 +++- fs/btrfs/zoned.h | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 4ccbc120e869ba..d4ce7c83f85a25 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -614,7 +614,7 @@ static bool btrfs_submit_chunk(struct bio *bio, int mirror_num) u64 logical = bio->bi_iter.bi_sector << 9; u64 length = bio->bi_iter.bi_size; u64 map_length = length; - bool use_append = btrfs_use_zone_append(inode, logical); + bool use_append = btrfs_use_zone_append(bbio); struct btrfs_io_context *bioc = NULL; struct btrfs_io_stripe smap; blk_status_t ret; diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 3d1bcc71ee9998..92724fac9e0824 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -930,7 +930,6 @@ static void calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, struct btrfs_inode *inode, u64 file_offset) { struct btrfs_ordered_extent *ordered; - u64 logical = (bio_ctrl->bio->bi_iter.bi_sector << SECTOR_SHIFT); /* * Limit the extent to the ordered boundary for Zone Append. @@ -938,7 +937,7 @@ static void calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, * to them. */ if (bio_ctrl->compress_type == BTRFS_COMPRESS_NONE && - btrfs_use_zone_append(inode, logical)) { + btrfs_use_zone_append(btrfs_bio(bio_ctrl->bio))) { ordered = btrfs_lookup_ordered_extent(inode, file_offset); if (ordered) { bio_ctrl->len_to_oe_boundary = min_t(u32, U32_MAX, diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index e8681615324dcb..77f453005dc924 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1622,8 +1622,10 @@ void btrfs_free_redirty_list(struct btrfs_transaction *trans) spin_unlock(&trans->releasing_ebs_lock); } -bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start) +bool btrfs_use_zone_append(struct btrfs_bio *bbio) { + u64 start = (bbio->bio.bi_iter.bi_sector << SECTOR_SHIFT); + struct btrfs_inode *inode = bbio->inode; struct btrfs_fs_info *fs_info = inode->root->fs_info; struct btrfs_block_group *cache; bool ret = false; diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index 157f46132c56e0..c0570d35fea291 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -55,7 +55,7 @@ void btrfs_calc_zone_unusable(struct btrfs_block_group *cache); void btrfs_redirty_list_add(struct btrfs_transaction *trans, struct extent_buffer *eb); void btrfs_free_redirty_list(struct btrfs_transaction *trans); -bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start); +bool btrfs_use_zone_append(struct btrfs_bio *bbio); void btrfs_record_physical_zoned(struct btrfs_bio *bbio); void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered); bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, @@ -181,7 +181,7 @@ static inline void btrfs_redirty_list_add(struct btrfs_transaction *trans, struct extent_buffer *eb) { } static inline void btrfs_free_redirty_list(struct btrfs_transaction *trans) { } -static inline bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start) +static inline bool btrfs_use_zone_append(struct btrfs_bio *bbio) { return false; } From patchwork Mon Dec 12 07:37:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13070804 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 48EA1C4332F for ; Mon, 12 Dec 2022 07:37:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbiLLHhy (ORCPT ); Mon, 12 Dec 2022 02:37:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbiLLHhx (ORCPT ); Mon, 12 Dec 2022 02:37:53 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 569BA10CF for ; Sun, 11 Dec 2022 23:37:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=AtXpPTW2mzQQt97Uub5ftGmYZ534LFYiAiluqPTOgBc=; b=JcsKw1taecunHyYf+aVlMqSXkD ZfUBzUB8Vhkz41TQkA8mEVroOgoRxO7wCYtZU6TnLvVzP9iydzNGT191uGJhAjzTr9wQFNORCqyrn +vxYhIS5avtW9S9tlfMIMkqZs9FeHsbnX5h5mUITeKF8/s8rreD4WpGB/Po3ZrNqLiV1W8x9IjgCr JFcm3MzXIe/sV8IV0p5dplMsob8xo2vvDtDyeIEdqV0Ad4D1TbCfzZroJ3couLmTyaK2AdI5dirok IIFSaRBpR+OM3Byc/gpLZLvPOBPaR+UxvVghPoBfwp2hIHaL0Byq3/JS5Vz0KzDi3F3yLQqZljEL4 jw2hYsYA==; Received: from [2001:4bb8:192:2f53:34e0:118:ce10:200c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4dNj-009WSY-Ed; Mon, 12 Dec 2022 07:37:48 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Naohiro Aota , linux-btrfs@vger.kernel.org Subject: [PATCH 5/7] btrfs: never return true for reads in btrfs_use_zone_append Date: Mon, 12 Dec 2022 08:37:22 +0100 Message-Id: <20221212073724.12637-6-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221212073724.12637-1-hch@lst.de> References: <20221212073724.12637-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Using Zone Append only makes sense for writes to the device, so check that in btrfs_use_zone_append. This avoids the possibility of artificially limited read size on zoned file systems. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 77f453005dc924..af063089ad3465 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1636,6 +1636,9 @@ bool btrfs_use_zone_append(struct btrfs_bio *bbio) if (!is_data_inode(&inode->vfs_inode)) return false; + if (btrfs_op(&bbio->bio) != BTRFS_MAP_WRITE) + return false; + /* * Using REQ_OP_ZONE_APPNED for relocation can break assumptions on the * extent layout the relocation code has. From patchwork Mon Dec 12 07:37:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13070805 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 2F2BBC4167B for ; Mon, 12 Dec 2022 07:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231365AbiLLHhz (ORCPT ); Mon, 12 Dec 2022 02:37:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbiLLHhy (ORCPT ); Mon, 12 Dec 2022 02:37:54 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE7D10CF for ; Sun, 11 Dec 2022 23:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=2YXYyBbzYOsoXdK1DYx+MW1FjFMpkGEozg/EUfT1UvI=; b=dj7FF/71ETuOYDZl1vOu6NOpgV KrMRw9yZYS0h1wPyoTUl/qr5dJChh27FJl3QQnhVVXv6x7kkCrRWad2R9y9cV7J++fToF03DHxG6F eF4NoWwIO+0LVq192aNHnOIS+To4H0SLfiC1NuFMq4c2liruzGcSGMtHuOuWG29z0T/jEeGVXXPHt gKcK3KgerCt51E841gxz+wUEF9LXRxDvUnB1BwjjOEcxfWM+WRahXZNvRHcWnUT51gmwclg4jiP4E tv4rSRj7VK28slrQHjpsXbdJ8XlRwKH1PA8qRY5Lh3ZnUKpWvNOCeGvrwsqt7s9L0QQl2j1up07o5 PW28WZyg==; Received: from [2001:4bb8:192:2f53:34e0:118:ce10:200c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4dNm-009WVv-Cl; Mon, 12 Dec 2022 07:37:50 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Naohiro Aota , linux-btrfs@vger.kernel.org Subject: [PATCH 6/7] btrfs: don't rely on unchanging ->bi_bdev for zone append remaps Date: Mon, 12 Dec 2022 08:37:23 +0100 Message-Id: <20221212073724.12637-7-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221212073724.12637-1-hch@lst.de> References: <20221212073724.12637-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_record_physical_zoned relies on a bio->bi_bdev samples in the bio_end_io handler to find the reverse map for remapping the zone append write, but stacked block device drivers can and usually do change bi_bdev when sending on the bio to a lower device. This can happen e.g. with the nvme-multipath driver when a NVMe SSD sets the shared namespace bit. But there is no real need for the bdev in btrfs_record_physical_zoned, as it is only passed to btrfs_rmap_block, which uses it to pick the mapping to report if there are multiple reverse mappings. As zone writes can only do simple non-mirror writes right now, and anything more complex will use the stripe tree there is no chance of the multiple mappings case actually happening. Instead open code the subset of btrfs_rmap_block in btrfs_record_physical_zoned, which also removes a memory allocation and remove the bdev field in the ordered extent. Fixes: d8e3fb106f39 ("btrfs: zoned: use ZONE_APPEND write for zoned mode") Signed-off-by: Christoph Hellwig --- fs/btrfs/inode.c | 4 ++-- fs/btrfs/ordered-data.h | 1 - fs/btrfs/zoned.c | 47 +++++++++++++++++++++-------------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 3a3a3e0e9484c6..94749227a73616 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3162,8 +3162,8 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) goto out; } - /* A valid bdev implies a write on a sequential zone */ - if (ordered_extent->bdev) { + /* A valid ->physical implies a write on a sequential zone */ + if (ordered_extent->physical != (u64)-1) { btrfs_rewrite_logical_zoned(ordered_extent); btrfs_zone_finish_endio(fs_info, ordered_extent->logical, ordered_extent->disk_num_bytes); diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 71f200b14a9369..7ab06aaeae83a1 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -157,7 +157,6 @@ struct btrfs_ordered_extent { * command in a workqueue context */ u64 physical; - struct block_device *bdev; }; static inline void diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index af063089ad3465..9782a40985923f 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1671,8 +1671,6 @@ void btrfs_record_physical_zoned(struct btrfs_bio *bbio) return; ordered->physical = physical; - ordered->bdev = bbio->bio.bi_bdev; - btrfs_put_ordered_extent(ordered); } @@ -1684,43 +1682,46 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered) struct extent_map *em; struct btrfs_ordered_sum *sum; u64 orig_logical = ordered->logical; - u64 *logical = NULL; - int nr, stripe_len; + struct map_lookup *map; + u64 physical = ordered->physical; + u64 chunk_start_phys; + u64 logical; - /* Zoned devices should not have partitions. So, we can assume it is 0 */ - ASSERT(!bdev_is_partition(ordered->bdev)); - if (WARN_ON(!ordered->bdev)) + em = btrfs_get_chunk_map(fs_info, orig_logical, 1); + if (IS_ERR(em)) return; + map = em->map_lookup; + chunk_start_phys = map->stripes[0].physical; - if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, ordered->bdev, - ordered->physical, &logical, &nr, - &stripe_len))) - goto out; - - WARN_ON(nr != 1); + if (WARN_ON_ONCE(map->num_stripes > 1) || + WARN_ON_ONCE((map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) != 0) || + WARN_ON_ONCE(physical < chunk_start_phys) || + WARN_ON_ONCE(physical > chunk_start_phys + em->orig_block_len)) { + free_extent_map(em); + return; + } + logical = em->start + (physical - map->stripes[0].physical); + free_extent_map(em); - if (orig_logical == *logical) - goto out; + if (orig_logical == logical) + return; - ordered->logical = *logical; + ordered->logical = logical; em_tree = &inode->extent_tree; write_lock(&em_tree->lock); em = search_extent_mapping(em_tree, ordered->file_offset, ordered->num_bytes); - em->block_start = *logical; + em->block_start = logical; free_extent_map(em); write_unlock(&em_tree->lock); list_for_each_entry(sum, &ordered->list, list) { - if (*logical < orig_logical) - sum->bytenr -= orig_logical - *logical; + if (logical < orig_logical) + sum->bytenr -= orig_logical - logical; else - sum->bytenr += *logical - orig_logical; + sum->bytenr += logical - orig_logical; } - -out: - kfree(logical); } bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, From patchwork Mon Dec 12 07:37:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13070806 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 CAC44C4332F for ; Mon, 12 Dec 2022 07:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231364AbiLLHiA (ORCPT ); Mon, 12 Dec 2022 02:38:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbiLLHh5 (ORCPT ); Mon, 12 Dec 2022 02:37:57 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB46B634F for ; Sun, 11 Dec 2022 23:37:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6Hw97FMPWKL8rzjA62fiZ1qEb2PWDJS525Y51FrAy4I=; b=4tbHZl4/a4en4HudXxDDM8RW6w 9YcDmOgKXn88f7oqU8XDkDdjf5uRO2doyhSonx31a46o6EbIyO51+ujVIBmWpk+CUomz+Dtv2MzYS NM/4a8ro0o4qg9JkdgTGmDFeJbA8BrIVl8HSAg4PUra7zjFH/qkK5j3I+JhTCPKp2vfeALVbmJVzE ThmgK5iGg73SX1W4mHgNlXmzW1p2GmjqZCZR7WKSZCXpdzA8fc1z3UeRS0AufK1GneLwZekXJum/t M+5IQqNKAnP7DXPO2MqWaXcIO3RchQ59MxEbX/axAPNulwHtOGXN5VuKCWdjpiOC6axm0rBJoTWYl 11fRGfag==; Received: from [2001:4bb8:192:2f53:34e0:118:ce10:200c] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4dNp-009WZZ-1R; Mon, 12 Dec 2022 07:37:53 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Naohiro Aota , linux-btrfs@vger.kernel.org Subject: [PATCH 7/7] btrfs: remove the bdev argument to btrfs_rmap_block Date: Mon, 12 Dec 2022 08:37:24 +0100 Message-Id: <20221212073724.12637-8-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221212073724.12637-1-hch@lst.de> References: <20221212073724.12637-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The only user in the zoned remap code is gone now, so remove the argument. Signed-off-by: Christoph Hellwig --- fs/btrfs/block-group.c | 9 ++------- fs/btrfs/block-group.h | 3 +-- fs/btrfs/tests/extent-map-tests.c | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 708d843daa72de..72688a4f38af99 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1816,7 +1816,6 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) * * @fs_info: the filesystem * @chunk_start: logical address of block group - * @bdev: physical device to resolve, can be NULL to indicate any device * @physical: physical address to map to logical addresses * @logical: return array of logical addresses which map to @physical * @naddrs: length of @logical @@ -1827,8 +1826,7 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) * block copies. */ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start, - struct block_device *bdev, u64 physical, u64 **logical, - int *naddrs, int *stripe_len) + u64 physical, u64 **logical, int *naddrs, int *stripe_len) { struct extent_map *em; struct map_lookup *map; @@ -1868,9 +1866,6 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start, data_stripe_length)) continue; - if (bdev && map->stripes[i].dev->bdev != bdev) - continue; - stripe_nr = physical - map->stripes[i].physical; stripe_nr = div64_u64_rem(stripe_nr, map->stripe_len, &offset); @@ -1927,7 +1922,7 @@ static int exclude_super_stripes(struct btrfs_block_group *cache) for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { bytenr = btrfs_sb_offset(i); - ret = btrfs_rmap_block(fs_info, cache->start, NULL, + ret = btrfs_rmap_block(fs_info, cache->start, bytenr, &logical, &nr, &stripe_len); if (ret) return ret; diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index a02ea76fd6cffe..0462f9b5cedf95 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -315,8 +315,7 @@ u64 btrfs_get_alloc_profile(struct btrfs_fs_info *fs_info, u64 orig_flags); void btrfs_put_block_group_cache(struct btrfs_fs_info *info); int btrfs_free_block_groups(struct btrfs_fs_info *info); int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start, - struct block_device *bdev, u64 physical, u64 **logical, - int *naddrs, int *stripe_len); + u64 physical, u64 **logical, int *naddrs, int *stripe_len); static inline u64 btrfs_data_alloc_profile(struct btrfs_fs_info *fs_info) { diff --git a/fs/btrfs/tests/extent-map-tests.c b/fs/btrfs/tests/extent-map-tests.c index c5b3a631bf4fb4..f2f2e11dac4c02 100644 --- a/fs/btrfs/tests/extent-map-tests.c +++ b/fs/btrfs/tests/extent-map-tests.c @@ -509,7 +509,7 @@ static int test_rmap_block(struct btrfs_fs_info *fs_info, goto out_free; } - ret = btrfs_rmap_block(fs_info, em->start, NULL, btrfs_sb_offset(1), + ret = btrfs_rmap_block(fs_info, em->start, btrfs_sb_offset(1), &logical, &out_ndaddrs, &out_stripe_len); if (ret || (out_ndaddrs == 0 && test->expected_mapped_addr)) { test_err("didn't rmap anything but expected %d",