@@ -1522,11 +1522,11 @@ static int _create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret,
1522
1522
INIT_LIST_HEAD (& lkb -> lkb_ownqueue );
1523
1523
INIT_LIST_HEAD (& lkb -> lkb_rsb_lookup );
1524
1524
1525
- spin_lock_bh (& ls -> ls_lkbidr_spin );
1525
+ write_lock_bh (& ls -> ls_lkbidr_lock );
1526
1526
rv = idr_alloc (& ls -> ls_lkbidr , lkb , start , end , GFP_NOWAIT );
1527
1527
if (rv >= 0 )
1528
1528
lkb -> lkb_id = rv ;
1529
- spin_unlock_bh (& ls -> ls_lkbidr_spin );
1529
+ write_unlock_bh (& ls -> ls_lkbidr_lock );
1530
1530
1531
1531
if (rv < 0 ) {
1532
1532
log_error (ls , "create_lkb idr error %d" , rv );
@@ -1547,11 +1547,11 @@ static int find_lkb(struct dlm_ls *ls, uint32_t lkid, struct dlm_lkb **lkb_ret)
1547
1547
{
1548
1548
struct dlm_lkb * lkb ;
1549
1549
1550
- spin_lock_bh (& ls -> ls_lkbidr_spin );
1550
+ read_lock_bh (& ls -> ls_lkbidr_lock );
1551
1551
lkb = idr_find (& ls -> ls_lkbidr , lkid );
1552
1552
if (lkb )
1553
1553
kref_get (& lkb -> lkb_ref );
1554
- spin_unlock_bh (& ls -> ls_lkbidr_spin );
1554
+ read_unlock_bh (& ls -> ls_lkbidr_lock );
1555
1555
1556
1556
* lkb_ret = lkb ;
1557
1557
return lkb ? 0 : - ENOENT ;
@@ -1567,36 +1567,6 @@ static void kill_lkb(struct kref *kref)
1567
1567
DLM_ASSERT (!lkb -> lkb_status , dlm_print_lkb (lkb ););
1568
1568
}
1569
1569
1570
- /* TODO move this to lib/refcount.c */
1571
- static __must_check bool
1572
- dlm_refcount_dec_and_lock_bh (refcount_t * r , spinlock_t * lock )
1573
- __cond_acquires (lock )
1574
- {
1575
- if (refcount_dec_not_one (r ))
1576
- return false;
1577
-
1578
- spin_lock_bh (lock );
1579
- if (!refcount_dec_and_test (r )) {
1580
- spin_unlock_bh (lock );
1581
- return false;
1582
- }
1583
-
1584
- return true;
1585
- }
1586
-
1587
- /* TODO move this to include/linux/kref.h */
1588
- static inline int dlm_kref_put_lock_bh (struct kref * kref ,
1589
- void (* release )(struct kref * kref ),
1590
- spinlock_t * lock )
1591
- {
1592
- if (dlm_refcount_dec_and_lock_bh (& kref -> refcount , lock )) {
1593
- release (kref );
1594
- return 1 ;
1595
- }
1596
-
1597
- return 0 ;
1598
- }
1599
-
1600
1570
/* __put_lkb() is used when an lkb may not have an rsb attached to
1601
1571
it so we need to provide the lockspace explicitly */
1602
1572
@@ -1605,11 +1575,11 @@ static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
1605
1575
uint32_t lkid = lkb -> lkb_id ;
1606
1576
int rv ;
1607
1577
1608
- rv = dlm_kref_put_lock_bh (& lkb -> lkb_ref , kill_lkb ,
1609
- & ls -> ls_lkbidr_spin );
1578
+ rv = dlm_kref_put_write_lock_bh (& lkb -> lkb_ref , kill_lkb ,
1579
+ & ls -> ls_lkbidr_lock );
1610
1580
if (rv ) {
1611
1581
idr_remove (& ls -> ls_lkbidr , lkid );
1612
- spin_unlock_bh (& ls -> ls_lkbidr_spin );
1582
+ write_unlock_bh (& ls -> ls_lkbidr_lock );
1613
1583
1614
1584
detach_lkb (lkb );
1615
1585
0 commit comments