Skip to content

Commit 1ffefc1

Browse files
Alexander Aringteigland
authored andcommitted
dlm: drop own rsb pre allocation mechanism
This patch drops the own written rsb pre allocation mechanism as this is already done by using kmem caches, we don't need another layer on top of that to running some pre allocation scheme. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 4db41bf commit 1ffefc1

File tree

3 files changed

+13
-99
lines changed

3 files changed

+13
-99
lines changed

fs/dlm/dlm_internal.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,7 @@ struct dlm_rsb {
322322
unsigned long res_toss_time;
323323
uint32_t res_first_lkid;
324324
struct list_head res_lookup; /* lkbs waiting on first */
325-
union {
326-
struct list_head res_hashchain;
327-
struct rhash_head res_node; /* rsbtbl */
328-
};
325+
struct rhash_head res_node; /* rsbtbl */
329326
struct list_head res_grantqueue;
330327
struct list_head res_convertqueue;
331328
struct list_head res_waitqueue;
@@ -596,10 +593,6 @@ struct dlm_ls {
596593
spinlock_t ls_orphans_lock;
597594
struct list_head ls_orphans;
598595

599-
spinlock_t ls_new_rsb_spin;
600-
int ls_new_rsb_count;
601-
struct list_head ls_new_rsb; /* new rsb structs */
602-
603596
struct list_head ls_nodes; /* current nodes in ls */
604597
struct list_head ls_nodes_gone; /* dead node list, recovery */
605598
int ls_num_nodes; /* number of nodes in ls */

fs/dlm/lock.c

Lines changed: 12 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -389,38 +389,6 @@ void dlm_put_rsb(struct dlm_rsb *r)
389389
put_rsb(r);
390390
}
391391

392-
static int pre_rsb_struct(struct dlm_ls *ls)
393-
{
394-
struct dlm_rsb *r1, *r2;
395-
int count = 0;
396-
397-
spin_lock_bh(&ls->ls_new_rsb_spin);
398-
if (ls->ls_new_rsb_count > dlm_config.ci_new_rsb_count / 2) {
399-
spin_unlock_bh(&ls->ls_new_rsb_spin);
400-
return 0;
401-
}
402-
spin_unlock_bh(&ls->ls_new_rsb_spin);
403-
404-
r1 = dlm_allocate_rsb(ls);
405-
r2 = dlm_allocate_rsb(ls);
406-
407-
spin_lock_bh(&ls->ls_new_rsb_spin);
408-
if (r1) {
409-
list_add(&r1->res_hashchain, &ls->ls_new_rsb);
410-
ls->ls_new_rsb_count++;
411-
}
412-
if (r2) {
413-
list_add(&r2->res_hashchain, &ls->ls_new_rsb);
414-
ls->ls_new_rsb_count++;
415-
}
416-
count = ls->ls_new_rsb_count;
417-
spin_unlock_bh(&ls->ls_new_rsb_spin);
418-
419-
if (!count)
420-
return -ENOMEM;
421-
return 0;
422-
}
423-
424392
/* connected with timer_delete_sync() in dlm_ls_stop() to stop
425393
* new timers when recovery is triggered and don't run them
426394
* again until a dlm_timer_resume() tries it again.
@@ -652,22 +620,10 @@ static int get_rsb_struct(struct dlm_ls *ls, const void *name, int len,
652620
struct dlm_rsb **r_ret)
653621
{
654622
struct dlm_rsb *r;
655-
int count;
656623

657-
spin_lock_bh(&ls->ls_new_rsb_spin);
658-
if (list_empty(&ls->ls_new_rsb)) {
659-
count = ls->ls_new_rsb_count;
660-
spin_unlock_bh(&ls->ls_new_rsb_spin);
661-
log_debug(ls, "find_rsb retry %d %d %s",
662-
count, dlm_config.ci_new_rsb_count,
663-
(const char *)name);
664-
return -EAGAIN;
665-
}
666-
667-
r = list_first_entry(&ls->ls_new_rsb, struct dlm_rsb, res_hashchain);
668-
list_del(&r->res_hashchain);
669-
ls->ls_new_rsb_count--;
670-
spin_unlock_bh(&ls->ls_new_rsb_spin);
624+
r = dlm_allocate_rsb(ls);
625+
if (!r)
626+
return -ENOMEM;
671627

672628
r->res_ls = ls;
673629
r->res_length = len;
@@ -792,13 +748,6 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
792748
}
793749

794750
retry:
795-
if (create) {
796-
error = pre_rsb_struct(ls);
797-
if (error < 0)
798-
goto out;
799-
}
800-
801-
retry_lookup:
802751

803752
/* check if the rsb is in keep state under read lock - likely path */
804753
read_lock_bh(&ls->ls_rsbtbl_lock);
@@ -832,7 +781,7 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
832781
if (!error) {
833782
if (!rsb_flag(r, RSB_TOSS)) {
834783
write_unlock_bh(&ls->ls_rsbtbl_lock);
835-
goto retry_lookup;
784+
goto retry;
836785
}
837786
} else {
838787
write_unlock_bh(&ls->ls_rsbtbl_lock);
@@ -898,9 +847,7 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
898847
goto out;
899848

900849
error = get_rsb_struct(ls, name, len, &r);
901-
if (error == -EAGAIN)
902-
goto retry;
903-
if (error)
850+
if (WARN_ON_ONCE(error))
904851
goto out;
905852

906853
r->res_hash = hash;
@@ -952,7 +899,7 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
952899
*/
953900
write_unlock_bh(&ls->ls_rsbtbl_lock);
954901
dlm_free_rsb(r);
955-
goto retry_lookup;
902+
goto retry;
956903
} else if (!error) {
957904
list_add(&r->res_rsbs_list, &ls->ls_keep);
958905
}
@@ -976,11 +923,6 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
976923
int error;
977924

978925
retry:
979-
error = pre_rsb_struct(ls);
980-
if (error < 0)
981-
goto out;
982-
983-
retry_lookup:
984926

985927
/* check if the rsb is in keep state under read lock - likely path */
986928
read_lock_bh(&ls->ls_rsbtbl_lock);
@@ -1015,7 +957,7 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
1015957
if (!error) {
1016958
if (!rsb_flag(r, RSB_TOSS)) {
1017959
write_unlock_bh(&ls->ls_rsbtbl_lock);
1018-
goto retry_lookup;
960+
goto retry;
1019961
}
1020962
} else {
1021963
write_unlock_bh(&ls->ls_rsbtbl_lock);
@@ -1070,10 +1012,7 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
10701012
*/
10711013

10721014
error = get_rsb_struct(ls, name, len, &r);
1073-
if (error == -EAGAIN) {
1074-
goto retry;
1075-
}
1076-
if (error)
1015+
if (WARN_ON_ONCE(error))
10771016
goto out;
10781017

10791018
r->res_hash = hash;
@@ -1090,7 +1029,7 @@ static int find_rsb_nodir(struct dlm_ls *ls, const void *name, int len,
10901029
*/
10911030
write_unlock_bh(&ls->ls_rsbtbl_lock);
10921031
dlm_free_rsb(r);
1093-
goto retry_lookup;
1032+
goto retry;
10941033
} else if (!error) {
10951034
list_add(&r->res_rsbs_list, &ls->ls_keep);
10961035
}
@@ -1304,11 +1243,6 @@ int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
13041243
}
13051244

13061245
retry:
1307-
error = pre_rsb_struct(ls);
1308-
if (error < 0)
1309-
return error;
1310-
1311-
retry_lookup:
13121246

13131247
/* check if the rsb is in keep state under read lock - likely path */
13141248
read_lock_bh(&ls->ls_rsbtbl_lock);
@@ -1354,7 +1288,7 @@ int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
13541288
/* something as changed, very unlikely but
13551289
* try again
13561290
*/
1357-
goto retry_lookup;
1291+
goto retry;
13581292
}
13591293
} else {
13601294
write_unlock_bh(&ls->ls_rsbtbl_lock);
@@ -1376,9 +1310,7 @@ int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
13761310

13771311
not_found:
13781312
error = get_rsb_struct(ls, name, len, &r);
1379-
if (error == -EAGAIN)
1380-
goto retry;
1381-
if (error)
1313+
if (WARN_ON_ONCE(error))
13821314
goto out;
13831315

13841316
r->res_hash = hash;
@@ -1395,7 +1327,7 @@ int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
13951327
*/
13961328
write_unlock_bh(&ls->ls_rsbtbl_lock);
13971329
dlm_free_rsb(r);
1398-
goto retry_lookup;
1330+
goto retry;
13991331
} else if (error) {
14001332
write_unlock_bh(&ls->ls_rsbtbl_lock);
14011333
/* should never happen */

fs/dlm/lockspace.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,6 @@ static int new_lockspace(const char *name, const char *cluster,
428428
INIT_LIST_HEAD(&ls->ls_orphans);
429429
spin_lock_init(&ls->ls_orphans_lock);
430430

431-
INIT_LIST_HEAD(&ls->ls_new_rsb);
432-
spin_lock_init(&ls->ls_new_rsb_spin);
433-
434431
INIT_LIST_HEAD(&ls->ls_nodes);
435432
INIT_LIST_HEAD(&ls->ls_nodes_gone);
436433
ls->ls_num_nodes = 0;
@@ -688,7 +685,6 @@ static void rhash_free_rsb(void *ptr, void *arg)
688685

689686
static int release_lockspace(struct dlm_ls *ls, int force)
690687
{
691-
struct dlm_rsb *rsb;
692688
int busy, rv;
693689

694690
busy = lockspace_busy(ls, force);
@@ -756,13 +752,6 @@ static int release_lockspace(struct dlm_ls *ls, int force)
756752
*/
757753
rhashtable_free_and_destroy(&ls->ls_rsbtbl, rhash_free_rsb, NULL);
758754

759-
while (!list_empty(&ls->ls_new_rsb)) {
760-
rsb = list_first_entry(&ls->ls_new_rsb, struct dlm_rsb,
761-
res_hashchain);
762-
list_del(&rsb->res_hashchain);
763-
dlm_free_rsb(rsb);
764-
}
765-
766755
/*
767756
* Free structures on any other lists
768757
*/

0 commit comments

Comments
 (0)