Skip to contentSkip to conversation

Lustre fixes

PATCH New [email protected] 1 participant 5 messages Mar 8, 2015 Staging

lore
Share & tools
lore
#0 lore raw

cover Lustre fixes

From: Oleg Drokin <[email protected]>

The first two patches are a follow on for the previous patch series on not using deprecated cpumask-related code.

And two blocking while atomic/not running fixes.

Please consider.

Lai Siyao (1):
staging/lustre/llite: avoid nonatomic memory alloc under spinlock

Oleg Drokin (3):
staging/lustre/libcfs: replace deprecated cpus_ calls with cpumask_ staging/lustre/o2iblnd: Don't use cpus_weight staging/lustre: Don't call blocking funcitons when !RUNNABLE

 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |  4 +--
 .../staging/lustre/lustre/libcfs/linux/linux-cpu.c | 32 ++++++++++++----------
 .../lustre/lustre/libcfs/linux/linux-tcpip.c       | 10 +++----
 drivers/staging/lustre/lustre/llite/statahead.c    | 13 +++++++--
 4 files changed, 35 insertions(+), 24 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/4 staging/lustre/libcfs: replace deprecated cpus_ calls with cpumask_

From: Oleg Drokin <[email protected]>

This patch continues to further remove deprecated functions, such as any_online_cpu, for_each_cpu_mask and also cleaning up usage of NR_CPUS in a few places

---
 .../staging/lustre/lustre/libcfs/linux/linux-cpu.c | 32 ++++++++++++----------
 1 file changed, 18 insertions(+), 14 deletions(-)
drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +18 -14
index 1eeacef..cc3ab35 100644
@@ -204,7 +204,7 @@ cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
 		}
 
 		tmp += rc;
-		for_each_cpu_mask(j, *cptab->ctb_parts[i].cpt_cpumask) {
+		for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
 			rc = snprintf(tmp, len, "%d ", j);
 			len -= rc;
 			if (len <= 0) {
@@ -251,8 +251,10 @@ cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
 	LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
 
 	return cpt == CFS_CPT_ANY ?
-	       any_online_cpu(*cptab->ctb_cpumask) < nr_cpu_ids :
-	       any_online_cpu(*cptab->ctb_parts[cpt].cpt_cpumask) < nr_cpu_ids;
+	       cpumask_any_and(cptab->ctb_cpumask,
+			       cpu_online_mask) < nr_cpu_ids :
+	       cpumask_any_and(cptab->ctb_parts[cpt].cpt_cpumask,
+			       cpu_online_mask) < nr_cpu_ids;
 }
 EXPORT_SYMBOL(cfs_cpt_online);
 
@@ -356,22 +358,22 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
 	LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask));
 	LASSERT(node_isset(node, *cptab->ctb_nodemask));
 
-	for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask) {
+	for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) {
 		/* this CPT has other CPU belonging to this node? */
 		if (cpu_to_node(i) == node)
 			break;
 	}
 
-	if (i == NR_CPUS)
+	if (i >= nr_cpu_ids)
 		node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask);
 
-	for_each_cpu_mask(i, *cptab->ctb_cpumask) {
+	for_each_cpu(i, cptab->ctb_cpumask) {
 		/* this CPT-table has other CPU belonging to this node? */
 		if (cpu_to_node(i) == node)
 			break;
 	}
 
-	if (i == NR_CPUS)
+	if (i >= nr_cpu_ids)
 		node_clear(node, *cptab->ctb_nodemask);
 
 	return;
@@ -383,13 +385,14 @@ cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
 {
 	int	i;
 
-	if (cpumask_weight(mask) == 0 || any_online_cpu(*mask) >= nr_cpu_ids) {
+	if (cpumask_weight(mask) == 0 ||
+	    cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
 		CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n",
 		       cpt);
 		return 0;
 	}
 
-	for_each_cpu_mask(i, *mask) {
+	for_each_cpu(i, mask) {
 		if (!cfs_cpt_set_cpu(cptab, cpt, i))
 			return 0;
 	}
@@ -403,7 +406,7 @@ cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
 {
 	int	i;
 
-	for_each_cpu_mask(i, *mask)
+	for_each_cpu(i, mask)
 		cfs_cpt_unset_cpu(cptab, cpt, i);
 }
 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
@@ -493,7 +496,7 @@ cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
 	}
 
 	for (; cpt <= last; cpt++) {
-		for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask)
+		for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask)
 			cfs_cpt_unset_cpu(cptab, cpt, i);
 	}
 }
@@ -578,7 +581,7 @@ cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
 		nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
 	}
 
-	if (any_online_cpu(*cpumask) >= nr_cpu_ids) {
+	if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids) {
 		CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n",
 		       cpt);
 		return -EINVAL;
@@ -654,7 +657,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
 
 			LASSERT(!cpumask_empty(core));
 
-			for_each_cpu_mask(i, *core) {
+			for_each_cpu(i, core) {
 				cpumask_clear_cpu(i, socket);
 				cpumask_clear_cpu(i, node);
 
@@ -965,7 +968,8 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
 		mutex_lock(&cpt_data.cpt_mutex);
 		/* if all HTs in a core are offline, it may break affinity */
 		cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask);
-		warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids;
+		warn = cpumask_any_and(cpt_data.cpt_cpumask,
+				       cpu_online_mask) >= nr_cpu_ids;
 		mutex_unlock(&cpt_data.cpt_mutex);
 		CDEBUG(warn ? D_WARNING : D_INFO,
 		       "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n",
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/4 staging/lustre/o2iblnd: Don't use cpus_weight

In reply to [email protected]

From: Oleg Drokin <[email protected]>

cpus_weight and for_each_cpu_mask are deprecated, so replace them with cpumask_weight and for_each_cpu respectively.

---
 drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +2 -2
index 109f44c..b725a99 100644
@@ -638,8 +638,8 @@ kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
 		return 0;
 
 	/* hash NID to CPU id in this partition... */
-	off = do_div(nid, cpus_weight(*mask));
-	for_each_cpu_mask(i, *mask) {
+	off = do_div(nid, cpumask_weight(mask));
+	for_each_cpu(i, mask) {
 		if (off-- == 0)
 			return i % vectors;
 	}
Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/4 staging/lustre/llite: avoid nonatomic memory alloc under spinlock

In reply to [email protected]

From: Lai Siyao <[email protected]>

ll_intent_drop_lock() may sleep in memory allocation, which should not be called inside spinlock.

Reviewed-on: http://review.whamcloud.com/10674
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2272

---
 drivers/staging/lustre/lustre/llite/statahead.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/llite/statahead.c +11 -2
index fe732fa..b75562c 100644
@@ -706,11 +706,21 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
 	struct ll_inode_info     *lli = ll_i2info(dir);
 	struct ll_statahead_info *sai = NULL;
 	struct ll_sa_entry       *entry;
+	__u64			  handle = 0;
 	int		       wakeup;
 
 	if (it_disposition(it, DISP_LOOKUP_NEG))
 		rc = -ENOENT;
 
+	if (rc == 0) {
+		/* release ibits lock ASAP to avoid deadlock when statahead
+		 * thread enqueues lock on parent in readdir and another
+		 * process enqueues lock on child with parent lock held, eg.
+		 * unlink. */
+		handle = it->d.lustre.it_lock_handle;
+		ll_intent_drop_lock(it);
+	}
+
 	spin_lock(&lli->lli_sa_lock);
 	/* stale entry */
 	if (unlikely(lli->lli_sai == NULL ||
@@ -745,8 +755,7 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
 			 * when statahead thread tries to enqueue lock on parent
 			 * for readpage and other tries to enqueue lock on child
 			 * with parent's lock held, for example: unlink. */
-			entry->se_handle = it->d.lustre.it_lock_handle;
-			ll_intent_drop_lock(it);
+			entry->se_handle = handle;
 			wakeup = sa_received_empty(sai);
 			list_add_tail(&entry->se_list,
 					  &sai->sai_entries_received);
Signature · 1 line
2.1.0
#4 lore raw

PATCH 4/4 staging/lustre: Don't call blocking funcitons when !RUNNABLE

In reply to [email protected]

From: Oleg Drokin <[email protected]>

Move setting of TASK_INTERRUPTIBLE just around schedule call in libcfs_sock_accept.

---
 drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +4 -6
index cd2fc01..f2462e7 100644
@@ -543,19 +543,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
 
 	newsock->ops = sock->ops;
 
-	set_current_state(TASK_INTERRUPTIBLE);
-	add_wait_queue(sk_sleep(sock->sk), &wait);
-
 	rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
 	if (rc == -EAGAIN) {
 		/* Nothing ready, so wait for activity */
+		set_current_state(TASK_INTERRUPTIBLE);
+		add_wait_queue(sk_sleep(sock->sk), &wait);
 		schedule();
+		remove_wait_queue(sk_sleep(sock->sk), &wait);
+		set_current_state(TASK_RUNNING);
 		rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
 	}
 
-	remove_wait_queue(sk_sleep(sock->sk), &wait);
-	set_current_state(TASK_RUNNING);
-
 	if (rc != 0)
 		goto failed;
 
Signature · 1 line
2.1.0