Skip to contentSkip to conversation

lustre: latest patches landed to OpenSFS 08/11/2020

PATCH New James Simmons 1 participant 24 messages Aug 11, 2020 Networking

lore
Share & tools
lore
#0 lore raw

cover lustre: latest patches landed to OpenSFS 08/11/2020

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

Bobi Jam (1):
lustre: lov: one more fix to write_intent end for trunc

Chris Horn (6):
lnet: Add param to control response tracking
lnet: Ensure LNet pings and pushes are always tracked
lnet: Preferred NI logic breaks MR routing
lnet: Allow duplicate nets in ip2nets syntax
lnet: Clear lp_dc_error when discovery completes
lnet: Have LNet routers monitor the ni_fatal flag

James Simmons (1):
lustre: obd: rename lprocfs_ / LPROC_SEQ_ to debugfs name

Lai Siyao (2):
lustre: uapi: add OBD_CONNECT2_GETATTR_PFID
lustre: llite: pack parent FID in getattr

Mr NeilBrown (7):
lustre: lov: annotate nested locking of obd_dev_mutex
lustre: ptlrpc: make ptlrpc_connection_put() static inline
lustre: mdc: create mdc_acl.c
lustre: sysfs: error-check value stored in jobid_var
lnet: socklnd: remove declarations of missing functions.
lnet: discard unused lnet_print_hdr()
lnet: clarify initialization of lpni_refcount

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

Patrick Farrell (1):
lustre: llite: Remove mutex on dio read

Sebastien Buisson (3):
lustre: sec: atomicity of encryption context getting/setting
lustre: sec: encryption support for DoM files
lustre: sec: check if page is empty with ZERO_PAGE

Serguei Smirnov (1):
lnet: socklnd: NID to interface mapping issues

 fs/lustre/fid/fid_internal.h           |   2 +-
 fs/lustre/fid/lproc_fid.c              |  10 +--
 fs/lustre/fld/fld_internal.h           |   2 +-
 fs/lustre/fld/lproc_fld.c              |  12 +--
 fs/lustre/include/lprocfs_status.h     | 158 +++++++++++----------------------
 fs/lustre/include/lustre_crypto.h      |   2 +
 fs/lustre/include/lustre_export.h      |   5 ++
 fs/lustre/include/lustre_net.h         |  32 ++++++-
 fs/lustre/include/lustre_req_layout.h  |   3 +-
 fs/lustre/include/obd.h                |   6 +-
 fs/lustre/include/obd_class.h          |  20 ++---
 fs/lustre/ldlm/ldlm_internal.h         |   2 +-
 fs/lustre/ldlm/ldlm_pool.c             |   4 +-
 fs/lustre/ldlm/ldlm_resource.c         |  10 +--
 fs/lustre/llite/crypto.c               |  85 +++++++++++-------
 fs/lustre/llite/dir.c                  |  16 +++-
 fs/lustre/llite/file.c                 |  30 ++++++-
 fs/lustre/llite/llite_internal.h       |   5 ++
 fs/lustre/llite/llite_lib.c            |   4 +-
 fs/lustre/llite/lproc_llite.c          |  30 ++++---
 fs/lustre/llite/namei.c                | 112 ++++++++++++++++++++---
 fs/lustre/llite/rw26.c                 |  10 ---
 fs/lustre/llite/xattr_cache.c          |  34 +++++++
 fs/lustre/lmv/lmv_intent.c             |   5 +-
 fs/lustre/lmv/lmv_obd.c                |   3 +-
 fs/lustre/lov/lov_io.c                 |   5 +-
 fs/lustre/mdc/Makefile                 |   1 +
 fs/lustre/mdc/lproc_mdc.c              |  28 +++---
 fs/lustre/mdc/mdc_acl.c                |  64 +++++++++++++
 fs/lustre/mdc/mdc_internal.h           |  12 +++
 fs/lustre/mdc/mdc_lib.c                |  23 +++++
 fs/lustre/mdc/mdc_locks.c              |  22 +++++
 fs/lustre/mdc/mdc_reint.c              |   3 +
 fs/lustre/mdc/mdc_request.c            |  65 ++------------
 fs/lustre/mgc/lproc_mgc.c              |  12 +--
 fs/lustre/obdclass/genops.c            |  11 +--
 fs/lustre/obdclass/lprocfs_status.c    |  50 ++++++-----
 fs/lustre/obdclass/obd_config.c        |  92 -------------------
 fs/lustre/obdclass/obd_sysfs.c         |  24 +++--
 fs/lustre/osc/lproc_osc.c              |  24 ++---
 fs/lustre/osc/osc_request.c            |  11 +--
 fs/lustre/ptlrpc/connection.c          |  35 --------
 fs/lustre/ptlrpc/import.c              |   6 +-
 fs/lustre/ptlrpc/layout.c              |  25 ++++--
 fs/lustre/ptlrpc/lproc_ptlrpc.c        |  30 ++++---
 fs/lustre/ptlrpc/ptlrpc_module.c       |   2 -
 fs/lustre/ptlrpc/sec_lproc.c           |  15 ++--
 fs/lustre/ptlrpc/wiretest.c            |   6 +-
 include/linux/lnet/lib-lnet.h          |  31 ++++++-
 include/uapi/linux/lustre/lustre_idl.h |   4 +-
 include/uapi/linux/lustre/lustre_ver.h |   4 +-
 net/lnet/klnds/socklnd/socklnd.c       |   2 +-
 net/lnet/klnds/socklnd/socklnd.h       |   2 -
 net/lnet/lnet/api-ni.c                 |  37 ++++++++
 net/lnet/lnet/config.c                 |  36 +-------
 net/lnet/lnet/lib-move.c               |  86 +++++-------------
 net/lnet/lnet/peer.c                   |  52 ++++++-----
 net/lnet/lnet/router.c                 |  35 +++++---
 58 files changed, 793 insertions(+), 664 deletions(-)
 create mode 100644 fs/lustre/mdc/mdc_acl.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/23 lustre: lov: one more fix to write_intent end for trunc

From: Bobi Jam <[email protected]>

This patch fixes another case where the truncate write intent extent is set incorrectly. This may cause errors when truncating PFL files to exactly the boundary between two extents.

Fixes 782b737b76c1 ("lustre: lov: Correct write_intent end for trunc")

WC-bug-id: https://jira.whamcloud.com/browse/LU-12586
Lustre-commit: ecf9e229cf59d ("LU-12586 lov: one more fix to write_intent end for trunc")

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

---
 fs/lustre/lov/lov_io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/lustre/lov/lov_io.c +3 -2
index 99b68d8..af79d20 100644
@@ -363,11 +363,12 @@ static int lov_io_mirror_init(struct lov_io *lio, struct lov_object *obj,
 			/**
 			 * for truncate, we uses [size, EOF) to judge whether
 			 * a write intent needs to be send, but we need to
-			 * restore the write extent to [0, size).
+			 * restore the write extent to [0, size), in truncate,
+			 * the byte in the size position is accessed.
 			 */
 			io->ci_write_intent.e_start = 0;
 			io->ci_write_intent.e_end =
-					io->u.ci_setattr.sa_attr.lvb_size;
+					io->u.ci_setattr.sa_attr.lvb_size + 1;
 		}
 		/* stop cl_io_init() loop */
 		return 1;
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/23 lustre: lov: annotate nested locking of obd_dev_mutex

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

obd_statfs() can call lmv_statfs() with ->obd_dev_mutex helds. lmv_statfs will then call obd_statfs() on a different device and ->obd_dev_mutex will be taken again. This is a *different* mutex, but lockdep cannot see the difference, so it complains.

We can tell lockdep not to worry in this case using mutex_lock_interruptible_nested().

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: 10dae4c3b68eb ("LU-9679 lov: annotate nested locking of obd_dev_mutex")

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

---
 fs/lustre/include/obd_class.h | 8 +++++++-
 fs/lustre/lmv/lmv_obd.c       | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)
fs/lustre/include/obd_class.h +7 -1
index 78f7b16..e8168bc5 100644
@@ -49,6 +49,10 @@
 #define OBD_STATFS_FOR_MDT0	0x0004
 /* get aggregated statfs from MDT */
 #define OBD_STATFS_SUM		0x0008
+#define OBD_STATFS_NESTED	0x0010 /* Call while already holding
+					* obd_dev_mutex of a difference
+					* device.
+					*/
 
 /* OBD Device Declarations */
 extern rwlock_t obd_dev_lock;
@@ -945,7 +949,9 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 	    ((obd->obd_osfs.os_state & OS_STATFS_SUM) &&
 	     !(flags & OBD_STATFS_SUM))) {
 		/* the RPC will block anyway, so avoid sending many at once */
-		rc = mutex_lock_interruptible(&obd->obd_dev_mutex);
+		rc = mutex_lock_interruptible_nested(&obd->obd_dev_mutex,
+						     (flags & OBD_STATFS_NESTED)
+						     ? SINGLE_DEPTH_NESTING : 0);
 		if (rc)
 			return rc;
 		if (obd->obd_osfs_age < max_age ||
fs/lustre/lmv/lmv_obd.c +2 -1
index 4131b49..5a75c69 100644
@@ -1248,7 +1248,8 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
 		if (!tgt || !tgt->ltd_exp)
 			continue;
 
-		rc = obd_statfs(env, tgt->ltd_exp, temp, max_age, flags);
+		rc = obd_statfs(env, tgt->ltd_exp, temp, max_age,
+				flags | OBD_STATFS_NESTED);
 		if (rc) {
 			CERROR("%s: can't stat MDS #%d: rc = %d\n",
 			       tgt->ltd_exp->exp_obd->obd_name, i, rc);
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/23 lustre: ptlrpc: make ptlrpc_connection_put() static inline

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

This function needs to be called from the obdclass modules, but is currently defined in a module that depends on that module. The get around this interdependence, a global variable
ptlrpc_put_connection_superhack
is used to make a pointer to the function available.

Rather than this hack, we can make ptlrpc_connection_put() static-inline. This does expose some details of ptlrpc to obdclass, but there is already a fairly tight connection.

Also change the return value to 'void' as it is never used, and don't bother checking for NULL before calling, as the function has its own test for NULL.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: 0a03e51b7e49a ("LU-9679 lustre: make ptlrpc_connection_put() static inline")

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

---
 fs/lustre/include/lustre_net.h   | 32 +++++++++++++++++++++++++++++++-
 fs/lustre/include/obd_class.h    |  8 --------
 fs/lustre/obdclass/genops.c      | 11 +++--------
 fs/lustre/ptlrpc/connection.c    | 35 -----------------------------------
 fs/lustre/ptlrpc/import.c        |  6 ++----
 fs/lustre/ptlrpc/ptlrpc_module.c |  2 --
 6 files changed, 36 insertions(+), 58 deletions(-)
fs/lustre/include/lustre_net.h +31 -1
index 2d58f13e..dd482bc 100644
@@ -1777,7 +1777,37 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
 struct ptlrpc_connection *ptlrpc_connection_get(struct lnet_process_id peer,
 						lnet_nid_t self,
 						struct obd_uuid *uuid);
-int ptlrpc_connection_put(struct ptlrpc_connection *c);
+
+static inline void  ptlrpc_connection_put(struct ptlrpc_connection *conn)
+{
+	if (!conn)
+		return;
+
+	LASSERT(atomic_read(&conn->c_refcount) > 0);
+
+	/*
+	 * We do not remove connection from hashtable and
+	 * do not free it even if last caller released ref,
+	 * as we want to have it cached for the case it is
+	 * needed again.
+	 *
+	 * Deallocating it and later creating new connection
+	 * again would be wastful. This way we also avoid
+	 * expensive locking to protect things from get/put
+	 * race when found cached connection is freed by
+	 * ptlrpc_connection_put().
+	 *
+	 * It will be freed later in module unload time,
+	 * when ptlrpc_connection_fini()->lh_exit->conn_exit()
+	 * path is called.
+	 */
+	atomic_dec(&conn->c_refcount);
+
+	CDEBUG(D_INFO, "PUT conn=%p refcount %d to %s\n",
+	       conn, atomic_read(&conn->c_refcount),
+	       libcfs_nid2str(conn->c_peer.nid));
+}
+
 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
 int ptlrpc_connection_init(void);
 void ptlrpc_connection_fini(void);
fs/lustre/include/obd_class.h +0 -8
index e8168bc5..187553d 100644
@@ -1691,14 +1691,6 @@ struct lwp_register_item {
 	char			lri_name[MTI_NAME_MAXLEN];
 };
 
-/*
- * I'm as embarrassed about this as you are.
- *
- * <shaver> // XXX do not look into _superhack with remaining eye
- * <shaver> // XXX if this were any uglier, I'd get my own show on MTV
- */
-extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
-
 /* obd_mount.c */
 int lustre_check_exclusion(struct super_block *sb, char *svname);
 
fs/lustre/obdclass/genops.c +3 -8
index 759d97e..7bc4dab 100644
@@ -53,9 +53,6 @@
 static void obd_zombie_export_add(struct obd_export *exp);
 static void obd_zombie_import_add(struct obd_import *imp);
 
-int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
-EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
-
 /*
  * support functions: we could use inter-module communication, but this
  * is more portable to other OS's
@@ -717,9 +714,7 @@ static void class_export_destroy(struct obd_export *exp)
 	CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp,
 	       exp->exp_client_uuid.uuid, obd->obd_name);
 
-	/* "Local" exports (lctl, LOV->{mdc,osc}) have no connection. */
-	if (exp->exp_connection)
-		ptlrpc_put_connection_superhack(exp->exp_connection);
+	ptlrpc_connection_put(exp->exp_connection);
 
 	LASSERT(list_empty(&exp->exp_outstanding_replies));
 	LASSERT(list_empty(&exp->exp_uncommitted_replies));
@@ -907,13 +902,13 @@ static void obd_zombie_import_free(struct obd_import *imp)
 
 	LASSERT(refcount_read(&imp->imp_refcount) == 0);
 
-	ptlrpc_put_connection_superhack(imp->imp_connection);
+	ptlrpc_connection_put(imp->imp_connection);
 
 	while ((imp_conn = list_first_entry_or_null(&imp->imp_conn_list,
 						    struct obd_import_conn,
 						    oic_item)) != NULL) {
 		list_del_init(&imp_conn->oic_item);
-		ptlrpc_put_connection_superhack(imp_conn->oic_conn);
+		ptlrpc_connection_put(imp_conn->oic_conn);
 		kfree(imp_conn);
 	}
 
fs/lustre/ptlrpc/connection.c +0 -35
index a548d99..1551a9a 100644
@@ -130,41 +130,6 @@ struct ptlrpc_connection *
 	return conn;
 }
 
-int ptlrpc_connection_put(struct ptlrpc_connection *conn)
-{
-	int rc = 0;
-
-	if (!conn)
-		return rc;
-
-	LASSERT(atomic_read(&conn->c_refcount) > 0);
-
-	/*
-	 * We do not remove connection from hashtable and
-	 * do not free it even if last caller released ref,
-	 * as we want to have it cached for the case it is
-	 * needed again.
-	 *
-	 * Deallocating it and later creating new connection
-	 * again would be wastful. This way we also avoid
-	 * expensive locking to protect things from get/put
-	 * race when found cached connection is freed by
-	 * ptlrpc_connection_put().
-	 *
-	 * It will be freed later in module unload time,
-	 * when ptlrpc_connection_fini()->lh_exit->conn_exit()
-	 * path is called.
-	 */
-	if (atomic_dec_return(&conn->c_refcount) == 0)
-		rc = 1;
-
-	CDEBUG(D_INFO, "PUT conn=%p refcount %d to %s\n",
-	       conn, atomic_read(&conn->c_refcount),
-	       libcfs_nid2str(conn->c_peer.nid));
-
-	return rc;
-}
-
 struct ptlrpc_connection *
 ptlrpc_connection_addref(struct ptlrpc_connection *conn)
 {
fs/lustre/ptlrpc/import.c +2 -4
index 1490dcf..4e573cd 100644
@@ -571,8 +571,7 @@ static int import_select_connection(struct obd_import *imp)
 	imp_conn->oic_last_attempt = ktime_get_seconds();
 
 	/* switch connection, don't mind if it's same as the current one */
-	if (imp->imp_connection)
-		ptlrpc_connection_put(imp->imp_connection);
+	ptlrpc_connection_put(imp->imp_connection);
 	imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
 
 	dlmexp = class_conn2export(&imp->imp_dlm_handle);
@@ -580,8 +579,7 @@ static int import_select_connection(struct obd_import *imp)
 		rc = -EINVAL;
 		goto out_unlock;
 	}
-	if (dlmexp->exp_connection)
-		ptlrpc_connection_put(dlmexp->exp_connection);
+	ptlrpc_connection_put(dlmexp->exp_connection);
 	dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
 	class_export_put(dlmexp);
 
fs/lustre/ptlrpc/ptlrpc_module.c +0 -2
index 0c988ae..85fb0fa 100644
@@ -49,8 +49,6 @@ int ptlrpc_inc_ref(void)
 
 	mutex_lock(&ptlrpc_startup);
 	if (ptlrpc_active++ == 0) {
-		ptlrpc_put_connection_superhack = ptlrpc_connection_put;
-
 		rc = ptlrpc_init_portals();
 		if (!rc) {
 			rc = ptlrpc_start_pinger();
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/23 lustre: mdc: create mdc_acl.c

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

This new C file contains acl related code so it can be conditionally compiled.

Also remove conditional code around the call to mdc_unpack_acl(), as those tests are already performed inside mdc_unpack_acl().

This removes all #ifdef of CONFIG_LUSTRE_FS_POSIX_ACL from C files in 'mdc'.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9679
Lustre-commit: 896ff00276afd ("LU-9679 mdc: create mdc_acl.c")

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

---
 fs/lustre/mdc/Makefile       |  1 +
 fs/lustre/mdc/mdc_acl.c      | 64 ++++++++++++++++++++++++++++++++++++++++++++
 fs/lustre/mdc/mdc_internal.h | 10 +++++++
 fs/lustre/mdc/mdc_request.c  | 61 +++++------------------------------------
 4 files changed, 81 insertions(+), 55 deletions(-)
 create mode 100644 fs/lustre/mdc/mdc_acl.c
fs/lustre/mdc/Makefile +1 -0
index 2cbc641..1ac97ee 100644
@@ -3,3 +3,4 @@ ccflags-y += -I$(srctree)/$(src)/../include
 obj-$(CONFIG_LUSTRE_FS) += mdc.o
 mdc-y := mdc_changelog.o mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.o
 mdc-y += mdc_dev.o
+mdc-$(CONFIG_LUSTRE_FS_POSIX_ACL) += mdc_acl.o
fs/lustre/mdc/mdc_acl.c new file +64 -0

64 lines not on this page · raw message

fs/lustre/mdc/mdc_internal.h +10 -0
index b7ccc58..a1fb5d9 100644
@@ -156,6 +156,16 @@ static inline int mdc_prep_elc_req(struct obd_export *exp,
 				 count);
 }
 
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md);
+#else
+static inline
+int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
+{
+	return 0;
+}
+#endif
+
 static inline unsigned long hash_x_index(u64 hash, int hash64)
 {
 	if (BITS_PER_LONG == 32 && hash64)
fs/lustre/mdc/mdc_request.c +6 -55

73 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/23 lustre: llite: Remove mutex on dio read

In reply to James Simmons

From: Patrick Farrell <[email protected]>

DIO reads in Lustre are protected by Lustre range locking and do not need the inode mutex. This code was removed in LU-1669, the range lock was added for DIO reads in LU-6227, and then the mutex was accidentally re-introduced in LU-6260.

Remove it again.

Fixes fde7ac1942f5 ("lustre: llite: add support for direct IO api changes")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13196
Lustre-commit: 5bc1fe092cba0 ("LU-13196 llite: Remove mutex on dio read")

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

---
 fs/lustre/llite/rw26.c | 10 ----------
 1 file changed, 10 deletions(-)
fs/lustre/llite/rw26.c +0 -10
index b3802cf..7010fe8 100644
@@ -328,13 +328,6 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	LASSERT(aio);
 	LASSERT(aio->cda_iocb == iocb);
 
-	/* 0. Need locking between buffered and direct access. and race with
-	 *    size changing by concurrent truncates and writes.
-	 * 1. Need inode mutex to operate transient pages.
-	 */
-	if (rw == READ)
-		inode_lock(inode);
-
 	while (iov_iter_count(iter)) {
 		struct ll_dio_pages pvec = { .ldp_aio = aio };
 		struct page **pages;
@@ -406,9 +399,6 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 		result = -EIOCBQUEUED;
 	}
 
-	if (rw == READ)
-		inode_unlock(inode);
-
 	return result;
 }
 
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/23 lustre: obd: rename lprocfs_ / LPROC_SEQ_ to debugfs name

In reply to James Simmons

For a long time lustre has not used procfs so rename several functions starting with lprocfs_* to ldebugfs_*. Do this as well the for LPROC_SEQ_* macros to LDEBUGFS_SEQ_*.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Lustre-commit: 0100ab268c312 ("LU-8066 obd: final pieces for sysfs/debugfs support.")

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

---
 fs/lustre/fid/fid_internal.h        |   2 +-
 fs/lustre/fid/lproc_fid.c           |  10 +--
 fs/lustre/fld/fld_internal.h        |   2 +-
 fs/lustre/fld/lproc_fld.c           |  12 +--
 fs/lustre/include/lprocfs_status.h  | 158 ++++++++++++------------------------
 fs/lustre/include/obd.h             |   2 +-
 fs/lustre/include/obd_class.h       |   4 -
 fs/lustre/ldlm/ldlm_internal.h      |   2 +-
 fs/lustre/ldlm/ldlm_pool.c          |   4 +-
 fs/lustre/ldlm/ldlm_resource.c      |  10 +--
 fs/lustre/llite/lproc_llite.c       |  30 +++----
 fs/lustre/mdc/lproc_mdc.c           |  28 +++----
 fs/lustre/mgc/lproc_mgc.c           |  12 +--
 fs/lustre/obdclass/lprocfs_status.c |  48 ++++++-----
 fs/lustre/obdclass/obd_config.c     |  92 ---------------------
 fs/lustre/obdclass/obd_sysfs.c      |   2 +-
 fs/lustre/osc/lproc_osc.c           |  24 +++---
 fs/lustre/ptlrpc/lproc_ptlrpc.c     |  30 +++----
 fs/lustre/ptlrpc/sec_lproc.c        |  15 ++--
 19 files changed, 171 insertions(+), 316 deletions(-)
fs/lustre/fid/fid_internal.h +1 -1
index 7bb1283..cbf0987 100644
@@ -41,6 +41,6 @@
 
 /* Functions used internally in module. */
 
-extern struct lprocfs_vars seq_client_debugfs_list[];
+extern struct ldebugfs_vars seq_client_debugfs_list[];
 
 #endif /* __FID_INTERNAL_H */
fs/lustre/fid/lproc_fid.c +5 -5
index 15468b4..be9846b 100644
@@ -209,12 +209,12 @@ static ssize_t ldebugfs_fid_width_seq_write(struct file *file,
 	return 0;
 }
 
-LPROC_SEQ_FOPS(ldebugfs_fid_space);
-LPROC_SEQ_FOPS(ldebugfs_fid_width);
-LPROC_SEQ_FOPS_RO(ldebugfs_fid_server);
-LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid);
+LDEBUGFS_SEQ_FOPS(ldebugfs_fid_space);
+LDEBUGFS_SEQ_FOPS(ldebugfs_fid_width);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_fid_server);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_fid_fid);
 
-struct lprocfs_vars seq_client_debugfs_list[] = {
+struct ldebugfs_vars seq_client_debugfs_list[] = {
 	{ .name =	"space",
 	  .fops =	&ldebugfs_fid_space_fops },
 	{ .name	=	"width",
fs/lustre/fld/fld_internal.h +1 -1
index d44e378..d32360c 100644
@@ -133,7 +133,7 @@ int fld_client_rpc(struct obd_export *exp,
 		   struct lu_seq_range *range, u32 fld_op,
 		   struct ptlrpc_request **reqp);
 
-extern struct lprocfs_vars fld_client_debugfs_list[];
+extern struct ldebugfs_vars fld_client_debugfs_list[];
 
 struct fld_cache *fld_cache_init(const char *name,
 				 int cache_size, int cache_threshold);
fs/lustre/fld/lproc_fld.c +6 -6
index e8c8bc7..9e1be53 100644
@@ -117,8 +117,8 @@
 }
 
 static ssize_t
-lprocfs_wr_cache_flush(struct file *file, const char __user *buffer,
-		      size_t count, loff_t *pos)
+ldebugfs_cache_flush_seq_write(struct file *file, const char __user *buffer,
+			       size_t count, loff_t *pos)
 {
 	struct seq_file *m = file->private_data;
 	struct lu_client_fld *fld = m->private;
@@ -130,11 +130,11 @@
 	return count;
 }
 
-LPROC_SEQ_FOPS_RO(fld_debugfs_targets);
-LPROC_SEQ_FOPS(fld_debugfs_hash);
-LPROC_SEQ_FOPS_WR_ONLY(fld, cache_flush);
+LDEBUGFS_SEQ_FOPS_RO(fld_debugfs_targets);
+LDEBUGFS_SEQ_FOPS(fld_debugfs_hash);
+LDEBUGFS_SEQ_FOPS_WR_ONLY(fld, cache_flush);
 
-struct lprocfs_vars fld_client_debugfs_list[] = {
+struct ldebugfs_vars fld_client_debugfs_list[] = {
 	{ .name =	"targets",
 	  .fops =	&fld_debugfs_targets_fops	},
 	{ .name =	"hash",
fs/lustre/include/lprocfs_status.h +50 -108

242 lines not on this page · raw message

fs/lustre/include/obd.h +1 -1
index ad2b2f4..849483f 100644
@@ -608,7 +608,7 @@ struct obd_device {
 	struct dentry		*obd_svc_debugfs_entry;
 	struct lprocfs_stats	*obd_svc_stats;
 	const struct attribute **obd_attrs;
-	struct lprocfs_vars	*obd_vars;
+	struct ldebugfs_vars	*obd_vars;
 	atomic_t		 obd_evict_inprogress;
 	wait_queue_head_t	 obd_evict_inprogress_waitq;
 	struct list_head	 obd_evict_list; /* protected with pet_lock */
fs/lustre/include/obd_class.h +0 -4
index 187553d..a22581d 100644
@@ -134,8 +134,6 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
 ssize_t class_set_global(const char *param);
 ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
 			    struct kobject *kobj);
-int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
-			     struct lustre_cfg *lcfg, void *data);
 
 /* For interoperability */
 struct cfg_interop_param {
@@ -162,8 +160,6 @@ int class_config_llog_handler(const struct lu_env *env,
 			      struct llog_rec_hdr *rec, void *data);
 
 /* obdecho */
-void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);
-
 #define CFG_F_START	0x01   /* Set when we start updating from a log */
 #define CFG_F_MARKER	0x02   /* We are within a maker */
 #define CFG_F_SKIP	0x04   /* We should ignore this cfg command */
fs/lustre/ldlm/ldlm_internal.h +1 -1
index 996c0fb..0dce219 100644
@@ -298,7 +298,7 @@ enum ldlm_policy_res {
 	struct __##var##__dummy_write {; } /* semicolon catcher */
 
 static inline void
-ldlm_add_var(struct lprocfs_vars *vars, struct dentry *debugfs_entry,
+ldlm_add_var(struct ldebugfs_vars *vars, struct dentry *debugfs_entry,
 	     const char *name, void *data, const struct file_operations *ops)
 {
 	vars->name = name;
fs/lustre/ldlm/ldlm_pool.c +2 -2
index 9185dc93..40585f7 100644
@@ -459,7 +459,7 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(lprocfs_pool_state);
+LDEBUGFS_SEQ_FOPS_RO(lprocfs_pool_state);
 
 static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr,
 				char *buf)
@@ -549,7 +549,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
 	struct ldlm_namespace *ns = container_of(pl, struct ldlm_namespace,
 						 ns_pool);
 	struct dentry *debugfs_ns_parent;
-	struct lprocfs_vars pool_vars[2];
+	struct ldebugfs_vars pool_vars[2];
 	int rc = 0;
 
 	debugfs_ns_parent = ns->ns_debugfs_entry;
fs/lustre/ldlm/ldlm_resource.c +5 -5
index a461ca7..d0a59a8 100644
@@ -71,15 +71,15 @@
 static unsigned int ldlm_dump_granted_max = 256;
 
 static ssize_t
-lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
-		   size_t count, loff_t *off)
+ldebugfs_dump_ns_seq_write(struct file *file, const char __user *buffer,
+			   size_t count, loff_t *off)
 {
 	ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
 	ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
 	return count;
 }
 
-LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns);
+LDEBUGFS_SEQ_FOPS_WR_ONLY(ldlm, dump_ns);
 
 static int ldlm_rw_uint_seq_show(struct seq_file *m, void *v)
 {
@@ -99,9 +99,9 @@ static int ldlm_rw_uint_seq_show(struct seq_file *m, void *v)
 				    (unsigned int *)seq->private);
 }
 
-LPROC_SEQ_FOPS(ldlm_rw_uint);
+LDEBUGFS_SEQ_FOPS(ldlm_rw_uint);
 
-static struct lprocfs_vars ldlm_debugfs_list[] = {
+static struct ldebugfs_vars ldlm_debugfs_list[] = {
 	{ "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 },
 	{ "dump_granted_max", &ldlm_rw_uint_fops, &ldlm_dump_granted_max },
 	{ NULL }
fs/lustre/llite/lproc_llite.c +16 -14
index f5a1940..a742200 100644
@@ -319,7 +319,7 @@ static int ll_site_stats_seq_show(struct seq_file *m, void *v)
 	return cl_site_stats_print(lu2cl_site(ll_s2sbi(sb)->ll_site), m);
 }
 
-LPROC_SEQ_FOPS_RO(ll_site_stats);
+LDEBUGFS_SEQ_FOPS_RO(ll_site_stats);
 
 static ssize_t max_read_ahead_mb_show(struct kobject *kobj,
 				      struct attribute *attr, char *buf)
@@ -601,7 +601,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file,
 	return rc;
 }
 
-LPROC_SEQ_FOPS(ll_max_cached_mb);
+LDEBUGFS_SEQ_FOPS(ll_max_cached_mb);
 
 static ssize_t checksums_show(struct kobject *kobj, struct attribute *attr,
 			      char *buf)
@@ -851,7 +851,7 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(ll_statahead_stats);
+LDEBUGFS_SEQ_FOPS_RO(ll_statahead_stats);
 
 static ssize_t lazystatfs_show(struct kobject *kobj,
 			       struct attribute *attr,
@@ -1028,7 +1028,7 @@ static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(ll_sbi_flags);
+LDEBUGFS_SEQ_FOPS_RO(ll_sbi_flags);
 
 static ssize_t xattr_cache_show(struct kobject *kobj,
 				struct attribute *attr,
@@ -1376,7 +1376,7 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file,
 
 	return count;
 }
-LPROC_SEQ_FOPS(ll_unstable_stats);
+LDEBUGFS_SEQ_FOPS(ll_unstable_stats);
 
 static int ll_root_squash_seq_show(struct seq_file *m, void *v)
 {
@@ -1397,9 +1397,10 @@ static ssize_t ll_root_squash_seq_write(struct file *file,
 	struct ll_sb_info *sbi = ll_s2sbi(sb);
 	struct root_squash_info *squash = &sbi->ll_squash;
 
-	return lprocfs_wr_root_squash(buffer, count, squash, sbi->ll_fsname);
+	return ldebugfs_root_squash_seq_write(buffer, count, squash,
+					      sbi->ll_fsname);
 }
-LPROC_SEQ_FOPS(ll_root_squash);
+LDEBUGFS_SEQ_FOPS(ll_root_squash);
 
 static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v)
 {
@@ -1432,7 +1433,8 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file,
 	struct root_squash_info *squash = &sbi->ll_squash;
 	int rc;
 
-	rc = lprocfs_wr_nosquash_nids(buffer, count, squash, sbi->ll_fsname);
+	rc = ldebugfs_nosquash_nids_seq_write(buffer, count, squash,
+					      sbi->ll_fsname);
 	if (rc < 0)
 		return rc;
 
@@ -1441,7 +1443,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file,
 	return rc;
 }
 
-LPROC_SEQ_FOPS(ll_nosquash_nids);
+LDEBUGFS_SEQ_FOPS(ll_nosquash_nids);
 
 static int ll_pcc_seq_show(struct seq_file *m, void *v)
 {
@@ -1480,9 +1482,9 @@ static ssize_t ll_pcc_seq_write(struct file *file, const char __user *buffer,
 	kfree(kernbuf);
 	return rc ? rc : count;
 }
-LPROC_SEQ_FOPS(ll_pcc);
+LDEBUGFS_SEQ_FOPS(ll_pcc);
 
-struct lprocfs_vars lprocfs_llite_obd_vars[] = {
+struct ldebugfs_vars lprocfs_llite_obd_vars[] = {
 	{ .name	=	"site",
 	  .fops	=	&ll_site_stats_fops			},
 	{ .name	=	"max_cached_mb",
@@ -1858,7 +1860,7 @@ static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file,
 	return len;
 }
 
-LPROC_SEQ_FOPS(ll_rw_extents_stats_pp);
+LDEBUGFS_SEQ_FOPS(ll_rw_extents_stats_pp);
 
 static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v)
 {
@@ -1918,7 +1920,7 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file,
 	return len;
 }
 
-LPROC_SEQ_FOPS(ll_rw_extents_stats);
+LDEBUGFS_SEQ_FOPS(ll_rw_extents_stats);
 
 void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
 		       struct ll_file_data *file, loff_t pos,
@@ -2109,4 +2111,4 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file,
 	return len;
 }
 
-LPROC_SEQ_FOPS(ll_rw_offset_stats);
+LDEBUGFS_SEQ_FOPS(ll_rw_offset_stats);
fs/lustre/mdc/lproc_mdc.c +14 -14
index 0c252ed..d7506ea 100644
@@ -90,7 +90,7 @@ static ssize_t mdc_max_dirty_mb_seq_write(struct file *file,
 
 	return count;
 }
-LPROC_SEQ_FOPS(mdc_max_dirty_mb);
+LDEBUGFS_SEQ_FOPS(mdc_max_dirty_mb);
 
 static int mdc_cached_mb_seq_show(struct seq_file *m, void *v)
 {
@@ -150,7 +150,7 @@ static int mdc_cached_mb_seq_show(struct seq_file *m, void *v)
 
 	return count;
 }
-LPROC_SEQ_FOPS(mdc_cached_mb);
+LDEBUGFS_SEQ_FOPS(mdc_cached_mb);
 
 static int mdc_contention_seconds_seq_show(struct seq_file *m, void *v)
 {
@@ -189,7 +189,7 @@ static ssize_t mdc_contention_seconds_seq_write(struct file *file,
 
 	return count;
 }
-LPROC_SEQ_FOPS(mdc_contention_seconds);
+LDEBUGFS_SEQ_FOPS(mdc_contention_seconds);
 
 static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v)
 {
@@ -205,7 +205,7 @@ static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v)
 		   "unstable_mb:              %10d\n", pages, mb);
 	return 0;
 }
-LPROC_SEQ_FOPS_RO(mdc_unstable_stats);
+LDEBUGFS_SEQ_FOPS_RO(mdc_unstable_stats);
 
 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
 			   char *buf)
@@ -427,7 +427,7 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 
 	return 0;
 }
-LPROC_SEQ_FOPS(mdc_rpc_stats);
+LDEBUGFS_SEQ_FOPS(mdc_rpc_stats);
 
 static int mdc_stats_seq_show(struct seq_file *seq, void *v)
 {
@@ -459,7 +459,7 @@ static ssize_t mdc_stats_seq_write(struct file *file,
 	memset(stats, 0, sizeof(*stats));
 	return len;
 }
-LPROC_SEQ_FOPS(mdc_stats);
+LDEBUGFS_SEQ_FOPS(mdc_stats);
 
 static int mdc_dom_min_repsize_seq_show(struct seq_file *m, void *v)
 {
@@ -489,17 +489,17 @@ static ssize_t mdc_dom_min_repsize_seq_write(struct file *file,
 	obd->u.cli.cl_dom_min_inline_repsize = val;
 	return count;
 }
-LPROC_SEQ_FOPS(mdc_dom_min_repsize);
+LDEBUGFS_SEQ_FOPS(mdc_dom_min_repsize);
 
-LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, timeouts);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, state);
 
-LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
-LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
+LDEBUGFS_SEQ_FOPS_RW_TYPE(mdc, import);
+LDEBUGFS_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
 
-static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
+static struct ldebugfs_vars lprocfs_mdc_obd_vars[] = {
 	{ .name	=	"connect_flags",
 	  .fops	=	&mdc_connect_flags_fops		},
 	{ .name	=	"mds_server_uuid",
fs/lustre/mgc/lproc_mgc.c +6 -6
index 0c716df..c22ec23 100644
@@ -37,22 +37,22 @@
 #include <lprocfs_status.h>
 #include "mgc_internal.h"
 
-LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, connect_flags);
 
-LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, server_uuid);
 
-LPROC_SEQ_FOPS_RO_TYPE(mgc, import);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, import);
 
-LPROC_SEQ_FOPS_RO_TYPE(mgc, state);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(mgc, state);
 
 static int mgc_ir_state_seq_show(struct seq_file *m, void *v)
 {
 	return lprocfs_mgc_rd_ir_state(m, m->private);
 }
 
-LPROC_SEQ_FOPS_RO(mgc_ir_state);
+LDEBUGFS_SEQ_FOPS_RO(mgc_ir_state);
 
-struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
+struct ldebugfs_vars lprocfs_mgc_obd_vars[] = {
 	{ .name =	"connect_flags",
 	  .fops =	&mgc_connect_flags_fops	},
 	{ .name =	"mgs_server_uuid",
fs/lustre/obdclass/lprocfs_status.c +26 -22

139 lines not on this page · raw message

fs/lustre/obdclass/obd_config.c +0 -92

98 lines not on this page · raw message

fs/lustre/obdclass/obd_sysfs.c +1 -1
index f1fc78d..cb2f0a9 100644
@@ -443,7 +443,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(health_check);
+LDEBUGFS_SEQ_FOPS_RO(health_check);
 
 struct kset *lustre_kset;
 EXPORT_SYMBOL_GPL(lustre_kset);
fs/lustre/osc/lproc_osc.c +12 -12
index 9b43710..14cbe54 100644
@@ -242,7 +242,7 @@ static ssize_t osc_cached_mb_seq_write(struct file *file,
 	return count;
 }
 
-LPROC_SEQ_FOPS(osc_cached_mb);
+LDEBUGFS_SEQ_FOPS(osc_cached_mb);
 
 static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
 				    struct attribute *attr,
@@ -447,7 +447,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file,
 	}
 	return rc;
 }
-LPROC_SEQ_FOPS(osc_checksum_type);
+LDEBUGFS_SEQ_FOPS(osc_checksum_type);
 
 static ssize_t resend_count_show(struct kobject *kobj,
 				 struct attribute *attr,
@@ -605,7 +605,7 @@ static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(osc_unstable_stats);
+LDEBUGFS_SEQ_FOPS_RO(osc_unstable_stats);
 
 static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr,
 				 char *buf)
@@ -729,15 +729,15 @@ static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_RW_ATTR(grant_shrink);
 
-LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
-LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
-LPROC_SEQ_FOPS_RO_TYPE(osc, state);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, connect_flags);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, server_uuid);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, timeouts);
+LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, state);
 
-LPROC_SEQ_FOPS_RW_TYPE(osc, import);
-LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
+LDEBUGFS_SEQ_FOPS_RW_TYPE(osc, import);
+LDEBUGFS_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
 
-static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
+static struct ldebugfs_vars lprocfs_osc_obd_vars[] = {
 	{ .name	=	"connect_flags",
 	  .fops	=	&osc_connect_flags_fops		},
 	{ .name	=	"ost_server_uuid",
@@ -876,7 +876,7 @@ static ssize_t osc_rpc_stats_seq_write(struct file *file,
 	return len;
 }
 
-LPROC_SEQ_FOPS(osc_rpc_stats);
+LDEBUGFS_SEQ_FOPS(osc_rpc_stats);
 
 static int osc_stats_seq_show(struct seq_file *seq, void *v)
 {
@@ -909,7 +909,7 @@ static ssize_t osc_stats_seq_write(struct file *file,
 	return len;
 }
 
-LPROC_SEQ_FOPS(osc_stats);
+LDEBUGFS_SEQ_FOPS(osc_stats);
 
 void lproc_osc_attach_seqstat(struct obd_device *obd)
 {
fs/lustre/ptlrpc/lproc_ptlrpc.c +16 -14
index 86ec1f5..4d2ae14 100644
@@ -263,7 +263,7 @@ static const char *ll_eopcode2str(u32 opcode)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_req_history_len);
+LDEBUGFS_SEQ_FOPS_RO(ptlrpc_lprocfs_req_history_len);
 
 static int
 ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n)
@@ -325,7 +325,7 @@ static const char *ll_eopcode2str(u32 opcode)
 	return count;
 }
 
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max);
+LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_req_history_max);
 
 static int
 ptlrpc_lprocfs_req_buffers_max_seq_show(struct seq_file *m, void *n)
@@ -362,7 +362,7 @@ static const char *ll_eopcode2str(u32 opcode)
 	return count;
 }
 
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_buffers_max);
+LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_req_buffers_max);
 
 static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr,
 				char *buf)
@@ -753,7 +753,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
 	return rc < 0 ? rc : count;
 }
 
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs);
+LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs);
 
 /** @} nrs */
 
@@ -1050,7 +1050,7 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts);
+LDEBUGFS_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts);
 
 static ssize_t high_priority_ratio_show(struct kobject *kobj,
 					struct attribute *attr,
@@ -1133,7 +1133,7 @@ int ptlrpc_sysfs_register_service(struct kset *parent,
 void ptlrpc_ldebugfs_register_service(struct dentry *entry,
 				      struct ptlrpc_service *svc)
 {
-	struct lprocfs_vars lproc_vars[] = {
+	struct ldebugfs_vars lproc_vars[] = {
 		{ .name		= "req_buffer_history_len",
 		  .fops		= &ptlrpc_lprocfs_req_history_len_fops,
 		  .data		= svc },
@@ -1284,8 +1284,9 @@ ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
  * The connection UUID is a node's primary NID. For example,
  * "echo connection=192.168.0.1@tcp0::instance > .../import".
  */
-int lprocfs_wr_import(struct file *file, const char __user *buffer,
-		      size_t count, loff_t *off)
+ssize_t
+ldebugfs_import_seq_write(struct file *file, const char __user *buffer,
+			  size_t count, loff_t *off)
 {
 	struct seq_file *m = file->private_data;
 	struct obd_device *obd = m->private;
@@ -1352,9 +1353,9 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
 	kfree(kbuf);
 	return rc ?: count;
 }
-EXPORT_SYMBOL(lprocfs_wr_import);
+EXPORT_SYMBOL(ldebugfs_import_seq_write);
 
-int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
+int ldebugfs_pinger_recov_seq_show(struct seq_file *m, void *n)
 {
 	struct obd_device *obd = m->private;
 	struct obd_import *imp = obd->u.cli.cl_import;
@@ -1365,10 +1366,11 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
 
 	return rc;
 }
-EXPORT_SYMBOL(lprocfs_rd_pinger_recov);
+EXPORT_SYMBOL(ldebugfs_pinger_recov_seq_show);
 
-int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
-			    size_t count, loff_t *off)
+ssize_t
+ldebugfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
+				size_t count, loff_t *off)
 {
 	struct seq_file *m = file->private_data;
 	struct obd_device *obd = m->private;
@@ -1388,4 +1390,4 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
 
 	return rc ?: count;
 }
-EXPORT_SYMBOL(lprocfs_wr_pinger_recov);
+EXPORT_SYMBOL(ldebugfs_pinger_recov_seq_write);
fs/lustre/ptlrpc/sec_lproc.c +8 -7
index b34ced4..94f77350 100644
@@ -104,7 +104,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(sptlrpc_info_lprocfs);
+LDEBUGFS_SEQ_FOPS_RO(sptlrpc_info_lprocfs);
 
 static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
 {
@@ -129,7 +129,7 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
 	return 0;
 }
 
-LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
+LDEBUGFS_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
 
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
 static ssize_t sepol_seq_write_old(struct obd_device *obd,
@@ -212,8 +212,8 @@ static ssize_t sepol_seq_write_old(struct obd_device *obd,
 #endif
 
 static ssize_t
-lprocfs_wr_sptlrpc_sepol(struct file *file, const char __user *buffer,
-			 size_t count, void *data)
+ldebugfs_sptlrpc_sepol_seq_write(struct file *file, const char __user *buffer,
+				 size_t count, void *data)
 {
 	struct seq_file	*seq = file->private_data;
 	struct obd_device *obd = seq->private;
@@ -309,7 +309,7 @@ static ssize_t sepol_seq_write_old(struct obd_device *obd,
 
 	return rc ? rc : count;
 }
-LPROC_SEQ_FOPS_WR_ONLY(srpc, sptlrpc_sepol);
+LDEBUGFS_SEQ_FOPS_WR_ONLY(srpc, sptlrpc_sepol);
 
 int sptlrpc_lprocfs_cliobd_attach(struct obd_device *obd)
 {
@@ -332,8 +332,9 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *obd)
 }
 EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach);
 
-LPROC_SEQ_FOPS_RO(sptlrpc_proc_enc_pool);
-static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
+LDEBUGFS_SEQ_FOPS_RO(sptlrpc_proc_enc_pool);
+
+static struct ldebugfs_vars sptlrpc_lprocfs_vars[] = {
 	{ "encrypt_page_pools", &sptlrpc_proc_enc_pool_fops },
 	{ NULL }
 };
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/23 lustre: sec: atomicity of encryption context getting/setting

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

Encryption layer needs to set an encryption context on files and dirs that are encrypted. This context is stored as an extended attribute, that then needs to be fetched upon metadata ops like lookup, getattr, open, truncate, and layout.

With this patch we send encryption context to the MDT along with create RPCs. This closes the insecure window between creation and setting of the encryption context, and saves a setxattr request.

This patch also introduces a way to have the MDT return encryption context upon granted lock reply, making the encryption context retrieval atomic, and sparing the client an additional getxattr request.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12275
Lustre-commit: 40d91eafe257f ("LU-12275 sec: atomicity of encryption context getting/setting")

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

---
 fs/lustre/include/lustre_crypto.h      |   2 +
 fs/lustre/include/lustre_export.h      |   5 ++
 fs/lustre/include/lustre_req_layout.h  |   3 +-
 fs/lustre/include/obd.h                |   4 ++
 fs/lustre/llite/crypto.c               |  75 ++++++++++++++++--------
 fs/lustre/llite/dir.c                  |  16 +++--
 fs/lustre/llite/llite_internal.h       |   5 ++
 fs/lustre/llite/llite_lib.c            |   1 +
 fs/lustre/llite/namei.c                | 104 ++++++++++++++++++++++++++++-----
 fs/lustre/llite/xattr_cache.c          |  34 +++++++++++
 fs/lustre/mdc/mdc_internal.h           |   2 +
 fs/lustre/mdc/mdc_lib.c                |  23 ++++++++
 fs/lustre/mdc/mdc_locks.c              |  22 +++++++
 fs/lustre/mdc/mdc_reint.c              |   3 +
 fs/lustre/mdc/mdc_request.c            |   4 +-
 fs/lustre/ptlrpc/layout.c              |  25 +++++---
 fs/lustre/ptlrpc/wiretest.c            |   2 +
 include/uapi/linux/lustre/lustre_idl.h |   3 +-
 18 files changed, 279 insertions(+), 54 deletions(-)
fs/lustre/include/lustre_crypto.h +2 -0
index e9091a2..b80147f 100644
@@ -31,6 +31,8 @@
 #define _LUSTRE_CRYPTO_H_
 
 struct ll_sb_info;
+int ll_set_encflags(struct inode *inode, void *encctx, u32 encctxlen,
+		    bool preload);
 bool ll_sbi_has_test_dummy_encryption(struct ll_sb_info *sbi);
 bool ll_sbi_has_encrypt(struct ll_sb_info *sbi);
 void ll_sbi_set_encrypt(struct ll_sb_info *sbi, bool set);
fs/lustre/include/lustre_export.h +5 -0
index b77605b..b5fdf8a 100644
@@ -280,6 +280,11 @@ static inline int exp_connect_archive_id_array(struct obd_export *exp)
 	return !!(exp_connect_flags2(exp) & OBD_CONNECT2_ARCHIVE_ID_ARRAY);
 }
 
+static inline int exp_connect_encrypt(struct obd_export *exp)
+{
+	return !!(exp_connect_flags2(exp) & OBD_CONNECT2_ENCRYPT);
+}
+
 enum {
 	/* archive_ids in array format */
 	KKUC_CT_DATA_ARRAY_MAGIC	= 0x092013cea,
fs/lustre/include/lustre_req_layout.h +2 -1
index 72d9df0..54041b0 100644
@@ -60,7 +60,7 @@ enum req_location {
 };
 
 /* Maximal number of fields (buffers) in a request message. */
-#define REQ_MAX_FIELD_NR 11
+#define REQ_MAX_FIELD_NR 12
 
 struct req_capsule {
 	struct ptlrpc_request		*rc_req;
@@ -243,6 +243,7 @@ void req_capsule_shrink(struct req_capsule *pill,
 extern struct req_msg_field RMF_FILE_SECCTX_NAME;
 extern struct req_msg_field RMF_FILE_SECCTX;
 extern struct req_msg_field RMF_FID_ARRAY;
+extern struct req_msg_field RMF_FILE_ENCCTX;
 
 /*
  * connection handle received in MDS_CONNECT request.
fs/lustre/include/obd.h +4 -0
index 849483f..cd3abfd 100644
@@ -784,6 +784,10 @@ struct md_op_data {
 	void		       *op_file_secctx;
 	u32			op_file_secctx_size;
 
+	/* File encryption context, for creates/metadata ops */
+	void		       *op_file_encctx;
+	u32			op_file_encctx_size;
+
 	u32			op_projid;
 
 	u16			op_mirror_id;
fs/lustre/llite/crypto.c +50 -25

100 lines not on this page · raw message

fs/lustre/llite/dir.c +12 -4
index e3305f7..c2a75ce 100644
@@ -448,8 +448,9 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
 	if (IS_ERR(op_data))
 		return PTR_ERR(op_data);
 
-	if (IS_ENCRYPTED(parent) ||
-	    unlikely(llcrypt_dummy_context_enabled(parent))) {
+	if (ll_sbi_has_encrypt(sbi) &&
+	    (IS_ENCRYPTED(parent) ||
+	     unlikely(llcrypt_dummy_context_enabled(parent)))) {
 		err = llcrypt_get_encryption_info(parent);
 		if (err)
 			goto out_op_data;
@@ -474,6 +475,13 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
 			goto out_op_data;
 	}
 
+	if (encrypt) {
+		err = llcrypt_inherit_context(parent, NULL, op_data, false);
+		if (err)
+			goto out_op_data;
+	}
+
+
 	op_data->op_cli_flags |= CLI_SET_MEA;
 	err = md_create(sbi->ll_md_exp, op_data, lump, len, mode,
 			from_kuid(&init_user_ns, current_fsuid()),
@@ -501,8 +509,8 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
 	}
 
 	if (encrypt)
-		err = llcrypt_inherit_context(parent, inode, NULL, false);
-
+		err = ll_set_encflags(inode, op_data->op_file_encctx,
+				      op_data->op_file_encctx_size, false);
 out_inode:
 	iput(inode);
 out_request:
fs/lustre/llite/llite_internal.h +5 -0
index 31c528f..89783fb 100644
@@ -402,6 +402,11 @@ static inline void ll_layout_version_set(struct ll_inode_info *lli, u32 gen)
 int ll_xattr_cache_get(struct inode *inode, const char *name,
 		       char *buffer, size_t size, u64 valid);
 
+int ll_xattr_cache_insert(struct inode *inode,
+			  const char *name,
+			  char *buffer,
+			  size_t size);
+
 static inline bool obd_connect_has_secctx(struct obd_connect_data *data)
 {
 #ifdef CONFIG_SECURITY
fs/lustre/llite/llite_lib.c +1 -0
index f52d2b5..4773fc1 100644
@@ -2873,6 +2873,7 @@ void ll_finish_md_op_data(struct md_op_data *op_data)
 	ll_unlock_md_op_lsm(op_data);
 	security_release_secctx(op_data->op_file_secctx,
 				op_data->op_file_secctx_size);
+	kfree(op_data->op_file_encctx);
 	kfree(op_data);
 }
 
fs/lustre/llite/namei.c +90 -14

214 lines not on this page · raw message

fs/lustre/llite/xattr_cache.c +34 -0
index c642444..fee1cf5 100644
@@ -502,3 +502,37 @@ int ll_xattr_cache_get(struct inode *inode, const char *name, char *buffer,
 
 	return rc;
 }
+
+/**
+ * Insert an xattr value into the cache.
+ *
+ * Add @name xattr with @buffer value and @size length for @inode.
+ * Init cache for @inode if necessary.
+ *
+ * Return:	0 success
+ *		< 0 from ll_xattr_cache_add(), except -EPROTO is ignored for
+ *		LL_XATTR_NAME_ENCRYPTION_CONTEXT xattr
+ */
+int ll_xattr_cache_insert(struct inode *inode,
+			  const char *name,
+			  char *buffer,
+			  size_t size)
+{
+	struct ll_inode_info *lli = ll_i2info(inode);
+	int rc;
+
+	down_read(&lli->lli_xattrs_list_rwsem);
+	if (!ll_xattr_cache_valid(lli))
+		ll_xattr_cache_init(lli);
+	rc = ll_xattr_cache_add(&lli->lli_xattrs, name, buffer,
+				size);
+	up_read(&lli->lli_xattrs_list_rwsem);
+
+	if (rc == -EPROTO &&
+	    strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0)
+		/* it means enc ctx was already in cache,
+		 * ignore error as it cannot be modified
+		 */
+		rc = 0;
+	return rc;
+}
fs/lustre/mdc/mdc_internal.h +2 -0
index a1fb5d9..065cba5 100644
@@ -57,6 +57,8 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 void mdc_file_secctx_pack(struct ptlrpc_request *req,
 			  const char *secctx_name,
 			  const void *secctx, size_t secctx_size);
+void mdc_file_encctx_pack(struct ptlrpc_request *req,
+			  const void *encctx, size_t encctx_size);
 void mdc_file_sepol_pack(struct ptlrpc_request *req);
 
 void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data);
fs/lustre/mdc/mdc_lib.c +23 -0
index be77944b..6cb14c1 100644
@@ -138,6 +138,23 @@ void mdc_file_secctx_pack(struct ptlrpc_request *req, const char *secctx_name,
 	memcpy(buf, secctx, buf_size);
 }
 
+void mdc_file_encctx_pack(struct ptlrpc_request *req,
+			  const void *encctx, size_t encctx_size)
+{
+	void *buf;
+	size_t buf_size;
+
+	if (!encctx)
+		return;
+
+	buf = req_capsule_client_get(&req->rq_pill, &RMF_FILE_ENCCTX);
+	buf_size = req_capsule_get_size(&req->rq_pill, &RMF_FILE_ENCCTX,
+					RCL_CLIENT);
+
+	LASSERT(buf_size == encctx_size);
+	memcpy(buf, encctx, buf_size);
+}
+
 void mdc_file_sepol_pack(struct ptlrpc_request *req)
 {
 	void *buf;
@@ -209,6 +226,9 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 			     op_data->op_file_secctx,
 			     op_data->op_file_secctx_size);
 
+	mdc_file_encctx_pack(req, op_data->op_file_encctx,
+			     op_data->op_file_encctx_size);
+
 	/* pack SELinux policy info if any */
 	mdc_file_sepol_pack(req);
 }
@@ -286,6 +306,9 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 				     op_data->op_file_secctx,
 				     op_data->op_file_secctx_size);
 
+		mdc_file_encctx_pack(req, op_data->op_file_encctx,
+				     op_data->op_file_encctx_size);
+
 		/* pack SELinux policy info if any */
 		mdc_file_sepol_pack(req);
 	}
fs/lustre/mdc/mdc_locks.c +22 -0
index 402e6e0..ea78415 100644
@@ -324,6 +324,9 @@ static int mdc_save_lovea(struct ptlrpc_request *req,
 	req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX, RCL_CLIENT,
 			     op_data->op_file_secctx_size);
 
+	req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, RCL_CLIENT,
+			     op_data->op_file_encctx_size);
+
 	/* get SELinux policy info if any */
 	rc = sptlrpc_get_sepol(req);
 	if (rc < 0) {
@@ -380,6 +383,15 @@ static int mdc_save_lovea(struct ptlrpc_request *req,
 				     RCL_SERVER, 0);
 	}
 
+	if (exp_connect_encrypt(exp) && !(it->it_op & IT_CREAT) &&
+	    it->it_op & IT_OPEN)
+		req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX,
+				     RCL_SERVER,
+				     obd->u.cli.cl_max_mds_easize);
+	else
+		req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX,
+				     RCL_SERVER, 0);
+
 	/**
 	 * Inline buffer for possible data from Data-on-MDT files.
 	 */
@@ -459,6 +471,9 @@ static int mdc_save_lovea(struct ptlrpc_request *req,
 	/* pack the intent */
 	lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
 	lit->opc = IT_GETXATTR;
+	/* Message below is checked in sanity-selinux test_20d
+	 * and sanity-sec test_49
+	 */
 	CDEBUG(D_INFO, "%s: get xattrs for " DFID "\n",
 	       exp->exp_obd->obd_name, PFID(&op_data->op_fid1));
 
@@ -571,6 +586,13 @@ static int mdc_save_lovea(struct ptlrpc_request *req,
 				     RCL_SERVER, 0);
 	}
 
+	if (exp_connect_encrypt(exp) && it->it_op & (IT_LOOKUP | IT_GETATTR))
+		req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX,
+				     RCL_SERVER, easize);
+	else
+		req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX,
+				     RCL_SERVER, 0);
+
 	ptlrpc_request_set_replen(req);
 	return req;
 }
fs/lustre/mdc/mdc_reint.c +3 -0
index cc09374..9e566e7 100644
@@ -205,6 +205,9 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data,
 	req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX, RCL_CLIENT,
 			     op_data->op_file_secctx_size);
 
+	req_capsule_set_size(&req->rq_pill, &RMF_FILE_ENCCTX, RCL_CLIENT,
+			     op_data->op_file_encctx_size);
+
 	/* get SELinux policy info if any */
 	rc = sptlrpc_get_sepol(req);
 	if (rc < 0) {
fs/lustre/mdc/mdc_request.c +3 -1
index f2bca8e..40670cb 100644
@@ -452,7 +452,9 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
 	LASSERT(obd_md_valid == OBD_MD_FLXATTR ||
 		obd_md_valid == OBD_MD_FLXATTRLS);
 
-	/* The below message is checked in sanity-selinux.sh test_20d */
+	/* Message below is checked in sanity-selinux test_20d
+	 * and sanity-sec test_49
+	 */
 	CDEBUG(D_INFO, "%s: get xattr '%s' for " DFID "\n",
 	       exp->exp_obd->obd_name, name, PFID(fid));
 	rc = mdc_xattr_common(exp, &RQF_MDS_GETXATTR, fid, MDS_GETXATTR,
fs/lustre/ptlrpc/layout.c +18 -7
index 1286547..4e37bbb 100644
@@ -189,7 +189,8 @@
 	&RMF_DLM_REQ,
 	&RMF_FILE_SECCTX_NAME,
 	&RMF_FILE_SECCTX,
-	&RMF_SELINUX_POL
+	&RMF_SELINUX_POL,
+	&RMF_FILE_ENCCTX,
 };
 
 static const struct req_msg_field *mds_reint_create_sym_client[] = {
@@ -201,7 +202,8 @@
 	&RMF_DLM_REQ,
 	&RMF_FILE_SECCTX_NAME,
 	&RMF_FILE_SECCTX,
-	&RMF_SELINUX_POL
+	&RMF_SELINUX_POL,
+	&RMF_FILE_ENCCTX,
 };
 
 static const struct req_msg_field *mds_reint_open_client[] = {
@@ -213,7 +215,8 @@
 	&RMF_EADATA,
 	&RMF_FILE_SECCTX_NAME,
 	&RMF_FILE_SECCTX,
-	&RMF_SELINUX_POL
+	&RMF_SELINUX_POL,
+	&RMF_FILE_ENCCTX,
 };
 
 static const struct req_msg_field *mds_reint_open_server[] = {
@@ -443,7 +446,8 @@
 	&RMF_CAPA1,
 	&RMF_CAPA2,
 	&RMF_NIOBUF_INLINE,
-	&RMF_FILE_SECCTX
+	&RMF_FILE_SECCTX,
+	&RMF_FILE_ENCCTX,
 };
 
 static const struct req_msg_field *ldlm_intent_getattr_client[] = {
@@ -464,7 +468,8 @@
 	&RMF_ACL,
 	&RMF_CAPA1,
 	&RMF_FILE_SECCTX,
-	&RMF_DEFAULT_MDT_MD
+	&RMF_DEFAULT_MDT_MD,
+	&RMF_FILE_ENCCTX,
 };
 
 static const struct req_msg_field *ldlm_intent_create_client[] = {
@@ -477,7 +482,8 @@
 	&RMF_EADATA,
 	&RMF_FILE_SECCTX_NAME,
 	&RMF_FILE_SECCTX,
-	&RMF_SELINUX_POL
+	&RMF_SELINUX_POL,
+	&RMF_FILE_ENCCTX,
 };
 
 static const struct req_msg_field *ldlm_intent_open_client[] = {
@@ -491,7 +497,8 @@
 	&RMF_EADATA,
 	&RMF_FILE_SECCTX_NAME,
 	&RMF_FILE_SECCTX,
-	&RMF_SELINUX_POL
+	&RMF_SELINUX_POL,
+	&RMF_FILE_ENCCTX,
 };
 
 static const struct req_msg_field *ldlm_intent_getxattr_client[] = {
@@ -987,6 +994,10 @@ struct req_msg_field RMF_FILE_SECCTX =
 	DEFINE_MSGF("file_secctx", RMF_F_NO_SIZE_CHECK, -1, NULL, NULL);
 EXPORT_SYMBOL(RMF_FILE_SECCTX);
 
+struct req_msg_field RMF_FILE_ENCCTX =
+	DEFINE_MSGF("file_encctx", RMF_F_NO_SIZE_CHECK, -1, NULL, NULL);
+EXPORT_SYMBOL(RMF_FILE_ENCCTX);
+
 struct req_msg_field RMF_LLOGD_BODY =
 	DEFINE_MSGF("llogd_body", 0,
 		    sizeof(struct llogd_body), lustre_swab_llogd_body, NULL);
fs/lustre/ptlrpc/wiretest.c +2 -0
index 74a4e940..d1dff09 100644
@@ -1497,6 +1497,8 @@ void lustre_assert_wire_constants(void)
 		 OBD_MD_FLLAZYSIZE);
 	LASSERTF(OBD_MD_FLLAZYBLOCKS == (0x0800000000000000ULL), "found 0x%.16llxULL\n",
 		 OBD_MD_FLLAZYBLOCKS);
+	LASSERTF(OBD_MD_ENCCTX == (0x2000000000000000ULL), "found 0x%.16llxULL\n",
+		 OBD_MD_ENCCTX);
 	BUILD_BUG_ON(OBD_FL_INLINEDATA != 0x00000001);
 	BUILD_BUG_ON(OBD_FL_OBDMDEXISTS != 0x00000002);
 	BUILD_BUG_ON(OBD_FL_DELORPHAN != 0x00000004);
include/uapi/linux/lustre/lustre_idl.h +1 -2
index d4df989..fdeb2a3 100644
@@ -1229,11 +1229,10 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
 #define OBD_MD_FLOSTLAYOUT	(0x0080000000000000ULL)	/* contain ost_layout */
 #define OBD_MD_FLPROJID		(0x0100000000000000ULL) /* project ID */
 #define OBD_MD_SECCTX        (0x0200000000000000ULL) /* embed security xattr */
-
 #define OBD_MD_FLLAZYSIZE    (0x0400000000000000ULL) /* Lazy size */
 #define OBD_MD_FLLAZYBLOCKS  (0x0800000000000000ULL) /* Lazy blocks */
-
 #define OBD_MD_FLBTIME		(0x1000000000000000ULL) /* birth time */
+#define OBD_MD_ENCCTX	     (0x2000000000000000ULL) /* embed encryption ctx */
 
 #define OBD_MD_FLALLQUOTA (OBD_MD_FLUSRQUOTA | \
 			   OBD_MD_FLGRPQUOTA | \
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 8/23 lustre: sec: encryption support for DoM files

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

On client side, data read from DoM files do not go through the OSC layer. So implement file decryption in ll_dom_finish_open() right after file data has been put in cache pages.
On server side, DoM file size needs to be properly set on MDT when content is encrypted. Pages are full of encrypted data, but inode size must be apparent, clear text object size.
For reads of DoM encrypted files to work proprely, we also need to make sure we send whole encryption units to client side. Also add sanity-sec test_50 to exercise encryption of DoM files.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12275
Lustre-commit: a71586d4ee8d6 ("LU-12275 sec: encryption support for DoM files")

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

---
 fs/lustre/llite/crypto.c | 10 +++-------
 fs/lustre/llite/file.c   | 20 +++++++++++++++++--
 fs/lustre/llite/namei.c  | 52 ++++++++++++++++++++++++++++--------------------
 3 files changed, 51 insertions(+), 31 deletions(-)
fs/lustre/llite/crypto.c +3 -7
index 83ed316..d37f0a9 100644
@@ -31,17 +31,13 @@
 
 static int ll_get_context(struct inode *inode, void *ctx, size_t len)
 {
-	struct dentry *dentry;
+	struct dentry *dentry = d_find_any_alias(inode);
 	int rc;
 
-	if (hlist_empty(&inode->i_dentry))
-		return -ENODATA;
-
-	hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias)
-		break;
-
 	rc = __vfs_getxattr(dentry, inode, LL_XATTR_NAME_ENCRYPTION_CONTEXT,
 			    ctx, len);
+	if (dentry)
+		dput(dentry);
 
 	/* used as encryption unit size */
 	if (S_ISREG(inode->i_mode))
fs/lustre/llite/file.c +18 -2
index 757950f..7d00728 100644
@@ -429,8 +429,10 @@ int ll_file_release(struct inode *inode, struct file *file)
 
 static inline int ll_dom_readpage(void *data, struct page *page)
 {
+	struct inode *inode = page2inode(page);
 	struct niobuf_local *lnb = data;
 	void *kaddr;
+	int rc = 0;
 
 	kaddr = kmap_atomic(page);
 	memcpy(kaddr, lnb->lnb_data, lnb->lnb_len);
@@ -440,9 +442,22 @@ static inline int ll_dom_readpage(void *data, struct page *page)
 	flush_dcache_page(page);
 	SetPageUptodate(page);
 	kunmap_atomic(kaddr);
+
+	if (inode && IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) {
+		if (!llcrypt_has_encryption_key(inode))
+			CDEBUG(D_SEC, "no enc key for " DFID "\n",
+			       PFID(ll_inode2fid(inode)));
+		/* decrypt only if page is not empty */
+		else if (memcmp(page_address(page),
+				page_address(ZERO_PAGE(0)),
+				PAGE_SIZE) != 0)
+			rc = llcrypt_decrypt_pagecache_blocks(page,
+							      PAGE_SIZE,
+							      0);
+	}
 	unlock_page(page);
 
-	return 0;
+	return rc;
 }
 
 void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req,
@@ -481,7 +496,8 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req,
 	 * buffer, in both cases total size should be equal to the file size.
 	 */
 	body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
-	if (rnb->rnb_offset + rnb->rnb_len != body->mbo_dom_size) {
+	if (rnb->rnb_offset + rnb->rnb_len != body->mbo_dom_size &&
+	    !(inode && IS_ENCRYPTED(inode))) {
 		CERROR("%s: server returns off/len %llu/%u but size %llu\n",
 		       ll_i2sbi(inode)->ll_fsname, rnb->rnb_offset,
 		       rnb->rnb_len, body->mbo_dom_size);
fs/lustre/llite/namei.c +30 -22

64 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 9/23 lustre: sec: check if page is empty with ZERO_PAGE

In reply to James Simmons

From: Sebastien Buisson <[email protected]>

In osc_brw_fini_request(), page needs decryption only if it is not empty. To check this, use ZERO_PAGE macro available for all architectures, and compare with memcmp.
It will likely be faster/more efficient than comparing the words by hand as may use optimized CPU instructions or ASM code.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12275
Lustre-commit: 45c26bc11b7b1e ("LU-12275 sec: check if page is empty with ZERO_PAGE")

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

---
 fs/lustre/osc/osc_request.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
fs/lustre/osc/osc_request.c +3 -8
index 1968d62..3bbe3d9 100644
@@ -2075,16 +2075,11 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
 		}
 		for (idx = 0; idx < aa->aa_page_count; idx++) {
 			struct brw_page *pg = aa->aa_ppga[idx];
-			u64 *p, *q;
 
 			/* do not decrypt if page is all 0s */
-			p = q = page_address(pg->pg);
-			while (p - q < PAGE_SIZE / sizeof(*p)) {
-				if (*p != 0)
-					break;
-				p++;
-			}
-			if (p - q == PAGE_SIZE / sizeof(*p)) {
+			if (memcmp(page_address(pg->pg),
+				   page_address(ZERO_PAGE(0)),
+				   PAGE_SIZE) == 0) {
 				/* if page is empty forward info to upper layers
 				 * (ll_io_zero_page) by clearing PagePrivate2
 				 */
Signature · 1 line
1.8.3.1
#10 lore raw

PATCH 10/23 lustre: uapi: add OBD_CONNECT2_GETATTR_PFID

In reply to James Simmons

From: Lai Siyao <[email protected]>

Add OBD_CONNECT2_GETATTR_PFID connect flag to pack parent FID in getattr request, which will be used to check whether target is remote object, if so, don't take LOOKUP lock, otherwise client may see stale directory entries.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13437
Lustre-commit: f384a8733c41e4 ("LU-13437 uapi: add OBD_CONNECT2_GETATTR_PFID")

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

---
 fs/lustre/obdclass/lprocfs_status.c    | 2 ++
 fs/lustre/ptlrpc/wiretest.c            | 4 +++-
 include/uapi/linux/lustre/lustre_idl.h | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
fs/lustre/obdclass/lprocfs_status.c +2 -0
index 3d16516..a3c5657 100644
@@ -127,6 +127,8 @@
 	"crush",		/* 0x2000 */
 	"async_discard",	/* 0x4000 */
 	"client_encryption",	/* 0x8000 */
+	"fidmap",		/* 0x10000 */
+	"getattr_pfid",		/* 0x20000 */
 	NULL
 };
 
fs/lustre/ptlrpc/wiretest.c +3 -1
index d1dff09..556aaff 100644
@@ -1241,8 +1241,10 @@ void lustre_assert_wire_constants(void)
 		 OBD_CONNECT2_ASYNC_DISCARD);
 	LASSERTF(OBD_CONNECT2_ENCRYPT == 0x8000ULL, "found 0x%.16llxULL\n",
 		 OBD_CONNECT2_ENCRYPT);
-	LASSERTF(OBD_CONNECT2_FIDMAP== 0x10000ULL, "found 0x%.16llxULL\n",
+	LASSERTF(OBD_CONNECT2_FIDMAP == 0x10000ULL, "found 0x%.16llxULL\n",
 		 OBD_CONNECT2_FIDMAP);
+	LASSERTF(OBD_CONNECT2_GETATTR_PFID == 0x20000ULL, "found 0x%.16llxULL\n",
+		 OBD_CONNECT2_GETATTR_PFID);
 	LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n",
 		 (unsigned int)OBD_CKSUM_CRC32);
 	LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n",
include/uapi/linux/lustre/lustre_idl.h +1 -0
index fdeb2a3..2cdc230 100644
@@ -837,6 +837,7 @@ struct ptlrpc_body_v2 {
 						  */
 #define OBD_CONNECT2_ENCRYPT	       0x8000ULL /* client-to-disk encrypt */
 #define OBD_CONNECT2_FIDMAP	      0x10000ULL /* FID map */
+#define OBD_CONNECT2_GETATTR_PFID     0x20000ULL /* pack parent FID in getattr */
 /* XXX README XXX:
  * Please DO NOT add flag values here before first ensuring that this same
  * flag value is not in use on some other branch.  Please clear any such
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 11/23 lustre: update version to 2.13.55

In reply to James Simmons

From: Oleg Drokin <[email protected]>

New tag 2.13.55

---
 include/uapi/linux/lustre/lustre_ver.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/lustre/lustre_ver.h +2 -2
index b862cf6..f206b6c 100644
@@ -3,9 +3,9 @@
 
 #define LUSTRE_MAJOR 2
 #define LUSTRE_MINOR 13
-#define LUSTRE_PATCH 54
+#define LUSTRE_PATCH 55
 #define LUSTRE_FIX 0
-#define LUSTRE_VERSION_STRING "2.13.54"
+#define LUSTRE_VERSION_STRING "2.13.55"
 
 #define OBD_OCD_VERSION(major, minor, patch, fix)			\
 	(((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix))
Signature · 1 line
1.8.3.1
#12 lore raw

PATCH 12/23 lustre: sysfs: error-check value stored in jobid_var

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

The jobid_var sysfs attribute only has 3 meaningful values. Other values cause lustre_get_jobid() to return an error which is uniformly ignored.

To improve usability and resilience, check that the value written is acceptable before storing it.

---
 fs/lustre/obdclass/obd_sysfs.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
fs/lustre/obdclass/obd_sysfs.c +16 -6
index cb2f0a9..5fc638f 100644
@@ -225,16 +225,26 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
 			       const char *buffer,
 			       size_t count)
 {
+	static const char * const valid[] = {
+		JOBSTATS_DISABLE,
+		JOBSTATS_PROCNAME_UID,
+		JOBSTATS_NODELOCAL,
+		JOBSTATS_SESSION,
+		NULL
+	};
+	int i;
+
 	if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
 		return -EINVAL;
 
-	memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1);
-
-	memcpy(obd_jobid_var, buffer, count);
+	for (i = 0; valid[i]; i++)
+		if (sysfs_streq(buffer, valid[i]))
+			break;
+	if (!valid[i])
+		return -EINVAL;
 
-	/* Trim the trailing '\n' if any */
-	if (obd_jobid_var[count - 1] == '\n')
-		obd_jobid_var[count - 1] = 0;
+	memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1);
+	strcpy(obd_jobid_var, valid[i]);
 
 	return count;
 }
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH 13/23 lnet: Add param to control response tracking

In reply to James Simmons

From: Chris Horn <[email protected]>

Add lnet_response_tracking parameter which will be used to control the behavior of LNet response tracking.

HPE-bug-id: LUS-8827
WC-bug-id: https://jira.whamcloud.com/browse/LU-13502
Lustre-commit: 5b3747294a4bf ("LU-13502 lnet: Add param to control response tracking")

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

---
 include/linux/lnet/lib-lnet.h |  1 +
 net/lnet/lnet/api-ni.c        | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
include/linux/lnet/lib-lnet.h +1 -0
index b069422..e733807 100644
@@ -417,6 +417,7 @@ struct lnet_ni *
 struct lnet_ni *lnet_net2ni_addref(u32 net);
 struct lnet_net *lnet_get_net_locked(u32 net_id);
 
+extern unsigned int lnet_response_tracking;
 extern unsigned int lnet_transaction_timeout;
 extern unsigned int lnet_retry_count;
 extern unsigned int lnet_lnd_timeout;
net/lnet/lnet/api-ni.c +37 -0
index 5f35468..c90ab2e 100644
@@ -170,6 +170,20 @@ static int recovery_interval_set(const char *val,
 MODULE_PARM_DESC(lnet_retry_count,
 		 "Maximum number of times to retry transmitting a message");
 
+unsigned int lnet_response_tracking = 3;
+static int response_tracking_set(const char *val,
+				 const struct kernel_param *kp);
+static struct kernel_param_ops param_ops_response_tracking = {
+	.set = response_tracking_set,
+	.get = param_get_int,
+};
+
+#define param_check_response_tracking(name, p)  \
+		__param_check(name, p, int)
+module_param(lnet_response_tracking, response_tracking, 0644);
+MODULE_PARM_DESC(lnet_response_tracking,
+		 "(0|1|2|3) LNet Internal Only|GET Reply only|PUT ACK only|Full Tracking (default)");
+
 #define LNET_LND_TIMEOUT_DEFAULT ((LNET_TRANSACTION_TIMEOUT_HEALTH_DEFAULT - 1) / \
 				  (LNET_RETRY_COUNT_HEALTH_DEFAULT + 1))
 unsigned int lnet_lnd_timeout = LNET_LND_TIMEOUT_DEFAULT;
@@ -470,6 +484,29 @@ static int lnet_discover(struct lnet_process_id id, u32 force,
 	return 0;
 }
 
+static int
+response_tracking_set(const char *val, const struct kernel_param *kp)
+{
+	int rc;
+	unsigned long new_value;
+
+	rc = kstrtoul(val, 0, &new_value);
+	if (rc) {
+		CERROR("Invalid value for 'lnet_response_tracking'\n");
+		return -EINVAL;
+	}
+
+	if (new_value < 0 || new_value > 3) {
+		CWARN("Invalid value (%lu) for 'lnet_response_tracking'\n",
+		      new_value);
+		return -EINVAL;
+	}
+
+	lnet_response_tracking = new_value;
+
+	return 0;
+}
+
 static const char *
 lnet_get_routes(void)
 {
Signature · 1 line
1.8.3.1
#14 lore raw

PATCH 14/23 lnet: Ensure LNet pings and pushes are always tracked

In reply to James Simmons

From: Chris Horn <[email protected]>

Add the appropriate option to the MD used for LNet pings and pushes to ensure that these are always tracked via LNet's response tracking mechanism, regardless of the value of lnet_response_tracking variable.

HPE-bug-id: LUS-8827
WC-bug-id: https://jira.whamcloud.com/browse/LU-13502
Lustre-commit: 9ed12d2e8f3f2 ("LU-13502 lnet: Ensure LNet pings and pushes are always tracked")

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

---
 net/lnet/lnet/lib-move.c | 2 +-
 net/lnet/lnet/peer.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
net/lnet/lnet/lib-move.c +1 -1
index c0dd30c..aa6fe37 100644
@@ -3340,7 +3340,7 @@ struct lnet_mt_event_info {
 	md.length = LNET_PING_INFO_SIZE(nnis);
 	md.threshold = 2; /* GET/REPLY */
 	md.max_size = 0;
-	md.options = LNET_MD_TRUNCATE;
+	md.options = LNET_MD_TRUNCATE | LNET_MD_TRACK_RESPONSE;
 	md.user_ptr = user_data;
 	md.handler = handler;
 
net/lnet/lnet/peer.c +1 -1
index f745394..578591d 100644
@@ -3097,7 +3097,7 @@ static int lnet_peer_send_push(struct lnet_peer *lp)
 	md.length = LNET_PING_INFO_SIZE(pbuf->pb_nnis);
 	md.threshold = 2; /* Put/Ack */
 	md.max_size = 0;
-	md.options = 0;
+	md.options = LNET_MD_TRACK_RESPONSE;
 	md.handler = the_lnet.ln_dc_handler;
 	md.user_ptr = lp;
 
Signature · 1 line
1.8.3.1
#15 lore raw

PATCH 15/23 lnet: Preferred NI logic breaks MR routing

In reply to James Simmons

From: Chris Horn <[email protected]>

Edge (final-hop) routers typically use the non-multi-rail destination (NMR_DST) send case. i.e. they treat the destination as non-multi-rail. The reason for this is that we do not want routers to modify the destination peer interface selected by the message originator. As a result of using the NMR_DST send case, edge routers set a preferred NI, and then continue to use that NI, because it's preferred, even if the NI goes down and the router has other healthy interfaces available to it. Routers do not need to use the preferred NI selection logic when they are forwarding a message, so modify the NMR_DST algorithm to allow routers to select any suitable local NI.

HPE-bug-id: LUS-9045
WC-bug-id: https://jira.whamcloud.com/browse/LU-13712
Lustre-commit: ef6c35877b96c ("LU-13712 lnet: Preferred NI logic breaks MR routing")

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

---
 net/lnet/lnet/lib-move.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
net/lnet/lnet/lib-move.c +18 -2
index aa6fe37..7c14518 100644
@@ -2107,7 +2107,7 @@ struct lnet_ni *
 static int
 lnet_handle_any_local_nmr_dst(struct lnet_send_data *sd)
 {
-	int rc;
+	int rc = 0;
 
 	/* sd->sd_best_lpni is already set to the final destination */
 
@@ -2122,7 +2122,23 @@ struct lnet_ni *
 		return -EFAULT;
 	}
 
-	rc = lnet_select_preferred_best_ni(sd);
+	if (sd->sd_msg->msg_routing) {
+		/* If I'm forwarding this message then I can choose any NI
+		 * on the destination peer net
+		 */
+		sd->sd_best_ni = lnet_find_best_ni_on_spec_net(NULL,
+							       sd->sd_peer,
+							       sd->sd_best_lpni->lpni_peer_net,
+							       sd->sd_md_cpt,
+							       true);
+		if (!sd->sd_best_ni) {
+			CERROR("Unable to forward message to %s. No local NI available\n",
+			       libcfs_nid2str(sd->sd_dst_nid));
+			rc = -EHOSTUNREACH;
+		}
+	} else {
+		rc = lnet_select_preferred_best_ni(sd);
+	}
 	if (!rc)
 		rc = lnet_handle_send(sd);
 
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH 16/23 lnet: socklnd: remove declarations of missing functions.

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

None of ksocknal_query(), ksocknal_notify(), and ksocknal_lib_bind_thread_to_cpu() exist, so don't declare them.

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 4e69e77201b4d ("LU-6142 socklnd: remove declarations of missing functions.")

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

---
 net/lnet/klnds/socklnd/socklnd.h | 2 --
 1 file changed, 2 deletions(-)
net/lnet/klnds/socklnd/socklnd.h +0 -2
index 350f2c8..261cbb46 100644
@@ -638,7 +638,6 @@ int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
 void ksocknal_next_tx_carrier(struct ksock_conn *conn);
 void ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn);
 void ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int error);
-void ksocknal_notify(lnet_nid_t gw_nid);
 void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, time64_t *when);
 int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name);
 void ksocknal_thread_fini(void);
@@ -682,6 +681,5 @@ int ksocknal_lib_get_conn_tunables(struct ksock_conn *conn, int *txmem,
 void ksocknal_lib_csum_tx(struct ksock_tx *tx);
 
 int ksocknal_lib_memory_pressure(struct ksock_conn *conn);
-int ksocknal_lib_bind_thread_to_cpu(int id);
 
 #endif /* _SOCKLND_SOCKLND_H_ */
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 17/23 lnet: discard unused lnet_print_hdr()

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

lnet_print_hdr() is unused, and has not been used in git history since at least 2004.
So remove it.

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 58d4a4c38ab1b ("LU-6142 lnet: discard unused lnet_print_hdr()")

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

---
 include/linux/lnet/lib-lnet.h |  1 -
 net/lnet/lnet/lib-move.c      | 58 -------------------------------------------
 2 files changed, 59 deletions(-)
include/linux/lnet/lib-lnet.h +0 -1
index e733807..299ecf5 100644
@@ -590,7 +590,6 @@ void lnet_drop_message(struct lnet_ni *ni, int cpt, void *private,
 
 char *lnet_health_error2str(enum lnet_msg_hstatus hstatus);
 char *lnet_msgtyp2str(int type);
-void lnet_print_hdr(struct lnet_hdr *hdr);
 int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);
 
 /** \addtogroup lnet_fault_simulation @{ */
net/lnet/lnet/lib-move.c +0 -58

64 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#18 lore raw

PATCH 18/23 lnet: clarify initialization of lpni_refcount

In reply to James Simmons

From: Mr NeilBrown <[email protected]>

This refcount is not explicitly initialized, so is implicitly initialized to zero. This prohibits the use lnet_peer_ni_addref_locked() for taking the first reference, so a couple of places open-code the atomic_inc just in case.

There is code in lnet_peer_add_nid() which drops a reference before accessing the structure. This isn't actually wrong, but it looks weird.

lnet_destroy_peer_ni_locked() makes assumptions about the content of the structure, so it cannot be used on a partially initialized structure.

All these special cases make the code harder to understand. This patch cleans this up:

- lpni_refcount is now initialized to one, so the called for lnet_peer_ni_alloc() now owns a reference and must be sure to release it.
- lnet_peer_attach_peer_ni() now consumes a reference to the lpni. A pointer returned by lnet_peer_ni_alloc() is most often passed to lnet_peer_attach_peer_ni() so these to changes largely cancel each other out - not completely
- The two 'atomic_inc' calls are changed to 'lnet_peer_ni_addref_locked().
- A kfree is replaced by lnet_peer_ni_decref_locked(), and that function is improved to cope with lpni_hashlist being empty, or ->lpni_net being NULL.
- lnet_peer_add_nid() now holds a reference on the lpni until it don't need it any more, then explicity drops it.

This should make no functional change, but should make the code a little less confusing.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12678
Lustre-commit: 5bcb17cf1d476 ("LU-12678 lnet: clarify initialization of lpni_refcount")

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

---
 net/lnet/lnet/peer.c | 48 +++++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)
net/lnet/lnet/peer.c +25 -23
index 578591d..81f908e 100644
@@ -125,6 +125,7 @@
 	INIT_LIST_HEAD(&lpni->lpni_recovery);
 	INIT_LIST_HEAD(&lpni->lpni_on_remote_peer_ni_list);
 	LNetInvalidateMDHandle(&lpni->lpni_recovery_ping_mdh);
+	atomic_set(&lpni->lpni_refcount, 1);
 
 	spin_lock_init(&lpni->lpni_lock);
 
@@ -152,7 +153,7 @@
 		 * list so it can be easily found and revisited.
 		 */
 		/* FIXME: per-net implementation instead? */
-		atomic_inc(&lpni->lpni_refcount);
+		lnet_peer_ni_addref_locked(lpni);
 		list_add_tail(&lpni->lpni_on_remote_peer_ni_list,
 			      &the_lnet.ln_remote_peer_ni_list);
 	}
@@ -1223,9 +1224,9 @@ struct lnet_peer_net *
  * may be attached to a different peer, in which case it will be
  * properly detached first. The whole operation is done atomically.
  *
- * Always returns 0.  This is the last function called from functions
- * that do return an int, so returning 0 here allows the compiler to
- * do a tail call.
+ * This function consumes the reference on lpni and Always returns 0.
+ * This is the last function called from functions that do return an
+ * int, so returning 0 here allows the compiler to do a tail call.
  */
 static int
 lnet_peer_attach_peer_ni(struct lnet_peer *lp,
@@ -1244,8 +1245,7 @@ struct lnet_peer_net *
 		ptable = the_lnet.ln_peer_tables[lpni->lpni_cpt];
 		list_add_tail(&lpni->lpni_hashlist, &ptable->pt_hash[hash]);
 		ptable->pt_version++;
-		/* This is the 1st refcount on lpni. */
-		atomic_inc(&lpni->lpni_refcount);
+		lnet_peer_ni_addref_locked(lpni);
 	}
 
 	/* Detach the peer_ni from an existing peer, if necessary. */
@@ -1293,11 +1293,12 @@ struct lnet_peer_net *
 	spin_unlock(&lp->lp_lock);
 
 	lp->lp_nnis++;
-	lnet_net_unlock(LNET_LOCK_EX);
 
 	CDEBUG(D_NET, "peer %s NID %s flags %#x\n",
 	       libcfs_nid2str(lp->lp_primary_nid),
 	       libcfs_nid2str(lpni->lpni_nid), flags);
+	lnet_peer_ni_decref_locked(lpni);
+	lnet_net_unlock(LNET_LOCK_EX);
 
 	return 0;
 }
@@ -1418,17 +1419,16 @@ struct lnet_peer_net *
 		 * it is not connected to this peer and was configured
 		 * by DLC.
 		 */
-		lnet_peer_ni_decref_locked(lpni);
 		if (lpni->lpni_peer_net->lpn_peer == lp)
-			goto out;
+			goto out_free_lpni;
 		if (lnet_peer_ni_is_configured(lpni)) {
 			rc = -EEXIST;
-			goto out;
+			goto out_free_lpni;
 		}
 		/* If this is the primary NID, destroy the peer. */
 		if (lnet_peer_ni_is_primary(lpni)) {
 			struct lnet_peer *rtr_lp =
-			  lpni->lpni_peer_net->lpn_peer;
+				lpni->lpni_peer_net->lpn_peer;
 			int rtr_refcount = rtr_lp->lp_rtr_refcount;
 
 			/* if we're trying to delete a router it means
@@ -1440,17 +1440,18 @@ struct lnet_peer_net *
 				lnet_rtr_transfer_to_peer(rtr_lp, lp);
 			}
 			lnet_peer_del(lpni->lpni_peer_net->lpn_peer);
+			lnet_peer_ni_decref_locked(lpni);
 			lpni = lnet_peer_ni_alloc(nid);
 			if (!lpni) {
 				rc = -ENOMEM;
-				goto out;
+				goto out_free_lpni;
 			}
 		}
 	} else {
 		lpni = lnet_peer_ni_alloc(nid);
 		if (!lpni) {
 			rc = -ENOMEM;
-			goto out;
+			goto out_free_lpni;
 		}
 	}
 
@@ -1473,9 +1474,7 @@ struct lnet_peer_net *
 	return lnet_peer_attach_peer_ni(lp, lpn, lpni, flags);
 
 out_free_lpni:
-	/* If the peer_ni was allocated above its peer_net pointer is NULL */
-	if (!lpni->lpni_peer_net)
-		kfree(lpni);
+	lnet_peer_ni_decref_locked(lpni);
 out:
 	CDEBUG(D_NET, "peer %s NID %s flags %#x: %d\n",
 	       libcfs_nid2str(lp->lp_primary_nid), libcfs_nid2str(nid),
@@ -1699,18 +1698,21 @@ struct lnet_peer_net *
 	lpni->lpni_peer_net = NULL;
 	lpni->lpni_net = NULL;
 
-	/* remove the peer ni from the zombie list */
-	ptable = the_lnet.ln_peer_tables[lpni->lpni_cpt];
-	spin_lock(&ptable->pt_zombie_lock);
-	list_del_init(&lpni->lpni_hashlist);
-	ptable->pt_zombies--;
-	spin_unlock(&ptable->pt_zombie_lock);
+	if (!list_empty(&lpni->lpni_hashlist)) {
+		/* remove the peer ni from the zombie list */
+		ptable = the_lnet.ln_peer_tables[lpni->lpni_cpt];
+		spin_lock(&ptable->pt_zombie_lock);
+		list_del_init(&lpni->lpni_hashlist);
+		ptable->pt_zombies--;
+		spin_unlock(&ptable->pt_zombie_lock);
+	}
 
 	if (lpni->lpni_pref_nnids > 1)
 		kfree(lpni->lpni_pref.nids);
 	kfree(lpni);
 
-	lnet_peer_net_decref_locked(lpn);
+	if (lpn)
+		lnet_peer_net_decref_locked(lpn);
 }
 
 struct lnet_peer_ni *
Signature · 1 line
1.8.3.1
#19 lore raw

PATCH 19/23 lnet: Allow duplicate nets in ip2nets syntax

In reply to James Simmons

From: Chris Horn <[email protected]>

Before the MR feature was implemented, it was not possible to configure multiple interfaces on the same LNet, so the ip2nets syntax did not allow for this. Now that we have MR feature, we should allow it to be configured via ip2nets syntax. e.g.

o2ib(ib0) 10.10.10.1
o2ib(ib1) 10.10.10.2

A test is added for configuring LNet with kernel ip2nets parameter.

setup_netns() refactored to facilitate the new test.

cleanup_lnet() is modified to check whether lnet module is loaded before attempting lnetctl lnet unconfigured otherwise sanity-lnet.sh could exit with rc 234 on cleanup.

HPE-bug-id: LUS-9046
WC-bug-id: https://jira.whamcloud.com/browse/LU-13734
Lustre-commit: 6203ed821ffac ("LU-13734 lnet: Allow duplicate nets in ip2nets syntax")

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

---
 net/lnet/lnet/config.c | 36 ++++--------------------------------
 1 file changed, 4 insertions(+), 32 deletions(-)
net/lnet/lnet/config.c +4 -32
index 9f36c82..6ddd9d6 100644
@@ -349,10 +349,10 @@ struct lnet_net *
 {
 	struct lnet_net *net;
 
-	if (!lnet_net_unique(net_id, net_list, NULL)) {
-		CERROR("Duplicate net %s. Ignore\n",
-		       libcfs_net2str(net_id));
-		return NULL;
+	if (!lnet_net_unique(net_id, net_list, &net)) {
+		CDEBUG(D_NET, "Returning duplicate net %p %s\n", net,
+		       libcfs_net2str(net->net_id));
+		return net;
 	}
 
 	net = kzalloc(sizeof(*net), GFP_NOFS);
@@ -1450,12 +1450,8 @@ struct lnet_ni *
 	struct list_head *t;
 	struct list_head *t2;
 	struct lnet_text_buf *tb;
-	struct lnet_text_buf *tb2;
-	u32 net1;
-	u32 net2;
 	int len;
 	int count;
-	int dup;
 	int rc;
 
 	if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) {
@@ -1494,30 +1490,6 @@ struct lnet_ni *
 		if (rc < 0)
 			break;
 
-		dup = 0;
-		list_for_each_entry(tb, &current_nets, ltb_list) {
-			net1 = lnet_netspec2net(tb->ltb_text);
-			LASSERT(net1 != LNET_NIDNET(LNET_NID_ANY));
-
-			list_for_each_entry(tb2, &matched_nets, ltb_list) {
-				net2 = lnet_netspec2net(tb2->ltb_text);
-				LASSERT(net2 != LNET_NIDNET(LNET_NID_ANY));
-
-				if (net1 == net2) {
-					dup = 1;
-					break;
-				}
-			}
-
-			if (dup)
-				break;
-		}
-
-		if (dup) {
-			lnet_free_text_bufs(&current_nets);
-			continue;
-		}
-
 		list_for_each_safe(t, t2, &current_nets) {
 			tb = list_entry(t, struct lnet_text_buf, ltb_list);
 
Signature · 1 line
1.8.3.1
#20 lore raw

PATCH 20/23 lustre: llite: pack parent FID in getattr

In reply to James Simmons

From: Lai Siyao <[email protected]>

Pack parent FID in getattr request if OBD_CONNECT2_GETATTR_PFID is enabled, otherwise fill it with target FID for backward compatibility.

Fixes e11fdb90 ("lustre: mdt: don't fetch LOOKUP lock for remot...")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13437
Lustre-commit: 5f2c44bf626b ("U-13437 llite: pack parent FID in getattr")

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

---
 fs/lustre/llite/file.c      | 10 ++++++++--
 fs/lustre/llite/llite_lib.c |  3 ++-
 fs/lustre/lmv/lmv_intent.c  |  5 ++++-
 3 files changed, 14 insertions(+), 4 deletions(-)
fs/lustre/llite/file.c +8 -2
index 7d00728..17c2d88 100644
@@ -4533,6 +4533,7 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc)
 
 static int ll_inode_revalidate(struct dentry *dentry, enum ldlm_intent_flags op)
 {
+	struct inode *parent;
 	struct inode *inode = d_inode(dentry);
 	struct obd_export *exp = ll_i2mdexp(inode);
 	struct lookup_intent oit = {
@@ -4545,9 +4546,14 @@ static int ll_inode_revalidate(struct dentry *dentry, enum ldlm_intent_flags op)
 	CDEBUG(D_VFSTRACE, "VFS Op:inode=" DFID "(%p),name=%pd\n",
 	       PFID(ll_inode2fid(inode)), inode, dentry);
 
+	if (exp_connect_flags2(exp) & OBD_CONNECT2_GETATTR_PFID)
+		parent = dentry->d_parent->d_inode;
+	else
+		parent = inode;
+
 	/* Call getattr by fid, so do not provide name at all. */
-	op_data = ll_prep_md_op_data(NULL, dentry->d_parent->d_inode, inode,
-				     NULL, 0, 0, LUSTRE_OPC_ANY, NULL);
+	op_data = ll_prep_md_op_data(NULL, parent, inode, NULL, 0, 0,
+				     LUSTRE_OPC_ANY, NULL);
 	if (IS_ERR(op_data))
 		return PTR_ERR(op_data);
 
fs/lustre/llite/llite_lib.c +2 -1
index 4773fc1..e732a82 100644
@@ -261,7 +261,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 				   OBD_CONNECT2_LSOM |
 				   OBD_CONNECT2_ASYNC_DISCARD |
 				   OBD_CONNECT2_PCC |
-				   OBD_CONNECT2_CRUSH;
+				   OBD_CONNECT2_CRUSH |
+				   OBD_CONNECT2_GETATTR_PFID;
 
 	if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
 		data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
fs/lustre/lmv/lmv_intent.c +4 -1
index 4af449e..3960b93 100644
@@ -197,7 +197,10 @@ int lmv_revalidate_slaves(struct obd_export *exp,
 		 * which is not needed here.
 		 */
 		memset(op_data, 0, sizeof(*op_data));
-		op_data->op_fid1 = *pfid;
+		if (exp_connect_flags2(exp) & OBD_CONNECT2_GETATTR_PFID)
+			op_data->op_fid1 = *pfid;
+		else
+			op_data->op_fid1 = fid;
 		op_data->op_fid2 = fid;
 
 		tgt = lmv_tgt(lmv, lsm->lsm_md_oinfo[i].lmo_mds);
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH 21/23 lnet: Clear lp_dc_error when discovery completes

In reply to James Simmons

From: Chris Horn <[email protected]>

If discovery completes successfully then we can clear the lp_dc_error.

HPE-bug-id: LUS-9081
WC-bug-id: https://jira.whamcloud.com/browse/LU-13764
Lustre-commit: d3fa46705225f ("LU-13764 lnet: Clear lp_dc_error when discovery completes")

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

---
 net/lnet/lnet/peer.c | 2 ++
 1 file changed, 2 insertions(+)
net/lnet/lnet/peer.c +2 -0
index 81f908e..5ca6f68 100644
@@ -3058,6 +3058,8 @@ static int lnet_peer_discovered(struct lnet_peer *lp)
 	lp->lp_state &= ~(LNET_PEER_DISCOVERING |
 			  LNET_PEER_REDISCOVER);
 
+	lp->lp_dc_error = 0;
+
 	CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid));
 
 	return 0;
Signature · 1 line
1.8.3.1
#22 lore raw

PATCH 22/23 lnet: Have LNet routers monitor the ni_fatal flag

In reply to James Simmons

From: Chris Horn <[email protected]>

Have the LNet monitor thread on LNet routers check the ni_fatal_error_on flag to set local NI status appropriately. When this results in a status change, perform a discovery push to all peers. This allows peers to update their route status appropriately.

HPE-bug-id: LUS-9068
WC-bug-id: https://jira.whamcloud.com/browse/LU-13782
Lustre-commit: 7e0ec0f809ea1 ("LU-13782 lnet: Have LNet routers monitor the ni_fatal flag")

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

---
 include/linux/lnet/lib-lnet.h | 29 +++++++++++++++++++++++++++++
 net/lnet/lnet/lib-move.c      |  6 +-----
 net/lnet/lnet/router.c        | 35 ++++++++++++++++++++++++-----------
 3 files changed, 54 insertions(+), 16 deletions(-)
include/linux/lnet/lib-lnet.h +29 -0
index 299ecf5..d2a39f6 100644
@@ -98,6 +98,35 @@
 extern struct kmem_cache *lnet_rspt_cachep;
 extern struct kmem_cache *lnet_msg_cachep;
 
+static inline bool
+lnet_ni_set_status_locked(struct lnet_ni *ni, u32 status)
+__must_hold(&ni->ni_lock)
+{
+	bool update = false;
+
+	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),
+		       ni->ni_status->ns_status, status);
+		ni->ni_status->ns_status = status;
+		update = true;
+	}
+
+	return update;
+}
+
+static inline bool
+lnet_ni_set_status(struct lnet_ni *ni, u32 status)
+{
+	bool update;
+
+	spin_lock(&ni->ni_lock);
+	update = lnet_ni_set_status_locked(ni, status);
+	spin_unlock(&ni->ni_lock);
+
+	return update;
+}
+
 bool lnet_is_route_alive(struct lnet_route *route);
 bool lnet_is_gateway_alive(struct lnet_peer *gw);
 
net/lnet/lnet/lib-move.c +1 -5
index 85b6453..f521817 100644
@@ -4012,11 +4012,7 @@ void lnet_monitor_thr_stop(void)
 		spin_lock(&ni->ni_net->net_lock);
 		ni->ni_net->net_last_alive = ktime_get_real_seconds();
 		spin_unlock(&ni->ni_net->net_lock);
-		if (ni->ni_status &&
-		    ni->ni_status->ns_status == LNET_NI_STATUS_DOWN) {
-			ni->ni_status->ns_status = LNET_NI_STATUS_UP;
-			push = true;
-		}
+		push = lnet_ni_set_status_locked(ni, LNET_NI_STATUS_UP);
 		lnet_ni_unlock(ni);
 	}
 
net/lnet/lnet/router.c +24 -11
index e3b3e71..1253e4c 100644
@@ -1014,15 +1014,9 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg)
 	struct lnet_ni *ni;
 	bool update = false;
 
-	list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
-		lnet_ni_lock(ni);
-		if (ni->ni_status &&
-		    ni->ni_status->ns_status != status) {
-			ni->ni_status->ns_status = status;
+	list_for_each_entry(ni, &net->net_ni_list, ni_netlist)
+		if (lnet_ni_set_status(ni, status))
 			update = true;
-		}
-		lnet_ni_unlock(ni);
-	}
 
 	return update;
 }
@@ -1031,6 +1025,7 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg)
 lnet_update_ni_status_locked(void)
 {
 	struct lnet_net *net;
+	struct lnet_ni *ni;
 	bool push = false;
 	time64_t now;
 	time64_t timeout;
@@ -1045,13 +1040,13 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg)
 			continue;
 
 		if (now < net->net_last_alive + timeout)
-			continue;
+			goto check_ni_fatal;
 
 		spin_lock(&net->net_lock);
 		/* re-check with lock */
 		if (now < net->net_last_alive + timeout) {
 			spin_unlock(&net->net_lock);
-			continue;
+			goto check_ni_fatal;
 		}
 		spin_unlock(&net->net_lock);
 
@@ -1059,7 +1054,25 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg)
 		 * timeout on any of its constituent NIs, then mark all
 		 * the NIs down.
 		 */
-		push = lnet_net_set_status_locked(net, LNET_NI_STATUS_DOWN);
+		if (lnet_net_set_status_locked(net, LNET_NI_STATUS_DOWN)) {
+			push = true;
+			continue;
+		}
+
+check_ni_fatal:
+		list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
+			/* lnet_ni_set_status() will perform the same check of
+			 * ni_status while holding the ni lock. We can safely
+			 * check ni_status without that lock because it is only
+			 * written to under net_lock/EX and our caller is
+			 * holding a net lock.
+			 */
+			if (atomic_read(&ni->ni_fatal_error_on) &&
+			    ni->ni_status &&
+			    ni->ni_status->ns_status != LNET_NI_STATUS_DOWN &&
+			    lnet_ni_set_status(ni, LNET_NI_STATUS_DOWN))
+				push = true;
+		}
 	}
 
 	return push;
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH 23/23 lnet: socklnd: NID to interface mapping issues

In reply to James Simmons

From: Serguei Smirnov <[email protected]>

Fix the NID to interface mapping in ksocknal_startup to make sure the messages go out the interface assigned by LNet on a system with multiple interfaces configured.

Fixes 3aa523159321 ("lnet: consoldate secondary IP address handling")

WC-bug-id: https://jira.whamcloud.com/browse/LU-13790
Lustre-commit: 00f672da3ba9a ("LU-13790 socklnd: NID to interface mapping issues")

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

---
 net/lnet/klnds/socklnd/socklnd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/lnet/klnds/socklnd/socklnd.c +1 -1
index 91925475..a7c0b65 100644
@@ -2694,7 +2694,7 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
 					   ni->ni_interfaces[i]) != 0)
 					continue;
 
-				ksi = &net->ksnn_interfaces[j];
+				ksi = &net->ksnn_interfaces[net->ksnn_ninterfaces];
 				ni->ni_dev_cpt = ifaces[j].li_cpt;
 				ksi->ksni_ipaddr = ifaces[j].li_ipaddr;
 				ksi->ksni_index =
Signature · 1 line
1.8.3.1