@@ -616,23 +616,22 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
616
616
617
617
spin_lock_bh (& ls -> ls_rsbtbl_lock );
618
618
619
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].keep , name , len , & r );
619
+ error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].r , name , len , & r );
620
620
if (error )
621
- goto do_toss ;
621
+ goto do_new ;
622
622
623
623
/*
624
624
* rsb is active, so we can't check master_nodeid without lock_rsb.
625
625
*/
626
626
627
+ if (rsb_flag (r , RSB_TOSS ))
628
+ goto do_toss ;
629
+
627
630
kref_get (& r -> res_ref );
628
631
goto out_unlock ;
629
632
630
633
631
634
do_toss :
632
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].toss , name , len , & r );
633
- if (error )
634
- goto do_new ;
635
-
636
635
/*
637
636
* rsb found inactive (master_nodeid may be out of date unless
638
637
* we are the dir_nodeid or were the master) No other thread
@@ -669,8 +668,7 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
669
668
r -> res_first_lkid = 0 ;
670
669
}
671
670
672
- rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].toss );
673
- error = rsb_insert (r , & ls -> ls_rsbtbl [b ].keep );
671
+ rsb_clear_flag (r , RSB_TOSS );
674
672
goto out_unlock ;
675
673
676
674
@@ -731,7 +729,7 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
731
729
}
732
730
733
731
out_add :
734
- error = rsb_insert (r , & ls -> ls_rsbtbl [b ].keep );
732
+ error = rsb_insert (r , & ls -> ls_rsbtbl [b ].r );
735
733
out_unlock :
736
734
spin_unlock_bh (& ls -> ls_rsbtbl_lock );
737
735
out :
@@ -760,8 +758,11 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
760
758
761
759
spin_lock_bh (& ls -> ls_rsbtbl_lock );
762
760
763
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].keep , name , len , & r );
761
+ error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].r , name , len , & r );
764
762
if (error )
763
+ goto do_new ;
764
+
765
+ if (rsb_flag (r , RSB_TOSS ))
765
766
goto do_toss ;
766
767
767
768
/*
@@ -773,10 +774,6 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
773
774
774
775
775
776
do_toss :
776
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].toss , name , len , & r );
777
- if (error )
778
- goto do_new ;
779
-
780
777
/*
781
778
* rsb found inactive. No other thread is using this rsb because
782
779
* it's on the toss list, so we can look at or update
@@ -804,8 +801,7 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
804
801
r -> res_nodeid = 0 ;
805
802
}
806
803
807
- rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].toss );
808
- error = rsb_insert (r , & ls -> ls_rsbtbl [b ].keep );
804
+ rsb_clear_flag (r , RSB_TOSS );
809
805
goto out_unlock ;
810
806
811
807
@@ -829,7 +825,7 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
829
825
r -> res_nodeid = (dir_nodeid == our_nodeid ) ? 0 : dir_nodeid ;
830
826
kref_init (& r -> res_ref );
831
827
832
- error = rsb_insert (r , & ls -> ls_rsbtbl [b ].keep );
828
+ error = rsb_insert (r , & ls -> ls_rsbtbl [b ].r );
833
829
out_unlock :
834
830
spin_unlock_bh (& ls -> ls_rsbtbl_lock );
835
831
out :
@@ -1049,8 +1045,11 @@ int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
1049
1045
return error ;
1050
1046
1051
1047
spin_lock_bh (& ls -> ls_rsbtbl_lock );
1052
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].keep , name , len , & r );
1048
+ error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].r , name , len , & r );
1053
1049
if (!error ) {
1050
+ if (rsb_flag (r , RSB_TOSS ))
1051
+ goto do_toss ;
1052
+
1054
1053
/* because the rsb is active, we need to lock_rsb before
1055
1054
* checking/changing re_master_nodeid
1056
1055
*/
@@ -1067,12 +1066,11 @@ int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
1067
1066
put_rsb (r );
1068
1067
1069
1068
return 0 ;
1070
- }
1071
-
1072
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].toss , name , len , & r );
1073
- if (error )
1069
+ } else {
1074
1070
goto not_found ;
1071
+ }
1075
1072
1073
+ do_toss :
1076
1074
/* because the rsb is inactive (on toss list), it's not refcounted
1077
1075
* and lock_rsb is not used, but is protected by the rsbtbl lock
1078
1076
*/
@@ -1102,8 +1100,9 @@ int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
1102
1100
r -> res_nodeid = from_nodeid ;
1103
1101
kref_init (& r -> res_ref );
1104
1102
r -> res_toss_time = jiffies ;
1103
+ rsb_set_flag (r , RSB_TOSS );
1105
1104
1106
- error = rsb_insert (r , & ls -> ls_rsbtbl [b ].toss );
1105
+ error = rsb_insert (r , & ls -> ls_rsbtbl [b ].r );
1107
1106
if (error ) {
1108
1107
/* should never happen */
1109
1108
dlm_free_rsb (r );
@@ -1127,8 +1126,11 @@ static void dlm_dump_rsb_hash(struct dlm_ls *ls, uint32_t hash)
1127
1126
1128
1127
spin_lock_bh (& ls -> ls_rsbtbl_lock );
1129
1128
for (i = 0 ; i < ls -> ls_rsbtbl_size ; i ++ ) {
1130
- for (n = rb_first (& ls -> ls_rsbtbl [i ].keep ); n ; n = rb_next (n )) {
1129
+ for (n = rb_first (& ls -> ls_rsbtbl [i ].r ); n ; n = rb_next (n )) {
1131
1130
r = rb_entry (n , struct dlm_rsb , res_hashnode );
1131
+ if (rsb_flag (r , RSB_TOSS ))
1132
+ continue ;
1133
+
1132
1134
if (r -> res_hash == hash )
1133
1135
dlm_dump_rsb (r );
1134
1136
}
@@ -1146,14 +1148,10 @@ void dlm_dump_rsb_name(struct dlm_ls *ls, const char *name, int len)
1146
1148
b = hash & (ls -> ls_rsbtbl_size - 1 );
1147
1149
1148
1150
spin_lock_bh (& ls -> ls_rsbtbl_lock );
1149
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].keep , name , len , & r );
1151
+ error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].r , name , len , & r );
1150
1152
if (!error )
1151
- goto out_dump ;
1152
-
1153
- error = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].toss , name , len , & r );
1154
- if (error )
1155
1153
goto out ;
1156
- out_dump :
1154
+
1157
1155
dlm_dump_rsb (r );
1158
1156
out :
1159
1157
spin_unlock_bh (& ls -> ls_rsbtbl_lock );
@@ -1166,8 +1164,8 @@ static void toss_rsb(struct kref *kref)
1166
1164
1167
1165
DLM_ASSERT (list_empty (& r -> res_root_list ), dlm_print_rsb (r ););
1168
1166
kref_init (& r -> res_ref );
1169
- rb_erase ( & r -> res_hashnode , & ls -> ls_rsbtbl [ r -> res_bucket ]. keep );
1170
- rsb_insert (r , & ls -> ls_rsbtbl [ r -> res_bucket ]. toss );
1167
+ WARN_ON ( rsb_flag ( r , RSB_TOSS ) );
1168
+ rsb_set_flag (r , RSB_TOSS );
1171
1169
r -> res_toss_time = jiffies ;
1172
1170
set_bit (DLM_RTF_SHRINK_BIT , & ls -> ls_rsbtbl [r -> res_bucket ].flags );
1173
1171
if (r -> res_lvbptr ) {
@@ -1627,9 +1625,11 @@ static void shrink_bucket(struct dlm_ls *ls, int b)
1627
1625
return ;
1628
1626
}
1629
1627
1630
- for (n = rb_first (& ls -> ls_rsbtbl [b ].toss ); n ; n = next ) {
1628
+ for (n = rb_first (& ls -> ls_rsbtbl [b ].r ); n ; n = next ) {
1631
1629
next = rb_next (n );
1632
1630
r = rb_entry (n , struct dlm_rsb , res_hashnode );
1631
+ if (!rsb_flag (r , RSB_TOSS ))
1632
+ continue ;
1633
1633
1634
1634
/* If we're the directory record for this rsb, and
1635
1635
we're not the master of it, then we need to wait
@@ -1672,7 +1672,7 @@ static void shrink_bucket(struct dlm_ls *ls, int b)
1672
1672
continue ;
1673
1673
}
1674
1674
1675
- rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].toss );
1675
+ rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].r );
1676
1676
dlm_free_rsb (r );
1677
1677
}
1678
1678
@@ -1696,8 +1696,14 @@ static void shrink_bucket(struct dlm_ls *ls, int b)
1696
1696
len = ls -> ls_remove_lens [i ];
1697
1697
1698
1698
spin_lock_bh (& ls -> ls_rsbtbl_lock );
1699
- rv = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].toss , name , len , & r );
1699
+ rv = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].r , name , len , & r );
1700
1700
if (rv ) {
1701
+ spin_unlock_bh (& ls -> ls_rsbtbl_lock );
1702
+ log_error (ls , "remove_name not found %s" , name );
1703
+ continue ;
1704
+ }
1705
+
1706
+ if (!rsb_flag (r , RSB_TOSS )) {
1701
1707
spin_unlock_bh (& ls -> ls_rsbtbl_lock );
1702
1708
log_debug (ls , "remove_name not toss %s" , name );
1703
1709
continue ;
@@ -1734,7 +1740,7 @@ static void shrink_bucket(struct dlm_ls *ls, int b)
1734
1740
continue ;
1735
1741
}
1736
1742
1737
- rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].toss );
1743
+ rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].r );
1738
1744
send_remove (r );
1739
1745
spin_unlock_bh (& ls -> ls_rsbtbl_lock );
1740
1746
@@ -4202,17 +4208,16 @@ static void receive_remove(struct dlm_ls *ls, const struct dlm_message *ms)
4202
4208
4203
4209
spin_lock_bh (& ls -> ls_rsbtbl_lock );
4204
4210
4205
- rv = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].toss , name , len , & r );
4211
+ rv = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].r , name , len , & r );
4206
4212
if (rv ) {
4207
- /* verify the rsb is on keep list per comment above */
4208
- rv = dlm_search_rsb_tree (& ls -> ls_rsbtbl [b ].keep , name , len , & r );
4209
- if (rv ) {
4210
- /* should not happen */
4211
- log_error (ls , "receive_remove from %d not found %s" ,
4212
- from_nodeid , name );
4213
- spin_unlock_bh (& ls -> ls_rsbtbl_lock );
4214
- return ;
4215
- }
4213
+ /* should not happen */
4214
+ log_error (ls , "%s from %d not found %s" , __func__ ,
4215
+ from_nodeid , name );
4216
+ spin_unlock_bh (& ls -> ls_rsbtbl_lock );
4217
+ return ;
4218
+ }
4219
+
4220
+ if (!rsb_flag (r , RSB_TOSS )) {
4216
4221
if (r -> res_master_nodeid != from_nodeid ) {
4217
4222
/* should not happen */
4218
4223
log_error (ls , "receive_remove keep from %d master %d" ,
@@ -4238,7 +4243,7 @@ static void receive_remove(struct dlm_ls *ls, const struct dlm_message *ms)
4238
4243
}
4239
4244
4240
4245
if (kref_put (& r -> res_ref , kill_rsb )) {
4241
- rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].toss );
4246
+ rb_erase (& r -> res_hashnode , & ls -> ls_rsbtbl [b ].r );
4242
4247
spin_unlock_bh (& ls -> ls_rsbtbl_lock );
4243
4248
dlm_free_rsb (r );
4244
4249
} else {
@@ -5314,8 +5319,10 @@ static struct dlm_rsb *find_grant_rsb(struct dlm_ls *ls, int bucket)
5314
5319
struct dlm_rsb * r ;
5315
5320
5316
5321
spin_lock_bh (& ls -> ls_rsbtbl_lock );
5317
- for (n = rb_first (& ls -> ls_rsbtbl [bucket ].keep ); n ; n = rb_next (n )) {
5322
+ for (n = rb_first (& ls -> ls_rsbtbl [bucket ].r ); n ; n = rb_next (n )) {
5318
5323
r = rb_entry (n , struct dlm_rsb , res_hashnode );
5324
+ if (rsb_flag (r , RSB_TOSS ))
5325
+ continue ;
5319
5326
5320
5327
if (!rsb_flag (r , RSB_RECOVER_GRANT ))
5321
5328
continue ;
0 commit comments