@@ -213,7 +213,7 @@ struct o2hb_region {
213213 unsigned int hr_num_pages ;
214214
215215 struct page * * hr_slot_data ;
216- struct block_device * hr_bdev ;
216+ struct bdev_handle * hr_bdev_handle ;
217217 struct o2hb_disk_slot * hr_slots ;
218218
219219 /* live node map of this region */
@@ -261,6 +261,11 @@ struct o2hb_region {
261261 int hr_last_hb_status ;
262262};
263263
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+
264269struct o2hb_bio_wait_ctxt {
265270 atomic_t wc_num_reqs ;
266271 struct completion wc_io_complete ;
@@ -286,7 +291,7 @@ static void o2hb_write_timeout(struct work_struct *work)
286291 hr_write_timeout_work .work );
287292
288293 mlog (ML_ERROR , "Heartbeat write timeout to device %pg after %u "
289- "milliseconds\n" , reg -> hr_bdev ,
294+ "milliseconds\n" , reg_bdev ( reg ) ,
290295 jiffies_to_msecs (jiffies - reg -> hr_last_timeout_start ));
291296
292297 if (o2hb_global_heartbeat_active ()) {
@@ -383,7 +388,7 @@ static void o2hb_nego_timeout(struct work_struct *work)
383388 if (!test_bit (master_node , reg -> hr_nego_node_bitmap )) {
384389 printk (KERN_NOTICE "o2hb: node %d hb write hung for %ds on region %s (%pg).\n" ,
385390 o2nm_this_node (), O2HB_NEGO_TIMEOUT_MS /1000 ,
386- config_item_name (& reg -> hr_item ), reg -> hr_bdev );
391+ config_item_name (& reg -> hr_item ), reg_bdev ( reg ) );
387392 set_bit (master_node , reg -> hr_nego_node_bitmap );
388393 }
389394 if (!bitmap_equal (reg -> hr_nego_node_bitmap , live_node_bitmap ,
@@ -398,7 +403,8 @@ static void o2hb_nego_timeout(struct work_struct *work)
398403 }
399404
400405 printk (KERN_NOTICE "o2hb: all nodes hb write hung, maybe region %s (%pg) is down.\n" ,
401- config_item_name (& reg -> hr_item ), reg -> hr_bdev );
406+ config_item_name (& reg -> hr_item ),
407+ reg_bdev (reg ));
402408 /* approve negotiate timeout request. */
403409 o2hb_arm_timeout (reg );
404410
@@ -419,7 +425,7 @@ static void o2hb_nego_timeout(struct work_struct *work)
419425 /* negotiate timeout with master node. */
420426 printk (KERN_NOTICE "o2hb: node %d hb write hung for %ds on region %s (%pg), negotiate timeout with node %d.\n" ,
421427 o2nm_this_node (), O2HB_NEGO_TIMEOUT_MS /1000 , config_item_name (& reg -> hr_item ),
422- reg -> hr_bdev , master_node );
428+ reg_bdev ( reg ) , master_node );
423429 ret = o2hb_send_nego_msg (reg -> hr_key , O2HB_NEGO_TIMEOUT_MSG ,
424430 master_node );
425431 if (ret )
@@ -436,7 +442,8 @@ static int o2hb_nego_timeout_handler(struct o2net_msg *msg, u32 len, void *data,
436442
437443 nego_msg = (struct o2hb_nego_msg * )msg -> buf ;
438444 printk (KERN_NOTICE "o2hb: receive negotiate timeout message from node %d on region %s (%pg).\n" ,
439- nego_msg -> node_num , config_item_name (& reg -> hr_item ), reg -> hr_bdev );
445+ nego_msg -> node_num , config_item_name (& reg -> hr_item ),
446+ reg_bdev (reg ));
440447 if (nego_msg -> node_num < O2NM_MAX_NODES )
441448 set_bit (nego_msg -> node_num , reg -> hr_nego_node_bitmap );
442449 else
@@ -451,7 +458,7 @@ static int o2hb_nego_approve_handler(struct o2net_msg *msg, u32 len, void *data,
451458 struct o2hb_region * reg = data ;
452459
453460 printk (KERN_NOTICE "o2hb: negotiate timeout approved by master node on region %s (%pg).\n" ,
454- config_item_name (& reg -> hr_item ), reg -> hr_bdev );
461+ config_item_name (& reg -> hr_item ), reg_bdev ( reg ) );
455462 o2hb_arm_timeout (reg );
456463 return 0 ;
457464}
@@ -515,7 +522,7 @@ static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg,
515522 * GFP_KERNEL that the local node can get fenced. It would be
516523 * nicest if we could pre-allocate these bios and avoid this
517524 * all together. */
518- bio = bio_alloc (reg -> hr_bdev , 16 , opf , GFP_ATOMIC );
525+ bio = bio_alloc (reg_bdev ( reg ) , 16 , opf , GFP_ATOMIC );
519526 if (!bio ) {
520527 mlog (ML_ERROR , "Could not alloc slots BIO!\n" );
521528 bio = ERR_PTR (- ENOMEM );
@@ -687,7 +694,7 @@ static int o2hb_check_own_slot(struct o2hb_region *reg)
687694 errstr = ERRSTR3 ;
688695
689696 mlog (ML_ERROR , "%s (%pg): expected(%u:0x%llx, 0x%llx), "
690- "ondisk(%u:0x%llx, 0x%llx)\n" , errstr , reg -> hr_bdev ,
697+ "ondisk(%u:0x%llx, 0x%llx)\n" , errstr , reg_bdev ( reg ) ,
691698 slot -> ds_node_num , (unsigned long long )slot -> ds_last_generation ,
692699 (unsigned long long )slot -> ds_last_time , hb_block -> hb_node ,
693700 (unsigned long long )le64_to_cpu (hb_block -> hb_generation ),
@@ -861,7 +868,7 @@ static void o2hb_set_quorum_device(struct o2hb_region *reg)
861868 goto unlock ;
862869
863870 printk (KERN_NOTICE "o2hb: Region %s (%pg) is now a quorum device\n" ,
864- config_item_name (& reg -> hr_item ), reg -> hr_bdev );
871+ config_item_name (& reg -> hr_item ), reg_bdev ( reg ) );
865872
866873 set_bit (reg -> hr_region_num , o2hb_quorum_region_bitmap );
867874
@@ -920,7 +927,7 @@ static int o2hb_check_slot(struct o2hb_region *reg,
920927 * consider it a transient miss but don't populate any
921928 * other values as they may be junk. */
922929 mlog (ML_ERROR , "Node %d has written a bad crc to %pg\n" ,
923- slot -> ds_node_num , reg -> hr_bdev );
930+ slot -> ds_node_num , reg_bdev ( reg ) );
924931 o2hb_dump_slot (hb_block );
925932
926933 slot -> ds_equal_samples ++ ;
@@ -1003,8 +1010,8 @@ static int o2hb_check_slot(struct o2hb_region *reg,
10031010 "of %u ms, but our count is %u ms.\n"
10041011 "Please double check your configuration values "
10051012 "for 'O2CB_HEARTBEAT_THRESHOLD'\n" ,
1006- slot -> ds_node_num , reg -> hr_bdev , slot_dead_ms ,
1007- dead_ms );
1013+ slot -> ds_node_num , reg_bdev ( reg ) ,
1014+ slot_dead_ms , dead_ms );
10081015 }
10091016 goto out ;
10101017 }
@@ -1143,7 +1150,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
11431150 * can't be sure that the new block ever made it to
11441151 * disk */
11451152 mlog (ML_ERROR , "Write error %d on device \"%pg\"\n" ,
1146- write_wc .wc_error , reg -> hr_bdev );
1153+ write_wc .wc_error , reg_bdev ( reg ) );
11471154 ret = write_wc .wc_error ;
11481155 goto bail ;
11491156 }
@@ -1169,7 +1176,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
11691176 printk (KERN_NOTICE "o2hb: Unable to stabilize "
11701177 "heartbeat on region %s (%pg)\n" ,
11711178 config_item_name (& reg -> hr_item ),
1172- reg -> hr_bdev );
1179+ reg_bdev ( reg ) );
11731180 atomic_set (& reg -> hr_steady_iterations , 0 );
11741181 reg -> hr_aborted_start = 1 ;
11751182 wake_up (& o2hb_steady_queue );
@@ -1489,7 +1496,7 @@ static void o2hb_region_release(struct config_item *item)
14891496 struct page * page ;
14901497 struct o2hb_region * reg = to_o2hb_region (item );
14911498
1492- mlog (ML_HEARTBEAT , "hb region release (%pg)\n" , reg -> hr_bdev );
1499+ mlog (ML_HEARTBEAT , "hb region release (%pg)\n" , reg_bdev ( reg ) );
14931500
14941501 kfree (reg -> hr_tmp_block );
14951502
@@ -1502,8 +1509,8 @@ static void o2hb_region_release(struct config_item *item)
15021509 kfree (reg -> hr_slot_data );
15031510 }
15041511
1505- if (reg -> hr_bdev )
1506- blkdev_put (reg -> hr_bdev , NULL );
1512+ if (reg -> hr_bdev_handle )
1513+ bdev_release (reg -> hr_bdev_handle );
15071514
15081515 kfree (reg -> hr_slots );
15091516
@@ -1562,7 +1569,7 @@ static ssize_t o2hb_region_block_bytes_store(struct config_item *item,
15621569 unsigned long block_bytes ;
15631570 unsigned int block_bits ;
15641571
1565- if (reg -> hr_bdev )
1572+ if (reg -> hr_bdev_handle )
15661573 return - EINVAL ;
15671574
15681575 status = o2hb_read_block_input (reg , page , & block_bytes ,
@@ -1591,7 +1598,7 @@ static ssize_t o2hb_region_start_block_store(struct config_item *item,
15911598 char * p = (char * )page ;
15921599 ssize_t ret ;
15931600
1594- if (reg -> hr_bdev )
1601+ if (reg -> hr_bdev_handle )
15951602 return - EINVAL ;
15961603
15971604 ret = kstrtoull (p , 0 , & tmp );
@@ -1616,7 +1623,7 @@ static ssize_t o2hb_region_blocks_store(struct config_item *item,
16161623 unsigned long tmp ;
16171624 char * p = (char * )page ;
16181625
1619- if (reg -> hr_bdev )
1626+ if (reg -> hr_bdev_handle )
16201627 return - EINVAL ;
16211628
16221629 tmp = simple_strtoul (p , & p , 0 );
@@ -1635,8 +1642,8 @@ static ssize_t o2hb_region_dev_show(struct config_item *item, char *page)
16351642{
16361643 unsigned int ret = 0 ;
16371644
1638- if (to_o2hb_region (item )-> hr_bdev )
1639- ret = sprintf (page , "%pg\n" , to_o2hb_region (item )-> hr_bdev );
1645+ if (to_o2hb_region (item )-> hr_bdev_handle )
1646+ ret = sprintf (page , "%pg\n" , reg_bdev ( to_o2hb_region (item )) );
16401647
16411648 return ret ;
16421649}
@@ -1745,7 +1752,10 @@ static int o2hb_populate_slot_data(struct o2hb_region *reg)
17451752 return ret ;
17461753}
17471754
1748- /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */
1755+ /*
1756+ * this is acting as commit; we set up all of hr_bdev_handle and hr_task or
1757+ * nothing
1758+ */
17491759static ssize_t o2hb_region_dev_store (struct config_item * item ,
17501760 const char * page ,
17511761 size_t count )
@@ -1759,7 +1769,7 @@ static ssize_t o2hb_region_dev_store(struct config_item *item,
17591769 ssize_t ret = - EINVAL ;
17601770 int live_threshold ;
17611771
1762- if (reg -> hr_bdev )
1772+ if (reg -> hr_bdev_handle )
17631773 goto out ;
17641774
17651775 /* We can't heartbeat without having had our node number
@@ -1785,16 +1795,15 @@ static ssize_t o2hb_region_dev_store(struct config_item *item,
17851795 if (!S_ISBLK (f .file -> f_mapping -> host -> i_mode ))
17861796 goto out2 ;
17871797
1788- reg -> hr_bdev = blkdev_get_by_dev (f .file -> f_mapping -> host -> i_rdev ,
1789- BLK_OPEN_WRITE | BLK_OPEN_READ , NULL ,
1790- NULL );
1791- if (IS_ERR (reg -> hr_bdev )) {
1792- ret = PTR_ERR (reg -> hr_bdev );
1793- reg -> hr_bdev = NULL ;
1798+ reg -> hr_bdev_handle = bdev_open_by_dev (f .file -> f_mapping -> host -> i_rdev ,
1799+ BLK_OPEN_WRITE | BLK_OPEN_READ , NULL , NULL );
1800+ if (IS_ERR (reg -> hr_bdev_handle )) {
1801+ ret = PTR_ERR (reg -> hr_bdev_handle );
1802+ reg -> hr_bdev_handle = NULL ;
17941803 goto out2 ;
17951804 }
17961805
1797- sectsize = bdev_logical_block_size (reg -> hr_bdev );
1806+ sectsize = bdev_logical_block_size (reg_bdev ( reg ) );
17981807 if (sectsize != reg -> hr_block_bytes ) {
17991808 mlog (ML_ERROR ,
18001809 "blocksize %u incorrect for device, expected %d" ,
@@ -1890,12 +1899,12 @@ static ssize_t o2hb_region_dev_store(struct config_item *item,
18901899
18911900 if (hb_task && o2hb_global_heartbeat_active ())
18921901 printk (KERN_NOTICE "o2hb: Heartbeat started on region %s (%pg)\n" ,
1893- config_item_name (& reg -> hr_item ), reg -> hr_bdev );
1902+ config_item_name (& reg -> hr_item ), reg_bdev ( reg ) );
18941903
18951904out3 :
18961905 if (ret < 0 ) {
1897- blkdev_put (reg -> hr_bdev , NULL );
1898- reg -> hr_bdev = NULL ;
1906+ bdev_release (reg -> hr_bdev_handle );
1907+ reg -> hr_bdev_handle = NULL ;
18991908 }
19001909out2 :
19011910 fdput (f );
@@ -2085,7 +2094,7 @@ static void o2hb_heartbeat_group_drop_item(struct config_group *group,
20852094 printk (KERN_NOTICE "o2hb: Heartbeat %s on region %s (%pg)\n" ,
20862095 ((atomic_read (& reg -> hr_steady_iterations ) == 0 ) ?
20872096 "stopped" : "start aborted" ), config_item_name (item ),
2088- reg -> hr_bdev );
2097+ reg_bdev ( reg ) );
20892098 }
20902099
20912100 /*
0 commit comments