Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 573c24c4 authored by David Teigland's avatar David Teigland
Browse files

dlm: always use GFP_NOFS



Replace all GFP_KERNEL and ls_allocation with GFP_NOFS.
ls_allocation would be GFP_KERNEL for userland lockspaces
and GFP_NOFS for file system lockspaces.

It was discovered that any lockspaces on the system can
affect all others by triggering memory reclaim in the
file system which could in turn call back into the dlm
to acquire locks, deadlocking dlm threads that were
shared by all lockspaces, like dlm_recv.

Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent a8a8a669
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -410,10 +410,10 @@ static struct config_group *make_cluster(struct config_group *g,
	struct dlm_comms *cms = NULL;
	void *gps = NULL;

	cl = kzalloc(sizeof(struct dlm_cluster), GFP_KERNEL);
	gps = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL);
	sps = kzalloc(sizeof(struct dlm_spaces), GFP_KERNEL);
	cms = kzalloc(sizeof(struct dlm_comms), GFP_KERNEL);
	cl = kzalloc(sizeof(struct dlm_cluster), GFP_NOFS);
	gps = kcalloc(3, sizeof(struct config_group *), GFP_NOFS);
	sps = kzalloc(sizeof(struct dlm_spaces), GFP_NOFS);
	cms = kzalloc(sizeof(struct dlm_comms), GFP_NOFS);

	if (!cl || !gps || !sps || !cms)
		goto fail;
@@ -482,9 +482,9 @@ static struct config_group *make_space(struct config_group *g, const char *name)
	struct dlm_nodes *nds = NULL;
	void *gps = NULL;

	sp = kzalloc(sizeof(struct dlm_space), GFP_KERNEL);
	gps = kcalloc(2, sizeof(struct config_group *), GFP_KERNEL);
	nds = kzalloc(sizeof(struct dlm_nodes), GFP_KERNEL);
	sp = kzalloc(sizeof(struct dlm_space), GFP_NOFS);
	gps = kcalloc(2, sizeof(struct config_group *), GFP_NOFS);
	nds = kzalloc(sizeof(struct dlm_nodes), GFP_NOFS);

	if (!sp || !gps || !nds)
		goto fail;
@@ -536,7 +536,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
{
	struct dlm_comm *cm;

	cm = kzalloc(sizeof(struct dlm_comm), GFP_KERNEL);
	cm = kzalloc(sizeof(struct dlm_comm), GFP_NOFS);
	if (!cm)
		return ERR_PTR(-ENOMEM);

@@ -569,7 +569,7 @@ static struct config_item *make_node(struct config_group *g, const char *name)
	struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent);
	struct dlm_node *nd;

	nd = kzalloc(sizeof(struct dlm_node), GFP_KERNEL);
	nd = kzalloc(sizeof(struct dlm_node), GFP_NOFS);
	if (!nd)
		return ERR_PTR(-ENOMEM);

@@ -705,7 +705,7 @@ static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len)
	if (cm->addr_count >= DLM_MAX_ADDR_COUNT)
		return -ENOSPC;

	addr = kzalloc(sizeof(*addr), GFP_KERNEL);
	addr = kzalloc(sizeof(*addr), GFP_NOFS);
	if (!addr)
		return -ENOMEM;

@@ -868,7 +868,7 @@ int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out,

	ids_count = sp->members_count;

	ids = kcalloc(ids_count, sizeof(int), GFP_KERNEL);
	ids = kcalloc(ids_count, sizeof(int), GFP_NOFS);
	if (!ids) {
		rv = -ENOMEM;
		goto out;
@@ -886,7 +886,7 @@ int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out,
	if (!new_count)
		goto out_ids;

	new = kcalloc(new_count, sizeof(int), GFP_KERNEL);
	new = kcalloc(new_count, sizeof(int), GFP_NOFS);
	if (!new) {
		kfree(ids);
		rv = -ENOMEM;
+1 −1
Original line number Diff line number Diff line
@@ -404,7 +404,7 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
	if (bucket >= ls->ls_rsbtbl_size)
		return NULL;

	ri = kzalloc(sizeof(struct rsbtbl_iter), GFP_KERNEL);
	ri = kzalloc(sizeof(struct rsbtbl_iter), GFP_NOFS);
	if (!ri)
		return NULL;
	if (n == 0)
+3 −4
Original line number Diff line number Diff line
@@ -49,8 +49,7 @@ static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len)
	spin_unlock(&ls->ls_recover_list_lock);

	if (!found)
		de = kzalloc(sizeof(struct dlm_direntry) + len,
			     ls->ls_allocation);
		de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_NOFS);
	return de;
}

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

	dlm_dir_clear(ls);

	last_name = kmalloc(DLM_RESNAME_MAXLEN, ls->ls_allocation);
	last_name = kmalloc(DLM_RESNAME_MAXLEN, GFP_NOFS);
	if (!last_name)
		goto out;

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

	de = kzalloc(sizeof(struct dlm_direntry) + namelen, ls->ls_allocation);
	de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_NOFS);
	if (!de)
		return -ENOMEM;

+0 −1
Original line number Diff line number Diff line
@@ -473,7 +473,6 @@ struct dlm_ls {
	int			ls_low_nodeid;
	int			ls_total_weight;
	int			*ls_node_array;
	gfp_t			ls_allocation;

	struct dlm_rsb		ls_stub_rsb;	/* for returning errors */
	struct dlm_lkb		ls_stub_lkb;	/* for returning errors */
+3 −3
Original line number Diff line number Diff line
@@ -2689,7 +2689,7 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
	   pass into lowcomms_commit and a message buffer (mb) that we
	   write our data into */

	mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, ls->ls_allocation, &mb);
	mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb);
	if (!mh)
		return -ENOBUFS;

@@ -4512,7 +4512,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
	}

	if (flags & DLM_LKF_VALBLK) {
		ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL);
		ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_NOFS);
		if (!ua->lksb.sb_lvbptr) {
			kfree(ua);
			__put_lkb(ls, lkb);
@@ -4582,7 +4582,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
	ua = lkb->lkb_ua;

	if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) {
		ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL);
		ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_NOFS);
		if (!ua->lksb.sb_lvbptr) {
			error = -ENOMEM;
			goto out_put;
Loading