Skip to contentSkip to conversation

Lustre fixes

PATCH In review [email protected] 2 participants 22 messages Sep 14, 2015 – Sep 15, 2015 Staging

lore
Share & tools
lore
#0 lore raw

cover Lustre fixes

From: Oleg Drokin <[email protected]>

This batch of changes is for various accumulated fixes since the last time I had a chance to look at it.

The only "exception" is the last patch in the series - the CPT-aware ptlrpcd patch. This one is included because there was a strange code in that area otherwise that was flagged as we were working on cpumasks code.

Please consider.

Andreas Dilger (1):
staging/lustre/ptlrpc: remove LUSTRE_MSG_MAGIC_V1 support

Andrew Perepechko (1):
staging/lustre/llite: ASSERTION( atomic_read(&d->ld_ref) == 0 ) failed

Ann Koehler (1):
staging/lustre/obdclass: Eliminate hash bucket scans in
lu_cache_shrink

Ben Evans (1):
staging/lustre: Remove unused MAY_ constants

Bruno Faccini (1):
staging/lustre/llite: strengthen checks for hsm flags and archive id

Fan Yong (1):
staging/lustre/llite: cleanup open handle for client open failure

Frank Zago (1):
staging/lustre/obdclass: reorganize busy object accounting

Hiroya Nozaki (1):
staging/lustre/osc: LBUG in osc_lru_reclaim

Isaac Huang (1):
staging/lustre/o2iblnd: wrong uses of kib_tx_t::tx_nfrags

James Simmons (1):
staging/lustre/libcfs: remove unused cfs_timer_done

Li Xi (1):
staging/lustre/osc: use global osc_rq_pool to reduce memory usage

Liang Zhen (3):
staging/lustre/o2iblnd: connection refcount fix for kiblnd_post_rx staging/lustre/lnet: fix deadloop in ksocknal_push staging/lustre/o2iblnd: leak cmid in kiblnd_dev_need_failover

Niu Yawei (2):
staging/lustre/llite: deny non-root user for changelog operations staging/lustre/libcfs: minor fix in cfs_hash_for_each_relax()

Olaf Weber (1):
staging/lustre/ptlrpc: make ptlrpcd threads cpt-aware

Oleg Drokin (2):
staging/lustre/lnet: Reenable lnet router debugfs staging/lustre/lmv: fix potential null pointer dereference

 .../staging/lustre/include/linux/libcfs/libcfs.h   |   8 +
 .../lustre/include/linux/libcfs/libcfs_prim.h      |   1 -
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |   4 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   9 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |   3 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |  55 +-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |  51 +-
 drivers/staging/lustre/lnet/lnet/api-ni.c          |   4 +-
 drivers/staging/lustre/lnet/lnet/router_proc.c     |  43 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |   5 +-
 .../lustre/lustre/include/lustre/lustre_idl.h      |  27 +-
 .../staging/lustre/lustre/include/lustre_import.h  |   2 -
 drivers/staging/lustre/lustre/include/lustre_net.h |  63 +-
 drivers/staging/lustre/lustre/include/obd_class.h  |   4 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   8 +-
 drivers/staging/lustre/lustre/libcfs/hash.c        |   4 +
 .../lustre/lustre/libcfs/linux/linux-prim.c        |   6 -
 drivers/staging/lustre/lustre/libcfs/module.c      | 188 +++---
 drivers/staging/lustre/lustre/llite/dir.c          |   3 +
 drivers/staging/lustre/lustre/llite/file.c         |   9 +
 .../staging/lustre/lustre/llite/llite_internal.h   |  11 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c    |  48 +-
 drivers/staging/lustre/lustre/llite/llite_nfs.c    |   5 +-
 drivers/staging/lustre/lustre/llite/namei.c        |  14 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |   8 +-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c      |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |   2 +-
 drivers/staging/lustre/lustre/obdclass/genops.c    |   1 -
 drivers/staging/lustre/lustre/obdclass/lu_object.c | 101 +--
 drivers/staging/lustre/lustre/osc/lproc_osc.c      |  17 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c      |  28 +-
 .../staging/lustre/lustre/osc/osc_cl_internal.h    |   2 +-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |   6 +-
 drivers/staging/lustre/lustre/osc/osc_page.c       |   3 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    | 120 ++--
 drivers/staging/lustre/lustre/ptlrpc/client.c      |  32 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c      |   7 +-
 drivers/staging/lustre/lustre/ptlrpc/niobuf.c      |   3 +-
 .../staging/lustre/lustre/ptlrpc/pack_generic.c    |  96 +--
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |   2 +-
 .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h |   2 +-
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c     | 702 +++++++++++++--------
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c    |   4 -
 43 files changed, 923 insertions(+), 790 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/19 staging/lustre/lnet: Reenable lnet router debugfs

From: Oleg Drokin <[email protected]>

It looks like router proc files were defined out, so I missed them during debugfs conversion.
Reenable the code and move all the variables to debugfs.

---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   8 +
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |   4 +-
 drivers/staging/lustre/lnet/lnet/api-ni.c          |   4 +-
 drivers/staging/lustre/lnet/lnet/router_proc.c     |  43 +----
 drivers/staging/lustre/lustre/libcfs/module.c      | 188 ++++++++++-----------
 5 files changed, 105 insertions(+), 142 deletions(-)
drivers/staging/lustre/include/linux/libcfs/libcfs.h +8 -0
index 01961d9..259a336 100644
@@ -161,4 +161,12 @@ extern struct cfs_psdev_ops libcfs_psdev_ops;
 
 extern struct cfs_wi_sched *cfs_sched_rehash;
 
+struct lnet_debugfs_symlink_def {
+	char *name;
+	char *target;
+};
+
+void lustre_insert_debugfs(struct ctl_table *table,
+			   const struct lnet_debugfs_symlink_def *symlinks);
+
 #endif /* _LIBCFS_H */
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +2 -2
index a9c9a07..22d54b2 100644
@@ -443,8 +443,8 @@ int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
 void lnet_destroy_routes(void);
 int lnet_get_route(int idx, __u32 *net, __u32 *hops,
 		   lnet_nid_t *gateway, __u32 *alive, __u32 *priority);
-void lnet_proc_init(void);
-void lnet_proc_fini(void);
+void lnet_router_debugfs_init(void);
+void lnet_router_debugfs_fini(void);
 int  lnet_rtrpools_alloc(int im_a_router);
 void lnet_rtrpools_free(void);
 lnet_remotenet_t *lnet_find_net_locked(__u32 net);
drivers/staging/lustre/lnet/lnet/api-ni.c +2 -2
index d14fe70..7fab03b 100644
@@ -1262,7 +1262,7 @@ LNetNIInit(lnet_pid_t requested_pid)
 	if (rc != 0)
 		goto failed4;
 
-	lnet_proc_init();
+	lnet_router_debugfs_init();
 	goto out;
 
  failed4:
@@ -1305,7 +1305,7 @@ LNetNIFini(void)
 	} else {
 		LASSERT(!the_lnet.ln_niinit_self);
 
-		lnet_proc_fini();
+		lnet_router_debugfs_fini();
 		lnet_router_checker_stop();
 		lnet_ping_target_fini();
 
drivers/staging/lustre/lnet/lnet/router_proc.c +3 -40

60 lines not on this page · raw message

drivers/staging/lustre/lustre/libcfs/module.c +90 -98

236 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/19 staging/lustre/obdclass: reorganize busy object accounting

In reply to [email protected]

From: Frank Zago <[email protected]>

Due to some accounting bug, lsb_busy of a hash bucket can become larger than the total number of objects in said bucket. A busy object can be counted more than once. When that happens, a negative value is returned by the shrinker callback.

Instead of trying (and failing) to count the busy objects, count the objects than are not busy, i.e. the objects that are present on the lsb_lru list. The number of busy objects is then the difference between the number of objects in the hash and the objects on the lsb_lru list.

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

---
 drivers/staging/lustre/lustre/include/lu_object.h  |  4 +--
 drivers/staging/lustre/lustre/obdclass/lu_object.c | 35 +++++++++-------------
 2 files changed, 16 insertions(+), 23 deletions(-)
drivers/staging/lustre/lustre/include/lu_object.h +2 -2
index a16c9ea..ea13a82 100644
@@ -554,9 +554,9 @@ struct fld;
 
 struct lu_site_bkt_data {
 	/**
-	 * number of busy object on this bucket
+	 * number of object in this bucket on the lsb_lru list.
 	 */
-	long		      lsb_busy;
+	long			lsb_lru_len;
 	/**
 	 * LRU list, updated on each access to object. Protected by
 	 * bucket lock of lu_site::ls_obj_hash.
drivers/staging/lustre/lustre/obdclass/lu_object.c +14 -21
index 3111982..4f7899f 100644
@@ -113,8 +113,6 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
 		return;
 	}
 
-	LASSERT(bkt->lsb_busy > 0);
-	bkt->lsb_busy--;
 	/*
 	 * When last reference is released, iterate over object
 	 * layers, and notify them that object is no longer busy.
@@ -127,6 +125,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
 	if (!lu_object_is_dying(top)) {
 		LASSERT(list_empty(&top->loh_lru));
 		list_add_tail(&top->loh_lru, &bkt->lsb_lru);
+		bkt->lsb_lru_len++;
 		cfs_hash_bd_unlock(site->ls_obj_hash, &bd, 1);
 		return;
 	}
@@ -179,7 +178,13 @@ void lu_object_unhash(const struct lu_env *env, struct lu_object *o)
 		struct cfs_hash_bd bd;
 
 		cfs_hash_bd_get_and_lock(obj_hash, &top->loh_fid, &bd, 1);
+		if (!list_empty(&top->loh_lru)) {
+			struct lu_site_bkt_data *bkt;
+
 		list_del_init(&top->loh_lru);
+			bkt = cfs_hash_bd_extra_get(obj_hash, &bd);
+			bkt->lsb_lru_len--;
+		}
 		cfs_hash_bd_del_locked(obj_hash, &bd, &top->loh_hash);
 		cfs_hash_bd_unlock(obj_hash, &bd, 1);
 	}
@@ -349,6 +354,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr)
 			cfs_hash_bd_del_locked(s->ls_obj_hash,
 					       &bd2, &h->loh_hash);
 			list_move(&h->loh_lru, &dispose);
+			bkt->lsb_lru_len--;
 			if (did_sth == 0)
 				did_sth = 1;
 
@@ -561,7 +567,10 @@ static struct lu_object *htable_lookup(struct lu_site *s,
 	if (likely(!lu_object_is_dying(h))) {
 		cfs_hash_get(s->ls_obj_hash, hnode);
 		lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
+		if (!list_empty(&h->loh_lru)) {
 		list_del_init(&h->loh_lru);
+			bkt->lsb_lru_len--;
+		}
 		return lu_object_top(h);
 	}
 
@@ -599,7 +608,6 @@ static struct lu_object *lu_object_new(const struct lu_env *env,
 	struct lu_object	*o;
 	struct cfs_hash	      *hs;
 	struct cfs_hash_bd	    bd;
-	struct lu_site_bkt_data *bkt;
 
 	o = lu_object_alloc(env, dev, f, conf);
 	if (IS_ERR(o))
@@ -607,9 +615,7 @@ static struct lu_object *lu_object_new(const struct lu_env *env,
 
 	hs = dev->ld_site->ls_obj_hash;
 	cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1);
-	bkt = cfs_hash_bd_extra_get(hs, &bd);
 	cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
-	bkt->lsb_busy++;
 	cfs_hash_bd_unlock(hs, &bd, 1);
 	return o;
 }
@@ -675,11 +681,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
 
 	shadow = htable_lookup(s, &bd, f, waiter, &version);
 	if (likely(PTR_ERR(shadow) == -ENOENT)) {
-		struct lu_site_bkt_data *bkt;
-
-		bkt = cfs_hash_bd_extra_get(hs, &bd);
 		cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
-		bkt->lsb_busy++;
 		cfs_hash_bd_unlock(hs, &bd, 1);
 		return o;
 	}
@@ -926,14 +928,7 @@ static void lu_obj_hop_get(struct cfs_hash *hs, struct hlist_node *hnode)
 	struct lu_object_header *h;
 
 	h = hlist_entry(hnode, struct lu_object_header, loh_hash);
-	if (atomic_add_return(1, &h->loh_ref) == 1) {
-		struct lu_site_bkt_data *bkt;
-		struct cfs_hash_bd	    bd;
-
-		cfs_hash_bd_get(hs, &h->loh_fid, &bd);
-		bkt = cfs_hash_bd_extra_get(hs, &bd);
-		bkt->lsb_busy++;
-	}
+	atomic_inc(&h->loh_ref);
 }
 
 static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
@@ -1802,7 +1797,8 @@ static void lu_site_stats_get(struct cfs_hash *hs,
 		struct hlist_head	*hhead;
 
 		cfs_hash_bd_lock(hs, &bd, 1);
-		stats->lss_busy  += bkt->lsb_busy;
+		stats->lss_busy  +=
+			cfs_hash_bd_count_get(&bd) - bkt->lsb_lru_len;
 		stats->lss_total += cfs_hash_bd_count_get(&bd);
 		stats->lss_max_search = max((int)stats->lss_max_search,
 					    cfs_hash_bd_depmax_get(&bd));
@@ -2067,7 +2063,6 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
 {
 	struct lu_site		*s = o->lo_dev->ld_site;
 	struct lu_fid		*old = &o->lo_header->loh_fid;
-	struct lu_site_bkt_data	*bkt;
 	struct lu_object	*shadow;
 	wait_queue_t		 waiter;
 	struct cfs_hash		*hs;
@@ -2082,9 +2077,7 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
 	/* supposed to be unique */
 	LASSERT(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT);
 	*old = *fid;
-	bkt = cfs_hash_bd_extra_get(hs, &bd);
 	cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
-	bkt->lsb_busy++;
 	cfs_hash_bd_unlock(hs, &bd, 1);
 }
 EXPORT_SYMBOL(lu_object_assign_fid);
Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/19 staging/lustre/llite: cleanup open handle for client open failure

In reply to [email protected]

From: Fan Yong <[email protected]>

For open case, the client side open handling thread may hit error after the MDT grant the open. Under such case, the client should send close RPC to the MDT as cleanup; otherwise, the open handle on the MDT will be leaked there until the client umount or evicted.

If the LFSCK marks LU_OBJECT_HEARD_BANSHEE on the MDT-object that is opened by others for repairing some inconsistency, such as repairing multiple-referenced OST-object, because the leaked open handle still references the MDT-object, then it will block the subsequent threads that want to locate such object via FID.

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

---
 .../staging/lustre/lustre/llite/llite_internal.h   |  1 +
 drivers/staging/lustre/lustre/llite/llite_lib.c    | 48 +++++++++++++++++++++-
 drivers/staging/lustre/lustre/llite/namei.c        | 14 +++++--
 3 files changed, 58 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +1 -0
index 2de64c2..8a3b03e 100644
@@ -801,6 +801,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
 void ll_finish_md_op_data(struct md_op_data *op_data);
 int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg);
 char *ll_get_fsname(struct super_block *sb, char *buf, int buflen);
+void ll_open_cleanup(struct super_block *sb, struct ptlrpc_request *open_req);
 
 /* llite/llite_nfs.c */
 extern struct export_operations lustre_export_operations;
drivers/staging/lustre/lustre/llite/llite_lib.c +47 -1

66 lines not on this page · raw message

drivers/staging/lustre/lustre/llite/namei.c +10 -4
index 05e7dc8..2635678 100644
@@ -409,7 +409,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
 {
 	struct inode *inode = NULL;
 	__u64 bits = 0;
-	int rc;
+	int rc = 0;
 
 	/* NB 1 request reference will be taken away by ll_intent_lock()
 	 * when I return */
@@ -439,8 +439,10 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
 		struct dentry *alias;
 
 		alias = ll_splice_alias(inode, *de);
-		if (IS_ERR(alias))
-			return PTR_ERR(alias);
+		if (IS_ERR(alias)) {
+			rc = PTR_ERR(alias);
+			goto out;
+		}
 		*de = alias;
 	} else if (!it_disposition(it, DISP_LOOKUP_NEG)  &&
 		   !it_disposition(it, DISP_OPEN_CREATE)) {
@@ -471,7 +473,11 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
 		}
 	}
 
-	return 0;
+out:
+	if (rc != 0 && it->it_op & IT_OPEN)
+		ll_open_cleanup((*de)->d_sb, request);
+
+	return rc;
 }
 
 static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
Signature · 1 line
2.1.0
#4 lore raw

PATCH 4/19 staging/lustre/llite: strengthen checks for hsm flags and archive id

In reply to [email protected]

From: Bruno Faccini <[email protected]>

Prior to this patch undefined flags bits and out of range archive id can be set.

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

---
 drivers/staging/lustre/lustre/include/lustre/lustre_idl.h | 7 +++++++
 drivers/staging/lustre/lustre/llite/file.c                | 9 +++++++++
 2 files changed, 16 insertions(+)
drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +7 -0
index e79af19..9416d95 100644
@@ -365,6 +365,13 @@ static inline __u64 fid_ver_oid(const struct lu_fid *fid)
 	return ((__u64)fid_ver(fid) << 32 | fid_oid(fid));
 }
 
+/* copytool uses a 32b bitmask field to encode archive-Ids during register
+ * with MDT thru kuc.
+ * archive num = 0 => all
+ * archive num from 1 to 32
+ */
+#define LL_HSM_MAX_ARCHIVE (sizeof(__u32) * 8)
+
 /**
  * Note that reserved SEQ numbers below 12 will conflict with ldiskfs
  * inodes in the IGIF namespace, so these reserved SEQ numbers can be
drivers/staging/lustre/lustre/llite/file.c +9 -0
index e332326..b610032 100644
@@ -2118,12 +2118,21 @@ static int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss)
 	struct md_op_data	*op_data;
 	int			 rc;
 
+	/* Detect out-of range masks */
+	if ((hss->hss_setmask | hss->hss_clearmask) & ~HSM_FLAGS_MASK)
+		return -EINVAL;
+
 	/* Non-root users are forbidden to set or clear flags which are
 	 * NOT defined in HSM_USER_MASK. */
 	if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) &&
 	    !capable(CFS_CAP_SYS_ADMIN))
 		return -EPERM;
 
+	/* Detect out-of range archive id */
+	if ((hss->hss_valid & HSS_ARCHIVE_ID) &&
+	    (hss->hss_archive_id > LL_HSM_MAX_ARCHIVE))
+		return -EINVAL;
+
 	op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
 				     LUSTRE_OPC_ANY, hss);
 	if (IS_ERR(op_data))
Signature · 1 line
2.1.0
#5 lore raw

PATCH 5/19 staging/lustre/ptlrpc: remove LUSTRE_MSG_MAGIC_V1 support

In reply to [email protected]

From: Andreas Dilger <[email protected]>

Remove the remains of LUSTRE_MSG_MAGIC_V1 support from ptlrpc. It has not been supported since 1.8 and is not functional since 2.0.

In lustre_msg_check_version(), return an error for unsupported RPC versions so that the server will reject such RPCs early. Otherwise the server only prints an error message and continue on.

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

---
 .../lustre/lustre/include/lustre/lustre_idl.h      |  3 -
 drivers/staging/lustre/lustre/include/lustre_net.h |  2 -
 drivers/staging/lustre/lustre/ptlrpc/niobuf.c      |  3 +-
 .../staging/lustre/lustre/ptlrpc/pack_generic.c    | 96 ++++++----------------
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c    |  4 -
 5 files changed, 24 insertions(+), 84 deletions(-)
drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +0 -3
index 9416d95..b0c4433 100644
@@ -154,10 +154,7 @@
 #define PTL_RPC_MSG_REPLY   4713
 
 /* DON'T use swabbed values of MAGIC as magic! */
-#define LUSTRE_MSG_MAGIC_V1 0x0BD00BD0
 #define LUSTRE_MSG_MAGIC_V2 0x0BD00BD3
-
-#define LUSTRE_MSG_MAGIC_V1_SWABBED 0xD00BD00B
 #define LUSTRE_MSG_MAGIC_V2_SWABBED 0xD30BD00B
 
 #define LUSTRE_MSG_MAGIC LUSTRE_MSG_MAGIC_V2
drivers/staging/lustre/lustre/include/lustre_net.h +0 -2
index 3341b5d..5df493e 100644
@@ -2610,7 +2610,6 @@ void lustre_msg_set_flags(struct lustre_msg *msg, int flags);
 void lustre_msg_clear_flags(struct lustre_msg *msg, int flags);
 __u32 lustre_msg_get_op_flags(struct lustre_msg *msg);
 void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags);
-void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags);
 struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg);
 __u32 lustre_msg_get_type(struct lustre_msg *msg);
 __u32 lustre_msg_get_version(struct lustre_msg *msg);
@@ -2626,7 +2625,6 @@ void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv);
 void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit);
 int lustre_msg_get_status(struct lustre_msg *msg);
 __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg);
-int lustre_msg_is_v1(struct lustre_msg *msg);
 __u32 lustre_msg_get_magic(struct lustre_msg *msg);
 __u32 lustre_msg_get_timeout(struct lustre_msg *msg);
 __u32 lustre_msg_get_service_time(struct lustre_msg *msg);
drivers/staging/lustre/lustre/ptlrpc/niobuf.c +1 -2
index 92c746b..22194c0 100644
@@ -337,9 +337,8 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags)
 
 	if (req->rq_reqmsg &&
 	    !(lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)) {
-		CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x req_flags=%#x magic=%d:%x/%x len=%d\n",
+		CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x req_flags=%#x magic=%x/%x len=%d\n",
 		       flags, lustre_msg_get_flags(req->rq_reqmsg),
-		       lustre_msg_is_v1(req->rq_reqmsg),
 		       lustre_msg_get_magic(req->rq_reqmsg),
 		       lustre_msg_get_magic(req->rq_repmsg), req->rq_replen);
 	}
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +23 -73

229 lines not on this page · raw message

drivers/staging/lustre/lustre/ptlrpc/wiretest.c +0 -4
index d6d9204..b2313af 100644
@@ -636,12 +636,8 @@ void lustre_assert_wire_constants(void)
 		 (long long)(int)offsetof(struct lustre_msg_v2, lm_buflens[0]));
 	LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0]) == 4, "found %lld\n",
 		 (long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0]));
-	LASSERTF(LUSTRE_MSG_MAGIC_V1 == 0x0BD00BD0, "found 0x%.8x\n",
-		LUSTRE_MSG_MAGIC_V1);
 	LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0BD00BD3, "found 0x%.8x\n",
 		LUSTRE_MSG_MAGIC_V2);
-	LASSERTF(LUSTRE_MSG_MAGIC_V1_SWABBED == 0xD00BD00B, "found 0x%.8x\n",
-		LUSTRE_MSG_MAGIC_V1_SWABBED);
 	LASSERTF(LUSTRE_MSG_MAGIC_V2_SWABBED == 0xD30BD00B, "found 0x%.8x\n",
 		LUSTRE_MSG_MAGIC_V2_SWABBED);
 
Signature · 1 line
2.1.0
#6 lore raw

PATCH 6/19 staging/lustre/lmv: fix potential null pointer dereference

In reply to [email protected]

From: Oleg Drokin <[email protected]>

In lmv_disconnect_mdc do procfs removal only if we actually know the name.

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

---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/lmv/lmv_obd.c +4 -4
index 0fc0b61..cebbacf 100644
@@ -593,11 +593,11 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
 		mdc_obd->obd_force = obd->obd_force;
 		mdc_obd->obd_fail = obd->obd_fail;
 		mdc_obd->obd_no_recov = obd->obd_no_recov;
-	}
 
-	if (lmv->lmv_tgts_kobj)
-		sysfs_remove_link(lmv->lmv_tgts_kobj,
-				  mdc_obd->obd_name);
+		if (lmv->lmv_tgts_kobj)
+			sysfs_remove_link(lmv->lmv_tgts_kobj,
+					  mdc_obd->obd_name);
+	}
 
 	rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
 	if (rc)
Signature · 1 line
2.1.0
#7 lore raw

Re: [PATCH 06/19] staging/lustre/lmv: fix potential null pointer dereference

Quoted 1 line · On 09/14/15 18:41, [email protected] wrote:

Reviewed-on: http://review.whamcloud.com/14605

I'm confused why the patch found in this email doesn't match the patch I find when I click on the above link? Some of the patches in this series match what I find on your jenkins URLs, and some do not.

For example, the function call in the body of the "if" below is "sysfs_remove_link()" but the function call in the "if" body of the code I find at http://review.whamcloud.com/14605 after clicking on the "lustre/lmv/lmv_obd.c" link is "lprocfs_remove_proc_entry()".

Maybe I'm not using your jenkins correctly?

Quoted 29 lines

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6517

---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/lmv/lmv_obd.c +4 -4
index 0fc0b61..cebbacf 100644
@@ -593,11 +593,11 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
 		mdc_obd->obd_force = obd->obd_force;
 		mdc_obd->obd_fail = obd->obd_fail;
 		mdc_obd->obd_no_recov = obd->obd_no_recov;
-	}
 
-	if (lmv->lmv_tgts_kobj)
-		sysfs_remove_link(lmv->lmv_tgts_kobj,
-				  mdc_obd->obd_name);
+		if (lmv->lmv_tgts_kobj)
+			sysfs_remove_link(lmv->lmv_tgts_kobj,
+					  mdc_obd->obd_name);
+	}
 
 	rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
 	if (rc)
#8 lore raw

Re: [PATCH 06/19] staging/lustre/lmv: fix potential null pointer dereference

Hello!

Quoted 7 lines · Trevor Woerner
Quoted 1 line · On 09/14/15 18:41, [email protected] wrote:

Reviewed-on: http://review.whamcloud.com/14605

I'm confused why the patch found in this email doesn't match the patch I find when I click on the above link? Some of the patches in this series match what I find on your jenkins URLs, and some do not.

Quoted 6 lines

For example, the function call in the body of the "if" below is "sysfs_remove_link()" but the function call in the "if" body of the code I find at http://review.whamcloud.com/14605 after clicking on the "lustre/lmv/lmv_obd.c" link is "lprocfs_remove_proc_entry()".

Maybe I'm not using your jenkins correctly?

You are using it correctly.

The patch is a "port" from one tree to another, but the pointer is to the original patch. As the trees have diverged, various differences have accumulated.

The pointer is still useful to better be able to see which patches were already included and which were not yet.

Bye,
Oleg

#9 lore raw

PATCH 7/19 staging/lustre/llite: deny non-root user for changelog operations

In reply to [email protected]

From: Niu Yawei <[email protected]>

To avoid potential security problems, non-privileged users should have no permission to run 'lfs changelog' & 'lfs changelog_clear'.

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

---
 drivers/staging/lustre/lustre/llite/dir.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/staging/lustre/lustre/llite/dir.c +3 -0
index d407fcc..cc6f0f5 100644
@@ -1734,6 +1734,9 @@ out_quotactl:
 	}
 	case OBD_IOC_CHANGELOG_SEND:
 	case OBD_IOC_CHANGELOG_CLEAR:
+		if (!capable(CFS_CAP_SYS_ADMIN))
+			return -EPERM;
+
 		rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg,
 				    sizeof(struct ioc_changelog));
 		return rc;
Signature · 1 line
2.1.0
#10 lore raw

PATCH 8/19 staging/lustre/o2iblnd: connection refcount fix for kiblnd_post_rx

In reply to [email protected]

From: Liang Zhen <[email protected]>

kiblnd_post_rx() can't refer to rx::rx_conn anymore after ib_post_recv() because this rx can be polled out by another thread which may drop this rx and destroy rx::rx_conn.

This patch fixes this issue by taking an extra refcount on connection before calling ib_post_recv().

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

---
 drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +12 -6
index 345ed4d..c0f5682 100644
@@ -178,24 +178,28 @@ kiblnd_post_rx(kib_rx_t *rx, int credit)
 
 	rx->rx_nob = -1;			/* flag posted */
 
+	/* NB: need an extra reference after ib_post_recv because we don't
+	 * own this rx (and rx::rx_conn) anymore, LU-5678.
+	 */
+	kiblnd_conn_addref(conn);
 	rc = ib_post_recv(conn->ibc_cmid->qp, &rx->rx_wrq, &bad_wrq);
-	if (rc != 0) {
+	if (unlikely(rc != 0)) {
 		CERROR("Can't post rx for %s: %d, bad_wrq: %p\n",
 		       libcfs_nid2str(conn->ibc_peer->ibp_nid), rc, bad_wrq);
 		rx->rx_nob = 0;
 	}
 
 	if (conn->ibc_state < IBLND_CONN_ESTABLISHED) /* Initial post */
-		return rc;
+		goto out;
 
-	if (rc != 0) {
+	if (unlikely(rc != 0)) {
 		kiblnd_close_conn(conn, rc);
 		kiblnd_drop_rx(rx);	     /* No more posts for this rx */
-		return rc;
+		goto out;
 	}
 
 	if (credit == IBLND_POSTRX_NO_CREDIT)
-		return 0;
+		goto out;
 
 	spin_lock(&conn->ibc_lock);
 	if (credit == IBLND_POSTRX_PEER_CREDIT)
@@ -205,7 +209,9 @@ kiblnd_post_rx(kib_rx_t *rx, int credit)
 	spin_unlock(&conn->ibc_lock);
 
 	kiblnd_check_sends(conn);
-	return 0;
+out:
+	kiblnd_conn_decref(conn);
+	return rc;
 }
 
 static kib_tx_t *
Signature · 1 line
2.1.0
#11 lore raw

PATCH 9/19 staging/lustre/osc: LBUG in osc_lru_reclaim

In reply to [email protected]

From: Hiroya Nozaki <[email protected]>

LASSERT touches cl_client_cache->ccc_lru without any protection. So this patch the LASSERT moves to the section protected by cl_client_cache->ccc_lru_lock

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

---
 drivers/staging/lustre/lustre/osc/osc_page.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/osc/osc_page.c +2 -1
index 856d859..2af3232 100644
@@ -818,7 +818,6 @@ static int osc_lru_reclaim(struct client_obd *cli)
 	int rc;
 
 	LASSERT(cache != NULL);
-	LASSERT(!list_empty(&cache->ccc_lru));
 
 	rc = osc_lru_shrink(cli, lru_shrink_min);
 	if (rc != 0) {
@@ -835,6 +834,8 @@ static int osc_lru_reclaim(struct client_obd *cli)
 	/* Reclaim LRU slots from other client_obd as it can't free enough
 	 * from its own. This should rarely happen. */
 	spin_lock(&cache->ccc_lru_lock);
+	LASSERT(!list_empty(&cache->ccc_lru));
+
 	cache->ccc_lru_shrinkers++;
 	list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru);
 
Signature · 1 line
2.1.0
#12 lore raw

PATCH 10/19 staging/lustre/libcfs: minor fix in cfs_hash_for_each_relax()

In reply to [email protected]

From: Niu Yawei <[email protected]>

cfs_hash_for_each_relax() should break iteration when callback returns non-zero value.

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

---
 drivers/staging/lustre/lustre/libcfs/hash.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/lustre/lustre/libcfs/hash.c +4 -0
index 286641b..6f4c7d4 100644
@@ -1623,8 +1623,12 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
 				if (rc) /* callback wants to break iteration */
 					break;
 			}
+			if (rc) /* callback wants to break iteration */
+				break;
 		}
 		cfs_hash_bd_unlock(hs, &bd, 0);
+		if (rc) /* callback wants to break iteration */
+			break;
 	}
 	cfs_hash_unlock(hs, 0);
 
Signature · 1 line
2.1.0
#13 lore raw

PATCH 11/19 staging/lustre/lnet: fix deadloop in ksocknal_push

In reply to [email protected]

From: Liang Zhen <[email protected]>

ksocknal_push() should break the loop if it can't find matching peer

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

---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    | 51 +++++++++++-----------
 1 file changed, 25 insertions(+), 26 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +25 -26
index d8bfcad..22f4cd0 100644
@@ -1874,52 +1874,51 @@ ksocknal_push_peer(ksock_peer_t *peer)
 	}
 }
 
-static int
-ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id)
+static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id)
 {
-	ksock_peer_t *peer;
+	struct list_head *start;
+	struct list_head *end;
 	struct list_head *tmp;
-	int index;
-	int i;
-	int j;
 	int rc = -ENOENT;
+	unsigned int hsize = ksocknal_data.ksnd_peer_hash_size;
 
-	for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-		for (j = 0; ; j++) {
-			read_lock(&ksocknal_data.ksnd_global_lock);
+	if (id.nid == LNET_NID_ANY) {
+		start = &ksocknal_data.ksnd_peers[0];
+		end = &ksocknal_data.ksnd_peers[hsize - 1];
+	} else {
+		start = end = ksocknal_nid2peerlist(id.nid);
+	}
 
-			index = 0;
-			peer = NULL;
+	for (tmp = start; tmp <= end; tmp++) {
+		int peer_off; /* searching offset in peer hash table */
 
-			list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) {
-				peer = list_entry(tmp, ksock_peer_t,
-						      ksnp_list);
+		for (peer_off = 0; ; peer_off++) {
+			ksock_peer_t *peer;
+			int i = 0;
 
+			read_lock(&ksocknal_data.ksnd_global_lock);
+			list_for_each_entry(peer, tmp, ksnp_list) {
 				if (!((id.nid == LNET_NID_ANY ||
 				       id.nid == peer->ksnp_id.nid) &&
 				      (id.pid == LNET_PID_ANY ||
-				       id.pid == peer->ksnp_id.pid))) {
-					peer = NULL;
+				       id.pid == peer->ksnp_id.pid)))
 					continue;
-				}
 
-				if (index++ == j) {
+				if (i++ == peer_off) {
 					ksocknal_peer_addref(peer);
 					break;
 				}
 			}
-
 			read_unlock(&ksocknal_data.ksnd_global_lock);
 
-			if (peer != NULL) {
-				rc = 0;
-				ksocknal_push_peer(peer);
-				ksocknal_peer_decref(peer);
-			}
-		}
+			if (i == 0) /* no match */
+				break;
 
+			rc = 0;
+			ksocknal_push_peer(peer);
+			ksocknal_peer_decref(peer);
+		}
 	}
-
 	return rc;
 }
 
Signature · 1 line
2.1.0
#14 lore raw

PATCH 12/19 staging/lustre/o2iblnd: wrong uses of kib_tx_t::tx_nfrags

In reply to [email protected]

From: Isaac Huang <[email protected]>

The kib_tx_t::tx_nfrags field is the # entries in the kib_tx_t::tx_frags array, rather than # DMA mapped entries. So kiblnd_send/kiblnd_recv should use kib_rdma_desc_t::rd_nfrags instead.

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

---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |  3 --
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 37 +++++++++++-----------
 2 files changed, 19 insertions(+), 21 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +0 -3
index 07e81cb..eb08400 100644
@@ -912,9 +912,6 @@ struct ib_mr *kiblnd_find_dma_mr(kib_hca_dev_t *hdev,
 				 __u64 addr, __u64 size);
 void kiblnd_map_rx_descs(kib_conn_t *conn);
 void kiblnd_unmap_rx_descs(kib_conn_t *conn);
-int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
-		  kib_rdma_desc_t *rd, int nfrags);
-void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx);
 void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node);
 struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps);
 
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +19 -18
index c0f5682..8ab73ee 100644
@@ -40,6 +40,8 @@
 
 #include "o2iblnd.h"
 
+static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx);
+
 static void
 kiblnd_tx_done(lnet_ni_t *ni, kib_tx_t *tx)
 {
@@ -596,8 +598,7 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
 	return 0;
 }
 
-void
-kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
+static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
 {
 	kib_net_t *net = ni->ni_data;
 
@@ -615,9 +616,8 @@ kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
 	}
 }
 
-int
-kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
-	      kib_rdma_desc_t *rd, int nfrags)
+static int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
+			 int nfrags)
 {
 	kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
 	kib_net_t *net = ni->ni_data;
@@ -1427,6 +1427,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 	unsigned int payload_offset = lntmsg->msg_offset;
 	unsigned int payload_nob = lntmsg->msg_len;
 	kib_msg_t *ibmsg;
+	kib_rdma_desc_t  *rd;
 	kib_tx_t *tx;
 	int nob;
 	int rc;
@@ -1470,16 +1471,14 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 		}
 
 		ibmsg = tx->tx_msg;
-
+		rd = &ibmsg->ibm_u.get.ibgm_rd;
 		if ((lntmsg->msg_md->md_options & LNET_MD_KIOV) == 0)
-			rc = kiblnd_setup_rd_iov(ni, tx,
-						 &ibmsg->ibm_u.get.ibgm_rd,
+			rc = kiblnd_setup_rd_iov(ni, tx, rd,
 						 lntmsg->msg_md->md_niov,
 						 lntmsg->msg_md->md_iov.iov,
 						 0, lntmsg->msg_md->md_length);
 		else
-			rc = kiblnd_setup_rd_kiov(ni, tx,
-						  &ibmsg->ibm_u.get.ibgm_rd,
+			rc = kiblnd_setup_rd_kiov(ni, tx, rd,
 						  lntmsg->msg_md->md_niov,
 						  lntmsg->msg_md->md_iov.kiov,
 						  0, lntmsg->msg_md->md_length);
@@ -1490,7 +1489,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 			return -EIO;
 		}
 
-		nob = offsetof(kib_get_msg_t, ibgm_rd.rd_frags[tx->tx_nfrags]);
+		nob = offsetof(kib_get_msg_t, ibgm_rd.rd_frags[rd->rd_nfrags]);
 		ibmsg->ibm_u.get.ibgm_cookie = tx->tx_cookie;
 		ibmsg->ibm_u.get.ibgm_hdr = *hdr;
 
@@ -1655,7 +1654,6 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
 	kib_msg_t *rxmsg = rx->rx_msg;
 	kib_conn_t *conn = rx->rx_conn;
 	kib_tx_t *tx;
-	kib_msg_t *txmsg;
 	int nob;
 	int post_credit = IBLND_POSTRX_PEER_CREDIT;
 	int rc = 0;
@@ -1692,7 +1690,10 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
 		lnet_finalize(ni, lntmsg, 0);
 		break;
 
-	case IBLND_MSG_PUT_REQ:
+	case IBLND_MSG_PUT_REQ: {
+		kib_msg_t	*txmsg;
+		kib_rdma_desc_t *rd;
+
 		if (mlen == 0) {
 			lnet_finalize(ni, lntmsg, 0);
 			kiblnd_send_completion(rx->rx_conn, IBLND_MSG_PUT_NAK, 0,
@@ -1710,13 +1711,12 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
 		}
 
 		txmsg = tx->tx_msg;
+		rd = &txmsg->ibm_u.putack.ibpam_rd;
 		if (kiov == NULL)
-			rc = kiblnd_setup_rd_iov(ni, tx,
-						 &txmsg->ibm_u.putack.ibpam_rd,
+			rc = kiblnd_setup_rd_iov(ni, tx, rd,
 						 niov, iov, offset, mlen);
 		else
-			rc = kiblnd_setup_rd_kiov(ni, tx,
-						  &txmsg->ibm_u.putack.ibpam_rd,
+			rc = kiblnd_setup_rd_kiov(ni, tx, rd,
 						  niov, kiov, offset, mlen);
 		if (rc != 0) {
 			CERROR("Can't setup PUT sink for %s: %d\n",
@@ -1728,7 +1728,7 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
 			break;
 		}
 
-		nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[tx->tx_nfrags]);
+		nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[rd->rd_nfrags]);
 		txmsg->ibm_u.putack.ibpam_src_cookie = rxmsg->ibm_u.putreq.ibprm_cookie;
 		txmsg->ibm_u.putack.ibpam_dst_cookie = tx->tx_cookie;
 
@@ -1741,6 +1741,7 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
 		/* reposted buffer reserved for PUT_DONE */
 		post_credit = IBLND_POSTRX_NO_CREDIT;
 		break;
+		}
 
 	case IBLND_MSG_GET_REQ:
 		if (lntmsg != NULL) {
Signature · 1 line
2.1.0
#15 lore raw

PATCH 13/19 staging/lustre/llite: ASSERTION( atomic_read(&d->ld_ref) == 0 ) failed

In reply to [email protected]

From: Andrew Perepechko <[email protected]>

ll_iget_for_nfs() can call unbalanced iput() causing memory leaks. This patch removes this iput() call.

Also, avoid unhashing disconnected dentries in d_lustre_invalidate(), which is another source of memory leaks.

One of the symptoms of the leak is the following crash pattern:
LustreError: 14812:0:(lu_object.c:1251:lu_device_fini())
ASSERTION( atomic_read(&d->ld_ref) == 0 ) failed: Refcount is 1
LustreError: 14812:0:(lu_object.c:1251:lu_device_fini()) LBUG
Pid: 14812, comm: umount

Call Trace:
 [<ffffffffa11bc895>] libcfs_debug_dumpstack+0x55/0x80 [libcfs]
 [<ffffffffa11bce97>] lbug_with_loc+0x47/0xb0 [libcfs]
 [<ffffffffa1458a48>] lu_device_fini+0xb8/0xc0 [obdclass]
 [<ffffffffa08e9ab2>] lovsub_device_free+0x52/0x220 [lov]
 [<ffffffffa145c64e>] lu_stack_fini+0x7e/0xc0 [obdclass]
 [<ffffffffa146356e>] cl_stack_fini+0xe/0x10 [obdclass]
 [<ffffffffa08bc1a8>] lov_device_fini+0x58/0x120 [lov]
 [<ffffffffa145c619>] lu_stack_fini+0x49/0xc0 [obdclass]
 [<ffffffffa146356e>] cl_stack_fini+0xe/0x10 [obdclass]
 [<ffffffffa0e1279d>] cl_sb_fini+0x6d/0x190 [lustre]
 [<ffffffffa0dd34bc>] ll_put_super+0x1bc/0x11e0 [lustre]
 [<ffffffff811cd0f2>] ? fsnotify_clear_marks_by_inode+0x32/0xf0
 [<ffffffff811a59df>] ? destroy_inode+0x2f/0x60
 [<ffffffff811a5eac>] ? dispose_list+0xfc/0x120
 [<ffffffff811a62a6>] ? invalidate_inodes+0xf6/0x190
 [<ffffffff8118b35b>] generic_shutdown_super+0x5b/0xe0
 [<ffffffff8118b446>] kill_anon_super+0x16/0x60
 [<ffffffffa144e7ba>] lustre_kill_super+0x4a/0x60 [obdclass]
 [<ffffffff8118bbe7>] deactivate_super+0x57/0x80
 [<ffffffff811aabef>] mntput_no_expire+0xbf/0x110
 [<ffffffff811ab73b>] sys_umount+0x7b/0x3a0
 [<ffffffff8100b072>] system_call_fastpath+0x16/0x1b

Reviewed-on: http://review.whamcloud.com/15480
Xyratex-bug-id: MRP-2414
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6794

---
 drivers/staging/lustre/lustre/llite/llite_internal.h | 10 +++++++++-
 drivers/staging/lustre/lustre/llite/llite_nfs.c      |  5 +----
 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +9 -1
index 8a3b03e..37bf331 100644
@@ -1466,7 +1466,15 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
 	spin_lock_nested(&dentry->d_lock,
 			 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
 	__d_lustre_invalidate(dentry);
-	if (d_count(dentry) == 0)
+	/*
+	 * We should be careful about dentries created by d_obtain_alias().
+	 * These dentries are not put in the dentry tree, instead they are
+	 * linked to sb->s_anon through dentry->d_hash.
+	 * shrink_dcache_for_umount() shrinks the tree and sb->s_anon list.
+	 * If we unhashed such a dentry, unmount would not be able to find
+	 * it and busy inodes would be reported.
+	 */
+	if (d_count(dentry) == 0 && !(dentry->d_flags & DCACHE_DISCONNECTED))
 		__d_drop(dentry);
 	spin_unlock(&dentry->d_lock);
 }
drivers/staging/lustre/lustre/llite/llite_nfs.c +1 -4
index 8d1c253..400acacc 100644
@@ -168,11 +168,8 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren
 		spin_unlock(&lli->lli_lock);
 	}
 
+	/* N.B. d_obtain_alias() drops inode ref on error */
 	result = d_obtain_alias(inode);
-	if (IS_ERR(result)) {
-		iput(inode);
-		return result;
-	}
 
 	return result;
 }
Signature · 1 line
2.1.0
#16 lore raw

PATCH 14/19 staging/lustre/obdclass: Eliminate hash bucket scans in lu_cache_shrink

In reply to [email protected]

From: Ann Koehler <[email protected]>

The lu_cache_shrink slab shrinker is too slow, accounting for > 90% of the time spent in shrink_slab when allocating huge pages. Most of its time is spent iterating over the buckets in each site's object hash table to compute the number of freeable objects. This iteration is eliminated by adding an lru length count to the lu_site struct. A percpu counter is used to maintain the lru length, so that the lu_site does not need to be locked when an object is accessed through the hash table. A counter is updated whenever an object is added to or deleted from any of the hash table buckets. The number of freeable objects is the sum of the counter values across all cpus.

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

---
 drivers/staging/lustre/lustre/include/lu_object.h  |  1 +
 drivers/staging/lustre/lustre/obdclass/lu_object.c | 66 ++++++++++++++--------
 2 files changed, 42 insertions(+), 25 deletions(-)
drivers/staging/lustre/lustre/include/lu_object.h +1 -0
index ea13a82..96e271d 100644
@@ -584,6 +584,7 @@ enum {
 	LU_SS_CACHE_RACE,
 	LU_SS_CACHE_DEATH_RACE,
 	LU_SS_LRU_PURGED,
+	LU_SS_LRU_LEN,	/* # of objects in lsb_lru lists */
 	LU_SS_LAST_STAT
 };
 
drivers/staging/lustre/lustre/obdclass/lu_object.c +41 -25

150 lines not on this page · raw message

Signature · 1 line
2.1.0
#17 lore raw

PATCH 15/19 staging/lustre: Remove unused MAY_ constants

In reply to [email protected]

From: Ben Evans <[email protected]>

Remove unused MAY_ constants from lustre_idl.h

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

---
 .../staging/lustre/lustre/include/lustre/lustre_idl.h   | 17 -----------------
 1 file changed, 17 deletions(-)
drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +0 -17
index b0c4433..d20e199 100644
@@ -2370,23 +2370,6 @@ void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa);
 					      */
 #define MDS_OPEN_RELEASE   02000000000000ULL /* Open the file for HSM release */
 
-/* permission for create non-directory file */
-#define MAY_CREATE      (1 << 7)
-/* permission for create directory file */
-#define MAY_LINK	(1 << 8)
-/* permission for delete from the directory */
-#define MAY_UNLINK      (1 << 9)
-/* source's permission for rename */
-#define MAY_RENAME_SRC  (1 << 10)
-/* target's permission for rename */
-#define MAY_RENAME_TAR  (1 << 11)
-/* part (parent's) VTX permission check */
-#define MAY_VTX_PART    (1 << 12)
-/* full VTX permission check */
-#define MAY_VTX_FULL    (1 << 13)
-/* lfs rgetfacl permission check */
-#define MAY_RGETFACL    (1 << 14)
-
 enum mds_op_bias {
 	MDS_CHECK_SPLIT		= 1 << 0,
 	MDS_CROSS_REF		= 1 << 1,
Signature · 1 line
2.1.0
#18 lore raw

PATCH 16/19 staging/lustre/osc: use global osc_rq_pool to reduce memory usage

In reply to [email protected]

From: Li Xi <[email protected]>

The per-osc request pools consume a lot of memory if there are hundreds of OSCs on one client. This will be a critical problem if the client doesn't have sufficient memory for both OSCs and applications.

This patch replaces per-osc request pools with a global pool osc_rq_pool. The total memory usage is 5MB by default. And it can be set by a module parameter of OSC:
"options osc osc_reqpool_mem_max=POOL_SIZE". The unit of POOL_SIZE is MB. If cl_max_rpcs_in_flight is the same for all OSCs, the memory usage of the OSC pool can be calculated as:
Min(POOL_SIZE * 1M,
(cl_max_rpcs_in_flight + 2) * OSC number * OST_MAXREQSIZE)

Also, this patch changes the allocation logic of OSC write requests. The allocation from osc_rq_pool will only be tried after normal allocation failed.

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

---
 .../staging/lustre/lustre/include/lustre_import.h  |  2 -
 drivers/staging/lustre/lustre/include/lustre_net.h |  7 +-
 drivers/staging/lustre/lustre/include/obd_class.h  |  4 --
 drivers/staging/lustre/lustre/obdclass/genops.c    |  1 -
 drivers/staging/lustre/lustre/osc/lproc_osc.c      | 17 ++++-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |  4 ++
 drivers/staging/lustre/lustre/osc/osc_request.c    | 79 ++++++++++++++++++----
 drivers/staging/lustre/lustre/ptlrpc/client.c      | 21 +++---
 8 files changed, 94 insertions(+), 41 deletions(-)
drivers/staging/lustre/lustre/include/lustre_import.h +0 -2
index 5a38f3d..c8b89a3 100644
@@ -306,8 +306,6 @@ struct obd_import {
 	__u32		     imp_msg_magic;
 	__u32		     imp_msghdr_flags;       /* adjusted based on server capability */
 
-	struct ptlrpc_request_pool *imp_rq_pool;	  /* emergency request pool */
-
 	struct imp_at	     imp_at;		 /* adaptive timeout data */
 	time_t		    imp_last_reply_time;    /* for health check */
 };
drivers/staging/lustre/lustre/include/lustre_net.h +3 -4
index 5df493e..313a56c 100644
@@ -500,7 +500,7 @@ struct ptlrpc_request_pool {
 	/** Maximum message size that would fit into a request from this pool */
 	int prp_rq_size;
 	/** Function to allocate more requests for this pool */
-	void (*prp_populate)(struct ptlrpc_request_pool *, int);
+	int (*prp_populate)(struct ptlrpc_request_pool *, int);
 };
 
 struct lu_context;
@@ -2381,11 +2381,11 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
 			    struct ptlrpc_request *req);
 
 void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool);
-void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
+int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
 
 struct ptlrpc_request_pool *
 ptlrpc_init_rq_pool(int, int,
-		    void (*populate_pool)(struct ptlrpc_request_pool *, int));
+		    int (*populate_pool)(struct ptlrpc_request_pool *, int));
 
 void ptlrpc_at_set_req_timeout(struct ptlrpc_request *req);
 struct ptlrpc_request *ptlrpc_request_alloc(struct obd_import *imp,
@@ -2957,7 +2957,6 @@ void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes);
 
 /* ptlrpc/llog_client.c */
 extern struct llog_operations llog_client_ops;
-
 /** @} net */
 
 #endif
drivers/staging/lustre/lustre/include/obd_class.h +0 -4
index 87bb2ce..ce6fa55 100644
@@ -626,10 +626,6 @@ static inline void obd_cleanup_client_import(struct obd_device *obd)
 		CDEBUG(D_CONFIG, "%s: client import never connected\n",
 		       obd->obd_name);
 		ptlrpc_invalidate_import(imp);
-		if (imp->imp_rq_pool) {
-			ptlrpc_free_rq_pool(imp->imp_rq_pool);
-			imp->imp_rq_pool = NULL;
-		}
 		client_destroy_import(imp);
 		obd->u.cli.cl_import = NULL;
 	}
drivers/staging/lustre/lustre/obdclass/genops.c +0 -1
index 370d5b4..594955d 100644
@@ -1663,7 +1663,6 @@ static void obd_zombie_export_add(struct obd_export *exp)
 static void obd_zombie_import_add(struct obd_import *imp)
 {
 	LASSERT(!imp->imp_sec);
-	LASSERT(!imp->imp_rq_pool);
 	spin_lock(&obd_zombie_impexp_lock);
 	LASSERT(list_empty(&imp->imp_zombie_chain));
 	zombies_count++;
drivers/staging/lustre/lustre/osc/lproc_osc.c +14 -3
index ff6d2e2..c504d15 100644
@@ -96,9 +96,9 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
 	struct obd_device *dev = container_of(kobj, struct obd_device,
 					      obd_kobj);
 	struct client_obd *cli = &dev->u.cli;
-	struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool;
 	int rc;
 	unsigned long val;
+	int adding, added, req_count;
 
 	rc = kstrtoul(buffer, 10, &val);
 	if (rc)
@@ -107,8 +107,19 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
 	if (val < 1 || val > OSC_MAX_RIF_MAX)
 		return -ERANGE;
 
-	if (pool && val > cli->cl_max_rpcs_in_flight)
-		pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight);
+	adding = val - cli->cl_max_rpcs_in_flight;
+	req_count = atomic_read(&osc_pool_req_count);
+	if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
+		/*
+		 * There might be some race which will cause over-limit
+		 * allocation, but it is fine.
+		 */
+		if (req_count + adding > osc_reqpool_maxreqcount)
+			adding = osc_reqpool_maxreqcount - req_count;
+
+		added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
+		atomic_add(added, &osc_pool_req_count);
+	}
 
 	client_obd_list_lock(&cli->cl_loi_list_lock);
 	cli->cl_max_rpcs_in_flight = val;
drivers/staging/lustre/lustre/osc/osc_internal.h +4 -0
index 470698b..7d0a3e2 100644
@@ -39,6 +39,10 @@
 
 #define OAP_MAGIC 8675309
 
+extern atomic_t osc_pool_req_count;
+extern unsigned int osc_reqpool_maxreqcount;
+extern struct ptlrpc_request_pool *osc_rq_pool;
+
 struct lu_env;
 
 enum async_flags {
drivers/staging/lustre/lustre/osc/osc_request.c +65 -14

128 lines not on this page · raw message

drivers/staging/lustre/lustre/ptlrpc/client.c +8 -13
index 1800db1..90b24fc 100644
@@ -446,7 +446,7 @@ EXPORT_SYMBOL(ptlrpc_free_rq_pool);
 /**
  * Allocates, initializes and adds \a num_rq requests to the pool \a pool
  */
-void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
+int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
 {
 	int i;
 	int size = 1;
@@ -468,11 +468,11 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
 		spin_unlock(&pool->prp_lock);
 		req = ptlrpc_request_cache_alloc(GFP_NOFS);
 		if (!req)
-			return;
+			return i;
 		msg = libcfs_kvzalloc(size, GFP_NOFS);
 		if (!msg) {
 			ptlrpc_request_cache_free(req);
-			return;
+			return i;
 		}
 		req->rq_reqbuf = msg;
 		req->rq_reqbuf_len = size;
@@ -481,6 +481,7 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
 		list_add_tail(&req->rq_list, &pool->prp_req_list);
 	}
 	spin_unlock(&pool->prp_lock);
+	return num_rq;
 }
 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
 
@@ -494,7 +495,7 @@ EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
  */
 struct ptlrpc_request_pool *
 ptlrpc_init_rq_pool(int num_rq, int msgsize,
-		    void (*populate_pool)(struct ptlrpc_request_pool *, int))
+		    int (*populate_pool)(struct ptlrpc_request_pool *, int))
 {
 	struct ptlrpc_request_pool *pool;
 
@@ -512,11 +513,6 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize,
 
 	populate_pool(pool, num_rq);
 
-	if (list_empty(&pool->prp_req_list)) {
-		/* have not allocated a single request for the pool */
-		kfree(pool);
-		pool = NULL;
-	}
 	return pool;
 }
 EXPORT_SYMBOL(ptlrpc_init_rq_pool);
@@ -702,11 +698,10 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp,
 {
 	struct ptlrpc_request *request = NULL;
 
-	if (pool)
-		request = ptlrpc_prep_req_from_pool(pool);
+	request = ptlrpc_request_cache_alloc(GFP_NOFS);
 
-	if (!request)
-		request = ptlrpc_request_cache_alloc(GFP_NOFS);
+	if (!request && pool)
+		request = ptlrpc_prep_req_from_pool(pool);
 
 	if (request) {
 		LASSERTF((unsigned long)imp > 0x1000, "%p", imp);
Signature · 1 line
2.1.0
#19 lore raw

PATCH 17/19 staging/lustre/o2iblnd: leak cmid in kiblnd_dev_need_failover

In reply to [email protected]

From: Liang Zhen <[email protected]>

cmid created by kiblnd_dev_need_failover should always be destroyed, however it is not the case in current implementation and we will leak cmid when this function detected a device failover.

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

---
 drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +3 -6
index c29d2ce..faa70f0 100644
@@ -2228,13 +2228,10 @@ static int kiblnd_dev_need_failover(kib_dev_t *dev)
 		return rc;
 	}
 
-	if (dev->ibd_hdev->ibh_ibdev == cmid->device) {
-		/* don't need device failover */
-		rdma_destroy_id(cmid);
-		return 0;
-	}
+	rc = dev->ibd_hdev->ibh_ibdev != cmid->device; /* true for failover */
+	rdma_destroy_id(cmid);
 
-	return 1;
+	return rc;
 }
 
 int kiblnd_dev_failover(kib_dev_t *dev)
Signature · 1 line
2.1.0
#20 lore raw

PATCH 18/19 staging/lustre/libcfs: remove unused cfs_timer_done

In reply to [email protected]

From: James Simmons <[email protected]>

Remove the cfs_timer_done function in the libcfs kernel module since it is not used anywhere.

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

---
 drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h | 1 -
 drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c   | 6 ------
 2 files changed, 7 deletions(-)
drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +0 -1
index 978d3e2..62ade08 100644
@@ -49,7 +49,6 @@ void add_wait_queue_exclusive_head(wait_queue_head_t *, wait_queue_t *);
 
 void cfs_init_timer(struct timer_list *t);
 void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg);
-void cfs_timer_done(struct timer_list *t);
 void cfs_timer_arm(struct timer_list *t, unsigned long deadline);
 void cfs_timer_disarm(struct timer_list *t);
 int  cfs_timer_is_armed(struct timer_list *t);
drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +0 -6
index 838f5f3..12b6af4 100644
@@ -84,12 +84,6 @@ void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg)
 }
 EXPORT_SYMBOL(cfs_timer_init);
 
-void cfs_timer_done(struct timer_list *t)
-{
-	return;
-}
-EXPORT_SYMBOL(cfs_timer_done);
-
 void cfs_timer_arm(struct timer_list *t, unsigned long deadline)
 {
 	mod_timer(t, deadline);
Signature · 1 line
2.1.0
#21 lore raw

PATCH 19/19 staging/lustre/ptlrpc: make ptlrpcd threads cpt-aware

In reply to [email protected]

From: Olaf Weber <[email protected]>

On NUMA systems, the placement of worker threads relative to the memory they use greatly affects performance. The CPT mechanism can be used to constrain a number of Lustre thread types, and this change makes it possible to configure the placement of ptlrpcd threads in a similar manner.

To simplify the code changes, the global structures used to manage ptlrpcd threads are changed to one per CPT. In particular this means there will be one ptlrpcd recovery thread per CPT.

To prevent ptlrpcd threads from wandering all over the system, all ptlrpcd thread are bound to a CPT. Note that some CPT configuration is always created, but the defaults are not likely to be correct for a NUMA system. After discussing the options with Liang Zhen we decided that we would not bind ptlrpcd threads to specific CPUs, and rather trust the kernel scheduler to migrate ptlrpcd threads.

With all ptlrpcd threads bound to a CPT, but not to specific CPUs, the load policy mechanism can be radically simplified:

- PDL_POLICY_LOCAL and PDL_POLICY_ROUND are currently identical.
- PDL_POLICY_ROUND, if fully implemented, would cost us the locality we are trying to achieve, so most or all calls using this policy would have to be changed to PDL_POLICY_LOCAL.
- PDL_POLICY_PREFERRED is not used, and cannot be implemented without binding ptlrpcd threads to individual CPUs.
- PDL_POLICY_SAME is rarely used, and cannot be implemented without binding ptlrpcd threads to individual CPUs.

The partner mechanism is also updated, because now all ptlrpcd threads are "bound" threads. The only difference between the various bind policies, PDB_POLICY_NONE, PDB_POLICY_FULL, PDB_POLICY_PAIR, and PDB_POLICY_NEIGHBOR, is the number of partner threads. The bind policy is replaced with a tunable that directly specifies the size of the groups of ptlrpcd partner threads.

Ensure that the ptlrpc_request_set for a ptlrpcd thread is created on the same CPT that the thread will work on. When threads are bound to specific nodes and/or CPUs in a NUMA system, it pays to ensure that the datastructures used by these threads are also on the same node.

Visible changes:

* ptlrpcd thread names include the CPT number, for example "ptlrpcd_02_07". In this case the "07" is relative to the CPT, and not a CPU number.

Tunables added:

* ptlrpcd_cpts (string): A CPT string describing the CPU partitions that ptlrpcd threads should run on. Used to make ptlrpcd threads run on a subset of all CPTs.

* ptlrpcd_per_cpt_max (int): The maximum number of ptlrpcd threads to run in a CPT.

* ptlrpcd_partner_group_size (int): The desired number of threads in each ptlrpcd partner thread group. Default is 2, corresponding to the old PDB_POLICY_PAIR. A negative value makes all ptlrpcd threads in a CPT partners of each other.

Tunables obsoleted:

* max_ptlrpcds: The new ptlrcpd_per_cpt_max can be used to obtain the same effect.

* ptlrpcd_bind_policy: The new ptlrpcd_partner_group_size can be used to obtain the same effect.

Internal interface changes:

* pdb_policy_t and related code have been removed. Groups of partner ptlrpcd threads are still created, and all threads in a partner group are bound on the same CPT. The ptlrpcd threads bound to a CPT are typically divided into several partner groups. The partner groups on a CPT all have an equal number of ptlrpcd threads.

* pdl_policy_t and related code have been removed. Since ptlrpcd threads are not bound to a specific CPU, all the code that avoids scheduling on the current CPU (or attempts to do so) has been removed as non-functional. A simplified form of PDL_POLICY_LOCAL is kept as the only load policy.

* LIOD_BIND and related code have been removed. All ptlrpcd threads are now bound to a CPT, and no additional binding policy is implemented.

* ptlrpc_prep_set(): Changed to allocate a ptlrpc_request_set on the current CPT.

* ptlrpcd(): If an error is encountered before entering the main loop store the error in pc_error before exiting.

* ptlrpcd_start(): Check pc_error to verify that the ptlrpcd thread has successfully entered its main loop.

* ptlrpcd_init(): Initialize the struct ptlrpcd_ctl for all threads for a CPT before starting any of them. This closes a race during startup where a partner thread could reference a non-initialized struct ptlrpcd_ctl.

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

---
 drivers/staging/lustre/lustre/include/lustre_net.h |  54 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   8 +-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c      |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |   2 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c      |  28 +-
 .../staging/lustre/lustre/osc/osc_cl_internal.h    |   2 +-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |   2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |  41 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c      |  11 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c      |   7 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |   2 +-
 .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h |   2 +-
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c     | 702 +++++++++++++--------
 13 files changed, 486 insertions(+), 377 deletions(-)
drivers/staging/lustre/lustre/include/lustre_net.h +13 -41
index 313a56c..3b6a2d7 100644
@@ -2191,21 +2191,29 @@ struct ptlrpcd_ctl {
 	 */
 	struct lu_env	       pc_env;
 	/**
-	 * Index of ptlrpcd thread in the array.
+	 * CPT the thread is bound on.
 	 */
-	int			 pc_index;
+	int				pc_cpt;
 	/**
-	 * Number of the ptlrpcd's partners.
+	 * Index of ptlrpcd thread in the array.
 	 */
-	int			 pc_npartners;
+	int				pc_index;
 	/**
 	 * Pointer to the array of partners' ptlrpcd_ctl structure.
 	 */
 	struct ptlrpcd_ctl	**pc_partners;
 	/**
+	 * Number of the ptlrpcd's partners.
+	 */
+	int				pc_npartners;
+	/**
 	 * Record the partner index to be processed next.
 	 */
 	int			 pc_cursor;
+	/**
+	 * Error code if the thread failed to fully start.
+	 */
+	int				pc_error;
 };
 
 /* Bits for pc_flags */
@@ -2228,10 +2236,6 @@ enum ptlrpcd_ctl_flags {
 	 * This is a recovery ptlrpc thread.
 	 */
 	LIOD_RECOVERY    = 1 << 3,
-	/**
-	 * The ptlrpcd is bound to some CPU core.
-	 */
-	LIOD_BIND	= 1 << 4,
 };
 
 /**
@@ -2903,43 +2907,11 @@ void ptlrpc_pinger_ir_down(void);
 /** @} */
 int ptlrpc_pinger_suppress_pings(void);
 
-/* ptlrpc daemon bind policy */
-typedef enum {
-	/* all ptlrpcd threads are free mode */
-	PDB_POLICY_NONE	  = 1,
-	/* all ptlrpcd threads are bound mode */
-	PDB_POLICY_FULL	  = 2,
-	/* <free1 bound1> <free2 bound2> ... <freeN boundN> */
-	PDB_POLICY_PAIR	  = 3,
-	/* <free1 bound1> <bound1 free2> ... <freeN boundN> <boundN free1>,
-	 * means each ptlrpcd[X] has two partners: thread[X-1] and thread[X+1].
-	 * If kernel supports NUMA, pthrpcd threads are binded and
-	 * grouped by NUMA node */
-	PDB_POLICY_NEIGHBOR      = 4,
-} pdb_policy_t;
-
-/* ptlrpc daemon load policy
- * It is caller's duty to specify how to push the async RPC into some ptlrpcd
- * queue, but it is not enforced, affected by "ptlrpcd_bind_policy". If it is
- * "PDB_POLICY_FULL", then the RPC will be processed by the selected ptlrpcd,
- * Otherwise, the RPC may be processed by the selected ptlrpcd or its partner,
- * depends on which is scheduled firstly, to accelerate the RPC processing. */
-typedef enum {
-	/* on the same CPU core as the caller */
-	PDL_POLICY_SAME	 = 1,
-	/* within the same CPU partition, but not the same core as the caller */
-	PDL_POLICY_LOCAL	= 2,
-	/* round-robin on all CPU cores, but not the same core as the caller */
-	PDL_POLICY_ROUND	= 3,
-	/* the specified CPU core is preferred, but not enforced */
-	PDL_POLICY_PREFERRED    = 4,
-} pdl_policy_t;
-
 /* ptlrpc/ptlrpcd.c */
 void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force);
 void ptlrpcd_free(struct ptlrpcd_ctl *pc);
 void ptlrpcd_wake(struct ptlrpc_request *req);
-void ptlrpcd_add_req(struct ptlrpc_request *req, pdl_policy_t policy, int idx);
+void ptlrpcd_add_req(struct ptlrpc_request *req);
 void ptlrpcd_add_rqset(struct ptlrpc_request_set *set);
 int ptlrpcd_addref(void);
 void ptlrpcd_decref(void);
drivers/staging/lustre/lustre/ldlm/ldlm_request.c +4 -4
index 6245a2c..b5ee9bd 100644
@@ -1212,12 +1212,12 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels,
 
 		ptlrpc_request_set_replen(req);
 		if (flags & LCF_ASYNC) {
-			ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+			ptlrpcd_add_req(req);
 			sent = count;
 			goto out;
-		} else {
-			rc = ptlrpc_queue_wait(req);
 		}
+
+		rc = ptlrpc_queue_wait(req);
 		if (rc == LUSTRE_ESTALE) {
 			CDEBUG(D_DLMTRACE, "client/server (nid %s) out of sync -- not fatal\n",
 			       libcfs_nid2str(req->rq_import->
@@ -2223,7 +2223,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
 	aa = ptlrpc_req_async_args(req);
 	aa->lock_handle = body->lock_handle[0];
 	req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret;
-	ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+	ptlrpcd_add_req(req);
 
 	return 0;
 }
drivers/staging/lustre/lustre/mdc/mdc_locks.c +1 -1
index e6b3bf9..20da064 100644
@@ -1307,7 +1307,7 @@ int mdc_intent_getattr_async(struct obd_export *exp,
 	ga->ga_einfo = einfo;
 
 	req->rq_interpret_reply = mdc_intent_getattr_async_interpret;
-	ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+	ptlrpcd_add_req(req);
 
 	return 0;
 }
drivers/staging/lustre/lustre/mdc/mdc_request.c +1 -1
index 204d512..d32ae761 100644
@@ -2639,7 +2639,7 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc,
 	ra->ra_oc = oc;
 	ra->ra_cb = cb;
 	req->rq_interpret_reply = mdc_interpret_renew_capa;
-	ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+	ptlrpcd_add_req(req);
 	return 0;
 }
 
drivers/staging/lustre/lustre/osc/osc_cache.c +13 -15
index c72035e..62da061 100644
@@ -1934,7 +1934,7 @@ static int get_write_extents(struct osc_object *obj, struct list_head *rpclist)
 
 static int
 osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
-		   struct osc_object *osc, pdl_policy_t pol)
+		   struct osc_object *osc)
 {
 	LIST_HEAD(rpclist);
 	struct osc_extent *ext;
@@ -1986,7 +1986,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
 
 	if (!list_empty(&rpclist)) {
 		LASSERT(page_count > 0);
-		rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_WRITE, pol);
+		rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_WRITE);
 		LASSERT(list_empty(&rpclist));
 	}
 
@@ -2006,7 +2006,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
  */
 static int
 osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli,
-		  struct osc_object *osc, pdl_policy_t pol)
+		  struct osc_object *osc)
 {
 	struct osc_extent *ext;
 	struct osc_extent *next;
@@ -2033,7 +2033,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli,
 		osc_object_unlock(osc);
 
 		LASSERT(page_count > 0);
-		rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ, pol);
+		rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ);
 		LASSERT(list_empty(&rpclist));
 
 		osc_object_lock(osc);
@@ -2079,8 +2079,7 @@ static struct osc_object *osc_next_obj(struct client_obd *cli)
 }
 
 /* called with the loi list lock held */
-static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
-			   pdl_policy_t pol)
+static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
 {
 	struct osc_object *osc;
 	int rc = 0;
@@ -2109,7 +2108,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
 		 * do io on writes while there are cache waiters */
 		osc_object_lock(osc);
 		if (osc_makes_rpc(cli, osc, OBD_BRW_WRITE)) {
-			rc = osc_send_write_rpc(env, cli, osc, pol);
+			rc = osc_send_write_rpc(env, cli, osc);
 			if (rc < 0) {
 				CERROR("Write request failed with %d\n", rc);
 
@@ -2133,7 +2132,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
 			}
 		}
 		if (osc_makes_rpc(cli, osc, OBD_BRW_READ)) {
-			rc = osc_send_read_rpc(env, cli, osc, pol);
+			rc = osc_send_read_rpc(env, cli, osc);
 			if (rc < 0)
 				CERROR("Read request failed with %d\n", rc);
 		}
@@ -2149,7 +2148,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
 }
 
 static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli,
-			  struct osc_object *osc, pdl_policy_t pol, int async)
+			  struct osc_object *osc, int async)
 {
 	int rc = 0;
 
@@ -2161,7 +2160,7 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli,
 		 * potential stack overrun problem. LU-2859 */
 		atomic_inc(&cli->cl_lru_shrinkers);
 		client_obd_list_lock(&cli->cl_loi_list_lock);
-		osc_check_rpcs(env, cli, pol);
+		osc_check_rpcs(env, cli);
 		client_obd_list_unlock(&cli->cl_loi_list_lock);
 		atomic_dec(&cli->cl_lru_shrinkers);
 	} else {
@@ -2175,14 +2174,13 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli,
 static int osc_io_unplug_async(const struct lu_env *env,
 			       struct client_obd *cli, struct osc_object *osc)
 {
-	/* XXX: policy is no use actually. */
-	return osc_io_unplug0(env, cli, osc, PDL_POLICY_ROUND, 1);
+	return osc_io_unplug0(env, cli, osc, 1);
 }
 
 void osc_io_unplug(const struct lu_env *env, struct client_obd *cli,
-		   struct osc_object *osc, pdl_policy_t pol)
+		   struct osc_object *osc)
 {
-	(void)osc_io_unplug0(env, cli, osc, pol, 0);
+	(void)osc_io_unplug0(env, cli, osc, 0);
 }
 
 int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
@@ -2922,7 +2920,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
 	}
 
 	if (unplug)
-		osc_io_unplug(env, osc_cli(obj), obj, PDL_POLICY_ROUND);
+		osc_io_unplug(env, osc_cli(obj), obj);
 
 	if (hp || discard) {
 		int rc;
drivers/staging/lustre/lustre/osc/osc_cl_internal.h +1 -1
index 365b278..75bfda6 100644
@@ -454,7 +454,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
 int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj,
 			 pgoff_t start, pgoff_t end);
 void osc_io_unplug(const struct lu_env *env, struct client_obd *cli,
-		   struct osc_object *osc, pdl_policy_t pol);
+		   struct osc_object *osc);
 
 void osc_object_set_contended  (struct osc_object *obj);
 void osc_object_clear_contended(struct osc_object *obj);
drivers/staging/lustre/lustre/osc/osc_internal.h +1 -1
index 7d0a3e2..448fdf4 100644
@@ -132,7 +132,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
 
 int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg);
 int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
-		  struct list_head *ext_list, int cmd, pdl_policy_t p);
+		  struct list_head *ext_list, int cmd);
 int osc_lru_shrink(struct client_obd *cli, int target);
 
 extern spinlock_t osc_ast_guard;
drivers/staging/lustre/lustre/osc/osc_request.c +15 -26

119 lines not on this page · raw message

drivers/staging/lustre/lustre/ptlrpc/client.c +7 -4
index 90b24fc..e1830fe 100644
@@ -844,14 +844,17 @@ ptlrpc_prep_req(struct obd_import *imp, __u32 version, int opcode, int count,
 EXPORT_SYMBOL(ptlrpc_prep_req);
 
 /**
- * Allocate and initialize new request set structure.
+ * Allocate and initialize new request set structure on the current CPT.
  * Returns a pointer to the newly allocated set structure or NULL on error.
  */
 struct ptlrpc_request_set *ptlrpc_prep_set(void)
 {
 	struct ptlrpc_request_set *set;
+	int cpt;
 
-	set = kzalloc(sizeof(*set), GFP_NOFS);
+	cpt = cfs_cpt_current(cfs_cpt_table, 0);
+	set = kzalloc_node(sizeof(*set), GFP_NOFS,
+			   cfs_cpt_spread_node(cfs_cpt_table, cpt));
 	if (!set)
 		return NULL;
 	atomic_set(&set->set_refcount, 1);
@@ -2827,7 +2830,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req)
 	atomic_inc(&req->rq_import->imp_replay_inflight);
 	ptlrpc_request_addref(req); /* ptlrpcd needs a ref */
 
-	ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+	ptlrpcd_add_req(req);
 	return 0;
 }
 EXPORT_SYMBOL(ptlrpc_replay_req);
@@ -3033,7 +3036,7 @@ static void ptlrpcd_add_work_req(struct ptlrpc_request *req)
 	req->rq_xid		= ptlrpc_next_xid();
 	req->rq_import_generation = req->rq_import->imp_generation;
 
-	ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+	ptlrpcd_add_req(req);
 }
 
 static int work_interpreter(const struct lu_env *env,
drivers/staging/lustre/lustre/ptlrpc/import.c +3 -4
index f5b3245..c52ceef 100644
@@ -742,12 +742,11 @@ int ptlrpc_connect_import(struct obd_import *imp)
 
 	DEBUG_REQ(D_RPCTRACE, request, "(re)connect request (timeout %d)",
 		  request->rq_timeout);
-	ptlrpcd_add_req(request, PDL_POLICY_ROUND, -1);
+	ptlrpcd_add_req(request);
 	rc = 0;
 out:
-	if (rc != 0) {
+	if (rc != 0)
 		IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
-	}
 
 	return rc;
 }
@@ -1257,7 +1256,7 @@ static int signal_completed_replay(struct obd_import *imp)
 		req->rq_timeout *= 3;
 	req->rq_interpret_reply = completed_replay_interpret;
 
-	ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+	ptlrpcd_add_req(req);
 	return 0;
 }
 
drivers/staging/lustre/lustre/ptlrpc/pinger.c +1 -1
index f8edb79..d3aea4a 100644
@@ -105,7 +105,7 @@ static int ptlrpc_ping(struct obd_import *imp)
 
 	DEBUG_REQ(D_INFO, req, "pinging %s->%s",
 		  imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
-	ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+	ptlrpcd_add_req(req);
 
 	return 0;
 }
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +1 -1
index 6dc3998..1d64ca7 100644
@@ -50,7 +50,7 @@ extern struct mutex ptlrpc_all_services_mutex;
 
 int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait);
 /* ptlrpcd.c */
-int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc);
+int ptlrpcd_start(struct ptlrpcd_ctl *pc);
 
 /* client.c */
 struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw,
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +425 -277

853 lines not on this page · raw message

Signature · 1 line
2.1.0