@@ -733,11 +733,13 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
733
733
}
734
734
735
735
retry :
736
+ error = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
737
+ if (error )
738
+ goto do_new ;
736
739
737
740
/* check if the rsb is active under read lock - likely path */
738
741
read_lock_bh (& ls -> ls_rsbtbl_lock );
739
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
740
- if (error ) {
742
+ if (!rsb_flag (r , RSB_HASHED )) {
741
743
read_unlock_bh (& ls -> ls_rsbtbl_lock );
742
744
goto do_new ;
743
745
}
@@ -918,11 +920,13 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
918
920
int error ;
919
921
920
922
retry :
923
+ error = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
924
+ if (error )
925
+ goto do_new ;
921
926
922
927
/* check if the rsb is in active state under read lock - likely path */
923
928
read_lock_bh (& ls -> ls_rsbtbl_lock );
924
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
925
- if (error ) {
929
+ if (!rsb_flag (r , RSB_HASHED )) {
926
930
read_unlock_bh (& ls -> ls_rsbtbl_lock );
927
931
goto do_new ;
928
932
}
@@ -1276,36 +1280,38 @@ static int _dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *na
1276
1280
}
1277
1281
1278
1282
retry :
1283
+ error = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
1284
+ if (error )
1285
+ goto not_found ;
1279
1286
1280
1287
/* check if the rsb is active under read lock - likely path */
1281
1288
read_lock_bh (& ls -> ls_rsbtbl_lock );
1282
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
1283
- if (!error ) {
1284
- if (rsb_flag (r , RSB_INACTIVE )) {
1285
- read_unlock_bh (& ls -> ls_rsbtbl_lock );
1286
- goto do_inactive ;
1287
- }
1288
-
1289
- /* because the rsb is active, we need to lock_rsb before
1290
- * checking/changing re_master_nodeid
1291
- */
1289
+ if (!rsb_flag (r , RSB_HASHED )) {
1290
+ read_unlock_bh (& ls -> ls_rsbtbl_lock );
1291
+ goto not_found ;
1292
+ }
1292
1293
1293
- hold_rsb ( r );
1294
+ if ( rsb_flag ( r , RSB_INACTIVE )) {
1294
1295
read_unlock_bh (& ls -> ls_rsbtbl_lock );
1295
- lock_rsb (r );
1296
+ goto do_inactive ;
1297
+ }
1296
1298
1297
- __dlm_master_lookup (ls , r , our_nodeid , from_nodeid , false,
1298
- flags , r_nodeid , result );
1299
+ /* because the rsb is active, we need to lock_rsb before
1300
+ * checking/changing re_master_nodeid
1301
+ */
1299
1302
1300
- /* the rsb was active */
1301
- unlock_rsb ( r );
1302
- put_rsb (r );
1303
+ hold_rsb ( r );
1304
+ read_unlock_bh ( & ls -> ls_rsbtbl_lock );
1305
+ lock_rsb (r );
1303
1306
1304
- return 0 ;
1305
- } else {
1306
- read_unlock_bh (& ls -> ls_rsbtbl_lock );
1307
- goto not_found ;
1308
- }
1307
+ __dlm_master_lookup (ls , r , our_nodeid , from_nodeid , false,
1308
+ flags , r_nodeid , result );
1309
+
1310
+ /* the rsb was active */
1311
+ unlock_rsb (r );
1312
+ put_rsb (r );
1313
+
1314
+ return 0 ;
1309
1315
1310
1316
do_inactive :
1311
1317
/* unlikely path - check if still part of ls_rsbtbl */
@@ -1403,14 +1409,14 @@ void dlm_dump_rsb_name(struct dlm_ls *ls, const char *name, int len)
1403
1409
struct dlm_rsb * r = NULL ;
1404
1410
int error ;
1405
1411
1406
- read_lock_bh ( & ls -> ls_rsbtbl_lock );
1412
+ rcu_read_lock ( );
1407
1413
error = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
1408
1414
if (!error )
1409
1415
goto out ;
1410
1416
1411
1417
dlm_dump_rsb (r );
1412
1418
out :
1413
- read_unlock_bh ( & ls -> ls_rsbtbl_lock );
1419
+ rcu_read_unlock ( );
1414
1420
}
1415
1421
1416
1422
static void deactivate_rsb (struct kref * kref )
@@ -4309,16 +4315,27 @@ static void receive_remove(struct dlm_ls *ls, const struct dlm_message *ms)
4309
4315
memset (name , 0 , sizeof (name ));
4310
4316
memcpy (name , ms -> m_extra , len );
4311
4317
4312
- write_lock_bh (& ls -> ls_rsbtbl_lock );
4313
-
4318
+ rcu_read_lock ();
4314
4319
rv = dlm_search_rsb_tree (& ls -> ls_rsbtbl , name , len , & r );
4315
4320
if (rv ) {
4321
+ rcu_read_unlock ();
4316
4322
/* should not happen */
4317
4323
log_error (ls , "%s from %d not found %s" , __func__ ,
4318
4324
from_nodeid , name );
4325
+ return ;
4326
+ }
4327
+
4328
+ write_lock_bh (& ls -> ls_rsbtbl_lock );
4329
+ if (!rsb_flag (r , RSB_HASHED )) {
4330
+ rcu_read_unlock ();
4319
4331
write_unlock_bh (& ls -> ls_rsbtbl_lock );
4332
+ /* should not happen */
4333
+ log_error (ls , "%s from %d got removed during removal %s" ,
4334
+ __func__ , from_nodeid , name );
4320
4335
return ;
4321
4336
}
4337
+ /* at this stage the rsb can only being freed here */
4338
+ rcu_read_unlock ();
4322
4339
4323
4340
if (!rsb_flag (r , RSB_INACTIVE )) {
4324
4341
if (r -> res_master_nodeid != from_nodeid ) {
0 commit comments