Skip to contentSkip to conversation

lustre: backport OpenSFS work as of Nov 20, 2022

PATCH New James Simmons 1 participant 23 messages Nov 20, 2022 Networking

lore
Share & tools
lore
#0 lore raw

cover lustre: backport OpenSFS work as of Nov 20, 2022

Merge the next batch of work from the OpenSFS tree to the Linux native client. Most of the IPv6 ping work is now merged.

Alex Zhuravlev (1):
lustre: llite: remove linefeed from LDLM_DEBUG

Bobi Jam (1):
lustre: llite: clear stale page's uptodate bit

Chris Horn (2):
lnet: Don't modify uptodate peer with temp NI
lnet: Signal completion on ping send failure

James Simmons (3):
lnet: use Netlink to support old and new NI APIs.
lnet: fix build issue when IPv6 is disabled.
lnet: selftest: migrate LNet selftest session handling to Netlink

Lei Feng (1):
lustre: obdclass: fill jobid in a safe way

Mikhail Pershin (1):
lustre: llog: skip bad records in llog

Mr NeilBrown (7):
lustre: obdclass: improve precision of wakeups for mod_rpcs
lnet: allow ping packet to contain large nids
lnet: extend lnet_is_nid_in_ping_info()
lnet: find correct primary for peer
lnet: change lnet_notify() to take struct lnet_nid
lnet: discard lnet_nid2ni_*()
lnet: change lnet_debug_peer() to struct lnet_nid

Patrick Farrell (1):
lustre: osc: Remove oap lock

Serguei Smirnov (2):
lnet: o2iblnd: add verbose debug prints for rx/tx events
lnet: fix debug message in lnet_discovery_event_reply

Shaun Tancheff (1):
lustre: llite: Explicitly support .splice_write

Vitaly Fertman (2):
lustre: clio: append to non-existent component
lustre: ldlm: group lock unlock fix

 fs/lustre/include/cl_object.h          |  15 +-
 fs/lustre/include/lustre_dlm.h         |   1 +
 fs/lustre/include/lustre_osc.h         |  17 -
 fs/lustre/include/obd.h                |   1 -
 fs/lustre/ldlm/ldlm_lib.c              |   1 -
 fs/lustre/ldlm/ldlm_lock.c             |  28 +-
 fs/lustre/llite/file.c                 |  79 ++-
 fs/lustre/llite/llite_internal.h       |   3 +
 fs/lustre/llite/llite_lib.c            |   3 +
 fs/lustre/llite/namei.c                |   2 +-
 fs/lustre/llite/rw.c                   |  10 +-
 fs/lustre/llite/vvp_io.c               | 124 ++++-
 fs/lustre/llite/vvp_page.c             |   5 +
 fs/lustre/lov/lov_page.c               |   2 +
 fs/lustre/mdc/mdc_dev.c                |  58 +-
 fs/lustre/obdclass/cl_page.c           |  37 +-
 fs/lustre/obdclass/genops.c            | 158 +++---
 fs/lustre/obdclass/jobid.c             |  13 +-
 fs/lustre/obdclass/llog.c              |  86 +--
 fs/lustre/osc/osc_cache.c              |  11 -
 fs/lustre/osc/osc_io.c                 |   8 +-
 fs/lustre/osc/osc_lock.c               | 157 +-----
 fs/lustre/osc/osc_object.c             |  16 -
 fs/lustre/osc/osc_page.c               |   5 -
 fs/lustre/osc/osc_request.c            |  14 +-
 include/linux/lnet/lib-lnet.h          |  23 +-
 include/linux/lnet/lib-types.h         | 142 +++++
 include/uapi/linux/lnet/libcfs_ioctl.h |   2 +-
 include/uapi/linux/lnet/lnet-dlc.h     |  23 +
 include/uapi/linux/lnet/lnet-idl.h     |  58 +-
 include/uapi/linux/lnet/lnet-types.h   |  15 +
 include/uapi/linux/lnet/lnetst.h       |  21 +-
 net/lnet/klnds/o2iblnd/o2iblnd.c       |  88 ++-
 net/lnet/klnds/o2iblnd/o2iblnd.h       |  94 +++-
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c    | 136 +++--
 net/lnet/klnds/socklnd/socklnd.c       |  39 +-
 net/lnet/klnds/socklnd/socklnd.h       |   9 +
 net/lnet/lnet/api-ni.c                 | 961 ++++++++++++++++++++++++++++-----
 net/lnet/lnet/config.c                 |   6 +-
 net/lnet/lnet/lib-msg.c                |   2 +-
 net/lnet/lnet/module.c                 |  42 +-
 net/lnet/lnet/peer.c                   | 144 ++++-
 net/lnet/lnet/router.c                 |  15 +-
 net/lnet/selftest/conctl.c             | 349 +++++++++---
 net/lnet/selftest/conrpc.c             |  28 +-
 net/lnet/selftest/console.c            |  81 +--
 net/lnet/selftest/console.h            |  68 +--
 net/lnet/selftest/framework.c          |  43 +-
 net/lnet/selftest/selftest.h           |  78 ++-
 49 files changed, 2427 insertions(+), 894 deletions(-)
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#1 lore raw

PATCH 1/22 lustre: llite: clear stale page's uptodate bit

From: Bobi Jam <[email protected]>

With truncate_inode_page()->do_invalidatepage()->ll_invalidatepage() call path before deleting vmpage from page cache, the page could be possibly picked up by ll_read_ahead_page()->grab_cache_page_nowait().

If ll_invalidatepage()->cl_page_delete() does not clear the vmpage's uptodate bit, the read ahead could pick it up and think it's already uptodate wrongly.

In ll_fault()->vvp_io_fault_start()->vvp_io_kernel_fault(), the filemap_fault() will call ll_readpage() to read vmpage and wait for the unlock of the vmpage, and when ll_readpage() successfully read the vmpage then unlock the vmpage, memory pressure or truncate can get in and delete the cl_page, afterward filemap_fault() find that the vmpage is not uptodate and VM_FAULT_SIGBUS got returned. To fix this situation, this patch makes vvp_io_kernel_fault() restart filemap_fault() to get uptodated vmpage again.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16160
Lustre-commit: 5b911e03261c3de6b ("LU-16160 llite: clear stale page's uptodate bit")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48607

---
 fs/lustre/include/cl_object.h |  15 ++++-
 fs/lustre/llite/rw.c          |  10 +++-
 fs/lustre/llite/vvp_io.c      | 124 +++++++++++++++++++++++++++++++++++++++---
 fs/lustre/llite/vvp_page.c    |   5 ++
 fs/lustre/obdclass/cl_page.c  |  37 ++++++++++---
 5 files changed, 172 insertions(+), 19 deletions(-)
fs/lustre/include/cl_object.h +14 -1
index 41ce0b0..8be58ff 100644
@@ -768,7 +768,15 @@ struct cl_page {
 	enum cl_page_type		 cp_type:CP_TYPE_BITS;
 	unsigned int			 cp_defer_uptodate:1,
 					 cp_ra_updated:1,
-					 cp_ra_used:1;
+					 cp_ra_used:1,
+					 /* fault page read grab extra referece */
+					 cp_fault_ref:1,
+					 /**
+					  * if fault page got delete before returned to
+					  * filemap_fault(), defer the vmpage detach/put
+					  * until filemap_fault() has been handled.
+					  */
+					 cp_defer_detach:1;
 
 	/* which slab kmem index this memory allocated from */
 	short int			 cp_kmem_index;
@@ -2393,6 +2401,11 @@ int cl_io_lru_reserve(const struct lu_env *env, struct cl_io *io,
 int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
 		     pgoff_t start, struct cl_read_ahead *ra);
 
+static inline int cl_io_is_pagefault(const struct cl_io *io)
+{
+	return io->ci_type == CIT_FAULT && !io->u.ci_fault.ft_mkwrite;
+}
+
 /**
  * True, if @io is an O_APPEND write(2).
  */
fs/lustre/llite/rw.c +9 -1
index 2290b31..0283af4 100644
@@ -1947,7 +1947,15 @@ int ll_readpage(struct file *file, struct page *vmpage)
 			unlock_page(vmpage);
 			result = 0;
 		}
-		cl_page_put(env, page);
+		if (cl_io_is_pagefault(io) && result == 0) {
+			/**
+			 * page fault, retain the cl_page reference until
+			 * vvp_io_kernel_fault() release it.
+			 */
+			page->cp_fault_ref = 1;
+		} else {
+			cl_page_put(env, page);
+		}
 	} else {
 		unlock_page(vmpage);
 		result = PTR_ERR(page);
fs/lustre/llite/vvp_io.c +116 -8

161 lines not on this page · raw message

fs/lustre/llite/vvp_page.c +5 -0
index f359596..9e8c158 100644
@@ -104,6 +104,11 @@ static void vvp_page_completion_read(const struct lu_env *env,
 		ll_ra_count_put(ll_i2sbi(inode), 1);
 
 	if (ioret == 0)  {
+		/**
+		 * cp_defer_uptodate is used for readahead page, and the
+		 * vmpage Uptodate bit is deferred to set in ll_readpage/
+		 * ll_io_read_page.
+		 */
 		if (!cp->cp_defer_uptodate)
 			SetPageUptodate(vmpage);
 	} else if (cp->cp_defer_uptodate) {
fs/lustre/obdclass/cl_page.c +28 -9
index 7011235..3bc1a9b 100644
@@ -725,16 +725,35 @@ static void __cl_page_delete(const struct lu_env *env, struct cl_page *cp)
 		LASSERT(PageLocked(vmpage));
 		LASSERT((struct cl_page *)vmpage->private == cp);
 
-		/* Drop the reference count held in vvp_page_init */
-		refcount_dec(&cp->cp_ref);
-		ClearPagePrivate(vmpage);
-		vmpage->private = 0;
-
-		/*
-		 * The reference from vmpage to cl_page is removed,
-		 * but the reference back is still here. It is removed
-		 * later in cl_page_free().
+		/**
+		 * clear vmpage uptodate bit, since ll_read_ahead_pages()->
+		 * ll_read_ahead_page() could pick up this stale vmpage and
+		 * take it as uptodated.
 		 */
+		ClearPageUptodate(vmpage);
+		/**
+		 * vvp_io_kernel_fault()->ll_readpage() set cp_fault_ref
+		 * and need it to check cl_page to retry the page fault read.
+		 */
+		if (cp->cp_fault_ref) {
+			cp->cp_defer_detach = 1;
+			/**
+			 * get a vmpage reference, so that filemap_fault()
+			 * won't free it from pagecache.
+			 */
+			get_page(vmpage);
+		} else {
+			/* Drop the reference count held in vvp_page_init */
+			refcount_dec(&cp->cp_ref);
+			ClearPagePrivate(vmpage);
+			vmpage->private = 0;
+
+			/*
+			 * The reference from vmpage to cl_page is removed,
+			 * but the reference back is still here. It is removed
+			 * later in cl_page_free().
+			 */
+		}
 	}
 }
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#2 lore raw

PATCH 2/22 lustre: osc: Remove oap lock

In reply to James Simmons

From: Patrick Farrell <[email protected]>

The OAP lock is taken around setting the oap flags, but not any of the other fields in oap. As far as I can tell, this is just some cargo cult belief about locking - there's no reason for it.

Remove it entirely. (From the code, a queued spin lock appears to be 12 bytes on x86_64.)

WC-bug-id: https://jira.whamcloud.com/browse/LU-15619
Lustre-commit: b2274a716087fad24 ("LU-15619 osc: Remove oap lock")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46719

---
 fs/lustre/include/lustre_osc.h |  2 --
 fs/lustre/osc/osc_cache.c      | 11 -----------
 fs/lustre/osc/osc_io.c         |  8 ++------
 fs/lustre/osc/osc_page.c       |  5 -----
 4 files changed, 2 insertions(+), 24 deletions(-)
fs/lustre/include/lustre_osc.h +0 -2
index 2e8c184..a0f1afc 100644
@@ -88,8 +88,6 @@ struct osc_async_page {
 
 	struct ptlrpc_request	*oap_request;
 	struct osc_object	*oap_obj;
-
-	spinlock_t		oap_lock;
 };
 
 #define oap_page	oap_brw_page.pg
fs/lustre/osc/osc_cache.c +0 -11
index e563809..b5776a1 100644
@@ -1140,9 +1140,7 @@ static int osc_extent_make_ready(const struct lu_env *env,
 		rc = osc_make_ready(env, oap, OBD_BRW_WRITE);
 		switch (rc) {
 		case 0:
-			spin_lock(&oap->oap_lock);
 			oap->oap_async_flags |= ASYNC_READY;
-			spin_unlock(&oap->oap_lock);
 			break;
 		case -EALREADY:
 			LASSERT((oap->oap_async_flags & ASYNC_READY) != 0);
@@ -1165,9 +1163,7 @@ static int osc_extent_make_ready(const struct lu_env *env,
 			 "last_oap_count %d\n", last_oap_count);
 		LASSERT(last->oap_page_off + last_oap_count <= PAGE_SIZE);
 		last->oap_count = last_oap_count;
-		spin_lock(&last->oap_lock);
 		last->oap_async_flags |= ASYNC_COUNT_STABLE;
-		spin_unlock(&last->oap_lock);
 	}
 
 	/* for the rest of pages, we don't need to call osf_refresh_count()
@@ -1176,9 +1172,7 @@ static int osc_extent_make_ready(const struct lu_env *env,
 	list_for_each_entry(oap, &ext->oe_pages, oap_pending_item) {
 		if (!(oap->oap_async_flags & ASYNC_COUNT_STABLE)) {
 			oap->oap_count = PAGE_SIZE - oap->oap_page_off;
-			spin_lock(&last->oap_lock);
 			oap->oap_async_flags |= ASYNC_COUNT_STABLE;
-			spin_unlock(&last->oap_lock);
 		}
 	}
 
@@ -1866,9 +1860,7 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli,
 	}
 
 	/* As the transfer for this page is being done, clear the flags */
-	spin_lock(&oap->oap_lock);
 	oap->oap_async_flags = 0;
-	spin_unlock(&oap->oap_lock);
 
 	if (oap->oap_cmd & OBD_BRW_WRITE && xid > 0) {
 		spin_lock(&cli->cl_loi_list_lock);
@@ -2330,7 +2322,6 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
 	INIT_LIST_HEAD(&oap->oap_pending_item);
 	INIT_LIST_HEAD(&oap->oap_rpc_item);
 
-	spin_lock_init(&oap->oap_lock);
 	CDEBUG(D_INFO, "oap %p vmpage %p obj off %llu\n",
 	       oap, vmpage, oap->oap_obj_off);
 	return 0;
@@ -2619,9 +2610,7 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io,
 	if (rc)
 		goto out;
 
-	spin_lock(&oap->oap_lock);
 	oap->oap_async_flags |= ASYNC_READY | ASYNC_URGENT;
-	spin_unlock(&oap->oap_lock);
 
 	if (current->flags & PF_MEMALLOC)
 		ext->oe_memalloc = 1;
fs/lustre/osc/osc_io.c +2 -6
index aa8f61d..b9362d9 100644
@@ -192,12 +192,8 @@ int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios,
 			continue;
 		}
 
-		if (page->cp_type != CPT_TRANSIENT) {
-			spin_lock(&oap->oap_lock);
-			oap->oap_async_flags = ASYNC_URGENT | ASYNC_READY;
-			oap->oap_async_flags |= ASYNC_COUNT_STABLE;
-			spin_unlock(&oap->oap_lock);
-		}
+		if (page->cp_type != CPT_TRANSIENT)
+			oap->oap_async_flags = ASYNC_URGENT | ASYNC_READY | ASYNC_COUNT_STABLE;
 
 		osc_page_submit(env, opg, crt, brw_flags);
 		list_add_tail(&oap->oap_pending_item, &list);
fs/lustre/osc/osc_page.c +0 -5
index ba10ba3..667825a 100644
@@ -204,12 +204,7 @@ static void osc_page_clip(const struct lu_env *env,
 	opg->ops_from = from;
 	/* argument @to is exclusive, but @ops_to is inclusive */
 	opg->ops_to = to - 1;
-	/* This isn't really necessary for transient pages, but we also don't
-	 * call clip on transient pages often, so it's OK.
-	 */
-	spin_lock(&oap->oap_lock);
 	oap->oap_async_flags |= ASYNC_COUNT_STABLE;
-	spin_unlock(&oap->oap_lock);
 }
 
 static int osc_page_flush(const struct lu_env *env,
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#3 lore raw

PATCH 3/22 lnet: Don't modify uptodate peer with temp NI

In reply to James Simmons

From: Chris Horn <[email protected]>

When processing the config log it is possible that we attempt to add temp NIs after discovery has completed on a peer. These temp may not actually exist on the peer. Since discovery has already completed the peer is considered up-to-date and we can end up with incorrect peer entries. We shouldn't add temp NIs to a peer that is already up-to-date.

HPE-bug-id: LUS-10867
WC-bug-id: https://jira.whamcloud.com/browse/LU-15852
Lustre-commit: 8f718df474e453fbc ("LU-15852 lnet: Don't modify uptodate peer with temp NI")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47322

---
 net/lnet/lnet/peer.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/lnet/lnet/peer.c +8 -0
index d8d1857..52ad791 100644
@@ -1855,6 +1855,7 @@ struct lnet_peer_net *
 int
 lnet_add_peer_ni(struct lnet_nid *prim_nid, struct lnet_nid *nid, bool mr,
 		 bool temp)
+__must_hold(&the_lnet.ln_api_mutex)
 {
 	struct lnet_peer *lp = NULL;
 	struct lnet_peer_ni *lpni;
@@ -1906,6 +1907,13 @@ struct lnet_peer_net *
 		return -EPERM;
 	}
 
+	if (temp && lnet_peer_is_uptodate(lp)) {
+		CDEBUG(D_NET,
+		       "Don't add temporary peer NI for uptodate peer %s\n",
+		       libcfs_nidstr(&lp->lp_primary_nid));
+		return -EINVAL;
+	}
+
 	return lnet_peer_add_nid(lp, nid, flags);
 }
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#4 lore raw

PATCH 4/22 lustre: llite: Explicitly support .splice_write

In reply to James Simmons

From: Shaun Tancheff <[email protected]>

Linux commit v5.9-rc1-6-g36e2c7421f02
fs: don't allow splice read/write without explicit ops

Lustre supports splice_write and previously provide handlers for splice_read.
Explicitly use iter_file_splice_write, if it exists.

HPE-bug-id: LUS-11259
WC-bug-id: https://jira.whamcloud.com/browse/LU-16258
Lustre-commit: c619b6d6a54235cc0 ("LU-16258 llite: Explicitly support .splice_write")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48928

---
 fs/lustre/llite/file.c | 3 +++
 1 file changed, 3 insertions(+)
fs/lustre/llite/file.c +3 -0
index 350d5df..34a449e 100644
@@ -5564,6 +5564,7 @@ int ll_inode_permission(struct inode *inode, int mask)
 	.mmap			= ll_file_mmap,
 	.llseek			= ll_file_seek,
 	.splice_read		= generic_file_splice_read,
+	.splice_write		= iter_file_splice_write,
 	.fsync			= ll_fsync,
 	.flush			= ll_flush,
 	.fallocate		= ll_fallocate,
@@ -5578,6 +5579,7 @@ int ll_inode_permission(struct inode *inode, int mask)
 	.mmap			= ll_file_mmap,
 	.llseek			= ll_file_seek,
 	.splice_read		= generic_file_splice_read,
+	.splice_write		= iter_file_splice_write,
 	.fsync			= ll_fsync,
 	.flush			= ll_flush,
 	.flock			= ll_file_flock,
@@ -5595,6 +5597,7 @@ int ll_inode_permission(struct inode *inode, int mask)
 	.mmap			= ll_file_mmap,
 	.llseek			= ll_file_seek,
 	.splice_read		= generic_file_splice_read,
+	.splice_write		= iter_file_splice_write,
 	.fsync			= ll_fsync,
 	.flush			= ll_flush,
 	.flock			= ll_file_noflock,
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#5 lore raw

PATCH 5/22 lnet: o2iblnd: add verbose debug prints for rx/tx events

In reply to James Simmons

From: Serguei Smirnov <[email protected]>

Added/modified debug messages for syncing with mlnx driver debug output. On rx/tx events print message type, size and peer credits. Make printing of debug message on o2iblnd conn refcount change events compile-time optional. Add compile-time option for dumping detailed connection state info to net debug log.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16172
Lustre-commit: b4e06ff1e4856ce08 ("LU-16172 o2iblnd: add verbose debug prints for rx/tx events")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48600

---
 net/lnet/klnds/o2iblnd/o2iblnd.h    |  78 +++++++++++++++++-------
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 117 ++++++++++++++++++++++--------------
 2 files changed, 129 insertions(+), 66 deletions(-)
net/lnet/klnds/o2iblnd/o2iblnd.h +56 -22
index 56d486f..bef7a55 100644
@@ -588,28 +588,32 @@ static inline int kiblnd_timeout(void)
 	return dev->ibd_can_failover;
 }
 
-#define kiblnd_conn_addref(conn)					\
-do {									\
-	CDEBUG(D_NET, "conn[%p] (%d)++\n",				\
-	       (conn), atomic_read(&(conn)->ibc_refcount));		\
-	atomic_inc(&(conn)->ibc_refcount);				\
-} while (0)
-
-#define kiblnd_conn_decref(conn)					\
-do {									\
-	unsigned long flags;						\
-									\
-	CDEBUG(D_NET, "conn[%p] (%d)--\n",				\
-	       (conn), atomic_read(&(conn)->ibc_refcount));		\
-	LASSERT_ATOMIC_POS(&(conn)->ibc_refcount);			\
-	if (atomic_dec_and_test(&(conn)->ibc_refcount)) {		\
-		spin_lock_irqsave(&kiblnd_data.kib_connd_lock, flags);	\
-		list_add_tail(&(conn)->ibc_list,			\
-				  &kiblnd_data.kib_connd_zombies);	\
-		wake_up(&kiblnd_data.kib_connd_waitq);			\
-		spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags);\
-	}								\
-} while (0)
+static inline void kiblnd_conn_addref(struct kib_conn *conn)
+{
+#ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
+	CDEBUG(D_NET, "conn[%p] (%d)++\n",
+	       conn, atomic_read(&conn->ibc_refcount));
+#endif
+	atomic_inc(&(conn)->ibc_refcount);
+}
+
+static inline void kiblnd_conn_decref(struct kib_conn *conn)
+{
+	unsigned long flags;
+
+#ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
+	CDEBUG(D_NET, "conn[%p] (%d)--\n",
+	       conn, atomic_read(&conn->ibc_refcount));
+#endif
+	LASSERT_ATOMIC_POS(&conn->ibc_refcount);
+	if (atomic_dec_and_test(&conn->ibc_refcount)) {
+		spin_lock_irqsave(&kiblnd_data.kib_connd_lock, flags);
+		list_add_tail(&conn->ibc_list,
+			      &kiblnd_data.kib_connd_zombies);
+		wake_up(&kiblnd_data.kib_connd_waitq);
+		spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags);
+	}
+}
 
 void kiblnd_destroy_peer(struct kref *kref);
 
@@ -971,3 +975,33 @@ void kiblnd_pack_msg(struct lnet_ni *ni, struct kib_msg *msg, int version,
 int kiblnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 		int delayed, struct iov_iter *to, unsigned int rlen);
 unsigned int kiblnd_get_dev_prio(struct lnet_ni *ni, unsigned int dev_idx);
+
+#define kiblnd_dump_conn_dbg(conn)			\
+({							\
+	if (conn && conn->ibc_cmid)			\
+		CDEBUG(D_NET,				\
+		       "conn %p state %d nposted %d/%d c/o/r %d/%d/%d ce %d : cm_id %p qp_num 0x%x device_name %s\n",    \
+		       conn,				\
+		       conn->ibc_state,			\
+		       conn->ibc_noops_posted,		\
+		       conn->ibc_nsends_posted,		\
+		       conn->ibc_credits,		\
+		       conn->ibc_outstanding_credits,	\
+		       conn->ibc_reserved_credits,	\
+		       conn->ibc_comms_error,		\
+		       conn->ibc_cmid,			\
+		       conn->ibc_cmid->qp ? conn->ibc_cmid->qp->qp_num : 0,	\
+		       conn->ibc_cmid->qp ? (conn->ibc_cmid->qp->device ? dev_name(&conn->ibc_cmid->qp->device->dev) : "NULL") : "NULL");	\
+	else if (conn)                                  \
+		CDEBUG(D_NET,				\
+		       "conn %p state %d nposted %d/%d c/o/r %d/%d/%d ce %d : cm_id NULL\n",	\
+		       conn,				\
+		       conn->ibc_state,			\
+		       conn->ibc_noops_posted,		\
+		       conn->ibc_nsends_posted,		\
+		       conn->ibc_credits,		\
+		       conn->ibc_outstanding_credits,	\
+		       conn->ibc_reserved_credits,	\
+		       conn->ibc_comms_error		\
+		       );				\
+})
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +73 -44

273 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#6 lore raw

PATCH 6/22 lnet: use Netlink to support old and new NI APIs.

In reply to James Simmons

The LNet layer uses two different sets of ioctls. One ioctl set is for Multi-Rail and the other is an older API. Both are in heavy use and with the upcoming support for IPv6 we are looking at an explosion of ioctls. The solution is to move the LNet layer to Netlink which can easily handle all the differences between the APIs. This also resolves a long standing issue of the user land API constantly changing in a non-compatible way with previous versions.

This patch unifies the handling the LNet NI to use Netlink and is fully aware of the new large NID addressing.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10003
Lustre-commit: 8f8f6e2f36e56e53e ("LU-10003 lnet: use Netlink to support old and new NI APIs.")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48814

---
 include/linux/lnet/lib-lnet.h          |   6 +-
 include/linux/lnet/lib-types.h         | 103 +++++
 include/uapi/linux/lnet/libcfs_ioctl.h |   2 +-
 include/uapi/linux/lnet/lnet-dlc.h     |  23 +
 include/uapi/linux/lnet/lnet-types.h   |  15 +
 net/lnet/klnds/o2iblnd/o2iblnd.c       |  88 +++-
 net/lnet/klnds/o2iblnd/o2iblnd.h       |  16 +
 net/lnet/klnds/socklnd/socklnd.c       |  37 +-
 net/lnet/klnds/socklnd/socklnd.h       |   9 +
 net/lnet/lnet/api-ni.c                 | 779 +++++++++++++++++++++++++++++++--
 net/lnet/lnet/config.c                 |   4 +-
 net/lnet/lnet/module.c                 |  42 +-
 12 files changed, 1054 insertions(+), 70 deletions(-)
include/linux/lnet/lib-lnet.h +4 -2
index bd4acef..13ce2bf 100644
@@ -457,6 +457,7 @@ struct lnet_ni *
 struct lnet_ni *
 lnet_ni_alloc_w_cpt_array(struct lnet_net *net, u32 *cpts, u32 ncpts,
 			  char *iface);
+int lnet_ni_add_interface(struct lnet_ni *ni, char *iface);
 
 static inline int
 lnet_nid2peerhash(struct lnet_nid *nid)
@@ -622,8 +623,9 @@ void lnet_rtr_transfer_to_peer(struct lnet_peer *src,
 struct lnet_remotenet *lnet_find_rnet_locked(u32 net);
 int lnet_dyn_add_net(struct lnet_ioctl_config_data *conf);
 int lnet_dyn_del_net(u32 net);
-int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf);
-int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf);
+int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf, u32 net,
+		    struct lnet_ioctl_config_lnd_tunables *tun);
+int lnet_dyn_del_ni(struct lnet_nid *nid);
 int lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason);
 struct lnet_net *lnet_get_net_locked(u32 net_id);
 void lnet_net_clr_pref_rtrs(struct lnet_net *net);
include/linux/lnet/lib-types.h +103 -0

115 lines not on this page · raw message

include/uapi/linux/lnet/libcfs_ioctl.h +1 -1
index f2ae76c..89ac075 100644
@@ -94,7 +94,7 @@ struct libcfs_ioctl_data {
 #define IOC_LIBCFS_MARK_DEBUG		_IOWR('e', 32, IOCTL_LIBCFS_TYPE)
 /* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */
 /* lnet ioctls */
-#define IOC_LIBCFS_GET_NI		_IOWR('e', 50, IOCTL_LIBCFS_TYPE)
+/* IOC_LIBCFS_GET_NI obsolete in 2.16, was _IOWR('e', 50, IOCTL_LIBCFS_TYPE) */
 #define IOC_LIBCFS_FAIL_NID		_IOWR('e', 51, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_NOTIFY_ROUTER	_IOWR('e', 55, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_UNCONFIGURE		_IOWR('e', 56, IOCTL_LIBCFS_TYPE)
include/uapi/linux/lnet/lnet-dlc.h +23 -0
index 415968a..58697c1 100644
@@ -49,6 +49,29 @@
 #define __user
 #endif
 
+#define LNET_GENL_NAME		"lnet"
+#define LNET_GENL_VERSION	0x05
+
+/* enum lnet_commands	      - Supported core LNet Netlink commands
+ *
+ *  @LNET_CMD_UNSPEC:		unspecified command to catch errors
+ *
+ *  @LNET_CMD_NETS:		command to manage the LNet networks
+ */
+enum lnet_commands {
+	LNET_CMD_UNSPEC		= 0,
+
+	LNET_CMD_CONFIGURE	= 1,
+	LNET_CMD_NETS		= 2,
+	LNET_CMD_PEERS		= 3,
+	LNET_CMD_ROUTES		= 4,
+	LNET_CMD_CONNS		= 5,
+
+	__LNET_CMD_MAX_PLUS_ONE
+};
+
+#define LNET_CMD_MAX (__LNET_CMD_MAX_PLUS_ONE - 1)
+
 /*
  * To allow for future enhancements to extend the tunables
  * add a hdr to this structure, so that the version can be set
include/uapi/linux/lnet/lnet-types.h +15 -0
index 5a2ea45..304add9 100644
@@ -37,8 +37,12 @@
 #include <linux/types.h>
 #include <linux/lnet/lnet-idl.h>
 
+#include <linux/types.h>
 #include <linux/string.h>
 #include <asm/byteorder.h>
+#ifndef __KERNEL__
+#include <stdbool.h>
+#endif
 
 /** \addtogroup lnet
  * @{
@@ -111,6 +115,17 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num)
 
 #define LNET_NET_ANY LNET_NIDNET(LNET_NID_ANY)
 
+/* check for address set */
+static inline bool nid_addr_is_set(const struct lnet_nid *nid)
+{
+	int sum = 0, i;
+
+	for (i = 0; i < NID_ADDR_BYTES(nid); i++)
+		sum |= nid->nid_addr[i];
+
+	return sum ? true : false;
+}
+
 static inline int nid_is_nid4(const struct lnet_nid *nid)
 {
 	return NID_ADDR_BYTES(nid) == 4;
net/lnet/klnds/o2iblnd/o2iblnd.c +87 -1

106 lines not on this page · raw message

net/lnet/klnds/o2iblnd/o2iblnd.h +16 -0
index bef7a55..e3c069b 100644
@@ -65,6 +65,22 @@
 #include <linux/lnet/lib-lnet.h>
 #include "o2iblnd-idl.h"
 
+enum kiblnd_ni_lnd_tunables_attr {
+	LNET_NET_O2IBLND_TUNABLES_ATTR_UNSPEC = 0,
+
+	LNET_NET_O2IBLND_TUNABLES_ATTR_HIW_PEER_CREDITS,
+	LNET_NET_O2IBLND_TUNABLES_ATTR_CONCURRENT_SENDS,
+	LNET_NET_O2IBLND_TUNABLES_ATTR_MAP_ON_DEMAND,
+	LNET_NET_O2IBLND_TUNABLES_ATTR_FMR_POOL_SIZE,
+	LNET_NET_O2IBLND_TUNABLES_ATTR_FMR_FLUSH_TRIGGER,
+	LNET_NET_O2IBLND_TUNABLES_ATTR_FMR_CACHE,
+	LNET_NET_O2IBLND_TUNABLES_ATTR_NTX,
+	LNET_NET_O2IBLND_TUNABLES_ATTR_CONNS_PER_PEER,
+	__LNET_NET_O2IBLND_TUNABLES_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_NET_O2IBLND_TUNABLES_ATTR_MAX (__LNET_NET_O2IBLND_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
+
 #define IBLND_PEER_HASH_BITS		7	/* log2 of # peer_ni lists */
 
 #define IBLND_N_SCHED			2
net/lnet/klnds/socklnd/socklnd.c +35 -2
index e8f8020..21fccfa 100644
@@ -840,6 +840,33 @@ struct ksock_peer_ni *
 	return 0;
 }
 
+static const struct ln_key_list ksocknal_tunables_keys = {
+	.lkl_maxattr			= LNET_NET_SOCKLND_TUNABLES_ATTR_MAX,
+	.lkl_list			= {
+		[LNET_NET_SOCKLND_TUNABLES_ATTR_CONNS_PER_PEER]  = {
+			.lkp_value	= "conns_per_peer",
+			.lkp_data_type	= NLA_S32
+		},
+	},
+};
+
+static int
+ksocknal_nl_set(int cmd, struct nlattr *attr, int type, void *data)
+{
+	struct lnet_lnd_tunables *tunables = data;
+
+	if (cmd != LNET_CMD_NETS)
+		return -EOPNOTSUPP;
+
+	if (type != LNET_NET_SOCKLND_TUNABLES_ATTR_CONNS_PER_PEER ||
+	    nla_type(attr) != LN_SCALAR_ATTR_INT_VALUE)
+		return -EINVAL;
+
+	tunables->lnd_tun_u.lnd_sock.lnd_conns_per_peer = nla_get_s64(attr);
+
+	return 0;
+}
+
 static int
 ksocknal_connecting(struct ksock_conn_cb *conn_cb, struct sockaddr *sa)
 {
@@ -2520,16 +2547,20 @@ static int ksocknal_inetaddr_event(struct notifier_block *unused,
 	ksi = &net->ksnn_interface;
 	/* Use the first discovered interface or look in the list */
 	if (ni->ni_interface) {
-		for (i = 0; i < rc; i++)
+		for (i = 0; i < rc; i++) {
 			if (strcmp(ifaces[i].li_name, ni->ni_interface) == 0)
 				break;
-
+		}
 		/* ni_interface doesn't contain the interface we want */
 		if (i == rc) {
 			CERROR("ksocklnd: failed to find interface %s\n",
 			       ni->ni_interface);
 			goto fail_1;
 		}
+	} else {
+		rc = lnet_ni_add_interface(ni, ifaces[i].li_name);
+		if (rc < 0)
+			CWARN("ksocklnd failed to allocate ni_interface\n");
 	}
 
 	ni->ni_dev_cpt = ifaces[i].li_cpt;
@@ -2590,6 +2621,8 @@ static void __exit ksocklnd_exit(void)
 	.lnd_recv		= ksocknal_recv,
 	.lnd_notify_peer_down	= ksocknal_notify_gw_down,
 	.lnd_accept		= ksocknal_accept,
+	.lnd_nl_set		= ksocknal_nl_set,
+	.lnd_keys		= &ksocknal_tunables_keys,
 };
 
 static int __init ksocklnd_init(void)
net/lnet/klnds/socklnd/socklnd.h +9 -0
index bb68a3d..50892b1 100644
@@ -74,6 +74,15 @@
 # define SOCKNAL_RISK_KMAP_DEADLOCK	1
 #endif
 
+enum ksocklnd_ni_lnd_tunables_attr {
+	LNET_NET_SOCKLND_TUNABLES_ATTR_UNSPEC = 0,
+
+	LNET_NET_SOCKLND_TUNABLES_ATTR_CONNS_PER_PEER,
+	__LNET_NET_SOCKLND_TUNABLES_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_NET_SOCKLND_TUNABLES_ATTR_MAX (__LNET_NET_SOCKLND_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
+
 /* per scheduler state */
 struct ksock_sched {				/* per scheduler state */
 	spinlock_t		kss_lock;	/* serialise */
net/lnet/lnet/api-ni.c +734 -45

894 lines not on this page · raw message

net/lnet/lnet/config.c +2 -2
index cebc725..4b2d776 100644
@@ -367,8 +367,7 @@ struct lnet_net *
 	return net;
 }
 
-static int
-lnet_ni_add_interface(struct lnet_ni *ni, char *iface)
+int lnet_ni_add_interface(struct lnet_ni *ni, char *iface)
 {
 	if (!ni)
 		return -ENOMEM;
@@ -395,6 +394,7 @@ struct lnet_net *
 
 	return 0;
 }
+EXPORT_SYMBOL(lnet_ni_add_interface);
 
 static struct lnet_ni *
 lnet_ni_alloc_common(struct lnet_net *net, char *iface)
net/lnet/lnet/module.c +25 -17

73 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#7 lore raw

PATCH 7/22 lustre: obdclass: improve precision of wakeups for mod_rpcs

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

There is a limit of the number of in-flight mod rpcs with a complication that a 'close' rpc is always permitted if there are no other close rpcs in flight, even if that would exceed the limit.

When a non-close-request complete, we just wake the first waiting request and assume it will use the slot we released. When a close-request completes, the first waiting request may not find a slot if the close was using the 'extra' slot. So in that case we wake all waiting requests and let them fit it out. This is wasteful and unfair.

To correct this we revise the wait/wake approach to use a dedicated wakeup function which atomically checks if a given task can proceed, and updates the counters when permission to proceed is given. This means that once a task has been woken, it has already been accounted and it can proceed.

To minimise locking, cl_mod_rpcs_lock is discarded and cl_mod_rpcs_waitq.lock is used to protect the counters. For the fast-path where the max has not been reached, this means we take and release that spinlock just once. We call wake_up_locked while still holding the lock, and if that woke the process, then we don't drop the spinlock to wait, but proceed directly to the remainder of the task.

When the last 'close' rpc completes, the wake function will iterate the whole wait queue until it finds a task waiting to submit a close request. When any other rpc completes, the queue will only be searched until the maximum is reached.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15947
Lustre-commit: 5243630b09d22e0b5 ("LU-15947 obdclass: improve precision of wakeups for mod_rpcs")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/44041

---
 fs/lustre/include/obd.h     |   1 -
 fs/lustre/ldlm/ldlm_lib.c   |   1 -
 fs/lustre/obdclass/genops.c | 158 ++++++++++++++++++++++++--------------------
 3 files changed, 88 insertions(+), 72 deletions(-)
fs/lustre/include/obd.h +0 -1
index 16f66ea..56e5641 100644
@@ -326,7 +326,6 @@ struct client_obd {
 	/* modify rpcs in flight
 	 * currently used for metadata only
 	 */
-	spinlock_t		cl_mod_rpcs_lock;
 	u16			cl_max_mod_rpcs_in_flight;
 	u16			cl_mod_rpcs_in_flight;
 	u16			cl_close_rpcs_in_flight;
fs/lustre/ldlm/ldlm_lib.c +0 -1
index 08aff4f..e4262c3 100644
@@ -444,7 +444,6 @@ int client_obd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	else
 		cli->cl_max_rpcs_in_flight = OBD_MAX_RIF_DEFAULT;
 
-	spin_lock_init(&cli->cl_mod_rpcs_lock);
 	spin_lock_init(&cli->cl_mod_rpcs_hist.oh_lock);
 	cli->cl_max_mod_rpcs_in_flight = 0;
 	cli->cl_mod_rpcs_in_flight = 0;
fs/lustre/obdclass/genops.c +88 -70

227 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#8 lore raw

PATCH 8/22 lnet: allow ping packet to contain large nids

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The ping packet has an array of fixed-size status entries that only have room for a 4-byte-address nid.

This patches adds a feature flag which activates a list of variable sized entries after the initial array.

Each entry contains a 4-byte status and then a nid, rounded to a multiple of 4 bytes. The total number of bytes of the ping_info (header, first array, subsequent list) is stored in the ns_unused field of the first entry in the array.

The user-space interfaces only see the initial array.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: db0fb8f2b649c0c38 ("LU-10391 lnet: allow ping packet to contain large nids")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/44628

---
 include/linux/lnet/lib-types.h     |  39 +++++++++++
 include/uapi/linux/lnet/lnet-idl.h |  58 +++++++++++-----
 net/lnet/lnet/api-ni.c             | 131 +++++++++++++++++++++++--------------
 net/lnet/lnet/lib-msg.c            |   2 +-
 4 files changed, 165 insertions(+), 65 deletions(-)
include/linux/lnet/lib-types.h +39 -0
index 2d3b044..73d962f 100644
@@ -684,6 +684,45 @@ struct lnet_ping_buffer {
 #define LNET_PING_INFO_TO_BUFFER(PINFO)	\
 	container_of((PINFO), struct lnet_ping_buffer, pb_info)
 
+static inline int
+lnet_ping_sts_size(const struct lnet_nid *nid)
+{
+	int size;
+
+	if (nid_is_nid4(nid))
+		return sizeof(struct lnet_ni_status);
+
+	size = offsetof(struct lnet_ni_large_status, ns_nid) +
+	       NID_BYTES(nid);
+
+	return round_up(size, 4);
+}
+
+static inline struct lnet_ni_large_status *
+lnet_ping_sts_next(const struct lnet_ni_large_status *nis)
+{
+	return (void *)nis + lnet_ping_sts_size(&nis->ns_nid);
+}
+
+static inline bool
+lnet_ping_at_least_two_entries(const struct lnet_ping_info *pi)
+{
+	/* Return true if we have at lease two entries.  There is always a
+	 * least one, a 4-byte lo0 interface.
+	 */
+	struct lnet_ni_large_status *lns;
+
+	if ((pi->pi_features & LNET_PING_FEAT_LARGE_ADDR) == 0)
+		return pi->pi_nnis <= 2;
+	/* There is at least 1 large-address entry */
+	if (pi->pi_nnis != 1)
+		return false;
+	lns = (void *)&pi->pi_ni[1];
+	lns = lnet_ping_sts_next(lns);
+
+	return ((void *)pi + lnet_ping_info_size(pi) <= (void *)lns);
+}
+
 struct lnet_nid_list {
 	struct list_head nl_list;
 	struct lnet_nid nl_nid;
include/uapi/linux/lnet/lnet-idl.h +43 -15

93 lines not on this page · raw message

net/lnet/lnet/api-ni.c +82 -49

222 lines not on this page · raw message

net/lnet/lnet/lib-msg.c +1 -1
index 9fb001e..898d867 100644
@@ -831,7 +831,7 @@
 		 * I only have a single (non-lolnd) interface.
 		 */
 		pi = &the_lnet.ln_ping_target->pb_info;
-		if (pi->pi_nnis <= 2) {
+		if (lnet_ping_at_least_two_entries(pi)) {
 			handle_local_health = false;
 			attempt_local_resend = false;
 		}
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#9 lore raw

PATCH 9/22 lustre: llog: skip bad records in llog

In reply to James Simmons

From: Mikhail Pershin <[email protected]>

This patch is further development of idea to skip bad corrupted) llogs data. If llog has fixed-size records then it is possible to skip one record but not rest of llog block.

Patch also fixes the skipping to the next chunk:
- make sure to skip to the next block for partial chunk or it causes the same block re-read.
- handle index == 0 as goal for the llog_next_block() as expected exclusion and just return requested block
- set new index after block was skipped to the first one in block
- don't create fake padding record in llog_osd_next_block() as the caller can handle it and would know about
- restore test_8 functionality to check corruption handling

Fixes b79e7c205e40 ("lustre: llog: add synchronization for the last record")

WC-bug-id: https://jira.whamcloud.com/browse/LU-16203
Lustre-commit: cf121b16685fe2a27 ("LU-16203 llog: skip bad records in llog")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48776

---
 fs/lustre/obdclass/llog.c | 86 ++++++++++++++++++++++++++++-------------------
 1 file changed, 52 insertions(+), 34 deletions(-)
fs/lustre/obdclass/llog.c +52 -34
index eb8f7e5..90bb8bd 100644
@@ -233,27 +233,26 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
 }
 EXPORT_SYMBOL(llog_init_handle);
 
+#define LLOG_ERROR_REC(lgh, rec, format, a...) \
+	CERROR("%s: "DFID" rec type=%x idx=%u len=%u, " format "\n", \
+	       loghandle2name(lgh), PLOGID(&lgh->lgh_id), (rec)->lrh_type, \
+	       (rec)->lrh_index, (rec)->lrh_len, ##a)
+
 int llog_verify_record(const struct llog_handle *llh, struct llog_rec_hdr *rec)
 {
 	int chunk_size = llh->lgh_hdr->llh_hdr.lrh_len;
 
-	if (rec->lrh_len == 0 || rec->lrh_len > chunk_size) {
-		CERROR("%s: record is too large: %d > %d\n",
-		       loghandle2name(llh), rec->lrh_len, chunk_size);
-		return -EINVAL;
-	}
-	if (rec->lrh_index >= LLOG_HDR_BITMAP_SIZE(llh->lgh_hdr)) {
-		CERROR("%s: index is too high: %d\n",
-		       loghandle2name(llh), rec->lrh_index);
-		return -EINVAL;
-	}
-	if ((rec->lrh_type & LLOG_OP_MASK) != LLOG_OP_MAGIC) {
-		CERROR("%s: magic %x is bad\n",
-		       loghandle2name(llh), rec->lrh_type);
-		return -EINVAL;
-	}
+	if ((rec->lrh_type & LLOG_OP_MASK) != LLOG_OP_MAGIC)
+		LLOG_ERROR_REC(llh, rec, "magic is bad");
+	else if (rec->lrh_len == 0 || rec->lrh_len > chunk_size)
+		LLOG_ERROR_REC(llh, rec, "bad record len, chunk size is %d",
+			       chunk_size);
+	else if (rec->lrh_index >= LLOG_HDR_BITMAP_SIZE(llh->lgh_hdr))
+		LLOG_ERROR_REC(llh, rec, "index is too high");
+	else
+		return 0;
 
-	return 0;
+	return -EINVAL;
 }
 
 static inline bool llog_is_index_skipable(int idx, struct llog_log_hdr *llh,
@@ -278,7 +277,6 @@ static int llog_process_thread(void *arg)
 	int saved_index = 0;
 	int last_called_index = 0;
 	bool repeated = false;
-	bool refresh_idx = false;
 
 	if (!llh)
 		return -EINVAL;
@@ -346,6 +344,11 @@ static int llog_process_thread(void *arg)
 			rc = 0;
 			goto out;
 		}
+		/* EOF while trying to skip to the next chunk */
+		if (!index && rc == -EBADR) {
+			rc = 0;
+			goto out;
+		}
 		if (rc)
 			goto out;
 
@@ -377,6 +380,15 @@ static int llog_process_thread(void *arg)
 			CDEBUG(D_OTHER, "after swabbing, type=%#x idx=%d\n",
 			       rec->lrh_type, rec->lrh_index);
 
+			/* start with first rec if block was skipped */
+			if (!index) {
+				CDEBUG(D_OTHER,
+				       "%s: skipping to the index %u\n",
+				       loghandle2name(loghandle),
+				       rec->lrh_index);
+				index = rec->lrh_index;
+			}
+
 			if (index == (synced_idx + 1) &&
 			    synced_idx == LLOG_HDR_TAIL(llh)->lrt_index) {
 				rc = 0;
@@ -399,11 +411,15 @@ static int llog_process_thread(void *arg)
 			 * it turns to
 			 * lh_last_idx != LLOG_HDR_TAIL(llh)->lrt_index
 			 * This exception is working for catalog only.
+			 * The last check is for the partial chunk boundary,
+			 * if it is reached then try to re-read for possible
+			 * new records once.
 			 */
 			if ((index == lh_last_idx && synced_idx != index) ||
 			    (index == (lh_last_idx + 1) &&
 			     lh_last_idx != LLOG_HDR_TAIL(llh)->lrt_index) ||
-			    (rec->lrh_index == 0 && !repeated)) {
+			    (((char *)rec - buf >= cur_offset - chunk_offset) &&
+			    !repeated)) {
 				/* save offset inside buffer for the re-read */
 				buf_offset = (char *)rec - (char *)buf;
 				cur_offset = chunk_offset;
@@ -415,24 +431,27 @@ static int llog_process_thread(void *arg)
 				CDEBUG(D_OTHER, "synced_idx: %d\n", synced_idx);
 				goto repeat;
 			}
-
 			repeated = false;
 
 			rc = llog_verify_record(loghandle, rec);
 			if (rc) {
-				CERROR("%s: invalid record in llog "DFID" record for index %d/%d: rc = %d\n",
-				       loghandle2name(loghandle),
-				       PLOGID(&loghandle->lgh_id),
-				       rec->lrh_len, index, rc);
+				CDEBUG(D_OTHER, "invalid record at index %d\n",
+				       index);
 				/*
-				 * the block seem to be corrupted, let's try
-				 * with the next one. reset rc to go to the
-				 * next chunk.
+				 * for fixed-sized llogs we can skip one record
+				 * by using llh_size from llog header.
+				 * Otherwise skip the next llog chunk.
 				 */
-				refresh_idx = true;
-				index = 0;
 				rc = 0;
-				goto repeat;
+				if (llh->llh_flags & LLOG_F_IS_FIXSIZE) {
+					rec->lrh_len = llh->llh_size;
+					goto next_rec;
+				}
+				/* make sure that is always next block */
+				cur_offset = chunk_offset + chunk_size;
+				/* no goal to find, just next block to read */
+				index = 0;
+				break;
 			}
 
 			if (rec->lrh_index < index) {
@@ -446,10 +465,9 @@ static int llog_process_thread(void *arg)
 				 * gap which can be result of old bugs, just
 				 * keep going
 				 */
-				CERROR("%s: "DFID" index %u, expected %u\n",
-				       loghandle2name(loghandle),
-				       PLOGID(&loghandle->lgh_id),
-				       rec->lrh_index, index);
+				LLOG_ERROR_REC(loghandle, rec,
+					       "gap in index, expected %u",
+					       index);
 				index = rec->lrh_index;
 			}
 
@@ -470,7 +488,7 @@ static int llog_process_thread(void *arg)
 				if (rc)
 					goto out;
 			}
-
+next_rec:
 			/* exit if the last index is reached */
 			if (index >= last_index) {
 				rc = 0;
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#10 lore raw

PATCH 10/22 lnet: fix build issue when IPv6 is disabled.

In reply to James Simmons

struct inet6_dev and struct inet6_ifaddr are not defined if IPv6 is not configured for the Linux kernel.

Fixes 351a6df78c3 ("lnet: support IPv6 in lnet_inet_enumerate()")

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 896cd5b7bcf94d4fd ("LU-10391 lnet: fix build issue when IPv6 is disabled.")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48990

---
 net/lnet/lnet/config.c | 2 ++
 1 file changed, 2 insertions(+)
net/lnet/lnet/config.c +2 -0
index 4b2d776..5bfae4e 100644
@@ -1501,8 +1501,10 @@ int lnet_inet_enumerate(struct lnet_inetdev **dev_list, struct net *ns, bool v6)
 		int flags = dev_get_flags(dev);
 		const struct in_ifaddr *ifa;
 		struct in_device *in_dev;
+#if IS_ENABLED(CONFIG_IPV6)
 		struct inet6_dev *in6_dev;
 		const struct inet6_ifaddr *ifa6;
+#endif
 		int node_id;
 		int cpt;
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#11 lore raw

PATCH 11/22 lustre: obdclass: fill jobid in a safe way

In reply to James Simmons

From: Lei Feng <[email protected]>

Ensure jobid_interpret_string() fills jobid in an atomic way. Make sure we use the proper length. The Linux native client got this mostly right.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16251
Lustre-commit: 9a0a89520e8b57bd6 ("LU-16251 obdclass: fill jobid in a safe way")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48915

---
 fs/lustre/obdclass/jobid.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
fs/lustre/obdclass/jobid.c +7 -6
index da1af51..77ea5b2 100644
@@ -308,7 +308,8 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid,
  */
 int lustre_get_jobid(char *jobid, size_t joblen)
 {
-	char tmp_jobid[LUSTRE_JOBID_SIZE] = "";
+	char id[LUSTRE_JOBID_SIZE] = "";
+	int len = min_t(int, joblen, LUSTRE_JOBID_SIZE);
 
 	if (unlikely(joblen < 2)) {
 		if (joblen == 1)
@@ -324,14 +325,14 @@ int lustre_get_jobid(char *jobid, size_t joblen)
 	if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0 ||
 	    strnstr(obd_jobid_name, "%j", LUSTRE_JOBID_SIZE)) {
 		int rc2 = jobid_interpret_string(obd_jobid_name,
-						 tmp_jobid, joblen);
+						 id, len);
 		if (!rc2)
 			goto out_cache_jobid;
 	}
 
 	/* Use process name + fsuid as jobid */
 	if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {
-		snprintf(tmp_jobid, LUSTRE_JOBID_SIZE, "%s.%u",
+		snprintf(id, LUSTRE_JOBID_SIZE, "%s.%u",
 			 current->comm,
 			 from_kuid(&init_user_ns, current_fsuid()));
 		goto out_cache_jobid;
@@ -343,7 +344,7 @@ int lustre_get_jobid(char *jobid, size_t joblen)
 		rcu_read_lock();
 		jid = jobid_current();
 		if (jid)
-			strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
+			strlcpy(id, jid, sizeof(id));
 		rcu_read_unlock();
 		goto out_cache_jobid;
 	}
@@ -352,8 +353,8 @@ int lustre_get_jobid(char *jobid, size_t joblen)
 
 out_cache_jobid:
 	/* Only replace the job ID if it changed. */
-	if (strcmp(jobid, tmp_jobid) != 0)
-		strcpy(jobid, tmp_jobid);
+	if (strcmp(jobid, id) != 0)
+		strcpy(jobid, id);
 
 	return 0;
 }
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#12 lore raw

PATCH 12/22 lustre: llite: remove linefeed from LDLM_DEBUG

In reply to James Simmons

From: Alex Zhuravlev <[email protected]>

to make the corresponding messages single-line

WC-bug-id: https://jira.whamcloud.com/browse/LU-15825
Lustre-commit: 93784852c8f20b27c ("LU-15825 ldlm: remove linefeed from LDLM_DEBUG")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47219

---
 fs/lustre/llite/namei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/lustre/llite/namei.c +1 -1
index 5ac634c..93abec8 100644
@@ -233,7 +233,7 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, u64 to_cancel)
 		 */
 		if (lock->l_resource->lr_lvb_inode)
 			LDLM_DEBUG(lock,
-				   "can't take inode for the lock (%sevicted)\n",
+				   "can't take inode for the lock (%sevicted)",
 				   lock->l_resource->lr_lvb_inode->i_state &
 				   I_FREEING ? "" : "not ");
 		return;
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#13 lore raw

PATCH 13/22 lnet: selftest: migrate LNet selftest session handling to Netlink

In reply to James Simmons

The currently LNet selftest ioctl interface has a few issues which can be resolved using Netlink. The first is the current API using struct list_head is disliked by the Linux VFS maintainers. While we technically don't need to use the struct list_head directly its still confusing and passing pointers from userland to kernel space is also frowned on.

Second issue that is exposed with debug kernels is that ioctl handling done with the lstcon_ioctl_handler can easily end up in a might_sleep state.

The new Netlink work is also needed for the IPv6 support. Update the session handling to work with large NIDs. Internally use struct lst_session_id which supports large NIDs instead of struct lst_sid.

Lastly we have been wanting YAMl handling with LNet selftest (LU-10975) which comes naturally with this work.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8915

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/43298

---
 include/uapi/linux/lnet/lnetst.h |  21 ++-
 net/lnet/selftest/conctl.c       | 349 +++++++++++++++++++++++++++++++--------
 net/lnet/selftest/conrpc.c       |  28 +++-
 net/lnet/selftest/console.c      |  81 +++------
 net/lnet/selftest/console.h      |  68 ++++----
 net/lnet/selftest/framework.c    |  43 +++--
 net/lnet/selftest/selftest.h     |  78 +++++++--
 7 files changed, 477 insertions(+), 191 deletions(-)
include/uapi/linux/lnet/lnetst.h +19 -2
index af0435f1..d04496d 100644
@@ -84,8 +84,6 @@ struct lst_sid {
 	__s64		ses_stamp;	/* time stamp */
 };					/*** session id */
 
-extern struct lst_sid LST_INVALID_SID;
-
 struct lst_bid {
 	__u64	bat_id;		/* unique id in session */
 };				/*** batch id (group of tests) */
@@ -577,4 +575,23 @@ struct sfw_counters {
 	__u32 ping_errors;
 } __packed;
 
+#define LNET_SELFTEST_GENL_NAME		"lnet_selftest"
+#define LNET_SELFTEST_GENL_VERSION	0x1
+
+/* enum lnet_selftest_commands	      - Supported core LNet Selftest Netlink
+ *					commands
+ *
+ * @LNET_SELFTEST_CMD_UNSPEC:		unspecified command to catch errors
+ * @LNET_SELFTEST_CMD_SESSIONS:		command to manage sessions
+ */
+enum lnet_selftest_commands {
+	LNET_SELFTEST_CMD_UNSPEC	= 0,
+
+	LNET_SELFTEST_CMD_SESSIONS	= 1,
+
+	__LNET_SELFTEST_CMD_MAX_PLUS_ONE,
+};
+
+#define LNET_SELFTEST_CMD_MAX (__LNET_SELFTEST_CMD_MAX_PLUS_ONE - 1)
+
 #endif
net/lnet/selftest/conctl.c +283 -66

366 lines not on this page · raw message

net/lnet/selftest/conrpc.c +21 -7
index 0170219..8096c46 100644
@@ -602,7 +602,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 			return rc;
 
 		msrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.mksn_reqst;
-		msrq->mksn_sid = console_session.ses_id;
+		msrq->mksn_sid.ses_stamp = console_session.ses_id.ses_stamp;
+		msrq->mksn_sid.ses_nid =
+			lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
 		msrq->mksn_force = console_session.ses_force;
 		strlcpy(msrq->mksn_name, console_session.ses_name,
 			sizeof(msrq->mksn_name));
@@ -615,7 +617,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 			return rc;
 
 		rsrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.rmsn_reqst;
-		rsrq->rmsn_sid = console_session.ses_id;
+		rsrq->rmsn_sid.ses_stamp = console_session.ses_id.ses_stamp;
+		rsrq->rmsn_sid.ses_nid =
+			lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
 		break;
 
 	default:
@@ -638,7 +642,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 
 	drq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.dbg_reqst;
 
-	drq->dbg_sid = console_session.ses_id;
+	drq->dbg_sid.ses_stamp = console_session.ses_id.ses_stamp;
+	drq->dbg_sid.ses_nid =
+		lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
 	drq->dbg_flags = 0;
 
 	return rc;
@@ -658,7 +664,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 
 	brq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.bat_reqst;
 
-	brq->bar_sid = console_session.ses_id;
+	brq->bar_sid.ses_stamp = console_session.ses_id.ses_stamp;
+	brq->bar_sid.ses_nid =
+		lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
 	brq->bar_bid = tsb->tsb_id;
 	brq->bar_testidx = tsb->tsb_index;
 	brq->bar_opc = transop == LST_TRANS_TSBRUN ? SRPC_BATCH_OPC_RUN :
@@ -690,7 +698,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 
 	srq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.stat_reqst;
 
-	srq->str_sid = console_session.ses_id;
+	srq->str_sid.ses_stamp = console_session.ses_id.ses_stamp;
+	srq->str_sid.ses_nid =
+		lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
 	srq->str_type = 0; /* XXX remove it */
 
 	return 0;
@@ -877,7 +887,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 		trq->tsr_loop = test->tes_loop;
 	}
 
-	trq->tsr_sid = console_session.ses_id;
+	trq->tsr_sid.ses_stamp = console_session.ses_id.ses_stamp;
+	trq->tsr_sid.ses_nid =
+		lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
 	trq->tsr_bid = test->tes_hdr.tsb_id;
 	trq->tsr_concur = test->tes_concur;
 	trq->tsr_is_client = (transop == LST_TRANS_TSBCLIADD) ? 1 : 0;
@@ -1259,7 +1271,9 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
 
 		drq = &crpc->crp_rpc->crpc_reqstmsg.msg_body.dbg_reqst;
 
-		drq->dbg_sid = console_session.ses_id;
+		drq->dbg_sid.ses_stamp = console_session.ses_id.ses_stamp;
+		drq->dbg_sid.ses_nid =
+			lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
 		drq->dbg_flags = 0;
 
 		lstcon_rpc_trans_addreq(trans, crpc);
net/lnet/selftest/console.c +27 -54

142 lines not on this page · raw message

net/lnet/selftest/console.h +34 -34

84 lines not on this page · raw message

net/lnet/selftest/framework.c +29 -14

131 lines not on this page · raw message

net/lnet/selftest/selftest.h +64 -14

93 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#14 lore raw

PATCH 14/22 lustre: clio: append to non-existent component

In reply to James Simmons

From: Vitaly Fertman <[email protected]>

should return an error, but it fails now with a BUG below because @rc of lov_io_layout_at() is not checked for < 0

BUG: unable to handle kernel paging request at ffff99d3c2f74030
    Call Trace:
      lov_stripe_number+0x19/0x40 [lov]
      lov_page_init_composite+0x103/0x5f0 [lov]
      ? kmem_cache_alloc+0x12e/0x270
      cl_page_alloc+0x19f/0x660 [obdclass]
      cl_page_find+0x1a0/0x250 [obdclass]
      ll_write_begin+0x1f7/0xfb0 [lustre]

HPE-bug-id: LUS-11075
WC-bug-id: https://jira.whamcloud.com/browse/LU-16281
Lustre-commit: 8fdeca3b6faf22c72 ("LU-16281 clio: append to non-existent component")

Reviewed-on: https://es-gerrit.dev.cray.com/161123

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48994

---
 fs/lustre/lov/lov_page.c | 2 ++
 1 file changed, 2 insertions(+)
fs/lustre/lov/lov_page.c +2 -0
index a22b71f..6e28e62 100644
@@ -84,6 +84,8 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
 		suboff = lio->lis_cached_suboff + offset - lio->lis_cached_off;
 	} else {
 		entry = lov_io_layout_at(lio, offset);
+		if (entry < 0)
+			return -ENODATA;
 
 		stripe = lov_stripe_number(loo->lo_lsm, entry, offset);
 		rc = lov_stripe_offset(loo->lo_lsm, entry, offset, stripe,
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#15 lore raw

PATCH 15/22 lnet: fix debug message in lnet_discovery_event_reply

In reply to James Simmons

From: Serguei Smirnov <[email protected]>

The message in lnet_discovery_event_reply currently says "Peer X has discovery disabled" even though the same path may be taken if discovery is disabled locally. Change the debug message to indicate whether discovery is disabled on the peer side or locally.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16282
Lustre-commit: 9f45a79e983c11def ("LU-16282 lnet: fix debug message in lnet_discovery_event_reply")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48997

---
 net/lnet/lnet/peer.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
net/lnet/lnet/peer.c +8 -6
index 52ad791..35b135e 100644
@@ -2592,6 +2592,7 @@ static void lnet_peer_clear_discovery_error(struct lnet_peer *lp)
 	struct lnet_ping_buffer *pbuf;
 	int infobytes;
 	int rc;
+	bool ping_feat_disc;
 
 	spin_lock(&lp->lp_lock);
 
@@ -2629,14 +2630,15 @@ static void lnet_peer_clear_discovery_error(struct lnet_peer *lp)
 		goto out;
 	}
 
-	/*
-	 * The peer may have discovery disabled at its end. Set
+	/* The peer may have discovery disabled at its end. Set
 	 * NO_DISCOVERY as appropriate.
 	 */
-	if (!(pbuf->pb_info.pi_features & LNET_PING_FEAT_DISCOVERY) &&
-	    lnet_peer_discovery_disabled) {
-		CDEBUG(D_NET, "Peer %s has discovery enabled\n",
-		       libcfs_nidstr(&lp->lp_primary_nid));
+	ping_feat_disc = pbuf->pb_info.pi_features & LNET_PING_FEAT_DISCOVERY;
+	if (!ping_feat_disc || lnet_peer_discovery_disabled) {
+		CDEBUG(D_NET, "Peer %s has discovery %s, local discovery %s\n",
+		       libcfs_nidstr(&lp->lp_primary_nid),
+		       ping_feat_disc ? "enabled" : "disabled",
+		       lnet_peer_discovery_disabled ? "disabled" : "enabled");
 
 		/* Detect whether this peer has toggled discovery from on to
 		 * off and whether we can delete and re-create the peer. Peers
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#16 lore raw

PATCH 16/22 lustre: ldlm: group lock unlock fix

In reply to James Simmons

From: Vitaly Fertman <[email protected]>

The original LU-9964 fix had a problem because with many pages in memory grouplock unlock takes 10+ seconds just to discard them.

The current patch makes grouplock unlock thread to be not atomic, but makes a new grouplock enqueue to wait until previous CBPENDING lock gets destroyed.

HPE-bug-id: LUS-10644

WC-bug-id: https://jira.whamcloud.com/browse/LU-16046
Lustre-commit: 3dc261c06434eceee ("LU-16046 ldlm: group lock unlock fix")
Lustre-commit: 62fd8f9b498ae3d16 ("Revert "LU-16046 revert: "LU-9964 llite: prevent mulitple group locks"")
Lustre-commit: dd609c6f31adeadab ("Revert "LU-16046 ldlm: group lock fix")

Reviewed-on: https://es-gerrit.dev.cray.com/161411

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49008

---
 fs/lustre/include/lustre_dlm.h   |   1 +
 fs/lustre/include/lustre_osc.h   |  15 ----
 fs/lustre/ldlm/ldlm_lock.c       |  28 ++++++-
 fs/lustre/llite/file.c           |  76 ++++++++++++-------
 fs/lustre/llite/llite_internal.h |   3 +
 fs/lustre/llite/llite_lib.c      |   3 +
 fs/lustre/mdc/mdc_dev.c          |  58 ++++-----------
 fs/lustre/osc/osc_lock.c         | 157 ++-------------------------------------
 fs/lustre/osc/osc_object.c       |  16 ----
 fs/lustre/osc/osc_request.c      |  14 ++--
 10 files changed, 110 insertions(+), 261 deletions(-)
fs/lustre/include/lustre_dlm.h +1 -0
index 6053e01..d08c48f 100644
@@ -855,6 +855,7 @@ enum ldlm_match_flags {
 	LDLM_MATCH_AST		= BIT(1),
 	LDLM_MATCH_AST_ANY	= BIT(2),
 	LDLM_MATCH_RIGHT	= BIT(3),
+	LDLM_MATCH_GROUP	= BIT(4),
 };
 
 /**
fs/lustre/include/lustre_osc.h +0 -15
index a0f1afc..d15f46b 100644
@@ -319,11 +319,6 @@ struct osc_object {
 
 	const struct osc_object_operations *oo_obj_ops;
 	bool			oo_initialized;
-
-	wait_queue_head_t	oo_group_waitq;
-	struct mutex		oo_group_mutex;
-	u64			oo_group_users;
-	unsigned long		oo_group_gid;
 };
 
 static inline void osc_build_res_name(struct osc_object *osc,
@@ -660,16 +655,6 @@ int osc_object_glimpse(const struct lu_env *env, const struct cl_object *obj,
 int osc_object_find_cbdata(const struct lu_env *env, struct cl_object *obj,
 			   ldlm_iterator_t iter, void *data);
 int osc_object_prune(const struct lu_env *env, struct cl_object *obj);
-void osc_grouplock_inc_locked(struct osc_object *osc, struct ldlm_lock *lock);
-void osc_grouplock_dec(struct osc_object *osc, struct ldlm_lock *lock);
-int osc_grouplock_enqueue_init(const struct lu_env *env,
-			       struct osc_object *obj,
-			       struct osc_lock *oscl,
-			       struct lustre_handle *lh);
-void osc_grouplock_enqueue_fini(const struct lu_env *env,
-				struct osc_object *obj,
-				struct osc_lock *oscl,
-				struct lustre_handle *lh);
 
 /* osc_request.c */
 void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd);
fs/lustre/ldlm/ldlm_lock.c +25 -3
index 39ab2a0..8659aa5 100644
@@ -324,6 +324,7 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
 		return 0;
 	}
 	ldlm_set_destroyed(lock);
+	wake_up(&lock->l_waitq);
 
 	ldlm_lock_remove_from_lru(lock);
 	class_handle_unhash(&lock->l_handle);
@@ -1067,10 +1068,12 @@ static bool lock_matches(struct ldlm_lock *lock, void *vdata)
 	 * can still happen.
 	 */
 	if (ldlm_is_cbpending(lock) &&
-	    !(data->lmd_flags & LDLM_FL_CBPENDING))
+	    !(data->lmd_flags & LDLM_FL_CBPENDING) &&
+	    !(data->lmd_match & LDLM_MATCH_GROUP))
 		return false;
 
-	if (!(data->lmd_match & LDLM_MATCH_UNREF) && ldlm_is_cbpending(lock) &&
+	if (!(data->lmd_match & (LDLM_MATCH_UNREF | LDLM_MATCH_GROUP)) &&
+	    ldlm_is_cbpending(lock) &&
 	    !lock->l_readers && !lock->l_writers)
 		return false;
 
@@ -1136,7 +1139,12 @@ static bool lock_matches(struct ldlm_lock *lock, void *vdata)
 		return false;
 
 matched:
-	if (data->lmd_flags & LDLM_FL_TEST_LOCK) {
+	/**
+	 * In case the lock is a CBPENDING grouplock, just pin it and return,
+	 * we need to wait until it gets to DESTROYED.
+	 */
+	if ((data->lmd_flags & LDLM_FL_TEST_LOCK) ||
+	    (ldlm_is_cbpending(lock) && (data->lmd_match & LDLM_MATCH_GROUP))) {
 		LDLM_LOCK_GET(lock);
 		ldlm_lock_touch_in_lru(lock);
 	} else {
@@ -1296,6 +1304,7 @@ enum ldlm_mode ldlm_lock_match_with_skip(struct ldlm_namespace *ns,
 	};
 	struct ldlm_resource *res;
 	struct ldlm_lock *lock;
+	struct ldlm_lock *group_lock;
 	int matched;
 
 	if (!ns) {
@@ -1314,6 +1323,8 @@ enum ldlm_mode ldlm_lock_match_with_skip(struct ldlm_namespace *ns,
 		return 0;
 	}
 
+repeat:
+	group_lock = NULL;
 	LDLM_RESOURCE_ADDREF(res);
 	lock_res(res);
 	if (res->lr_type == LDLM_EXTENT)
@@ -1323,8 +1334,19 @@ enum ldlm_mode ldlm_lock_match_with_skip(struct ldlm_namespace *ns,
 	if (!lock && !(flags & LDLM_FL_BLOCK_GRANTED))
 		lock = search_queue(&res->lr_waiting, &data);
 	matched = lock ? mode : 0;
+
+	if (lock && ldlm_is_cbpending(lock) &&
+	    (data.lmd_match & LDLM_MATCH_GROUP))
+		group_lock = lock;
 	unlock_res(res);
 	LDLM_RESOURCE_DELREF(res);
+
+	if (group_lock) {
+		l_wait_event_abortable(group_lock->l_waitq,
+				       ldlm_is_destroyed(lock));
+		LDLM_LOCK_RELEASE(lock);
+		goto repeat;
+	}
 	ldlm_resource_putref(res);
 
 	if (lock) {
fs/lustre/llite/file.c +50 -26

132 lines not on this page · raw message

fs/lustre/llite/llite_internal.h +3 -0
index d245dd8..998eed8 100644
@@ -253,6 +253,9 @@ struct ll_inode_info {
 			u64				lli_pcc_generation;
 			enum pcc_dataset_flags		lli_pcc_dsflags;
 			struct pcc_inode		*lli_pcc_inode;
+			struct mutex			lli_group_mutex;
+			u64				lli_group_users;
+			unsigned long			lli_group_gid;
 
 			u64				lli_attr_valid;
 			u64				lli_lazysize;
fs/lustre/llite/llite_lib.c +3 -0
index 3dc0030..176e61b5 100644
@@ -1194,6 +1194,9 @@ void ll_lli_init(struct ll_inode_info *lli)
 		lli->lli_pcc_inode = NULL;
 		lli->lli_pcc_dsflags = PCC_DATASET_INVALID;
 		lli->lli_pcc_generation = 0;
+		mutex_init(&lli->lli_group_mutex);
+		lli->lli_group_users = 0;
+		lli->lli_group_gid = 0;
 	}
 	mutex_init(&lli->lli_layout_mutex);
 	memset(lli->lli_jobid, 0, sizeof(lli->lli_jobid));
fs/lustre/mdc/mdc_dev.c +14 -44

125 lines not on this page · raw message

fs/lustre/osc/osc_lock.c +5 -152

206 lines not on this page · raw message

fs/lustre/osc/osc_object.c +0 -16
index c3667a3..efb0533 100644
@@ -74,10 +74,6 @@ int osc_object_init(const struct lu_env *env, struct lu_object *obj,
 
 	atomic_set(&osc->oo_nr_ios, 0);
 	init_waitqueue_head(&osc->oo_io_waitq);
-	init_waitqueue_head(&osc->oo_group_waitq);
-	mutex_init(&osc->oo_group_mutex);
-	osc->oo_group_users = 0;
-	osc->oo_group_gid = 0;
 
 	osc->oo_root.rb_node = NULL;
 	INIT_LIST_HEAD(&osc->oo_hp_exts);
@@ -117,7 +113,6 @@ void osc_object_free(const struct lu_env *env, struct lu_object *obj)
 	LASSERT(atomic_read(&osc->oo_nr_writes) == 0);
 	LASSERT(list_empty(&osc->oo_ol_list));
 	LASSERT(!atomic_read(&osc->oo_nr_ios));
-	LASSERT(!osc->oo_group_users);
 
 	lu_object_fini(obj);
 	/* osc doen't contain an lu_object_header, so we don't need call_rcu */
@@ -230,17 +225,6 @@ static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
 		memcpy(lvb, &oinfo->loi_lvb, sizeof(oinfo->loi_lvb));
 		cl_object_attr_unlock(&osc->oo_cl);
 		ldlm_clear_lvb_cached(lock);
-
-		/**
-		 * Object is being destroyed and gets unlinked from the lock,
-		 * IO is finished and no cached data is left under the lock. As
-		 * grouplock is immediately marked CBPENDING it is not reused.
-		 * It will also be not possible to flush data later due to a
-		 * NULL l_ast_data - enough conditions to let new grouplocks to
-		 * be enqueued even if the lock still exists on client.
-		 */
-		if (lock->l_req_mode == LCK_GROUP)
-			osc_grouplock_dec(osc, lock);
 	}
 	return LDLM_ITER_CONTINUE;
 }
fs/lustre/osc/osc_request.c +9 -5
index 7577fad..5a3f418 100644
@@ -3009,7 +3009,8 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
 	struct lustre_handle lockh = { 0 };
 	struct ptlrpc_request *req = NULL;
 	int intent = *flags & LDLM_FL_HAS_INTENT;
-	u64 match_flags = *flags;
+	u64 search_flags = *flags;
+	u64 match_flags = 0;
 	enum ldlm_mode mode;
 	int rc;
 
@@ -3040,11 +3041,14 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
 	 * because they will not actually use the lock.
 	 */
 	if (!speculative)
-		match_flags |= LDLM_FL_LVB_READY;
+		search_flags |= LDLM_FL_LVB_READY;
 	if (intent != 0)
-		match_flags |= LDLM_FL_BLOCK_GRANTED;
-	mode = ldlm_lock_match(obd->obd_namespace, match_flags, res_id,
-			       einfo->ei_type, policy, mode, &lockh);
+		search_flags |= LDLM_FL_BLOCK_GRANTED;
+	if (mode == LCK_GROUP)
+		match_flags = LDLM_MATCH_GROUP;
+	mode = ldlm_lock_match_with_skip(obd->obd_namespace, search_flags, 0,
+					 res_id, einfo->ei_type, policy, mode,
+					 &lockh, match_flags);
 	if (mode) {
 		struct ldlm_lock *matched;
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#17 lore raw

PATCH 17/22 lnet: Signal completion on ping send failure

In reply to James Simmons

From: Chris Horn <[email protected]>

Call complete() on the ping_data::completion if we get LNET_EVENT_SEND with non-zero status. Otherwise the thread which issued the ping is stuck waiting for the full ping timeout.

A pd_unlinked member is added to struct ping_data to indicate whether the associated MD has been unlinked. This is checked by lnet_ping() to determine whether it needs to explicitly called LNetMDUnlink().

Lastly, in cases where we do not receive a reply, we now return the value of pd.rc, if it is non-zero, rather than -EIO. This can provide more information about the underlying ping failure.

HPE-bug-id: LUS-11317
WC-bug-id: https://jira.whamcloud.com/browse/LU-16290
Lustre-commit: 48c34c71de65e8a25 ("LU-16290 lnet: Signal completion on ping send failure")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49020

---
 net/lnet/lnet/api-ni.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
net/lnet/lnet/api-ni.c +10 -3
index 935c848..8b53adf 100644
@@ -5333,6 +5333,7 @@ void LNetDebugPeer(struct lnet_processid *id)
 struct ping_data {
 	int rc;
 	int replied;
+	int pd_unlinked;
 	struct lnet_handle_md mdh;
 	struct completion completion;
 };
@@ -5353,7 +5354,12 @@ struct ping_data {
 		pd->replied = 1;
 		pd->rc = event->mlength;
 	}
+
 	if (event->unlinked)
+		pd->pd_unlinked = 1;
+
+	if (event->unlinked ||
+	    (event->type == LNET_EVENT_SEND && event->status))
 		complete(&pd->completion);
 }
 
@@ -5424,13 +5430,14 @@ static int lnet_ping(struct lnet_process_id id4, struct lnet_nid *src_nid,
 		/* NB must wait for the UNLINK event below... */
 	}
 
-	if (wait_for_completion_timeout(&pd.completion, timeout) == 0) {
-		/* Ensure completion in finite time... */
+	/* Ensure completion in finite time... */
+	wait_for_completion_timeout(&pd.completion, timeout);
+	if (!pd.pd_unlinked) {
 		LNetMDUnlink(pd.mdh);
 		wait_for_completion(&pd.completion);
 	}
 	if (!pd.replied) {
-		rc = -EIO;
+		rc = pd.rc ?: -EIO;
 		goto fail_ping_buffer_decref;
 	}
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#18 lore raw

PATCH 18/22 lnet: extend lnet_is_nid_in_ping_info()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

lnet_is_nid_in_ping_info() now checks the ping_info for both nid4 and larger nids.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 56bcfbf22d91b96c3 ("LU-10391 lnet: extend lnet_is_nid_in_ping_info()")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/44629

---
 include/linux/lnet/lib-lnet.h |  9 ++++++
 net/lnet/lnet/peer.c          | 71 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 70 insertions(+), 10 deletions(-)
include/linux/lnet/lib-lnet.h +9 -0
index 13ce2bf..7ce6cff 100644
@@ -886,6 +886,15 @@ static inline void lnet_ping_buffer_decref(struct lnet_ping_buffer *pbuf)
 	}
 }
 
+struct lnet_ping_iter {
+	struct lnet_ping_info	*pinfo;
+	void			*pos, *end;
+};
+
+u32 *ping_iter_first(struct lnet_ping_iter *pi, struct lnet_ping_buffer *pbuf,
+		     struct lnet_nid *nid);
+u32 *ping_iter_next(struct lnet_ping_iter *pi, struct lnet_nid *nid);
+
 static inline int lnet_push_target_resize_needed(void)
 {
 	return the_lnet.ln_push_target->pb_nbytes < the_lnet.ln_push_target_nbytes;
net/lnet/lnet/peer.c +61 -10

91 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#19 lore raw

PATCH 19/22 lnet: find correct primary for peer

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

If the peer has a large-address for the primary, it can now be found.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 022b46d887603f703 ("LU-10391 lnet: find correct primary for peer")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/44632

---
 net/lnet/lnet/peer.c | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)
net/lnet/lnet/peer.c +34 -7
index b33d6ac..a1305b6 100644
@@ -2585,11 +2585,40 @@ static void lnet_peer_clear_discovery_error(struct lnet_peer *lp)
 	       libcfs_nidstr(&lp->lp_primary_nid), ev->status);
 }
 
+static bool find_primary(struct lnet_nid *nid,
+			 struct lnet_ping_buffer *pbuf)
+{
+	struct lnet_ping_info *pi = &pbuf->pb_info;
+	struct lnet_ping_iter piter;
+	u32 *stp;
+
+	if (pi->pi_features & LNET_PING_FEAT_PRIMARY_LARGE) {
+		/* First large nid is primary */
+		for (stp = ping_iter_first(&piter, pbuf, nid);
+		     stp;
+		     stp = ping_iter_next(&piter, nid)) {
+			if (nid_is_nid4(nid))
+				continue;
+			/* nid has already been copied in */
+			return true;
+		}
+		/* no large nids ... weird ... ignore the flag
+		 * and use first nid.
+		 */
+	}
+	/* pi_nids[1] is primary */
+	if (pi->pi_nnis < 2)
+		return false;
+	lnet_nid4_to_nid(pbuf->pb_info.pi_ni[1].ns_nid, nid);
+	return true;
+}
+
 /* Handle a Reply message. This is the reply to a Ping message. */
 static void
 lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev)
 {
 	struct lnet_ping_buffer *pbuf;
+	struct lnet_nid primary;
 	int infobytes;
 	int rc;
 	bool ping_feat_disc;
@@ -2731,9 +2760,8 @@ static void lnet_peer_clear_discovery_error(struct lnet_peer *lp)
 	 * available if the reply came from a Multi-Rail peer.
 	 */
 	if (pbuf->pb_info.pi_features & LNET_PING_FEAT_MULTI_RAIL &&
-	    pbuf->pb_info.pi_nnis > 1 &&
-	    lnet_nid_to_nid4(&lp->lp_primary_nid) ==
-	    pbuf->pb_info.pi_ni[1].ns_nid) {
+	    find_primary(&primary, pbuf) &&
+	    nid_same(&lp->lp_primary_nid, &primary)) {
 		if (LNET_PING_BUFFER_SEQNO(pbuf) < lp->lp_peer_seqno)
 			CDEBUG(D_NET,
 			       "peer %s: seq# got %u have %u. peer rebooted?\n",
@@ -3081,11 +3109,11 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
 	 * peer's lp_peer_nets list, and the peer NI for the primary NID should
 	 * be the first entry in its peer net's lpn_peer_nis list.
 	 */
-	lnet_nid4_to_nid(pbuf->pb_info.pi_ni[1].ns_nid, &nid);
+	find_primary(&nid, pbuf);
 	lpni = lnet_peer_ni_find_locked(&nid);
 	if (!lpni) {
 		CERROR("Internal error: Failed to lookup peer NI for primary NID: %s\n",
-		       libcfs_nid2str(pbuf->pb_info.pi_ni[1].ns_nid));
+		       libcfs_nidstr(&nid));
 		goto out;
 	}
 
@@ -3341,11 +3369,10 @@ static int lnet_peer_data_present(struct lnet_peer *lp)
 	 * primary NID to the correct value here. Moreover, this peer
 	 * can show up with only the loopback NID in the ping buffer.
 	 */
-	if (pbuf->pb_info.pi_nnis <= 1) {
+	if (!find_primary(&nid, pbuf)) {
 		lnet_ping_buffer_decref(pbuf);
 		goto out;
 	}
-	lnet_nid4_to_nid(pbuf->pb_info.pi_ni[1].ns_nid, &nid);
 	if (nid_is_lo0(&lp->lp_primary_nid)) {
 		rc = lnet_peer_set_primary_nid(lp, &nid, flags);
 		if (rc)
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#20 lore raw

PATCH 20/22 lnet: change lnet_notify() to take struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

lnet_notify() now takes a 'struct lnet_nid *' instead of a lnet_nid_t.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 4a88236f40a47c05d ("LU-10391 lnet: change lnet_notify() to take struct lnet_nid")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/44633

---
 include/linux/lnet/lib-lnet.h       |  4 ++--
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 10 +++++++---
 net/lnet/klnds/socklnd/socklnd.c    |  2 +-
 net/lnet/lnet/api-ni.c              |  3 ++-
 net/lnet/lnet/router.c              | 15 +++++++--------
 5 files changed, 19 insertions(+), 15 deletions(-)
include/linux/lnet/lib-lnet.h +2 -2
index 7ce6cff..3bcea11 100644
@@ -574,8 +574,8 @@ unsigned int lnet_nid_cpt_hash(struct lnet_nid *nid,
 
 void lnet_mt_event_handler(struct lnet_event *event);
 
-int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, bool alive, bool reset,
-		time64_t when);
+int lnet_notify(struct lnet_ni *ni, struct lnet_nid *peer, bool alive,
+		bool reset, time64_t when);
 void lnet_notify_locked(struct lnet_peer_ni *lp, int notifylnd, int alive,
 			time64_t when);
 int lnet_add_route(u32 net, u32 hops, struct lnet_nid *gateway,
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +7 -3
index d4de326..451363b 100644
@@ -1967,9 +1967,13 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 
 	read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
-	if (error)
-		lnet_notify(peer_ni->ibp_ni,
-			    peer_ni->ibp_nid, false, false, last_alive);
+	if (error != 0) {
+		struct lnet_nid nid;
+
+		lnet_nid4_to_nid(peer_ni->ibp_nid, &nid);
+		lnet_notify(peer_ni->ibp_ni, &nid,
+			    false, false, last_alive);
+	}
 }
 
 void
net/lnet/klnds/socklnd/socklnd.c +1 -1
index 21fccfa..d8d1071 100644
@@ -1424,7 +1424,7 @@ struct ksock_peer_ni *
 
 	if (notify)
 		lnet_notify(peer_ni->ksnp_ni,
-			    lnet_nid_to_nid4(&peer_ni->ksnp_id.nid),
+			    &peer_ni->ksnp_id.nid,
 			    false, false, last_alive);
 }
 
net/lnet/lnet/api-ni.c +2 -1
index 8b53adf..5be2aff 100644
@@ -4372,7 +4372,8 @@ u32 lnet_get_dlc_seq_locked(void)
 		 * that deadline to the wall clock.
 		 */
 		deadline += ktime_get_seconds();
-		return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, false,
+		lnet_nid4_to_nid(data->ioc_nid, &nid);
+		return lnet_notify(NULL, &nid, data->ioc_flags, false,
 				   deadline);
 	}
 
net/lnet/lnet/router.c +7 -8
index ee4f1d8..358c3f1 100644
@@ -1672,26 +1672,25 @@ bool lnet_router_checker_active(void)
  * when: notificaiton time.
  */
 int
-lnet_notify(struct lnet_ni *ni, lnet_nid_t nid4, bool alive, bool reset,
+lnet_notify(struct lnet_ni *ni, struct lnet_nid *nid, bool alive, bool reset,
 	    time64_t when)
 {
 	struct lnet_peer_ni *lpni = NULL;
 	struct lnet_route *route;
 	struct lnet_peer *lp;
 	time64_t now = ktime_get_seconds();
-	struct lnet_nid nid;
 	int cpt;
 
 	LASSERT(!in_interrupt());
 
 	CDEBUG(D_NET, "%s notifying %s: %s\n",
 	       !ni ? "userspace" : libcfs_nidstr(&ni->ni_nid),
-	       libcfs_nidstr(&nid), alive ? "up" : "down");
+	       libcfs_nidstr(nid), alive ? "up" : "down");
 
 	if (ni &&
-	    LNET_NID_NET(&ni->ni_nid) != LNET_NID_NET(&nid)) {
+	    LNET_NID_NET(&ni->ni_nid) != LNET_NID_NET(nid)) {
 		CWARN("Ignoring notification of %s %s by %s (different net)\n",
-		      libcfs_nidstr(&nid), alive ? "birth" : "death",
+		      libcfs_nidstr(nid), alive ? "birth" : "death",
 		      libcfs_nidstr(&ni->ni_nid));
 		return -EINVAL;
 	}
@@ -1700,7 +1699,7 @@ bool lnet_router_checker_active(void)
 	if (when > now) {
 		CWARN("Ignoring prediction from %s of %s %s %lld seconds in the future\n",
 		      ni ? libcfs_nidstr(&ni->ni_nid) : "userspace",
-		      libcfs_nidstr(&nid), alive ? "up" : "down", when - now);
+		      libcfs_nidstr(nid), alive ? "up" : "down", when - now);
 		return -EINVAL;
 	}
 
@@ -1718,11 +1717,11 @@ bool lnet_router_checker_active(void)
 		return -ESHUTDOWN;
 	}
 
-	lpni = lnet_peer_ni_find_locked(&nid);
+	lpni = lnet_peer_ni_find_locked(nid);
 	if (!lpni) {
 		/* nid not found */
 		lnet_net_unlock(0);
-		CDEBUG(D_NET, "%s not found\n", libcfs_nidstr(&nid));
+		CDEBUG(D_NET, "%s not found\n", libcfs_nidstr(nid));
 		return 0;
 	}
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#21 lore raw

PATCH 21/22 lnet: discard lnet_nid2ni_*()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

These 'struct lnet_ni' lookup functions which take a nid4, are discarded in favour of the versions which take a 'struct lnet_nid'.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: cbfbe6d132c6d0fe5 ("LU-10391 lnet: discard lnet_nid2ni_*()")

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/44634

---
 include/linux/lnet/lib-lnet.h       |  2 --
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c |  9 +++++----
 net/lnet/lnet/api-ni.c              | 33 +++------------------------------
 3 files changed, 8 insertions(+), 36 deletions(-)
include/linux/lnet/lib-lnet.h +0 -2
index 3bcea11..a2d5adc 100644
@@ -542,9 +542,7 @@ unsigned int lnet_nid_cpt_hash(struct lnet_nid *nid,
 int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni);
 int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 int lnet_nid2cpt(struct lnet_nid *nid, struct lnet_ni *ni);
-struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 struct lnet_ni *lnet_nid_to_ni_locked(struct lnet_nid *nid, int cpt);
-struct lnet_ni *lnet_nid2ni_addref(lnet_nid_t nid);
 struct lnet_ni *lnet_net2ni_locked(u32 net, int cpt);
 struct lnet_ni *lnet_net2ni_addref(u32 net);
 struct lnet_ni *lnet_nid_to_ni_addref(struct lnet_nid *nid);
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +5 -4
index 451363b..6fc1730 100644
@@ -2397,8 +2397,9 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	struct kib_peer_ni *peer_ni;
 	struct kib_peer_ni *peer2;
 	struct kib_conn *conn;
-	struct lnet_ni *ni  = NULL;
+	struct lnet_ni *ni = NULL;
 	struct kib_net *net = NULL;
+	struct lnet_nid destnid;
 	lnet_nid_t nid;
 	struct rdma_conn_param cp;
 	struct kib_rej rej;
@@ -2461,7 +2462,8 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	}
 
 	nid = reqmsg->ibm_srcnid;
-	ni = lnet_nid2ni_addref(reqmsg->ibm_dstnid);
+	lnet_nid4_to_nid(reqmsg->ibm_dstnid, &destnid);
+	ni  = lnet_nid_to_ni_addref(&destnid);
 
 	if (ni) {
 		net = (struct kib_net *)ni->ni_data;
@@ -2469,8 +2471,7 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	}
 
 	if (!ni ||				/* no matching net */
-	    lnet_nid_to_nid4(&ni->ni_nid) !=
-	    reqmsg->ibm_dstnid ||		/* right NET, wrong NID! */
+	    !nid_same(&ni->ni_nid, &destnid) ||	/* right NET, wrong NID! */
 	    net->ibn_dev != ibdev) {		/* wrong device */
 		CERROR("Can't accept conn from %s on %s (%s:%d:%pI4h): bad dst nid %s\n",
 		       libcfs_nid2str(nid),
net/lnet/lnet/api-ni.c +3 -30
index 5be2aff..0146509 100644
@@ -1654,33 +1654,6 @@ struct lnet_ni *
 	return NULL;
 }
 
-struct lnet_ni  *
-lnet_nid2ni_locked(lnet_nid_t nid4, int cpt)
-{
-	struct lnet_nid nid;
-
-	lnet_nid4_to_nid(nid4, &nid);
-	return lnet_nid_to_ni_locked(&nid, cpt);
-}
-
-struct lnet_ni *
-lnet_nid2ni_addref(lnet_nid_t nid4)
-{
-	struct lnet_ni *ni;
-	struct lnet_nid nid;
-
-	lnet_nid4_to_nid(nid4, &nid);
-
-	lnet_net_lock(0);
-	ni = lnet_nid_to_ni_locked(&nid, 0);
-	if (ni)
-		lnet_ni_addref_locked(ni, 0);
-	lnet_net_unlock(0);
-
-	return ni;
-}
-EXPORT_SYMBOL(lnet_nid2ni_addref);
-
 struct lnet_ni *
 lnet_nid_to_ni_addref(struct lnet_nid *nid)
 {
@@ -3918,11 +3891,11 @@ u32 lnet_get_dlc_seq_locked(void)
 {
 	int cpt, rc = 0;
 	struct lnet_ni *ni;
-	lnet_nid_t nid = stats->hlni_nid;
+	struct lnet_nid nid;
 
+	lnet_nid4_to_nid(stats->hlni_nid, &nid);
 	cpt = lnet_net_lock_current();
-	ni = lnet_nid2ni_locked(nid, cpt);
-
+	ni = lnet_nid_to_ni_locked(&nid, cpt);
 	if (!ni) {
 		rc = -ENOENT;
 		goto unlock;
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
#22 lore raw

PATCH 22/22 lnet: change lnet_debug_peer() to struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

lnet_debug_peer() now takes 'struct lnet_nid *'.

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

Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/44635

---
 include/linux/lnet/lib-lnet.h |  2 +-
 net/lnet/lnet/api-ni.c        |  2 +-
 net/lnet/lnet/peer.c          | 10 ++++------
 3 files changed, 6 insertions(+), 8 deletions(-)
include/linux/lnet/lib-lnet.h +1 -1
index a2d5adc..ba68d50 100644
@@ -936,7 +936,7 @@ void lnet_peer_primary_nid_locked(struct lnet_nid *nid,
 void lnet_peer_tables_cleanup(struct lnet_net *net);
 void lnet_peer_uninit(void);
 int lnet_peer_tables_create(void);
-void lnet_debug_peer(lnet_nid_t nid);
+void lnet_debug_peer(struct lnet_nid *nid);
 struct lnet_peer_net *lnet_peer_get_net_locked(struct lnet_peer *peer,
 					       u32 net_id);
 bool lnet_peer_is_pref_nid_locked(struct lnet_peer_ni *lpni,
net/lnet/lnet/api-ni.c +1 -1
index 0146509..e400de7 100644
@@ -5257,7 +5257,7 @@ static int lnet_net_cmd(struct sk_buff *skb, struct genl_info *info)
 
 void LNetDebugPeer(struct lnet_processid *id)
 {
-	lnet_debug_peer(lnet_nid_to_nid4(&id->nid));
+	lnet_debug_peer(&id->nid);
 }
 EXPORT_SYMBOL(LNetDebugPeer);
 
net/lnet/lnet/peer.c +4 -6
index a1305b6..8c603c9 100644
@@ -3966,21 +3966,19 @@ void lnet_peer_discovery_stop(void)
 /* Debugging */
 
 void
-lnet_debug_peer(lnet_nid_t nid4)
+lnet_debug_peer(struct lnet_nid *nid)
 {
 	char *aliveness = "NA";
 	struct lnet_peer_ni *lp;
-	struct lnet_nid nid;
 	int cpt;
 
-	lnet_nid4_to_nid(nid4, &nid);
-	cpt = lnet_nid2cpt(&nid, NULL);
+	cpt = lnet_nid2cpt(nid, NULL);
 	lnet_net_lock(cpt);
 
-	lp = lnet_peerni_by_nid_locked(&nid, NULL, cpt);
+	lp = lnet_peerni_by_nid_locked(nid, NULL, cpt);
 	if (IS_ERR(lp)) {
 		lnet_net_unlock(cpt);
-		CDEBUG(D_WARNING, "No peer %s\n", libcfs_nidstr(&nid));
+		CDEBUG(D_WARNING, "No peer %s\n", libcfs_nidstr(nid));
 		return;
 	}
 
Signature · 6 lines
1.8.3.1

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org