Skip to content

Commit

Permalink
btrfs: debug patch
Browse files Browse the repository at this point in the history
btrfs_bio_save_iter() call is ending up corrupting ioend structure.
Why?
  • Loading branch information
goldwynr committed Dec 29, 2021
1 parent bf3743d commit 30c74a8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fs/btrfs/volumes.c
Expand Up @@ -6884,13 +6884,30 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
const enum btrfs_map_op op = btrfs_op(bio);
u64 cur_logical = orig_logical;
int ret;
struct iomap_ioend *ioend = bio->bi_private;

if (ioend)
pr_info("%s: %d ioend: %lx inode %lu %llu/%lu",
__func__, __LINE__,
(unsigned long)ioend, ioend->io_inode->i_ino,
ioend->io_offset, ioend->io_size);

while (cur_logical < orig_logical + orig_length) {
u64 map_length = orig_logical + orig_length - cur_logical;
struct btrfs_io_context *bioc = NULL;
struct bio *cur_bio;

if (ioend)
pr_info("%s: %d ioend: %lx inode %lu %llu/%lu",
__func__, __LINE__,
(unsigned long)ioend, ioend->io_inode->i_ino,
ioend->io_offset, ioend->io_size);
btrfs_bio_save_iter(btrfs_bio(bio));
if (ioend)
pr_info("%s: %d ioend: %lx inode %lu %llu/%lu",
__func__, __LINE__,
(unsigned long)ioend, ioend->io_inode->i_ino,
ioend->io_offset, ioend->io_size);
ret = __btrfs_map_block(fs_info, op, cur_logical, &map_length,
&bioc, mirror_num, 1);
if (ret)
Expand All @@ -6917,6 +6934,11 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
return errno_to_blk_status(ret);
cur_logical += map_length;
}
if (ioend)
pr_info("%s: %d ioend: %lx inode %lu %llu/%lu",
__func__, __LINE__,
(unsigned long)ioend, ioend->io_inode->i_ino,
ioend->io_offset, ioend->io_size);
return BLK_STS_OK;
}

Expand Down

0 comments on commit 30c74a8

Please sign in to comment.