From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 6/8] btrfs-progs: remove extent_buffer::fd and extent_buffer::dev_bytes
Date: Tue, 5 Apr 2022 20:48:28 +0800 [thread overview]
Message-ID: <0fd76db333976b6ded293f89629751abf87752d1.1649162174.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1649162174.git.wqu@suse.com>
Those two members are a shortcut for non-RAID56 profiles.
But we should not use such shortcut, and move all our logical address
read/write to the unified read_data_from_disk()/write_data_to_disk().
With previous refactors, now we're safe to remove them.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
btrfs-corrupt-block.c | 5 ++---
kernel-shared/ctree.c | 5 ++---
kernel-shared/extent_io.c | 2 --
kernel-shared/extent_io.h | 2 --
kernel-shared/volumes.c | 12 +++---------
5 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index 92d608e6b9c0..b17e0bf8e1c9 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -55,7 +55,7 @@ static int debug_corrupt_block(struct extent_buffer *eb,
if (ret < 0) {
errno = -ret;
error("cannot read eb bytenr %llu: %m",
- eb->dev_bytenr);
+ eb->start);
return ret;
}
printf("corrupting %llu copy %d\n", eb->start,
@@ -65,10 +65,9 @@ static int debug_corrupt_block(struct extent_buffer *eb,
if (ret < 0) {
errno = -ret;
error("cannot write eb bytenr %llu: %m",
- eb->dev_bytenr);
+ eb->start);
return ret;
}
- fsync(eb->fd);
}
num_copies = btrfs_num_copies(root->fs_info, eb->start,
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 42bbd50d86a1..ecc37a42eecc 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -590,10 +590,9 @@ static void generic_err(const struct extent_buffer *buf, int slot,
{
va_list args;
- fprintf(stderr, "corrupt %s: root=%lld block=%llu physical=%llu slot=%d, ",
+ fprintf(stderr, "corrupt %s: root=%lld block=%llu slot=%d, ",
btrfs_header_level(buf) == 0 ? "leaf": "node",
- btrfs_header_owner(buf), btrfs_header_bytenr(buf),
- buf->dev_bytenr, slot);
+ btrfs_header_owner(buf), btrfs_header_bytenr(buf), slot);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
diff --git a/kernel-shared/extent_io.c b/kernel-shared/extent_io.c
index c8bb30f62c2d..b8ded5cf7373 100644
--- a/kernel-shared/extent_io.c
+++ b/kernel-shared/extent_io.c
@@ -616,8 +616,6 @@ static struct extent_buffer *__alloc_extent_buffer(struct btrfs_fs_info *info,
eb->len = blocksize;
eb->refs = 1;
eb->flags = 0;
- eb->fd = -1;
- eb->dev_bytenr = (u64)-1;
eb->cache_node.start = bytenr;
eb->cache_node.size = blocksize;
eb->fs_info = info;
diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h
index cd5e893b165a..aa4f34e187ba 100644
--- a/kernel-shared/extent_io.h
+++ b/kernel-shared/extent_io.h
@@ -88,13 +88,11 @@ struct extent_state {
struct extent_buffer {
struct cache_extent cache_node;
u64 start;
- u64 dev_bytenr;
struct list_head lru;
struct list_head recow;
u32 len;
int refs;
u32 flags;
- int fd;
struct btrfs_fs_info *fs_info;
char data[] __attribute__((aligned(8)));
};
diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
index 7d1e7ea00903..cb49609cc60c 100644
--- a/kernel-shared/volumes.c
+++ b/kernel-shared/volumes.c
@@ -2620,8 +2620,6 @@ static int split_eb_for_raid56(struct btrfs_fs_info *info,
eb->len = stripe_len;
eb->refs = 1;
eb->flags = 0;
- eb->fd = -1;
- eb->dev_bytenr = (u64)-1;
eb->fs_info = info;
this_eb_start = raid_map[i];
@@ -2676,9 +2674,6 @@ int write_raid56_with_parity(struct btrfs_fs_info *info,
for (i = 0; i < multi->num_stripes; i++) {
struct extent_buffer *new_eb;
if (raid_map[i] < BTRFS_RAID5_P_STRIPE) {
- ebs[i]->dev_bytenr = multi->stripes[i].physical;
- ebs[i]->fd = multi->stripes[i].dev->fd;
- multi->stripes[i].dev->total_ios++;
if (ebs[i]->start != raid_map[i]) {
ret = -EINVAL;
goto out_free_split;
@@ -2690,8 +2685,6 @@ int write_raid56_with_parity(struct btrfs_fs_info *info,
ret = -ENOMEM;
goto out_free_split;
}
- new_eb->dev_bytenr = multi->stripes[i].physical;
- new_eb->fd = multi->stripes[i].dev->fd;
multi->stripes[i].dev->total_ios++;
new_eb->len = stripe_len;
new_eb->fs_info = info;
@@ -2720,8 +2713,9 @@ int write_raid56_with_parity(struct btrfs_fs_info *info,
}
for (i = 0; i < multi->num_stripes; i++) {
- ret = btrfs_pwrite(ebs[i]->fd, ebs[i]->data, ebs[i]->len,
- ebs[i]->dev_bytenr, info->zoned);
+ multi->stripes[i].dev->total_ios++;
+ ret = btrfs_pwrite(multi->stripes[i].dev->fd, ebs[i]->data, ebs[i]->len,
+ multi->stripes[i].physical, info->zoned);
if (ret < 0)
goto out_free_split;
}
--
2.35.1
next prev parent reply other threads:[~2022-04-05 15:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-05 12:48 [PATCH 0/8] btrfs-progs: add RAID56 rebuild ability at read time Qu Wenruo
2022-04-05 12:48 ` [PATCH 1/8] btrfs-progs: remove the unnecessary BTRFS_SUPER_INFO_OFFSET path for tree block read Qu Wenruo
2022-04-05 12:48 ` [PATCH 2/8] btrfs-progs: extract metadata restore read code into its own helper Qu Wenruo
2022-04-05 12:48 ` [PATCH 3/8] btrfs-progs: don't use write_extent_to_disk() directly Qu Wenruo
2022-04-05 12:48 ` [PATCH 4/8] btrfs-progs: use write_data_to_disk() to replace write_extent_to_disk() Qu Wenruo
2022-04-05 12:48 ` [PATCH 5/8] btrfs-progs: use read_data_from_disk() to replace read_extent_from_disk() and replace read_extent_data() Qu Wenruo
2022-04-05 12:48 ` Qu Wenruo [this message]
2022-04-05 12:48 ` [PATCH 7/8] btrfs-progs: allow read_data_from_disk() to rebuild RAID56 using P/Q Qu Wenruo
2022-04-05 12:48 ` [PATCH 8/8] btrfs-progs: tests/fsck: add test case for data csum check on raid5 Qu Wenruo
2022-04-08 21:16 ` [PATCH 0/8] btrfs-progs: add RAID56 rebuild ability at read time David Sterba
2022-04-11 15:01 ` David Sterba
2022-04-25 16:29 ` David Sterba
2022-04-25 22:38 ` Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0fd76db333976b6ded293f89629751abf87752d1.1649162174.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox