Skip to contentSkip to conversation

lustre: Update to OpenSFS Sept 21, 2021

PATCH New James Simmons 1 participant 25 messages Sep 22, 2021 Networking

lore
Share & tools
lore
#0 lore raw

cover lustre: Update to OpenSFS Sept 21, 2021

Merge latest new OpenSFS work to native Linux client. Biggest change is the native support of the Lustre utilites with the Linux client!!!! I do see new test failures due to the debugfs root only issues which will be addressed later.

Alex Zhuravlev (1):
lustre: obdclass: EAGAIN after rhashtable_walk_next()

Alexander Boyko (1):
lustre: llite: don't touch vma after filemap_fault

Amir Shehata (1):
lnet: Lock primary NID logic

Chris Horn (1):
lnet: Check for -ESHUTDOWN in lnet_parse

Hongchao Zhang (2):
lustre: quota: enforce block quota for chgrp
lustre: llite: check read only mount for setquota

James Simmons (2):
lustre: uapi: fixup UAPI headers for native Linux client.
lustre: ptlrpc: separate out server code for wiretest

Mr NeilBrown (10):
lnet: introduce struct lnet_nid
lnet: add string formating/parsing for IPv6 nids
lnet: change lpni_nid in lnet_peer_ni to lnet_nid
lnet: change lp_primary_nid to struct lnet_nid
lnet: change lp_disc_*_nid to struct lnet_nid
lnet: socklnd: factor out key calculation for ksnd_peers
lnet: introduce lnet_processid for ksock_peer_ni
lnet: enhance connect/accept to support large addr
lnet: change lr_nid to struct lnet_nid
lnet: extend rspt_next_hop_nid in lnet_rsp_tracker

Oleg Drokin (1):
lustre: llite: Remove inode locking in ll_fsync

Patrick Farrell (1):
lustre: llite: Always do lookup on ENOENT in open

Qian Yingjin (1):
lustre: pcc: VM_WRITE should not trigger layout write

Sebastien Buisson (1):
lustre: sec: filename encryption

Serguei Smirnov (1):
lnet: socklnd: fix link state detection

Vitaly Fertman (1):
lustre: ptlrpc: two replay lock threads

 fs/lustre/include/cl_object.h           |   5 -
 fs/lustre/include/lustre_swab.h         |   1 -
 fs/lustre/include/obd.h                 |   4 +
 fs/lustre/include/obd_support.h         |   1 +
 fs/lustre/ldlm/ldlm_request.c           |  10 +-
 fs/lustre/llite/crypto.c                | 144 +++++++++
 fs/lustre/llite/dcache.c                |   8 +
 fs/lustre/llite/dir.c                   |  52 +++-
 fs/lustre/llite/file.c                  |  56 ++--
 fs/lustre/llite/llite_internal.h        |  29 +-
 fs/lustre/llite/llite_lib.c             |  63 +++-
 fs/lustre/llite/llite_mmap.c            |  31 +-
 fs/lustre/llite/namei.c                 |  47 ++-
 fs/lustre/llite/statahead.c             |  48 +++
 fs/lustre/llite/vvp_dev.c               |   6 +
 fs/lustre/llite/vvp_io.c                |   3 +-
 fs/lustre/lov/lov_io.c                  |   6 +-
 fs/lustre/mdc/mdc_lib.c                 |   6 +-
 fs/lustre/obdclass/jobid.c              |   5 +
 fs/lustre/obdclass/llog_swab.c          |  33 ---
 fs/lustre/obdclass/obd_config.c         |   4 +-
 fs/lustre/ptlrpc/layout.c               |   5 +-
 fs/lustre/ptlrpc/pack_generic.c         |  13 +-
 fs/lustre/ptlrpc/wiretest.c             | 210 ++++++-------
 include/linux/lnet/lib-lnet.h           |  39 ++-
 include/linux/lnet/lib-types.h          |  18 +-
 include/uapi/linux/lnet/lnet-idl.h      |  39 ++-
 include/uapi/linux/lnet/lnet-types.h    | 106 ++++++-
 include/uapi/linux/lnet/nidstr.h        |  12 +-
 include/uapi/linux/lustre/lustre_idl.h  |  78 +----
 include/uapi/linux/lustre/lustre_user.h |  20 ++
 net/lnet/klnds/o2iblnd/o2iblnd.c        |  13 +-
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c     |  17 +-
 net/lnet/klnds/socklnd/socklnd.c        | 353 +++++++++++++++-------
 net/lnet/klnds/socklnd/socklnd.h        |  14 +-
 net/lnet/klnds/socklnd/socklnd_cb.c     | 119 ++++----
 net/lnet/klnds/socklnd/socklnd_proto.c  |  14 +-
 net/lnet/lnet/acceptor.c                | 112 ++++---
 net/lnet/lnet/api-ni.c                  | 178 ++++++++---
 net/lnet/lnet/config.c                  |  20 +-
 net/lnet/lnet/lib-move.c                | 155 +++++-----
 net/lnet/lnet/lib-msg.c                 |  13 +-
 net/lnet/lnet/lib-socket.c              |  32 +-
 net/lnet/lnet/lo.c                      |   3 +-
 net/lnet/lnet/net_fault.c               |   4 +-
 net/lnet/lnet/nidstrings.c              | 163 ++++++++++-
 net/lnet/lnet/peer.c                    | 503 +++++++++++++++++++-------------
 net/lnet/lnet/router.c                  |  88 +++---
 net/lnet/lnet/router_proc.c             |  12 +-
 net/lnet/lnet/udsp.c                    |  39 +--
 50 files changed, 1997 insertions(+), 957 deletions(-)
Signature · 6 lines
1.8.3.1

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

PATCH 1/24 lnet: Lock primary NID logic

From: Amir Shehata <[email protected]>

If a peer is created by Lustre make sure to lock that peer's primary NID. This peer can be discovered in the background. There is no need to block until discovery is complete, as Lustre can continue on with the primary NID it provided.

Discovery will populate the peer with other interfaces the peer has but will not change the peer's primary NID. It can also delete peer's NIDs which Lustre told it about (not the Primary NID).

WC-bug-id: https://jira.whamcloud.com/browse/LU-14668
Lustre-commit: 024f9303bc6f32a31 ("LU-14668 lnet: Lock primary NID logic")

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

---
 net/lnet/lnet/peer.c | 69 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 53 insertions(+), 16 deletions(-)
net/lnet/lnet/peer.c +53 -16
index c2f5d8b..720af99 100644
@@ -530,6 +530,16 @@ static void lnet_peer_cancel_discovery(struct lnet_peer *lp)
 			goto out;
 		}
 	}
+
+	/* If we're asked to lock down the primary NID we shouldn't be
+	 * deleting it
+	 */
+	if (lp->lp_state & LNET_PEER_LOCK_PRIMARY &&
+	    primary_nid == nid) {
+		rc = -EPERM;
+		goto out;
+	}
+
 	lpni = lnet_find_peer_ni_locked(nid);
 	if (!lpni) {
 		rc = -ENOENT;
@@ -1388,13 +1398,18 @@ struct lnet_peer_ni *
 	 * down then this discovery can introduce long delays into the mount
 	 * process, so skip it if it isn't necessary.
 	 */
-	while (!lnet_peer_discovery_disabled && !lnet_peer_is_uptodate(lp)) {
+	if (!lnet_peer_discovery_disabled && !lnet_peer_is_uptodate(lp)) {
 		spin_lock(&lp->lp_lock);
 		/* force a full discovery cycle */
-		lp->lp_state |= LNET_PEER_FORCE_PING | LNET_PEER_FORCE_PUSH;
+		lp->lp_state |= LNET_PEER_FORCE_PING | LNET_PEER_FORCE_PUSH |
+				LNET_PEER_LOCK_PRIMARY;
 		spin_unlock(&lp->lp_lock);
 
-		rc = lnet_discover_peer_locked(lpni, cpt, true);
+		/* start discovery in the background. Messages to that
+		 * peer will not go through until the discovery is
+		 * complete
+		 */
+		rc = lnet_discover_peer_locked(lpni, cpt, false);
 		if (rc)
 			goto out_decref;
 		/* The lpni (or lp) for this NID may have changed and our ref is
@@ -1408,14 +1423,6 @@ struct lnet_peer_ni *
 			goto out_unlock;
 		}
 		lp = lpni->lpni_peer_net->lpn_peer;
-
-		/* If we find that the peer has discovery disabled then we will
-		 * not modify whatever primary NID is currently set for this
-		 * peer. Thus, we can break out of this loop even if the peer
-		 * is not fully up to date.
-		 */
-		if (lnet_is_discovery_disabled(lp))
-			break;
 	}
 	primary_nid = lp->lp_primary_nid;
 out_decref:
@@ -1522,6 +1529,8 @@ struct lnet_peer_net *
 			lnet_peer_clr_non_mr_pref_nids(lp);
 		}
 	}
+	if (flags & LNET_PEER_LOCK_PRIMARY)
+		lp->lp_state |= LNET_PEER_LOCK_PRIMARY;
 	spin_unlock(&lp->lp_lock);
 
 	lp->lp_nnis++;
@@ -1676,9 +1685,27 @@ struct lnet_peer_net *
 		}
 		/* If this is the primary NID, destroy the peer. */
 		if (lnet_peer_ni_is_primary(lpni)) {
-			struct lnet_peer *rtr_lp =
+			struct lnet_peer *lp2 =
 				lpni->lpni_peer_net->lpn_peer;
-			int rtr_refcount = rtr_lp->lp_rtr_refcount;
+			int rtr_refcount = lp2->lp_rtr_refcount;
+
+			/* If the new peer that this NID belongs to is
+			 * a primary NID for another peer which we're
+			 * suppose to preserve the Primary for then we
+			 * don't want to mess with it. But the
+			 * configuration is wrong at this point, so we
+			 * should flag both of these peers as in a bad
+			 * state
+			 */
+			if (lp2->lp_state & LNET_PEER_LOCK_PRIMARY) {
+				spin_lock(&lp->lp_lock);
+				lp->lp_state |= LNET_PEER_BAD_CONFIG;
+				spin_unlock(&lp->lp_lock);
+				spin_lock(&lp2->lp_lock);
+				lp2->lp_state |= LNET_PEER_BAD_CONFIG;
+				spin_unlock(&lp2->lp_lock);
+				goto out_free_lpni;
+			}
 
 			/* if we're trying to delete a router it means
 			 * we're moving this peer NI to a new peer so must
@@ -1686,9 +1713,9 @@ struct lnet_peer_net *
 			 */
 			if (rtr_refcount > 0) {
 				flags |= LNET_PEER_RTR_NI_FORCE_DEL;
-				lnet_rtr_transfer_to_peer(rtr_lp, lp);
+				lnet_rtr_transfer_to_peer(lp2, lp);
 			}
-			lnet_peer_del(lpni->lpni_peer_net->lpn_peer);
+			lnet_peer_del(lp2);
 			lnet_peer_ni_decref_locked(lpni);
 			lpni = lnet_peer_ni_alloc(nid);
 			if (!lpni) {
@@ -1746,7 +1773,8 @@ struct lnet_peer_net *
 	if (lp->lp_primary_nid == nid)
 		goto out;
 
-	lp->lp_primary_nid = nid;
+	if (!(lp->lp_state & LNET_PEER_LOCK_PRIMARY))
+		lp->lp_primary_nid = nid;
 
 	rc = lnet_peer_add_nid(lp, nid, flags);
 	if (rc) {
@@ -1754,8 +1782,17 @@ struct lnet_peer_net *
 		goto out;
 	}
 out:
+	/* if this is a configured peer or the primary for that peer has
+	 * been locked, then we don't want to flag this scenario as
+	 * a failure
+	 */
+	if (lp->lp_state & LNET_PEER_CONFIGURED ||
+	    lp->lp_state & LNET_PEER_LOCK_PRIMARY)
+		return 0;
+
 	CDEBUG(D_NET, "peer %s NID %s: %d\n",
 	       libcfs_nid2str(old), libcfs_nid2str(nid), rc);
+
 	return rc;
 }
 
Signature · 6 lines
1.8.3.1

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

PATCH 2/24 lustre: quota: enforce block quota for chgrp

In reply to James Simmons

From: Hongchao Zhang <[email protected]>

In patch https://review.whamcloud.com/30146 "LU-5152 quota: enforce block quota for chgrp", problems were introduced due to synchronous requests from the MDS to the OSS to change the quota assignment of files during chgrp operations. However, in some cases, the OSTs are themselves out of grant and may send a quota request to the MDS, which may result in a deadlock. Another issue is the slow performance caused by the synchronous operation between MDT and OSTs.

This patch drops the synchronous RPC requirement of the original patch #30146 to avoid this problem.

Previously, problems in quota tracking related to chgrp were introduced due to synchronous RPCs from the MDS to the OSS when changing the group ownership of objects for quota tracking since
Fixes: ("LU-5152 quota: enforce block quota for chgrp")

WC-bug-id: https://jira.whamcloud.com/browse/LU-11303
Lustre-commit: 83f5544d8518ad12 ("LU-11303 quota: enforce block quota for chgrp")

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

---
 fs/lustre/llite/llite_lib.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
fs/lustre/llite/llite_lib.c +10 -0
index f540caf..cc50503 100644
@@ -1714,6 +1714,16 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data)
 	if (IS_ERR(op_data))
 		return PTR_ERR(op_data);
 
+	/* If this is a chgrp of a regular file, we want to reserve enough
+	 * quota to cover the entire file size.
+	 */
+	if (S_ISREG(inode->i_mode) && op_data->op_attr.ia_valid & ATTR_GID &&
+	    from_kgid(&init_user_ns, op_data->op_attr.ia_gid) !=
+	    from_kgid(&init_user_ns, inode->i_gid)) {
+		op_data->op_xvalid |= OP_XVALID_BLOCKS;
+		op_data->op_attr_blocks = inode->i_blocks;
+	}
+
 	rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, &request);
 	if (rc) {
 		ptlrpc_req_finished(request);
Signature · 6 lines
1.8.3.1

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

PATCH 3/24 lnet: introduce struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

LNet nids are currently limited to 4-bytes for addresses. This excludes the use of IPv6.

In order to support IPv6, introduce 'struct lnet_nid' which can hold up to 128bit address and is extensible, and deprecate 'lnet_nid_t'. lnet_nid_it will eventually be removed. Where lnet_nid_t is often passed around by value, 'struct lnet_nid' will normally be passed around by reference as it is over twice as large.

The net_type field, which currently has value up to 16, is now limited to 0-254 with 255 being used as a wildcard. The most significant byte is now a size field which gives the size of the whole nid minus 8. So zero is correct for current nids with 4-byte addresses.

Where we still need to use 4-byte-address nids, we will use names containing "nid4". So "nid4" is a lnet_nid_t when "nid" is a struct lnet_nid. lnet_nid_to_nid4 converts a 'struct lnet_nid' to an lnet_nid_t.

While lnet_nid_t is stored and often transmitted in host-endian format (and possibly byte-swapped on receipt), 'struct lnet_nid' is always stored in network-byte-order (i.e. big-endian). This is more common approach for network addresses.

In this first instance, 'struct lnet_nid' is used for ni_nid in 'struct lnet_ni', and related support functions.

In particular libcfs_nidstr() is introduced which parallels libcfs_nid2str(), but takes 'struct lnet_nid'.

In cases were we need to have similar functions for old and new style nid, the new function is introduced with a slightly different name, such as libcfs_nid2str above, or LNET_NID_NET (like LNET_NIDNET). It will be confusing having both, but the plan is to remove the old names as soon as practical.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 82a17076f880770a ("LU-10391 lnet: introduce struct lnet_nid")

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

---
 include/linux/lnet/lib-lnet.h        |  4 +-
 include/linux/lnet/lib-types.h       |  2 +-
 include/uapi/linux/lnet/lnet-idl.h   | 28 ++++++++++-
 include/uapi/linux/lnet/lnet-types.h | 66 ++++++++++++++++++++++++-
 include/uapi/linux/lnet/nidstr.h     | 10 +++-
 net/lnet/klnds/o2iblnd/o2iblnd.c     | 13 +++--
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c  | 17 ++++---
 net/lnet/klnds/socklnd/socklnd.c     | 10 ++--
 net/lnet/klnds/socklnd/socklnd_cb.c  | 10 ++--
 net/lnet/lnet/acceptor.c             |  3 +-
 net/lnet/lnet/api-ni.c               | 60 +++++++++++++---------
 net/lnet/lnet/config.c               |  5 +-
 net/lnet/lnet/lib-move.c             | 96 +++++++++++++++++++++---------------
 net/lnet/lnet/lib-msg.c              | 11 +++--
 net/lnet/lnet/lib-socket.c           | 32 +++++++++---
 net/lnet/lnet/lo.c                   |  3 +-
 net/lnet/lnet/net_fault.c            |  2 +-
 net/lnet/lnet/nidstrings.c           | 40 +++++++++++++++
 net/lnet/lnet/router.c               |  8 +--
 net/lnet/lnet/router_proc.c          |  2 +-
 net/lnet/lnet/udsp.c                 | 13 ++---
 21 files changed, 312 insertions(+), 123 deletions(-)
include/linux/lnet/lib-lnet.h +2 -2
index 37489ae..acc069d 100644
@@ -110,7 +110,7 @@
 
 	if (ni->ni_status && ni->ni_status->ns_status != status) {
 		CDEBUG(D_NET, "ni %s status changed from %#x to %#x\n",
-		       libcfs_nid2str(ni->ni_nid),
+		       libcfs_nidstr(&ni->ni_nid),
 		       ni->ni_status->ns_status, status);
 		ni->ni_status->ns_status = status;
 		update = true;
@@ -123,7 +123,7 @@
 lnet_ni_get_status_locked(struct lnet_ni *ni)
 __must_hold(&ni->ni_lock)
 {
-	if (ni->ni_nid == LNET_NID_LO_0)
+	if (nid_is_lo0(&ni->ni_nid))
 		return LNET_NI_STATUS_UP;
 	else if (atomic_read(&ni->ni_fatal_error_on))
 		return LNET_NI_STATUS_DOWN;
include/linux/lnet/lib-types.h +1 -1
index 85b0d54..80cf4f3 100644
@@ -463,7 +463,7 @@ struct lnet_ni {
 	u32			*ni_cpts;
 
 	/* interface's NID */
-	lnet_nid_t		ni_nid;
+	struct lnet_nid		ni_nid;
 
 	/* instance-specific data */
 	void			*ni_data;
include/uapi/linux/lnet/lnet-idl.h +26 -2
index 1e27f3b..3fc0df1 100644
@@ -40,18 +40,42 @@
  * These are sent in sender's byte order (i.e. receiver flips).
  */
 
-/**
- * Address of an end-point in an LNet network.
+/** Address of an end-point in an LNet network.
  *
  * A node can have multiple end-points and hence multiple addresses.
  * An LNet network can be a simple network (e.g. tcp0) or a network of
  * LNet networks connected by LNet routers. Therefore an end-point address
  * has two parts: network ID, and address within a network.
+ * The most-significant-byte in this format is always 0.  A larger value
+ * would imply a larger nid with a larger address.
  *
  * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
  */
 typedef __u64 lnet_nid_t;
 
+/*
+ * Address of LNet end-point in extended form
+ *
+ * To support addresses larger than 32bits we have
+ * an extended nid which supports up to 128 bits
+ * of address and is extensible.
+ * If nid_size is 0, then the nid can be stored in an lnet_nid_t,
+ * and the first 8 bytes of the 'struct lnet_nid' are identical to
+ * the lnet_nid_t in big-endian format.
+ * If nid_type == 0xff, then all other fields should be ignored
+ * and this is an ANY wildcard address.  In particular, the nid_size
+ * can be 0xff without making the address too big to fit.
+ */
+struct lnet_nid {
+	__u8	nid_size;	/* total bytes - 8 */
+	__u8	nid_type;
+	__be16	nid_num;
+	__be32	nid_addr[4];
+} __attribute__((packed));
+
+#define NID_BYTES(nid)		((nid)->nid_size + 8)
+#define NID_ADDR_BYTES(nid)	((nid)->nid_size + 4)
+
 /**
  * ID of a process in a node. Shortened as PID to distinguish from
  * lnet_process_id, the global process ID.
include/uapi/linux/lnet/lnet-types.h +65 -1

90 lines not on this page · raw message

include/uapi/linux/lnet/nidstr.h +9 -1
index caf28e2..d5b9d69 100644
@@ -62,7 +62,7 @@ enum {
 struct list_head;
 
 #define LNET_NIDSTR_COUNT	1024	/* # of nidstrings */
-#define LNET_NIDSTR_SIZE	32	/* size of each one (see below for usage) */
+#define LNET_NIDSTR_SIZE	64	/* size of each one (see below for usage) */
 
 /* support decl needed by both kernel and user space */
 char *libcfs_next_nidstring(void);
@@ -90,6 +90,14 @@ static inline char *libcfs_nid2str(lnet_nid_t nid)
 				LNET_NIDSTR_SIZE);
 }
 
+char *libcfs_nidstr_r(const struct lnet_nid *nid,
+		      char *buf, __kernel_size_t buf_size);
+static inline char *libcfs_nidstr(const struct lnet_nid *nid)
+{
+	return libcfs_nidstr_r(nid, libcfs_next_nidstring(),
+			       LNET_NIDSTR_SIZE);
+}
+
 __u32 libcfs_str2net(const char *str);
 lnet_nid_t libcfs_str2nid(const char *str);
 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
net/lnet/klnds/o2iblnd/o2iblnd.c +6 -7
index a4949d8..fd807c2 100644
@@ -178,8 +178,7 @@ void kiblnd_pack_msg(struct lnet_ni *ni, struct kib_msg *msg, int version,
 {
 	struct kib_net *net = ni->ni_data;
 
-	/*
-	 * CAVEAT EMPTOR! all message fields not set here should have been
+	/* CAVEAT EMPTOR! all message fields not set here should have been
 	 * initialised previously.
 	 */
 	msg->ibm_magic = IBLND_MSG_MAGIC;
@@ -188,7 +187,7 @@ void kiblnd_pack_msg(struct lnet_ni *ni, struct kib_msg *msg, int version,
 	msg->ibm_credits = credits;
 	/*   ibm_nob */
 	msg->ibm_cksum = 0;
-	msg->ibm_srcnid = ni->ni_nid;
+	msg->ibm_srcnid = lnet_nid_to_nid4(&ni->ni_nid);
 	msg->ibm_srcstamp = net->ibn_incarnation;
 	msg->ibm_dstnid = dstnid;
 	msg->ibm_dststamp = dststamp;
@@ -397,7 +396,7 @@ struct kib_peer_ni *kiblnd_find_peer_locked(struct lnet_ni *ni, lnet_nid_t nid)
 		 * created.
 		 */
 		if (peer_ni->ibp_nid != nid ||
-		    peer_ni->ibp_ni->ni_nid != ni->ni_nid)
+		    !nid_same(&peer_ni->ibp_ni->ni_nid, &ni->ni_nid))
 			continue;
 
 		CDEBUG(D_NET, "got peer_ni [%p] -> %s (%d) version: %x\n",
@@ -2201,7 +2200,7 @@ static int kiblnd_port_get_attr(struct kib_hca_dev *hdev)
 	list_for_each_entry(net, &hdev->ibh_dev->ibd_nets, ibn_list) {
 		if (val)
 			CDEBUG(D_NETERROR, "Fatal device error for NI %s\n",
-			       libcfs_nid2str(net->ibn_ni->ni_nid));
+			       libcfs_nidstr(&net->ibn_ni->ni_nid));
 		atomic_set(&net->ibn_ni->ni_fatal_error_on, val);
 	}
 }
@@ -2591,7 +2590,7 @@ static void kiblnd_shutdown(struct lnet_ni *ni)
 		wait_var_event_warning(&net->ibn_npeers,
 				       atomic_read(&net->ibn_npeers) == 0,
 				       "%s: waiting for %d peers to disconnect\n",
-				       libcfs_nid2str(ni->ni_nid),
+				       libcfs_nidstr(&ni->ni_nid),
 				       atomic_read(&net->ibn_npeers));
 
 		kiblnd_net_fini_pools(net);
@@ -2906,7 +2905,7 @@ static int kiblnd_startup(struct lnet_ni *ni)
 	}
 
 	net->ibn_dev = ibdev;
-	ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid), ibdev->ibd_ifip);
+	ni->ni_nid.nid_addr[0] = cpu_to_be32(ibdev->ibd_ifip);
 
 	ni->ni_dev_cpt = ifaces[i].li_cpt;
 
net/lnet/klnds/o2iblnd/o2iblnd_cb.c +9 -8
index 8ccd2ab..380374e 100644
@@ -507,7 +507,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type,
 	}
 
 	if (msg->ibm_srcnid != conn->ibc_peer->ibp_nid ||
-	    msg->ibm_dstnid != ni->ni_nid ||
+	    msg->ibm_dstnid != lnet_nid_to_nid4(&ni->ni_nid) ||
 	    msg->ibm_srcstamp != conn->ibc_incarnation ||
 	    msg->ibm_dststamp != net->ibn_incarnation) {
 		CERROR("Stale rx from %s\n",
@@ -2369,11 +2369,12 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	}
 
 	if (!ni ||				/* no matching net */
-	    ni->ni_nid != reqmsg->ibm_dstnid ||	/* right NET, wrong NID! */
+	    lnet_nid_to_nid4(&ni->ni_nid) !=
+	    reqmsg->ibm_dstnid ||		/* right NET, wrong NID! */
 	    net->ibn_dev != ibdev) {		/* wrong device */
 		CERROR("Can't accept conn from %s on %s (%s:%d:%pI4h): bad dst nid %s\n",
 		       libcfs_nid2str(nid),
-		       !ni ? "NA" : libcfs_nid2str(ni->ni_nid),
+		       ni ? libcfs_nidstr(&ni->ni_nid) : "NA",
 		       ibdev->ibd_ifname, ibdev->ibd_nnets,
 		       &ibdev->ibd_ifip,
 		       libcfs_nid2str(reqmsg->ibm_dstnid));
@@ -2490,8 +2491,8 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 		 * the lower NID connection win so we can move forward.
 		 */
 		if (peer2->ibp_connecting &&
-		    nid < ni->ni_nid && peer2->ibp_races <
-		    MAX_CONN_RACES_BEFORE_ABORT) {
+		    nid < lnet_nid_to_nid4(&ni->ni_nid) &&
+		    peer2->ibp_races < MAX_CONN_RACES_BEFORE_ABORT) {
 			peer2->ibp_races++;
 			write_unlock_irqrestore(g_lock, flags);
 
@@ -2924,7 +2925,7 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	}
 
 	read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
-	if (msg->ibm_dstnid == ni->ni_nid &&
+	if (msg->ibm_dstnid == lnet_nid_to_nid4(&ni->ni_nid) &&
 	    msg->ibm_dststamp == net->ibn_incarnation)
 		rc = 0;
 	else
@@ -3568,13 +3569,13 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	case IB_EVENT_PORT_ERR:
 	case IB_EVENT_DEVICE_FATAL:
 		CERROR("Fatal device error for NI %s\n",
-		       libcfs_nid2str(conn->ibc_peer->ibp_ni->ni_nid));
+		       libcfs_nidstr(&conn->ibc_peer->ibp_ni->ni_nid));
 		atomic_set(&conn->ibc_peer->ibp_ni->ni_fatal_error_on, 1);
 		return;
 
 	case IB_EVENT_PORT_ACTIVE:
 		CERROR("Port reactivated for NI %s\n",
-		       libcfs_nid2str(conn->ibc_peer->ibp_ni->ni_nid));
+		       libcfs_nidstr(&conn->ibc_peer->ibp_ni->ni_nid));
 		atomic_set(&conn->ibc_peer->ibp_ni->ni_fatal_error_on, 0);
 		return;
 
net/lnet/klnds/socklnd/socklnd.c +5 -5
index 96cb0e0..21569fb 100644
@@ -949,7 +949,7 @@ struct ksock_peer_ni *
 		 * Am I already connecting to this guy?  Resolve in
 		 * favour of higher NID...
 		 */
-		if (peerid.nid < ni->ni_nid &&
+		if (peerid.nid < lnet_nid_to_nid4(&ni->ni_nid) &&
 		    ksocknal_connecting(peer_ni->ksnp_conn_cb,
 					((struct sockaddr *)&conn->ksnc_peeraddr))) {
 			rc = EALREADY;
@@ -1820,12 +1820,13 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 
 	case IOC_LIBCFS_REGISTER_MYNID:
 		/* Ignore if this is a noop */
-		if (data->ioc_nid == ni->ni_nid)
+		if (nid_is_nid4(&ni->ni_nid) &&
+		    data->ioc_nid == lnet_nid_to_nid4(&ni->ni_nid))
 			return 0;
 
 		CERROR("obsolete IOC_LIBCFS_REGISTER_MYNID: %s(%s)\n",
 		       libcfs_nid2str(data->ioc_nid),
-		       libcfs_nid2str(ni->ni_nid));
+		       libcfs_nidstr(&ni->ni_nid));
 		return -EINVAL;
 
 	case IOC_LIBCFS_PUSH_CONNECTION:
@@ -2369,8 +2370,7 @@ static int ksocknal_device_event(struct notifier_block *unused,
 
 	LASSERT(ksi);
 	LASSERT(ksi->ksni_addr.ss_family == AF_INET);
-	ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid),
-				ntohl(((struct sockaddr_in *)&ksi->ksni_addr)->sin_addr.s_addr));
+	ni->ni_nid.nid_addr[0] = ((struct sockaddr_in *)&ksi->ksni_addr)->sin_addr.s_addr;
 	list_add(&net->ksnn_list, &ksocknal_data.ksnd_nets);
 	net->ksnn_ni = ni;
 	ksocknal_data.ksnd_nnets++;
net/lnet/klnds/socklnd/socklnd_cb.c +6 -4
index efec479..e6cd976 100644
@@ -1579,7 +1579,7 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 	/* rely on caller to hold a ref on socket so it wouldn't disappear */
 	LASSERT(conn->ksnc_proto);
 
-	hello->kshm_src_nid = ni->ni_nid;
+	hello->kshm_src_nid = lnet_nid_to_nid4(&ni->ni_nid);
 	hello->kshm_dst_nid = peer_nid;
 	hello->kshm_src_pid = the_lnet.ln_pid;
 
@@ -1628,7 +1628,7 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 	LASSERT(!active == !(conn->ksnc_type != SOCKLND_CONN_NONE));
 
 	timeout = active ? ksocknal_timeout() :
-			    lnet_acceptor_timeout();
+		lnet_acceptor_timeout();
 
 	rc = lnet_sock_read(sock, &hello->kshm_magic,
 			    sizeof(hello->kshm_magic), timeout);
@@ -1672,7 +1672,9 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 				conn->ksnc_proto = &ksocknal_protocol_v1x;
 #endif
 			hello->kshm_nips = 0;
-			ksocknal_send_hello(ni, conn, ni->ni_nid, hello);
+			ksocknal_send_hello(ni, conn,
+					    lnet_nid_to_nid4(&ni->ni_nid),
+					    hello);
 		}
 
 		CERROR("Unknown protocol version (%d.x expected) from %pIS\n",
@@ -1709,7 +1711,7 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 		recv_id.pid = rpc_get_port((struct sockaddr *)
 					   &conn->ksnc_peeraddr) |
 					   LNET_PID_USERFLAG;
-		recv_id.nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid),
+		recv_id.nid = LNET_MKNID(LNET_NID_NET(&ni->ni_nid),
 					 ntohl(((struct sockaddr_in *)
 					 &conn->ksnc_peeraddr)->sin_addr.s_addr));
 	} else {
net/lnet/lnet/acceptor.c +2 -1
index 3708b89..243c34f 100644
@@ -284,7 +284,8 @@ struct socket *
 
 	ni = lnet_nid2ni_addref(cr.acr_nid);
 	if (!ni ||			/* no matching net */
-	    ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */
+	    lnet_nid_to_nid4(&ni->ni_nid) != cr.acr_nid) {
+		/* right NET, wrong NID! */
 		if (ni)
 			lnet_ni_decref(ni);
 		LCONSOLE_ERROR_MSG(0x120,
net/lnet/lnet/api-ni.c +37 -23

176 lines not on this page · raw message

net/lnet/lnet/config.c +3 -2
index 0117611..0c833fe 100644
@@ -375,7 +375,7 @@ struct lnet_net *
 	if (ni->ni_interface) {
 		LCONSOLE_ERROR_MSG(0x115, "%s: interface %s already set for net %s: rc = %d\n",
 				   iface, ni->ni_interface,
-				   libcfs_net2str(LNET_NIDNET(ni->ni_nid)),
+				   libcfs_net2str(LNET_NID_NET(&ni->ni_nid)),
 				   -EINVAL);
 		return -EINVAL;
 	}
@@ -435,7 +435,8 @@ struct lnet_net *
 
 	ni->ni_net = net;
 	/* LND will fill in the address part of the NID */
-	ni->ni_nid = LNET_MKNID(net->net_id, 0);
+	ni->ni_nid.nid_type = LNET_NETTYP(net->net_id);
+	ni->ni_nid.nid_num = cpu_to_be16(LNET_NETNUM(net->net_id));
 
 	/* Store net namespace in which current ni is being created */
 	if (current->nsproxy && current->nsproxy->net_ns)
net/lnet/lnet/lib-move.c +56 -40

308 lines not on this page · raw message

net/lnet/lnet/lib-msg.c +6 -5
index e471848..b1f684f 100644
@@ -473,7 +473,7 @@
 
 	CDEBUG(D_NET,
 	       "%s added to recovery queue. ping count: %u next ping: %lld health :%d\n",
-	       libcfs_nid2str(ni->ni_nid),
+	       libcfs_nidstr(&ni->ni_nid),
 	       ni->ni_ping_count,
 	       ni->ni_next_ping,
 	       atomic_read(&ni->ni_healthv));
@@ -796,10 +796,11 @@
 	/* if we're sending to the LOLND then the msg_txpeer will not be
 	 * set. So no need to sanity check it.
 	 */
-	if (msg->msg_tx_committed && msg->msg_txni->ni_nid != LNET_NID_LO_0)
+	if (msg->msg_tx_committed &&
+	    !nid_is_lo0(&msg->msg_txni->ni_nid))
 		LASSERT(msg->msg_txpeer);
 	else if (msg->msg_tx_committed &&
-		 msg->msg_txni->ni_nid == LNET_NID_LO_0)
+		 nid_is_lo0(&msg->msg_txni->ni_nid))
 		lo = true;
 
 	if (hstatus != LNET_MSG_STATUS_OK &&
@@ -827,7 +828,7 @@
 		LASSERT(ni);
 
 	CDEBUG(D_NET, "health check: %s->%s: %s: %s\n",
-	       libcfs_nid2str(ni->ni_nid),
+	       libcfs_nidstr(&ni->ni_nid),
 	       (lo) ? "self" : libcfs_nid2str(lpni->lpni_nid),
 	       lnet_msgtyp2str(msg->msg_type),
 	       lnet_health_error2str(hstatus));
@@ -1114,7 +1115,7 @@
 	CDEBUG(D_NET,
 	       "src %s(%s)->dst %s: %s simulate health error: %s\n",
 	       libcfs_nid2str(msg->msg_hdr.src_nid),
-	       libcfs_nid2str(msg->msg_txni->ni_nid),
+	       libcfs_nidstr(&msg->msg_txni->ni_nid),
 	       libcfs_nid2str(msg->msg_hdr.dest_nid),
 	       lnet_msgtyp2str(msg->msg_type),
 	       lnet_health_error2str(*hstatus));
net/lnet/lnet/lib-socket.c +24 -8
index 317d3cf..7deb48a 100644
@@ -235,9 +235,33 @@ int choose_ipv4_src(u32 *ret, int interface, u32 dst_ipaddr, struct net *ns)
 #if IS_ENABLED(CONFIG_IPV6)
 		case AF_INET6: {
 			struct sockaddr_in6 *sin6 = (void *)&locaddr;
+			int val = 0;
 
 			sin6->sin6_family = AF_INET6;
 			sin6->sin6_addr = in6addr_any;
+
+			/* Make sure we get both IPv4 and IPv6 connections.
+			 * This is the default, but it can be overridden so we
+			 * force it back.
+			 */
+			/* From v5.7-rc6-2614-g5a892ff2facb when
+			 * kernel_setsockopt() was removed until
+			 * sockptr_t (above) there is no clean way to
+			 * pass kernel address to setsockopt.  We could
+			 * use get_fs()/set_fs(), but in this particular
+			 * situation there is an easier way.  It depends
+			 * on the fact that at least for these few
+			 * kernels a NULL address to ipv6_setsockopt()
+			 * is treated like the address of a zero.
+			 */
+			if (ipv6_only_sock(sock->sk) && !val) {
+				void *optval = NULL;
+
+				sock->ops->setsockopt(sock,
+						      IPPROTO_IPV6, IPV6_V6ONLY,
+						      optval, sizeof(val));
+			}
+
 			if (interface >= 0 && remaddr) {
 				struct sockaddr_in6 *rem = (void *)remaddr;
 
@@ -352,7 +376,6 @@ struct socket *
 lnet_sock_listen(int local_port, int backlog, struct net *ns)
 {
 	struct socket *sock;
-	int val = 0;
 	int rc;
 
 	sock = lnet_sock_create(-1, NULL, local_port, ns);
@@ -364,13 +387,6 @@ struct socket *
 		return ERR_PTR(rc);
 	}
 
-	/* Make sure we get both IPv4 and IPv6 connections.
-	 * This is the default, but it can be overridden so
-	 * we force it back.
-	 */
-	kernel_setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
-			  (char *)&val, sizeof(val));
-
 	rc = kernel_listen(sock, backlog);
 	if (!rc)
 		return sock;
net/lnet/lnet/lo.c +2 -1
index 4ddf1cd..3d3dcf8 100644
@@ -40,7 +40,8 @@
 	LASSERT(!lntmsg->msg_routing);
 	LASSERT(!lntmsg->msg_target_is_router);
 
-	return lnet_parse(ni, &lntmsg->msg_hdr, ni->ni_nid, lntmsg, 0);
+	return lnet_parse(ni, &lntmsg->msg_hdr,
+			  lnet_nid_to_nid4(&ni->ni_nid), lntmsg, 0);
 }
 
 static int
net/lnet/lnet/net_fault.c +1 -1
index 0d19da4..4c50eec 100644
@@ -684,7 +684,7 @@ struct delay_daemon_data {
 			list_del_init(&msg->msg_list);
 			ni = msg->msg_txni;
 			CDEBUG(D_NET, "TRACE: msg %p %s -> %s : %s\n", msg,
-			       libcfs_nid2str(ni->ni_nid),
+			       libcfs_nidstr(&ni->ni_nid),
 			       libcfs_nid2str(msg->msg_txpeer->lpni_nid),
 			       lnet_msgtyp2str(msg->msg_type));
 			lnet_ni_send(ni, msg);
net/lnet/lnet/nidstrings.c +40 -0
index 209da0f..6da43d5 100644
@@ -906,6 +906,46 @@ int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist)
 }
 EXPORT_SYMBOL(libcfs_nid2str_r);
 
+char *
+libcfs_nidstr_r(const struct lnet_nid *nid, char *buf, size_t buf_size)
+{
+	u32 nnum = be16_to_cpu(nid->nid_num);
+	u32 lnd  = nid->nid_type;
+	struct netstrfns *nf;
+
+	if (LNET_NID_IS_ANY(nid)) {
+		strncpy(buf, "<?>", buf_size);
+		buf[buf_size - 1] = '\0';
+		return buf;
+	}
+
+	nf = libcfs_lnd2netstrfns(lnd);
+	if (nf && nid_is_nid4(nid)) {
+		size_t addr_len;
+
+		nf->nf_addr2str(ntohl(nid->nid_addr[0]), buf, buf_size);
+		addr_len = strlen(buf);
+		if (nnum == 0)
+			snprintf(buf + addr_len, buf_size - addr_len, "@%s",
+				 nf->nf_name);
+		else
+			snprintf(buf + addr_len, buf_size - addr_len, "@%s%u",
+				 nf->nf_name, nnum);
+	} else {
+		int l = 0;
+		int words = DIV_ROUND_UP(NID_ADDR_BYTES(nid), 4);
+		int i;
+
+		for (i = 0; i < words && i < 4; i++)
+			l = snprintf(buf + l, buf_size - l, "%s%x",
+				     i ? ":" : "", ntohl(nid->nid_addr[i]));
+		snprintf(buf + l, buf_size - l, "@<%u:%u>", lnd, nnum);
+	}
+
+	return buf;
+}
+EXPORT_SYMBOL(libcfs_nidstr_r);
+
 static struct netstrfns *
 libcfs_str2net_internal(const char *str, u32 *net)
 {
net/lnet/lnet/router.c +4 -4
index 9003d47..6335425 100644
@@ -1691,21 +1691,21 @@ bool lnet_router_checker_active(void)
 	LASSERT(!in_interrupt());
 
 	CDEBUG(D_NET, "%s notifying %s: %s\n",
-	       !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
+	       !ni ? "userspace" : libcfs_nidstr(&ni->ni_nid),
 	       libcfs_nid2str(nid), alive ? "up" : "down");
 
 	if (ni &&
-	    LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
+	    LNET_NID_NET(&ni->ni_nid) != LNET_NIDNET(nid)) {
 		CWARN("Ignoring notification of %s %s by %s (different net)\n",
 		      libcfs_nid2str(nid), alive ? "birth" : "death",
-		      libcfs_nid2str(ni->ni_nid));
+		      libcfs_nidstr(&ni->ni_nid));
 		return -EINVAL;
 	}
 
 	/* can't do predictions... */
 	if (when > now) {
 		CWARN("Ignoring prediction from %s of %s %s %lld seconds in the future\n",
-		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
+		      ni ? libcfs_nidstr(&ni->ni_nid) : "userspace",
 		      libcfs_nid2str(nid), alive ? "up" : "down", when - now);
 		return -EINVAL;
 	}
net/lnet/lnet/router_proc.c +1 -1
index 43f70b6..6649f06 100644
@@ -702,7 +702,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
 
 				s += scnprintf(s, tmpstr + tmpsiz - s,
 					       "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n",
-					       libcfs_nid2str(ni->ni_nid), stat,
+					       libcfs_nidstr(&ni->ni_nid), stat,
 					       last_alive, *ni->ni_refs[i],
 					       ni->ni_net->net_tunables.lct_peer_tx_credits,
 					       ni->ni_net->net_tunables.lct_peer_rtr_credits,
net/lnet/lnet/udsp.c +7 -6
index 516db98..4495062 100644
@@ -213,7 +213,7 @@ enum udsp_apply {
 	struct lnet_ud_nid_descr *ni_match = udi->udi_match;
 	u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
 
-	rc = cfs_match_nid_net(ni->ni_nid,
+	rc = cfs_match_nid_net(lnet_nid_to_nid4(&ni->ni_nid),
 			       ni_match->ud_net_id.udn_net_type,
 			       &ni_match->ud_net_id.udn_net_num_range,
 			       &ni_match->ud_addr_range);
@@ -221,7 +221,7 @@ enum udsp_apply {
 		return 0;
 
 	CDEBUG(D_NET, "apply udsp on ni %s\n",
-	       libcfs_nid2str(ni->ni_nid));
+	       libcfs_nidstr(&ni->ni_nid));
 
 	/* Detected match. Set NIDs priority */
 	lnet_ni_set_sel_priority_locked(ni, priority);
@@ -481,7 +481,7 @@ enum udsp_apply {
 		    ni_action->ud_net_id.udn_net_type)
 			continue;
 		list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-			rc = cfs_match_nid_net(ni->ni_nid,
+			rc = cfs_match_nid_net(lnet_nid_to_nid4(&ni->ni_nid),
 					       ni_action->ud_net_id.udn_net_type,
 					       &ni_action->ud_net_id.udn_net_num_range,
 					       &ni_action->ud_addr_range);
@@ -500,15 +500,16 @@ enum udsp_apply {
 				}
 			}
 			CDEBUG(D_NET, "add nid %s as preferred for peer %s\n",
-			       libcfs_nid2str(ni->ni_nid),
+			       libcfs_nidstr(&ni->ni_nid),
 			       libcfs_nid2str(lpni->lpni_nid));
 			/* match. Add to pref NIDs */
-			rc = lnet_peer_add_pref_nid(lpni, ni->ni_nid);
+			rc = lnet_peer_add_pref_nid(lpni,
+						    lnet_nid_to_nid4(&ni->ni_nid));
 			lnet_net_lock(LNET_LOCK_EX);
 			/* success if EEXIST return */
 			if (rc && rc != -EEXIST) {
 				CERROR("Failed to add %s to %s pref nid list\n",
-				       libcfs_nid2str(ni->ni_nid),
+				       libcfs_nidstr(&ni->ni_nid),
 				       libcfs_nid2str(lpni->lpni_nid));
 				return rc;
 			}
Signature · 6 lines
1.8.3.1

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

PATCH 4/24 lnet: add string formating/parsing for IPv6 nids

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

New entries for struct netstrfns:
nf_addr2str_size
nf_str2addr_size
which accept or report the size of the address in bytes. New matching functions that can report or parse IPv4 and IPv6 addresses.

New interface - currently unused - libcfs_strnid() which takes a str and provides a 'struct lnet_nid' with appropriate nid_size.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 7224b21156639a63 ("LU-10391 lnet: add string formating/parsing for IPv6 nids")

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

---
 include/linux/lnet/lib-types.h   |   4 ++
 include/uapi/linux/lnet/nidstr.h |   1 +
 net/lnet/lnet/nidstrings.c       | 109 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 110 insertions(+), 4 deletions(-)
include/linux/lnet/lib-types.h +4 -0
index 80cf4f3..5b517cc 100644
@@ -248,7 +248,11 @@ struct netstrfns {
 	char	*nf_name;
 	char	*nf_modname;
 	void	(*nf_addr2str)(u32 addr, char *str, size_t size);
+	void	(*nf_addr2str_size)(const __be32 *addr, size_t asize,
+				    char *str, size_t size);
 	int	(*nf_str2addr)(const char *str, int nob, u32 *addr);
+	int	(*nf_str2addr_size)(const char *str, int nob,
+				    __be32 *addr, size_t *asize);
 	int	(*nf_parse_addrlist)(char *str, int len,
 				     struct list_head *list);
 	int	(*nf_print_addrlist)(char *buffer, int count,
include/uapi/linux/lnet/nidstr.h +1 -0
index d5b9d69..13a0d10 100644
@@ -100,6 +100,7 @@ static inline char *libcfs_nidstr(const struct lnet_nid *nid)
 
 __u32 libcfs_str2net(const char *str);
 lnet_nid_t libcfs_str2nid(const char *str);
+int libcfs_strnid(struct lnet_nid *nid, const char *str);
 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
 char *libcfs_id2str(struct lnet_process_id id);
 void cfs_free_nidlist(struct list_head *list);
net/lnet/lnet/nidstrings.c +105 -4

148 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

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

PATCH 5/24 lnet: change lpni_nid in lnet_peer_ni to lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

lpni_nid in 'struct lnet_peer_ni' is converted to 'struct lnet_nid' and various supporting functions updated.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 6c5561a1e1eeab18e ("LU-10391 lnet: change lpni_nid in lnet_peer_ni to lnet_nid")

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

---
 include/linux/lnet/lib-lnet.h  | 14 ++++++---
 include/linux/lnet/lib-types.h |  2 +-
 net/lnet/lnet/api-ni.c         | 61 +++++++++++++++++++++++++++----------
 net/lnet/lnet/lib-move.c       | 49 ++++++++++++++++--------------
 net/lnet/lnet/lib-msg.c        |  2 +-
 net/lnet/lnet/net_fault.c      |  2 +-
 net/lnet/lnet/peer.c           | 68 +++++++++++++++++++++++-------------------
 net/lnet/lnet/router.c         |  7 +++--
 net/lnet/lnet/router_proc.c    |  4 +--
 net/lnet/lnet/udsp.c           | 20 ++++++-------
 10 files changed, 139 insertions(+), 90 deletions(-)
include/linux/lnet/lib-lnet.h +10 -4
index acc069d..05c099d 100644
@@ -459,9 +459,14 @@ struct lnet_ni *
 			  char *iface);
 
 static inline int
-lnet_nid2peerhash(lnet_nid_t nid)
+lnet_nid2peerhash(struct lnet_nid *nid)
 {
-	return hash_long(nid, LNET_PEER_HASH_BITS);
+	u32 h = 0;
+	int i;
+
+	for (i = 0; i < 4; i++)
+		h = hash_32(nid->nid_addr[i]^h, 32);
+	return hash_32(LNET_NID_NET(nid) ^ h, LNET_PEER_HASH_BITS);
 }
 
 static inline struct list_head *
@@ -476,7 +481,7 @@ struct lnet_ni *
 extern int avoid_asym_router_failure;
 
 unsigned int lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number);
-int lnet_cpt_of_nid_locked(lnet_nid_t nid, struct lnet_ni *ni);
+int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni);
 int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 struct lnet_ni *lnet_nid2ni_addref(lnet_nid_t nid);
@@ -900,7 +905,8 @@ int lnet_get_peer_ni_info(u32 peer_index, u64 *nid,
 static inline bool
 lnet_peer_ni_is_primary(struct lnet_peer_ni *lpni)
 {
-	return lpni->lpni_nid == lpni->lpni_peer_net->lpn_peer->lp_primary_nid;
+	return lnet_nid_to_nid4(&lpni->lpni_nid) ==
+			lpni->lpni_peer_net->lpn_peer->lp_primary_nid;
 }
 
 bool lnet_peer_is_uptodate(struct lnet_peer *lp);
include/linux/lnet/lib-types.h +1 -1
index 5b517cc..a6223d2 100644
@@ -606,7 +606,7 @@ struct lnet_peer_ni {
 	/* network peer is on */
 	struct lnet_net		*lpni_net;
 	/* peer's NID */
-	lnet_nid_t		 lpni_nid;
+	struct lnet_nid		 lpni_nid;
 	/* # refs */
 	struct kref		 lpni_kref;
 	/* health value for the peer */
net/lnet/lnet/api-ni.c +45 -16

138 lines not on this page · raw message

net/lnet/lnet/lib-move.c +27 -22

155 lines not on this page · raw message

net/lnet/lnet/lib-msg.c +1 -1
index b1f684f..3c8b7c3 100644
@@ -829,7 +829,7 @@
 
 	CDEBUG(D_NET, "health check: %s->%s: %s: %s\n",
 	       libcfs_nidstr(&ni->ni_nid),
-	       (lo) ? "self" : libcfs_nid2str(lpni->lpni_nid),
+	       (lo) ? "self" : libcfs_nidstr(&lpni->lpni_nid),
 	       lnet_msgtyp2str(msg->msg_type),
 	       lnet_health_error2str(hstatus));
 
net/lnet/lnet/net_fault.c +1 -1
index 4c50eec..06366df 100644
@@ -685,7 +685,7 @@ struct delay_daemon_data {
 			ni = msg->msg_txni;
 			CDEBUG(D_NET, "TRACE: msg %p %s -> %s : %s\n", msg,
 			       libcfs_nidstr(&ni->ni_nid),
-			       libcfs_nid2str(msg->msg_txpeer->lpni_nid),
+			       libcfs_nidstr(&msg->msg_txpeer->lpni_nid),
 			       lnet_msgtyp2str(msg->msg_type));
 			lnet_ni_send(ni, msg);
 			continue;
net/lnet/lnet/peer.c +38 -30

246 lines not on this page · raw message

net/lnet/lnet/router.c +4 -3
index 6335425..f6fcc93 100644
@@ -1198,7 +1198,7 @@ bool lnet_router_checker_active(void)
 
 		/* discover the router */
 		CDEBUG(D_NET, "discover %s, cpt = %d\n",
-		       libcfs_nid2str(lpni->lpni_nid), cpt);
+		       libcfs_nidstr(&lpni->lpni_nid), cpt);
 		rc = lnet_discover_peer_locked(lpni, cpt, false);
 
 		/* drop ref taken above */
@@ -1772,7 +1772,8 @@ bool lnet_router_checker_active(void)
 		 */
 		if (lnet_is_discovery_disabled(lp)) {
 			list_for_each_entry(route, &lp->lp_routes, lr_gwlist) {
-				if (route->lr_nid == lpni->lpni_nid)
+				if (route->lr_nid ==
+				    lnet_nid_to_nid4(&lpni->lpni_nid))
 					lnet_set_route_aliveness(route, alive);
 			}
 		}
@@ -1781,7 +1782,7 @@ bool lnet_router_checker_active(void)
 	lnet_net_unlock(0);
 
 	if (ni && !alive)
-		lnet_notify_peer_down(ni, lpni->lpni_nid);
+		lnet_notify_peer_down(ni, lnet_nid_to_nid4(&lpni->lpni_nid));
 
 	cpt = lpni->lpni_cpt;
 	lnet_net_lock(cpt);
net/lnet/lnet/router_proc.c +2 -2
index 6649f06..1a04ac4 100644
@@ -474,7 +474,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 		}
 
 		if (peer) {
-			lnet_nid_t nid = peer->lpni_nid;
+			struct lnet_nid nid = peer->lpni_nid;
 			int nrefs = kref_read(&peer->lpni_kref);
 			time64_t lastalive = -1;
 			char *aliveness = "NA";
@@ -495,7 +495,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 
 			s += scnprintf(s, tmpstr + tmpsiz - s,
 				       "%-24s %4d %5s %5lld %5d %5d %5d %5d %5d %d\n",
-				       libcfs_nid2str(nid), nrefs, aliveness,
+				       libcfs_nidstr(&nid), nrefs, aliveness,
 				       lastalive, maxcr, rtrcr, minrtrcr, txcr,
 				       mintxcr, txqnob);
 			LASSERT(tmpstr + tmpsiz - s > 0);
net/lnet/lnet/udsp.c +10 -10
index 4495062..03669e6 100644
@@ -255,7 +255,7 @@ enum udsp_apply {
 									    lpni)) != NULL) {
 					if (!lnet_get_net_locked(lpni->lpni_peer_net->lpn_net_id))
 						continue;
-					gw_nid = lpni->lpni_nid;
+					gw_nid = lnet_nid_to_nid4(&lpni->lpni_nid);
 					rc = cfs_match_nid_net(gw_nid,
 							       rte_action->ud_net_id.udn_net_type,
 							       &rte_action->ud_net_id.udn_net_num_range,
@@ -437,7 +437,7 @@ enum udsp_apply {
 					CDEBUG(D_NET,
 					       "%spref rtr nids from lpni %s\n",
 					       (revert) ? "revert " : "clear ",
-					       libcfs_nid2str(lpni->lpni_nid));
+					       libcfs_nidstr(&lpni->lpni_nid));
 					lnet_peer_clr_pref_rtrs(lpni);
 					cleared = true;
 					if (revert) {
@@ -448,7 +448,7 @@ enum udsp_apply {
 				CDEBUG(D_NET,
 				       "add gw nid %s as preferred for peer %s\n",
 				       libcfs_nid2str(gw_nid),
-				       libcfs_nid2str(lpni->lpni_nid));
+				       libcfs_nidstr(&lpni->lpni_nid));
 				/* match. Add to pref NIDs */
 				rc = lnet_peer_add_pref_rtr(lpni, gw_nid);
 				lnet_net_lock(LNET_LOCK_EX);
@@ -456,7 +456,7 @@ enum udsp_apply {
 				if (rc && rc != -EEXIST) {
 					CERROR("Failed to add %s to %s pref rtr list\n",
 					       libcfs_nid2str(gw_nid),
-					       libcfs_nid2str(lpni->lpni_nid));
+					       libcfs_nidstr(&lpni->lpni_nid));
 					return rc;
 				}
 			}
@@ -492,7 +492,7 @@ enum udsp_apply {
 				lnet_peer_clr_pref_nids(lpni);
 				CDEBUG(D_NET, "%spref nids from lpni %s\n",
 				       (revert) ? "revert " : "clear ",
-				       libcfs_nid2str(lpni->lpni_nid));
+				       libcfs_nidstr(&lpni->lpni_nid));
 				cleared = true;
 				if (revert) {
 					lnet_net_lock(LNET_LOCK_EX);
@@ -501,7 +501,7 @@ enum udsp_apply {
 			}
 			CDEBUG(D_NET, "add nid %s as preferred for peer %s\n",
 			       libcfs_nidstr(&ni->ni_nid),
-			       libcfs_nid2str(lpni->lpni_nid));
+			       libcfs_nidstr(&lpni->lpni_nid));
 			/* match. Add to pref NIDs */
 			rc = lnet_peer_add_pref_nid(lpni,
 						    lnet_nid_to_nid4(&ni->ni_nid));
@@ -510,7 +510,7 @@ enum udsp_apply {
 			if (rc && rc != -EEXIST) {
 				CERROR("Failed to add %s to %s pref nid list\n",
 				       libcfs_nidstr(&ni->ni_nid),
-				       libcfs_nid2str(lpni->lpni_nid));
+				       libcfs_nidstr(&lpni->lpni_nid));
 				return rc;
 			}
 		}
@@ -530,7 +530,7 @@ enum udsp_apply {
 	bool local = udi->udi_local;
 	enum lnet_udsp_action_type type = udi->udi_type;
 
-	rc = cfs_match_nid_net(lpni->lpni_nid,
+	rc = cfs_match_nid_net(lnet_nid_to_nid4(&lpni->lpni_nid),
 			       lp_match->ud_net_id.udn_net_type,
 			       &lp_match->ud_net_id.udn_net_num_range,
 			       &lp_match->ud_addr_range);
@@ -629,7 +629,7 @@ enum udsp_apply {
 						    lpni_peer_nis) {
 					CDEBUG(D_NET,
 					       "udsp examining lpni %s\n",
-					       libcfs_nid2str(lpni->lpni_nid));
+					       libcfs_nidstr(&lpni->lpni_nid));
 					udi->udi_lpni = lpni;
 					rc = lnet_udsp_apply_rule_on_lpni(udi);
 					if (rc)
@@ -1017,7 +1017,7 @@ struct lnet_udsp *
 
 	info->cud_nid_priority = lpni->lpni_sel_priority;
 	CDEBUG(D_NET, "lpni %s has %d pref nids\n",
-	       libcfs_nid2str(lpni->lpni_nid),
+	       libcfs_nidstr(&lpni->lpni_nid),
 	       lpni->lpni_pref_nnids);
 	if (lpni->lpni_pref_nnids == 1) {
 		info->cud_pref_nid[0] = lpni->lpni_pref.nid;
Signature · 6 lines
1.8.3.1

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

PATCH 6/24 lnet: change lp_primary_nid to struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Change lp_primary_nid in struct lnet_peer to struct lnet_nid.

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

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

---
 include/linux/lnet/lib-lnet.h  |  10 +-
 include/linux/lnet/lib-types.h |   2 +-
 net/lnet/lnet/api-ni.c         |  46 +++++--
 net/lnet/lnet/lib-move.c       |   7 +-
 net/lnet/lnet/peer.c           | 297 +++++++++++++++++++++++------------------
 net/lnet/lnet/router.c         |  38 +++---
 net/lnet/lnet/router_proc.c    |   4 +-
 net/lnet/lnet/udsp.c           |   6 +-
 8 files changed, 238 insertions(+), 172 deletions(-)
include/linux/lnet/lib-lnet.h +6 -4
index 05c099d..a4ec067 100644
@@ -480,7 +480,8 @@ struct lnet_ni *
 extern struct lnet_lnd the_lolnd;
 extern int avoid_asym_router_failure;
 
-unsigned int lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number);
+unsigned int lnet_nid_cpt_hash(struct lnet_nid *nid,
+			       unsigned int number);
 int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni);
 int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
@@ -838,6 +839,7 @@ struct lnet_peer_ni *lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref,
 struct lnet_peer_ni *lnet_peer_get_ni_locked(struct lnet_peer *lp,
 					     lnet_nid_t nid);
 struct lnet_peer_ni *lnet_find_peer_ni_locked(lnet_nid_t nid);
+struct lnet_peer_ni *lnet_peer_ni_find_locked(struct lnet_nid *nid);
 struct lnet_peer *lnet_find_peer(lnet_nid_t nid);
 void lnet_peer_net_added(struct lnet_net *net);
 lnet_nid_t lnet_peer_primary_nid_locked(lnet_nid_t nid);
@@ -905,8 +907,8 @@ int lnet_get_peer_ni_info(u32 peer_index, u64 *nid,
 static inline bool
 lnet_peer_ni_is_primary(struct lnet_peer_ni *lpni)
 {
-	return lnet_nid_to_nid4(&lpni->lpni_nid) ==
-			lpni->lpni_peer_net->lpn_peer->lp_primary_nid;
+	return nid_same(&lpni->lpni_nid,
+			 &lpni->lpni_peer_net->lpn_peer->lp_primary_nid);
 }
 
 bool lnet_peer_is_uptodate(struct lnet_peer *lp);
@@ -1081,7 +1083,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	if (old != alive)
 		CERROR("route to %s through %s has gone from %s to %s\n",
 		       libcfs_net2str(route->lr_net),
-		       libcfs_nid2str(route->lr_gateway->lp_primary_nid),
+		       libcfs_nidstr(&route->lr_gateway->lp_primary_nid),
 		       old ? "up" : "down",
 		       alive ? "up" : "down");
 }
include/linux/lnet/lib-types.h +1 -1
index a6223d2..f980f2f 100644
@@ -669,7 +669,7 @@ struct lnet_peer {
 	struct list_head	lp_rtr_list;
 
 	/* primary NID of the peer */
-	lnet_nid_t		lp_primary_nid;
+	struct lnet_nid		lp_primary_nid;
 
 	/* source NID to use during discovery */
 	lnet_nid_t		lp_disc_src_nid;
net/lnet/lnet/api-ni.c +34 -12

88 lines not on this page · raw message

net/lnet/lnet/lib-move.c +4 -3
index 9a2fdb6..8c8db31 100644
@@ -1324,7 +1324,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 	list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
 		if (!lnet_is_route_alive(route))
 			continue;
-		gw_pnid = route->lr_gateway->lp_primary_nid;
+		gw_pnid = lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid);
 
 		/* no protection on below fields, but it's harmless */
 		if (last_route && (last_route->lr_seq - route->lr_seq < 0))
@@ -1938,7 +1938,7 @@ struct lnet_ni *
 	lnet_peer_ni_decref_locked(new_lpni);
 
 	CDEBUG(D_NET, "msg %p delayed. %s pending discovery\n",
-	       msg, libcfs_nid2str(peer->lp_primary_nid));
+	       msg, libcfs_nidstr(&peer->lp_primary_nid));
 
 	return LNET_DC_WAIT;
 }
@@ -4831,7 +4831,8 @@ struct lnet_msg *
 	       libcfs_nidstr(&ni->ni_nid), libcfs_id2str(peer_id), getmd);
 
 	/* setup information for lnet_build_msg_event */
-	msg->msg_initiator = getmsg->msg_txpeer->lpni_peer_net->lpn_peer->lp_primary_nid;
+	msg->msg_initiator =
+		lnet_nid_to_nid4(&getmsg->msg_txpeer->lpni_peer_net->lpn_peer->lp_primary_nid);
 	msg->msg_from = peer_id.nid;
 	msg->msg_type = LNET_MSG_GET; /* flag this msg as an "optimized" GET */
 	msg->msg_hdr.src_nid = peer_id.nid;
net/lnet/lnet/peer.c +168 -129

840 lines not on this page · raw message

net/lnet/lnet/router.c +20 -18
index f6fcc93..2d5f0b6 100644
@@ -175,7 +175,7 @@ static void lnet_del_route_from_rnet(lnet_nid_t gw_nid,
 	/* use the gateway's lp_primary_nid to delete the route as the
 	 * lr_nid can be a constituent NID of the peer
 	 */
-	lnet_del_route_from_rnet(route->lr_gateway->lp_primary_nid,
+	lnet_del_route_from_rnet(lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid),
 				 &rnet->lrn_routes, l);
 
 	if (lp) {
@@ -201,11 +201,11 @@ static void lnet_del_route_from_rnet(lnet_nid_t gw_nid,
 
 	lnet_net_lock(LNET_LOCK_EX);
 	CDEBUG(D_NET, "transferring routes from %s -> %s\n",
-	       libcfs_nid2str(src->lp_primary_nid),
-	       libcfs_nid2str(target->lp_primary_nid));
+	       libcfs_nidstr(&src->lp_primary_nid),
+	       libcfs_nidstr(&target->lp_primary_nid));
 	list_for_each_entry(route, &src->lp_routes, lr_gwlist) {
 		CDEBUG(D_NET, "%s: %s->%s\n",
-		       libcfs_nid2str(src->lp_primary_nid),
+		       libcfs_nidstr(&src->lp_primary_nid),
 		       libcfs_net2str(route->lr_net),
 		       libcfs_nid2str(route->lr_nid));
 	}
@@ -331,7 +331,7 @@ bool lnet_is_route_alive(struct lnet_route *route)
 		spin_unlock(&gw->lp_lock);
 		if (gw->lp_rtr_refcount > 0)
 			CERROR("peer %s is being used as a gateway but routing feature is not turned on\n",
-			       libcfs_nid2str(gw->lp_primary_nid));
+			       libcfs_nidstr(&gw->lp_primary_nid));
 		return false;
 	}
 	spin_unlock(&gw->lp_lock);
@@ -372,7 +372,7 @@ bool lnet_is_route_alive(struct lnet_route *route)
 	    (route->lr_hops == 1 || route->lr_hops == LNET_UNDEFINED_HOPS)) {
 		CWARN("route %s->%s is detected to be multi-hop but hop count is set to %d\n",
 		      libcfs_net2str(route->lr_net),
-		      libcfs_nid2str(route->lr_gateway->lp_primary_nid),
+		      libcfs_nidstr(&route->lr_gateway->lp_primary_nid),
 		      (int)route->lr_hops);
 	}
 }
@@ -420,7 +420,7 @@ bool lnet_is_route_alive(struct lnet_route *route)
 	if (lp_state & LNET_PEER_PING_FAILED ||
 	    pbuf->pb_info.pi_features & LNET_PING_FEAT_RTE_DISABLED) {
 		CDEBUG(D_NET, "Set routes down for gw %s because %s %d\n",
-		       libcfs_nid2str(lp->lp_primary_nid),
+		       libcfs_nidstr(&lp->lp_primary_nid),
 		       lp_state & LNET_PEER_PING_FAILED ? "ping failed" :
 		       "route feature is disabled", lp->lp_ping_error);
 		/* If the ping failed or the peer has routing disabled then
@@ -432,7 +432,7 @@ bool lnet_is_route_alive(struct lnet_route *route)
 	}
 
 	CDEBUG(D_NET, "Discovery is disabled. Processing reply for gw: %s:%d\n",
-	       libcfs_nid2str(lp->lp_primary_nid), pbuf->pb_info.pi_nnis);
+	       libcfs_nidstr(&lp->lp_primary_nid), pbuf->pb_info.pi_nnis);
 
 	/* examine the ping response to determine if the routes on that
 	 * gateway should be declared alive.
@@ -521,7 +521,7 @@ bool lnet_is_route_alive(struct lnet_route *route)
 	 * determine otherwise.
 	 */
 	CDEBUG(D_NET, "%s: Router discovery failed %d\n",
-	       libcfs_nid2str(lp->lp_primary_nid), lp->lp_dc_error);
+	       libcfs_nidstr(&lp->lp_primary_nid), lp->lp_dc_error);
 	while ((lpni = lnet_get_next_peer_ni_locked(lp, NULL, lpni)) != NULL)
 		lpni->lpni_ns_status = LNET_NI_STATUS_DOWN;
 
@@ -741,7 +741,8 @@ static void lnet_shuffle_seed(void)
 		}
 
 		/* our lookups must be true */
-		LASSERT(route2->lr_gateway->lp_primary_nid != gateway);
+		LASSERT(lnet_nid_to_nid4(&route2->lr_gateway->lp_primary_nid) !=
+			gateway);
 	}
 
 	/* It is possible to add multiple routes through the same peer,
@@ -790,7 +791,7 @@ static void lnet_shuffle_seed(void)
 	list_for_each_entry_safe(route, tmp, route_list, lr_list) {
 		gateway = route->lr_gateway;
 		if (gw_nid != LNET_NID_ANY &&
-		    gw_nid != gateway->lp_primary_nid)
+		    gw_nid != lnet_nid_to_nid4(&gateway->lp_primary_nid))
 			continue;
 
 		/* move to zombie to delete outside the lock
@@ -834,7 +835,7 @@ static void lnet_shuffle_seed(void)
 	if (lpni) {
 		lp = lpni->lpni_peer_net->lpn_peer;
 		LASSERT(lp);
-		gw_nid = lp->lp_primary_nid;
+		gw_nid = lnet_nid_to_nid4(&lp->lp_primary_nid);
 		lnet_peer_ni_decref_locked(lpni);
 	}
 
@@ -1142,7 +1143,7 @@ bool lnet_router_checker_active(void)
 			lpn = lnet_get_next_peer_net_locked(rtr, net_id);
 			if (!lpn) {
 				CERROR("gateway %s has no networks\n",
-				       libcfs_nid2str(rtr->lp_primary_nid));
+				       libcfs_nidstr(&rtr->lp_primary_nid));
 				break;
 			}
 
@@ -1159,7 +1160,7 @@ bool lnet_router_checker_active(void)
 			found_lpn = true;
 
 			CDEBUG(D_NET, "rtr %s(%p) %s(%p) next ping %lld\n",
-			       libcfs_nid2str(rtr->lp_primary_nid), rtr,
+			       libcfs_nidstr(&rtr->lp_primary_nid), rtr,
 			       libcfs_net2str(net_id), lpn,
 			       lpn->lpn_next_ping);
 
@@ -1169,7 +1170,7 @@ bool lnet_router_checker_active(void)
 
 		if (!found_lpn || !lpn) {
 			CERROR("no local network found for gateway %s\n",
-			       libcfs_nid2str(rtr->lp_primary_nid));
+			       libcfs_nidstr(&rtr->lp_primary_nid));
 			continue;
 		}
 
@@ -1184,11 +1185,12 @@ bool lnet_router_checker_active(void)
 		spin_unlock(&rtr->lp_lock);
 
 		/* find the peer_ni associated with the primary NID */
-		lpni = lnet_peer_get_ni_locked(rtr, rtr->lp_primary_nid);
+		lpni = lnet_peer_get_ni_locked(rtr,
+					       lnet_nid_to_nid4(&rtr->lp_primary_nid));
 		if (!lpni) {
 			CDEBUG(D_NET,
 			       "Expected to find an lpni for %s, but non found\n",
-			       libcfs_nid2str(rtr->lp_primary_nid));
+			       libcfs_nidstr(&rtr->lp_primary_nid));
 			continue;
 		}
 		lnet_peer_ni_addref_locked(lpni);
@@ -1208,7 +1210,7 @@ bool lnet_router_checker_active(void)
 			lpn->lpn_next_ping = now + alive_router_check_interval;
 		else
 			CERROR("Failed to discover router %s\n",
-			       libcfs_nid2str(rtr->lp_primary_nid));
+			       libcfs_nidstr(&rtr->lp_primary_nid));
 
 		/* NB cpt lock was dropped in lnet_discover_peer_locked() */
 		if (version != the_lnet.ln_routers_version) {
net/lnet/lnet/router_proc.c +2 -2
index 1a04ac4..2e3c802 100644
@@ -310,7 +310,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 		}
 
 		if (peer) {
-			lnet_nid_t nid = peer->lp_primary_nid;
+			struct lnet_nid *nid = &peer->lp_primary_nid;
 			int nrefs = atomic_read(&peer->lp_refcount);
 			int nrtrrefs = peer->lp_rtr_refcount;
 			int alive = lnet_is_gateway_alive(peer);
@@ -319,7 +319,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 				       "%-4d %7d %5s %s\n",
 				       nrefs, nrtrrefs,
 				       alive ? "up" : "down",
-				       libcfs_nid2str(nid));
+				       libcfs_nidstr(nid));
 		}
 
 		lnet_net_unlock(0);
net/lnet/lnet/udsp.c +3 -3
index 03669e6..977a6a6 100644
@@ -248,7 +248,7 @@ enum udsp_apply {
 		list_for_each_entry(rnet, rn_list, lrn_list) {
 			list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
 				/* look if gw nid on the same net matches */
-				gw_prim_nid = route->lr_gateway->lp_primary_nid;
+				gw_prim_nid = lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid);
 				lpni = NULL;
 				while ((lpni = lnet_get_next_peer_ni_locked(route->lr_gateway,
 									    NULL,
@@ -425,7 +425,7 @@ enum udsp_apply {
 		rn_list = &the_lnet.ln_remote_nets_hash[i];
 		list_for_each_entry(rnet, rn_list, lrn_list) {
 			list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
-				gw_nid = route->lr_gateway->lp_primary_nid;
+				gw_nid = lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid);
 				rc = cfs_match_nid_net(gw_nid,
 						       rte_action->ud_net_id.udn_net_type,
 						       &rte_action->ud_net_id.udn_net_num_range,
@@ -608,7 +608,7 @@ enum udsp_apply {
 		ptable = the_lnet.ln_peer_tables[cpt];
 		list_for_each_entry(lp, &ptable->pt_peer_list, lp_peer_list) {
 			CDEBUG(D_NET, "udsp examining lp %s\n",
-			       libcfs_nid2str(lp->lp_primary_nid));
+			       libcfs_nidstr(&lp->lp_primary_nid));
 			list_for_each_entry(lpn,
 					    &lp->lp_peer_nets,
 					    lpn_peer_nets) {
Signature · 6 lines
1.8.3.1

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

PATCH 7/24 lnet: change lp_disc_*_nid to struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

Change lp_disc_src_nid and lp_disc_dst_nid in struct lnet_peer to struct lnet_nid.

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

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

---
 include/linux/lnet/lib-types.h |  4 ++--
 net/lnet/lnet/peer.c           | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)
include/linux/lnet/lib-types.h +2 -2
index f980f2f..ba900e8 100644
@@ -672,9 +672,9 @@ struct lnet_peer {
 	struct lnet_nid		lp_primary_nid;
 
 	/* source NID to use during discovery */
-	lnet_nid_t		lp_disc_src_nid;
+	struct lnet_nid		lp_disc_src_nid;
 	/* destination NID to use during discovery */
-	lnet_nid_t		lp_disc_dst_nid;
+	struct lnet_nid		lp_disc_dst_nid;
 
 	/* net to perform discovery on */
 	u32			lp_disc_net_id;
net/lnet/lnet/peer.c +10 -10
index 7f2c6f3..17f99ee 100644
@@ -224,8 +224,8 @@
 	init_waitqueue_head(&lp->lp_dc_waitq);
 	spin_lock_init(&lp->lp_lock);
 	lp->lp_primary_nid = nid;
-	lp->lp_disc_src_nid = LNET_NID_ANY;
-	lp->lp_disc_dst_nid = LNET_NID_ANY;
+	lp->lp_disc_src_nid = LNET_ANY_NID;
+	lp->lp_disc_dst_nid = LNET_ANY_NID;
 	if (lnet_peers_start_down())
 		lp->lp_alive = false;
 	else
@@ -2635,8 +2635,8 @@ static void lnet_peer_clear_discovery_error(struct lnet_peer *lp)
 
 	spin_lock(&lp->lp_lock);
 
-	lp->lp_disc_src_nid = ev->target.nid;
-	lp->lp_disc_dst_nid = ev->source.nid;
+	lnet_nid4_to_nid(ev->target.nid, &lp->lp_disc_src_nid);
+	lnet_nid4_to_nid(ev->source.nid, &lp->lp_disc_dst_nid);
 
 	/*
 	 * If some kind of error happened the contents of message
@@ -3367,7 +3367,7 @@ static int lnet_peer_data_present(struct lnet_peer *lp)
 			 * received by lp, we need to set the discovery source
 			 * NID for new_lp to the NID stored in lp.
 			 */
-			if (lp->lp_disc_src_nid != LNET_NID_ANY) {
+			if (!LNET_NID_IS_ANY(&lp->lp_disc_src_nid)) {
 				new_lp->lp_disc_src_nid = lp->lp_disc_src_nid;
 				new_lp->lp_disc_dst_nid = lp->lp_disc_dst_nid;
 			}
@@ -3567,13 +3567,13 @@ static int lnet_peer_send_push(struct lnet_peer *lp)
 	/* Refcount for MD. */
 	lnet_peer_addref_locked(lp);
 	id.pid = LNET_PID_LUSTRE;
-	if (lp->lp_disc_dst_nid != LNET_NID_ANY)
-		id.nid = lp->lp_disc_dst_nid;
+	if (!LNET_NID_IS_ANY(&lp->lp_disc_dst_nid))
+		id.nid = lnet_nid_to_nid4(&lp->lp_disc_dst_nid);
 	else
 		id.nid = lnet_nid_to_nid4(&lp->lp_primary_nid);
 	lnet_net_unlock(cpt);
 
-	rc = LNetPut(lp->lp_disc_src_nid, lp->lp_push_mdh,
+	rc = LNetPut(lnet_nid_to_nid4(&lp->lp_disc_src_nid), lp->lp_push_mdh,
 		     LNET_ACK_REQ, id, LNET_RESERVED_PORTAL,
 		     LNET_PROTO_PING_MATCHBITS, 0, 0);
 	/* reset the discovery nid. There is no need to restrict sending
@@ -3581,8 +3581,8 @@ static int lnet_peer_send_push(struct lnet_peer *lp)
 	 * get set to a specific NID, if we initiate discovery from the
 	 * scratch
 	 */
-	lp->lp_disc_src_nid = LNET_NID_ANY;
-	lp->lp_disc_dst_nid = LNET_NID_ANY;
+	lp->lp_disc_src_nid = LNET_ANY_NID;
+	lp->lp_disc_dst_nid = LNET_ANY_NID;
 	if (rc)
 		goto fail_unlink;
 
Signature · 6 lines
1.8.3.1

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

PATCH 8/24 lnet: socklnd: factor out key calculation for ksnd_peers

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The hash_table library requires a "long" to be used as a key. We currently provide the nid, which at 64bits is a suitable long on 64bit hosts, but isn't really correct on 32bit hosts.

When we change to an extend nid (which is 160bits) it will be even less appropriate.

So create a separate function to compute a 'long' key, and implement by simply xoring 'long'-sized parts of the nid together. On a 64bit machine, this is currently optimized away for lnet_nid_t, but that will change when we convert to struct lnet_nid.

This new function is placed in lnet-types.h as it will be more generally useful later.

The hash_table library calls hash_long() on the key, so we don't need to do anything more interesting than xoring.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 96a0c378c2e0a0c8f ("LU-10391 socklnd: factor out key calculation for ksnd_peers")

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

---
 include/uapi/linux/lnet/lnet-types.h | 10 ++++++++++
 net/lnet/klnds/socklnd/socklnd.c     | 17 +++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)
include/uapi/linux/lnet/lnet-types.h +10 -0
index ba8a079..5538d4e 100644
@@ -163,6 +163,16 @@ static inline int nid_same(const struct lnet_nid *n1,
 		n1->nid_addr[3] == n2->nid_addr[3];
 }
 
+/* This can be used when we need to hash a nid */
+static inline unsigned long nidhash(lnet_nid_t nid)
+{
+	unsigned long hash = 0;
+
+	hash ^= LNET_NIDNET(nid);
+	hash ^= LNET_NIDADDR(nid);
+	return hash;
+}
+
 struct lnet_counters_health {
 	__u32	lch_rst_alloc;
 	__u32	lch_resend_count;
net/lnet/klnds/socklnd/socklnd.c +11 -6
index 21569fb..08d1cf4 100644
@@ -221,9 +221,10 @@ struct ksock_peer_ni *
 ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id)
 {
 	struct ksock_peer_ni *peer_ni;
+	unsigned long hash = nidhash(id.nid);
 
 	hash_for_each_possible(ksocknal_data.ksnd_peers, peer_ni,
-			       ksnp_list, id.nid) {
+			       ksnp_list, hash) {
 		LASSERT(!peer_ni->ksnp_closing);
 
 		if (peer_ni->ksnp_ni != ni)
@@ -602,7 +603,8 @@ struct ksock_peer_ni *
 		peer_ni = peer2;
 	} else {
 		/* peer_ni table takes my ref on peer_ni */
-		hash_add(ksocknal_data.ksnd_peers, &peer_ni->ksnp_list, id.nid);
+		hash_add(ksocknal_data.ksnd_peers, &peer_ni->ksnp_list,
+			 nidhash(id.nid));
 	}
 
 	ksocknal_add_conn_cb_locked(peer_ni, conn_cb);
@@ -656,7 +658,8 @@ struct ksock_peer_ni *
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
 	if (id.nid != LNET_NID_ANY) {
-		lo = hash_min(id.nid, HASH_BITS(ksocknal_data.ksnd_peers));
+		lo = hash_min(nidhash(id.nid),
+			      HASH_BITS(ksocknal_data.ksnd_peers));
 		hi = lo;
 	} else {
 		lo = 0;
@@ -935,7 +938,7 @@ struct ksock_peer_ni *
 			 * table (which takes my ref)
 			 */
 			hash_add(ksocknal_data.ksnd_peers,
-				 &peer_ni->ksnp_list, peerid.nid);
+				 &peer_ni->ksnp_list, nidhash(peerid.nid));
 		} else {
 			ksocknal_peer_decref(peer_ni);
 			peer_ni = peer2;
@@ -1567,7 +1570,8 @@ struct ksock_peer_ni *
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
 	if (id.nid != LNET_NID_ANY) {
-		lo = hash_min(id.nid, HASH_BITS(ksocknal_data.ksnd_peers));
+		lo = hash_min(nidhash(id.nid),
+			      HASH_BITS(ksocknal_data.ksnd_peers));
 		hi = lo;
 	} else {
 		lo = 0;
@@ -1662,7 +1666,8 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 	int rc = -ENOENT;
 
 	if (id.nid != LNET_NID_ANY) {
-		lo = hash_min(id.nid, HASH_BITS(ksocknal_data.ksnd_peers));
+		lo = hash_min(nidhash(id.nid),
+			      HASH_BITS(ksocknal_data.ksnd_peers));
 		hi = lo;
 	} else {
 		lo = 0;
Signature · 6 lines
1.8.3.1

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

PATCH 9/24 lnet: introduce lnet_processid for ksock_peer_ni

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

struct lnet_processid (without the '_') is like lnet_process_id, but contains a 'struct lnet_nid' rather than lnet_nid_t.

So far it is only used for ksnp_id in struct ksock_peer_ni, and related functions.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: e1dbfdd53e2ce9543 ("LU-10391 lnet: introduce lnet_processid for ksock_peer_ni")

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

---
 include/linux/lnet/lib-lnet.h          |   1 +
 include/uapi/linux/lnet/lnet-types.h   |  36 +++++-
 include/uapi/linux/lnet/nidstr.h       |   1 +
 net/lnet/klnds/socklnd/socklnd.c       | 208 ++++++++++++++++++---------------
 net/lnet/klnds/socklnd/socklnd.h       |  14 +--
 net/lnet/klnds/socklnd/socklnd_cb.c    | 111 ++++++++++--------
 net/lnet/klnds/socklnd/socklnd_proto.c |  14 +--
 net/lnet/lnet/api-ni.c                 |  21 +++-
 net/lnet/lnet/nidstrings.c             |  18 +++
 9 files changed, 259 insertions(+), 165 deletions(-)
include/linux/lnet/lib-lnet.h +1 -0
index a4ec067..3842976 100644
@@ -484,6 +484,7 @@ unsigned int lnet_nid_cpt_hash(struct lnet_nid *nid,
 			       unsigned int number);
 int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni);
 int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
+int lnet_nid2cpt(struct lnet_nid *nid, struct lnet_ni *ni);
 struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 struct lnet_ni *lnet_nid2ni_addref(lnet_nid_t nid);
 struct lnet_ni *lnet_net2ni_locked(u32 net, int cpt);
include/uapi/linux/lnet/lnet-types.h +33 -3
index 5538d4e..ec0c4ef 100644
@@ -164,12 +164,14 @@ static inline int nid_same(const struct lnet_nid *n1,
 }
 
 /* This can be used when we need to hash a nid */
-static inline unsigned long nidhash(lnet_nid_t nid)
+static inline unsigned long nidhash(const struct lnet_nid *nid)
 {
+	int i;
 	unsigned long hash = 0;
 
-	hash ^= LNET_NIDNET(nid);
-	hash ^= LNET_NIDADDR(nid);
+	hash ^= LNET_NID_NET(nid);
+	for (i = 0; i < 4; i++)
+		hash ^= nid->nid_addr[i];
 	return hash;
 }
 
@@ -241,6 +243,34 @@ struct lnet_process_id {
 	/** process id */
 	lnet_pid_t pid;
 };
+
+/**
+ * Global process ID - with large addresses
+ */
+struct lnet_processid {
+	/** node id */
+	struct lnet_nid nid;
+	/** process id */
+	lnet_pid_t pid;
+};
+
+static inline void
+lnet_pid4_to_pid(struct lnet_process_id pid4, struct lnet_processid *pid)
+{
+	pid->pid = pid4.pid;
+	lnet_nid4_to_nid(pid4.nid, &pid->nid);
+}
+
+static inline struct lnet_process_id
+lnet_pid_to_pid4(struct lnet_processid *pid)
+{
+	struct lnet_process_id ret;
+
+	ret.pid = pid->pid;
+	ret.nid = lnet_nid_to_nid4(&pid->nid);
+	return ret;
+}
+
 /** @} lnet_addr */
 
 /** \addtogroup lnet_me
include/uapi/linux/lnet/nidstr.h +1 -0
index 13a0d10..bfc9644 100644
@@ -103,6 +103,7 @@ static inline char *libcfs_nidstr(const struct lnet_nid *nid)
 int libcfs_strnid(struct lnet_nid *nid, const char *str);
 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
 char *libcfs_id2str(struct lnet_process_id id);
+char *libcfs_idstr(struct lnet_processid *id);
 void cfs_free_nidlist(struct list_head *list);
 int cfs_parse_nidlist(char *str, int len, struct list_head *list);
 int cfs_print_nidlist(char *buffer, int count, struct list_head *list);
net/lnet/klnds/socklnd/socklnd.c +113 -95

552 lines not on this page · raw message

net/lnet/klnds/socklnd/socklnd.h +7 -7
index 7a55492..fe1bc7d 100644
@@ -415,7 +415,7 @@ struct ksock_peer_ni {
 	time64_t		ksnp_last_alive;	/* when (in seconds) I was last
 							 * alive
 							 */
-	struct lnet_process_id	ksnp_id;		/* who's on the other end(s) */
+	struct lnet_processid	ksnp_id;		/* who's on the other end(s) */
 	refcount_t		ksnp_refcount;		/* # users */
 	int			ksnp_closing;		/* being closed */
 	int			ksnp_accepting;		/* # passive connections pending
@@ -625,12 +625,12 @@ int ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 		  int delayed, struct iov_iter *to, unsigned int rlen);
 int ksocknal_accept(struct lnet_ni *ni, struct socket *sock);
 
-int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, u32 ip,
-		      int port);
+int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id,
+		      struct sockaddr *addr);
 struct ksock_peer_ni *ksocknal_find_peer_locked(struct lnet_ni *ni,
-					        struct lnet_process_id id);
+						struct lnet_processid *id);
 struct ksock_peer_ni *ksocknal_find_peer(struct lnet_ni *ni,
-				         struct lnet_process_id id);
+					 struct lnet_processid *id);
 void ksocknal_peer_failed(struct ksock_peer_ni *peer_ni);
 int ksocknal_create_conn(struct lnet_ni *ni, struct ksock_conn_cb *conn_cb,
 			 struct socket *sock, int type);
@@ -640,12 +640,12 @@ int ksocknal_create_conn(struct lnet_ni *ni, struct ksock_conn_cb *conn_cb,
 int ksocknal_close_peer_conns_locked(struct ksock_peer_ni *peer_ni,
 				     struct sockaddr *peer, int why);
 int ksocknal_close_conn_and_siblings(struct ksock_conn *conn, int why);
-int ksocknal_close_matching_conns(struct lnet_process_id id, u32 ipaddr);
+int ksocknal_close_matching_conns(struct lnet_processid *id, u32 ipaddr);
 struct ksock_conn *ksocknal_find_conn_locked(struct ksock_peer_ni *peer_ni,
 					     struct ksock_tx *tx, int nonblk);
 
 int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
-			   struct lnet_process_id id);
+			   struct lnet_processid *id);
 struct ksock_tx *ksocknal_alloc_tx(int type, int size);
 void ksocknal_free_tx(struct ksock_tx *tx);
 struct ksock_tx *ksocknal_alloc_tx_noop(u64 cookie, int nonblk);
net/lnet/klnds/socklnd/socklnd_cb.c +62 -49

306 lines not on this page · raw message

net/lnet/klnds/socklnd/socklnd_proto.c +7 -7
index 0a6072b..c3ba070 100644
@@ -189,7 +189,7 @@
 	if (cookie == tx->tx_msg.ksm_zc_cookies[0] ||
 	    cookie == tx->tx_msg.ksm_zc_cookies[1]) {
 		CWARN("%s: duplicated ZC cookie: %llu\n",
-		      libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie);
+		      libcfs_idstr(&conn->ksnc_peer->ksnp_id), cookie);
 		return 1; /* XXX return error in the future */
 	}
 
@@ -243,14 +243,14 @@
 		}
 
 	} else {
-		/*
-		 * ksm_zc_cookies[0] < ksm_zc_cookies[1],
-		 * it is range of cookies
+		/* ksm_zc_cookies[0] < ksm_zc_cookies[1], it is range
+		 * of cookies
 		 */
 		if (cookie >= tx->tx_msg.ksm_zc_cookies[0] &&
 		    cookie <= tx->tx_msg.ksm_zc_cookies[1]) {
 			CWARN("%s: duplicated ZC cookie: %llu\n",
-			      libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie);
+			      libcfs_idstr(&conn->ksnc_peer->ksnp_id),
+			      cookie);
 			return 1; /* XXX: return error in the future */
 		}
 
@@ -398,8 +398,8 @@
 	if (!tx)
 		return -ENOMEM;
 
-	rc = ksocknal_launch_packet(peer_ni->ksnp_ni, tx, peer_ni->ksnp_id);
-	if (!rc)
+	rc = ksocknal_launch_packet(peer_ni->ksnp_ni, tx, &peer_ni->ksnp_id);
+	if (rc == 0)
 		return 0;
 
 	ksocknal_free_tx(tx);
net/lnet/lnet/api-ni.c +17 -4
index f5b022f..1f053b3 100644
@@ -1509,22 +1509,35 @@ struct lnet_net *
 }
 
 int
-lnet_cpt_of_nid(lnet_nid_t nid4, struct lnet_ni *ni)
+lnet_nid2cpt(struct lnet_nid *nid, struct lnet_ni *ni)
 {
 	int cpt;
 	int cpt2;
-	struct lnet_nid nid;
 
 	if (LNET_CPT_NUMBER == 1)
 		return 0; /* the only one */
 
-	lnet_nid4_to_nid(nid4, &nid);
 	cpt = lnet_net_lock_current();
-	cpt2 = lnet_cpt_of_nid_locked(&nid, ni);
+
+	cpt2 = lnet_cpt_of_nid_locked(nid, ni);
+
 	lnet_net_unlock(cpt);
 
 	return cpt2;
 }
+EXPORT_SYMBOL(lnet_nid2cpt);
+
+int
+lnet_cpt_of_nid(lnet_nid_t nid4, struct lnet_ni *ni)
+{
+	struct lnet_nid nid;
+
+	if (LNET_CPT_NUMBER == 1)
+		return 0; /* the only one */
+
+	lnet_nid4_to_nid(nid4, &nid);
+	return lnet_nid2cpt(&nid, ni);
+}
 EXPORT_SYMBOL(lnet_cpt_of_nid);
 
 int
net/lnet/lnet/nidstrings.c +18 -0
index 08f828b..d91815d 100644
@@ -1139,6 +1139,24 @@ int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist)
 }
 EXPORT_SYMBOL(libcfs_id2str);
 
+char *
+libcfs_idstr(struct lnet_processid *id)
+{
+	char *str = libcfs_next_nidstring();
+
+	if (id->pid == LNET_PID_ANY) {
+		snprintf(str, LNET_NIDSTR_SIZE,
+			 "LNET_PID_ANY-%s", libcfs_nidstr(&id->nid));
+		return str;
+	}
+
+	snprintf(str, LNET_NIDSTR_SIZE, "%s%u-%s",
+		 ((id->pid & LNET_PID_USERFLAG) != 0) ? "U" : "",
+		 (id->pid & ~LNET_PID_USERFLAG), libcfs_nidstr(&id->nid));
+	return str;
+}
+EXPORT_SYMBOL(libcfs_idstr);
+
 int
 libcfs_str2anynid(lnet_nid_t *nidp, const char *str)
 {
Signature · 6 lines
1.8.3.1

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

PATCH 10/24 lnet: enhance connect/accept to support large addr

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

This patch introduces a version-2 of the acceptor protocol. This version uses a 'struct lnet_nid' rather than 'lnet_nid_t'

lnet_connect() now accepts a struct lnet_nid and uses version 2 if necessary. lnet_accept() accepts either v1 or v2.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 9b0738c53c962f426 ("LU-10391 lnet: enhance connect/accept to support large addr")

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

---
 include/linux/lnet/lib-lnet.h       |   5 +-
 include/uapi/linux/lnet/lnet-idl.h  |  11 +++-
 net/lnet/klnds/socklnd/socklnd_cb.c |   8 +--
 net/lnet/lnet/acceptor.c            | 111 +++++++++++++++++++++++-------------
 net/lnet/lnet/api-ni.c              |   9 +++
 5 files changed, 97 insertions(+), 47 deletions(-)
include/linux/lnet/lib-lnet.h +3 -2
index 3842976..9e7d0b8 100644
@@ -489,6 +489,7 @@ unsigned int lnet_nid_cpt_hash(struct lnet_nid *nid,
 struct lnet_ni *lnet_nid2ni_addref(lnet_nid_t nid);
 struct lnet_ni *lnet_net2ni_locked(u32 net, int cpt);
 struct lnet_ni *lnet_net2ni_addref(u32 net);
+struct lnet_ni *lnet_nid_to_ni_addref(struct lnet_nid *nid);
 struct lnet_net *lnet_get_net_locked(u32 net_id);
 
 extern unsigned int lnet_response_tracking;
@@ -742,9 +743,9 @@ void lnet_copy_kiov2iter(struct iov_iter *to,
 void lnet_register_lnd(struct lnet_lnd *lnd);
 void lnet_unregister_lnd(struct lnet_lnd *lnd);
 
-struct socket *lnet_connect(lnet_nid_t peer_nid, int interface,
+struct socket *lnet_connect(struct lnet_nid *peer_nid, int interface,
 			    struct sockaddr *peeraddr, struct net *ns);
-void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
+void lnet_connect_console_error(int rc, struct lnet_nid *peer_nid,
 				struct sockaddr *sa);
 int lnet_count_acceptor_nets(void);
 int lnet_acceptor_timeout(void);
include/uapi/linux/lnet/lnet-idl.h +10 -1
index 3fc0df1..b14723e 100644
@@ -191,13 +191,22 @@ struct lnet_magicversion {
 
 /* Acceptor connection request */
 struct lnet_acceptor_connreq {
-	__u32	acr_magic;	/* PTL_ACCEPTOR_PROTO_MAGIC */
+	__u32	acr_magic;	/* LNET_PROTO_ACCEPTOR_MAGIC */
 	__u32	acr_version;	/* protocol version */
 	__u64	acr_nid;	/* target NID */
 } __attribute__((packed));
 
 #define LNET_PROTO_ACCEPTOR_VERSION	1
 
+struct lnet_acceptor_connreq_v2 {
+	__u32			acr_magic;	/* LNET_PROTO_ACCEPTOR_MAGIC */
+	__u32			acr_version;	/* protocol version - 2 */
+	struct lnet_nid		acr_nid;	/* target NID */
+} __attribute__((packed));
+
+/* For use with 16-byte addresses */
+#define LNET_PROTO_ACCEPTOR_VERSION_16  2
+
 struct lnet_counters_common {
 	__u32	lcc_msgs_alloc;
 	__u32	lcc_msgs_max;
net/lnet/klnds/socklnd/socklnd_cb.c +3 -5
index a2298275..edc584a 100644
@@ -1833,13 +1833,12 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 
 		if (ktime_get_seconds() >= deadline) {
 			rc = -ETIMEDOUT;
-			lnet_connect_console_error(rc,
-						   lnet_nid_to_nid4(&peer_ni->ksnp_id.nid),
+			lnet_connect_console_error(rc, &peer_ni->ksnp_id.nid,
 						   (struct sockaddr *)&conn_cb->ksnr_addr);
 			goto failed;
 		}
 
-		sock = lnet_connect(lnet_nid_to_nid4(&peer_ni->ksnp_id.nid),
+		sock = lnet_connect(&peer_ni->ksnp_id.nid,
 				    conn_cb->ksnr_myiface,
 				    (struct sockaddr *)&conn_cb->ksnr_addr,
 				    peer_ni->ksnp_ni->ni_net_ns);
@@ -1851,8 +1850,7 @@ void ksocknal_write_callback(struct ksock_conn *conn)
 		rc = ksocknal_create_conn(peer_ni->ksnp_ni, conn_cb, sock,
 					  type);
 		if (rc < 0) {
-			lnet_connect_console_error(rc,
-						   lnet_nid_to_nid4(&peer_ni->ksnp_id.nid),
+			lnet_connect_console_error(rc, &peer_ni->ksnp_id.nid,
 						   (struct sockaddr *)&conn_cb->ksnr_addr);
 			goto failed;
 		}
net/lnet/lnet/acceptor.c +72 -39

209 lines not on this page · raw message

net/lnet/lnet/api-ni.c +9 -0
index 1f053b3..31ccb2c 100644
@@ -810,6 +810,15 @@ static void lnet_assert_wire_constants(void)
 	BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq, acr_nid) != 8);
 	BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq *)0)->acr_nid) != 8);
 
+	/* Checks for struct lnet_acceptor_connreq_v2 */
+	BUILD_BUG_ON((int)sizeof(struct lnet_acceptor_connreq_v2) != 28);
+	BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_magic) != 0);
+	BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_magic) != 4);
+	BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_version) != 4);
+	BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_version) != 4);
+	BUILD_BUG_ON((int)offsetof(struct lnet_acceptor_connreq_v2, acr_nid) != 8);
+	BUILD_BUG_ON((int)sizeof(((struct lnet_acceptor_connreq_v2 *)0)->acr_nid) != 20);
+
 	/* Checks for struct lnet_counters_common */
 	BUILD_BUG_ON((int)sizeof(struct lnet_counters_common) != 60);
 	BUILD_BUG_ON((int)offsetof(struct lnet_counters_common, lcc_msgs_alloc) != 0);
Signature · 6 lines
1.8.3.1

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

PATCH 11/24 lnet: change lr_nid to struct lnet_nid

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The nid in 'struct lnet_route' is now a struct lnet_nid'.

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

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

---
 include/linux/lnet/lib-lnet.h  |   9 ++--
 include/linux/lnet/lib-types.h |   2 +-
 net/lnet/lnet/api-ni.c         |  19 +++++++-
 net/lnet/lnet/config.c         |  15 +++---
 net/lnet/lnet/lib-move.c       |   2 +-
 net/lnet/lnet/peer.c           | 105 ++++++++++++++++++++++++-----------------
 net/lnet/lnet/router.c         |  43 +++++++++--------
 net/lnet/lnet/router_proc.c    |   2 +-
 8 files changed, 117 insertions(+), 80 deletions(-)
include/linux/lnet/lib-lnet.h +6 -3
index 9e7d0b8..890f61a 100644
@@ -517,7 +517,7 @@ int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, bool alive, bool reset,
 		time64_t when);
 void lnet_notify_locked(struct lnet_peer_ni *lp, int notifylnd, int alive,
 			time64_t when);
-int lnet_add_route(u32 net, u32 hops, lnet_nid_t gateway_nid,
+int lnet_add_route(u32 net, u32 hops, struct lnet_nid *gateway,
 		   u32 priority, u32 sensitivity);
 int lnet_del_route(u32 net, lnet_nid_t gw_nid);
 void lnet_move_route(struct lnet_route *route, struct lnet_peer *lp,
@@ -567,7 +567,8 @@ void lnet_rtr_transfer_to_peer(struct lnet_peer *src,
 void lnet_net_clr_pref_rtrs(struct lnet_net *net);
 int lnet_net_add_pref_rtr(struct lnet_net *net, lnet_nid_t gw_nid);
 
-int lnet_islocalnid(lnet_nid_t nid);
+int lnet_islocalnid4(lnet_nid_t nid);
+int lnet_islocalnid(struct lnet_nid *nid);
 int lnet_islocalnet(u32 net);
 int lnet_islocalnet_locked(u32 net);
 
@@ -837,9 +838,11 @@ struct lnet_peer_ni *lnet_get_next_peer_ni_locked(struct lnet_peer *peer,
 						  struct lnet_peer_ni *prev);
 struct lnet_peer_ni *lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref,
 					    int cpt);
-struct lnet_peer_ni *lnet_nid2peerni_ex(lnet_nid_t nid, int cpt);
+struct lnet_peer_ni *lnet_nid2peerni_ex(struct lnet_nid *nid, int cpt);
 struct lnet_peer_ni *lnet_peer_get_ni_locked(struct lnet_peer *lp,
 					     lnet_nid_t nid);
+struct lnet_peer_ni *lnet_peer_ni_get_locked(struct lnet_peer *lp,
+					     struct lnet_nid *nid);
 struct lnet_peer_ni *lnet_find_peer_ni_locked(lnet_nid_t nid);
 struct lnet_peer_ni *lnet_peer_ni_find_locked(struct lnet_nid *nid);
 struct lnet_peer *lnet_find_peer(lnet_nid_t nid);
include/linux/lnet/lib-types.h +1 -1
index ba900e8..1e1ddd7 100644
@@ -905,7 +905,7 @@ struct lnet_route {
 	/* router node */
 	struct lnet_peer       *lr_gateway;
 	/* NID used to add route */
-	lnet_nid_t		lr_nid;
+	struct lnet_nid		lr_nid;
 	/* remote network number */
 	u32			lr_net;
 	/* local network number */
net/lnet/lnet/api-ni.c +17 -2
index 31ccb2c..0f4feda 100644
@@ -1635,7 +1635,7 @@ struct lnet_ni *
 EXPORT_SYMBOL(lnet_nid_to_ni_addref);
 
 int
-lnet_islocalnid(lnet_nid_t nid)
+lnet_islocalnid4(lnet_nid_t nid)
 {
 	struct lnet_ni *ni;
 	int cpt;
@@ -1648,6 +1648,19 @@ struct lnet_ni *
 }
 
 int
+lnet_islocalnid(struct lnet_nid *nid)
+{
+	struct lnet_ni	*ni;
+	int		cpt;
+
+	cpt = lnet_net_lock_current();
+	ni = lnet_nid_to_ni_locked(nid, cpt);
+	lnet_net_unlock(cpt);
+
+	return ni != NULL;
+}
+
+int
 lnet_count_acceptor_nets(void)
 {
 	/* Return the # of NIs that need the acceptor. */
@@ -3852,6 +3865,7 @@ u32 lnet_get_dlc_seq_locked(void)
 	struct lnet_ioctl_config_data *config;
 	struct lnet_process_id id = { 0 };
 	struct lnet_ni *ni;
+	struct lnet_nid nid;
 	int rc;
 
 	BUILD_BUG_ON(LIBCFS_IOC_DATA_MAX <
@@ -3880,10 +3894,11 @@ u32 lnet_get_dlc_seq_locked(void)
 			  config->cfg_config_u.cfg_route.rtr_sensitivity;
 		}
 
+		lnet_nid4_to_nid(config->cfg_nid, &nid);
 		mutex_lock(&the_lnet.ln_api_mutex);
 		rc = lnet_add_route(config->cfg_net,
 				    config->cfg_config_u.cfg_route.rtr_hop,
-				    config->cfg_nid,
+				    &nid,
 				    config->cfg_config_u.cfg_route.rtr_priority,
 				    sensitivity);
 		mutex_unlock(&the_lnet.ln_api_mutex);
net/lnet/lnet/config.c +7 -8
index 0c833fe..f499c91 100644
@@ -1065,7 +1065,7 @@ struct lnet_ni *
 	struct list_head *tmp1;
 	struct list_head *tmp2;
 	u32 net;
-	lnet_nid_t nid;
+	struct lnet_nid nid;
 	struct lnet_text_buf *ltb;
 	struct lnet_text_buf *ltb1, *ltb2;
 	int rc;
@@ -1145,8 +1145,8 @@ struct lnet_ni *
 				if (rc < 0)
 					goto token_error;
 
-				nid = libcfs_str2nid(ltb->ltb_text);
-				if (nid == LNET_NID_ANY || nid == LNET_NID_LO_0)
+				if (libcfs_strnid(&nid, ltb->ltb_text) != 0 ||
+				    nid_is_lo0(&nid))
 					goto token_error;
 			}
 		}
@@ -1167,19 +1167,18 @@ struct lnet_ni *
 		LASSERT(net != LNET_NET_ANY);
 
 		list_for_each_entry(ltb2, &gateways, ltb_list) {
-			nid = libcfs_str2nid(ltb2->ltb_text);
-			LASSERT(nid != LNET_NID_ANY);
+			LASSERT(libcfs_strnid(&nid, ltb->ltb_text) == 0);
 
-			if (lnet_islocalnid(nid)) {
+			if (lnet_islocalnid(&nid)) {
 				*im_a_router = 1;
 				continue;
 			}
 
-			rc = lnet_add_route(net, hops, nid, priority, 1);
+			rc = lnet_add_route(net, hops, &nid, priority, 1);
 			if (rc && rc != -EEXIST && rc != -EHOSTUNREACH) {
 				CERROR("Can't create route to %s via %s\n",
 				       libcfs_net2str(net),
-				       libcfs_nid2str(nid));
+				       libcfs_nidstr(&nid));
 				goto out;
 			}
 		}
net/lnet/lnet/lib-move.c +1 -1
index 8c8db31..2454a0c 100644
@@ -4298,7 +4298,7 @@ void lnet_monitor_thr_stop(void)
 			return -EPROTO;
 		}
 
-		if (lnet_islocalnid(dest_nid)) {
+		if (lnet_islocalnid4(dest_nid)) {
 			/*
 			 * dest is another local NI; sender should have used
 			 * this node's NID on its own network
net/lnet/lnet/peer.c +63 -42

321 lines not on this page · raw message

net/lnet/lnet/router.c +21 -22

126 lines not on this page · raw message

net/lnet/lnet/router_proc.c +1 -1
index 2e3c802..a53d6fa 100644
@@ -217,7 +217,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
 				       libcfs_net2str(net), hops,
 				       priority,
 				       alive ? "up" : "down",
-				       libcfs_nid2str(route->lr_nid));
+				       libcfs_nidstr(&route->lr_nid));
 			LASSERT(tmpstr + tmpsiz - s > 0);
 		}
 
Signature · 6 lines
1.8.3.1

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

PATCH 12/24 lnet: extend rspt_next_hop_nid in lnet_rsp_tracker

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

rspt_next_hop_nid in 'struct lnet_rsp_tracker' is now a 'struct lnet_nid'.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: a34afe7f20ec7d618 ("LU-10391 lnet: extend rspt_next_hop_nid in lnet_rsp_tracker")

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

---
 include/linux/lnet/lib-types.h |  2 +-
 net/lnet/lnet/lib-move.c       | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/lnet/lib-types.h +1 -1
index 1e1ddd7..380a7b9 100644
@@ -87,7 +87,7 @@ struct lnet_rsp_tracker {
 	/* cpt to lock */
 	int rspt_cpt;
 	/* nid of next hop */
-	lnet_nid_t rspt_next_hop_nid;
+	struct lnet_nid rspt_next_hop_nid;
 	/* deadline of the REPLY/ACK */
 	ktime_t rspt_deadline;
 	/* parent MD */
net/lnet/lnet/lib-move.c +5 -5
index 2454a0c..f2978eb 100644
@@ -1755,9 +1755,9 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 		rspt = msg->msg_md->md_rspt_ptr;
 		if (rspt) {
 			rspt->rspt_next_hop_nid =
-				lnet_nid_to_nid4(&msg->msg_txpeer->lpni_nid);
+				msg->msg_txpeer->lpni_nid;
 			CDEBUG(D_NET, "rspt_next_hop_nid = %s\n",
-			       libcfs_nid2str(rspt->rspt_next_hop_nid));
+			       libcfs_nidstr(&rspt->rspt_next_hop_nid));
 		}
 	}
 
@@ -2969,7 +2969,7 @@ struct lnet_mt_event_info {
 			if (ktime_compare(now, rspt->rspt_deadline) >= 0 ||
 			    the_lnet.ln_mt_state == LNET_MT_STATE_SHUTDOWN) {
 				struct lnet_peer_ni *lpni;
-				lnet_nid_t nid;
+				struct lnet_nid nid;
 
 				md = lnet_handle2md(&rspt->rspt_mdh);
 				if (!md) {
@@ -3028,14 +3028,14 @@ struct lnet_mt_event_info {
 
 				CDEBUG(D_NET,
 				       "Response timeout: md = %p: nid = %s\n",
-				       md, libcfs_nid2str(nid));
+				       md, libcfs_nidstr(&nid));
 
 				/* If there is a timeout on the response
 				 * from the next hop decrement its health
 				 * value so that we don't use it
 				 */
 				lnet_net_lock(0);
-				lpni = lnet_find_peer_ni_locked(nid);
+				lpni = lnet_peer_ni_find_locked(&nid);
 				if (lpni) {
 					lnet_handle_remote_failure_locked(lpni);
 					lnet_peer_ni_decref_locked(lpni);
Signature · 6 lines
1.8.3.1

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

PATCH 13/24 lustre: ptlrpc: two replay lock threads

In reply to James Simmons

From: Vitaly Fertman <[email protected]>

conflict to each other what leads to:

        ASSERTION( atomic_read(&imp->imp_replay_inflight) == 1 )

replay_lock_interpret() does ptlrpc_connect_import() on error, and one thread will appear starting with connect reply interpret.

replay_lock_interpret() also wakes up ldlm_lock_replay_thread() which does ptlrpc_import_recovery_state_machine().

It may happen that both threads will get to ldlm_replay_locks() on the next round at the same time, both increment imp_replay_inflight and the second one will assert.

The problem appeared in LU-13600 which added ldlm_lock_replay_thread() with the ptlrpc_import_recovery_state_machine() call.

HPE-bug-id: LUS-10147
WC-bug-id: https://jira.whamcloud.com/browse/LU-14847
Lustre-commit: d7d7eb50c8f5fd3fc ("LU-14847 ptlrpc: two replay lock threads")

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

Reviewed-on: https://es-gerrit.dev.cray.com/158931
Reviewed-on: https://review.whamcloud.com/44294

---
 fs/lustre/ldlm/ldlm_request.c   | 10 +++++++---
 fs/lustre/obdclass/obd_config.c |  4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)
fs/lustre/ldlm/ldlm_request.c +7 -3
index 7718e07..746c45b 100644
@@ -2253,7 +2253,8 @@ int __ldlm_replay_locks(struct obd_import *imp, bool rate_limit)
 	struct ldlm_lock *lock;
 	int rc = 0;
 
-	LASSERT(atomic_read(&imp->imp_replay_inflight) == 1);
+	while (atomic_read(&imp->imp_replay_inflight) != 1)
+		cond_resched();
 
 	/* don't replay locks if import failed recovery */
 	if (imp->imp_vbr_failed)
@@ -2311,9 +2312,12 @@ int ldlm_replay_locks(struct obd_import *imp)
 	struct task_struct *task;
 	int rc = 0;
 
-	class_import_get(imp);
 	/* ensure this doesn't fall to 0 before all have been queued */
-	atomic_inc(&imp->imp_replay_inflight);
+	if (atomic_inc_return(&imp->imp_replay_inflight) > 1) {
+		atomic_dec(&imp->imp_replay_inflight);
+		return 0;
+	}
+	class_import_get(imp);
 
 	task = kthread_run(ldlm_lock_replay_thread, imp, "ldlm_lock_replay");
 	if (IS_ERR(task)) {
fs/lustre/obdclass/obd_config.c +2 -2
index 3a0dbd5..cb70ed5 100644
@@ -519,8 +519,8 @@ struct obd_device *class_incref(struct obd_device *obd,
 {
 	lu_ref_add_atomic(&obd->obd_reference, scope, source);
 	atomic_inc(&obd->obd_refcount);
-	CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd,
-	       atomic_read(&obd->obd_refcount));
+	CDEBUG(D_INFO, "incref %s (%p) now %d - %s\n", obd->obd_name, obd,
+	       atomic_read(&obd->obd_refcount), scope);
 
 	return obd;
 }
Signature · 6 lines
1.8.3.1

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

PATCH 14/24 lustre: llite: Always do lookup on ENOENT in open

In reply to James Simmons

From: Patrick Farrell <[email protected]>

When there is no valid dentry found for a file we want to open, we perform a full lookup, which goes to the server and looks up the file by name. When we find an existing dentry in cache *but the file is not open on the node*, we do not do a full lookup. We move directly to opening the file.

When we open files, we use the FID of the file. The problem occurs when a new file is renamed *over* the file we were trying to open. This removes the FID we are trying to open, but the file *name* userspace called open() on is still present. In this case, we will return ENOENT, even though there is a file matching the name used in the open() call.

The solution is when we get an ENOENT on open (indicating our open raced with an unlink), we always send ESTALE back to the VFS, which restarts the open and forces a lookup to the server (by forcing Lustre to consider the dentry invalid, see comments in ll_intent_file_open and code in ll_revalidate_dentry).

This causes a lookup by name, which will correctly handle the rename, allowing the open to proceed normally.

This should only generate extra retries in the case where a positive dentry exists on the client but the file has been removed on the server, ie, open racing with unlink.

This should hopefully be rare.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14949
lustre-commit: 72c1f7095203cc1ba ("LU-14949 llite: Always do lookup on ENOENT in open")

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

---
 fs/lustre/include/obd_support.h |  1 +
 fs/lustre/llite/file.c          | 23 +++++++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)
fs/lustre/include/obd_support.h +1 -0
index 1e8cebf..540e1e0 100644
@@ -483,6 +483,7 @@
 #define OBD_FAIL_LLITE_CREATE_FILE_PAUSE2		0x1416
 #define OBD_FAIL_LLITE_RACE_MOUNT			0x1417
 #define OBD_FAIL_LLITE_PAGE_ALLOC			0x1418
+#define OBD_FAIL_LLITE_OPEN_DELAY			0x1419
 
 #define OBD_FAIL_FID_INDIR				0x1501
 #define OBD_FAIL_FID_INLMA				0x1502
fs/lustre/llite/file.c +15 -8
index aa5c662..10450ce 100644
@@ -639,6 +639,8 @@ static int ll_intent_file_open(struct dentry *de, void *lmm, int lmmsize,
 	op_data->op_data = lmm;
 	op_data->op_data_size = lmmsize;
 
+	OBD_FAIL_TIMEOUT(OBD_FAIL_LLITE_OPEN_DELAY, cfs_fail_val);
+
 	rc = md_intent_lock(sbi->ll_md_exp, op_data, itp, &req,
 			    &ll_md_blocking_ast, 0);
 	kfree(name);
@@ -692,15 +694,20 @@ static int ll_intent_file_open(struct dentry *de, void *lmm, int lmmsize,
 	ptlrpc_req_finished(req);
 	ll_intent_drop_lock(itp);
 
-	/*
-	 * We did open by fid, but by the time we got to the server,
-	 * the object disappeared. If this is a create, we cannot really
-	 * tell the userspace that the file it was trying to create
-	 * does not exist. Instead let's return -ESTALE, and the VFS will
-	 * retry the create with LOOKUP_REVAL that we are going to catch
-	 * in ll_revalidate_dentry() and use lookup then.
+	/* We did open by fid, but by the time we got to the server, the object
+	 * disappeared.  This is possible if the object was unlinked, but it's
+	 * also possible if the object was unlinked by a rename.  In the case
+	 * of an object renamed over our existing one, we can't fail this open.
+	 * O_CREAT also goes through this path if we had an existing dentry,
+	 * and it's obviously wrong to return ENOENT for O_CREAT.
+	 *
+	 * Instead let's return -ESTALE, and the VFS will retry the open with
+	 * LOOKUP_REVAL, which we catch in ll_revalidate_dentry and fail to
+	 * revalidate, causing a lookup.  This causes extra lookups in the case
+	 * where we had a dentry in cache but the file is being unlinked and we
+	 * lose the race with unlink, but this should be very rare.
 	 */
-	if (rc == -ENOENT && itp->it_op & IT_CREAT)
+	if (rc == -ENOENT)
 		rc = -ESTALE;
 
 	return rc;
Signature · 6 lines
1.8.3.1

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

PATCH 15/24 lustre: llite: Remove inode locking in ll_fsync

In reply to James Simmons

From: Oleg Drokin <[email protected]>

It does not appear to be necessary

WC-bug-id: https://jira.whamcloud.com/browse/LU-14877
Lustre-commit: e8d76d1090e912ee5 ("LU-14877 llite: Remove inode locking in ll_fsync")

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

---
 fs/lustre/llite/file.c | 3 ---
 1 file changed, 3 deletions(-)
fs/lustre/llite/file.c +0 -3
index 10450ce..e60789b 100644
@@ -4460,7 +4460,6 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 
 
 	rc = file_write_and_wait_range(file, start, end);
-	inode_lock(inode);
 
 	/* catch async errors that were recorded back when async writeback
 	 * failed for pages in this mapping.
@@ -4503,8 +4502,6 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 			fd->fd_write_failed = false;
 	}
 
-	inode_unlock(inode);
-
 	if (!rc)
 		ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FSYNC,
 				   ktime_us_delta(ktime_get(), kstart));
Signature · 6 lines
1.8.3.1

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

PATCH 16/24 lnet: socklnd: fix link state detection

In reply to James Simmons

From: Serguei Smirnov <[email protected]>

Due to matching only the device index, link detection implemented in LU-14742 has issues with confusing the link events for the virtual interfaces with the link events for the interface that LNet was actually configured to use. Fix this by improving the identification of the event source: use both device name and device index.

Also, to make sure the link fatal state is cleared only when the device is bound to the IP address used at NI creation, subscribe to inetaddr events in addition to the netdev events.

Fixes 1db29e184712 ("lnet: socklnd: detect link state to set fatal error on ni")

WC-bug-id: https://jira.whamcloud.com/browse/LU-14954
Lustre-commit: 008795508d65bb40b ("LU-14954 socklnd: fix link state detection")

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

---
 net/lnet/klnds/socklnd/socklnd.c | 132 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 122 insertions(+), 10 deletions(-)
net/lnet/klnds/socklnd/socklnd.c +122 -10
index 7397ac7..b014aa8 100644
@@ -1896,11 +1896,15 @@ static int ksocknal_get_link_status(struct net_device *dev)
 
 	LASSERT(dev);
 
-	if (!netif_running(dev))
+	if (!netif_running(dev)) {
 		ret = 0;
+		CDEBUG(D_NET, "device not running\n");
+	}
 	/* Some devices may not be providing link settings */
-	else if (dev->ethtool_ops->get_link)
+	else if (dev->ethtool_ops->get_link) {
 		ret = dev->ethtool_ops->get_link(dev);
+		CDEBUG(D_NET, "get_link returns %u\n", ret);
+	}
 
 	return ret;
 }
@@ -1909,11 +1913,16 @@ static int ksocknal_get_link_status(struct net_device *dev)
 ksocknal_handle_link_state_change(struct net_device *dev,
 				  unsigned char operstate)
 {
-	struct lnet_ni *ni;
+	struct lnet_ni *ni = NULL;
 	struct ksock_net *net;
 	struct ksock_net *cnxt;
 	int ifindex;
 	unsigned char link_down = !(operstate == IF_OPER_UP);
+	struct in_device *in_dev;
+	bool found_ip = false;
+	struct ksock_interface *ksi = NULL;
+	struct sockaddr_in *sa;
+	const struct in_ifaddr *ifa;
 
 	ifindex = dev->ifindex;
 
@@ -1922,20 +1931,91 @@ static int ksocknal_get_link_status(struct net_device *dev)
 
 	list_for_each_entry_safe(net, cnxt, &ksocknal_data.ksnd_nets,
 				 ksnn_list) {
-		if (net->ksnn_interface.ksni_index != ifindex)
+
+		ksi = &net->ksnn_interface;
+		sa = (void *)&ksi->ksni_addr;
+		found_ip = false;
+
+		if (ksi->ksni_index != ifindex ||
+		    strcmp(ksi->ksni_name, dev->name))
 			continue;
+
 		ni = net->ksnn_ni;
-		if (link_down)
+
+		in_dev = __in_dev_get_rtnl(dev);
+		if (!in_dev) {
+			CDEBUG(D_NET, "Interface %s has no IPv4 status.\n",
+			       dev->name);
+			CDEBUG(D_NET, "set link fatal state to 1\n");
+			atomic_set(&ni->ni_fatal_error_on, 1);
+			continue;
+		}
+		in_dev_for_each_ifa_rtnl(ifa, in_dev) {
+			if (sa->sin_addr.s_addr == ifa->ifa_local)
+				found_ip = true;
+		}
+
+		if (!found_ip) {
+			CDEBUG(D_NET, "Interface %s has no matching ip\n",
+			       dev->name);
+			CDEBUG(D_NET, "set link fatal state to 1\n");
+			atomic_set(&ni->ni_fatal_error_on, 1);
+			continue;
+		}
+
+		if (link_down) {
+			CDEBUG(D_NET, "set link fatal state to 1\n");
 			atomic_set(&ni->ni_fatal_error_on, link_down);
-		else
+		} else {
+			CDEBUG(D_NET, "set link fatal state to %u\n",
+			       (ksocknal_get_link_status(dev) == 0));
 			atomic_set(&ni->ni_fatal_error_on,
 				   (ksocknal_get_link_status(dev) == 0));
+		}
 	}
 out:
 	return 0;
 }
 
 
+static int
+ksocknal_handle_inetaddr_change(struct in_ifaddr *ifa, unsigned long event)
+{
+	struct lnet_ni *ni;
+	struct ksock_net *net;
+	struct ksock_net *cnxt;
+	struct net_device *event_netdev = ifa->ifa_dev->dev;
+	int ifindex;
+	struct ksock_interface *ksi = NULL;
+	struct sockaddr_in *sa;
+
+	if (!ksocknal_data.ksnd_nnets)
+		goto out;
+
+	ifindex = event_netdev->ifindex;
+
+	list_for_each_entry_safe(net, cnxt, &ksocknal_data.ksnd_nets,
+				 ksnn_list) {
+
+		ksi = &net->ksnn_interface;
+		sa = (void *)&ksi->ksni_addr;
+
+		if (ksi->ksni_index != ifindex ||
+		    strcmp(ksi->ksni_name, event_netdev->name))
+			continue;
+
+		if (sa->sin_addr.s_addr == ifa->ifa_local) {
+			CDEBUG(D_NET, "set link fatal state to %u\n",
+			       (event == NETDEV_DOWN));
+			ni = net->ksnn_ni;
+			atomic_set(&ni->ni_fatal_error_on,
+				   (event == NETDEV_DOWN));
+		}
+	}
+out:
+	return 0;
+}
+
 /************************************
  * Net device notifier event handler
  ************************************/
@@ -1947,6 +2027,9 @@ static int ksocknal_device_event(struct notifier_block *unused,
 
 	operstate = dev->operstate;
 
+	CDEBUG(D_NET, "devevent: status=%ld, iface=%s ifindex %d state %u\n",
+	       event, dev->name, dev->ifindex, operstate);
+
 	switch (event) {
 	case NETDEV_UP:
 	case NETDEV_DOWN:
@@ -1958,10 +2041,36 @@ static int ksocknal_device_event(struct notifier_block *unused,
 	return NOTIFY_OK;
 }
 
-static struct notifier_block ksocknal_notifier_block = {
+/************************************
+ * Inetaddr notifier event handler
+ ************************************/
+static int ksocknal_inetaddr_event(struct notifier_block *unused,
+				   unsigned long event, void *ptr)
+{
+	struct in_ifaddr *ifa = ptr;
+
+	CDEBUG(D_NET, "addrevent: status %ld ip addr %pI4, netmask %pI4.\n",
+	       event, &ifa->ifa_address, &ifa->ifa_mask);
+
+	switch (event) {
+	case NETDEV_UP:
+	case NETDEV_DOWN:
+	case NETDEV_CHANGE:
+		ksocknal_handle_inetaddr_change(ifa, event);
+		break;
+
+	}
+	return NOTIFY_OK;
+}
+
+static struct notifier_block ksocknal_dev_notifier_block = {
 	.notifier_call = ksocknal_device_event,
 };
 
+static struct notifier_block ksocknal_inetaddr_notifier_block = {
+	.notifier_call = ksocknal_inetaddr_event,
+};
+
 static void
 ksocknal_base_shutdown(void)
 {
@@ -1971,8 +2080,10 @@ static int ksocknal_device_event(struct notifier_block *unused,
 
 	LASSERT(!ksocknal_data.ksnd_nnets);
 
-	if (ksocknal_data.ksnd_init == SOCKNAL_INIT_ALL)
-		unregister_netdevice_notifier(&ksocknal_notifier_block);
+	if (ksocknal_data.ksnd_init == SOCKNAL_INIT_ALL) {
+		unregister_netdevice_notifier(&ksocknal_dev_notifier_block);
+		unregister_inetaddr_notifier(&ksocknal_inetaddr_notifier_block);
+	}
 
 	switch (ksocknal_data.ksnd_init) {
 	default:
@@ -2135,7 +2246,8 @@ static int ksocknal_device_event(struct notifier_block *unused,
 		goto failed;
 	}
 
-	register_netdevice_notifier(&ksocknal_notifier_block);
+	register_netdevice_notifier(&ksocknal_dev_notifier_block);
+	register_inetaddr_notifier(&ksocknal_inetaddr_notifier_block);
 
 	/* flag everything initialised */
 	ksocknal_data.ksnd_init = SOCKNAL_INIT_ALL;
Signature · 6 lines
1.8.3.1

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

PATCH 17/24 lustre: llite: check read only mount for setquota

In reply to James Simmons

From: Hongchao Zhang <[email protected]>

During setting quota, it should fail if the mount is read-only.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14696
Lustre-commit: 29e00cecc6019fbdb ("LU-14696 llite: check read only mount for setquota")

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

---
 fs/lustre/llite/dir.c            | 8 ++++++--
 fs/lustre/llite/llite_internal.h | 2 +-
 fs/lustre/llite/llite_lib.c      | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)
fs/lustre/llite/dir.c +6 -2
index 57f7c3c..9a4ccfc 100644
@@ -1080,8 +1080,9 @@ static int check_owner(int type, int id)
 	return 0;
 }
 
-int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
+int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl)
 {
+	struct ll_sb_info *sbi = ll_s2sbi(sb);
 	int cmd = qctl->qc_cmd;
 	int type = qctl->qc_type;
 	int id = qctl->qc_id;
@@ -1097,6 +1098,9 @@ int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
 	case LUSTRE_Q_SETDEFAULT_POOL:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
+
+		if (sb->s_flags & SB_RDONLY)
+			return -EROFS;
 		break;
 	case Q_GETQUOTA:
 	case LUSTRE_Q_GETDEFAULT:
@@ -1873,7 +1877,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			}
 		}
 
-		rc = quotactl_ioctl(sbi, qctl);
+		rc = quotactl_ioctl(inode->i_sb, qctl);
 		if (rc == 0 && copy_to_user((void __user *)arg, qctl,
 					    sizeof(*qctl)))
 			rc = -EFAULT;
fs/lustre/llite/llite_internal.h +1 -1
index 6b5e318..ed6ff07 100644
@@ -1080,7 +1080,7 @@ int ll_dir_read(struct inode *inode, u64 *ppos, struct md_op_data *op_data,
 struct page *ll_get_dir_page(struct inode *dir, struct md_op_data *op_data,
 			     u64 offset);
 void ll_release_page(struct inode *inode, struct page *page, bool remove);
-int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl);
+int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl);
 
 enum get_default_layout_type {
 	GET_DEFAULT_LAYOUT_ROOT = 1,
fs/lustre/llite/llite_lib.c +1 -1
index cc50503..58e60c8 100644
@@ -2263,7 +2263,7 @@ static int ll_statfs_project(struct inode *inode, struct kstatfs *sfs)
 	int ret;
 
 	qctl.qc_id = ll_i2info(inode)->lli_projid;
-	ret = quotactl_ioctl(ll_i2sbi(inode), &qctl);
+	ret = quotactl_ioctl(inode->i_sb, &qctl);
 	if (ret) {
 		/* ignore errors if project ID does not have
 		 * a quota limit or feature unsupported.
Signature · 6 lines
1.8.3.1

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

PATCH 18/24 lustre: llite: don't touch vma after filemap_fault

In reply to James Simmons

From: Alexander Boyko <[email protected]>

In case of error filemap_fault unlock mutex vma->vm_mm->mmap_sem, so touching vma is dangerous, it could be reused or freed. The patch uses local file variable to skip vma.

HPE-bug-id: LUS-10240
WC-bug-id: https://jira.whamcloud.com/browse/LU-14021
Lustre-commit: 0f5d3c4b954da2f6b ("LU-14021 llite: don't touch vma after filemap_fault")

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

---
 fs/lustre/llite/llite_mmap.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
fs/lustre/llite/llite_mmap.c +8 -4
index ebcb8d9..85a082c 100644
@@ -38,9 +38,9 @@
 #include <linux/unistd.h>
 #include <linux/uaccess.h>
 #include <linux/delay.h>
-
 #include <linux/fs.h>
 #include <linux/pagemap.h>
+#include <linux/file.h>
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
@@ -317,6 +317,8 @@ static vm_fault_t __ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 
 	result = io->ci_result;
 	if (result == 0) {
+		struct file *vm_file = vma->vm_file;
+
 		vio = vvp_env_io(env);
 		vio->u.fault.ft_vma = vma;
 		vio->u.fault.ft_vmpage = NULL;
@@ -324,13 +326,15 @@ static vm_fault_t __ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 		vio->u.fault.ft_flags = 0;
 		vio->u.fault.ft_flags_valid = false;
 
+		get_file(vm_file);
+
 		/* May call ll_readpage() */
-		ll_cl_add(vma->vm_file, env, io, LCC_MMAP);
+		ll_cl_add(vm_file, env, io, LCC_MMAP);
 
 		result = cl_io_loop(env, io);
 
-		ll_cl_remove(vma->vm_file, env);
-
+		ll_cl_remove(vm_file, env);
+		fput(vm_file);
 		/* ft_flags are only valid if we reached
 		 * the call to filemap_fault
 		 */
Signature · 6 lines
1.8.3.1

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

PATCH 19/24 lnet: Check for -ESHUTDOWN in lnet_parse

In reply to James Simmons

From: Chris Horn <[email protected]>

The fix for LU-8106, http://review.whamcloud.com/19993, no longer works because rc does not have the return value from lnet_nid2peerni_locked(). Use PTR_ERR to get the return value and restore the LU-8106 fix.

HPE-bug-id: LUS-10333

Fixes 6e872a4ffd ("lustre: lnet: peer/peer_ni handling adjustments")

WC-bug-id: https://jira.whamcloud.com/browse/LU-14962
Lustre-commit: cce82630cbf2c7bad ("LU-14962 lnet: Check for -ESHUTDOWN in lnet_parse")

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

---
 net/lnet/lnet/lib-move.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/lnet/lnet/lib-move.c +3 -2
index f2978eb..b9b322a 100644
@@ -4389,9 +4389,10 @@ void lnet_monitor_thr_stop(void)
 				      cpt);
 	if (IS_ERR(lpni)) {
 		lnet_net_unlock(cpt);
-		CERROR("%s, src %s: Dropping %s (error %ld looking up sender)\n",
+		rc = PTR_ERR(lpni);
+		CERROR("%s, src %s: Dropping %s (error %d looking up sender)\n",
 		       libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
-		       lnet_msgtyp2str(type), PTR_ERR(lpni));
+		       lnet_msgtyp2str(type), rc);
 		kfree(msg);
 		if (rc == -ESHUTDOWN)
 			/* We are shutting down. Don't do anything more */
Signature · 6 lines
1.8.3.1

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

PATCH 20/24 lustre: obdclass: EAGAIN after rhashtable_walk_next()

In reply to James Simmons

From: Alex Zhuravlev <[email protected]>

rhashtable_walk_next() can return -EAGAIN when concurrent resizing has happened. so the callers should check for this error and just repeat rhashtable_walk_next().

WC-bug-id: https://jira.whamcloud.com/browse/LU-14967
Lustre-commit: 96aa615f91cd25b04 ("LU-14967 obdclass: EAGAIN after rhashtable_walk_next()")

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

---
 fs/lustre/llite/vvp_dev.c  | 6 ++++++
 fs/lustre/obdclass/jobid.c | 5 +++++
 2 files changed, 11 insertions(+)
fs/lustre/llite/vvp_dev.c +6 -0
index fdcd314..fda48bb 100644
@@ -385,6 +385,12 @@ static struct page *vvp_pgcache_current(struct vvp_seq_private *priv)
 		struct inode *inode;
 		int nr;
 
+		if (IS_ERR(h)) {
+			if (PTR_ERR(h) == -EAGAIN)
+				continue;
+			break;
+		}
+
 		if (!priv->vsp_clob) {
 			struct lu_object *lu_obj;
 
fs/lustre/obdclass/jobid.c +5 -0
index 52ba398..da1af51 100644
@@ -164,6 +164,11 @@ static void jobid_prune(struct work_struct *work)
 	rhashtable_walk_enter(&session_jobids, &iter);
 	rhashtable_walk_start(&iter);
 	while ((sj = rhashtable_walk_next(&iter)) != NULL) {
+		if (IS_ERR(sj)) {
+			if (PTR_ERR(sj) == -EAGAIN)
+				continue;
+			break;
+		}
 		if (!hlist_empty(&sj->sj_session->tasks[PIDTYPE_SID])) {
 			remaining++;
 			continue;
Signature · 6 lines
1.8.3.1

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

PATCH 21/24 lustre: sec: filename encryption

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

On client side, call the appropriate fscrypt primitives for llite, to proceed with filename encryption before sending requests to servers and filename decryption upon request receipt.
Note we need specific overlay functions to handle encoding and decoding of encrypted filenames, as we do not want server side to deal with binary names before they reach the backend file system layer.

On server side, mainly the OSD layer, we need to know the encryption status of files being processed.
If an object belongs to an encrypted file, the filename has been encoded by the client because it is binary, so it needs to be decoded before being handed over to the backend file system layer. And conversely, the filename of an encrypted file has to be encoded before being sent over the wire.
Note server side is osd-ldiskfs only for now.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13717
Lustre-commit: 4d38566a004f6a636 ("LU-13717 sec: filename encryption")

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

---
 fs/lustre/include/obd.h          |   4 ++
 fs/lustre/llite/crypto.c         | 144 +++++++++++++++++++++++++++++++++++++++
 fs/lustre/llite/dcache.c         |   8 +++
 fs/lustre/llite/dir.c            |  39 ++++++++++-
 fs/lustre/llite/file.c           |  11 +--
 fs/lustre/llite/llite_internal.h |  27 ++++++++
 fs/lustre/llite/llite_lib.c      |  51 +++++++++++++-
 fs/lustre/llite/namei.c          |  47 ++++++++++---
 fs/lustre/llite/statahead.c      |  48 +++++++++++++
 fs/lustre/mdc/mdc_lib.c          |   6 +-
 fs/lustre/ptlrpc/layout.c        |   2 +-
 11 files changed, 366 insertions(+), 21 deletions(-)
fs/lustre/include/obd.h +4 -0
index 7c5e699..7642973 100644
@@ -708,6 +708,7 @@ enum md_op_flags {
 	MF_GETATTR_BY_FID	= BIT(5),
 	MF_QOS_MKDIR		= BIT(6),
 	MF_RR_MKDIR		= BIT(7),
+	MF_OPNAME_KMALLOCED	= BIT(8),
 };
 
 enum md_cli_flags {
@@ -725,6 +726,9 @@ enum md_op_code {
 	LUSTRE_OPC_MKNOD,
 	LUSTRE_OPC_CREATE,
 	LUSTRE_OPC_ANY,
+	LUSTRE_OPC_LOOKUP,
+	LUSTRE_OPC_OPEN,
+	LUSTRE_OPC_MIGR,
 };
 
 /**
fs/lustre/llite/crypto.c +144 -0

150 lines not on this page · raw message

fs/lustre/llite/dcache.c +8 -0
index 4162f46..a074a2c 100644
@@ -235,6 +235,14 @@ static int ll_revalidate_dentry(struct dentry *dentry,
 				unsigned int lookup_flags)
 {
 	struct inode *dir = d_inode(dentry->d_parent);
+	int rc;
+
+	CDEBUG(D_VFSTRACE, "VFS Op:name=%s, flags=%u\n",
+	       dentry->d_name.name, lookup_flags);
+
+	rc = ll_revalidate_d_crypto(dentry, lookup_flags);
+	if (rc != 1)
+		return rc;
 
 	/* If this is intermediate component path lookup and we were able to get
 	 * to this dentry, then its lock has not been revoked and the
fs/lustre/llite/dir.c +36 -3
index 9a4ccfc..f7216db 100644
@@ -42,6 +42,7 @@
 #include <linux/pagevec.h>
 #include <linux/prefetch.h>
 #include <linux/security.h>
+#include <linux/fscrypt.h>
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
@@ -181,11 +182,18 @@ int ll_dir_read(struct inode *inode, u64 *ppos, struct md_op_data *op_data,
 	struct ll_sb_info *sbi = ll_i2sbi(inode);
 	u64 pos = *ppos;
 	bool is_api32 = ll_need_32bit_api(sbi);
-	int is_hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH;
+	bool is_hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH;
+	struct fscrypt_str lltr = FSTR_INIT(NULL, 0);
 	struct page *page;
 	bool done = false;
 	int rc = 0;
 
+	if (IS_ENCRYPTED(inode)) {
+		rc = fscrypt_fname_alloc_buffer(inode, NAME_MAX, &lltr);
+		if (rc < 0)
+			return rc;
+	}
+
 	page = ll_get_dir_page(inode, op_data, pos);
 
 	while (rc == 0 && !done) {
@@ -232,8 +240,26 @@ int ll_dir_read(struct inode *inode, u64 *ppos, struct md_op_data *op_data,
 			 * so the parameter 'name' for 'ctx->actor()'
 			 * must be part of the 'ent'.
 			 */
-			done = !dir_emit(ctx, ent->lde_name,
-					 namelen, ino, type);
+			if (!IS_ENCRYPTED(inode)) {
+				done = !dir_emit(ctx, ent->lde_name, namelen,
+						 ino, type);
+			} else {
+				/* Directory is encrypted */
+				int save_len = lltr.len;
+				struct fscrypt_str de_name
+					= FSTR_INIT(ent->lde_name, namelen);
+
+				rc = ll_fname_disk_to_usr(inode, 0, 0, &de_name,
+							  &lltr);
+				de_name = lltr;
+				lltr.len = save_len;
+				if (rc) {
+					done = 1;
+					break;
+				}
+				done = !dir_emit(ctx, de_name.name, de_name.len,
+						 ino, type);
+			}
 		}
 
 		if (done) {
@@ -264,6 +290,7 @@ int ll_dir_read(struct inode *inode, u64 *ppos, struct md_op_data *op_data,
 	}
 
 	ctx->pos = pos;
+	fscrypt_fname_free_buffer(&lltr);
 	return rc;
 }
 
@@ -285,6 +312,12 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx)
 	       PFID(ll_inode2fid(inode)), inode, (unsigned long)pos,
 	       i_size_read(inode), api32);
 
+	if (IS_ENCRYPTED(inode)) {
+		rc = fscrypt_get_encryption_info(inode);
+		if (rc && rc != -ENOKEY)
+			goto out;
+	}
+
 	if (pos == MDS_DIR_END_OFF) {
 		/*
 		 * end-of-file.
fs/lustre/llite/file.c +6 -5
index e60789b..ab7c72a 100644
@@ -631,7 +631,7 @@ static int ll_intent_file_open(struct dentry *de, void *lmm, int lmmsize,
 	}
 
 	op_data  = ll_prep_md_op_data(NULL, d_inode(parent), inode, name, len,
-				      O_RDWR, LUSTRE_OPC_ANY, NULL);
+				      O_RDWR, LUSTRE_OPC_OPEN, NULL);
 	if (IS_ERR(op_data)) {
 		kfree(name);
 		return PTR_ERR(op_data);
@@ -2164,7 +2164,7 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
 			     struct ptlrpc_request **request)
 {
 	struct ll_sb_info *sbi = ll_i2sbi(inode);
-	struct mdt_body *body;
+	struct mdt_body  *body;
 	struct lov_mds_md *lmm = NULL;
 	struct ptlrpc_request *req = NULL;
 	struct md_op_data *op_data;
@@ -4744,7 +4744,7 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
 	}
 
 	op_data = ll_prep_md_op_data(NULL, parent, NULL, name, namelen,
-				     child_inode->i_mode, LUSTRE_OPC_ANY, NULL);
+				     child_inode->i_mode, LUSTRE_OPC_MIGR, NULL);
 	if (IS_ERR(op_data)) {
 		rc = PTR_ERR(op_data);
 		goto out_iput;
@@ -4788,8 +4788,9 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
 		spin_unlock(&och->och_mod->mod_open_req->rq_lock);
 	}
 
-	rc = md_rename(ll_i2sbi(parent)->ll_md_exp, op_data, name, namelen,
-		       name, namelen, &request);
+	rc = md_rename(ll_i2sbi(parent)->ll_md_exp, op_data,
+		       op_data->op_name, op_data->op_namelen,
+		       op_data->op_name, op_data->op_namelen, &request);
 	if (!rc) {
 		LASSERT(request);
 		ll_update_times(request, parent);
fs/lustre/llite/llite_internal.h +27 -0
index ed6ff07..25bd460 100644
@@ -1731,6 +1731,33 @@ static inline struct pcc_super *ll_info2pccs(struct ll_inode_info *lli)
 }
 
 /* crypto.c */
+#ifdef CONFIG_FS_ENCRYPTION
+int ll_setup_filename(struct inode *dir, const struct qstr *iname,
+		      int lookup, struct fscrypt_name *fname);
+int ll_fname_disk_to_usr(struct inode *inode,
+			 u32 hash, u32 minor_hash,
+			 struct fscrypt_str *iname, struct fscrypt_str *oname);
+int ll_revalidate_d_crypto(struct dentry *dentry, unsigned int flags);
+#else
+int ll_setup_filename(struct inode *dir, const struct qstr *iname,
+		      int lookup, struct fscrypt_name *fname)
+{
+	return fscrypt_setup_filename(dir, iname, lookup, fname);
+}
+
+int ll_fname_disk_to_usr(struct inode *inode,
+			 u32 hash, u32 minor_hash,
+			 struct fscrypt_str *iname, struct fscrypt_str *oname)
+{
+	return fscrypt_fname_disk_to_usr(inode, hash, minor_hash, iname, oname);
+}
+
+int ll_revalidate_d_crypto(struct dentry *dentry, unsigned int flags)
+{
+	return 1;
+}
+#endif
+
 extern const struct fscrypt_operations lustre_cryptops;
 
 /* llite/llite_foreign.c */
fs/lustre/llite/llite_lib.c +48 -3

75 lines not on this page · raw message

fs/lustre/llite/namei.c +39 -8

80 lines not on this page · raw message

fs/lustre/llite/statahead.c +48 -0

97 lines not on this page · raw message

fs/lustre/mdc/mdc_lib.c +5 -1
index ccaa0f2..d07ef81 100644
@@ -101,8 +101,12 @@ static void mdc_pack_name(struct req_capsule *pill,
 	buf = req_capsule_client_get(pill, field);
 	buf_size = req_capsule_get_size(pill, field, RCL_CLIENT);
 
-	LASSERT(name && name_len && buf && buf_size == name_len + 1);
+	LASSERT(buf && buf_size == name_len + 1);
 
+	if (!name) {
+		buf[name_len] = '\0';
+		return;
+	}
 	cpy_len = strlcpy(buf, name, buf_size);
 
 	LASSERT(lu_name_is_valid_2(buf, cpy_len));
fs/lustre/ptlrpc/layout.c +1 -1
index 836b2a2..2874a41 100644
@@ -969,7 +969,7 @@ struct req_msg_field RMF_FID_ARRAY =
 EXPORT_SYMBOL(RMF_FID_ARRAY);
 
 struct req_msg_field RMF_SYMTGT =
-	DEFINE_MSGF("symtgt", RMF_F_STRING, -1, NULL, NULL);
+	DEFINE_MSGF("symtgt", 0, -1, NULL, NULL);
 EXPORT_SYMBOL(RMF_SYMTGT);
 
 struct req_msg_field RMF_TGTUUID =
Signature · 6 lines
1.8.3.1

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

PATCH 22/24 lustre: uapi: fixup UAPI headers for native Linux client.

In reply to James Simmons

This covers all the UAPI problems outside of the user land wiretest utility. One set of problems is build and the second is that UAPI header definitions are either user land only or never used to valid data going to or from user land.

1) Use UAPI header definitions to validate data send to or from kernel space. We check lum_hash_type using LMV_HASH_TYPE_MASK. This avoids a round trip to the server which will report back an error. The other case is we check the values returned for LL_IOC_HSM_ACTION. We keep the original behavior of passing unknown data to the user land application but add debug logging if the data looks corrupt to help track down bug issues.

2) We can use QIF_DQBLKSIZE* instead of Lustre specific values for our quota handling. QIF_DQBLKSIZE* is a Linux UAPI quota value.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13903
Lustre-commit: d963e66f609c3bf47 ("LU-13903 uapi: fixup UAPI headers for native Linux client.")

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

---
 fs/lustre/llite/dir.c                   |  5 +++++
 fs/lustre/llite/file.c                  | 19 ++++++++++++++++++-
 fs/lustre/ptlrpc/wiretest.c             |  5 +++++
 include/uapi/linux/lustre/lustre_user.h | 20 ++++++++++++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)
fs/lustre/llite/dir.c +5 -0
index f7216db..b7dd2aa 100644
@@ -423,6 +423,7 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
 		},
 	};
 	bool encrypt = false;
+	int hash_flags;
 	int err;
 
 	if (unlikely(!lmv_user_magic_supported(lump->lum_magic)))
@@ -463,6 +464,10 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
 					      LMV_HASH_TYPE_FNV_1A_64;
 	}
 
+	hash_flags = lump->lum_hash_type & ~LMV_HASH_TYPE_MASK;
+	if (hash_flags & ~LMV_HASH_FLAG_KNOWN)
+		return -EINVAL;
+
 	if (unlikely(!lmv_user_magic_supported(cpu_to_le32(lump->lum_magic))))
 		lustre_swab_lmv_user_md(lump);
 
fs/lustre/llite/file.c +18 -1
index ab7c72a..f340d67 100644
@@ -3973,6 +3973,7 @@ static int ll_heat_set(struct inode *inode, enum lu_heat_flag flags)
 	case LL_IOC_HSM_ACTION: {
 		struct md_op_data *op_data;
 		struct hsm_current_action *hca;
+		const char *action;
 		int rc;
 
 		hca = kzalloc(sizeof(*hca), GFP_KERNEL);
@@ -3988,10 +3989,26 @@ static int ll_heat_set(struct inode *inode, enum lu_heat_flag flags)
 
 		rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data),
 				   op_data, NULL);
+		if (rc < 0)
+			goto skip_copy;
+
+		/* The hsm_current_action retreived from the server could
+		 * contain corrupt information. If it is incorrect data collect
+		 * debug information. We still send the data even if incorrect
+		 * to user land to handle.
+		 */
+		action = hsm_user_action2name(hca->hca_action);
+		if (strcmp(action, "UNKNOWN") == 0 ||
+		    hca->hca_state > HPS_DONE) {
+			CDEBUG(D_HSM,
+			       "HSM current state %s action %s, offset = %llu, length %llu\n",
+			       hsm_progress_state2name(hca->hca_state), action,
+			       hca->hca_location.offset, hca->hca_location.length);
+		}
 
 		if (copy_to_user((char __user *)arg, hca, sizeof(*hca)))
 			rc = -EFAULT;
-
+skip_copy:
 		ll_finish_md_op_data(op_data);
 		kfree(hca);
 		return rc;
fs/lustre/ptlrpc/wiretest.c +5 -0
index b063cb9..1e89974 100644
@@ -1908,6 +1908,11 @@ void lustre_assert_wire_constants(void)
 	LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n",
 		 (long long)(int)sizeof(union lquota_id));
 
+	LASSERTF(QIF_DQBLKSIZE_BITS == 10, "found %lld\n",
+		 (long long)QIF_DQBLKSIZE_BITS);
+	LASSERTF(QIF_DQBLKSIZE == 1024, "found %lld\n",
+		 (long long)QIF_DQBLKSIZE);
+
 	/* Checks for struct obd_quotactl */
 	LASSERTF((int)sizeof(struct obd_quotactl) == 112, "found %lld\n",
 		 (long long)(int)sizeof(struct obd_quotactl));
include/uapi/linux/lustre/lustre_user.h +20 -0
index 1940e52..5c4dadf 100644
@@ -1877,6 +1877,26 @@ enum hsm_states {
  */
 #define HSM_FLAGS_MASK  (HSM_USER_MASK | HSM_STATUS_MASK)
 
+/**
+ * HSM request progress state
+ */
+enum hsm_progress_states {
+	HPS_NONE	= 0,
+	HPS_WAITING	= 1,
+	HPS_RUNNING	= 2,
+	HPS_DONE	= 3,
+};
+
+static inline const char *hsm_progress_state2name(enum hsm_progress_states s)
+{
+	switch  (s) {
+	case HPS_WAITING:	return "waiting";
+	case HPS_RUNNING:	return "running";
+	case HPS_DONE:		return "done";
+	default:		return "unknown";
+	}
+}
+
 struct hsm_extent {
 	__u64 offset;
 	__u64 length;
Signature · 6 lines
1.8.3.1

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

PATCH 23/24 lustre: ptlrpc: separate out server code for wiretest

In reply to James Simmons

Both the kernel and userland utility wiretest is used by both client and server to validate data being sent over the network. Make userland wiretest buildable on the native Linux client which lacks server specific data structures. Use of the UAPI values to hardern testing of user land data passed to the kernel.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13903
Lustre-commit: 9ef92397c3c806631 ("LU-13903 utils: separate out server code for wiretest")

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

---
 fs/lustre/include/lustre_swab.h        |   1 -
 fs/lustre/obdclass/llog_swab.c         |  33 ------
 fs/lustre/ptlrpc/layout.c              |   3 +-
 fs/lustre/ptlrpc/pack_generic.c        |  13 +--
 fs/lustre/ptlrpc/wiretest.c            | 205 +++++++++++++--------------------
 include/uapi/linux/lustre/lustre_idl.h |  78 +++----------
 6 files changed, 97 insertions(+), 236 deletions(-)
fs/lustre/include/lustre_swab.h +0 -1
index bac3636..000e622 100644
@@ -70,7 +70,6 @@
 void lustre_swab_lmv_desc(struct lmv_desc *ld);
 void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm);
 void lustre_swab_lov_desc(struct lov_desc *ld);
-void lustre_swab_gl_desc(union ldlm_gl_desc *desc);
 void lustre_swab_ldlm_intent(struct ldlm_intent *i);
 void lustre_swab_ldlm_request(struct ldlm_request *rq);
 void lustre_swab_ldlm_reply(struct ldlm_reply *r);
fs/lustre/obdclass/llog_swab.c +0 -33
index 7bfc304..fcc2a48 100644
@@ -189,25 +189,6 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec)
 		break;
 	}
 
-	case CHANGELOG_USER_REC:
-	case CHANGELOG_USER_REC2:
-	{
-		struct llog_changelog_user_rec2 *cur =
-			(struct llog_changelog_user_rec2 *)rec;
-
-		__swab32s(&cur->cur_id);
-		__swab64s(&cur->cur_endrec);
-		if (cur->cur_hdr.lrh_type == CHANGELOG_USER_REC2) {
-			__swab32s(&cur->cur_mask);
-			BUILD_BUG_ON(offsetof(typeof(*cur), cur_padding1) == 0);
-			BUILD_BUG_ON(offsetof(typeof(*cur), cur_padding2) == 0);
-			BUILD_BUG_ON(offsetof(typeof(*cur), cur_padding3) == 0);
-		}
-		tail = (struct llog_rec_tail *)((char *)rec +
-						rec->lrh_len - sizeof(*tail));
-		break;
-	}
-
 	case HSM_AGENT_REC: {
 		struct llog_agent_req_rec *arr =
 			(struct llog_agent_req_rec *)rec;
@@ -225,20 +206,6 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec)
 		break;
 	}
 
-	case MDS_SETATTR64_REC:
-	{
-		struct llog_setattr64_rec *lsr =
-			(struct llog_setattr64_rec *)rec;
-
-		lustre_swab_ost_id(&lsr->lsr_oi);
-		__swab32s(&lsr->lsr_uid);
-		__swab32s(&lsr->lsr_uid_h);
-		__swab32s(&lsr->lsr_gid);
-		__swab32s(&lsr->lsr_gid_h);
-		__swab64s(&lsr->lsr_valid);
-		tail = &lsr->lsr_tail;
-		break;
-	}
 	case OBD_CFG_REC:
 		/* these are swabbed as they are consumed */
 		break;
fs/lustre/ptlrpc/layout.c +1 -2
index 2874a41..f31ab6e 100644
@@ -1052,8 +1052,7 @@ struct req_msg_field RMF_DLM_LVB =
 EXPORT_SYMBOL(RMF_DLM_LVB);
 
 struct req_msg_field RMF_DLM_GL_DESC =
-	DEFINE_MSGF("dlm_gl_desc", 0, sizeof(union ldlm_gl_desc),
-		    lustre_swab_gl_desc, NULL);
+	DEFINE_MSGF("dlm_gl_desc", 0, sizeof(union ldlm_gl_desc), NULL, NULL);
 EXPORT_SYMBOL(RMF_DLM_GL_DESC);
 
 struct req_msg_field RMF_MDT_MD =
fs/lustre/ptlrpc/pack_generic.c +1 -12
index 6710e6b..62e060d 100644
@@ -1738,17 +1738,6 @@ void lustre_swab_generic_32s(u32 *val)
 	__swab32s(val);
 }
 
-void lustre_swab_gl_desc(union ldlm_gl_desc *desc)
-{
-	lustre_swab_lu_fid(&desc->lquota_desc.gl_id.qid_fid);
-	__swab64s(&desc->lquota_desc.gl_flags);
-	__swab64s(&desc->lquota_desc.gl_ver);
-	__swab64s(&desc->lquota_desc.gl_hardlimit);
-	__swab64s(&desc->lquota_desc.gl_softlimit);
-	__swab64s(&desc->lquota_desc.gl_time);
-	BUILD_BUG_ON(offsetof(typeof(desc->lquota_desc), gl_pad2) == 0);
-}
-
 void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb)
 {
 	__swab64s(&lvb->lvb_size);
@@ -2321,7 +2310,7 @@ void lustre_swab_ldlm_intent(struct ldlm_intent *i)
 static void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r)
 {
 	__swab32s(&r->lr_type);
-	BUILD_BUG_ON(offsetof(typeof(*r), lr_padding) == 0);
+	BUILD_BUG_ON(offsetof(typeof(*r), lr_pad) == 0);
 	lustre_swab_ldlm_res_id(&r->lr_name);
 }
 
fs/lustre/ptlrpc/wiretest.c +82 -123

390 lines not on this page · raw message

include/uapi/linux/lustre/lustre_idl.h +13 -65

138 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

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

PATCH 24/24 lustre: pcc: VM_WRITE should not trigger layout write

In reply to James Simmons

From: Qian Yingjin <[email protected]>

VM area marked with VM_WRITE means that pages may be written, but mmap page write may never happen.
It should delay layout write until the actual modification on the file happen in ->page_mkwrite().
Otherwise, it will trigger panic for PCC-RO sanity-pcc test_21f().

Fixes 0b5ce361e ("lustre: flr: mmap write/punch does not stale other mirrors")

WC-bug-id: https://jira.whamcloud.com/browse/LU-14709
Lustre-commit: 373475a4f448c8e26 ("LU-14709 pcc: VM_WRITE should not trigger layout write")

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

---
 fs/lustre/include/cl_object.h |  5 -----
 fs/lustre/llite/llite_mmap.c  | 19 ++++++++++---------
 fs/lustre/llite/vvp_io.c      |  3 +--
 fs/lustre/lov/lov_io.c        |  6 ++----
 4 files changed, 13 insertions(+), 20 deletions(-)
fs/lustre/include/cl_object.h +0 -5
index d068454..a65240b 100644
@@ -2465,11 +2465,6 @@ int cl_io_lru_reserve(const struct lu_env *env, struct cl_io *io,
 int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
 		     pgoff_t start, struct cl_read_ahead *ra);
 
-static inline int cl_io_is_fault_writable(const struct cl_io *io)
-{
-	return io->ci_type == CIT_FAULT && io->u.ci_fault.ft_writable;
-}
-
 /**
  * True, if @io is an O_APPEND write(2).
  */
fs/lustre/llite/llite_mmap.c +10 -9
index 85a082c..8238a4e 100644
@@ -83,11 +83,13 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
  * @vma		virtual memory area addressed to page fault
  * @env		corespondent lu_env to processing
  * @index	page index corespondent to fault.
+ * @mkwrite	whether it is mmap write.
  *
  * RETURN	error codes from cl_io_init.
  */
 static struct cl_io *
-ll_fault_io_init(struct lu_env *env, struct vm_area_struct *vma, pgoff_t index)
+ll_fault_io_init(struct lu_env *env, struct vm_area_struct *vma,
+		 pgoff_t index, bool mkwrite)
 {
 	struct file *file = vma->vm_file;
 	struct inode *inode = file_inode(file);
@@ -107,6 +109,11 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
 	fio->ft_index = index;
 	fio->ft_executable = vma->vm_flags & VM_EXEC;
 
+	if (mkwrite) {
+		fio->ft_mkwrite = 1;
+		fio->ft_writable = 1;
+	}
+
 	CDEBUG(D_MMAP,
 	       DFID": vma=%p start=%#lx end=%#lx vm_flags=%#lx idx=%lu\n",
 	       PFID(&ll_i2info(inode)->lli_fid), vma, vma->vm_start,
@@ -117,9 +124,6 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
 	else if (vma->vm_flags & VM_RAND_READ)
 		io->ci_rand_read = 1;
 
-	if (vma->vm_flags & VM_WRITE)
-		fio->ft_writable = 1;
-
 	rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj);
 	if (rc == 0) {
 		struct vvp_io *vio = vvp_env_io(env);
@@ -157,7 +161,7 @@ static int __ll_page_mkwrite(struct vm_area_struct *vma, struct page *vmpage,
 	if (IS_ERR(env))
 		return PTR_ERR(env);
 
-	io = ll_fault_io_init(env, vma, vmpage->index);
+	io = ll_fault_io_init(env, vma, vmpage->index, true);
 	if (IS_ERR(io)) {
 		result = PTR_ERR(io);
 		goto out;
@@ -167,9 +171,6 @@ static int __ll_page_mkwrite(struct vm_area_struct *vma, struct page *vmpage,
 	if (result < 0)
 		goto out_io;
 
-	io->u.ci_fault.ft_mkwrite = 1;
-	io->u.ci_fault.ft_writable = 1;
-
 	vio = vvp_env_io(env);
 	vio->u.fault.ft_vma = vma;
 	vio->u.fault.ft_vmpage = vmpage;
@@ -309,7 +310,7 @@ static vm_fault_t __ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 		fault_ret = 0;
 	}
 
-	io = ll_fault_io_init(env, vma, vmf->pgoff);
+	io = ll_fault_io_init(env, vma, vmf->pgoff, false);
 	if (IS_ERR(io)) {
 		fault_ret = to_fault_error(PTR_ERR(io));
 		goto out;
fs/lustre/llite/vvp_io.c +1 -2
index a117800..d8951ac 100644
@@ -363,8 +363,7 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
 		io->ci_need_write_intent = 0;
 
 		LASSERT(io->ci_type == CIT_WRITE || cl_io_is_fallocate(io) ||
-			cl_io_is_trunc(io) || cl_io_is_mkwrite(io) ||
-			cl_io_is_fault_writable(io));
+			cl_io_is_trunc(io) || cl_io_is_mkwrite(io));
 
 		CDEBUG(D_VFSTRACE, DFID" write layout, type %u " DEXT "\n",
 		       PFID(lu_object_fid(&obj->co_lu)), io->ci_type,
fs/lustre/lov/lov_io.c +2 -4
index 2885943..eb71d7a 100644
@@ -222,8 +222,7 @@ static int lov_io_mirror_write_intent(struct lov_io *lio,
 	io->ci_need_write_intent = 0;
 
 	if (!(io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io) ||
-	      cl_io_is_fallocate(io) || cl_io_is_trunc(io) ||
-	      cl_io_is_fault_writable(io)))
+	      cl_io_is_fallocate(io) || cl_io_is_trunc(io)))
 		return 0;
 
 	/* FLR: check if it needs to send a write intent RPC to server.
@@ -575,8 +574,7 @@ static int lov_io_slice_init(struct lov_io *lio, struct lov_object *obj,
 	/* check if it needs to instantiate layout */
 	if (!(io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io) ||
 	      cl_io_is_fallocate(io) ||
-	      (cl_io_is_trunc(io) && io->u.ci_setattr.sa_attr.lvb_size > 0)) ||
-	      cl_io_is_fault_writable(io)) {
+	      (cl_io_is_trunc(io) && io->u.ci_setattr.sa_attr.lvb_size > 0))) {
 		result = 0;
 		goto out;
 	}
Signature · 6 lines
1.8.3.1

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