Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-5.13-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:
"A few more fixes:

- fix unaligned compressed writes in zoned mode

- fix false positive lockdep warning when cloning inline extent

- remove wrong BUG_ON in tree-log error handling"

* tag 'for-5.13-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: zoned: fix parallel compressed writes
btrfs: zoned: pass start block to btrfs_use_zone_append
btrfs: do not BUG_ON in link_to_fixup_dir
btrfs: release path before starting transaction when cloning inline extent

+49 -13
+38 -4
fs/btrfs/compression.c
··· 28 28 #include "compression.h" 29 29 #include "extent_io.h" 30 30 #include "extent_map.h" 31 + #include "zoned.h" 31 32 32 33 static const char* const btrfs_compress_types[] = { "", "zlib", "lzo", "zstd" }; 33 34 ··· 350 349 */ 351 350 inode = cb->inode; 352 351 cb->compressed_pages[0]->mapping = cb->inode->i_mapping; 352 + btrfs_record_physical_zoned(inode, cb->start, bio); 353 353 btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0], 354 354 cb->start, cb->start + cb->len - 1, 355 355 bio->bi_status == BLK_STS_OK); ··· 403 401 u64 first_byte = disk_start; 404 402 blk_status_t ret; 405 403 int skip_sum = inode->flags & BTRFS_INODE_NODATASUM; 404 + const bool use_append = btrfs_use_zone_append(inode, disk_start); 405 + const unsigned int bio_op = use_append ? REQ_OP_ZONE_APPEND : REQ_OP_WRITE; 406 406 407 407 WARN_ON(!PAGE_ALIGNED(start)); 408 408 cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS); ··· 422 418 cb->nr_pages = nr_pages; 423 419 424 420 bio = btrfs_bio_alloc(first_byte); 425 - bio->bi_opf = REQ_OP_WRITE | write_flags; 421 + bio->bi_opf = bio_op | write_flags; 426 422 bio->bi_private = cb; 427 423 bio->bi_end_io = end_compressed_bio_write; 424 + 425 + if (use_append) { 426 + struct extent_map *em; 427 + struct map_lookup *map; 428 + struct block_device *bdev; 429 + 430 + em = btrfs_get_chunk_map(fs_info, disk_start, PAGE_SIZE); 431 + if (IS_ERR(em)) { 432 + kfree(cb); 433 + bio_put(bio); 434 + return BLK_STS_NOTSUPP; 435 + } 436 + 437 + map = em->map_lookup; 438 + /* We only support single profile for now */ 439 + ASSERT(map->num_stripes == 1); 440 + bdev = map->stripes[0].dev->bdev; 441 + 442 + bio_set_dev(bio, bdev); 443 + free_extent_map(em); 444 + } 428 445 429 446 if (blkcg_css) { 430 447 bio->bi_opf |= REQ_CGROUP_PUNT; ··· 457 432 bytes_left = compressed_len; 458 433 for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) { 459 434 int submit = 0; 435 + int len; 460 436 461 437 page = compressed_pages[pg_index]; 462 438 page->mapping = inode->vfs_inode.i_mapping; ··· 465 439 submit = btrfs_bio_fits_in_stripe(page, PAGE_SIZE, bio, 466 440 0); 467 441 442 + if (pg_index == 0 && use_append) 443 + len = bio_add_zone_append_page(bio, page, PAGE_SIZE, 0); 444 + else 445 + len = bio_add_page(bio, page, PAGE_SIZE, 0); 446 + 468 447 page->mapping = NULL; 469 - if (submit || bio_add_page(bio, page, PAGE_SIZE, 0) < 470 - PAGE_SIZE) { 448 + if (submit || len < PAGE_SIZE) { 471 449 /* 472 450 * inc the count before we submit the bio so 473 451 * we know the end IO handler won't happen before ··· 495 465 } 496 466 497 467 bio = btrfs_bio_alloc(first_byte); 498 - bio->bi_opf = REQ_OP_WRITE | write_flags; 468 + bio->bi_opf = bio_op | write_flags; 499 469 bio->bi_private = cb; 500 470 bio->bi_end_io = end_compressed_bio_write; 501 471 if (blkcg_css) 502 472 bio->bi_opf |= REQ_CGROUP_PUNT; 473 + /* 474 + * Use bio_add_page() to ensure the bio has at least one 475 + * page. 476 + */ 503 477 bio_add_page(bio, page, PAGE_SIZE, 0); 504 478 } 505 479 if (bytes_left < PAGE_SIZE) {
+1 -1
fs/btrfs/extent_io.c
··· 3753 3753 /* Note that em_end from extent_map_end() is exclusive */ 3754 3754 iosize = min(em_end, end + 1) - cur; 3755 3755 3756 - if (btrfs_use_zone_append(inode, em)) 3756 + if (btrfs_use_zone_append(inode, em->block_start)) 3757 3757 opf = REQ_OP_ZONE_APPEND; 3758 3758 3759 3759 free_extent_map(em);
+1 -1
fs/btrfs/inode.c
··· 7786 7786 iomap->bdev = fs_info->fs_devices->latest_bdev; 7787 7787 iomap->length = len; 7788 7788 7789 - if (write && btrfs_use_zone_append(BTRFS_I(inode), em)) 7789 + if (write && btrfs_use_zone_append(BTRFS_I(inode), em->block_start)) 7790 7790 iomap->flags |= IOMAP_F_ZONE_APPEND; 7791 7791 7792 7792 free_extent_map(em);
+5
fs/btrfs/reflink.c
··· 282 282 out: 283 283 if (!ret && !trans) { 284 284 /* 285 + * Release path before starting a new transaction so we don't 286 + * hold locks that would confuse lockdep. 287 + */ 288 + btrfs_release_path(path); 289 + /* 285 290 * No transaction here means we copied the inline extent into a 286 291 * page of the destination inode. 287 292 *
-2
fs/btrfs/tree-log.c
··· 1858 1858 ret = btrfs_update_inode(trans, root, BTRFS_I(inode)); 1859 1859 } else if (ret == -EEXIST) { 1860 1860 ret = 0; 1861 - } else { 1862 - BUG(); /* Logic Error */ 1863 1861 } 1864 1862 iput(inode); 1865 1863
+2 -2
fs/btrfs/zoned.c
··· 1278 1278 spin_unlock(&trans->releasing_ebs_lock); 1279 1279 } 1280 1280 1281 - bool btrfs_use_zone_append(struct btrfs_inode *inode, struct extent_map *em) 1281 + bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start) 1282 1282 { 1283 1283 struct btrfs_fs_info *fs_info = inode->root->fs_info; 1284 1284 struct btrfs_block_group *cache; ··· 1293 1293 if (!is_data_inode(&inode->vfs_inode)) 1294 1294 return false; 1295 1295 1296 - cache = btrfs_lookup_block_group(fs_info, em->block_start); 1296 + cache = btrfs_lookup_block_group(fs_info, start); 1297 1297 ASSERT(cache); 1298 1298 if (!cache) 1299 1299 return false;
+2 -3
fs/btrfs/zoned.h
··· 53 53 void btrfs_redirty_list_add(struct btrfs_transaction *trans, 54 54 struct extent_buffer *eb); 55 55 void btrfs_free_redirty_list(struct btrfs_transaction *trans); 56 - bool btrfs_use_zone_append(struct btrfs_inode *inode, struct extent_map *em); 56 + bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start); 57 57 void btrfs_record_physical_zoned(struct inode *inode, u64 file_offset, 58 58 struct bio *bio); 59 59 void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered); ··· 152 152 struct extent_buffer *eb) { } 153 153 static inline void btrfs_free_redirty_list(struct btrfs_transaction *trans) { } 154 154 155 - static inline bool btrfs_use_zone_append(struct btrfs_inode *inode, 156 - struct extent_map *em) 155 + static inline bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start) 157 156 { 158 157 return false; 159 158 }