Skip to contentSkip to conversation

lustre: sync with OpenSFS tree June 8, 2022

PATCH In review James Simmons 2 participants 20 messages Jun 9, 2022 – Jun 10, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover lustre: sync with OpenSFS tree June 8, 2022

Sync with the new work coming in for 2.16 development branch. Hold back the LU-15189 work since it introduced a regression that has an outstanding fix.

Alexander Boyko (1):
lustre: ptlrpc: send disconnected events

Alexey Lyashkov (1):
lnet: selftest: improve lnet_selftest speed

Arshad Hussain (1):
lustre: quota: fallocate does not increase projectid usage

Chris Horn (1):
lnet: Avoid redundant peer NI lookups

Etienne AUJAMES (2):
lustre: llog: read canceled records in llog_backup
lustre: mdc: Use early cancels for hsm requests

John L. Hammond (1):
lustre: llite: reenable fast_read by default

Lai Siyao (1):
lustre: llite: access lli_lsm_md with lock in all places

Mr NeilBrown (8):
lnet: change LNetPrimaryNID to use struct lnet_nid
lnet: alter lnet_drop_rule_match() to take lnet_nid
lnet: Change LNetDist to work with struct lnet_nid
lnet: convert LNetPut to take 16byte nid and pid.
lnet: change LNetGet to take 16byte nid and pid.
lnet: socklnd: pass large processid to ksocknal_add_peer
lnet: socklnd: large processid for ksocknal_get_peer_info
lnet: socklnd: switch ksocknal_del_peer to lnet_processid

Oleg Drokin (1):
lustre: update version to 2.15.50

Patrick Farrell (1):
lustre: llite: Check vmpage in releasepage

 fs/lustre/include/cl_object.h          |  10 +++
 fs/lustre/include/lustre_log.h         |  11 +++
 fs/lustre/include/obd_class.h          |   3 +-
 fs/lustre/llite/dir.c                  |   6 +-
 fs/lustre/llite/file.c                 |  26 ++++---
 fs/lustre/llite/llite_internal.h       |  17 ++++-
 fs/lustre/llite/llite_lib.c            |  22 +++---
 fs/lustre/llite/namei.c                |   7 +-
 fs/lustre/llite/rw26.c                 |  19 +++--
 fs/lustre/llite/statahead.c            |   2 +
 fs/lustre/llite/vvp_object.c           |   3 +-
 fs/lustre/lmv/lmv_obd.c                |   3 +-
 fs/lustre/lov/lov_io.c                 |   2 +
 fs/lustre/mdc/mdc_request.c            |  37 ++++++++--
 fs/lustre/obdclass/llog.c              |  22 ++++--
 fs/lustre/obdclass/llog_cat.c          |   5 +-
 fs/lustre/obdclass/lustre_peer.c       |   4 +-
 fs/lustre/obdclass/obd_config.c        |   1 +
 fs/lustre/osc/osc_io.c                 |   9 ++-
 fs/lustre/osc/osc_page.c               |   9 ++-
 fs/lustre/ptlrpc/connection.c          |   2 +-
 fs/lustre/ptlrpc/events.c              |  12 ++--
 fs/lustre/ptlrpc/import.c              |   4 ++
 fs/lustre/ptlrpc/niobuf.c              |  15 ++--
 include/linux/lnet/api.h               |  12 ++--
 include/linux/lnet/lib-lnet.h          |   4 +-
 include/uapi/linux/lustre/lustre_ver.h |   4 +-
 net/lnet/klnds/socklnd/socklnd.c       |  77 +++++++++------------
 net/lnet/klnds/socklnd/socklnd.h       |   2 +-
 net/lnet/klnds/socklnd/socklnd_cb.c    |  28 +++++---
 net/lnet/lnet/api-ni.c                 |  29 ++++----
 net/lnet/lnet/lib-move.c               | 100 ++++++++++++---------------
 net/lnet/lnet/lib-msg.c                |   3 +-
 net/lnet/lnet/net_fault.c              |  40 ++++++-----
 net/lnet/lnet/peer.c                   | 105 +++++++++++++---------------
 net/lnet/lnet/router.c                 |   6 +-
 net/lnet/selftest/rpc.c                | 122 +++++++++++++++++++--------------
 net/lnet/selftest/selftest.h           |   1 -
 38 files changed, 447 insertions(+), 337 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/18 lustre: llite: reenable fast_read by default

From: "John L. Hammond" <[email protected]>

Reenable fast_read by default.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14541
Lustre-commit: a94e28fda44077f77 ("LU-14541 llite: reenable fast_read by default")

Reviewed-on: https://review.whamcloud.com/47298

---
 fs/lustre/llite/llite_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/lustre/llite/llite_lib.c +1 -1
index 4578a9e..ad77ef0 100644
@@ -169,7 +169,7 @@ static struct ll_sb_info *ll_init_sbi(void)
 	atomic_set(&sbi->ll_sa_running, 0);
 	atomic_set(&sbi->ll_agl_total, 0);
 	set_bit(LL_SBI_AGL_ENABLED, sbi->ll_flags);
-	/* Disable LL_SBI_FAST_READ by default, see LU-15815. */
+	set_bit(LL_SBI_FAST_READ, sbi->ll_flags);
 	set_bit(LL_SBI_TINY_WRITE, sbi->ll_flags);
 	set_bit(LL_SBI_PARALLEL_DIO, sbi->ll_flags);
 	ll_sbi_set_encrypt(sbi, true);
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/18 lustre: llite: Check vmpage in releasepage

In reply to James Simmons

From: Patrick Farrell <[email protected]>

We cannot release a page if the vmpage reference count is

Quoted 1 line

1, otherwise we will detach a vmpage from Lustre when the

page is still referenced in the VM.

This creates a situation where page discard for lock cancellation will not find the page, so we can get stale data reads.

This re-introduces the LU-12587 issue where direct I/O on a client falls back to buffered I/O if there are pages in cache, since it cannot flush them. This is annoying but not a huge problem.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14541
Lustre-commit: c524079f4f59a39b9 ("LU-14541 llite: Check vmpage in releasepage")

Reviewed-on: https://review.whamcloud.com/47262

---
 fs/lustre/include/cl_object.h |  9 +++++++++
 fs/lustre/llite/rw26.c        | 19 +++++++++++++------
 fs/lustre/osc/osc_page.c      |  9 +++++++--
 3 files changed, 29 insertions(+), 8 deletions(-)
fs/lustre/include/cl_object.h +9 -0
index ab7f0f2..b98109d 100644
@@ -91,6 +91,7 @@
 #include <linux/uio.h>
 #include <lu_object.h>
 #include <linux/atomic.h>
+#include <linux/mm.h>
 #include <linux/mutex.h>
 #include <linux/radix-tree.h>
 #include <linux/spinlock.h>
@@ -1071,6 +1072,14 @@ static inline bool __page_in_use(const struct cl_page *page, int refc)
  */
 #define cl_page_in_use_noref(pg) __page_in_use(pg, 0)
 
+/* references: cl_page, page cache, optional + refcount for caller reference
+ * (always 0 or 1 currently)
+ */
+static inline int vmpage_in_use(struct page *vmpage, int refcount)
+{
+	return (page_count(vmpage) - page_mapcount(vmpage) > 2 + refcount);
+}
+
 /** @} cl_page */
 
 /** \addtogroup cl_lock cl_lock
fs/lustre/llite/rw26.c +13 -6
index a5cdb01..8b379ca 100644
@@ -102,7 +102,7 @@ static int ll_releasepage(struct page *vmpage, gfp_t gfp_mask)
 {
 	struct lu_env *env;
 	struct cl_object *obj;
-	struct cl_page *page;
+	struct cl_page *clpage;
 	struct address_space *mapping;
 	int result = 0;
 
@@ -118,16 +118,23 @@ static int ll_releasepage(struct page *vmpage, gfp_t gfp_mask)
 	if (!obj)
 		return 1;
 
-	page = cl_vmpage_page(vmpage, obj);
-	if (!page)
+	clpage = cl_vmpage_page(vmpage, obj);
+	if (!clpage)
 		return 1;
 
 	env = cl_env_percpu_get();
 	LASSERT(!IS_ERR(env));
 
-	if (!cl_page_in_use(page)) {
+	/* we must not delete the cl_page if the vmpage is in use, otherwise we
+	 * disconnect the vmpage from Lustre while it's still alive(!), which
+	 * means we won't find it to discard on lock cancellation.
+	 *
+	 * References here are: caller + cl_page + page cache.
+	 * Any other references are potentially transient and must be ignored.
+	 */
+	if (!cl_page_in_use(clpage) && !vmpage_in_use(vmpage, 1)) {
 		result = 1;
-		cl_page_delete(env, page);
+		cl_page_delete(env, clpage);
 	}
 
 	/* To use percpu env array, the call path can not be rescheduled;
@@ -144,7 +151,7 @@ static int ll_releasepage(struct page *vmpage, gfp_t gfp_mask)
 	 * that we won't get into object delete path.
 	 */
 	LASSERT(cl_object_refc(obj) > 1);
-	cl_page_put(env, page);
+	cl_page_put(env, clpage);
 
 	cl_env_percpu_put(env);
 	return result;
fs/lustre/osc/osc_page.c +7 -2
index f46b4e7..b56bc1a 100644
@@ -539,8 +539,13 @@ static inline bool lru_page_busy(struct client_obd *cli, struct cl_page *page)
 	if (cli->cl_cache->ccc_unstable_check) {
 		struct page *vmpage = cl_page_vmpage(page);
 
-		/* vmpage have two known users: cl_page and VM page cache */
-		if (page_count(vmpage) - page_mapcount(vmpage) > 2)
+		/* this check is racy because the vmpage is not locked, but
+		 * that's OK - the code which does the actual page release
+		 * checks this again before releasing
+		 *
+		 * vmpage have two known users: cl_page and VM page cache
+		 */
+		if (vmpage_in_use(vmpage, 0))
 			return true;
 	}
 	return false;
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/18 lustre: update version to 2.15.50

In reply to James Simmons

From: Oleg Drokin <[email protected]>

New tag 2.15.50

---
 include/uapi/linux/lustre/lustre_ver.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/lustre/lustre_ver.h +2 -2
index a17edd6..bcee87c 100644
@@ -3,9 +3,9 @@
 
 #define LUSTRE_MAJOR 2
 #define LUSTRE_MINOR 15
-#define LUSTRE_PATCH 0
+#define LUSTRE_PATCH 50
 #define LUSTRE_FIX 0
-#define LUSTRE_VERSION_STRING "2.15.0"
+#define LUSTRE_VERSION_STRING "2.15.50"
 
 #define OBD_OCD_VERSION(major, minor, patch, fix)			\
 	(((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix))
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/18 lustre: llog: read canceled records in llog_backup

In reply to James Simmons

From: Etienne AUJAMES <[email protected]>

llog_backup() do not reproduce index "holes" in the generated copy. This could result to a llog copy indexes different from the source. Then it might confuse the configuration update mechanism that rely on indexes between the MGS source and the target copy.

This index gaps can be caused by "lctl --device MGS llog_cancel".

This patch add "raw" read mode to llog_process* to read canceled records.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15000
Lustre-commit: d8e2723b4e9409954 ("LU-15000 llog: read canceled records in llog_backup")

Reviewed-on: https://review.whamcloud.com/46552

---
 fs/lustre/include/lustre_log.h  | 11 +++++++++++
 fs/lustre/obdclass/llog.c       | 22 +++++++++++++++++-----
 fs/lustre/obdclass/llog_cat.c   |  5 ++++-
 fs/lustre/obdclass/obd_config.c |  1 +
 4 files changed, 33 insertions(+), 6 deletions(-)
fs/lustre/include/lustre_log.h +11 -0
index 1fc7729..2e43d56 100644
@@ -94,6 +94,13 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt,
 /* llog_process flags */
 #define LLOG_FLAG_NODEAMON 0x0001
 
+/* llog read mode, LLOG_READ_MODE_RAW will process llog canceled records */
+enum llog_read_mode {
+	LLOG_READ_MODE_NORMAL	= 0x0000,
+	LLOG_READ_MODE_RAW	= 0x0001,
+};
+
+
 /* llog_cat.c - catalog api */
 struct llog_process_data {
 	/**
@@ -122,6 +129,10 @@ struct llog_process_cat_data {
 	 * Temporary stored last_idx while scanning log.
 	 */
 	int			lpcd_last_idx;
+	/**
+	 * llog read mode
+	 */
+	enum llog_read_mode	lpcd_read_mode;
 };
 
 struct thandle;
fs/lustre/obdclass/llog.c +17 -5
index acede87..0cc64ce 100644
@@ -256,6 +256,15 @@ int llog_verify_record(const struct llog_handle *llh, struct llog_rec_hdr *rec)
 	return 0;
 }
 
+static inline bool llog_is_index_skipable(int idx, struct llog_log_hdr *llh,
+					  struct llog_process_cat_data *cd)
+{
+	if (cd && (cd->lpcd_read_mode & LLOG_READ_MODE_RAW))
+		return false;
+
+	return !test_bit_le(idx, LLOG_HDR_BITMAP(llh));
+}
+
 static int llog_process_thread(void *arg)
 {
 	struct llog_process_info *lpi = arg;
@@ -291,6 +300,8 @@ static int llog_process_thread(void *arg)
 	}
 	if (cd && cd->lpcd_last_idx)
 		last_index = cd->lpcd_last_idx;
+	else if (cd && (cd->lpcd_read_mode & LLOG_READ_MODE_RAW))
+		last_index = loghandle->lgh_last_idx;
 	else
 		last_index = LLOG_HDR_BITMAP_SIZE(llh) - 1;
 
@@ -303,7 +314,7 @@ static int llog_process_thread(void *arg)
 
 		/* skip records not set in bitmap */
 		while (index <= last_index &&
-		       !test_bit_le(index, LLOG_HDR_BITMAP(llh)))
+		       llog_is_index_skipable(index, llh, cd))
 			++index;
 
 		if (index > last_index)
@@ -451,8 +462,8 @@ static int llog_process_thread(void *arg)
 			loghandle->lgh_cur_offset = (char *)rec - (char *)buf +
 						    chunk_offset;
 
-			/* if set, process the callback on this record */
-			if (test_bit_le(index, LLOG_HDR_BITMAP(llh))) {
+			/* if needed, process the callback on this record */
+			if (!llog_is_index_skipable(index, llh, cd)) {
 				rc = lpi->lpi_cb(lpi->lpi_env, loghandle, rec,
 						 lpi->lpi_cbdata);
 				last_called_index = index;
@@ -522,11 +533,12 @@ int llog_process_or_fork(const struct lu_env *env,
 	lpi->lpi_catdata = catdata;
 
 	CDEBUG(D_OTHER,
-	       "Processing " DFID " flags 0x%03x startcat %d startidx %d first_idx %d last_idx %d\n",
+	       "Processing " DFID " flags 0x%03x startcat %d startidx %d first_idx %d last_idx %d read_mode %d\n",
 	       PFID(&loghandle->lgh_id.lgl_oi.oi_fid), flags,
 	       (flags & LLOG_F_IS_CAT) && d ? d->lpd_startcat : -1,
 	       (flags & LLOG_F_IS_CAT) && d ? d->lpd_startidx : -1,
-	       cd ? cd->lpcd_first_idx : -1, cd ? cd->lpcd_last_idx : -1);
+	       cd ? cd->lpcd_first_idx : -1, cd ? cd->lpcd_last_idx : -1,
+	       cd ? cd->lpcd_read_mode : -1);
 
 	if (fork) {
 		struct task_struct *task;
fs/lustre/obdclass/llog_cat.c +4 -1
index 7f55895..753422b 100644
@@ -197,6 +197,7 @@ static int llog_cat_process_cb(const struct lu_env *env,
 	else if (d->lpd_startidx > 0) {
 		struct llog_process_cat_data cd;
 
+		cd.lpcd_read_mode = LLOG_READ_MODE_NORMAL;
 		cd.lpcd_first_idx = d->lpd_startidx;
 		cd.lpcd_last_idx = 0;
 		rc = llog_process_or_fork(env, llh, d->lpd_cb, d->lpd_data,
@@ -231,7 +232,9 @@ static int llog_cat_process_or_fork(const struct lu_env *env,
 	d.lpd_startidx = startidx;
 
 	if (llh->llh_cat_idx > cat_llh->lgh_last_idx) {
-		struct llog_process_cat_data cd;
+		struct llog_process_cat_data cd = {
+			.lpcd_read_mode = LLOG_READ_MODE_NORMAL
+		};
 
 		CWARN("%s: catlog " DFID " crosses index zero\n",
 		      loghandle2name(cat_llh),
fs/lustre/obdclass/obd_config.c +1 -0
index cb70ed5..4db7399 100644
@@ -1401,6 +1401,7 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
 {
 	struct llog_process_cat_data cd = {
 		.lpcd_first_idx = 0,
+		.lpcd_read_mode = LLOG_READ_MODE_NORMAL,
 	};
 	struct llog_handle *llh;
 	llog_cb_t callback;
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/18 lnet: change LNetPrimaryNID to use struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Rather than taking and returning a 4-byte-addr nid, LNetPrimaryNID now takes a pointer to a struct lnet_nid, and updates it in-place.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: ac881498fa19e6b04 ("LU-10391 lnet: change LNetPrimaryNID to use struct lnet_nid")

Reviewed-on: https://review.whamcloud.com/43616

---
 fs/lustre/ptlrpc/connection.c |  2 +-
 include/linux/lnet/api.h      |  2 +-
 net/lnet/lnet/peer.c          | 21 +++++++++++----------
 3 files changed, 13 insertions(+), 12 deletions(-)
fs/lustre/ptlrpc/connection.c +1 -1
index d1f53c6..58161fe 100644
@@ -82,8 +82,8 @@ struct ptlrpc_connection *
 	struct ptlrpc_connection *conn, *conn2;
 	struct lnet_processid peer;
 
-	peer4.nid = LNetPrimaryNID(peer4.nid);
 	lnet_pid4_to_pid(peer4, &peer);
+	LNetPrimaryNID(&peer.nid);
 	conn = rhashtable_lookup_fast(&conn_hash, &peer, conn_hash_params);
 	if (conn) {
 		ptlrpc_connection_addref(conn);
include/linux/lnet/api.h +1 -1
index 6d8e915..447b41d 100644
@@ -77,7 +77,7 @@
  */
 int LNetGetId(unsigned int index, struct lnet_processid *id);
 int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, u32 *order);
-lnet_nid_t LNetPrimaryNID(lnet_nid_t nid);
+void LNetPrimaryNID(struct lnet_nid *nid);
 
 /** @} lnet_addr */
 
net/lnet/lnet/peer.c +11 -10
index 714326a..2055f31 100644
@@ -1430,18 +1430,20 @@ struct lnet_peer_ni *
 }
 EXPORT_SYMBOL(LNetAddPeer);
 
-/* FIXME support large-addr nid */
-lnet_nid_t
-LNetPrimaryNID(lnet_nid_t nid)
+void LNetPrimaryNID(struct lnet_nid *nid)
 {
 	struct lnet_peer *lp;
 	struct lnet_peer_ni *lpni;
-	lnet_nid_t primary_nid = nid;
+	struct lnet_nid orig;
 	int rc = 0;
 	int cpt;
 
+	if (!nid || nid_is_lo0(nid))
+		return;
+	orig = *nid;
+
 	cpt = lnet_net_lock_current();
-	lpni = lnet_nid2peerni_locked(nid, LNET_NID_ANY, cpt);
+	lpni = lnet_peerni_by_nid_locked(nid, NULL, cpt);
 	if (IS_ERR(lpni)) {
 		rc = PTR_ERR(lpni);
 		goto out_unlock;
@@ -1468,7 +1470,7 @@ struct lnet_peer_ni *
 		 * and lookup the lpni again
 		 */
 		lnet_peer_ni_decref_locked(lpni);
-		lpni = lnet_find_peer_ni_locked(nid);
+		lpni = lnet_peer_ni_find_locked(nid);
 		if (!lpni) {
 			rc = -ENOENT;
 			goto out_unlock;
@@ -1483,15 +1485,14 @@ struct lnet_peer_ni *
 		if (lnet_is_discovery_disabled(lp))
 			break;
 	}
-	primary_nid = lnet_nid_to_nid4(&lp->lp_primary_nid);
+	*nid = lp->lp_primary_nid;
 out_decref:
 	lnet_peer_ni_decref_locked(lpni);
 out_unlock:
 	lnet_net_unlock(cpt);
 
-	CDEBUG(D_NET, "NID %s primary NID %s rc %d\n", libcfs_nid2str(nid),
-	       libcfs_nid2str(primary_nid), rc);
-	return primary_nid;
+	CDEBUG(D_NET, "NID %s primary NID %s rc %d\n", libcfs_nidstr(&orig),
+	       libcfs_nidstr(nid), rc);
 }
 EXPORT_SYMBOL(LNetPrimaryNID);
 
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/18 lnet: alter lnet_drop_rule_match() to take lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The local nid passed to lnet_drop_rule_match() is now a 16-byte nid. Various support functions are also changed to embrace 'struct lnet_nid'.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 57b7b3d36f5fa1527 ("LU-10391 lnet: alter lnet_drop_rule_match() to take lnet_nid")

Reviewed-on: https://review.whamcloud.com/43617

---
 include/linux/lnet/lib-lnet.h |  2 +-
 net/lnet/lnet/lib-move.c      |  3 +--
 net/lnet/lnet/lib-msg.c       |  3 +--
 net/lnet/lnet/net_fault.c     | 40 +++++++++++++++++++++++-----------------
 4 files changed, 26 insertions(+), 22 deletions(-)
include/linux/lnet/lib-lnet.h +1 -1
index b6a7a54..2e3c391 100644
@@ -751,7 +751,7 @@ void lnet_drop_message(struct lnet_ni *ni, int cpt, void *private,
 int lnet_fault_init(void);
 void lnet_fault_fini(void);
 
-bool lnet_drop_rule_match(struct lnet_hdr *hdr, lnet_nid_t local_nid,
+bool lnet_drop_rule_match(struct lnet_hdr *hdr, struct lnet_nid *local_nid,
 			  enum lnet_msg_hstatus *hstatus);
 
 int lnet_delay_rule_add(struct lnet_fault_attr *attr);
net/lnet/lnet/lib-move.c +1 -2
index 0496bf5..080bfe6 100644
@@ -4379,9 +4379,8 @@ void lnet_monitor_thr_stop(void)
 		goto drop;
 	}
 
-	/* FIXME need to support large-addr nid */
 	if (!list_empty(&the_lnet.ln_drop_rules) &&
-	    lnet_drop_rule_match(hdr, lnet_nid_to_nid4(&ni->ni_nid), NULL)) {
+	    lnet_drop_rule_match(hdr, &ni->ni_nid, NULL)) {
 		CDEBUG(D_NET, "%s, src %s, dst %s: Dropping %s to simulate silent message loss\n",
 		       libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
 		       libcfs_nidstr(&dest_nid), lnet_msgtyp2str(type));
net/lnet/lnet/lib-msg.c +1 -2
index f476975..95695b2 100644
@@ -1115,8 +1115,7 @@
 		return false;
 
 	/* match only health rules */
-	if (!lnet_drop_rule_match(&msg->msg_hdr, LNET_NID_ANY,
-				  hstatus))
+	if (!lnet_drop_rule_match(&msg->msg_hdr, NULL, hstatus))
 		return false;
 
 	CDEBUG(D_NET,
net/lnet/lnet/net_fault.c +23 -17
index 1f08b38..fe7a07c 100644
@@ -65,12 +65,16 @@ struct lnet_drop_rule {
 };
 
 static bool
-lnet_fault_nid_match(lnet_nid_t nid, lnet_nid_t msg_nid)
+lnet_fault_nid_match(lnet_nid_t nid, struct lnet_nid *msg_nid)
 {
-	if (nid == msg_nid || nid == LNET_NID_ANY)
+	if (nid == LNET_NID_ANY)
+		return true;
+	if (!msg_nid)
+		return false;
+	if (lnet_nid_to_nid4(msg_nid) == nid)
 		return true;
 
-	if (LNET_NIDNET(nid) != LNET_NIDNET(msg_nid))
+	if (LNET_NIDNET(nid) != LNET_NID_NET(msg_nid))
 		return false;
 
 	/* 255.255.255.255@net is wildcard for all addresses in a network */
@@ -78,8 +82,10 @@ struct lnet_drop_rule {
 }
 
 static bool
-lnet_fault_attr_match(struct lnet_fault_attr *attr, lnet_nid_t src,
-		      lnet_nid_t local_nid, lnet_nid_t dst,
+lnet_fault_attr_match(struct lnet_fault_attr *attr,
+		      struct lnet_nid *src,
+		      struct lnet_nid *local_nid,
+		      struct lnet_nid *dst,
 		      unsigned int type, unsigned int portal)
 {
 	if (!lnet_fault_nid_match(attr->fa_src, src) ||
@@ -339,8 +345,10 @@ struct lnet_drop_rule {
  * decide whether should drop this message or not
  */
 static bool
-drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
-		lnet_nid_t local_nid, lnet_nid_t dst,
+drop_rule_match(struct lnet_drop_rule *rule,
+		struct lnet_nid *src,
+		struct lnet_nid *local_nid,
+		struct lnet_nid *dst,
 		unsigned int type, unsigned int portal,
 		enum lnet_msg_hstatus *hstatus)
 {
@@ -424,11 +432,9 @@ struct lnet_drop_rule {
  */
 bool
 lnet_drop_rule_match(struct lnet_hdr *hdr,
-		     lnet_nid_t local_nid,
+		     struct lnet_nid *local_nid,
 		     enum lnet_msg_hstatus *hstatus)
 {
-	lnet_nid_t src = lnet_nid_to_nid4(&hdr->src_nid);
-	lnet_nid_t dst = lnet_nid_to_nid4(&hdr->dest_nid);
 	unsigned int typ = hdr->type;
 	struct lnet_drop_rule *rule;
 	unsigned int ptl = -1;
@@ -446,7 +452,8 @@ struct lnet_drop_rule {
 
 	cpt = lnet_net_lock_current();
 	list_for_each_entry(rule, &the_lnet.ln_drop_rules, dr_link) {
-		drop = drop_rule_match(rule, src, local_nid, dst, typ, ptl,
+		drop = drop_rule_match(rule, &hdr->src_nid, local_nid,
+				       &hdr->dest_nid, typ, ptl,
 				       hstatus);
 		if (drop)
 			break;
@@ -530,15 +537,15 @@ struct delay_daemon_data {
  * decide whether should delay this message or not
  */
 static bool
-delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
-		 lnet_nid_t dst, unsigned int type, unsigned int portal,
+delay_rule_match(struct lnet_delay_rule *rule, struct lnet_nid *src,
+		 struct lnet_nid *dst, unsigned int type, unsigned int portal,
 		 struct lnet_msg *msg)
 {
 	struct lnet_fault_attr *attr = &rule->dl_attr;
 	bool delay;
 	time64_t now = ktime_get_seconds();
 
-	if (!lnet_fault_attr_match(attr, src, LNET_NID_ANY,
+	if (!lnet_fault_attr_match(attr, src, NULL,
 				   dst, type, portal))
 		return false;
 
@@ -605,8 +612,6 @@ struct delay_daemon_data {
 lnet_delay_rule_match_locked(struct lnet_hdr *hdr, struct lnet_msg *msg)
 {
 	struct lnet_delay_rule *rule;
-	lnet_nid_t src = lnet_nid_to_nid4(&hdr->src_nid);
-	lnet_nid_t dst = lnet_nid_to_nid4(&hdr->dest_nid);
 	unsigned int typ = hdr->type;
 	unsigned int ptl = -1;
 
@@ -622,7 +627,8 @@ struct delay_daemon_data {
 		ptl = le32_to_cpu(hdr->msg.get.ptl_index);
 
 	list_for_each_entry(rule, &the_lnet.ln_delay_rules, dl_link) {
-		if (delay_rule_match(rule, src, dst, typ, ptl, msg))
+		if (delay_rule_match(rule, &hdr->src_nid, &hdr->dest_nid,
+				     typ, ptl, msg))
 			return true;
 	}
 
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/18 lnet: Change LNetDist to work with struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

LNetDist now takes and returns 'struct lnet_nid'
lustre_uuid_to_peer() is also updated.

The 'dst' and 'src' parameters to LNetDist are now both pointers, and that can point to the same 'struct lnet_nid'. Code needs to be careful not to set *src until after the last use of *dst.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: c87f70acd86c59425 ("LU-10391 lnet: Change LNetDist to work with struct lnet_nid")

Reviewed-on: https://review.whamcloud.com/43618

---
 fs/lustre/include/obd_class.h    |  3 ++-
 fs/lustre/obdclass/lustre_peer.c |  4 ++--
 fs/lustre/ptlrpc/events.c        | 12 ++++++------
 include/linux/lnet/api.h         |  2 +-
 net/lnet/lnet/api-ni.c           |  4 +++-
 net/lnet/lnet/lib-move.c         | 35 ++++++++++++++++-------------------
 6 files changed, 30 insertions(+), 30 deletions(-)
fs/lustre/include/obd_class.h +2 -1
index 3f444b0..f603140 100644
@@ -1688,7 +1688,8 @@ struct lwp_register_item {
 int lustre_check_exclusion(struct super_block *sb, char *svname);
 
 /* lustre_peer.c    */
-int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
+int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid,
+			int index);
 int class_add_uuid(const char *uuid, u64 nid);
 int class_del_uuid(const char *uuid);
 int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
fs/lustre/obdclass/lustre_peer.c +2 -2
index f7e6a0f..5eae2eb 100644
@@ -51,7 +51,7 @@ struct uuid_nid_data {
 static LIST_HEAD(g_uuid_list);
 static DEFINE_SPINLOCK(g_uuid_lock);
 
-int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index)
+int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid, int index)
 {
 	struct uuid_nid_data *data;
 	struct obd_uuid tmp;
@@ -65,7 +65,7 @@ int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index)
 				break;
 
 			rc = 0;
-			*peer_nid = data->un_nids[index];
+			lnet_nid4_to_nid(data->un_nids[index], peer_nid);
 			break;
 		}
 	}
fs/lustre/ptlrpc/events.c +6 -6
index 385a6f2..140ea85 100644
@@ -476,18 +476,18 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
 	int rc = -ENOENT;
 	int dist;
 	u32 order;
-	lnet_nid_t dst_nid;
-	lnet_nid_t src_nid;
+	struct lnet_nid dst_nid;
+	struct lnet_nid src_nid;
 
 	peer->pid = LNET_PID_LUSTRE;
 
 	/* Choose the matching UUID that's closest */
 	while (lustre_uuid_to_peer(uuid->uuid, &dst_nid, count++) == 0) {
 		if (peer->nid != LNET_NID_ANY && LNET_NIDADDR(peer->nid) == 0 &&
-		    LNET_NIDNET(dst_nid) != LNET_NIDNET(peer->nid))
+		    LNET_NID_NET(&dst_nid) != LNET_NIDNET(peer->nid))
 			continue;
 
-		dist = LNetDist(dst_nid, &src_nid, &order);
+		dist = LNetDist(&dst_nid, &src_nid, &order);
 		if (dist < 0)
 			continue;
 
@@ -503,8 +503,8 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
 			best_dist = dist;
 			best_order = order;
 
-			peer->nid = dst_nid;
-			*self = src_nid;
+			peer->nid = lnet_nid_to_nid4(&dst_nid);
+			*self = lnet_nid_to_nid4(&src_nid);
 			rc = 0;
 		}
 	}
include/linux/lnet/api.h +1 -1
index 447b41d..3657c13 100644
@@ -76,7 +76,7 @@
  * @{
  */
 int LNetGetId(unsigned int index, struct lnet_processid *id);
-int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, u32 *order);
+int LNetDist(struct lnet_nid *nid, struct lnet_nid *srcnid, u32 *order);
 void LNetPrimaryNID(struct lnet_nid *nid);
 
 /** @} lnet_addr */
net/lnet/lnet/api-ni.c +3 -1
index 44d5014..c977b47 100644
@@ -4261,10 +4261,12 @@ u32 lnet_get_dlc_seq_locked(void)
 	}
 
 	case IOC_LIBCFS_LNET_DIST:
-		rc = LNetDist(data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1]);
+		lnet_nid4_to_nid(data->ioc_nid, &nid);
+		rc = LNetDist(&nid, &nid, &data->ioc_u32[1]);
 		if (rc < 0 && rc != -EHOSTUNREACH)
 			return rc;
 
+		data->ioc_nid = lnet_nid_to_nid4(&nid);
 		data->ioc_u32[0] = rc;
 		return 0;
 
net/lnet/lnet/lib-move.c +16 -19
index 080bfe6..bca33bf 100644
@@ -5072,55 +5072,51 @@ struct lnet_msg *
  *		-EHOSTUNREACH If @dstnid is not reachable.
  */
 int
-LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, u32 *orderp)
+LNetDist(struct lnet_nid *dstnid, struct lnet_nid *srcnid, u32 *orderp)
 {
 	struct lnet_ni *ni = NULL;
 	struct lnet_remotenet *rnet;
-	u32 dstnet = LNET_NIDNET(dstnid);
+	u32 dstnet = LNET_NID_NET(dstnid);
 	int hops;
 	int cpt;
 	u32 order = 2;
 	struct list_head *rn_list;
-	bool matched_dstnet = false;
+	struct lnet_ni *matched_dstnet = NULL;
 
-	/*
-	 * if !local_nid_dist_zero, I don't return a distance of 0 ever
+	/* if !local_nid_dist_zero, I don't return a distance of 0 ever
 	 * (when lustre sees a distance of 0, it substitutes 0@lo), so I
 	 * keep order 0 free for 0@lo and order 1 free for a local NID
 	 * match
+	 * WARNING: dstnid and srcnid might point to same place.
+	 * Don't set *srcnid until late.
 	 */
 	LASSERT(the_lnet.ln_refcount > 0);
 
 	cpt = lnet_net_lock_current();
 
 	while ((ni = lnet_get_next_ni_locked(NULL, ni))) {
-		/* FIXME support large-addr nid */
-		if (lnet_nid_to_nid4(&ni->ni_nid) == dstnid) {
-			if (srcnidp)
-				*srcnidp = dstnid;
+		if (nid_same(&ni->ni_nid, dstnid)) {
 			if (orderp) {
-				if (dstnid == LNET_NID_LO_0)
+				if (nid_is_lo0(dstnid))
 					*orderp = 0;
 				else
 					*orderp = 1;
 			}
+			if (srcnid)
+				*srcnid = *dstnid;
 			lnet_net_unlock(cpt);
 
 			return local_nid_dist_zero ? 0 : 1;
 		}
 
 		if (!matched_dstnet && LNET_NID_NET(&ni->ni_nid) == dstnet) {
-			matched_dstnet = true;
+			matched_dstnet = ni;
 			/* We matched the destination net, but we may have
 			 * additional local NIs to inspect.
 			 *
-			 * We record the nid and order as appropriate, but
+			 * We record the order as appropriate, but
 			 * they may be overwritten if we match local NI above.
 			 */
-			if (srcnidp)
-				/* FIXME support large-addr nids */
-				*srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
-
 			if (orderp) {
 				/* Check if ni was originally created in
 				 * current net namespace.
@@ -5140,6 +5136,8 @@ struct lnet_msg *
 	}
 
 	if (matched_dstnet) {
+		if (srcnid)
+			*srcnid = matched_dstnet->ni_nid;
 		lnet_net_unlock(cpt);
 		return 1;
 	}
@@ -5168,14 +5166,13 @@ struct lnet_msg *
 
 			LASSERT(shortest);
 			hops = shortest_hops;
-			if (srcnidp) {
+			if (srcnid) {
 				struct lnet_net *net;
 
 				net = lnet_get_net_locked(shortest->lr_lnet);
 				LASSERT(net);
 				ni = lnet_get_next_ni_locked(net, NULL);
-				/* FIXME support large-addr nids */
-				*srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
+				*srcnid = ni->ni_nid;
 			}
 			if (orderp)
 				*orderp = order;
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 8/18 lnet: convert LNetPut to take 16byte nid and pid.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

LNetPut() now takes a 16byte nid for self and similar process_id for target.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 50f6bb62987c54ea9 ("LU-10391 lnet: convert LNetPut to take 16byte nid and pid.")

Reviewed-on: https://review.whamcloud.com/43619

---
 fs/lustre/ptlrpc/niobuf.c | 15 ++++++++++-----
 include/linux/lnet/api.h  |  4 ++--
 net/lnet/lnet/lib-move.c  | 28 +++++++++++-----------------
 net/lnet/lnet/peer.c      | 10 +++++-----
 net/lnet/selftest/rpc.c   | 17 +++++++++++------
 5 files changed, 39 insertions(+), 35 deletions(-)
fs/lustre/ptlrpc/niobuf.c +10 -5
index afe83ad..94a0329 100644
@@ -46,15 +46,20 @@
  */
 static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len,
 			enum lnet_ack_req ack, struct ptlrpc_cb_id *cbid,
-			lnet_nid_t self, struct lnet_process_id peer_id,
+			lnet_nid_t self4, struct lnet_process_id peer_id4,
 			int portal, u64 xid, unsigned int offset,
 			struct lnet_handle_md *bulk_cookie)
 {
 	int rc;
 	struct lnet_md md;
+	struct lnet_nid self;
+	struct lnet_processid peer_id;
+
+	lnet_nid4_to_nid(self4, &self);
+	lnet_pid4_to_pid(peer_id4, &peer_id);
 
 	LASSERT(portal != 0);
-	CDEBUG(D_INFO, "peer_id %s\n", libcfs_id2str(peer_id));
+	CDEBUG(D_INFO, "peer_id %s\n", libcfs_id2str(peer_id4));
 	md.start = base;
 	md.length = len;
 	md.threshold = (ack == LNET_ACK_REQ) ? 2 : 1;
@@ -85,8 +90,8 @@ static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len,
 
 	percpu_ref_get(&ptlrpc_pending);
 
-	rc = LNetPut(self, *mdh, ack,
-		     peer_id, portal, xid, offset, 0);
+	rc = LNetPut(&self, *mdh, ack,
+		     &peer_id, portal, xid, offset, 0);
 	if (unlikely(rc != 0)) {
 		int rc2;
 		/* We're going to get an UNLINK event when I unlink below,
@@ -94,7 +99,7 @@ static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len,
 		 * I fall through and return success here!
 		 */
 		CERROR("LNetPut(%s, %d, %lld) failed: %d\n",
-		       libcfs_id2str(peer_id), portal, xid, rc);
+		       libcfs_id2str(peer_id4), portal, xid, rc);
 		rc2 = LNetMDUnlink(*mdh);
 		LASSERTF(rc2 == 0, "rc2 = %d\n", rc2);
 	}
include/linux/lnet/api.h +2 -2
index 3657c13..514cbe7 100644
@@ -137,10 +137,10 @@ int LNetMDBind(const struct lnet_md *md_in,
  * and LNetGet().
  * @{
  */
-int LNetPut(lnet_nid_t self,
+int LNetPut(struct lnet_nid *self,
 	    struct lnet_handle_md md_in,
 	    enum lnet_ack_req ack_req_in,
-	    struct lnet_process_id target_in,
+	    struct lnet_processid *target_in,
 	    unsigned int portal_in,
 	    u64 match_bits_in,
 	    unsigned int offset_in,
net/lnet/lnet/lib-move.c +11 -17
index bca33bf..55a001e 100644
@@ -4707,36 +4707,30 @@ void lnet_monitor_thr_stop(void)
  * \see lnet_event::hdr_data and lnet_event_kind.
  */
 int
-LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack,
-	struct lnet_process_id target4, unsigned int portal,
+LNetPut(struct lnet_nid *self, struct lnet_handle_md mdh, enum lnet_ack_req ack,
+	struct lnet_processid *target, unsigned int portal,
 	u64 match_bits, unsigned int offset,
 	u64 hdr_data)
 {
 	struct lnet_rsp_tracker *rspt = NULL;
-	struct lnet_processid target;
 	struct lnet_msg *msg;
 	struct lnet_libmd *md;
-	struct lnet_nid self;
 	int cpt;
 	int rc;
 
 	LASSERT(the_lnet.ln_refcount > 0);
 
-	lnet_nid4_to_nid(self4, &self);
-	lnet_nid4_to_nid(target4.nid, &target.nid);
-	target.pid = target4.pid;
-
 	if (!list_empty(&the_lnet.ln_test_peers) &&	/* normally we don't */
-	    fail_peer(&target.nid, 1)) {		/* shall we now? */
+	    fail_peer(&target->nid, 1)) {		/* shall we now? */
 		CERROR("Dropping PUT to %s: simulated failure\n",
-		       libcfs_id2str(target4));
+		       libcfs_idstr(target));
 		return -EIO;
 	}
 
 	msg = kmem_cache_zalloc(lnet_msg_cachep, GFP_NOFS);
 	if (!msg) {
 		CERROR("Dropping PUT to %s: ENOMEM on struct lnet_msg\n",
-		       libcfs_id2str(target4));
+		       libcfs_idstr(target));
 		return -ENOMEM;
 	}
 	msg->msg_vmflush = !!(current->flags & PF_MEMALLOC);
@@ -4747,7 +4741,7 @@ void lnet_monitor_thr_stop(void)
 		rspt = lnet_rspt_alloc(cpt);
 		if (!rspt) {
 			CERROR("Dropping PUT to %s: ENOMEM on response tracker\n",
-			       libcfs_id2str(target4));
+			       libcfs_idstr(target));
 			return -ENOMEM;
 		}
 		INIT_LIST_HEAD(&rspt->rspt_on_list);
@@ -4758,7 +4752,7 @@ void lnet_monitor_thr_stop(void)
 	md = lnet_handle2md(&mdh);
 	if (!md || !md->md_threshold || md->md_me) {
 		CERROR("Dropping PUT (%llu:%d:%s): MD (%d) invalid\n",
-		       match_bits, portal, libcfs_id2str(target4),
+		       match_bits, portal, libcfs_idstr(target),
 		       !md ? -1 : md->md_threshold);
 		if (md && md->md_me)
 			CERROR("Source MD also attached to portal %d\n",
@@ -4772,11 +4766,11 @@ void lnet_monitor_thr_stop(void)
 		return -ENOENT;
 	}
 
-	CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_id2str(target4));
+	CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_idstr(target));
 
 	lnet_msg_attach_md(msg, md, 0, 0);
 
-	lnet_prep_send(msg, LNET_MSG_PUT, &target, 0, md->md_length);
+	lnet_prep_send(msg, LNET_MSG_PUT, target, 0, md->md_length);
 
 	msg->msg_hdr.msg.put.match_bits = cpu_to_le64(match_bits);
 	msg->msg_hdr.msg.put.ptl_index = cpu_to_le32(portal);
@@ -4810,10 +4804,10 @@ void lnet_monitor_thr_stop(void)
 				 CFS_FAIL_ONCE))
 		rc = -EIO;
 	else
-		rc = lnet_send(&self, msg, NULL);
+		rc = lnet_send(self, msg, NULL);
 	if (rc) {
 		CNETERR("Error sending PUT to %s: %d\n",
-			libcfs_id2str(target4), rc);
+			libcfs_idstr(target), rc);
 		msg->msg_no_resend = true;
 		lnet_finalize(msg, rc);
 	}
net/lnet/lnet/peer.c +5 -5
index 2055f31..6c35901 100644
@@ -3559,7 +3559,7 @@ static int lnet_peer_send_push(struct lnet_peer *lp)
 __must_hold(&lp->lp_lock)
 {
 	struct lnet_ping_buffer *pbuf;
-	struct lnet_process_id id;
+	struct lnet_processid id;
 	struct lnet_md md;
 	int cpt;
 	int rc;
@@ -3606,13 +3606,13 @@ static int lnet_peer_send_push(struct lnet_peer *lp)
 	lnet_peer_addref_locked(lp);
 	id.pid = LNET_PID_LUSTRE;
 	if (!LNET_NID_IS_ANY(&lp->lp_disc_dst_nid))
-		id.nid = lnet_nid_to_nid4(&lp->lp_disc_dst_nid);
+		id.nid = lp->lp_disc_dst_nid;
 	else
-		id.nid = lnet_nid_to_nid4(&lp->lp_primary_nid);
+		id.nid = lp->lp_primary_nid;
 	lnet_net_unlock(cpt);
 
-	rc = LNetPut(lnet_nid_to_nid4(&lp->lp_disc_src_nid), lp->lp_push_mdh,
-		     LNET_ACK_REQ, id, LNET_RESERVED_PORTAL,
+	rc = LNetPut(&lp->lp_disc_src_nid, lp->lp_push_mdh,
+		     LNET_ACK_REQ, &id, LNET_RESERVED_PORTAL,
 		     LNET_PROTO_PING_MATCHBITS, 0, 0);
 	/* reset the discovery nid. There is no need to restrict sending
 	 * from that source, if we call lnet_push_update_to_peers(). It'll
net/lnet/selftest/rpc.c +11 -6
index d1538be..b16711a 100644
@@ -397,12 +397,17 @@ struct srpc_bulk *
 
 static int
 srpc_post_active_rdma(int portal, u64 matchbits, void *buf, int len,
-		      int options, struct lnet_process_id peer,
-		      lnet_nid_t self, struct lnet_handle_md *mdh,
+		      int options, struct lnet_process_id peer4,
+		      lnet_nid_t self4, struct lnet_handle_md *mdh,
 		      struct srpc_event *ev)
 {
 	int rc;
 	struct lnet_md md;
+	struct lnet_nid self;
+	struct lnet_processid peer;
+
+	lnet_nid4_to_nid(self4, &self);
+	lnet_pid4_to_pid(peer4, &peer);
 
 	md.user_ptr = ev;
 	md.start = buf;
@@ -424,18 +429,18 @@ struct srpc_bulk *
 	 * buffers...
 	 */
 	if (options & LNET_MD_OP_PUT) {
-		rc = LNetPut(self, *mdh, LNET_NOACK_REQ, peer,
+		rc = LNetPut(&self, *mdh, LNET_NOACK_REQ, &peer,
 			     portal, matchbits, 0, 0);
 	} else {
 		LASSERT(options & LNET_MD_OP_GET);
 
-		rc = LNetGet(self, *mdh, peer, portal, matchbits, 0, false);
+		rc = LNetGet(self4, *mdh, peer4, portal, matchbits, 0, false);
 	}
 
 	if (rc) {
 		CERROR("LNet%s(%s, %d, %lld) failed: %d\n",
 		       options & LNET_MD_OP_PUT ? "Put" : "Get",
-		       libcfs_id2str(peer), portal, matchbits, rc);
+		       libcfs_id2str(peer4), portal, matchbits, rc);
 
 		/*
 		 * The forthcoming unlink event will complete this operation
@@ -446,7 +451,7 @@ struct srpc_bulk *
 	} else {
 		CDEBUG(D_NET,
 		       "Posted active RDMA: peer %s, portal %u, matchbits %#llx\n",
-		       libcfs_id2str(peer), portal, matchbits);
+		       libcfs_id2str(peer4), portal, matchbits);
 	}
 	return 0;
 }
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 9/18 lnet: change LNetGet to take 16byte nid and pid.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

"self" is now passed to LNetGet as a pointer to a 16-byte-addr nid, or NULL for "ANY". "target" is passed as a 16-bytes-addr process_id.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: d727ec56b26cbd1b8 ("LU-10391 lnet: change LNetGet to take 16byte nid and pid.")

Reviewed-on: https://review.whamcloud.com/43620

---
 include/linux/lnet/api.h |  4 ++--
 net/lnet/lnet/api-ni.c   | 25 +++++++++++++------------
 net/lnet/lnet/lib-move.c | 34 ++++++++++++++--------------------
 net/lnet/selftest/rpc.c  |  2 +-
 4 files changed, 30 insertions(+), 35 deletions(-)
include/linux/lnet/api.h +2 -2
index 514cbe7..7ea61cb 100644
@@ -146,9 +146,9 @@ int LNetPut(struct lnet_nid *self,
 	    unsigned int offset_in,
 	    u64	hdr_data_in);
 
-int LNetGet(lnet_nid_t self,
+int LNetGet(struct lnet_nid *self,
 	    struct lnet_handle_md md_in,
-	    struct lnet_process_id target_in,
+	    struct lnet_processid *target_in,
 	    unsigned int portal_in,
 	    u64	match_bits_in,
 	    unsigned int offset_in,
net/lnet/lnet/api-ni.c +13 -12
index c977b47..8643ac8d 100644
@@ -205,7 +205,7 @@ static void lnet_set_lnd_timeout(void)
  */
 static atomic_t lnet_dlc_seq_no = ATOMIC_INIT(0);
 
-static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
+static int lnet_ping(struct lnet_process_id id4, struct lnet_nid *src_nid,
 		     signed long timeout, struct lnet_process_id __user *ids,
 		     int n_ids);
 
@@ -4562,7 +4562,7 @@ struct ping_data {
 		complete(&pd->completion);
 }
 
-static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
+static int lnet_ping(struct lnet_process_id id4, struct lnet_nid *src_nid,
 		     signed long timeout, struct lnet_process_id __user *ids,
 		     int n_ids)
 {
@@ -4570,13 +4570,14 @@ static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
 	struct ping_data pd = { 0 };
 	struct lnet_ping_buffer *pbuf;
 	struct lnet_process_id tmpid;
+	struct lnet_processid id;
 	int i;
 	int nob;
 	int rc;
 	int rc2;
 
 	/* n_ids limit is arbitrary */
-	if (n_ids <= 0 || id.nid == LNET_NID_ANY)
+	if (n_ids <= 0 || id4.nid == LNET_NID_ANY)
 		return -EINVAL;
 
 	/* if the user buffer has more space than the lnet_interfaces_max
@@ -4585,8 +4586,8 @@ static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
 	if (n_ids > lnet_interfaces_max)
 		n_ids = lnet_interfaces_max;
 
-	if (id.pid == LNET_PID_ANY)
-		id.pid = LNET_PID_LUSTRE;
+	if (id4.pid == LNET_PID_ANY)
+		id4.pid = LNET_PID_LUSTRE;
 
 	pbuf = lnet_ping_buffer_alloc(n_ids, GFP_NOFS);
 	if (!pbuf)
@@ -4609,8 +4610,8 @@ static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
 		goto fail_ping_buffer_decref;
 	}
 
-	rc = LNetGet(lnet_nid_to_nid4(src_nid), pd.mdh, id,
-		     LNET_RESERVED_PORTAL,
+	lnet_pid4_to_pid(id4, &id);
+	rc = LNetGet(src_nid, pd.mdh, &id, LNET_RESERVED_PORTAL,
 		     LNET_PROTO_PING_MATCHBITS, 0, false);
 	if (rc) {
 		/* Don't CERROR; this could be deliberate! */
@@ -4637,7 +4638,7 @@ static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
 
 	if (nob < 8) {
 		CERROR("%s: ping info too short %d\n",
-		       libcfs_id2str(id), nob);
+		       libcfs_id2str(id4), nob);
 		goto fail_ping_buffer_decref;
 	}
 
@@ -4645,19 +4646,19 @@ static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
 		lnet_swap_pinginfo(pbuf);
 	} else if (pbuf->pb_info.pi_magic != LNET_PROTO_PING_MAGIC) {
 		CERROR("%s: Unexpected magic %08x\n",
-		       libcfs_id2str(id), pbuf->pb_info.pi_magic);
+		       libcfs_id2str(id4), pbuf->pb_info.pi_magic);
 		goto fail_ping_buffer_decref;
 	}
 
 	if (!(pbuf->pb_info.pi_features & LNET_PING_FEAT_NI_STATUS)) {
 		CERROR("%s: ping w/o NI status: 0x%x\n",
-		       libcfs_id2str(id), pbuf->pb_info.pi_features);
+		       libcfs_id2str(id4), pbuf->pb_info.pi_features);
 		goto fail_ping_buffer_decref;
 	}
 
 	if (nob < LNET_PING_INFO_SIZE(0)) {
 		CERROR("%s: Short reply %d(%d min)\n",
-		       libcfs_id2str(id),
+		       libcfs_id2str(id4),
 		       nob, (int)LNET_PING_INFO_SIZE(0));
 		goto fail_ping_buffer_decref;
 	}
@@ -4667,7 +4668,7 @@ static int lnet_ping(struct lnet_process_id id, struct lnet_nid *src_nid,
 
 	if (nob < LNET_PING_INFO_SIZE(n_ids)) {
 		CERROR("%s: Short reply %d(%d expected)\n",
-		       libcfs_id2str(id),
+		       libcfs_id2str(id4),
 		       nob, (int)LNET_PING_INFO_SIZE(n_ids));
 		goto fail_ping_buffer_decref;
 	}
net/lnet/lnet/lib-move.c +14 -20
index 55a001e..9ee1075 100644
@@ -3630,7 +3630,7 @@ struct lnet_mt_event_info {
 	       void *user_data, lnet_handler_t handler, bool recovery)
 {
 	struct lnet_md md = { NULL };
-	struct lnet_process_id id;
+	struct lnet_processid id;
 	struct lnet_ping_buffer *pbuf;
 	int rc;
 
@@ -3662,9 +3662,9 @@ struct lnet_mt_event_info {
 		goto fail_error;
 	}
 	id.pid = LNET_PID_LUSTRE;
-	id.nid = lnet_nid_to_nid4(dest_nid);
+	id.nid = *dest_nid;
 
-	rc = LNetGet(LNET_NID_ANY, *mdh, id,
+	rc = LNetGet(NULL, *mdh, &id,
 		     LNET_RESERVED_PORTAL,
 		     LNET_PROTO_PING_MATCHBITS, 0, recovery);
 	if (rc)
@@ -4948,35 +4948,29 @@ struct lnet_msg *
  *		-ENOENT Invalid MD object.
  */
 int
-LNetGet(lnet_nid_t self4, struct lnet_handle_md mdh,
-	struct lnet_process_id target4, unsigned int portal,
+LNetGet(struct lnet_nid *self, struct lnet_handle_md mdh,
+	struct lnet_processid *target, unsigned int portal,
 	u64 match_bits, unsigned int offset, bool recovery)
 {
 	struct lnet_rsp_tracker *rspt;
-	struct lnet_processid target;
 	struct lnet_msg *msg;
 	struct lnet_libmd *md;
-	struct lnet_nid self;
 	int cpt;
 	int rc;
 
 	LASSERT(the_lnet.ln_refcount > 0);
 
-	lnet_nid4_to_nid(self4, &self);
-	lnet_nid4_to_nid(target4.nid, &target.nid);
-	target.pid = target4.pid;
-
 	if (!list_empty(&the_lnet.ln_test_peers) &&	/* normally we don't */
-	    fail_peer(&target.nid, 1)) {		/* shall we now? */
+	    fail_peer(&target->nid, 1)) {		/* shall we now? */
 		CERROR("Dropping GET to %s: simulated failure\n",
-		       libcfs_id2str(target4));
+		       libcfs_idstr(target));
 		return -EIO;
 	}
 
 	msg = kmem_cache_zalloc(lnet_msg_cachep, GFP_NOFS);
 	if (!msg) {
 		CERROR("Dropping GET to %s: ENOMEM on struct lnet_msg\n",
-		       libcfs_id2str(target4));
+		       libcfs_idstr(target));
 		return -ENOMEM;
 	}
 
@@ -4985,7 +4979,7 @@ struct lnet_msg *
 	rspt = lnet_rspt_alloc(cpt);
 	if (!rspt) {
 		CERROR("Dropping GET to %s: ENOMEM on response tracker\n",
-		       libcfs_id2str(target4));
+		       libcfs_idstr(target));
 		return -ENOMEM;
 	}
 	INIT_LIST_HEAD(&rspt->rspt_on_list);
@@ -4997,7 +4991,7 @@ struct lnet_msg *
 	md = lnet_handle2md(&mdh);
 	if (!md || !md->md_threshold || md->md_me) {
 		CERROR("Dropping GET (%llu:%d:%s): MD (%d) invalid\n",
-		       match_bits, portal, libcfs_id2str(target4),
+		       match_bits, portal, libcfs_idstr(target),
 		       !md ? -1 : md->md_threshold);
 		if (md && md->md_me)
 			CERROR("REPLY MD also attached to portal %d\n",
@@ -5010,11 +5004,11 @@ struct lnet_msg *
 		return -ENOENT;
 	}
 
-	CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_id2str(target4));
+	CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_idstr(target));
 
 	lnet_msg_attach_md(msg, md, 0, 0);
 
-	lnet_prep_send(msg, LNET_MSG_GET, &target, 0, 0);
+	lnet_prep_send(msg, LNET_MSG_GET, target, 0, 0);
 
 	msg->msg_hdr.msg.get.match_bits = cpu_to_le64(match_bits);
 	msg->msg_hdr.msg.get.ptl_index = cpu_to_le32(portal);
@@ -5036,10 +5030,10 @@ struct lnet_msg *
 	else
 		lnet_rspt_free(rspt, cpt);
 
-	rc = lnet_send(&self, msg, NULL);
+	rc = lnet_send(self, msg, NULL);
 	if (rc < 0) {
 		CNETERR("Error sending GET to %s: %d\n",
-			libcfs_id2str(target4), rc);
+			libcfs_idstr(target), rc);
 		msg->msg_no_resend = true;
 		lnet_finalize(msg, rc);
 	}
net/lnet/selftest/rpc.c +1 -1
index b16711a..17277b8 100644
@@ -434,7 +434,7 @@ struct srpc_bulk *
 	} else {
 		LASSERT(options & LNET_MD_OP_GET);
 
-		rc = LNetGet(self4, *mdh, peer4, portal, matchbits, 0, false);
+		rc = LNetGet(&self, *mdh, &peer, portal, matchbits, 0, false);
 	}
 
 	if (rc) {
Signature · 1 line
1.8.3.1
#10 lore raw

PATCH 10/18 lnet: socklnd: pass large processid to ksocknal_add_peer

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Teach ksocknal_add_peer() to handle large-address processid, and now ksocknal_launch_packet() can support IPv6 addresses as well as IPv4.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 6deddc3d46704643d ("LU-10391 socklnd: pass large processid to ksocknal_add_peer")

Reviewed-on: https://review.whamcloud.com/44621

---
 net/lnet/klnds/socklnd/socklnd.c    | 22 +++++++++-------------
 net/lnet/klnds/socklnd/socklnd.h    |  2 +-
 net/lnet/klnds/socklnd/socklnd_cb.c | 28 ++++++++++++++++++----------
 3 files changed, 28 insertions(+), 24 deletions(-)
net/lnet/klnds/socklnd/socklnd.c +9 -13
index 4267832..2b6fa18 100644
@@ -611,23 +611,19 @@ struct ksock_peer_ni *
 }
 
 int
-ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id4,
+ksocknal_add_peer(struct lnet_ni *ni, struct lnet_processid *id,
 		  struct sockaddr *addr)
 {
 	struct ksock_peer_ni *peer_ni;
 	struct ksock_peer_ni *peer2;
 	struct ksock_conn_cb *conn_cb;
-	struct lnet_processid id;
 
-	if (id4.nid == LNET_NID_ANY ||
-	    id4.pid == LNET_PID_ANY)
+	if (LNET_NID_IS_ANY(&id->nid) ||
+	    id->pid == LNET_PID_ANY)
 		return -EINVAL;
 
-	id.pid = id4.pid;
-	lnet_nid4_to_nid(id4.nid, &id.nid);
-
 	/* Have a brand new peer_ni ready... */
-	peer_ni = ksocknal_create_peer(ni, &id);
+	peer_ni = ksocknal_create_peer(ni, id);
 	if (IS_ERR(peer_ni))
 		return PTR_ERR(peer_ni);
 
@@ -642,14 +638,14 @@ struct ksock_peer_ni *
 	/* always called with a ref on ni, so shutdown can't have started */
 	LASSERT(atomic_read(&((struct ksock_net *)ni->ni_data)->ksnn_npeers) >= 0);
 
-	peer2 = ksocknal_find_peer_locked(ni, &id);
+	peer2 = ksocknal_find_peer_locked(ni, id);
 	if (peer2) {
 		ksocknal_peer_decref(peer_ni);
 		peer_ni = peer2;
 	} else {
 		/* peer_ni table takes my ref on peer_ni */
 		hash_add(ksocknal_data.ksnd_peers, &peer_ni->ksnp_list,
-			 nidhash(&id.nid));
+			 nidhash(&id->nid));
 	}
 
 	ksocknal_add_conn_cb_locked(peer_ni, conn_cb);
@@ -1830,11 +1826,11 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_processid *id)
 	case IOC_LIBCFS_ADD_PEER: {
 		struct sockaddr_in sa = {.sin_family = AF_INET};
 
-		id4.nid = data->ioc_nid;
-		id4.pid = LNET_PID_LUSTRE;
+		id.pid = LNET_PID_LUSTRE;
+		lnet_nid4_to_nid(data->ioc_nid, &id.nid);
 		sa.sin_addr.s_addr = htonl(data->ioc_u32[0]);
 		sa.sin_port = htons(data->ioc_u32[1]);
-		return ksocknal_add_peer(ni, id4, (struct sockaddr *)&sa);
+		return ksocknal_add_peer(ni, &id, (struct sockaddr *)&sa);
 	}
 	case IOC_LIBCFS_DEL_PEER:
 		id4.nid = data->ioc_nid;
net/lnet/klnds/socklnd/socklnd.h +1 -1
index 13abe20..93368bd 100644
@@ -627,7 +627,7 @@ int ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 		  int delayed, struct iov_iter *to, unsigned int rlen);
 int ksocknal_accept(struct lnet_ni *ni, struct socket *sock);
 
-int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id,
+int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_processid *id,
 		      struct sockaddr *addr);
 struct ksock_peer_ni *ksocknal_find_peer_locked(struct lnet_ni *ni,
 						struct lnet_processid *id);
net/lnet/klnds/socklnd/socklnd_cb.c +18 -10
index adec183..94600f3 100644
@@ -808,7 +808,7 @@ struct ksock_conn_cb *
 {
 	struct ksock_peer_ni *peer_ni;
 	struct ksock_conn *conn;
-	struct sockaddr_in sa;
+	struct sockaddr_storage sa;
 	rwlock_t *g_lock;
 	int retry;
 	int rc;
@@ -859,16 +859,24 @@ struct ksock_conn_cb *
 		}
 
 		memset(&sa, 0, sizeof(sa));
-		sa.sin_family = AF_INET;
-		sa.sin_addr.s_addr = id->nid.nid_addr[0];
-		sa.sin_port = htons(lnet_acceptor_port());
-		{
-			struct lnet_process_id id4 = {
-				.pid = id->pid,
-				.nid = lnet_nid_to_nid4(&id->nid),
-			};
-			rc = ksocknal_add_peer(ni, id4, (struct sockaddr *)&sa);
+		switch (NID_ADDR_BYTES(&id->nid)) {
+			struct sockaddr_in *sin;
+			struct sockaddr_in6 *sin6;
+		case 4:
+			sin = (void *)&sa;
+			sin->sin_family = AF_INET;
+			sin->sin_addr.s_addr = id->nid.nid_addr[0];
+			sin->sin_port = htons(lnet_acceptor_port());
+			break;
+		case 16:
+			sin6 = (void *)&sa;
+			sin6->sin6_family = AF_INET6;
+			memcpy(&sin6->sin6_addr, id->nid.nid_addr,
+			       sizeof(sin6->sin6_addr));
+			sin6->sin6_port = htons(lnet_acceptor_port());
+			break;
 		}
+		rc = ksocknal_add_peer(ni, id, (struct sockaddr *)&sa);
 		if (rc) {
 			CERROR("Can't add peer_ni %s: %d\n",
 			       libcfs_idstr(id), rc);
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 11/18 lnet: socklnd: large processid for ksocknal_get_peer_info

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Have ksocknal_launch_packet() report a 'struct lnet_processid' with a large address.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: e4a49294530a5d5f7 ("LU-10391 socklnd: large processid for ksocknal_get_peer_info")

Reviewed-on: https://review.whamcloud.com/44622

---
 net/lnet/klnds/socklnd/socklnd.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
net/lnet/klnds/socklnd/socklnd.c +9 -10
index 2b6fa18..857aa05 100644
@@ -292,7 +292,7 @@ struct ksock_peer_ni *
 
 static int
 ksocknal_get_peer_info(struct lnet_ni *ni, int index,
-		       struct lnet_process_id *id, u32 *myip, u32 *peer_ip,
+		       struct lnet_processid *id, u32 *myip, u32 *peer_ip,
 		       int *port, int *conn_count, int *share_count)
 {
 	struct ksock_peer_ni *peer_ni;
@@ -312,8 +312,7 @@ struct ksock_peer_ni *
 			if (index-- > 0)
 				continue;
 
-			id->pid = peer_ni->ksnp_id.pid;
-			id->nid = lnet_nid_to_nid4(&peer_ni->ksnp_id.nid);
+			*id = peer_ni->ksnp_id;
 			*myip = 0;
 			*peer_ip = 0;
 			*port = 0;
@@ -327,8 +326,7 @@ struct ksock_peer_ni *
 			if (index-- > 0)
 				continue;
 
-			id->pid = peer_ni->ksnp_id.pid;
-			id->nid = lnet_nid_to_nid4(&peer_ni->ksnp_id.nid);
+			*id = peer_ni->ksnp_id;
 			*myip = peer_ni->ksnp_passive_ips[j];
 			*peer_ip = 0;
 			*port = 0;
@@ -344,8 +342,7 @@ struct ksock_peer_ni *
 
 			conn_cb = peer_ni->ksnp_conn_cb;
 
-			id->pid = peer_ni->ksnp_id.pid;
-			id->nid = lnet_nid_to_nid4(&peer_ni->ksnp_id.nid);
+			*id = peer_ni->ksnp_id;
 			if (conn_cb->ksnr_addr.ss_family == AF_INET) {
 				struct sockaddr_in *sa;
 
@@ -1808,18 +1805,20 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_processid *id)
 		int share_count = 0;
 
 		rc = ksocknal_get_peer_info(ni, data->ioc_count,
-					    &id4, &myip, &ip, &port,
+					    &id, &myip, &ip, &port,
 					    &conn_count,  &share_count);
 		if (rc)
 			return rc;
 
-		data->ioc_nid = id4.nid;
+		if (!nid_is_nid4(&id.nid))
+			return -EINVAL;
+		data->ioc_nid = lnet_nid_to_nid4(&id.nid);
 		data->ioc_count = share_count;
 		data->ioc_u32[0] = ip;
 		data->ioc_u32[1] = port;
 		data->ioc_u32[2] = myip;
 		data->ioc_u32[3] = conn_count;
-		data->ioc_u32[4] = id4.pid;
+		data->ioc_u32[4] = id.pid;
 		return 0;
 	}
 
Signature · 1 line
1.8.3.1
#12 lore raw

PATCH 12/18 lnet: socklnd: switch ksocknal_del_peer to lnet_processid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

ksocknal_del_peer now takes a pointer to a lnet_processid, with room for a large address.
A NULL means "ANY NID, AND PID".
The "ip" argument was completely unused, so has been removed.

This was the last use of 'struct lnet_process_id' in ksocklnd.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 782e37e54f5c54886 ("LU-10391 socklnd: switch ksocknal_del_peer to lnet_processid")

Reviewed-on: https://review.whamcloud.com/44623

---
 net/lnet/klnds/socklnd/socklnd.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)
net/lnet/klnds/socklnd/socklnd.c +13 -23
index 857aa05..01b434f 100644
@@ -660,7 +660,7 @@ struct ksock_peer_ni *
 }
 
 static void
-ksocknal_del_peer_locked(struct ksock_peer_ni *peer_ni, u32 ip)
+ksocknal_del_peer_locked(struct ksock_peer_ni *peer_ni)
 {
 	struct ksock_conn *conn;
 	struct ksock_conn *cnxt;
@@ -683,7 +683,7 @@ struct ksock_peer_ni *
 }
 
 static int
-ksocknal_del_peer(struct lnet_ni *ni, struct lnet_process_id id4, u32 ip)
+ksocknal_del_peer(struct lnet_ni *ni, struct lnet_processid *id)
 {
 	LIST_HEAD(zombies);
 	struct hlist_node *pnxt;
@@ -692,15 +692,11 @@ struct ksock_peer_ni *
 	int hi;
 	int i;
 	int rc = -ENOENT;
-	struct lnet_processid id;
-
-	id.pid = id4.pid;
-	lnet_nid4_to_nid(id4.nid, &id.nid);
 
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
-	if (!LNET_NID_IS_ANY(&id.nid)) {
-		lo = hash_min(nidhash(&id.nid),
+	if (id && !LNET_NID_IS_ANY(&id->nid)) {
+		lo = hash_min(nidhash(&id->nid),
 			      HASH_BITS(ksocknal_data.ksnd_peers));
 		hi = lo;
 	} else {
@@ -715,15 +711,15 @@ struct ksock_peer_ni *
 			if (peer_ni->ksnp_ni != ni)
 				continue;
 
-			if (!((LNET_NID_IS_ANY(&id.nid) ||
-			       nid_same(&peer_ni->ksnp_id.nid, &id.nid)) &&
-			      (id.pid == LNET_PID_ANY ||
-			       peer_ni->ksnp_id.pid == id.pid)))
+			if (!((!id || LNET_NID_IS_ANY(&id->nid) ||
+			       nid_same(&peer_ni->ksnp_id.nid, &id->nid)) &&
+			      (!id || id->pid == LNET_PID_ANY ||
+			       peer_ni->ksnp_id.pid == id->pid)))
 				continue;
 
 			ksocknal_peer_addref(peer_ni);     /* a ref for me... */
 
-			ksocknal_del_peer_locked(peer_ni, ip);
+			ksocknal_del_peer_locked(peer_ni);
 
 			if (peer_ni->ksnp_closing &&
 			    !list_empty(&peer_ni->ksnp_tx_queue)) {
@@ -1764,7 +1760,6 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_processid *id)
 int
 ksocknal_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg)
 {
-	struct lnet_process_id id4 = {};
 	struct lnet_processid id = {};
 	struct libcfs_ioctl_data *data = arg;
 	int rc;
@@ -1832,10 +1827,9 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_processid *id)
 		return ksocknal_add_peer(ni, &id, (struct sockaddr *)&sa);
 	}
 	case IOC_LIBCFS_DEL_PEER:
-		id4.nid = data->ioc_nid;
-		id4.pid = LNET_PID_ANY;
-		return ksocknal_del_peer(ni, id4,
-					 data->ioc_u32[0]); /* IP */
+		lnet_nid4_to_nid(data->ioc_nid, &id.nid);
+		id.pid = LNET_PID_ANY;
+		return ksocknal_del_peer(ni, &id);
 
 	case IOC_LIBCFS_GET_CONN: {
 		int txmem;
@@ -2347,10 +2341,6 @@ static int ksocknal_inetaddr_event(struct notifier_block *unused,
 ksocknal_shutdown(struct lnet_ni *ni)
 {
 	struct ksock_net *net = ni->ni_data;
-	struct lnet_process_id anyid = { 0 };
-
-	anyid.nid = LNET_NID_ANY;
-	anyid.pid = LNET_PID_ANY;
 
 	LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_ALL);
 	LASSERT(ksocknal_data.ksnd_nnets > 0);
@@ -2359,7 +2349,7 @@ static int ksocknal_inetaddr_event(struct notifier_block *unused,
 	atomic_add(SOCKNAL_SHUTDOWN_BIAS, &net->ksnn_npeers);
 
 	/* Delete all peers */
-	ksocknal_del_peer(ni, anyid, 0);
+	ksocknal_del_peer(ni, NULL);
 
 	/* Wait for all peer_ni state to clean up */
 	wait_var_event_warning(&net->ksnn_npeers,
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH 13/18 lustre: llite: access lli_lsm_md with lock in all places

In reply to James Simmons

From: Lai Siyao <[email protected]>

lli_lsm_md should be accessed with lock in all places. Among all the changes, ll_rease_page() is inside lock already, except statahead code.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15284
Lustre-commit: 1dfae156d1dbc11cf ("LU-15284 llite: access lli_lsm_md with lock in all places")

Reviewed-on: https://review.whamcloud.com/46355

---
 fs/lustre/llite/dir.c            |  6 +++---
 fs/lustre/llite/file.c           |  8 +++++---
 fs/lustre/llite/llite_internal.h | 17 +++++++++++++++--
 fs/lustre/llite/llite_lib.c      | 20 +++++++++++---------
 fs/lustre/llite/namei.c          |  7 +++++--
 fs/lustre/llite/statahead.c      |  2 ++
 fs/lustre/lmv/lmv_obd.c          |  3 ++-
 7 files changed, 43 insertions(+), 20 deletions(-)
fs/lustre/llite/dir.c +3 -3
index cfd8184..29d7e44 100644
@@ -162,11 +162,11 @@ void ll_release_page(struct inode *inode, struct page *page, bool remove)
 {
 	kunmap(page);
 
-	/*
-	 * Always remove the page for striped dir, because the page is
+	/* Always remove the page for striped dir, because the page is
 	 * built from temporarily in LMV layer
 	 */
-	if (inode && ll_dir_striped(inode)) {
+	if (inode && S_ISDIR(inode->i_mode) &&
+	    lmv_dir_striped(ll_i2info(inode)->lli_lsm_md)) {
 		__free_page(page);
 		return;
 	}
fs/lustre/llite/file.c +5 -3
index 1ac3e4f..30f522b 100644
@@ -5066,12 +5066,14 @@ static int ll_merge_md_attr(struct inode *inode)
 	struct cl_attr attr = { 0 };
 	int rc;
 
-	LASSERT(lli->lli_lsm_md);
-
-	if (!lmv_dir_striped(lli->lli_lsm_md))
+	if (!lli->lli_lsm_md)
 		return 0;
 
 	down_read(&lli->lli_lsm_sem);
+	if (!lmv_dir_striped(lli->lli_lsm_md)) {
+		up_read(&lli->lli_lsm_sem);
+		return 0;
+	}
 	rc = md_merge_attr(ll_i2mdexp(inode), lli->lli_lsm_md, &attr,
 			   ll_md_blocking_ast);
 	up_read(&lli->lli_lsm_sem);
fs/lustre/llite/llite_internal.h +15 -2
index f51ab19..bc50169 100644
@@ -1373,9 +1373,22 @@ static inline struct lu_fid *ll_inode2fid(struct inode *inode)
 
 static inline bool ll_dir_striped(struct inode *inode)
 {
+	struct ll_inode_info *lli;
+	bool rc;
+
 	LASSERT(inode);
-	return S_ISDIR(inode->i_mode) &&
-	       lmv_dir_striped(ll_i2info(inode)->lli_lsm_md);
+	if (!S_ISDIR(inode->i_mode))
+		return false;
+
+	lli = ll_i2info(inode);
+	if (!lli->lli_lsm_md)
+		return false;
+
+	down_read(&lli->lli_lsm_sem);
+	rc = lmv_dir_striped(lli->lli_lsm_md);
+	up_read(&lli->lli_lsm_sem);
+
+	return rc;
 }
 
 static inline loff_t ll_file_maxbytes(struct inode *inode)
fs/lustre/llite/llite_lib.c +11 -9
index ad77ef0..99ab9ac 100644
@@ -1626,23 +1626,25 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
 	}
 
 	rc = ll_init_lsm_md(inode, md);
-	up_write(&lli->lli_lsm_sem);
-
-	if (rc)
+	if (rc) {
+		up_write(&lli->lli_lsm_sem);
 		return rc;
+	}
+
+	/* md_merge_attr() may take long, since lsm is already set, switch to
+	 * read lock.
+	 */
+	downgrade_write(&lli->lli_lsm_sem);
 
 	/* set md->lmv to NULL, so the following free lustre_md will not free
 	 * this lsm.
 	 */
 	md->lmv = NULL;
 
-	/* md_merge_attr() may take long, since lsm is already set, switch to
-	 * read lock.
-	 */
-	down_read(&lli->lli_lsm_sem);
-
-	if (!lmv_dir_striped(lli->lli_lsm_md))
+	if (!lmv_dir_striped(lli->lli_lsm_md)) {
+		rc = 0;
 		goto unlock;
+	}
 
 	attr = kzalloc(sizeof(*attr), GFP_NOFS);
 	if (!attr) {
fs/lustre/llite/namei.c +5 -2
index c05e3bf..f7e900d 100644
@@ -765,14 +765,17 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
 			.it_op = IT_GETATTR,
 			.it_lock_handle = 0
 		};
-		struct lu_fid fid = ll_i2info(parent)->lli_fid;
+		struct ll_inode_info *lli = ll_i2info(parent);
+		struct lu_fid fid = lli->lli_fid;
 
 		/* If it is striped directory, get the real stripe parent */
 		if (unlikely(ll_dir_striped(parent))) {
+			down_read(&lli->lli_lsm_sem);
 			rc = md_get_fid_from_lsm(ll_i2mdexp(parent),
-						 ll_i2info(parent)->lli_lsm_md,
+						 lli->lli_lsm_md,
 						 (*de)->d_name.name,
 						 (*de)->d_name.len, &fid);
+			up_read(&lli->lli_lsm_sem);
 			if (rc)
 				return rc;
 		}
fs/lustre/llite/statahead.c +2 -0
index c781e49..3043a51 100644
@@ -1164,8 +1164,10 @@ static int ll_statahead_thread(void *arg)
 		}
 
 		pos = le64_to_cpu(dp->ldp_hash_end);
+		down_read(&lli->lli_lsm_sem);
 		ll_release_page(dir, page,
 				le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
+		up_read(&lli->lli_lsm_sem);
 
 		if (sa_low_hit(sai)) {
 			rc = -EFAULT;
fs/lustre/lmv/lmv_obd.c +2 -1
index 5b43cfd..d83ba41ff 100644
@@ -3654,7 +3654,8 @@ static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
 {
 	const struct lmv_oinfo *oinfo;
 
-	LASSERT(lmv_dir_striped(lsm));
+	if (!lmv_dir_striped(lsm))
+		return -ESTALE;
 
 	oinfo = lsm_name_to_stripe_info(lsm, name, namelen, false);
 	if (IS_ERR(oinfo))
Signature · 1 line
1.8.3.1
#14 lore raw

PATCH 14/18 lustre: quota: fallocate does not increase projectid usage

In reply to James Simmons

From: Arshad Hussain <[email protected]>

fallocate() was not accounting for projectid quota usage. This was happening due to two reasons. 1) the projectid was not properly passed to md_op_data in ll_set_project() and 2) the OBD_MD_FLPROJID flag was not set receive the projctid.

This patch addresses the above reasons.

Fixes d748d2ffa1bc ("lustre: fallocate: Implement fallocate preallocate operation")

WC-bug-id: https://jira.whamcloud.com/browse/LU-15519
Lustre-commit: 5fc934ebbbe665f24 ("LU-15519 quota: fallocate does not increase projectid usage")

Reviewed-on: https://review.whamcloud.com/46676

---
 fs/lustre/include/cl_object.h |  1 +
 fs/lustre/llite/file.c        | 18 +++++++++++-------
 fs/lustre/llite/vvp_object.c  |  3 ++-
 fs/lustre/lov/lov_io.c        |  2 ++
 fs/lustre/osc/osc_io.c        |  9 ++++++---
 5 files changed, 22 insertions(+), 11 deletions(-)
fs/lustre/include/cl_object.h +1 -0
index b98109d..06f03b4 100644
@@ -1889,6 +1889,7 @@ struct cl_io {
 			loff_t			sa_falloc_end;
 			uid_t			sa_falloc_uid;
 			gid_t			sa_falloc_gid;
+			u32			sa_falloc_projid;
 		} ci_setattr;
 		struct cl_data_version_io {
 			u64			dv_data_version;
fs/lustre/llite/file.c +11 -7
index 30f522b..5be77e8 100644
@@ -2629,7 +2629,7 @@ static int ll_do_fiemap(struct inode *inode, struct fiemap *fiemap,
 			goto out;
 	}
 
-	fmkey.lfik_oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+	fmkey.lfik_oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLPROJID;
 	obdo_from_inode(&fmkey.lfik_oa, inode, OBD_MD_FLSIZE);
 	obdo_set_parent_fid(&fmkey.lfik_oa, &ll_i2info(inode)->lli_fid);
 
@@ -3412,10 +3412,12 @@ static int ll_set_project(struct inode *inode, u32 xflags, u32 projid)
 	op_data->op_attr_flags = ll_inode_to_ext_flags(inode_flags);
 	if (xflags & FS_XFLAG_PROJINHERIT)
 		op_data->op_attr_flags |= LUSTRE_PROJINHERIT_FL;
+
+	/* pass projid to md_op_data */
 	op_data->op_projid = projid;
-	op_data->op_xvalid |= OP_XVALID_PROJID;
-	rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
-			0, &req);
+
+	op_data->op_xvalid |= OP_XVALID_PROJID | OP_XVALID_FLAGS;
+	rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL, 0, &req);
 	ptlrpc_req_finished(req);
 	if (rc)
 		goto out_fsxattr;
@@ -5262,11 +5264,11 @@ int ll_getattr(const struct path *path, struct kstat *stat,
 int cl_falloc(struct file *file, struct inode *inode, int mode, loff_t offset,
 	      loff_t len)
 {
+	loff_t size = i_size_read(inode);
 	struct lu_env *env;
 	struct cl_io *io;
 	u16 refcheck;
 	int rc;
-	loff_t size = i_size_read(inode);
 
 	env = cl_env_get(&refcheck);
 	if (IS_ERR(env))
@@ -5283,12 +5285,14 @@ int cl_falloc(struct file *file, struct inode *inode, int mode, loff_t offset,
 	io->u.ci_setattr.sa_falloc_end = offset + len;
 	io->u.ci_setattr.sa_subtype = CL_SETATTR_FALLOCATE;
 
-	CDEBUG(D_INODE, "UID %u GID %u\n",
+	CDEBUG(D_INODE, "UID %u GID %u PRJID %u\n",
 	       from_kuid(&init_user_ns, inode->i_uid),
-	       from_kgid(&init_user_ns, inode->i_gid));
+	       from_kgid(&init_user_ns, inode->i_gid),
+	       ll_i2info(inode)->lli_projid);
 
 	io->u.ci_setattr.sa_falloc_uid = from_kuid(&init_user_ns, inode->i_uid);
 	io->u.ci_setattr.sa_falloc_gid = from_kgid(&init_user_ns, inode->i_gid);
+	io->u.ci_setattr.sa_falloc_projid = ll_i2info(inode)->lli_projid;
 
 	if (io->u.ci_setattr.sa_falloc_end > size) {
 		loff_t newsize = io->u.ci_setattr.sa_falloc_end;
fs/lustre/llite/vvp_object.c +2 -1
index 8a53458..64ecdb9 100644
@@ -190,7 +190,8 @@ static int vvp_object_glimpse(const struct lu_env *env,
 static void vvp_req_attr_set(const struct lu_env *env, struct cl_object *obj,
 			     struct cl_req_attr *attr)
 {
-	u64 valid_flags = OBD_MD_FLTYPE | OBD_MD_FLUID | OBD_MD_FLGID;
+	u64 valid_flags = OBD_MD_FLTYPE | OBD_MD_FLUID | OBD_MD_FLGID |
+			  OBD_MD_FLPROJID;
 	struct inode *inode;
 	struct obdo *oa;
 
fs/lustre/lov/lov_io.c +2 -0
index 38dacd35..b535092 100644
@@ -685,6 +685,8 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio,
 				parent->u.ci_setattr.sa_falloc_uid;
 			io->u.ci_setattr.sa_falloc_gid =
 				parent->u.ci_setattr.sa_falloc_gid;
+			io->u.ci_setattr.sa_falloc_projid =
+				parent->u.ci_setattr.sa_falloc_projid;
 		}
 		if (cl_io_is_trunc(io)) {
 			loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size;
fs/lustre/osc/osc_io.c +6 -3
index db91bf2..1361d7f 100644
@@ -671,11 +671,14 @@ static int osc_io_setattr_start(const struct lu_env *env,
 			oa->o_blocks = io->u.ci_setattr.sa_falloc_end;
 			oa->o_uid = io->u.ci_setattr.sa_falloc_uid;
 			oa->o_gid = io->u.ci_setattr.sa_falloc_gid;
+			oa->o_projid = io->u.ci_setattr.sa_falloc_projid;
 			oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
-				OBD_MD_FLUID | OBD_MD_FLGID;
+				OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLPROJID;
 
-			CDEBUG(D_INODE, "size %llu blocks %llu uid %u gid %u\n",
-			       oa->o_size, oa->o_blocks, oa->o_uid, oa->o_gid);
+			CDEBUG(D_INODE,
+			       "size %llu blocks %llu uid %u gid %u prjid %u\n",
+			       oa->o_size, oa->o_blocks, oa->o_uid, oa->o_gid,
+			       oa->o_projid);
 			result = osc_fallocate_base(osc_export(cl2osc(obj)),
 						    oa, osc_async_upcall,
 						    cbargs, falloc_mode);
Signature · 1 line
1.8.3.1
#15 lore raw

PATCH 15/18 lnet: selftest: improve lnet_selftest speed

In reply to James Simmons

From: Alexey Lyashkov <[email protected]>

lets replace a global spinlock with atomic variables, to avoid cpu power limit in testing.

HPE-bug-id: LUS-10812
WC-bug-id: https://jira.whamcloud.com/browse/LU-15718
Lustre-commit: dd5aa640781d8c6dc ("LU-15718 lnet: improve lnet_selftest speed")

Reviewed-on: https://review.whamcloud.com/47002

---
 net/lnet/selftest/rpc.c      | 105 ++++++++++++++++++++++++-------------------
 net/lnet/selftest/selftest.h |   1 -
 2 files changed, 58 insertions(+), 48 deletions(-)
net/lnet/selftest/rpc.c +58 -47
index 17277b8..c376019 100644
@@ -50,15 +50,41 @@ enum srpc_state {
 	SRPC_STATE_STOPPING,
 };
 
+enum rpc_counter_32 {
+	SRPC_ERROR,
+	SRPC_RPC_SENT,
+	SRPC_RPC_RCVD,
+	SRPC_RPC_DROP,
+	SRPC_RPC_EXPIRED,
+	SRPC_COUNTER32_MAX,
+};
+
+enum rpc_counter_64 {
+	SRPC_BULK_GET,
+	SRPC_BULK_PUT,
+	SRPC_COUNTER64_MAX,
+};
+
 static struct smoketest_rpc {
-	spinlock_t	 rpc_glock;	/* global lock */
-	struct srpc_service	*rpc_services[SRPC_SERVICE_MAX_ID + 1];
-	lnet_handler_t		 rpc_lnet_handler; /* _the_ LNet event queue */
-	enum srpc_state	 rpc_state;
-	struct srpc_counters	 rpc_counters;
-	u64		 rpc_matchbits;	/* matchbits counter */
+	spinlock_t		rpc_glock;	/* global lock */
+	struct srpc_service    *rpc_services[SRPC_SERVICE_MAX_ID + 1];
+	lnet_handler_t		rpc_lnet_handler; /* _the_ LNet event queue */
+	enum srpc_state		rpc_state;
+	struct srpc_counters	rpc_counters;
+	atomic_t		rpc_counters32[SRPC_COUNTER32_MAX];
+	atomic64_t		rpc_counters64[SRPC_COUNTER64_MAX];
+	atomic64_t		rpc_matchbits;	/* matchbits counter */
 } srpc_data;
 
+#define RPC_STAT32(a) \
+	srpc_data.rpc_counters32[(a)]
+
+#define GET_RPC_STAT32(a) \
+	atomic_read(&srpc_data.rpc_counters32[(a)])
+
+#define GET_RPC_STAT64(a) \
+	atomic64_read(&srpc_data.rpc_counters64[(a)])
+
 static inline int
 srpc_serv_portal(int svc_id)
 {
@@ -69,18 +95,17 @@ enum srpc_state {
 /* forward ref's */
 void srpc_handle_rpc(struct swi_workitem *wi);
 
-void srpc_get_counters(struct srpc_counters *cnt)
-{
-	spin_lock(&srpc_data.rpc_glock);
-	*cnt = srpc_data.rpc_counters;
-	spin_unlock(&srpc_data.rpc_glock);
-}
 
-void srpc_set_counters(const struct srpc_counters *cnt)
+void srpc_get_counters(struct srpc_counters *cnt)
 {
-	spin_lock(&srpc_data.rpc_glock);
-	srpc_data.rpc_counters = *cnt;
-	spin_unlock(&srpc_data.rpc_glock);
+	cnt->errors = GET_RPC_STAT32(SRPC_ERROR);
+	cnt->rpcs_sent = GET_RPC_STAT32(SRPC_RPC_SENT);
+	cnt->rpcs_rcvd = GET_RPC_STAT32(SRPC_RPC_RCVD);
+	cnt->rpcs_dropped = GET_RPC_STAT32(SRPC_RPC_DROP);
+	cnt->rpcs_expired = GET_RPC_STAT32(SRPC_RPC_EXPIRED);
+
+	cnt->bulk_get = GET_RPC_STAT64(SRPC_BULK_GET);
+	cnt->bulk_put = GET_RPC_STAT64(SRPC_BULK_PUT);
 }
 
 static int
@@ -162,12 +187,7 @@ struct srpc_bulk *
 static inline u64
 srpc_next_id(void)
 {
-	u64 id;
-
-	spin_lock(&srpc_data.rpc_glock);
-	id = srpc_data.rpc_matchbits++;
-	spin_unlock(&srpc_data.rpc_glock);
-	return id;
+	return atomic64_inc_return(&srpc_data.rpc_matchbits);
 }
 
 static void
@@ -922,11 +942,8 @@ struct srpc_bulk *
 		     rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer),
 		     swi_state2str(rpc->srpc_wi.swi_state), status);
 
-	if (status) {
-		spin_lock(&srpc_data.rpc_glock);
-		srpc_data.rpc_counters.rpcs_dropped++;
-		spin_unlock(&srpc_data.rpc_glock);
-	}
+	if (status)
+		atomic_inc(&RPC_STAT32(SRPC_RPC_DROP));
 
 	if (rpc->srpc_done)
 		(*rpc->srpc_done) (rpc);
@@ -1096,9 +1113,7 @@ struct srpc_bulk *
 
 	spin_unlock(&rpc->crpc_lock);
 
-	spin_lock(&srpc_data.rpc_glock);
-	srpc_data.rpc_counters.rpcs_expired++;
-	spin_unlock(&srpc_data.rpc_glock);
+	atomic_inc(&RPC_STAT32(SRPC_RPC_EXPIRED));
 }
 
 static void
@@ -1431,11 +1446,10 @@ struct srpc_client_rpc *
 	if (ev->status) {
 		u32 errors;
 
-		spin_lock(&srpc_data.rpc_glock);
 		if (ev->status != -ECANCELED) /* cancellation is not error */
-			srpc_data.rpc_counters.errors++;
-		errors = srpc_data.rpc_counters.errors;
-		spin_unlock(&srpc_data.rpc_glock);
+			errors = atomic_inc_return(&RPC_STAT32(SRPC_ERROR));
+		else
+			errors = atomic_read(&RPC_STAT32(SRPC_ERROR));
 
 		CNETERR("LNet event status %d type %d, RPC errors %u\n",
 			ev->status, ev->type, errors);
@@ -1449,11 +1463,9 @@ struct srpc_client_rpc *
 		       rpcev->ev_status, rpcev->ev_type, rpcev->ev_lnet);
 		LBUG();
 	case SRPC_REQUEST_SENT:
-		if (!ev->status && ev->type != LNET_EVENT_UNLINK) {
-			spin_lock(&srpc_data.rpc_glock);
-			srpc_data.rpc_counters.rpcs_sent++;
-			spin_unlock(&srpc_data.rpc_glock);
-		}
+		if (!ev->status && ev->type != LNET_EVENT_UNLINK)
+			atomic_inc(&RPC_STAT32(SRPC_RPC_SENT));
+
 		/* fall through */
 	case SRPC_REPLY_RCVD:
 	case SRPC_BULK_REQ_RCVD:
@@ -1566,9 +1578,7 @@ struct srpc_client_rpc *
 
 		spin_unlock(&scd->scd_lock);
 
-		spin_lock(&srpc_data.rpc_glock);
-		srpc_data.rpc_counters.rpcs_rcvd++;
-		spin_unlock(&srpc_data.rpc_glock);
+		atomic_inc(&RPC_STAT32(SRPC_RPC_RCVD));
 		break;
 
 	case SRPC_BULK_GET_RPLD:
@@ -1581,14 +1591,14 @@ struct srpc_client_rpc *
 		/* fall through */
 	case SRPC_BULK_PUT_SENT:
 		if (!ev->status && ev->type != LNET_EVENT_UNLINK) {
-			spin_lock(&srpc_data.rpc_glock);
+			atomic64_t *data;
 
 			if (rpcev->ev_type == SRPC_BULK_GET_RPLD)
-				srpc_data.rpc_counters.bulk_get += ev->mlength;
+				data = &srpc_data.rpc_counters64[SRPC_BULK_GET];
 			else
-				srpc_data.rpc_counters.bulk_put += ev->mlength;
+				data = &srpc_data.rpc_counters64[SRPC_BULK_PUT];
 
-			spin_unlock(&srpc_data.rpc_glock);
+			atomic64_add(ev->mlength, data);
 		}
 		/* fall through */
 	case SRPC_REPLY_SENT:
@@ -1619,7 +1629,8 @@ struct srpc_client_rpc *
 
 	/* 1 second pause to avoid timestamp reuse */
 	schedule_timeout_uninterruptible(HZ);
-	srpc_data.rpc_matchbits = ((u64)ktime_get_real_seconds()) << 48;
+	atomic64_set(&srpc_data.rpc_matchbits,
+		     ((u64)ktime_get_real_seconds() << 48));
 
 	srpc_data.rpc_state = SRPC_STATE_NONE;
 
net/lnet/selftest/selftest.h +0 -1
index 26202c1..223a432 100644
@@ -452,7 +452,6 @@ struct srpc_bulk *srpc_alloc_bulk(int cpt, unsigned int off,
 int srpc_service_add_buffers(struct srpc_service *sv, int nbuffer);
 void srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer);
 void srpc_get_counters(struct srpc_counters *cnt);
-void srpc_set_counters(const struct srpc_counters *cnt);
 
 extern struct workqueue_struct *lst_serial_wq;
 extern struct workqueue_struct **lst_test_wq;
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH 16/18 lustre: mdc: Use early cancels for hsm requests

In reply to James Simmons

From: Etienne AUJAMES <[email protected]>

HSM RELEASE and RESTORE requests take EX layout lock on the MDT side. So the client can use early cancel for its local lock on the resource to limit the contention (mdt side).

This patch does not pack ldlm request inside the hsm request because the field (RMF_DLM_REQ) does not exist in the request. Adding this field inside the request would break compatibility with _old_ servers.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15132
Lustre-commit: 60d2a4b0efa4a944b ("LU-15132 mdc: Use early cancels for hsm requests")

Reviewed-on: https://review.whamcloud.com/47181

---
 fs/lustre/mdc/mdc_request.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)
fs/lustre/mdc/mdc_request.c +33 -4
index f553d44..bb51878 100644
@@ -2000,6 +2000,32 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
 	return rc;
 }
 
+/* For RESTORE and RELEASE the mdt will take EX lock on the file layout.
+ * So we can use early cancel on client side locks for that resource.
+ */
+static inline int mdc_hsm_request_lock_to_cancel(struct obd_export *exp,
+						 struct hsm_user_request *hur,
+						 struct list_head *cancels)
+{
+	struct hsm_user_item *hui = &hur->hur_user_item[0];
+	struct hsm_request *req_hr = &hur->hur_request;
+	int count = 0;
+	int i;
+
+	if (req_hr->hr_action != HUA_RESTORE &&
+	    req_hr->hr_action != HUA_RELEASE)
+		return 0;
+
+	for (i = 0; i < req_hr->hr_itemcount; i++, hui++) {
+		if (!fid_is_sane(&hui->hui_fid))
+			continue;
+		count += mdc_resource_get_unused(exp, &hui->hui_fid, cancels,
+						 LCK_EX, MDS_INODELOCK_LAYOUT);
+	}
+
+	return count;
+}
+
 static int mdc_ioc_hsm_request(struct obd_export *exp,
 			       struct hsm_user_request *hur)
 {
@@ -2008,13 +2034,13 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	struct hsm_request *req_hr;
 	struct hsm_user_item *req_hui;
 	char *req_opaque;
+	LIST_HEAD(cancels);
+	int count;
 	int rc;
 
 	req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST);
-	if (!req) {
-		rc = -ENOMEM;
-		goto out;
-	}
+	if (!req)
+		return -ENOMEM;
 
 	req_capsule_set_size(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM, RCL_CLIENT,
 			     hur->hur_request.hr_itemcount
@@ -2028,6 +2054,9 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 		return rc;
 	}
 
+	/* Cancel existing locks */
+	count = mdc_hsm_request_lock_to_cancel(exp, hur, &cancels);
+	ldlm_cli_cancel_list(&cancels, count, NULL, 0);
 	mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
 
 	/* Copy hsm_request struct */
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 17/18 lustre: ptlrpc: send disconnected events

In reply to James Simmons

From: Alexander Boyko <[email protected]>

Failover of node does not produce disconnect event, only inactive. Add sending disconnected events.

HPE-bug-id: LUS-10750
WC-bug-id: https://jira.whamcloud.com/browse/LU-15724
Lustre-commit: e55fc043679cdfadf ("LU-15724 osp: wakeup all precreate threads")

Reviewed-on: https://review.whamcloud.com/47005

---
 fs/lustre/ptlrpc/import.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/lustre/ptlrpc/import.c +4 -0
index 3dc987cf..c0aee34 100644
@@ -1726,6 +1726,10 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
 	memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle));
 	spin_unlock(&imp->imp_lock);
 
+	obd_import_event(imp->imp_obd, imp, IMP_EVENT_DISCON);
+	if (!noclose)
+		obd_import_event(imp->imp_obd, imp, IMP_EVENT_INACTIVE);
+
 	if (rc == -ETIMEDOUT || rc == -ENOTCONN || rc == -ESHUTDOWN)
 		rc = 0;
 
Signature · 1 line
1.8.3.1
#18 lore raw

PATCH 18/18 lnet: Avoid redundant peer NI lookups

In reply to James Simmons

From: Chris Horn <[email protected]>

Each caller of lnet_peer_ni_traffic_add() performs a subsequent call to lnet_peer_ni_find_locked(). We can avoid the extra lookup by having lnet_peer_ni_traffic_add() return a peer NI pointer (or ERR_PTR as appropriate).

lnet_peer_ni_traffic_add() now takes a ref on the peer NI to mimic the behavior of lnet_peer_ni_find_locked().

lnet_nid2peerni_ex() only has a single caller that always passes LNET_LOCK_EX for the cpt argument, so this function argument is removed.

Some duplicate code dealing with ln_state handling is removed from lnet_peerni_by_nid_locked()

WC-bug-id: https://jira.whamcloud.com/browse/LU-12756
Lustre-commit: b00ac5f7038434a33 ("LU-12756 lnet: Avoid redundant peer NI lookups")

Reviewed-on: https://review.whamcloud.com/36623

---
 include/linux/lnet/lib-lnet.h |  2 +-
 net/lnet/lnet/peer.c          | 74 ++++++++++++++++++-------------------------
 net/lnet/lnet/router.c        |  6 ++--
 3 files changed, 35 insertions(+), 47 deletions(-)
include/linux/lnet/lib-lnet.h +1 -1
index 2e3c391..ca2a565 100644
@@ -901,7 +901,7 @@ struct lnet_peer_ni *lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref,
 struct lnet_peer_ni *lnet_peerni_by_nid_locked(struct lnet_nid *nid,
 					       struct lnet_nid *pref,
 					       int cpt);
-struct lnet_peer_ni *lnet_nid2peerni_ex(struct lnet_nid *nid, int cpt);
+struct lnet_peer_ni *lnet_nid2peerni_ex(struct lnet_nid *nid);
 struct lnet_peer_ni *lnet_peer_get_ni_locked(struct lnet_peer *lp,
 					     lnet_nid_t nid);
 struct lnet_peer_ni *lnet_peer_ni_get_locked(struct lnet_peer *lp,
net/lnet/lnet/peer.c +30 -44

146 lines not on this page · raw message

net/lnet/lnet/router.c +4 -2
index 60ae15d..b4f7aaa 100644
@@ -702,7 +702,7 @@ static void lnet_shuffle_seed(void)
 	/* lnet_nid2peerni_ex() grabs a ref on the lpni. We will need to
 	 * lose that once we're done
 	 */
-	lpni = lnet_nid2peerni_ex(gateway, LNET_LOCK_EX);
+	lpni = lnet_nid2peerni_ex(gateway);
 	if (IS_ERR(lpni)) {
 		lnet_net_unlock(LNET_LOCK_EX);
 
@@ -716,7 +716,9 @@ static void lnet_shuffle_seed(void)
 		return rc;
 	}
 
-	LASSERT(lpni->lpni_peer_net && lpni->lpni_peer_net->lpn_peer);
+	LASSERT(lpni);
+	LASSERT(lpni->lpni_peer_net);
+	LASSERT(lpni->lpni_peer_net->lpn_peer);
 	gw = lpni->lpni_peer_net->lpn_peer;
 
 	route->lr_gateway = gw;
Signature · 1 line
1.8.3.1
maintainer
#19 lore raw
In reply to James Simmons
Quoted 3 lines · James Simmons

Sync with the new work coming in for 2.16 development branch. Hold back the LU-15189 work since it introduced a regression that has an outstanding fix.

Is there a reason why this was sent to me and the linux-fscrypt list?

- Eric