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 'block-5.8-2020-06-19' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:

- Use import_uuid() where appropriate (Andy)

- bcache fixes (Coly, Mauricio, Zhiqiang)

- blktrace sparse warnings fix (Jan)

- blktrace concurrent setup fix (Luis)

- blkdev_get use-after-free fix (Jason)

- Ensure all blk-mq maps are updated (Weiping)

- Loop invalidate bdev fix (Zheng)

* tag 'block-5.8-2020-06-19' of git://git.kernel.dk/linux-block:
block: make function 'kill_bdev' static
loop: replace kill_bdev with invalidate_bdev
partitions/ldm: Replace uuid_copy() with import_uuid() where it makes sense
block: update hctx map when use multiple maps
blktrace: Avoid sparse warnings when assigning q->blk_trace
blktrace: break out of blktrace setup on concurrent calls
block: Fix use-after-free in blkdev_get()
trace/events/block.h: drop kernel-doc for dropped function parameter
blk-mq: Remove redundant 'return' statement
bcache: pr_info() format clean up in bcache_device_init()
bcache: use delayed kworker fo asynchronous devices registration
bcache: check and adjust logical block size for backing devices
bcache: fix potential deadlock problem in btree_gc_coalesce

+70 -39
+1 -1
block/blk-mq-tag.c
··· 376 376 void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn, 377 377 void *priv) 378 378 { 379 - return __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS); 379 + __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS); 380 380 } 381 381 382 382 /**
+3 -1
block/blk-mq.c
··· 3479 3479 3480 3480 if (set->nr_maps == 1 && nr_hw_queues > nr_cpu_ids) 3481 3481 nr_hw_queues = nr_cpu_ids; 3482 - if (nr_hw_queues < 1 || nr_hw_queues == set->nr_hw_queues) 3482 + if (nr_hw_queues < 1) 3483 + return; 3484 + if (set->nr_maps == 1 && nr_hw_queues == set->nr_hw_queues) 3483 3485 return; 3484 3486 3485 3487 list_for_each_entry(q, &set->tag_list, tag_set_list)
+1 -1
block/partitions/ldm.c
··· 910 910 return false; 911 911 912 912 disk = &vb->vblk.disk; 913 - uuid_copy(&disk->disk_id, (uuid_t *)(buffer + 0x18 + r_name)); 913 + import_uuid(&disk->disk_id, buffer + 0x18 + r_name); 914 914 return true; 915 915 } 916 916
+4 -4
drivers/block/loop.c
··· 1368 1368 lo->lo_sizelimit != info->lo_sizelimit) { 1369 1369 size_changed = true; 1370 1370 sync_blockdev(lo->lo_device); 1371 - kill_bdev(lo->lo_device); 1371 + invalidate_bdev(lo->lo_device); 1372 1372 } 1373 1373 1374 1374 /* I/O need to be drained during transfer transition */ 1375 1375 blk_mq_freeze_queue(lo->lo_queue); 1376 1376 1377 1377 if (size_changed && lo->lo_device->bd_inode->i_mapping->nrpages) { 1378 - /* If any pages were dirtied after kill_bdev(), try again */ 1378 + /* If any pages were dirtied after invalidate_bdev(), try again */ 1379 1379 err = -EAGAIN; 1380 1380 pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n", 1381 1381 __func__, lo->lo_number, lo->lo_file_name, ··· 1615 1615 return 0; 1616 1616 1617 1617 sync_blockdev(lo->lo_device); 1618 - kill_bdev(lo->lo_device); 1618 + invalidate_bdev(lo->lo_device); 1619 1619 1620 1620 blk_mq_freeze_queue(lo->lo_queue); 1621 1621 1622 - /* kill_bdev should have truncated all the pages */ 1622 + /* invalidate_bdev should have truncated all the pages */ 1623 1623 if (lo->lo_device->bd_inode->i_mapping->nrpages) { 1624 1624 err = -EAGAIN; 1625 1625 pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
+6 -2
drivers/md/bcache/btree.c
··· 1389 1389 if (__set_blocks(n1, n1->keys + n2->keys, 1390 1390 block_bytes(b->c)) > 1391 1391 btree_blocks(new_nodes[i])) 1392 - goto out_nocoalesce; 1392 + goto out_unlock_nocoalesce; 1393 1393 1394 1394 keys = n2->keys; 1395 1395 /* Take the key of the node we're getting rid of */ ··· 1418 1418 1419 1419 if (__bch_keylist_realloc(&keylist, 1420 1420 bkey_u64s(&new_nodes[i]->key))) 1421 - goto out_nocoalesce; 1421 + goto out_unlock_nocoalesce; 1422 1422 1423 1423 bch_btree_node_write(new_nodes[i], &cl); 1424 1424 bch_keylist_add(&keylist, &new_nodes[i]->key); ··· 1463 1463 1464 1464 /* Invalidated our iterator */ 1465 1465 return -EINTR; 1466 + 1467 + out_unlock_nocoalesce: 1468 + for (i = 0; i < nodes; i++) 1469 + mutex_unlock(&new_nodes[i]->write_lock); 1466 1470 1467 1471 out_nocoalesce: 1468 1472 closure_sync(&cl);
+26 -9
drivers/md/bcache/super.c
··· 19 19 #include <linux/genhd.h> 20 20 #include <linux/idr.h> 21 21 #include <linux/kthread.h> 22 + #include <linux/workqueue.h> 22 23 #include <linux/module.h> 23 24 #include <linux/random.h> 24 25 #include <linux/reboot.h> ··· 820 819 } 821 820 822 821 static int bcache_device_init(struct bcache_device *d, unsigned int block_size, 823 - sector_t sectors, make_request_fn make_request_fn) 822 + sector_t sectors, make_request_fn make_request_fn, 823 + struct block_device *cached_bdev) 824 824 { 825 825 struct request_queue *q; 826 826 const size_t max_stripes = min_t(size_t, INT_MAX, ··· 887 885 q->limits.io_min = block_size; 888 886 q->limits.logical_block_size = block_size; 889 887 q->limits.physical_block_size = block_size; 888 + 889 + if (q->limits.logical_block_size > PAGE_SIZE && cached_bdev) { 890 + /* 891 + * This should only happen with BCACHE_SB_VERSION_BDEV. 892 + * Block/page size is checked for BCACHE_SB_VERSION_CDEV. 893 + */ 894 + pr_info("%s: sb/logical block size (%u) greater than page size (%lu) falling back to device logical block size (%u)\n", 895 + d->disk->disk_name, q->limits.logical_block_size, 896 + PAGE_SIZE, bdev_logical_block_size(cached_bdev)); 897 + 898 + /* This also adjusts physical block size/min io size if needed */ 899 + blk_queue_logical_block_size(q, bdev_logical_block_size(cached_bdev)); 900 + } 901 + 890 902 blk_queue_flag_set(QUEUE_FLAG_NONROT, d->disk->queue); 891 903 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, d->disk->queue); 892 904 blk_queue_flag_set(QUEUE_FLAG_DISCARD, d->disk->queue); ··· 1356 1340 1357 1341 ret = bcache_device_init(&dc->disk, block_size, 1358 1342 dc->bdev->bd_part->nr_sects - dc->sb.data_offset, 1359 - cached_dev_make_request); 1343 + cached_dev_make_request, dc->bdev); 1360 1344 if (ret) 1361 1345 return ret; 1362 1346 ··· 1469 1453 kobject_init(&d->kobj, &bch_flash_dev_ktype); 1470 1454 1471 1455 if (bcache_device_init(d, block_bytes(c), u->sectors, 1472 - flash_dev_make_request)) 1456 + flash_dev_make_request, NULL)) 1473 1457 goto err; 1474 1458 1475 1459 bcache_device_attach(d, c, u - c->uuids); ··· 2380 2364 } 2381 2365 2382 2366 struct async_reg_args { 2383 - struct work_struct reg_work; 2367 + struct delayed_work reg_work; 2384 2368 char *path; 2385 2369 struct cache_sb *sb; 2386 2370 struct cache_sb_disk *sb_disk; ··· 2391 2375 { 2392 2376 int fail = false; 2393 2377 struct async_reg_args *args = 2394 - container_of(work, struct async_reg_args, reg_work); 2378 + container_of(work, struct async_reg_args, reg_work.work); 2395 2379 struct cached_dev *dc; 2396 2380 2397 2381 dc = kzalloc(sizeof(*dc), GFP_KERNEL); ··· 2421 2405 { 2422 2406 int fail = false; 2423 2407 struct async_reg_args *args = 2424 - container_of(work, struct async_reg_args, reg_work); 2408 + container_of(work, struct async_reg_args, reg_work.work); 2425 2409 struct cache *ca; 2426 2410 2427 2411 ca = kzalloc(sizeof(*ca), GFP_KERNEL); ··· 2449 2433 static void register_device_aync(struct async_reg_args *args) 2450 2434 { 2451 2435 if (SB_IS_BDEV(args->sb)) 2452 - INIT_WORK(&args->reg_work, register_bdev_worker); 2436 + INIT_DELAYED_WORK(&args->reg_work, register_bdev_worker); 2453 2437 else 2454 - INIT_WORK(&args->reg_work, register_cache_worker); 2438 + INIT_DELAYED_WORK(&args->reg_work, register_cache_worker); 2455 2439 2456 - queue_work(system_wq, &args->reg_work); 2440 + /* 10 jiffies is enough for a delay */ 2441 + queue_delayed_work(system_wq, &args->reg_work, 10); 2457 2442 } 2458 2443 2459 2444 static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
+9 -8
fs/block_dev.c
··· 75 75 } 76 76 77 77 /* Kill _all_ buffers and pagecache , dirty or not.. */ 78 - void kill_bdev(struct block_device *bdev) 78 + static void kill_bdev(struct block_device *bdev) 79 79 { 80 80 struct address_space *mapping = bdev->bd_inode->i_mapping; 81 81 ··· 84 84 85 85 invalidate_bh_lrus(); 86 86 truncate_inode_pages(mapping, 0); 87 - } 88 - EXPORT_SYMBOL(kill_bdev); 87 + } 89 88 90 89 /* Invalidate clean unused buffers and pagecache. */ 91 90 void invalidate_bdev(struct block_device *bdev) ··· 1564 1565 */ 1565 1566 if (!for_part) { 1566 1567 ret = devcgroup_inode_permission(bdev->bd_inode, perm); 1567 - if (ret != 0) { 1568 - bdput(bdev); 1568 + if (ret != 0) 1569 1569 return ret; 1570 - } 1571 1570 } 1572 1571 1573 1572 restart: ··· 1634 1637 goto out_clear; 1635 1638 BUG_ON(for_part); 1636 1639 ret = __blkdev_get(whole, mode, 1); 1637 - if (ret) 1640 + if (ret) { 1641 + bdput(whole); 1638 1642 goto out_clear; 1643 + } 1639 1644 bdev->bd_contains = whole; 1640 1645 bdev->bd_part = disk_get_part(disk, partno); 1641 1646 if (!(disk->flags & GENHD_FL_UP) || ··· 1687 1688 disk_unblock_events(disk); 1688 1689 put_disk_and_module(disk); 1689 1690 out: 1690 - bdput(bdev); 1691 1691 1692 1692 return ret; 1693 1693 } ··· 1752 1754 mutex_unlock(&bdev->bd_mutex); 1753 1755 bdput(whole); 1754 1756 } 1757 + 1758 + if (res) 1759 + bdput(bdev); 1755 1760 1756 1761 return res; 1757 1762 }
-2
include/linux/fs.h
··· 2592 2592 extern void invalidate_bdev(struct block_device *); 2593 2593 extern void iterate_bdevs(void (*)(struct block_device *, void *), void *); 2594 2594 extern int sync_blockdev(struct block_device *bdev); 2595 - extern void kill_bdev(struct block_device *); 2596 2595 extern struct super_block *freeze_bdev(struct block_device *); 2597 2596 extern void emergency_thaw_all(void); 2598 2597 extern void emergency_thaw_bdev(struct super_block *sb); ··· 2607 2608 #else 2608 2609 static inline void bd_forget(struct inode *inode) {} 2609 2610 static inline int sync_blockdev(struct block_device *bdev) { return 0; } 2610 - static inline void kill_bdev(struct block_device *bdev) {} 2611 2611 static inline void invalidate_bdev(struct block_device *bdev) {} 2612 2612 2613 2613 static inline struct super_block *freeze_bdev(struct block_device *sb)
-1
include/trace/events/block.h
··· 254 254 * block_bio_complete - completed all work on the block operation 255 255 * @q: queue holding the block operation 256 256 * @bio: block operation completed 257 - * @error: io error value 258 257 * 259 258 * This tracepoint indicates there is no further work to do on this 260 259 * block IO operation @bio.
+20 -10
kernel/trace/blktrace.c
··· 3 3 * Copyright (C) 2006 Jens Axboe <axboe@kernel.dk> 4 4 * 5 5 */ 6 + 7 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + 6 9 #include <linux/kernel.h> 7 10 #include <linux/blkdev.h> 8 11 #include <linux/blktrace_api.h> ··· 347 344 { 348 345 struct blk_trace *bt; 349 346 350 - bt = xchg(&q->blk_trace, NULL); 347 + bt = rcu_replace_pointer(q->blk_trace, NULL, 348 + lockdep_is_held(&q->blk_trace_mutex)); 351 349 if (!bt) 352 350 return -EINVAL; 353 351 ··· 498 494 */ 499 495 strreplace(buts->name, '/', '_'); 500 496 497 + /* 498 + * bdev can be NULL, as with scsi-generic, this is a helpful as 499 + * we can be. 500 + */ 501 + if (rcu_dereference_protected(q->blk_trace, 502 + lockdep_is_held(&q->blk_trace_mutex))) { 503 + pr_warn("Concurrent blktraces are not allowed on %s\n", 504 + buts->name); 505 + return -EBUSY; 506 + } 507 + 501 508 bt = kzalloc(sizeof(*bt), GFP_KERNEL); 502 509 if (!bt) 503 510 return -ENOMEM; ··· 558 543 bt->pid = buts->pid; 559 544 bt->trace_state = Blktrace_setup; 560 545 561 - ret = -EBUSY; 562 - if (cmpxchg(&q->blk_trace, NULL, bt)) 563 - goto err; 564 - 546 + rcu_assign_pointer(q->blk_trace, bt); 565 547 get_probe_ref(); 566 548 567 549 ret = 0; ··· 1641 1629 { 1642 1630 struct blk_trace *bt; 1643 1631 1644 - bt = xchg(&q->blk_trace, NULL); 1632 + bt = rcu_replace_pointer(q->blk_trace, NULL, 1633 + lockdep_is_held(&q->blk_trace_mutex)); 1645 1634 if (bt == NULL) 1646 1635 return -EINVAL; 1647 1636 ··· 1674 1661 1675 1662 blk_trace_setup_lba(bt, bdev); 1676 1663 1677 - ret = -EBUSY; 1678 - if (cmpxchg(&q->blk_trace, NULL, bt)) 1679 - goto free_bt; 1680 - 1664 + rcu_assign_pointer(q->blk_trace, bt); 1681 1665 get_probe_ref(); 1682 1666 return 0; 1683 1667