Skip to content

Commit 748285c

Browse files
committed
dlm: use more NOFS allocation
Change some GFP_KERNEL allocations to use either GFP_NOFS or ls_allocation (when available) which the fs sets to GFP_NOFS. The point is to prevent allocations from going back into the cluster fs in places where that might lead to deadlock. Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 391fbdc commit 748285c

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎fs/dlm/dir.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len)
4949
spin_unlock(&ls->ls_recover_list_lock);
5050

5151
if (!found)
52-
de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_KERNEL);
52+
de = kzalloc(sizeof(struct dlm_direntry) + len,
53+
ls->ls_allocation);
5354
return de;
5455
}
5556

@@ -211,7 +212,7 @@ int dlm_recover_directory(struct dlm_ls *ls)
211212

212213
dlm_dir_clear(ls);
213214

214-
last_name = kmalloc(DLM_RESNAME_MAXLEN, GFP_KERNEL);
215+
last_name = kmalloc(DLM_RESNAME_MAXLEN, ls->ls_allocation);
215216
if (!last_name)
216217
goto out;
217218

@@ -322,7 +323,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
322323
if (namelen > DLM_RESNAME_MAXLEN)
323324
return -EINVAL;
324325

325-
de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL);
326+
de = kzalloc(sizeof(struct dlm_direntry) + namelen, ls->ls_allocation);
326327
if (!de)
327328
return -ENOMEM;
328329

‎fs/dlm/lowcomms.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ static void process_sctp_notification(struct connection *con,
500500
return;
501501
}
502502

503-
new_con = nodeid2con(nodeid, GFP_KERNEL);
503+
new_con = nodeid2con(nodeid, GFP_NOFS);
504504
if (!new_con)
505505
return;
506506

@@ -736,7 +736,7 @@ static int tcp_accept_from_sock(struct connection *con)
736736
* the same time and the connections cross on the wire.
737737
* In this case we store the incoming one in "othercon"
738738
*/
739-
newcon = nodeid2con(nodeid, GFP_KERNEL);
739+
newcon = nodeid2con(nodeid, GFP_NOFS);
740740
if (!newcon) {
741741
result = -ENOMEM;
742742
goto accept_err;
@@ -746,7 +746,7 @@ static int tcp_accept_from_sock(struct connection *con)
746746
struct connection *othercon = newcon->othercon;
747747

748748
if (!othercon) {
749-
othercon = kmem_cache_zalloc(con_cache, GFP_KERNEL);
749+
othercon = kmem_cache_zalloc(con_cache, GFP_NOFS);
750750
if (!othercon) {
751751
log_print("failed to allocate incoming socket");
752752
mutex_unlock(&newcon->sock_mutex);

‎fs/dlm/member.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int dlm_add_member(struct dlm_ls *ls, int nodeid)
4848
struct dlm_member *memb;
4949
int w, error;
5050

51-
memb = kzalloc(sizeof(struct dlm_member), GFP_KERNEL);
51+
memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation);
5252
if (!memb)
5353
return -ENOMEM;
5454

@@ -143,7 +143,7 @@ static void make_member_array(struct dlm_ls *ls)
143143

144144
ls->ls_total_weight = total;
145145

146-
array = kmalloc(sizeof(int) * total, GFP_KERNEL);
146+
array = kmalloc(sizeof(int) * total, ls->ls_allocation);
147147
if (!array)
148148
return;
149149

@@ -226,7 +226,7 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
226226
continue;
227227
log_debug(ls, "new nodeid %d is a re-added member", rv->new[i]);
228228

229-
memb = kzalloc(sizeof(struct dlm_member), GFP_KERNEL);
229+
memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation);
230230
if (!memb)
231231
return -ENOMEM;
232232
memb->nodeid = rv->new[i];
@@ -341,7 +341,7 @@ int dlm_ls_start(struct dlm_ls *ls)
341341
int *ids = NULL, *new = NULL;
342342
int error, ids_count = 0, new_count = 0;
343343

344-
rv = kzalloc(sizeof(struct dlm_recover), GFP_KERNEL);
344+
rv = kzalloc(sizeof(struct dlm_recover), ls->ls_allocation);
345345
if (!rv)
346346
return -ENOMEM;
347347

‎fs/dlm/requestqueue.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms)
3535
struct rq_entry *e;
3636
int length = ms->m_header.h_length - sizeof(struct dlm_message);
3737

38-
e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL);
38+
e = kmalloc(sizeof(struct rq_entry) + length, ls->ls_allocation);
3939
if (!e) {
4040
log_print("dlm_add_requestqueue: out of memory len %d", length);
4141
return;

0 commit comments

Comments
 (0)