Skip to content

Commit 3a562ae

Browse files
committed
Merge tag 'for-5.5-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: "A few fixes for btrfs: - blkcg accounting problem with compression that could stall writes - setting up blkcg bio for compression crashes due to NULL bdev pointer - fix possible infinite loop in writeback for nocow files (here possible means almost impossible, 13 things that need to happen to trigger it)" * tag 'for-5.5-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: Btrfs: fix infinite loop during nocow writeback due to race btrfs: fix compressed write bio blkcg attribution btrfs: punt all bios created in btrfs_submit_compressed_write()
2 parents b6b4aaf + de7999a commit 3a562ae

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

fs/btrfs/compression.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
447447

448448
if (blkcg_css) {
449449
bio->bi_opf |= REQ_CGROUP_PUNT;
450-
bio_associate_blkg_from_css(bio, blkcg_css);
450+
kthread_associate_blkcg(blkcg_css);
451451
}
452452
refcount_set(&cb->pending_bios, 1);
453453

@@ -491,6 +491,8 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
491491
bio->bi_opf = REQ_OP_WRITE | write_flags;
492492
bio->bi_private = cb;
493493
bio->bi_end_io = end_compressed_bio_write;
494+
if (blkcg_css)
495+
bio->bi_opf |= REQ_CGROUP_PUNT;
494496
bio_add_page(bio, page, PAGE_SIZE, 0);
495497
}
496498
if (bytes_left < PAGE_SIZE) {
@@ -517,6 +519,9 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
517519
bio_endio(bio);
518520
}
519521

522+
if (blkcg_css)
523+
kthread_associate_blkcg(NULL);
524+
520525
return 0;
521526
}
522527

fs/btrfs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,10 +1479,10 @@ static noinline int run_delalloc_nocow(struct inode *inode,
14791479
disk_num_bytes =
14801480
btrfs_file_extent_disk_num_bytes(leaf, fi);
14811481
/*
1482-
* If extent we got ends before our range starts, skip
1483-
* to next extent
1482+
* If the extent we got ends before our current offset,
1483+
* skip to the next extent.
14841484
*/
1485-
if (extent_end <= start) {
1485+
if (extent_end <= cur_offset) {
14861486
path->slots[0]++;
14871487
goto next_slot;
14881488
}

0 commit comments

Comments
 (0)