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.

ocfs2: Convert to use bdev_open_by_dev()

Convert ocfs2 heartbeat code to use bdev_open_by_dev() and pass the
handle around.

CC: Joseph Qi <joseph.qi@linux.alibaba.com>
CC: ocfs2-devel@oss.oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230927093442.25915-26-jack@suse.cz
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Jan Kara and committed by
Christian Brauner
ebc41854 3fe5d9fb

+45 -36
+45 -36
fs/ocfs2/cluster/heartbeat.c
··· 213 213 unsigned int hr_num_pages; 214 214 215 215 struct page **hr_slot_data; 216 - struct block_device *hr_bdev; 216 + struct bdev_handle *hr_bdev_handle; 217 217 struct o2hb_disk_slot *hr_slots; 218 218 219 219 /* live node map of this region */ ··· 261 261 int hr_last_hb_status; 262 262 }; 263 263 264 + static inline struct block_device *reg_bdev(struct o2hb_region *reg) 265 + { 266 + return reg->hr_bdev_handle ? reg->hr_bdev_handle->bdev : NULL; 267 + } 268 + 264 269 struct o2hb_bio_wait_ctxt { 265 270 atomic_t wc_num_reqs; 266 271 struct completion wc_io_complete; ··· 291 286 hr_write_timeout_work.work); 292 287 293 288 mlog(ML_ERROR, "Heartbeat write timeout to device %pg after %u " 294 - "milliseconds\n", reg->hr_bdev, 289 + "milliseconds\n", reg_bdev(reg), 295 290 jiffies_to_msecs(jiffies - reg->hr_last_timeout_start)); 296 291 297 292 if (o2hb_global_heartbeat_active()) { ··· 388 383 if (!test_bit(master_node, reg->hr_nego_node_bitmap)) { 389 384 printk(KERN_NOTICE "o2hb: node %d hb write hung for %ds on region %s (%pg).\n", 390 385 o2nm_this_node(), O2HB_NEGO_TIMEOUT_MS/1000, 391 - config_item_name(&reg->hr_item), reg->hr_bdev); 386 + config_item_name(&reg->hr_item), reg_bdev(reg)); 392 387 set_bit(master_node, reg->hr_nego_node_bitmap); 393 388 } 394 389 if (!bitmap_equal(reg->hr_nego_node_bitmap, live_node_bitmap, ··· 403 398 } 404 399 405 400 printk(KERN_NOTICE "o2hb: all nodes hb write hung, maybe region %s (%pg) is down.\n", 406 - config_item_name(&reg->hr_item), reg->hr_bdev); 401 + config_item_name(&reg->hr_item), 402 + reg_bdev(reg)); 407 403 /* approve negotiate timeout request. */ 408 404 o2hb_arm_timeout(reg); 409 405 ··· 425 419 /* negotiate timeout with master node. */ 426 420 printk(KERN_NOTICE "o2hb: node %d hb write hung for %ds on region %s (%pg), negotiate timeout with node %d.\n", 427 421 o2nm_this_node(), O2HB_NEGO_TIMEOUT_MS/1000, config_item_name(&reg->hr_item), 428 - reg->hr_bdev, master_node); 422 + reg_bdev(reg), master_node); 429 423 ret = o2hb_send_nego_msg(reg->hr_key, O2HB_NEGO_TIMEOUT_MSG, 430 424 master_node); 431 425 if (ret) ··· 442 436 443 437 nego_msg = (struct o2hb_nego_msg *)msg->buf; 444 438 printk(KERN_NOTICE "o2hb: receive negotiate timeout message from node %d on region %s (%pg).\n", 445 - nego_msg->node_num, config_item_name(&reg->hr_item), reg->hr_bdev); 439 + nego_msg->node_num, config_item_name(&reg->hr_item), 440 + reg_bdev(reg)); 446 441 if (nego_msg->node_num < O2NM_MAX_NODES) 447 442 set_bit(nego_msg->node_num, reg->hr_nego_node_bitmap); 448 443 else ··· 458 451 struct o2hb_region *reg = data; 459 452 460 453 printk(KERN_NOTICE "o2hb: negotiate timeout approved by master node on region %s (%pg).\n", 461 - config_item_name(&reg->hr_item), reg->hr_bdev); 454 + config_item_name(&reg->hr_item), reg_bdev(reg)); 462 455 o2hb_arm_timeout(reg); 463 456 return 0; 464 457 } ··· 522 515 * GFP_KERNEL that the local node can get fenced. It would be 523 516 * nicest if we could pre-allocate these bios and avoid this 524 517 * all together. */ 525 - bio = bio_alloc(reg->hr_bdev, 16, opf, GFP_ATOMIC); 518 + bio = bio_alloc(reg_bdev(reg), 16, opf, GFP_ATOMIC); 526 519 if (!bio) { 527 520 mlog(ML_ERROR, "Could not alloc slots BIO!\n"); 528 521 bio = ERR_PTR(-ENOMEM); ··· 694 687 errstr = ERRSTR3; 695 688 696 689 mlog(ML_ERROR, "%s (%pg): expected(%u:0x%llx, 0x%llx), " 697 - "ondisk(%u:0x%llx, 0x%llx)\n", errstr, reg->hr_bdev, 690 + "ondisk(%u:0x%llx, 0x%llx)\n", errstr, reg_bdev(reg), 698 691 slot->ds_node_num, (unsigned long long)slot->ds_last_generation, 699 692 (unsigned long long)slot->ds_last_time, hb_block->hb_node, 700 693 (unsigned long long)le64_to_cpu(hb_block->hb_generation), ··· 868 861 goto unlock; 869 862 870 863 printk(KERN_NOTICE "o2hb: Region %s (%pg) is now a quorum device\n", 871 - config_item_name(&reg->hr_item), reg->hr_bdev); 864 + config_item_name(&reg->hr_item), reg_bdev(reg)); 872 865 873 866 set_bit(reg->hr_region_num, o2hb_quorum_region_bitmap); 874 867 ··· 927 920 * consider it a transient miss but don't populate any 928 921 * other values as they may be junk. */ 929 922 mlog(ML_ERROR, "Node %d has written a bad crc to %pg\n", 930 - slot->ds_node_num, reg->hr_bdev); 923 + slot->ds_node_num, reg_bdev(reg)); 931 924 o2hb_dump_slot(hb_block); 932 925 933 926 slot->ds_equal_samples++; ··· 1010 1003 "of %u ms, but our count is %u ms.\n" 1011 1004 "Please double check your configuration values " 1012 1005 "for 'O2CB_HEARTBEAT_THRESHOLD'\n", 1013 - slot->ds_node_num, reg->hr_bdev, slot_dead_ms, 1014 - dead_ms); 1006 + slot->ds_node_num, reg_bdev(reg), 1007 + slot_dead_ms, dead_ms); 1015 1008 } 1016 1009 goto out; 1017 1010 } ··· 1150 1143 * can't be sure that the new block ever made it to 1151 1144 * disk */ 1152 1145 mlog(ML_ERROR, "Write error %d on device \"%pg\"\n", 1153 - write_wc.wc_error, reg->hr_bdev); 1146 + write_wc.wc_error, reg_bdev(reg)); 1154 1147 ret = write_wc.wc_error; 1155 1148 goto bail; 1156 1149 } ··· 1176 1169 printk(KERN_NOTICE "o2hb: Unable to stabilize " 1177 1170 "heartbeat on region %s (%pg)\n", 1178 1171 config_item_name(&reg->hr_item), 1179 - reg->hr_bdev); 1172 + reg_bdev(reg)); 1180 1173 atomic_set(&reg->hr_steady_iterations, 0); 1181 1174 reg->hr_aborted_start = 1; 1182 1175 wake_up(&o2hb_steady_queue); ··· 1496 1489 struct page *page; 1497 1490 struct o2hb_region *reg = to_o2hb_region(item); 1498 1491 1499 - mlog(ML_HEARTBEAT, "hb region release (%pg)\n", reg->hr_bdev); 1492 + mlog(ML_HEARTBEAT, "hb region release (%pg)\n", reg_bdev(reg)); 1500 1493 1501 1494 kfree(reg->hr_tmp_block); 1502 1495 ··· 1509 1502 kfree(reg->hr_slot_data); 1510 1503 } 1511 1504 1512 - if (reg->hr_bdev) 1513 - blkdev_put(reg->hr_bdev, NULL); 1505 + if (reg->hr_bdev_handle) 1506 + bdev_release(reg->hr_bdev_handle); 1514 1507 1515 1508 kfree(reg->hr_slots); 1516 1509 ··· 1569 1562 unsigned long block_bytes; 1570 1563 unsigned int block_bits; 1571 1564 1572 - if (reg->hr_bdev) 1565 + if (reg->hr_bdev_handle) 1573 1566 return -EINVAL; 1574 1567 1575 1568 status = o2hb_read_block_input(reg, page, &block_bytes, ··· 1598 1591 char *p = (char *)page; 1599 1592 ssize_t ret; 1600 1593 1601 - if (reg->hr_bdev) 1594 + if (reg->hr_bdev_handle) 1602 1595 return -EINVAL; 1603 1596 1604 1597 ret = kstrtoull(p, 0, &tmp); ··· 1623 1616 unsigned long tmp; 1624 1617 char *p = (char *)page; 1625 1618 1626 - if (reg->hr_bdev) 1619 + if (reg->hr_bdev_handle) 1627 1620 return -EINVAL; 1628 1621 1629 1622 tmp = simple_strtoul(p, &p, 0); ··· 1642 1635 { 1643 1636 unsigned int ret = 0; 1644 1637 1645 - if (to_o2hb_region(item)->hr_bdev) 1646 - ret = sprintf(page, "%pg\n", to_o2hb_region(item)->hr_bdev); 1638 + if (to_o2hb_region(item)->hr_bdev_handle) 1639 + ret = sprintf(page, "%pg\n", reg_bdev(to_o2hb_region(item))); 1647 1640 1648 1641 return ret; 1649 1642 } ··· 1752 1745 return ret; 1753 1746 } 1754 1747 1755 - /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */ 1748 + /* 1749 + * this is acting as commit; we set up all of hr_bdev_handle and hr_task or 1750 + * nothing 1751 + */ 1756 1752 static ssize_t o2hb_region_dev_store(struct config_item *item, 1757 1753 const char *page, 1758 1754 size_t count) ··· 1769 1759 ssize_t ret = -EINVAL; 1770 1760 int live_threshold; 1771 1761 1772 - if (reg->hr_bdev) 1762 + if (reg->hr_bdev_handle) 1773 1763 goto out; 1774 1764 1775 1765 /* We can't heartbeat without having had our node number ··· 1795 1785 if (!S_ISBLK(f.file->f_mapping->host->i_mode)) 1796 1786 goto out2; 1797 1787 1798 - reg->hr_bdev = blkdev_get_by_dev(f.file->f_mapping->host->i_rdev, 1799 - BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, 1800 - NULL); 1801 - if (IS_ERR(reg->hr_bdev)) { 1802 - ret = PTR_ERR(reg->hr_bdev); 1803 - reg->hr_bdev = NULL; 1788 + reg->hr_bdev_handle = bdev_open_by_dev(f.file->f_mapping->host->i_rdev, 1789 + BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, NULL); 1790 + if (IS_ERR(reg->hr_bdev_handle)) { 1791 + ret = PTR_ERR(reg->hr_bdev_handle); 1792 + reg->hr_bdev_handle = NULL; 1804 1793 goto out2; 1805 1794 } 1806 1795 1807 - sectsize = bdev_logical_block_size(reg->hr_bdev); 1796 + sectsize = bdev_logical_block_size(reg_bdev(reg)); 1808 1797 if (sectsize != reg->hr_block_bytes) { 1809 1798 mlog(ML_ERROR, 1810 1799 "blocksize %u incorrect for device, expected %d", ··· 1899 1890 1900 1891 if (hb_task && o2hb_global_heartbeat_active()) 1901 1892 printk(KERN_NOTICE "o2hb: Heartbeat started on region %s (%pg)\n", 1902 - config_item_name(&reg->hr_item), reg->hr_bdev); 1893 + config_item_name(&reg->hr_item), reg_bdev(reg)); 1903 1894 1904 1895 out3: 1905 1896 if (ret < 0) { 1906 - blkdev_put(reg->hr_bdev, NULL); 1907 - reg->hr_bdev = NULL; 1897 + bdev_release(reg->hr_bdev_handle); 1898 + reg->hr_bdev_handle = NULL; 1908 1899 } 1909 1900 out2: 1910 1901 fdput(f); ··· 2094 2085 printk(KERN_NOTICE "o2hb: Heartbeat %s on region %s (%pg)\n", 2095 2086 ((atomic_read(&reg->hr_steady_iterations) == 0) ? 2096 2087 "stopped" : "start aborted"), config_item_name(item), 2097 - reg->hr_bdev); 2088 + reg_bdev(reg)); 2098 2089 } 2099 2090 2100 2091 /*