Skip to contentSkip to conversation

lustre: latest patches landed to OpenSFS 07/14/2020

PATCH New James Simmons 1 participant 38 messages Jul 15, 2020 Networking

lore
Share & tools
lore
#0 lore raw

cover lustre: latest patches landed to OpenSFS 07/14/2020

Latest patches to landed to the OpenSFS tree as of July 14, 2020. Please review to make sure they are correct.

Amir Shehata (2):
lnet: socklnd: fix local interface binding
lnet: check rtr_nid is a gateway

Andreas Dilger (1):
lustre: misc: quiet compiler warning on armv7l

Chris Horn (2):
lnet: Allow router to forward to healthier NID
lnet: Set remote NI status in lnet_notify

Hongchao Zhang (1):
lustre: ptlrpc: fix endless loop issue

James Simmons (1):
lustre: ptlrpc: handle conn_hash rhashtable resize

Mikhail Pershin (1):
lustre: ptlrpc: re-enterable signal_completed_replay()

Mr NeilBrown (18):
lustre: osc: fix osc_extent_find()
lustre: obdclass: remove init to 0 from lustre_init_lsi()
lustre: lu_object: convert lu_object cache to rhashtable
lnet: o2iblnd: allocate init_qp_attr on stack.
lnet: Fix some out-of-date comments.
lnet: socklnd: don't fall-back to tcp_sendpage.
lustre: remove some "#ifdef CONFIG*" from .c files.
lnet: o2iblnd: Use ib_mtu_int_to_enum()
lnet: o2iblnd: wait properly for fps->increasing.
lnet: o2iblnd: use need_resched()
lnet: o2iblnd: Use list_for_each_entry_safe
lnet: socklnd: use need_resched()
lnet: socklnd: use list_for_each_entry_safe()
lnet: socklnd: convert various refcounts to refcount_t
lnet: libcfs: don't call unshare_fs_struct()
lustre: llite: annotate non-owner locking
lnet: remove LNetMEUnlink and clean up related code
lnet: socklnd: change ksnd_nthreads to atomic_t

Sebastien Buisson (1):
lustre: sec: better struct sepol_downcall_data

Shaun Tancheff (1):
lustre: llite: Fix lock ordering in pagevec_dirty

Vladimir Saveliev (1):
lustre: osc: consume grants for direct I/O

Wang Shilong (7):
lustre: ldlm: check slv and limit before updating
lustre: osc: disable ext merging for rdma only pages and non-rdma
lustre: obdclass: use offset instead of cp_linkage
lustre: obdclass: re-declare cl_page variables to reduce its size
lustre: osc: re-declare ops_from/to to shrink osc_page
lustre: llite: fix to free cl_dio_aio properly
lustre: llite: fix short io for AIO

Yang Sheng (1):
lustre: obdcalss: ensure LCT_QUIESCENT take sync

 fs/lustre/include/cl_object.h              |  34 +-
 fs/lustre/include/lu_object.h              |  28 +-
 fs/lustre/include/lustre_osc.h             |  12 +-
 fs/lustre/include/obd.h                    |  21 ++
 fs/lustre/ldlm/ldlm_request.c              |   8 +
 fs/lustre/llite/file.c                     |  32 +-
 fs/lustre/llite/llite_internal.h           |  29 ++
 fs/lustre/llite/llite_lib.c                |  54 +--
 fs/lustre/llite/rw26.c                     |  43 ++-
 fs/lustre/llite/vvp_dev.c                  | 105 ++----
 fs/lustre/llite/vvp_internal.h             |   3 +-
 fs/lustre/llite/vvp_io.c                   | 111 +++---
 fs/lustre/lov/lovsub_dev.c                 |   5 +-
 fs/lustre/mdc/mdc_request.c                |   8 +-
 fs/lustre/obdclass/cl_io.c                 |  19 +-
 fs/lustre/obdclass/cl_page.c               | 360 ++++++++++---------
 fs/lustre/obdclass/llog.c                  |   2 -
 fs/lustre/obdclass/lu_object.c             | 539 ++++++++++++++---------------
 fs/lustre/obdclass/lu_tgt_descs.c          |   2 +-
 fs/lustre/obdclass/obd_mount.c             |   6 +-
 fs/lustre/osc/osc_cache.c                  |  64 ++--
 fs/lustre/osc/osc_page.c                   |  21 +-
 fs/lustre/ptlrpc/connection.c              |  12 +-
 fs/lustre/ptlrpc/import.c                  |   6 +-
 fs/lustre/ptlrpc/niobuf.c                  |  12 +-
 fs/lustre/ptlrpc/pinger.c                  |  11 +-
 fs/lustre/ptlrpc/ptlrpcd.c                 |   1 -
 fs/lustre/ptlrpc/sec_lproc.c               | 134 ++++++-
 fs/lustre/ptlrpc/service.c                 |   3 -
 include/linux/lnet/api.h                   |   6 +-
 include/linux/lnet/lib-lnet.h              |   4 +-
 include/uapi/linux/lustre/lustre_user.h    |  16 +-
 net/lnet/klnds/o2iblnd/o2iblnd.c           | 103 ++----
 net/lnet/klnds/o2iblnd/o2iblnd.h           |   2 -
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c        |  12 +-
 net/lnet/klnds/o2iblnd/o2iblnd_modparams.c |   4 +-
 net/lnet/klnds/socklnd/socklnd.c           |  97 +++---
 net/lnet/klnds/socklnd/socklnd.h           |  56 ++-
 net/lnet/klnds/socklnd/socklnd_cb.c        |  26 +-
 net/lnet/klnds/socklnd/socklnd_lib.c       |   8 +-
 net/lnet/lnet/api-ni.c                     |   5 +-
 net/lnet/lnet/lib-md.c                     |  62 ++--
 net/lnet/lnet/lib-me.c                     |  39 ---
 net/lnet/lnet/lib-move.c                   |  57 ++-
 net/lnet/lnet/router.c                     |   6 +-
 net/lnet/selftest/rpc.c                    |   1 -
 46 files changed, 1176 insertions(+), 1013 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/37 lustre: osc: fix osc_extent_find()

From: Mr NeilBrown <[email protected]>

- fix a pre-existing bug - osc_extent_merge() should never try to merge two extends with different ->oe_mppr as later alignment checks can get confused.
- Remove a redundant list_del_init() which is already included in __osc_extent_remove().

Fixes 85ebb57ddc ("lustre: osc: simplify osc_extent_find()")

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: 80e21cce3dd67 ("LU-9679 osc: simplify osc_extent_find()")

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

---
 fs/lustre/osc/osc_cache.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)
fs/lustre/osc/osc_cache.c +15 -18
index 5049aaa..474b711 100644
@@ -574,6 +574,14 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur,
 	if (cur->oe_max_end != victim->oe_max_end)
 		return -ERANGE;
 
+	/*
+	 * In the rare case max_pages_per_rpc (mppr) is changed, don't
+	 * merge extents until after old ones have been sent, or the
+	 * "extents are aligned to RPCs" checks are unhappy.
+	 */
+	if (cur->oe_mppr != victim->oe_mppr)
+		return -ERANGE;
+
 	LASSERT(cur->oe_dlmlock == victim->oe_dlmlock);
 	ppc_bits = osc_cli(obj)->cl_chunkbits - PAGE_SHIFT;
 	chunk_start = cur->oe_start >> ppc_bits;
@@ -601,7 +609,6 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur,
 	cur->oe_urgent |= victim->oe_urgent;
 	cur->oe_memalloc |= victim->oe_memalloc;
 	list_splice_init(&victim->oe_pages, &cur->oe_pages);
-	list_del_init(&victim->oe_link);
 	victim->oe_nr_pages = 0;
 
 	osc_extent_get(victim);
@@ -727,8 +734,7 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 		cur->oe_start = descr->cld_start;
 	if (cur->oe_end > max_end)
 		cur->oe_end = max_end;
-	LASSERT(*grants >= chunksize);
-	cur->oe_grants = chunksize;
+	cur->oe_grants = chunksize + cli->cl_grant_extent_tax;
 	cur->oe_mppr = max_pages;
 	if (olck->ols_dlmlock) {
 		LASSERT(olck->ols_hold);
@@ -800,17 +806,8 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 			 */
 			continue;
 
-		/* it's required that an extent must be contiguous at chunk
-		 * level so that we know the whole extent is covered by grant
-		 * (the pages in the extent are NOT required to be contiguous).
-		 * Otherwise, it will be too much difficult to know which
-		 * chunks have grants allocated.
-		 */
-		/* On success, osc_extent_merge() will put cur,
-		 * so we take an extra reference
-		 */
-		osc_extent_get(cur);
 		if (osc_extent_merge(env, ext, cur) == 0) {
+			LASSERT(*grants >= chunksize);
 			*grants -= chunksize;
 			found = osc_extent_hold(ext);
 
@@ -824,19 +821,19 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 
 			break;
 		}
-		osc_extent_put(env, cur);
 	}
 
 	osc_extent_tree_dump(D_CACHE, obj);
 	if (found) {
 		LASSERT(!conflict);
-		LASSERT(found->oe_dlmlock == cur->oe_dlmlock);
-		OSC_EXTENT_DUMP(D_CACHE, found,
-				"found caching ext for %lu.\n", index);
+		if (!IS_ERR(found)) {
+			LASSERT(found->oe_dlmlock == cur->oe_dlmlock);
+			OSC_EXTENT_DUMP(D_CACHE, found,
+					"found caching ext for %lu.\n", index);
+		}
 	} else if (!conflict) {
 		/* create a new extent */
 		EASSERT(osc_extent_is_overlapped(obj, cur) == 0, cur);
-		cur->oe_grants = chunksize + cli->cl_grant_extent_tax;
 		LASSERT(*grants >= cur->oe_grants);
 		*grants -= cur->oe_grants;
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/37 lustre: ldlm: check slv and limit before updating

In reply to James Simmons

From: Wang Shilong <[email protected]>

slv and limit do not change for most of time, ldlm_cli_update_pool() could be called for each RPC reply, try hold read lock to check firstly could avoid heavy write lock in hot path.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13365
Lustre-commit: 3116b9e19dc09 ("LU-13365 ldlm: check slv and limit before updating")

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

---
 fs/lustre/ldlm/ldlm_request.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/lustre/ldlm/ldlm_request.c +8 -0
index e1ba596..6318137 100644
@@ -1163,6 +1163,14 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req)
 	new_slv = lustre_msg_get_slv(req->rq_repmsg);
 	obd = req->rq_import->imp_obd;
 
+	read_lock(&obd->obd_pool_lock);
+	if (obd->obd_pool_slv == new_slv &&
+	    obd->obd_pool_limit == new_limit) {
+		read_unlock(&obd->obd_pool_lock);
+		return 0;
+	}
+	read_unlock(&obd->obd_pool_lock);
+
 	/*
 	 * Set new SLV and limit in OBD fields to make them accessible
 	 * to the pool thread. We do not access obd_namespace and pool
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/37 lustre: sec: better struct sepol_downcall_data

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

struct sepol_downcall_data is badly formed for several reasons:
- it uses a __kernel_time_t field, which can be variably sized, depending on the size of __kernel_long_t. Replace it with a fixed-size __s64 type;
- it has __u32 sdd_magic that is immediately before a potentially 64-bit field, whereas the 64-bit fields in a structure should always be naturally aligned on 64-bit boundaries to avoid potential incompatibility in the structure definition;
- it has __u16 sdd_sepol_len which may be followed by padding.

So create a better struct sepol_downcall_data, while maintaining compatibility with 2.12 by keeping a struct sepol_downcall_data_old.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13525
Lustre-commit: 82b8cb5528f48 ("LU-13525 sec: better struct sepol_downcall_data")

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

---
 fs/lustre/ptlrpc/sec_lproc.c            | 134 ++++++++++++++++++++++++++++----
 include/uapi/linux/lustre/lustre_user.h |  16 +++-
 2 files changed, 135 insertions(+), 15 deletions(-)
fs/lustre/ptlrpc/sec_lproc.c +121 -13
index 7db7e81..b34ced4 100644
@@ -131,6 +131,86 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
 
 LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
+static ssize_t sepol_seq_write_old(struct obd_device *obd,
+				   const char __user *buffer,
+				   size_t count)
+{
+	struct client_obd *cli = &obd->u.cli;
+	struct obd_import *imp = cli->cl_import;
+	struct sepol_downcall_data_old *param;
+	int size = sizeof(*param);
+	u16 len;
+	int rc = 0;
+
+	if (count < size) {
+		rc = -EINVAL;
+		CERROR("%s: invalid data count = %lu, size = %d: rc = %d\n",
+		       obd->obd_name, (unsigned long) count, size, rc);
+		return rc;
+	}
+
+	param = kmalloc(size, GFP_KERNEL);
+	if (!param)
+		return -ENOMEM;
+
+	if (copy_from_user(param, buffer, size)) {
+		rc = -EFAULT;
+		CERROR("%s: bad sepol data: rc = %d\n", obd->obd_name, rc);
+		goto out;
+	}
+
+	if (param->sdd_magic != SEPOL_DOWNCALL_MAGIC_OLD) {
+		rc = -EINVAL;
+		CERROR("%s: sepol downcall bad params: rc = %d\n",
+		       obd->obd_name, rc);
+		goto out;
+	}
+
+	if (param->sdd_sepol_len == 0 ||
+	    param->sdd_sepol_len >= sizeof(imp->imp_sec->ps_sepol)) {
+		rc = -EINVAL;
+		CERROR("%s: invalid sepol data returned: rc = %d\n",
+		       obd->obd_name, rc);
+		goto out;
+	}
+	len = param->sdd_sepol_len; /* save sdd_sepol_len */
+	kfree(param);
+	size = offsetof(struct sepol_downcall_data_old,
+			sdd_sepol[len]);
+
+	if (count < size) {
+		rc = -EINVAL;
+		CERROR("%s: invalid sepol count = %lu, size = %d: rc = %d\n",
+		       obd->obd_name, (unsigned long) count, size, rc);
+		return rc;
+	}
+
+	/* alloc again with real size */
+	param = kmalloc(size, GFP_KERNEL);
+	if (!param)
+		return -ENOMEM;
+
+	if (copy_from_user(param, buffer, size)) {
+		rc = -EFAULT;
+		CERROR("%s: cannot copy sepol data: rc = %d\n",
+		       obd->obd_name, rc);
+		goto out;
+	}
+
+	spin_lock(&imp->imp_sec->ps_lock);
+	snprintf(imp->imp_sec->ps_sepol, param->sdd_sepol_len + 1, "%s",
+		 param->sdd_sepol);
+	imp->imp_sec->ps_sepol_mtime = ktime_set(param->sdd_sepol_mtime, 0);
+	spin_unlock(&imp->imp_sec->ps_lock);
+
+out:
+	kfree(param);
+
+	return rc ? rc : count;
+}
+#endif
+
 static ssize_t
 lprocfs_wr_sptlrpc_sepol(struct file *file, const char __user *buffer,
 			 size_t count, void *data)
@@ -140,13 +220,41 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
 	struct client_obd *cli = &obd->u.cli;
 	struct obd_import *imp = cli->cl_import;
 	struct sepol_downcall_data *param;
-	int size = sizeof(*param);
+	u32 magic;
+	int size = sizeof(magic);
+	u16 len;
 	int rc = 0;
 
 	if (count < size) {
-		CERROR("%s: invalid data count = %lu, size = %d\n",
-		       obd->obd_name, (unsigned long) count, size);
-		return -EINVAL;
+		rc = -EINVAL;
+		CERROR("%s: invalid buffer count = %lu, size = %d: rc = %d\n",
+		       obd->obd_name, (unsigned long) count, size, rc);
+		return rc;
+	}
+
+	if (copy_from_user(&magic, buffer, size)) {
+		rc = -EFAULT;
+		CERROR("%s: bad sepol magic: rc = %d\n", obd->obd_name, rc);
+		return rc;
+	}
+
+	if (magic != SEPOL_DOWNCALL_MAGIC) {
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
+		if (magic == SEPOL_DOWNCALL_MAGIC_OLD)
+			return sepol_seq_write_old(obd, buffer, count);
+#endif
+		rc = -EINVAL;
+		CERROR("%s: sepol downcall bad magic '%#08x': rc = %d\n",
+		       obd->obd_name, magic, rc);
+		return rc;
+	}
+
+	size = sizeof(*param);
+	if (count < size) {
+		rc = -EINVAL;
+		CERROR("%s: invalid data count = %lu, size = %d: rc = %d\n",
+		       obd->obd_name, (unsigned long) count, size, rc);
+		return rc;
 	}
 
 	param = kzalloc(size, GFP_KERNEL);
@@ -154,39 +262,39 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
 		return -ENOMEM;
 
 	if (copy_from_user(param, buffer, size)) {
-		CERROR("%s: bad sepol data\n", obd->obd_name);
 		rc = -EFAULT;
+		CERROR("%s: bad sepol data: rc = %d\n", obd->obd_name, rc);
 		goto out;
 	}
 
 	if (param->sdd_magic != SEPOL_DOWNCALL_MAGIC) {
-		CERROR("%s: sepol downcall bad params\n",
-		       obd->obd_name);
 		rc = -EINVAL;
+		CERROR("%s: invalid sepol data returned: rc = %d\n",
+		       obd->obd_name, rc);
 		goto out;
 	}
 
 	if (param->sdd_sepol_len == 0 ||
 	    param->sdd_sepol_len >= sizeof(imp->imp_sec->ps_sepol)) {
-		CERROR("%s: invalid sepol data returned\n",
-		       obd->obd_name);
 		rc = -EINVAL;
+		CERROR("%s: invalid sepol data returned: rc = %d\n",
+		       obd->obd_name, rc);
 		goto out;
 	}
-	rc = param->sdd_sepol_len; /* save sdd_sepol_len */
+	len = param->sdd_sepol_len; /* save sdd_sepol_len */
 	kfree(param);
 	size = offsetof(struct sepol_downcall_data,
-			sdd_sepol[rc]);
+			sdd_sepol[len]);
 
 	/* alloc again with real size */
-	rc = 0;
 	param = kzalloc(size, GFP_KERNEL);
 	if (!param)
 		return -ENOMEM;
 
 	if (copy_from_user(param, buffer, size)) {
-		CERROR("%s: bad sepol data\n", obd->obd_name);
 		rc = -EFAULT;
+		CERROR("%s: cannot copy sepol data: rc = %d\n",
+		       obd->obd_name, rc);
 		goto out;
 	}
 
include/uapi/linux/lustre/lustre_user.h +14 -2
index 6a2d5f9..b0301e1 100644
@@ -51,6 +51,7 @@
 #include <linux/types.h>
 #include <linux/unistd.h>
 #include <linux/lustre/lustre_fiemap.h>
+#include <linux/lustre/lustre_ver.h>
 
 #ifndef __KERNEL__
 # define __USE_ISOC99  1
@@ -980,7 +981,6 @@ static inline const char *qtype_name(int qtype)
 }
 
 #define IDENTITY_DOWNCALL_MAGIC 0x6d6dd629
-#define SEPOL_DOWNCALL_MAGIC 0x8b8bb842
 
 /* permission */
 #define N_PERMS_MAX	64
@@ -1002,13 +1002,25 @@ struct identity_downcall_data {
 	__u32			    idd_groups[0];
 };
 
-struct sepol_downcall_data {
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
+/* old interface struct is deprecated in 2.14 */
+#define SEPOL_DOWNCALL_MAGIC_OLD 0x8b8bb842
+struct sepol_downcall_data_old {
 	__u32		sdd_magic;
 	__s64		sdd_sepol_mtime;
 	__u16		sdd_sepol_len;
 	char		sdd_sepol[0];
 };
+#endif
 
+#define SEPOL_DOWNCALL_MAGIC 0x8b8bb843
+struct sepol_downcall_data {
+	__u32		sdd_magic;
+	__u16		sdd_sepol_len;
+	__u16		sdd_padding1;
+	__s64		sdd_sepol_mtime;
+	char		sdd_sepol[0];
+};
 
 /* lustre volatile file support
  * file name header: ".^L^S^T^R:volatile"
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/37 lustre: obdclass: remove init to 0 from lustre_init_lsi()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

After allocating a struct with kzalloc, there is no value in setting a few of the fields to zero.

And as all fields were zero, it must be safe to kfree lmd_exclude, whether lmd_exclude_count is zero or not.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: 513dde601d2e9 ("LU-9679 obdclass: remove init to 0 from lustre_init_lsi()")

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

---
 fs/lustre/obdclass/obd_mount.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
fs/lustre/obdclass/obd_mount.c +1 -5
index 13e6521..ea5b469 100644
@@ -515,9 +515,6 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
 		return NULL;
 	}
 
-	lsi->lsi_lmd->lmd_exclude_count = 0;
-	lsi->lsi_lmd->lmd_recovery_time_soft = 0;
-	lsi->lsi_lmd->lmd_recovery_time_hard = 0;
 	s2lsi_nocast(sb) = lsi;
 	/* we take 1 extra ref for our setup */
 	atomic_set(&lsi->lsi_mounts, 1);
@@ -544,8 +541,7 @@ static int lustre_free_lsi(struct super_block *sb)
 		kfree(lsi->lsi_lmd->lmd_fileset);
 		kfree(lsi->lsi_lmd->lmd_mgssec);
 		kfree(lsi->lsi_lmd->lmd_opts);
-		if (lsi->lsi_lmd->lmd_exclude_count)
-			kfree(lsi->lsi_lmd->lmd_exclude);
+		kfree(lsi->lsi_lmd->lmd_exclude);
 		kfree(lsi->lsi_lmd->lmd_mgs);
 		kfree(lsi->lsi_lmd->lmd_osd_type);
 		kfree(lsi->lsi_lmd->lmd_params);
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/37 lustre: ptlrpc: handle conn_hash rhashtable resize

In reply to James Simmons

The errors returned by rhashtable_lookup_get_insert_fast() of the values -ENOMEM or -EBUSY is due to the hashtable being resized. This is not fatal so retry a lookup.

Fixes ac2370ac2b ("staging: lustre: ptlrpc: convert conn_hash to rhashtable")

WC-bug-id: https://jira.whamcloud.com/browse/LU-8130
Lustre-commit: 37b29a8f709aa ("LU-8130 ptlrpc: convert conn_hash to rhashtable")

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

---
 fs/lustre/ptlrpc/connection.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
fs/lustre/ptlrpc/connection.c +11 -1
index 5466755..a548d99 100644
@@ -32,6 +32,8 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
+
+#include <linux/delay.h>
 #include <obd_support.h>
 #include <obd_class.h>
 #include <lustre_net.h>
@@ -103,13 +105,21 @@ struct ptlrpc_connection *
 	 * connection.  The object which exists in the hash will be
 	 * returned, otherwise NULL is returned on success.
 	 */
+try_again:
 	conn2 = rhashtable_lookup_get_insert_fast(&conn_hash, &conn->c_hash,
 						  conn_hash_params);
 	if (conn2) {
 		/* insertion failed */
 		kfree(conn);
-		if (IS_ERR(conn2))
+		if (IS_ERR(conn2)) {
+			/* hash table could be resizing. */
+			if (PTR_ERR(conn2) == -ENOMEM ||
+			    PTR_ERR(conn2) == -EBUSY) {
+				msleep(20);
+				goto try_again;
+			}
 			return NULL;
+		}
 		conn = conn2;
 		ptlrpc_connection_addref(conn);
 	}
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/37 lustre: lu_object: convert lu_object cache to rhashtable

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The lu_object cache is a little more complex than the other lustre hash tables for two reasons.
1/ there is a debugfs file which displays the contents of the cache,
so we need to use rhashtable_walk in a way that works for seq_file.

2/ There is a (sharded) lru list for objects which are no longer
referenced, so finding an object needs to consider races with the lru as well as with the hash table.

The debugfs file already manages walking the libcfs hash table keeping a current-position in the private data. We can fairly easily convert that to a struct rhashtable_iter. The debugfs file actually reports pages, and there are multiple pages per hashtable object. So as well as rhashtable_iter, we need the current page index.

For the double-locking, the current code uses direct-access to the bucket locks that libcfs_hash provides. rhashtable doesn't provide that access - callers must provide their own locking or use rcu techniques.

The lsb_waitq.lock is still used to manage the lru list, but with this patch it is no longer nested *inside* the hashtable locks, but instead is outside. It is used to protect an object with a refcount of zero.

When purging old objects from an lru, we first set LU_OBJECT_HEARD_BANSHEE while holding the lsb_waitq.lock, then remove all the entries from the hashtable separately.

When removing the last reference from an object, we first take the lsb_waitq.lock, then decrement the reference and add to the lru list or discard it setting LU_OBJECT_UNHASHED.

When we find an object in the hashtable with a refcount of zero, we take the corresponding lsb_waitq.lock and check that neither LU_OBJECT_HEARD_BANSHEE or LU_OBJECT_UNHASHED is set. If neither is, we can safely increment the refcount. If either are, the object is gone.

This way, we only ever manipulate an object with a refcount of zero while holding the lsb_waitq.lock.

As there is nothing to stop us using the resizing capabilities of rhashtable, the code to try to guess the perfect hash size has been removed.

Also: the "is_dying" variable in lu_object_put() is racey - the value could change the moment it is sampled. It is also not needed as it is only used to avoid a wakeup, which is not particularly expensive. In the same code as comment says that 'top' could not be accessed, but the code then immediately accesses 'top' to calculate 'bkt'. So move the initialization of 'bkt' to before 'top' becomes unsafe.

Also: Change "wake_up_all()" to "wake_up()". wake_up_all() is only relevant when an exclusive wait is used.

Moving from the libcfs hashtable to rhashtable also gives the benefit of a very large performance boost.

Before patch:

SUMMARY rate: (of 5 iterations)

   Operation                      Max            Min           Mean        Std Dev
   ---------                      ---            ---           ----        -------
   Directory creation:      12036.610      11091.880      11452.978        318.829
   Directory stat:          25871.734      24232.310      24935.661        574.996
   Directory removal:       12698.769      12239.685      12491.008        149.149
   File creation:           11722.036      11673.961      11692.157         15.966
   File stat:               62304.540      58237.124      60282.003       1479.103
   File read:               24204.811      23889.091      24048.577        110.245
   File removal:             9412.930       9111.828       9217.546        120.894
   Tree creation:            3515.536       3195.627       3442.609        123.792

Tree removal: 433.917 418.935 428.038 5.545

After patch:

SUMMARY rate: (of 5 iterations)

   Operation                      Max            Min           Mean        Std Dev
   ---------                      ---            ---           ----        -------
   Directory creation:      11873.308        303.626       9371.860       4539.539
   Directory stat:          31116.512      30190.574      30568.091        335.545
   Directory removal:       13082.121      12645.228      12943.239        157.695
   File creation:           12607.135      12293.319      12466.647        138.307
   File stat:              124419.347     105240.996     116919.977       7847.165
   File read:               39707.270      36295.477      38266.011       1328.857
   File removal:             9614.333       9273.931       9477.299        140.201
   Tree creation:            3572.602       3017.580       3339.547        207.061
   Tree removal:              487.687          0.004        282.188        230.659

WC-bug-id: https://jira.whamcloud.com/browse/LU-8130
Lustre-commit: aff14dbc522e1 ("LU-8130 lu_object: convert lu_object cache to rhashtable")

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

---
 fs/lustre/include/lu_object.h  |  20 +-
 fs/lustre/llite/vvp_dev.c      | 105 +++------
 fs/lustre/lov/lovsub_dev.c     |   5 +-
 fs/lustre/obdclass/lu_object.c | 481 +++++++++++++++++++----------------------
 4 files changed, 272 insertions(+), 339 deletions(-)
fs/lustre/include/lu_object.h +10 -10
index 2a2f38e..1a6b6e1 100644
@@ -36,6 +36,7 @@
 
 #include <stdarg.h>
 #include <linux/percpu_counter.h>
+#include <linux/rhashtable.h>
 #include <linux/libcfs/libcfs.h>
 #include <linux/ctype.h>
 #include <obd_target.h>
@@ -469,11 +470,6 @@ enum lu_object_header_flags {
 	 * initialized yet, the object allocator will initialize it.
 	 */
 	LU_OBJECT_INITED	= 2,
-	/**
-	 * Object is being purged, so mustn't be returned by
-	 * htable_lookup()
-	 */
-	LU_OBJECT_PURGING	= 3,
 };
 
 enum lu_object_header_attr {
@@ -496,6 +492,8 @@ enum lu_object_header_attr {
  * it is created for things like not-yet-existing child created by mkdir or
  * create calls. lu_object_operations::loo_exists() can be used to check
  * whether object is backed by persistent storage entity.
+ * Any object containing this structre which might be placed in an
+ * rhashtable via loh_hash MUST be freed using call_rcu() or rcu_kfree().
  */
 struct lu_object_header {
 	/**
@@ -517,9 +515,9 @@ struct lu_object_header {
 	 */
 	u32			loh_attr;
 	/**
-	 * Linkage into per-site hash table. Protected by lu_site::ls_guard.
+	 * Linkage into per-site hash table.
 	 */
-	struct hlist_node	loh_hash;
+	struct rhash_head	loh_hash;
 	/**
 	 * Linkage into per-site LRU list. Protected by lu_site::ls_guard.
 	 */
@@ -566,7 +564,7 @@ struct lu_site {
 	/**
 	 * objects hash table
 	 */
-	struct cfs_hash	       *ls_obj_hash;
+	struct rhashtable	ls_obj_hash;
 	/*
 	 * buckets for summary data
 	 */
@@ -643,6 +641,8 @@ int lu_object_init(struct lu_object *o,
 void lu_object_fini(struct lu_object *o);
 void lu_object_add_top(struct lu_object_header *h, struct lu_object *o);
 void lu_object_add(struct lu_object *before, struct lu_object *o);
+struct lu_object *lu_object_get_first(struct lu_object_header *h,
+				      struct lu_device *dev);
 
 /**
  * Helpers to initialize and finalize device types.
@@ -697,8 +697,8 @@ static inline int lu_site_purge(const struct lu_env *env, struct lu_site *s,
 	return lu_site_purge_objects(env, s, nr, true);
 }
 
-void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie,
-		   lu_printer_t printer);
+void lu_site_print(const struct lu_env *env, struct lu_site *s, atomic_t *ref,
+		   int msg_flags, lu_printer_t printer);
 struct lu_object *lu_object_find_at(const struct lu_env *env,
 				    struct lu_device *dev,
 				    const struct lu_fid *f,
fs/lustre/llite/vvp_dev.c +33 -72

183 lines not on this page · raw message

fs/lustre/lov/lovsub_dev.c +1 -4
index 69380fc..0555737 100644
@@ -88,10 +88,7 @@ static struct lu_device *lovsub_device_free(const struct lu_env *env,
 	struct lovsub_device *lsd = lu2lovsub_dev(d);
 	struct lu_device *next = cl2lu_dev(lsd->acid_next);
 
-	if (atomic_read(&d->ld_ref) && d->ld_site) {
-		LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL);
-		lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer);
-	}
+	lu_site_print(env, d->ld_site, &d->ld_ref, D_ERROR, lu_cdebug_printer);
 	cl_device_fini(lu2cl_dev(d));
 	kfree(lsd);
 	return next;
fs/lustre/obdclass/lu_object.c +228 -253

772 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/37 lustre: osc: disable ext merging for rdma only pages and non-rdma

In reply to James Simmons

From: Wang Shilong <[email protected]>

This patch try to add logic to prevent CPU memory pages and RDMA memory pages from merging into one RPC, codes which set OBD_BRW_RDMA_ONLY will be added whenever RDMA only codes added later.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13180
Lustre-commit: 9f6c9fa44d6e6 ("LU-13180 osc: disable ext merging for rdma only pages and non-rdma")

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

---
 fs/lustre/include/lustre_osc.h | 4 +++-
 fs/lustre/osc/osc_cache.c      | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)
fs/lustre/include/lustre_osc.h +3 -1
index 11b7e92..cd08f27 100644
@@ -939,7 +939,9 @@ struct osc_extent {
 	/* Non-delay RPC should be used for this extent. */
 				oe_ndelay:1,
 	/* direct IO pages */
-				oe_dio:1;
+				oe_dio:1,
+	/* this extent consists of RDMA only pages */
+				oe_is_rdma_only;
 	/* how many grants allocated for this extent.
 	 *  Grant allocated for this extent. There is no grant allocated
 	 *  for reading extents and sync write extents.
fs/lustre/osc/osc_cache.c +4 -0
index 474b711..f811dadb 100644
@@ -1927,6 +1927,9 @@ static inline unsigned int osc_extent_chunks(const struct osc_extent *ext)
 	if (in_rpc->oe_dio && overlapped(ext, in_rpc))
 		return false;
 
+	if (ext->oe_is_rdma_only != in_rpc->oe_is_rdma_only)
+		return false;
+
 	return true;
 }
 
@@ -2688,6 +2691,7 @@ int osc_queue_sync_pages(const struct lu_env *env, const struct cl_io *io,
 	ext->oe_srvlock = !!(brw_flags & OBD_BRW_SRVLOCK);
 	ext->oe_ndelay = !!(brw_flags & OBD_BRW_NDELAY);
 	ext->oe_dio = !!(brw_flags & OBD_BRW_NOCACHE);
+	ext->oe_is_rdma_only = !!(brw_flags & OBD_BRW_RDMA_ONLY);
 	ext->oe_nr_pages = page_count;
 	ext->oe_mppr = mppr;
 	list_splice_init(list, &ext->oe_pages);
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 8/37 lnet: socklnd: fix local interface binding

In reply to James Simmons

From: Amir Shehata <[email protected]>

When a node is configured with multiple interfaces in Multi-Rail config, socklnd was not utilizing the local interface requested by LNet. In essence LNet was using all the NIDs in round robin, however the socklnd module was not binding to the correct interface. Traffic was thus sent on a subset of the interfaces.

The reason is that the route interface number was not being set. In most cases lnet_connect() is called to create a socket. The socket is bound to the interface provided and then ksocknal_create_conn() is called to create the socklnd connection. ksocknal_create_conn() calls ksocknal_associate_route_conn_locked() at which point the route's local interface is assigned. However, this is already too late as the socket has already been created and bound to a local interface.

Therefore, it's important to assign the route's interface before calling lnet_connect() to ensure socket is bound to correct local interface.

To address this issue, the route's interface index is initialized to the NI's interface index when it's added to the peer_ni.

Another bug fixed:
The interface index was not being initialized in the startup routine.

Note: We're strictly assuming that there is one interface for each NI. This is because tcp bonding will be removed from the socklnd as it has been deprecated by LNet mutli-rail.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13566
Lustre-commit: a7c9aba5eb96d ("LU-13566 socklnd: fix local interface binding")

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

---
 net/lnet/klnds/socklnd/socklnd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
net/lnet/klnds/socklnd/socklnd.c +10 -0
index 444b90b..2b8fd3d 100644
@@ -409,12 +409,14 @@ struct ksock_peer_ni *
 {
 	struct ksock_conn *conn;
 	struct ksock_route *route2;
+	struct ksock_net *net = peer_ni->ksnp_ni->ni_data;
 
 	LASSERT(!peer_ni->ksnp_closing);
 	LASSERT(!route->ksnr_peer);
 	LASSERT(!route->ksnr_scheduled);
 	LASSERT(!route->ksnr_connecting);
 	LASSERT(!route->ksnr_connected);
+	LASSERT(net->ksnn_ninterfaces > 0);
 
 	/* LASSERT(unique) */
 	list_for_each_entry(route2, &peer_ni->ksnp_routes, ksnr_list) {
@@ -428,6 +430,11 @@ struct ksock_peer_ni *
 
 	route->ksnr_peer = peer_ni;
 	ksocknal_peer_addref(peer_ni);
+
+	/* set the route's interface to the current net's interface */
+	route->ksnr_myiface = net->ksnn_interfaces[0].ksni_index;
+	net->ksnn_interfaces[0].ksni_nroutes++;
+
 	/* peer_ni's routelist takes over my ref on 'route' */
 	list_add_tail(&route->ksnr_list, &peer_ni->ksnp_routes);
 
@@ -2667,6 +2674,7 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 		net->ksnn_ninterfaces = 1;
 		ni->ni_dev_cpt = ifaces[0].li_cpt;
 		ksi->ksni_ipaddr = ifaces[0].li_ipaddr;
+		ksi->ksni_index = ksocknal_ip2index(ksi->ksni_ipaddr, ni);
 		ksi->ksni_netmask = ifaces[0].li_netmask;
 		strlcpy(ksi->ksni_name, ifaces[0].li_name,
 			sizeof(ksi->ksni_name));
@@ -2706,6 +2714,8 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 				ksi = &net->ksnn_interfaces[j];
 				ni->ni_dev_cpt = ifaces[j].li_cpt;
 				ksi->ksni_ipaddr = ifaces[j].li_ipaddr;
+				ksi->ksni_index =
+					ksocknal_ip2index(ksi->ksni_ipaddr, ni);
 				ksi->ksni_netmask = ifaces[j].li_netmask;
 				strlcpy(ksi->ksni_name, ifaces[j].li_name,
 					sizeof(ksi->ksni_name));
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 9/37 lnet: o2iblnd: allocate init_qp_attr on stack.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

'struct ib_qp_init_attr' is not so large that it cannot be allocated on the stack. It is about 100 bytes, various other function in Linux allocate it on the stack, and the stack isn't as constrained as it once was.

So allocate on stack instead of using kmalloc and handling errors.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 524a5a733ba1c ("LU-12678 o2iblnd: allocate init_qp_attr on stack.")

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

---
 net/lnet/klnds/o2iblnd/o2iblnd.c | 45 +++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 28 deletions(-)
net/lnet/klnds/o2iblnd/o2iblnd.c +17 -28
index 16edfba..d8fca2a 100644
@@ -699,7 +699,7 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer_ni *peer_ni,
 	rwlock_t *glock = &kiblnd_data.kib_global_lock;
 	struct kib_net *net = peer_ni->ibp_ni->ni_data;
 	struct kib_dev *dev;
-	struct ib_qp_init_attr *init_qp_attr;
+	struct ib_qp_init_attr init_qp_attr = {};
 	struct kib_sched_info *sched;
 	struct ib_cq_init_attr cq_attr = {};
 	struct kib_conn *conn;
@@ -727,18 +727,11 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer_ni *peer_ni,
 	 */
 	cpt = sched->ibs_cpt;
 
-	init_qp_attr = kzalloc_cpt(sizeof(*init_qp_attr), GFP_NOFS, cpt);
-	if (!init_qp_attr) {
-		CERROR("Can't allocate qp_attr for %s\n",
-		       libcfs_nid2str(peer_ni->ibp_nid));
-		goto failed_0;
-	}
-
 	conn = kzalloc_cpt(sizeof(*conn), GFP_NOFS, cpt);
 	if (!conn) {
 		CERROR("Can't allocate connection for %s\n",
 		       libcfs_nid2str(peer_ni->ibp_nid));
-		goto failed_1;
+		goto failed_0;
 	}
 
 	conn->ibc_state = IBLND_CONN_INIT;
@@ -819,27 +812,27 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer_ni *peer_ni,
 		goto failed_2;
 	}
 
-	init_qp_attr->event_handler = kiblnd_qp_event;
-	init_qp_attr->qp_context = conn;
-	init_qp_attr->cap.max_send_sge = *kiblnd_tunables.kib_wrq_sge;
-	init_qp_attr->cap.max_recv_sge = 1;
-	init_qp_attr->sq_sig_type = IB_SIGNAL_REQ_WR;
-	init_qp_attr->qp_type = IB_QPT_RC;
-	init_qp_attr->send_cq = cq;
-	init_qp_attr->recv_cq = cq;
+	init_qp_attr.event_handler = kiblnd_qp_event;
+	init_qp_attr.qp_context = conn;
+	init_qp_attr.cap.max_send_sge = *kiblnd_tunables.kib_wrq_sge;
+	init_qp_attr.cap.max_recv_sge = 1;
+	init_qp_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
+	init_qp_attr.qp_type = IB_QPT_RC;
+	init_qp_attr.send_cq = cq;
+	init_qp_attr.recv_cq = cq;
 	/* kiblnd_send_wrs() can change the connection's queue depth if
 	 * the maximum work requests for the device is maxed out
 	 */
-	init_qp_attr->cap.max_send_wr = kiblnd_send_wrs(conn);
-	init_qp_attr->cap.max_recv_wr = IBLND_RECV_WRS(conn);
+	init_qp_attr.cap.max_send_wr = kiblnd_send_wrs(conn);
+	init_qp_attr.cap.max_recv_wr = IBLND_RECV_WRS(conn);
 
-	rc = rdma_create_qp(cmid, conn->ibc_hdev->ibh_pd, init_qp_attr);
+	rc = rdma_create_qp(cmid, conn->ibc_hdev->ibh_pd, &init_qp_attr);
 	if (rc) {
 		CERROR("Can't create QP: %d, send_wr: %d, recv_wr: %d, send_sge: %d, recv_sge: %d\n",
-		       rc, init_qp_attr->cap.max_send_wr,
-		       init_qp_attr->cap.max_recv_wr,
-		       init_qp_attr->cap.max_send_sge,
-		       init_qp_attr->cap.max_recv_sge);
+		       rc, init_qp_attr.cap.max_send_wr,
+		       init_qp_attr.cap.max_recv_wr,
+		       init_qp_attr.cap.max_send_sge,
+		       init_qp_attr.cap.max_recv_sge);
 		goto failed_2;
 	}
 
@@ -851,8 +844,6 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer_ni *peer_ni,
 		      peer_ni->ibp_queue_depth,
 		      conn->ibc_queue_depth);
 
-	kfree(init_qp_attr);
-
 	conn->ibc_rxs = kzalloc_cpt(IBLND_RX_MSGS(conn) *
 				    sizeof(*conn->ibc_rxs),
 				    GFP_NOFS, cpt);
@@ -918,8 +909,6 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer_ni *peer_ni,
 failed_2:
 	kiblnd_destroy_conn(conn);
 	kfree(conn);
-failed_1:
-	kfree(init_qp_attr);
 failed_0:
 	return NULL;
 }
Signature · 1 line
1.8.3.1
#10 lore raw

PATCH 10/37 lnet: Fix some out-of-date comments.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The structures these comments describe have changed or been removed, but the comments weren't updated at the time.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 617ad3af720a3 ("LU-12678 lnet: Fix some out-of-date comments.")

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

---
 net/lnet/klnds/socklnd/socklnd.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
net/lnet/klnds/socklnd/socklnd.h +4 -8
index 7d49fff..0ac3637 100644
@@ -255,15 +255,13 @@ struct ksock_nal_data {
 #define SOCKNAL_INIT_DATA	1
 #define SOCKNAL_INIT_ALL	2
 
-/*
- * A packet just assembled for transmission is represented by 1 or more
- * struct iovec fragments (the first frag contains the portals header),
- * followed by 0 or more struct bio_vec fragments.
+/* A packet just assembled for transmission is represented by 1
+ * struct iovec fragment - the portals header -  followed by 0
+ * or more struct bio_vec fragments.
  *
  * On the receive side, initially 1 struct iovec fragment is posted for
  * receive (the header).  Once the header has been received, the payload is
- * received into either struct iovec or struct bio_vec fragments, depending on
- * what the header matched or whether the message needs forwarding.
+ * received into struct bio_vec fragments.
  */
 struct ksock_conn;				/* forward ref */
 struct ksock_route;				/* forward ref */
@@ -296,8 +294,6 @@ struct ksock_tx {				/* transmit packet */
 
 #define KSOCK_NOOP_TX_SIZE (offsetof(struct ksock_tx, tx_payload[0]))
 
-/* network zero copy callback descriptor embedded in struct ksock_tx */
-
 #define SOCKNAL_RX_KSM_HEADER	1 /* reading ksock message header */
 #define SOCKNAL_RX_LNET_HEADER	2 /* reading lnet message header */
 #define SOCKNAL_RX_PARSE	3 /* Calling lnet_parse() */
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 11/37 lnet: socklnd: don't fall-back to tcp_sendpage.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

sk_prot->sendpage is never NULL, so there is no
need for a fallback to tcp_sendpage.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 011d760069142 ("LU-12678 socklnd: don't fall-back to tcp_sendpage.")

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

---
 net/lnet/klnds/socklnd/socklnd_lib.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/lnet/klnds/socklnd/socklnd_lib.c +2 -6
index 2adc99c..1d6cd0e 100644
@@ -123,12 +123,8 @@
 		    fragsize < tx->tx_resid)
 			msgflg |= MSG_MORE;
 
-		if (sk->sk_prot->sendpage) {
-			rc = sk->sk_prot->sendpage(sk, page,
-						   offset, fragsize, msgflg);
-		} else {
-			rc = tcp_sendpage(sk, page, offset, fragsize, msgflg);
-		}
+		rc = sk->sk_prot->sendpage(sk, page,
+					   offset, fragsize, msgflg);
 	} else {
 		struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 		int i;
Signature · 1 line
1.8.3.1
#12 lore raw

PATCH 12/37 lustre: ptlrpc: re-enterable signal_completed_replay()

In reply to James Simmons

From: Mikhail Pershin <[email protected]>

The signal_completed_replay() can meet race conditions while checking imp_replay_inflight counter, so remove assertion and check race conditions instead.

Fixes 8cc7f22847 ("lustre: ptlrpc: limit rate of lock replays")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13600
Lustre-commit: 24451f3790503 ("LU-13600 ptlrpc: re-enterable signal_completed_replay()")

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

---
 fs/lustre/ptlrpc/import.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/lustre/ptlrpc/import.c +2 -2
index 7ec3638..1b62b81 100644
@@ -1407,8 +1407,8 @@ static int signal_completed_replay(struct obd_import *imp)
 	if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_FINISH_REPLAY)))
 		return 0;
 
-	LASSERT(atomic_read(&imp->imp_replay_inflight) == 0);
-	atomic_inc(&imp->imp_replay_inflight);
+	if (!atomic_add_unless(&imp->imp_replay_inflight, 1, 1))
+		return 0;
 
 	req = ptlrpc_request_alloc_pack(imp, &RQF_OBD_PING, LUSTRE_OBD_VERSION,
 					OBD_PING);
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH 13/37 lustre: obdcalss: ensure LCT_QUIESCENT take sync

In reply to James Simmons

From: Yang Sheng <[email protected]>

Add locking in lu_device_init ensure LCT_QUIESCENT operating can be seen on other thread in parallel mounting. Also add extra checking before unset the flag to make sure we don't do it after device has been started.

(osd_handler.c:7730:osd_device_init0()) ASSERTION( info ) failed:
(osd_handler.c:7730:osd_device_init0()) LBUG
Pid: 28098, comm: mount.lustre 3.10.0-1062.9.1.el7_lustre.x86_64

Call Trace:
 libcfs_call_trace+0x8c/0xc0 [libcfs]
 lbug_with_loc+0x4c/0xa0 [libcfs]
 osd_device_alloc+0x778/0x8f0 [osd_ldiskfs]
 obd_setup+0x129/0x2f0 [obdclass]
 class_setup+0x48f/0x7f0 [obdclass]
 class_process_config+0x190f/0x2830 [obdclass]
 do_lcfg+0x258/0x500 [obdclass]
 lustre_start_simple+0x88/0x210 [obdclass]
 server_fill_super+0xf55/0x1890 [obdclass]
 lustre_fill_super+0x498/0x990 [obdclass]
 mount_nodev+0x4f/0xb0
 lustre_mount+0x18/0x20 [obdclass]
 mount_fs+0x3e/0x1b0
 vfs_kern_mount+0x67/0x110
 do_mount+0x1ef/0xce0
 SyS_mount+0x83/0xd0
 system_call_fastpath+0x25/0x2a
 0xffffffffffffffff
 Kernel panic - not syncing: LBUG

WC-bug-id: https://jira.whamcloud.com/browse/LU-11814
Lustre-commit: 979f5e1db041d ("LU-11814 obdcalss: ensure LCT_QUIESCENT take sync")

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

---
 fs/lustre/include/lu_object.h  |  8 +++---
 fs/lustre/obdclass/lu_object.c | 58 ++++++++++++++++++++++++------------------
 2 files changed, 38 insertions(+), 28 deletions(-)
fs/lustre/include/lu_object.h +5 -3
index 1a6b6e1..6c47f43 100644
@@ -1151,7 +1151,8 @@ struct lu_context_key {
 void lu_context_key_degister(struct lu_context_key *key);
 void *lu_context_key_get(const struct lu_context *ctx,
 			 const struct lu_context_key *key);
-void lu_context_key_quiesce(struct lu_context_key *key);
+void lu_context_key_quiesce(struct lu_device_type *t,
+			    struct lu_context_key *key);
 void lu_context_key_revive(struct lu_context_key *key);
 
 /*
@@ -1199,7 +1200,7 @@ void *lu_context_key_get(const struct lu_context *ctx,
 #define LU_TYPE_STOP(mod, ...)						\
 	static void mod##_type_stop(struct lu_device_type *t)		\
 	{								\
-		lu_context_key_quiesce_many(__VA_ARGS__, NULL);		\
+		lu_context_key_quiesce_many(t, __VA_ARGS__, NULL);	\
 	}								\
 	struct __##mod##_dummy_type_stop {; }
 
@@ -1223,7 +1224,8 @@ void *lu_context_key_get(const struct lu_context *ctx,
 int lu_context_key_register_many(struct lu_context_key *k, ...);
 void lu_context_key_degister_many(struct lu_context_key *k, ...);
 void lu_context_key_revive_many(struct lu_context_key *k, ...);
-void lu_context_key_quiesce_many(struct lu_context_key *k, ...);
+void lu_context_key_quiesce_many(struct lu_device_type *t,
+				 struct lu_context_key *k, ...);
 
 /*
  * update/clear ctx/ses tags.
fs/lustre/obdclass/lu_object.c +33 -25

109 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#14 lore raw

PATCH 14/37 lustre: remove some "#ifdef CONFIG*" from .c files.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

It is Linux policy to avoid #ifdef in C files where convenient - .h files are OK.

This patch defines a few inline functions which differ depending on CONFIG_LUSTRE_FS_POSIX_ACL, and removes some #ifdefs from .c files.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: f37e26964a34f ("LU-9679 lustre: remove some "#ifdef CONFIG*" from .c files.")

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

---
 fs/lustre/include/obd.h          | 21 ++++++++++++++++++++
 fs/lustre/llite/llite_internal.h | 29 +++++++++++++++++++++++++++
 fs/lustre/llite/llite_lib.c      | 43 +++++++++-------------------------------
 fs/lustre/mdc/mdc_request.c      |  8 +++-----
 4 files changed, 62 insertions(+), 39 deletions(-)
fs/lustre/include/obd.h +21 -0
index 438f4ca..ad2b2f4 100644
@@ -34,6 +34,8 @@
 #ifndef __OBD_H
 #define __OBD_H
 
+#include <linux/fs.h>
+#include <linux/posix_acl.h>
 #include <linux/kobject.h>
 #include <linux/spinlock.h>
 #include <linux/sysfs.h>
@@ -930,6 +932,25 @@ struct lustre_md {
 	struct mdt_remote_perm		*remote_perm;
 };
 
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+static inline void lmd_clear_acl(struct lustre_md *md)
+{
+	if (md->posix_acl) {
+		posix_acl_release(md->posix_acl);
+		md->posix_acl = NULL;
+	}
+}
+
+#define OBD_CONNECT_ACL_FLAGS  \
+	(OBD_CONNECT_ACL | OBD_CONNECT_UMASK | OBD_CONNECT_LARGE_ACL)
+#else
+static inline void lmd_clear_acl(struct lustre_md *md)
+{
+}
+
+#define OBD_CONNECT_ACL_FLAGS  (0)
+#endif
+
 struct md_open_data {
 	struct obd_client_handle	*mod_och;
 	struct ptlrpc_request		*mod_open_req;
fs/lustre/llite/llite_internal.h +29 -0
index 2556dd8..31c528f 100644
@@ -350,6 +350,35 @@ static inline void trunc_sem_up_write(struct ll_trunc_sem *sem)
 	wake_up_var(&sem->ll_trunc_readers);
 }
 
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+static inline void lli_clear_acl(struct ll_inode_info *lli)
+{
+	if (lli->lli_posix_acl) {
+		posix_acl_release(lli->lli_posix_acl);
+		lli->lli_posix_acl = NULL;
+	}
+}
+
+static inline void lli_replace_acl(struct ll_inode_info *lli,
+				   struct lustre_md *md)
+{
+	spin_lock(&lli->lli_lock);
+	if (lli->lli_posix_acl)
+		posix_acl_release(lli->lli_posix_acl);
+	lli->lli_posix_acl = md->posix_acl;
+	spin_unlock(&lli->lli_lock);
+}
+#else
+static inline void lli_clear_acl(struct ll_inode_info *lli)
+{
+}
+
+static inline void lli_replace_acl(struct ll_inode_info *lli,
+				   struct lustre_md *md)
+{
+}
+#endif
+
 static inline u32 ll_layout_version_get(struct ll_inode_info *lli)
 {
 	u32 gen;
fs/lustre/llite/llite_lib.c +9 -34

73 lines not on this page · raw message

fs/lustre/mdc/mdc_request.c +3 -5
index d6d9f43..cacc58b 100644
@@ -675,11 +675,9 @@ static int mdc_get_lustre_md(struct obd_export *exp,
 	}
 
 out:
-	if (rc) {
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-		posix_acl_release(md->posix_acl);
-#endif
-	}
+	if (rc)
+		lmd_clear_acl(md);
+
 	return rc;
 }
 
Signature · 1 line
1.8.3.1
#15 lore raw

PATCH 15/37 lustre: obdclass: use offset instead of cp_linkage

In reply to James Simmons

From: Wang Shilong <[email protected]>

Since we have fixed-size cl_page allocations, we could use offset array to store every slices pointer for cl_page.

With this patch, we will reduce cl_page size from 392 bytes to 336 bytes which means we could allocate from 10 to 12 objects.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13134
Lustre-commit: 55967f1e5c701 ("LU-13134 obdclass: use offset instead of cp_linkage")

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

---
 fs/lustre/include/cl_object.h |   8 +-
 fs/lustre/obdclass/cl_page.c  | 284 ++++++++++++++++++++++++------------------
 2 files changed, 168 insertions(+), 124 deletions(-)
fs/lustre/include/cl_object.h +4 -4
index a0b9e87..47997f8 100644
@@ -737,8 +737,10 @@ struct cl_page {
 	struct page			*cp_vmpage;
 	/** Linkage of pages within group. Pages must be owned */
 	struct list_head		 cp_batch;
-	/** List of slices. Immutable after creation. */
-	struct list_head		 cp_layers;
+	/** array of slices offset. Immutable after creation. */
+	unsigned char			 cp_layer_offset[3];
+	/** current slice index */
+	unsigned char			 cp_layer_count:2;
 	/**
 	 * Page state. This field is const to avoid accidental update, it is
 	 * modified only internally within cl_page.c. Protected by a VM lock.
@@ -781,8 +783,6 @@ struct cl_page_slice {
 	 */
 	struct cl_object		*cpl_obj;
 	const struct cl_page_operations *cpl_ops;
-	/** Linkage into cl_page::cp_layers. Immutable after creation. */
-	struct list_head		 cpl_linkage;
 };
 
 /**
fs/lustre/obdclass/cl_page.c +164 -120

603 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#16 lore raw

PATCH 16/37 lustre: obdclass: re-declare cl_page variables to reduce its size

In reply to James Simmons

From: Wang Shilong <[email protected]>

With following changes:
1) make CPS_CACHED declare start from 1 consistent with CPT_CACHED
2) add CPT_NR to indicate max allowed CPT state value.
3) Reserve 4 bits for @cp_state which allow 15 kind of states
4) Reserve 2 bits for @cp_type which allow 3 kinds of cl_page types
5) use short int for @cp_kmem_index and We still have another 16 bits reserved for future extension.
6) move @cp_lov_index after @cp_ref to fill 4 bytes hole.

After this patch, cl_page size could reduce from 336 bytes to 320 bytes

WC-bug-id: https://jira.whamcloud.com/browse/LU-13134
Lustre-commit: 5fb29cd1e77ca ("LU-13134 obdclass: re-declare cl_page variables to reduce its size")

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

---
 fs/lustre/include/cl_object.h | 26 +++++++++------
 fs/lustre/obdclass/cl_page.c  | 76 +++++++++++++++++++++----------------------
 2 files changed, 53 insertions(+), 49 deletions(-)
fs/lustre/include/cl_object.h +16 -10
index 47997f8..8611285 100644
@@ -621,7 +621,7 @@ enum cl_page_state {
 	 *
 	 * \invariant cl_page::cp_owner == NULL && cl_page::cp_req == NULL
 	 */
-	CPS_CACHED,
+	CPS_CACHED = 1,
 	/**
 	 * Page is exclusively owned by some cl_io. Page may end up in this
 	 * state as a result of
@@ -715,8 +715,13 @@ enum cl_page_type {
 	 *  it is used in DirectIO and lockless IO.
 	 */
 	CPT_TRANSIENT,
+	CPT_NR
 };
 
+#define	CP_STATE_BITS	4
+#define	CP_TYPE_BITS	2
+#define	CP_MAX_LAYER	3
+
 /**
  * Fields are protected by the lock on struct page, except for atomics and
  * immutables.
@@ -729,8 +734,9 @@ enum cl_page_type {
 struct cl_page {
 	/** Reference counter. */
 	refcount_t			 cp_ref;
-	/* which slab kmem index this memory allocated from */
-	int				 cp_kmem_index;
+	/** layout_entry + stripe index, composed using lov_comp_index() */
+	unsigned int			 cp_lov_index;
+	pgoff_t				 cp_osc_index;
 	/** An object this page is a part of. Immutable after creation. */
 	struct cl_object		*cp_obj;
 	/** vmpage */
@@ -738,19 +744,22 @@ struct cl_page {
 	/** Linkage of pages within group. Pages must be owned */
 	struct list_head		 cp_batch;
 	/** array of slices offset. Immutable after creation. */
-	unsigned char			 cp_layer_offset[3];
+	unsigned char			 cp_layer_offset[CP_MAX_LAYER]; /* 24 bits */
 	/** current slice index */
-	unsigned char			 cp_layer_count:2;
+	unsigned char			 cp_layer_count:2; /* 26 bits */
 	/**
 	 * Page state. This field is const to avoid accidental update, it is
 	 * modified only internally within cl_page.c. Protected by a VM lock.
 	 */
-	const enum cl_page_state	 cp_state;
+	enum cl_page_state		 cp_state:CP_STATE_BITS; /* 30 bits */
 	/**
 	 * Page type. Only CPT_TRANSIENT is used so far. Immutable after
 	 * creation.
 	 */
-	enum cl_page_type		 cp_type;
+	enum cl_page_type		 cp_type:CP_TYPE_BITS; /* 32 bits */
+	/* which slab kmem index this memory allocated from */
+	short int			 cp_kmem_index; /* 48 bits */
+	unsigned int			 cp_unused1:16; /* 64 bits */
 
 	/**
 	 * Owning IO in cl_page_state::CPS_OWNED state. Sub-page can be owned
@@ -765,9 +774,6 @@ struct cl_page {
 	struct lu_ref_link		 cp_queue_ref;
 	/** Assigned if doing a sync_io */
 	struct cl_sync_io		*cp_sync_io;
-	/** layout_entry + stripe index, composed using lov_comp_index() */
-	unsigned int			 cp_lov_index;
-	pgoff_t				 cp_osc_index;
 };
 
 /**
fs/lustre/obdclass/cl_page.c +37 -39

123 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 17/37 lustre: osc: re-declare ops_from/to to shrink osc_page

In reply to James Simmons

From: Wang Shilong <[email protected]>

@ops_from and @ops_to is within PAGE_SIZE, use PAGE_SHIFT bits to limit it is fine, on x86_64 platform, this patch will reduce another 8 bytes.

Notice, previous @ops_to is exclusive which could be PAGE_SIZE, this patch change it to inclusive which means max value will be PAGE_SIZE - 1, and be careful to calculate its length.

After this patch, cl_page size could reduce from 320 to 312 bytes, and we are able to allocate 13 objects using slab pool for 4K page.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13134
Lustre-commit: 9821754235e24 ("LU-13134 osc: re-declare ops_from/to to shrink osc_page")

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

---
 fs/lustre/include/lustre_osc.h |  8 ++++----
 fs/lustre/osc/osc_cache.c      |  5 +++--
 fs/lustre/osc/osc_page.c       | 21 +++++++++++----------
 3 files changed, 18 insertions(+), 16 deletions(-)
fs/lustre/include/lustre_osc.h +4 -4
index cd08f27..3956ab4 100644
@@ -507,17 +507,17 @@ struct osc_page {
 	 * An offset within page from which next transfer starts. This is used
 	 * by cl_page_clip() to submit partial page transfers.
 	 */
-	int			ops_from;
+	unsigned int		ops_from:PAGE_SHIFT,
 	/*
-	 * An offset within page at which next transfer ends.
+	 * An offset within page at which next transfer ends(inclusive).
 	 *
 	 * \see osc_page::ops_from.
 	 */
-	int			ops_to;
+				ops_to:PAGE_SHIFT,
 	/*
 	 * Boolean, true iff page is under transfer. Used for sanity checking.
 	 */
-	unsigned		ops_transfer_pinned:1,
+				ops_transfer_pinned:1,
 	/*
 	 * in LRU?
 	 */
fs/lustre/osc/osc_cache.c +3 -2
index f811dadb..fe03c0d 100644
@@ -2395,7 +2395,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
 
 	oap->oap_cmd = cmd;
 	oap->oap_page_off = ops->ops_from;
-	oap->oap_count = ops->ops_to - ops->ops_from;
+	oap->oap_count = ops->ops_to - ops->ops_from + 1;
 	/*
 	 * No need to hold a lock here,
 	 * since this page is not in any list yet.
@@ -2664,7 +2664,8 @@ int osc_queue_sync_pages(const struct lu_env *env, const struct cl_io *io,
 		++page_count;
 		mppr <<= (page_count > mppr);
 
-		if (unlikely(opg->ops_from > 0 || opg->ops_to < PAGE_SIZE))
+		if (unlikely(opg->ops_from > 0 ||
+			     opg->ops_to < PAGE_SIZE - 1))
 			can_merge = false;
 	}
 
fs/lustre/osc/osc_page.c +11 -10
index 2856f30..bb605af 100644
@@ -211,7 +211,8 @@ static void osc_page_clip(const struct lu_env *env,
 	struct osc_async_page *oap = &opg->ops_oap;
 
 	opg->ops_from = from;
-	opg->ops_to = to;
+	/* argument @to is exclusive, but @ops_to is inclusive */
+	opg->ops_to = to - 1;
 	spin_lock(&oap->oap_lock);
 	oap->oap_async_flags |= ASYNC_COUNT_STABLE;
 	spin_unlock(&oap->oap_lock);
@@ -246,28 +247,28 @@ static void osc_page_touch(const struct lu_env *env,
 };
 
 int osc_page_init(const struct lu_env *env, struct cl_object *obj,
-		  struct cl_page *page, pgoff_t index)
+		  struct cl_page *cl_page, pgoff_t index)
 {
 	struct osc_object *osc = cl2osc(obj);
-	struct osc_page *opg = cl_object_page_slice(obj, page);
+	struct osc_page *opg = cl_object_page_slice(obj, cl_page);
 	struct osc_io *oio = osc_env_io(env);
 	int result;
 
 	opg->ops_from = 0;
-	opg->ops_to = PAGE_SIZE;
+	opg->ops_to = PAGE_SIZE - 1;
 	INIT_LIST_HEAD(&opg->ops_lru);
 
-	result = osc_prep_async_page(osc, opg, page->cp_vmpage,
+	result = osc_prep_async_page(osc, opg, cl_page->cp_vmpage,
 				     cl_offset(obj, index));
 	if (result != 0)
 		return result;
 
 	opg->ops_srvlock = osc_io_srvlock(oio);
-	cl_page_slice_add(page, &opg->ops_cl, obj, &osc_page_ops);
-	page->cp_osc_index = index;
+	cl_page_slice_add(cl_page, &opg->ops_cl, obj, &osc_page_ops);
+	cl_page->cp_osc_index = index;
 
-	/* reserve an LRU space for this page */
-	if (page->cp_type == CPT_CACHEABLE) {
+	/* reserve an LRU space for this cl_page */
+	if (cl_page->cp_type == CPT_CACHEABLE) {
 		result = osc_lru_alloc(env, osc_cli(osc), opg);
 		if (result == 0) {
 			result = radix_tree_preload(GFP_KERNEL);
@@ -308,7 +309,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
 
 	oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ;
 	oap->oap_page_off = opg->ops_from;
-	oap->oap_count = opg->ops_to - opg->ops_from;
+	oap->oap_count = opg->ops_to - opg->ops_from + 1;
 	oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags;
 
 	if (oio->oi_cap_sys_resource) {
Signature · 1 line
1.8.3.1
#18 lore raw

PATCH 18/37 lustre: llite: Fix lock ordering in pagevec_dirty

In reply to James Simmons

From: Shaun Tancheff <[email protected]>

In vvp_set_pagevec_dirty lock order between i_pages and lock_page_memcg was inverted with the expectation that no other users would conflict.

However in vvp_page_completion_write the call to test_clear_page_writeback does expect to be able to lock_page_memcg then lock i_pages which appears to conflict with the original analysis.

The reported case shows as RCU stalls with vvp_set_pagevec_dirty blocked attempting to lock i_pages.

Fixes f8a5fb036ae ("lustre: vvp: dirty pages with pagevec")

HPE-bug-id: LUS-8798
WC-bug-id: https://jira.whamcloud.com/browse/LU-13746
Lustre-commit: c4ed9b0fb1013 ("LU-13476 llite: Fix lock ordering in pagevec_dirty")

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

---
 fs/lustre/llite/vvp_io.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)
fs/lustre/llite/vvp_io.c +21 -13
index 8edd3c1..7627431 100644
@@ -897,19 +897,31 @@ void vvp_set_pagevec_dirty(struct pagevec *pvec)
 	struct page *page = pvec->pages[0];
 	struct address_space *mapping = page->mapping;
 	unsigned long flags;
+	unsigned long skip_pages = 0;
 	int count = pagevec_count(pvec);
 	int dirtied = 0;
-	int i = 0;
-
-	/* From set_page_dirty */
-	for (i = 0; i < count; i++)
-		ClearPageReclaim(pvec->pages[i]);
+	int i;
 
+	BUILD_BUG_ON(PAGEVEC_SIZE > BITS_PER_LONG);
 	LASSERTF(page->mapping,
 		 "mapping must be set. page %p, page->private (cl_page) %p\n",
 		 page, (void *) page->private);
 
-	/* Rest of code derived from __set_page_dirty_nobuffers */
+	for (i = 0; i < count; i++) {
+		page = pvec->pages[i];
+
+		ClearPageReclaim(page);
+
+		lock_page_memcg(page);
+		if (TestSetPageDirty(page)) {
+			/* page is already dirty .. no extra work needed
+			 * set a flag for the i'th page to be skipped
+			 */
+			unlock_page_memcg(page);
+			skip_pages |= (1 << i);
+		}
+	}
+
 	xa_lock_irqsave(&mapping->i_pages, flags);
 
 	/* Notes on differences with __set_page_dirty_nobuffers:
@@ -920,17 +932,13 @@ void vvp_set_pagevec_dirty(struct pagevec *pvec)
 	 * 3. No mapping is impossible. (Race w/truncate mentioned in
 	 * dirty_nobuffers should be impossible because we hold the page lock.)
 	 * 4. All mappings are the same because i/o is only to one file.
-	 * 5. We invert the lock order on lock_page_memcg(page) and the mapping
-	 * xa_lock, but this is the only function that should use that pair of
-	 * locks and it can't race because Lustre locks pages throughout i/o.
 	 */
 	for (i = 0; i < count; i++) {
 		page = pvec->pages[i];
-		lock_page_memcg(page);
-		if (TestSetPageDirty(page)) {
-			unlock_page_memcg(page);
+		/* if the i'th page was unlocked above, skip it here */
+		if ((skip_pages >> i) & 1)
 			continue;
-		}
+
 		LASSERTF(page->mapping == mapping,
 			 "all pages must have the same mapping.  page %p, mapping %p, first mapping %p\n",
 			 page, page->mapping, mapping);
Signature · 1 line
1.8.3.1
#19 lore raw

PATCH 19/37 lustre: misc: quiet compiler warning on armv7l

In reply to James Simmons

From: Andreas Dilger <[email protected]>

Avoid overflow in lu_prandom_u64_max().

Quiet printk() warning for mismatched type of size_t variables by using %z modifier for those variables.

Fixes bc2e21c54ba2 ("lustre: obdclass: generate random u64 max correctly")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13673
Lustre-commit: 57bb302461383 ("LU-13673 misc: quiet compiler warning on armv7l")

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

---
 fs/lustre/llite/vvp_io.c          | 4 ++--
 fs/lustre/obdclass/lu_tgt_descs.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/lustre/llite/vvp_io.c +2 -2
index 7627431..c3fb03a 100644
@@ -791,7 +791,7 @@ static int vvp_io_read_start(const struct lu_env *env,
 		goto out;
 
 	LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu,
-			 "Read ino %lu, %lu bytes, offset %lld, size %llu\n",
+			 "Read ino %lu, %zu bytes, offset %lld, size %llu\n",
 			 inode->i_ino, cnt, pos, i_size_read(inode));
 
 	/* turn off the kernel's read-ahead */
@@ -1197,7 +1197,7 @@ static int vvp_io_write_start(const struct lu_env *env,
 	}
 	if (vio->vui_iocb->ki_pos != (pos + io->ci_nob - nob)) {
 		CDEBUG(D_VFSTRACE,
-		       "%s: write position mismatch: ki_pos %lld vs. pos %lld, written %ld, commit %ld rc %ld\n",
+		       "%s: write position mismatch: ki_pos %lld vs. pos %lld, written %zd, commit %zd rc %zd\n",
 		       file_dentry(file)->d_name.name,
 		       vio->vui_iocb->ki_pos, pos + io->ci_nob - nob,
 		       written, io->ci_nob - nob, result);
fs/lustre/obdclass/lu_tgt_descs.c +1 -1
index db5a93b..469c935 100644
@@ -62,7 +62,7 @@ u64 lu_prandom_u64_max(u64 ep_ro)
 		 * 32 bits (truncated to the upper limit, if needed)
 		 */
 		if (ep_ro > 0xffffffffULL)
-			rand = prandom_u32_max((u32)(ep_ro >> 32)) << 32;
+			rand = (u64)prandom_u32_max((u32)(ep_ro >> 32)) << 32;
 
 		if (rand == (ep_ro & 0xffffffff00000000ULL))
 			rand |= prandom_u32_max((u32)ep_ro);
Signature · 1 line
1.8.3.1
#20 lore raw

PATCH 20/37 lustre: llite: fix to free cl_dio_aio properly

In reply to James Simmons

From: Wang Shilong <[email protected]>

@cl_dio_aio is allocated by slab, we should use slab free helper to free its memory.

Fixes ebdbecbaf50b ("lustre: obdclass: use slab allocation for cl_dio_aio")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13134
Lustre-commit: f71a539c3e41b ("LU-13134 llite: fix to free cl_dio_aio properly")

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

---
 fs/lustre/include/cl_object.h |  2 ++
 fs/lustre/llite/rw26.c        |  2 +-
 fs/lustre/obdclass/cl_io.c    | 10 ++++++++--
 3 files changed, 11 insertions(+), 3 deletions(-)
fs/lustre/include/cl_object.h +2 -0
index 8611285..e656c68 100644
@@ -2538,6 +2538,8 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor,
 void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
 		     int ioret);
 struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb);
+void cl_aio_free(struct cl_dio_aio *aio);
+
 static inline void cl_sync_io_init(struct cl_sync_io *anchor, int nr)
 {
 	cl_sync_io_init_notify(anchor, nr, NULL, NULL);
fs/lustre/llite/rw26.c +1 -1
index 0971185..d0e3ff6 100644
@@ -384,7 +384,7 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 			vio->u.write.vui_written += tot_bytes;
 			result = tot_bytes;
 		}
-		kfree(aio);
+		cl_aio_free(aio);
 	} else {
 		result = -EIOCBQUEUED;
 	}
fs/lustre/obdclass/cl_io.c +8 -2
index 2f597d1..dcf940f 100644
@@ -1106,6 +1106,13 @@ struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb)
 }
 EXPORT_SYMBOL(cl_aio_alloc);
 
+void cl_aio_free(struct cl_dio_aio *aio)
+{
+	if (aio)
+		kmem_cache_free(cl_dio_aio_kmem, aio);
+}
+EXPORT_SYMBOL(cl_aio_free);
+
 /**
  * Indicate that transfer of a single page completed.
  */
@@ -1143,8 +1150,7 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
 		 * If anchor->csi_aio is set, we are responsible for freeing
 		 * memory here rather than when cl_sync_io_wait() completes.
 		 */
-		if (aio)
-			kmem_cache_free(cl_dio_aio_kmem, aio);
+		cl_aio_free(aio);
 	}
 }
 EXPORT_SYMBOL(cl_sync_io_note);
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH 21/37 lnet: o2iblnd: Use ib_mtu_int_to_enum()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Rather than bespoke code for converting an MTU into the enum, use ib_mtu_int_to_enum().
This has slightly different behaviour for invalid values, but those are caught when the parameter is set.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 1b622e2007483 ("LU-12678 o2iblnd: Use ib_mtu_int_to_enum()")

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

---
 net/lnet/klnds/o2iblnd/o2iblnd.c           | 29 +++--------------------------
 net/lnet/klnds/o2iblnd/o2iblnd_modparams.c |  4 +++-
 2 files changed, 6 insertions(+), 27 deletions(-)
net/lnet/klnds/o2iblnd/o2iblnd.c +3 -26
index d8fca2a..e2e94b7 100644
@@ -560,38 +560,15 @@ static struct kib_conn *kiblnd_get_conn_by_idx(struct lnet_ni *ni, int index)
 	return NULL;
 }
 
-int kiblnd_translate_mtu(int value)
-{
-	switch (value) {
-	default:
-		return -1;
-	case 0:
-		return 0;
-	case 256:
-		return IB_MTU_256;
-	case 512:
-		return IB_MTU_512;
-	case 1024:
-		return IB_MTU_1024;
-	case 2048:
-		return IB_MTU_2048;
-	case 4096:
-		return IB_MTU_4096;
-	}
-}
-
 static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
 {
-	int mtu;
-
 	/* XXX There is no path record for iWARP, set by netdev->change_mtu? */
 	if (!cmid->route.path_rec)
 		return;
 
-	mtu = kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu);
-	LASSERT(mtu >= 0);
-	if (mtu)
-		cmid->route.path_rec->mtu = mtu;
+	if (*kiblnd_tunables.kib_ib_mtu)
+		cmid->route.path_rec->mtu =
+			ib_mtu_int_to_enum(*kiblnd_tunables.kib_ib_mtu);
 }
 
 static int kiblnd_get_completion_vector(struct kib_conn *conn, int cpt)
net/lnet/klnds/o2iblnd/o2iblnd_modparams.c +3 -1
index f341376..73ad22d 100644
@@ -230,7 +230,9 @@ int kiblnd_tunables_setup(struct lnet_ni *ni)
 	/* Current API version */
 	tunables->lnd_version = 0;
 
-	if (kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu) < 0) {
+	if (*kiblnd_tunables.kib_ib_mtu &&
+	    ib_mtu_enum_to_int(ib_mtu_int_to_enum(*kiblnd_tunables.kib_ib_mtu)) !=
+	    *kiblnd_tunables.kib_ib_mtu) {
 		CERROR("Invalid ib_mtu %d, expected 256/512/1024/2048/4096\n",
 		       *kiblnd_tunables.kib_ib_mtu);
 		return -EINVAL;
Signature · 1 line
1.8.3.1
#22 lore raw

PATCH 22/37 lnet: o2iblnd: wait properly for fps->increasing.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

If we need to allocate a new fmr_pool and another thread is currently allocating one, we call schedule() and then try again. This can spin, consuming a CPU and wasting power.

Instead, use wait_var_event() and wake_up_var() to wait for fps_increasing to be cleared.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 530eca31556f7 ("LU-12768 o2iblnd: wait properly for fps->increasing.")

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

---
 net/lnet/klnds/o2iblnd/o2iblnd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/lnet/klnds/o2iblnd/o2iblnd.c +2 -1
index e2e94b7..6c7659c 100644
@@ -1750,7 +1750,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 	if (fps->fps_increasing) {
 		spin_unlock(&fps->fps_lock);
 		CDEBUG(D_NET, "Another thread is allocating new FMR pool, waiting for her to complete\n");
-		schedule();
+		wait_var_event(fps, !fps->fps_increasing);
 		goto again;
 	}
 
@@ -1767,6 +1767,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 	rc = kiblnd_create_fmr_pool(fps, &fpo);
 	spin_lock(&fps->fps_lock);
 	fps->fps_increasing = 0;
+	wake_up_var(fps);
 	if (!rc) {
 		fps->fps_version++;
 		list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH 23/37 lnet: o2iblnd: use need_resched()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Rather than using a counter to decide when to drop the lock and see if we need to reshedule we can
use need_resched(), which is a precise test instead of a guess.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: dcd799269f693 ("LU-12678 o2iblnd: use need_resched()")

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

---
 net/lnet/klnds/o2iblnd/o2iblnd.h    | 2 --
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 5 +----
 2 files changed, 1 insertion(+), 6 deletions(-)
net/lnet/klnds/o2iblnd/o2iblnd.h +0 -2
index f60a69d..9a2fb42 100644
@@ -67,8 +67,6 @@
 #include <linux/lnet/lib-lnet.h>
 
 #define IBLND_PEER_HASH_SIZE		101	/* # peer_ni lists */
-/* # scheduler loops before reschedule */
-#define IBLND_RESCHED			100
 
 #define IBLND_N_SCHED			2
 #define IBLND_N_SCHED_HIGH		4
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +1 -4
index 3b9d10d..2c670a33 100644
@@ -3605,7 +3605,6 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 	unsigned long flags;
 	struct ib_wc wc;
 	int did_something;
-	int busy_loops = 0;
 	int rc;
 
 	init_waitqueue_entry(&wait, current);
@@ -3621,11 +3620,10 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 	spin_lock_irqsave(&sched->ibs_lock, flags);
 
 	while (!kiblnd_data.kib_shutdown) {
-		if (busy_loops++ >= IBLND_RESCHED) {
+		if (need_resched()) {
 			spin_unlock_irqrestore(&sched->ibs_lock, flags);
 
 			cond_resched();
-			busy_loops = 0;
 
 			spin_lock_irqsave(&sched->ibs_lock, flags);
 		}
@@ -3718,7 +3716,6 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 		spin_unlock_irqrestore(&sched->ibs_lock, flags);
 
 		schedule();
-		busy_loops = 0;
 
 		remove_wait_queue(&sched->ibs_waitq, &wait);
 		spin_lock_irqsave(&sched->ibs_lock, flags);
Signature · 1 line
1.8.3.1
#24 lore raw

PATCH 24/37 lnet: o2iblnd: Use list_for_each_entry_safe

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Several loops use list_for_each_safe(), then call list_entry() as first step.
These can be merged using list_for_each_entry_safe().

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: e5574f72f2fd9 ("LU-12678 o2iblnd: Use list_for_each_entry_safe")

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

---
 net/lnet/klnds/o2iblnd/o2iblnd.c    | 26 ++++++++++----------------
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c |  7 ++-----
 2 files changed, 12 insertions(+), 21 deletions(-)
net/lnet/klnds/o2iblnd/o2iblnd.c +10 -16
index 6c7659c..c6a077b 100644
@@ -454,18 +454,16 @@ static int kiblnd_get_peer_info(struct lnet_ni *ni, int index,
 
 static void kiblnd_del_peer_locked(struct kib_peer_ni *peer_ni)
 {
-	struct list_head *ctmp;
-	struct list_head *cnxt;
+	struct kib_conn *cnxt;
 	struct kib_conn *conn;
 
 	if (list_empty(&peer_ni->ibp_conns)) {
 		kiblnd_unlink_peer_locked(peer_ni);
 	} else {
-		list_for_each_safe(ctmp, cnxt, &peer_ni->ibp_conns) {
-			conn = list_entry(ctmp, struct kib_conn, ibc_list);
-
+		list_for_each_entry_safe(conn, cnxt, &peer_ni->ibp_conns,
+					 ibc_list)
 			kiblnd_close_conn_locked(conn, 0);
-		}
+
 		/* NB closing peer_ni's last conn unlinked it. */
 	}
 	/*
@@ -952,13 +950,11 @@ void kiblnd_destroy_conn(struct kib_conn *conn)
 int kiblnd_close_peer_conns_locked(struct kib_peer_ni *peer_ni, int why)
 {
 	struct kib_conn *conn;
-	struct list_head *ctmp;
-	struct list_head *cnxt;
+	struct kib_conn *cnxt;
 	int count = 0;
 
-	list_for_each_safe(ctmp, cnxt, &peer_ni->ibp_conns) {
-		conn = list_entry(ctmp, struct kib_conn, ibc_list);
-
+	list_for_each_entry_safe(conn, cnxt, &peer_ni->ibp_conns,
+				 ibc_list) {
 		CDEBUG(D_NET, "Closing conn -> %s, version: %x, reason: %d\n",
 		       libcfs_nid2str(peer_ni->ibp_nid),
 		       conn->ibc_version, why);
@@ -974,13 +970,11 @@ int kiblnd_close_stale_conns_locked(struct kib_peer_ni *peer_ni,
 				    int version, u64 incarnation)
 {
 	struct kib_conn *conn;
-	struct list_head *ctmp;
-	struct list_head *cnxt;
+	struct kib_conn *cnxt;
 	int count = 0;
 
-	list_for_each_safe(ctmp, cnxt, &peer_ni->ibp_conns) {
-		conn = list_entry(ctmp, struct kib_conn, ibc_list);
-
+	list_for_each_entry_safe(conn, cnxt, &peer_ni->ibp_conns,
+				 ibc_list) {
 		if (conn->ibc_version == version &&
 		    conn->ibc_incarnation == incarnation)
 			continue;
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +2 -5
index 2c670a33..ba2f46f 100644
@@ -1982,15 +1982,12 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 kiblnd_abort_txs(struct kib_conn *conn, struct list_head *txs)
 {
 	LIST_HEAD(zombies);
-	struct list_head *tmp;
-	struct list_head *nxt;
+	struct kib_tx *nxt;
 	struct kib_tx *tx;
 
 	spin_lock(&conn->ibc_lock);
 
-	list_for_each_safe(tmp, nxt, txs) {
-		tx = list_entry(tmp, struct kib_tx, tx_list);
-
+	list_for_each_entry_safe(tx, nxt, txs, tx_list) {
 		if (txs == &conn->ibc_active_txs) {
 			LASSERT(!tx->tx_queued);
 			LASSERT(tx->tx_waiting || tx->tx_sending);
Signature · 1 line
1.8.3.1
#25 lore raw

PATCH 25/37 lnet: socklnd: use need_resched()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Rather than using a counter to decide when to drop the lock and see if we need to reshedule we can use need_resched(), which is a precise test instead of a guess.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 3f848f85ba3d3 ("LU-12678 socklnd: use need_resched()")

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

---
 net/lnet/klnds/socklnd/socklnd.h    |  1 -
 net/lnet/klnds/socklnd/socklnd_cb.c | 12 +++---------
 2 files changed, 3 insertions(+), 10 deletions(-)
net/lnet/klnds/socklnd/socklnd.h +0 -1
index 0ac3637..0a0f0a7 100644
@@ -55,7 +55,6 @@
 #define SOCKNAL_NSCHEDS_HIGH	(SOCKNAL_NSCHEDS << 1)
 
 #define SOCKNAL_PEER_HASH_BITS	7     /* # log2 of # of peer_ni lists */
-#define SOCKNAL_RESCHED		100   /* # scheduler loops before reschedule */
 #define SOCKNAL_INSANITY_RECONN	5000  /* connd is trying on reconn infinitely */
 #define SOCKNAL_ENOMEM_RETRY	1     /* seconds between retries */
 
net/lnet/klnds/socklnd/socklnd_cb.c +3 -9
index 623478c..936054ee 100644
@@ -1328,7 +1328,6 @@ int ksocknal_scheduler(void *arg)
 	struct ksock_conn *conn;
 	struct ksock_tx *tx;
 	int rc;
-	int nloops = 0;
 	long id = (long)arg;
 
 	sched = ksocknal_data.ksnd_schedulers[KSOCK_THREAD_CPT(id)];
@@ -1470,12 +1469,10 @@ int ksocknal_scheduler(void *arg)
 
 			did_something = 1;
 		}
-		if (!did_something ||		/* nothing to do */
-		    ++nloops == SOCKNAL_RESCHED) { /* hogging CPU? */
+		if (!did_something ||	/* nothing to do */
+		    need_resched()) {	/* hogging CPU? */
 			spin_unlock_bh(&sched->kss_lock);
 
-			nloops = 0;
-
 			if (!did_something) {   /* wait for something to do */
 				rc = wait_event_interruptible_exclusive(
 					sched->kss_waitq,
@@ -2080,7 +2077,6 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 	spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock;
 	struct ksock_connreq *cr;
 	wait_queue_entry_t wait;
-	int nloops = 0;
 	int cons_retry = 0;
 
 	init_waitqueue_entry(&wait, current);
@@ -2158,10 +2154,9 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 		}
 
 		if (dropped_lock) {
-			if (++nloops < SOCKNAL_RESCHED)
+			if (!need_resched())
 				continue;
 			spin_unlock_bh(connd_lock);
-			nloops = 0;
 			cond_resched();
 			spin_lock_bh(connd_lock);
 			continue;
@@ -2173,7 +2168,6 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 					 &wait);
 		spin_unlock_bh(connd_lock);
 
-		nloops = 0;
 		schedule_timeout(timeout);
 
 		remove_wait_queue(&ksocknal_data.ksnd_connd_waitq, &wait);
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH 26/37 lnet: socklnd: use list_for_each_entry_safe()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Several loops use list_for_each_safe(), then call list_entry() as first step. These can be merged using list_for_each_entry_safe().

In one case, the 'safe' version is clearly not needed, so just use list_for_each_entry().

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 03f375e9f6390 ("LU-12678 socklnd: use list_for_each_entry_safe()")

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

---
 net/lnet/klnds/socklnd/socklnd.c | 55 ++++++++++++++--------------------------
 1 file changed, 19 insertions(+), 36 deletions(-)
net/lnet/klnds/socklnd/socklnd.c +19 -36
index 2b8fd3d..2e11737 100644
@@ -453,15 +453,12 @@ struct ksock_peer_ni *
 	struct ksock_peer_ni *peer_ni = route->ksnr_peer;
 	struct ksock_interface *iface;
 	struct ksock_conn *conn;
-	struct list_head *ctmp;
-	struct list_head *cnxt;
+	struct ksock_conn *cnxt;
 
 	LASSERT(!route->ksnr_deleted);
 
 	/* Close associated conns */
-	list_for_each_safe(ctmp, cnxt, &peer_ni->ksnp_conns) {
-		conn = list_entry(ctmp, struct ksock_conn, ksnc_list);
-
+	list_for_each_entry_safe(conn, cnxt, &peer_ni->ksnp_conns, ksnc_list) {
 		if (conn->ksnc_route != route)
 			continue;
 
@@ -548,9 +545,9 @@ struct ksock_peer_ni *
 ksocknal_del_peer_locked(struct ksock_peer_ni *peer_ni, u32 ip)
 {
 	struct ksock_conn *conn;
+	struct ksock_conn *cnxt;
 	struct ksock_route *route;
-	struct list_head *tmp;
-	struct list_head *nxt;
+	struct ksock_route *rnxt;
 	int nshared;
 
 	LASSERT(!peer_ni->ksnp_closing);
@@ -558,9 +555,8 @@ struct ksock_peer_ni *
 	/* Extra ref prevents peer_ni disappearing until I'm done with it */
 	ksocknal_peer_addref(peer_ni);
 
-	list_for_each_safe(tmp, nxt, &peer_ni->ksnp_routes) {
-		route = list_entry(tmp, struct ksock_route, ksnr_list);
-
+	list_for_each_entry_safe(route, rnxt, &peer_ni->ksnp_routes,
+				 ksnr_list) {
 		/* no match */
 		if (!(!ip || route->ksnr_ipaddr == ip))
 			continue;
@@ -571,29 +567,23 @@ struct ksock_peer_ni *
 	}
 
 	nshared = 0;
-	list_for_each_safe(tmp, nxt, &peer_ni->ksnp_routes) {
-		route = list_entry(tmp, struct ksock_route, ksnr_list);
+	list_for_each_entry(route, &peer_ni->ksnp_routes, ksnr_list)
 		nshared += route->ksnr_share_count;
-	}
 
 	if (!nshared) {
-		/*
-		 * remove everything else if there are no explicit entries
+		/* remove everything else if there are no explicit entries
 		 * left
 		 */
-		list_for_each_safe(tmp, nxt, &peer_ni->ksnp_routes) {
-			route = list_entry(tmp, struct ksock_route, ksnr_list);
-
+		list_for_each_entry_safe(route, rnxt, &peer_ni->ksnp_routes,
+					 ksnr_list) {
 			/* we should only be removing auto-entries */
 			LASSERT(!route->ksnr_share_count);
 			ksocknal_del_route_locked(route);
 		}
 
-		list_for_each_safe(tmp, nxt, &peer_ni->ksnp_conns) {
-			conn = list_entry(tmp, struct ksock_conn, ksnc_list);
-
+		list_for_each_entry_safe(conn, cnxt, &peer_ni->ksnp_conns,
+					 ksnc_list)
 			ksocknal_close_conn_locked(conn, 0);
-		}
 	}
 
 	ksocknal_peer_decref(peer_ni);
@@ -1752,13 +1742,10 @@ struct ksock_peer_ni *
 				 u32 ipaddr, int why)
 {
 	struct ksock_conn *conn;
-	struct list_head *ctmp;
-	struct list_head *cnxt;
+	struct ksock_conn *cnxt;
 	int count = 0;
 
-	list_for_each_safe(ctmp, cnxt, &peer_ni->ksnp_conns) {
-		conn = list_entry(ctmp, struct ksock_conn, ksnc_list);
-
+	list_for_each_entry_safe(conn, cnxt, &peer_ni->ksnp_conns, ksnc_list) {
 		if (!ipaddr || conn->ksnc_ipaddr == ipaddr) {
 			count++;
 			ksocknal_close_conn_locked(conn, why);
@@ -1992,10 +1979,10 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 ksocknal_peer_del_interface_locked(struct ksock_peer_ni *peer_ni,
 				   u32 ipaddr, int index)
 {
-	struct list_head *tmp;
-	struct list_head *nxt;
 	struct ksock_route *route;
+	struct ksock_route *rnxt;
 	struct ksock_conn *conn;
+	struct ksock_conn *cnxt;
 	int i;
 	int j;
 
@@ -2008,9 +1995,8 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 			break;
 		}
 
-	list_for_each_safe(tmp, nxt, &peer_ni->ksnp_routes) {
-		route = list_entry(tmp, struct ksock_route, ksnr_list);
-
+	list_for_each_entry_safe(route, rnxt, &peer_ni->ksnp_routes,
+				 ksnr_list) {
 		if (route->ksnr_myiface != index)
 			continue;
 
@@ -2022,12 +2008,9 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 		}
 	}
 
-	list_for_each_safe(tmp, nxt, &peer_ni->ksnp_conns) {
-		conn = list_entry(tmp, struct ksock_conn, ksnc_list);
-
+	list_for_each_entry_safe(conn, cnxt, &peer_ni->ksnp_conns, ksnc_list)
 		if (conn->ksnc_myipaddr == ipaddr)
 			ksocknal_close_conn_locked(conn, 0);
-	}
 }
 
 static int
Signature · 1 line
1.8.3.1
#27 lore raw

PATCH 27/37 lnet: socklnd: convert various refcounts to refcount_t

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Each of these refcounts exactly follows the expectations of refcount_t, so change the atomic_t to refcoun_t.

We can remove the LASSERTs on incref/decref as they can now be enabled at build time with CONFIG_REFCOUNT_FULL

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: db3e51f612069 ("LU-12678 socklnd: convert various refcounts to refcount_t")

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

---
 net/lnet/klnds/socklnd/socklnd.c    | 28 ++++++++++++-------------
 net/lnet/klnds/socklnd/socklnd.h    | 41 +++++++++++++++----------------------
 net/lnet/klnds/socklnd/socklnd_cb.c |  6 +++---
 3 files changed, 33 insertions(+), 42 deletions(-)
net/lnet/klnds/socklnd/socklnd.c +14 -14
index 2e11737..22a73c3 100644
@@ -123,7 +123,7 @@ static int ksocknal_ip2index(__u32 ipaddress, struct lnet_ni *ni)
 	if (!route)
 		return NULL;
 
-	atomic_set(&route->ksnr_refcount, 1);
+	refcount_set(&route->ksnr_refcount, 1);
 	route->ksnr_peer = NULL;
 	route->ksnr_retry_interval = 0;		/* OK to connect at any time */
 	route->ksnr_ipaddr = ipaddr;
@@ -142,7 +142,7 @@ static int ksocknal_ip2index(__u32 ipaddress, struct lnet_ni *ni)
 void
 ksocknal_destroy_route(struct ksock_route *route)
 {
-	LASSERT(!atomic_read(&route->ksnr_refcount));
+	LASSERT(!refcount_read(&route->ksnr_refcount));
 
 	if (route->ksnr_peer)
 		ksocknal_peer_decref(route->ksnr_peer);
@@ -174,7 +174,7 @@ static int ksocknal_ip2index(__u32 ipaddress, struct lnet_ni *ni)
 
 	peer_ni->ksnp_ni = ni;
 	peer_ni->ksnp_id = id;
-	atomic_set(&peer_ni->ksnp_refcount, 1);   /* 1 ref for caller */
+	refcount_set(&peer_ni->ksnp_refcount, 1);   /* 1 ref for caller */
 	peer_ni->ksnp_closing = 0;
 	peer_ni->ksnp_accepting = 0;
 	peer_ni->ksnp_proto = NULL;
@@ -198,7 +198,7 @@ static int ksocknal_ip2index(__u32 ipaddress, struct lnet_ni *ni)
 	CDEBUG(D_NET, "peer_ni %s %p deleted\n",
 	       libcfs_id2str(peer_ni->ksnp_id), peer_ni);
 
-	LASSERT(!atomic_read(&peer_ni->ksnp_refcount));
+	LASSERT(!refcount_read(&peer_ni->ksnp_refcount));
 	LASSERT(!peer_ni->ksnp_accepting);
 	LASSERT(list_empty(&peer_ni->ksnp_conns));
 	LASSERT(list_empty(&peer_ni->ksnp_routes));
@@ -235,7 +235,7 @@ struct ksock_peer_ni *
 
 		CDEBUG(D_NET, "got peer_ni [%p] -> %s (%d)\n",
 		       peer_ni, libcfs_id2str(id),
-		       atomic_read(&peer_ni->ksnp_refcount));
+		       refcount_read(&peer_ni->ksnp_refcount));
 		return peer_ni;
 	}
 	return NULL;
@@ -1069,10 +1069,10 @@ struct ksock_peer_ni *
 	 * 2 ref, 1 for conn, another extra ref prevents socket
 	 * being closed before establishment of connection
 	 */
-	atomic_set(&conn->ksnc_sock_refcount, 2);
+	refcount_set(&conn->ksnc_sock_refcount, 2);
 	conn->ksnc_type = type;
 	ksocknal_lib_save_callback(sock, conn);
-	atomic_set(&conn->ksnc_conn_refcount, 1); /* 1 ref for me */
+	refcount_set(&conn->ksnc_conn_refcount, 1); /* 1 ref for me */
 
 	conn->ksnc_rx_ready = 0;
 	conn->ksnc_rx_scheduled = 0;
@@ -1667,7 +1667,7 @@ struct ksock_peer_ni *
 {
 	/* Queue the conn for the reaper to destroy */
 
-	LASSERT(!atomic_read(&conn->ksnc_conn_refcount));
+	LASSERT(!refcount_read(&conn->ksnc_conn_refcount));
 	spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
 
 	list_add_tail(&conn->ksnc_list, &ksocknal_data.ksnd_zombie_conns);
@@ -1684,8 +1684,8 @@ struct ksock_peer_ni *
 	/* Final coup-de-grace of the reaper */
 	CDEBUG(D_NET, "connection %p\n", conn);
 
-	LASSERT(!atomic_read(&conn->ksnc_conn_refcount));
-	LASSERT(!atomic_read(&conn->ksnc_sock_refcount));
+	LASSERT(!refcount_read(&conn->ksnc_conn_refcount));
+	LASSERT(!refcount_read(&conn->ksnc_sock_refcount));
 	LASSERT(!conn->ksnc_sock);
 	LASSERT(!conn->ksnc_route);
 	LASSERT(!conn->ksnc_tx_scheduled);
@@ -2412,7 +2412,7 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 
 		CWARN("Active peer_ni on shutdown: %s, ref %d, closing %d, accepting %d, err %d, zcookie %llu, txq %d, zc_req %d\n",
 		      libcfs_id2str(peer_ni->ksnp_id),
-		      atomic_read(&peer_ni->ksnp_refcount),
+		      refcount_read(&peer_ni->ksnp_refcount),
 		      peer_ni->ksnp_closing,
 		      peer_ni->ksnp_accepting, peer_ni->ksnp_error,
 		      peer_ni->ksnp_zc_next_cookie,
@@ -2421,7 +2421,7 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 
 		list_for_each_entry(route, &peer_ni->ksnp_routes, ksnr_list) {
 			CWARN("Route: ref %d, schd %d, conn %d, cnted %d, del %d\n",
-			      atomic_read(&route->ksnr_refcount),
+			      refcount_read(&route->ksnr_refcount),
 			      route->ksnr_scheduled,
 			      route->ksnr_connecting,
 			      route->ksnr_connected,
@@ -2430,8 +2430,8 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 
 		list_for_each_entry(conn, &peer_ni->ksnp_conns, ksnc_list) {
 			CWARN("Conn: ref %d, sref %d, t %d, c %d\n",
-			      atomic_read(&conn->ksnc_conn_refcount),
-			      atomic_read(&conn->ksnc_sock_refcount),
+			      refcount_read(&conn->ksnc_conn_refcount),
+			      refcount_read(&conn->ksnc_sock_refcount),
 			      conn->ksnc_type, conn->ksnc_closing);
 		}
 		goto done;
net/lnet/klnds/socklnd/socklnd.h +16 -25

131 lines not on this page · raw message

net/lnet/klnds/socklnd/socklnd_cb.c +3 -3
index 936054ee..9b3b604 100644
@@ -52,7 +52,7 @@ struct ksock_tx *
 	if (!tx)
 		return NULL;
 
-	atomic_set(&tx->tx_refcount, 1);
+	refcount_set(&tx->tx_refcount, 1);
 	tx->tx_zc_aborted = 0;
 	tx->tx_zc_capable = 0;
 	tx->tx_zc_checked = 0;
@@ -381,7 +381,7 @@ struct ksock_tx *
 				tx->tx_hstatus = LNET_MSG_STATUS_LOCAL_ERROR;
 		}
 
-		LASSERT(atomic_read(&tx->tx_refcount) == 1);
+		LASSERT(refcount_read(&tx->tx_refcount) == 1);
 		ksocknal_tx_done(ni, tx, error);
 	}
 }
@@ -1072,7 +1072,7 @@ struct ksock_route *
 	struct lnet_process_id *id;
 	int rc;
 
-	LASSERT(atomic_read(&conn->ksnc_conn_refcount) > 0);
+	LASSERT(refcount_read(&conn->ksnc_conn_refcount) > 0);
 
 	/* NB: sched lock NOT held */
 	/* SOCKNAL_RX_LNET_HEADER is here for backward compatibility */
Signature · 1 line
1.8.3.1
#28 lore raw

PATCH 28/37 lnet: libcfs: don't call unshare_fs_struct()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

A kthread runs with the same fs_struct as init.
It is only helpful to unshare this if the thread
will change one of the fields in the fs_struct:
root directory
current working directory
umask.

No lustre kthread changes any of these, so there is no need to call unshare_fs_struct().

WC-bug-id: https://jira.whamcloud.com/browse/LU-9859
Lustre-commit: 9013eb2bb5492 ("LU-9859 libcfs: don't call unshare_fs_struct()")

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

---
 fs/lustre/obdclass/llog.c  | 2 --
 fs/lustre/ptlrpc/import.c  | 2 --
 fs/lustre/ptlrpc/ptlrpcd.c | 1 -
 fs/lustre/ptlrpc/service.c | 3 ---
 4 files changed, 8 deletions(-)
fs/lustre/obdclass/llog.c +0 -2
index b2667d9..e172ebc 100644
@@ -449,8 +449,6 @@ static int llog_process_thread_daemonize(void *arg)
 	struct lu_env env;
 	int rc;
 
-	unshare_fs_struct();
-
 	/* client env has no keys, tags is just 0 */
 	rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD);
 	if (rc)
fs/lustre/ptlrpc/import.c +0 -2
index 1b62b81..1490dcf 100644
@@ -1438,8 +1438,6 @@ static int ptlrpc_invalidate_import_thread(void *data)
 {
 	struct obd_import *imp = data;
 
-	unshare_fs_struct();
-
 	CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n",
 	       imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
 	       imp->imp_connection->c_remote_uuid.uuid);
fs/lustre/ptlrpc/ptlrpcd.c +0 -1
index 533f592..b0b81cc 100644
@@ -393,7 +393,6 @@ static int ptlrpcd(void *arg)
 	int rc = 0;
 	int exit = 0;
 
-	unshare_fs_struct();
 	if (cfs_cpt_bind(cfs_cpt_tab, pc->pc_cpt) != 0)
 		CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt);
 
fs/lustre/ptlrpc/service.c +0 -3
index 4d5e6b3..5881e0a 100644
@@ -2175,7 +2175,6 @@ static int ptlrpc_main(void *arg)
 
 	thread->t_task = current;
 	thread->t_pid = current->pid;
-	unshare_fs_struct();
 
 	if (svc->srv_cpt_bind) {
 		rc = cfs_cpt_bind(svc->srv_cptable, svcpt->scp_cpt);
@@ -2391,8 +2390,6 @@ static int ptlrpc_hr_main(void *arg)
 	if (!env)
 		return -ENOMEM;
 
-	unshare_fs_struct();
-
 	rc = cfs_cpt_bind(ptlrpc_hr.hr_cpt_table, hrp->hrp_cpt);
 	if (rc != 0) {
 		char threadname[20];
Signature · 1 line
1.8.3.1
#29 lore raw

PATCH 29/37 lnet: Allow router to forward to healthier NID

In reply to James Simmons

From: Chris Horn <[email protected]>

When a final-hop router (aka edge router) is forwarding a message, if both the originator and destination of the message are mutli-rail capable, then allow the router to choose a new destination lpni if the one selected by the message originator is unhealthy or down.

HPE-bug-id: LUS-8905
WC-bug-id: https://jira.whamcloud.com/browse/LU-13606
Lustre-commit: b0e8ab1a5f6f8 ("LU-13606 lnet: Allow router to forward to healthier NID")

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

---
 include/linux/lnet/lib-lnet.h |  4 ++--
 net/lnet/lnet/lib-move.c      | 37 +++++++++++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 4 deletions(-)
include/linux/lnet/lib-lnet.h +2 -2
index 75c0da7..b069422 100644
@@ -819,8 +819,8 @@ int lnet_get_peer_ni_info(u32 peer_index, u64 *nid,
 }
 
 /*
- * A peer is alive if it satisfies the following two conditions:
- *  1. peer health >= LNET_MAX_HEALTH_VALUE * router_sensitivity_percentage
+ * A peer NI is alive if it satisfies the following two conditions:
+ *  1. peer NI health >= LNET_MAX_HEALTH_VALUE * router_sensitivity_percentage
  *  2. the cached NI status received when we discover the peer is UP
  */
 static inline bool
net/lnet/lnet/lib-move.c +35 -2
index 2f3ef8c..234fbb5 100644
@@ -2371,6 +2371,8 @@ struct lnet_ni *
 	int cpt, rc;
 	int md_cpt;
 	u32 send_case = 0;
+	bool final_hop;
+	bool mr_forwarding_allowed;
 
 	memset(&send_data, 0, sizeof(send_data));
 
@@ -2447,16 +2449,47 @@ struct lnet_ni *
 	else
 		send_case |= REMOTE_DST;
 
+	final_hop = false;
+	if (msg->msg_routing && (send_case & LOCAL_DST))
+		final_hop = true;
+
+	/* Determine whether to allow MR forwarding for this message.
+	 * NB: MR forwarding is allowed if the message originator and the
+	 * destination are both MR capable, and the destination lpni that was
+	 * originally chosen by the originator is unhealthy or down.
+	 * We check the MR capability of the destination further below
+	 */
+	mr_forwarding_allowed = false;
+	if (final_hop) {
+		struct lnet_peer *src_lp;
+		struct lnet_peer_ni *src_lpni;
+
+		src_lpni = lnet_nid2peerni_locked(msg->msg_hdr.src_nid,
+						  LNET_NID_ANY, cpt);
+		/* We don't fail the send if we hit any errors here. We'll just
+		 * try to send it via non-multi-rail criteria
+		 */
+		if (!IS_ERR(src_lpni)) {
+			src_lp = lpni->lpni_peer_net->lpn_peer;
+			if (lnet_peer_is_multi_rail(src_lp) &&
+			    !lnet_is_peer_ni_alive(lpni))
+				mr_forwarding_allowed = true;
+		}
+		CDEBUG(D_NET, "msg %p MR forwarding %s\n", msg,
+		       mr_forwarding_allowed ? "allowed" : "not allowed");
+	}
+
 	/* Deal with the peer as NMR in the following cases:
 	 * 1. the peer is NMR
 	 * 2. We're trying to recover a specific peer NI
-	 * 3. I'm a router sending to the final destination
+	 * 3. I'm a router sending to the final destination and MR forwarding is
+	 *    not allowed for this message (as determined above).
 	 *    In this case the source of the message would've
 	 *    already selected the final destination so my job
 	 *    is to honor the selection.
 	 */
 	if (!lnet_peer_is_multi_rail(peer) || msg->msg_recovery ||
-	    (msg->msg_routing && (send_case & LOCAL_DST)))
+	    (final_hop && !mr_forwarding_allowed))
 		send_case |= NMR_DST;
 	else
 		send_case |= MR_DST;
Signature · 1 line
1.8.3.1
#30 lore raw

PATCH 30/37 lustre: llite: annotate non-owner locking

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The lli_lsm_sem locks taken by ll_prep_md_op_data() are sometimes released by a different thread. This confuses lockdep unless we explain the situation.

So use down_read_non_owner() and up_read_non_owner().

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: f34392412fe22 ("LU-9679 llite: annotate non-owner locking")

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

---
 fs/lustre/llite/llite_lib.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
fs/lustre/llite/llite_lib.c +7 -4
index c62e182..f52d2b5 100644
@@ -2783,12 +2783,12 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
 void ll_unlock_md_op_lsm(struct md_op_data *op_data)
 {
 	if (op_data->op_mea2_sem) {
-		up_read(op_data->op_mea2_sem);
+		up_read_non_owner(op_data->op_mea2_sem);
 		op_data->op_mea2_sem = NULL;
 	}
 
 	if (op_data->op_mea1_sem) {
-		up_read(op_data->op_mea1_sem);
+		up_read_non_owner(op_data->op_mea1_sem);
 		op_data->op_mea1_sem = NULL;
 	}
 }
@@ -2823,7 +2823,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
 	op_data->op_code = opc;
 
 	if (S_ISDIR(i1->i_mode)) {
-		down_read(&ll_i2info(i1)->lli_lsm_sem);
+		down_read_non_owner(&ll_i2info(i1)->lli_lsm_sem);
 		op_data->op_mea1_sem = &ll_i2info(i1)->lli_lsm_sem;
 		op_data->op_mea1 = ll_i2info(i1)->lli_lsm_md;
 		op_data->op_default_mea1 = ll_i2info(i1)->lli_default_lsm_md;
@@ -2833,7 +2833,10 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
 		op_data->op_fid2 = *ll_inode2fid(i2);
 		if (S_ISDIR(i2->i_mode)) {
 			if (i2 != i1) {
-				down_read(&ll_i2info(i2)->lli_lsm_sem);
+				/* i2 is typically a child of i1, and MUST be
+				 * further from the root to avoid deadlocks.
+				 */
+				down_read_non_owner(&ll_i2info(i2)->lli_lsm_sem);
 				op_data->op_mea2_sem =
 						&ll_i2info(i2)->lli_lsm_sem;
 			}
Signature · 1 line
1.8.3.1
#31 lore raw

PATCH 31/37 lustre: osc: consume grants for direct I/O

In reply to James Simmons

From: Vladimir Saveliev <[email protected]>

New IO engine implementation lost consuming grants by direct I/O writes. That led to early emergence of out of space condition during direct I/O. The below illustrates the problem:
# OSTSIZE=100000 sh llmount.sh

  # dd if=/dev/zero of=/mnt/lustre/file bs=4k count=100 oflag=direct
  dd: error writing ?/mnt/lustre/file?: No space left on device

Consume grants for direct I/O.

Try to consume grants in osc_queue_sync_pages() when it is called for pages which are being writted in direct i/o.

Tests are added to verify grant consumption in buffered and direct i/o and to verify direct i/o overwrite when ost is full.
The overwrite test is for ldiskfs only as zfs is unable to overwrite when it is full.

Cray-bug-id: LUS-7036
WC-bug-id: https://jira.whamcloud.com/browse/LU-12687
Lustre-commit: 05f326a7988a7a ("LU-12687 osc: consume grants for direct I/O")

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

---
 fs/lustre/osc/osc_cache.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
fs/lustre/osc/osc_cache.c +22 -0
index fe03c0d..c7aaabb 100644
@@ -2692,6 +2692,28 @@ int osc_queue_sync_pages(const struct lu_env *env, const struct cl_io *io,
 	ext->oe_srvlock = !!(brw_flags & OBD_BRW_SRVLOCK);
 	ext->oe_ndelay = !!(brw_flags & OBD_BRW_NDELAY);
 	ext->oe_dio = !!(brw_flags & OBD_BRW_NOCACHE);
+	if (ext->oe_dio && !ext->oe_rw) { /* direct io write */
+		int grants;
+		int ppc;
+
+		ppc = 1 << (cli->cl_chunkbits - PAGE_SHIFT);
+		grants = cli->cl_grant_extent_tax;
+		grants += (1 << cli->cl_chunkbits) *
+			  ((page_count + ppc - 1) / ppc);
+
+		spin_lock(&cli->cl_loi_list_lock);
+		if (osc_reserve_grant(cli, grants) == 0) {
+			list_for_each_entry(oap, list, oap_pending_item) {
+				osc_consume_write_grant(cli,
+							&oap->oap_brw_page);
+				atomic_long_inc(&obd_dirty_pages);
+			}
+			osc_unreserve_grant_nolock(cli, grants, 0);
+			ext->oe_grants = grants;
+		}
+		spin_unlock(&cli->cl_loi_list_lock);
+	}
+
 	ext->oe_is_rdma_only = !!(brw_flags & OBD_BRW_RDMA_ONLY);
 	ext->oe_nr_pages = page_count;
 	ext->oe_mppr = mppr;
Signature · 1 line
1.8.3.1
#32 lore raw

PATCH 32/37 lnet: remove LNetMEUnlink and clean up related code

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

LNetMEUnlink is not particularly useful, and exposing it as an LNet interface only provides the opportunity for it to be misused.

Every successful call to LNetMEAttach() is followed by a call to LNetMDAttach(). If that call succeeds, the ME is owned by the MD and the caller mustn't touch it again.
If the call fails, the caller is currently required to call LNetMEUnlink(), which all callers do, and these are the only places that LNetMEUnlink() are called.

As LNetMDAttach() knows when it will fail, it can unlink the ME itself and save the caller the effort.
This allows LNetMEUnlink() to be removed which simplifies the LNet interface.

LNetMEUnlink() is also used in in ptl_send_rpc() in a situation where ptl_send_buf() fails. In this case both the ME and the MD need to be unlinked, as as they are interconnected, LNetMEUnlink() or LNetMDUnlink() can equally do the job. So change it to use LNetMDUnlink().

LNetMEUnlink() is primarily a call the lnet_me_unlink(). It also
- has some handling if ->me_md is not NULL, but that is never the case
- takes the lnet_res_lock(). However LNetMDAttach() already takes that lock.
So none of this functionality is useful to LNetMDAttach(). On failure, it can call lnet_me_unlink() directly while ensuring it still has the lock.

This patch:
- moves the calls to lnet_md_validate() into lnet_md_build()
- changes LNetMDAttach() to always take the lnet_res_lock(), and to call lnet_me_unlink() on failure.
- removes all calls to LNetMEUnlink() and sometimes simplifies surrounding code.
- changes lnet_md_link() to 'void' as it only ever returns '0', and thus simplify error handling in LNetMDAttach() and LNetMDBind()

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: e17ee2296c201 ("LU-12678 lnet: remove LNetMEUnlink and clean up related code")

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

---
 fs/lustre/ptlrpc/niobuf.c | 12 +++------
 include/linux/lnet/api.h  |  6 ++---
 net/lnet/lnet/api-ni.c    |  5 +---
 net/lnet/lnet/lib-md.c    | 62 +++++++++++++++--------------------------------
 net/lnet/lnet/lib-me.c    | 39 -----------------------------
 net/lnet/selftest/rpc.c   |  1 -
 6 files changed, 26 insertions(+), 99 deletions(-)
fs/lustre/ptlrpc/niobuf.c +3 -9
index 6fb79a2..924b9c4 100644
@@ -203,7 +203,6 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req)
 			CERROR("%s: LNetMDAttach failed x%llu/%d: rc = %d\n",
 			       desc->bd_import->imp_obd->obd_name, mbits,
 			       posted_md, rc);
-			LNetMEUnlink(me);
 			break;
 		}
 	}
@@ -676,7 +675,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
 			request->rq_receiving_reply = 0;
 			spin_unlock(&request->rq_lock);
 			rc = -ENOMEM;
-			goto cleanup_me;
+			goto cleanup_bulk;
 		}
 		percpu_ref_get(&ptlrpc_pending);
 
@@ -720,12 +719,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
 	if (noreply)
 		goto out;
 
-cleanup_me:
-	/* MEUnlink is safe; the PUT didn't even get off the ground, and
-	 * nobody apart from the PUT's target has the right nid+XID to
-	 * access the reply buffer.
-	 */
-	LNetMEUnlink(reply_me);
+	LNetMDUnlink(request->rq_reply_md_h);
+
 	/* UNLINKED callback called synchronously */
 	LASSERT(!request->rq_receiving_reply);
 
@@ -802,7 +797,6 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
 
 	CERROR("ptlrpc: LNetMDAttach failed: rc = %d\n", rc);
 	LASSERT(rc == -ENOMEM);
-	LNetMEUnlink(me);
 	rqbd->rqbd_refcount = 0;
 
 	return -ENOMEM;
include/linux/lnet/api.h +2 -4
index 24115eb..95805de 100644
@@ -90,8 +90,8 @@
  * list is a chain of MEs. Each ME includes a pointer to a memory descriptor
  * and a set of match criteria. The match criteria can be used to reject
  * incoming requests based on process ID or the match bits provided in the
- * request. MEs can be dynamically inserted into a match list by LNetMEAttach()
- * and removed from its list by LNetMEUnlink().
+ * request. MEs can be dynamically inserted into a match list by LNetMEAttach(),
+ * and must then be attached to an MD with LNetMDAttach().
  * @{
  */
 struct lnet_me *
@@ -101,8 +101,6 @@ struct lnet_me *
 	     u64 ignore_bits_in,
 	     enum lnet_unlink unlink_in,
 	     enum lnet_ins_pos pos_in);
-
-void LNetMEUnlink(struct lnet_me *current_in);
 /** @} lnet_me */
 
 /** \defgroup lnet_md Memory descriptors
net/lnet/lnet/api-ni.c +1 -4
index 3e69435..5f35468 100644
@@ -1645,14 +1645,12 @@ struct lnet_ping_buffer *
 	rc = LNetMDAttach(me, &md, LNET_RETAIN, ping_mdh);
 	if (rc) {
 		CERROR("Can't attach ping target MD: %d\n", rc);
-		goto fail_unlink_ping_me;
+		goto fail_decref_ping_buffer;
 	}
 	lnet_ping_buffer_addref(*ppbuf);
 
 	return 0;
 
-fail_unlink_ping_me:
-	LNetMEUnlink(me);
 fail_decref_ping_buffer:
 	LASSERT(atomic_read(&(*ppbuf)->pb_refcnt) == 1);
 	lnet_ping_buffer_decref(*ppbuf);
@@ -1855,7 +1853,6 @@ int lnet_push_target_post(struct lnet_ping_buffer *pbuf,
 	rc = LNetMDAttach(me, &md, LNET_UNLINK, mdhp);
 	if (rc) {
 		CERROR("Can't attach push MD: %d\n", rc);
-		LNetMEUnlink(me);
 		lnet_ping_buffer_decref(pbuf);
 		pbuf->pb_needs_post = true;
 		return rc;
net/lnet/lnet/lib-md.c +20 -42

148 lines not on this page · raw message

net/lnet/lnet/lib-me.c +0 -39
index 14ab21f..f75f3cb 100644
@@ -118,45 +118,6 @@ struct lnet_me *
 }
 EXPORT_SYMBOL(LNetMEAttach);
 
-/**
- * Unlink a match entry from its match list.
- *
- * This operation also releases any resources associated with the ME. If a
- * memory descriptor is attached to the ME, then it will be unlinked as well
- * and an unlink event will be generated. It is an error to use the ME handle
- * after calling LNetMEUnlink().
- *
- * @me		The ME to be unlinked.
- *
- * \see LNetMDUnlink() for the discussion on delivering unlink event.
- */
-void
-LNetMEUnlink(struct lnet_me *me)
-{
-	struct lnet_libmd *md;
-	struct lnet_event ev;
-	int cpt;
-
-	LASSERT(the_lnet.ln_refcount > 0);
-
-	cpt = me->me_cpt;
-	lnet_res_lock(cpt);
-
-	md = me->me_md;
-	if (md) {
-		md->md_flags |= LNET_MD_FLAG_ABORTED;
-		if (md->md_handler && !md->md_refcount) {
-			lnet_build_unlink_event(md, &ev);
-			md->md_handler(&ev);
-		}
-	}
-
-	lnet_me_unlink(me);
-
-	lnet_res_unlock(cpt);
-}
-EXPORT_SYMBOL(LNetMEUnlink);
-
 /* call with lnet_res_lock please */
 void
 lnet_me_unlink(struct lnet_me *me)
net/lnet/selftest/rpc.c +0 -1
index 799ad99..a72e485 100644
@@ -383,7 +383,6 @@ struct srpc_bulk *
 		CERROR("LNetMDAttach failed: %d\n", rc);
 		LASSERT(rc == -ENOMEM);
 
-		LNetMEUnlink(me);
 		return -ENOMEM;
 	}
 
Signature · 1 line
1.8.3.1
#33 lore raw

PATCH 33/37 lnet: Set remote NI status in lnet_notify

In reply to James Simmons

From: Chris Horn <[email protected]>

The gnilnd receives node health information asynchronous from any tx failure, so aliveness of lpni as reported by lnet_is_peer_ni_alive() may not match what LND is telling us. Use existing reset flag to set cached NI status down so we can be sure that remote NIs are correctly set down.

HPE-bug-id: LUS-8897
WC-bug-id: https://jira.whamcloud.com/browse/LU-13648
Lustre-commit: 8010dbb660766 ("LU-13648 lnet: Set remote NI status in lnet_notify")

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

---
 net/lnet/lnet/router.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/lnet/lnet/router.c +4 -2
index c0578d9..e3b3e71 100644
@@ -1671,8 +1671,7 @@ bool lnet_router_checker_active(void)
 
 	CDEBUG(D_NET, "%s notifying %s: %s\n",
 	       !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
-	       libcfs_nid2str(nid),
-	       alive ? "up" : "down");
+	       libcfs_nid2str(nid), alive ? "up" : "down");
 
 	if (ni &&
 	    LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
@@ -1714,6 +1713,7 @@ bool lnet_router_checker_active(void)
 
 	if (alive) {
 		if (reset) {
+			lpni->lpni_ns_status = LNET_NI_STATUS_UP;
 			lnet_set_lpni_healthv_locked(lpni,
 						     LNET_MAX_HEALTH_VALUE);
 		} else {
@@ -1726,6 +1726,8 @@ bool lnet_router_checker_active(void)
 						     (sensitivity) ? sensitivity :
 						     lnet_health_sensitivity);
 		}
+	} else if (reset) {
+		lpni->lpni_ns_status = LNET_NI_STATUS_DOWN;
 	}
 
 	/* recalculate aliveness */
Signature · 1 line
1.8.3.1
#34 lore raw

PATCH 34/37 lustre: ptlrpc: fix endless loop issue

In reply to James Simmons

From: Hongchao Zhang <[email protected]>

In ptlrpc_pinger_main, if the process to ping the recoverable clients takes too long time, it could be stuck in endless loop because of the negative value returned by pinger_check_timeout.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13667
Lustre-commit: 6be2dbb259512 ("LU-13667 ptlrpc: fix endless loop issue")

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

---
 fs/lustre/ptlrpc/pinger.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/lustre/ptlrpc/pinger.c +9 -2
index ec4c51a..9f57c61 100644
@@ -258,12 +258,13 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
 
 static void ptlrpc_pinger_main(struct work_struct *ws)
 {
-	time64_t this_ping = ktime_get_seconds();
-	time64_t time_to_next_wake;
+	time64_t this_ping, time_after_ping, time_to_next_wake;
 	struct timeout_item *item;
 	struct obd_import *imp;
 
 	do {
+		this_ping = ktime_get_seconds();
+
 		mutex_lock(&pinger_mutex);
 		list_for_each_entry(item, &timeout_list, ti_chain) {
 			item->ti_cb(item, item->ti_cb_data);
@@ -277,6 +278,12 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 		}
 		mutex_unlock(&pinger_mutex);
 
+		time_after_ping = ktime_get_seconds();
+
+		if ((ktime_get_seconds() - this_ping - 3) > PING_INTERVAL)
+			CDEBUG(D_HA, "long time to ping: %lld, %lld, %lld\n",
+			       this_ping, time_after_ping, ktime_get_seconds());
+
 		/* Wait until the next ping time, or until we're stopped. */
 		time_to_next_wake = pinger_check_timeout(this_ping);
 		/* The ping sent by ptlrpc_send_rpc may get sent out
Signature · 1 line
1.8.3.1
#35 lore raw

PATCH 35/37 lustre: llite: fix short io for AIO

In reply to James Simmons

From: Wang Shilong <[email protected]>

The problem is currently AIO could not handle i/o size > stripe size:

We need cl io loop to handle io across stripes, since -EIOCBQUEUED is returned for AIO, io loop will be stopped thus short io happen.

The patch try to fix the problem by making IO engine aware of special error, and it will be proceed to finish all IO requests.

Fixes fde7ac1942f5 ("lustre: clio: AIO support for direct IO")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13697
Lustre-commit: 84c3e85ced2dd ("LU-13697 llite: fix short io for AIO")

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

---
 fs/lustre/include/cl_object.h  |  2 ++
 fs/lustre/llite/file.c         | 32 +++++++++++++++++-
 fs/lustre/llite/rw26.c         | 43 +++++++++++++++++--------
 fs/lustre/llite/vvp_internal.h |  3 +-
 fs/lustre/llite/vvp_io.c       | 73 ++++++++++++++++++++++++++++--------------
 fs/lustre/obdclass/cl_io.c     |  9 +++++-
 6 files changed, 122 insertions(+), 40 deletions(-)
fs/lustre/include/cl_object.h +2 -0
index e656c68..e849f23 100644
@@ -1814,6 +1814,8 @@ struct cl_io {
 	enum cl_io_state	ci_state;
 	/** main object this io is against. Immutable after creation. */
 	struct cl_object	*ci_obj;
+	/** one AIO request might be split in cl_io_loop */
+	struct cl_dio_aio	*ci_aio;
 	/**
 	 * Upper layer io, of which this io is a part of. Immutable after
 	 * creation.
fs/lustre/llite/file.c +31 -1
index 1849229..757950f 100644
@@ -1514,6 +1514,7 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 	int rc = 0;
 	unsigned int retried = 0;
 	unsigned int ignore_lockless = 0;
+	bool is_aio = false;
 
 	CDEBUG(D_VFSTRACE, "file: %pD, type: %d ppos: %llu, count: %zu\n",
 	       file, iot, *ppos, count);
@@ -1536,6 +1537,15 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 		vio->vui_fd  = file->private_data;
 		vio->vui_iter = args->u.normal.via_iter;
 		vio->vui_iocb = args->u.normal.via_iocb;
+		if (file->f_flags & O_DIRECT) {
+			if (!is_sync_kiocb(vio->vui_iocb))
+				is_aio = true;
+			io->ci_aio = cl_aio_alloc(vio->vui_iocb);
+			if (!io->ci_aio) {
+				rc = -ENOMEM;
+				goto out;
+			}
+		}
 		/*
 		 * Direct IO reads must also take range lock,
 		 * or multiple reads will try to work on the same pages
@@ -1567,7 +1577,14 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 		rc = io->ci_result;
 	}
 
-	if (io->ci_nob > 0) {
+	/*
+	 * In order to move forward AIO, ci_nob was increased,
+	 * but that doesn't mean io have been finished, it just
+	 * means io have been submited, we will always return
+	 * EIOCBQUEUED to the caller, So we could only return
+	 * number of bytes in non-AIO case.
+	 */
+	if (io->ci_nob > 0 && !is_aio) {
 		result += io->ci_nob;
 		count -= io->ci_nob;
 		*ppos = io->u.ci_wr.wr.crw_pos;
@@ -1577,6 +1594,19 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 			args->u.normal.via_iter = vio->vui_iter;
 	}
 out:
+	if (io->ci_aio) {
+		/**
+		 * Drop one extra reference so that end_io() could be
+		 * called for this IO context, we could call it after
+		 * we make sure all AIO requests have been proceed.
+		 */
+		cl_sync_io_note(env, &io->ci_aio->cda_sync,
+				rc == -EIOCBQUEUED ? 0 : rc);
+		if (!is_aio) {
+			cl_aio_free(io->ci_aio);
+			io->ci_aio = NULL;
+		}
+	}
 	cl_io_fini(env, io);
 
 	CDEBUG(D_VFSTRACE,
fs/lustre/llite/rw26.c +30 -13

96 lines not on this page · raw message

fs/lustre/llite/vvp_internal.h +2 -1
index cff85ea..6956d6b 100644
@@ -88,9 +88,10 @@ struct vvp_io {
 		struct {
 			struct cl_page_list	vui_queue;
 			unsigned long		vui_written;
+			unsigned long		vui_read;
 			int			vui_from;
 			int			vui_to;
-		} write;
+		} readwrite; /* normal io */
 	} u;
 
 	/**
fs/lustre/llite/vvp_io.c +49 -24

156 lines not on this page · raw message

fs/lustre/obdclass/cl_io.c +8 -1
index dcf940f..1564d9f 100644
@@ -695,6 +695,7 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io,
 int cl_io_loop(const struct lu_env *env, struct cl_io *io)
 {
 	int result = 0;
+	int rc = 0;
 
 	LINVRNT(cl_io_is_loopable(io));
 
@@ -727,7 +728,13 @@ int cl_io_loop(const struct lu_env *env, struct cl_io *io)
 			}
 		}
 		cl_io_iter_fini(env, io);
-	} while (result == 0 && io->ci_continue);
+		if (result)
+			rc = result;
+	} while ((result == 0 || result == -EIOCBQUEUED) &&
+		 io->ci_continue);
+
+	if (rc && !result)
+		result = rc;
 
 	if (result == -EWOULDBLOCK && io->ci_ndelay) {
 		io->ci_need_restart = 1;
Signature · 1 line
1.8.3.1
#36 lore raw

PATCH 36/37 lnet: socklnd: change ksnd_nthreads to atomic_t

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

This variable is treated like an atomic_t, but a global spinlock is used to protect updates - and also unnecessarily to protect reads.

Change to atomic_t and avoid using the spinlock.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 4b0d3c0e41201 ("LU-12678 socklnd: change ksnd_nthreads to atomic_t")

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

---
 net/lnet/klnds/socklnd/socklnd.c    | 4 ++--
 net/lnet/klnds/socklnd/socklnd.h    | 2 +-
 net/lnet/klnds/socklnd/socklnd_cb.c | 8 ++------
 3 files changed, 5 insertions(+), 9 deletions(-)
net/lnet/klnds/socklnd/socklnd.c +2 -2
index 22a73c3..91925475 100644
@@ -2260,9 +2260,9 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 		}
 
 		wait_var_event_warning(&ksocknal_data.ksnd_nthreads,
-				       ksocknal_data.ksnd_nthreads == 0,
+				       atomic_read(&ksocknal_data.ksnd_nthreads) == 0,
 				       "waiting for %d threads to terminate\n",
-				       ksocknal_data.ksnd_nthreads);
+				       atomic_read(&ksocknal_data.ksnd_nthreads));
 
 		ksocknal_free_buffers();
 
net/lnet/klnds/socklnd/socklnd.h +1 -1
index df863f2..350f2c8 100644
@@ -196,7 +196,7 @@ struct ksock_nal_data {
 							 * known peers
 							 */
 
-	int			ksnd_nthreads;		/* # live threads */
+	atomic_t		ksnd_nthreads;		/* # live threads */
 	int			ksnd_shuttingdown;	/* tell threads to exit
 							 */
 	struct ksock_sched	**ksnd_schedulers;	/* schedulers info */
net/lnet/klnds/socklnd/socklnd_cb.c +2 -6
index 9b3b604..a1c0c3d 100644
@@ -976,19 +976,15 @@ struct ksock_route *
 	if (IS_ERR(task))
 		return PTR_ERR(task);
 
-	write_lock_bh(&ksocknal_data.ksnd_global_lock);
-	ksocknal_data.ksnd_nthreads++;
-	write_unlock_bh(&ksocknal_data.ksnd_global_lock);
+	atomic_inc(&ksocknal_data.ksnd_nthreads);
 	return 0;
 }
 
 void
 ksocknal_thread_fini(void)
 {
-	write_lock_bh(&ksocknal_data.ksnd_global_lock);
-	if (--ksocknal_data.ksnd_nthreads == 0)
+	if (atomic_dec_and_test(&ksocknal_data.ksnd_nthreads))
 		wake_up_var(&ksocknal_data.ksnd_nthreads);
-	write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 }
 
 int
Signature · 1 line
1.8.3.1
#37 lore raw

PATCH 37/37 lnet: check rtr_nid is a gateway

In reply to James Simmons

From: Amir Shehata <[email protected]>

The rtr_nid is specified for all REPLY/ACK. However it is possible for the route through the gateway specified by rtr_nid to be removed. In this case we don't want to use it. We should lookup alternative paths.

This patch checks if the peer looked up is indeed a gateway. If it's not a gateway then we attempt to find another path. There is no need to fail right away. It's not a hard requirement to fail if the default rtr_nid is not valid.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13713
Lustre-commit: 07397a2e7473c ("LU-13713 lnet: check rtr_nid is a gateway")

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

---
 net/lnet/lnet/lib-move.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
net/lnet/lnet/lib-move.c +13 -7
index 234fbb5..c0dd30c 100644
@@ -1777,6 +1777,7 @@ struct lnet_ni *
 	struct lnet_route *last_route = NULL;
 	struct lnet_peer_ni *lpni = NULL;
 	struct lnet_peer_ni *gwni = NULL;
+	bool route_found = false;
 	lnet_nid_t src_nid = (sd->sd_src_nid != LNET_NID_ANY) ? sd->sd_src_nid :
 			      sd->sd_best_ni ? sd->sd_best_ni->ni_nid :
 			      LNET_NID_ANY;
@@ -1790,15 +1791,20 @@ struct lnet_ni *
 	 */
 	if (sd->sd_rtr_nid != LNET_NID_ANY) {
 		gwni = lnet_find_peer_ni_locked(sd->sd_rtr_nid);
-		if (!gwni) {
-			CERROR("No peer NI for gateway %s\n",
+		if (gwni) {
+			gw = gwni->lpni_peer_net->lpn_peer;
+			lnet_peer_ni_decref_locked(gwni);
+			if (gw->lp_rtr_refcount) {
+				local_lnet = LNET_NIDNET(sd->sd_rtr_nid);
+				route_found = true;
+			}
+		} else {
+			CWARN("No peer NI for gateway %s. Attempting to find an alternative route.\n",
 			       libcfs_nid2str(sd->sd_rtr_nid));
-			return -EHOSTUNREACH;
 		}
-		gw = gwni->lpni_peer_net->lpn_peer;
-		lnet_peer_ni_decref_locked(gwni);
-		local_lnet = LNET_NIDNET(sd->sd_rtr_nid);
-	} else {
+	}
+
+	if (!route_found) {
 		/* we've already looked up the initial lpni using dst_nid */
 		lpni = sd->sd_best_lpni;
 		/* the peer tree must be in existence */
Signature · 1 line
1.8.3.1