All of lore.kernel.org
 help / color / mirror / Atom feed
* [lustre-devel] [PATCH 00/37] More lustre patches from obdclass
@ 2019-02-19  0:09 NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type NeilBrown
                   ` (36 more replies)
  0 siblings, 37 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

These patches are all a result of my reading of obdclass code,
though some of them extend will beyond obdclass.
One has been posted already but was buggy, another few replace
an earlier patch which, as James pointed out, didn't really
go far enough.

I've done some testing (and found a bug) but haven't completed a full
test run yet.  So both comments and testing most welcome.

NeilBrown

---

NeilBrown (37):
      lustre: obdclass: char obd_ioctl_getdata type.
      lustre: llite: don't use class_setup_tunables()
      lustre: embed typ_kobj if obd_type
      lustre: collect all resource releasing for obj_type.
      lustre: obd_type: use typ_kobj.name as typ_name
      lustre: obd_type: discard obd_types linked list.
      lustre: obd_type: discard obd_type_lock
      lustre: obdclass: don't copy ops structures in to new type.
      lustre: obdclass: fix module load locking.
      lustre: kernelcomm: pass correct gfp_t to kmalloc.
      lustre: kernelcomm: make libcfs_kkuc_msg_put static.
      lustre: remove unused function in linkea.
      lustre: llog: remove lgh_hdr_lock.
      lustre: llog: change lgh_refcount to struct kref.
      lustre: llog_obd: Convert loc_refcount to refcount_t
      lustre: obdclass: typo: Banlance -> Balance
      lustre: simplify lprocfs_read_frac_helper.
      lustre: obdclass: discard lprocfs_single/seq_release
      lustre: discard lprocfs_strnstr()
      lustre: convert rsi_sem to a spinlock.
      lustre: remove several MAX_STRING_SIZE defines.
      lustre: lprocfs: use log2.h macros instead of shift loop.
      lustre: prefer to use tabs for alignment.
      lustre: lu_object: remove extra newline from debug printing.
      lustre: deprecate libcfs_debug_vmsg2
      lustre: remove libcfs_debug_vmsg2
      lustre: discard lu_ref
      lustre: remove scope and source from class_incref and class_decref.
      lustre: handles: discard h_owner in favour of h_ops
      lustre: handle: move refcount into the lustre_handle.
      lustre: discard OBD_FREE_RCU
      lustre: portals_handle: rename ops to owner
      lustre: portals_handle: remove locking from class_handle2object()
      lustre: portals_handle: use hlist for hash lists.
      lustre: portals_handle: discard h_lock.
      lustre: remove unused fields from struct obd_device
      lustre: obd_sysfs: error-check value stored in jobid_var


 .../lustre/include/linux/libcfs/libcfs_cpu.h       |    2 
 .../lustre/include/linux/libcfs/libcfs_crypto.h    |   10 -
 .../lustre/include/linux/libcfs/libcfs_debug.h     |   35 +-
 .../lustre/include/linux/libcfs/libcfs_fail.h      |   12 -
 .../lustre/include/linux/libcfs/libcfs_hash.h      |   24 +
 .../lustre/include/linux/libcfs/libcfs_private.h   |    2 
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |    4 
 .../staging/lustre/include/linux/lnet/socklnd.h    |    2 
 .../lustre/include/uapi/linux/lnet/libcfs_debug.h  |  124 +++----
 .../lustre/include/uapi/linux/lnet/libcfs_ioctl.h  |   56 +--
 .../lustre/include/uapi/linux/lnet/lnet-types.h    |   10 -
 .../lustre/include/uapi/linux/lnet/lnetst.h        |   14 -
 .../lustre/include/uapi/linux/lnet/nidstr.h        |    6 
 .../include/uapi/linux/lustre/lustre_fiemap.h      |    2 
 .../lustre/include/uapi/linux/lustre/lustre_idl.h  |  350 +++++++++----------
 .../lustre/include/uapi/linux/lustre/lustre_user.h |  378 ++++++++++----------
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |   60 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h    |   32 +-
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |   63 +--
 drivers/staging/lustre/lnet/libcfs/tracefile.h     |    2 
 drivers/staging/lustre/lnet/lnet/nidstrings.c      |    4 
 drivers/staging/lustre/lnet/selftest/timer.c       |    8 
 drivers/staging/lustre/lustre/fld/lproc_fld.c      |    2 
 drivers/staging/lustre/lustre/include/cl_object.h  |    6 
 .../staging/lustre/lustre/include/lprocfs_status.h |    7 
 drivers/staging/lustre/lustre/include/lu_object.h  |   45 --
 drivers/staging/lustre/lustre/include/lu_ref.h     |  178 ---------
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   26 -
 .../staging/lustre/lustre/include/lustre_export.h  |    1 
 .../staging/lustre/lustre/include/lustre_handles.h |   22 -
 .../staging/lustre/lustre/include/lustre_import.h  |    8 
 .../lustre/lustre/include/lustre_kernelcomm.h      |    1 
 .../staging/lustre/lustre/include/lustre_linkea.h  |    8 
 drivers/staging/lustre/lustre/include/lustre_log.h |   21 -
 drivers/staging/lustre/lustre/include/lustre_net.h |    4 
 drivers/staging/lustre/lustre/include/obd.h        |   62 +--
 drivers/staging/lustre/lustre/include/obd_class.h  |   18 -
 .../staging/lustre/lustre/include/obd_support.h    |   10 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c      |    2 
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |  252 ++++++-------
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   12 -
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   12 -
 drivers/staging/lustre/lustre/llite/dir.c          |   18 -
 drivers/staging/lustre/lustre/llite/file.c         |    2 
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |    2 
 drivers/staging/lustre/lustre/llite/llite_lib.c    |   20 -
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   10 -
 drivers/staging/lustre/lustre/llite/rw.c           |    6 
 drivers/staging/lustre/lustre/llite/rw26.c         |    6 
 drivers/staging/lustre/lustre/llite/vvp_dev.c      |   20 -
 drivers/staging/lustre/lustre/llite/vvp_internal.h |    2 
 drivers/staging/lustre/lustre/llite/vvp_io.c       |    5 
 drivers/staging/lustre/lustre/llite/xattr.c        |    2 
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    6 
 drivers/staging/lustre/lustre/lov/lov_ea.c         |    2 
 drivers/staging/lustre/lustre/lov/lov_obd.c        |   43 +-
 drivers/staging/lustre/lustre/lov/lov_object.c     |    2 
 drivers/staging/lustre/lustre/lov/lovsub_dev.c     |    1 
 drivers/staging/lustre/lustre/lov/lproc_lov.c      |    2 
 drivers/staging/lustre/lustre/mdc/mdc_reint.c      |    2 
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    6 
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |   32 +-
 drivers/staging/lustre/lustre/obdclass/Makefile    |    2 
 drivers/staging/lustre/lustre/obdclass/cl_io.c     |    8 
 drivers/staging/lustre/lustre/obdclass/cl_object.c |    2 
 drivers/staging/lustre/lustre/obdclass/cl_page.c   |    5 
 drivers/staging/lustre/lustre/obdclass/class_obd.c |   19 -
 drivers/staging/lustre/lustre/obdclass/genops.c    |  258 ++++++--------
 .../staging/lustre/lustre/obdclass/kernelcomm.c    |    5 
 drivers/staging/lustre/lustre/obdclass/linkea.c    |  150 --------
 drivers/staging/lustre/lustre/obdclass/llog.c      |   17 -
 drivers/staging/lustre/lustre/obdclass/llog_obd.c  |   14 -
 .../lustre/lustre/obdclass/lprocfs_status.c        |  102 +----
 drivers/staging/lustre/lustre/obdclass/lu_object.c |   46 +-
 drivers/staging/lustre/lustre/obdclass/lu_ref.c    |   45 --
 .../lustre/lustre/obdclass/lustre_handles.c        |   59 +--
 .../staging/lustre/lustre/obdclass/obd_config.c    |   20 -
 drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |   27 +
 .../staging/lustre/lustre/obdecho/echo_client.c    |    4 
 drivers/staging/lustre/lustre/osc/osc_cache.c      |   12 -
 drivers/staging/lustre/lustre/osc/osc_lock.c       |    2 
 drivers/staging/lustre/lustre/osc/osc_page.c       |    2 
 drivers/staging/lustre/lustre/osc/osc_request.c    |   44 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    2 
 .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c    |    2 
 .../staging/lustre/lustre/ptlrpc/pack_generic.c    |   42 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c    |    2 
 88 files changed, 1077 insertions(+), 1904 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/include/lu_ref.h
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ref.c

--
Signature

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 18:35   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() NeilBrown
                   ` (35 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Instead of having obd_ioctl_getdata() return the allocated
data as a "char *", return it as it really is,
 struct obd_ioctl_data *

This avoids the need for extra variables and casts.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd_class.h  |    3 ++-
 drivers/staging/lustre/lustre/llite/dir.c          |   18 ++++++------------
 drivers/staging/lustre/lustre/llite/llite_lib.c    |    8 +++-----
 drivers/staging/lustre/lustre/lov/lov_obd.c        |   15 ++++++---------
 drivers/staging/lustre/lustre/obdclass/class_obd.c |   18 ++++++++----------
 5 files changed, 25 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 30b3e2c69f83..32d4ab6e78a0 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -1697,6 +1697,7 @@ struct root_squash_info {
 };
 
 /* linux-module.c */
-int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
+struct obd_ioctl_data;
+int obd_ioctl_getdata(struct obd_ioctl_data **data, int *len, void __user *arg);
 
 #endif /* __LINUX_OBD_CLASS_H */
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index fd1af4a5cdad..17bb6185ba87 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1130,13 +1130,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	}
 	case IOC_MDC_LOOKUP: {
 		int namelen, len = 0;
-		char *buf = NULL;
 		char *filename;
 
-		rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
+		rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
 		if (rc)
 			return rc;
-		data = (void *)buf;
 
 		filename = data->ioc_inlbuf1;
 		namelen = strlen(filename);
@@ -1155,12 +1153,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			goto out_free;
 		}
 out_free:
-		kvfree(buf);
+		kvfree(data);
 		return rc;
 	}
 	case LL_IOC_LMV_SETSTRIPE: {
 		struct lmv_user_md  *lum;
-		char *buf = NULL;
 		char *filename;
 		int namelen = 0;
 		int lumlen = 0;
@@ -1168,11 +1165,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		int len;
 		int rc;
 
-		rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
+		rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
 		if (rc)
 			return rc;
 
-		data = (void *)buf;
 		if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
 		    data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0) {
 			rc = -EINVAL;
@@ -1205,7 +1201,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 #endif
 		rc = ll_dir_setdirstripe(dentry, lum, filename, mode);
 lmv_out_free:
-		kvfree(buf);
+		kvfree(data);
 		return rc;
 	}
 	case LL_IOC_LMV_SET_DEFAULT_STRIPE: {
@@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		return rc;
 	}
 	case LL_IOC_MIGRATE: {
-		char *buf = NULL;
 		const char *filename;
 		int namelen = 0;
 		int len;
 		int rc;
 		int mdtidx;
 
-		rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
+		rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
 		if (rc < 0)
 			return rc;
 
-		data = (struct obd_ioctl_data *)buf;
 		if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
 		    !data->ioc_inllen1 || !data->ioc_inllen2) {
 			rc = -EINVAL;
@@ -1684,7 +1678,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1);
 migrate_free:
-		kvfree(buf);
+		kvfree(data);
 
 		return rc;
 	}
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 8e09fdd7a96e..e2417cd5aaed 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -2295,7 +2295,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
 {
 	struct ll_sb_info *sbi = NULL;
 	struct obd_export *exp;
-	char *buf = NULL;
 	struct obd_ioctl_data *data = NULL;
 	u32 type;
 	int len = 0, rc;
@@ -2311,11 +2310,10 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
 		goto out_statfs;
 	}
 
-	rc = obd_ioctl_getdata(&buf, &len, arg);
+	rc = obd_ioctl_getdata(&data, &len, arg);
 	if (rc)
 		goto out_statfs;
 
-	data = (void *)buf;
 	if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
 	    !data->ioc_pbuf1 || !data->ioc_pbuf2) {
 		rc = -EINVAL;
@@ -2340,11 +2338,11 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
 		goto out_statfs;
 	}
 
-	rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL);
+	rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, data, NULL);
 	if (rc)
 		goto out_statfs;
 out_statfs:
-	kvfree(buf);
+	kvfree(data);
 	return rc;
 }
 
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 04d0a9ed1d05..fd769c39b482 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1039,27 +1039,24 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 	case OBD_IOC_LOV_GET_CONFIG: {
 		struct obd_ioctl_data *data;
 		struct lov_desc *desc;
-		char *buf = NULL;
 		u32 *genp;
 
 		len = 0;
-		if (obd_ioctl_getdata(&buf, &len, uarg))
+		if (obd_ioctl_getdata(&data, &len, uarg))
 			return -EINVAL;
 
-		data = (struct obd_ioctl_data *)buf;
-
 		if (sizeof(*desc) > data->ioc_inllen1) {
-			kvfree(buf);
+			kvfree(data);
 			return -EINVAL;
 		}
 
 		if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
-			kvfree(buf);
+			kvfree(data);
 			return -EINVAL;
 		}
 
 		if (sizeof(u32) * count > data->ioc_inllen3) {
-			kvfree(buf);
+			kvfree(data);
 			return -EINVAL;
 		}
 
@@ -1076,9 +1073,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 			*genp = lov->lov_tgts[i]->ltd_gen;
 		}
 
-		if (copy_to_user(uarg, buf, len))
+		if (copy_to_user(uarg, data, len))
 			rc = -EFAULT;
-		kvfree(buf);
+		kvfree(data);
 		break;
 	}
 	case OBD_IOC_QUOTACTL: {
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 2ee6b96f4830..b8fc74044fe3 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -229,7 +229,7 @@ static int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
 }
 
 /* buffer MUST be at least the size of obd_ioctl_hdr */
-int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
+int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg)
 {
 	struct obd_ioctl_data *data;
 	struct obd_ioctl_hdr hdr;
@@ -261,16 +261,16 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
 	 * obdfilter-survey is an example, which relies on ioctl. So we'd
 	 * better avoid vmalloc on ioctl path. LU-66
 	 */
-	*buf = kvzalloc(hdr.ioc_len, GFP_KERNEL);
-	if (!*buf) {
+	data = kvzalloc(hdr.ioc_len, GFP_KERNEL);
+	if (!data) {
 		CERROR("Cannot allocate control buffer of len %d\n",
 		       hdr.ioc_len);
 		return -EINVAL;
 	}
 	*len = hdr.ioc_len;
-	data = (struct obd_ioctl_data *)*buf;
+	*datap = data;
 
-	if (copy_from_user(*buf, arg, hdr.ioc_len)) {
+	if (copy_from_user(data, arg, hdr.ioc_len)) {
 		err = -EFAULT;
 		goto free_buf;
 	}
@@ -307,14 +307,13 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
 	return 0;
 
 free_buf:
-	kvfree(*buf);
+	kvfree(data);
 	return err;
 }
 EXPORT_SYMBOL(obd_ioctl_getdata);
 
 int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 {
-	char *buf = NULL;
 	struct obd_ioctl_data *data;
 	struct libcfs_debug_ioctl_data *debug_data;
 	struct obd_device *obd = NULL;
@@ -329,11 +328,10 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 	}
 
 	CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
-	if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) {
+	if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) {
 		CERROR("OBD ioctl: data error\n");
 		return -EINVAL;
 	}
-	data = (struct obd_ioctl_data *)buf;
 
 	switch (cmd) {
 	case OBD_IOC_PROCESS_CFG: {
@@ -542,7 +540,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 	}
 
  out:
-	kvfree(buf);
+	kvfree(data);
 	return err;
 } /* class_handle_ioctl */
 

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables()
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 16:35   ` James Simmons
  2019-02-24 16:52   ` [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref NeilBrown
                   ` (34 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

llite_kobj does not benefit from being in the
lustre_kset kset (though it does need lustre_kset
as a parent)
It also does not need the class_ktype type, as dynamic_kobj_ktype
is sufficient.

So use the simple kobject_create_and_add() to initialize it.

This provides flexibility for making changes to
class_setup_tunables().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/llite/lproc_llite.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 8215296dc15d..78ec0fa65c58 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -46,7 +46,7 @@ int llite_tunables_register(void)
 {
 	int rc = 0;
 
-	llite_kobj = class_setup_tunables("llite");
+	llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj);
 	if (IS_ERR(llite_kobj))
 		return PTR_ERR(llite_kobj);
 

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (7 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking NeilBrown
                   ` (27 subsequent siblings)
  36 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

As there is a 1-1 ammping between obd_types and their ->typ_kobj, it
is simple and more normal to embed the kobj in the obd_type, rather
than allocate it separately.

This requires calling "kobject_init()" earlier, so we discard
class_setup_tunables() and move the content to appropriate places in
the only caller.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd.h        |    2 -
 drivers/staging/lustre/lustre/include/obd_class.h  |    1 
 drivers/staging/lustre/lustre/obdclass/genops.c    |   46 ++++++--------------
 .../lustre/lustre/obdclass/lprocfs_status.c        |    2 -
 4 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 171d2c214be6..b161542855fc 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -107,7 +107,7 @@ struct obd_type {
 	int			 typ_refcnt;
 	struct lu_device_type	*typ_lu;
 	spinlock_t		 obd_type_lock;
-	struct kobject		*typ_kobj;
+	struct kobject		 typ_kobj;
 };
 
 struct brw_page {
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 32d4ab6e78a0..e4695f5b748d 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -60,7 +60,6 @@ struct lu_device_type;
 
 /* genops.c */
 struct obd_export *class_conn2export(struct lustre_handle *conn);
-struct kobject *class_setup_tunables(const char *name);
 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 			const char *name, struct lu_device_type *ldt);
 int class_unregister_type(const char *name);
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 75d25b7206fc..2bd72f8a38eb 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -136,7 +136,9 @@ void class_put_type(struct obd_type *type)
 
 static void class_sysfs_release(struct kobject *kobj)
 {
-	kfree(kobj);
+	struct obd_type *type = container_of(kobj, struct obd_type, typ_kobj);
+
+	kfree(type);
 }
 
 static struct kobj_type class_ktype = {
@@ -144,26 +146,6 @@ static struct kobj_type class_ktype = {
 	.release	= class_sysfs_release,
 };
 
-struct kobject *class_setup_tunables(const char *name)
-{
-	struct kobject *kobj;
-	int rc;
-
-	kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
-	if (!kobj)
-		return ERR_PTR(-ENOMEM);
-
-	kobj->kset = lustre_kset;
-	kobject_init(kobj, &class_ktype);
-	rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name);
-	if (rc) {
-		kobject_put(kobj);
-		return ERR_PTR(rc);
-	}
-	return kobj;
-}
-EXPORT_SYMBOL(class_setup_tunables);
-
 #define CLASS_MAX_NAME 1024
 
 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
@@ -186,6 +168,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	if (!type)
 		return rc;
 
+	type->typ_kobj.kset = lustre_kset;
+	kobject_init(&type->typ_kobj, &class_ktype);
+
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
 	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
 	type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS);
@@ -205,19 +190,16 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	type->typ_debugfs_entry = debugfs_create_dir(type->typ_name,
 						     debugfs_lustre_root);
 
-	type->typ_kobj = class_setup_tunables(type->typ_name);
-	if (IS_ERR(type->typ_kobj)) {
-		rc = PTR_ERR(type->typ_kobj);
+	rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
+
+	if (rc)
 		goto failed;
-	}
 
 	if (ldt) {
 		type->typ_lu = ldt;
 		rc = lu_device_type_init(ldt);
-		if (rc != 0) {
-			kobject_put(type->typ_kobj);
+		if (rc != 0)
 			goto failed;
-		}
 	}
 
 	spin_lock(&obd_types_lock);
@@ -230,7 +212,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	kfree(type->typ_name);
 	kfree(type->typ_md_ops);
 	kfree(type->typ_dt_ops);
-	kfree(type);
+	kobject_put(&type->typ_kobj);
+
 	return rc;
 }
 EXPORT_SYMBOL(class_register_type);
@@ -253,8 +236,6 @@ int class_unregister_type(const char *name)
 		return -EBUSY;
 	}
 
-	kobject_put(type->typ_kobj);
-
 	debugfs_remove_recursive(type->typ_debugfs_entry);
 
 	if (type->typ_lu)
@@ -266,7 +247,8 @@ int class_unregister_type(const char *name)
 	kfree(type->typ_name);
 	kfree(type->typ_dt_ops);
 	kfree(type->typ_md_ops);
-	kfree(type);
+	kobject_put(&type->typ_kobj);
+
 	return 0;
 } /* class_unregister_type */
 EXPORT_SYMBOL(class_unregister_type);
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index e1ac610eaed5..568e6623e0c8 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1050,7 +1050,7 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only)
 	obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops;
 	obd->obd_ktype.release = obd_sysfs_release;
 
-	obd->obd_kset.kobj.parent = obd->obd_type->typ_kobj;
+	obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj;
 	obd->obd_kset.kobj.ktype = &obd->obd_ktype;
 	init_completion(&obd->obd_kobj_unregister);
 	rc = kset_register(&obd->obd_kset);

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (17 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 16:54   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list NeilBrown
                   ` (17 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Now that obj_type is managed as a kobject, move all
the freeing and deregistering into class_sysfs_release().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/genops.c |   27 +++++++++++------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 2bd72f8a38eb..4c0dc2098823 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -138,6 +138,18 @@ static void class_sysfs_release(struct kobject *kobj)
 {
 	struct obd_type *type = container_of(kobj, struct obd_type, typ_kobj);
 
+	debugfs_remove_recursive(type->typ_debugfs_entry);
+
+	if (type->typ_lu)
+		lu_device_type_fini(type->typ_lu);
+
+	spin_lock(&obd_types_lock);
+	list_del(&type->typ_chain);
+	spin_unlock(&obd_types_lock);
+
+	kfree(type->typ_name);
+	kfree(type->typ_md_ops);
+	kfree(type->typ_dt_ops);
 	kfree(type);
 }
 
@@ -170,6 +182,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 
 	type->typ_kobj.kset = lustre_kset;
 	kobject_init(&type->typ_kobj, &class_ktype);
+	INIT_LIST_HEAD(&type->typ_chain);
 
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
 	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
@@ -209,9 +222,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	return 0;
 
 failed:
-	kfree(type->typ_name);
-	kfree(type->typ_md_ops);
-	kfree(type->typ_dt_ops);
 	kobject_put(&type->typ_kobj);
 
 	return rc;
@@ -236,17 +246,6 @@ int class_unregister_type(const char *name)
 		return -EBUSY;
 	}
 
-	debugfs_remove_recursive(type->typ_debugfs_entry);
-
-	if (type->typ_lu)
-		lu_device_type_fini(type->typ_lu);
-
-	spin_lock(&obd_types_lock);
-	list_del(&type->typ_chain);
-	spin_unlock(&obd_types_lock);
-	kfree(type->typ_name);
-	kfree(type->typ_dt_ops);
-	kfree(type->typ_md_ops);
 	kobject_put(&type->typ_kobj);
 
 	return 0;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (6 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 16:56   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type NeilBrown
                   ` (28 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

As the kobject has a name (after kobject_add has been called),
we don't need to also store it in typ_name.
So use typ_kobj.name instead of typ_name.

This requires changing some "char *" to "const char *" as
typ.kobj.name is const.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |    4 ++-
 drivers/staging/lustre/lustre/include/obd.h        |    2 +-
 drivers/staging/lustre/lustre/include/obd_class.h  |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_lib.c      |    2 +-
 drivers/staging/lustre/lustre/obdclass/genops.c    |   25 ++++++++------------
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    2 +-
 6 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 47b9632e5660..f3b6ba061eed 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -308,7 +308,7 @@ struct ptlrpc_client {
 	/** What portal do we expect replies on */
 	u32			cli_reply_portal;
 	/** Name of the client */
-	char			*cli_name;
+	const char		*cli_name;
 };
 
 /** state flags of requests */
@@ -1817,7 +1817,7 @@ void ptlrpc_request_committed(struct ptlrpc_request *req, int force);
 int ptlrpc_inc_ref(void);
 void ptlrpc_dec_ref(void);
 
-void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
+void ptlrpc_init_client(int req_portal, int rep_portal, const char *name,
 			struct ptlrpc_client *);
 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid,
 						    lnet_nid_t nid4refnet);
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index b161542855fc..3aa9cc889949 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -103,12 +103,12 @@ struct obd_type {
 	struct obd_ops		*typ_dt_ops;
 	struct md_ops		*typ_md_ops;
 	struct dentry		*typ_debugfs_entry;
-	char			*typ_name;
 	int			 typ_refcnt;
 	struct lu_device_type	*typ_lu;
 	spinlock_t		 obd_type_lock;
 	struct kobject		 typ_kobj;
 };
+#define typ_name typ_kobj.name
 
 struct brw_page {
 	u64			off;
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index e4695f5b748d..a61c7950393c 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -74,7 +74,7 @@ int class_name2dev(const char *name);
 struct obd_device *class_name2obd(const char *name);
 int class_uuid2dev(struct obd_uuid *uuid);
 struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
-					 const char *typ_name,
+					 const char *type_name,
 					 struct obd_uuid *grp_uuid);
 struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid,
 					  int *next);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index aef83ffc8bb3..ac0fbb24fc92 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -247,7 +247,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
 	struct obd_import *imp;
 	struct obd_uuid server_uuid;
 	int rq_portal, rp_portal, connect_op;
-	char *name = obddev->obd_type->typ_name;
+	const char *name = obddev->obd_type->typ_name;
 	enum ldlm_ns_type ns_type = LDLM_NS_TYPE_UNKNOWN;
 	struct ptlrpc_connection fake_conn = {
 		.c_self = 0,
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 4c0dc2098823..32581f1a92ac 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -147,7 +147,6 @@ static void class_sysfs_release(struct kobject *kobj)
 	list_del(&type->typ_chain);
 	spin_unlock(&obd_types_lock);
 
-	kfree(type->typ_name);
 	kfree(type->typ_md_ops);
 	kfree(type->typ_dt_ops);
 	kfree(type);
@@ -186,28 +185,24 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
 	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
-	type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS);
 
 	if (!type->typ_dt_ops ||
-	    !type->typ_md_ops ||
-	    !type->typ_name)
+	    !type->typ_md_ops)
 		goto failed;
 
 	*type->typ_dt_ops = *dt_ops;
 	/* md_ops is optional */
 	if (md_ops)
 		*type->typ_md_ops = *md_ops;
-	strcpy(type->typ_name, name);
 	spin_lock_init(&type->obd_type_lock);
 
-	type->typ_debugfs_entry = debugfs_create_dir(type->typ_name,
-						     debugfs_lustre_root);
-
 	rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
-
 	if (rc)
 		goto failed;
 
+	type->typ_debugfs_entry = debugfs_create_dir(type->typ_name,
+						     debugfs_lustre_root);
+
 	if (ldt) {
 		type->typ_lu = ldt;
 		rc = lu_device_type_init(ldt);
@@ -534,7 +529,7 @@ struct obd_device *class_num2obd(int num)
  * otherwise any client connected to the tgt is returned.
  */
 struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
-					 const char *typ_name,
+					 const char *type_name,
 					 struct obd_uuid *grp_uuid)
 {
 	int i;
@@ -545,8 +540,8 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
 
 		if (!obd)
 			continue;
-		if ((strncmp(obd->obd_type->typ_name, typ_name,
-			     strlen(typ_name)) == 0)) {
+		if ((strncmp(obd->obd_type->typ_name, type_name,
+			     strlen(type_name)) == 0)) {
 			if (obd_uuid_equals(tgt_uuid,
 					    &obd->u.cli.cl_target_uuid) &&
 			    ((grp_uuid) ? obd_uuid_equals(grp_uuid,
@@ -1358,7 +1353,7 @@ EXPORT_SYMBOL(obd_get_max_rpcs_in_flight);
 int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max)
 {
 	struct obd_request_slot_waiter *orsw;
-	const char *typ_name;
+	const char *type_name;
 	u32 old;
 	int diff;
 	int rc;
@@ -1367,8 +1362,8 @@ int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max)
 	if (max > OBD_MAX_RIF_MAX || max < 1)
 		return -ERANGE;
 
-	typ_name = cli->cl_import->imp_obd->obd_type->typ_name;
-	if (!strcmp(typ_name, LUSTRE_MDC_NAME)) {
+	type_name = cli->cl_import->imp_obd->obd_type->typ_name;
+	if (!strcmp(type_name, LUSTRE_MDC_NAME)) {
 		/*
 		 * adjust max_mod_rpcs_in_flight to ensure it is always
 		 * strictly lower that max_rpcs_in_flight
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index b2b11047ea19..0a76a8549fac 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -67,7 +67,7 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async);
 /**
  * Initialize passed in client structure \a cl.
  */
-void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
+void ptlrpc_init_client(int req_portal, int rep_portal, const char *name,
 			struct ptlrpc_client *cl)
 {
 	cl->cli_request_portal = req_portal;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (18 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:00   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock NeilBrown
                   ` (16 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

As all obd_types are kobjects in the lustre_kset kset,
they are linked together in that kset and don't
need any extra linkage.

As kset_find_obj() returns a counted reference, we need
to put that reference when done.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd.h     |    1 -
 drivers/staging/lustre/lustre/obdclass/genops.c |   41 +++++++++++------------
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 3aa9cc889949..50f33f400075 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -99,7 +99,6 @@ struct obd_info {
 };
 
 struct obd_type {
-	struct list_head	 typ_chain;
 	struct obd_ops		*typ_dt_ops;
 	struct md_ops		*typ_md_ops;
 	struct dentry		*typ_debugfs_entry;
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 32581f1a92ac..775e4fa4f6a8 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -42,8 +42,6 @@
 #include <lprocfs_status.h>
 #include <lustre_kernelcomm.h>
 
-static DEFINE_SPINLOCK(obd_types_lock);
-static LIST_HEAD(obd_types);
 DEFINE_RWLOCK(obd_dev_lock);
 static struct obd_device *obd_devs[MAX_OBD_DEVICES];
 
@@ -88,22 +86,19 @@ static void obd_device_free(struct obd_device *obd)
 
 static struct obd_type *class_search_type(const char *name)
 {
-	struct obd_type *type;
+	struct kobject *kobj = kset_find_obj(lustre_kset, name);
+
+	if (kobj)
+		return container_of(kobj, struct obd_type, typ_kobj);
 
-	spin_lock(&obd_types_lock);
-	list_for_each_entry(type, &obd_types, typ_chain) {
-		if (strcmp(type->typ_name, name) == 0) {
-			spin_unlock(&obd_types_lock);
-			return type;
-		}
-	}
-	spin_unlock(&obd_types_lock);
 	return NULL;
 }
 
 static struct obd_type *class_get_type(const char *name)
 {
-	struct obd_type *type = class_search_type(name);
+	struct obd_type *type;
+
+	type = class_search_type(name);
 
 	if (!type) {
 		const char *modname = name;
@@ -121,6 +116,11 @@ static struct obd_type *class_get_type(const char *name)
 		type->typ_refcnt++;
 		try_module_get(type->typ_dt_ops->owner);
 		spin_unlock(&type->obd_type_lock);
+		/* class_search_type() returned a counted reference,
+		 * but we don't need that count any more as
+		 * we have one through typ_refcnt.
+		 */
+		kobject_put(&type->typ_kobj);
 	}
 	return type;
 }
@@ -143,10 +143,6 @@ static void class_sysfs_release(struct kobject *kobj)
 	if (type->typ_lu)
 		lu_device_type_fini(type->typ_lu);
 
-	spin_lock(&obd_types_lock);
-	list_del(&type->typ_chain);
-	spin_unlock(&obd_types_lock);
-
 	kfree(type->typ_md_ops);
 	kfree(type->typ_dt_ops);
 	kfree(type);
@@ -169,8 +165,10 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	/* sanity check */
 	LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME);
 
-	if (class_search_type(name)) {
+	type = class_search_type(name);
+	if (type) {
 		CDEBUG(D_IOCTL, "Type %s already registered\n", name);
+		kobject_put(&type->typ_kobj);
 		return -EEXIST;
 	}
 
@@ -181,7 +179,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 
 	type->typ_kobj.kset = lustre_kset;
 	kobject_init(&type->typ_kobj, &class_ktype);
-	INIT_LIST_HEAD(&type->typ_chain);
 
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
 	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
@@ -210,10 +207,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 			goto failed;
 	}
 
-	spin_lock(&obd_types_lock);
-	list_add(&type->typ_chain, &obd_types);
-	spin_unlock(&obd_types_lock);
-
 	return 0;
 
 failed:
@@ -238,9 +231,13 @@ int class_unregister_type(const char *name)
 		/* Remove ops, but leave the name for debugging */
 		kfree(type->typ_dt_ops);
 		kfree(type->typ_md_ops);
+		kobject_put(&type->typ_kobj);
 		return -EBUSY;
 	}
 
+	/* Put the ref returned by class_search_type() */
+	kobject_put(&type->typ_kobj);
+	/* Put the final ref */
 	kobject_put(&type->typ_kobj);
 
 	return 0;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (3 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:02   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type NeilBrown
                   ` (31 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

This lock is only used to protect typ_refcnt, so change
that to a refcount_t and discard the lock.

The lock also covers calls to try_module_get and module_put,
but this serves no purpose as it does not prevent the module
from being unloaded.

Finally, the return value for the call to try_module_get is
ignored, which is not safe.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd.h        |    3 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |    2 +
 drivers/staging/lustre/lustre/obdclass/genops.c    |   30 +++++++++-----------
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    2 +
 5 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 50f33f400075..a67eb9a14879 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -102,9 +102,8 @@ struct obd_type {
 	struct obd_ops		*typ_dt_ops;
 	struct md_ops		*typ_md_ops;
 	struct dentry		*typ_debugfs_entry;
-	int			 typ_refcnt;
+	refcount_t		 typ_refcnt;
 	struct lu_device_type	*typ_lu;
-	spinlock_t		 obd_type_lock;
 	struct kobject		 typ_kobj;
 };
 #define typ_name typ_kobj.name
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 3eb89ec80b7e..db2c045aa1cd 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -2540,7 +2540,7 @@ static int mdc_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize)
 static int mdc_precleanup(struct obd_device *obd)
 {
 	/* Failsafe, ok if racy */
-	if (obd->obd_type->typ_refcnt <= 1)
+	if (refcount_read(&obd->obd_type->typ_refcnt) <= 1)
 		libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
 
 	mdc_changelog_cdev_finish(obd);
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index a4dfdc08cc48..a6ee715921b8 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -715,7 +715,7 @@ static int mgc_cleanup(struct obd_device *obd)
 	/* COMPAT_146 - old config logs may have added profiles we don't
 	 * know about
 	 */
-	if (obd->obd_type->typ_refcnt <= 1)
+	if (refcount_read(&obd->obd_type->typ_refcnt) <= 1)
 		/* Only for the last mgc */
 		class_del_profiles();
 
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 775e4fa4f6a8..a3437c2d07bb 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -112,15 +112,17 @@ static struct obd_type *class_get_type(const char *name)
 		}
 	}
 	if (type) {
-		spin_lock(&type->obd_type_lock);
-		type->typ_refcnt++;
-		try_module_get(type->typ_dt_ops->owner);
-		spin_unlock(&type->obd_type_lock);
-		/* class_search_type() returned a counted reference,
-		 * but we don't need that count any more as
-		 * we have one through typ_refcnt.
-		 */
-		kobject_put(&type->typ_kobj);
+		if (try_module_get(type->typ_dt_ops->owner)) {
+			refcount_inc(&type->typ_refcnt);
+			/* class_search_type() returned a counted reference,
+			 * but we don't need that count any more as
+			 * we have one through typ_refcnt.
+			 */
+			kobject_put(&type->typ_kobj);
+		} else {
+			kobject_put(&type->typ_kobj);
+			type = NULL;
+		}
 	}
 	return type;
 }
@@ -128,10 +130,7 @@ static struct obd_type *class_get_type(const char *name)
 void class_put_type(struct obd_type *type)
 {
 	LASSERT(type);
-	spin_lock(&type->obd_type_lock);
-	type->typ_refcnt--;
-	module_put(type->typ_dt_ops->owner);
-	spin_unlock(&type->obd_type_lock);
+	refcount_dec(&type->typ_refcnt);
 }
 
 static void class_sysfs_release(struct kobject *kobj)
@@ -191,7 +190,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	/* md_ops is optional */
 	if (md_ops)
 		*type->typ_md_ops = *md_ops;
-	spin_lock_init(&type->obd_type_lock);
 
 	rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
 	if (rc)
@@ -225,8 +223,8 @@ int class_unregister_type(const char *name)
 		return -EINVAL;
 	}
 
-	if (type->typ_refcnt) {
-		CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt);
+	if (refcount_read(&type->typ_refcnt)) {
+		CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt));
 		/* This is a bad situation, let's make the best of it */
 		/* Remove ops, but leave the name for debugging */
 		kfree(type->typ_dt_ops);
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 639c298b6a90..69a56cca99f2 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -1267,7 +1267,7 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top)
 		next = ldt->ldt_ops->ldto_device_free(env, scan);
 		type = ldt->ldt_obd_type;
 		if (type) {
-			type->typ_refcnt--;
+			refcount_dec(&type->typ_refcnt);
 			class_put_type(type);
 		}
 	}

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (4 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:03   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance NeilBrown
                   ` (30 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

The obd_ops and md_ops structures passed to class_register_type() are
read-only, and have a lifetime that is exceeds the lifetime of the
obd_type - they are static in a module which unregisters the type before
being unloaded.

So there is no need to copy the ops, just store a pointer.

Also mark all the structures as read-only to confirm they don't get
written.  This is best-practice for structures of function pointers.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd.h        |    4 ++--
 drivers/staging/lustre/lustre/include/obd_class.h  |    3 ++-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    4 ++--
 drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    4 ++--
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |    2 +-
 drivers/staging/lustre/lustre/obdclass/genops.c    |   22 +++++---------------
 .../staging/lustre/lustre/obdecho/echo_client.c    |    2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
 9 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index a67eb9a14879..9cffda3741ce 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -99,8 +99,8 @@ struct obd_info {
 };
 
 struct obd_type {
-	struct obd_ops		*typ_dt_ops;
-	struct md_ops		*typ_md_ops;
+	const struct obd_ops	*typ_dt_ops;
+	const struct md_ops	*typ_md_ops;
 	struct dentry		*typ_debugfs_entry;
 	refcount_t		 typ_refcnt;
 	struct lu_device_type	*typ_lu;
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index a61c7950393c..7c2e248a8110 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -60,7 +60,8 @@ struct lu_device_type;
 
 /* genops.c */
 struct obd_export *class_conn2export(struct lustre_handle *conn);
-int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
+int class_register_type(const struct obd_ops *dt_ops,
+			const struct md_ops *md_ops,
 			const char *name, struct lu_device_type *ldt);
 int class_unregister_type(const char *name);
 
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 1c7379b14f8c..35dff0e96bf7 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -3044,7 +3044,7 @@ static int lmv_merge_attr(struct obd_export *exp,
 	return 0;
 }
 
-static struct obd_ops lmv_obd_ops = {
+static const struct obd_ops lmv_obd_ops = {
 	.owner			= THIS_MODULE,
 	.setup			= lmv_setup,
 	.cleanup		= lmv_cleanup,
@@ -3061,7 +3061,7 @@ static struct obd_ops lmv_obd_ops = {
 	.quotactl		= lmv_quotactl
 };
 
-static struct md_ops lmv_md_ops = {
+static const struct md_ops lmv_md_ops = {
 	.get_root		= lmv_get_root,
 	.null_inode		= lmv_null_inode,
 	.close			= lmv_close,
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index fd769c39b482..bad9538706f0 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1332,7 +1332,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
 	return rc;
 }
 
-static struct obd_ops lov_obd_ops = {
+static const struct obd_ops lov_obd_ops = {
 	.owner		= THIS_MODULE,
 	.setup		= lov_setup,
 	.cleanup	= lov_cleanup,
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index db2c045aa1cd..72a5264b2d78 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -2569,7 +2569,7 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf)
 	return count > 0 ? 0 : count;
 }
 
-static struct obd_ops mdc_obd_ops = {
+static const struct obd_ops mdc_obd_ops = {
 	.owner			= THIS_MODULE,
 	.setup			= mdc_setup,
 	.precleanup		= mdc_precleanup,
@@ -2591,7 +2591,7 @@ static struct obd_ops mdc_obd_ops = {
 	.quotactl		= mdc_quotactl,
 };
 
-static struct md_ops mdc_md_ops = {
+static const struct md_ops mdc_md_ops = {
 	.get_root		= mdc_get_root,
 	.null_inode		= mdc_null_inode,
 	.close			= mdc_close,
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index a6ee715921b8..3ff0bf1c4a22 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1817,7 +1817,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
 	return rc;
 }
 
-static struct obd_ops mgc_obd_ops = {
+static const struct obd_ops mgc_obd_ops = {
 	.owner          = THIS_MODULE,
 	.setup          = mgc_setup,
 	.precleanup     = mgc_precleanup,
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index a3437c2d07bb..d013e9a358f1 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -142,8 +142,6 @@ static void class_sysfs_release(struct kobject *kobj)
 	if (type->typ_lu)
 		lu_device_type_fini(type->typ_lu);
 
-	kfree(type->typ_md_ops);
-	kfree(type->typ_dt_ops);
 	kfree(type);
 }
 
@@ -154,7 +152,8 @@ static struct kobj_type class_ktype = {
 
 #define CLASS_MAX_NAME 1024
 
-int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
+int class_register_type(const struct obd_ops *dt_ops,
+			const struct md_ops *md_ops,
 			const char *name,
 			struct lu_device_type *ldt)
 {
@@ -179,17 +178,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	type->typ_kobj.kset = lustre_kset;
 	kobject_init(&type->typ_kobj, &class_ktype);
 
-	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
-	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
-
-	if (!type->typ_dt_ops ||
-	    !type->typ_md_ops)
-		goto failed;
-
-	*type->typ_dt_ops = *dt_ops;
-	/* md_ops is optional */
-	if (md_ops)
-		*type->typ_md_ops = *md_ops;
+	type->typ_dt_ops = dt_ops;
+	type->typ_md_ops = md_ops;
 
 	rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
 	if (rc)
@@ -227,8 +217,8 @@ int class_unregister_type(const char *name)
 		CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt));
 		/* This is a bad situation, let's make the best of it */
 		/* Remove ops, but leave the name for debugging */
-		kfree(type->typ_dt_ops);
-		kfree(type->typ_md_ops);
+		type->typ_dt_ops = NULL;
+		type->typ_md_ops = NULL;
 		kobject_put(&type->typ_kobj);
 		return -EBUSY;
 	}
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index 317123fd27cb..baf34c85c4b5 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -1676,7 +1676,7 @@ static int echo_client_disconnect(struct obd_export *exp)
 	return rc;
 }
 
-static struct obd_ops echo_client_obd_ops = {
+static const struct obd_ops echo_client_obd_ops = {
 	.owner			= THIS_MODULE,
 	.iocontrol		= echo_client_iocontrol,
 	.connect		= echo_client_connect,
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 3fedfaf249c4..442b4355d946 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -2988,7 +2988,7 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf)
 	return osc_process_config_base(obd, buf);
 }
 
-static struct obd_ops osc_obd_ops = {
+static const struct obd_ops osc_obd_ops = {
 	.owner          = THIS_MODULE,
 	.setup          = osc_setup,
 	.precleanup     = osc_precleanup,

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (8 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:04   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper NeilBrown
                   ` (26 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Safe module loading requires that we try_module_get() in a context
where the module cannot be unloaded, typically protected by
a spinlock that module-unload has to take.
This doesn't currently happen in class_get_type().

As free_module() calls synchronize_rcu() between calling the
exit function and freeing the module, we can use rcu_read_lock()
to check if the exit function has been called, and try_module_get()
if it hasn't.

We must also check the return status of try_module_get().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/genops.c |   24 ++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index d013e9a358f1..1d1a6b2d436e 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -98,21 +98,31 @@ static struct obd_type *class_get_type(const char *name)
 {
 	struct obd_type *type;
 
+	rcu_read_lock();
 	type = class_search_type(name);
 
 	if (!type) {
 		const char *modname = name;
 
+		rcu_read_unlock();
 		if (!request_module("%s", modname)) {
 			CDEBUG(D_INFO, "Loaded module '%s'\n", modname);
-			type = class_search_type(name);
 		} else {
 			LCONSOLE_ERROR_MSG(0x158, "Can't load module '%s'\n",
 					   modname);
 		}
+		rcu_read_lock();
+		type = class_search_type(name);
 	}
 	if (type) {
-		if (try_module_get(type->typ_dt_ops->owner)) {
+		/*
+		 * Holding rcu_read_lock() matches the synchronize_rcu() call
+		 * in free_module() and ensures that if type->typ_dt_ops is
+		 * not yet NULL, then the module won't be freed until after
+		 * we rcu_read_unlock().
+		 */
+		const struct obd_ops *dt_ops = READ_ONCE(type->typ_dt_ops);
+		if (dt_ops && try_module_get(dt_ops->owner)) {
 			refcount_inc(&type->typ_refcnt);
 			/* class_search_type() returned a counted reference,
 			 * but we don't need that count any more as
@@ -124,6 +134,7 @@ static struct obd_type *class_get_type(const char *name)
 			type = NULL;
 		}
 	}
+	rcu_read_unlock();
 	return type;
 }
 
@@ -213,11 +224,18 @@ int class_unregister_type(const char *name)
 		return -EINVAL;
 	}
 
+	/*
+	 * Ensure that class_get_type doesn't try to get the module
+	 * as it could be freed before the obd_type is released.
+	 * synchronize_rcu() will be called before the module
+	 * is freed.
+	 */
+	type->typ_dt_ops = NULL;
+
 	if (refcount_read(&type->typ_refcnt)) {
 		CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt));
 		/* This is a bad situation, let's make the best of it */
 		/* Remove ops, but leave the name for debugging */
-		type->typ_dt_ops = NULL;
 		type->typ_md_ops = NULL;
 		kobject_put(&type->typ_kobj);
 		return -EBUSY;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (12 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:05   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines NeilBrown
                   ` (22 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Passing 0 as the gfp_t for kmalloc() is not meaningful, and
could change behaviour.
Use an explicit GFP_KERNEL instead.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/obdclass/kernelcomm.c    |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
index 925ba52c53b4..09d0b1ab8d1c 100644
--- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
+++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
@@ -133,7 +133,7 @@ int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group,
 		return -EBADF;
 
 	/* freed in group_rem */
-	reg = kmalloc(sizeof(*reg) + data_len, 0);
+	reg = kmalloc(sizeof(*reg) + data_len, GFP_KERNEL);
 	if (!reg)
 		return -ENOMEM;
 

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (16 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:15   ` James Simmons
  2019-02-27 22:37   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type NeilBrown
                   ` (18 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

libcfs_kkuc_msg_put() is never used outside of kernelcomm.c,
so make it static.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/lustre/include/lustre_kernelcomm.h      |    1 -
 .../staging/lustre/lustre/obdclass/kernelcomm.c    |    3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
index 8e3a99057a38..1ed41840ab8f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
@@ -46,7 +46,6 @@ typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg);
 
 /* Kernel methods */
 void libcfs_kkuc_init(void);
-int libcfs_kkuc_msg_put(struct file *fp, void *payload);
 int libcfs_kkuc_group_put(unsigned int group, void *payload);
 int libcfs_kkuc_group_add(struct file *fp, int uid, unsigned int group,
 			  void *data, size_t data_len);
diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
index 09d0b1ab8d1c..27870952b1f0 100644
--- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
+++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
@@ -49,7 +49,7 @@
  * @param payload Payload data.  First field of payload is always
  *   struct kuc_hdr
  */
-int libcfs_kkuc_msg_put(struct file *filp, void *payload)
+static int libcfs_kkuc_msg_put(struct file *filp, void *payload)
 {
 	struct kuc_hdr *kuch = (struct kuc_hdr *)payload;
 	ssize_t count = kuch->kuc_msglen;
@@ -80,7 +80,6 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload)
 
 	return rc;
 }
-EXPORT_SYMBOL(libcfs_kkuc_msg_put);
 
 /*
  * Broadcast groups are global across all mounted filesystems;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (11 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc NeilBrown
                   ` (23 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Much of the linkea functionality is server-only.
Keep the parts used on the client, but remove the rest.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lustre_linkea.h  |    8 -
 drivers/staging/lustre/lustre/obdclass/linkea.c    |  150 --------------------
 2 files changed, 1 insertion(+), 157 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_linkea.h b/drivers/staging/lustre/lustre/include/lustre_linkea.h
index 03db1511bfd3..a028d91dd151 100644
--- a/drivers/staging/lustre/lustre/include/lustre_linkea.h
+++ b/drivers/staging/lustre/lustre/include/lustre_linkea.h
@@ -55,17 +55,9 @@ struct linkea_data {
 };
 
 int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf);
-int linkea_init(struct linkea_data *ldata);
 int linkea_init_with_rec(struct linkea_data *ldata);
 void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen,
 			 struct lu_name *lname, struct lu_fid *pfid);
-int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname,
-		      const struct lu_fid *pfid);
-int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname,
-		   const struct lu_fid *pfid);
-void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname);
-int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname,
-		      const struct lu_fid  *pfid);
 
 static inline void linkea_first_entry(struct linkea_data *ldata)
 {
diff --git a/drivers/staging/lustre/lustre/obdclass/linkea.c b/drivers/staging/lustre/lustre/obdclass/linkea.c
index 33594bd26794..b1aa80a73a2c 100644
--- a/drivers/staging/lustre/lustre/obdclass/linkea.c
+++ b/drivers/staging/lustre/lustre/obdclass/linkea.c
@@ -48,7 +48,7 @@ int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf)
 }
 EXPORT_SYMBOL(linkea_data_new);
 
-int linkea_init(struct linkea_data *ldata)
+static int linkea_init(struct linkea_data *ldata)
 {
 	struct link_ea_header *leh;
 
@@ -72,7 +72,6 @@ int linkea_init(struct linkea_data *ldata)
 	ldata->ld_leh = leh;
 	return 0;
 }
-EXPORT_SYMBOL(linkea_init);
 
 int linkea_init_with_rec(struct linkea_data *ldata)
 {
@@ -86,32 +85,6 @@ int linkea_init_with_rec(struct linkea_data *ldata)
 }
 EXPORT_SYMBOL(linkea_init_with_rec);
 
-/**
- * Pack a link_ea_entry.
- * All elements are stored as chars to avoid alignment issues.
- * Numbers are always big-endian
- * \retval record length
- */
-int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname,
-		      const struct lu_fid *pfid)
-{
-	struct lu_fid tmpfid;
-	int reclen;
-
-	tmpfid = *pfid;
-	if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LINKEA_CRASH))
-		tmpfid.f_ver = ~0;
-	fid_cpu_to_be(&tmpfid, &tmpfid);
-	memcpy(&lee->lee_parent_fid, &tmpfid, sizeof(tmpfid));
-	memcpy(lee->lee_name, lname->ln_name, lname->ln_namelen);
-	reclen = sizeof(struct link_ea_entry) + lname->ln_namelen;
-
-	lee->lee_reclen[0] = (reclen >> 8) & 0xff;
-	lee->lee_reclen[1] = reclen & 0xff;
-	return reclen;
-}
-EXPORT_SYMBOL(linkea_entry_pack);
-
 void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen,
 			 struct lu_name *lname, struct lu_fid *pfid)
 {
@@ -126,124 +99,3 @@ void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen,
 	}
 }
 EXPORT_SYMBOL(linkea_entry_unpack);
-
-/**
- * Add a record to the end of link ea buf
- **/
-int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname,
-		   const struct lu_fid *pfid)
-{
-	struct link_ea_header *leh = ldata->ld_leh;
-	int reclen;
-
-	LASSERT(leh);
-
-	if (!lname || !pfid)
-		return -EINVAL;
-
-	reclen = lname->ln_namelen + sizeof(struct link_ea_entry);
-	if (unlikely(leh->leh_len + reclen > MAX_LINKEA_SIZE)) {
-		/*
-		 * Use 32-bits to save the overflow time, although it will
-		 * shrink the ktime_get_real_seconds() returned 64-bits value
-		 * to 32-bits value, it is still quite large and can be used
-		 * for about 140 years. That is enough.
-		 */
-		leh->leh_overflow_time = ktime_get_real_seconds();
-		if (unlikely(leh->leh_overflow_time == 0))
-			leh->leh_overflow_time++;
-
-		CDEBUG(D_INODE, "No enough space to hold linkea entry '" DFID ": %.*s' at %u\n",
-		       PFID(pfid), lname->ln_namelen,
-		       lname->ln_name, leh->leh_overflow_time);
-		return 0;
-	}
-
-	if (leh->leh_len + reclen > ldata->ld_buf->lb_len) {
-		/* Note: this never happens as MAX_LINKEA_SIZE is 4096, while
-		 * the initial allocation is PAGE_SIZE.
-		 */
-		void *b = krealloc(ldata->ld_buf->lb_buf, leh->leh_len + reclen, GFP_NOFS);
-		if (!b)
-			return -ENOMEM;
-
-		ldata->ld_buf->lb_len = leh->leh_len + reclen;
-		leh = ldata->ld_leh = ldata->ld_buf->lb_buf = b;
-	}
-
-	ldata->ld_lee = ldata->ld_buf->lb_buf + leh->leh_len;
-	ldata->ld_reclen = linkea_entry_pack(ldata->ld_lee, lname, pfid);
-	leh->leh_len += ldata->ld_reclen;
-	leh->leh_reccount++;
-	CDEBUG(D_INODE, "New link_ea name '" DFID ":%.*s' is added\n",
-	       PFID(pfid), lname->ln_namelen, lname->ln_name);
-	return 0;
-}
-EXPORT_SYMBOL(linkea_add_buf);
-
-/** Del the current record from the link ea buf */
-void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname)
-{
-	LASSERT(ldata->ld_leh && ldata->ld_lee);
-	LASSERT(ldata->ld_leh->leh_reccount > 0);
-
-	ldata->ld_leh->leh_reccount--;
-	ldata->ld_leh->leh_len -= ldata->ld_reclen;
-	memmove(ldata->ld_lee, (char *)ldata->ld_lee + ldata->ld_reclen,
-		(char *)ldata->ld_leh + ldata->ld_leh->leh_len -
-		(char *)ldata->ld_lee);
-	CDEBUG(D_INODE, "Old link_ea name '%.*s' is removed\n",
-	       lname->ln_namelen, lname->ln_name);
-
-	if ((char *)ldata->ld_lee >= ((char *)ldata->ld_leh +
-				      ldata->ld_leh->leh_len))
-		ldata->ld_lee = NULL;
-}
-EXPORT_SYMBOL(linkea_del_buf);
-
-/**
- * Check if such a link exists in linkEA.
- *
- * \param ldata link data the search to be done on
- * \param lname name in the parent's directory entry pointing to this object
- * \param pfid parent fid the link to be found for
- *
- * \retval   0 success
- * \retval -ENOENT link does not exist
- * \retval -ve on error
- */
-int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname,
-		      const struct lu_fid  *pfid)
-{
-	struct lu_name tmpname;
-	struct lu_fid tmpfid;
-	int count;
-
-	LASSERT(ldata->ld_leh);
-
-	/* link #0, if leh_reccount == 0 we skip the loop and return -ENOENT */
-	if (likely(ldata->ld_leh->leh_reccount > 0))
-		ldata->ld_lee = (struct link_ea_entry *)(ldata->ld_leh + 1);
-
-	for (count = 0; count < ldata->ld_leh->leh_reccount; count++) {
-		linkea_entry_unpack(ldata->ld_lee, &ldata->ld_reclen,
-				    &tmpname, &tmpfid);
-		if (tmpname.ln_namelen == lname->ln_namelen &&
-		    lu_fid_eq(&tmpfid, pfid) &&
-		    (strncmp(tmpname.ln_name, lname->ln_name,
-			     tmpname.ln_namelen) == 0))
-			break;
-		ldata->ld_lee = (struct link_ea_entry *)((char *)ldata->ld_lee +
-							 ldata->ld_reclen);
-	}
-
-	if (count == ldata->ld_leh->leh_reccount) {
-		CDEBUG(D_INODE, "Old link_ea name '%.*s' not found\n",
-		       lname->ln_namelen, lname->ln_name);
-		ldata->ld_lee = NULL;
-		ldata->ld_reclen = 0;
-		return -ENOENT;
-	}
-	return 0;
-}
-EXPORT_SYMBOL(linkea_links_find);

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (2 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 20:29   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock NeilBrown
                   ` (32 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

This lock is unused on the client (and on the server,
it has been changed to a mutex).

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_log.h |    1 -
 drivers/staging/lustre/lustre/obdclass/llog.c      |    1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h
index a576d40f03f7..e96bd6ab0fa4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_log.h
+++ b/drivers/staging/lustre/lustre/include/lustre_log.h
@@ -212,7 +212,6 @@ struct llog_operations {
 /* In-memory descriptor for a log object or log catalog */
 struct llog_handle {
 	struct rw_semaphore	 lgh_lock;
-	spinlock_t		 lgh_hdr_lock; /* protect lgh_hdr data */
 	struct llog_logid	 lgh_id; /* id of this log */
 	struct llog_log_hdr	*lgh_hdr;
 	size_t			 lgh_hdr_size;
diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index 7aa459bb444e..9d161c16c2f9 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -64,7 +64,6 @@ static struct llog_handle *llog_alloc_handle(void)
 		return NULL;
 
 	init_rwsem(&loghandle->lgh_lock);
-	spin_lock_init(&loghandle->lgh_hdr_lock);
 	INIT_LIST_HEAD(&loghandle->u.phd.phd_entry);
 	atomic_set(&loghandle->lgh_refcount, 1);
 

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock NeilBrown
                   ` (33 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

This is a refcount that perfectly fits the
pattern for kref, so change it to a kref.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_log.h |    9 +--------
 drivers/staging/lustre/lustre/obdclass/llog.c      |   16 +++++++++-------
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h
index e96bd6ab0fa4..83fc9374d7f0 100644
--- a/drivers/staging/lustre/lustre/include/lustre_log.h
+++ b/drivers/staging/lustre/lustre/include/lustre_log.h
@@ -226,7 +226,7 @@ struct llog_handle {
 	char			*lgh_name;
 	void			*private_data;
 	struct llog_operations	*lgh_logops;
-	atomic_t		 lgh_refcount;
+	struct kref		 lgh_refcount;
 };
 
 #define LLOG_CTXT_FLAG_UNINITIALIZED     0x00000001
@@ -365,13 +365,6 @@ static inline int llog_next_block(const struct lu_env *env,
 }
 
 /* llog.c */
-int llog_declare_write_rec(const struct lu_env *env,
-			   struct llog_handle *handle,
-			   struct llog_rec_hdr *rec, int idx,
-			   struct thandle *th);
-int llog_write_rec(const struct lu_env *env, struct llog_handle *handle,
-		   struct llog_rec_hdr *rec, struct llog_cookie *logcookies,
-		   int numcookies, void *buf, int idx, struct thandle *th);
 int lustre_process_log(struct super_block *sb, char *logname,
 		       struct config_llog_instance *cfg);
 int lustre_end_log(struct super_block *sb, char *logname,
diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index 9d161c16c2f9..a34b1a7108b7 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -65,7 +65,7 @@ static struct llog_handle *llog_alloc_handle(void)
 
 	init_rwsem(&loghandle->lgh_lock);
 	INIT_LIST_HEAD(&loghandle->u.phd.phd_entry);
-	atomic_set(&loghandle->lgh_refcount, 1);
+	kref_init(&loghandle->lgh_refcount);
 
 	return loghandle;
 }
@@ -73,8 +73,11 @@ static struct llog_handle *llog_alloc_handle(void)
 /*
  * Free llog handle and header data if exists. Used in llog_close() only
  */
-static void llog_free_handle(struct llog_handle *loghandle)
+static void llog_free_handle(struct kref *kref)
 {
+	struct llog_handle *loghandle = container_of(kref, struct llog_handle,
+						     lgh_refcount);
+
 	/* failed llog_init_handle */
 	if (!loghandle->lgh_hdr)
 		goto out;
@@ -90,14 +93,13 @@ static void llog_free_handle(struct llog_handle *loghandle)
 
 void llog_handle_get(struct llog_handle *loghandle)
 {
-	atomic_inc(&loghandle->lgh_refcount);
+	kref_get(&loghandle->lgh_refcount);
 }
 
 void llog_handle_put(struct llog_handle *loghandle)
 {
-	LASSERT(atomic_read(&loghandle->lgh_refcount) > 0);
-	if (atomic_dec_and_test(&loghandle->lgh_refcount))
-		llog_free_handle(loghandle);
+	LASSERT(kref_read(&loghandle->lgh_refcount) > 0);
+	kref_put(&loghandle->lgh_refcount, llog_free_handle);
 }
 
 static int llog_read_header(const struct lu_env *env,
@@ -497,7 +499,7 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt,
 		revert_creds(old_cred);
 
 	if (rc) {
-		llog_free_handle(*lgh);
+		llog_free_handle(&(*lgh)->lgh_refcount);
 		*lgh = NULL;
 	}
 	return rc;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (15 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr() NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static NeilBrown
                   ` (19 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Make this a refcount_t for clarity, and also
use refcount_dec_and_lock() rather than having separate
lock and dec calls.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_log.h |   11 ++++++-----
 drivers/staging/lustre/lustre/obdclass/llog_obd.c  |   12 +++++-------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h
index 83fc9374d7f0..ab0262c20278 100644
--- a/drivers/staging/lustre/lustre/include/lustre_log.h
+++ b/drivers/staging/lustre/lustre/include/lustre_log.h
@@ -243,7 +243,7 @@ struct llog_ctxt {
 	struct llog_operations  *loc_logops;
 	struct llog_handle      *loc_handle;
 	struct mutex		 loc_mutex; /* protect loc_imp */
-	atomic_t		 loc_refcount;
+	refcount_t		 loc_refcount;
 	long			 loc_flags; /* flags, see above defines */
 	/*
 	 * llog chunk size, and llog record size can not be bigger than
@@ -267,9 +267,9 @@ static inline int llog_handle2ops(struct llog_handle *loghandle,
 
 static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt)
 {
-	atomic_inc(&ctxt->loc_refcount);
+	refcount_inc(&ctxt->loc_refcount);
 	CDEBUG(D_INFO, "GETting ctxt %p : new refcount %d\n", ctxt,
-	       atomic_read(&ctxt->loc_refcount));
+	       refcount_read(&ctxt->loc_refcount));
 	return ctxt;
 }
 
@@ -277,9 +277,10 @@ static inline void llog_ctxt_put(struct llog_ctxt *ctxt)
 {
 	if (!ctxt)
 		return;
-	LASSERT_ATOMIC_GT_LT(&ctxt->loc_refcount, 0, LI_POISON);
+	LASSERT(refcount_read(&ctxt->loc_refcount) > 0);
+	LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON);
 	CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt,
-	       atomic_read(&ctxt->loc_refcount) - 1);
+	       refcount_read(&ctxt->loc_refcount) - 1);
 	__llog_ctxt_put(NULL, ctxt);
 }
 
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
index e074b6ee50e6..2b6489e2632d 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
@@ -47,7 +47,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd)
 		return NULL;
 
 	ctxt->loc_obd = obd;
-	atomic_set(&ctxt->loc_refcount, 1);
+	refcount_set(&ctxt->loc_refcount, 1);
 
 	return ctxt;
 }
@@ -71,11 +71,9 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt)
 	struct obd_device *obd;
 	int rc = 0;
 
-	spin_lock(&olg->olg_lock);
-	if (!atomic_dec_and_test(&ctxt->loc_refcount)) {
-		spin_unlock(&olg->olg_lock);
+	if (!refcount_dec_and_lock(&ctxt->loc_refcount, &olg->olg_lock))
 		return rc;
-	}
+
 	olg->olg_ctxts[ctxt->loc_idx] = NULL;
 	spin_unlock(&olg->olg_lock);
 
@@ -116,8 +114,8 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
 	/*
 	 * Banlance the ctxt get when calling llog_cleanup()
 	 */
-	LASSERT(atomic_read(&ctxt->loc_refcount) < LI_POISON);
-	LASSERT(atomic_read(&ctxt->loc_refcount) > 1);
+	LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON);
+	LASSERT(refcount_read(&ctxt->loc_refcount) > 1);
 	llog_ctxt_put(ctxt);
 
 	/*

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (5 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:39   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name NeilBrown
                   ` (29 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Fix mistyped "Balance" in a comment.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/llog_obd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
index 2b6489e2632d..a89ec816b043 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
@@ -112,7 +112,7 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
 	idx = ctxt->loc_idx;
 
 	/*
-	 * Banlance the ctxt get when calling llog_cleanup()
+	 * Balance the ctxt get when calling llog_cleanup()
 	 */
 	LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON);
 	LASSERT(refcount_read(&ctxt->loc_refcount) > 1);

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (9 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:52   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release NeilBrown
                   ` (25 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

This function seems overly complex, the same functionality
is available with much less effort.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/lustre/obdclass/lprocfs_status.c        |   47 +++-----------------
 1 file changed, 7 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 568e6623e0c8..bd24e48f6145 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m,
 int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val,
 			     int mult)
 {
-	long decimal_val, frac_val;
 	int prtn;
 
 	if (count < 10)
 		return -EINVAL;
 
-	decimal_val = val / mult;
-	prtn = snprintf(buffer, count, "%ld", decimal_val);
-	frac_val = val % mult;
-
-	if (prtn < (count - 4) && frac_val > 0) {
-		long temp_frac;
-		int i, temp_mult = 1, frac_bits = 0;
-
-		temp_frac = frac_val * 10;
-		buffer[prtn++] = '.';
-		while (frac_bits < 2 && (temp_frac / mult) < 1) {
-			/* only reserved 2 bits fraction */
-			buffer[prtn++] = '0';
-			temp_frac *= 10;
-			frac_bits++;
-		}
-		/*
-		 * Need to think these cases :
-		 *      1. #echo x.00 > /sys/xxx       output result : x
-		 *      2. #echo x.0x > /sys/xxx       output result : x.0x
-		 *      3. #echo x.x0 > /sys/xxx       output result : x.x
-		 *      4. #echo x.xx > /sys/xxx       output result : x.xx
-		 *      Only reserved 2 bits fraction.
-		 */
-		for (i = 0; i < (5 - prtn); i++)
-			temp_mult *= 10;
-
-		frac_bits = min((int)count - prtn, 3 - frac_bits);
-		prtn += snprintf(buffer + prtn, frac_bits, "%ld",
-				 frac_val * temp_mult / mult);
+	prtn = snprintf(buffer, count, "%ld.%02lu",
+			val / mult,
+			(val % mult) / (mult / 100));
 
+	/* Strip trailing zeroes, and trailing '.' */
+	while (prtn && buffer[prtn-1] == '0')
+		prtn--;
+	if (prtn && buffer[prtn-1] == '.')
 		prtn--;
-		while (buffer[prtn] < '1' || buffer[prtn] > '9') {
-			prtn--;
-			if (buffer[prtn] == '.') {
-				prtn--;
-				break;
-			}
-		}
-		prtn++;
-	}
 	buffer[prtn++] = '\n';
 	return prtn;
 }

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (10 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:53   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea NeilBrown
                   ` (24 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Neither lprocfs_single_release() or lprocfs_seq_release()
add any value to single_release() or seq_release() which
they wrap.
So just use the base functions and discard the wrapper.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lprocfs_status.h |    7 ++-----
 drivers/staging/lustre/lustre/lov/lproc_lov.c      |    2 +-
 .../lustre/lustre/obdclass/lprocfs_status.c        |   14 +-------------
 .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c    |    2 +-
 4 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index d69f395e3d52..8565c28f08ee 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -502,9 +502,6 @@ unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
 			   struct lprocfs_counter *cnt);
 
-int lprocfs_single_release(struct inode *inode, struct file *file);
-int lprocfs_seq_release(struct inode *inode, struct file *file);
-
 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
  * proc entries; otherwise, you will define name##_seq_write function also for
  * a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
@@ -521,7 +518,7 @@ static const struct file_operations name##_fops = {			\
 	.read    = seq_read,						\
 	.write   = custom_seq_write,					\
 	.llseek  = seq_lseek,						\
-	.release = lprocfs_single_release,				\
+	.release = single_release,					\
 }
 
 #define LPROC_SEQ_FOPS_RO(name)	 __LPROC_SEQ_FOPS(name, NULL)
@@ -563,7 +560,7 @@ static const struct file_operations name##_fops = {			\
 	static const struct file_operations name##_##type##_fops = {	\
 		.open	= name##_##type##_open,				\
 		.write	= name##_##type##_write,			\
-		.release = lprocfs_single_release,			\
+		.release = single_release,				\
 	}
 
 struct lustre_attr {
diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c
index fc53f2386c39..cfb274498d30 100644
--- a/drivers/staging/lustre/lustre/lov/lproc_lov.c
+++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c
@@ -264,7 +264,7 @@ static const struct file_operations lov_debugfs_target_fops = {
 	.open		= lov_target_seq_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
-	.release	= lprocfs_seq_release,
+	.release	= seq_release,
 };
 
 static struct attribute *lov_attrs[] = {
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index bd24e48f6145..76d298337e95 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -273,18 +273,6 @@ MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs
 
 #define MAX_STRING_SIZE 128
 
-int lprocfs_single_release(struct inode *inode, struct file *file)
-{
-	return single_release(inode, file);
-}
-EXPORT_SYMBOL(lprocfs_single_release);
-
-int lprocfs_seq_release(struct inode *inode, struct file *file)
-{
-	return seq_release(inode, file);
-}
-EXPORT_SYMBOL(lprocfs_seq_release);
-
 /* lprocfs API calls */
 
 static const struct file_operations lprocfs_generic_fops = { };
@@ -1331,7 +1319,7 @@ const struct file_operations lprocfs_stats_seq_fops = {
 	.read		= seq_read,
 	.write		= lprocfs_stats_seq_write,
 	.llseek		= seq_lseek,
-	.release	= lprocfs_seq_release,
+	.release	= seq_release,
 };
 EXPORT_SYMBOL_GPL(lprocfs_stats_seq_fops);
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 25858b8f6cbd..d09bddaf88ba 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1093,7 +1093,7 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry,
 		.open		= ptlrpc_lprocfs_svc_req_history_open,
 		.read		= seq_read,
 		.llseek		= seq_lseek,
-		.release	= lprocfs_seq_release,
+		.release	= seq_release,
 	};
 
 	ptlrpc_ldebugfs_register(entry, svc->srv_name,

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr()
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (14 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 17:53   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t NeilBrown
                   ` (20 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

This is identical to strnstr() in lib/string.h,
so just use that.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/lustre/obdclass/lprocfs_status.c        |   19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 76d298337e95..27d73c95403d 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1552,22 +1552,6 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer,
 }
 EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);
 
-static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len)
-{
-	size_t l2;
-
-	l2 = strlen(s2);
-	if (!l2)
-		return (char *)s1;
-	while (len >= l2) {
-		len--;
-		if (!memcmp(s1, s2, l2))
-			return (char *)s1;
-		s1++;
-	}
-	return NULL;
-}
-
 /**
  * Find the string \a name in the input \a buffer, and return a pointer to the
  * value immediately following \a name, reducing \a count appropriately.
@@ -1579,8 +1563,7 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
 	char *val;
 	size_t buflen = *count;
 
-	/* there is no strnstr() in rhel5 and ubuntu kernels */
-	val = lprocfs_strnstr(buffer, name, buflen);
+	val = strnstr(buffer, name, buflen);
 	if (!val)
 		return (char *)buffer;
 

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (19 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 32/37] lustre: portals_handle: rename ops to owner NeilBrown
                   ` (15 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

This lock is never held over code that sleeps, and is
only ever held for short periods of time.
So a simple spinlock is best.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd_class.h  |    3 +--
 drivers/staging/lustre/lustre/llite/llite_lib.c    |    6 +++---
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |    4 ++--
 .../lustre/lustre/obdclass/lprocfs_status.c        |    8 ++++----
 4 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 7c2e248a8110..dd480501d7df 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -1688,12 +1688,11 @@ void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
 
 /* root squash info */
-struct rw_semaphore;
 struct root_squash_info {
 	uid_t			rsi_uid;
 	gid_t			rsi_gid;
 	struct list_head	rsi_nosquash_nids;
-	struct rw_semaphore	rsi_sem;
+	spinlock_t		rsi_lock;	/* protects rsi_nosquash_nids */
 };
 
 /* linux-module.c */
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e2417cd5aaed..d97abbfddccf 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -130,7 +130,7 @@ static struct ll_sb_info *ll_init_sbi(void)
 	sbi->ll_squash.rsi_uid = 0;
 	sbi->ll_squash.rsi_gid = 0;
 	INIT_LIST_HEAD(&sbi->ll_squash.rsi_nosquash_nids);
-	init_rwsem(&sbi->ll_squash.rsi_sem);
+	spin_lock_init(&sbi->ll_squash.rsi_lock);
 
 	return sbi;
 }
@@ -2578,7 +2578,7 @@ void ll_compute_rootsquash_state(struct ll_sb_info *sbi)
 	int i;
 
 	/* Update norootsquash flag */
-	down_write(&squash->rsi_sem);
+	spin_lock(&squash->rsi_lock);
 	if (list_empty(&squash->rsi_nosquash_nids)) {
 		spin_lock(&sbi->ll_lock);
 		sbi->ll_flags &= ~LL_SBI_NOROOTSQUASH;
@@ -2606,7 +2606,7 @@ void ll_compute_rootsquash_state(struct ll_sb_info *sbi)
 			sbi->ll_flags &= ~LL_SBI_NOROOTSQUASH;
 		spin_unlock(&sbi->ll_lock);
 	}
-	up_write(&squash->rsi_sem);
+	spin_unlock(&squash->rsi_lock);
 }
 
 /**
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 78ec0fa65c58..db2fbf1f3a50 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -1133,7 +1133,7 @@ static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v)
 	struct root_squash_info *squash = &sbi->ll_squash;
 	int len;
 
-	down_read(&squash->rsi_sem);
+	spin_lock(&squash->rsi_lock);
 	if (!list_empty(&squash->rsi_nosquash_nids)) {
 		len = cfs_print_nidlist(m->buf + m->count, m->size - m->count,
 					&squash->rsi_nosquash_nids);
@@ -1142,7 +1142,7 @@ static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v)
 	} else {
 		seq_puts(m, "NONE\n");
 	}
-	up_read(&squash->rsi_sem);
+	spin_unlock(&squash->rsi_lock);
 
 	return 0;
 }
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 27d73c95403d..aed33068ff3c 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
 	if ((len == 4 && !strncmp(kernbuf, "NONE", len)) ||
 	    (len == 5 && !strncmp(kernbuf, "clear", len))) {
 		/* empty string is special case */
-		down_write(&squash->rsi_sem);
+		spin_lock(&squash->rsi_lock);
 		if (!list_empty(&squash->rsi_nosquash_nids))
 			cfs_free_nidlist(&squash->rsi_nosquash_nids);
-		up_write(&squash->rsi_sem);
+		spin_unlock(&squash->rsi_lock);
 		LCONSOLE_INFO("%s: nosquash_nids is cleared\n", name);
 		kfree(kernbuf);
 		return count;
@@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
 	kfree(kernbuf);
 	kernbuf = NULL;
 
-	down_write(&squash->rsi_sem);
+	spin_lock(&squash->rsi_lock);
 	if (!list_empty(&squash->rsi_nosquash_nids))
 		cfs_free_nidlist(&squash->rsi_nosquash_nids);
 	list_splice(&tmp, &squash->rsi_nosquash_nids);
-	up_write(&squash->rsi_sem);
+	spin_unlock(&squash->rsi_lock);
 
 	return count;
 

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (13 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 19:07   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr() NeilBrown
                   ` (21 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Some of these are unused.
One is used in a minimal way where it is easier to use
an explicit number.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 --
 drivers/staging/lustre/lustre/llite/llite_lib.c    |    6 ++----
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |    4 ----
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 --
 .../lustre/lustre/obdclass/lprocfs_status.c        |    2 --
 5 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 74c7644d6ef8..261857e4540d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -392,8 +392,6 @@ static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns)
 	return 0;
 }
 
-#undef MAX_STRING_SIZE
-
 struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
 {
 	LASSERT(res);
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index d97abbfddccf..fda6d9b07952 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -906,8 +906,6 @@ void ll_lli_init(struct ll_inode_info *lli)
 	memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE);
 }
 
-#define MAX_STRING_SIZE 128
-
 int ll_fill_super(struct super_block *sb)
 {
 	struct lustre_profile *lprof = NULL;
@@ -916,7 +914,7 @@ int ll_fill_super(struct super_block *sb)
 	char *dt = NULL, *md = NULL;
 	char *profilenm = get_profile_name(sb);
 	struct config_llog_instance *cfg;
-	char name[MAX_STRING_SIZE];
+	char name[128];
 	char *ptr;
 	int len;
 	int err;
@@ -960,7 +958,7 @@ int ll_fill_super(struct super_block *sb)
 		len -= 7;
 
 	/* Mount info */
-	snprintf(name, MAX_STRING_SIZE, "%.*s-%px", len,
+	snprintf(name, sizeof(name), "%.*s-%px", len,
 		 lsi->lsi_lmd->lmd_profile, sb);
 
 	/* Call ll_debugsfs_register_super() before lustre_process_log()
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index db2fbf1f3a50..5ed703d7bb1e 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -1187,8 +1187,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
 	{ NULL }
 };
 
-#define MAX_STRING_SIZE 128
-
 static struct attribute *llite_attrs[] = {
 	&lustre_attr_blocksize.attr,
 	&lustre_attr_stat_blocksize.attr,
@@ -1434,8 +1432,6 @@ void ll_debugfs_unregister_super(struct super_block *sb)
 	lprocfs_free_stats(&sbi->ll_stats);
 }
 
-#undef MAX_STRING_SIZE
-
 #define pct(a, b) (b ? a * 100 / b : 0)
 
 static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 35dff0e96bf7..138e124bd05e 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -273,8 +273,6 @@ static int lmv_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize)
 	return rc;
 }
 
-#define MAX_STRING_SIZE 128
-
 static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
 {
 	struct lmv_obd *lmv = &obd->u.lmv;
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index aed33068ff3c..a179b0d6979e 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -271,8 +271,6 @@ static int lprocfs_no_percpu_stats;
 module_param(lprocfs_no_percpu_stats, int, 0644);
 MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats");
 
-#define MAX_STRING_SIZE 128
-
 /* lprocfs API calls */
 
 static const struct file_operations lprocfs_generic_fops = { };

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (21 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 32/37] lustre: portals_handle: rename ops to owner NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 18:09   ` James Simmons
  2019-02-26 20:55   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 NeilBrown
                   ` (13 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

These shift loops seem to be trying to avoid doing a
multiplication.
We same effect can be achieved more transparently using
rounddown_pow_of_two().  Even though there is a multiplication
in the C code, the resulting machine code just does a single shift.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/lustre/obdclass/lprocfs_status.c        |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index a179b0d6979e..637aaca96888 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
 		u32 blk_size = osfs.os_bsize >> 10;
 		u64 result = osfs.os_blocks;
 
-		while (blk_size >>= 1)
-			result <<= 1;
-
+		result *= rounddown_pow_of_two(blk_size);
 		return sprintf(buf, "%llu\n", result);
 	}
 
@@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
 		u32 blk_size = osfs.os_bsize >> 10;
 		u64 result = osfs.os_bfree;
 
-		while (blk_size >>= 1)
-			result <<= 1;
+		result *= rounddown_pow_of_two(blk_size);
 
 		return sprintf(buf, "%llu\n", result);
 	}
@@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
 		u32 blk_size = osfs.os_bsize >> 10;
 		u64 result = osfs.os_bavail;
 
-		while (blk_size >>= 1)
-			result <<= 1;
+		result *= rounddown_pow_of_two(blk_size);
 
 		return sprintf(buf, "%llu\n", result);
 	}

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (26 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2 NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 18:51   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 27/37] lustre: discard lu_ref NeilBrown
                   ` (8 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

This patch changes a lot of places that use spaces for
alignment to instead use tabs - though in one case in a
comment, spaces are used in place of tabs to be more consistent.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/libcfs_cpu.h       |    2 
 .../lustre/include/linux/libcfs/libcfs_crypto.h    |   10 -
 .../lustre/include/linux/libcfs/libcfs_debug.h     |   30 +-
 .../lustre/include/linux/libcfs/libcfs_fail.h      |   12 -
 .../lustre/include/linux/libcfs/libcfs_hash.h      |   24 +
 .../lustre/include/linux/libcfs/libcfs_private.h   |    2 
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |    4 
 .../staging/lustre/include/linux/lnet/socklnd.h    |    2 
 .../lustre/include/uapi/linux/lnet/libcfs_debug.h  |  124 +++----
 .../lustre/include/uapi/linux/lnet/libcfs_ioctl.h  |   56 +--
 .../lustre/include/uapi/linux/lnet/lnet-types.h    |   10 -
 .../lustre/include/uapi/linux/lnet/lnetst.h        |   14 -
 .../lustre/include/uapi/linux/lnet/nidstr.h        |    6 
 .../include/uapi/linux/lustre/lustre_fiemap.h      |    2 
 .../lustre/include/uapi/linux/lustre/lustre_idl.h  |  350 +++++++++----------
 .../lustre/include/uapi/linux/lustre/lustre_user.h |  378 ++++++++++----------
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |   60 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h    |   32 +-
 drivers/staging/lustre/lnet/lnet/nidstrings.c      |    4 
 drivers/staging/lustre/lnet/selftest/timer.c       |    8 
 drivers/staging/lustre/lustre/fld/lproc_fld.c      |    2 
 .../staging/lustre/lustre/include/lustre_import.h  |    6 
 drivers/staging/lustre/lustre/include/obd.h        |   10 -
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    6 
 drivers/staging/lustre/lustre/llite/file.c         |    2 
 drivers/staging/lustre/lustre/llite/vvp_internal.h |    2 
 drivers/staging/lustre/lustre/llite/xattr.c        |    2 
 drivers/staging/lustre/lustre/lov/lov_ea.c         |    2 
 drivers/staging/lustre/lustre/lov/lov_obd.c        |   26 +
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |   24 +
 drivers/staging/lustre/lustre/obdclass/genops.c    |    6 
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 
 drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |    2 
 drivers/staging/lustre/lustre/osc/osc_request.c    |   40 +-
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c    |    2 
 35 files changed, 635 insertions(+), 635 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 3e51752491d0..56905317fab0 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -372,7 +372,7 @@ enum {
 
 struct cfs_percpt_lock {
 	/* cpu-partition-table for this lock */
-	struct cfs_cpt_table     *pcl_cptab;
+	struct cfs_cpt_table	 *pcl_cptab;
 	/* exclusively locked */
 	unsigned int		  pcl_locked;
 	/* private lock table */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
index ca8620b93de7..03da963b8d33 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
@@ -33,17 +33,17 @@
 struct page;
 
 struct cfs_crypto_hash_type {
-	char		*cht_name;      /*< hash algorithm name, equal to
+	char		*cht_name;	/*< hash algorithm name, equal to
 					 * format name for crypto api
 					 */
-	unsigned int    cht_key;	/*< init key by default (valid for
+	unsigned int	cht_key;	/*< init key by default (valid for
 					 * 4 bytes context like crc32, adler
 					 */
-	unsigned int    cht_size;       /**< hash digest size */
+	unsigned int	cht_size;	/**< hash digest size */
 };
 
 enum cfs_crypto_hash_alg {
-	CFS_HASH_ALG_NULL       = 0,
+	CFS_HASH_ALG_NULL	= 0,
 	CFS_HASH_ALG_ADLER32,
 	CFS_HASH_ALG_CRC32,
 	CFS_HASH_ALG_CRC32C,
@@ -54,7 +54,7 @@ enum cfs_crypto_hash_alg {
 	CFS_HASH_ALG_SHA384,
 	CFS_HASH_ALG_SHA512,
 	CFS_HASH_ALG_MAX,
-	CFS_HASH_ALG_SPEED_MAX = CFS_HASH_ALG_MD5,
+	CFS_HASH_ALG_SPEED_MAX	= CFS_HASH_ALG_MD5,
 	CFS_HASH_ALG_UNKNOWN	= 0xff
 };
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 3fd6ad7a3b56..ba5d5ba2dac2 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -68,11 +68,11 @@ extern unsigned int libcfs_panic_on_lbug;
 #if !defined(__x86_64__)
 # ifdef __ia64__
 #  define CDEBUG_STACK() (THREAD_SIZE -					\
-			  ((unsigned long)__builtin_dwarf_cfa() &       \
+			  ((unsigned long)__builtin_dwarf_cfa() &	\
 			   (THREAD_SIZE - 1)))
 # else
 #  define CDEBUG_STACK() (THREAD_SIZE -					\
-			  ((unsigned long)__builtin_frame_address(0) &  \
+			  ((unsigned long)__builtin_frame_address(0) &	\
 			   (THREAD_SIZE - 1)))
 # endif /* __ia64__ */
 
@@ -87,7 +87,7 @@ do {									\
 		(msgdata)->msg_mask = mask;				\
 		(msgdata)->msg_cdls = cdls;				\
 		dump_stack();						\
-	      /*panic("LBUG");*/					\
+		/*panic("LBUG");*/					\
 	}								\
 } while (0)
 #define CFS_CHECK_STACK(msgdata, mask, cdls)  __CHECK_STACK(msgdata, mask, cdls)
@@ -120,22 +120,22 @@ struct libcfs_debug_msg_data {
 
 #define LIBCFS_DEBUG_MSG_DATA_INIT(data, mask, cdls)			\
 do {									\
-	(data)->msg_subsys = DEBUG_SUBSYSTEM;				\
-	(data)->msg_file   = __FILE__;					\
-	(data)->msg_fn     = __func__;					\
-	(data)->msg_line   = __LINE__;					\
-	(data)->msg_cdls   = (cdls);					\
-	(data)->msg_mask   = (mask);					\
+	(data)->msg_subsys	= DEBUG_SUBSYSTEM;			\
+	(data)->msg_file	= __FILE__;				\
+	(data)->msg_fn		= __func__;				\
+	(data)->msg_line	= __LINE__;				\
+	(data)->msg_cdls	= (cdls);				\
+	(data)->msg_mask	= (mask);				\
 } while (0)
 
 #define LIBCFS_DEBUG_MSG_DATA_DECL(dataname, mask, cdls)		\
 	static struct libcfs_debug_msg_data dataname = {		\
-	       .msg_subsys = DEBUG_SUBSYSTEM,				\
-	       .msg_file   = __FILE__,					\
-	       .msg_fn     = __func__,					\
-	       .msg_line   = __LINE__,					\
-	       .msg_cdls   = (cdls)	 };				\
-	dataname.msg_mask   = (mask)
+		.msg_subsys	= DEBUG_SUBSYSTEM,			\
+		.msg_file	= __FILE__,				\
+		.msg_fn		= __func__,				\
+		.msg_line	= __LINE__,				\
+		.msg_cdls	= (cdls)	 };			\
+	dataname.msg_mask	= (mask)
 
 /**
  * Filters out logging messages based on mask and subsystem.
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
index 4a4197874f80..0e73eef6a992 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
@@ -47,10 +47,10 @@ int __cfs_fail_check_set(u32 id, u32 value, int set);
 int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set);
 
 enum {
-	CFS_FAIL_LOC_NOSET      = 0,
-	CFS_FAIL_LOC_ORSET      = 1,
-	CFS_FAIL_LOC_RESET      = 2,
-	CFS_FAIL_LOC_VALUE      = 3
+	CFS_FAIL_LOC_NOSET	= 0,
+	CFS_FAIL_LOC_ORSET	= 1,
+	CFS_FAIL_LOC_RESET	= 2,
+	CFS_FAIL_LOC_VALUE	= 3
 };
 
 /* Failure injection control */
@@ -76,8 +76,8 @@ enum {
 static inline bool CFS_FAIL_PRECHECK(u32 id)
 {
 	return cfs_fail_loc &&
-	       ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) ||
-		(cfs_fail_loc & id & CFS_FAULT));
+		((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) ||
+		 (cfs_fail_loc & id & CFS_FAULT));
 }
 
 static inline int cfs_fail_check_set(u32 id, u32 value,
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
index be315958a4b3..89d25ca57c18 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
@@ -304,25 +304,25 @@ struct cfs_hash_ops {
 	unsigned int (*hs_hash)(struct cfs_hash *hs, const void *key,
 				unsigned int mask);
 	/** return key address of @hnode */
-	void *   (*hs_key)(struct hlist_node *hnode);
+	void *	(*hs_key)(struct hlist_node *hnode);
 	/** copy key from @hnode to @key */
-	void     (*hs_keycpy)(struct hlist_node *hnode, void *key);
+	void	(*hs_keycpy)(struct hlist_node *hnode, void *key);
 	/**
 	 *  compare @key with key of @hnode
 	 *  returns 1 on a match
 	 */
-	int      (*hs_keycmp)(const void *key, struct hlist_node *hnode);
+	int	(*hs_keycmp)(const void *key, struct hlist_node *hnode);
 	/** return object address of @hnode, i.e: container_of(...hnode) */
-	void *   (*hs_object)(struct hlist_node *hnode);
+	void *	(*hs_object)(struct hlist_node *hnode);
 	/** get refcount of item, always called with holding bucket-lock */
-	void     (*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode);
+	void	(*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode);
 	/** release refcount of item */
-	void     (*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode);
+	void	(*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode);
 	/** release refcount of item, always called with holding bucket-lock */
-	void     (*hs_put_locked)(struct cfs_hash *hs,
-				  struct hlist_node *hnode);
+	void	(*hs_put_locked)(struct cfs_hash *hs,
+				 struct hlist_node *hnode);
 	/** it's called before removing of @hnode */
-	void     (*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode);
+	void	(*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode);
 };
 
 /** total number of buckets in @hs */
@@ -460,8 +460,8 @@ static inline int
 cfs_hash_bkt_size(struct cfs_hash *hs)
 {
 	return offsetof(struct cfs_hash_bucket, hsb_head[0]) +
-	       hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) +
-	       hs->hs_extra_bytes;
+		hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) +
+		hs->hs_extra_bytes;
 }
 
 static inline unsigned
@@ -703,7 +703,7 @@ void *cfs_hash_del(struct cfs_hash *hs, const void *key,
 void *cfs_hash_del_key(struct cfs_hash *hs, const void *key);
 
 /* Hash lookup/for_each functions */
-#define CFS_HASH_LOOP_HOG       1024
+#define CFS_HASH_LOOP_HOG	1024
 
 typedef int (*cfs_hash_for_each_cb_t)(struct cfs_hash *hs,
 				      struct cfs_hash_bd *bd,
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index d525e4f928fe..515fd63708c0 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -141,7 +141,7 @@ void  cfs_array_free(void *vars);
 #define LASSERT_ATOMIC_GT_LT(a, v1, v2)				\
 do {								\
 	int __v = atomic_read(a);				\
-	LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v);     \
+	LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v);	\
 } while (0)
 
 /** assert value of @a is great than @v1 and little/equal to @v2 */
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index fb5d07460243..e60c446fbb27 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -611,7 +611,7 @@ void lnet_counters_reset(void);
 unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov);
 int lnet_extract_iov(int dst_niov, struct kvec *dst,
 		     int src_niov, const struct kvec *src,
-		      unsigned int offset, unsigned int len);
+		     unsigned int offset, unsigned int len);
 
 unsigned int lnet_kiov_nob(unsigned int niov, struct bio_vec *iov);
 int lnet_extract_kiov(int dst_niov, struct bio_vec *dst,
@@ -827,7 +827,7 @@ void lnet_incr_stats(struct lnet_element_stats *stats,
 		     enum lnet_stats_type stats_type);
 
 u32 lnet_sum_stats(struct lnet_element_stats *stats,
-		     enum lnet_stats_type stats_type);
+		   enum lnet_stats_type stats_type);
 
 void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
 			      struct lnet_element_stats *stats);
diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h
index ca814afd34ef..9f318b73cd34 100644
--- a/drivers/staging/lustre/include/linux/lnet/socklnd.h
+++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h
@@ -41,7 +41,7 @@
 struct ksock_hello_msg {
 	u32		kshm_magic;	/* magic number of socklnd message */
 	u32		kshm_version;	/* version of socklnd message */
-	lnet_nid_t      kshm_src_nid;	/* sender's nid */
+	lnet_nid_t	kshm_src_nid;	/* sender's nid */
 	lnet_nid_t	kshm_dst_nid;	/* destination nid */
 	lnet_pid_t	kshm_src_pid;	/* sender's pid */
 	lnet_pid_t	kshm_dst_pid;	/* destination pid */
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h
index 2672fe7ae103..91d80ab064ad 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h
@@ -62,38 +62,38 @@ struct ptldebug_header {
 #define PH_FLAG_FIRST_RECORD	1
 
 /* Debugging subsystems (32 bits, non-overlapping) */
-#define S_UNDEFINED     0x00000001
-#define S_MDC           0x00000002
-#define S_MDS           0x00000004
-#define S_OSC           0x00000008
-#define S_OST           0x00000010
-#define S_CLASS         0x00000020
-#define S_LOG           0x00000040
-#define S_LLITE         0x00000080
-#define S_RPC           0x00000100
-#define S_MGMT          0x00000200
-#define S_LNET          0x00000400
-#define S_LND           0x00000800 /* ALL LNDs */
-#define S_PINGER        0x00001000
-#define S_FILTER        0x00002000
-#define S_LIBCFS        0x00004000
-#define S_ECHO          0x00008000
-#define S_LDLM          0x00010000
-#define S_LOV           0x00020000
-#define S_LQUOTA        0x00040000
-#define S_OSD           0x00080000
-#define S_LFSCK         0x00100000
-#define S_SNAPSHOT      0x00200000
+#define S_UNDEFINED	0x00000001
+#define S_MDC		0x00000002
+#define S_MDS		0x00000004
+#define S_OSC		0x00000008
+#define S_OST		0x00000010
+#define S_CLASS		0x00000020
+#define S_LOG		0x00000040
+#define S_LLITE		0x00000080
+#define S_RPC		0x00000100
+#define S_MGMT		0x00000200
+#define S_LNET		0x00000400
+#define S_LND		0x00000800 /* ALL LNDs */
+#define S_PINGER	0x00001000
+#define S_FILTER	0x00002000
+#define S_LIBCFS	0x00004000
+#define S_ECHO		0x00008000
+#define S_LDLM		0x00010000
+#define S_LOV		0x00020000
+#define S_LQUOTA	0x00040000
+#define S_OSD		0x00080000
+#define S_LFSCK		0x00100000
+#define S_SNAPSHOT	0x00200000
 /* unused */
-#define S_LMV           0x00800000 /* b_new_cmd */
+#define S_LMV		0x00800000 /* b_new_cmd */
 /* unused */
-#define S_SEC           0x02000000 /* upcall cache */
-#define S_GSS           0x04000000 /* b_new_cmd */
+#define S_SEC		0x02000000 /* upcall cache */
+#define S_GSS		0x04000000 /* b_new_cmd */
 /* unused */
-#define S_MGC           0x10000000
-#define S_MGS           0x20000000
-#define S_FID           0x40000000 /* b_new_cmd */
-#define S_FLD           0x80000000 /* b_new_cmd */
+#define S_MGC		0x10000000
+#define S_MGS		0x20000000
+#define S_FID		0x40000000 /* b_new_cmd */
+#define S_FLD		0x80000000 /* b_new_cmd */
 
 #define LIBCFS_DEBUG_SUBSYS_NAMES {					\
 	"undefined", "mdc", "mds", "osc", "ost", "class", "log",	\
@@ -103,38 +103,38 @@ struct ptldebug_header {
 	"fid", "fld", NULL }
 
 /* Debugging masks (32 bits, non-overlapping) */
-#define D_TRACE         0x00000001 /* ENTRY/EXIT markers */
-#define D_INODE         0x00000002
-#define D_SUPER         0x00000004
-#define D_EXT2          0x00000008 /* anything from ext2_debug */
-#define D_MALLOC        0x00000010 /* print malloc, free information */
-#define D_CACHE         0x00000020 /* cache-related items */
-#define D_INFO          0x00000040 /* general information */
-#define D_IOCTL         0x00000080 /* ioctl related information */
-#define D_NETERROR      0x00000100 /* network errors */
-#define D_NET           0x00000200 /* network communications */
-#define D_WARNING       0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
-#define D_BUFFS         0x00000800
-#define D_OTHER         0x00001000
-#define D_DENTRY        0x00002000
-#define D_NETTRACE      0x00004000
-#define D_PAGE          0x00008000 /* bulk page handling */
-#define D_DLMTRACE      0x00010000
-#define D_ERROR         0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
-#define D_EMERG         0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
-#define D_HA            0x00080000 /* recovery and failover */
-#define D_RPCTRACE      0x00100000 /* for distributed debugging */
-#define D_VFSTRACE      0x00200000
-#define D_READA         0x00400000 /* read-ahead */
-#define D_MMAP          0x00800000
-#define D_CONFIG        0x01000000
-#define D_CONSOLE       0x02000000
-#define D_QUOTA         0x04000000
-#define D_SEC           0x08000000
-#define D_LFSCK         0x10000000 /* For both OI scrub and LFSCK */
-#define D_HSM           0x20000000
-#define D_SNAPSHOT      0x40000000 /* snapshot */
-#define D_LAYOUT        0x80000000
+#define D_TRACE		0x00000001 /* ENTRY/EXIT markers */
+#define D_INODE		0x00000002
+#define D_SUPER		0x00000004
+#define D_EXT2		0x00000008 /* anything from ext2_debug */
+#define D_MALLOC	0x00000010 /* print malloc, free information */
+#define D_CACHE		0x00000020 /* cache-related items */
+#define D_INFO		0x00000040 /* general information */
+#define D_IOCTL		0x00000080 /* ioctl related information */
+#define D_NETERROR	0x00000100 /* network errors */
+#define D_NET		0x00000200 /* network communications */
+#define D_WARNING	0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
+#define D_BUFFS		0x00000800
+#define D_OTHER		0x00001000
+#define D_DENTRY	0x00002000
+#define D_NETTRACE	0x00004000
+#define D_PAGE		0x00008000 /* bulk page handling */
+#define D_DLMTRACE	0x00010000
+#define D_ERROR		0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
+#define D_EMERG		0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
+#define D_HA		0x00080000 /* recovery and failover */
+#define D_RPCTRACE	0x00100000 /* for distributed debugging */
+#define D_VFSTRACE	0x00200000
+#define D_READA		0x00400000 /* read-ahead */
+#define D_MMAP		0x00800000
+#define D_CONFIG	0x01000000
+#define D_CONSOLE	0x02000000
+#define D_QUOTA		0x04000000
+#define D_SEC		0x08000000
+#define D_LFSCK		0x10000000 /* For both OI scrub and LFSCK */
+#define D_HSM		0x20000000
+#define D_SNAPSHOT	0x40000000 /* snapshot */
+#define D_LAYOUT	0x80000000
 
 #define LIBCFS_DEBUG_MASKS_NAMES {					\
 	"trace", "inode", "super", "ext2", "malloc", "cache", "info",	\
@@ -144,7 +144,7 @@ struct ptldebug_header {
 	"console", "quota", "sec", "lfsck", "hsm", "snapshot", "layout",\
 	NULL }
 
-#define D_CANTMASK   (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
+#define D_CANTMASK	(D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
 
 #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log"
 
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h
index 4590f65c333f..765466f41d61 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h
@@ -82,41 +82,41 @@ struct libcfs_debug_ioctl_data {
 };
 
 /* 'f' ioctls are defined in lustre_ioctl.h and lustre_user.h except for: */
-#define LIBCFS_IOC_DEBUG_MASK		   _IOWR('f', 250, long)
-#define IOCTL_LIBCFS_TYPE		   long
+#define LIBCFS_IOC_DEBUG_MASK		_IOWR('f', 250, long)
+#define IOCTL_LIBCFS_TYPE		long
 
-#define IOC_LIBCFS_TYPE			   ('e')
-#define IOC_LIBCFS_MIN_NR		   30
+#define IOC_LIBCFS_TYPE			('e')
+#define IOC_LIBCFS_MIN_NR		30
 /* libcfs ioctls */
 /* IOC_LIBCFS_PANIC obsolete in 2.8.0, was _IOWR('e', 30, IOCTL_LIBCFS_TYPE) */
-#define IOC_LIBCFS_CLEAR_DEBUG		   _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_MARK_DEBUG		   _IOWR('e', 32, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CLEAR_DEBUG		_IOWR('e', 31, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_MARK_DEBUG		_IOWR('e', 32, IOCTL_LIBCFS_TYPE)
 /* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */
 /* lnet ioctls */
-#define IOC_LIBCFS_GET_NI		   _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_FAIL_NID		   _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_NOTIFY_ROUTER	   _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_UNCONFIGURE		   _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_NI		_IOWR('e', 50, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_FAIL_NID		_IOWR('e', 51, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_NOTIFY_ROUTER	_IOWR('e', 55, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_UNCONFIGURE		_IOWR('e', 56, IOCTL_LIBCFS_TYPE)
 /*	 IOC_LIBCFS_PORTALS_COMPATIBILITY  _IOWR('e', 57, IOCTL_LIBCFS_TYPE) */
-#define IOC_LIBCFS_LNET_DIST		   _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_CONFIGURE		   _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_TESTPROTOCOMPAT	   _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_PING			   _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_PING_PEER               _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_LNETST		   _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_LNET_FAULT		   _IOWR('e', 64, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNET_DIST		_IOWR('e', 58, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CONFIGURE		_IOWR('e', 59, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_TESTPROTOCOMPAT	_IOWR('e', 60, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PING			_IOWR('e', 61, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PING_PEER		_IOWR('e', 62, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNETST		_IOWR('e', 63, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNET_FAULT		_IOWR('e', 64, IOCTL_LIBCFS_TYPE)
 /* lnd ioctls */
-#define IOC_LIBCFS_REGISTER_MYNID	   _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_CLOSE_CONNECTION	   _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_PUSH_CONNECTION	   _IOWR('e', 72, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_CONN		   _IOWR('e', 73, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_DEL_PEER		   _IOWR('e', 74, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_ADD_PEER		   _IOWR('e', 75, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_PEER		   _IOWR('e', 76, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_DISCOVER                _IOWR('e', 77, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_ADD_INTERFACE	   _IOWR('e', 78, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_DEL_INTERFACE	   _IOWR('e', 79, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_GET_INTERFACE	   _IOWR('e', 80, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_REGISTER_MYNID	_IOWR('e', 70, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CLOSE_CONNECTION	_IOWR('e', 71, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PUSH_CONNECTION	_IOWR('e', 72, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_CONN		_IOWR('e', 73, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_PEER		_IOWR('e', 74, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_PEER		_IOWR('e', 75, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_PEER		_IOWR('e', 76, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DISCOVER		_IOWR('e', 77, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_INTERFACE	_IOWR('e', 78, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_INTERFACE	_IOWR('e', 79, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_INTERFACE	_IOWR('e', 80, IOCTL_LIBCFS_TYPE)
 
 /*
  * DLC Specific IOCTL numbers.
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
index 4fcc5336d927..956af3c53cfc 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
@@ -289,9 +289,9 @@ struct lnet_counters {
 	__u64	drop_length;
 } __packed;
 
-#define LNET_NI_STATUS_UP      0x15aac0de
-#define LNET_NI_STATUS_DOWN    0xdeadface
-#define LNET_NI_STATUS_INVALID 0x00000000
+#define LNET_NI_STATUS_UP	0x15aac0de
+#define LNET_NI_STATUS_DOWN	0xdeadface
+#define LNET_NI_STATUS_INVALID	0x00000000
 
 #define LNET_INTERFACES_NUM		16
 
@@ -596,7 +596,7 @@ enum lnet_event_kind {
 	LNET_EVENT_UNLINK,
 };
 
-#define LNET_SEQ_GT(a, b)      (((signed long)((a) - (b))) > 0)
+#define LNET_SEQ_GT(a, b)	(((signed long)((a) - (b))) > 0)
 
 /**
  * Information about an event on a MD.
@@ -650,7 +650,7 @@ struct lnet_event {
 	 * The message type, to ensure a handler for LNET_EVENT_SEND can
 	 * distinguish between LNET_MSG_GET and LNET_MSG_PUT.
 	 */
-	__u32               msg_type;
+	__u32			msg_type;
 	/**
 	 * Indicates the completion status of the operation. It's 0 for
 	 * successful operations, otherwise it's an error code.
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h
index a6eebee1a69c..27fcd91931a6 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h
@@ -58,7 +58,7 @@
 					 */
 #define LSTIO_GROUP_DEL		0xC13	/* delete group */
 #define LSTIO_NODES_ADD		0xC14	/* add nodes to specified group */
-#define LSTIO_GROUP_UPDATE      0xC15	/* update group */
+#define LSTIO_GROUP_UPDATE	0xC15	/* update group */
 #define LSTIO_BATCH_ADD		0xC20	/* add batch */
 #define LSTIO_BATCH_START	0xC21	/* start batch */
 #define LSTIO_BATCH_STOP	0xC22	/* stop batch */
@@ -100,9 +100,9 @@ struct lstcon_ndlist_ent {
 };				/*** node_list entry, for list_batch command */
 
 struct lstcon_test_ent {
-	int	tse_type;       /* test type */
-	int	tse_loop;       /* loop count */
-	int	tse_concur;     /* concurrency of test */
+	int	tse_type;	/* test type */
+	int	tse_loop;	/* loop count */
+	int	tse_concur;	/* concurrency of test */
 };				/* test summary entry, for
 				 * list_batch command
 				 */
@@ -520,9 +520,9 @@ enum lst_brw_flags {
 
 struct lst_test_bulk_param {
 	int	blk_opc;	/* bulk operation code */
-	int	blk_size;       /* size (bytes) */
-	int	blk_time;       /* time of running the test*/
-	int	blk_flags;      /* reserved flags */
+	int	blk_size;	/* size (bytes) */
+	int	blk_time;	/* time of running the test*/
+	int	blk_flags;	/* reserved flags */
 	int	blk_cli_off;	/* bulk offset on client */
 	int	blk_srv_off;	/* reserved: bulk offset on server */
 };
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h
index 3c5901d81d52..6c49d59f4f85 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h
@@ -44,7 +44,7 @@ enum {
 	/*GMLND		= 3, removed v2_0_0-rc1a-16-gc660aac	*/
 	/*PTLLND	= 4, removed v2_7_50			*/
 	O2IBLND		= 5,
-	/*CIBLND        = 6, removed v2_0_0-rc1a-175-gd2b8a0e	*/
+	/*CIBLND	= 6, removed v2_0_0-rc1a-175-gd2b8a0e	*/
 	/*OPENIBLND	= 7, removed v2_0_0-rc1a-175-gd2b8a0e	*/
 	/*IIBLND	= 8, removed v2_0_0-rc1a-175-gd2b8a0e	*/
 	LOLND		= 9,
@@ -57,8 +57,8 @@ 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_COUNT	1024	/* # of nidstrings */
+#define LNET_NIDSTR_SIZE	32	/* size of each one (see below for usage) */
 
 /* support decl needed by both kernel and user space */
 char *libcfs_next_nidstring(void);
diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
index d24a93e57ed7..7ecb6f6354cc 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
@@ -49,7 +49,7 @@
 static inline size_t fiemap_count_to_size(size_t extent_count)
 {
 	return sizeof(struct fiemap) + extent_count *
-				       sizeof(struct fiemap_extent);
+		sizeof(struct fiemap_extent);
 }
 
 static inline unsigned int fiemap_size_to_count(size_t array_size)
diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
index bffe62e87e00..62b9a3301c4d 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
@@ -443,14 +443,14 @@ struct luda_type {
 };
 
 #ifndef IFSHIFT
-#define IFSHIFT                 12
+#define IFSHIFT		12
 #endif
 
 #ifndef IFTODT
-#define IFTODT(type)		(((type) & S_IFMT) >> IFSHIFT)
+#define IFTODT(type)	(((type) & S_IFMT) >> IFSHIFT)
 #endif
 #ifndef DTTOIF
-#define DTTOIF(dirtype)		((dirtype) << IFSHIFT)
+#define DTTOIF(dirtype)	((dirtype) << IFSHIFT)
 #endif
 
 struct lu_dirpage {
@@ -551,8 +551,8 @@ static inline void lustre_handle_copy(struct lustre_handle *tgt,
 }
 
 /* flags for lm_flags */
-#define MSGHDR_AT_SUPPORT	       0x1
-#define MSGHDR_CKSUM_INCOMPAT18	 0x2
+#define MSGHDR_AT_SUPPORT	0x1
+#define MSGHDR_CKSUM_INCOMPAT18	0x2
 
 #define lustre_msg lustre_msg_v2
 /* we depend on this structure to be 8-byte aligned */
@@ -570,7 +570,7 @@ struct lustre_msg_v2 {
 };
 
 /* without gss, ptlrpc_body is put@the first buffer. */
-#define PTLRPC_NUM_VERSIONS     4
+#define PTLRPC_NUM_VERSIONS	4
 
 struct ptlrpc_body_v3 {
 	struct lustre_handle pb_handle;
@@ -578,8 +578,8 @@ struct ptlrpc_body_v3 {
 	__u32 pb_version;
 	__u32 pb_opc;
 	__u32 pb_status;
-	__u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
-	__u16 pb_tag;      /* virtual slot idx for multiple modifying RPCs */
+	__u64 pb_last_xid;	/* highest replied XID without lower unreplied XID */
+	__u16 pb_tag;		/* virtual slot idx for multiple modifying RPCs */
 	__u16 pb_padding0;
 	__u32 pb_padding1;
 	__u64 pb_last_committed;
@@ -587,13 +587,13 @@ struct ptlrpc_body_v3 {
 	__u32 pb_flags;
 	__u32 pb_op_flags;
 	__u32 pb_conn_cnt;
-	__u32 pb_timeout;  /* for req, the deadline, for rep, the service est */
-	__u32 pb_service_time; /* for rep, actual service time */
+	__u32 pb_timeout;	/* for req, the deadline, for rep, the service est */
+	__u32 pb_service_time;	/* for rep, actual service time */
 	__u32 pb_limit;
 	__u64 pb_slv;
 	/* VBR: pre-versions */
 	__u64 pb_pre_versions[PTLRPC_NUM_VERSIONS];
-	__u64 pb_mbits; /**< match bits for bulk request */
+	__u64 pb_mbits;		/**< match bits for bulk request */
 	/* padding for future needs */
 	__u64 pb_padding64_0;
 	__u64 pb_padding64_1;
@@ -601,7 +601,7 @@ struct ptlrpc_body_v3 {
 	char  pb_jobid[LUSTRE_JOBID_SIZE];
 };
 
-#define ptlrpc_body     ptlrpc_body_v3
+#define ptlrpc_body	ptlrpc_body_v3
 
 struct ptlrpc_body_v2 {
 	struct lustre_handle pb_handle;
@@ -609,8 +609,8 @@ struct ptlrpc_body_v2 {
 	__u32 pb_version;
 	__u32 pb_opc;
 	__u32 pb_status;
-	__u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
-	__u16 pb_tag;      /* virtual slot idx for multiple modifying RPCs */
+	__u64 pb_last_xid;	/* highest replied XID without lower unreplied XID */
+	__u16 pb_tag;		/* virtual slot idx for multiple modifying RPCs */
 	__u16 pb_padding0;
 	__u32 pb_padding1;
 	__u64 pb_last_committed;
@@ -618,10 +618,10 @@ struct ptlrpc_body_v2 {
 	__u32 pb_flags;
 	__u32 pb_op_flags;
 	__u32 pb_conn_cnt;
-	__u32 pb_timeout;  /* for req, the deadline, for rep, the service est */
-	__u32 pb_service_time; /* for rep, actual service time, also used for
-				* net_latency of req
-				*/
+	__u32 pb_timeout;	/* for req, the deadline, for rep, the service est */
+	__u32 pb_service_time;	/* for rep, actual service time, also used for
+				 * net_latency of req
+				 */
 	__u32 pb_limit;
 	__u64 pb_slv;
 	/* VBR: pre-versions */
@@ -881,66 +881,66 @@ enum cksum_type {
 
 /* opcodes */
 enum ost_cmd {
-	OST_REPLY      =  0,       /* reply ? */
-	OST_GETATTR    =  1,
-	OST_SETATTR    =  2,
-	OST_READ       =  3,
-	OST_WRITE      =  4,
-	OST_CREATE     =  5,
-	OST_DESTROY    =  6,
-	OST_GET_INFO   =  7,
-	OST_CONNECT    =  8,
-	OST_DISCONNECT =  9,
-	OST_PUNCH      = 10,
-	OST_OPEN       = 11,
-	OST_CLOSE      = 12,
-	OST_STATFS     = 13,
-	OST_SYNC       = 16,
-	OST_SET_INFO   = 17,
-	OST_QUOTACHECK = 18, /* not used since 2.4 */
-	OST_QUOTACTL   = 19,
+	OST_REPLY	=  0,	/* reply ? */
+	OST_GETATTR	=  1,
+	OST_SETATTR	=  2,
+	OST_READ	=  3,
+	OST_WRITE	=  4,
+	OST_CREATE	=  5,
+	OST_DESTROY	=  6,
+	OST_GET_INFO	=  7,
+	OST_CONNECT	=  8,
+	OST_DISCONNECT	=  9,
+	OST_PUNCH	= 10,
+	OST_OPEN	= 11,
+	OST_CLOSE	= 12,
+	OST_STATFS	= 13,
+	OST_SYNC	= 16,
+	OST_SET_INFO	= 17,
+	OST_QUOTACHECK	= 18,	/* not used since 2.4 */
+	OST_QUOTACTL	= 19,
 	OST_QUOTA_ADJUST_QUNIT = 20, /* not used since 2.4 */
-	OST_LADVISE    = 21,
+	OST_LADVISE	= 21,
 	OST_LAST_OPC /* must be < 33 to avoid MDS_GETATTR */
 };
 #define OST_FIRST_OPC  OST_REPLY
 
 enum obdo_flags {
-	OBD_FL_INLINEDATA   = 0x00000001,
-	OBD_FL_OBDMDEXISTS  = 0x00000002,
-	OBD_FL_DELORPHAN    = 0x00000004, /* if set in o_flags delete orphans */
-	OBD_FL_NORPC        = 0x00000008, /* set in o_flags do in OSC not OST */
-	OBD_FL_IDONLY       = 0x00000010, /* set in o_flags only adjust obj id*/
-	OBD_FL_RECREATE_OBJS = 0x00000020, /* recreate missing obj */
-	OBD_FL_DEBUG_CHECK  = 0x00000040, /* echo client/server debug check */
-	OBD_FL_NO_PRJQUOTA  = 0x00000080, /* the object's project is over
-					   * quota
-					   */
-	OBD_FL_NO_USRQUOTA  = 0x00000100, /* the object's owner is over quota */
-	OBD_FL_NO_GRPQUOTA  = 0x00000200, /* the object's group is over quota */
-	OBD_FL_CREATE_CROW  = 0x00000400, /* object should be create on write */
-	OBD_FL_SRVLOCK      = 0x00000800, /* delegate DLM locking to server */
-	OBD_FL_CKSUM_CRC32  = 0x00001000, /* CRC32 checksum type */
-	OBD_FL_CKSUM_ADLER  = 0x00002000, /* ADLER checksum type */
-	OBD_FL_CKSUM_CRC32C = 0x00004000, /* CRC32C checksum type */
-	OBD_FL_CKSUM_RSVD2  = 0x00008000, /* for future cksum types */
-	OBD_FL_CKSUM_RSVD3  = 0x00010000, /* for future cksum types */
-	OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */
-	OBD_FL_MMAP         = 0x00040000, /* object is mmapped on the client.
-					   * XXX: obsoleted - reserved for old
-					   * clients prior than 2.2
-					   */
-	OBD_FL_RECOV_RESEND = 0x00080000, /* recoverable resent */
-	OBD_FL_NOSPC_BLK    = 0x00100000, /* no more block space on OST */
-	OBD_FL_FLUSH        = 0x00200000, /* flush pages on the OST */
-	OBD_FL_SHORT_IO     = 0x00400000, /* short io request */
+	OBD_FL_INLINEDATA	= 0x00000001,
+	OBD_FL_OBDMDEXISTS	= 0x00000002,
+	OBD_FL_DELORPHAN	= 0x00000004, /* if set in o_flags delete orphans */
+	OBD_FL_NORPC		= 0x00000008, /* set in o_flags do in OSC not OST */
+	OBD_FL_IDONLY		= 0x00000010, /* set in o_flags only adjust obj id*/
+	OBD_FL_RECREATE_OBJS	= 0x00000020, /* recreate missing obj */
+	OBD_FL_DEBUG_CHECK	= 0x00000040, /* echo client/server debug check */
+	OBD_FL_NO_PRJQUOTA	= 0x00000080, /* the object's project is over
+					       * quota
+					       */
+	OBD_FL_NO_USRQUOTA	= 0x00000100, /* the object's owner is over quota */
+	OBD_FL_NO_GRPQUOTA	= 0x00000200, /* the object's group is over quota */
+	OBD_FL_CREATE_CROW	= 0x00000400, /* object should be create on write */
+	OBD_FL_SRVLOCK		= 0x00000800, /* delegate DLM locking to server */
+	OBD_FL_CKSUM_CRC32	= 0x00001000, /* CRC32 checksum type */
+	OBD_FL_CKSUM_ADLER	= 0x00002000, /* ADLER checksum type */
+	OBD_FL_CKSUM_CRC32C	= 0x00004000, /* CRC32C checksum type */
+	OBD_FL_CKSUM_RSVD2	= 0x00008000, /* for future cksum types */
+	OBD_FL_CKSUM_RSVD3	= 0x00010000, /* for future cksum types */
+	OBD_FL_SHRINK_GRANT	= 0x00020000, /* object shrink the grant */
+	OBD_FL_MMAP		= 0x00040000, /* object is mmapped on the client.
+					       * XXX: obsoleted - reserved for old
+					       * clients prior than 2.2
+					       */
+	OBD_FL_RECOV_RESEND	= 0x00080000, /* recoverable resent */
+	OBD_FL_NOSPC_BLK	= 0x00100000, /* no more block space on OST */
+	OBD_FL_FLUSH		= 0x00200000, /* flush pages on the OST */
+	OBD_FL_SHORT_IO		= 0x00400000, /* short io request */
 	/* OBD_FL_LOCAL_MASK = 0xF0000000, was local-only flags until 2.10 */
 
 	/* Note that while these checksum values are currently separate bits,
 	 * in 2.x we can actually allow all values from 1-31 if we wanted.
 	 */
-	OBD_FL_CKSUM_ALL    = OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER |
-			      OBD_FL_CKSUM_CRC32C,
+	OBD_FL_CKSUM_ALL	= (OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER |
+				   OBD_FL_CKSUM_CRC32C),
 };
 
 /*
@@ -1233,9 +1233,9 @@ struct niobuf_remote {
  */
 #define OST_LVB_ERR_INIT 0xffbadbad80000000ULL
 #define OST_LVB_ERR_MASK 0xffbadbad00000000ULL
-#define OST_LVB_IS_ERR(blocks)					  \
+#define OST_LVB_IS_ERR(blocks)					\
 	((blocks & OST_LVB_ERR_MASK) == OST_LVB_ERR_MASK)
-#define OST_LVB_SET_ERR(blocks, rc)				     \
+#define OST_LVB_SET_ERR(blocks, rc)				\
 	do { blocks = OST_LVB_ERR_INIT + rc; } while (0)
 #define OST_LVB_GET_ERR(blocks)    (int)(blocks - OST_LVB_ERR_INIT)
 
@@ -1316,9 +1316,9 @@ struct ldlm_gl_lquota_desc {
 /* LVB used with quota (global and per-ID) locks */
 struct lquota_lvb {
 	__u64	lvb_flags;	/* see LQUOTA_FL* above */
-	__u64	lvb_id_may_rel; /* space that might be released later */
-	__u64	lvb_id_rel;     /* space released by the slave for this ID */
-	__u64	lvb_id_qunit;   /* current qunit value */
+	__u64	lvb_id_may_rel;	/* space that might be released later */
+	__u64	lvb_id_rel;	/* space released by the slave for this ID */
+	__u64	lvb_id_qunit;	/* current qunit value */
 	__u64	lvb_pad1;
 };
 
@@ -1488,17 +1488,17 @@ static inline int ll_inode_to_ext_flags(int iflags)
 
 static inline int ll_xflags_to_inode_flags(int xflags)
 {
-	return ((xflags & FS_XFLAG_SYNC) ? S_SYNC : 0) |
-	       ((xflags & FS_XFLAG_NOATIME) ? S_NOATIME : 0) |
-	       ((xflags & FS_XFLAG_APPEND) ? S_APPEND : 0) |
+	return ((xflags & FS_XFLAG_SYNC)      ? S_SYNC      : 0) |
+	       ((xflags & FS_XFLAG_NOATIME)   ? S_NOATIME   : 0) |
+	       ((xflags & FS_XFLAG_APPEND)    ? S_APPEND    : 0) |
 	       ((xflags & FS_XFLAG_IMMUTABLE) ? S_IMMUTABLE : 0);
 }
 
 static inline int ll_inode_flags_to_xflags(int flags)
 {
-	return ((flags & S_SYNC) ? FS_XFLAG_SYNC : 0) |
-	       ((flags & S_NOATIME) ? FS_XFLAG_NOATIME : 0) |
-	       ((flags & S_APPEND) ? FS_XFLAG_APPEND : 0) |
+	return ((flags & S_SYNC)      ? FS_XFLAG_SYNC      : 0) |
+	       ((flags & S_NOATIME)   ? FS_XFLAG_NOATIME   : 0) |
+	       ((flags & S_APPEND)    ? FS_XFLAG_APPEND    : 0) |
 	       ((flags & S_IMMUTABLE) ? FS_XFLAG_IMMUTABLE : 0);
 }
 
@@ -1583,7 +1583,7 @@ struct mdt_rec_setattr {
 	__s64		sa_ctime;
 	__u32		sa_attr_flags;
 	__u32		sa_mode;
-	__u32		sa_bias;      /* some operation flags */
+	__u32		sa_bias;	/* some operation flags */
 	__u32		sa_projid;
 	__u32		sa_padding_4;
 	__u32		sa_padding_5;
@@ -1698,17 +1698,17 @@ struct mdt_rec_create {
 	__s64		cr_time;
 	__u64		cr_rdev;
 	__u64		cr_ioepoch;
-	__u64		cr_padding_1;   /* rr_blocks */
+	__u64		cr_padding_1;	/* rr_blocks */
 	__u32		cr_mode;
 	__u32		cr_bias;
 	/* use of helpers set/get_mrc_cr_flags() is needed to access
 	 * 64 bits cr_flags [cr_flags_l, cr_flags_h], this is done to
 	 * extend cr_flags size without breaking 1.8 compat
 	 */
-	__u32		cr_flags_l;     /* for use with open, low  32 bits  */
-	__u32		cr_flags_h;     /* for use with open, high 32 bits */
-	__u32		cr_umask;       /* umask for create */
-	__u32		cr_padding_4;   /* rr_padding_4 */
+	__u32		cr_flags_l;	/* for use with open, low  32 bits  */
+	__u32		cr_flags_h;	/* for use with open, high 32 bits */
+	__u32		cr_umask;	/* umask for create */
+	__u32		cr_padding_4;	/* rr_padding_4 */
 };
 
 /* instance of mdt_reint_rec */
@@ -1726,16 +1726,16 @@ struct mdt_rec_link {
 	struct lu_fid   lk_fid1;
 	struct lu_fid   lk_fid2;
 	__s64		lk_time;
-	__u64		lk_padding_1;   /* rr_atime */
-	__u64		lk_padding_2;   /* rr_ctime */
-	__u64		lk_padding_3;   /* rr_size */
-	__u64		lk_padding_4;   /* rr_blocks */
+	__u64		lk_padding_1;	/* rr_atime */
+	__u64		lk_padding_2;	/* rr_ctime */
+	__u64		lk_padding_3;	/* rr_size */
+	__u64		lk_padding_4;	/* rr_blocks */
 	__u32		lk_bias;
-	__u32		lk_padding_5;   /* rr_mode */
-	__u32		lk_padding_6;   /* rr_flags */
-	__u32		lk_padding_7;   /* rr_padding_2 */
-	__u32		lk_padding_8;   /* rr_padding_3 */
-	__u32		lk_padding_9;   /* rr_padding_4 */
+	__u32		lk_padding_5;	/* rr_mode */
+	__u32		lk_padding_6;	/* rr_flags */
+	__u32		lk_padding_7;	/* rr_padding_2 */
+	__u32		lk_padding_8;	/* rr_padding_3 */
+	__u32		lk_padding_9;	/* rr_padding_4 */
 };
 
 /* instance of mdt_reint_rec */
@@ -1753,16 +1753,16 @@ struct mdt_rec_unlink {
 	struct lu_fid   ul_fid1;
 	struct lu_fid   ul_fid2;
 	__s64		ul_time;
-	__u64		ul_padding_2;   /* rr_atime */
-	__u64		ul_padding_3;   /* rr_ctime */
-	__u64		ul_padding_4;   /* rr_size */
-	__u64		ul_padding_5;   /* rr_blocks */
+	__u64		ul_padding_2;	/* rr_atime */
+	__u64		ul_padding_3;	/* rr_ctime */
+	__u64		ul_padding_4;	/* rr_size */
+	__u64		ul_padding_5;	/* rr_blocks */
 	__u32		ul_bias;
 	__u32		ul_mode;
-	__u32		ul_padding_6;   /* rr_flags */
-	__u32		ul_padding_7;   /* rr_padding_2 */
-	__u32		ul_padding_8;   /* rr_padding_3 */
-	__u32		ul_padding_9;   /* rr_padding_4 */
+	__u32		ul_padding_6;	/* rr_flags */
+	__u32		ul_padding_7;	/* rr_padding_2 */
+	__u32		ul_padding_8;	/* rr_padding_3 */
+	__u32		ul_padding_9;	/* rr_padding_4 */
 };
 
 /* instance of mdt_reint_rec */
@@ -1777,19 +1777,19 @@ struct mdt_rec_rename {
 	__u32		rn_suppgid1_h;
 	__u32		rn_suppgid2;
 	__u32		rn_suppgid2_h;
-	struct lu_fid   rn_fid1;
-	struct lu_fid   rn_fid2;
+	struct lu_fid	rn_fid1;
+	struct lu_fid	rn_fid2;
 	__s64		rn_time;
-	__u64		rn_padding_1;   /* rr_atime */
-	__u64		rn_padding_2;   /* rr_ctime */
-	__u64		rn_padding_3;   /* rr_size */
-	__u64		rn_padding_4;   /* rr_blocks */
+	__u64		rn_padding_1;	/* rr_atime */
+	__u64		rn_padding_2;	/* rr_ctime */
+	__u64		rn_padding_3;	/* rr_size */
+	__u64		rn_padding_4;	/* rr_blocks */
 	__u32		rn_bias;	/* some operation flags */
 	__u32		rn_mode;	/* cross-ref rename has mode */
-	__u32		rn_padding_5;   /* rr_flags */
-	__u32		rn_padding_6;   /* rr_padding_2 */
-	__u32		rn_padding_7;   /* rr_padding_3 */
-	__u32		rn_padding_8;   /* rr_padding_4 */
+	__u32		rn_padding_5;	/* rr_flags */
+	__u32		rn_padding_6;	/* rr_padding_2 */
+	__u32		rn_padding_7;	/* rr_padding_3 */
+	__u32		rn_padding_8;	/* rr_padding_4 */
 };
 
 /* instance of mdt_reint_rec */
@@ -1804,21 +1804,21 @@ struct mdt_rec_setxattr {
 	__u32		sx_suppgid1_h;
 	__u32		sx_suppgid2;
 	__u32		sx_suppgid2_h;
-	struct lu_fid   sx_fid;
-	__u64		sx_padding_1;   /* These three are rr_fid2 */
+	struct lu_fid	sx_fid;
+	__u64		sx_padding_1;	/* These three are rr_fid2 */
 	__u32		sx_padding_2;
 	__u32		sx_padding_3;
 	__u64		sx_valid;
 	__s64		sx_time;
-	__u64		sx_padding_5;   /* rr_ctime */
-	__u64		sx_padding_6;   /* rr_size */
-	__u64		sx_padding_7;   /* rr_blocks */
+	__u64		sx_padding_5;	/* rr_ctime */
+	__u64		sx_padding_6;	/* rr_size */
+	__u64		sx_padding_7;	/* rr_blocks */
 	__u32		sx_size;
 	__u32		sx_flags;
-	__u32		sx_padding_8;   /* rr_flags */
-	__u32		sx_padding_9;   /* rr_padding_2 */
-	__u32		sx_padding_10;  /* rr_padding_3 */
-	__u32		sx_padding_11;  /* rr_padding_4 */
+	__u32		sx_padding_8;	/* rr_flags */
+	__u32		sx_padding_9;	/* rr_padding_2 */
+	__u32		sx_padding_10;	/* rr_padding_3 */
+	__u32		sx_padding_11;	/* rr_padding_4 */
 };
 
 /*
@@ -1858,13 +1858,13 @@ struct mdt_rec_reint {
 /* lmv structures */
 struct lmv_desc {
 	__u32 ld_tgt_count;		/* how many MDS's */
-	__u32 ld_active_tgt_count;	 /* how many active */
-	__u32 ld_default_stripe_count;     /* how many objects are used */
-	__u32 ld_pattern;		  /* default hash pattern */
+	__u32 ld_active_tgt_count;	/* how many active */
+	__u32 ld_default_stripe_count;	/* how many objects are used */
+	__u32 ld_pattern;		/* default hash pattern */
 	__u64 ld_default_hash_size;
 	__u64 ld_padding_1;		/* also fix lustre_swab_lmv_desc */
 	__u32 ld_padding_2;		/* also fix lustre_swab_lmv_desc */
-	__u32 ld_qos_maxage;		    /* in second */
+	__u32 ld_qos_maxage;		/* in second */
 	__u32 ld_padding_3;		/* also fix lustre_swab_lmv_desc */
 	__u32 ld_padding_4;		/* also fix lustre_swab_lmv_desc */
 	struct obd_uuid ld_uuid;
@@ -2038,20 +2038,20 @@ struct lov_desc {
 	struct obd_uuid ld_uuid;
 };
 
-#define ld_magic ld_active_tgt_count       /* for swabbing from llogs */
+#define ld_magic ld_active_tgt_count	/* for swabbing from llogs */
 
 /*
  *   LDLM requests:
  */
 /* opcodes -- MUST be distinct from OST/MDS opcodes */
 enum ldlm_cmd {
-	LDLM_ENQUEUE     = 101,
-	LDLM_CONVERT     = 102,
-	LDLM_CANCEL      = 103,
+	LDLM_ENQUEUE	 = 101,
+	LDLM_CONVERT	 = 102,
+	LDLM_CANCEL	 = 103,
 	LDLM_BL_CALLBACK = 104,
 	LDLM_CP_CALLBACK = 105,
 	LDLM_GL_CALLBACK = 106,
-	LDLM_SET_INFO    = 107,
+	LDLM_SET_INFO	 = 107,
 	LDLM_LAST_OPC
 };
 #define LDLM_FIRST_OPC LDLM_ENQUEUE
@@ -2067,25 +2067,25 @@ struct ldlm_res_id {
 
 /* lock types */
 enum ldlm_mode {
-	LCK_MINMODE = 0,
-	LCK_EX      = 1,
-	LCK_PW      = 2,
-	LCK_PR      = 4,
-	LCK_CW      = 8,
-	LCK_CR      = 16,
-	LCK_NL      = 32,
-	LCK_GROUP   = 64,
-	LCK_COS     = 128,
+	LCK_MINMODE	= 0,
+	LCK_EX		= 1,
+	LCK_PW		= 2,
+	LCK_PR		= 4,
+	LCK_CW		= 8,
+	LCK_CR		= 16,
+	LCK_NL		= 32,
+	LCK_GROUP	= 64,
+	LCK_COS		= 128,
 	LCK_MAXMODE
 };
 
-#define LCK_MODE_NUM    8
+#define LCK_MODE_NUM	8
 
 enum ldlm_type {
-	LDLM_PLAIN     = 10,
-	LDLM_EXTENT    = 11,
-	LDLM_FLOCK     = 12,
-	LDLM_IBITS     = 13,
+	LDLM_PLAIN	= 10,
+	LDLM_EXTENT	= 11,
+	LDLM_FLOCK	= 12,
+	LDLM_IBITS	= 13,
 	LDLM_MAX_TYPE
 };
 
@@ -2150,7 +2150,7 @@ struct ldlm_intent {
 
 struct ldlm_resource_desc {
 	enum ldlm_type lr_type;
-	__u32 lr_padding;       /* also fix lustre_swab_ldlm_resource_desc */
+	__u32 lr_padding;	/* also fix lustre_swab_ldlm_resource_desc */
 	struct ldlm_res_id lr_name;
 };
 
@@ -2173,7 +2173,7 @@ struct ldlm_request {
 
 struct ldlm_reply {
 	__u32 lock_flags;
-	__u32 lock_padding;     /* also fix lustre_swab_ldlm_reply */
+	__u32 lock_padding;	/* also fix lustre_swab_ldlm_reply */
 	struct ldlm_lock_desc lock_desc;
 	struct lustre_handle lock_handle;
 	__u64  lock_policy_res1;
@@ -2206,9 +2206,9 @@ struct mgs_send_param {
 };
 
 /* We pass this info to the MGS so it can write config logs */
-#define MTI_NAME_MAXLEN  64
+#define MTI_NAME_MAXLEN	 64
 #define MTI_PARAM_MAXLEN 4096
-#define MTI_NIDS_MAX     32
+#define MTI_NIDS_MAX	 32
 struct mgs_target_info {
 	__u32		mti_lustre_ver;
 	__u32		mti_stripe_index;
@@ -2695,8 +2695,8 @@ enum sec_cmd {
 /*
  * capa related definitions
  */
-#define CAPA_HMAC_MAX_LEN       64
-#define CAPA_HMAC_KEY_MAX_LEN   56
+#define CAPA_HMAC_MAX_LEN	64
+#define CAPA_HMAC_KEY_MAX_LEN	56
 
 /* NB take care when changing the sequence of elements this struct,
  * because the offset info is used in find_capa()
@@ -2716,34 +2716,34 @@ struct lustre_capa {
 
 /** lustre_capa::lc_opc */
 enum {
-	CAPA_OPC_BODY_WRITE   = 1 << 0,  /**< write object data */
-	CAPA_OPC_BODY_READ    = 1 << 1,  /**< read object data */
-	CAPA_OPC_INDEX_LOOKUP = 1 << 2,  /**< lookup object fid */
-	CAPA_OPC_INDEX_INSERT = 1 << 3,  /**< insert object fid */
-	CAPA_OPC_INDEX_DELETE = 1 << 4,  /**< delete object fid */
-	CAPA_OPC_OSS_WRITE    = 1 << 5,  /**< write oss object data */
-	CAPA_OPC_OSS_READ     = 1 << 6,  /**< read oss object data */
-	CAPA_OPC_OSS_TRUNC    = 1 << 7,  /**< truncate oss object */
-	CAPA_OPC_OSS_DESTROY  = 1 << 8,  /**< destroy oss object */
-	CAPA_OPC_META_WRITE   = 1 << 9,  /**< write object meta data */
-	CAPA_OPC_META_READ    = 1 << 10, /**< read object meta data */
+	CAPA_OPC_BODY_WRITE	= 1 << 0,  /**< write object data */
+	CAPA_OPC_BODY_READ	= 1 << 1,  /**< read object data */
+	CAPA_OPC_INDEX_LOOKUP	= 1 << 2,  /**< lookup object fid */
+	CAPA_OPC_INDEX_INSERT	= 1 << 3,  /**< insert object fid */
+	CAPA_OPC_INDEX_DELETE	= 1 << 4,  /**< delete object fid */
+	CAPA_OPC_OSS_WRITE	= 1 << 5,  /**< write oss object data */
+	CAPA_OPC_OSS_READ	= 1 << 6,  /**< read oss object data */
+	CAPA_OPC_OSS_TRUNC	= 1 << 7,  /**< truncate oss object */
+	CAPA_OPC_OSS_DESTROY	= 1 << 8,  /**< destroy oss object */
+	CAPA_OPC_META_WRITE	= 1 << 9,  /**< write object meta data */
+	CAPA_OPC_META_READ	= 1 << 10, /**< read object meta data */
 };
 
 #define CAPA_OPC_OSS_RW (CAPA_OPC_OSS_READ | CAPA_OPC_OSS_WRITE)
-#define CAPA_OPC_MDS_ONLY						   \
+#define CAPA_OPC_MDS_ONLY						\
 	(CAPA_OPC_BODY_WRITE | CAPA_OPC_BODY_READ | CAPA_OPC_INDEX_LOOKUP | \
 	 CAPA_OPC_INDEX_INSERT | CAPA_OPC_INDEX_DELETE)
-#define CAPA_OPC_OSS_ONLY						   \
-	(CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC |      \
+#define CAPA_OPC_OSS_ONLY						\
+	(CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC |	\
 	 CAPA_OPC_OSS_DESTROY)
 #define CAPA_OPC_MDS_DEFAULT ~CAPA_OPC_OSS_ONLY
 #define CAPA_OPC_OSS_DEFAULT ~(CAPA_OPC_MDS_ONLY | CAPA_OPC_OSS_ONLY)
 
 struct lustre_capa_key {
-	__u64   lk_seq;       /**< mds# */
-	__u32   lk_keyid;     /**< key# */
-	__u32   lk_padding;
-	__u8    lk_key[CAPA_HMAC_KEY_MAX_LEN];    /**< key */
+	__u64	lk_seq;				/**< mds# */
+	__u32	lk_keyid;			/**< key# */
+	__u32	lk_padding;
+	__u8	lk_key[CAPA_HMAC_KEY_MAX_LEN];	/**< key */
 } __packed;
 
 /** The link ea holds 1 \a link_ea_entry for each hardlink */
@@ -2751,7 +2751,7 @@ struct lustre_capa_key {
 struct link_ea_header {
 	__u32 leh_magic;
 	__u32 leh_reccount;
-	__u64 leh_len;      /* total size */
+	__u64 leh_len;		/* total size */
 	__u32 leh_overflow_time;
 	__u32 leh_padding;
 };
@@ -2787,13 +2787,13 @@ struct getparent {
 } __packed;
 
 enum {
-	LAYOUT_INTENT_ACCESS    = 0,	/** generic access */
-	LAYOUT_INTENT_READ      = 1,	/** not used */
-	LAYOUT_INTENT_WRITE     = 2,	/** write file, for comp layout */
-	LAYOUT_INTENT_GLIMPSE   = 3,	/** not used */
-	LAYOUT_INTENT_TRUNC     = 4,	/** truncate file, for comp layout */
-	LAYOUT_INTENT_RELEASE   = 5,	/** reserved for HSM release */
-	LAYOUT_INTENT_RESTORE   = 6	/** reserved for HSM restore */
+	LAYOUT_INTENT_ACCESS	= 0,	/** generic access */
+	LAYOUT_INTENT_READ	= 1,	/** not used */
+	LAYOUT_INTENT_WRITE	= 2,	/** write file, for comp layout */
+	LAYOUT_INTENT_GLIMPSE	= 3,	/** not used */
+	LAYOUT_INTENT_TRUNC	= 4,	/** truncate file, for comp layout */
+	LAYOUT_INTENT_RELEASE	= 5,	/** reserved for HSM release */
+	LAYOUT_INTENT_RESTORE	= 6	/** reserved for HSM restore */
 };
 
 /* enqueue layout lock with intent */
diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
index 178837cedd07..3b80b50543d8 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
@@ -68,13 +68,13 @@
  * are co-existing.
  */
 #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64)
-typedef struct stat64   lstat_t;
-#define lstat_f  lstat64
+typedef struct stat64	lstat_t;
+#define lstat_f		lstat64
 #define fstat_f		fstat64
 #define fstatat_f	fstatat64
 #else
-typedef struct stat     lstat_t;
-#define lstat_f  lstat
+typedef struct stat	lstat_t;
+#define lstat_f		lstat
 #define fstat_f		fstat
 #define fstatat_f	fstatat
 #endif
@@ -87,47 +87,47 @@ typedef struct stat     lstat_t;
 #define LL_SUPER_MAGIC 0x0BD00BD0
 
 #ifndef FSFILT_IOC_GETFLAGS
-#define FSFILT_IOC_GETFLAGS	       _IOR('f', 1, long)
-#define FSFILT_IOC_SETFLAGS	       _IOW('f', 2, long)
-#define FSFILT_IOC_GETVERSION	     _IOR('f', 3, long)
-#define FSFILT_IOC_SETVERSION	     _IOW('f', 4, long)
-#define FSFILT_IOC_GETVERSION_OLD	 _IOR('v', 1, long)
-#define FSFILT_IOC_SETVERSION_OLD	 _IOW('v', 2, long)
+#define FSFILT_IOC_GETFLAGS		_IOR('f', 1, long)
+#define FSFILT_IOC_SETFLAGS		_IOW('f', 2, long)
+#define FSFILT_IOC_GETVERSION		_IOR('f', 3, long)
+#define FSFILT_IOC_SETVERSION		_IOW('f', 4, long)
+#define FSFILT_IOC_GETVERSION_OLD	_IOR('v', 1, long)
+#define FSFILT_IOC_SETVERSION_OLD	_IOW('v', 2, long)
 #endif
 
 /* FIEMAP flags supported by Lustre */
 #define LUSTRE_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_DEVICE_ORDER)
 
 enum obd_statfs_state {
-	OS_STATE_DEGRADED       = 0x00000001, /**< RAID degraded/rebuilding */
-	OS_STATE_READONLY       = 0x00000002, /**< filesystem is read-only */
-	OS_STATE_RDONLY_1       = 0x00000004, /**< obsolete 1.6, was EROFS=30 */
-	OS_STATE_RDONLY_2       = 0x00000008, /**< obsolete 1.6, was EROFS=30 */
-	OS_STATE_RDONLY_3       = 0x00000010, /**< obsolete 1.6, was EROFS=30 */
+	OS_STATE_DEGRADED	= 0x00000001, /**< RAID degraded/rebuilding */
+	OS_STATE_READONLY	= 0x00000002, /**< filesystem is read-only */
+	OS_STATE_RDONLY_1	= 0x00000004, /**< obsolete 1.6, was EROFS=30 */
+	OS_STATE_RDONLY_2	= 0x00000008, /**< obsolete 1.6, was EROFS=30 */
+	OS_STATE_RDONLY_3	= 0x00000010, /**< obsolete 1.6, was EROFS=30 */
 };
 
 struct obd_statfs {
-	__u64	   os_type;
-	__u64	   os_blocks;
-	__u64	   os_bfree;
-	__u64	   os_bavail;
-	__u64	   os_files;
-	__u64	   os_ffree;
-	__u8	    os_fsid[40];
-	__u32	   os_bsize;
-	__u32	   os_namelen;
-	__u64	   os_maxbytes;
-	__u32	   os_state;       /**< obd_statfs_state OS_STATE_* flag */
-	__u32	   os_fprecreated; /* objs available now to the caller */
-				   /* used in QoS code to find preferred OSTs */
-	__u32	   os_spare2;
-	__u32	   os_spare3;
-	__u32	   os_spare4;
-	__u32	   os_spare5;
-	__u32	   os_spare6;
-	__u32	   os_spare7;
-	__u32	   os_spare8;
-	__u32	   os_spare9;
+	__u64	os_type;
+	__u64	os_blocks;
+	__u64	os_bfree;
+	__u64	os_bavail;
+	__u64	os_files;
+	__u64	os_ffree;
+	__u8	os_fsid[40];
+	__u32	os_bsize;
+	__u32	os_namelen;
+	__u64	os_maxbytes;
+	__u32	os_state;	/**< obd_statfs_state OS_STATE_* flag */
+	__u32	os_fprecreated;	/* objs available now to the caller
+				 * used in QoS code to find preferred OSTs */
+	__u32	os_spare2;
+	__u32	os_spare3;
+	__u32	os_spare4;
+	__u32	os_spare5;
+	__u32	os_spare6;
+	__u32	os_spare7;
+	__u32	os_spare8;
+	__u32	os_spare9;
 };
 
 /**
@@ -137,12 +137,12 @@ struct obd_statfs {
  * FIDs are never reused.
  **/
 struct lu_fid {
-       /**
-	* FID sequence. Sequence is a unit of migration: all files (objects)
-	* with FIDs from a given sequence are stored on the same server.
-	* Lustre should support 2^64 objects, so even if each sequence
-	* has only a single object we can still enumerate 2^64 objects.
-	**/
+	/**
+	 * FID sequence. Sequence is a unit of migration: all files (objects)
+	 * with FIDs from a given sequence are stored on the same server.
+	 * Lustre should support 2^64 objects, so even if each sequence
+	 * has only a single object we can still enumerate 2^64 objects.
+	 **/
 	__u64 f_seq;
 	/* FID number within sequence. */
 	__u32 f_oid;
@@ -237,33 +237,33 @@ struct ll_futimes_3 {
  * *INFO    - set/get lov_user_mds_data
  */
 /*	lustre_ioctl.h			101-150 */
-#define LL_IOC_GETFLAGS		 _IOR('f', 151, long)
-#define LL_IOC_SETFLAGS		 _IOW('f', 152, long)
-#define LL_IOC_CLRFLAGS		 _IOW('f', 153, long)
-#define LL_IOC_LOV_SETSTRIPE	    _IOW('f', 154, long)
+#define LL_IOC_GETFLAGS			_IOR('f', 151, long)
+#define LL_IOC_SETFLAGS			_IOW('f', 152, long)
+#define LL_IOC_CLRFLAGS			_IOW('f', 153, long)
+#define LL_IOC_LOV_SETSTRIPE		_IOW('f', 154, long)
 #define LL_IOC_LOV_SETSTRIPE_NEW	_IOWR('f', 154, struct lov_user_md)
-#define LL_IOC_LOV_GETSTRIPE	    _IOW('f', 155, long)
+#define LL_IOC_LOV_GETSTRIPE		_IOW('f', 155, long)
 #define LL_IOC_LOV_GETSTRIPE_NEW	_IOR('f', 155, struct lov_user_md)
 #define LL_IOC_LOV_SETEA		_IOW('f', 156, long)
 /*	LL_IOC_RECREATE_OBJ		157 obsolete */
 /*	LL_IOC_RECREATE_FID		158 obsolete */
-#define LL_IOC_GROUP_LOCK	       _IOW('f', 158, long)
-#define LL_IOC_GROUP_UNLOCK	     _IOW('f', 159, long)
+#define LL_IOC_GROUP_LOCK		_IOW('f', 158, long)
+#define LL_IOC_GROUP_UNLOCK		_IOW('f', 159, long)
 /* #define LL_IOC_QUOTACHECK		160 OBD_IOC_QUOTACHECK */
 /* #define LL_IOC_POLL_QUOTACHECK	161 OBD_IOC_POLL_QUOTACHECK */
 /* #define LL_IOC_QUOTACTL		162 OBD_IOC_QUOTACTL */
-#define IOC_OBD_STATFS		  _IOWR('f', 164, struct obd_statfs *)
+#define IOC_OBD_STATFS			_IOWR('f', 164, struct obd_statfs *)
 /*	IOC_LOV_GETINFO			165 obsolete */
-#define LL_IOC_FLUSHCTX		 _IOW('f', 166, long)
+#define LL_IOC_FLUSHCTX			_IOW('f', 166, long)
 /* LL_IOC_RMTACL			167 obsolete */
-#define LL_IOC_GETOBDCOUNT	      _IOR('f', 168, long)
-#define LL_IOC_LLOOP_ATTACH	     _IOWR('f', 169, long)
-#define LL_IOC_LLOOP_DETACH	     _IOWR('f', 170, long)
-#define LL_IOC_LLOOP_INFO	       _IOWR('f', 171, struct lu_fid)
-#define LL_IOC_LLOOP_DETACH_BYDEV       _IOWR('f', 172, long)
-#define LL_IOC_PATH2FID		 _IOR('f', 173, long)
+#define LL_IOC_GETOBDCOUNT		_IOR('f', 168, long)
+#define LL_IOC_LLOOP_ATTACH		_IOWR('f', 169, long)
+#define LL_IOC_LLOOP_DETACH		_IOWR('f', 170, long)
+#define LL_IOC_LLOOP_INFO		_IOWR('f', 171, struct lu_fid)
+#define LL_IOC_LLOOP_DETACH_BYDEV	_IOWR('f', 172, long)
+#define LL_IOC_PATH2FID			_IOR('f', 173, long)
 #define LL_IOC_GET_CONNECT_FLAGS	_IOWR('f', 174, __u64 *)
-#define LL_IOC_GET_MDTIDX	       _IOR('f', 175, int)
+#define LL_IOC_GET_MDTIDX		_IOR('f', 175, int)
 #define LL_IOC_FUTIMES_3		_IOWR('f', 176, struct ll_futimes_3)
 
 /*	lustre_ioctl.h			177-210 */
@@ -281,8 +281,8 @@ struct ll_futimes_3 {
 						struct hsm_current_action)
 /* see <lustre_lib.h> for ioctl numbers 221-232 */
 
-#define LL_IOC_LMV_SETSTRIPE	    _IOWR('f', 240, struct lmv_user_md)
-#define LL_IOC_LMV_GETSTRIPE	    _IOWR('f', 241, struct lmv_user_md)
+#define LL_IOC_LMV_SETSTRIPE		_IOWR('f', 240, struct lmv_user_md)
+#define LL_IOC_LMV_GETSTRIPE		_IOWR('f', 241, struct lmv_user_md)
 #define LL_IOC_SET_LEASE		_IOWR('f', 243, long)
 #define LL_IOC_GET_LEASE		_IO('f', 244)
 #define LL_IOC_HSM_IMPORT		_IOWR('f', 245, struct hsm_user_import)
@@ -299,15 +299,15 @@ enum ll_lease_type {
 	LL_LEASE_UNLCK	= 0x4,
 };
 
-#define LL_STATFS_LMV	   1
-#define LL_STATFS_LOV	   2
+#define LL_STATFS_LMV		1
+#define LL_STATFS_LOV		2
 #define LL_STATFS_NODELAY	4
 
-#define IOC_MDC_TYPE	    'i'
-#define IOC_MDC_LOOKUP	  _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
-#define IOC_MDC_GETFILESTRIPE   _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *)
-#define IOC_MDC_GETFILEINFO     _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *)
-#define LL_IOC_MDC_GETINFO      _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *)
+#define IOC_MDC_TYPE		'i'
+#define IOC_MDC_LOOKUP		_IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
+#define IOC_MDC_GETFILESTRIPE	_IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *)
+#define IOC_MDC_GETFILEINFO	_IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *)
+#define LL_IOC_MDC_GETINFO	_IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *)
 
 #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */
 
@@ -318,12 +318,12 @@ enum ll_lease_type {
  */
 #define O_LOV_DELAY_CREATE	(O_NOCTTY | FASYNC)
 
-#define LL_FILE_IGNORE_LOCK     0x00000001
-#define LL_FILE_GROUP_LOCKED    0x00000002
+#define LL_FILE_IGNORE_LOCK	0x00000001
+#define LL_FILE_GROUP_LOCKED	0x00000002
 #define LL_FILE_READAHEA	0x00000004
 #define LL_FILE_LOCKED_DIRECTIO 0x00000008 /* client-side locks with dio */
-#define LL_FILE_LOCKLESS_IO     0x00000010 /* server-side locks with cio */
-#define LL_FILE_RMTACL	  0x00000020
+#define LL_FILE_LOCKLESS_IO	0x00000010 /* server-side locks with cio */
+#define LL_FILE_RMTACL		0x00000020
 
 #define LOV_USER_MAGIC_V1	0x0BD10BD0
 #define LOV_USER_MAGIC		LOV_USER_MAGIC_V1
@@ -333,7 +333,7 @@ enum ll_lease_type {
 #define LOV_USER_MAGIC_SPECIFIC	0x0BD50BD0	/* for specific OSTs */
 #define LOV_USER_MAGIC_COMP_V1	0x0BD60BD0
 
-#define LMV_USER_MAGIC    0x0CD30CD0    /*default lmv magic*/
+#define LMV_USER_MAGIC		0x0CD30CD0	/*default lmv magic*/
 
 #define LOV_PATTERN_RAID0	0x001
 #define LOV_PATTERN_RAID1	0x002
@@ -347,8 +347,8 @@ enum ll_lease_type {
 #define LOV_MAXPOOLNAME 15
 #define LOV_POOLNAMEF "%.15s"
 
-#define LOV_MIN_STRIPE_BITS 16   /* maximum PAGE_SIZE (ia64), power of 2 */
-#define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS)
+#define LOV_MIN_STRIPE_BITS	16	/* maximum PAGE_SIZE (ia64), power of 2 */
+#define LOV_MIN_STRIPE_SIZE	(1 << LOV_MIN_STRIPE_BITS)
 #define LOV_MAX_STRIPE_COUNT_OLD 160
 /* This calculation is crafted so that input of 4096 will result in 160
  * which in turn is equal to old maximal stripe count.
@@ -360,49 +360,49 @@ enum ll_lease_type {
  *
  * (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1)
  */
-#define LOV_MAX_STRIPE_COUNT 2000  /* ((12 * 4096 - 256) / 24) */
-#define LOV_ALL_STRIPES       0xffff /* only valid for directories */
+#define LOV_MAX_STRIPE_COUNT	2000  /* ((12 * 4096 - 256) / 24) */
+#define LOV_ALL_STRIPES		0xffff /* only valid for directories */
 #define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */
 
 #define XATTR_LUSTRE_PREFIX	"lustre."
 #define XATTR_LUSTRE_LOV	"lustre.lov"
 
 #define lov_user_ost_data lov_user_ost_data_v1
-struct lov_user_ost_data_v1 {     /* per-stripe data structure */
-	struct ost_id l_ost_oi;	  /* OST object ID */
-	__u32 l_ost_gen;	  /* generation of this OST index */
-	__u32 l_ost_idx;	  /* OST index in LOV */
+struct lov_user_ost_data_v1 {	/* per-stripe data structure */
+	struct ost_id l_ost_oi;	/* OST object ID */
+	__u32 l_ost_gen;	/* generation of this OST index */
+	__u32 l_ost_idx;	/* OST index in LOV */
 } __packed;
 
 #define lov_user_md lov_user_md_v1
-struct lov_user_md_v1 {	   /* LOV EA user data (host-endian) */
-	__u32 lmm_magic;	  /* magic number = LOV_USER_MAGIC_V1 */
+struct lov_user_md_v1 {		/* LOV EA user data (host-endian) */
+	__u32 lmm_magic;	/* magic number = LOV_USER_MAGIC_V1 */
 	__u32 lmm_pattern;	/* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
-	struct ost_id lmm_oi;	  /* LOV object ID */
-	__u32 lmm_stripe_size;    /* size of stripe in bytes */
-	__u16 lmm_stripe_count;   /* num stripes in use for this object */
+	struct ost_id lmm_oi;	/* LOV object ID */
+	__u32 lmm_stripe_size;	/* size of stripe in bytes */
+	__u16 lmm_stripe_count;	/* num stripes in use for this object */
 	union {
 		__u16 lmm_stripe_offset;  /* starting stripe offset in
 					   * lmm_objects, use when writing
 					   */
-		__u16 lmm_layout_gen;     /* layout generation number
+		__u16 lmm_layout_gen;	  /* layout generation number
 					   * used when reading
 					   */
 	};
 	struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 } __attribute__((packed,  __may_alias__));
 
-struct lov_user_md_v3 {	   /* LOV EA user data (host-endian) */
-	__u32 lmm_magic;	  /* magic number = LOV_USER_MAGIC_V3 */
+struct lov_user_md_v3 {		/* LOV EA user data (host-endian) */
+	__u32 lmm_magic;	/* magic number = LOV_USER_MAGIC_V3 */
 	__u32 lmm_pattern;	/* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
-	struct ost_id lmm_oi;	  /* LOV object ID */
-	__u32 lmm_stripe_size;    /* size of stripe in bytes */
-	__u16 lmm_stripe_count;   /* num stripes in use for this object */
+	struct ost_id lmm_oi;	/* LOV object ID */
+	__u32 lmm_stripe_size;	/* size of stripe in bytes */
+	__u16 lmm_stripe_count;	/* num stripes in use for this object */
 	union {
 		__u16 lmm_stripe_offset;  /* starting stripe offset in
 					   * lmm_objects, use when writing
 					   */
-		__u16 lmm_layout_gen;     /* layout generation number
+		__u16 lmm_layout_gen;	  /* layout generation number
 					   * used when reading
 					   */
 	};
@@ -425,9 +425,9 @@ static inline bool lu_extent_is_overlapped(struct lu_extent *e1,
 }
 
 enum lov_comp_md_entry_flags {
-	LCME_FL_PRIMARY		= 0x00000001,   /* Not used */
-	LCME_FL_STALE		= 0x00000002,   /* Not used */
-	LCME_FL_OFFLINE		= 0x00000004,   /* Not used */
+	LCME_FL_PRIMARY		= 0x00000001,	/* Not used */
+	LCME_FL_STALE		= 0x00000002,	/* Not used */
+	LCME_FL_OFFLINE		= 0x00000004,	/* Not used */
 	LCME_FL_PREFERRED	= 0x00000008,	/* Not used */
 	LCME_FL_INIT		= 0x00000010,	/* instantiated */
 	LCME_FL_NEG		= 0x80000000,	/* used to indicate a negative
@@ -480,7 +480,7 @@ static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
 		return sizeof(struct lov_user_md_v1) +
 				stripes * sizeof(struct lov_user_ost_data_v1);
 	return sizeof(struct lov_user_md_v3) +
-	       stripes * sizeof(struct lov_user_ost_data_v1);
+		stripes * sizeof(struct lov_user_ost_data_v1);
 }
 
 /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
@@ -524,16 +524,16 @@ enum lmv_hash_type {
 #define LMV_MAX_STRIPE_COUNT 2000  /* ((12 * 4096 - 256) / 24) */
 #define lmv_user_md lmv_user_md_v1
 struct lmv_user_md_v1 {
-	__u32	lum_magic;	 /* must be the first field */
-	__u32	lum_stripe_count;  /* dirstripe count */
-	__u32	lum_stripe_offset; /* MDT idx for default dirstripe */
-	__u32	lum_hash_type;     /* Dir stripe policy */
-	__u32	lum_type;	  /* LMV type: default or normal */
+	__u32	lum_magic;		/* must be the first field */
+	__u32	lum_stripe_count;	/* dirstripe count */
+	__u32	lum_stripe_offset;	/* MDT idx for default dirstripe */
+	__u32	lum_hash_type;		/* Dir stripe policy */
+	__u32	lum_type;		/* LMV type: default or normal */
 	__u32	lum_padding1;
 	__u32	lum_padding2;
 	__u32	lum_padding3;
 	char	lum_pool_name[LOV_MAXPOOLNAME + 1];
-	struct	lmv_user_mds_data  lum_objects[0];
+	struct lmv_user_mds_data  lum_objects[0];
 } __packed;
 
 static inline int lmv_user_md_size(int stripes, int lmm_magic)
@@ -548,11 +548,11 @@ struct ll_recreate_obj {
 };
 
 struct ll_fid {
-	__u64 id;	 /* holds object id */
-	__u32 generation; /* holds object generation */
-	__u32 f_type;     /* holds object type or stripe idx when passing it to
-			   * OST for saving into EA.
-			   */
+	__u64 id;		/* holds object id */
+	__u32 generation;	/* holds object generation */
+	__u32 f_type;		/* holds object type or stripe idx when
+				 * passing it to OST for saving into EA.
+				 */
 };
 
 #define UUID_MAX	40
@@ -631,22 +631,22 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen)
 
 /********* Quotas **********/
 
-#define Q_QUOTACHECK   0x800100 /* deprecated as of 2.4 */
-#define Q_INITQUOTA    0x800101 /* deprecated as of 2.4  */
-#define Q_GETOINFO     0x800102 /* get obd quota info */
-#define Q_GETOQUOTA    0x800103 /* get obd quotas */
-#define Q_FINVALIDATE  0x800104 /* deprecated as of 2.4 */
+#define Q_QUOTACHECK	0x800100 /* deprecated as of 2.4 */
+#define Q_INITQUOTA	0x800101 /* deprecated as of 2.4  */
+#define Q_GETOINFO	0x800102 /* get obd quota info */
+#define Q_GETOQUOTA	0x800103 /* get obd quotas */
+#define Q_FINVALIDATE	0x800104 /* deprecated as of 2.4 */
 
 /* these must be explicitly translated into linux Q_* in ll_dir_ioctl */
-#define LUSTRE_Q_QUOTAON    0x800002	/* deprecated as of 2.4 */
-#define LUSTRE_Q_QUOTAOFF   0x800003	/* deprecated as of 2.4 */
-#define LUSTRE_Q_GETINFO    0x800005     /* get information about quota files */
-#define LUSTRE_Q_SETINFO    0x800006     /* set information about quota files */
-#define LUSTRE_Q_GETQUOTA   0x800007     /* get user quota structure */
-#define LUSTRE_Q_SETQUOTA   0x800008     /* set user quota structure */
+#define LUSTRE_Q_QUOTAON	0x800002	/* deprecated as of 2.4 */
+#define LUSTRE_Q_QUOTAOFF	0x800003	/* deprecated as of 2.4 */
+#define LUSTRE_Q_GETINFO	0x800005	/* get information about quota files */
+#define LUSTRE_Q_SETINFO	0x800006	/* set information about quota files */
+#define LUSTRE_Q_GETQUOTA	0x800007	/* get user quota structure */
+#define LUSTRE_Q_SETQUOTA	0x800008	/* set user quota structure */
 /* lustre-specific control commands */
-#define LUSTRE_Q_INVALIDATE  0x80000b	/* deprecated as of 2.4 */
-#define LUSTRE_Q_FINVALIDATE 0x80000c	/* deprecated as of 2.4 */
+#define LUSTRE_Q_INVALIDATE	0x80000b	/* deprecated as of 2.4 */
+#define LUSTRE_Q_FINVALIDATE	0x80000c	/* deprecated as of 2.4 */
 
 #define ALLQUOTA 255	/* set all quota */
 
@@ -666,7 +666,7 @@ static inline char *qtype_name(int qtype)
 #define IDENTITY_DOWNCALL_MAGIC 0x6d6dd629
 
 /* permission */
-#define N_PERMS_MAX      64
+#define N_PERMS_MAX	64
 
 struct perm_downcall_data {
 	__u64 pdd_nid;
@@ -720,23 +720,23 @@ struct obd_dqblk {
 };
 
 enum {
-	QC_GENERAL      = 0,
-	QC_MDTIDX       = 1,
-	QC_OSTIDX       = 2,
-	QC_UUID	 = 3
+	QC_GENERAL	= 0,
+	QC_MDTIDX	= 1,
+	QC_OSTIDX	= 2,
+	QC_UUID		= 3
 };
 
 struct if_quotactl {
-	__u32		   qc_cmd;
-	__u32		   qc_type;
-	__u32		   qc_id;
-	__u32		   qc_stat;
-	__u32		   qc_valid;
-	__u32		   qc_idx;
-	struct obd_dqinfo       qc_dqinfo;
-	struct obd_dqblk	qc_dqblk;
-	char		    obd_type[16];
-	struct obd_uuid	 obd_uuid;
+	__u32		  qc_cmd;
+	__u32		  qc_type;
+	__u32		  qc_id;
+	__u32		  qc_stat;
+	__u32		  qc_valid;
+	__u32		  qc_idx;
+	struct obd_dqinfo qc_dqinfo;
+	struct obd_dqblk  qc_dqblk;
+	char		  obd_type[16];
+	struct obd_uuid	  obd_uuid;
 };
 
 /* swap layout flags */
@@ -759,26 +759,26 @@ struct lustre_swap_layouts {
 /********* Changelogs **********/
 /** Changelog record types */
 enum changelog_rec_type {
-	CL_MARK     = 0,
-	CL_CREATE   = 1,  /* namespace */
-	CL_MKDIR    = 2,  /* namespace */
-	CL_HARDLINK = 3,  /* namespace */
-	CL_SOFTLINK = 4,  /* namespace */
-	CL_MKNOD    = 5,  /* namespace */
-	CL_UNLINK   = 6,  /* namespace */
-	CL_RMDIR    = 7,  /* namespace */
-	CL_RENAME   = 8,  /* namespace */
-	CL_EXT      = 9,  /* namespace extended record (2nd half of rename) */
-	CL_OPEN     = 10, /* not currently used */
-	CL_CLOSE    = 11, /* may be written to log only with mtime change */
-	CL_LAYOUT   = 12, /* file layout/striping modified */
-	CL_TRUNC    = 13,
-	CL_SETATTR  = 14,
-	CL_XATTR    = 15,
-	CL_HSM      = 16, /* HSM specific events, see flags */
-	CL_MTIME    = 17, /* Precedence: setattr > mtime > ctime > atime */
-	CL_CTIME    = 18,
-	CL_ATIME    = 19,
+	CL_MARK		= 0,
+	CL_CREATE	= 1,  /* namespace */
+	CL_MKDIR	= 2,  /* namespace */
+	CL_HARDLINK	= 3,  /* namespace */
+	CL_SOFTLINK	= 4,  /* namespace */
+	CL_MKNOD	= 5,  /* namespace */
+	CL_UNLINK	= 6,  /* namespace */
+	CL_RMDIR	= 7,  /* namespace */
+	CL_RENAME	= 8,  /* namespace */
+	CL_EXT		= 9,  /* namespace extended record (2nd half of rename) */
+	CL_OPEN		= 10, /* not currently used */
+	CL_CLOSE	= 11, /* may be written to log only with mtime change */
+	CL_LAYOUT	= 12, /* file layout/striping modified */
+	CL_TRUNC	= 13,
+	CL_SETATTR	= 14,
+	CL_XATTR	= 15,
+	CL_HSM		= 16, /* HSM specific events, see flags */
+	CL_MTIME	= 17, /* Precedence: setattr > mtime > ctime > atime */
+	CL_CTIME	= 18,
+	CL_ATIME	= 19,
 	CL_LAST
 };
 
@@ -808,9 +808,9 @@ enum changelog_rec_flags {
 
 /* Anything under the flagmask may be per-type (if desired) */
 /* Flags for unlink */
-#define CLF_UNLINK_LAST       0x0001 /* Unlink of last hardlink */
-#define CLF_UNLINK_HSM_EXISTS 0x0002 /* File has something in HSM */
-				     /* HSM cleaning needed */
+#define CLF_UNLINK_LAST		0x0001 /* Unlink of last hardlink */
+#define CLF_UNLINK_HSM_EXISTS	0x0002 /* File has something in HSM
+					* HSM cleaning needed */
 /* Flags for rename */
 #define CLF_RENAME_LAST		0x0001	/* rename unlink last hardlink of
 					 * target
@@ -827,12 +827,12 @@ enum changelog_rec_flags {
  */
 #define CLF_HSM_ERR_L	0 /* HSM return code, 7 bits */
 #define CLF_HSM_ERR_H	6
-#define CLF_HSM_EVENT_L      7 /* HSM event, 3 bits, see enum hsm_event */
-#define CLF_HSM_EVENT_H      9
-#define CLF_HSM_FLAG_L      10 /* HSM flags, 2 bits, 1 used, 1 spare */
-#define CLF_HSM_FLAG_H      11
-#define CLF_HSM_SPARE_L     12 /* 4 spare bits */
-#define CLF_HSM_SPARE_H     15
+#define CLF_HSM_EVENT_L	7 /* HSM event, 3 bits, see enum hsm_event */
+#define CLF_HSM_EVENT_H	9
+#define CLF_HSM_FLAG_L	10 /* HSM flags, 2 bits, 1 used, 1 spare */
+#define CLF_HSM_FLAG_H	11
+#define CLF_HSM_SPARE_L	12 /* 4 spare bits */
+#define CLF_HSM_SPARE_H	15
 #define CLF_HSM_LAST	15
 
 /* Remove bits higher than _h, then extract the value
@@ -841,22 +841,22 @@ enum changelog_rec_flags {
 #define CLF_GET_BITS(_b, _h, _l) (((_b << (CLF_HSM_LAST - _h)) & 0xFFFF) \
 				   >> (CLF_HSM_LAST - _h + _l))
 
-#define CLF_HSM_SUCCESS      0x00
-#define CLF_HSM_MAXERROR     0x7E
-#define CLF_HSM_ERROVERFLOW  0x7F
+#define CLF_HSM_SUCCESS		0x00
+#define CLF_HSM_MAXERROR	0x7E
+#define CLF_HSM_ERROVERFLOW	0x7F
 
 #define CLF_HSM_DIRTY	1 /* file is dirty after HSM request end */
 
 /* 3 bits field => 8 values allowed */
 enum hsm_event {
-	HE_ARCHIVE      = 0,
-	HE_RESTORE      = 1,
-	HE_CANCEL       = 2,
-	HE_RELEASE      = 3,
-	HE_REMOVE       = 4,
+	HE_ARCHIVE	= 0,
+	HE_RESTORE	= 1,
+	HE_CANCEL	= 2,
+	HE_RELEASE	= 3,
+	HE_REMOVE	= 4,
 	HE_STATE	= 5,
-	HE_SPARE1       = 6,
-	HE_SPARE2       = 7,
+	HE_SPARE1	= 6,
+	HE_SPARE2	= 7,
 };
 
 static inline enum hsm_event hsm_get_cl_event(__u16 flags)
@@ -1070,14 +1070,14 @@ enum changelog_message_type {
 
 struct ioc_data_version {
 	__u64 idv_version;
-	__u64 idv_flags;     /* See LL_DV_xxx */
+	__u64 idv_flags;	/* See LL_DV_xxx */
 };
 
 #define LL_DV_RD_FLUSH	(1 << 0) /* Flush dirty pages from clients */
 #define LL_DV_WR_FLUSH	(1 << 1) /* Flush all caching pages from clients */
 
 #ifndef offsetof
-# define offsetof(typ, memb)     ((unsigned long)((char *)&(((typ *)0)->memb)))
+# define offsetof(typ, memb)	((unsigned long)((char *)&(((typ *)0)->memb)))
 #endif
 
 #define dot_lustre_name ".lustre"
@@ -1284,14 +1284,14 @@ static inline const char *hsm_copytool_action2name(enum hsm_copytool_action  a)
 
 /* Copytool item action description */
 struct hsm_action_item {
-	__u32      hai_len;     /* valid size of this struct */
-	__u32      hai_action;  /* hsm_copytool_action, but use known size */
-	struct lu_fid hai_fid;     /* Lustre FID to operated on */
-	struct lu_fid hai_dfid;    /* fid used for data access */
+	__u32		hai_len;     /* valid size of this struct */
+	__u32		hai_action;  /* hsm_copytool_action, but use known size */
+	struct lu_fid	hai_fid;     /* Lustre FID to operated on */
+	struct lu_fid	hai_dfid;    /* fid used for data access */
 	struct hsm_extent hai_extent;  /* byte range to operate on */
-	__u64      hai_cookie;  /* action cookie from coordinator */
-	__u64      hai_gid;     /* grouplock id */
-	char       hai_data[0]; /* variable length */
+	__u64		hai_cookie;  /* action cookie from coordinator */
+	__u64		hai_gid;     /* grouplock id */
+	char		hai_data[0]; /* variable length */
 } __packed;
 
 /*
@@ -1326,12 +1326,12 @@ static inline char *hai_dump_data_field(struct hsm_action_item *hai,
 #define HAL_MAXSIZE LNET_MTU /* bytes, used in userspace only */
 struct hsm_action_list {
 	__u32 hal_version;
-	__u32 hal_count;       /* number of hai's to follow */
-	__u64 hal_compound_id; /* returned by coordinator */
+	__u32 hal_count;	/* number of hai's to follow */
+	__u64 hal_compound_id;	/* returned by coordinator */
 	__u64 hal_flags;
-	__u32 hal_archive_id; /* which archive backend */
+	__u32 hal_archive_id;	/* which archive backend */
 	__u32 padding1;
-	char  hal_fsname[0];   /* null-terminated */
+	char  hal_fsname[0];	/* null-terminated */
 	/* struct hsm_action_item[hal_count] follows, aligned on 8-byte
 	 * boundaries. See hai_first
 	 */
@@ -1384,8 +1384,8 @@ struct hsm_user_import {
 };
 
 /* Copytool progress reporting */
-#define HP_FLAG_COMPLETED 0x01
-#define HP_FLAG_RETRY     0x02
+#define HP_FLAG_COMPLETED	0x01
+#define HP_FLAG_RETRY		0x02
 
 struct hsm_progress {
 	struct lu_fid		hp_fid;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index 2bf12284bf43..92427254d74c 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -74,25 +74,25 @@
 #define IBLND_N_SCHED_HIGH		4
 
 struct kib_tunables {
-	int *kib_dev_failover;           /* HCA failover */
-	unsigned int *kib_service;       /* IB service number */
+	int *kib_dev_failover;		/* HCA failover */
+	unsigned int *kib_service;	/* IB service number */
 	int *kib_min_reconnect_interval; /* first failed connection retry... */
 	int *kib_max_reconnect_interval; /* exponentially increasing to this */
-	int *kib_cksum;                  /* checksum struct kib_msg? */
-	int *kib_timeout;                /* comms timeout (seconds) */
-	int *kib_keepalive;              /* keepalive timeout (seconds) */
-	int *kib_ntx;                    /* # tx descs */
-	char **kib_default_ipif;         /* default IPoIB interface */
+	int *kib_cksum;			/* checksum struct kib_msg? */
+	int *kib_timeout;		/* comms timeout (seconds) */
+	int *kib_keepalive;		/* keepalive timeout (seconds) */
+	int *kib_ntx;			/* # tx descs */
+	char **kib_default_ipif;	/* default IPoIB interface */
 	int *kib_retry_count;
 	int *kib_rnr_retry_count;
-	int *kib_ib_mtu;                 /* IB MTU */
-	int *kib_require_priv_port;      /* accept only privileged ports */
-	int *kib_use_priv_port; /* use privileged port for active connect */
-	int *kib_nscheds;                /* # threads on each CPT */
-	int *kib_wrq_sge;		 /* # sg elements per wrq */
-	bool *kib_use_fastreg_gaps;	 /* enable discontiguous fastreg
-					  * fragment support
-					  */
+	int *kib_ib_mtu;		/* IB MTU */
+	int *kib_require_priv_port;	/* accept only privileged ports */
+	int *kib_use_priv_port;		/* use privileged port for active connect */
+	int *kib_nscheds;		/* # threads on each CPT */
+	int *kib_wrq_sge;		/* # sg elements per wrq */
+	bool *kib_use_fastreg_gaps;	/* enable discontiguous fastreg
+					 * fragment support
+					 */
 };
 
 extern struct kib_tunables  kiblnd_tunables;
@@ -164,11 +164,11 @@ struct kib_dev {
 	int			ibd_nnets;	/* # nets extant */
 
 	time64_t		ibd_next_failover;
-	int			ibd_failed_failover; /* # failover failures */
-	unsigned int		ibd_failover;        /* failover in progress */
-	unsigned int		ibd_can_failover;    /* IPoIB interface is a
-						      * bonding master
-						      */
+	int			ibd_failed_failover;	/* # failover failures */
+	unsigned int		ibd_failover;		/* failover in progress */
+	unsigned int		ibd_can_failover;	/* IPoIB interface is a
+							 * bonding master
+							 */
 	struct list_head	ibd_nets;
 	struct kib_hca_dev	*ibd_hdev;
 	enum kib_dev_caps	ibd_dev_caps;
@@ -330,8 +330,8 @@ struct kib_sched_info {
 
 struct kib_data {
 	int			kib_init;	    /* initialisation state */
-	int			kib_shutdown;       /* shut down? */
-	struct list_head	kib_devs;           /* IB devices extant */
+	int			kib_shutdown;	    /* shut down? */
+	struct list_head	kib_devs;	    /* IB devices extant */
 	struct list_head	kib_failed_devs;    /* list head of failed devices */
 	wait_queue_head_t	kib_failover_waitq; /* schedulers sleep here */
 	atomic_t		kib_nthreads;	    /* # live threads */
@@ -540,7 +540,7 @@ struct kib_conn {
 	int			ibc_state;	/* what's happening */
 	int			ibc_nsends_posted;	/* # uncompleted sends */
 	int			ibc_noops_posted;	/* # uncompleted NOOPs */
-	int			ibc_credits;     /* # credits I have */
+	int			ibc_credits;		/* # credits I have */
 	int			ibc_outstanding_credits; /* # credits to return */
 	int			ibc_reserved_credits; /* # ACK/DONE msg credits */
 	int			ibc_comms_error; /* set on comms error */
@@ -581,13 +581,13 @@ struct kib_conn {
 #define IBLND_CONN_DISCONNECTED		5	 /* disconnected */
 
 struct kib_peer_ni {
-	struct list_head	ibp_list;        /* stash on global peer_ni list */
-	lnet_nid_t		ibp_nid;         /* who's on the other end(s) */
-	struct lnet_ni		*ibp_ni;         /* LNet interface */
-	struct list_head	ibp_conns;       /* all active connections */
-	struct kib_conn		*ibp_next_conn;  /* next connection to send on for
-						  * round robin */
-	struct list_head	ibp_tx_queue;	 /* msgs waiting for a conn */
+	struct list_head	ibp_list;	/* stash on global peer_ni list */
+	lnet_nid_t		ibp_nid;	/* who's on the other end(s) */
+	struct lnet_ni		*ibp_ni;	/* LNet interface */
+	struct list_head	ibp_conns;	/* all active connections */
+	struct kib_conn		*ibp_next_conn; /* next connection to send on for
+						 * round robin */
+	struct list_head	ibp_tx_queue;	/* msgs waiting for a conn */
 	u64			ibp_incarnation; /* incarnation of peer_ni */
 	/* when (in seconds) I was last alive */
 	time64_t		ibp_last_alive;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index ce1f9e78b4d9..add2744c9d8d 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -54,15 +54,15 @@
 #define SOCKNAL_NSCHEDS		3
 #define SOCKNAL_NSCHEDS_HIGH	(SOCKNAL_NSCHEDS << 1)
 
-#define SOCKNAL_PEER_HASH_SIZE  101   /* # peer_ni lists */
-#define SOCKNAL_RESCHED         100   /* # scheduler loops before reschedule */
-#define SOCKNAL_INSANITY_RECONN 5000  /* connd is trying on reconn infinitely */
-#define SOCKNAL_ENOMEM_RETRY    1     /* seconds between retries */
+#define SOCKNAL_PEER_HASH_SIZE	101   /* # peer_ni lists */
+#define SOCKNAL_RESCHED		100   /* # scheduler loops before reschedule */
+#define SOCKNAL_INSANITY_RECONN	5000  /* connd is trying on reconn infinitely */
+#define SOCKNAL_ENOMEM_RETRY	1     /* seconds between retries */
 
-#define SOCKNAL_SINGLE_FRAG_TX  0     /* disable multi-fragment sends */
-#define SOCKNAL_SINGLE_FRAG_RX  0     /* disable multi-fragment receives */
+#define SOCKNAL_SINGLE_FRAG_TX	0     /* disable multi-fragment sends */
+#define SOCKNAL_SINGLE_FRAG_RX	0     /* disable multi-fragment receives */
 
-#define SOCKNAL_VERSION_DEBUG   0     /* enable protocol version debugging */
+#define SOCKNAL_VERSION_DEBUG	0     /* enable protocol version debugging */
 
 /*
  * risk kmap deadlock on multi-frag I/O (backs off to single-frag if disabled).
@@ -461,31 +461,31 @@ extern struct ksock_tunables ksocknal_tunables;
 
 struct ksock_proto {
 	/* version number of protocol */
-	int        pro_version;
+	int	pro_version;
 
 	/* handshake function */
-	int        (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *);
+	int	(*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *);
 
 	/* handshake function */
-	int        (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int);
+	int	(*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int);
 
 	/* message pack */
-	void       (*pro_pack)(struct ksock_tx *);
+	void	(*pro_pack)(struct ksock_tx *);
 
 	/* message unpack */
-	void       (*pro_unpack)(struct ksock_msg *);
+	void	(*pro_unpack)(struct ksock_msg *);
 
 	/* queue tx on the connection */
 	struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *);
 
 	/* queue ZC ack on the connection */
-	int        (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64);
+	int	(*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64);
 
 	/* handle ZC request */
-	int        (*pro_handle_zcreq)(struct ksock_conn *, u64, int);
+	int	(*pro_handle_zcreq)(struct ksock_conn *, u64, int);
 
 	/* handle ZC ACK */
-	int        (*pro_handle_zcack)(struct ksock_conn *, u64, u64);
+	int	(*pro_handle_zcack)(struct ksock_conn *, u64, u64);
 
 	/*
 	 * msg type matches the connection type:
@@ -494,7 +494,7 @@ struct ksock_proto {
 	 *   return MATCH_YES : matching type
 	 *   return MATCH_MAY : can be backup
 	 */
-	int        (*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int);
+	int	(*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int);
 };
 
 extern struct ksock_proto ksocknal_protocol_v1x;
diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c
index 2df9ce4995f3..18f5c6b3b587 100644
--- a/drivers/staging/lustre/lnet/lnet/nidstrings.c
+++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c
@@ -92,9 +92,9 @@ EXPORT_SYMBOL(libcfs_next_nidstring);
  * <nidrange>        :== <addrrange> '@' <net>
  * <addrrange>       :== '*' |
  *                       <ipaddr_range> |
- *			 <cfs_expr_list>
+ *                       <cfs_expr_list>
  * <ipaddr_range>    :== <cfs_expr_list>.<cfs_expr_list>.<cfs_expr_list>.
- *			 <cfs_expr_list>
+ *                       <cfs_expr_list>
  * <cfs_expr_list>   :== <number> |
  *                       <expr_list>
  * <expr_list>       :== '[' <range_expr> [ ',' <range_expr>] ']'
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index bb61e3aa11e9..51ff979ca4ad 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -46,12 +46,12 @@
  * sorted by increasing expiry time. The number of slots is 2**7 (128),
  * to cover a time period of 1024 seconds into the future before wrapping.
  */
-#define STTIMER_MINPOLL        3	/* log2 min poll interval (8 s) */
+#define STTIMER_MINPOLL		3	/* log2 min poll interval (8 s) */
 #define STTIMER_SLOTTIME	BIT(STTIMER_MINPOLL)
-#define STTIMER_SLOTTIMEMASK   (~(STTIMER_SLOTTIME - 1))
+#define STTIMER_SLOTTIMEMASK	(~(STTIMER_SLOTTIME - 1))
 #define STTIMER_NSLOTS		BIT(7)
-#define STTIMER_SLOT(t)	       (&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \
-						    (STTIMER_NSLOTS - 1))])
+#define STTIMER_SLOT(t)		(&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \
+						     (STTIMER_NSLOTS - 1))])
 
 static struct st_timer_data {
 	spinlock_t	  stt_lock;
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index c85ef9ec639f..67b002bb1d1d 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -139,7 +139,7 @@ fld_debugfs_cache_flush_release(struct inode *inode, struct file *file)
 
 static const struct file_operations fld_debugfs_cache_flush_fops = {
 	.owner		= THIS_MODULE,
-	.open           = simple_open,
+	.open		= simple_open,
 	.write		= fld_debugfs_cache_flush_write,
 	.release	= fld_debugfs_cache_flush_release,
 };
diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h
index 7d52665a3c33..31b3881fb6c9 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -69,9 +69,9 @@ struct adaptive_timeout {
 
 struct ptlrpc_at_array {
 	struct list_head	*paa_reqs_array; /** array to hold requests */
-	u32			paa_size;        /** the size of array */
-	u32			paa_count;       /** the total count of reqs */
-	time64_t		paa_deadline;    /** the earliest deadline of reqs */
+	u32			paa_size;	 /** the size of array */
+	u32			paa_count;	 /** the total count of reqs */
+	time64_t		paa_deadline;	 /** the earliest deadline of reqs */
 	u32			*paa_reqs_count; /** the count of reqs in each entry */
 };
 
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 9cffda3741ce..e09268f08e5c 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -690,10 +690,10 @@ static inline int it_to_lock_mode(struct lookup_intent *it)
 
 enum md_op_flags {
 	MF_MDC_CANCEL_FID1	= BIT(0),
-	MF_MDC_CANCEL_FID2      = BIT(1),
-	MF_MDC_CANCEL_FID3      = BIT(2),
-	MF_MDC_CANCEL_FID4      = BIT(3),
-	MF_GET_MDT_IDX          = BIT(4),
+	MF_MDC_CANCEL_FID2	= BIT(1),
+	MF_MDC_CANCEL_FID3	= BIT(2),
+	MF_MDC_CANCEL_FID4	= BIT(3),
+	MF_GET_MDT_IDX		= BIT(4),
 };
 
 enum md_cli_flags {
@@ -744,7 +744,7 @@ struct md_op_data {
 	u32			op_flags;
 
 	/* Various operation flags. */
-	enum mds_op_bias        op_bias;
+	enum mds_op_bias	op_bias;
 
 	/* Used by readdir */
 	u64			op_offset;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 261857e4540d..ae2fddd044ea 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -335,9 +335,9 @@ static void ldlm_ns_release(struct kobject *kobj)
 }
 
 static struct kobj_type ldlm_ns_ktype = {
-	.default_attrs  = ldlm_ns_attrs,
-	.sysfs_ops      = &lustre_sysfs_ops,
-	.release        = ldlm_ns_release,
+	.default_attrs	= ldlm_ns_attrs,
+	.sysfs_ops	= &lustre_sysfs_ops,
+	.release	= ldlm_ns_release,
 };
 
 static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns)
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 6afaa9028864..07cb2c92c197 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2636,7 +2636,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			return -EFAULT;
 
 		return ll_file_futimes_3(file, &lfu);
-        }
+	}
 	case LL_IOC_LADVISE: {
 		struct llapi_ladvise_hdr *ladvise_hdr;
 		int alloc_size = sizeof(*ladvise_hdr);
diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
index 102d143691b2..0f7c0272d630 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
+++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
@@ -204,7 +204,7 @@ struct vvp_object {
 	 *
 	 * \see ll_vm_open(), ll_vm_close().
 	 */
-	atomic_t                vob_mmap_cnt;
+	atomic_t		vob_mmap_cnt;
 
 	/**
 	 * various flags
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 22f178a3abe2..a1d27061ac19 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -209,7 +209,7 @@ static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump)
 	if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
 		entry_count = comp_v1->lcm_entry_count;
 		is_composite = true;
-        }
+	}
 
 	for (i = 0; i < entry_count; i++) {
 		if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c
index 6db4d5eb46cd..395ef772fc17 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -536,7 +536,7 @@ void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm)
 		       DEXT ": id: %u, flags: %x, magic 0x%08X, layout_gen %u, stripe count %u, sstripe size %u, pool: [" LOV_POOLNAMEF "]\n",
 		       PEXT(&lse->lsme_extent), lse->lsme_id, lse->lsme_flags,
 		       lse->lsme_magic, lse->lsme_layout_gen,
-                       lse->lsme_stripe_count, lse->lsme_stripe_size,
+		       lse->lsme_stripe_count, lse->lsme_stripe_size,
 		       lse->lsme_pool_name);
 		if (!lsme_inited(lse) ||
 		    lse->lsme_pattern & LOV_PATTERN_F_RELEASED)
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index bad9538706f0..652ed6a20af3 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1336,19 +1336,19 @@ static const struct obd_ops lov_obd_ops = {
 	.owner		= THIS_MODULE,
 	.setup		= lov_setup,
 	.cleanup	= lov_cleanup,
-	.connect        = lov_connect,
-	.disconnect     = lov_disconnect,
-	.statfs         = lov_statfs,
-	.statfs_async   = lov_statfs_async,
-	.iocontrol      = lov_iocontrol,
-	.get_info       = lov_get_info,
-	.set_info_async = lov_set_info_async,
-	.notify         = lov_notify,
-	.pool_new       = lov_pool_new,
-	.pool_rem       = lov_pool_remove,
-	.pool_add       = lov_pool_add,
-	.pool_del       = lov_pool_del,
-	.quotactl       = lov_quotactl,
+	.connect	= lov_connect,
+	.disconnect	= lov_disconnect,
+	.statfs		= lov_statfs,
+	.statfs_async	= lov_statfs_async,
+	.iocontrol	= lov_iocontrol,
+	.get_info	= lov_get_info,
+	.set_info_async	= lov_set_info_async,
+	.notify		= lov_notify,
+	.pool_new	= lov_pool_new,
+	.pool_rem	= lov_pool_remove,
+	.pool_add	= lov_pool_add,
+	.pool_del	= lov_pool_del,
+	.quotactl	= lov_quotactl,
 };
 
 struct kmem_cache *lov_oinfo_slab;
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 3ff0bf1c4a22..ec872e8ae9be 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1818,18 +1818,18 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
 }
 
 static const struct obd_ops mgc_obd_ops = {
-	.owner          = THIS_MODULE,
-	.setup          = mgc_setup,
-	.precleanup     = mgc_precleanup,
-	.cleanup        = mgc_cleanup,
-	.add_conn       = client_import_add_conn,
-	.del_conn       = client_import_del_conn,
-	.connect        = client_connect_import,
-	.disconnect     = client_disconnect_export,
-	.set_info_async = mgc_set_info_async,
-	.get_info       = mgc_get_info,
-	.import_event   = mgc_import_event,
-	.process_config = mgc_process_config,
+	.owner		= THIS_MODULE,
+	.setup		= mgc_setup,
+	.precleanup	= mgc_precleanup,
+	.cleanup	= mgc_cleanup,
+	.add_conn	= client_import_add_conn,
+	.del_conn	= client_import_del_conn,
+	.connect	= client_connect_import,
+	.disconnect	= client_disconnect_export,
+	.set_info_async	= mgc_set_info_async,
+	.get_info	= mgc_get_info,
+	.import_event	= mgc_import_event,
+	.process_config	= mgc_process_config,
 };
 
 static int __init mgc_init(void)
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 1d1a6b2d436e..c91704d87042 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -313,9 +313,9 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
 
 	llog_group_init(&newdev->obd_olg);
 	/* Detach drops this */
-        atomic_set(&newdev->obd_refcount, 1);
-        lu_ref_init(&newdev->obd_reference);
-        lu_ref_add(&newdev->obd_reference, "newdev", newdev);
+	atomic_set(&newdev->obd_refcount, 1);
+	lu_ref_init(&newdev->obd_reference);
+	lu_ref_add(&newdev->obd_reference, "newdev", newdev);
 
 	newdev->obd_conn_inprogress = 0;
 
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 69a56cca99f2..d4f1eddd96ca 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -73,7 +73,7 @@ struct lu_site_bkt_data {
 	 *
 	 * \see htable_lookup().
 	 */
-	wait_queue_head_t	       lsb_marche_funebre;
+	wait_queue_head_t		lsb_marche_funebre;
 };
 
 enum {
@@ -935,10 +935,10 @@ static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
 static struct cfs_hash_ops lu_site_hash_ops = {
 	.hs_hash	= lu_obj_hop_hash,
 	.hs_key		= lu_obj_hop_key,
-	.hs_keycmp      = lu_obj_hop_keycmp,
-	.hs_object      = lu_obj_hop_object,
+	.hs_keycmp	= lu_obj_hop_keycmp,
+	.hs_object	= lu_obj_hop_object,
 	.hs_get		= lu_obj_hop_get,
-	.hs_put_locked  = lu_obj_hop_put_locked,
+	.hs_put_locked	= lu_obj_hop_put_locked,
 };
 
 static void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d)
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
index 71490b75c7ae..e9e0bcf39d4e 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
@@ -105,7 +105,7 @@ static ssize_t static_uintvalue_store(struct kobject *kobj,
 }
 
 #define LUSTRE_STATIC_UINT_ATTR(name, value)				\
-static struct static_lustre_uintvalue_attr lustre_sattr_##name =        \
+static struct static_lustre_uintvalue_attr lustre_sattr_##name =	\
 	{ __ATTR(name, 0644, static_uintvalue_show,			\
 		 static_uintvalue_store), value }
 
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 442b4355d946..765b5a7b9662 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -2989,26 +2989,26 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf)
 }
 
 static const struct obd_ops osc_obd_ops = {
-	.owner          = THIS_MODULE,
-	.setup          = osc_setup,
-	.precleanup     = osc_precleanup,
-	.cleanup        = osc_cleanup,
-	.add_conn       = client_import_add_conn,
-	.del_conn       = client_import_del_conn,
-	.connect        = client_connect_import,
-	.reconnect      = osc_reconnect,
-	.disconnect     = osc_disconnect,
-	.statfs         = osc_statfs,
-	.statfs_async   = osc_statfs_async,
-	.create         = osc_create,
-	.destroy        = osc_destroy,
-	.getattr        = osc_getattr,
-	.setattr        = osc_setattr,
-	.iocontrol      = osc_iocontrol,
-	.set_info_async = osc_set_info_async,
-	.import_event   = osc_import_event,
-	.process_config = osc_process_config,
-	.quotactl       = osc_quotactl,
+	.owner		= THIS_MODULE,
+	.setup		= osc_setup,
+	.precleanup	= osc_precleanup,
+	.cleanup	= osc_cleanup,
+	.add_conn	= client_import_add_conn,
+	.del_conn	= client_import_del_conn,
+	.connect	= client_connect_import,
+	.reconnect	= osc_reconnect,
+	.disconnect	= osc_disconnect,
+	.statfs		= osc_statfs,
+	.statfs_async	= osc_statfs_async,
+	.create		= osc_create,
+	.destroy	= osc_destroy,
+	.getattr	= osc_getattr,
+	.setattr	= osc_setattr,
+	.iocontrol	= osc_iocontrol,
+	.set_info_async	= osc_set_info_async,
+	.import_event	= osc_import_event,
+	.process_config	= osc_process_config,
+	.quotactl	= osc_quotactl,
 };
 
 struct list_head osc_shrink_list = LIST_HEAD_INIT(osc_shrink_list);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
index c2f49a3e0454..5dde3495aaf4 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
@@ -1508,7 +1508,7 @@ void lustre_assert_wire_constants(void)
 	LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding) == 16, "found %lld\n",
 		 (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding));
 	LASSERTF(LCME_FL_INIT == 0x00000010UL, "found 0x%.8xUL\n",
-	         (unsigned int)LCME_FL_INIT);
+		 (unsigned int)LCME_FL_INIT);
 
 	/* Checks for struct lov_comp_md_v1 */
 	LASSERTF((int)sizeof(struct lov_comp_md_v1) == 32, "found %lld\n",

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (32 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 31/37] lustre: discard OBD_FREE_RCU NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 19:08   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 35/37] lustre: portals_handle: discard h_lock NeilBrown
                   ` (2 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

In lu_cdebug_printer(), is "complete" is true, then
key->lck_area ends with a newline, so there is no need to
include on in the format too.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index d4f1eddd96ca..3e23babb329a 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -526,7 +526,7 @@ int lu_cdebug_printer(const struct lu_env *env,
 		  ARRAY_SIZE(key->lck_area) - used, format, args);
 	if (complete) {
 		if (cfs_cdebug_show(msgdata->msg_mask, msgdata->msg_subsys))
-			libcfs_debug_msg(msgdata, "%s\n", key->lck_area);
+			libcfs_debug_msg(msgdata, "%s", key->lck_area);
 		key->lck_area[0] = 0;
 	}
 	va_end(args);

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (22 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 20:02   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle NeilBrown
                   ` (12 subsequent siblings)
  36 siblings, 2 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Since 2.6.36, Linux' vsprintf has supported %pV
which supports "recursive sprintf" - exactly the task
that libcfs_debug_vmsg2 aims to provide.

Instead of calling libcfs_debug_vmsg2(), we can put the fmt and
args in a 'struct va_format', and pass the address of that structure
to the "%pV" format.

So do this to remove all users of libcfs_debug_vmsg2().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |  176 ++++++++++----------
 .../staging/lustre/lustre/ptlrpc/pack_generic.c    |   42 +++--
 2 files changed, 115 insertions(+), 103 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index f2433dc0e558..6789d3bf0485 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1970,6 +1970,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 	struct ldlm_resource *resource = NULL;
 	char *nid = "local";
 	va_list args;
+	struct va_format vaf;
 
 	if (spin_trylock(&lock->l_lock)) {
 		if (lock->l_resource)
@@ -1978,6 +1979,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 	}
 
 	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
 
 	if (exp && exp->exp_connection) {
 		nid = libcfs_nid2str(exp->exp_connection->c_peer.nid);
@@ -1988,105 +1991,110 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 	}
 
 	if (!resource) {
-		libcfs_debug_vmsg2(msgdata, fmt, args,
-				   " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
-				   lock,
-				   lock->l_handle.h_cookie,
-				   atomic_read(&lock->l_refc),
-				   lock->l_readers, lock->l_writers,
-				   ldlm_lockname[lock->l_granted_mode],
-				   ldlm_lockname[lock->l_req_mode],
-				   lock->l_flags, nid,
-				   lock->l_remote_handle.cookie,
-				   exp ? refcount_read(&exp->exp_refcount) : -99,
-				   lock->l_pid, lock->l_callback_timeout,
-				   lock->l_lvb_type);
+		libcfs_debug_msg(msgdata,
+				 "%pV ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
+				 &vaf,
+				 lock,
+				 lock->l_handle.h_cookie,
+				 atomic_read(&lock->l_refc),
+				 lock->l_readers, lock->l_writers,
+				 ldlm_lockname[lock->l_granted_mode],
+				 ldlm_lockname[lock->l_req_mode],
+				 lock->l_flags, nid,
+				 lock->l_remote_handle.cookie,
+				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 lock->l_pid, lock->l_callback_timeout,
+				 lock->l_lvb_type);
 		va_end(args);
 		return;
 	}
 
 	switch (resource->lr_type) {
 	case LDLM_EXTENT:
-		libcfs_debug_vmsg2(msgdata, fmt, args,
-				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
-				   ldlm_lock_to_ns_name(lock), lock,
-				   lock->l_handle.h_cookie,
-				   atomic_read(&lock->l_refc),
-				   lock->l_readers, lock->l_writers,
-				   ldlm_lockname[lock->l_granted_mode],
-				   ldlm_lockname[lock->l_req_mode],
-				   PLDLMRES(resource),
-				   atomic_read(&resource->lr_refcount),
-				   ldlm_typename[resource->lr_type],
-				   lock->l_policy_data.l_extent.start,
-				   lock->l_policy_data.l_extent.end,
-				   lock->l_req_extent.start,
-				   lock->l_req_extent.end,
-				   lock->l_flags, nid,
-				   lock->l_remote_handle.cookie,
-				   exp ? refcount_read(&exp->exp_refcount) : -99,
-				   lock->l_pid, lock->l_callback_timeout,
-				   lock->l_lvb_type);
+		libcfs_debug_msg(msgdata,
+				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
+				 &vaf,
+				 ldlm_lock_to_ns_name(lock), lock,
+				 lock->l_handle.h_cookie,
+				 atomic_read(&lock->l_refc),
+				 lock->l_readers, lock->l_writers,
+				 ldlm_lockname[lock->l_granted_mode],
+				 ldlm_lockname[lock->l_req_mode],
+				 PLDLMRES(resource),
+				 atomic_read(&resource->lr_refcount),
+				 ldlm_typename[resource->lr_type],
+				 lock->l_policy_data.l_extent.start,
+				 lock->l_policy_data.l_extent.end,
+				 lock->l_req_extent.start,
+				 lock->l_req_extent.end,
+				 lock->l_flags, nid,
+				 lock->l_remote_handle.cookie,
+				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 lock->l_pid, lock->l_callback_timeout,
+				 lock->l_lvb_type);
 		break;
 
 	case LDLM_FLOCK:
-		libcfs_debug_vmsg2(msgdata, fmt, args,
-				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n",
-				   ldlm_lock_to_ns_name(lock), lock,
-				   lock->l_handle.h_cookie,
-				   atomic_read(&lock->l_refc),
-				   lock->l_readers, lock->l_writers,
-				   ldlm_lockname[lock->l_granted_mode],
-				   ldlm_lockname[lock->l_req_mode],
-				   PLDLMRES(resource),
-				   atomic_read(&resource->lr_refcount),
-				   ldlm_typename[resource->lr_type],
-				   lock->l_policy_data.l_flock.pid,
-				   lock->l_policy_data.l_flock.start,
-				   lock->l_policy_data.l_flock.end,
-				   lock->l_flags, nid,
-				   lock->l_remote_handle.cookie,
-				   exp ? refcount_read(&exp->exp_refcount) : -99,
-				   lock->l_pid, lock->l_callback_timeout);
+		libcfs_debug_msg(msgdata,
+				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n",
+				 &vaf,
+				 ldlm_lock_to_ns_name(lock), lock,
+				 lock->l_handle.h_cookie,
+				 atomic_read(&lock->l_refc),
+				 lock->l_readers, lock->l_writers,
+				 ldlm_lockname[lock->l_granted_mode],
+				 ldlm_lockname[lock->l_req_mode],
+				 PLDLMRES(resource),
+				 atomic_read(&resource->lr_refcount),
+				 ldlm_typename[resource->lr_type],
+				 lock->l_policy_data.l_flock.pid,
+				 lock->l_policy_data.l_flock.start,
+				 lock->l_policy_data.l_flock.end,
+				 lock->l_flags, nid,
+				 lock->l_remote_handle.cookie,
+				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 lock->l_pid, lock->l_callback_timeout);
 		break;
 
 	case LDLM_IBITS:
-		libcfs_debug_vmsg2(msgdata, fmt, args,
-				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
-				   ldlm_lock_to_ns_name(lock),
-				   lock, lock->l_handle.h_cookie,
-				   atomic_read(&lock->l_refc),
-				   lock->l_readers, lock->l_writers,
-				   ldlm_lockname[lock->l_granted_mode],
-				   ldlm_lockname[lock->l_req_mode],
-				   PLDLMRES(resource),
-				   lock->l_policy_data.l_inodebits.bits,
-				   atomic_read(&resource->lr_refcount),
-				   ldlm_typename[resource->lr_type],
-				   lock->l_flags, nid,
-				   lock->l_remote_handle.cookie,
-				   exp ? refcount_read(&exp->exp_refcount) : -99,
-				   lock->l_pid, lock->l_callback_timeout,
-				   lock->l_lvb_type);
+		libcfs_debug_msg(msgdata,
+				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
+				 &vaf,
+				 ldlm_lock_to_ns_name(lock),
+				 lock, lock->l_handle.h_cookie,
+				 atomic_read(&lock->l_refc),
+				 lock->l_readers, lock->l_writers,
+				 ldlm_lockname[lock->l_granted_mode],
+				 ldlm_lockname[lock->l_req_mode],
+				 PLDLMRES(resource),
+				 lock->l_policy_data.l_inodebits.bits,
+				 atomic_read(&resource->lr_refcount),
+				 ldlm_typename[resource->lr_type],
+				 lock->l_flags, nid,
+				 lock->l_remote_handle.cookie,
+				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 lock->l_pid, lock->l_callback_timeout,
+				 lock->l_lvb_type);
 		break;
 
 	default:
-		libcfs_debug_vmsg2(msgdata, fmt, args,
-				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
-				   ldlm_lock_to_ns_name(lock),
-				   lock, lock->l_handle.h_cookie,
-				   atomic_read(&lock->l_refc),
-				   lock->l_readers, lock->l_writers,
-				   ldlm_lockname[lock->l_granted_mode],
-				   ldlm_lockname[lock->l_req_mode],
-				   PLDLMRES(resource),
-				   atomic_read(&resource->lr_refcount),
-				   ldlm_typename[resource->lr_type],
-				   lock->l_flags, nid,
-				   lock->l_remote_handle.cookie,
-				   exp ? refcount_read(&exp->exp_refcount) : -99,
-				   lock->l_pid, lock->l_callback_timeout,
-				   lock->l_lvb_type);
+		libcfs_debug_msg(msgdata,
+				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
+				 &vaf,
+				 ldlm_lock_to_ns_name(lock),
+				 lock, lock->l_handle.h_cookie,
+				 atomic_read(&lock->l_refc),
+				 lock->l_readers, lock->l_writers,
+				 ldlm_lockname[lock->l_granted_mode],
+				 ldlm_lockname[lock->l_req_mode],
+				 PLDLMRES(resource),
+				 atomic_read(&resource->lr_refcount),
+				 ldlm_typename[resource->lr_type],
+				 lock->l_flags, nid,
+				 lock->l_remote_handle.cookie,
+				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 lock->l_pid, lock->l_callback_timeout,
+				 lock->l_lvb_type);
 		break;
 	}
 	va_end(args);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index c7cc86c3fbc3..879cb1162cc7 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -2276,6 +2276,7 @@ void _debug_req(struct ptlrpc_request *req,
 	int rep_flags = -1;
 	int rep_status = -1;
 	va_list args;
+	struct va_format vaf;
 
 	spin_lock(&req->rq_early_free_lock);
 	if (req->rq_repmsg)
@@ -2298,25 +2299,28 @@ void _debug_req(struct ptlrpc_request *req,
 		nid = req->rq_export->exp_connection->c_peer.nid;
 
 	va_start(args, fmt);
-	libcfs_debug_vmsg2(msgdata, fmt, args,
-			   " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n",
-			   req, req->rq_xid, req->rq_transno,
-			   req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
-			   req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
-			   req->rq_import ?
-			   req->rq_import->imp_obd->obd_name :
-			   req->rq_export ?
-			   req->rq_export->exp_client_uuid.uuid :
-			   "<?>",
-			   libcfs_nid2str(nid),
-			   req->rq_request_portal, req->rq_reply_portal,
-			   req->rq_reqlen, req->rq_replen,
-			   req->rq_early_count, (s64)req->rq_timedout,
-			   (s64)req->rq_deadline,
-			   atomic_read(&req->rq_refcount),
-			   DEBUG_REQ_FLAGS(req),
-			   req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1,
-			   rep_flags, req->rq_status, rep_status);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+	libcfs_debug_msg(msgdata,
+			 "%pV req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n",
+			 &vaf,
+			 req, req->rq_xid, req->rq_transno,
+			 req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
+			 req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
+			 req->rq_import ?
+			 req->rq_import->imp_obd->obd_name :
+			 req->rq_export ?
+			 req->rq_export->exp_client_uuid.uuid :
+			 "<?>",
+			 libcfs_nid2str(nid),
+			 req->rq_request_portal, req->rq_reply_portal,
+			 req->rq_reqlen, req->rq_replen,
+			 req->rq_early_count, (s64)req->rq_timedout,
+			 (s64)req->rq_deadline,
+			 atomic_read(&req->rq_refcount),
+			 DEBUG_REQ_FLAGS(req),
+			 req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1,
+			 rep_flags, req->rq_status, rep_status);
 	va_end(args);
 }
 EXPORT_SYMBOL(_debug_req);

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (25 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-25 18:16   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment NeilBrown
                   ` (9 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Now that libcfs_debug_vmsg2 has no (external) users, we can remove it.
It is used to implement libcfs_debug_msg(), so simply move
the body of the function (suitably modified) into that one caller.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/libcfs_debug.h     |    5 --
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |   63 +++++---------------
 drivers/staging/lustre/lnet/libcfs/tracefile.h     |    2 -
 3 files changed, 18 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index ba5d5ba2dac2..911fd35b81b5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -192,11 +192,6 @@ int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata,
 		     const char *format1, ...)
 	__printf(2, 3);
 
-int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
-		       const char *format1,
-		       va_list args, const char *format2, ...)
-	__printf(4, 5);
-
 /* other external symbols that tracefile provides: */
 int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
 			    const char __user *usr_buffer, int usr_buffer_nob);
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 40440ce13050..45da892cf276 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -409,22 +409,7 @@ static void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
 }
 
 int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata,
-		     const char *format, ...)
-{
-	va_list args;
-	int rc;
-
-	va_start(args, format);
-	rc = libcfs_debug_vmsg2(msgdata, format, args, NULL);
-	va_end(args);
-
-	return rc;
-}
-EXPORT_SYMBOL(libcfs_debug_msg);
-
-int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
-		       const char *format1, va_list args,
-		       const char *format2, ...)
+		       const char *format, ...)
 {
 	struct cfs_trace_cpu_data *tcd = NULL;
 	struct ptldebug_header header = { 0 };
@@ -488,7 +473,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 		}
 
 		string_buf = (char *)page_address(tage->page) +
-			     tage->used + known_size;
+			tage->used + known_size;
 
 		max_nob = PAGE_SIZE - tage->used - known_size;
 		if (max_nob <= 0) {
@@ -500,22 +485,15 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 		}
 
 		needed = 0;
-		if (format1) {
-			va_copy(ap, args);
-			needed = vsnprintf(string_buf, max_nob, format1, ap);
-			va_end(ap);
-		}
 
-		if (format2) {
-			remain = max_nob - needed;
-			if (remain < 0)
-				remain = 0;
+		remain = max_nob - needed;
+		if (remain < 0)
+			remain = 0;
 
-			va_start(ap, format2);
-			needed += vsnprintf(string_buf + needed, remain,
-					    format2, ap);
-			va_end(ap);
-		}
+		va_start(ap, format);
+		needed += vsnprintf(string_buf + needed, remain,
+				    format, ap);
+		va_end(ap);
 
 		if (needed < max_nob) /* well. printing ok.. */
 			break;
@@ -600,22 +578,15 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 		string_buf = cfs_trace_get_console_buffer();
 
 		needed = 0;
-		if (format1) {
-			va_copy(ap, args);
-			needed = vsnprintf(string_buf,
-					   CFS_TRACE_CONSOLE_BUFFER_SIZE,
-					   format1, ap);
+
+		remain = CFS_TRACE_CONSOLE_BUFFER_SIZE - needed;
+		if (remain > 0) {
+			va_start(ap, format);
+			needed += vsnprintf(string_buf + needed, remain,
+					    format, ap);
 			va_end(ap);
 		}
-		if (format2) {
-			remain = CFS_TRACE_CONSOLE_BUFFER_SIZE - needed;
-			if (remain > 0) {
-				va_start(ap, format2);
-				needed += vsnprintf(string_buf + needed, remain,
-						    format2, ap);
-				va_end(ap);
-			}
-		}
+
 		cfs_print_to_console(&header, mask,
 				     string_buf, needed, file, msgdata->msg_fn);
 
@@ -639,7 +610,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 
 	return 0;
 }
-EXPORT_SYMBOL(libcfs_debug_vmsg2);
+EXPORT_SYMBOL(libcfs_debug_msg);
 
 void
 cfs_trace_assertion_failed(const char *str,
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h
index 71a031d12f42..3a00a6c60653 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h
@@ -82,7 +82,7 @@ union cfs_trace_data_union {
 		 * Even though this structure is meant to be per-CPU, locking
 		 * is needed because in some places the data may be accessed
 		 * from other CPUs. This lock is directly used in trace_get_tcd
-		 * and trace_put_tcd, which are called in libcfs_debug_vmsg2 and
+		 * and trace_put_tcd, which are called in libcfs_debug_msg and
 		 * tcd_for_each_type_lock
 		 */
 		spinlock_t		tcd_lock;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 27/37] lustre: discard lu_ref
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (27 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-24 20:28   ` James Simmons
  2019-02-19  0:09 ` [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops NeilBrown
                   ` (7 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

struct lu_ref is always an empty structure, and the functions
which manipulate it do nothing.
So this is not being tested and so cannot be trusted.
So remove all these calls and field declarations.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/cl_object.h  |    6 -
 drivers/staging/lustre/lustre/include/lu_object.h  |   45 -----
 drivers/staging/lustre/lustre/include/lu_ref.h     |  178 --------------------
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   20 --
 drivers/staging/lustre/lustre/include/obd.h        |    7 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   36 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   12 -
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    4 
 drivers/staging/lustre/lustre/llite/lcommon_cl.c   |    2 
 drivers/staging/lustre/lustre/llite/rw.c           |    6 -
 drivers/staging/lustre/lustre/llite/rw26.c         |    6 -
 drivers/staging/lustre/lustre/llite/vvp_dev.c      |   20 +-
 drivers/staging/lustre/lustre/llite/vvp_io.c       |    5 -
 drivers/staging/lustre/lustre/lov/lov_object.c     |    2 
 drivers/staging/lustre/lustre/lov/lovsub_dev.c     |    1 
 drivers/staging/lustre/lustre/mdc/mdc_reint.c      |    2 
 drivers/staging/lustre/lustre/obdclass/Makefile    |    2 
 drivers/staging/lustre/lustre/obdclass/cl_io.c     |    8 -
 drivers/staging/lustre/lustre/obdclass/cl_object.c |    2 
 drivers/staging/lustre/lustre/obdclass/cl_page.c   |    5 -
 drivers/staging/lustre/lustre/obdclass/genops.c    |    3 
 drivers/staging/lustre/lustre/obdclass/lu_object.c |   34 ----
 drivers/staging/lustre/lustre/obdclass/lu_ref.c    |   45 -----
 .../staging/lustre/lustre/obdclass/obd_config.c    |    2 
 drivers/staging/lustre/lustre/osc/osc_cache.c      |   12 -
 drivers/staging/lustre/lustre/osc/osc_lock.c       |    2 
 drivers/staging/lustre/lustre/osc/osc_page.c       |    2 
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 
 28 files changed, 19 insertions(+), 452 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/include/lu_ref.h
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ref.c

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 05be85306663..1484821995e9 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -742,12 +742,6 @@ struct cl_page {
 	 * by sub-io. Protected by a VM lock.
 	 */
 	struct cl_io			*cp_owner;
-	/** List of references to this page, for debugging. */
-	struct lu_ref			 cp_reference;
-	/** Link to an object, for debugging. */
-	struct lu_ref_link		 cp_obj_ref;
-	/** Link to a queue, for debugging. */
-	struct lu_ref_link		 cp_queue_ref;
 	/** Assigned if doing a sync_io */
 	struct cl_sync_io		*cp_sync_io;
 };
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index 68aa0d05b03a..cef02e66ea8e 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -38,7 +38,6 @@
 #include <linux/percpu_counter.h>
 #include <linux/libcfs/libcfs.h>
 #include <uapi/linux/lustre/lustre_idl.h>
-#include <lu_ref.h>
 
 struct seq_file;
 struct lustre_cfg;
@@ -277,10 +276,6 @@ struct lu_device {
 
 	/** \todo XXX: temporary back pointer into obd. */
 	struct obd_device			*ld_obd;
-	/**
-	 * A list of references to this object, for debugging.
-	 */
-	struct lu_ref				ld_reference;
 	/**
 	 * Link the device to the site.
 	 **/
@@ -464,10 +459,6 @@ struct lu_object {
 	 * Linkage into list of all layers.
 	 */
 	struct list_head			 lo_linkage;
-	/**
-	 * Link to the device, for debugging.
-	 */
-	struct lu_ref_link			 lo_dev_ref;
 };
 
 enum lu_object_header_flags {
@@ -536,10 +527,6 @@ struct lu_object_header {
 	 * during object destruction). No locking is necessary.
 	 */
 	struct list_head	loh_layers;
-	/**
-	 * A list of references to this object, for debugging.
-	 */
-	struct lu_ref		loh_reference;
 };
 
 struct fld;
@@ -818,34 +805,6 @@ static inline u32 lu_object_attr(const struct lu_object *o)
 	return o->lo_header->loh_attr;
 }
 
-static inline void lu_object_ref_add(struct lu_object *o,
-				     const char *scope,
-				     const void *source)
-{
-	lu_ref_add(&o->lo_header->loh_reference, scope, source);
-}
-
-static inline void lu_object_ref_add_at(struct lu_object *o,
-					struct lu_ref_link *link,
-					const char *scope,
-					const void *source)
-{
-	lu_ref_add_at(&o->lo_header->loh_reference, link, scope, source);
-}
-
-static inline void lu_object_ref_del(struct lu_object *o,
-				     const char *scope, const void *source)
-{
-	lu_ref_del(&o->lo_header->loh_reference, scope, source);
-}
-
-static inline void lu_object_ref_del_at(struct lu_object *o,
-					struct lu_ref_link *link,
-					const char *scope, const void *source)
-{
-	lu_ref_del_at(&o->lo_header->loh_reference, link, scope, source);
-}
-
 /** input params, should be filled out by mdt */
 struct lu_rdpg {
 	/** hash */
@@ -1084,10 +1043,6 @@ struct lu_context_key {
 	 * Internal implementation detail: module for this key.
 	 */
 	struct module	*lct_owner;
-	/**
-	 * References to this key. For debugging.
-	 */
-	struct lu_ref	lct_reference;
 };
 
 #define LU_KEY_INIT(mod, type)						\
diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h
deleted file mode 100644
index ad0c24d29ffa..000000000000
--- a/drivers/staging/lustre/lustre/include/lu_ref.h
+++ /dev/null
@@ -1,178 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- *
- *   Author: Nikita Danilov <nikita.danilov@sun.com>
- *
- *   This file is part of Lustre, http://www.lustre.org.
- *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   Lustre is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- */
-
-#ifndef __LUSTRE_LU_REF_H
-#define __LUSTRE_LU_REF_H
-
-#include <linux/list.h>
-
-/** \defgroup lu_ref lu_ref
- *
- * An interface to track references between objects. Mostly for debugging.
- *
- * Suppose there is a reference counted data-structure struct foo. To track
- * who acquired references to instance of struct foo, add lu_ref field to it:
- *
- * \code
- *	 struct foo {
- *		 atomic_t      foo_refcount;
- *		 struct lu_ref foo_reference;
- *		 ...
- *	 };
- * \endcode
- *
- * foo::foo_reference has to be initialized by calling
- * lu_ref_init(). Typically there will be functions or macros to increment and
- * decrement foo::foo_refcount, let's say they are foo_get(struct foo *foo)
- * and foo_put(struct foo *foo), respectively.
- *
- * Whenever foo_get() is called to acquire a reference on a foo, lu_ref_add()
- * has to be called to insert into foo::foo_reference a record, describing
- * acquired reference. Dually, lu_ref_del() removes matching record. Typical
- * usages are:
- *
- * \code
- *	struct bar *bar;
- *
- *	// bar owns a reference to foo.
- *	bar->bar_foo = foo_get(foo);
- *	lu_ref_add(&foo->foo_reference, "bar", bar);
- *
- *	...
- *
- *	// reference from bar to foo is released.
- *	lu_ref_del(&foo->foo_reference, "bar", bar);
- *	foo_put(bar->bar_foo);
- *
- *
- *	// current thread acquired a temporary reference to foo.
- *	foo_get(foo);
- *	lu_ref_add(&foo->reference, __func__, current);
- *
- *	...
- *
- *	// temporary reference is released.
- *	lu_ref_del(&foo->reference, __func__, current);
- *	foo_put(foo);
- * \endcode
- *
- * \e Et \e cetera. Often it makes sense to include lu_ref_add() and
- * lu_ref_del() calls into foo_get() and foo_put(). When an instance of struct
- * foo is destroyed, lu_ref_fini() has to be called that checks that no
- * pending references remain. lu_ref_print() can be used to dump a list of
- * pending references, while hunting down a leak.
- *
- * For objects to which a large number of references can be acquired,
- * lu_ref_del() can become cpu consuming, as it has to scan the list of
- * references. To work around this, remember result of lu_ref_add() (usually
- * in the same place where pointer to struct foo is stored), and use
- * lu_ref_del_at():
- *
- * \code
- *	// There is a large number of bar's for a single foo.
- *	bar->bar_foo     = foo_get(foo);
- *	bar->bar_foo_ref = lu_ref_add(&foo->foo_reference, "bar", bar);
- *
- *	...
- *
- *	// reference from bar to foo is released.
- *	lu_ref_del_at(&foo->foo_reference, bar->bar_foo_ref, "bar", bar);
- *	foo_put(bar->bar_foo);
- * \endcode
- *
- * lu_ref interface degrades gracefully in case of memory shortages.
- *
- * @{
- */
-
-/*
- * dummy data structures/functions to pass compile for now.
- * We need to reimplement them with kref.
- */
-struct lu_ref {};
-struct lu_ref_link {};
-
-static inline void lu_ref_init(struct lu_ref *ref)
-{
-}
-
-static inline void lu_ref_fini(struct lu_ref *ref)
-{
-}
-
-static inline struct lu_ref_link *lu_ref_add(struct lu_ref *ref,
-					     const char *scope,
-					     const void *source)
-{
-	return NULL;
-}
-
-static inline struct lu_ref_link *lu_ref_add_atomic(struct lu_ref *ref,
-						    const char *scope,
-						    const void *source)
-{
-	return NULL;
-}
-
-static inline void lu_ref_add_at(struct lu_ref *ref,
-				 struct lu_ref_link *link,
-				 const char *scope,
-				 const void *source)
-{
-}
-
-static inline void lu_ref_del(struct lu_ref *ref, const char *scope,
-			      const void *source)
-{
-}
-
-static inline void lu_ref_set_at(struct lu_ref *ref, struct lu_ref_link *link,
-				 const char *scope, const void *source0,
-				 const void *source1)
-{
-}
-
-static inline void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link,
-				 const char *scope, const void *source)
-{
-}
-
-static inline int lu_ref_global_init(void)
-{
-	return 0;
-}
-
-static inline void lu_ref_global_fini(void)
-{
-}
-
-static inline void lu_ref_print(const struct lu_ref *ref)
-{
-}
-
-static inline void lu_ref_print_all(void)
-{
-}
-
-/** @} lu */
-
-#endif /* __LUSTRE_LU_REF_H */
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index c561d61d1a49..6c0371ef056c 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -49,7 +49,6 @@
 #include <lustre_net.h>
 #include <lustre_import.h>
 #include <lustre_handles.h>
-#include <lu_ref.h>
 
 #include "lustre_dlm_flags.h"
 
@@ -785,8 +784,6 @@ struct ldlm_lock {
 	struct list_head		l_sl_mode;
 	struct list_head		l_sl_policy;
 
-	/** Reference tracking structure to debug leaked locks. */
-	struct lu_ref			l_reference;
 #if LUSTRE_TRACKS_LOCK_EXP_REFS
 	/* Debugging stuff for bug 20498, for tracking export references. */
 	/** number of export references taken */
@@ -859,9 +856,6 @@ struct ldlm_resource {
 	 * Associated inode, used only on client side.
 	 */
 	struct inode			*lr_lvb_inode;
-
-	/** List of references to this resource. For debugging. */
-	struct lu_ref			lr_reference;
 };
 
 static inline bool ldlm_has_layout(struct ldlm_lock *lock)
@@ -1066,17 +1060,12 @@ static inline struct ldlm_lock *ldlm_handle2lock(const struct lustre_handle *h)
 	return __ldlm_handle2lock(h, 0);
 }
 
-#define LDLM_LOCK_REF_DEL(lock) \
-	lu_ref_del(&lock->l_reference, "handle", current)
-
 static inline struct ldlm_lock *
 ldlm_handle2lock_long(const struct lustre_handle *h, u64 flags)
 {
 	struct ldlm_lock *lock;
 
 	lock = __ldlm_handle2lock(h, flags);
-	if (lock)
-		LDLM_LOCK_REF_DEL(lock);
 	return lock;
 }
 
@@ -1107,7 +1096,6 @@ void ldlm_dump_export_locks(struct obd_export *exp);
  */
 #define LDLM_LOCK_PUT(lock)		\
 do {					\
-	LDLM_LOCK_REF_DEL(lock);	\
 	/*LDLM_DEBUG((lock), "put");*/	\
 	ldlm_lock_put(lock);		\
 } while (0)
@@ -1198,14 +1186,6 @@ void ldlm_resource_dump(int level, struct ldlm_resource *);
 int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
 			      const struct ldlm_res_id *);
 
-#define LDLM_RESOURCE_ADDREF(res) do {					\
-	lu_ref_add_atomic(&(res)->lr_reference, __func__, current);	\
-} while (0)
-
-#define LDLM_RESOURCE_DELREF(res) do {				\
-	lu_ref_del(&(res)->lr_reference, __func__, current);	\
-} while (0)
-
 /* ldlm_request.c */
 /** \defgroup ldlm_local_ast Default AST handlers for local locks
  * These AST handlers are typically used for server-side local locks and are
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index e09268f08e5c..f7f4db0481b2 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -40,7 +40,6 @@
 
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lustre_lib.h>
-#include <lu_ref.h>
 #include <lustre_export.h>
 #include <lustre_fid.h>
 #include <lustre_fld.h>
@@ -615,12 +614,6 @@ struct obd_device {
 
 	int			 obd_conn_inprogress;
 
-	/**
-	 * A list of outstanding class_incref()'s against this obd. For
-	 * debugging.
-	 */
-	struct lu_ref		 obd_reference;
-
 	struct kset		 obd_kset; /* sysfs object collection */
 	struct kobj_type	 obd_ktype;
 	struct completion	 obd_kobj_unregister;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 6789d3bf0485..60a6ec2f7136 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -175,7 +175,6 @@ void ldlm_lock_put(struct ldlm_lock *lock)
 
 		lprocfs_counter_decr(ldlm_res_to_ns(res)->ns_stats,
 				     LDLM_NSS_LOCKS);
-		lu_ref_del(&res->lr_reference, "lock", lock);
 		ldlm_resource_putref(res);
 		lock->l_resource = NULL;
 		if (lock->l_export) {
@@ -185,7 +184,6 @@ void ldlm_lock_put(struct ldlm_lock *lock)
 
 		kfree(lock->l_lvb_data);
 
-		lu_ref_fini(&lock->l_reference);
 		OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle);
 	}
 }
@@ -334,10 +332,8 @@ static void ldlm_lock_destroy(struct ldlm_lock *lock)
 	unlock_res_and_lock(lock);
 
 	/* drop reference from hashtable only for first destroy */
-	if (first) {
-		lu_ref_del(&lock->l_reference, "hash", lock);
+	if (first)
 		LDLM_LOCK_RELEASE(lock);
-	}
 }
 
 /**
@@ -349,10 +345,8 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock)
 
 	first = ldlm_lock_destroy_internal(lock);
 	/* drop reference from hashtable only for first destroy */
-	if (first) {
-		lu_ref_del(&lock->l_reference, "hash", lock);
+	if (first)
 		LDLM_LOCK_RELEASE(lock);
-	}
 }
 
 /* this is called by portals_handle2object with the handle lock taken */
@@ -392,7 +386,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
 
 	spin_lock_init(&lock->l_lock);
 	lock->l_resource = resource;
-	lu_ref_add(&resource->lr_reference, "lock", lock);
 
 	atomic_set(&lock->l_refc, 2);
 	INIT_LIST_HEAD(&lock->l_res_link);
@@ -412,8 +405,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
 	INIT_LIST_HEAD(&lock->l_handle.h_link);
 	class_handle_hash(&lock->l_handle, &lock_handle_ops);
 
-	lu_ref_init(&lock->l_reference);
-	lu_ref_add(&lock->l_reference, "hash", lock);
 	lock->l_callback_timeout = 0;
 
 #if LUSTRE_TRACKS_LOCK_EXP_REFS
@@ -457,7 +448,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock,
 	if (IS_ERR(newres))
 		return PTR_ERR(newres);
 
-	lu_ref_add(&newres->lr_reference, "lock", lock);
 	/*
 	 * To flip the lock from the old to the new resource, lock, oldres and
 	 * newres have to be locked. Resource spin-locks are nested within
@@ -480,7 +470,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock,
 	unlock_res_and_lock(lock);
 
 	/* ...and the flowers are still standing! */
-	lu_ref_del(&oldres->lr_reference, "lock", lock);
 	ldlm_resource_putref(oldres);
 
 	return 0;
@@ -528,16 +517,13 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
 	/* It's unlikely but possible that someone marked the lock as
 	 * destroyed after we did handle2object on it
 	 */
-	if (flags == 0 && !ldlm_is_destroyed(lock)) {
-		lu_ref_add(&lock->l_reference, "handle", current);
+	if (flags == 0 && !ldlm_is_destroyed(lock))
 		return lock;
-	}
 
 	lock_res_and_lock(lock);
 
 	LASSERT(lock->l_resource);
 
-	lu_ref_add_atomic(&lock->l_reference, "handle", current);
 	if (unlikely(ldlm_is_destroyed(lock))) {
 		unlock_res_and_lock(lock);
 		CDEBUG(D_INFO, "lock already destroyed: lock %p\n", lock);
@@ -658,16 +644,13 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock,
 				      enum ldlm_mode mode)
 {
 	ldlm_lock_remove_from_lru(lock);
-	if (mode & (LCK_NL | LCK_CR | LCK_PR)) {
+	if (mode & (LCK_NL | LCK_CR | LCK_PR))
 		lock->l_readers++;
-		lu_ref_add_atomic(&lock->l_reference, "reader", lock);
-	}
-	if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) {
+
+	if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS))
 		lock->l_writers++;
-		lu_ref_add_atomic(&lock->l_reference, "writer", lock);
-	}
+
 	LDLM_LOCK_GET(lock);
-	lu_ref_add_atomic(&lock->l_reference, "user", lock);
 	LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]);
 }
 
@@ -725,16 +708,13 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock,
 	LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]);
 	if (mode & (LCK_NL | LCK_CR | LCK_PR)) {
 		LASSERT(lock->l_readers > 0);
-		lu_ref_del(&lock->l_reference, "reader", lock);
 		lock->l_readers--;
 	}
 	if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) {
 		LASSERT(lock->l_writers > 0);
-		lu_ref_del(&lock->l_reference, "writer", lock);
 		lock->l_writers--;
 	}
 
-	lu_ref_del(&lock->l_reference, "user", lock);
 	LDLM_LOCK_RELEASE(lock);    /* matches the LDLM_LOCK_GET() in addref */
 }
 
@@ -1285,7 +1265,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags,
 		return 0;
 	}
 
-	LDLM_RESOURCE_ADDREF(res);
 	lock_res(res);
 
 	if (res->lr_type == LDLM_EXTENT)
@@ -1307,7 +1286,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags,
 	}
 out:
 	unlock_res(res);
-	LDLM_RESOURCE_DELREF(res);
 	ldlm_resource_putref(res);
 
 	if (lock) {
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index b819adef2bfe..1f04a782bd89 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1423,7 +1423,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
 
 		LDLM_LOCK_GET(lock);
 		spin_unlock(&ns->ns_lock);
-		lu_ref_add(&lock->l_reference, __func__, current);
 
 		/* Pass the lock through the policy filter and see if it
 		 * should stay in LRU.
@@ -1441,15 +1440,11 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
 		 */
 		result = pf(ns, lock, unused, added, count);
 		if (result == LDLM_POLICY_KEEP_LOCK) {
-			lu_ref_del(&lock->l_reference,
-				   __func__, current);
 			LDLM_LOCK_RELEASE(lock);
 			spin_lock(&ns->ns_lock);
 			break;
 		}
 		if (result == LDLM_POLICY_SKIP_LOCK) {
-			lu_ref_del(&lock->l_reference,
-				   __func__, current);
 			LDLM_LOCK_RELEASE(lock);
 			spin_lock(&ns->ns_lock);
 			continue;
@@ -1467,8 +1462,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
 			 * pages could be put under it.
 			 */
 			unlock_res_and_lock(lock);
-			lu_ref_del(&lock->l_reference,
-				   __func__, current);
 			LDLM_LOCK_RELEASE(lock);
 			spin_lock(&ns->ns_lock);
 			continue;
@@ -1507,7 +1500,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
 		LASSERT(list_empty(&lock->l_bl_ast));
 		list_add(&lock->l_bl_ast, cancels);
 		unlock_res_and_lock(lock);
-		lu_ref_del(&lock->l_reference, __func__, current);
 		spin_lock(&ns->ns_lock);
 		added++;
 		unused--;
@@ -1695,7 +1687,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
 		return 0;
 	}
 
-	LDLM_RESOURCE_ADDREF(res);
 	count = ldlm_cancel_resource_local(res, &cancels, policy, mode,
 					   0, flags | LCF_BL_AST, opaque);
 	rc = ldlm_cli_cancel_list(&cancels, count, NULL, flags);
@@ -1703,7 +1694,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
 		CERROR("canceling unused lock " DLDLMRES ": rc = %d\n",
 		       PLDLMRES(res), rc);
 
-	LDLM_RESOURCE_DELREF(res);
 	ldlm_resource_putref(res);
 	return 0;
 }
@@ -1843,9 +1833,7 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns,
 	if (IS_ERR(res))
 		return 0;
 
-	LDLM_RESOURCE_ADDREF(res);
 	rc = ldlm_resource_foreach(res, iter, data);
-	LDLM_RESOURCE_DELREF(res);
 	ldlm_resource_putref(res);
 	return rc;
 }
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index ae2fddd044ea..371cc1d5e539 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1021,7 +1021,6 @@ static struct ldlm_resource *ldlm_resource_new(enum ldlm_type ldlm_type)
 
 	atomic_set(&res->lr_refcount, 1);
 	spin_lock_init(&res->lr_lock);
-	lu_ref_init(&res->lr_reference);
 
 	/* The creator of the resource must unlock the mutex after LVB
 	 * initialization.
@@ -1084,8 +1083,6 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
 	if (hnode) {
 		/* Someone won the race and already added the resource. */
 		cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
-		/* Clean lu_ref for failed resource. */
-		lu_ref_fini(&res->lr_reference);
 		/* We have taken lr_lvb_mutex. Drop it. */
 		mutex_unlock(&res->lr_lvb_mutex);
 		if (res->lr_itree)
@@ -1163,7 +1160,6 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
 
 	cfs_hash_bd_del_locked(ns->ns_rs_hash,
 			       bd, &res->lr_hash);
-	lu_ref_fini(&res->lr_reference);
 	cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
 	if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
 		ns->ns_lvbo->lvbo_free(res);
diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
index afcaa5ec13c2..94299fc2f5e3 100644
--- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
@@ -179,7 +179,6 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md)
 			 * locked by I_NEW bit.
 			 */
 			lli->lli_clob = clob;
-			lu_object_ref_add(&clob->co_lu, "inode", inode);
 		} else {
 			result = PTR_ERR(clob);
 		}
@@ -254,7 +253,6 @@ void cl_inode_fini(struct inode *inode)
 		 * when its master is evicted.
 		 */
 		cl_object_kill(env, clob);
-		lu_object_ref_del(&clob->co_lu, "inode", inode);
 		cl_object_put_last(env, clob);
 		lli->lli_clob = NULL;
 		if (emergency)
diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c
index af983ee09e8e..185d1692d79b 100644
--- a/drivers/staging/lustre/lustre/llite/rw.c
+++ b/drivers/staging/lustre/lustre/llite/rw.c
@@ -209,7 +209,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io,
 		goto out;
 	}
 
-	lu_ref_add(&page->cp_reference, "ra", current);
 	cl_page_assume(env, io, page);
 	vpg = cl2vvp_page(cl_object_page_slice(clob, page));
 	if (!vpg->vpg_defer_uptodate && !PageUptodate(vmpage)) {
@@ -225,7 +224,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io,
 		rc = 1;
 	}
 
-	lu_ref_del(&page->cp_reference, "ra", current);
 	cl_page_put(env, page);
 out:
 	if (vmpage) {
@@ -936,8 +934,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
 		page = cl_page_find(env, clob, vmpage->index,
 				    vmpage, CPT_CACHEABLE);
 		if (!IS_ERR(page)) {
-			lu_ref_add(&page->cp_reference, "writepage",
-				   current);
 			cl_page_assume(env, io, page);
 			result = cl_page_flush(env, io, page);
 			if (result != 0) {
@@ -954,8 +950,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
 			}
 			cl_page_disown(env, io, page);
 			unlocked = true;
-			lu_ref_del(&page->cp_reference,
-				   "writepage", current);
 			cl_page_put(env, page);
 		} else {
 			result = PTR_ERR(page);
diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c
index e4ce3b6f5772..9bcbc8b084e5 100644
--- a/drivers/staging/lustre/lustre/llite/rw26.c
+++ b/drivers/staging/lustre/lustre/llite/rw26.c
@@ -482,7 +482,6 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 	}
 
 	lcc->lcc_page = page;
-	lu_ref_add(&page->cp_reference, "cl_io", io);
 
 	cl_page_assume(env, io, page);
 	if (!PageUptodate(vmpage)) {
@@ -511,10 +510,8 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 			unlock_page(vmpage);
 			put_page(vmpage);
 		}
-		if (!IS_ERR_OR_NULL(page)) {
-			lu_ref_del(&page->cp_reference, "cl_io", io);
+		if (!IS_ERR_OR_NULL(page))
 			cl_page_put(env, page);
-		}
 		if (io)
 			io->ci_result = result;
 	} else {
@@ -575,7 +572,6 @@ static int ll_write_end(struct file *file, struct address_space *mapping,
 		cl_page_disown(env, io, page);
 
 		lcc->lcc_page = NULL;
-		lu_ref_del(&page->cp_reference, "cl_io", io);
 		cl_page_put(env, page);
 
 		/* page list is not contiguous now, commit it now */
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index c10ca6e7c606..34206166ada4 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -240,10 +240,9 @@ static int vvp_device_init(const struct lu_env *env, struct lu_device *d,
 	rc = next->ld_type->ldt_ops->ldto_device_init(env, next,
 						      next->ld_type->ldt_name,
 						      NULL);
-	if (rc == 0) {
+	if (rc == 0)
 		lu_device_get(next);
-		lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init);
-	}
+
 	return rc;
 }
 
@@ -420,10 +419,9 @@ static struct cl_object *vvp_pgcache_obj(const struct lu_env *env,
 		struct lu_object *lu_obj;
 
 		lu_obj = lu_object_locate(id->vpi_obj, dev->ld_type);
-		if (lu_obj) {
-			lu_object_ref_add(lu_obj, "dump", current);
+		if (lu_obj)
 			return lu2cl(lu_obj);
-		}
+
 		lu_object_put(env, lu_object_top(id->vpi_obj));
 	}
 	return NULL;
@@ -456,7 +454,6 @@ static struct page *vvp_pgcache_current(struct vvp_seq_private *priv)
 			priv->vsp_id.vpi_index = vmpage->index;
 			return vmpage;
 		}
-		lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current);
 		cl_object_put(priv->vsp_env, priv->vsp_clob);
 		priv->vsp_clob = NULL;
 		priv->vsp_id.vpi_index = 0;
@@ -527,11 +524,8 @@ static void vvp_pgcache_rewind(struct vvp_seq_private *priv)
 	if (priv->vsp_prev_pos) {
 		memset(&priv->vsp_id, 0, sizeof(priv->vsp_id));
 		priv->vsp_prev_pos = 0;
-		if (priv->vsp_clob) {
-			lu_object_ref_del(&priv->vsp_clob->co_lu, "dump",
-					  current);
+		if (priv->vsp_clob)
 			cl_object_put(priv->vsp_env, priv->vsp_clob);
-		}
 		priv->vsp_clob = NULL;
 	}
 }
@@ -607,10 +601,8 @@ static int vvp_dump_pgcache_seq_release(struct inode *inode, struct file *file)
 	struct seq_file *seq = file->private_data;
 	struct vvp_seq_private *priv = seq->private;
 
-	if (priv->vsp_clob) {
-		lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current);
+	if (priv->vsp_clob)
 		cl_object_put(priv->vsp_env, priv->vsp_clob);
-	}
 
 	cl_env_put(priv->vsp_env, &priv->vsp_refcheck);
 	return seq_release_private(inode, file);
diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c
index 593b10cecf7d..62b507926c20 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_io.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_io.c
@@ -382,7 +382,6 @@ static void vvp_io_fault_fini(const struct lu_env *env,
 	CLOBINVRNT(env, io->ci_obj, vvp_object_invariant(io->ci_obj));
 
 	if (page) {
-		lu_ref_del(&page->cp_reference, "fault", io);
 		cl_page_put(env, page);
 		io->u.ci_fault.ft_page = NULL;
 	}
@@ -824,7 +823,6 @@ static int vvp_io_commit_sync(const struct lu_env *env, struct cl_io *io,
 			cl_page_disown(env, io, page);
 
 			/* held in ll_cl_init() */
-			lu_ref_del(&page->cp_reference, "cl_io", io);
 			cl_page_put(env, page);
 		}
 	}
@@ -843,7 +841,6 @@ static void write_commit_callback(const struct lu_env *env, struct cl_io *io,
 	cl_page_disown(env, io, page);
 
 	/* held in ll_cl_init() */
-	lu_ref_del(&page->cp_reference, "cl_io", cl_io_top(io));
 	cl_page_put(env, page);
 }
 
@@ -944,7 +941,6 @@ int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io)
 		cl_page_disown(env, io, page);
 
 		/* held in ll_cl_init() */
-		lu_ref_del(&page->cp_reference, "cl_io", io);
 		cl_page_put(env, page);
 	}
 	cl_page_list_fini(env, queue);
@@ -1260,7 +1256,6 @@ static int vvp_io_fault_start(const struct lu_env *env,
 	else
 		fio->ft_nob = cl_page_size(obj);
 
-	lu_ref_add(&page->cp_reference, "fault", io);
 	fio->ft_page = page;
 
 out:
diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c
index 397ecc1dbb4c..cde8215a0b4c 100644
--- a/drivers/staging/lustre/lustre/lov/lov_object.c
+++ b/drivers/staging/lustre/lustre/lov/lov_object.c
@@ -149,7 +149,6 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov,
 		subhdr->coh_parent = hdr;
 		spin_unlock(&subhdr->coh_attr_guard);
 		subhdr->coh_nesting = hdr->coh_nesting + 1;
-		lu_object_ref_add(&subobj->co_lu, "lov-parent", lov);
 		r0->lo_sub[stripe] = cl2lovsub(subobj);
 		r0->lo_sub[stripe]->lso_super = lov;
 		r0->lo_sub[stripe]->lso_index = idx;
@@ -405,7 +404,6 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
 
 	cl_object_kill(env, sub);
 	/* release a reference to the sub-object and ... */
-	lu_object_ref_del(&sub->co_lu, "lov-parent", lov);
 	cl_object_put(env, sub);
 
 	/* ... wait until it is actually destroyed---sub-object clears its
diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
index 69380fc6aeab..d9b044e5aca1 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
@@ -65,7 +65,6 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d,
 	}
 
 	lu_device_get(next);
-	lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init);
 	lsd->acid_next = lu2cl_dev(next);
 	return rc;
 }
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
index e0e7b00fd2be..e878bc76da8a 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
@@ -87,12 +87,10 @@ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
 				NULL, &res_id, 0, 0);
 	if (IS_ERR(res))
 		return 0;
-	LDLM_RESOURCE_ADDREF(res);
 	/* Initialize ibits lock policy. */
 	policy.l_inodebits.bits = bits;
 	count = ldlm_cancel_resource_local(res, cancels, &policy,
 					   mode, 0, 0, NULL);
-	LDLM_RESOURCE_DELREF(res);
 	ldlm_resource_putref(res);
 	return count;
 }
diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index 1669c24a0b03..ee63ebd3947b 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -7,5 +7,5 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o
 obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o \
 	      genops.o obd_sysfs.o lprocfs_status.o lprocfs_counters.o \
 	      lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \
-	      obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \
+	      obdo.o obd_config.o obd_mount.o lu_object.o \
 	      cl_object.o cl_page.o cl_lock.o cl_io.o kernelcomm.o
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index 3b4aca4e4a53..9755174c2db6 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -770,7 +770,6 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page)
 	LASSERT(list_empty(&page->cp_batch));
 	list_add_tail(&page->cp_batch, &plist->pl_pages);
 	++plist->pl_nr;
-	lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist);
 	cl_page_get(page);
 }
 EXPORT_SYMBOL(cl_page_list_add);
@@ -787,7 +786,6 @@ void cl_page_list_del(const struct lu_env *env, struct cl_page_list *plist,
 
 	list_del_init(&page->cp_batch);
 	--plist->pl_nr;
-	lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist);
 	cl_page_put(env, page);
 }
 EXPORT_SYMBOL(cl_page_list_del);
@@ -805,8 +803,6 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src,
 	list_move_tail(&page->cp_batch, &dst->pl_pages);
 	--src->pl_nr;
 	++dst->pl_nr;
-	lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue",
-		      src, dst);
 }
 EXPORT_SYMBOL(cl_page_list_move);
 
@@ -823,8 +819,6 @@ void cl_page_list_move_head(struct cl_page_list *dst, struct cl_page_list *src,
 	list_move(&page->cp_batch, &dst->pl_pages);
 	--src->pl_nr;
 	++dst->pl_nr;
-	lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue",
-		      src, dst);
 }
 EXPORT_SYMBOL(cl_page_list_move_head);
 
@@ -869,8 +863,6 @@ void cl_page_list_disown(const struct lu_env *env,
 		 * XXX __cl_page_disown() will fail if page is not locked.
 		 */
 		__cl_page_disown(env, io, page);
-		lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue",
-			      plist);
 		cl_page_put(env, page);
 	}
 }
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index b09621f0f1f8..c7cf2e736ff7 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -924,8 +924,6 @@ struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site,
 		rc = ldt->ldt_ops->ldto_device_init(env, d, typename, next);
 		if (rc == 0) {
 			lu_device_get(d);
-			lu_ref_add(&d->ld_reference,
-				   "lu-stack", &lu_site_init);
 		} else {
 			ldt->ldt_ops->ldto_device_free(env, d);
 			CERROR("can't init device '%s', %d\n", typename, rc);
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c
index 7dcd3aff229f..a44533a063df 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -106,9 +106,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page)
 		if (unlikely(slice->cpl_ops->cpo_fini))
 			slice->cpl_ops->cpo_fini(env, slice);
 	}
-	lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page);
 	cl_object_put(env, obj);
-	lu_ref_fini(&page->cp_reference);
 	kfree(page);
 }
 
@@ -138,14 +136,11 @@ struct cl_page *cl_page_alloc(const struct lu_env *env,
 		refcount_set(&page->cp_ref, 1);
 		page->cp_obj = o;
 		cl_object_get(o);
-		lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page",
-				     page);
 		page->cp_vmpage = vmpage;
 		cl_page_state_set_trust(page, CPS_CACHED);
 		page->cp_type = type;
 		INIT_LIST_HEAD(&page->cp_layers);
 		INIT_LIST_HEAD(&page->cp_batch);
-		lu_ref_init(&page->cp_reference);
 		cl_object_for_each(o2, o) {
 			if (o2->co_ops->coo_page_init) {
 				result = o2->co_ops->coo_page_init(env, o2, page,
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index c91704d87042..ce92c8c1dc75 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -80,7 +80,6 @@ static void obd_device_free(struct obd_device *obd)
 		       obd, obd->obd_namespace, obd->obd_force);
 		LBUG();
 	}
-	lu_ref_fini(&obd->obd_reference);
 	kmem_cache_free(obd_device_cachep, obd);
 }
 
@@ -314,8 +313,6 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
 	llog_group_init(&newdev->obd_olg);
 	/* Detach drops this */
 	atomic_set(&newdev->obd_refcount, 1);
-	lu_ref_init(&newdev->obd_reference);
-	lu_ref_add(&newdev->obd_reference, "newdev", newdev);
 
 	newdev->obd_conn_inprogress = 0;
 
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 3e23babb329a..6a1c3bc3e9e8 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -52,7 +52,6 @@
 #include <lustre_fid.h>
 #include <lu_object.h>
 #include <cl_object.h>
-#include <lu_ref.h>
 #include <linux/list.h>
 
 struct lu_site_bkt_data {
@@ -1018,7 +1017,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top)
 	s->ls_top_dev = top;
 	top->ld_site = s;
 	lu_device_get(top);
-	lu_ref_add(&top->ld_reference, "site-top", s);
 
 	INIT_LIST_HEAD(&s->ls_ld_linkage);
 	spin_lock_init(&s->ls_ld_lock);
@@ -1047,7 +1045,6 @@ void lu_site_fini(struct lu_site *s)
 
 	if (s->ls_top_dev) {
 		s->ls_top_dev->ld_site = NULL;
-		lu_ref_del(&s->ls_top_dev->ld_reference, "site-top", s);
 		lu_device_put(s->ls_top_dev);
 		s->ls_top_dev = NULL;
 	}
@@ -1104,7 +1101,6 @@ int lu_device_init(struct lu_device *d, struct lu_device_type *t)
 	memset(d, 0, sizeof(*d));
 	atomic_set(&d->ld_ref, 0);
 	d->ld_type = t;
-	lu_ref_init(&d->ld_reference);
 	INIT_LIST_HEAD(&d->ld_linkage);
 	return 0;
 }
@@ -1122,7 +1118,6 @@ void lu_device_fini(struct lu_device *d)
 		d->ld_obd = NULL;
 	}
 
-	lu_ref_fini(&d->ld_reference);
 	LASSERTF(atomic_read(&d->ld_ref) == 0,
 		 "Refcount is %u\n", atomic_read(&d->ld_ref));
 	LASSERT(atomic_read(&t->ldt_device_nr) > 0);
@@ -1144,7 +1139,6 @@ int lu_object_init(struct lu_object *o, struct lu_object_header *h,
 	o->lo_header = h;
 	o->lo_dev = d;
 	lu_device_get(d);
-	lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o);
 	INIT_LIST_HEAD(&o->lo_linkage);
 
 	return 0;
@@ -1161,8 +1155,6 @@ void lu_object_fini(struct lu_object *o)
 	LASSERT(list_empty(&o->lo_linkage));
 
 	if (dev) {
-		lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref,
-			      "lu_object", o);
 		lu_device_put(dev);
 		o->lo_dev = NULL;
 	}
@@ -1203,7 +1195,6 @@ int lu_object_header_init(struct lu_object_header *h)
 	INIT_HLIST_NODE(&h->loh_hash);
 	INIT_LIST_HEAD(&h->loh_lru);
 	INIT_LIST_HEAD(&h->loh_layers);
-	lu_ref_init(&h->loh_reference);
 	return 0;
 }
 EXPORT_SYMBOL(lu_object_header_init);
@@ -1216,7 +1207,6 @@ void lu_object_header_fini(struct lu_object_header *h)
 	LASSERT(list_empty(&h->loh_layers));
 	LASSERT(list_empty(&h->loh_lru));
 	LASSERT(hlist_unhashed(&h->loh_hash));
-	lu_ref_fini(&h->loh_reference);
 }
 EXPORT_SYMBOL(lu_object_header_fini);
 
@@ -1253,7 +1243,6 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top)
 	lu_site_purge(env, site, ~0);
 	for (scan = top; scan; scan = next) {
 		next = scan->ld_type->ldt_ops->ldto_device_fini(env, scan);
-		lu_ref_del(&scan->ld_reference, "lu-stack", &lu_site_init);
 		lu_device_put(scan);
 	}
 
@@ -1306,7 +1295,6 @@ int lu_context_key_register(struct lu_context_key *key)
 
 	result = -ENFILE;
 	atomic_set(&key->lct_used, 1);
-	lu_ref_init(&key->lct_reference);
 	for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
 		if (lu_keys[i])
 			continue;
@@ -1318,10 +1306,9 @@ int lu_context_key_register(struct lu_context_key *key)
 		atomic_inc(&key_set_version);
 		break;
 	}
-	if (result) {
-		lu_ref_fini(&key->lct_reference);
+	if (result)
 		atomic_set(&key->lct_used, 0);
-	}
+
 	return result;
 }
 EXPORT_SYMBOL(lu_context_key_register);
@@ -1335,7 +1322,6 @@ static void key_fini(struct lu_context *ctx, int index)
 		LASSERT(atomic_read(&key->lct_used) > 1);
 
 		key->lct_fini(ctx, key, ctx->lc_value[index]);
-		lu_ref_del(&key->lct_reference, "ctx", ctx);
 		if (atomic_dec_and_test(&key->lct_used))
 			wake_up_var(&key->lct_used);
 
@@ -1364,8 +1350,7 @@ void lu_context_key_degister(struct lu_context_key *key)
 	atomic_dec(&key->lct_used);
 	wait_var_event(&key->lct_used, atomic_read(&key->lct_used) == 0);
 
-	if (!WARN_ON(lu_keys[key->lct_index] == NULL))
-		lu_ref_fini(&key->lct_reference);
+	WARN_ON(lu_keys[key->lct_index] == NULL);
 	smp_store_release(&lu_keys[key->lct_index], NULL);
 }
 EXPORT_SYMBOL(lu_context_key_degister);
@@ -1562,7 +1547,6 @@ static int keys_fill(struct lu_context *ctx)
 				break;
 			}
 
-			lu_ref_add_atomic(&key->lct_reference, "ctx", ctx);
 			atomic_inc(&key->lct_used);
 			/*
 			 * This is the only place in the code, where an
@@ -1873,16 +1857,10 @@ int lu_global_init(void)
 
 	CDEBUG(D_INFO, "Lustre LU module (%p).\n", &lu_keys);
 
-	result = lu_ref_global_init();
-	if (result != 0)
-		return result;
-
 	LU_CONTEXT_KEY_INIT(&lu_global_key);
 	result = lu_context_key_register(&lu_global_key);
-	if (result != 0) {
-		lu_ref_global_fini();
+	if (result != 0)
 		return result;
-	}
 
 	/*
 	 * At this level, we don't know what tags are needed, so allocate them
@@ -1894,7 +1872,6 @@ int lu_global_init(void)
 	up_write(&lu_sites_guard);
 	if (result != 0) {
 		lu_context_key_degister(&lu_global_key);
-		lu_ref_global_fini();
 		return result;
 	}
 
@@ -1912,7 +1889,6 @@ int lu_global_init(void)
 		lu_env_fini(&lu_shrink_env);
 		up_write(&lu_sites_guard);
 
-		lu_ref_global_fini();
 		return result;
 	}
 
@@ -1934,8 +1910,6 @@ void lu_global_fini(void)
 	down_write(&lu_sites_guard);
 	lu_env_fini(&lu_shrink_env);
 	up_write(&lu_sites_guard);
-
-	lu_ref_global_fini();
 }
 
 static u32 ls_stats_read(struct lprocfs_stats *stats, int idx)
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
deleted file mode 100644
index f67cb89ea0ba..000000000000
--- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c
+++ /dev/null
@@ -1,45 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/obdclass/lu_ref.c
- *
- * Lustre reference.
- *
- *   Author: Nikita Danilov <nikita.danilov@sun.com>
- */
-
-#define DEBUG_SUBSYSTEM S_CLASS
-
-#include <obd.h>
-#include <obd_class.h>
-#include <obd_support.h>
-#include <lu_ref.h>
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 0cdadea4e63c..45e8f03dec80 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -520,7 +520,6 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
 struct obd_device *class_incref(struct obd_device *obd,
 				const char *scope, const void *source)
 {
-	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));
@@ -538,7 +537,6 @@ void class_decref(struct obd_device *obd, const char *scope, const void *source)
 
 	LASSERT(obd->obd_num_exports >= 0);
 	last = atomic_dec_and_test(&obd->obd_refcount);
-	lu_ref_del(&obd->obd_reference, scope, source);
 
 	if (last) {
 		struct obd_export *exp;
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 4359a9320f37..81af452fbd85 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -388,8 +388,6 @@ static void osc_extent_free(struct kref *kref)
 	LASSERT(RB_EMPTY_NODE(&ext->oe_node));
 
 	if (ext->oe_dlmlock) {
-		lu_ref_add(&ext->oe_dlmlock->l_reference,
-			   "osc_extent", ext);
 		LDLM_LOCK_PUT(ext->oe_dlmlock);
 		ext->oe_dlmlock = NULL;
 	}
@@ -731,7 +729,6 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 	if (olck->ols_dlmlock) {
 		LASSERT(olck->ols_hold);
 		cur->oe_dlmlock = LDLM_LOCK_GET(olck->ols_dlmlock);
-		lu_ref_add(&olck->ols_dlmlock->l_reference, "osc_extent", cur);
 	}
 
 	/* grants has been allocated by caller */
@@ -1039,7 +1036,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
 		list_del_init(&oap->oap_pending_item);
 
 		cl_page_get(page);
-		lu_ref_add(&page->cp_reference, "truncate", current);
 
 		if (cl_page_own(env, io, page) == 0) {
 			cl_page_discard(env, io, page);
@@ -1049,7 +1045,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
 			LASSERT(0);
 		}
 
-		lu_ref_del(&page->cp_reference, "truncate", current);
 		cl_page_put(env, page);
 
 		--ext->oe_nr_pages;
@@ -1386,7 +1381,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
 	 * released in cl_page_completion() and nothing except for the
 	 * reference counter protects page from concurrent reclaim.
 	 */
-	lu_ref_del(&page->cp_reference, "transfer", page);
 
 	cl_page_completion(env, page, crt, rc);
 	cl_page_put(env, page);
@@ -2208,7 +2202,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
 	spin_lock(&cli->cl_loi_list_lock);
 	while ((osc = osc_next_obj(cli)) != NULL) {
 		struct cl_object *obj = osc2cl(osc);
-		struct lu_ref_link link;
 
 		OSC_IO_DEBUG(osc, "%lu in flight\n", rpcs_in_flight(cli));
 
@@ -2219,7 +2212,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
 
 		cl_object_get(obj);
 		spin_unlock(&cli->cl_loi_list_lock);
-		lu_object_ref_add_at(&obj->co_lu, &link, "check", current);
 
 		/* attempt some read/write balancing by alternating between
 		 * reads and writes in an object.  The makes_rpc checks here
@@ -2256,7 +2248,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
 			CERROR("Read request failed with %d\n", rc);
 
 		osc_list_maint(cli, osc);
-		lu_object_ref_del_at(&obj->co_lu, &link, "check", current);
 		cl_object_put(env, obj);
 
 		spin_lock(&cli->cl_loi_list_lock);
@@ -3065,8 +3056,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
 				continue;
 
 			cl_page_get(page);
-			lu_ref_add_atomic(&page->cp_reference,
-					  "gang_lookup", current);
 			pvec[j++] = ops;
 		}
 		++idx;
@@ -3088,7 +3077,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
 				res = (*cb)(env, io, ops, cbdata);
 
 			page = ops->ops_cl.cpl_page;
-			lu_ref_del(&page->cp_reference, "gang_lookup", current);
 			cl_page_put(env, page);
 		}
 		if (nr < OTI_PVEC_SIZE || end_of_region)
diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c
index bfc1abb47b49..ccdbdeffd1f3 100644
--- a/drivers/staging/lustre/lustre/osc/osc_lock.c
+++ b/drivers/staging/lustre/lustre/osc/osc_lock.c
@@ -239,7 +239,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *oscl,
 	/* lock reference taken by ldlm_handle2lock_long() is
 	 * owned by osc_lock and released in osc_lock_detach()
 	 */
-	lu_ref_add(&dlmlock->l_reference, "osc_lock", oscl);
 	oscl->ols_has_ref = 1;
 
 	LASSERT(!oscl->ols_dlmlock);
@@ -1031,7 +1030,6 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck)
 
 	/* release a reference taken in osc_lock_upcall(). */
 	LASSERT(olck->ols_has_ref);
-	lu_ref_del(&dlmlock->l_reference, "osc_lock", olck);
 	LDLM_LOCK_RELEASE(dlmlock);
 	olck->ols_has_ref = 0;
 }
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index ce911b82512d..3ee7f14f7c7a 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -61,7 +61,6 @@ static void osc_page_transfer_get(struct osc_page *opg, const char *label)
 
 	LASSERT(!opg->ops_transfer_pinned);
 	cl_page_get(page);
-	lu_ref_add_atomic(&page->cp_reference, label, page);
 	opg->ops_transfer_pinned = 1;
 }
 
@@ -72,7 +71,6 @@ static void osc_page_transfer_put(const struct lu_env *env,
 
 	if (opg->ops_transfer_pinned) {
 		opg->ops_transfer_pinned = 0;
-		lu_ref_del(&page->cp_reference, "transfer", page);
 		cl_page_put(env, page);
 	}
 }
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 765b5a7b9662..6ba443be1026 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -556,10 +556,8 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa,
 	if (IS_ERR(res))
 		return 0;
 
-	LDLM_RESOURCE_ADDREF(res);
 	count = ldlm_cancel_resource_local(res, cancels, NULL, mode,
 					   lock_flags, 0, NULL);
-	LDLM_RESOURCE_DELREF(res);
 	ldlm_resource_putref(res);
 	return count;
 }

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (24 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-27  6:52   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2 NeilBrown
                   ` (10 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

These arguments are no longer used, so we can discard them.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd_class.h  |    6 ++----
 drivers/staging/lustre/lustre/obdclass/genops.c    |   12 ++++++------
 .../staging/lustre/lustre/obdclass/obd_config.c    |   17 ++++++++---------
 drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |    4 ++--
 4 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index dd480501d7df..a913ef76a008 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -133,10 +133,8 @@ int class_parse_net(char *buf, u32 *net, char **endh);
 int class_match_nid(char *buf, char *key, lnet_nid_t nid);
 int class_match_net(char *buf, char *key, u32 net);
 
-struct obd_device *class_incref(struct obd_device *obd,
-				const char *scope, const void *source);
-void class_decref(struct obd_device *obd,
-		  const char *scope, const void *source);
+struct obd_device *class_incref(struct obd_device *obd);
+void class_decref(struct obd_device *obd);
 int class_config_llog_handler(const struct lu_env *env,
 			      struct llog_handle *handle,
 			      struct llog_rec_hdr *rec, void *data);
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index ce92c8c1dc75..fc7985a2922c 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -622,13 +622,13 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen)
 		if (strncmp(obd->obd_name, fsname, namelen))
 			continue;
 
-		class_incref(obd, __func__, obd);
+		class_incref(obd);
 		read_unlock(&obd_dev_lock);
 		rc2 = obd_set_info_async(NULL, obd->obd_self_export,
 					 sizeof(KEY_SPTLRPC_CONF),
 					 KEY_SPTLRPC_CONF, 0, NULL, NULL);
 		rc = rc ? rc : rc2;
-		class_decref(obd, __func__, obd);
+		class_decref(obd);
 		read_lock(&obd_dev_lock);
 	}
 	read_unlock(&obd_dev_lock);
@@ -737,7 +737,7 @@ static void class_export_destroy(struct obd_export *exp)
 	 * exists until freeing of the obd
 	 */
 	if (exp != obd->obd_self_export)
-		class_decref(obd, "export", exp);
+		class_decref(obd);
 
 	OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle);
 }
@@ -863,7 +863,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd,
 	}
 
 	if (!is_self) {
-		class_incref(obd, "export", export);
+		class_incref(obd);
 		list_add(&export->exp_obd_chain, &export->exp_obd->obd_exports);
 		obd->obd_num_exports++;
 	} else {
@@ -934,7 +934,7 @@ static void class_import_destroy(struct obd_import *imp)
 	}
 
 	LASSERT(!imp->imp_sec);
-	class_decref(imp->imp_obd, "import", imp);
+	class_decref(imp->imp_obd);
 	OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle);
 }
 
@@ -1017,7 +1017,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
 	spin_lock_init(&imp->imp_lock);
 	imp->imp_last_success_conn = 0;
 	imp->imp_state = LUSTRE_IMP_NEW;
-	imp->imp_obd = class_incref(obd, "import", imp);
+	imp->imp_obd = class_incref(obd);
 	mutex_init(&imp->imp_sec_mutex);
 	init_waitqueue_head(&imp->imp_recovery_waitq);
 	INIT_WORK(&imp->imp_zombie_work, obd_zombie_imp_cull);
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 45e8f03dec80..776f251e9f43 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -334,7 +334,7 @@ static int class_attach(struct lustre_cfg *lcfg)
 
 	rc = class_register_device(obd);
 	if (rc) {
-		class_decref(obd, "newdev", obd);
+		class_decref(obd);
 		return rc;
 	}
 
@@ -399,7 +399,7 @@ static int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 
 	spin_lock(&obd->obd_dev_lock);
 	/* cleanup drops this */
-	class_incref(obd, "setup", obd);
+	class_incref(obd);
 	spin_unlock(&obd->obd_dev_lock);
 
 	CDEBUG(D_IOCTL, "finished setup of obd %s (uuid %s)\n",
@@ -439,7 +439,7 @@ static int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)
 	CDEBUG(D_IOCTL, "detach on obd %s (uuid %s)\n",
 	       obd->obd_name, obd->obd_uuid.uuid);
 
-	class_decref(obd, "newdev", obd);
+	class_decref(obd);
 	return 0;
 }
 
@@ -511,14 +511,13 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	/* destroy an uuid-export hash body */
 	rhashtable_free_and_destroy(&obd->obd_uuid_hash, uuid_export_exit, NULL);
 
-	class_decref(obd, "setup", obd);
+	class_decref(obd);
 	obd->obd_set_up = 0;
 
 	return 0;
 }
 
-struct obd_device *class_incref(struct obd_device *obd,
-				const char *scope, const void *source)
+struct obd_device *class_incref(struct obd_device *obd)
 {
 	atomic_inc(&obd->obd_refcount);
 	CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd,
@@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd,
 }
 EXPORT_SYMBOL(class_incref);
 
-void class_decref(struct obd_device *obd, const char *scope, const void *source)
+void class_decref(struct obd_device *obd)
 {
 	int last;
 
-	CDEBUG(D_INFO, "Decref %s (%p) now %d - %s\n", obd->obd_name, obd,
-	       atomic_read(&obd->obd_refcount), scope);
+	CDEBUG(D_INFO, "Decref %s (%p) now %d\n", obd->obd_name, obd,
+	       atomic_read(&obd->obd_refcount));
 
 	LASSERT(obd->obd_num_exports >= 0);
 	last = atomic_dec_and_test(&obd->obd_refcount);
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
index e9e0bcf39d4e..57a6f2c2da1c 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
@@ -188,12 +188,12 @@ health_check_show(struct kobject *kobj, struct attribute *attr, char *buf)
 		if (obd->obd_stopping)
 			continue;
 
-		class_incref(obd, __func__, current);
+		class_incref(obd);
 		read_unlock(&obd_dev_lock);
 
 		if (obd_health_check(NULL, obd))
 			healthy = false;
-		class_decref(obd, __func__, current);
+		class_decref(obd);
 		read_lock(&obd_dev_lock);
 	}
 	read_unlock(&obd_dev_lock);

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (28 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 27/37] lustre: discard lu_ref NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-27  6:37   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 33/37] lustre: portals_handle: remove locking from class_handle2object() NeilBrown
                   ` (6 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

lustre_handles  assigned a  64bit  unique identifier  (a 'cookie')  to
objects of  various types and  stored them  in a hash  table, allowing
them to be accessed by the cookie.

The is a facility for type checking by recording an 'owner' for each
object, and checking the owner on lookup.  Unfortunately this is not
used - owner is always zero.

Eahc object also contains an h_ops pointer which can be used to
reliably identify an owner.

So discard h_owner, pass and 'ops' pointer to class_handle2object(),
and only return objects for which the h_ops matches.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lustre_handles.h |    7 +++----
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |    2 +-
 drivers/staging/lustre/lustre/obdclass/genops.c    |    3 ++-
 .../lustre/lustre/obdclass/lustre_handles.c        |    6 +++---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index 683680891e4c..9a4b1a821e7b 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -65,8 +65,7 @@ struct portals_handle_ops {
 struct portals_handle {
 	struct list_head		h_link;
 	u64				h_cookie;
-	const void			*h_owner;
-	struct portals_handle_ops	*h_ops;
+	const struct portals_handle_ops	*h_ops;
 
 	/* newly added fields to handle the RCU issue. -jxiong */
 	struct rcu_head			h_rcu;
@@ -79,9 +78,9 @@ struct portals_handle {
 
 /* Add a handle to the hash table */
 void class_handle_hash(struct portals_handle *,
-		       struct portals_handle_ops *ops);
+		       const struct portals_handle_ops *ops);
 void class_handle_unhash(struct portals_handle *);
-void *class_handle2object(u64 cookie, const void *owner);
+void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops);
 void class_handle_free_cb(struct rcu_head *rcu);
 int class_handle_init(void);
 void class_handle_cleanup(void);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 60a6ec2f7136..248331153c68 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -503,7 +503,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
 
 	LASSERT(handle);
 
-	lock = class_handle2object(handle->cookie, NULL);
+	lock = class_handle2object(handle->cookie, &lock_handle_ops);
 	if (!lock)
 		return NULL;
 
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index fc7985a2922c..b5fce96e43f7 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -674,6 +674,7 @@ int obd_init_caches(void)
 	return -ENOMEM;
 }
 
+static struct portals_handle_ops export_handle_ops;
 /* map connection to client */
 struct obd_export *class_conn2export(struct lustre_handle *conn)
 {
@@ -690,7 +691,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn)
 	}
 
 	CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie);
-	export = class_handle2object(conn->cookie, NULL);
+	export = class_handle2object(conn->cookie, &export_handle_ops);
 	return export;
 }
 EXPORT_SYMBOL(class_conn2export);
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index 0674afb0059f..32b70d613f71 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -59,7 +59,7 @@ static struct handle_bucket {
  * global (per-node) hash-table.
  */
 void class_handle_hash(struct portals_handle *h,
-		       struct portals_handle_ops *ops)
+		       const struct portals_handle_ops *ops)
 {
 	struct handle_bucket *bucket;
 
@@ -132,7 +132,7 @@ void class_handle_unhash(struct portals_handle *h)
 }
 EXPORT_SYMBOL(class_handle_unhash);
 
-void *class_handle2object(u64 cookie, const void *owner)
+void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)
 {
 	struct handle_bucket *bucket;
 	struct portals_handle *h;
@@ -147,7 +147,7 @@ void *class_handle2object(u64 cookie, const void *owner)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(h, &bucket->head, h_link) {
-		if (h->h_cookie != cookie || h->h_owner != owner)
+		if (h->h_cookie != cookie || h->h_ops != ops)
 			continue;
 
 		spin_lock(&h->h_lock);

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (23 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-27  6:32   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref NeilBrown
                   ` (11 subsequent siblings)
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Every object with a lustre_handle has (and must have) a refcount.
The lustre_handles code needs a call-out to increment this.
To simplify things, move the refcount into the lustre_handle
and discard the call-out.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |    6 ---
 .../staging/lustre/lustre/include/lustre_export.h  |    1 
 .../staging/lustre/lustre/include/lustre_handles.h |    2 -
 .../staging/lustre/lustre/include/lustre_import.h  |    2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   35 ++++++----------
 drivers/staging/lustre/lustre/obdclass/genops.c    |   44 +++++++-------------
 .../lustre/lustre/obdclass/lustre_handles.c        |    2 -
 .../staging/lustre/lustre/obdecho/echo_client.c    |    2 -
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 +-
 9 files changed, 35 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 6c0371ef056c..19c0f74b7c04 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -589,12 +589,6 @@ struct ldlm_lock {
 	 * Must be first in the structure.
 	 */
 	struct portals_handle		l_handle;
-	/**
-	 * Lock reference count.
-	 * This is how many users have pointers to actual structure, so that
-	 * we do not accidentally free lock structure that is in use.
-	 */
-	atomic_t			l_refc;
 	/**
 	 * Internal spinlock protects l_resource.  We should hold this lock
 	 * first before taking res_lock.
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index fb34e0b7de35..d05323313f55 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -67,7 +67,6 @@ struct obd_export {
 	 * what export they are talking to.
 	 */
 	struct portals_handle		exp_handle;
-	refcount_t			exp_refcount;
 	/**
 	 * Set of counters below is to track where export references are
 	 * kept. The exp_rpc_count is used for reconnect handling also,
diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index 9a4b1a821e7b..7e868aecff0e 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -46,7 +46,6 @@
 #include <linux/types.h>
 
 struct portals_handle_ops {
-	void (*hop_addref)(void *object);
 	void (*hop_free)(void *object, int size);
 };
 
@@ -66,6 +65,7 @@ struct portals_handle {
 	struct list_head		h_link;
 	u64				h_cookie;
 	const struct portals_handle_ops	*h_ops;
+	refcount_t			h_ref;
 
 	/* newly added fields to handle the RCU issue. -jxiong */
 	struct rcu_head			h_rcu;
diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h
index 31b3881fb6c9..ab7e1d94f4b2 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -154,8 +154,6 @@ struct import_state_hist {
 struct obd_import {
 	/** Local handle (== id) for this import. */
 	struct portals_handle		imp_handle;
-	/** Reference counter */
-	atomic_t			imp_refcount;
 	struct lustre_handle		imp_dlm_handle; /* client's ldlm export */
 	/** Currently active connection */
 	struct ptlrpc_connection       *imp_connection;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 248331153c68..7864f9a7ef90 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -148,7 +148,7 @@ EXPORT_SYMBOL(ldlm_it2str);
  */
 struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock)
 {
-	atomic_inc(&lock->l_refc);
+	refcount_inc(&lock->l_handle.h_ref);
 	return lock;
 }
 EXPORT_SYMBOL(ldlm_lock_get);
@@ -161,8 +161,8 @@ EXPORT_SYMBOL(ldlm_lock_get);
 void ldlm_lock_put(struct ldlm_lock *lock)
 {
 	LASSERT(lock->l_resource != LP_POISON);
-	LASSERT(atomic_read(&lock->l_refc) > 0);
-	if (atomic_dec_and_test(&lock->l_refc)) {
+	LASSERT(refcount_read(&lock->l_handle.h_ref) > 0);
+	if (refcount_dec_and_test(&lock->l_handle.h_ref)) {
 		struct ldlm_resource *res;
 
 		LDLM_DEBUG(lock,
@@ -349,12 +349,6 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock)
 		LDLM_LOCK_RELEASE(lock);
 }
 
-/* this is called by portals_handle2object with the handle lock taken */
-static void lock_handle_addref(void *lock)
-{
-	LDLM_LOCK_GET((struct ldlm_lock *)lock);
-}
-
 static void lock_handle_free(void *lock, int size)
 {
 	LASSERT(size == sizeof(struct ldlm_lock));
@@ -362,7 +356,6 @@ static void lock_handle_free(void *lock, int size)
 }
 
 static struct portals_handle_ops lock_handle_ops = {
-	.hop_addref = lock_handle_addref,
 	.hop_free   = lock_handle_free,
 };
 
@@ -387,7 +380,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
 	spin_lock_init(&lock->l_lock);
 	lock->l_resource = resource;
 
-	atomic_set(&lock->l_refc, 2);
+	refcount_set(&lock->l_handle.h_ref, 2);
 	INIT_LIST_HEAD(&lock->l_res_link);
 	INIT_LIST_HEAD(&lock->l_lru);
 	INIT_LIST_HEAD(&lock->l_pending_chain);
@@ -1974,13 +1967,13 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 &vaf,
 				 lock,
 				 lock->l_handle.h_cookie,
-				 atomic_read(&lock->l_refc),
+				 refcount_read(&lock->l_handle.h_ref),
 				 lock->l_readers, lock->l_writers,
 				 ldlm_lockname[lock->l_granted_mode],
 				 ldlm_lockname[lock->l_req_mode],
 				 lock->l_flags, nid,
 				 lock->l_remote_handle.cookie,
-				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 exp ? refcount_read(&exp->exp_handle.h_ref) : -99,
 				 lock->l_pid, lock->l_callback_timeout,
 				 lock->l_lvb_type);
 		va_end(args);
@@ -1994,7 +1987,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 &vaf,
 				 ldlm_lock_to_ns_name(lock), lock,
 				 lock->l_handle.h_cookie,
-				 atomic_read(&lock->l_refc),
+				 refcount_read(&lock->l_handle.h_ref),
 				 lock->l_readers, lock->l_writers,
 				 ldlm_lockname[lock->l_granted_mode],
 				 ldlm_lockname[lock->l_req_mode],
@@ -2007,7 +2000,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 lock->l_req_extent.end,
 				 lock->l_flags, nid,
 				 lock->l_remote_handle.cookie,
-				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 exp ? refcount_read(&exp->exp_handle.h_ref) : -99,
 				 lock->l_pid, lock->l_callback_timeout,
 				 lock->l_lvb_type);
 		break;
@@ -2018,7 +2011,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 &vaf,
 				 ldlm_lock_to_ns_name(lock), lock,
 				 lock->l_handle.h_cookie,
-				 atomic_read(&lock->l_refc),
+				 refcount_read(&lock->l_handle.h_ref),
 				 lock->l_readers, lock->l_writers,
 				 ldlm_lockname[lock->l_granted_mode],
 				 ldlm_lockname[lock->l_req_mode],
@@ -2030,7 +2023,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 lock->l_policy_data.l_flock.end,
 				 lock->l_flags, nid,
 				 lock->l_remote_handle.cookie,
-				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 exp ? refcount_read(&exp->exp_handle.h_ref) : -99,
 				 lock->l_pid, lock->l_callback_timeout);
 		break;
 
@@ -2040,7 +2033,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 &vaf,
 				 ldlm_lock_to_ns_name(lock),
 				 lock, lock->l_handle.h_cookie,
-				 atomic_read(&lock->l_refc),
+				 refcount_read(&lock->l_handle.h_ref),
 				 lock->l_readers, lock->l_writers,
 				 ldlm_lockname[lock->l_granted_mode],
 				 ldlm_lockname[lock->l_req_mode],
@@ -2050,7 +2043,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 ldlm_typename[resource->lr_type],
 				 lock->l_flags, nid,
 				 lock->l_remote_handle.cookie,
-				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 exp ? refcount_read(&exp->exp_handle.h_ref) : -99,
 				 lock->l_pid, lock->l_callback_timeout,
 				 lock->l_lvb_type);
 		break;
@@ -2061,7 +2054,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 &vaf,
 				 ldlm_lock_to_ns_name(lock),
 				 lock, lock->l_handle.h_cookie,
-				 atomic_read(&lock->l_refc),
+				 refcount_read(&lock->l_handle.h_ref),
 				 lock->l_readers, lock->l_writers,
 				 ldlm_lockname[lock->l_granted_mode],
 				 ldlm_lockname[lock->l_req_mode],
@@ -2070,7 +2063,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				 ldlm_typename[resource->lr_type],
 				 lock->l_flags, nid,
 				 lock->l_remote_handle.cookie,
-				 exp ? refcount_read(&exp->exp_refcount) : -99,
+				 exp ? refcount_read(&exp->exp_handle.h_ref) : -99,
 				 lock->l_pid, lock->l_callback_timeout,
 				 lock->l_lvb_type);
 		break;
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index b5fce96e43f7..4b1e14957a66 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -719,7 +719,7 @@ static void class_export_destroy(struct obd_export *exp)
 {
 	struct obd_device *obd = exp->exp_obd;
 
-	LASSERT(refcount_read(&exp->exp_refcount) == 0);
+	LASSERT(refcount_read(&exp->exp_handle.h_ref) == 0);
 	LASSERT(obd);
 
 	CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp,
@@ -743,33 +743,27 @@ static void class_export_destroy(struct obd_export *exp)
 	OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle);
 }
 
-static void export_handle_addref(void *export)
-{
-	class_export_get(export);
-}
-
 static struct portals_handle_ops export_handle_ops = {
-	.hop_addref	= export_handle_addref,
 	.hop_free	= NULL,
 };
 
 struct obd_export *class_export_get(struct obd_export *exp)
 {
-	refcount_inc(&exp->exp_refcount);
+	refcount_inc(&exp->exp_handle.h_ref);
 	CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
-	       refcount_read(&exp->exp_refcount));
+	       refcount_read(&exp->exp_handle.h_ref));
 	return exp;
 }
 EXPORT_SYMBOL(class_export_get);
 
 void class_export_put(struct obd_export *exp)
 {
-	LASSERT(refcount_read(&exp->exp_refcount) >  0);
-	LASSERT(refcount_read(&exp->exp_refcount) < LI_POISON);
+	LASSERT(refcount_read(&exp->exp_handle.h_ref) >  0);
+	LASSERT(refcount_read(&exp->exp_handle.h_ref) < LI_POISON);
 	CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp,
-	       refcount_read(&exp->exp_refcount) - 1);
+	       refcount_read(&exp->exp_handle.h_ref) - 1);
 
-	if (refcount_dec_and_test(&exp->exp_refcount)) {
+	if (refcount_dec_and_test(&exp->exp_handle.h_ref)) {
 		struct obd_device *obd = exp->exp_obd;
 
 		CDEBUG(D_IOCTL, "final put %p/%s\n",
@@ -819,7 +813,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd,
 
 	export->exp_conn_cnt = 0;
 	/* 2 = class_handle_hash + last */
-	refcount_set(&export->exp_refcount, 2);
+	refcount_set(&export->exp_handle.h_ref, 2);
 	atomic_set(&export->exp_rpc_count, 0);
 	atomic_set(&export->exp_cb_count, 0);
 	atomic_set(&export->exp_locks_count, 0);
@@ -922,7 +916,7 @@ static void class_import_destroy(struct obd_import *imp)
 	CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp,
 	       imp->imp_obd->obd_name);
 
-	LASSERT_ATOMIC_ZERO(&imp->imp_refcount);
+	LASSERT(refcount_read(&imp->imp_handle.h_ref) == 0);
 
 	ptlrpc_put_connection_superhack(imp->imp_connection);
 
@@ -939,21 +933,15 @@ static void class_import_destroy(struct obd_import *imp)
 	OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle);
 }
 
-static void import_handle_addref(void *import)
-{
-	class_import_get(import);
-}
-
 static struct portals_handle_ops import_handle_ops = {
-	.hop_addref	= import_handle_addref,
 	.hop_free	= NULL,
 };
 
 struct obd_import *class_import_get(struct obd_import *import)
 {
-	atomic_inc(&import->imp_refcount);
+	refcount_inc(&import->imp_handle.h_ref);
 	CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", import,
-	       atomic_read(&import->imp_refcount),
+	       refcount_read(&import->imp_handle.h_ref),
 	       import->imp_obd->obd_name);
 	return import;
 }
@@ -961,19 +949,19 @@ EXPORT_SYMBOL(class_import_get);
 
 void class_import_put(struct obd_import *imp)
 {
-	LASSERT_ATOMIC_GT_LT(&imp->imp_refcount, 0, LI_POISON);
+	LASSERT(refcount_read(&imp->imp_handle.h_ref) > 0);
 
 	CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp,
-	       atomic_read(&imp->imp_refcount) - 1,
+	       refcount_read(&imp->imp_handle.h_ref) - 1,
 	       imp->imp_obd->obd_name);
 
-	if (atomic_dec_and_test(&imp->imp_refcount)) {
+	if (refcount_dec_and_test(&imp->imp_handle.h_ref)) {
 		CDEBUG(D_INFO, "final put import %p\n", imp);
 		obd_zombie_import_add(imp);
 	}
 
 	/* catch possible import put race */
-	LASSERT_ATOMIC_GE_LT(&imp->imp_refcount, 0, LI_POISON);
+	LASSERT(refcount_read(&imp->imp_handle.h_ref) >= 0);
 }
 EXPORT_SYMBOL(class_import_put);
 
@@ -1023,7 +1011,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
 	init_waitqueue_head(&imp->imp_recovery_waitq);
 	INIT_WORK(&imp->imp_zombie_work, obd_zombie_imp_cull);
 
-	atomic_set(&imp->imp_refcount, 2);
+	refcount_set(&imp->imp_handle.h_ref, 2);
 	atomic_set(&imp->imp_unregistering, 0);
 	atomic_set(&imp->imp_inflight, 0);
 	atomic_set(&imp->imp_replay_inflight, 0);
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index 32b70d613f71..5c722d336c21 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)
 
 		spin_lock(&h->h_lock);
 		if (likely(h->h_in != 0)) {
-			h->h_ops->hop_addref(h);
+			refcount_inc(&h->h_ref);
 			retval = h;
 		}
 		spin_unlock(&h->h_lock);
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index baf34c85c4b5..6f00eee6170a 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -1638,7 +1638,7 @@ static int echo_client_cleanup(struct obd_device *obddev)
 		return -EBUSY;
 	}
 
-	LASSERT(refcount_read(&ec->ec_exp->exp_refcount) > 0);
+	LASSERT(refcount_read(&ec->ec_exp->exp_handle.h_ref) > 0);
 	rc = obd_disconnect(ec->ec_exp);
 	if (rc != 0)
 		CERROR("fail to disconnect device: %d\n", rc);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index eda921cce8f5..88a81ab2feb8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -1697,7 +1697,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
 	       (request->rq_export ?
 		(char *)request->rq_export->exp_client_uuid.uuid : "0"),
 	       (request->rq_export ?
-		refcount_read(&request->rq_export->exp_refcount) : -99),
+		refcount_read(&request->rq_export->exp_handle.h_ref) : -99),
 	       lustre_msg_get_status(request->rq_reqmsg), request->rq_xid,
 	       libcfs_id2str(request->rq_peer),
 	       lustre_msg_get_opc(request->rq_reqmsg));
@@ -1741,7 +1741,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
 	       (request->rq_export ?
 		(char *)request->rq_export->exp_client_uuid.uuid : "0"),
 	       (request->rq_export ?
-		refcount_read(&request->rq_export->exp_refcount) : -99),
+		refcount_read(&request->rq_export->exp_handle.h_ref) : -99),
 	       lustre_msg_get_status(request->rq_reqmsg),
 	       request->rq_xid,
 	       libcfs_id2str(request->rq_peer),

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 31/37] lustre: discard OBD_FREE_RCU
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (31 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 34/37] lustre: portals_handle: use hlist for hash lists NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing NeilBrown
                   ` (3 subsequent siblings)
  36 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

OBD_FREE_RCU and the hop_free call-back together form an overly
complex mechanism equivalent to kfree_rcu() or call_rcu(...).
Discard them and use the simpler approach.

This removes the only use for the field h_size, so discard
that too.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lustre_handles.h |    3 ---
 .../staging/lustre/lustre/include/obd_support.h    |   10 ----------
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   16 ++++++++--------
 drivers/staging/lustre/lustre/obdclass/genops.c    |    6 ++----
 .../lustre/lustre/obdclass/lustre_handles.c        |   15 ---------------
 5 files changed, 10 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index 7e868aecff0e..7079982ffd31 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -46,7 +46,6 @@
 #include <linux/types.h>
 
 struct portals_handle_ops {
-	void (*hop_free)(void *object, int size);
 };
 
 /* These handles are most easily used by having them appear at the very top of
@@ -70,7 +69,6 @@ struct portals_handle {
 	/* newly added fields to handle the RCU issue. -jxiong */
 	struct rcu_head			h_rcu;
 	spinlock_t			h_lock;
-	unsigned int			h_size:31;
 	unsigned int			h_in:1;
 };
 
@@ -81,7 +79,6 @@ void class_handle_hash(struct portals_handle *,
 		       const struct portals_handle_ops *ops);
 void class_handle_unhash(struct portals_handle *);
 void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops);
-void class_handle_free_cb(struct rcu_head *rcu);
 int class_handle_init(void);
 void class_handle_cleanup(void);
 
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index 3e15cac04ac5..91d6a862fa92 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -503,16 +503,6 @@ extern char obd_jobid_var[];
 #define POISON_PAGE(page, val) do { } while (0)
 #endif
 
-#define OBD_FREE_RCU(ptr, size, handle)			\
-do {							\
-	struct portals_handle *__h = (handle);		\
-							\
-	__h->h_cookie = (unsigned long)(ptr);		\
-	__h->h_size = (size);				\
-	call_rcu(&__h->h_rcu, class_handle_free_cb);	\
-	POISON_PTR(ptr);				\
-} while (0)
-
 #define KEY_IS(str)					\
 	(keylen >= (sizeof(str) - 1) &&			\
 	memcmp(key, str, (sizeof(str) - 1)) == 0)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 7864f9a7ef90..010285b226e6 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -153,6 +153,13 @@ struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock)
 }
 EXPORT_SYMBOL(ldlm_lock_get);
 
+static void lock_handle_free(struct rcu_head *rcu)
+{
+	struct ldlm_lock *lock = container_of(rcu, struct ldlm_lock,
+					      l_handle.h_rcu);
+	kmem_cache_free(ldlm_lock_slab, lock);
+}
+
 /**
  * Release lock reference.
  *
@@ -184,7 +191,7 @@ void ldlm_lock_put(struct ldlm_lock *lock)
 
 		kfree(lock->l_lvb_data);
 
-		OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle);
+		call_rcu(&lock->l_handle.h_rcu, lock_handle_free);
 	}
 }
 EXPORT_SYMBOL(ldlm_lock_put);
@@ -349,14 +356,7 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock)
 		LDLM_LOCK_RELEASE(lock);
 }
 
-static void lock_handle_free(void *lock, int size)
-{
-	LASSERT(size == sizeof(struct ldlm_lock));
-	kmem_cache_free(ldlm_lock_slab, lock);
-}
-
 static struct portals_handle_ops lock_handle_ops = {
-	.hop_free   = lock_handle_free,
 };
 
 /**
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 4b1e14957a66..156541ead12e 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -740,11 +740,10 @@ static void class_export_destroy(struct obd_export *exp)
 	if (exp != obd->obd_self_export)
 		class_decref(obd);
 
-	OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle);
+	kfree_rcu(exp, exp_handle.h_rcu);
 }
 
 static struct portals_handle_ops export_handle_ops = {
-	.hop_free	= NULL,
 };
 
 struct obd_export *class_export_get(struct obd_export *exp)
@@ -930,11 +929,10 @@ static void class_import_destroy(struct obd_import *imp)
 
 	LASSERT(!imp->imp_sec);
 	class_decref(imp->imp_obd);
-	OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle);
+	kfree_rcu(imp, imp_handle.h_rcu);
 }
 
 static struct portals_handle_ops import_handle_ops = {
-	.hop_free	= NULL,
 };
 
 struct obd_import *class_import_get(struct obd_import *import)
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index 5c722d336c21..f4599ec5b0f0 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -164,21 +164,6 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)
 }
 EXPORT_SYMBOL(class_handle2object);
 
-void class_handle_free_cb(struct rcu_head *rcu)
-{
-	struct portals_handle *h;
-	void *ptr;
-
-	h = container_of(rcu, struct portals_handle, h_rcu);
-	ptr = (void *)(unsigned long)h->h_cookie;
-
-	if (h->h_ops->hop_free)
-		h->h_ops->hop_free(ptr, h->h_size);
-	else
-		kfree(ptr);
-}
-EXPORT_SYMBOL(class_handle_free_cb);
-
 int class_handle_init(void)
 {
 	struct handle_bucket *bucket;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 32/37] lustre: portals_handle: rename ops to owner
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (20 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop NeilBrown
                   ` (14 subsequent siblings)
  36 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

Now the portals_handle_ops is empty, it is functioning
only to identify the owner of each handle.
So change the name to h_owner, and the type to void*

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lustre_handles.h |   10 +++-------
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |    7 +++----
 drivers/staging/lustre/lustre/obdclass/genops.c    |   15 ++++++---------
 .../lustre/lustre/obdclass/lustre_handles.c        |   13 ++++++-------
 4 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index 7079982ffd31..9d0f0b61b51a 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -45,9 +45,6 @@
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
-struct portals_handle_ops {
-};
-
 /* These handles are most easily used by having them appear at the very top of
  * whatever object that you want to make handles for.  ie:
  *
@@ -63,7 +60,7 @@ struct portals_handle_ops {
 struct portals_handle {
 	struct list_head		h_link;
 	u64				h_cookie;
-	const struct portals_handle_ops	*h_ops;
+	void				*h_owner;
 	refcount_t			h_ref;
 
 	/* newly added fields to handle the RCU issue. -jxiong */
@@ -75,10 +72,9 @@ struct portals_handle {
 /* handles.c */
 
 /* Add a handle to the hash table */
-void class_handle_hash(struct portals_handle *,
-		       const struct portals_handle_ops *ops);
+void class_handle_hash(struct portals_handle *, void *owner);
 void class_handle_unhash(struct portals_handle *);
-void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops);
+void *class_handle2object(u64 cookie, void *owner);
 int class_handle_init(void);
 void class_handle_cleanup(void);
 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 010285b226e6..b22aa640b723 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -356,8 +356,7 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock)
 		LDLM_LOCK_RELEASE(lock);
 }
 
-static struct portals_handle_ops lock_handle_ops = {
-};
+static int lock_handle_owner;
 
 /**
  *
@@ -396,7 +395,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
 	lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats,
 			     LDLM_NSS_LOCKS);
 	INIT_LIST_HEAD(&lock->l_handle.h_link);
-	class_handle_hash(&lock->l_handle, &lock_handle_ops);
+	class_handle_hash(&lock->l_handle, &lock_handle_owner);
 
 	lock->l_callback_timeout = 0;
 
@@ -496,7 +495,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
 
 	LASSERT(handle);
 
-	lock = class_handle2object(handle->cookie, &lock_handle_ops);
+	lock = class_handle2object(handle->cookie, &lock_handle_owner);
 	if (!lock)
 		return NULL;
 
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 156541ead12e..8ddee93b2a9d 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -674,7 +674,8 @@ int obd_init_caches(void)
 	return -ENOMEM;
 }
 
-static struct portals_handle_ops export_handle_ops;
+static int export_handle_owner;
+
 /* map connection to client */
 struct obd_export *class_conn2export(struct lustre_handle *conn)
 {
@@ -691,7 +692,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn)
 	}
 
 	CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie);
-	export = class_handle2object(conn->cookie, &export_handle_ops);
+	export = class_handle2object(conn->cookie, &export_handle_owner);
 	return export;
 }
 EXPORT_SYMBOL(class_conn2export);
@@ -743,9 +744,6 @@ static void class_export_destroy(struct obd_export *exp)
 	kfree_rcu(exp, exp_handle.h_rcu);
 }
 
-static struct portals_handle_ops export_handle_ops = {
-};
-
 struct obd_export *class_export_get(struct obd_export *exp)
 {
 	refcount_inc(&exp->exp_handle.h_ref);
@@ -828,7 +826,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd,
 	INIT_LIST_HEAD(&export->exp_req_replay_queue);
 	INIT_LIST_HEAD(&export->exp_handle.h_link);
 	INIT_LIST_HEAD(&export->exp_hp_rpcs);
-	class_handle_hash(&export->exp_handle, &export_handle_ops);
+	class_handle_hash(&export->exp_handle, &export_handle_owner);
 	spin_lock_init(&export->exp_lock);
 	spin_lock_init(&export->exp_rpc_lock);
 	spin_lock_init(&export->exp_bl_list_lock);
@@ -932,8 +930,7 @@ static void class_import_destroy(struct obd_import *imp)
 	kfree_rcu(imp, imp_handle.h_rcu);
 }
 
-static struct portals_handle_ops import_handle_ops = {
-};
+static int import_handle_owner;
 
 struct obd_import *class_import_get(struct obd_import *import)
 {
@@ -1016,7 +1013,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
 	atomic_set(&imp->imp_inval_count, 0);
 	INIT_LIST_HEAD(&imp->imp_conn_list);
 	INIT_LIST_HEAD(&imp->imp_handle.h_link);
-	class_handle_hash(&imp->imp_handle, &import_handle_ops);
+	class_handle_hash(&imp->imp_handle, &import_handle_owner);
 	init_imp_at(&imp->imp_at);
 
 	/* the default magic is V2, will be used in connect RPC, and
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index f4599ec5b0f0..30a84ff1e479 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -58,8 +58,7 @@ static struct handle_bucket {
  * Generate a unique 64bit cookie (hash) for a handle and insert it into
  * global (per-node) hash-table.
  */
-void class_handle_hash(struct portals_handle *h,
-		       const struct portals_handle_ops *ops)
+void class_handle_hash(struct portals_handle *h, void *owner)
 {
 	struct handle_bucket *bucket;
 
@@ -85,7 +84,7 @@ void class_handle_hash(struct portals_handle *h,
 	h->h_cookie = handle_base;
 	spin_unlock(&handle_base_lock);
 
-	h->h_ops = ops;
+	h->h_owner = owner;
 	spin_lock_init(&h->h_lock);
 
 	bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK];
@@ -132,7 +131,7 @@ void class_handle_unhash(struct portals_handle *h)
 }
 EXPORT_SYMBOL(class_handle_unhash);
 
-void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)
+void *class_handle2object(u64 cookie, void *owner)
 {
 	struct handle_bucket *bucket;
 	struct portals_handle *h;
@@ -147,7 +146,7 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(h, &bucket->head, h_link) {
-		if (h->h_cookie != cookie || h->h_ops != ops)
+		if (h->h_cookie != cookie || h->h_owner != owner)
 			continue;
 
 		spin_lock(&h->h_lock);
@@ -198,8 +197,8 @@ static int cleanup_all_handles(void)
 
 		spin_lock(&handle_hash[i].lock);
 		list_for_each_entry_rcu(h, &handle_hash[i].head, h_link) {
-			CERROR("force clean handle %#llx addr %p ops %p\n",
-			       h->h_cookie, h, h->h_ops);
+			CERROR("force clean handle %#llx addr %p owner %p\n",
+			       h->h_cookie, h, h->h_owner);
 
 			class_handle_unhash_nolock(h);
 			rc++;

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 33/37] lustre: portals_handle: remove locking from class_handle2object()
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (29 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 34/37] lustre: portals_handle: use hlist for hash lists NeilBrown
                   ` (5 subsequent siblings)
  36 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

There can be no value in this locking and test on h_in.

If the lookup could have run in parallel with
class_handle_unhash_nolock() and seen "h_in == 0", then it could
equally well have run moments earlier and not seen it - no locking
would prevent that, so the caller much be prepared to have
an object returned which has already been unhashed by the time it
sees the object.

In other words, an interlock between unhash and lookup much be
provided at a higher level than where this code is trying
to handle it.

So remove this pointless code.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/lustre/obdclass/lustre_handles.c        |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index 30a84ff1e479..40461c7fc8ef 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -149,12 +149,8 @@ void *class_handle2object(u64 cookie, void *owner)
 		if (h->h_cookie != cookie || h->h_owner != owner)
 			continue;
 
-		spin_lock(&h->h_lock);
-		if (likely(h->h_in != 0)) {
-			refcount_inc(&h->h_ref);
-			retval = h;
-		}
-		spin_unlock(&h->h_lock);
+		refcount_inc(&h->h_ref);
+		retval = h;
 		break;
 	}
 	rcu_read_unlock();

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 34/37] lustre: portals_handle: use hlist for hash lists.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (30 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 33/37] lustre: portals_handle: remove locking from class_handle2object() NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 31/37] lustre: discard OBD_FREE_RCU NeilBrown
                   ` (4 subsequent siblings)
  36 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

hlist_head/hlist_node is the preferred data structure
for hash tables. Not only does it make the 'head' smaller,
but is also provides hlist_unhashed() which can be used to
check if an object is in the list.  This means that
we don't need h_in any more.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lustre_handles.h |    3 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |    2 +-
 drivers/staging/lustre/lustre/obdclass/genops.c    |    4 ++--
 .../lustre/lustre/obdclass/lustre_handles.c        |   20 +++++++++-----------
 4 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index 9d0f0b61b51a..17aee8ea63ac 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -58,7 +58,7 @@
  * to compute the start of the structure based on the handle field.
  */
 struct portals_handle {
-	struct list_head		h_link;
+	struct hlist_node		h_link;
 	u64				h_cookie;
 	void				*h_owner;
 	refcount_t			h_ref;
@@ -66,7 +66,6 @@ struct portals_handle {
 	/* newly added fields to handle the RCU issue. -jxiong */
 	struct rcu_head			h_rcu;
 	spinlock_t			h_lock;
-	unsigned int			h_in:1;
 };
 
 /* handles.c */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b22aa640b723..03b2f582c47f 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -394,7 +394,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
 
 	lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats,
 			     LDLM_NSS_LOCKS);
-	INIT_LIST_HEAD(&lock->l_handle.h_link);
+	INIT_HLIST_NODE(&lock->l_handle.h_link);
 	class_handle_hash(&lock->l_handle, &lock_handle_owner);
 
 	lock->l_callback_timeout = 0;
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 8ddee93b2a9d..3324f3a82446 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -824,7 +824,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd,
 	spin_lock_init(&export->exp_uncommitted_replies_lock);
 	INIT_LIST_HEAD(&export->exp_uncommitted_replies);
 	INIT_LIST_HEAD(&export->exp_req_replay_queue);
-	INIT_LIST_HEAD(&export->exp_handle.h_link);
+	INIT_HLIST_NODE(&export->exp_handle.h_link);
 	INIT_LIST_HEAD(&export->exp_hp_rpcs);
 	class_handle_hash(&export->exp_handle, &export_handle_owner);
 	spin_lock_init(&export->exp_lock);
@@ -1012,7 +1012,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
 	atomic_set(&imp->imp_replay_inflight, 0);
 	atomic_set(&imp->imp_inval_count, 0);
 	INIT_LIST_HEAD(&imp->imp_conn_list);
-	INIT_LIST_HEAD(&imp->imp_handle.h_link);
+	INIT_HLIST_NODE(&imp->imp_handle.h_link);
 	class_handle_hash(&imp->imp_handle, &import_handle_owner);
 	init_imp_at(&imp->imp_at);
 
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index 40461c7fc8ef..78c1ca52fc77 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -48,7 +48,7 @@ static spinlock_t handle_base_lock;
 
 static struct handle_bucket {
 	spinlock_t		lock;
-	struct list_head	head;
+	struct hlist_head	head;
 } *handle_hash;
 
 #define HANDLE_HASH_SIZE (1 << 16)
@@ -63,7 +63,7 @@ void class_handle_hash(struct portals_handle *h, void *owner)
 	struct handle_bucket *bucket;
 
 	LASSERT(h);
-	LASSERT(list_empty(&h->h_link));
+	LASSERT(hlist_unhashed(&h->h_link));
 
 	/*
 	 * This is fast, but simplistic cookie generation algorithm, it will
@@ -89,8 +89,7 @@ void class_handle_hash(struct portals_handle *h, void *owner)
 
 	bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK];
 	spin_lock(&bucket->lock);
-	list_add_rcu(&h->h_link, &bucket->head);
-	h->h_in = 1;
+	hlist_add_head_rcu(&h->h_link, &bucket->head);
 	spin_unlock(&bucket->lock);
 
 	CDEBUG(D_INFO, "added object %p with handle %#llx to hash\n",
@@ -100,7 +99,7 @@ EXPORT_SYMBOL(class_handle_hash);
 
 static void class_handle_unhash_nolock(struct portals_handle *h)
 {
-	if (list_empty(&h->h_link)) {
+	if (hlist_unhashed(&h->h_link)) {
 		CERROR("removing an already-removed handle (%#llx)\n",
 		       h->h_cookie);
 		return;
@@ -110,13 +109,12 @@ static void class_handle_unhash_nolock(struct portals_handle *h)
 	       h, h->h_cookie);
 
 	spin_lock(&h->h_lock);
-	if (h->h_in == 0) {
+	if (hlist_unhashed(&h->h_link)) {
 		spin_unlock(&h->h_lock);
 		return;
 	}
-	h->h_in = 0;
+	hlist_del_init_rcu(&h->h_link);
 	spin_unlock(&h->h_lock);
-	list_del_rcu(&h->h_link);
 }
 
 void class_handle_unhash(struct portals_handle *h)
@@ -145,7 +143,7 @@ void *class_handle2object(u64 cookie, void *owner)
 	bucket = handle_hash + (cookie & HANDLE_HASH_MASK);
 
 	rcu_read_lock();
-	list_for_each_entry_rcu(h, &bucket->head, h_link) {
+	hlist_for_each_entry_rcu(h, &bucket->head, h_link) {
 		if (h->h_cookie != cookie || h->h_owner != owner)
 			continue;
 
@@ -173,7 +171,7 @@ int class_handle_init(void)
 	spin_lock_init(&handle_base_lock);
 	for (bucket = handle_hash + HANDLE_HASH_SIZE - 1; bucket >= handle_hash;
 	     bucket--) {
-		INIT_LIST_HEAD(&bucket->head);
+		INIT_HLIST_HEAD(&bucket->head);
 		spin_lock_init(&bucket->lock);
 	}
 
@@ -192,7 +190,7 @@ static int cleanup_all_handles(void)
 		struct portals_handle *h;
 
 		spin_lock(&handle_hash[i].lock);
-		list_for_each_entry_rcu(h, &handle_hash[i].head, h_link) {
+		hlist_for_each_entry_rcu(h, &handle_hash[i].head, h_link) {
 			CERROR("force clean handle %#llx addr %p owner %p\n",
 			       h->h_cookie, h, h->h_owner);
 

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 35/37] lustre: portals_handle: discard h_lock.
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (33 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var NeilBrown
  2019-02-19  0:09 ` [lustre-devel] [PATCH 36/37] lustre: remove unused fields from struct obd_device NeilBrown
  36 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

The h_lock spinlock is now only taken while bucket->lock
is held.  As a handle is associated with precisely one bucket,
this means that h_lock can never be contended, so it isn't needed.

So discard h_lock.

Also discard and increasingly irrelevant comment in the declaration
of struct portals_handle.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lustre_handles.h |    3 ---
 .../lustre/lustre/obdclass/lustre_handles.c        |    7 -------
 2 files changed, 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index 17aee8ea63ac..d07b0a498bff 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -62,10 +62,7 @@ struct portals_handle {
 	u64				h_cookie;
 	void				*h_owner;
 	refcount_t			h_ref;
-
-	/* newly added fields to handle the RCU issue. -jxiong */
 	struct rcu_head			h_rcu;
-	spinlock_t			h_lock;
 };
 
 /* handles.c */
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index 78c1ca52fc77..88a65a19785c 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -85,7 +85,6 @@ void class_handle_hash(struct portals_handle *h, void *owner)
 	spin_unlock(&handle_base_lock);
 
 	h->h_owner = owner;
-	spin_lock_init(&h->h_lock);
 
 	bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK];
 	spin_lock(&bucket->lock);
@@ -108,13 +107,7 @@ static void class_handle_unhash_nolock(struct portals_handle *h)
 	CDEBUG(D_INFO, "removing object %p with handle %#llx from hash\n",
 	       h, h->h_cookie);
 
-	spin_lock(&h->h_lock);
-	if (hlist_unhashed(&h->h_link)) {
-		spin_unlock(&h->h_lock);
-		return;
-	}
 	hlist_del_init_rcu(&h->h_link);
-	spin_unlock(&h->h_lock);
 }
 
 void class_handle_unhash(struct portals_handle *h)

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 36/37] lustre: remove unused fields from struct obd_device
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (35 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  36 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

One field is set but never access.
Another is accessed but never set.
Other are never mentioned at all.

Also remove the comment
	/* use separate field as it is set in interrupt to don't mess with
	 * protection of other bits using _bh lock
	 */

This is not correct - were it used, obd_recovery_expired would be part
of the same 'unsigned long' as the other fields.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd.h        |   33 +++++++-------------
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |    4 +-
 drivers/staging/lustre/lustre/obdclass/class_obd.c |    1 -
 .../staging/lustre/lustre/obdclass/obd_config.c    |    1 -
 4 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index f7f4db0481b2..c2716e7c1c58 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -538,27 +538,18 @@ struct obd_device {
 	char			 obd_name[MAX_OBD_NAME];
 
 	/* bitfield modification is protected by obd_dev_lock */
-	unsigned long obd_attached:1,      /* finished attach */
-		      obd_set_up:1,	/* finished setup */
-		      obd_version_recov:1, /* obd uses version checking */
-		      obd_replayable:1,/* recovery is enabled; inform clients */
-		      obd_no_transno:1,  /* no committed-transno notification */
-		      obd_no_recov:1,      /* fail instead of retry messages */
-		      obd_stopping:1,      /* started cleanup */
-		      obd_starting:1,      /* started setup */
-		      obd_force:1,	 /* cleanup with > 0 obd refcount */
-		      obd_fail:1,	 /* cleanup with failover */
-		      obd_no_conn:1,       /* deny new connections */
-		      obd_inactive:1,      /* device active/inactive
-					    * (for sysfs status only!!)
-					    */
-		      obd_no_ir:1,	 /* no imperative recovery. */
-		      obd_process_conf:1,  /* device is processing mgs config */
-		      obd_checksum_dump:1; /* dump pages upon cksum error */
-	/* use separate field as it is set in interrupt to don't mess with
-	 * protection of other bits using _bh lock
-	 */
-	unsigned long obd_recovery_expired:1;
+	unsigned long obd_attached:1,	  /* finished attach */
+		      obd_set_up:1,	  /* finished setup */
+		      obd_no_recov:1,	  /* fail instead of retry messages */
+		      obd_stopping:1,	  /* started cleanup */
+		      obd_starting:1,	  /* started setup */
+		      obd_force:1,	  /* cleanup with > 0 obd refcount */
+		      obd_fail:1,	  /* cleanup with failover */
+		      obd_inactive:1,	  /* device active/inactive
+					   * (for sysfs status only!!)
+					   */
+		      obd_process_conf:1;/* device is processing mgs config */
+
 	/* uuid-export hash body */
 	struct rhashtable	 obd_uuid_hash;
 	wait_queue_head_t	 obd_refcount_waitq;
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index ec872e8ae9be..a91724013773 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -991,10 +991,10 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
 		if (vallen != sizeof(int))
 			return -EINVAL;
 		value = *(int *)val;
-		CDEBUG(D_MGC, "InitRecov %s %d/d%d:i%d:r%d:or%d:%s\n",
+		CDEBUG(D_MGC, "InitRecov %s %d/d%d:i%d:r%d:%s\n",
 		       imp->imp_obd->obd_name, value,
 		       imp->imp_deactive, imp->imp_invalid,
-		       imp->imp_replayable, imp->imp_obd->obd_replayable,
+		       imp->imp_replayable,
 		       ptlrpc_import_state_name(imp->imp_state));
 		/* Resurrect if we previously died */
 		if ((imp->imp_state != LUSTRE_IMP_FULL &&
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index b8fc74044fe3..1fcbda128a58 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -525,7 +525,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 		}
 		CDEBUG(D_HA, "%s: disabling committed-transno notification\n",
 		       obd->obd_name);
-		obd->obd_no_transno = 1;
 		err = 0;
 		break;
 
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 776f251e9f43..79071b0d38ef 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -487,7 +487,6 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
 				LCONSOLE_WARN("Failing over %s\n",
 					      obd->obd_name);
 				obd->obd_fail = 1;
-				obd->obd_no_transno = 1;
 				obd->obd_no_recov = 1;
 				if (OBP(obd, iocontrol)) {
 					obd_iocontrol(OBD_IOC_SYNC,

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
                   ` (34 preceding siblings ...)
  2019-02-19  0:09 ` [lustre-devel] [PATCH 35/37] lustre: portals_handle: discard h_lock NeilBrown
@ 2019-02-19  0:09 ` NeilBrown
  2019-02-27  6:17   ` Andreas Dilger
  2019-02-19  0:09 ` [lustre-devel] [PATCH 36/37] lustre: remove unused fields from struct obd_device NeilBrown
  36 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-19  0:09 UTC (permalink / raw)
  To: lustre-devel

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.

Signed-off-by: NeilBrown <neilb@suse.com>

---
 drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |   21 ++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
index 57a6f2c2da1c..69ccc6a55947 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
@@ -216,16 +216,25 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
 			       const char *buffer,
 			       size_t count)
 {
+	static char *valid[] = {
+		JOBSTATS_DISABLE,
+		JOBSTATS_PROCNAME_UID,
+		JOBSTATS_NODELOCAL,
+		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;
 }

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables()
  2019-02-19  0:09 ` [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() NeilBrown
@ 2019-02-24 16:35   ` James Simmons
  2019-02-25 22:27     ` NeilBrown
  2019-02-24 16:52   ` [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type James Simmons
  1 sibling, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-24 16:35 UTC (permalink / raw)
  To: lustre-devel

y
> llite_kobj does not benefit from being in the
> lustre_kset kset (though it does need lustre_kset
> as a parent)

Nak.

Yes llite does benefit from being in the kset. On large clusters you
can end up with 1000s of clients so keeping the sysfs files setting 
in sync needs to be done in mass. The way Lustre does this is by 
running on the MGS server 'lctl conf_param $FSNAME.llite.lazystats=1'
or with the newer 'lctl set_param -P llite.$FSNAME-*.lazystats=1' as
an example. When this is done on the MGS that new value is first
persistently stored and then transmitted to the target nodes.
  
The magic behind this is with class_process_config(). In the code
path LCFG_PARAM, which handles the conf_param case' the main function
is class_modify_config() which is used by both llite and the obd
devices. This function first attempts to find the sysfs attribute
from the kobject and call lustre_attr_store() directly to set it.
If it can't find the attribute, which means its a debugfs file
most likely, then a uevent is created and sent off. The udev rule
then exexcutes some application to handle the debugfs settings.
For uevents to work the kobject (llite) must belong to a kset.

With LCFG_SET_PARAM, which handles the 'set_param -P' case the
master function is process_param2_config(). For this case we
always send attribute changes with uevents. Besides the requirement
of the kobject belonging to the kset this function uses 
kset_find_object() directly which if llite is not in the kset
will never be found.

> It also does not need the class_ktype type, as dynamic_kobj_ktype
> is sufficient.
> 
> So use the simple kobject_create_and_add() to initialize it.
> 
> This provides flexibility for making changes to
> class_setup_tunables().
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/llite/lproc_llite.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> index 8215296dc15d..78ec0fa65c58 100644
> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> @@ -46,7 +46,7 @@ int llite_tunables_register(void)
>  {
>  	int rc = 0;
>  
> -	llite_kobj = class_setup_tunables("llite");
> +	llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj);
>  	if (IS_ERR(llite_kobj))
>  		return PTR_ERR(llite_kobj);
>  

        llite_kobj->kset = kset_get(&lustre_kset);
> 

In llite_tunables_unregister() the call for kobject_put()
should really be replaced with kobject_del(). This is a bug
in my original work. 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type
  2019-02-19  0:09 ` [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() NeilBrown
  2019-02-24 16:35   ` James Simmons
@ 2019-02-24 16:52   ` James Simmons
  2019-02-25 22:38     ` NeilBrown
  1 sibling, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-24 16:52 UTC (permalink / raw)
  To: lustre-devel


For some reason this patch didn't land in my mailbox but I can
see it on https://patchwork.kernel.org/patch/10819037. This patch
is mostly good since llite now uses dynamic_kobj_ktype with its own
ktype. Thus class_sysfs_release() will never be called with llite.

What does need fixing is

--------------------------------------------------------
type->typ_kobj.kset = lustre_kset;

changed to:

type->typ_kobj.kset = kset_get(&lustre_kset);
--------------------------------------------------------

Next change needed it change all the 

kobject_put(&type->typ_kobj); -> kobject_del(&type->typ_kobj); 

So we properly handle the kset referencing. That is currently
broken by me :-(

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type NeilBrown
@ 2019-02-24 16:54   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 16:54 UTC (permalink / raw)
  To: lustre-devel


> Now that obj_type is managed as a kobject, move all
> the freeing and deregistering into class_sysfs_release().

This is a really nice change. I would have never considered that.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/genops.c |   27 +++++++++++------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 2bd72f8a38eb..4c0dc2098823 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -138,6 +138,18 @@ static void class_sysfs_release(struct kobject *kobj)
>  {
>  	struct obd_type *type = container_of(kobj, struct obd_type, typ_kobj);
>  
> +	debugfs_remove_recursive(type->typ_debugfs_entry);
> +
> +	if (type->typ_lu)
> +		lu_device_type_fini(type->typ_lu);
> +
> +	spin_lock(&obd_types_lock);
> +	list_del(&type->typ_chain);
> +	spin_unlock(&obd_types_lock);
> +
> +	kfree(type->typ_name);
> +	kfree(type->typ_md_ops);
> +	kfree(type->typ_dt_ops);
>  	kfree(type);
>  }
>  
> @@ -170,6 +182,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  
>  	type->typ_kobj.kset = lustre_kset;
>  	kobject_init(&type->typ_kobj, &class_ktype);
> +	INIT_LIST_HEAD(&type->typ_chain);
>  
>  	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
>  	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
> @@ -209,9 +222,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  	return 0;
>  
>  failed:
> -	kfree(type->typ_name);
> -	kfree(type->typ_md_ops);
> -	kfree(type->typ_dt_ops);
>  	kobject_put(&type->typ_kobj);
>  
>  	return rc;
> @@ -236,17 +246,6 @@ int class_unregister_type(const char *name)
>  		return -EBUSY;
>  	}
>  
> -	debugfs_remove_recursive(type->typ_debugfs_entry);
> -
> -	if (type->typ_lu)
> -		lu_device_type_fini(type->typ_lu);
> -
> -	spin_lock(&obd_types_lock);
> -	list_del(&type->typ_chain);
> -	spin_unlock(&obd_types_lock);
> -	kfree(type->typ_name);
> -	kfree(type->typ_dt_ops);
> -	kfree(type->typ_md_ops);
>  	kobject_put(&type->typ_kobj);
>  
>  	return 0;
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name
  2019-02-19  0:09 ` [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name NeilBrown
@ 2019-02-24 16:56   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 16:56 UTC (permalink / raw)
  To: lustre-devel


> As the kobject has a name (after kobject_add has been called),
> we don't need to also store it in typ_name.
> So use typ_kobj.name instead of typ_name.
> 
> This requires changing some "char *" to "const char *" as
> typ.kobj.name is const.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_net.h |    4 ++-
>  drivers/staging/lustre/lustre/include/obd.h        |    2 +-
>  drivers/staging/lustre/lustre/include/obd_class.h  |    2 +-
>  drivers/staging/lustre/lustre/ldlm/ldlm_lib.c      |    2 +-
>  drivers/staging/lustre/lustre/obdclass/genops.c    |   25 ++++++++------------
>  drivers/staging/lustre/lustre/ptlrpc/client.c      |    2 +-
>  6 files changed, 16 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
> index 47b9632e5660..f3b6ba061eed 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_net.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_net.h
> @@ -308,7 +308,7 @@ struct ptlrpc_client {
>  	/** What portal do we expect replies on */
>  	u32			cli_reply_portal;
>  	/** Name of the client */
> -	char			*cli_name;
> +	const char		*cli_name;
>  };
>  
>  /** state flags of requests */
> @@ -1817,7 +1817,7 @@ void ptlrpc_request_committed(struct ptlrpc_request *req, int force);
>  int ptlrpc_inc_ref(void);
>  void ptlrpc_dec_ref(void);
>  
> -void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
> +void ptlrpc_init_client(int req_portal, int rep_portal, const char *name,
>  			struct ptlrpc_client *);
>  struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid,
>  						    lnet_nid_t nid4refnet);
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index b161542855fc..3aa9cc889949 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -103,12 +103,12 @@ struct obd_type {
>  	struct obd_ops		*typ_dt_ops;
>  	struct md_ops		*typ_md_ops;
>  	struct dentry		*typ_debugfs_entry;
> -	char			*typ_name;
>  	int			 typ_refcnt;
>  	struct lu_device_type	*typ_lu;
>  	spinlock_t		 obd_type_lock;
>  	struct kobject		 typ_kobj;
>  };
> +#define typ_name typ_kobj.name
>  
>  struct brw_page {
>  	u64			off;
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index e4695f5b748d..a61c7950393c 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -74,7 +74,7 @@ int class_name2dev(const char *name);
>  struct obd_device *class_name2obd(const char *name);
>  int class_uuid2dev(struct obd_uuid *uuid);
>  struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
> -					 const char *typ_name,
> +					 const char *type_name,
>  					 struct obd_uuid *grp_uuid);
>  struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid,
>  					  int *next);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
> index aef83ffc8bb3..ac0fbb24fc92 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
> @@ -247,7 +247,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
>  	struct obd_import *imp;
>  	struct obd_uuid server_uuid;
>  	int rq_portal, rp_portal, connect_op;
> -	char *name = obddev->obd_type->typ_name;
> +	const char *name = obddev->obd_type->typ_name;
>  	enum ldlm_ns_type ns_type = LDLM_NS_TYPE_UNKNOWN;
>  	struct ptlrpc_connection fake_conn = {
>  		.c_self = 0,
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 4c0dc2098823..32581f1a92ac 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -147,7 +147,6 @@ static void class_sysfs_release(struct kobject *kobj)
>  	list_del(&type->typ_chain);
>  	spin_unlock(&obd_types_lock);
>  
> -	kfree(type->typ_name);
>  	kfree(type->typ_md_ops);
>  	kfree(type->typ_dt_ops);
>  	kfree(type);
> @@ -186,28 +185,24 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  
>  	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
>  	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
> -	type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS);
>  
>  	if (!type->typ_dt_ops ||
> -	    !type->typ_md_ops ||
> -	    !type->typ_name)
> +	    !type->typ_md_ops)
>  		goto failed;
>  
>  	*type->typ_dt_ops = *dt_ops;
>  	/* md_ops is optional */
>  	if (md_ops)
>  		*type->typ_md_ops = *md_ops;
> -	strcpy(type->typ_name, name);
>  	spin_lock_init(&type->obd_type_lock);
>  
> -	type->typ_debugfs_entry = debugfs_create_dir(type->typ_name,
> -						     debugfs_lustre_root);
> -
>  	rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
> -
>  	if (rc)
>  		goto failed;
>  
> +	type->typ_debugfs_entry = debugfs_create_dir(type->typ_name,
> +						     debugfs_lustre_root);
> +
>  	if (ldt) {
>  		type->typ_lu = ldt;
>  		rc = lu_device_type_init(ldt);
> @@ -534,7 +529,7 @@ struct obd_device *class_num2obd(int num)
>   * otherwise any client connected to the tgt is returned.
>   */
>  struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
> -					 const char *typ_name,
> +					 const char *type_name,
>  					 struct obd_uuid *grp_uuid)
>  {
>  	int i;
> @@ -545,8 +540,8 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
>  
>  		if (!obd)
>  			continue;
> -		if ((strncmp(obd->obd_type->typ_name, typ_name,
> -			     strlen(typ_name)) == 0)) {
> +		if ((strncmp(obd->obd_type->typ_name, type_name,
> +			     strlen(type_name)) == 0)) {
>  			if (obd_uuid_equals(tgt_uuid,
>  					    &obd->u.cli.cl_target_uuid) &&
>  			    ((grp_uuid) ? obd_uuid_equals(grp_uuid,
> @@ -1358,7 +1353,7 @@ EXPORT_SYMBOL(obd_get_max_rpcs_in_flight);
>  int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max)
>  {
>  	struct obd_request_slot_waiter *orsw;
> -	const char *typ_name;
> +	const char *type_name;
>  	u32 old;
>  	int diff;
>  	int rc;
> @@ -1367,8 +1362,8 @@ int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max)
>  	if (max > OBD_MAX_RIF_MAX || max < 1)
>  		return -ERANGE;
>  
> -	typ_name = cli->cl_import->imp_obd->obd_type->typ_name;
> -	if (!strcmp(typ_name, LUSTRE_MDC_NAME)) {
> +	type_name = cli->cl_import->imp_obd->obd_type->typ_name;
> +	if (!strcmp(type_name, LUSTRE_MDC_NAME)) {
>  		/*
>  		 * adjust max_mod_rpcs_in_flight to ensure it is always
>  		 * strictly lower that max_rpcs_in_flight
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> index b2b11047ea19..0a76a8549fac 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/client.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
> @@ -67,7 +67,7 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async);
>  /**
>   * Initialize passed in client structure \a cl.
>   */
> -void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
> +void ptlrpc_init_client(int req_portal, int rep_portal, const char *name,
>  			struct ptlrpc_client *cl)
>  {
>  	cl->cli_request_portal = req_portal;
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list NeilBrown
@ 2019-02-24 17:00   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:00 UTC (permalink / raw)
  To: lustre-devel


> As all obd_types are kobjects in the lustre_kset kset,
> they are linked together in that kset and don't
> need any extra linkage.
> 
> As kset_find_obj() returns a counted reference, we need
> to put that reference when done.
>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/obd.h     |    1 -
>  drivers/staging/lustre/lustre/obdclass/genops.c |   41 +++++++++++------------
>  2 files changed, 19 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index 3aa9cc889949..50f33f400075 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -99,7 +99,6 @@ struct obd_info {
>  };
>  
>  struct obd_type {
> -	struct list_head	 typ_chain;
>  	struct obd_ops		*typ_dt_ops;
>  	struct md_ops		*typ_md_ops;
>  	struct dentry		*typ_debugfs_entry;
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 32581f1a92ac..775e4fa4f6a8 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -42,8 +42,6 @@
>  #include <lprocfs_status.h>
>  #include <lustre_kernelcomm.h>
>  
> -static DEFINE_SPINLOCK(obd_types_lock);
> -static LIST_HEAD(obd_types);
>  DEFINE_RWLOCK(obd_dev_lock);
>  static struct obd_device *obd_devs[MAX_OBD_DEVICES];
>  
> @@ -88,22 +86,19 @@ static void obd_device_free(struct obd_device *obd)
>  
>  static struct obd_type *class_search_type(const char *name)
>  {
> -	struct obd_type *type;
> +	struct kobject *kobj = kset_find_obj(lustre_kset, name);
> +
> +	if (kobj)
> +		return container_of(kobj, struct obd_type, typ_kobj);
>  
> -	spin_lock(&obd_types_lock);
> -	list_for_each_entry(type, &obd_types, typ_chain) {
> -		if (strcmp(type->typ_name, name) == 0) {
> -			spin_unlock(&obd_types_lock);
> -			return type;
> -		}
> -	}
> -	spin_unlock(&obd_types_lock);
>  	return NULL;
>  }
>  
>  static struct obd_type *class_get_type(const char *name)
>  {
> -	struct obd_type *type = class_search_type(name);
> +	struct obd_type *type;
> +
> +	type = class_search_type(name);
>  
>  	if (!type) {
>  		const char *modname = name;
> @@ -121,6 +116,11 @@ static struct obd_type *class_get_type(const char *name)
>  		type->typ_refcnt++;
>  		try_module_get(type->typ_dt_ops->owner);
>  		spin_unlock(&type->obd_type_lock);
> +		/* class_search_type() returned a counted reference,
> +		 * but we don't need that count any more as
> +		 * we have one through typ_refcnt.
> +		 */
> +		kobject_put(&type->typ_kobj);
>  	}
>  	return type;
>  }
> @@ -143,10 +143,6 @@ static void class_sysfs_release(struct kobject *kobj)
>  	if (type->typ_lu)
>  		lu_device_type_fini(type->typ_lu);
>  
> -	spin_lock(&obd_types_lock);
> -	list_del(&type->typ_chain);
> -	spin_unlock(&obd_types_lock);
> -
>  	kfree(type->typ_md_ops);
>  	kfree(type->typ_dt_ops);
>  	kfree(type);
> @@ -169,8 +165,10 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  	/* sanity check */
>  	LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME);
>  
> -	if (class_search_type(name)) {
> +	type = class_search_type(name);
> +	if (type) {
>  		CDEBUG(D_IOCTL, "Type %s already registered\n", name);
> +		kobject_put(&type->typ_kobj);
>  		return -EEXIST;
>  	}
>  
> @@ -181,7 +179,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  
>  	type->typ_kobj.kset = lustre_kset;
>  	kobject_init(&type->typ_kobj, &class_ktype);
> -	INIT_LIST_HEAD(&type->typ_chain);
>  
>  	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
>  	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
> @@ -210,10 +207,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  			goto failed;
>  	}
>  
> -	spin_lock(&obd_types_lock);
> -	list_add(&type->typ_chain, &obd_types);
> -	spin_unlock(&obd_types_lock);
> -
>  	return 0;
>  
>  failed:
> @@ -238,9 +231,13 @@ int class_unregister_type(const char *name)
>  		/* Remove ops, but leave the name for debugging */
>  		kfree(type->typ_dt_ops);
>  		kfree(type->typ_md_ops);
> +		kobject_put(&type->typ_kobj);
>  		return -EBUSY;
>  	}
>  
> +	/* Put the ref returned by class_search_type() */
> +	kobject_put(&type->typ_kobj);
> +	/* Put the final ref */
>  	kobject_put(&type->typ_kobj);

This last part needs to be kobject_del(&type->typ_kobj); but that
will be handled in the early patch.

>  	return 0;
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock
  2019-02-19  0:09 ` [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock NeilBrown
@ 2019-02-24 17:02   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:02 UTC (permalink / raw)
  To: lustre-devel


> This lock is only used to protect typ_refcnt, so change
> that to a refcount_t and discard the lock.
> 
> The lock also covers calls to try_module_get and module_put,
> but this serves no purpose as it does not prevent the module
> from being unloaded.
> 
> Finally, the return value for the call to try_module_get is
> ignored, which is not safe.

Looks good. I do need to test this work tho.
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/obd.h        |    3 +-
>  drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +
>  drivers/staging/lustre/lustre/mgc/mgc_request.c    |    2 +
>  drivers/staging/lustre/lustre/obdclass/genops.c    |   30 +++++++++-----------
>  drivers/staging/lustre/lustre/obdclass/lu_object.c |    2 +
>  5 files changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index 50f33f400075..a67eb9a14879 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -102,9 +102,8 @@ struct obd_type {
>  	struct obd_ops		*typ_dt_ops;
>  	struct md_ops		*typ_md_ops;
>  	struct dentry		*typ_debugfs_entry;
> -	int			 typ_refcnt;
> +	refcount_t		 typ_refcnt;
>  	struct lu_device_type	*typ_lu;
> -	spinlock_t		 obd_type_lock;
>  	struct kobject		 typ_kobj;
>  };
>  #define typ_name typ_kobj.name
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index 3eb89ec80b7e..db2c045aa1cd 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -2540,7 +2540,7 @@ static int mdc_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize)
>  static int mdc_precleanup(struct obd_device *obd)
>  {
>  	/* Failsafe, ok if racy */
> -	if (obd->obd_type->typ_refcnt <= 1)
> +	if (refcount_read(&obd->obd_type->typ_refcnt) <= 1)
>  		libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
>  
>  	mdc_changelog_cdev_finish(obd);
> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> index a4dfdc08cc48..a6ee715921b8 100644
> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> @@ -715,7 +715,7 @@ static int mgc_cleanup(struct obd_device *obd)
>  	/* COMPAT_146 - old config logs may have added profiles we don't
>  	 * know about
>  	 */
> -	if (obd->obd_type->typ_refcnt <= 1)
> +	if (refcount_read(&obd->obd_type->typ_refcnt) <= 1)
>  		/* Only for the last mgc */
>  		class_del_profiles();
>  
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 775e4fa4f6a8..a3437c2d07bb 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -112,15 +112,17 @@ static struct obd_type *class_get_type(const char *name)
>  		}
>  	}
>  	if (type) {
> -		spin_lock(&type->obd_type_lock);
> -		type->typ_refcnt++;
> -		try_module_get(type->typ_dt_ops->owner);
> -		spin_unlock(&type->obd_type_lock);
> -		/* class_search_type() returned a counted reference,
> -		 * but we don't need that count any more as
> -		 * we have one through typ_refcnt.
> -		 */
> -		kobject_put(&type->typ_kobj);
> +		if (try_module_get(type->typ_dt_ops->owner)) {
> +			refcount_inc(&type->typ_refcnt);
> +			/* class_search_type() returned a counted reference,
> +			 * but we don't need that count any more as
> +			 * we have one through typ_refcnt.
> +			 */
> +			kobject_put(&type->typ_kobj);
> +		} else {
> +			kobject_put(&type->typ_kobj);
> +			type = NULL;
> +		}
>  	}
>  	return type;
>  }
> @@ -128,10 +130,7 @@ static struct obd_type *class_get_type(const char *name)
>  void class_put_type(struct obd_type *type)
>  {
>  	LASSERT(type);
> -	spin_lock(&type->obd_type_lock);
> -	type->typ_refcnt--;
> -	module_put(type->typ_dt_ops->owner);
> -	spin_unlock(&type->obd_type_lock);
> +	refcount_dec(&type->typ_refcnt);
>  }
>  
>  static void class_sysfs_release(struct kobject *kobj)
> @@ -191,7 +190,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  	/* md_ops is optional */
>  	if (md_ops)
>  		*type->typ_md_ops = *md_ops;
> -	spin_lock_init(&type->obd_type_lock);
>  
>  	rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
>  	if (rc)
> @@ -225,8 +223,8 @@ int class_unregister_type(const char *name)
>  		return -EINVAL;
>  	}
>  
> -	if (type->typ_refcnt) {
> -		CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt);
> +	if (refcount_read(&type->typ_refcnt)) {
> +		CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt));
>  		/* This is a bad situation, let's make the best of it */
>  		/* Remove ops, but leave the name for debugging */
>  		kfree(type->typ_dt_ops);
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> index 639c298b6a90..69a56cca99f2 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> @@ -1267,7 +1267,7 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top)
>  		next = ldt->ldt_ops->ldto_device_free(env, scan);
>  		type = ldt->ldt_obd_type;
>  		if (type) {
> -			type->typ_refcnt--;
> +			refcount_dec(&type->typ_refcnt);
>  			class_put_type(type);
>  		}
>  	}
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type NeilBrown
@ 2019-02-24 17:03   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:03 UTC (permalink / raw)
  To: lustre-devel


> The obd_ops and md_ops structures passed to class_register_type() are
> read-only, and have a lifetime that is exceeds the lifetime of the
> obd_type - they are static in a module which unregisters the type before
> being unloaded.
> 
> So there is no need to copy the ops, just store a pointer.
> 
> Also mark all the structures as read-only to confirm they don't get
> written.  This is best-practice for structures of function pointers.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/obd.h        |    4 ++--
>  drivers/staging/lustre/lustre/include/obd_class.h  |    3 ++-
>  drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    4 ++--
>  drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
>  drivers/staging/lustre/lustre/mdc/mdc_request.c    |    4 ++--
>  drivers/staging/lustre/lustre/mgc/mgc_request.c    |    2 +-
>  drivers/staging/lustre/lustre/obdclass/genops.c    |   22 +++++---------------
>  .../staging/lustre/lustre/obdecho/echo_client.c    |    2 +-
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
>  9 files changed, 18 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index a67eb9a14879..9cffda3741ce 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -99,8 +99,8 @@ struct obd_info {
>  };
>  
>  struct obd_type {
> -	struct obd_ops		*typ_dt_ops;
> -	struct md_ops		*typ_md_ops;
> +	const struct obd_ops	*typ_dt_ops;
> +	const struct md_ops	*typ_md_ops;
>  	struct dentry		*typ_debugfs_entry;
>  	refcount_t		 typ_refcnt;
>  	struct lu_device_type	*typ_lu;
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index a61c7950393c..7c2e248a8110 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -60,7 +60,8 @@ struct lu_device_type;
>  
>  /* genops.c */
>  struct obd_export *class_conn2export(struct lustre_handle *conn);
> -int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
> +int class_register_type(const struct obd_ops *dt_ops,
> +			const struct md_ops *md_ops,
>  			const char *name, struct lu_device_type *ldt);
>  int class_unregister_type(const char *name);
>  
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index 1c7379b14f8c..35dff0e96bf7 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -3044,7 +3044,7 @@ static int lmv_merge_attr(struct obd_export *exp,
>  	return 0;
>  }
>  
> -static struct obd_ops lmv_obd_ops = {
> +static const struct obd_ops lmv_obd_ops = {
>  	.owner			= THIS_MODULE,
>  	.setup			= lmv_setup,
>  	.cleanup		= lmv_cleanup,
> @@ -3061,7 +3061,7 @@ static struct obd_ops lmv_obd_ops = {
>  	.quotactl		= lmv_quotactl
>  };
>  
> -static struct md_ops lmv_md_ops = {
> +static const struct md_ops lmv_md_ops = {
>  	.get_root		= lmv_get_root,
>  	.null_inode		= lmv_null_inode,
>  	.close			= lmv_close,
> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
> index fd769c39b482..bad9538706f0 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
> @@ -1332,7 +1332,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
>  	return rc;
>  }
>  
> -static struct obd_ops lov_obd_ops = {
> +static const struct obd_ops lov_obd_ops = {
>  	.owner		= THIS_MODULE,
>  	.setup		= lov_setup,
>  	.cleanup	= lov_cleanup,
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index db2c045aa1cd..72a5264b2d78 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -2569,7 +2569,7 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf)
>  	return count > 0 ? 0 : count;
>  }
>  
> -static struct obd_ops mdc_obd_ops = {
> +static const struct obd_ops mdc_obd_ops = {
>  	.owner			= THIS_MODULE,
>  	.setup			= mdc_setup,
>  	.precleanup		= mdc_precleanup,
> @@ -2591,7 +2591,7 @@ static struct obd_ops mdc_obd_ops = {
>  	.quotactl		= mdc_quotactl,
>  };
>  
> -static struct md_ops mdc_md_ops = {
> +static const struct md_ops mdc_md_ops = {
>  	.get_root		= mdc_get_root,
>  	.null_inode		= mdc_null_inode,
>  	.close			= mdc_close,
> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> index a6ee715921b8..3ff0bf1c4a22 100644
> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> @@ -1817,7 +1817,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
>  	return rc;
>  }
>  
> -static struct obd_ops mgc_obd_ops = {
> +static const struct obd_ops mgc_obd_ops = {
>  	.owner          = THIS_MODULE,
>  	.setup          = mgc_setup,
>  	.precleanup     = mgc_precleanup,
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index a3437c2d07bb..d013e9a358f1 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -142,8 +142,6 @@ static void class_sysfs_release(struct kobject *kobj)
>  	if (type->typ_lu)
>  		lu_device_type_fini(type->typ_lu);
>  
> -	kfree(type->typ_md_ops);
> -	kfree(type->typ_dt_ops);
>  	kfree(type);
>  }
>  
> @@ -154,7 +152,8 @@ static struct kobj_type class_ktype = {
>  
>  #define CLASS_MAX_NAME 1024
>  
> -int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
> +int class_register_type(const struct obd_ops *dt_ops,
> +			const struct md_ops *md_ops,
>  			const char *name,
>  			struct lu_device_type *ldt)
>  {
> @@ -179,17 +178,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
>  	type->typ_kobj.kset = lustre_kset;
>  	kobject_init(&type->typ_kobj, &class_ktype);
>  
> -	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
> -	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
> -
> -	if (!type->typ_dt_ops ||
> -	    !type->typ_md_ops)
> -		goto failed;
> -
> -	*type->typ_dt_ops = *dt_ops;
> -	/* md_ops is optional */
> -	if (md_ops)
> -		*type->typ_md_ops = *md_ops;
> +	type->typ_dt_ops = dt_ops;
> +	type->typ_md_ops = md_ops;
>  
>  	rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name);
>  	if (rc)
> @@ -227,8 +217,8 @@ int class_unregister_type(const char *name)
>  		CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt));
>  		/* This is a bad situation, let's make the best of it */
>  		/* Remove ops, but leave the name for debugging */
> -		kfree(type->typ_dt_ops);
> -		kfree(type->typ_md_ops);
> +		type->typ_dt_ops = NULL;
> +		type->typ_md_ops = NULL;
>  		kobject_put(&type->typ_kobj);
>  		return -EBUSY;
>  	}
> diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
> index 317123fd27cb..baf34c85c4b5 100644
> --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
> +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
> @@ -1676,7 +1676,7 @@ static int echo_client_disconnect(struct obd_export *exp)
>  	return rc;
>  }
>  
> -static struct obd_ops echo_client_obd_ops = {
> +static const struct obd_ops echo_client_obd_ops = {
>  	.owner			= THIS_MODULE,
>  	.iocontrol		= echo_client_iocontrol,
>  	.connect		= echo_client_connect,
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 3fedfaf249c4..442b4355d946 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -2988,7 +2988,7 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf)
>  	return osc_process_config_base(obd, buf);
>  }
>  
> -static struct obd_ops osc_obd_ops = {
> +static const struct obd_ops osc_obd_ops = {
>  	.owner          = THIS_MODULE,
>  	.setup          = osc_setup,
>  	.precleanup     = osc_precleanup,
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking NeilBrown
@ 2019-02-24 17:04   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:04 UTC (permalink / raw)
  To: lustre-devel


> Safe module loading requires that we try_module_get() in a context
> where the module cannot be unloaded, typically protected by
> a spinlock that module-unload has to take.
> This doesn't currently happen in class_get_type().
> 
> As free_module() calls synchronize_rcu() between calling the
> exit function and freeing the module, we can use rcu_read_lock()
> to check if the exit function has been called, and try_module_get()
> if it hasn't.
> 
> We must also check the return status of try_module_get().

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/genops.c |   24 ++++++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index d013e9a358f1..1d1a6b2d436e 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -98,21 +98,31 @@ static struct obd_type *class_get_type(const char *name)
>  {
>  	struct obd_type *type;
>  
> +	rcu_read_lock();
>  	type = class_search_type(name);
>  
>  	if (!type) {
>  		const char *modname = name;
>  
> +		rcu_read_unlock();
>  		if (!request_module("%s", modname)) {
>  			CDEBUG(D_INFO, "Loaded module '%s'\n", modname);
> -			type = class_search_type(name);
>  		} else {
>  			LCONSOLE_ERROR_MSG(0x158, "Can't load module '%s'\n",
>  					   modname);
>  		}
> +		rcu_read_lock();
> +		type = class_search_type(name);
>  	}
>  	if (type) {
> -		if (try_module_get(type->typ_dt_ops->owner)) {
> +		/*
> +		 * Holding rcu_read_lock() matches the synchronize_rcu() call
> +		 * in free_module() and ensures that if type->typ_dt_ops is
> +		 * not yet NULL, then the module won't be freed until after
> +		 * we rcu_read_unlock().
> +		 */
> +		const struct obd_ops *dt_ops = READ_ONCE(type->typ_dt_ops);
> +		if (dt_ops && try_module_get(dt_ops->owner)) {
>  			refcount_inc(&type->typ_refcnt);
>  			/* class_search_type() returned a counted reference,
>  			 * but we don't need that count any more as
> @@ -124,6 +134,7 @@ static struct obd_type *class_get_type(const char *name)
>  			type = NULL;
>  		}
>  	}
> +	rcu_read_unlock();
>  	return type;
>  }
>  
> @@ -213,11 +224,18 @@ int class_unregister_type(const char *name)
>  		return -EINVAL;
>  	}
>  
> +	/*
> +	 * Ensure that class_get_type doesn't try to get the module
> +	 * as it could be freed before the obd_type is released.
> +	 * synchronize_rcu() will be called before the module
> +	 * is freed.
> +	 */
> +	type->typ_dt_ops = NULL;
> +
>  	if (refcount_read(&type->typ_refcnt)) {
>  		CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt));
>  		/* This is a bad situation, let's make the best of it */
>  		/* Remove ops, but leave the name for debugging */
> -		type->typ_dt_ops = NULL;
>  		type->typ_md_ops = NULL;
>  		kobject_put(&type->typ_kobj);
>  		return -EBUSY;
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc NeilBrown
@ 2019-02-24 17:05   ` James Simmons
  2019-02-25 18:16     ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:05 UTC (permalink / raw)
  To: lustre-devel


> Passing 0 as the gfp_t for kmalloc() is not meaningful, and
> could change behaviour.
> Use an explicit GFP_KERNEL instead.

Why did it every do this ??????

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/lustre/obdclass/kernelcomm.c    |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> index 925ba52c53b4..09d0b1ab8d1c 100644
> --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> @@ -133,7 +133,7 @@ int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group,
>  		return -EBADF;
>  
>  	/* freed in group_rem */
> -	reg = kmalloc(sizeof(*reg) + data_len, 0);
> +	reg = kmalloc(sizeof(*reg) + data_len, GFP_KERNEL);
>  	if (!reg)
>  		return -ENOMEM;
>  
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static NeilBrown
@ 2019-02-24 17:15   ` James Simmons
  2019-02-26 23:45     ` NeilBrown
  2019-02-27 22:37   ` James Simmons
  1 sibling, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:15 UTC (permalink / raw)
  To: lustre-devel


> libcfs_kkuc_msg_put() is never used outside of kernelcomm.c,
> so make it static.

In the OpenSFS branch libcfs_kkuc_msg_put() is used by the
client and server code. While this is okay now in the future
this will be reverted. So do we keep it as is so it can handle
server code or do this change and then later do what I added
below:
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/lustre/include/lustre_kernelcomm.h      |    1 -
>  .../staging/lustre/lustre/obdclass/kernelcomm.c    |    3 +--
>  2 files changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
> index 8e3a99057a38..1ed41840ab8f 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
> @@ -46,7 +46,6 @@ typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg);
>  
>  /* Kernel methods */
>  void libcfs_kkuc_init(void);
#ifdef CONFIG_LUSTRE_SERVER
> -int libcfs_kkuc_msg_put(struct file *fp, void *payload);
#endif
>  int libcfs_kkuc_group_put(unsigned int group, void *payload);
>  int libcfs_kkuc_group_add(struct file *fp, int uid, unsigned int group,
>  			  void *data, size_t data_len);
> diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> index 09d0b1ab8d1c..27870952b1f0 100644
> --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> @@ -49,7 +49,7 @@
>   * @param payload Payload data.  First field of payload is always
>   *   struct kuc_hdr
>   */
#ifndef CONFIG_LUSTRE_SERVER
> -int libcfs_kkuc_msg_put(struct file *filp, void *payload)
#else
> +static int libcfs_kkuc_msg_put(struct file *filp, void *payload)
#endif
>  {
>  	struct kuc_hdr *kuch = (struct kuc_hdr *)payload;
>  	ssize_t count = kuch->kuc_msglen;
> @@ -80,7 +80,6 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload)
>  
>  	return rc;
>  }
#ifdef CONFIG_LUSTER_SERVER
> -EXPORT_SYMBOL(libcfs_kkuc_msg_put);
#endif

>  /*
>   * Broadcast groups are global across all mounted filesystems;

I do say the ifdef do look messy.

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance
  2019-02-19  0:09 ` [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance NeilBrown
@ 2019-02-24 17:39   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:39 UTC (permalink / raw)
  To: lustre-devel


> Fix mistyped "Balance" in a comment.

Reviewed-by: James Simmons <jsimmons@infradead.org>

> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/llog_obd.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
> index 2b6489e2632d..a89ec816b043 100644
> --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c
> +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
> @@ -112,7 +112,7 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
>  	idx = ctxt->loc_idx;
>  
>  	/*
> -	 * Banlance the ctxt get when calling llog_cleanup()
> +	 * Balance the ctxt get when calling llog_cleanup()
>  	 */
>  	LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON);
>  	LASSERT(refcount_read(&ctxt->loc_refcount) > 1);
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper NeilBrown
@ 2019-02-24 17:52   ` James Simmons
  2019-02-26 23:59     ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:52 UTC (permalink / raw)
  To: lustre-devel


> This function seems overly complex, the same functionality
> is available with much less effort.

Actually we are in discussion about removing these functions.
The details are at:

https://jira.whamcloud.com/browse/LU-11157

Since shells typically don't handle "floating point" representation
well you can see the following:

sanity 64d with the same error message; '209.9: syntax error: invalid 
arithmetic operator (error token is ".9")'

The second issues is that the read values are not true representation
of the desired value. The same issues is with the string helpers as
well. Take for example

test_string_get_size_one(1100, 1, "1.10 kB", "1.07 KiB");

Which is taken from linux/lib/test-string_helpers.c.

If you pass 1100 to string_get_size() you can get either 1.10 kB or 1.07 
KiB. Now if do the reverse 1.10 kB you get ~1126 which is not the same as
11000. I discussed how to handle this problem with Andreas and he agreed
the best solution is make all the sysfs / debugfs *_mb files turn any 
values passed in to around up to the nearest MiB. This way we can report
the exact MiB settings to the users. We already have a patch to do this
for max_dirty_mb which I can push. The other *_mb files need to be updated
to round off. If you can wait a few days I can backport the already done
patch and push a patch for the rest. 

> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   47 +++-----------------
>  1 file changed, 7 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 568e6623e0c8..bd24e48f6145 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m,
>  int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val,
>  			     int mult)
>  {
> -	long decimal_val, frac_val;
>  	int prtn;
>  
>  	if (count < 10)
>  		return -EINVAL;
>  
> -	decimal_val = val / mult;
> -	prtn = snprintf(buffer, count, "%ld", decimal_val);
> -	frac_val = val % mult;
> -
> -	if (prtn < (count - 4) && frac_val > 0) {
> -		long temp_frac;
> -		int i, temp_mult = 1, frac_bits = 0;
> -
> -		temp_frac = frac_val * 10;
> -		buffer[prtn++] = '.';
> -		while (frac_bits < 2 && (temp_frac / mult) < 1) {
> -			/* only reserved 2 bits fraction */
> -			buffer[prtn++] = '0';
> -			temp_frac *= 10;
> -			frac_bits++;
> -		}
> -		/*
> -		 * Need to think these cases :
> -		 *      1. #echo x.00 > /sys/xxx       output result : x
> -		 *      2. #echo x.0x > /sys/xxx       output result : x.0x
> -		 *      3. #echo x.x0 > /sys/xxx       output result : x.x
> -		 *      4. #echo x.xx > /sys/xxx       output result : x.xx
> -		 *      Only reserved 2 bits fraction.
> -		 */
> -		for (i = 0; i < (5 - prtn); i++)
> -			temp_mult *= 10;
> -
> -		frac_bits = min((int)count - prtn, 3 - frac_bits);
> -		prtn += snprintf(buffer + prtn, frac_bits, "%ld",
> -				 frac_val * temp_mult / mult);
> +	prtn = snprintf(buffer, count, "%ld.%02lu",
> +			val / mult,
> +			(val % mult) / (mult / 100));
>  
> +	/* Strip trailing zeroes, and trailing '.' */
> +	while (prtn && buffer[prtn-1] == '0')
> +		prtn--;
> +	if (prtn && buffer[prtn-1] == '.')
>  		prtn--;
> -		while (buffer[prtn] < '1' || buffer[prtn] > '9') {
> -			prtn--;
> -			if (buffer[prtn] == '.') {
> -				prtn--;
> -				break;
> -			}
> -		}
> -		prtn++;
> -	}
>  	buffer[prtn++] = '\n';
>  	return prtn;
>  }
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release
  2019-02-19  0:09 ` [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release NeilBrown
@ 2019-02-24 17:53   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:53 UTC (permalink / raw)
  To: lustre-devel


> Neither lprocfs_single_release() or lprocfs_seq_release()
> add any value to single_release() or seq_release() which
> they wrap.
> So just use the base functions and discard the wrapper.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/lustre/include/lprocfs_status.h |    7 ++-----
>  drivers/staging/lustre/lustre/lov/lproc_lov.c      |    2 +-
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   14 +-------------
>  .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c    |    2 +-
>  4 files changed, 5 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> index d69f395e3d52..8565c28f08ee 100644
> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> @@ -502,9 +502,6 @@ unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
>  void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
>  			   struct lprocfs_counter *cnt);
>  
> -int lprocfs_single_release(struct inode *inode, struct file *file);
> -int lprocfs_seq_release(struct inode *inode, struct file *file);
> -
>  /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
>   * proc entries; otherwise, you will define name##_seq_write function also for
>   * a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
> @@ -521,7 +518,7 @@ static const struct file_operations name##_fops = {			\
>  	.read    = seq_read,						\
>  	.write   = custom_seq_write,					\
>  	.llseek  = seq_lseek,						\
> -	.release = lprocfs_single_release,				\
> +	.release = single_release,					\
>  }
>  
>  #define LPROC_SEQ_FOPS_RO(name)	 __LPROC_SEQ_FOPS(name, NULL)
> @@ -563,7 +560,7 @@ static const struct file_operations name##_fops = {			\
>  	static const struct file_operations name##_##type##_fops = {	\
>  		.open	= name##_##type##_open,				\
>  		.write	= name##_##type##_write,			\
> -		.release = lprocfs_single_release,			\
> +		.release = single_release,				\
>  	}
>  
>  struct lustre_attr {
> diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c
> index fc53f2386c39..cfb274498d30 100644
> --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c
> +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c
> @@ -264,7 +264,7 @@ static const struct file_operations lov_debugfs_target_fops = {
>  	.open		= lov_target_seq_open,
>  	.read		= seq_read,
>  	.llseek		= seq_lseek,
> -	.release	= lprocfs_seq_release,
> +	.release	= seq_release,
>  };
>  
>  static struct attribute *lov_attrs[] = {
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index bd24e48f6145..76d298337e95 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -273,18 +273,6 @@ MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs
>  
>  #define MAX_STRING_SIZE 128
>  
> -int lprocfs_single_release(struct inode *inode, struct file *file)
> -{
> -	return single_release(inode, file);
> -}
> -EXPORT_SYMBOL(lprocfs_single_release);
> -
> -int lprocfs_seq_release(struct inode *inode, struct file *file)
> -{
> -	return seq_release(inode, file);
> -}
> -EXPORT_SYMBOL(lprocfs_seq_release);
> -
>  /* lprocfs API calls */
>  
>  static const struct file_operations lprocfs_generic_fops = { };
> @@ -1331,7 +1319,7 @@ const struct file_operations lprocfs_stats_seq_fops = {
>  	.read		= seq_read,
>  	.write		= lprocfs_stats_seq_write,
>  	.llseek		= seq_lseek,
> -	.release	= lprocfs_seq_release,
> +	.release	= seq_release,
>  };
>  EXPORT_SYMBOL_GPL(lprocfs_stats_seq_fops);
>  
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
> index 25858b8f6cbd..d09bddaf88ba 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
> @@ -1093,7 +1093,7 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry,
>  		.open		= ptlrpc_lprocfs_svc_req_history_open,
>  		.read		= seq_read,
>  		.llseek		= seq_lseek,
> -		.release	= lprocfs_seq_release,
> +		.release	= seq_release,
>  	};
>  
>  	ptlrpc_ldebugfs_register(entry, svc->srv_name,
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr()
  2019-02-19  0:09 ` [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr() NeilBrown
@ 2019-02-24 17:53   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 17:53 UTC (permalink / raw)
  To: lustre-devel


> This is identical to strnstr() in lib/string.h,
> so just use that.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   19 +------------------
>  1 file changed, 1 insertion(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 76d298337e95..27d73c95403d 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -1552,22 +1552,6 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer,
>  }
>  EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);
>  
> -static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len)
> -{
> -	size_t l2;
> -
> -	l2 = strlen(s2);
> -	if (!l2)
> -		return (char *)s1;
> -	while (len >= l2) {
> -		len--;
> -		if (!memcmp(s1, s2, l2))
> -			return (char *)s1;
> -		s1++;
> -	}
> -	return NULL;
> -}
> -
>  /**
>   * Find the string \a name in the input \a buffer, and return a pointer to the
>   * value immediately following \a name, reducing \a count appropriately.
> @@ -1579,8 +1563,7 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
>  	char *val;
>  	size_t buflen = *count;
>  
> -	/* there is no strnstr() in rhel5 and ubuntu kernels */
> -	val = lprocfs_strnstr(buffer, name, buflen);
> +	val = strnstr(buffer, name, buflen);
>  	if (!val)
>  		return (char *)buffer;
>  
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop NeilBrown
@ 2019-02-24 18:09   ` James Simmons
  2019-02-26 20:55   ` James Simmons
  1 sibling, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 18:09 UTC (permalink / raw)
  To: lustre-devel


> These shift loops seem to be trying to avoid doing a
> multiplication.
> We same effect can be achieved more transparently using
> rounddown_pow_of_two().  Even though there is a multiplication
> in the C code, the resulting machine code just does a single shift.

Be aware rounddown_pow_of_two(n) is undefined when "n == 0". We should
handle the "0" case as well. We are aware of this because this case
bit us in the LNet layer.
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index a179b0d6979e..637aaca96888 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>  		u32 blk_size = osfs.os_bsize >> 10;
>  		u64 result = osfs.os_blocks;
>  
> -		while (blk_size >>= 1)
> -			result <<= 1;
> -
> +		result *= rounddown_pow_of_two(blk_size);
>  		return sprintf(buf, "%llu\n", result);
>  	}
>  
> @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>  		u32 blk_size = osfs.os_bsize >> 10;
>  		u64 result = osfs.os_bfree;
>  
> -		while (blk_size >>= 1)
> -			result <<= 1;
> +		result *= rounddown_pow_of_two(blk_size);
>  
>  		return sprintf(buf, "%llu\n", result);
>  	}
> @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>  		u32 blk_size = osfs.os_bsize >> 10;
>  		u64 result = osfs.os_bavail;
>  
> -		while (blk_size >>= 1)
> -			result <<= 1;
> +		result *= rounddown_pow_of_two(blk_size);
>  
>  		return sprintf(buf, "%llu\n", result);
>  	}
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type NeilBrown
@ 2019-02-24 18:35   ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 18:35 UTC (permalink / raw)
  To: lustre-devel


> Instead of having obd_ioctl_getdata() return the allocated
> data as a "char *", return it as it really is,
>  struct obd_ioctl_data *
> 
> This avoids the need for extra variables and casts.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/obd_class.h  |    3 ++-
>  drivers/staging/lustre/lustre/llite/dir.c          |   18 ++++++------------
>  drivers/staging/lustre/lustre/llite/llite_lib.c    |    8 +++-----
>  drivers/staging/lustre/lustre/lov/lov_obd.c        |   15 ++++++---------
>  drivers/staging/lustre/lustre/obdclass/class_obd.c |   18 ++++++++----------
>  5 files changed, 25 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index 30b3e2c69f83..32d4ab6e78a0 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -1697,6 +1697,7 @@ struct root_squash_info {
>  };
>  
>  /* linux-module.c */
> -int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
> +struct obd_ioctl_data;
> +int obd_ioctl_getdata(struct obd_ioctl_data **data, int *len, void __user *arg);
>  
>  #endif /* __LINUX_OBD_CLASS_H */
> diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
> index fd1af4a5cdad..17bb6185ba87 100644
> --- a/drivers/staging/lustre/lustre/llite/dir.c
> +++ b/drivers/staging/lustre/lustre/llite/dir.c
> @@ -1130,13 +1130,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  	}
>  	case IOC_MDC_LOOKUP: {
>  		int namelen, len = 0;
> -		char *buf = NULL;
>  		char *filename;
>  
> -		rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
> +		rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
>  		if (rc)
>  			return rc;
> -		data = (void *)buf;
>  
>  		filename = data->ioc_inlbuf1;
>  		namelen = strlen(filename);
> @@ -1155,12 +1153,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  			goto out_free;
>  		}
>  out_free:
> -		kvfree(buf);
> +		kvfree(data);
>  		return rc;
>  	}
>  	case LL_IOC_LMV_SETSTRIPE: {
>  		struct lmv_user_md  *lum;
> -		char *buf = NULL;
>  		char *filename;
>  		int namelen = 0;
>  		int lumlen = 0;
> @@ -1168,11 +1165,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  		int len;
>  		int rc;
>  
> -		rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
> +		rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
>  		if (rc)
>  			return rc;
>  
> -		data = (void *)buf;
>  		if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
>  		    data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0) {
>  			rc = -EINVAL;
> @@ -1205,7 +1201,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  #endif
>  		rc = ll_dir_setdirstripe(dentry, lum, filename, mode);
>  lmv_out_free:
> -		kvfree(buf);
> +		kvfree(data);
>  		return rc;
>  	}
>  	case LL_IOC_LMV_SET_DEFAULT_STRIPE: {
> @@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  		return rc;
>  	}
>  	case LL_IOC_MIGRATE: {
> -		char *buf = NULL;
>  		const char *filename;
>  		int namelen = 0;
>  		int len;
>  		int rc;
>  		int mdtidx;
>  
> -		rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
> +		rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
>  		if (rc < 0)
>  			return rc;
>  
> -		data = (struct obd_ioctl_data *)buf;
>  		if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
>  		    !data->ioc_inllen1 || !data->ioc_inllen2) {
>  			rc = -EINVAL;
> @@ -1684,7 +1678,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  
>  		rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1);
>  migrate_free:
> -		kvfree(buf);
> +		kvfree(data);
>  
>  		return rc;
>  	}
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index 8e09fdd7a96e..e2417cd5aaed 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -2295,7 +2295,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
>  {
>  	struct ll_sb_info *sbi = NULL;
>  	struct obd_export *exp;
> -	char *buf = NULL;
>  	struct obd_ioctl_data *data = NULL;
>  	u32 type;
>  	int len = 0, rc;
> @@ -2311,11 +2310,10 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
>  		goto out_statfs;
>  	}
>  
> -	rc = obd_ioctl_getdata(&buf, &len, arg);
> +	rc = obd_ioctl_getdata(&data, &len, arg);
>  	if (rc)
>  		goto out_statfs;
>  
> -	data = (void *)buf;
>  	if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
>  	    !data->ioc_pbuf1 || !data->ioc_pbuf2) {
>  		rc = -EINVAL;
> @@ -2340,11 +2338,11 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
>  		goto out_statfs;
>  	}
>  
> -	rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL);
> +	rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, data, NULL);
>  	if (rc)
>  		goto out_statfs;
>  out_statfs:
> -	kvfree(buf);
> +	kvfree(data);
>  	return rc;
>  }
>  
> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
> index 04d0a9ed1d05..fd769c39b482 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
> @@ -1039,27 +1039,24 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>  	case OBD_IOC_LOV_GET_CONFIG: {
>  		struct obd_ioctl_data *data;
>  		struct lov_desc *desc;
> -		char *buf = NULL;
>  		u32 *genp;
>  
>  		len = 0;
> -		if (obd_ioctl_getdata(&buf, &len, uarg))
> +		if (obd_ioctl_getdata(&data, &len, uarg))
>  			return -EINVAL;
>  
> -		data = (struct obd_ioctl_data *)buf;
> -
>  		if (sizeof(*desc) > data->ioc_inllen1) {
> -			kvfree(buf);
> +			kvfree(data);
>  			return -EINVAL;
>  		}
>  
>  		if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
> -			kvfree(buf);
> +			kvfree(data);
>  			return -EINVAL;
>  		}
>  
>  		if (sizeof(u32) * count > data->ioc_inllen3) {
> -			kvfree(buf);
> +			kvfree(data);
>  			return -EINVAL;
>  		}
>  
> @@ -1076,9 +1073,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>  			*genp = lov->lov_tgts[i]->ltd_gen;
>  		}
>  
> -		if (copy_to_user(uarg, buf, len))
> +		if (copy_to_user(uarg, data, len))
>  			rc = -EFAULT;
> -		kvfree(buf);
> +		kvfree(data);
>  		break;
>  	}
>  	case OBD_IOC_QUOTACTL: {
> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> index 2ee6b96f4830..b8fc74044fe3 100644
> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> @@ -229,7 +229,7 @@ static int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
>  }
>  
>  /* buffer MUST be at least the size of obd_ioctl_hdr */
> -int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
> +int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg)
>  {
>  	struct obd_ioctl_data *data;
>  	struct obd_ioctl_hdr hdr;
> @@ -261,16 +261,16 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
>  	 * obdfilter-survey is an example, which relies on ioctl. So we'd
>  	 * better avoid vmalloc on ioctl path. LU-66
>  	 */
> -	*buf = kvzalloc(hdr.ioc_len, GFP_KERNEL);
> -	if (!*buf) {
> +	data = kvzalloc(hdr.ioc_len, GFP_KERNEL);
> +	if (!data) {
>  		CERROR("Cannot allocate control buffer of len %d\n",
>  		       hdr.ioc_len);
>  		return -EINVAL;
>  	}
>  	*len = hdr.ioc_len;
> -	data = (struct obd_ioctl_data *)*buf;
> +	*datap = data;
>  
> -	if (copy_from_user(*buf, arg, hdr.ioc_len)) {
> +	if (copy_from_user(data, arg, hdr.ioc_len)) {
>  		err = -EFAULT;
>  		goto free_buf;
>  	}
> @@ -307,14 +307,13 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
>  	return 0;
>  
>  free_buf:
> -	kvfree(*buf);
> +	kvfree(data);
>  	return err;
>  }
>  EXPORT_SYMBOL(obd_ioctl_getdata);
>  
>  int class_handle_ioctl(unsigned int cmd, unsigned long arg)
>  {
> -	char *buf = NULL;
>  	struct obd_ioctl_data *data;
>  	struct libcfs_debug_ioctl_data *debug_data;
>  	struct obd_device *obd = NULL;
> @@ -329,11 +328,10 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
>  	}
>  
>  	CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
> -	if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) {
> +	if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) {
>  		CERROR("OBD ioctl: data error\n");
>  		return -EINVAL;
>  	}
> -	data = (struct obd_ioctl_data *)buf;
>  
>  	switch (cmd) {
>  	case OBD_IOC_PROCESS_CFG: {
> @@ -542,7 +540,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
>  	}
>  
>   out:
> -	kvfree(buf);
> +	kvfree(data);
>  	return err;
>  } /* class_handle_ioctl */
>  
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment NeilBrown
@ 2019-02-24 18:51   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 18:51 UTC (permalink / raw)
  To: lustre-devel


> This patch changes a lot of places that use spaces for
> alignment to instead use tabs - though in one case in a
> comment, spaces are used in place of tabs to be more consistent.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_cpu.h       |    2 
>  .../lustre/include/linux/libcfs/libcfs_crypto.h    |   10 -
>  .../lustre/include/linux/libcfs/libcfs_debug.h     |   30 +-
>  .../lustre/include/linux/libcfs/libcfs_fail.h      |   12 -
>  .../lustre/include/linux/libcfs/libcfs_hash.h      |   24 +
>  .../lustre/include/linux/libcfs/libcfs_private.h   |    2 
>  .../staging/lustre/include/linux/lnet/lib-lnet.h   |    4 
>  .../staging/lustre/include/linux/lnet/socklnd.h    |    2 
>  .../lustre/include/uapi/linux/lnet/libcfs_debug.h  |  124 +++----
>  .../lustre/include/uapi/linux/lnet/libcfs_ioctl.h  |   56 +--
>  .../lustre/include/uapi/linux/lnet/lnet-types.h    |   10 -
>  .../lustre/include/uapi/linux/lnet/lnetst.h        |   14 -
>  .../lustre/include/uapi/linux/lnet/nidstr.h        |    6 
>  .../include/uapi/linux/lustre/lustre_fiemap.h      |    2 
>  .../lustre/include/uapi/linux/lustre/lustre_idl.h  |  350 +++++++++----------
>  .../lustre/include/uapi/linux/lustre/lustre_user.h |  378 ++++++++++----------
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |   60 ++-
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.h    |   32 +-
>  drivers/staging/lustre/lnet/lnet/nidstrings.c      |    4 
>  drivers/staging/lustre/lnet/selftest/timer.c       |    8 
>  drivers/staging/lustre/lustre/fld/lproc_fld.c      |    2 
>  .../staging/lustre/lustre/include/lustre_import.h  |    6 
>  drivers/staging/lustre/lustre/include/obd.h        |   10 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    6 
>  drivers/staging/lustre/lustre/llite/file.c         |    2 
>  drivers/staging/lustre/lustre/llite/vvp_internal.h |    2 
>  drivers/staging/lustre/lustre/llite/xattr.c        |    2 
>  drivers/staging/lustre/lustre/lov/lov_ea.c         |    2 
>  drivers/staging/lustre/lustre/lov/lov_obd.c        |   26 +
>  drivers/staging/lustre/lustre/mgc/mgc_request.c    |   24 +
>  drivers/staging/lustre/lustre/obdclass/genops.c    |    6 
>  drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 
>  drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |    2 
>  drivers/staging/lustre/lustre/osc/osc_request.c    |   40 +-
>  drivers/staging/lustre/lustre/ptlrpc/wiretest.c    |    2 
>  35 files changed, 635 insertions(+), 635 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
> index 3e51752491d0..56905317fab0 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
> @@ -372,7 +372,7 @@ enum {
>  
>  struct cfs_percpt_lock {
>  	/* cpu-partition-table for this lock */
> -	struct cfs_cpt_table     *pcl_cptab;
> +	struct cfs_cpt_table	 *pcl_cptab;
>  	/* exclusively locked */
>  	unsigned int		  pcl_locked;
>  	/* private lock table */
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
> index ca8620b93de7..03da963b8d33 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
> @@ -33,17 +33,17 @@
>  struct page;
>  
>  struct cfs_crypto_hash_type {
> -	char		*cht_name;      /*< hash algorithm name, equal to
> +	char		*cht_name;	/*< hash algorithm name, equal to
>  					 * format name for crypto api
>  					 */
> -	unsigned int    cht_key;	/*< init key by default (valid for
> +	unsigned int	cht_key;	/*< init key by default (valid for
>  					 * 4 bytes context like crc32, adler
>  					 */
> -	unsigned int    cht_size;       /**< hash digest size */
> +	unsigned int	cht_size;	/**< hash digest size */
>  };
>  
>  enum cfs_crypto_hash_alg {
> -	CFS_HASH_ALG_NULL       = 0,
> +	CFS_HASH_ALG_NULL	= 0,
>  	CFS_HASH_ALG_ADLER32,
>  	CFS_HASH_ALG_CRC32,
>  	CFS_HASH_ALG_CRC32C,
> @@ -54,7 +54,7 @@ enum cfs_crypto_hash_alg {
>  	CFS_HASH_ALG_SHA384,
>  	CFS_HASH_ALG_SHA512,
>  	CFS_HASH_ALG_MAX,
> -	CFS_HASH_ALG_SPEED_MAX = CFS_HASH_ALG_MD5,
> +	CFS_HASH_ALG_SPEED_MAX	= CFS_HASH_ALG_MD5,
>  	CFS_HASH_ALG_UNKNOWN	= 0xff
>  };
>  
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
> index 3fd6ad7a3b56..ba5d5ba2dac2 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
> @@ -68,11 +68,11 @@ extern unsigned int libcfs_panic_on_lbug;
>  #if !defined(__x86_64__)
>  # ifdef __ia64__
>  #  define CDEBUG_STACK() (THREAD_SIZE -					\
> -			  ((unsigned long)__builtin_dwarf_cfa() &       \
> +			  ((unsigned long)__builtin_dwarf_cfa() &	\
>  			   (THREAD_SIZE - 1)))
>  # else
>  #  define CDEBUG_STACK() (THREAD_SIZE -					\
> -			  ((unsigned long)__builtin_frame_address(0) &  \
> +			  ((unsigned long)__builtin_frame_address(0) &	\
>  			   (THREAD_SIZE - 1)))
>  # endif /* __ia64__ */
>  
> @@ -87,7 +87,7 @@ do {									\
>  		(msgdata)->msg_mask = mask;				\
>  		(msgdata)->msg_cdls = cdls;				\
>  		dump_stack();						\
> -	      /*panic("LBUG");*/					\
> +		/*panic("LBUG");*/					\
>  	}								\
>  } while (0)
>  #define CFS_CHECK_STACK(msgdata, mask, cdls)  __CHECK_STACK(msgdata, mask, cdls)
> @@ -120,22 +120,22 @@ struct libcfs_debug_msg_data {
>  
>  #define LIBCFS_DEBUG_MSG_DATA_INIT(data, mask, cdls)			\
>  do {									\
> -	(data)->msg_subsys = DEBUG_SUBSYSTEM;				\
> -	(data)->msg_file   = __FILE__;					\
> -	(data)->msg_fn     = __func__;					\
> -	(data)->msg_line   = __LINE__;					\
> -	(data)->msg_cdls   = (cdls);					\
> -	(data)->msg_mask   = (mask);					\
> +	(data)->msg_subsys	= DEBUG_SUBSYSTEM;			\
> +	(data)->msg_file	= __FILE__;				\
> +	(data)->msg_fn		= __func__;				\
> +	(data)->msg_line	= __LINE__;				\
> +	(data)->msg_cdls	= (cdls);				\
> +	(data)->msg_mask	= (mask);				\
>  } while (0)
>  
>  #define LIBCFS_DEBUG_MSG_DATA_DECL(dataname, mask, cdls)		\
>  	static struct libcfs_debug_msg_data dataname = {		\
> -	       .msg_subsys = DEBUG_SUBSYSTEM,				\
> -	       .msg_file   = __FILE__,					\
> -	       .msg_fn     = __func__,					\
> -	       .msg_line   = __LINE__,					\
> -	       .msg_cdls   = (cdls)	 };				\
> -	dataname.msg_mask   = (mask)
> +		.msg_subsys	= DEBUG_SUBSYSTEM,			\
> +		.msg_file	= __FILE__,				\
> +		.msg_fn		= __func__,				\
> +		.msg_line	= __LINE__,				\
> +		.msg_cdls	= (cdls)	 };			\
> +	dataname.msg_mask	= (mask)
>  
>  /**
>   * Filters out logging messages based on mask and subsystem.
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
> index 4a4197874f80..0e73eef6a992 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
> @@ -47,10 +47,10 @@ int __cfs_fail_check_set(u32 id, u32 value, int set);
>  int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set);
>  
>  enum {
> -	CFS_FAIL_LOC_NOSET      = 0,
> -	CFS_FAIL_LOC_ORSET      = 1,
> -	CFS_FAIL_LOC_RESET      = 2,
> -	CFS_FAIL_LOC_VALUE      = 3
> +	CFS_FAIL_LOC_NOSET	= 0,
> +	CFS_FAIL_LOC_ORSET	= 1,
> +	CFS_FAIL_LOC_RESET	= 2,
> +	CFS_FAIL_LOC_VALUE	= 3
>  };
>  
>  /* Failure injection control */
> @@ -76,8 +76,8 @@ enum {
>  static inline bool CFS_FAIL_PRECHECK(u32 id)
>  {
>  	return cfs_fail_loc &&
> -	       ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) ||
> -		(cfs_fail_loc & id & CFS_FAULT));
> +		((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) ||
> +		 (cfs_fail_loc & id & CFS_FAULT));
>  }
>  
>  static inline int cfs_fail_check_set(u32 id, u32 value,
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
> index be315958a4b3..89d25ca57c18 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
> @@ -304,25 +304,25 @@ struct cfs_hash_ops {
>  	unsigned int (*hs_hash)(struct cfs_hash *hs, const void *key,
>  				unsigned int mask);
>  	/** return key address of @hnode */
> -	void *   (*hs_key)(struct hlist_node *hnode);
> +	void *	(*hs_key)(struct hlist_node *hnode);
>  	/** copy key from @hnode to @key */
> -	void     (*hs_keycpy)(struct hlist_node *hnode, void *key);
> +	void	(*hs_keycpy)(struct hlist_node *hnode, void *key);
>  	/**
>  	 *  compare @key with key of @hnode
>  	 *  returns 1 on a match
>  	 */
> -	int      (*hs_keycmp)(const void *key, struct hlist_node *hnode);
> +	int	(*hs_keycmp)(const void *key, struct hlist_node *hnode);
>  	/** return object address of @hnode, i.e: container_of(...hnode) */
> -	void *   (*hs_object)(struct hlist_node *hnode);
> +	void *	(*hs_object)(struct hlist_node *hnode);
>  	/** get refcount of item, always called with holding bucket-lock */
> -	void     (*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode);
> +	void	(*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode);
>  	/** release refcount of item */
> -	void     (*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode);
> +	void	(*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode);
>  	/** release refcount of item, always called with holding bucket-lock */
> -	void     (*hs_put_locked)(struct cfs_hash *hs,
> -				  struct hlist_node *hnode);
> +	void	(*hs_put_locked)(struct cfs_hash *hs,
> +				 struct hlist_node *hnode);
>  	/** it's called before removing of @hnode */
> -	void     (*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode);
> +	void	(*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode);
>  };
>  
>  /** total number of buckets in @hs */
> @@ -460,8 +460,8 @@ static inline int
>  cfs_hash_bkt_size(struct cfs_hash *hs)
>  {
>  	return offsetof(struct cfs_hash_bucket, hsb_head[0]) +
> -	       hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) +
> -	       hs->hs_extra_bytes;
> +		hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) +
> +		hs->hs_extra_bytes;
>  }
>  
>  static inline unsigned
> @@ -703,7 +703,7 @@ void *cfs_hash_del(struct cfs_hash *hs, const void *key,
>  void *cfs_hash_del_key(struct cfs_hash *hs, const void *key);
>  
>  /* Hash lookup/for_each functions */
> -#define CFS_HASH_LOOP_HOG       1024
> +#define CFS_HASH_LOOP_HOG	1024
>  
>  typedef int (*cfs_hash_for_each_cb_t)(struct cfs_hash *hs,
>  				      struct cfs_hash_bd *bd,
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> index d525e4f928fe..515fd63708c0 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> @@ -141,7 +141,7 @@ void  cfs_array_free(void *vars);
>  #define LASSERT_ATOMIC_GT_LT(a, v1, v2)				\
>  do {								\
>  	int __v = atomic_read(a);				\
> -	LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v);     \
> +	LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v);	\
>  } while (0)
>  
>  /** assert value of @a is great than @v1 and little/equal to @v2 */
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> index fb5d07460243..e60c446fbb27 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> @@ -611,7 +611,7 @@ void lnet_counters_reset(void);
>  unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov);
>  int lnet_extract_iov(int dst_niov, struct kvec *dst,
>  		     int src_niov, const struct kvec *src,
> -		      unsigned int offset, unsigned int len);
> +		     unsigned int offset, unsigned int len);
>  
>  unsigned int lnet_kiov_nob(unsigned int niov, struct bio_vec *iov);
>  int lnet_extract_kiov(int dst_niov, struct bio_vec *dst,
> @@ -827,7 +827,7 @@ void lnet_incr_stats(struct lnet_element_stats *stats,
>  		     enum lnet_stats_type stats_type);
>  
>  u32 lnet_sum_stats(struct lnet_element_stats *stats,
> -		     enum lnet_stats_type stats_type);
> +		   enum lnet_stats_type stats_type);
>  
>  void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
>  			      struct lnet_element_stats *stats);
> diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h
> index ca814afd34ef..9f318b73cd34 100644
> --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h
> +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h
> @@ -41,7 +41,7 @@
>  struct ksock_hello_msg {
>  	u32		kshm_magic;	/* magic number of socklnd message */
>  	u32		kshm_version;	/* version of socklnd message */
> -	lnet_nid_t      kshm_src_nid;	/* sender's nid */
> +	lnet_nid_t	kshm_src_nid;	/* sender's nid */
>  	lnet_nid_t	kshm_dst_nid;	/* destination nid */
>  	lnet_pid_t	kshm_src_pid;	/* sender's pid */
>  	lnet_pid_t	kshm_dst_pid;	/* destination pid */
> diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h
> index 2672fe7ae103..91d80ab064ad 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h
> @@ -62,38 +62,38 @@ struct ptldebug_header {
>  #define PH_FLAG_FIRST_RECORD	1
>  
>  /* Debugging subsystems (32 bits, non-overlapping) */
> -#define S_UNDEFINED     0x00000001
> -#define S_MDC           0x00000002
> -#define S_MDS           0x00000004
> -#define S_OSC           0x00000008
> -#define S_OST           0x00000010
> -#define S_CLASS         0x00000020
> -#define S_LOG           0x00000040
> -#define S_LLITE         0x00000080
> -#define S_RPC           0x00000100
> -#define S_MGMT          0x00000200
> -#define S_LNET          0x00000400
> -#define S_LND           0x00000800 /* ALL LNDs */
> -#define S_PINGER        0x00001000
> -#define S_FILTER        0x00002000
> -#define S_LIBCFS        0x00004000
> -#define S_ECHO          0x00008000
> -#define S_LDLM          0x00010000
> -#define S_LOV           0x00020000
> -#define S_LQUOTA        0x00040000
> -#define S_OSD           0x00080000
> -#define S_LFSCK         0x00100000
> -#define S_SNAPSHOT      0x00200000
> +#define S_UNDEFINED	0x00000001
> +#define S_MDC		0x00000002
> +#define S_MDS		0x00000004
> +#define S_OSC		0x00000008
> +#define S_OST		0x00000010
> +#define S_CLASS		0x00000020
> +#define S_LOG		0x00000040
> +#define S_LLITE		0x00000080
> +#define S_RPC		0x00000100
> +#define S_MGMT		0x00000200
> +#define S_LNET		0x00000400
> +#define S_LND		0x00000800 /* ALL LNDs */
> +#define S_PINGER	0x00001000
> +#define S_FILTER	0x00002000
> +#define S_LIBCFS	0x00004000
> +#define S_ECHO		0x00008000
> +#define S_LDLM		0x00010000
> +#define S_LOV		0x00020000
> +#define S_LQUOTA	0x00040000
> +#define S_OSD		0x00080000
> +#define S_LFSCK		0x00100000
> +#define S_SNAPSHOT	0x00200000
>  /* unused */
> -#define S_LMV           0x00800000 /* b_new_cmd */
> +#define S_LMV		0x00800000 /* b_new_cmd */
>  /* unused */
> -#define S_SEC           0x02000000 /* upcall cache */
> -#define S_GSS           0x04000000 /* b_new_cmd */
> +#define S_SEC		0x02000000 /* upcall cache */
> +#define S_GSS		0x04000000 /* b_new_cmd */
>  /* unused */
> -#define S_MGC           0x10000000
> -#define S_MGS           0x20000000
> -#define S_FID           0x40000000 /* b_new_cmd */
> -#define S_FLD           0x80000000 /* b_new_cmd */
> +#define S_MGC		0x10000000
> +#define S_MGS		0x20000000
> +#define S_FID		0x40000000 /* b_new_cmd */
> +#define S_FLD		0x80000000 /* b_new_cmd */
>  
>  #define LIBCFS_DEBUG_SUBSYS_NAMES {					\
>  	"undefined", "mdc", "mds", "osc", "ost", "class", "log",	\
> @@ -103,38 +103,38 @@ struct ptldebug_header {
>  	"fid", "fld", NULL }
>  
>  /* Debugging masks (32 bits, non-overlapping) */
> -#define D_TRACE         0x00000001 /* ENTRY/EXIT markers */
> -#define D_INODE         0x00000002
> -#define D_SUPER         0x00000004
> -#define D_EXT2          0x00000008 /* anything from ext2_debug */
> -#define D_MALLOC        0x00000010 /* print malloc, free information */
> -#define D_CACHE         0x00000020 /* cache-related items */
> -#define D_INFO          0x00000040 /* general information */
> -#define D_IOCTL         0x00000080 /* ioctl related information */
> -#define D_NETERROR      0x00000100 /* network errors */
> -#define D_NET           0x00000200 /* network communications */
> -#define D_WARNING       0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
> -#define D_BUFFS         0x00000800
> -#define D_OTHER         0x00001000
> -#define D_DENTRY        0x00002000
> -#define D_NETTRACE      0x00004000
> -#define D_PAGE          0x00008000 /* bulk page handling */
> -#define D_DLMTRACE      0x00010000
> -#define D_ERROR         0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
> -#define D_EMERG         0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
> -#define D_HA            0x00080000 /* recovery and failover */
> -#define D_RPCTRACE      0x00100000 /* for distributed debugging */
> -#define D_VFSTRACE      0x00200000
> -#define D_READA         0x00400000 /* read-ahead */
> -#define D_MMAP          0x00800000
> -#define D_CONFIG        0x01000000
> -#define D_CONSOLE       0x02000000
> -#define D_QUOTA         0x04000000
> -#define D_SEC           0x08000000
> -#define D_LFSCK         0x10000000 /* For both OI scrub and LFSCK */
> -#define D_HSM           0x20000000
> -#define D_SNAPSHOT      0x40000000 /* snapshot */
> -#define D_LAYOUT        0x80000000
> +#define D_TRACE		0x00000001 /* ENTRY/EXIT markers */
> +#define D_INODE		0x00000002
> +#define D_SUPER		0x00000004
> +#define D_EXT2		0x00000008 /* anything from ext2_debug */
> +#define D_MALLOC	0x00000010 /* print malloc, free information */
> +#define D_CACHE		0x00000020 /* cache-related items */
> +#define D_INFO		0x00000040 /* general information */
> +#define D_IOCTL		0x00000080 /* ioctl related information */
> +#define D_NETERROR	0x00000100 /* network errors */
> +#define D_NET		0x00000200 /* network communications */
> +#define D_WARNING	0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
> +#define D_BUFFS		0x00000800
> +#define D_OTHER		0x00001000
> +#define D_DENTRY	0x00002000
> +#define D_NETTRACE	0x00004000
> +#define D_PAGE		0x00008000 /* bulk page handling */
> +#define D_DLMTRACE	0x00010000
> +#define D_ERROR		0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
> +#define D_EMERG		0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
> +#define D_HA		0x00080000 /* recovery and failover */
> +#define D_RPCTRACE	0x00100000 /* for distributed debugging */
> +#define D_VFSTRACE	0x00200000
> +#define D_READA		0x00400000 /* read-ahead */
> +#define D_MMAP		0x00800000
> +#define D_CONFIG	0x01000000
> +#define D_CONSOLE	0x02000000
> +#define D_QUOTA		0x04000000
> +#define D_SEC		0x08000000
> +#define D_LFSCK		0x10000000 /* For both OI scrub and LFSCK */
> +#define D_HSM		0x20000000
> +#define D_SNAPSHOT	0x40000000 /* snapshot */
> +#define D_LAYOUT	0x80000000
>  
>  #define LIBCFS_DEBUG_MASKS_NAMES {					\
>  	"trace", "inode", "super", "ext2", "malloc", "cache", "info",	\
> @@ -144,7 +144,7 @@ struct ptldebug_header {
>  	"console", "quota", "sec", "lfsck", "hsm", "snapshot", "layout",\
>  	NULL }
>  
> -#define D_CANTMASK   (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
> +#define D_CANTMASK	(D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
>  
>  #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log"
>  
> diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h
> index 4590f65c333f..765466f41d61 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h
> @@ -82,41 +82,41 @@ struct libcfs_debug_ioctl_data {
>  };
>  
>  /* 'f' ioctls are defined in lustre_ioctl.h and lustre_user.h except for: */
> -#define LIBCFS_IOC_DEBUG_MASK		   _IOWR('f', 250, long)
> -#define IOCTL_LIBCFS_TYPE		   long
> +#define LIBCFS_IOC_DEBUG_MASK		_IOWR('f', 250, long)
> +#define IOCTL_LIBCFS_TYPE		long
>  
> -#define IOC_LIBCFS_TYPE			   ('e')
> -#define IOC_LIBCFS_MIN_NR		   30
> +#define IOC_LIBCFS_TYPE			('e')
> +#define IOC_LIBCFS_MIN_NR		30
>  /* libcfs ioctls */
>  /* IOC_LIBCFS_PANIC obsolete in 2.8.0, was _IOWR('e', 30, IOCTL_LIBCFS_TYPE) */
> -#define IOC_LIBCFS_CLEAR_DEBUG		   _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_MARK_DEBUG		   _IOWR('e', 32, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_CLEAR_DEBUG		_IOWR('e', 31, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_MARK_DEBUG		_IOWR('e', 32, IOCTL_LIBCFS_TYPE)
>  /* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */
>  /* lnet ioctls */
> -#define IOC_LIBCFS_GET_NI		   _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_FAIL_NID		   _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_NOTIFY_ROUTER	   _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_UNCONFIGURE		   _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_GET_NI		_IOWR('e', 50, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_FAIL_NID		_IOWR('e', 51, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_NOTIFY_ROUTER	_IOWR('e', 55, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_UNCONFIGURE		_IOWR('e', 56, IOCTL_LIBCFS_TYPE)
>  /*	 IOC_LIBCFS_PORTALS_COMPATIBILITY  _IOWR('e', 57, IOCTL_LIBCFS_TYPE) */
> -#define IOC_LIBCFS_LNET_DIST		   _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_CONFIGURE		   _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_TESTPROTOCOMPAT	   _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_PING			   _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_PING_PEER               _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_LNETST		   _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_LNET_FAULT		   _IOWR('e', 64, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_LNET_DIST		_IOWR('e', 58, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_CONFIGURE		_IOWR('e', 59, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_TESTPROTOCOMPAT	_IOWR('e', 60, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_PING			_IOWR('e', 61, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_PING_PEER		_IOWR('e', 62, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_LNETST		_IOWR('e', 63, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_LNET_FAULT		_IOWR('e', 64, IOCTL_LIBCFS_TYPE)
>  /* lnd ioctls */
> -#define IOC_LIBCFS_REGISTER_MYNID	   _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_CLOSE_CONNECTION	   _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_PUSH_CONNECTION	   _IOWR('e', 72, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_GET_CONN		   _IOWR('e', 73, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_DEL_PEER		   _IOWR('e', 74, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_ADD_PEER		   _IOWR('e', 75, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_GET_PEER		   _IOWR('e', 76, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_DISCOVER                _IOWR('e', 77, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_ADD_INTERFACE	   _IOWR('e', 78, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_DEL_INTERFACE	   _IOWR('e', 79, IOCTL_LIBCFS_TYPE)
> -#define IOC_LIBCFS_GET_INTERFACE	   _IOWR('e', 80, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_REGISTER_MYNID	_IOWR('e', 70, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_CLOSE_CONNECTION	_IOWR('e', 71, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_PUSH_CONNECTION	_IOWR('e', 72, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_GET_CONN		_IOWR('e', 73, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_DEL_PEER		_IOWR('e', 74, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_ADD_PEER		_IOWR('e', 75, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_GET_PEER		_IOWR('e', 76, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_DISCOVER		_IOWR('e', 77, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_ADD_INTERFACE	_IOWR('e', 78, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_DEL_INTERFACE	_IOWR('e', 79, IOCTL_LIBCFS_TYPE)
> +#define IOC_LIBCFS_GET_INTERFACE	_IOWR('e', 80, IOCTL_LIBCFS_TYPE)
>  
>  /*
>   * DLC Specific IOCTL numbers.
> diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
> index 4fcc5336d927..956af3c53cfc 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
> @@ -289,9 +289,9 @@ struct lnet_counters {
>  	__u64	drop_length;
>  } __packed;
>  
> -#define LNET_NI_STATUS_UP      0x15aac0de
> -#define LNET_NI_STATUS_DOWN    0xdeadface
> -#define LNET_NI_STATUS_INVALID 0x00000000
> +#define LNET_NI_STATUS_UP	0x15aac0de
> +#define LNET_NI_STATUS_DOWN	0xdeadface
> +#define LNET_NI_STATUS_INVALID	0x00000000
>  
>  #define LNET_INTERFACES_NUM		16
>  
> @@ -596,7 +596,7 @@ enum lnet_event_kind {
>  	LNET_EVENT_UNLINK,
>  };
>  
> -#define LNET_SEQ_GT(a, b)      (((signed long)((a) - (b))) > 0)
> +#define LNET_SEQ_GT(a, b)	(((signed long)((a) - (b))) > 0)
>  
>  /**
>   * Information about an event on a MD.
> @@ -650,7 +650,7 @@ struct lnet_event {
>  	 * The message type, to ensure a handler for LNET_EVENT_SEND can
>  	 * distinguish between LNET_MSG_GET and LNET_MSG_PUT.
>  	 */
> -	__u32               msg_type;
> +	__u32			msg_type;
>  	/**
>  	 * Indicates the completion status of the operation. It's 0 for
>  	 * successful operations, otherwise it's an error code.
> diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h
> index a6eebee1a69c..27fcd91931a6 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h
> @@ -58,7 +58,7 @@
>  					 */
>  #define LSTIO_GROUP_DEL		0xC13	/* delete group */
>  #define LSTIO_NODES_ADD		0xC14	/* add nodes to specified group */
> -#define LSTIO_GROUP_UPDATE      0xC15	/* update group */
> +#define LSTIO_GROUP_UPDATE	0xC15	/* update group */
>  #define LSTIO_BATCH_ADD		0xC20	/* add batch */
>  #define LSTIO_BATCH_START	0xC21	/* start batch */
>  #define LSTIO_BATCH_STOP	0xC22	/* stop batch */
> @@ -100,9 +100,9 @@ struct lstcon_ndlist_ent {
>  };				/*** node_list entry, for list_batch command */
>  
>  struct lstcon_test_ent {
> -	int	tse_type;       /* test type */
> -	int	tse_loop;       /* loop count */
> -	int	tse_concur;     /* concurrency of test */
> +	int	tse_type;	/* test type */
> +	int	tse_loop;	/* loop count */
> +	int	tse_concur;	/* concurrency of test */
>  };				/* test summary entry, for
>  				 * list_batch command
>  				 */
> @@ -520,9 +520,9 @@ enum lst_brw_flags {
>  
>  struct lst_test_bulk_param {
>  	int	blk_opc;	/* bulk operation code */
> -	int	blk_size;       /* size (bytes) */
> -	int	blk_time;       /* time of running the test*/
> -	int	blk_flags;      /* reserved flags */
> +	int	blk_size;	/* size (bytes) */
> +	int	blk_time;	/* time of running the test*/
> +	int	blk_flags;	/* reserved flags */
>  	int	blk_cli_off;	/* bulk offset on client */
>  	int	blk_srv_off;	/* reserved: bulk offset on server */
>  };
> diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h
> index 3c5901d81d52..6c49d59f4f85 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h
> @@ -44,7 +44,7 @@ enum {
>  	/*GMLND		= 3, removed v2_0_0-rc1a-16-gc660aac	*/
>  	/*PTLLND	= 4, removed v2_7_50			*/
>  	O2IBLND		= 5,
> -	/*CIBLND        = 6, removed v2_0_0-rc1a-175-gd2b8a0e	*/
> +	/*CIBLND	= 6, removed v2_0_0-rc1a-175-gd2b8a0e	*/
>  	/*OPENIBLND	= 7, removed v2_0_0-rc1a-175-gd2b8a0e	*/
>  	/*IIBLND	= 8, removed v2_0_0-rc1a-175-gd2b8a0e	*/
>  	LOLND		= 9,
> @@ -57,8 +57,8 @@ 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_COUNT	1024	/* # of nidstrings */
> +#define LNET_NIDSTR_SIZE	32	/* size of each one (see below for usage) */
>  
>  /* support decl needed by both kernel and user space */
>  char *libcfs_next_nidstring(void);
> diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
> index d24a93e57ed7..7ecb6f6354cc 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h
> @@ -49,7 +49,7 @@
>  static inline size_t fiemap_count_to_size(size_t extent_count)
>  {
>  	return sizeof(struct fiemap) + extent_count *
> -				       sizeof(struct fiemap_extent);
> +		sizeof(struct fiemap_extent);
>  }
>  
>  static inline unsigned int fiemap_size_to_count(size_t array_size)
> diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
> index bffe62e87e00..62b9a3301c4d 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
> @@ -443,14 +443,14 @@ struct luda_type {
>  };
>  
>  #ifndef IFSHIFT
> -#define IFSHIFT                 12
> +#define IFSHIFT		12
>  #endif
>  
>  #ifndef IFTODT
> -#define IFTODT(type)		(((type) & S_IFMT) >> IFSHIFT)
> +#define IFTODT(type)	(((type) & S_IFMT) >> IFSHIFT)
>  #endif
>  #ifndef DTTOIF
> -#define DTTOIF(dirtype)		((dirtype) << IFSHIFT)
> +#define DTTOIF(dirtype)	((dirtype) << IFSHIFT)
>  #endif
>  
>  struct lu_dirpage {
> @@ -551,8 +551,8 @@ static inline void lustre_handle_copy(struct lustre_handle *tgt,
>  }
>  
>  /* flags for lm_flags */
> -#define MSGHDR_AT_SUPPORT	       0x1
> -#define MSGHDR_CKSUM_INCOMPAT18	 0x2
> +#define MSGHDR_AT_SUPPORT	0x1
> +#define MSGHDR_CKSUM_INCOMPAT18	0x2
>  
>  #define lustre_msg lustre_msg_v2
>  /* we depend on this structure to be 8-byte aligned */
> @@ -570,7 +570,7 @@ struct lustre_msg_v2 {
>  };
>  
>  /* without gss, ptlrpc_body is put at the first buffer. */
> -#define PTLRPC_NUM_VERSIONS     4
> +#define PTLRPC_NUM_VERSIONS	4
>  
>  struct ptlrpc_body_v3 {
>  	struct lustre_handle pb_handle;
> @@ -578,8 +578,8 @@ struct ptlrpc_body_v3 {
>  	__u32 pb_version;
>  	__u32 pb_opc;
>  	__u32 pb_status;
> -	__u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
> -	__u16 pb_tag;      /* virtual slot idx for multiple modifying RPCs */
> +	__u64 pb_last_xid;	/* highest replied XID without lower unreplied XID */
> +	__u16 pb_tag;		/* virtual slot idx for multiple modifying RPCs */
>  	__u16 pb_padding0;
>  	__u32 pb_padding1;
>  	__u64 pb_last_committed;
> @@ -587,13 +587,13 @@ struct ptlrpc_body_v3 {
>  	__u32 pb_flags;
>  	__u32 pb_op_flags;
>  	__u32 pb_conn_cnt;
> -	__u32 pb_timeout;  /* for req, the deadline, for rep, the service est */
> -	__u32 pb_service_time; /* for rep, actual service time */
> +	__u32 pb_timeout;	/* for req, the deadline, for rep, the service est */
> +	__u32 pb_service_time;	/* for rep, actual service time */
>  	__u32 pb_limit;
>  	__u64 pb_slv;
>  	/* VBR: pre-versions */
>  	__u64 pb_pre_versions[PTLRPC_NUM_VERSIONS];
> -	__u64 pb_mbits; /**< match bits for bulk request */
> +	__u64 pb_mbits;		/**< match bits for bulk request */
>  	/* padding for future needs */
>  	__u64 pb_padding64_0;
>  	__u64 pb_padding64_1;
> @@ -601,7 +601,7 @@ struct ptlrpc_body_v3 {
>  	char  pb_jobid[LUSTRE_JOBID_SIZE];
>  };
>  
> -#define ptlrpc_body     ptlrpc_body_v3
> +#define ptlrpc_body	ptlrpc_body_v3
>  
>  struct ptlrpc_body_v2 {
>  	struct lustre_handle pb_handle;
> @@ -609,8 +609,8 @@ struct ptlrpc_body_v2 {
>  	__u32 pb_version;
>  	__u32 pb_opc;
>  	__u32 pb_status;
> -	__u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
> -	__u16 pb_tag;      /* virtual slot idx for multiple modifying RPCs */
> +	__u64 pb_last_xid;	/* highest replied XID without lower unreplied XID */
> +	__u16 pb_tag;		/* virtual slot idx for multiple modifying RPCs */
>  	__u16 pb_padding0;
>  	__u32 pb_padding1;
>  	__u64 pb_last_committed;
> @@ -618,10 +618,10 @@ struct ptlrpc_body_v2 {
>  	__u32 pb_flags;
>  	__u32 pb_op_flags;
>  	__u32 pb_conn_cnt;
> -	__u32 pb_timeout;  /* for req, the deadline, for rep, the service est */
> -	__u32 pb_service_time; /* for rep, actual service time, also used for
> -				* net_latency of req
> -				*/
> +	__u32 pb_timeout;	/* for req, the deadline, for rep, the service est */
> +	__u32 pb_service_time;	/* for rep, actual service time, also used for
> +				 * net_latency of req
> +				 */
>  	__u32 pb_limit;
>  	__u64 pb_slv;
>  	/* VBR: pre-versions */
> @@ -881,66 +881,66 @@ enum cksum_type {
>  
>  /* opcodes */
>  enum ost_cmd {
> -	OST_REPLY      =  0,       /* reply ? */
> -	OST_GETATTR    =  1,
> -	OST_SETATTR    =  2,
> -	OST_READ       =  3,
> -	OST_WRITE      =  4,
> -	OST_CREATE     =  5,
> -	OST_DESTROY    =  6,
> -	OST_GET_INFO   =  7,
> -	OST_CONNECT    =  8,
> -	OST_DISCONNECT =  9,
> -	OST_PUNCH      = 10,
> -	OST_OPEN       = 11,
> -	OST_CLOSE      = 12,
> -	OST_STATFS     = 13,
> -	OST_SYNC       = 16,
> -	OST_SET_INFO   = 17,
> -	OST_QUOTACHECK = 18, /* not used since 2.4 */
> -	OST_QUOTACTL   = 19,
> +	OST_REPLY	=  0,	/* reply ? */
> +	OST_GETATTR	=  1,
> +	OST_SETATTR	=  2,
> +	OST_READ	=  3,
> +	OST_WRITE	=  4,
> +	OST_CREATE	=  5,
> +	OST_DESTROY	=  6,
> +	OST_GET_INFO	=  7,
> +	OST_CONNECT	=  8,
> +	OST_DISCONNECT	=  9,
> +	OST_PUNCH	= 10,
> +	OST_OPEN	= 11,
> +	OST_CLOSE	= 12,
> +	OST_STATFS	= 13,
> +	OST_SYNC	= 16,
> +	OST_SET_INFO	= 17,
> +	OST_QUOTACHECK	= 18,	/* not used since 2.4 */
> +	OST_QUOTACTL	= 19,
>  	OST_QUOTA_ADJUST_QUNIT = 20, /* not used since 2.4 */
> -	OST_LADVISE    = 21,
> +	OST_LADVISE	= 21,
>  	OST_LAST_OPC /* must be < 33 to avoid MDS_GETATTR */
>  };
>  #define OST_FIRST_OPC  OST_REPLY
>  
>  enum obdo_flags {
> -	OBD_FL_INLINEDATA   = 0x00000001,
> -	OBD_FL_OBDMDEXISTS  = 0x00000002,
> -	OBD_FL_DELORPHAN    = 0x00000004, /* if set in o_flags delete orphans */
> -	OBD_FL_NORPC        = 0x00000008, /* set in o_flags do in OSC not OST */
> -	OBD_FL_IDONLY       = 0x00000010, /* set in o_flags only adjust obj id*/
> -	OBD_FL_RECREATE_OBJS = 0x00000020, /* recreate missing obj */
> -	OBD_FL_DEBUG_CHECK  = 0x00000040, /* echo client/server debug check */
> -	OBD_FL_NO_PRJQUOTA  = 0x00000080, /* the object's project is over
> -					   * quota
> -					   */
> -	OBD_FL_NO_USRQUOTA  = 0x00000100, /* the object's owner is over quota */
> -	OBD_FL_NO_GRPQUOTA  = 0x00000200, /* the object's group is over quota */
> -	OBD_FL_CREATE_CROW  = 0x00000400, /* object should be create on write */
> -	OBD_FL_SRVLOCK      = 0x00000800, /* delegate DLM locking to server */
> -	OBD_FL_CKSUM_CRC32  = 0x00001000, /* CRC32 checksum type */
> -	OBD_FL_CKSUM_ADLER  = 0x00002000, /* ADLER checksum type */
> -	OBD_FL_CKSUM_CRC32C = 0x00004000, /* CRC32C checksum type */
> -	OBD_FL_CKSUM_RSVD2  = 0x00008000, /* for future cksum types */
> -	OBD_FL_CKSUM_RSVD3  = 0x00010000, /* for future cksum types */
> -	OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */
> -	OBD_FL_MMAP         = 0x00040000, /* object is mmapped on the client.
> -					   * XXX: obsoleted - reserved for old
> -					   * clients prior than 2.2
> -					   */
> -	OBD_FL_RECOV_RESEND = 0x00080000, /* recoverable resent */
> -	OBD_FL_NOSPC_BLK    = 0x00100000, /* no more block space on OST */
> -	OBD_FL_FLUSH        = 0x00200000, /* flush pages on the OST */
> -	OBD_FL_SHORT_IO     = 0x00400000, /* short io request */
> +	OBD_FL_INLINEDATA	= 0x00000001,
> +	OBD_FL_OBDMDEXISTS	= 0x00000002,
> +	OBD_FL_DELORPHAN	= 0x00000004, /* if set in o_flags delete orphans */
> +	OBD_FL_NORPC		= 0x00000008, /* set in o_flags do in OSC not OST */
> +	OBD_FL_IDONLY		= 0x00000010, /* set in o_flags only adjust obj id*/
> +	OBD_FL_RECREATE_OBJS	= 0x00000020, /* recreate missing obj */
> +	OBD_FL_DEBUG_CHECK	= 0x00000040, /* echo client/server debug check */
> +	OBD_FL_NO_PRJQUOTA	= 0x00000080, /* the object's project is over
> +					       * quota
> +					       */
> +	OBD_FL_NO_USRQUOTA	= 0x00000100, /* the object's owner is over quota */
> +	OBD_FL_NO_GRPQUOTA	= 0x00000200, /* the object's group is over quota */
> +	OBD_FL_CREATE_CROW	= 0x00000400, /* object should be create on write */
> +	OBD_FL_SRVLOCK		= 0x00000800, /* delegate DLM locking to server */
> +	OBD_FL_CKSUM_CRC32	= 0x00001000, /* CRC32 checksum type */
> +	OBD_FL_CKSUM_ADLER	= 0x00002000, /* ADLER checksum type */
> +	OBD_FL_CKSUM_CRC32C	= 0x00004000, /* CRC32C checksum type */
> +	OBD_FL_CKSUM_RSVD2	= 0x00008000, /* for future cksum types */
> +	OBD_FL_CKSUM_RSVD3	= 0x00010000, /* for future cksum types */
> +	OBD_FL_SHRINK_GRANT	= 0x00020000, /* object shrink the grant */
> +	OBD_FL_MMAP		= 0x00040000, /* object is mmapped on the client.
> +					       * XXX: obsoleted - reserved for old
> +					       * clients prior than 2.2
> +					       */
> +	OBD_FL_RECOV_RESEND	= 0x00080000, /* recoverable resent */
> +	OBD_FL_NOSPC_BLK	= 0x00100000, /* no more block space on OST */
> +	OBD_FL_FLUSH		= 0x00200000, /* flush pages on the OST */
> +	OBD_FL_SHORT_IO		= 0x00400000, /* short io request */
>  	/* OBD_FL_LOCAL_MASK = 0xF0000000, was local-only flags until 2.10 */
>  
>  	/* Note that while these checksum values are currently separate bits,
>  	 * in 2.x we can actually allow all values from 1-31 if we wanted.
>  	 */
> -	OBD_FL_CKSUM_ALL    = OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER |
> -			      OBD_FL_CKSUM_CRC32C,
> +	OBD_FL_CKSUM_ALL	= (OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER |
> +				   OBD_FL_CKSUM_CRC32C),
>  };
>  
>  /*
> @@ -1233,9 +1233,9 @@ struct niobuf_remote {
>   */
>  #define OST_LVB_ERR_INIT 0xffbadbad80000000ULL
>  #define OST_LVB_ERR_MASK 0xffbadbad00000000ULL
> -#define OST_LVB_IS_ERR(blocks)					  \
> +#define OST_LVB_IS_ERR(blocks)					\
>  	((blocks & OST_LVB_ERR_MASK) == OST_LVB_ERR_MASK)
> -#define OST_LVB_SET_ERR(blocks, rc)				     \
> +#define OST_LVB_SET_ERR(blocks, rc)				\
>  	do { blocks = OST_LVB_ERR_INIT + rc; } while (0)
>  #define OST_LVB_GET_ERR(blocks)    (int)(blocks - OST_LVB_ERR_INIT)
>  
> @@ -1316,9 +1316,9 @@ struct ldlm_gl_lquota_desc {
>  /* LVB used with quota (global and per-ID) locks */
>  struct lquota_lvb {
>  	__u64	lvb_flags;	/* see LQUOTA_FL* above */
> -	__u64	lvb_id_may_rel; /* space that might be released later */
> -	__u64	lvb_id_rel;     /* space released by the slave for this ID */
> -	__u64	lvb_id_qunit;   /* current qunit value */
> +	__u64	lvb_id_may_rel;	/* space that might be released later */
> +	__u64	lvb_id_rel;	/* space released by the slave for this ID */
> +	__u64	lvb_id_qunit;	/* current qunit value */
>  	__u64	lvb_pad1;
>  };
>  
> @@ -1488,17 +1488,17 @@ static inline int ll_inode_to_ext_flags(int iflags)
>  
>  static inline int ll_xflags_to_inode_flags(int xflags)
>  {
> -	return ((xflags & FS_XFLAG_SYNC) ? S_SYNC : 0) |
> -	       ((xflags & FS_XFLAG_NOATIME) ? S_NOATIME : 0) |
> -	       ((xflags & FS_XFLAG_APPEND) ? S_APPEND : 0) |
> +	return ((xflags & FS_XFLAG_SYNC)      ? S_SYNC      : 0) |
> +	       ((xflags & FS_XFLAG_NOATIME)   ? S_NOATIME   : 0) |
> +	       ((xflags & FS_XFLAG_APPEND)    ? S_APPEND    : 0) |
>  	       ((xflags & FS_XFLAG_IMMUTABLE) ? S_IMMUTABLE : 0);
>  }
>  
>  static inline int ll_inode_flags_to_xflags(int flags)
>  {
> -	return ((flags & S_SYNC) ? FS_XFLAG_SYNC : 0) |
> -	       ((flags & S_NOATIME) ? FS_XFLAG_NOATIME : 0) |
> -	       ((flags & S_APPEND) ? FS_XFLAG_APPEND : 0) |
> +	return ((flags & S_SYNC)      ? FS_XFLAG_SYNC      : 0) |
> +	       ((flags & S_NOATIME)   ? FS_XFLAG_NOATIME   : 0) |
> +	       ((flags & S_APPEND)    ? FS_XFLAG_APPEND    : 0) |
>  	       ((flags & S_IMMUTABLE) ? FS_XFLAG_IMMUTABLE : 0);
>  }
>  
> @@ -1583,7 +1583,7 @@ struct mdt_rec_setattr {
>  	__s64		sa_ctime;
>  	__u32		sa_attr_flags;
>  	__u32		sa_mode;
> -	__u32		sa_bias;      /* some operation flags */
> +	__u32		sa_bias;	/* some operation flags */
>  	__u32		sa_projid;
>  	__u32		sa_padding_4;
>  	__u32		sa_padding_5;
> @@ -1698,17 +1698,17 @@ struct mdt_rec_create {
>  	__s64		cr_time;
>  	__u64		cr_rdev;
>  	__u64		cr_ioepoch;
> -	__u64		cr_padding_1;   /* rr_blocks */
> +	__u64		cr_padding_1;	/* rr_blocks */
>  	__u32		cr_mode;
>  	__u32		cr_bias;
>  	/* use of helpers set/get_mrc_cr_flags() is needed to access
>  	 * 64 bits cr_flags [cr_flags_l, cr_flags_h], this is done to
>  	 * extend cr_flags size without breaking 1.8 compat
>  	 */
> -	__u32		cr_flags_l;     /* for use with open, low  32 bits  */
> -	__u32		cr_flags_h;     /* for use with open, high 32 bits */
> -	__u32		cr_umask;       /* umask for create */
> -	__u32		cr_padding_4;   /* rr_padding_4 */
> +	__u32		cr_flags_l;	/* for use with open, low  32 bits  */
> +	__u32		cr_flags_h;	/* for use with open, high 32 bits */
> +	__u32		cr_umask;	/* umask for create */
> +	__u32		cr_padding_4;	/* rr_padding_4 */
>  };
>  
>  /* instance of mdt_reint_rec */
> @@ -1726,16 +1726,16 @@ struct mdt_rec_link {
>  	struct lu_fid   lk_fid1;
>  	struct lu_fid   lk_fid2;
>  	__s64		lk_time;
> -	__u64		lk_padding_1;   /* rr_atime */
> -	__u64		lk_padding_2;   /* rr_ctime */
> -	__u64		lk_padding_3;   /* rr_size */
> -	__u64		lk_padding_4;   /* rr_blocks */
> +	__u64		lk_padding_1;	/* rr_atime */
> +	__u64		lk_padding_2;	/* rr_ctime */
> +	__u64		lk_padding_3;	/* rr_size */
> +	__u64		lk_padding_4;	/* rr_blocks */
>  	__u32		lk_bias;
> -	__u32		lk_padding_5;   /* rr_mode */
> -	__u32		lk_padding_6;   /* rr_flags */
> -	__u32		lk_padding_7;   /* rr_padding_2 */
> -	__u32		lk_padding_8;   /* rr_padding_3 */
> -	__u32		lk_padding_9;   /* rr_padding_4 */
> +	__u32		lk_padding_5;	/* rr_mode */
> +	__u32		lk_padding_6;	/* rr_flags */
> +	__u32		lk_padding_7;	/* rr_padding_2 */
> +	__u32		lk_padding_8;	/* rr_padding_3 */
> +	__u32		lk_padding_9;	/* rr_padding_4 */
>  };
>  
>  /* instance of mdt_reint_rec */
> @@ -1753,16 +1753,16 @@ struct mdt_rec_unlink {
>  	struct lu_fid   ul_fid1;
>  	struct lu_fid   ul_fid2;
>  	__s64		ul_time;
> -	__u64		ul_padding_2;   /* rr_atime */
> -	__u64		ul_padding_3;   /* rr_ctime */
> -	__u64		ul_padding_4;   /* rr_size */
> -	__u64		ul_padding_5;   /* rr_blocks */
> +	__u64		ul_padding_2;	/* rr_atime */
> +	__u64		ul_padding_3;	/* rr_ctime */
> +	__u64		ul_padding_4;	/* rr_size */
> +	__u64		ul_padding_5;	/* rr_blocks */
>  	__u32		ul_bias;
>  	__u32		ul_mode;
> -	__u32		ul_padding_6;   /* rr_flags */
> -	__u32		ul_padding_7;   /* rr_padding_2 */
> -	__u32		ul_padding_8;   /* rr_padding_3 */
> -	__u32		ul_padding_9;   /* rr_padding_4 */
> +	__u32		ul_padding_6;	/* rr_flags */
> +	__u32		ul_padding_7;	/* rr_padding_2 */
> +	__u32		ul_padding_8;	/* rr_padding_3 */
> +	__u32		ul_padding_9;	/* rr_padding_4 */
>  };
>  
>  /* instance of mdt_reint_rec */
> @@ -1777,19 +1777,19 @@ struct mdt_rec_rename {
>  	__u32		rn_suppgid1_h;
>  	__u32		rn_suppgid2;
>  	__u32		rn_suppgid2_h;
> -	struct lu_fid   rn_fid1;
> -	struct lu_fid   rn_fid2;
> +	struct lu_fid	rn_fid1;
> +	struct lu_fid	rn_fid2;
>  	__s64		rn_time;
> -	__u64		rn_padding_1;   /* rr_atime */
> -	__u64		rn_padding_2;   /* rr_ctime */
> -	__u64		rn_padding_3;   /* rr_size */
> -	__u64		rn_padding_4;   /* rr_blocks */
> +	__u64		rn_padding_1;	/* rr_atime */
> +	__u64		rn_padding_2;	/* rr_ctime */
> +	__u64		rn_padding_3;	/* rr_size */
> +	__u64		rn_padding_4;	/* rr_blocks */
>  	__u32		rn_bias;	/* some operation flags */
>  	__u32		rn_mode;	/* cross-ref rename has mode */
> -	__u32		rn_padding_5;   /* rr_flags */
> -	__u32		rn_padding_6;   /* rr_padding_2 */
> -	__u32		rn_padding_7;   /* rr_padding_3 */
> -	__u32		rn_padding_8;   /* rr_padding_4 */
> +	__u32		rn_padding_5;	/* rr_flags */
> +	__u32		rn_padding_6;	/* rr_padding_2 */
> +	__u32		rn_padding_7;	/* rr_padding_3 */
> +	__u32		rn_padding_8;	/* rr_padding_4 */
>  };
>  
>  /* instance of mdt_reint_rec */
> @@ -1804,21 +1804,21 @@ struct mdt_rec_setxattr {
>  	__u32		sx_suppgid1_h;
>  	__u32		sx_suppgid2;
>  	__u32		sx_suppgid2_h;
> -	struct lu_fid   sx_fid;
> -	__u64		sx_padding_1;   /* These three are rr_fid2 */
> +	struct lu_fid	sx_fid;
> +	__u64		sx_padding_1;	/* These three are rr_fid2 */
>  	__u32		sx_padding_2;
>  	__u32		sx_padding_3;
>  	__u64		sx_valid;
>  	__s64		sx_time;
> -	__u64		sx_padding_5;   /* rr_ctime */
> -	__u64		sx_padding_6;   /* rr_size */
> -	__u64		sx_padding_7;   /* rr_blocks */
> +	__u64		sx_padding_5;	/* rr_ctime */
> +	__u64		sx_padding_6;	/* rr_size */
> +	__u64		sx_padding_7;	/* rr_blocks */
>  	__u32		sx_size;
>  	__u32		sx_flags;
> -	__u32		sx_padding_8;   /* rr_flags */
> -	__u32		sx_padding_9;   /* rr_padding_2 */
> -	__u32		sx_padding_10;  /* rr_padding_3 */
> -	__u32		sx_padding_11;  /* rr_padding_4 */
> +	__u32		sx_padding_8;	/* rr_flags */
> +	__u32		sx_padding_9;	/* rr_padding_2 */
> +	__u32		sx_padding_10;	/* rr_padding_3 */
> +	__u32		sx_padding_11;	/* rr_padding_4 */
>  };
>  
>  /*
> @@ -1858,13 +1858,13 @@ struct mdt_rec_reint {
>  /* lmv structures */
>  struct lmv_desc {
>  	__u32 ld_tgt_count;		/* how many MDS's */
> -	__u32 ld_active_tgt_count;	 /* how many active */
> -	__u32 ld_default_stripe_count;     /* how many objects are used */
> -	__u32 ld_pattern;		  /* default hash pattern */
> +	__u32 ld_active_tgt_count;	/* how many active */
> +	__u32 ld_default_stripe_count;	/* how many objects are used */
> +	__u32 ld_pattern;		/* default hash pattern */
>  	__u64 ld_default_hash_size;
>  	__u64 ld_padding_1;		/* also fix lustre_swab_lmv_desc */
>  	__u32 ld_padding_2;		/* also fix lustre_swab_lmv_desc */
> -	__u32 ld_qos_maxage;		    /* in second */
> +	__u32 ld_qos_maxage;		/* in second */
>  	__u32 ld_padding_3;		/* also fix lustre_swab_lmv_desc */
>  	__u32 ld_padding_4;		/* also fix lustre_swab_lmv_desc */
>  	struct obd_uuid ld_uuid;
> @@ -2038,20 +2038,20 @@ struct lov_desc {
>  	struct obd_uuid ld_uuid;
>  };
>  
> -#define ld_magic ld_active_tgt_count       /* for swabbing from llogs */
> +#define ld_magic ld_active_tgt_count	/* for swabbing from llogs */
>  
>  /*
>   *   LDLM requests:
>   */
>  /* opcodes -- MUST be distinct from OST/MDS opcodes */
>  enum ldlm_cmd {
> -	LDLM_ENQUEUE     = 101,
> -	LDLM_CONVERT     = 102,
> -	LDLM_CANCEL      = 103,
> +	LDLM_ENQUEUE	 = 101,
> +	LDLM_CONVERT	 = 102,
> +	LDLM_CANCEL	 = 103,
>  	LDLM_BL_CALLBACK = 104,
>  	LDLM_CP_CALLBACK = 105,
>  	LDLM_GL_CALLBACK = 106,
> -	LDLM_SET_INFO    = 107,
> +	LDLM_SET_INFO	 = 107,
>  	LDLM_LAST_OPC
>  };
>  #define LDLM_FIRST_OPC LDLM_ENQUEUE
> @@ -2067,25 +2067,25 @@ struct ldlm_res_id {
>  
>  /* lock types */
>  enum ldlm_mode {
> -	LCK_MINMODE = 0,
> -	LCK_EX      = 1,
> -	LCK_PW      = 2,
> -	LCK_PR      = 4,
> -	LCK_CW      = 8,
> -	LCK_CR      = 16,
> -	LCK_NL      = 32,
> -	LCK_GROUP   = 64,
> -	LCK_COS     = 128,
> +	LCK_MINMODE	= 0,
> +	LCK_EX		= 1,
> +	LCK_PW		= 2,
> +	LCK_PR		= 4,
> +	LCK_CW		= 8,
> +	LCK_CR		= 16,
> +	LCK_NL		= 32,
> +	LCK_GROUP	= 64,
> +	LCK_COS		= 128,
>  	LCK_MAXMODE
>  };
>  
> -#define LCK_MODE_NUM    8
> +#define LCK_MODE_NUM	8
>  
>  enum ldlm_type {
> -	LDLM_PLAIN     = 10,
> -	LDLM_EXTENT    = 11,
> -	LDLM_FLOCK     = 12,
> -	LDLM_IBITS     = 13,
> +	LDLM_PLAIN	= 10,
> +	LDLM_EXTENT	= 11,
> +	LDLM_FLOCK	= 12,
> +	LDLM_IBITS	= 13,
>  	LDLM_MAX_TYPE
>  };
>  
> @@ -2150,7 +2150,7 @@ struct ldlm_intent {
>  
>  struct ldlm_resource_desc {
>  	enum ldlm_type lr_type;
> -	__u32 lr_padding;       /* also fix lustre_swab_ldlm_resource_desc */
> +	__u32 lr_padding;	/* also fix lustre_swab_ldlm_resource_desc */
>  	struct ldlm_res_id lr_name;
>  };
>  
> @@ -2173,7 +2173,7 @@ struct ldlm_request {
>  
>  struct ldlm_reply {
>  	__u32 lock_flags;
> -	__u32 lock_padding;     /* also fix lustre_swab_ldlm_reply */
> +	__u32 lock_padding;	/* also fix lustre_swab_ldlm_reply */
>  	struct ldlm_lock_desc lock_desc;
>  	struct lustre_handle lock_handle;
>  	__u64  lock_policy_res1;
> @@ -2206,9 +2206,9 @@ struct mgs_send_param {
>  };
>  
>  /* We pass this info to the MGS so it can write config logs */
> -#define MTI_NAME_MAXLEN  64
> +#define MTI_NAME_MAXLEN	 64
>  #define MTI_PARAM_MAXLEN 4096
> -#define MTI_NIDS_MAX     32
> +#define MTI_NIDS_MAX	 32
>  struct mgs_target_info {
>  	__u32		mti_lustre_ver;
>  	__u32		mti_stripe_index;
> @@ -2695,8 +2695,8 @@ enum sec_cmd {
>  /*
>   * capa related definitions
>   */
> -#define CAPA_HMAC_MAX_LEN       64
> -#define CAPA_HMAC_KEY_MAX_LEN   56
> +#define CAPA_HMAC_MAX_LEN	64
> +#define CAPA_HMAC_KEY_MAX_LEN	56
>  
>  /* NB take care when changing the sequence of elements this struct,
>   * because the offset info is used in find_capa()
> @@ -2716,34 +2716,34 @@ struct lustre_capa {
>  
>  /** lustre_capa::lc_opc */
>  enum {
> -	CAPA_OPC_BODY_WRITE   = 1 << 0,  /**< write object data */
> -	CAPA_OPC_BODY_READ    = 1 << 1,  /**< read object data */
> -	CAPA_OPC_INDEX_LOOKUP = 1 << 2,  /**< lookup object fid */
> -	CAPA_OPC_INDEX_INSERT = 1 << 3,  /**< insert object fid */
> -	CAPA_OPC_INDEX_DELETE = 1 << 4,  /**< delete object fid */
> -	CAPA_OPC_OSS_WRITE    = 1 << 5,  /**< write oss object data */
> -	CAPA_OPC_OSS_READ     = 1 << 6,  /**< read oss object data */
> -	CAPA_OPC_OSS_TRUNC    = 1 << 7,  /**< truncate oss object */
> -	CAPA_OPC_OSS_DESTROY  = 1 << 8,  /**< destroy oss object */
> -	CAPA_OPC_META_WRITE   = 1 << 9,  /**< write object meta data */
> -	CAPA_OPC_META_READ    = 1 << 10, /**< read object meta data */
> +	CAPA_OPC_BODY_WRITE	= 1 << 0,  /**< write object data */
> +	CAPA_OPC_BODY_READ	= 1 << 1,  /**< read object data */
> +	CAPA_OPC_INDEX_LOOKUP	= 1 << 2,  /**< lookup object fid */
> +	CAPA_OPC_INDEX_INSERT	= 1 << 3,  /**< insert object fid */
> +	CAPA_OPC_INDEX_DELETE	= 1 << 4,  /**< delete object fid */
> +	CAPA_OPC_OSS_WRITE	= 1 << 5,  /**< write oss object data */
> +	CAPA_OPC_OSS_READ	= 1 << 6,  /**< read oss object data */
> +	CAPA_OPC_OSS_TRUNC	= 1 << 7,  /**< truncate oss object */
> +	CAPA_OPC_OSS_DESTROY	= 1 << 8,  /**< destroy oss object */
> +	CAPA_OPC_META_WRITE	= 1 << 9,  /**< write object meta data */
> +	CAPA_OPC_META_READ	= 1 << 10, /**< read object meta data */
>  };
>  
>  #define CAPA_OPC_OSS_RW (CAPA_OPC_OSS_READ | CAPA_OPC_OSS_WRITE)
> -#define CAPA_OPC_MDS_ONLY						   \
> +#define CAPA_OPC_MDS_ONLY						\
>  	(CAPA_OPC_BODY_WRITE | CAPA_OPC_BODY_READ | CAPA_OPC_INDEX_LOOKUP | \
>  	 CAPA_OPC_INDEX_INSERT | CAPA_OPC_INDEX_DELETE)
> -#define CAPA_OPC_OSS_ONLY						   \
> -	(CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC |      \
> +#define CAPA_OPC_OSS_ONLY						\
> +	(CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC |	\
>  	 CAPA_OPC_OSS_DESTROY)
>  #define CAPA_OPC_MDS_DEFAULT ~CAPA_OPC_OSS_ONLY
>  #define CAPA_OPC_OSS_DEFAULT ~(CAPA_OPC_MDS_ONLY | CAPA_OPC_OSS_ONLY)
>  
>  struct lustre_capa_key {
> -	__u64   lk_seq;       /**< mds# */
> -	__u32   lk_keyid;     /**< key# */
> -	__u32   lk_padding;
> -	__u8    lk_key[CAPA_HMAC_KEY_MAX_LEN];    /**< key */
> +	__u64	lk_seq;				/**< mds# */
> +	__u32	lk_keyid;			/**< key# */
> +	__u32	lk_padding;
> +	__u8	lk_key[CAPA_HMAC_KEY_MAX_LEN];	/**< key */
>  } __packed;
>  
>  /** The link ea holds 1 \a link_ea_entry for each hardlink */
> @@ -2751,7 +2751,7 @@ struct lustre_capa_key {
>  struct link_ea_header {
>  	__u32 leh_magic;
>  	__u32 leh_reccount;
> -	__u64 leh_len;      /* total size */
> +	__u64 leh_len;		/* total size */
>  	__u32 leh_overflow_time;
>  	__u32 leh_padding;
>  };
> @@ -2787,13 +2787,13 @@ struct getparent {
>  } __packed;
>  
>  enum {
> -	LAYOUT_INTENT_ACCESS    = 0,	/** generic access */
> -	LAYOUT_INTENT_READ      = 1,	/** not used */
> -	LAYOUT_INTENT_WRITE     = 2,	/** write file, for comp layout */
> -	LAYOUT_INTENT_GLIMPSE   = 3,	/** not used */
> -	LAYOUT_INTENT_TRUNC     = 4,	/** truncate file, for comp layout */
> -	LAYOUT_INTENT_RELEASE   = 5,	/** reserved for HSM release */
> -	LAYOUT_INTENT_RESTORE   = 6	/** reserved for HSM restore */
> +	LAYOUT_INTENT_ACCESS	= 0,	/** generic access */
> +	LAYOUT_INTENT_READ	= 1,	/** not used */
> +	LAYOUT_INTENT_WRITE	= 2,	/** write file, for comp layout */
> +	LAYOUT_INTENT_GLIMPSE	= 3,	/** not used */
> +	LAYOUT_INTENT_TRUNC	= 4,	/** truncate file, for comp layout */
> +	LAYOUT_INTENT_RELEASE	= 5,	/** reserved for HSM release */
> +	LAYOUT_INTENT_RESTORE	= 6	/** reserved for HSM restore */
>  };
>  
>  /* enqueue layout lock with intent */
> diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
> index 178837cedd07..3b80b50543d8 100644
> --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
> +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h
> @@ -68,13 +68,13 @@
>   * are co-existing.
>   */
>  #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64)
> -typedef struct stat64   lstat_t;
> -#define lstat_f  lstat64
> +typedef struct stat64	lstat_t;
> +#define lstat_f		lstat64
>  #define fstat_f		fstat64
>  #define fstatat_f	fstatat64
>  #else
> -typedef struct stat     lstat_t;
> -#define lstat_f  lstat
> +typedef struct stat	lstat_t;
> +#define lstat_f		lstat
>  #define fstat_f		fstat
>  #define fstatat_f	fstatat
>  #endif
> @@ -87,47 +87,47 @@ typedef struct stat     lstat_t;
>  #define LL_SUPER_MAGIC 0x0BD00BD0
>  
>  #ifndef FSFILT_IOC_GETFLAGS
> -#define FSFILT_IOC_GETFLAGS	       _IOR('f', 1, long)
> -#define FSFILT_IOC_SETFLAGS	       _IOW('f', 2, long)
> -#define FSFILT_IOC_GETVERSION	     _IOR('f', 3, long)
> -#define FSFILT_IOC_SETVERSION	     _IOW('f', 4, long)
> -#define FSFILT_IOC_GETVERSION_OLD	 _IOR('v', 1, long)
> -#define FSFILT_IOC_SETVERSION_OLD	 _IOW('v', 2, long)
> +#define FSFILT_IOC_GETFLAGS		_IOR('f', 1, long)
> +#define FSFILT_IOC_SETFLAGS		_IOW('f', 2, long)
> +#define FSFILT_IOC_GETVERSION		_IOR('f', 3, long)
> +#define FSFILT_IOC_SETVERSION		_IOW('f', 4, long)
> +#define FSFILT_IOC_GETVERSION_OLD	_IOR('v', 1, long)
> +#define FSFILT_IOC_SETVERSION_OLD	_IOW('v', 2, long)
>  #endif
>  
>  /* FIEMAP flags supported by Lustre */
>  #define LUSTRE_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_DEVICE_ORDER)
>  
>  enum obd_statfs_state {
> -	OS_STATE_DEGRADED       = 0x00000001, /**< RAID degraded/rebuilding */
> -	OS_STATE_READONLY       = 0x00000002, /**< filesystem is read-only */
> -	OS_STATE_RDONLY_1       = 0x00000004, /**< obsolete 1.6, was EROFS=30 */
> -	OS_STATE_RDONLY_2       = 0x00000008, /**< obsolete 1.6, was EROFS=30 */
> -	OS_STATE_RDONLY_3       = 0x00000010, /**< obsolete 1.6, was EROFS=30 */
> +	OS_STATE_DEGRADED	= 0x00000001, /**< RAID degraded/rebuilding */
> +	OS_STATE_READONLY	= 0x00000002, /**< filesystem is read-only */
> +	OS_STATE_RDONLY_1	= 0x00000004, /**< obsolete 1.6, was EROFS=30 */
> +	OS_STATE_RDONLY_2	= 0x00000008, /**< obsolete 1.6, was EROFS=30 */
> +	OS_STATE_RDONLY_3	= 0x00000010, /**< obsolete 1.6, was EROFS=30 */
>  };
>  
>  struct obd_statfs {
> -	__u64	   os_type;
> -	__u64	   os_blocks;
> -	__u64	   os_bfree;
> -	__u64	   os_bavail;
> -	__u64	   os_files;
> -	__u64	   os_ffree;
> -	__u8	    os_fsid[40];
> -	__u32	   os_bsize;
> -	__u32	   os_namelen;
> -	__u64	   os_maxbytes;
> -	__u32	   os_state;       /**< obd_statfs_state OS_STATE_* flag */
> -	__u32	   os_fprecreated; /* objs available now to the caller */
> -				   /* used in QoS code to find preferred OSTs */
> -	__u32	   os_spare2;
> -	__u32	   os_spare3;
> -	__u32	   os_spare4;
> -	__u32	   os_spare5;
> -	__u32	   os_spare6;
> -	__u32	   os_spare7;
> -	__u32	   os_spare8;
> -	__u32	   os_spare9;
> +	__u64	os_type;
> +	__u64	os_blocks;
> +	__u64	os_bfree;
> +	__u64	os_bavail;
> +	__u64	os_files;
> +	__u64	os_ffree;
> +	__u8	os_fsid[40];
> +	__u32	os_bsize;
> +	__u32	os_namelen;
> +	__u64	os_maxbytes;
> +	__u32	os_state;	/**< obd_statfs_state OS_STATE_* flag */
> +	__u32	os_fprecreated;	/* objs available now to the caller
> +				 * used in QoS code to find preferred OSTs */
> +	__u32	os_spare2;
> +	__u32	os_spare3;
> +	__u32	os_spare4;
> +	__u32	os_spare5;
> +	__u32	os_spare6;
> +	__u32	os_spare7;
> +	__u32	os_spare8;
> +	__u32	os_spare9;
>  };
>  
>  /**
> @@ -137,12 +137,12 @@ struct obd_statfs {
>   * FIDs are never reused.
>   **/
>  struct lu_fid {
> -       /**
> -	* FID sequence. Sequence is a unit of migration: all files (objects)
> -	* with FIDs from a given sequence are stored on the same server.
> -	* Lustre should support 2^64 objects, so even if each sequence
> -	* has only a single object we can still enumerate 2^64 objects.
> -	**/
> +	/**
> +	 * FID sequence. Sequence is a unit of migration: all files (objects)
> +	 * with FIDs from a given sequence are stored on the same server.
> +	 * Lustre should support 2^64 objects, so even if each sequence
> +	 * has only a single object we can still enumerate 2^64 objects.
> +	 **/
>  	__u64 f_seq;
>  	/* FID number within sequence. */
>  	__u32 f_oid;
> @@ -237,33 +237,33 @@ struct ll_futimes_3 {
>   * *INFO    - set/get lov_user_mds_data
>   */
>  /*	lustre_ioctl.h			101-150 */
> -#define LL_IOC_GETFLAGS		 _IOR('f', 151, long)
> -#define LL_IOC_SETFLAGS		 _IOW('f', 152, long)
> -#define LL_IOC_CLRFLAGS		 _IOW('f', 153, long)
> -#define LL_IOC_LOV_SETSTRIPE	    _IOW('f', 154, long)
> +#define LL_IOC_GETFLAGS			_IOR('f', 151, long)
> +#define LL_IOC_SETFLAGS			_IOW('f', 152, long)
> +#define LL_IOC_CLRFLAGS			_IOW('f', 153, long)
> +#define LL_IOC_LOV_SETSTRIPE		_IOW('f', 154, long)
>  #define LL_IOC_LOV_SETSTRIPE_NEW	_IOWR('f', 154, struct lov_user_md)
> -#define LL_IOC_LOV_GETSTRIPE	    _IOW('f', 155, long)
> +#define LL_IOC_LOV_GETSTRIPE		_IOW('f', 155, long)
>  #define LL_IOC_LOV_GETSTRIPE_NEW	_IOR('f', 155, struct lov_user_md)
>  #define LL_IOC_LOV_SETEA		_IOW('f', 156, long)
>  /*	LL_IOC_RECREATE_OBJ		157 obsolete */
>  /*	LL_IOC_RECREATE_FID		158 obsolete */
> -#define LL_IOC_GROUP_LOCK	       _IOW('f', 158, long)
> -#define LL_IOC_GROUP_UNLOCK	     _IOW('f', 159, long)
> +#define LL_IOC_GROUP_LOCK		_IOW('f', 158, long)
> +#define LL_IOC_GROUP_UNLOCK		_IOW('f', 159, long)
>  /* #define LL_IOC_QUOTACHECK		160 OBD_IOC_QUOTACHECK */
>  /* #define LL_IOC_POLL_QUOTACHECK	161 OBD_IOC_POLL_QUOTACHECK */
>  /* #define LL_IOC_QUOTACTL		162 OBD_IOC_QUOTACTL */
> -#define IOC_OBD_STATFS		  _IOWR('f', 164, struct obd_statfs *)
> +#define IOC_OBD_STATFS			_IOWR('f', 164, struct obd_statfs *)
>  /*	IOC_LOV_GETINFO			165 obsolete */
> -#define LL_IOC_FLUSHCTX		 _IOW('f', 166, long)
> +#define LL_IOC_FLUSHCTX			_IOW('f', 166, long)
>  /* LL_IOC_RMTACL			167 obsolete */
> -#define LL_IOC_GETOBDCOUNT	      _IOR('f', 168, long)
> -#define LL_IOC_LLOOP_ATTACH	     _IOWR('f', 169, long)
> -#define LL_IOC_LLOOP_DETACH	     _IOWR('f', 170, long)
> -#define LL_IOC_LLOOP_INFO	       _IOWR('f', 171, struct lu_fid)
> -#define LL_IOC_LLOOP_DETACH_BYDEV       _IOWR('f', 172, long)
> -#define LL_IOC_PATH2FID		 _IOR('f', 173, long)
> +#define LL_IOC_GETOBDCOUNT		_IOR('f', 168, long)
> +#define LL_IOC_LLOOP_ATTACH		_IOWR('f', 169, long)
> +#define LL_IOC_LLOOP_DETACH		_IOWR('f', 170, long)
> +#define LL_IOC_LLOOP_INFO		_IOWR('f', 171, struct lu_fid)
> +#define LL_IOC_LLOOP_DETACH_BYDEV	_IOWR('f', 172, long)
> +#define LL_IOC_PATH2FID			_IOR('f', 173, long)
>  #define LL_IOC_GET_CONNECT_FLAGS	_IOWR('f', 174, __u64 *)
> -#define LL_IOC_GET_MDTIDX	       _IOR('f', 175, int)
> +#define LL_IOC_GET_MDTIDX		_IOR('f', 175, int)
>  #define LL_IOC_FUTIMES_3		_IOWR('f', 176, struct ll_futimes_3)
>  
>  /*	lustre_ioctl.h			177-210 */
> @@ -281,8 +281,8 @@ struct ll_futimes_3 {
>  						struct hsm_current_action)
>  /* see <lustre_lib.h> for ioctl numbers 221-232 */
>  
> -#define LL_IOC_LMV_SETSTRIPE	    _IOWR('f', 240, struct lmv_user_md)
> -#define LL_IOC_LMV_GETSTRIPE	    _IOWR('f', 241, struct lmv_user_md)
> +#define LL_IOC_LMV_SETSTRIPE		_IOWR('f', 240, struct lmv_user_md)
> +#define LL_IOC_LMV_GETSTRIPE		_IOWR('f', 241, struct lmv_user_md)
>  #define LL_IOC_SET_LEASE		_IOWR('f', 243, long)
>  #define LL_IOC_GET_LEASE		_IO('f', 244)
>  #define LL_IOC_HSM_IMPORT		_IOWR('f', 245, struct hsm_user_import)
> @@ -299,15 +299,15 @@ enum ll_lease_type {
>  	LL_LEASE_UNLCK	= 0x4,
>  };
>  
> -#define LL_STATFS_LMV	   1
> -#define LL_STATFS_LOV	   2
> +#define LL_STATFS_LMV		1
> +#define LL_STATFS_LOV		2
>  #define LL_STATFS_NODELAY	4
>  
> -#define IOC_MDC_TYPE	    'i'
> -#define IOC_MDC_LOOKUP	  _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
> -#define IOC_MDC_GETFILESTRIPE   _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *)
> -#define IOC_MDC_GETFILEINFO     _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *)
> -#define LL_IOC_MDC_GETINFO      _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *)
> +#define IOC_MDC_TYPE		'i'
> +#define IOC_MDC_LOOKUP		_IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
> +#define IOC_MDC_GETFILESTRIPE	_IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *)
> +#define IOC_MDC_GETFILEINFO	_IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *)
> +#define LL_IOC_MDC_GETINFO	_IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *)
>  
>  #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */
>  
> @@ -318,12 +318,12 @@ enum ll_lease_type {
>   */
>  #define O_LOV_DELAY_CREATE	(O_NOCTTY | FASYNC)
>  
> -#define LL_FILE_IGNORE_LOCK     0x00000001
> -#define LL_FILE_GROUP_LOCKED    0x00000002
> +#define LL_FILE_IGNORE_LOCK	0x00000001
> +#define LL_FILE_GROUP_LOCKED	0x00000002
>  #define LL_FILE_READAHEA	0x00000004
>  #define LL_FILE_LOCKED_DIRECTIO 0x00000008 /* client-side locks with dio */
> -#define LL_FILE_LOCKLESS_IO     0x00000010 /* server-side locks with cio */
> -#define LL_FILE_RMTACL	  0x00000020
> +#define LL_FILE_LOCKLESS_IO	0x00000010 /* server-side locks with cio */
> +#define LL_FILE_RMTACL		0x00000020
>  
>  #define LOV_USER_MAGIC_V1	0x0BD10BD0
>  #define LOV_USER_MAGIC		LOV_USER_MAGIC_V1
> @@ -333,7 +333,7 @@ enum ll_lease_type {
>  #define LOV_USER_MAGIC_SPECIFIC	0x0BD50BD0	/* for specific OSTs */
>  #define LOV_USER_MAGIC_COMP_V1	0x0BD60BD0
>  
> -#define LMV_USER_MAGIC    0x0CD30CD0    /*default lmv magic*/
> +#define LMV_USER_MAGIC		0x0CD30CD0	/*default lmv magic*/
>  
>  #define LOV_PATTERN_RAID0	0x001
>  #define LOV_PATTERN_RAID1	0x002
> @@ -347,8 +347,8 @@ enum ll_lease_type {
>  #define LOV_MAXPOOLNAME 15
>  #define LOV_POOLNAMEF "%.15s"
>  
> -#define LOV_MIN_STRIPE_BITS 16   /* maximum PAGE_SIZE (ia64), power of 2 */
> -#define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS)
> +#define LOV_MIN_STRIPE_BITS	16	/* maximum PAGE_SIZE (ia64), power of 2 */
> +#define LOV_MIN_STRIPE_SIZE	(1 << LOV_MIN_STRIPE_BITS)
>  #define LOV_MAX_STRIPE_COUNT_OLD 160
>  /* This calculation is crafted so that input of 4096 will result in 160
>   * which in turn is equal to old maximal stripe count.
> @@ -360,49 +360,49 @@ enum ll_lease_type {
>   *
>   * (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1)
>   */
> -#define LOV_MAX_STRIPE_COUNT 2000  /* ((12 * 4096 - 256) / 24) */
> -#define LOV_ALL_STRIPES       0xffff /* only valid for directories */
> +#define LOV_MAX_STRIPE_COUNT	2000  /* ((12 * 4096 - 256) / 24) */
> +#define LOV_ALL_STRIPES		0xffff /* only valid for directories */
>  #define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */
>  
>  #define XATTR_LUSTRE_PREFIX	"lustre."
>  #define XATTR_LUSTRE_LOV	"lustre.lov"
>  
>  #define lov_user_ost_data lov_user_ost_data_v1
> -struct lov_user_ost_data_v1 {     /* per-stripe data structure */
> -	struct ost_id l_ost_oi;	  /* OST object ID */
> -	__u32 l_ost_gen;	  /* generation of this OST index */
> -	__u32 l_ost_idx;	  /* OST index in LOV */
> +struct lov_user_ost_data_v1 {	/* per-stripe data structure */
> +	struct ost_id l_ost_oi;	/* OST object ID */
> +	__u32 l_ost_gen;	/* generation of this OST index */
> +	__u32 l_ost_idx;	/* OST index in LOV */
>  } __packed;
>  
>  #define lov_user_md lov_user_md_v1
> -struct lov_user_md_v1 {	   /* LOV EA user data (host-endian) */
> -	__u32 lmm_magic;	  /* magic number = LOV_USER_MAGIC_V1 */
> +struct lov_user_md_v1 {		/* LOV EA user data (host-endian) */
> +	__u32 lmm_magic;	/* magic number = LOV_USER_MAGIC_V1 */
>  	__u32 lmm_pattern;	/* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
> -	struct ost_id lmm_oi;	  /* LOV object ID */
> -	__u32 lmm_stripe_size;    /* size of stripe in bytes */
> -	__u16 lmm_stripe_count;   /* num stripes in use for this object */
> +	struct ost_id lmm_oi;	/* LOV object ID */
> +	__u32 lmm_stripe_size;	/* size of stripe in bytes */
> +	__u16 lmm_stripe_count;	/* num stripes in use for this object */
>  	union {
>  		__u16 lmm_stripe_offset;  /* starting stripe offset in
>  					   * lmm_objects, use when writing
>  					   */
> -		__u16 lmm_layout_gen;     /* layout generation number
> +		__u16 lmm_layout_gen;	  /* layout generation number
>  					   * used when reading
>  					   */
>  	};
>  	struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
>  } __attribute__((packed,  __may_alias__));
>  
> -struct lov_user_md_v3 {	   /* LOV EA user data (host-endian) */
> -	__u32 lmm_magic;	  /* magic number = LOV_USER_MAGIC_V3 */
> +struct lov_user_md_v3 {		/* LOV EA user data (host-endian) */
> +	__u32 lmm_magic;	/* magic number = LOV_USER_MAGIC_V3 */
>  	__u32 lmm_pattern;	/* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
> -	struct ost_id lmm_oi;	  /* LOV object ID */
> -	__u32 lmm_stripe_size;    /* size of stripe in bytes */
> -	__u16 lmm_stripe_count;   /* num stripes in use for this object */
> +	struct ost_id lmm_oi;	/* LOV object ID */
> +	__u32 lmm_stripe_size;	/* size of stripe in bytes */
> +	__u16 lmm_stripe_count;	/* num stripes in use for this object */
>  	union {
>  		__u16 lmm_stripe_offset;  /* starting stripe offset in
>  					   * lmm_objects, use when writing
>  					   */
> -		__u16 lmm_layout_gen;     /* layout generation number
> +		__u16 lmm_layout_gen;	  /* layout generation number
>  					   * used when reading
>  					   */
>  	};
> @@ -425,9 +425,9 @@ static inline bool lu_extent_is_overlapped(struct lu_extent *e1,
>  }
>  
>  enum lov_comp_md_entry_flags {
> -	LCME_FL_PRIMARY		= 0x00000001,   /* Not used */
> -	LCME_FL_STALE		= 0x00000002,   /* Not used */
> -	LCME_FL_OFFLINE		= 0x00000004,   /* Not used */
> +	LCME_FL_PRIMARY		= 0x00000001,	/* Not used */
> +	LCME_FL_STALE		= 0x00000002,	/* Not used */
> +	LCME_FL_OFFLINE		= 0x00000004,	/* Not used */
>  	LCME_FL_PREFERRED	= 0x00000008,	/* Not used */
>  	LCME_FL_INIT		= 0x00000010,	/* instantiated */
>  	LCME_FL_NEG		= 0x80000000,	/* used to indicate a negative
> @@ -480,7 +480,7 @@ static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
>  		return sizeof(struct lov_user_md_v1) +
>  				stripes * sizeof(struct lov_user_ost_data_v1);
>  	return sizeof(struct lov_user_md_v3) +
> -	       stripes * sizeof(struct lov_user_ost_data_v1);
> +		stripes * sizeof(struct lov_user_ost_data_v1);
>  }
>  
>  /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
> @@ -524,16 +524,16 @@ enum lmv_hash_type {
>  #define LMV_MAX_STRIPE_COUNT 2000  /* ((12 * 4096 - 256) / 24) */
>  #define lmv_user_md lmv_user_md_v1
>  struct lmv_user_md_v1 {
> -	__u32	lum_magic;	 /* must be the first field */
> -	__u32	lum_stripe_count;  /* dirstripe count */
> -	__u32	lum_stripe_offset; /* MDT idx for default dirstripe */
> -	__u32	lum_hash_type;     /* Dir stripe policy */
> -	__u32	lum_type;	  /* LMV type: default or normal */
> +	__u32	lum_magic;		/* must be the first field */
> +	__u32	lum_stripe_count;	/* dirstripe count */
> +	__u32	lum_stripe_offset;	/* MDT idx for default dirstripe */
> +	__u32	lum_hash_type;		/* Dir stripe policy */
> +	__u32	lum_type;		/* LMV type: default or normal */
>  	__u32	lum_padding1;
>  	__u32	lum_padding2;
>  	__u32	lum_padding3;
>  	char	lum_pool_name[LOV_MAXPOOLNAME + 1];
> -	struct	lmv_user_mds_data  lum_objects[0];
> +	struct lmv_user_mds_data  lum_objects[0];
>  } __packed;
>  
>  static inline int lmv_user_md_size(int stripes, int lmm_magic)
> @@ -548,11 +548,11 @@ struct ll_recreate_obj {
>  };
>  
>  struct ll_fid {
> -	__u64 id;	 /* holds object id */
> -	__u32 generation; /* holds object generation */
> -	__u32 f_type;     /* holds object type or stripe idx when passing it to
> -			   * OST for saving into EA.
> -			   */
> +	__u64 id;		/* holds object id */
> +	__u32 generation;	/* holds object generation */
> +	__u32 f_type;		/* holds object type or stripe idx when
> +				 * passing it to OST for saving into EA.
> +				 */
>  };
>  
>  #define UUID_MAX	40
> @@ -631,22 +631,22 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen)
>  
>  /********* Quotas **********/
>  
> -#define Q_QUOTACHECK   0x800100 /* deprecated as of 2.4 */
> -#define Q_INITQUOTA    0x800101 /* deprecated as of 2.4  */
> -#define Q_GETOINFO     0x800102 /* get obd quota info */
> -#define Q_GETOQUOTA    0x800103 /* get obd quotas */
> -#define Q_FINVALIDATE  0x800104 /* deprecated as of 2.4 */
> +#define Q_QUOTACHECK	0x800100 /* deprecated as of 2.4 */
> +#define Q_INITQUOTA	0x800101 /* deprecated as of 2.4  */
> +#define Q_GETOINFO	0x800102 /* get obd quota info */
> +#define Q_GETOQUOTA	0x800103 /* get obd quotas */
> +#define Q_FINVALIDATE	0x800104 /* deprecated as of 2.4 */
>  
>  /* these must be explicitly translated into linux Q_* in ll_dir_ioctl */
> -#define LUSTRE_Q_QUOTAON    0x800002	/* deprecated as of 2.4 */
> -#define LUSTRE_Q_QUOTAOFF   0x800003	/* deprecated as of 2.4 */
> -#define LUSTRE_Q_GETINFO    0x800005     /* get information about quota files */
> -#define LUSTRE_Q_SETINFO    0x800006     /* set information about quota files */
> -#define LUSTRE_Q_GETQUOTA   0x800007     /* get user quota structure */
> -#define LUSTRE_Q_SETQUOTA   0x800008     /* set user quota structure */
> +#define LUSTRE_Q_QUOTAON	0x800002	/* deprecated as of 2.4 */
> +#define LUSTRE_Q_QUOTAOFF	0x800003	/* deprecated as of 2.4 */
> +#define LUSTRE_Q_GETINFO	0x800005	/* get information about quota files */
> +#define LUSTRE_Q_SETINFO	0x800006	/* set information about quota files */
> +#define LUSTRE_Q_GETQUOTA	0x800007	/* get user quota structure */
> +#define LUSTRE_Q_SETQUOTA	0x800008	/* set user quota structure */
>  /* lustre-specific control commands */
> -#define LUSTRE_Q_INVALIDATE  0x80000b	/* deprecated as of 2.4 */
> -#define LUSTRE_Q_FINVALIDATE 0x80000c	/* deprecated as of 2.4 */
> +#define LUSTRE_Q_INVALIDATE	0x80000b	/* deprecated as of 2.4 */
> +#define LUSTRE_Q_FINVALIDATE	0x80000c	/* deprecated as of 2.4 */
>  
>  #define ALLQUOTA 255	/* set all quota */
>  
> @@ -666,7 +666,7 @@ static inline char *qtype_name(int qtype)
>  #define IDENTITY_DOWNCALL_MAGIC 0x6d6dd629
>  
>  /* permission */
> -#define N_PERMS_MAX      64
> +#define N_PERMS_MAX	64
>  
>  struct perm_downcall_data {
>  	__u64 pdd_nid;
> @@ -720,23 +720,23 @@ struct obd_dqblk {
>  };
>  
>  enum {
> -	QC_GENERAL      = 0,
> -	QC_MDTIDX       = 1,
> -	QC_OSTIDX       = 2,
> -	QC_UUID	 = 3
> +	QC_GENERAL	= 0,
> +	QC_MDTIDX	= 1,
> +	QC_OSTIDX	= 2,
> +	QC_UUID		= 3
>  };
>  
>  struct if_quotactl {
> -	__u32		   qc_cmd;
> -	__u32		   qc_type;
> -	__u32		   qc_id;
> -	__u32		   qc_stat;
> -	__u32		   qc_valid;
> -	__u32		   qc_idx;
> -	struct obd_dqinfo       qc_dqinfo;
> -	struct obd_dqblk	qc_dqblk;
> -	char		    obd_type[16];
> -	struct obd_uuid	 obd_uuid;
> +	__u32		  qc_cmd;
> +	__u32		  qc_type;
> +	__u32		  qc_id;
> +	__u32		  qc_stat;
> +	__u32		  qc_valid;
> +	__u32		  qc_idx;
> +	struct obd_dqinfo qc_dqinfo;
> +	struct obd_dqblk  qc_dqblk;
> +	char		  obd_type[16];
> +	struct obd_uuid	  obd_uuid;
>  };
>  
>  /* swap layout flags */
> @@ -759,26 +759,26 @@ struct lustre_swap_layouts {
>  /********* Changelogs **********/
>  /** Changelog record types */
>  enum changelog_rec_type {
> -	CL_MARK     = 0,
> -	CL_CREATE   = 1,  /* namespace */
> -	CL_MKDIR    = 2,  /* namespace */
> -	CL_HARDLINK = 3,  /* namespace */
> -	CL_SOFTLINK = 4,  /* namespace */
> -	CL_MKNOD    = 5,  /* namespace */
> -	CL_UNLINK   = 6,  /* namespace */
> -	CL_RMDIR    = 7,  /* namespace */
> -	CL_RENAME   = 8,  /* namespace */
> -	CL_EXT      = 9,  /* namespace extended record (2nd half of rename) */
> -	CL_OPEN     = 10, /* not currently used */
> -	CL_CLOSE    = 11, /* may be written to log only with mtime change */
> -	CL_LAYOUT   = 12, /* file layout/striping modified */
> -	CL_TRUNC    = 13,
> -	CL_SETATTR  = 14,
> -	CL_XATTR    = 15,
> -	CL_HSM      = 16, /* HSM specific events, see flags */
> -	CL_MTIME    = 17, /* Precedence: setattr > mtime > ctime > atime */
> -	CL_CTIME    = 18,
> -	CL_ATIME    = 19,
> +	CL_MARK		= 0,
> +	CL_CREATE	= 1,  /* namespace */
> +	CL_MKDIR	= 2,  /* namespace */
> +	CL_HARDLINK	= 3,  /* namespace */
> +	CL_SOFTLINK	= 4,  /* namespace */
> +	CL_MKNOD	= 5,  /* namespace */
> +	CL_UNLINK	= 6,  /* namespace */
> +	CL_RMDIR	= 7,  /* namespace */
> +	CL_RENAME	= 8,  /* namespace */
> +	CL_EXT		= 9,  /* namespace extended record (2nd half of rename) */
> +	CL_OPEN		= 10, /* not currently used */
> +	CL_CLOSE	= 11, /* may be written to log only with mtime change */
> +	CL_LAYOUT	= 12, /* file layout/striping modified */
> +	CL_TRUNC	= 13,
> +	CL_SETATTR	= 14,
> +	CL_XATTR	= 15,
> +	CL_HSM		= 16, /* HSM specific events, see flags */
> +	CL_MTIME	= 17, /* Precedence: setattr > mtime > ctime > atime */
> +	CL_CTIME	= 18,
> +	CL_ATIME	= 19,
>  	CL_LAST
>  };
>  
> @@ -808,9 +808,9 @@ enum changelog_rec_flags {
>  
>  /* Anything under the flagmask may be per-type (if desired) */
>  /* Flags for unlink */
> -#define CLF_UNLINK_LAST       0x0001 /* Unlink of last hardlink */
> -#define CLF_UNLINK_HSM_EXISTS 0x0002 /* File has something in HSM */
> -				     /* HSM cleaning needed */
> +#define CLF_UNLINK_LAST		0x0001 /* Unlink of last hardlink */
> +#define CLF_UNLINK_HSM_EXISTS	0x0002 /* File has something in HSM
> +					* HSM cleaning needed */
>  /* Flags for rename */
>  #define CLF_RENAME_LAST		0x0001	/* rename unlink last hardlink of
>  					 * target
> @@ -827,12 +827,12 @@ enum changelog_rec_flags {
>   */
>  #define CLF_HSM_ERR_L	0 /* HSM return code, 7 bits */
>  #define CLF_HSM_ERR_H	6
> -#define CLF_HSM_EVENT_L      7 /* HSM event, 3 bits, see enum hsm_event */
> -#define CLF_HSM_EVENT_H      9
> -#define CLF_HSM_FLAG_L      10 /* HSM flags, 2 bits, 1 used, 1 spare */
> -#define CLF_HSM_FLAG_H      11
> -#define CLF_HSM_SPARE_L     12 /* 4 spare bits */
> -#define CLF_HSM_SPARE_H     15
> +#define CLF_HSM_EVENT_L	7 /* HSM event, 3 bits, see enum hsm_event */
> +#define CLF_HSM_EVENT_H	9
> +#define CLF_HSM_FLAG_L	10 /* HSM flags, 2 bits, 1 used, 1 spare */
> +#define CLF_HSM_FLAG_H	11
> +#define CLF_HSM_SPARE_L	12 /* 4 spare bits */
> +#define CLF_HSM_SPARE_H	15
>  #define CLF_HSM_LAST	15
>  
>  /* Remove bits higher than _h, then extract the value
> @@ -841,22 +841,22 @@ enum changelog_rec_flags {
>  #define CLF_GET_BITS(_b, _h, _l) (((_b << (CLF_HSM_LAST - _h)) & 0xFFFF) \
>  				   >> (CLF_HSM_LAST - _h + _l))
>  
> -#define CLF_HSM_SUCCESS      0x00
> -#define CLF_HSM_MAXERROR     0x7E
> -#define CLF_HSM_ERROVERFLOW  0x7F
> +#define CLF_HSM_SUCCESS		0x00
> +#define CLF_HSM_MAXERROR	0x7E
> +#define CLF_HSM_ERROVERFLOW	0x7F
>  
>  #define CLF_HSM_DIRTY	1 /* file is dirty after HSM request end */
>  
>  /* 3 bits field => 8 values allowed */
>  enum hsm_event {
> -	HE_ARCHIVE      = 0,
> -	HE_RESTORE      = 1,
> -	HE_CANCEL       = 2,
> -	HE_RELEASE      = 3,
> -	HE_REMOVE       = 4,
> +	HE_ARCHIVE	= 0,
> +	HE_RESTORE	= 1,
> +	HE_CANCEL	= 2,
> +	HE_RELEASE	= 3,
> +	HE_REMOVE	= 4,
>  	HE_STATE	= 5,
> -	HE_SPARE1       = 6,
> -	HE_SPARE2       = 7,
> +	HE_SPARE1	= 6,
> +	HE_SPARE2	= 7,
>  };
>  
>  static inline enum hsm_event hsm_get_cl_event(__u16 flags)
> @@ -1070,14 +1070,14 @@ enum changelog_message_type {
>  
>  struct ioc_data_version {
>  	__u64 idv_version;
> -	__u64 idv_flags;     /* See LL_DV_xxx */
> +	__u64 idv_flags;	/* See LL_DV_xxx */
>  };
>  
>  #define LL_DV_RD_FLUSH	(1 << 0) /* Flush dirty pages from clients */
>  #define LL_DV_WR_FLUSH	(1 << 1) /* Flush all caching pages from clients */
>  
>  #ifndef offsetof
> -# define offsetof(typ, memb)     ((unsigned long)((char *)&(((typ *)0)->memb)))
> +# define offsetof(typ, memb)	((unsigned long)((char *)&(((typ *)0)->memb)))
>  #endif
>  
>  #define dot_lustre_name ".lustre"
> @@ -1284,14 +1284,14 @@ static inline const char *hsm_copytool_action2name(enum hsm_copytool_action  a)
>  
>  /* Copytool item action description */
>  struct hsm_action_item {
> -	__u32      hai_len;     /* valid size of this struct */
> -	__u32      hai_action;  /* hsm_copytool_action, but use known size */
> -	struct lu_fid hai_fid;     /* Lustre FID to operated on */
> -	struct lu_fid hai_dfid;    /* fid used for data access */
> +	__u32		hai_len;     /* valid size of this struct */
> +	__u32		hai_action;  /* hsm_copytool_action, but use known size */
> +	struct lu_fid	hai_fid;     /* Lustre FID to operated on */
> +	struct lu_fid	hai_dfid;    /* fid used for data access */
>  	struct hsm_extent hai_extent;  /* byte range to operate on */
> -	__u64      hai_cookie;  /* action cookie from coordinator */
> -	__u64      hai_gid;     /* grouplock id */
> -	char       hai_data[0]; /* variable length */
> +	__u64		hai_cookie;  /* action cookie from coordinator */
> +	__u64		hai_gid;     /* grouplock id */
> +	char		hai_data[0]; /* variable length */
>  } __packed;
>  
>  /*
> @@ -1326,12 +1326,12 @@ static inline char *hai_dump_data_field(struct hsm_action_item *hai,
>  #define HAL_MAXSIZE LNET_MTU /* bytes, used in userspace only */
>  struct hsm_action_list {
>  	__u32 hal_version;
> -	__u32 hal_count;       /* number of hai's to follow */
> -	__u64 hal_compound_id; /* returned by coordinator */
> +	__u32 hal_count;	/* number of hai's to follow */
> +	__u64 hal_compound_id;	/* returned by coordinator */
>  	__u64 hal_flags;
> -	__u32 hal_archive_id; /* which archive backend */
> +	__u32 hal_archive_id;	/* which archive backend */
>  	__u32 padding1;
> -	char  hal_fsname[0];   /* null-terminated */
> +	char  hal_fsname[0];	/* null-terminated */
>  	/* struct hsm_action_item[hal_count] follows, aligned on 8-byte
>  	 * boundaries. See hai_first
>  	 */
> @@ -1384,8 +1384,8 @@ struct hsm_user_import {
>  };
>  
>  /* Copytool progress reporting */
> -#define HP_FLAG_COMPLETED 0x01
> -#define HP_FLAG_RETRY     0x02
> +#define HP_FLAG_COMPLETED	0x01
> +#define HP_FLAG_RETRY		0x02
>  
>  struct hsm_progress {
>  	struct lu_fid		hp_fid;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> index 2bf12284bf43..92427254d74c 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> @@ -74,25 +74,25 @@
>  #define IBLND_N_SCHED_HIGH		4
>  
>  struct kib_tunables {
> -	int *kib_dev_failover;           /* HCA failover */
> -	unsigned int *kib_service;       /* IB service number */
> +	int *kib_dev_failover;		/* HCA failover */
> +	unsigned int *kib_service;	/* IB service number */
>  	int *kib_min_reconnect_interval; /* first failed connection retry... */
>  	int *kib_max_reconnect_interval; /* exponentially increasing to this */
> -	int *kib_cksum;                  /* checksum struct kib_msg? */
> -	int *kib_timeout;                /* comms timeout (seconds) */
> -	int *kib_keepalive;              /* keepalive timeout (seconds) */
> -	int *kib_ntx;                    /* # tx descs */
> -	char **kib_default_ipif;         /* default IPoIB interface */
> +	int *kib_cksum;			/* checksum struct kib_msg? */
> +	int *kib_timeout;		/* comms timeout (seconds) */
> +	int *kib_keepalive;		/* keepalive timeout (seconds) */
> +	int *kib_ntx;			/* # tx descs */
> +	char **kib_default_ipif;	/* default IPoIB interface */
>  	int *kib_retry_count;
>  	int *kib_rnr_retry_count;
> -	int *kib_ib_mtu;                 /* IB MTU */
> -	int *kib_require_priv_port;      /* accept only privileged ports */
> -	int *kib_use_priv_port; /* use privileged port for active connect */
> -	int *kib_nscheds;                /* # threads on each CPT */
> -	int *kib_wrq_sge;		 /* # sg elements per wrq */
> -	bool *kib_use_fastreg_gaps;	 /* enable discontiguous fastreg
> -					  * fragment support
> -					  */
> +	int *kib_ib_mtu;		/* IB MTU */
> +	int *kib_require_priv_port;	/* accept only privileged ports */
> +	int *kib_use_priv_port;		/* use privileged port for active connect */
> +	int *kib_nscheds;		/* # threads on each CPT */
> +	int *kib_wrq_sge;		/* # sg elements per wrq */
> +	bool *kib_use_fastreg_gaps;	/* enable discontiguous fastreg
> +					 * fragment support
> +					 */
>  };
>  
>  extern struct kib_tunables  kiblnd_tunables;
> @@ -164,11 +164,11 @@ struct kib_dev {
>  	int			ibd_nnets;	/* # nets extant */
>  
>  	time64_t		ibd_next_failover;
> -	int			ibd_failed_failover; /* # failover failures */
> -	unsigned int		ibd_failover;        /* failover in progress */
> -	unsigned int		ibd_can_failover;    /* IPoIB interface is a
> -						      * bonding master
> -						      */
> +	int			ibd_failed_failover;	/* # failover failures */
> +	unsigned int		ibd_failover;		/* failover in progress */
> +	unsigned int		ibd_can_failover;	/* IPoIB interface is a
> +							 * bonding master
> +							 */
>  	struct list_head	ibd_nets;
>  	struct kib_hca_dev	*ibd_hdev;
>  	enum kib_dev_caps	ibd_dev_caps;
> @@ -330,8 +330,8 @@ struct kib_sched_info {
>  
>  struct kib_data {
>  	int			kib_init;	    /* initialisation state */
> -	int			kib_shutdown;       /* shut down? */
> -	struct list_head	kib_devs;           /* IB devices extant */
> +	int			kib_shutdown;	    /* shut down? */
> +	struct list_head	kib_devs;	    /* IB devices extant */
>  	struct list_head	kib_failed_devs;    /* list head of failed devices */
>  	wait_queue_head_t	kib_failover_waitq; /* schedulers sleep here */
>  	atomic_t		kib_nthreads;	    /* # live threads */
> @@ -540,7 +540,7 @@ struct kib_conn {
>  	int			ibc_state;	/* what's happening */
>  	int			ibc_nsends_posted;	/* # uncompleted sends */
>  	int			ibc_noops_posted;	/* # uncompleted NOOPs */
> -	int			ibc_credits;     /* # credits I have */
> +	int			ibc_credits;		/* # credits I have */
>  	int			ibc_outstanding_credits; /* # credits to return */
>  	int			ibc_reserved_credits; /* # ACK/DONE msg credits */
>  	int			ibc_comms_error; /* set on comms error */
> @@ -581,13 +581,13 @@ struct kib_conn {
>  #define IBLND_CONN_DISCONNECTED		5	 /* disconnected */
>  
>  struct kib_peer_ni {
> -	struct list_head	ibp_list;        /* stash on global peer_ni list */
> -	lnet_nid_t		ibp_nid;         /* who's on the other end(s) */
> -	struct lnet_ni		*ibp_ni;         /* LNet interface */
> -	struct list_head	ibp_conns;       /* all active connections */
> -	struct kib_conn		*ibp_next_conn;  /* next connection to send on for
> -						  * round robin */
> -	struct list_head	ibp_tx_queue;	 /* msgs waiting for a conn */
> +	struct list_head	ibp_list;	/* stash on global peer_ni list */
> +	lnet_nid_t		ibp_nid;	/* who's on the other end(s) */
> +	struct lnet_ni		*ibp_ni;	/* LNet interface */
> +	struct list_head	ibp_conns;	/* all active connections */
> +	struct kib_conn		*ibp_next_conn; /* next connection to send on for
> +						 * round robin */
> +	struct list_head	ibp_tx_queue;	/* msgs waiting for a conn */
>  	u64			ibp_incarnation; /* incarnation of peer_ni */
>  	/* when (in seconds) I was last alive */
>  	time64_t		ibp_last_alive;
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
> index ce1f9e78b4d9..add2744c9d8d 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
> @@ -54,15 +54,15 @@
>  #define SOCKNAL_NSCHEDS		3
>  #define SOCKNAL_NSCHEDS_HIGH	(SOCKNAL_NSCHEDS << 1)
>  
> -#define SOCKNAL_PEER_HASH_SIZE  101   /* # peer_ni lists */
> -#define SOCKNAL_RESCHED         100   /* # scheduler loops before reschedule */
> -#define SOCKNAL_INSANITY_RECONN 5000  /* connd is trying on reconn infinitely */
> -#define SOCKNAL_ENOMEM_RETRY    1     /* seconds between retries */
> +#define SOCKNAL_PEER_HASH_SIZE	101   /* # peer_ni lists */
> +#define SOCKNAL_RESCHED		100   /* # scheduler loops before reschedule */
> +#define SOCKNAL_INSANITY_RECONN	5000  /* connd is trying on reconn infinitely */
> +#define SOCKNAL_ENOMEM_RETRY	1     /* seconds between retries */
>  
> -#define SOCKNAL_SINGLE_FRAG_TX  0     /* disable multi-fragment sends */
> -#define SOCKNAL_SINGLE_FRAG_RX  0     /* disable multi-fragment receives */
> +#define SOCKNAL_SINGLE_FRAG_TX	0     /* disable multi-fragment sends */
> +#define SOCKNAL_SINGLE_FRAG_RX	0     /* disable multi-fragment receives */
>  
> -#define SOCKNAL_VERSION_DEBUG   0     /* enable protocol version debugging */
> +#define SOCKNAL_VERSION_DEBUG	0     /* enable protocol version debugging */
>  
>  /*
>   * risk kmap deadlock on multi-frag I/O (backs off to single-frag if disabled).
> @@ -461,31 +461,31 @@ extern struct ksock_tunables ksocknal_tunables;
>  
>  struct ksock_proto {
>  	/* version number of protocol */
> -	int        pro_version;
> +	int	pro_version;
>  
>  	/* handshake function */
> -	int        (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *);
> +	int	(*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *);
>  
>  	/* handshake function */
> -	int        (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int);
> +	int	(*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int);
>  
>  	/* message pack */
> -	void       (*pro_pack)(struct ksock_tx *);
> +	void	(*pro_pack)(struct ksock_tx *);
>  
>  	/* message unpack */
> -	void       (*pro_unpack)(struct ksock_msg *);
> +	void	(*pro_unpack)(struct ksock_msg *);
>  
>  	/* queue tx on the connection */
>  	struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *);
>  
>  	/* queue ZC ack on the connection */
> -	int        (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64);
> +	int	(*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64);
>  
>  	/* handle ZC request */
> -	int        (*pro_handle_zcreq)(struct ksock_conn *, u64, int);
> +	int	(*pro_handle_zcreq)(struct ksock_conn *, u64, int);
>  
>  	/* handle ZC ACK */
> -	int        (*pro_handle_zcack)(struct ksock_conn *, u64, u64);
> +	int	(*pro_handle_zcack)(struct ksock_conn *, u64, u64);
>  
>  	/*
>  	 * msg type matches the connection type:
> @@ -494,7 +494,7 @@ struct ksock_proto {
>  	 *   return MATCH_YES : matching type
>  	 *   return MATCH_MAY : can be backup
>  	 */
> -	int        (*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int);
> +	int	(*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int);
>  };
>  
>  extern struct ksock_proto ksocknal_protocol_v1x;
> diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c
> index 2df9ce4995f3..18f5c6b3b587 100644
> --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c
> +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c
> @@ -92,9 +92,9 @@ EXPORT_SYMBOL(libcfs_next_nidstring);
>   * <nidrange>        :== <addrrange> '@' <net>
>   * <addrrange>       :== '*' |
>   *                       <ipaddr_range> |
> - *			 <cfs_expr_list>
> + *                       <cfs_expr_list>
>   * <ipaddr_range>    :== <cfs_expr_list>.<cfs_expr_list>.<cfs_expr_list>.
> - *			 <cfs_expr_list>
> + *                       <cfs_expr_list>
>   * <cfs_expr_list>   :== <number> |
>   *                       <expr_list>
>   * <expr_list>       :== '[' <range_expr> [ ',' <range_expr>] ']'
> diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
> index bb61e3aa11e9..51ff979ca4ad 100644
> --- a/drivers/staging/lustre/lnet/selftest/timer.c
> +++ b/drivers/staging/lustre/lnet/selftest/timer.c
> @@ -46,12 +46,12 @@
>   * sorted by increasing expiry time. The number of slots is 2**7 (128),
>   * to cover a time period of 1024 seconds into the future before wrapping.
>   */
> -#define STTIMER_MINPOLL        3	/* log2 min poll interval (8 s) */
> +#define STTIMER_MINPOLL		3	/* log2 min poll interval (8 s) */
>  #define STTIMER_SLOTTIME	BIT(STTIMER_MINPOLL)
> -#define STTIMER_SLOTTIMEMASK   (~(STTIMER_SLOTTIME - 1))
> +#define STTIMER_SLOTTIMEMASK	(~(STTIMER_SLOTTIME - 1))
>  #define STTIMER_NSLOTS		BIT(7)
> -#define STTIMER_SLOT(t)	       (&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \
> -						    (STTIMER_NSLOTS - 1))])
> +#define STTIMER_SLOT(t)		(&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \
> +						     (STTIMER_NSLOTS - 1))])
>  
>  static struct st_timer_data {
>  	spinlock_t	  stt_lock;
> diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
> index c85ef9ec639f..67b002bb1d1d 100644
> --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
> +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
> @@ -139,7 +139,7 @@ fld_debugfs_cache_flush_release(struct inode *inode, struct file *file)
>  
>  static const struct file_operations fld_debugfs_cache_flush_fops = {
>  	.owner		= THIS_MODULE,
> -	.open           = simple_open,
> +	.open		= simple_open,
>  	.write		= fld_debugfs_cache_flush_write,
>  	.release	= fld_debugfs_cache_flush_release,
>  };
> diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h
> index 7d52665a3c33..31b3881fb6c9 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_import.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_import.h
> @@ -69,9 +69,9 @@ struct adaptive_timeout {
>  
>  struct ptlrpc_at_array {
>  	struct list_head	*paa_reqs_array; /** array to hold requests */
> -	u32			paa_size;        /** the size of array */
> -	u32			paa_count;       /** the total count of reqs */
> -	time64_t		paa_deadline;    /** the earliest deadline of reqs */
> +	u32			paa_size;	 /** the size of array */
> +	u32			paa_count;	 /** the total count of reqs */
> +	time64_t		paa_deadline;	 /** the earliest deadline of reqs */
>  	u32			*paa_reqs_count; /** the count of reqs in each entry */
>  };
>  
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index 9cffda3741ce..e09268f08e5c 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -690,10 +690,10 @@ static inline int it_to_lock_mode(struct lookup_intent *it)
>  
>  enum md_op_flags {
>  	MF_MDC_CANCEL_FID1	= BIT(0),
> -	MF_MDC_CANCEL_FID2      = BIT(1),
> -	MF_MDC_CANCEL_FID3      = BIT(2),
> -	MF_MDC_CANCEL_FID4      = BIT(3),
> -	MF_GET_MDT_IDX          = BIT(4),
> +	MF_MDC_CANCEL_FID2	= BIT(1),
> +	MF_MDC_CANCEL_FID3	= BIT(2),
> +	MF_MDC_CANCEL_FID4	= BIT(3),
> +	MF_GET_MDT_IDX		= BIT(4),
>  };
>  
>  enum md_cli_flags {
> @@ -744,7 +744,7 @@ struct md_op_data {
>  	u32			op_flags;
>  
>  	/* Various operation flags. */
> -	enum mds_op_bias        op_bias;
> +	enum mds_op_bias	op_bias;
>  
>  	/* Used by readdir */
>  	u64			op_offset;
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index 261857e4540d..ae2fddd044ea 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -335,9 +335,9 @@ static void ldlm_ns_release(struct kobject *kobj)
>  }
>  
>  static struct kobj_type ldlm_ns_ktype = {
> -	.default_attrs  = ldlm_ns_attrs,
> -	.sysfs_ops      = &lustre_sysfs_ops,
> -	.release        = ldlm_ns_release,
> +	.default_attrs	= ldlm_ns_attrs,
> +	.sysfs_ops	= &lustre_sysfs_ops,
> +	.release	= ldlm_ns_release,
>  };
>  
>  static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns)
> diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
> index 6afaa9028864..07cb2c92c197 100644
> --- a/drivers/staging/lustre/lustre/llite/file.c
> +++ b/drivers/staging/lustre/lustre/llite/file.c
> @@ -2636,7 +2636,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  			return -EFAULT;
>  
>  		return ll_file_futimes_3(file, &lfu);
> -        }
> +	}
>  	case LL_IOC_LADVISE: {
>  		struct llapi_ladvise_hdr *ladvise_hdr;
>  		int alloc_size = sizeof(*ladvise_hdr);
> diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
> index 102d143691b2..0f7c0272d630 100644
> --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
> @@ -204,7 +204,7 @@ struct vvp_object {
>  	 *
>  	 * \see ll_vm_open(), ll_vm_close().
>  	 */
> -	atomic_t                vob_mmap_cnt;
> +	atomic_t		vob_mmap_cnt;
>  
>  	/**
>  	 * various flags
> diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
> index 22f178a3abe2..a1d27061ac19 100644
> --- a/drivers/staging/lustre/lustre/llite/xattr.c
> +++ b/drivers/staging/lustre/lustre/llite/xattr.c
> @@ -209,7 +209,7 @@ static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump)
>  	if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
>  		entry_count = comp_v1->lcm_entry_count;
>  		is_composite = true;
> -        }
> +	}
>  
>  	for (i = 0; i < entry_count; i++) {
>  		if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) {
> diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c
> index 6db4d5eb46cd..395ef772fc17 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_ea.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
> @@ -536,7 +536,7 @@ void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm)
>  		       DEXT ": id: %u, flags: %x, magic 0x%08X, layout_gen %u, stripe count %u, sstripe size %u, pool: [" LOV_POOLNAMEF "]\n",
>  		       PEXT(&lse->lsme_extent), lse->lsme_id, lse->lsme_flags,
>  		       lse->lsme_magic, lse->lsme_layout_gen,
> -                       lse->lsme_stripe_count, lse->lsme_stripe_size,
> +		       lse->lsme_stripe_count, lse->lsme_stripe_size,
>  		       lse->lsme_pool_name);
>  		if (!lsme_inited(lse) ||
>  		    lse->lsme_pattern & LOV_PATTERN_F_RELEASED)
> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
> index bad9538706f0..652ed6a20af3 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
> @@ -1336,19 +1336,19 @@ static const struct obd_ops lov_obd_ops = {
>  	.owner		= THIS_MODULE,
>  	.setup		= lov_setup,
>  	.cleanup	= lov_cleanup,
> -	.connect        = lov_connect,
> -	.disconnect     = lov_disconnect,
> -	.statfs         = lov_statfs,
> -	.statfs_async   = lov_statfs_async,
> -	.iocontrol      = lov_iocontrol,
> -	.get_info       = lov_get_info,
> -	.set_info_async = lov_set_info_async,
> -	.notify         = lov_notify,
> -	.pool_new       = lov_pool_new,
> -	.pool_rem       = lov_pool_remove,
> -	.pool_add       = lov_pool_add,
> -	.pool_del       = lov_pool_del,
> -	.quotactl       = lov_quotactl,
> +	.connect	= lov_connect,
> +	.disconnect	= lov_disconnect,
> +	.statfs		= lov_statfs,
> +	.statfs_async	= lov_statfs_async,
> +	.iocontrol	= lov_iocontrol,
> +	.get_info	= lov_get_info,
> +	.set_info_async	= lov_set_info_async,
> +	.notify		= lov_notify,
> +	.pool_new	= lov_pool_new,
> +	.pool_rem	= lov_pool_remove,
> +	.pool_add	= lov_pool_add,
> +	.pool_del	= lov_pool_del,
> +	.quotactl	= lov_quotactl,
>  };
>  
>  struct kmem_cache *lov_oinfo_slab;
> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> index 3ff0bf1c4a22..ec872e8ae9be 100644
> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> @@ -1818,18 +1818,18 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
>  }
>  
>  static const struct obd_ops mgc_obd_ops = {
> -	.owner          = THIS_MODULE,
> -	.setup          = mgc_setup,
> -	.precleanup     = mgc_precleanup,
> -	.cleanup        = mgc_cleanup,
> -	.add_conn       = client_import_add_conn,
> -	.del_conn       = client_import_del_conn,
> -	.connect        = client_connect_import,
> -	.disconnect     = client_disconnect_export,
> -	.set_info_async = mgc_set_info_async,
> -	.get_info       = mgc_get_info,
> -	.import_event   = mgc_import_event,
> -	.process_config = mgc_process_config,
> +	.owner		= THIS_MODULE,
> +	.setup		= mgc_setup,
> +	.precleanup	= mgc_precleanup,
> +	.cleanup	= mgc_cleanup,
> +	.add_conn	= client_import_add_conn,
> +	.del_conn	= client_import_del_conn,
> +	.connect	= client_connect_import,
> +	.disconnect	= client_disconnect_export,
> +	.set_info_async	= mgc_set_info_async,
> +	.get_info	= mgc_get_info,
> +	.import_event	= mgc_import_event,
> +	.process_config	= mgc_process_config,
>  };
>  
>  static int __init mgc_init(void)
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 1d1a6b2d436e..c91704d87042 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -313,9 +313,9 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
>  
>  	llog_group_init(&newdev->obd_olg);
>  	/* Detach drops this */
> -        atomic_set(&newdev->obd_refcount, 1);
> -        lu_ref_init(&newdev->obd_reference);
> -        lu_ref_add(&newdev->obd_reference, "newdev", newdev);
> +	atomic_set(&newdev->obd_refcount, 1);
> +	lu_ref_init(&newdev->obd_reference);
> +	lu_ref_add(&newdev->obd_reference, "newdev", newdev);
>  
>  	newdev->obd_conn_inprogress = 0;
>  
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> index 69a56cca99f2..d4f1eddd96ca 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> @@ -73,7 +73,7 @@ struct lu_site_bkt_data {
>  	 *
>  	 * \see htable_lookup().
>  	 */
> -	wait_queue_head_t	       lsb_marche_funebre;
> +	wait_queue_head_t		lsb_marche_funebre;
>  };
>  
>  enum {
> @@ -935,10 +935,10 @@ static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
>  static struct cfs_hash_ops lu_site_hash_ops = {
>  	.hs_hash	= lu_obj_hop_hash,
>  	.hs_key		= lu_obj_hop_key,
> -	.hs_keycmp      = lu_obj_hop_keycmp,
> -	.hs_object      = lu_obj_hop_object,
> +	.hs_keycmp	= lu_obj_hop_keycmp,
> +	.hs_object	= lu_obj_hop_object,
>  	.hs_get		= lu_obj_hop_get,
> -	.hs_put_locked  = lu_obj_hop_put_locked,
> +	.hs_put_locked	= lu_obj_hop_put_locked,
>  };
>  
>  static void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d)
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> index 71490b75c7ae..e9e0bcf39d4e 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> @@ -105,7 +105,7 @@ static ssize_t static_uintvalue_store(struct kobject *kobj,
>  }
>  
>  #define LUSTRE_STATIC_UINT_ATTR(name, value)				\
> -static struct static_lustre_uintvalue_attr lustre_sattr_##name =        \
> +static struct static_lustre_uintvalue_attr lustre_sattr_##name =	\
>  	{ __ATTR(name, 0644, static_uintvalue_show,			\
>  		 static_uintvalue_store), value }
>  
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 442b4355d946..765b5a7b9662 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -2989,26 +2989,26 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf)
>  }
>  
>  static const struct obd_ops osc_obd_ops = {
> -	.owner          = THIS_MODULE,
> -	.setup          = osc_setup,
> -	.precleanup     = osc_precleanup,
> -	.cleanup        = osc_cleanup,
> -	.add_conn       = client_import_add_conn,
> -	.del_conn       = client_import_del_conn,
> -	.connect        = client_connect_import,
> -	.reconnect      = osc_reconnect,
> -	.disconnect     = osc_disconnect,
> -	.statfs         = osc_statfs,
> -	.statfs_async   = osc_statfs_async,
> -	.create         = osc_create,
> -	.destroy        = osc_destroy,
> -	.getattr        = osc_getattr,
> -	.setattr        = osc_setattr,
> -	.iocontrol      = osc_iocontrol,
> -	.set_info_async = osc_set_info_async,
> -	.import_event   = osc_import_event,
> -	.process_config = osc_process_config,
> -	.quotactl       = osc_quotactl,
> +	.owner		= THIS_MODULE,
> +	.setup		= osc_setup,
> +	.precleanup	= osc_precleanup,
> +	.cleanup	= osc_cleanup,
> +	.add_conn	= client_import_add_conn,
> +	.del_conn	= client_import_del_conn,
> +	.connect	= client_connect_import,
> +	.reconnect	= osc_reconnect,
> +	.disconnect	= osc_disconnect,
> +	.statfs		= osc_statfs,
> +	.statfs_async	= osc_statfs_async,
> +	.create		= osc_create,
> +	.destroy	= osc_destroy,
> +	.getattr	= osc_getattr,
> +	.setattr	= osc_setattr,
> +	.iocontrol	= osc_iocontrol,
> +	.set_info_async	= osc_set_info_async,
> +	.import_event	= osc_import_event,
> +	.process_config	= osc_process_config,
> +	.quotactl	= osc_quotactl,
>  };
>  
>  struct list_head osc_shrink_list = LIST_HEAD_INIT(osc_shrink_list);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
> index c2f49a3e0454..5dde3495aaf4 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
> @@ -1508,7 +1508,7 @@ void lustre_assert_wire_constants(void)
>  	LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding) == 16, "found %lld\n",
>  		 (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding));
>  	LASSERTF(LCME_FL_INIT == 0x00000010UL, "found 0x%.8xUL\n",
> -	         (unsigned int)LCME_FL_INIT);
> +		 (unsigned int)LCME_FL_INIT);
>  
>  	/* Checks for struct lov_comp_md_v1 */
>  	LASSERTF((int)sizeof(struct lov_comp_md_v1) == 32, "found %lld\n",
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines NeilBrown
@ 2019-02-24 19:07   ` James Simmons
  2019-02-27  0:41     ` NeilBrown
  2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-24 19:07 UTC (permalink / raw)
  To: lustre-devel


> Some of these are unused.
> One is used in a minimal way where it is easier to use
> an explicit number.

While I dislike mystery meat type defines like MAX_STRING_SIZE I also 
don't like using raw numbers. In the past using raw numbers has causes
problems when requirements changed that were not easy to track down
why the new bug appeared. Mind you the same problem exist for constants 
like MAX_STRING_SIZE which provides no real meaning to why the magically 
number 128 is used. 
 
This number seems to be a limiting factor in the naming of sysfs directory
and file naming. I kind of see why this number has no meaning. So such
a number belongs in one place, lprocfs_status.h. Now sysfs attributes
can have any naming style they want, within reason :-) As for directories
that is limited by MAX_OBD_NAME. What do you know MAX_OBD_NAME is equal
too MAX_STRING_SIZE (hint hint) :-) 

> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 --
>  drivers/staging/lustre/lustre/llite/llite_lib.c    |    6 ++----
>  drivers/staging/lustre/lustre/llite/lproc_llite.c  |    4 ----
>  drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 --
>  .../lustre/lustre/obdclass/lprocfs_status.c        |    2 --
>  5 files changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index 74c7644d6ef8..261857e4540d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -392,8 +392,6 @@ static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns)
>  	return 0;
>  }
>  
> -#undef MAX_STRING_SIZE
> -
>  struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
>  {
>  	LASSERT(res);
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index d97abbfddccf..fda6d9b07952 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -906,8 +906,6 @@ void ll_lli_init(struct ll_inode_info *lli)
>  	memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE);
>  }
>  
> -#define MAX_STRING_SIZE 128
> -
>  int ll_fill_super(struct super_block *sb)
>  {
>  	struct lustre_profile *lprof = NULL;
> @@ -916,7 +914,7 @@ int ll_fill_super(struct super_block *sb)
>  	char *dt = NULL, *md = NULL;
>  	char *profilenm = get_profile_name(sb);
>  	struct config_llog_instance *cfg;
> -	char name[MAX_STRING_SIZE];
> +	char name[128];
>  	char *ptr;
>  	int len;
>  	int err;
> @@ -960,7 +958,7 @@ int ll_fill_super(struct super_block *sb)
>  		len -= 7;
>  
>  	/* Mount info */
> -	snprintf(name, MAX_STRING_SIZE, "%.*s-%px", len,
> +	snprintf(name, sizeof(name), "%.*s-%px", len,
>  		 lsi->lsi_lmd->lmd_profile, sb);
>  
>  	/* Call ll_debugsfs_register_super() before lustre_process_log()
> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> index db2fbf1f3a50..5ed703d7bb1e 100644
> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> @@ -1187,8 +1187,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
>  	{ NULL }
>  };
>  
> -#define MAX_STRING_SIZE 128
> -
>  static struct attribute *llite_attrs[] = {
>  	&lustre_attr_blocksize.attr,
>  	&lustre_attr_stat_blocksize.attr,
> @@ -1434,8 +1432,6 @@ void ll_debugfs_unregister_super(struct super_block *sb)
>  	lprocfs_free_stats(&sbi->ll_stats);
>  }
>  
> -#undef MAX_STRING_SIZE
> -
>  #define pct(a, b) (b ? a * 100 / b : 0)
>  
>  static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index 35dff0e96bf7..138e124bd05e 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -273,8 +273,6 @@ static int lmv_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize)
>  	return rc;
>  }
>  
> -#define MAX_STRING_SIZE 128
> -
>  static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
>  {
>  	struct lmv_obd *lmv = &obd->u.lmv;
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index aed33068ff3c..a179b0d6979e 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -271,8 +271,6 @@ static int lprocfs_no_percpu_stats;
>  module_param(lprocfs_no_percpu_stats, int, 0644);
>  MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats");
>  
> -#define MAX_STRING_SIZE 128
> -
>  /* lprocfs API calls */
>  
>  static const struct file_operations lprocfs_generic_fops = { };
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing NeilBrown
@ 2019-02-24 19:08   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 19:08 UTC (permalink / raw)
  To: lustre-devel


> In lu_cdebug_printer(), is "complete" is true, then
> key->lck_area ends with a newline, so there is no need to
> include on in the format too.

We thought we found all those extra or missing newlines. Thanks
for finding it.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/lu_object.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> index d4f1eddd96ca..3e23babb329a 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> @@ -526,7 +526,7 @@ int lu_cdebug_printer(const struct lu_env *env,
>  		  ARRAY_SIZE(key->lck_area) - used, format, args);
>  	if (complete) {
>  		if (cfs_cdebug_show(msgdata->msg_mask, msgdata->msg_subsys))
> -			libcfs_debug_msg(msgdata, "%s\n", key->lck_area);
> +			libcfs_debug_msg(msgdata, "%s", key->lck_area);
>  		key->lck_area[0] = 0;
>  	}
>  	va_end(args);
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2
  2019-02-19  0:09 ` [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 NeilBrown
@ 2019-02-24 20:02   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 20:02 UTC (permalink / raw)
  To: lustre-devel


> Since 2.6.36, Linux' vsprintf has supported %pV
> which supports "recursive sprintf" - exactly the task
> that libcfs_debug_vmsg2 aims to provide.
> 
> Instead of calling libcfs_debug_vmsg2(), we can put the fmt and
> args in a 'struct va_format', and pass the address of that structure
> to the "%pV" format.
> 
> So do this to remove all users of libcfs_debug_vmsg2().

This is a really nice cleanup.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |  176 ++++++++++----------
>  .../staging/lustre/lustre/ptlrpc/pack_generic.c    |   42 +++--
>  2 files changed, 115 insertions(+), 103 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index f2433dc0e558..6789d3bf0485 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -1970,6 +1970,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
>  	struct ldlm_resource *resource = NULL;
>  	char *nid = "local";
>  	va_list args;
> +	struct va_format vaf;
>  
>  	if (spin_trylock(&lock->l_lock)) {
>  		if (lock->l_resource)
> @@ -1978,6 +1979,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
>  	}
>  
>  	va_start(args, fmt);
> +	vaf.fmt = fmt;
> +	vaf.va = &args;
>  
>  	if (exp && exp->exp_connection) {
>  		nid = libcfs_nid2str(exp->exp_connection->c_peer.nid);
> @@ -1988,105 +1991,110 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
>  	}
>  
>  	if (!resource) {
> -		libcfs_debug_vmsg2(msgdata, fmt, args,
> -				   " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> -				   lock,
> -				   lock->l_handle.h_cookie,
> -				   atomic_read(&lock->l_refc),
> -				   lock->l_readers, lock->l_writers,
> -				   ldlm_lockname[lock->l_granted_mode],
> -				   ldlm_lockname[lock->l_req_mode],
> -				   lock->l_flags, nid,
> -				   lock->l_remote_handle.cookie,
> -				   exp ? refcount_read(&exp->exp_refcount) : -99,
> -				   lock->l_pid, lock->l_callback_timeout,
> -				   lock->l_lvb_type);
> +		libcfs_debug_msg(msgdata,
> +				 "%pV ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> +				 &vaf,
> +				 lock,
> +				 lock->l_handle.h_cookie,
> +				 atomic_read(&lock->l_refc),
> +				 lock->l_readers, lock->l_writers,
> +				 ldlm_lockname[lock->l_granted_mode],
> +				 ldlm_lockname[lock->l_req_mode],
> +				 lock->l_flags, nid,
> +				 lock->l_remote_handle.cookie,
> +				 exp ? refcount_read(&exp->exp_refcount) : -99,
> +				 lock->l_pid, lock->l_callback_timeout,
> +				 lock->l_lvb_type);
>  		va_end(args);
>  		return;
>  	}
>  
>  	switch (resource->lr_type) {
>  	case LDLM_EXTENT:
> -		libcfs_debug_vmsg2(msgdata, fmt, args,
> -				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> -				   ldlm_lock_to_ns_name(lock), lock,
> -				   lock->l_handle.h_cookie,
> -				   atomic_read(&lock->l_refc),
> -				   lock->l_readers, lock->l_writers,
> -				   ldlm_lockname[lock->l_granted_mode],
> -				   ldlm_lockname[lock->l_req_mode],
> -				   PLDLMRES(resource),
> -				   atomic_read(&resource->lr_refcount),
> -				   ldlm_typename[resource->lr_type],
> -				   lock->l_policy_data.l_extent.start,
> -				   lock->l_policy_data.l_extent.end,
> -				   lock->l_req_extent.start,
> -				   lock->l_req_extent.end,
> -				   lock->l_flags, nid,
> -				   lock->l_remote_handle.cookie,
> -				   exp ? refcount_read(&exp->exp_refcount) : -99,
> -				   lock->l_pid, lock->l_callback_timeout,
> -				   lock->l_lvb_type);
> +		libcfs_debug_msg(msgdata,
> +				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> +				 &vaf,
> +				 ldlm_lock_to_ns_name(lock), lock,
> +				 lock->l_handle.h_cookie,
> +				 atomic_read(&lock->l_refc),
> +				 lock->l_readers, lock->l_writers,
> +				 ldlm_lockname[lock->l_granted_mode],
> +				 ldlm_lockname[lock->l_req_mode],
> +				 PLDLMRES(resource),
> +				 atomic_read(&resource->lr_refcount),
> +				 ldlm_typename[resource->lr_type],
> +				 lock->l_policy_data.l_extent.start,
> +				 lock->l_policy_data.l_extent.end,
> +				 lock->l_req_extent.start,
> +				 lock->l_req_extent.end,
> +				 lock->l_flags, nid,
> +				 lock->l_remote_handle.cookie,
> +				 exp ? refcount_read(&exp->exp_refcount) : -99,
> +				 lock->l_pid, lock->l_callback_timeout,
> +				 lock->l_lvb_type);
>  		break;
>  
>  	case LDLM_FLOCK:
> -		libcfs_debug_vmsg2(msgdata, fmt, args,
> -				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n",
> -				   ldlm_lock_to_ns_name(lock), lock,
> -				   lock->l_handle.h_cookie,
> -				   atomic_read(&lock->l_refc),
> -				   lock->l_readers, lock->l_writers,
> -				   ldlm_lockname[lock->l_granted_mode],
> -				   ldlm_lockname[lock->l_req_mode],
> -				   PLDLMRES(resource),
> -				   atomic_read(&resource->lr_refcount),
> -				   ldlm_typename[resource->lr_type],
> -				   lock->l_policy_data.l_flock.pid,
> -				   lock->l_policy_data.l_flock.start,
> -				   lock->l_policy_data.l_flock.end,
> -				   lock->l_flags, nid,
> -				   lock->l_remote_handle.cookie,
> -				   exp ? refcount_read(&exp->exp_refcount) : -99,
> -				   lock->l_pid, lock->l_callback_timeout);
> +		libcfs_debug_msg(msgdata,
> +				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n",
> +				 &vaf,
> +				 ldlm_lock_to_ns_name(lock), lock,
> +				 lock->l_handle.h_cookie,
> +				 atomic_read(&lock->l_refc),
> +				 lock->l_readers, lock->l_writers,
> +				 ldlm_lockname[lock->l_granted_mode],
> +				 ldlm_lockname[lock->l_req_mode],
> +				 PLDLMRES(resource),
> +				 atomic_read(&resource->lr_refcount),
> +				 ldlm_typename[resource->lr_type],
> +				 lock->l_policy_data.l_flock.pid,
> +				 lock->l_policy_data.l_flock.start,
> +				 lock->l_policy_data.l_flock.end,
> +				 lock->l_flags, nid,
> +				 lock->l_remote_handle.cookie,
> +				 exp ? refcount_read(&exp->exp_refcount) : -99,
> +				 lock->l_pid, lock->l_callback_timeout);
>  		break;
>  
>  	case LDLM_IBITS:
> -		libcfs_debug_vmsg2(msgdata, fmt, args,
> -				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> -				   ldlm_lock_to_ns_name(lock),
> -				   lock, lock->l_handle.h_cookie,
> -				   atomic_read(&lock->l_refc),
> -				   lock->l_readers, lock->l_writers,
> -				   ldlm_lockname[lock->l_granted_mode],
> -				   ldlm_lockname[lock->l_req_mode],
> -				   PLDLMRES(resource),
> -				   lock->l_policy_data.l_inodebits.bits,
> -				   atomic_read(&resource->lr_refcount),
> -				   ldlm_typename[resource->lr_type],
> -				   lock->l_flags, nid,
> -				   lock->l_remote_handle.cookie,
> -				   exp ? refcount_read(&exp->exp_refcount) : -99,
> -				   lock->l_pid, lock->l_callback_timeout,
> -				   lock->l_lvb_type);
> +		libcfs_debug_msg(msgdata,
> +				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> +				 &vaf,
> +				 ldlm_lock_to_ns_name(lock),
> +				 lock, lock->l_handle.h_cookie,
> +				 atomic_read(&lock->l_refc),
> +				 lock->l_readers, lock->l_writers,
> +				 ldlm_lockname[lock->l_granted_mode],
> +				 ldlm_lockname[lock->l_req_mode],
> +				 PLDLMRES(resource),
> +				 lock->l_policy_data.l_inodebits.bits,
> +				 atomic_read(&resource->lr_refcount),
> +				 ldlm_typename[resource->lr_type],
> +				 lock->l_flags, nid,
> +				 lock->l_remote_handle.cookie,
> +				 exp ? refcount_read(&exp->exp_refcount) : -99,
> +				 lock->l_pid, lock->l_callback_timeout,
> +				 lock->l_lvb_type);
>  		break;
>  
>  	default:
> -		libcfs_debug_vmsg2(msgdata, fmt, args,
> -				   " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> -				   ldlm_lock_to_ns_name(lock),
> -				   lock, lock->l_handle.h_cookie,
> -				   atomic_read(&lock->l_refc),
> -				   lock->l_readers, lock->l_writers,
> -				   ldlm_lockname[lock->l_granted_mode],
> -				   ldlm_lockname[lock->l_req_mode],
> -				   PLDLMRES(resource),
> -				   atomic_read(&resource->lr_refcount),
> -				   ldlm_typename[resource->lr_type],
> -				   lock->l_flags, nid,
> -				   lock->l_remote_handle.cookie,
> -				   exp ? refcount_read(&exp->exp_refcount) : -99,
> -				   lock->l_pid, lock->l_callback_timeout,
> -				   lock->l_lvb_type);
> +		libcfs_debug_msg(msgdata,
> +				 "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n",
> +				 &vaf,
> +				 ldlm_lock_to_ns_name(lock),
> +				 lock, lock->l_handle.h_cookie,
> +				 atomic_read(&lock->l_refc),
> +				 lock->l_readers, lock->l_writers,
> +				 ldlm_lockname[lock->l_granted_mode],
> +				 ldlm_lockname[lock->l_req_mode],
> +				 PLDLMRES(resource),
> +				 atomic_read(&resource->lr_refcount),
> +				 ldlm_typename[resource->lr_type],
> +				 lock->l_flags, nid,
> +				 lock->l_remote_handle.cookie,
> +				 exp ? refcount_read(&exp->exp_refcount) : -99,
> +				 lock->l_pid, lock->l_callback_timeout,
> +				 lock->l_lvb_type);
>  		break;
>  	}
>  	va_end(args);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
> index c7cc86c3fbc3..879cb1162cc7 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
> @@ -2276,6 +2276,7 @@ void _debug_req(struct ptlrpc_request *req,
>  	int rep_flags = -1;
>  	int rep_status = -1;
>  	va_list args;
> +	struct va_format vaf;
>  
>  	spin_lock(&req->rq_early_free_lock);
>  	if (req->rq_repmsg)
> @@ -2298,25 +2299,28 @@ void _debug_req(struct ptlrpc_request *req,
>  		nid = req->rq_export->exp_connection->c_peer.nid;
>  
>  	va_start(args, fmt);
> -	libcfs_debug_vmsg2(msgdata, fmt, args,
> -			   " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n",
> -			   req, req->rq_xid, req->rq_transno,
> -			   req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
> -			   req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
> -			   req->rq_import ?
> -			   req->rq_import->imp_obd->obd_name :
> -			   req->rq_export ?
> -			   req->rq_export->exp_client_uuid.uuid :
> -			   "<?>",
> -			   libcfs_nid2str(nid),
> -			   req->rq_request_portal, req->rq_reply_portal,
> -			   req->rq_reqlen, req->rq_replen,
> -			   req->rq_early_count, (s64)req->rq_timedout,
> -			   (s64)req->rq_deadline,
> -			   atomic_read(&req->rq_refcount),
> -			   DEBUG_REQ_FLAGS(req),
> -			   req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1,
> -			   rep_flags, req->rq_status, rep_status);
> +	vaf.fmt = fmt;
> +	vaf.va = &args;
> +	libcfs_debug_msg(msgdata,
> +			 "%pV req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n",
> +			 &vaf,
> +			 req, req->rq_xid, req->rq_transno,
> +			 req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
> +			 req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
> +			 req->rq_import ?
> +			 req->rq_import->imp_obd->obd_name :
> +			 req->rq_export ?
> +			 req->rq_export->exp_client_uuid.uuid :
> +			 "<?>",
> +			 libcfs_nid2str(nid),
> +			 req->rq_request_portal, req->rq_reply_portal,
> +			 req->rq_reqlen, req->rq_replen,
> +			 req->rq_early_count, (s64)req->rq_timedout,
> +			 (s64)req->rq_deadline,
> +			 atomic_read(&req->rq_refcount),
> +			 DEBUG_REQ_FLAGS(req),
> +			 req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1,
> +			 rep_flags, req->rq_status, rep_status);
>  	va_end(args);
>  }
>  EXPORT_SYMBOL(_debug_req);
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 27/37] lustre: discard lu_ref
  2019-02-19  0:09 ` [lustre-devel] [PATCH 27/37] lustre: discard lu_ref NeilBrown
@ 2019-02-24 20:28   ` James Simmons
  2019-02-27  1:17     ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-24 20:28 UTC (permalink / raw)
  To: lustre-devel


> struct lu_ref is always an empty structure, and the functions
> which manipulate it do nothing.
> So this is not being tested and so cannot be trusted.
> So remove all these calls and field declarations.

Or we can make lu_ref really work and always test with it :-)
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/cl_object.h  |    6 -
>  drivers/staging/lustre/lustre/include/lu_object.h  |   45 -----
>  drivers/staging/lustre/lustre/include/lu_ref.h     |  178 --------------------
>  drivers/staging/lustre/lustre/include/lustre_dlm.h |   20 --
>  drivers/staging/lustre/lustre/include/obd.h        |    7 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   36 +---
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   12 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    4 
>  drivers/staging/lustre/lustre/llite/lcommon_cl.c   |    2 
>  drivers/staging/lustre/lustre/llite/rw.c           |    6 -
>  drivers/staging/lustre/lustre/llite/rw26.c         |    6 -
>  drivers/staging/lustre/lustre/llite/vvp_dev.c      |   20 +-
>  drivers/staging/lustre/lustre/llite/vvp_io.c       |    5 -
>  drivers/staging/lustre/lustre/lov/lov_object.c     |    2 
>  drivers/staging/lustre/lustre/lov/lovsub_dev.c     |    1 
>  drivers/staging/lustre/lustre/mdc/mdc_reint.c      |    2 
>  drivers/staging/lustre/lustre/obdclass/Makefile    |    2 
>  drivers/staging/lustre/lustre/obdclass/cl_io.c     |    8 -
>  drivers/staging/lustre/lustre/obdclass/cl_object.c |    2 
>  drivers/staging/lustre/lustre/obdclass/cl_page.c   |    5 -
>  drivers/staging/lustre/lustre/obdclass/genops.c    |    3 
>  drivers/staging/lustre/lustre/obdclass/lu_object.c |   34 ----
>  drivers/staging/lustre/lustre/obdclass/lu_ref.c    |   45 -----
>  .../staging/lustre/lustre/obdclass/obd_config.c    |    2 
>  drivers/staging/lustre/lustre/osc/osc_cache.c      |   12 -
>  drivers/staging/lustre/lustre/osc/osc_lock.c       |    2 
>  drivers/staging/lustre/lustre/osc/osc_page.c       |    2 
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 
>  28 files changed, 19 insertions(+), 452 deletions(-)
>  delete mode 100644 drivers/staging/lustre/lustre/include/lu_ref.h
>  delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ref.c
> 
> diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
> index 05be85306663..1484821995e9 100644
> --- a/drivers/staging/lustre/lustre/include/cl_object.h
> +++ b/drivers/staging/lustre/lustre/include/cl_object.h
> @@ -742,12 +742,6 @@ struct cl_page {
>  	 * by sub-io. Protected by a VM lock.
>  	 */
>  	struct cl_io			*cp_owner;
> -	/** List of references to this page, for debugging. */
> -	struct lu_ref			 cp_reference;
> -	/** Link to an object, for debugging. */
> -	struct lu_ref_link		 cp_obj_ref;
> -	/** Link to a queue, for debugging. */
> -	struct lu_ref_link		 cp_queue_ref;
>  	/** Assigned if doing a sync_io */
>  	struct cl_sync_io		*cp_sync_io;
>  };
> diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
> index 68aa0d05b03a..cef02e66ea8e 100644
> --- a/drivers/staging/lustre/lustre/include/lu_object.h
> +++ b/drivers/staging/lustre/lustre/include/lu_object.h
> @@ -38,7 +38,6 @@
>  #include <linux/percpu_counter.h>
>  #include <linux/libcfs/libcfs.h>
>  #include <uapi/linux/lustre/lustre_idl.h>
> -#include <lu_ref.h>
>  
>  struct seq_file;
>  struct lustre_cfg;
> @@ -277,10 +276,6 @@ struct lu_device {
>  
>  	/** \todo XXX: temporary back pointer into obd. */
>  	struct obd_device			*ld_obd;
> -	/**
> -	 * A list of references to this object, for debugging.
> -	 */
> -	struct lu_ref				ld_reference;
>  	/**
>  	 * Link the device to the site.
>  	 **/
> @@ -464,10 +459,6 @@ struct lu_object {
>  	 * Linkage into list of all layers.
>  	 */
>  	struct list_head			 lo_linkage;
> -	/**
> -	 * Link to the device, for debugging.
> -	 */
> -	struct lu_ref_link			 lo_dev_ref;
>  };
>  
>  enum lu_object_header_flags {
> @@ -536,10 +527,6 @@ struct lu_object_header {
>  	 * during object destruction). No locking is necessary.
>  	 */
>  	struct list_head	loh_layers;
> -	/**
> -	 * A list of references to this object, for debugging.
> -	 */
> -	struct lu_ref		loh_reference;
>  };
>  
>  struct fld;
> @@ -818,34 +805,6 @@ static inline u32 lu_object_attr(const struct lu_object *o)
>  	return o->lo_header->loh_attr;
>  }
>  
> -static inline void lu_object_ref_add(struct lu_object *o,
> -				     const char *scope,
> -				     const void *source)
> -{
> -	lu_ref_add(&o->lo_header->loh_reference, scope, source);
> -}
> -
> -static inline void lu_object_ref_add_at(struct lu_object *o,
> -					struct lu_ref_link *link,
> -					const char *scope,
> -					const void *source)
> -{
> -	lu_ref_add_at(&o->lo_header->loh_reference, link, scope, source);
> -}
> -
> -static inline void lu_object_ref_del(struct lu_object *o,
> -				     const char *scope, const void *source)
> -{
> -	lu_ref_del(&o->lo_header->loh_reference, scope, source);
> -}
> -
> -static inline void lu_object_ref_del_at(struct lu_object *o,
> -					struct lu_ref_link *link,
> -					const char *scope, const void *source)
> -{
> -	lu_ref_del_at(&o->lo_header->loh_reference, link, scope, source);
> -}
> -
>  /** input params, should be filled out by mdt */
>  struct lu_rdpg {
>  	/** hash */
> @@ -1084,10 +1043,6 @@ struct lu_context_key {
>  	 * Internal implementation detail: module for this key.
>  	 */
>  	struct module	*lct_owner;
> -	/**
> -	 * References to this key. For debugging.
> -	 */
> -	struct lu_ref	lct_reference;
>  };
>  
>  #define LU_KEY_INIT(mod, type)						\
> diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h
> deleted file mode 100644
> index ad0c24d29ffa..000000000000
> --- a/drivers/staging/lustre/lustre/include/lu_ref.h
> +++ /dev/null
> @@ -1,178 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - *
> - * Copyright (c) 2012, Intel Corporation.
> - *
> - *   Author: Nikita Danilov <nikita.danilov@sun.com>
> - *
> - *   This file is part of Lustre, http://www.lustre.org.
> - *
> - *   Lustre is free software; you can redistribute it and/or
> - *   modify it under the terms of version 2 of the GNU General Public
> - *   License as published by the Free Software Foundation.
> - *
> - *   Lustre is distributed in the hope that it will be useful,
> - *   but WITHOUT ANY WARRANTY; without even the implied warranty of
> - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - *   GNU General Public License for more details.
> - *
> - */
> -
> -#ifndef __LUSTRE_LU_REF_H
> -#define __LUSTRE_LU_REF_H
> -
> -#include <linux/list.h>
> -
> -/** \defgroup lu_ref lu_ref
> - *
> - * An interface to track references between objects. Mostly for debugging.
> - *
> - * Suppose there is a reference counted data-structure struct foo. To track
> - * who acquired references to instance of struct foo, add lu_ref field to it:
> - *
> - * \code
> - *	 struct foo {
> - *		 atomic_t      foo_refcount;
> - *		 struct lu_ref foo_reference;
> - *		 ...
> - *	 };
> - * \endcode
> - *
> - * foo::foo_reference has to be initialized by calling
> - * lu_ref_init(). Typically there will be functions or macros to increment and
> - * decrement foo::foo_refcount, let's say they are foo_get(struct foo *foo)
> - * and foo_put(struct foo *foo), respectively.
> - *
> - * Whenever foo_get() is called to acquire a reference on a foo, lu_ref_add()
> - * has to be called to insert into foo::foo_reference a record, describing
> - * acquired reference. Dually, lu_ref_del() removes matching record. Typical
> - * usages are:
> - *
> - * \code
> - *	struct bar *bar;
> - *
> - *	// bar owns a reference to foo.
> - *	bar->bar_foo = foo_get(foo);
> - *	lu_ref_add(&foo->foo_reference, "bar", bar);
> - *
> - *	...
> - *
> - *	// reference from bar to foo is released.
> - *	lu_ref_del(&foo->foo_reference, "bar", bar);
> - *	foo_put(bar->bar_foo);
> - *
> - *
> - *	// current thread acquired a temporary reference to foo.
> - *	foo_get(foo);
> - *	lu_ref_add(&foo->reference, __func__, current);
> - *
> - *	...
> - *
> - *	// temporary reference is released.
> - *	lu_ref_del(&foo->reference, __func__, current);
> - *	foo_put(foo);
> - * \endcode
> - *
> - * \e Et \e cetera. Often it makes sense to include lu_ref_add() and
> - * lu_ref_del() calls into foo_get() and foo_put(). When an instance of struct
> - * foo is destroyed, lu_ref_fini() has to be called that checks that no
> - * pending references remain. lu_ref_print() can be used to dump a list of
> - * pending references, while hunting down a leak.
> - *
> - * For objects to which a large number of references can be acquired,
> - * lu_ref_del() can become cpu consuming, as it has to scan the list of
> - * references. To work around this, remember result of lu_ref_add() (usually
> - * in the same place where pointer to struct foo is stored), and use
> - * lu_ref_del_at():
> - *
> - * \code
> - *	// There is a large number of bar's for a single foo.
> - *	bar->bar_foo     = foo_get(foo);
> - *	bar->bar_foo_ref = lu_ref_add(&foo->foo_reference, "bar", bar);
> - *
> - *	...
> - *
> - *	// reference from bar to foo is released.
> - *	lu_ref_del_at(&foo->foo_reference, bar->bar_foo_ref, "bar", bar);
> - *	foo_put(bar->bar_foo);
> - * \endcode
> - *
> - * lu_ref interface degrades gracefully in case of memory shortages.
> - *
> - * @{
> - */
> -
> -/*
> - * dummy data structures/functions to pass compile for now.
> - * We need to reimplement them with kref.
> - */
> -struct lu_ref {};
> -struct lu_ref_link {};
> -
> -static inline void lu_ref_init(struct lu_ref *ref)
> -{
> -}
> -
> -static inline void lu_ref_fini(struct lu_ref *ref)
> -{
> -}
> -
> -static inline struct lu_ref_link *lu_ref_add(struct lu_ref *ref,
> -					     const char *scope,
> -					     const void *source)
> -{
> -	return NULL;
> -}
> -
> -static inline struct lu_ref_link *lu_ref_add_atomic(struct lu_ref *ref,
> -						    const char *scope,
> -						    const void *source)
> -{
> -	return NULL;
> -}
> -
> -static inline void lu_ref_add_at(struct lu_ref *ref,
> -				 struct lu_ref_link *link,
> -				 const char *scope,
> -				 const void *source)
> -{
> -}
> -
> -static inline void lu_ref_del(struct lu_ref *ref, const char *scope,
> -			      const void *source)
> -{
> -}
> -
> -static inline void lu_ref_set_at(struct lu_ref *ref, struct lu_ref_link *link,
> -				 const char *scope, const void *source0,
> -				 const void *source1)
> -{
> -}
> -
> -static inline void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link,
> -				 const char *scope, const void *source)
> -{
> -}
> -
> -static inline int lu_ref_global_init(void)
> -{
> -	return 0;
> -}
> -
> -static inline void lu_ref_global_fini(void)
> -{
> -}
> -
> -static inline void lu_ref_print(const struct lu_ref *ref)
> -{
> -}
> -
> -static inline void lu_ref_print_all(void)
> -{
> -}
> -
> -/** @} lu */
> -
> -#endif /* __LUSTRE_LU_REF_H */
> diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> index c561d61d1a49..6c0371ef056c 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> @@ -49,7 +49,6 @@
>  #include <lustre_net.h>
>  #include <lustre_import.h>
>  #include <lustre_handles.h>
> -#include <lu_ref.h>
>  
>  #include "lustre_dlm_flags.h"
>  
> @@ -785,8 +784,6 @@ struct ldlm_lock {
>  	struct list_head		l_sl_mode;
>  	struct list_head		l_sl_policy;
>  
> -	/** Reference tracking structure to debug leaked locks. */
> -	struct lu_ref			l_reference;
>  #if LUSTRE_TRACKS_LOCK_EXP_REFS
>  	/* Debugging stuff for bug 20498, for tracking export references. */
>  	/** number of export references taken */
> @@ -859,9 +856,6 @@ struct ldlm_resource {
>  	 * Associated inode, used only on client side.
>  	 */
>  	struct inode			*lr_lvb_inode;
> -
> -	/** List of references to this resource. For debugging. */
> -	struct lu_ref			lr_reference;
>  };
>  
>  static inline bool ldlm_has_layout(struct ldlm_lock *lock)
> @@ -1066,17 +1060,12 @@ static inline struct ldlm_lock *ldlm_handle2lock(const struct lustre_handle *h)
>  	return __ldlm_handle2lock(h, 0);
>  }
>  
> -#define LDLM_LOCK_REF_DEL(lock) \
> -	lu_ref_del(&lock->l_reference, "handle", current)
> -
>  static inline struct ldlm_lock *
>  ldlm_handle2lock_long(const struct lustre_handle *h, u64 flags)
>  {
>  	struct ldlm_lock *lock;
>  
>  	lock = __ldlm_handle2lock(h, flags);
> -	if (lock)
> -		LDLM_LOCK_REF_DEL(lock);
>  	return lock;
>  }
>  
> @@ -1107,7 +1096,6 @@ void ldlm_dump_export_locks(struct obd_export *exp);
>   */
>  #define LDLM_LOCK_PUT(lock)		\
>  do {					\
> -	LDLM_LOCK_REF_DEL(lock);	\
>  	/*LDLM_DEBUG((lock), "put");*/	\
>  	ldlm_lock_put(lock);		\
>  } while (0)
> @@ -1198,14 +1186,6 @@ void ldlm_resource_dump(int level, struct ldlm_resource *);
>  int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
>  			      const struct ldlm_res_id *);
>  
> -#define LDLM_RESOURCE_ADDREF(res) do {					\
> -	lu_ref_add_atomic(&(res)->lr_reference, __func__, current);	\
> -} while (0)
> -
> -#define LDLM_RESOURCE_DELREF(res) do {				\
> -	lu_ref_del(&(res)->lr_reference, __func__, current);	\
> -} while (0)
> -
>  /* ldlm_request.c */
>  /** \defgroup ldlm_local_ast Default AST handlers for local locks
>   * These AST handlers are typically used for server-side local locks and are
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index e09268f08e5c..f7f4db0481b2 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -40,7 +40,6 @@
>  
>  #include <uapi/linux/lustre/lustre_idl.h>
>  #include <lustre_lib.h>
> -#include <lu_ref.h>
>  #include <lustre_export.h>
>  #include <lustre_fid.h>
>  #include <lustre_fld.h>
> @@ -615,12 +614,6 @@ struct obd_device {
>  
>  	int			 obd_conn_inprogress;
>  
> -	/**
> -	 * A list of outstanding class_incref()'s against this obd. For
> -	 * debugging.
> -	 */
> -	struct lu_ref		 obd_reference;
> -
>  	struct kset		 obd_kset; /* sysfs object collection */
>  	struct kobj_type	 obd_ktype;
>  	struct completion	 obd_kobj_unregister;
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index 6789d3bf0485..60a6ec2f7136 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -175,7 +175,6 @@ void ldlm_lock_put(struct ldlm_lock *lock)
>  
>  		lprocfs_counter_decr(ldlm_res_to_ns(res)->ns_stats,
>  				     LDLM_NSS_LOCKS);
> -		lu_ref_del(&res->lr_reference, "lock", lock);
>  		ldlm_resource_putref(res);
>  		lock->l_resource = NULL;
>  		if (lock->l_export) {
> @@ -185,7 +184,6 @@ void ldlm_lock_put(struct ldlm_lock *lock)
>  
>  		kfree(lock->l_lvb_data);
>  
> -		lu_ref_fini(&lock->l_reference);
>  		OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle);
>  	}
>  }
> @@ -334,10 +332,8 @@ static void ldlm_lock_destroy(struct ldlm_lock *lock)
>  	unlock_res_and_lock(lock);
>  
>  	/* drop reference from hashtable only for first destroy */
> -	if (first) {
> -		lu_ref_del(&lock->l_reference, "hash", lock);
> +	if (first)
>  		LDLM_LOCK_RELEASE(lock);
> -	}
>  }
>  
>  /**
> @@ -349,10 +345,8 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock)
>  
>  	first = ldlm_lock_destroy_internal(lock);
>  	/* drop reference from hashtable only for first destroy */
> -	if (first) {
> -		lu_ref_del(&lock->l_reference, "hash", lock);
> +	if (first)
>  		LDLM_LOCK_RELEASE(lock);
> -	}
>  }
>  
>  /* this is called by portals_handle2object with the handle lock taken */
> @@ -392,7 +386,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
>  
>  	spin_lock_init(&lock->l_lock);
>  	lock->l_resource = resource;
> -	lu_ref_add(&resource->lr_reference, "lock", lock);
>  
>  	atomic_set(&lock->l_refc, 2);
>  	INIT_LIST_HEAD(&lock->l_res_link);
> @@ -412,8 +405,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
>  	INIT_LIST_HEAD(&lock->l_handle.h_link);
>  	class_handle_hash(&lock->l_handle, &lock_handle_ops);
>  
> -	lu_ref_init(&lock->l_reference);
> -	lu_ref_add(&lock->l_reference, "hash", lock);
>  	lock->l_callback_timeout = 0;
>  
>  #if LUSTRE_TRACKS_LOCK_EXP_REFS
> @@ -457,7 +448,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock,
>  	if (IS_ERR(newres))
>  		return PTR_ERR(newres);
>  
> -	lu_ref_add(&newres->lr_reference, "lock", lock);
>  	/*
>  	 * To flip the lock from the old to the new resource, lock, oldres and
>  	 * newres have to be locked. Resource spin-locks are nested within
> @@ -480,7 +470,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock,
>  	unlock_res_and_lock(lock);
>  
>  	/* ...and the flowers are still standing! */
> -	lu_ref_del(&oldres->lr_reference, "lock", lock);
>  	ldlm_resource_putref(oldres);
>  
>  	return 0;
> @@ -528,16 +517,13 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
>  	/* It's unlikely but possible that someone marked the lock as
>  	 * destroyed after we did handle2object on it
>  	 */
> -	if (flags == 0 && !ldlm_is_destroyed(lock)) {
> -		lu_ref_add(&lock->l_reference, "handle", current);
> +	if (flags == 0 && !ldlm_is_destroyed(lock))
>  		return lock;
> -	}
>  
>  	lock_res_and_lock(lock);
>  
>  	LASSERT(lock->l_resource);
>  
> -	lu_ref_add_atomic(&lock->l_reference, "handle", current);
>  	if (unlikely(ldlm_is_destroyed(lock))) {
>  		unlock_res_and_lock(lock);
>  		CDEBUG(D_INFO, "lock already destroyed: lock %p\n", lock);
> @@ -658,16 +644,13 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock,
>  				      enum ldlm_mode mode)
>  {
>  	ldlm_lock_remove_from_lru(lock);
> -	if (mode & (LCK_NL | LCK_CR | LCK_PR)) {
> +	if (mode & (LCK_NL | LCK_CR | LCK_PR))
>  		lock->l_readers++;
> -		lu_ref_add_atomic(&lock->l_reference, "reader", lock);
> -	}
> -	if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) {
> +
> +	if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS))
>  		lock->l_writers++;
> -		lu_ref_add_atomic(&lock->l_reference, "writer", lock);
> -	}
> +
>  	LDLM_LOCK_GET(lock);
> -	lu_ref_add_atomic(&lock->l_reference, "user", lock);
>  	LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]);
>  }
>  
> @@ -725,16 +708,13 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock,
>  	LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]);
>  	if (mode & (LCK_NL | LCK_CR | LCK_PR)) {
>  		LASSERT(lock->l_readers > 0);
> -		lu_ref_del(&lock->l_reference, "reader", lock);
>  		lock->l_readers--;
>  	}
>  	if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) {
>  		LASSERT(lock->l_writers > 0);
> -		lu_ref_del(&lock->l_reference, "writer", lock);
>  		lock->l_writers--;
>  	}
>  
> -	lu_ref_del(&lock->l_reference, "user", lock);
>  	LDLM_LOCK_RELEASE(lock);    /* matches the LDLM_LOCK_GET() in addref */
>  }
>  
> @@ -1285,7 +1265,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags,
>  		return 0;
>  	}
>  
> -	LDLM_RESOURCE_ADDREF(res);
>  	lock_res(res);
>  
>  	if (res->lr_type == LDLM_EXTENT)
> @@ -1307,7 +1286,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags,
>  	}
>  out:
>  	unlock_res(res);
> -	LDLM_RESOURCE_DELREF(res);
>  	ldlm_resource_putref(res);
>  
>  	if (lock) {
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index b819adef2bfe..1f04a782bd89 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -1423,7 +1423,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
>  
>  		LDLM_LOCK_GET(lock);
>  		spin_unlock(&ns->ns_lock);
> -		lu_ref_add(&lock->l_reference, __func__, current);
>  
>  		/* Pass the lock through the policy filter and see if it
>  		 * should stay in LRU.
> @@ -1441,15 +1440,11 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
>  		 */
>  		result = pf(ns, lock, unused, added, count);
>  		if (result == LDLM_POLICY_KEEP_LOCK) {
> -			lu_ref_del(&lock->l_reference,
> -				   __func__, current);
>  			LDLM_LOCK_RELEASE(lock);
>  			spin_lock(&ns->ns_lock);
>  			break;
>  		}
>  		if (result == LDLM_POLICY_SKIP_LOCK) {
> -			lu_ref_del(&lock->l_reference,
> -				   __func__, current);
>  			LDLM_LOCK_RELEASE(lock);
>  			spin_lock(&ns->ns_lock);
>  			continue;
> @@ -1467,8 +1462,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
>  			 * pages could be put under it.
>  			 */
>  			unlock_res_and_lock(lock);
> -			lu_ref_del(&lock->l_reference,
> -				   __func__, current);
>  			LDLM_LOCK_RELEASE(lock);
>  			spin_lock(&ns->ns_lock);
>  			continue;
> @@ -1507,7 +1500,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
>  		LASSERT(list_empty(&lock->l_bl_ast));
>  		list_add(&lock->l_bl_ast, cancels);
>  		unlock_res_and_lock(lock);
> -		lu_ref_del(&lock->l_reference, __func__, current);
>  		spin_lock(&ns->ns_lock);
>  		added++;
>  		unused--;
> @@ -1695,7 +1687,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
>  		return 0;
>  	}
>  
> -	LDLM_RESOURCE_ADDREF(res);
>  	count = ldlm_cancel_resource_local(res, &cancels, policy, mode,
>  					   0, flags | LCF_BL_AST, opaque);
>  	rc = ldlm_cli_cancel_list(&cancels, count, NULL, flags);
> @@ -1703,7 +1694,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
>  		CERROR("canceling unused lock " DLDLMRES ": rc = %d\n",
>  		       PLDLMRES(res), rc);
>  
> -	LDLM_RESOURCE_DELREF(res);
>  	ldlm_resource_putref(res);
>  	return 0;
>  }
> @@ -1843,9 +1833,7 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns,
>  	if (IS_ERR(res))
>  		return 0;
>  
> -	LDLM_RESOURCE_ADDREF(res);
>  	rc = ldlm_resource_foreach(res, iter, data);
> -	LDLM_RESOURCE_DELREF(res);
>  	ldlm_resource_putref(res);
>  	return rc;
>  }
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index ae2fddd044ea..371cc1d5e539 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -1021,7 +1021,6 @@ static struct ldlm_resource *ldlm_resource_new(enum ldlm_type ldlm_type)
>  
>  	atomic_set(&res->lr_refcount, 1);
>  	spin_lock_init(&res->lr_lock);
> -	lu_ref_init(&res->lr_reference);
>  
>  	/* The creator of the resource must unlock the mutex after LVB
>  	 * initialization.
> @@ -1084,8 +1083,6 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
>  	if (hnode) {
>  		/* Someone won the race and already added the resource. */
>  		cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
> -		/* Clean lu_ref for failed resource. */
> -		lu_ref_fini(&res->lr_reference);
>  		/* We have taken lr_lvb_mutex. Drop it. */
>  		mutex_unlock(&res->lr_lvb_mutex);
>  		if (res->lr_itree)
> @@ -1163,7 +1160,6 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
>  
>  	cfs_hash_bd_del_locked(ns->ns_rs_hash,
>  			       bd, &res->lr_hash);
> -	lu_ref_fini(&res->lr_reference);
>  	cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
>  	if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
>  		ns->ns_lvbo->lvbo_free(res);
> diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
> index afcaa5ec13c2..94299fc2f5e3 100644
> --- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c
> +++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c
> @@ -179,7 +179,6 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md)
>  			 * locked by I_NEW bit.
>  			 */
>  			lli->lli_clob = clob;
> -			lu_object_ref_add(&clob->co_lu, "inode", inode);
>  		} else {
>  			result = PTR_ERR(clob);
>  		}
> @@ -254,7 +253,6 @@ void cl_inode_fini(struct inode *inode)
>  		 * when its master is evicted.
>  		 */
>  		cl_object_kill(env, clob);
> -		lu_object_ref_del(&clob->co_lu, "inode", inode);
>  		cl_object_put_last(env, clob);
>  		lli->lli_clob = NULL;
>  		if (emergency)
> diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c
> index af983ee09e8e..185d1692d79b 100644
> --- a/drivers/staging/lustre/lustre/llite/rw.c
> +++ b/drivers/staging/lustre/lustre/llite/rw.c
> @@ -209,7 +209,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io,
>  		goto out;
>  	}
>  
> -	lu_ref_add(&page->cp_reference, "ra", current);
>  	cl_page_assume(env, io, page);
>  	vpg = cl2vvp_page(cl_object_page_slice(clob, page));
>  	if (!vpg->vpg_defer_uptodate && !PageUptodate(vmpage)) {
> @@ -225,7 +224,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io,
>  		rc = 1;
>  	}
>  
> -	lu_ref_del(&page->cp_reference, "ra", current);
>  	cl_page_put(env, page);
>  out:
>  	if (vmpage) {
> @@ -936,8 +934,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
>  		page = cl_page_find(env, clob, vmpage->index,
>  				    vmpage, CPT_CACHEABLE);
>  		if (!IS_ERR(page)) {
> -			lu_ref_add(&page->cp_reference, "writepage",
> -				   current);
>  			cl_page_assume(env, io, page);
>  			result = cl_page_flush(env, io, page);
>  			if (result != 0) {
> @@ -954,8 +950,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
>  			}
>  			cl_page_disown(env, io, page);
>  			unlocked = true;
> -			lu_ref_del(&page->cp_reference,
> -				   "writepage", current);
>  			cl_page_put(env, page);
>  		} else {
>  			result = PTR_ERR(page);
> diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c
> index e4ce3b6f5772..9bcbc8b084e5 100644
> --- a/drivers/staging/lustre/lustre/llite/rw26.c
> +++ b/drivers/staging/lustre/lustre/llite/rw26.c
> @@ -482,7 +482,6 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
>  	}
>  
>  	lcc->lcc_page = page;
> -	lu_ref_add(&page->cp_reference, "cl_io", io);
>  
>  	cl_page_assume(env, io, page);
>  	if (!PageUptodate(vmpage)) {
> @@ -511,10 +510,8 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
>  			unlock_page(vmpage);
>  			put_page(vmpage);
>  		}
> -		if (!IS_ERR_OR_NULL(page)) {
> -			lu_ref_del(&page->cp_reference, "cl_io", io);
> +		if (!IS_ERR_OR_NULL(page))
>  			cl_page_put(env, page);
> -		}
>  		if (io)
>  			io->ci_result = result;
>  	} else {
> @@ -575,7 +572,6 @@ static int ll_write_end(struct file *file, struct address_space *mapping,
>  		cl_page_disown(env, io, page);
>  
>  		lcc->lcc_page = NULL;
> -		lu_ref_del(&page->cp_reference, "cl_io", io);
>  		cl_page_put(env, page);
>  
>  		/* page list is not contiguous now, commit it now */
> diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c
> index c10ca6e7c606..34206166ada4 100644
> --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
> +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
> @@ -240,10 +240,9 @@ static int vvp_device_init(const struct lu_env *env, struct lu_device *d,
>  	rc = next->ld_type->ldt_ops->ldto_device_init(env, next,
>  						      next->ld_type->ldt_name,
>  						      NULL);
> -	if (rc == 0) {
> +	if (rc == 0)
>  		lu_device_get(next);
> -		lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init);
> -	}
> +
>  	return rc;
>  }
>  
> @@ -420,10 +419,9 @@ static struct cl_object *vvp_pgcache_obj(const struct lu_env *env,
>  		struct lu_object *lu_obj;
>  
>  		lu_obj = lu_object_locate(id->vpi_obj, dev->ld_type);
> -		if (lu_obj) {
> -			lu_object_ref_add(lu_obj, "dump", current);
> +		if (lu_obj)
>  			return lu2cl(lu_obj);
> -		}
> +
>  		lu_object_put(env, lu_object_top(id->vpi_obj));
>  	}
>  	return NULL;
> @@ -456,7 +454,6 @@ static struct page *vvp_pgcache_current(struct vvp_seq_private *priv)
>  			priv->vsp_id.vpi_index = vmpage->index;
>  			return vmpage;
>  		}
> -		lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current);
>  		cl_object_put(priv->vsp_env, priv->vsp_clob);
>  		priv->vsp_clob = NULL;
>  		priv->vsp_id.vpi_index = 0;
> @@ -527,11 +524,8 @@ static void vvp_pgcache_rewind(struct vvp_seq_private *priv)
>  	if (priv->vsp_prev_pos) {
>  		memset(&priv->vsp_id, 0, sizeof(priv->vsp_id));
>  		priv->vsp_prev_pos = 0;
> -		if (priv->vsp_clob) {
> -			lu_object_ref_del(&priv->vsp_clob->co_lu, "dump",
> -					  current);
> +		if (priv->vsp_clob)
>  			cl_object_put(priv->vsp_env, priv->vsp_clob);
> -		}
>  		priv->vsp_clob = NULL;
>  	}
>  }
> @@ -607,10 +601,8 @@ static int vvp_dump_pgcache_seq_release(struct inode *inode, struct file *file)
>  	struct seq_file *seq = file->private_data;
>  	struct vvp_seq_private *priv = seq->private;
>  
> -	if (priv->vsp_clob) {
> -		lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current);
> +	if (priv->vsp_clob)
>  		cl_object_put(priv->vsp_env, priv->vsp_clob);
> -	}
>  
>  	cl_env_put(priv->vsp_env, &priv->vsp_refcheck);
>  	return seq_release_private(inode, file);
> diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c
> index 593b10cecf7d..62b507926c20 100644
> --- a/drivers/staging/lustre/lustre/llite/vvp_io.c
> +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c
> @@ -382,7 +382,6 @@ static void vvp_io_fault_fini(const struct lu_env *env,
>  	CLOBINVRNT(env, io->ci_obj, vvp_object_invariant(io->ci_obj));
>  
>  	if (page) {
> -		lu_ref_del(&page->cp_reference, "fault", io);
>  		cl_page_put(env, page);
>  		io->u.ci_fault.ft_page = NULL;
>  	}
> @@ -824,7 +823,6 @@ static int vvp_io_commit_sync(const struct lu_env *env, struct cl_io *io,
>  			cl_page_disown(env, io, page);
>  
>  			/* held in ll_cl_init() */
> -			lu_ref_del(&page->cp_reference, "cl_io", io);
>  			cl_page_put(env, page);
>  		}
>  	}
> @@ -843,7 +841,6 @@ static void write_commit_callback(const struct lu_env *env, struct cl_io *io,
>  	cl_page_disown(env, io, page);
>  
>  	/* held in ll_cl_init() */
> -	lu_ref_del(&page->cp_reference, "cl_io", cl_io_top(io));
>  	cl_page_put(env, page);
>  }
>  
> @@ -944,7 +941,6 @@ int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io)
>  		cl_page_disown(env, io, page);
>  
>  		/* held in ll_cl_init() */
> -		lu_ref_del(&page->cp_reference, "cl_io", io);
>  		cl_page_put(env, page);
>  	}
>  	cl_page_list_fini(env, queue);
> @@ -1260,7 +1256,6 @@ static int vvp_io_fault_start(const struct lu_env *env,
>  	else
>  		fio->ft_nob = cl_page_size(obj);
>  
> -	lu_ref_add(&page->cp_reference, "fault", io);
>  	fio->ft_page = page;
>  
>  out:
> diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c
> index 397ecc1dbb4c..cde8215a0b4c 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_object.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_object.c
> @@ -149,7 +149,6 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov,
>  		subhdr->coh_parent = hdr;
>  		spin_unlock(&subhdr->coh_attr_guard);
>  		subhdr->coh_nesting = hdr->coh_nesting + 1;
> -		lu_object_ref_add(&subobj->co_lu, "lov-parent", lov);
>  		r0->lo_sub[stripe] = cl2lovsub(subobj);
>  		r0->lo_sub[stripe]->lso_super = lov;
>  		r0->lo_sub[stripe]->lso_index = idx;
> @@ -405,7 +404,6 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
>  
>  	cl_object_kill(env, sub);
>  	/* release a reference to the sub-object and ... */
> -	lu_object_ref_del(&sub->co_lu, "lov-parent", lov);
>  	cl_object_put(env, sub);
>  
>  	/* ... wait until it is actually destroyed---sub-object clears its
> diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
> index 69380fc6aeab..d9b044e5aca1 100644
> --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c
> +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
> @@ -65,7 +65,6 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d,
>  	}
>  
>  	lu_device_get(next);
> -	lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init);
>  	lsd->acid_next = lu2cl_dev(next);
>  	return rc;
>  }
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
> index e0e7b00fd2be..e878bc76da8a 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
> @@ -87,12 +87,10 @@ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
>  				NULL, &res_id, 0, 0);
>  	if (IS_ERR(res))
>  		return 0;
> -	LDLM_RESOURCE_ADDREF(res);
>  	/* Initialize ibits lock policy. */
>  	policy.l_inodebits.bits = bits;
>  	count = ldlm_cancel_resource_local(res, cancels, &policy,
>  					   mode, 0, 0, NULL);
> -	LDLM_RESOURCE_DELREF(res);
>  	ldlm_resource_putref(res);
>  	return count;
>  }
> diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
> index 1669c24a0b03..ee63ebd3947b 100644
> --- a/drivers/staging/lustre/lustre/obdclass/Makefile
> +++ b/drivers/staging/lustre/lustre/obdclass/Makefile
> @@ -7,5 +7,5 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o
>  obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o \
>  	      genops.o obd_sysfs.o lprocfs_status.o lprocfs_counters.o \
>  	      lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \
> -	      obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \
> +	      obdo.o obd_config.o obd_mount.o lu_object.o \
>  	      cl_object.o cl_page.o cl_lock.o cl_io.o kernelcomm.o
> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
> index 3b4aca4e4a53..9755174c2db6 100644
> --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
> +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
> @@ -770,7 +770,6 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page)
>  	LASSERT(list_empty(&page->cp_batch));
>  	list_add_tail(&page->cp_batch, &plist->pl_pages);
>  	++plist->pl_nr;
> -	lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist);
>  	cl_page_get(page);
>  }
>  EXPORT_SYMBOL(cl_page_list_add);
> @@ -787,7 +786,6 @@ void cl_page_list_del(const struct lu_env *env, struct cl_page_list *plist,
>  
>  	list_del_init(&page->cp_batch);
>  	--plist->pl_nr;
> -	lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist);
>  	cl_page_put(env, page);
>  }
>  EXPORT_SYMBOL(cl_page_list_del);
> @@ -805,8 +803,6 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src,
>  	list_move_tail(&page->cp_batch, &dst->pl_pages);
>  	--src->pl_nr;
>  	++dst->pl_nr;
> -	lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue",
> -		      src, dst);
>  }
>  EXPORT_SYMBOL(cl_page_list_move);
>  
> @@ -823,8 +819,6 @@ void cl_page_list_move_head(struct cl_page_list *dst, struct cl_page_list *src,
>  	list_move(&page->cp_batch, &dst->pl_pages);
>  	--src->pl_nr;
>  	++dst->pl_nr;
> -	lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue",
> -		      src, dst);
>  }
>  EXPORT_SYMBOL(cl_page_list_move_head);
>  
> @@ -869,8 +863,6 @@ void cl_page_list_disown(const struct lu_env *env,
>  		 * XXX __cl_page_disown() will fail if page is not locked.
>  		 */
>  		__cl_page_disown(env, io, page);
> -		lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue",
> -			      plist);
>  		cl_page_put(env, page);
>  	}
>  }
> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
> index b09621f0f1f8..c7cf2e736ff7 100644
> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
> @@ -924,8 +924,6 @@ struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site,
>  		rc = ldt->ldt_ops->ldto_device_init(env, d, typename, next);
>  		if (rc == 0) {
>  			lu_device_get(d);
> -			lu_ref_add(&d->ld_reference,
> -				   "lu-stack", &lu_site_init);
>  		} else {
>  			ldt->ldt_ops->ldto_device_free(env, d);
>  			CERROR("can't init device '%s', %d\n", typename, rc);
> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c
> index 7dcd3aff229f..a44533a063df 100644
> --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
> +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
> @@ -106,9 +106,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page)
>  		if (unlikely(slice->cpl_ops->cpo_fini))
>  			slice->cpl_ops->cpo_fini(env, slice);
>  	}
> -	lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page);
>  	cl_object_put(env, obj);
> -	lu_ref_fini(&page->cp_reference);
>  	kfree(page);
>  }
>  
> @@ -138,14 +136,11 @@ struct cl_page *cl_page_alloc(const struct lu_env *env,
>  		refcount_set(&page->cp_ref, 1);
>  		page->cp_obj = o;
>  		cl_object_get(o);
> -		lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page",
> -				     page);
>  		page->cp_vmpage = vmpage;
>  		cl_page_state_set_trust(page, CPS_CACHED);
>  		page->cp_type = type;
>  		INIT_LIST_HEAD(&page->cp_layers);
>  		INIT_LIST_HEAD(&page->cp_batch);
> -		lu_ref_init(&page->cp_reference);
>  		cl_object_for_each(o2, o) {
>  			if (o2->co_ops->coo_page_init) {
>  				result = o2->co_ops->coo_page_init(env, o2, page,
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index c91704d87042..ce92c8c1dc75 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -80,7 +80,6 @@ static void obd_device_free(struct obd_device *obd)
>  		       obd, obd->obd_namespace, obd->obd_force);
>  		LBUG();
>  	}
> -	lu_ref_fini(&obd->obd_reference);
>  	kmem_cache_free(obd_device_cachep, obd);
>  }
>  
> @@ -314,8 +313,6 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
>  	llog_group_init(&newdev->obd_olg);
>  	/* Detach drops this */
>  	atomic_set(&newdev->obd_refcount, 1);
> -	lu_ref_init(&newdev->obd_reference);
> -	lu_ref_add(&newdev->obd_reference, "newdev", newdev);
>  
>  	newdev->obd_conn_inprogress = 0;
>  
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> index 3e23babb329a..6a1c3bc3e9e8 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> @@ -52,7 +52,6 @@
>  #include <lustre_fid.h>
>  #include <lu_object.h>
>  #include <cl_object.h>
> -#include <lu_ref.h>
>  #include <linux/list.h>
>  
>  struct lu_site_bkt_data {
> @@ -1018,7 +1017,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top)
>  	s->ls_top_dev = top;
>  	top->ld_site = s;
>  	lu_device_get(top);
> -	lu_ref_add(&top->ld_reference, "site-top", s);
>  
>  	INIT_LIST_HEAD(&s->ls_ld_linkage);
>  	spin_lock_init(&s->ls_ld_lock);
> @@ -1047,7 +1045,6 @@ void lu_site_fini(struct lu_site *s)
>  
>  	if (s->ls_top_dev) {
>  		s->ls_top_dev->ld_site = NULL;
> -		lu_ref_del(&s->ls_top_dev->ld_reference, "site-top", s);
>  		lu_device_put(s->ls_top_dev);
>  		s->ls_top_dev = NULL;
>  	}
> @@ -1104,7 +1101,6 @@ int lu_device_init(struct lu_device *d, struct lu_device_type *t)
>  	memset(d, 0, sizeof(*d));
>  	atomic_set(&d->ld_ref, 0);
>  	d->ld_type = t;
> -	lu_ref_init(&d->ld_reference);
>  	INIT_LIST_HEAD(&d->ld_linkage);
>  	return 0;
>  }
> @@ -1122,7 +1118,6 @@ void lu_device_fini(struct lu_device *d)
>  		d->ld_obd = NULL;
>  	}
>  
> -	lu_ref_fini(&d->ld_reference);
>  	LASSERTF(atomic_read(&d->ld_ref) == 0,
>  		 "Refcount is %u\n", atomic_read(&d->ld_ref));
>  	LASSERT(atomic_read(&t->ldt_device_nr) > 0);
> @@ -1144,7 +1139,6 @@ int lu_object_init(struct lu_object *o, struct lu_object_header *h,
>  	o->lo_header = h;
>  	o->lo_dev = d;
>  	lu_device_get(d);
> -	lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o);
>  	INIT_LIST_HEAD(&o->lo_linkage);
>  
>  	return 0;
> @@ -1161,8 +1155,6 @@ void lu_object_fini(struct lu_object *o)
>  	LASSERT(list_empty(&o->lo_linkage));
>  
>  	if (dev) {
> -		lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref,
> -			      "lu_object", o);
>  		lu_device_put(dev);
>  		o->lo_dev = NULL;
>  	}
> @@ -1203,7 +1195,6 @@ int lu_object_header_init(struct lu_object_header *h)
>  	INIT_HLIST_NODE(&h->loh_hash);
>  	INIT_LIST_HEAD(&h->loh_lru);
>  	INIT_LIST_HEAD(&h->loh_layers);
> -	lu_ref_init(&h->loh_reference);
>  	return 0;
>  }
>  EXPORT_SYMBOL(lu_object_header_init);
> @@ -1216,7 +1207,6 @@ void lu_object_header_fini(struct lu_object_header *h)
>  	LASSERT(list_empty(&h->loh_layers));
>  	LASSERT(list_empty(&h->loh_lru));
>  	LASSERT(hlist_unhashed(&h->loh_hash));
> -	lu_ref_fini(&h->loh_reference);
>  }
>  EXPORT_SYMBOL(lu_object_header_fini);
>  
> @@ -1253,7 +1243,6 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top)
>  	lu_site_purge(env, site, ~0);
>  	for (scan = top; scan; scan = next) {
>  		next = scan->ld_type->ldt_ops->ldto_device_fini(env, scan);
> -		lu_ref_del(&scan->ld_reference, "lu-stack", &lu_site_init);
>  		lu_device_put(scan);
>  	}
>  
> @@ -1306,7 +1295,6 @@ int lu_context_key_register(struct lu_context_key *key)
>  
>  	result = -ENFILE;
>  	atomic_set(&key->lct_used, 1);
> -	lu_ref_init(&key->lct_reference);
>  	for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
>  		if (lu_keys[i])
>  			continue;
> @@ -1318,10 +1306,9 @@ int lu_context_key_register(struct lu_context_key *key)
>  		atomic_inc(&key_set_version);
>  		break;
>  	}
> -	if (result) {
> -		lu_ref_fini(&key->lct_reference);
> +	if (result)
>  		atomic_set(&key->lct_used, 0);
> -	}
> +
>  	return result;
>  }
>  EXPORT_SYMBOL(lu_context_key_register);
> @@ -1335,7 +1322,6 @@ static void key_fini(struct lu_context *ctx, int index)
>  		LASSERT(atomic_read(&key->lct_used) > 1);
>  
>  		key->lct_fini(ctx, key, ctx->lc_value[index]);
> -		lu_ref_del(&key->lct_reference, "ctx", ctx);
>  		if (atomic_dec_and_test(&key->lct_used))
>  			wake_up_var(&key->lct_used);
>  
> @@ -1364,8 +1350,7 @@ void lu_context_key_degister(struct lu_context_key *key)
>  	atomic_dec(&key->lct_used);
>  	wait_var_event(&key->lct_used, atomic_read(&key->lct_used) == 0);
>  
> -	if (!WARN_ON(lu_keys[key->lct_index] == NULL))
> -		lu_ref_fini(&key->lct_reference);
> +	WARN_ON(lu_keys[key->lct_index] == NULL);
>  	smp_store_release(&lu_keys[key->lct_index], NULL);
>  }
>  EXPORT_SYMBOL(lu_context_key_degister);
> @@ -1562,7 +1547,6 @@ static int keys_fill(struct lu_context *ctx)
>  				break;
>  			}
>  
> -			lu_ref_add_atomic(&key->lct_reference, "ctx", ctx);
>  			atomic_inc(&key->lct_used);
>  			/*
>  			 * This is the only place in the code, where an
> @@ -1873,16 +1857,10 @@ int lu_global_init(void)
>  
>  	CDEBUG(D_INFO, "Lustre LU module (%p).\n", &lu_keys);
>  
> -	result = lu_ref_global_init();
> -	if (result != 0)
> -		return result;
> -
>  	LU_CONTEXT_KEY_INIT(&lu_global_key);
>  	result = lu_context_key_register(&lu_global_key);
> -	if (result != 0) {
> -		lu_ref_global_fini();
> +	if (result != 0)
>  		return result;
> -	}
>  
>  	/*
>  	 * At this level, we don't know what tags are needed, so allocate them
> @@ -1894,7 +1872,6 @@ int lu_global_init(void)
>  	up_write(&lu_sites_guard);
>  	if (result != 0) {
>  		lu_context_key_degister(&lu_global_key);
> -		lu_ref_global_fini();
>  		return result;
>  	}
>  
> @@ -1912,7 +1889,6 @@ int lu_global_init(void)
>  		lu_env_fini(&lu_shrink_env);
>  		up_write(&lu_sites_guard);
>  
> -		lu_ref_global_fini();
>  		return result;
>  	}
>  
> @@ -1934,8 +1910,6 @@ void lu_global_fini(void)
>  	down_write(&lu_sites_guard);
>  	lu_env_fini(&lu_shrink_env);
>  	up_write(&lu_sites_guard);
> -
> -	lu_ref_global_fini();
>  }
>  
>  static u32 ls_stats_read(struct lprocfs_stats *stats, int idx)
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c
> deleted file mode 100644
> index f67cb89ea0ba..000000000000
> --- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c
> +++ /dev/null
> @@ -1,45 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - *
> - * Copyright (c) 2012, Intel Corporation.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - *
> - * lustre/obdclass/lu_ref.c
> - *
> - * Lustre reference.
> - *
> - *   Author: Nikita Danilov <nikita.danilov@sun.com>
> - */
> -
> -#define DEBUG_SUBSYSTEM S_CLASS
> -
> -#include <obd.h>
> -#include <obd_class.h>
> -#include <obd_support.h>
> -#include <lu_ref.h>
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> index 0cdadea4e63c..45e8f03dec80 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> @@ -520,7 +520,6 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
>  struct obd_device *class_incref(struct obd_device *obd,
>  				const char *scope, const void *source)
>  {
> -	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));
> @@ -538,7 +537,6 @@ void class_decref(struct obd_device *obd, const char *scope, const void *source)
>  
>  	LASSERT(obd->obd_num_exports >= 0);
>  	last = atomic_dec_and_test(&obd->obd_refcount);
> -	lu_ref_del(&obd->obd_reference, scope, source);
>  
>  	if (last) {
>  		struct obd_export *exp;
> diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
> index 4359a9320f37..81af452fbd85 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_cache.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
> @@ -388,8 +388,6 @@ static void osc_extent_free(struct kref *kref)
>  	LASSERT(RB_EMPTY_NODE(&ext->oe_node));
>  
>  	if (ext->oe_dlmlock) {
> -		lu_ref_add(&ext->oe_dlmlock->l_reference,
> -			   "osc_extent", ext);
>  		LDLM_LOCK_PUT(ext->oe_dlmlock);
>  		ext->oe_dlmlock = NULL;
>  	}
> @@ -731,7 +729,6 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
>  	if (olck->ols_dlmlock) {
>  		LASSERT(olck->ols_hold);
>  		cur->oe_dlmlock = LDLM_LOCK_GET(olck->ols_dlmlock);
> -		lu_ref_add(&olck->ols_dlmlock->l_reference, "osc_extent", cur);
>  	}
>  
>  	/* grants has been allocated by caller */
> @@ -1039,7 +1036,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
>  		list_del_init(&oap->oap_pending_item);
>  
>  		cl_page_get(page);
> -		lu_ref_add(&page->cp_reference, "truncate", current);
>  
>  		if (cl_page_own(env, io, page) == 0) {
>  			cl_page_discard(env, io, page);
> @@ -1049,7 +1045,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
>  			LASSERT(0);
>  		}
>  
> -		lu_ref_del(&page->cp_reference, "truncate", current);
>  		cl_page_put(env, page);
>  
>  		--ext->oe_nr_pages;
> @@ -1386,7 +1381,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
>  	 * released in cl_page_completion() and nothing except for the
>  	 * reference counter protects page from concurrent reclaim.
>  	 */
> -	lu_ref_del(&page->cp_reference, "transfer", page);
>  
>  	cl_page_completion(env, page, crt, rc);
>  	cl_page_put(env, page);
> @@ -2208,7 +2202,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
>  	spin_lock(&cli->cl_loi_list_lock);
>  	while ((osc = osc_next_obj(cli)) != NULL) {
>  		struct cl_object *obj = osc2cl(osc);
> -		struct lu_ref_link link;
>  
>  		OSC_IO_DEBUG(osc, "%lu in flight\n", rpcs_in_flight(cli));
>  
> @@ -2219,7 +2212,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
>  
>  		cl_object_get(obj);
>  		spin_unlock(&cli->cl_loi_list_lock);
> -		lu_object_ref_add_at(&obj->co_lu, &link, "check", current);
>  
>  		/* attempt some read/write balancing by alternating between
>  		 * reads and writes in an object.  The makes_rpc checks here
> @@ -2256,7 +2248,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
>  			CERROR("Read request failed with %d\n", rc);
>  
>  		osc_list_maint(cli, osc);
> -		lu_object_ref_del_at(&obj->co_lu, &link, "check", current);
>  		cl_object_put(env, obj);
>  
>  		spin_lock(&cli->cl_loi_list_lock);
> @@ -3065,8 +3056,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
>  				continue;
>  
>  			cl_page_get(page);
> -			lu_ref_add_atomic(&page->cp_reference,
> -					  "gang_lookup", current);
>  			pvec[j++] = ops;
>  		}
>  		++idx;
> @@ -3088,7 +3077,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
>  				res = (*cb)(env, io, ops, cbdata);
>  
>  			page = ops->ops_cl.cpl_page;
> -			lu_ref_del(&page->cp_reference, "gang_lookup", current);
>  			cl_page_put(env, page);
>  		}
>  		if (nr < OTI_PVEC_SIZE || end_of_region)
> diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c
> index bfc1abb47b49..ccdbdeffd1f3 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_lock.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c
> @@ -239,7 +239,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *oscl,
>  	/* lock reference taken by ldlm_handle2lock_long() is
>  	 * owned by osc_lock and released in osc_lock_detach()
>  	 */
> -	lu_ref_add(&dlmlock->l_reference, "osc_lock", oscl);
>  	oscl->ols_has_ref = 1;
>  
>  	LASSERT(!oscl->ols_dlmlock);
> @@ -1031,7 +1030,6 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck)
>  
>  	/* release a reference taken in osc_lock_upcall(). */
>  	LASSERT(olck->ols_has_ref);
> -	lu_ref_del(&dlmlock->l_reference, "osc_lock", olck);
>  	LDLM_LOCK_RELEASE(dlmlock);
>  	olck->ols_has_ref = 0;
>  }
> diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
> index ce911b82512d..3ee7f14f7c7a 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_page.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_page.c
> @@ -61,7 +61,6 @@ static void osc_page_transfer_get(struct osc_page *opg, const char *label)
>  
>  	LASSERT(!opg->ops_transfer_pinned);
>  	cl_page_get(page);
> -	lu_ref_add_atomic(&page->cp_reference, label, page);
>  	opg->ops_transfer_pinned = 1;
>  }
>  
> @@ -72,7 +71,6 @@ static void osc_page_transfer_put(const struct lu_env *env,
>  
>  	if (opg->ops_transfer_pinned) {
>  		opg->ops_transfer_pinned = 0;
> -		lu_ref_del(&page->cp_reference, "transfer", page);
>  		cl_page_put(env, page);
>  	}
>  }
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 765b5a7b9662..6ba443be1026 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -556,10 +556,8 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa,
>  	if (IS_ERR(res))
>  		return 0;
>  
> -	LDLM_RESOURCE_ADDREF(res);
>  	count = ldlm_cancel_resource_local(res, cancels, NULL, mode,
>  					   lock_flags, 0, NULL);
> -	LDLM_RESOURCE_DELREF(res);
>  	ldlm_resource_putref(res);
>  	return count;
>  }
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock NeilBrown
@ 2019-02-24 20:29   ` James Simmons
  2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-24 20:29 UTC (permalink / raw)
  To: lustre-devel


> This lock is unused on the client (and on the server,
> it has been changed to a mutex).

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_log.h |    1 -
>  drivers/staging/lustre/lustre/obdclass/llog.c      |    1 -
>  2 files changed, 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h
> index a576d40f03f7..e96bd6ab0fa4 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_log.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_log.h
> @@ -212,7 +212,6 @@ struct llog_operations {
>  /* In-memory descriptor for a log object or log catalog */
>  struct llog_handle {
>  	struct rw_semaphore	 lgh_lock;
> -	spinlock_t		 lgh_hdr_lock; /* protect lgh_hdr data */
>  	struct llog_logid	 lgh_id; /* id of this log */
>  	struct llog_log_hdr	*lgh_hdr;
>  	size_t			 lgh_hdr_size;
> diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
> index 7aa459bb444e..9d161c16c2f9 100644
> --- a/drivers/staging/lustre/lustre/obdclass/llog.c
> +++ b/drivers/staging/lustre/lustre/obdclass/llog.c
> @@ -64,7 +64,6 @@ static struct llog_handle *llog_alloc_handle(void)
>  		return NULL;
>  
>  	init_rwsem(&loghandle->lgh_lock);
> -	spin_lock_init(&loghandle->lgh_hdr_lock);
>  	INIT_LIST_HEAD(&loghandle->u.phd.phd_entry);
>  	atomic_set(&loghandle->lgh_refcount, 1);
>  
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock NeilBrown
  2019-02-24 20:29   ` James Simmons
@ 2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel



> On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> This lock is unused on the client (and on the server,
> it has been changed to a mutex).
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>


> ---
> drivers/staging/lustre/lustre/include/lustre_log.h |    1 -
> drivers/staging/lustre/lustre/obdclass/llog.c      |    1 -
> 2 files changed, 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h
> index a576d40f03f7..e96bd6ab0fa4 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_log.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_log.h
> @@ -212,7 +212,6 @@ struct llog_operations {
> /* In-memory descriptor for a log object or log catalog */
> struct llog_handle {
> 	struct rw_semaphore	 lgh_lock;
> -	spinlock_t		 lgh_hdr_lock; /* protect lgh_hdr data */
> 	struct llog_logid	 lgh_id; /* id of this log */
> 	struct llog_log_hdr	*lgh_hdr;
> 	size_t			 lgh_hdr_size;
> diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
> index 7aa459bb444e..9d161c16c2f9 100644
> --- a/drivers/staging/lustre/lustre/obdclass/llog.c
> +++ b/drivers/staging/lustre/lustre/obdclass/llog.c
> @@ -64,7 +64,6 @@ static struct llog_handle *llog_alloc_handle(void)
> 		return NULL;
> 
> 	init_rwsem(&loghandle->lgh_lock);
> -	spin_lock_init(&loghandle->lgh_hdr_lock);
> 	INIT_LIST_HEAD(&loghandle->u.phd.phd_entry);
> 	atomic_set(&loghandle->lgh_refcount, 1);
> 
> 
> 

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea NeilBrown
@ 2019-02-25 18:16   ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> Much of the linkea functionality is server-only.
> Keep the parts used on the client, but remove the rest.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>


Reviewed-by: Andreas Dilger <adilger@whamcloud.com>


Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref NeilBrown
@ 2019-02-25 18:16   ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> This is a refcount that perfectly fits the
> pattern for kref, so change it to a kref.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t
  2019-02-19  0:09 ` [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t NeilBrown
@ 2019-02-25 18:16   ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> Make this a refcount_t for clarity, and also
> use refcount_dec_and_lock() rather than having separate
> lock and dec calls.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock NeilBrown
@ 2019-02-25 18:16   ` Andreas Dilger
  2019-02-27  0:22     ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> This lock is never held over code that sleeps, and is
> only ever held for short periods of time.
> So a simple spinlock is best.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 27d73c95403d..aed33068ff3c 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
> 	if ((len == 4 && !strncmp(kernbuf, "NONE", len)) ||
> 	    (len == 5 && !strncmp(kernbuf, "clear", len))) {
> 		/* empty string is special case */
> -		down_write(&squash->rsi_sem);
> +		spin_lock(&squash->rsi_lock);
> 		if (!list_empty(&squash->rsi_nosquash_nids))
> 			cfs_free_nidlist(&squash->rsi_nosquash_nids);
> -		up_write(&squash->rsi_sem);
> +		spin_unlock(&squash->rsi_lock);
> 

> @@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
> 	kfree(kernbuf);
> 	kernbuf = NULL;
> 
> -	down_write(&squash->rsi_sem);
> +	spin_lock(&squash->rsi_lock);
> 	if (!list_empty(&squash->rsi_nosquash_nids))
> 		cfs_free_nidlist(&squash->rsi_nosquash_nids);
> 	list_splice(&tmp, &squash->rsi_nosquash_nids);
> -	up_write(&squash->rsi_sem);
> +	spin_unlock(&squash->rsi_lock);


This is held here over cds_free_nidlist(), which has calls to kfree()
internally.  I don't think it is acceptable to hold a spinlock over
kfree() these days?

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines NeilBrown
  2019-02-24 19:07   ` James Simmons
@ 2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> Some of these are unused.
> One is used in a minimal way where it is easier to use
> an explicit number.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>


Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing NeilBrown
  2019-02-24 19:08   ` James Simmons
@ 2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> In lu_cdebug_printer(), is "complete" is true, then
> key->lck_area ends with a newline, so there is no need to
> include on in the format too.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment NeilBrown
  2019-02-24 18:51   ` James Simmons
@ 2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> This patch changes a lot of places that use spaces for
> alignment to instead use tabs - though in one case in a
> comment, spaces are used in place of tabs to be more consistent.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2
  2019-02-19  0:09 ` [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 NeilBrown
  2019-02-24 20:02   ` James Simmons
@ 2019-02-25 18:16   ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> Since 2.6.36, Linux' vsprintf has supported %pV
> which supports "recursive sprintf" - exactly the task
> that libcfs_debug_vmsg2 aims to provide.
> 
> Instead of calling libcfs_debug_vmsg2(), we can put the fmt and
> args in a 'struct va_format', and pass the address of that structure
> to the "%pV" format.
> 
> So do this to remove all users of libcfs_debug_vmsg2().

Interesting.  This code was always more complex than I'd like.

> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2
  2019-02-19  0:09 ` [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2 NeilBrown
@ 2019-02-25 18:16   ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
> 
> Now that libcfs_debug_vmsg2 has no (external) users, we can remove it.
> It is used to implement libcfs_debug_msg(), so simply move
> the body of the function (suitably modified) into that one caller.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc.
  2019-02-24 17:05   ` James Simmons
@ 2019-02-25 18:16     ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-25 18:16 UTC (permalink / raw)
  To: lustre-devel

On Feb 24, 2019, at 09:05, James Simmons <jsimmons@infradead.org> wrote:
> 
> 
>> Passing 0 as the gfp_t for kmalloc() is not meaningful, and
>> could change behaviour.
>> Use an explicit GFP_KERNEL instead.
> 
> Why did it every do this ??????

This is a defect introduced by commit 1b254784381 "LU-1346 libcfs: replace cfs_ memory wrappers".
It replaced cfs_alloc(), which internally supplied the GFP_* mask with kmalloc(), which does not.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables()
  2019-02-24 16:35   ` James Simmons
@ 2019-02-25 22:27     ` NeilBrown
  2019-02-26 22:18       ` James Simmons
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-25 22:27 UTC (permalink / raw)
  To: lustre-devel

On Sun, Feb 24 2019, James Simmons wrote:

> y
>> llite_kobj does not benefit from being in the
>> lustre_kset kset (though it does need lustre_kset
>> as a parent)
>
> Nak.
>
> Yes llite does benefit from being in the kset. On large clusters you
> can end up with 1000s of clients so keeping the sysfs files setting 
> in sync needs to be done in mass. The way Lustre does this is by 
> running on the MGS server 'lctl conf_param $FSNAME.llite.lazystats=1'
> or with the newer 'lctl set_param -P llite.$FSNAME-*.lazystats=1' as
> an example. When this is done on the MGS that new value is first
> persistently stored and then transmitted to the target nodes.
>   
> The magic behind this is with class_process_config(). In the code
> path LCFG_PARAM, which handles the conf_param case' the main function
> is class_modify_config() which is used by both llite and the obd
> devices. This function first attempts to find the sysfs attribute
> from the kobject and call lustre_attr_store() directly to set it.
> If it can't find the attribute, which means its a debugfs file
> most likely, then a uevent is created and sent off. The udev rule
> then exexcutes some application to handle the debugfs settings.
> For uevents to work the kobject (llite) must belong to a kset.
>
> With LCFG_SET_PARAM, which handles the 'set_param -P' case the
> master function is process_param2_config(). For this case we
> always send attribute changes with uevents. Besides the requirement
> of the kobject belonging to the kset this function uses 
> kset_find_object() directly which if llite is not in the kset
> will never be found.

Thanks a lot for the explanation - there are definitely things I missed
there.
I'll drop this patch, and keep class_setup_tunables() in the later patch
that removed it.

Thanks,
NeilBrown


>
>> It also does not need the class_ktype type, as dynamic_kobj_ktype
>> is sufficient.
>> 
>> So use the simple kobject_create_and_add() to initialize it.
>> 
>> This provides flexibility for making changes to
>> class_setup_tunables().
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>>  drivers/staging/lustre/lustre/llite/lproc_llite.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> index 8215296dc15d..78ec0fa65c58 100644
>> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> @@ -46,7 +46,7 @@ int llite_tunables_register(void)
>>  {
>>  	int rc = 0;
>>  
>> -	llite_kobj = class_setup_tunables("llite");
>> +	llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj);
>>  	if (IS_ERR(llite_kobj))
>>  		return PTR_ERR(llite_kobj);
>>  
>
>         llite_kobj->kset = kset_get(&lustre_kset);
>> 
>
> In llite_tunables_unregister() the call for kobject_put()
> should really be replaced with kobject_del(). This is a bug
> in my original work. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190226/d5010829/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type
  2019-02-24 16:52   ` [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type James Simmons
@ 2019-02-25 22:38     ` NeilBrown
  2019-02-26 20:41       ` Simmons, James A.
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-25 22:38 UTC (permalink / raw)
  To: lustre-devel

On Sun, Feb 24 2019, James Simmons wrote:

> For some reason this patch didn't land in my mailbox but I can
> see it on https://patchwork.kernel.org/patch/10819037. This patch
> is mostly good since llite now uses dynamic_kobj_ktype with its own
> ktype. Thus class_sysfs_release() will never be called with llite.
>
> What does need fixing is
>
> --------------------------------------------------------
> type->typ_kobj.kset = lustre_kset;
>
> changed to:
>
> type->typ_kobj.kset = kset_get(&lustre_kset);

Why?  Where is the kset_put() what will match this?


> --------------------------------------------------------
>
> Next change needed it change all the 
>
> kobject_put(&type->typ_kobj); -> kobject_del(&type->typ_kobj); 
>

Why?
kobject_del() removed from sysfs.  kobject_put() calls kobject_release()
on the last put.  This calls kobject_cleanup() which calls kobject_del()
if needed.
So why do we need to call kobject_del()?

Thanks,
NeilBrown


> So we properly handle the kset referencing. That is currently
> broken by me :-(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190226/cc38e8e6/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type
  2019-02-25 22:38     ` NeilBrown
@ 2019-02-26 20:41       ` Simmons, James A.
  0 siblings, 0 replies; 105+ messages in thread
From: Simmons, James A. @ 2019-02-26 20:41 UTC (permalink / raw)
  To: lustre-devel


On Sun, Feb 24 2019, James Simmons wrote:

>> For some reason this patch didn't land in my mailbox but I can see it 
>> on https://patchwork.kernel.org/patch/10819037. This patch is mostly 
>> good since llite now uses dynamic_kobj_ktype with its own ktype. Thus 
>> class_sysfs_release() will never be called with llite.
>>
>> What does need fixing is
>>
>> --------------------------------------------------------
>> type->typ_kobj.kset = lustre_kset;
>>
>> changed to:
>>
>> type->typ_kobj.kset = kset_get(&lustre_kset);
>
>Why?  Where is the kset_put() what will match this?

Just an off the cuff review. I'm work on a full fledge patch.
Just testing on OpenSFS branch since the server side has
some unique needs. Basically in the old days the lov and osc
layer were present on servers so you have a /sys/fs/lustre/osc
tree on the MDS server for example. Now a new layer osp
has replaced it but we need to keep the old osc tree structure
around. The function part is some people test with everything
on one node which can create unique conditions to handle.
I'm trying to sort it out.

>> --------------------------------------------------------
>>
>> Next change needed it change all the
>>
>> kobject_put(&type->typ_kobj); -> kobject_del(&type->typ_kobj);
>>
>
>Why?
>kobject_del() removed from sysfs.  kobject_put() calls kobject_release()
>on the last put.  This calls kobject_cleanup() which calls kobject_del()
>if needed.
>So why do we need to call kobject_del()?

You are right. I missed that kobject_cleanup() calls kobject_del(). I noticed
It latter when you pointed out. 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop NeilBrown
  2019-02-24 18:09   ` James Simmons
@ 2019-02-26 20:55   ` James Simmons
  2019-02-27  0:51     ` NeilBrown
  1 sibling, 1 reply; 105+ messages in thread
From: James Simmons @ 2019-02-26 20:55 UTC (permalink / raw)
  To: lustre-devel


> These shift loops seem to be trying to avoid doing a
> multiplication.
> We same effect can be achieved more transparently using
> rounddown_pow_of_two().  Even though there is a multiplication
> in the C code, the resulting machine code just does a single shift.

Be aware rounddown_pow_of_two(n) is undefined when "n == 0". 
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index a179b0d6979e..637aaca96888 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>  		u32 blk_size = osfs.os_bsize >> 10;
>  		u64 result = osfs.os_blocks;
>  
> -		while (blk_size >>= 1)
> -			result <<= 1;
> -
> +		result *= rounddown_pow_of_two(blk_size);
>  		return sprintf(buf, "%llu\n", result);
>  	}
>  
> @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>  		u32 blk_size = osfs.os_bsize >> 10;
>  		u64 result = osfs.os_bfree;
>  
> -		while (blk_size >>= 1)
> -			result <<= 1;
> +		result *= rounddown_pow_of_two(blk_size);
>  
>  		return sprintf(buf, "%llu\n", result);
>  	}
> @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>  		u32 blk_size = osfs.os_bsize >> 10;
>  		u64 result = osfs.os_bavail;
>  
> -		while (blk_size >>= 1)
> -			result <<= 1;
> +		result *= rounddown_pow_of_two(blk_size);
>  
>  		return sprintf(buf, "%llu\n", result);
>  	}
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables()
  2019-02-25 22:27     ` NeilBrown
@ 2019-02-26 22:18       ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-26 22:18 UTC (permalink / raw)
  To: lustre-devel


> >> llite_kobj does not benefit from being in the
> >> lustre_kset kset (though it does need lustre_kset
> >> as a parent)
> >
> > Nak.
> >
> > Yes llite does benefit from being in the kset. On large clusters you
> > can end up with 1000s of clients so keeping the sysfs files setting 
> > in sync needs to be done in mass. The way Lustre does this is by 
> > running on the MGS server 'lctl conf_param $FSNAME.llite.lazystats=1'
> > or with the newer 'lctl set_param -P llite.$FSNAME-*.lazystats=1' as
> > an example. When this is done on the MGS that new value is first
> > persistently stored and then transmitted to the target nodes.
> >   
> > The magic behind this is with class_process_config(). In the code
> > path LCFG_PARAM, which handles the conf_param case' the main function
> > is class_modify_config() which is used by both llite and the obd
> > devices. This function first attempts to find the sysfs attribute
> > from the kobject and call lustre_attr_store() directly to set it.
> > If it can't find the attribute, which means its a debugfs file
> > most likely, then a uevent is created and sent off. The udev rule
> > then exexcutes some application to handle the debugfs settings.
> > For uevents to work the kobject (llite) must belong to a kset.
> >
> > With LCFG_SET_PARAM, which handles the 'set_param -P' case the
> > master function is process_param2_config(). For this case we
> > always send attribute changes with uevents. Besides the requirement
> > of the kobject belonging to the kset this function uses 
> > kset_find_object() directly which if llite is not in the kset
> > will never be found.
> 
> Thanks a lot for the explanation - there are definitely things I missed
> there.
> I'll drop this patch, and keep class_setup_tunables() in the later patch
> that removed it.

I have a patch to replace this one. In fact I love the using the release
for cleanups for ktype that I moved debugfs handling in llite into a new
llite_kobj_release(). I'm looking at the next patch but that one is 
tricker since it impacts server code as well as I pointed out in another
email. I think we can do a reasonable cleanup here.

> >> It also does not need the class_ktype type, as dynamic_kobj_ktype
> >> is sufficient.
> >> 
> >> So use the simple kobject_create_and_add() to initialize it.
> >> 
> >> This provides flexibility for making changes to
> >> class_setup_tunables().
> >> 
> >> Signed-off-by: NeilBrown <neilb@suse.com>
> >> ---
> >>  drivers/staging/lustre/lustre/llite/lproc_llite.c |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> >> index 8215296dc15d..78ec0fa65c58 100644
> >> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
> >> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> >> @@ -46,7 +46,7 @@ int llite_tunables_register(void)
> >>  {
> >>  	int rc = 0;
> >>  
> >> -	llite_kobj = class_setup_tunables("llite");
> >> +	llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj);
> >>  	if (IS_ERR(llite_kobj))
> >>  		return PTR_ERR(llite_kobj);
> >>  
> >
> >         llite_kobj->kset = kset_get(&lustre_kset);
> >> 
> >
> > In llite_tunables_unregister() the call for kobject_put()
> > should really be replaced with kobject_del(). This is a bug
> > in my original work. 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static.
  2019-02-24 17:15   ` James Simmons
@ 2019-02-26 23:45     ` NeilBrown
  2019-02-27 22:36       ` James Simmons
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-26 23:45 UTC (permalink / raw)
  To: lustre-devel

On Sun, Feb 24 2019, James Simmons wrote:

>> libcfs_kkuc_msg_put() is never used outside of kernelcomm.c,
>> so make it static.
>
> In the OpenSFS branch libcfs_kkuc_msg_put() is used by the
> client and server code. While this is okay now in the future
> this will be reverted. So do we keep it as is so it can handle
> server code or do this change and then later do what I added
> below:

Where is it used?

Looking in the current whamcloud master
Commit f7155420024e ("LU-11208 tests: add version check to sanity tests")

$ git grep libcfs_kkuc_msg_put
lustre/include/lustre_kernelcomm.h:int libcfs_kkuc_msg_put(struct file *fp, void *payload);
lustre/obdclass/kernelcomm.c: * libcfs_kkuc_msg_put - send an message from kernel to userspace
lustre/obdclass/kernelcomm.c:int libcfs_kkuc_msg_put(struct file *filp, void *payload)
lustre/obdclass/kernelcomm.c:EXPORT_SYMBOL(libcfs_kkuc_msg_put);
lustre/obdclass/kernelcomm.c:                   rc = libcfs_kkuc_msg_put(reg->kr_fp, payload);

libcfs_kkuc_msg_put() is only called from libcfs_kkuc_group_put().
What am I missing?

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190227/f24b1f45/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper.
  2019-02-24 17:52   ` James Simmons
@ 2019-02-26 23:59     ` NeilBrown
  2019-02-27  1:06       ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-26 23:59 UTC (permalink / raw)
  To: lustre-devel

On Sun, Feb 24 2019, James Simmons wrote:

>> This function seems overly complex, the same functionality
>> is available with much less effort.
>
> Actually we are in discussion about removing these functions.
> The details are at:
>
> https://jira.whamcloud.com/browse/LU-11157
>
> Since shells typically don't handle "floating point" representation
> well you can see the following:
>
> sanity 64d with the same error message; '209.9: syntax error: invalid 
> arithmetic operator (error token is ".9")'
>
> The second issues is that the read values are not true representation
> of the desired value. The same issues is with the string helpers as
> well. Take for example
>
> test_string_get_size_one(1100, 1, "1.10 kB", "1.07 KiB");
>
> Which is taken from linux/lib/test-string_helpers.c.
>
> If you pass 1100 to string_get_size() you can get either 1.10 kB or 1.07 
> KiB. Now if do the reverse 1.10 kB you get ~1126 which is not the same as
> 11000. I discussed how to handle this problem with Andreas and he agreed
> the best solution is make all the sysfs / debugfs *_mb files turn any 
> values passed in to around up to the nearest MiB. This way we can report
> the exact MiB settings to the users. We already have a patch to do this
> for max_dirty_mb which I can push. The other *_mb files need to be updated
> to round off. If you can wait a few days I can backport the already done
> patch and push a patch for the rest.

My  recommendation would be to deprecate all _mb files and instead have
_bytes files which report a simple integer - the number of bytes.

Leave all the unit conversion to user-space.

Linus once told me that he prefers sysfs files to always be in basic
units, and that decimals are fine.  So use "seconds" for time, even if
that means 0.002 for 2 milliseconds.  Use bytes for storage, etc.

NeilBrown

>
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>>  .../lustre/lustre/obdclass/lprocfs_status.c        |   47 +++-----------------
>>  1 file changed, 7 insertions(+), 40 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> index 568e6623e0c8..bd24e48f6145 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> @@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m,
>>  int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val,
>>  			     int mult)
>>  {
>> -	long decimal_val, frac_val;
>>  	int prtn;
>>  
>>  	if (count < 10)
>>  		return -EINVAL;
>>  
>> -	decimal_val = val / mult;
>> -	prtn = snprintf(buffer, count, "%ld", decimal_val);
>> -	frac_val = val % mult;
>> -
>> -	if (prtn < (count - 4) && frac_val > 0) {
>> -		long temp_frac;
>> -		int i, temp_mult = 1, frac_bits = 0;
>> -
>> -		temp_frac = frac_val * 10;
>> -		buffer[prtn++] = '.';
>> -		while (frac_bits < 2 && (temp_frac / mult) < 1) {
>> -			/* only reserved 2 bits fraction */
>> -			buffer[prtn++] = '0';
>> -			temp_frac *= 10;
>> -			frac_bits++;
>> -		}
>> -		/*
>> -		 * Need to think these cases :
>> -		 *      1. #echo x.00 > /sys/xxx       output result : x
>> -		 *      2. #echo x.0x > /sys/xxx       output result : x.0x
>> -		 *      3. #echo x.x0 > /sys/xxx       output result : x.x
>> -		 *      4. #echo x.xx > /sys/xxx       output result : x.xx
>> -		 *      Only reserved 2 bits fraction.
>> -		 */
>> -		for (i = 0; i < (5 - prtn); i++)
>> -			temp_mult *= 10;
>> -
>> -		frac_bits = min((int)count - prtn, 3 - frac_bits);
>> -		prtn += snprintf(buffer + prtn, frac_bits, "%ld",
>> -				 frac_val * temp_mult / mult);
>> +	prtn = snprintf(buffer, count, "%ld.%02lu",
>> +			val / mult,
>> +			(val % mult) / (mult / 100));
>>  
>> +	/* Strip trailing zeroes, and trailing '.' */
>> +	while (prtn && buffer[prtn-1] == '0')
>> +		prtn--;
>> +	if (prtn && buffer[prtn-1] == '.')
>>  		prtn--;
>> -		while (buffer[prtn] < '1' || buffer[prtn] > '9') {
>> -			prtn--;
>> -			if (buffer[prtn] == '.') {
>> -				prtn--;
>> -				break;
>> -			}
>> -		}
>> -		prtn++;
>> -	}
>>  	buffer[prtn++] = '\n';
>>  	return prtn;
>>  }
>> 
>> 
>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190227/d86b2ad5/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock.
  2019-02-25 18:16   ` Andreas Dilger
@ 2019-02-27  0:22     ` NeilBrown
  2019-02-27  1:00       ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-27  0:22 UTC (permalink / raw)
  To: lustre-devel

On Mon, Feb 25 2019, Andreas Dilger wrote:

> On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
>> 
>> This lock is never held over code that sleeps, and is
>> only ever held for short periods of time.
>> So a simple spinlock is best.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> index 27d73c95403d..aed33068ff3c 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> @@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
>> 	if ((len == 4 && !strncmp(kernbuf, "NONE", len)) ||
>> 	    (len == 5 && !strncmp(kernbuf, "clear", len))) {
>> 		/* empty string is special case */
>> -		down_write(&squash->rsi_sem);
>> +		spin_lock(&squash->rsi_lock);
>> 		if (!list_empty(&squash->rsi_nosquash_nids))
>> 			cfs_free_nidlist(&squash->rsi_nosquash_nids);
>> -		up_write(&squash->rsi_sem);
>> +		spin_unlock(&squash->rsi_lock);
>> 
>
>> @@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
>> 	kfree(kernbuf);
>> 	kernbuf = NULL;
>> 
>> -	down_write(&squash->rsi_sem);
>> +	spin_lock(&squash->rsi_lock);
>> 	if (!list_empty(&squash->rsi_nosquash_nids))
>> 		cfs_free_nidlist(&squash->rsi_nosquash_nids);
>> 	list_splice(&tmp, &squash->rsi_nosquash_nids);
>> -	up_write(&squash->rsi_sem);
>> +	spin_unlock(&squash->rsi_lock);
>
>
> This is held here over cds_free_nidlist(), which has calls to kfree()
> internally.  I don't think it is acceptable to hold a spinlock over
> kfree() these days?

I have not heard that, and have myself called kfree inside a spinlock before.
A quick look finds some examples in lib/idr.c
ida_free() calls kfree() while holding a spinlock (xas_unlock_irqrestore
is a wrapper around spin_unlock_irqrestore).

I couldn't find any documentation which said one way or the other, and
normally if a common function cannot be called under a spinlock, it will
call may_sleep() to ensure errors are found quickly.

NeilBrown


>
> Cheers, Andreas
> ---
> Andreas Dilger
> Principal Lustre Architect
> Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190227/92e6fea8/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines.
  2019-02-24 19:07   ` James Simmons
@ 2019-02-27  0:41     ` NeilBrown
  0 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-27  0:41 UTC (permalink / raw)
  To: lustre-devel

On Sun, Feb 24 2019, James Simmons wrote:

>> Some of these are unused.
>> One is used in a minimal way where it is easier to use
>> an explicit number.
>
> While I dislike mystery meat type defines like MAX_STRING_SIZE I also 
> don't like using raw numbers. In the past using raw numbers has causes
> problems when requirements changed that were not easy to track down
> why the new bug appeared. Mind you the same problem exist for constants 
> like MAX_STRING_SIZE which provides no real meaning to why the magically 
> number 128 is used. 
>  
> This number seems to be a limiting factor in the naming of sysfs directory
> and file naming. I kind of see why this number has no meaning. So such
> a number belongs in one place, lprocfs_status.h. Now sysfs attributes
> can have any naming style they want, within reason :-) As for directories
> that is limited by MAX_OBD_NAME. What do you know MAX_OBD_NAME is equal
> too MAX_STRING_SIZE (hint hint) :-) 

I've changed the 128 to MAX_OBD_NAME - seems to make sense.

I've also added the patch below.

Thanks,
NeilBrown

From: NeilBrown <neilb@suse.com>
Subject: [PATCH] lustre: ldlm: discard varname in ldlm_pool.

This allocated buffer serves no purpose.
A constant string is copied into it, it is passed to some
function which copies it out again, then the buffer is freed.
Instead, we can pass the constant string to that function.
---
 drivers/staging/lustre/lustre/ldlm/ldlm_internal.h |  2 --
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c     | 16 ++++------------
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index d8dcf8a73e4b..c907d880274d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -31,8 +31,6 @@
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
-#define MAX_STRING_SIZE 128
-
 extern int ldlm_srv_namespace_nr;
 extern int ldlm_cli_namespace_nr;
 extern struct mutex ldlm_srv_namespace_lock;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index 5b23767faecf..adc3f3737daa 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -505,7 +505,7 @@ LUSTRE_RW_ATTR(lock_volume_factor);
 
 #define LDLM_POOL_ADD_VAR(name, var, ops)			\
 	do {							\
-		snprintf(var_name, MAX_STRING_SIZE, #name);	\
+		pool_vars[0].name = #name;			\
 		pool_vars[0].data = var;			\
 		pool_vars[0].fops = ops;			\
 		ldebugfs_add_vars(pl->pl_debugfs_entry, pool_vars, NULL);\
@@ -557,25 +557,18 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
 						 ns_pool);
 	struct dentry *debugfs_ns_parent;
 	struct lprocfs_vars pool_vars[2];
-	char *var_name = NULL;
 	int rc = 0;
 
-	var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS);
-	if (!var_name)
-		return -ENOMEM;
-
 	debugfs_ns_parent = ns->ns_debugfs_entry;
 	if (IS_ERR_OR_NULL(debugfs_ns_parent)) {
 		CERROR("%s: debugfs entry is not initialized\n",
 		       ldlm_ns_name(ns));
 		rc = -EINVAL;
-		goto out_free_name;
+		goto out;
 	}
 	pl->pl_debugfs_entry = debugfs_create_dir("pool", debugfs_ns_parent);
 
-	var_name[MAX_STRING_SIZE] = '\0';
 	memset(pool_vars, 0, sizeof(pool_vars));
-	pool_vars[0].name = var_name;
 
 	LDLM_POOL_ADD_VAR(state, pl, &lprocfs_pool_state_fops);
 
@@ -583,7 +576,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
 					   LDLM_POOL_FIRST_STAT, 0);
 	if (!pl->pl_stats) {
 		rc = -ENOMEM;
-		goto out_free_name;
+		goto out;
 	}
 
 	lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
@@ -622,8 +615,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
 	debugfs_create_file("stats", 0644, pl->pl_debugfs_entry, pl->pl_stats,
 			    &lprocfs_stats_seq_fops);
 
-out_free_name:
-	kfree(var_name);
+out:
 	return rc;
 }
 
-- 
2.14.0.rc0.dirty

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190227/6294d854/attachment.sig>

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop.
  2019-02-26 20:55   ` James Simmons
@ 2019-02-27  0:51     ` NeilBrown
  2019-02-27  0:54       ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-27  0:51 UTC (permalink / raw)
  To: lustre-devel

On Tue, Feb 26 2019, James Simmons wrote:

>> These shift loops seem to be trying to avoid doing a
>> multiplication.
>> We same effect can be achieved more transparently using
>> rounddown_pow_of_two().  Even though there is a multiplication
>> in the C code, the resulting machine code just does a single shift.
>
> Be aware rounddown_pow_of_two(n) is undefined when "n == 0". 

Hmm... can os_bsize ever be less than 1024?  I guess we still need to be
careful of the possibility.

The current code treats anything less than 1024 as though it were 1024,
so I could achieve the same thing with 

		result *= rounddown_pow_of_two(blk_size ?: 1);

Is that too obscure?

Thanks,
NeilBrown


>  
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>>  .../lustre/lustre/obdclass/lprocfs_status.c        |   10 +++-------
>>  1 file changed, 3 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> index a179b0d6979e..637aaca96888 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>>  		u32 blk_size = osfs.os_bsize >> 10;
>>  		u64 result = osfs.os_blocks;
>>  
>> -		while (blk_size >>= 1)
>> -			result <<= 1;
>> -
>> +		result *= rounddown_pow_of_two(blk_size);
>>  		return sprintf(buf, "%llu\n", result);
>>  	}
>>  
>> @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>>  		u32 blk_size = osfs.os_bsize >> 10;
>>  		u64 result = osfs.os_bfree;
>>  
>> -		while (blk_size >>= 1)
>> -			result <<= 1;
>> +		result *= rounddown_pow_of_two(blk_size);
>>  
>>  		return sprintf(buf, "%llu\n", result);
>>  	}
>> @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>>  		u32 blk_size = osfs.os_bsize >> 10;
>>  		u64 result = osfs.os_bavail;
>>  
>> -		while (blk_size >>= 1)
>> -			result <<= 1;
>> +		result *= rounddown_pow_of_two(blk_size);
>>  
>>  		return sprintf(buf, "%llu\n", result);
>>  	}
>> 
>> 
>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190227/3e106961/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop.
  2019-02-27  0:51     ` NeilBrown
@ 2019-02-27  0:54       ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  0:54 UTC (permalink / raw)
  To: lustre-devel

On Feb 26, 2019, at 17:51, NeilBrown <neilb@suse.com> wrote:
> 
> On Tue, Feb 26 2019, James Simmons wrote:
> 
>>> These shift loops seem to be trying to avoid doing a
>>> multiplication.
>>> We same effect can be achieved more transparently using
>>> rounddown_pow_of_two().  Even though there is a multiplication
>>> in the C code, the resulting machine code just does a single shift.
>> 
>> Be aware rounddown_pow_of_two(n) is undefined when "n == 0". 
> 
> Hmm... can os_bsize ever be less than 1024?  I guess we still need to be
> careful of the possibility.

In theory, ZFS allows a 512-byte blocksize, but we don't use that today.
There is some chance the MDT will be on a byte-granular NVRAM storage at
some point in the future, but even those would have an allocation unit
of 16-32 bytes or so.

> The current code treats anything less than 1024 as though it were 1024,
> so I could achieve the same thing with 
> 
> 		result *= rounddown_pow_of_two(blk_size ?: 1);
> 
> Is that too obscure?

Should be fine.

Cheers, Andreas

> 
> Thanks,
> NeilBrown
> 
> 
>> 
>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>> ---
>>> .../lustre/lustre/obdclass/lprocfs_status.c        |   10 +++-------
>>> 1 file changed, 3 insertions(+), 7 deletions(-)
>>> 
>>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> index a179b0d6979e..637aaca96888 100644
>>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>>> 		u32 blk_size = osfs.os_bsize >> 10;
>>> 		u64 result = osfs.os_blocks;
>>> 
>>> -		while (blk_size >>= 1)
>>> -			result <<= 1;
>>> -
>>> +		result *= rounddown_pow_of_two(blk_size);
>>> 		return sprintf(buf, "%llu\n", result);
>>> 	}
>>> 
>>> @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>>> 		u32 blk_size = osfs.os_bsize >> 10;
>>> 		u64 result = osfs.os_bfree;
>>> 
>>> -		while (blk_size >>= 1)
>>> -			result <<= 1;
>>> +		result *= rounddown_pow_of_two(blk_size);
>>> 
>>> 		return sprintf(buf, "%llu\n", result);
>>> 	}
>>> @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>>> 		u32 blk_size = osfs.os_bsize >> 10;
>>> 		u64 result = osfs.os_bavail;
>>> 
>>> -		while (blk_size >>= 1)
>>> -			result <<= 1;
>>> +		result *= rounddown_pow_of_two(blk_size);
>>> 
>>> 		return sprintf(buf, "%llu\n", result);
>>> 	}
>>> 
>>> 
>>> 

Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock.
  2019-02-27  0:22     ` NeilBrown
@ 2019-02-27  1:00       ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  1:00 UTC (permalink / raw)
  To: lustre-devel

On Feb 26, 2019, at 17:22, NeilBrown <neilb@suse.com> wrote:
> 
> On Mon, Feb 25 2019, Andreas Dilger wrote:
> 
>> On Feb 18, 2019, at 16:09, NeilBrown <neilb@suse.com> wrote:
>>> 
>>> This lock is never held over code that sleeps, and is
>>> only ever held for short periods of time.
>>> So a simple spinlock is best.
>>> 
>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>> ---
>>> 
>>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> index 27d73c95403d..aed33068ff3c 100644
>>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> @@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
>>> 	if ((len == 4 && !strncmp(kernbuf, "NONE", len)) ||
>>> 	    (len == 5 && !strncmp(kernbuf, "clear", len))) {
>>> 		/* empty string is special case */
>>> -		down_write(&squash->rsi_sem);
>>> +		spin_lock(&squash->rsi_lock);
>>> 		if (!list_empty(&squash->rsi_nosquash_nids))
>>> 			cfs_free_nidlist(&squash->rsi_nosquash_nids);
>>> -		up_write(&squash->rsi_sem);
>>> +		spin_unlock(&squash->rsi_lock);
>>> 
>> 
>>> @@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
>>> 	kfree(kernbuf);
>>> 	kernbuf = NULL;
>>> 
>>> -	down_write(&squash->rsi_sem);
>>> +	spin_lock(&squash->rsi_lock);
>>> 	if (!list_empty(&squash->rsi_nosquash_nids))
>>> 		cfs_free_nidlist(&squash->rsi_nosquash_nids);
>>> 	list_splice(&tmp, &squash->rsi_nosquash_nids);
>>> -	up_write(&squash->rsi_sem);
>>> +	spin_unlock(&squash->rsi_lock);
>> 
>> 
>> This is held here over cds_free_nidlist(), which has calls to kfree()
>> internally.  I don't think it is acceptable to hold a spinlock over
>> kfree() these days?
> 
> I have not heard that, and have myself called kfree inside a spinlock before.
> A quick look finds some examples in lib/idr.c
> ida_free() calls kfree() while holding a spinlock (xas_unlock_irqrestore
> is a wrapper around spin_unlock_irqrestore).
> 
> I couldn't find any documentation which said one way or the other, and
> normally if a common function cannot be called under a spinlock, it will
> call may_sleep() to ensure errors are found quickly.

Hmm, maybe I'm wrong.  I thought there was something about freeing slab
objects and eventually they spilled out of the per-CPU slab cache and
might sleep, but that could be ancient news.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper.
  2019-02-26 23:59     ` NeilBrown
@ 2019-02-27  1:06       ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  1:06 UTC (permalink / raw)
  To: lustre-devel

On Feb 26, 2019, at 16:59, NeilBrown <neilb@suse.com> wrote:
> 
> On Sun, Feb 24 2019, James Simmons wrote:
> 
>>> This function seems overly complex, the same functionality
>>> is available with much less effort.
>> 
>> Actually we are in discussion about removing these functions.
>> The details are at:
>> 
>> https://jira.whamcloud.com/browse/LU-11157
>> 
>> Since shells typically don't handle "floating point" representation
>> well you can see the following:
>> 
>> sanity 64d with the same error message; '209.9: syntax error: invalid 
>> arithmetic operator (error token is ".9")'
>> 
>> The second issues is that the read values are not true representation
>> of the desired value. The same issues is with the string helpers as
>> well. Take for example
>> 
>> test_string_get_size_one(1100, 1, "1.10 kB", "1.07 KiB");
>> 
>> Which is taken from linux/lib/test-string_helpers.c.
>> 
>> If you pass 1100 to string_get_size() you can get either 1.10 kB or 1.07 
>> KiB. Now if do the reverse 1.10 kB you get ~1126 which is not the same as
>> 11000. I discussed how to handle this problem with Andreas and he agreed
>> the best solution is make all the sysfs / debugfs *_mb files turn any 
>> values passed in to around up to the nearest MiB. This way we can report
>> the exact MiB settings to the users. We already have a patch to do this
>> for max_dirty_mb which I can push. The other *_mb files need to be updated
>> to round off. If you can wait a few days I can backport the already done
>> patch and push a patch for the rest.
> 
> My  recommendation would be to deprecate all _mb files and instead have
> _bytes files which report a simple integer - the number of bytes.

That would break a lot of configurations and documentation.  Also, bytes
are not very convenient units for a lot of the numbers, for example you
don't want to (nor could you) send 47-byte RPCs.

> Leave all the unit conversion to user-space.
> 
> Linus once told me that he prefers sysfs files to always be in basic
> units, and that decimals are fine.  So use "seconds" for time, even if
> that means 0.002 for 2 milliseconds.  Use bytes for storage, etc.

That is not going to be better than allowing "max_dirty_mb=0.5", which
is what we wanted to get rid of in the first place.  Back in the day
when a system had 4MB DIMMs it was useful to allow fractional MB for the
cache size or debug log size, but I don't think that is useful today.

I'm content to just round these to the nearest MB, in the rare case that
someone specifies a fractional unit, but honestly I don't think that
anyone does anymore.  It is much more likely they will be setting the
cache size to 16G per target on their 256GB RAM nodes.

Cheers, Andreas

>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>> ---
>>> .../lustre/lustre/obdclass/lprocfs_status.c        |   47 +++-----------------
>>> 1 file changed, 7 insertions(+), 40 deletions(-)
>>> 
>>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> index 568e6623e0c8..bd24e48f6145 100644
>>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>>> @@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m,
>>> int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val,
>>> 			     int mult)
>>> {
>>> -	long decimal_val, frac_val;
>>> 	int prtn;
>>> 
>>> 	if (count < 10)
>>> 		return -EINVAL;
>>> 
>>> -	decimal_val = val / mult;
>>> -	prtn = snprintf(buffer, count, "%ld", decimal_val);
>>> -	frac_val = val % mult;
>>> -
>>> -	if (prtn < (count - 4) && frac_val > 0) {
>>> -		long temp_frac;
>>> -		int i, temp_mult = 1, frac_bits = 0;
>>> -
>>> -		temp_frac = frac_val * 10;
>>> -		buffer[prtn++] = '.';
>>> -		while (frac_bits < 2 && (temp_frac / mult) < 1) {
>>> -			/* only reserved 2 bits fraction */
>>> -			buffer[prtn++] = '0';
>>> -			temp_frac *= 10;
>>> -			frac_bits++;
>>> -		}
>>> -		/*
>>> -		 * Need to think these cases :
>>> -		 *      1. #echo x.00 > /sys/xxx       output result : x
>>> -		 *      2. #echo x.0x > /sys/xxx       output result : x.0x
>>> -		 *      3. #echo x.x0 > /sys/xxx       output result : x.x
>>> -		 *      4. #echo x.xx > /sys/xxx       output result : x.xx
>>> -		 *      Only reserved 2 bits fraction.
>>> -		 */
>>> -		for (i = 0; i < (5 - prtn); i++)
>>> -			temp_mult *= 10;
>>> -
>>> -		frac_bits = min((int)count - prtn, 3 - frac_bits);
>>> -		prtn += snprintf(buffer + prtn, frac_bits, "%ld",
>>> -				 frac_val * temp_mult / mult);
>>> +	prtn = snprintf(buffer, count, "%ld.%02lu",
>>> +			val / mult,
>>> +			(val % mult) / (mult / 100));
>>> 
>>> +	/* Strip trailing zeroes, and trailing '.' */
>>> +	while (prtn && buffer[prtn-1] == '0')
>>> +		prtn--;
>>> +	if (prtn && buffer[prtn-1] == '.')
>>> 		prtn--;
>>> -		while (buffer[prtn] < '1' || buffer[prtn] > '9') {
>>> -			prtn--;
>>> -			if (buffer[prtn] == '.') {
>>> -				prtn--;
>>> -				break;
>>> -			}
>>> -		}
>>> -		prtn++;
>>> -	}
>>> 	buffer[prtn++] = '\n';
>>> 	return prtn;
>>> }

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 27/37] lustre: discard lu_ref
  2019-02-24 20:28   ` James Simmons
@ 2019-02-27  1:17     ` NeilBrown
  2019-02-27  5:35       ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-27  1:17 UTC (permalink / raw)
  To: lustre-devel

On Sun, Feb 24 2019, James Simmons wrote:

>> struct lu_ref is always an empty structure, and the functions
>> which manipulate it do nothing.
>> So this is not being tested and so cannot be trusted.
>> So remove all these calls and field declarations.
>
> Or we can make lu_ref really work and always test with it :-)

We could ... though a lot of the code has been removed already, I was
just finishing the job.

How useful is this stuff?
Has it actually helped to find any bugs?
Does it do any run-time checks, or it is just
there to help you pull apart a crash-dump?

I think there is a real cost in having these extra linkages.  I'd like
to be clear what the benefit is.

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190227/07a96103/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 27/37] lustre: discard lu_ref
  2019-02-27  1:17     ` NeilBrown
@ 2019-02-27  5:35       ` Andreas Dilger
  2019-03-01  6:45         ` Mike Pershin
  0 siblings, 1 reply; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  5:35 UTC (permalink / raw)
  To: lustre-devel



> On Feb 26, 2019, at 18:17, NeilBrown <neilb@suse.com> wrote:
> 
> On Sun, Feb 24 2019, James Simmons wrote:
> 
>>> struct lu_ref is always an empty structure, and the functions
>>> which manipulate it do nothing.
>>> So this is not being tested and so cannot be trusted.
>>> So remove all these calls and field declarations.
>> 
>> Or we can make lu_ref really work and always test with it :-)
> 
> We could ... though a lot of the code has been removed already, I was
> just finishing the job.
> 
> How useful is this stuff?
> Has it actually helped to find any bugs?
> Does it do any run-time checks, or it is just
> there to help you pull apart a crash-dump?
> 
> I think there is a real cost in having these extra linkages.  I'd like
> to be clear what the benefit is.

I've never used it myself, though I know a few developers that did in the
past.  That said, most of the time they needed to use it to debug some
issue they had to push a patch to fix it first...

Mike, Alex, you are most likely to use this code - do you think it is
still useful?

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-02-19  0:09 ` [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var NeilBrown
@ 2019-02-27  6:17   ` Andreas Dilger
  2019-03-01  2:35     ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  6:17 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
> 
> 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.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

This will no longer be true once https://review.whamcloud.com/31691
commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")
is merged into your tree.  That allows specifying more useful jobid
values, similar to how coredump files can be named:

    Allow specifying a format string for the jobid_name variable to create
    a jobid for processes on the client.  The jobid_name is used when
    jobid_var=nodelocal, if jobid_name contains "%j", or as a fallback if
    getting the specified jobid_var from the environment fails.
    
    The jobid_node string allows the following escape sequences:
    
        %e = executable name
        %g = group ID
        %h = hostname (system utsname)
        %j = jobid from jobid_var environment variable
        %p = process ID
        %u = user ID
    
    Any unknown escape sequences are dropped. Other arbitrary characters
    pass through unmodified, up to the maximum jobid string size of 32,
    though whitespace within the jobid is not copied.

    This allows, for example, specifying an arbitrary prefix, such as the
    cluster name, in addition to the traditional "procname.uid" format,
    to distinguish between jobs running on clients in different clusters:
    
        lctl set_param jobid_var=nodelocal jobid_name=cluster2.%e.%u
    or
        lctl set_param jobid_var=SLURM_JOB_ID jobid_name=cluster2.%j.%e
    
    To use an environment-specified JobID, if available, but fall back to
    a static string for all processes that do not have a valid JobID:
    
        lctl set_param jobid_var=SLURM_JOB_ID jobid_name=unknown


Currently the "%j" function was removed from the kernel client, even
though there is no technical reason it can't work (i.e. all of the code
to implement it is available and exported).  This is actually super
useful for HPC cluster administrators to monitor per-job IO bandwidth
and IOPS on the server, and something that I think should be restored.

Cheers, Andreas

> ---
> drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |   21 ++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> index 57a6f2c2da1c..69ccc6a55947 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> @@ -216,16 +216,25 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
> 			       const char *buffer,
> 			       size_t count)
> {
> +	static char *valid[] = {
> +		JOBSTATS_DISABLE,
> +		JOBSTATS_PROCNAME_UID,
> +		JOBSTATS_NODELOCAL,
> +		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;
> }
> 
> 

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle NeilBrown
@ 2019-02-27  6:32   ` Andreas Dilger
  2019-02-27 21:48     ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  6:32 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
> 
> Every object with a lustre_handle has (and must have) a refcount.
> The lustre_handles code needs a call-out to increment this.
> To simplify things, move the refcount into the lustre_handle
> and discard the call-out.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

This patch reduces the debugbility of refcounting on these data
structures, which can be tricky to diagnose if there is a leak
at some point and nothing can clean up at the end because some
data structure is holding an extra reference (e.g. lock->exp->dev).

> struct obd_export *class_export_get(struct obd_export *exp)
> {
> -	refcount_inc(&exp->exp_refcount);
> +	refcount_inc(&exp->exp_handle.h_ref);
> 	CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
> -	       refcount_read(&exp->exp_refcount));
> +	       refcount_read(&exp->exp_handle.h_ref));
> 	return exp;
> }

For example, with the existing callback mechanism, class_export_get()
and class_export_put() would be called for every reference added
and removed to this struct obd_export (e.g. when a valid lock handle
is looked up), so with D_INFO logging enabled we can trace all of the
reference counting of the data structures involved.

> @@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie,
> 			const struct portals_handle_ops *ops)
> 
> 		spin_lock(&h->h_lock);
> 		if (likely(h->h_in != 0)) {
> -			h->h_ops->hop_addref(h);
> +			refcount_inc(&h->h_ref);
> 			retval = h;
> 		}
> 		spin_unlock(&h->h_lock);

With this change, while class_handle2object() will still reference the
handle correctly, it not print anything into the logs so if there is
something wrong it will be much more difficult to find.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops
  2019-02-19  0:09 ` [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops NeilBrown
@ 2019-02-27  6:37   ` Andreas Dilger
  2019-02-27 21:41     ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  6:37 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
> 
> lustre_handles  assigned a  64bit  unique identifier  (a 'cookie')  to
> objects of  various types and  stored them  in a hash  table, allowing
> them to be accessed by the cookie.
> 
> The is a facility for type checking by recording an 'owner' for each
> object, and checking the owner on lookup.  Unfortunately this is not
> used - owner is always zero.
> 
> Eahc object also contains an h_ops pointer which can be used to
> reliably identify an owner.
> 
> So discard h_owner, pass and 'ops' pointer to class_handle2object(),
> and only return objects for which the h_ops matches.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

The h_owner is not used in the client code, but it is still used in the
server code to ensure that only clients which have already opened a file
handle can use the open file handle cookie to re-open the file.  The
h_owner in this case is an MDS-local pointer to the client export data,
so just using the h_ops pointer (which is generic to the class of users,
not the specific user) would not provide this functionality.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref NeilBrown
@ 2019-02-27  6:52   ` Andreas Dilger
  2019-02-28  0:39     ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27  6:52 UTC (permalink / raw)
  To: lustre-devel

On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
> 
> These arguments are no longer used, so we can discard them.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Well, they are no longer used, because you've removed the users.

> -struct obd_device *class_incref(struct obd_device *obd,
> -				const char *scope, const void *source)
> +struct obd_device *class_incref(struct obd_device *obd)
> {
> 	atomic_inc(&obd->obd_refcount);
> 	CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd,
> @@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd,
> }
> EXPORT_SYMBOL(class_incref);
> 
> -void class_decref(struct obd_device *obd, const char *scope, const void *source)
> +void class_decref(struct obd_device *obd)
> {
> 	int last;
> 
> -	CDEBUG(D_INFO, "Decref %s (%p) now %d - %s\n", obd->obd_name, obd,
> -	       atomic_read(&obd->obd_refcount), scope);
> +	CDEBUG(D_INFO, "Decref %s (%p) now %d\n", obd->obd_name, obd,
> +	       atomic_read(&obd->obd_refcount));

In particular, the scope (object type) is printed, which allows debugging the
generic incref/decref of these objects (similar to class_get_export() and
class_put_export() as mentioned in my other email).  If we at least can keep
the scope and source, then these generic refcount functions could still be used
for debugging.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops
  2019-02-27  6:37   ` Andreas Dilger
@ 2019-02-27 21:41     ` NeilBrown
  2019-02-28  6:41       ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-27 21:41 UTC (permalink / raw)
  To: lustre-devel

On Wed, Feb 27 2019, Andreas Dilger wrote:

> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>> 
>> lustre_handles  assigned a  64bit  unique identifier  (a 'cookie')  to
>> objects of  various types and  stored them  in a hash  table, allowing
>> them to be accessed by the cookie.
>> 
>> The is a facility for type checking by recording an 'owner' for each
>> object, and checking the owner on lookup.  Unfortunately this is not
>> used - owner is always zero.
>> 
>> Eahc object also contains an h_ops pointer which can be used to
>> reliably identify an owner.
>> 
>> So discard h_owner, pass and 'ops' pointer to class_handle2object(),
>> and only return objects for which the h_ops matches.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> The h_owner is not used in the client code, but it is still used in the
> server code to ensure that only clients which have already opened a file
> handle can use the open file handle cookie to re-open the file.  The
> h_owner in this case is an MDS-local pointer to the client export data,
> so just using the h_ops pointer (which is generic to the class of users,
> not the specific user) would not provide this functionality.

Is it possible for two different clients to be using the same cookie?
The lookup code in class_handle2object() appears to allow this, but I
assume it doesn't happen.

If it *does*, then the 'owner' does need to be part of the lookup key,
at least on the server.
If it doesn't, then I think it would be better for the owner to live in
struct mdt_file_data rather than in the handle.  In the handle it
wastes space in the thousands of instances that don't need it.

Thanks,
NeilBrown

>
> Cheers, Andreas
> ---
> Andreas Dilger
> Principal Lustre Architect
> Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190228/fe131738/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle.
  2019-02-27  6:32   ` Andreas Dilger
@ 2019-02-27 21:48     ` NeilBrown
  2019-02-27 22:14       ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-02-27 21:48 UTC (permalink / raw)
  To: lustre-devel

On Wed, Feb 27 2019, Andreas Dilger wrote:

> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>> 
>> Every object with a lustre_handle has (and must have) a refcount.
>> The lustre_handles code needs a call-out to increment this.
>> To simplify things, move the refcount into the lustre_handle
>> and discard the call-out.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> This patch reduces the debugbility of refcounting on these data
> structures, which can be tricky to diagnose if there is a leak
> at some point and nothing can clean up at the end because some
> data structure is holding an extra reference (e.g. lock->exp->dev).
>
>> struct obd_export *class_export_get(struct obd_export *exp)
>> {
>> -	refcount_inc(&exp->exp_refcount);
>> +	refcount_inc(&exp->exp_handle.h_ref);
>> 	CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
>> -	       refcount_read(&exp->exp_refcount));
>> +	       refcount_read(&exp->exp_handle.h_ref));
>> 	return exp;
>> }
>
> For example, with the existing callback mechanism, class_export_get()
> and class_export_put() would be called for every reference added
> and removed to this struct obd_export (e.g. when a valid lock handle
> is looked up), so with D_INFO logging enabled we can trace all of the
> reference counting of the data structures involved.
>
>> @@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie,
>> 			const struct portals_handle_ops *ops)
>> 
>> 		spin_lock(&h->h_lock);
>> 		if (likely(h->h_in != 0)) {
>> -			h->h_ops->hop_addref(h);
>> +			refcount_inc(&h->h_ref);
>> 			retval = h;
>> 		}
>> 		spin_unlock(&h->h_lock);
>
> With this change, while class_handle2object() will still reference the
> handle correctly, it not print anything into the logs so if there is
> something wrong it will be much more difficult to find.

To restore the debugability, would it be sufficient to add a
CDEBUG(D_INFO) to class_handle2object() where it increments the ref?
We could even add a type name to powers_handle_ops to make the messages
easier to search for?

Thanks,
NeilBrown


>
> Cheers, Andreas
> ---
> Andreas Dilger
> Principal Lustre Architect
> Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190228/59a4c46b/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle.
  2019-02-27 21:48     ` NeilBrown
@ 2019-02-27 22:14       ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-27 22:14 UTC (permalink / raw)
  To: lustre-devel

On Feb 27, 2019, at 14:48, NeilBrown <neilb@suse.com> wrote:
> 
> On Wed, Feb 27 2019, Andreas Dilger wrote:
> 
>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>>> 
>>> Every object with a lustre_handle has (and must have) a refcount.
>>> The lustre_handles code needs a call-out to increment this.
>>> To simplify things, move the refcount into the lustre_handle
>>> and discard the call-out.
>>> 
>>> Signed-off-by: NeilBrown <neilb@suse.com>
>> 
>> This patch reduces the debugbility of refcounting on these data
>> structures, which can be tricky to diagnose if there is a leak
>> at some point and nothing can clean up at the end because some
>> data structure is holding an extra reference (e.g. lock->exp->dev).
>> 
>>> struct obd_export *class_export_get(struct obd_export *exp)
>>> {
>>> -	refcount_inc(&exp->exp_refcount);
>>> +	refcount_inc(&exp->exp_handle.h_ref);
>>> 	CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
>>> -	       refcount_read(&exp->exp_refcount));
>>> +	       refcount_read(&exp->exp_handle.h_ref));
>>> 	return exp;
>>> }
>> 
>> For example, with the existing callback mechanism, class_export_get()
>> and class_export_put() would be called for every reference added
>> and removed to this struct obd_export (e.g. when a valid lock handle
>> is looked up), so with D_INFO logging enabled we can trace all of the
>> reference counting of the data structures involved.
>> 
>>> @@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie,
>>> 			const struct portals_handle_ops *ops)
>>> 
>>> 		spin_lock(&h->h_lock);
>>> 		if (likely(h->h_in != 0)) {
>>> -			h->h_ops->hop_addref(h);
>>> +			refcount_inc(&h->h_ref);
>>> 			retval = h;
>>> 		}
>>> 		spin_unlock(&h->h_lock);
>> 
>> With this change, while class_handle2object() will still reference the
>> handle correctly, it not print anything into the logs so if there is
>> something wrong it will be much more difficult to find.
> 
> To restore the debugability, would it be sufficient to add a
> CDEBUG(D_INFO) to class_handle2object() where it increments the ref?
> We could even add a type name to powers_handle_ops to make the messages
> easier to search for?

That would probably work.  We'd have the pointer+type from the initial
reference, and if the pointer+type is logged in the increment/decrement
functions then it doesn't matter that they aren't printed by the same
function.  Ideally the formatting of such messages would be consistent
to make searching easier. 

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static.
  2019-02-26 23:45     ` NeilBrown
@ 2019-02-27 22:36       ` James Simmons
  0 siblings, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-27 22:36 UTC (permalink / raw)
  To: lustre-devel


> >> libcfs_kkuc_msg_put() is never used outside of kernelcomm.c,
> >> so make it static.
> >
> > In the OpenSFS branch libcfs_kkuc_msg_put() is used by the
> > client and server code. While this is okay now in the future
> > this will be reverted. So do we keep it as is so it can handle
> > server code or do this change and then later do what I added
> > below:
> 
> Where is it used?
> 
> Looking in the current whamcloud master
> Commit f7155420024e ("LU-11208 tests: add version check to sanity tests")
> 
> $ git grep libcfs_kkuc_msg_put
> lustre/include/lustre_kernelcomm.h:int libcfs_kkuc_msg_put(struct file *fp, void *payload);
> lustre/obdclass/kernelcomm.c: * libcfs_kkuc_msg_put - send an message from kernel to userspace
> lustre/obdclass/kernelcomm.c:int libcfs_kkuc_msg_put(struct file *filp, void *payload)
> lustre/obdclass/kernelcomm.c:EXPORT_SYMBOL(libcfs_kkuc_msg_put);
> lustre/obdclass/kernelcomm.c:                   rc = libcfs_kkuc_msg_put(reg->kr_fp, payload);
> 
> libcfs_kkuc_msg_put() is only called from libcfs_kkuc_group_put().
> What am I missing?

I'm remembering older code. You are correct. Let me give it a proper 
review.

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static.
  2019-02-19  0:09 ` [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static NeilBrown
  2019-02-24 17:15   ` James Simmons
@ 2019-02-27 22:37   ` James Simmons
  1 sibling, 0 replies; 105+ messages in thread
From: James Simmons @ 2019-02-27 22:37 UTC (permalink / raw)
  To: lustre-devel


> libcfs_kkuc_msg_put() is never used outside of kernelcomm.c,
> so make it static.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/lustre/include/lustre_kernelcomm.h      |    1 -
>  .../staging/lustre/lustre/obdclass/kernelcomm.c    |    3 +--
>  2 files changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
> index 8e3a99057a38..1ed41840ab8f 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h
> @@ -46,7 +46,6 @@ typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg);
>  
>  /* Kernel methods */
>  void libcfs_kkuc_init(void);
> -int libcfs_kkuc_msg_put(struct file *fp, void *payload);
>  int libcfs_kkuc_group_put(unsigned int group, void *payload);
>  int libcfs_kkuc_group_add(struct file *fp, int uid, unsigned int group,
>  			  void *data, size_t data_len);
> diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> index 09d0b1ab8d1c..27870952b1f0 100644
> --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> @@ -49,7 +49,7 @@
>   * @param payload Payload data.  First field of payload is always
>   *   struct kuc_hdr
>   */
> -int libcfs_kkuc_msg_put(struct file *filp, void *payload)
> +static int libcfs_kkuc_msg_put(struct file *filp, void *payload)
>  {
>  	struct kuc_hdr *kuch = (struct kuc_hdr *)payload;
>  	ssize_t count = kuch->kuc_msglen;
> @@ -80,7 +80,6 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload)
>  
>  	return rc;
>  }
> -EXPORT_SYMBOL(libcfs_kkuc_msg_put);
>  
>  /*
>   * Broadcast groups are global across all mounted filesystems;
> 
> 
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref.
  2019-02-27  6:52   ` Andreas Dilger
@ 2019-02-28  0:39     ` NeilBrown
  0 siblings, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-02-28  0:39 UTC (permalink / raw)
  To: lustre-devel

On Wed, Feb 27 2019, Andreas Dilger wrote:

> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>> 
>> These arguments are no longer used, so we can discard them.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> Well, they are no longer used, because you've removed the users.

yes......
'source' isn't used since I removed lu_ref.
'scope' is used, as you say, in a CDEBUG() message.

I'll wait until there is more input on the lu_ref stuff before doing
anything more about these.  I won't push them for now.

Thanks,
NeilBrown


>
>> -struct obd_device *class_incref(struct obd_device *obd,
>> -				const char *scope, const void *source)
>> +struct obd_device *class_incref(struct obd_device *obd)
>> {
>> 	atomic_inc(&obd->obd_refcount);
>> 	CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd,
>> @@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd,
>> }
>> EXPORT_SYMBOL(class_incref);
>> 
>> -void class_decref(struct obd_device *obd, const char *scope, const void *source)
>> +void class_decref(struct obd_device *obd)
>> {
>> 	int last;
>> 
>> -	CDEBUG(D_INFO, "Decref %s (%p) now %d - %s\n", obd->obd_name, obd,
>> -	       atomic_read(&obd->obd_refcount), scope);
>> +	CDEBUG(D_INFO, "Decref %s (%p) now %d\n", obd->obd_name, obd,
>> +	       atomic_read(&obd->obd_refcount));
>
> In particular, the scope (object type) is printed, which allows debugging the
> generic incref/decref of these objects (similar to class_get_export() and
> class_put_export() as mentioned in my other email).  If we at least can keep
> the scope and source, then these generic refcount functions could still be used
> for debugging.
>
> Cheers, Andreas
> ---
> Andreas Dilger
> Principal Lustre Architect
> Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190228/cbc73a10/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops
  2019-02-27 21:41     ` NeilBrown
@ 2019-02-28  6:41       ` Andreas Dilger
  0 siblings, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-02-28  6:41 UTC (permalink / raw)
  To: lustre-devel

On Feb 27, 2019, at 14:41, NeilBrown <neilb@suse.com> wrote:
> 
> On Wed, Feb 27 2019, Andreas Dilger wrote:
> 
>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>>> 
>>> lustre_handles  assigned a  64bit  unique identifier  (a 'cookie')  to
>>> objects of  various types and  stored them  in a hash  table, allowing
>>> them to be accessed by the cookie.
>>> 
>>> The is a facility for type checking by recording an 'owner' for each
>>> object, and checking the owner on lookup.  Unfortunately this is not
>>> used - owner is always zero.
>>> 
>>> Eahc object also contains an h_ops pointer which can be used to
>>> reliably identify an owner.
>>> 
>>> So discard h_owner, pass and 'ops' pointer to class_handle2object(),
>>> and only return objects for which the h_ops matches.
>>> 
>>> Signed-off-by: NeilBrown <neilb@suse.com>
>> 
>> The h_owner is not used in the client code, but it is still used in the
>> server code to ensure that only clients which have already opened a file
>> handle can use the open file handle cookie to re-open the file.  The
>> h_owner in this case is an MDS-local pointer to the client export data,
>> so just using the h_ops pointer (which is generic to the class of users,
>> not the specific user) would not provide this functionality.
> 
> Is it possible for two different clients to be using the same cookie?
> The lookup code in class_handle2object() appears to allow this, but I
> assume it doesn't happen.
> 
> If it *does*, then the 'owner' does need to be part of the lookup key,
> at least on the server.
> If it doesn't, then I think it would be better for the owner to live in
> struct mdt_file_data rather than in the handle.  In the handle it
> wastes space in the thousands of instances that don't need it.

No, since the cookie is generated by the MDS in this case, it should be
unique among all clients, and a single open file handle can't be used
by multiple clients.  The goal of class_handle2object() was to ensure
that the handle was only valid for the right caller, and some other
client couldn't accidentally or maliciously use the same cookie to get
access to an object that they weren't allowed to.

That said, it looks like the caller mdt_open_handle2mfd() could also do
this check itself, to verify that the found handle actually belongs to
the client using it.  That would need an "owner" pointer to be stored in
struct mdt_file_data to reference the export, but at least this overhead
would be contained to the one place that needs it.

While the MDS could also verify this by scanning the entire list of open
files for that client, there could potentially be thousands of files per
client that need to be checked.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-02-27  6:17   ` Andreas Dilger
@ 2019-03-01  2:35     ` NeilBrown
  2019-03-01  8:32       ` Andreas Dilger
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-03-01  2:35 UTC (permalink / raw)
  To: lustre-devel

On Wed, Feb 27 2019, Andreas Dilger wrote:

> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>> 
>> 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.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> This will no longer be true once https://review.whamcloud.com/31691
> commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")

Actually it will.  That patch changes the use of jobid_name, my patch
restricts the values of jobid_var.

I just realized why it is called "jobid_var" - in OpenSFS lustre, it can
be an environment variable name.  In drivers/staging lustre it cannot,
so the name is a little odd.

>
> Currently the "%j" function was removed from the kernel client, even
> though there is no technical reason it can't work (i.e. all of the code
> to implement it is available and exported).  This is actually super
> useful for HPC cluster administrators to monitor per-job IO bandwidth
> and IOPS on the server, and something that I think should be restored.

I think that you probably need to let go of that desire - I don't think
it is going to happen.  While the code may, as you say, work - it is
easy to dislike that approach, and would be hard to push against such
resistance.

I have an alternate approach, patch below.
Instead of
 export LUSTRE_JOBID=foobar
and process can run
 echo foobar > /sys/fs/lustre/jobid_this_session

and it will affect all processes in the current "session".

Could you warm to this approach at all?

Thanks,
NeilBrown

From: NeilBrown <neilb@suse.com>
Subject: [PATCH] lustre: obdclass: allow per-session jobids.

Lustre includes a jobid in all RPC message sent to the server.  This
is used to collected per-job statistics, where a "job" can involve
multiple processes on multiple nodes in a cluster.

Nodes in a cluster can be running processes for multiple jobs, so it
is best if different processes can have different jobids, and that
processes on different nodes can have the same job id.

This is not currently possible with the drivers/staging code.

Lustre traditionally uses an environment variable to name a job, but
having the kernel reach into the address space of a process to find
that environment variable is seen by some developers to be an
unacceptable design choice.

This patch provides an alternate method, leveraging the concept of a
"session id", as set with setsid().  Each login session already gets a
unique sid which is preserved for all processes in that session unless
explicitly changed (with setsid(1)).
When a process in a session writes to
/sys/fs/lustre/jobid_this_session, the string becomes the name for
that session.
If jobid_var is set to "manual", then the per-session jobid is used
for the jobid for all requests from processes in that session.

When a session ends, the jobid information will be purged within 5
minutes.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lprocfs_status.h |   1 +
 drivers/staging/lustre/lustre/include/obd_class.h  |   3 +
 drivers/staging/lustre/lustre/obdclass/class_obd.c | 160 ++++++++++++++++++++-
 drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |  41 ++++++
 4 files changed, 204 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 8565c28f08ee..1335a5722903 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -370,6 +370,7 @@ static inline void s2dhms(struct dhms *ts, time64_t secs64)
 #define JOBSTATS_DISABLE		"disable"
 #define JOBSTATS_PROCNAME_UID		"procname_uid"
 #define JOBSTATS_NODELOCAL		"nodelocal"
+#define JOBSTATS_MANUAL			"manual"
 
 /* obd_config.c */
 void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 50b08c89ecc5..08003f3dd467 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -55,6 +55,9 @@ extern rwlock_t obd_dev_lock;
 struct obd_device *class_exp2obd(struct obd_export *exp);
 int class_handle_ioctl(unsigned int cmd, unsigned long arg);
 int lustre_get_jobid(char *jobid);
+char *jobid_current(void);
+int jobid_set_current(char *jobid);
+
 
 struct lu_device_type;
 
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 1fcbda128a58..19ce3c858e59 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -79,6 +79,144 @@ EXPORT_SYMBOL(at_extra);
 char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
 char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
 
+/*
+ * Jobid can be set for a session (see setsid(2)) by writing to
+ * a sysfs file from any process in that session.
+ * The jobids are stored in a hash table indexed by the relevant
+ * struct pid.  We periodically look for entries where the pid has
+ * no PIDTYPE_SID tasks any more, and prune them.  This happens within
+ * 5 seconds of a jobid being added, and every 5 minutes when jobids exist,
+ * but none are added.
+ */
+#define JOBID_EXPEDITED_CLEAN (5 * HZ)
+#define JOBID_BACKGROUND_CLEAN (5 * 60 * HZ)
+
+struct session_jobid {
+	struct pid		*session;
+	struct rhash_head	linkage;
+	struct rcu_head		rcu;
+	char			jobid[1];
+};
+
+const static struct rhashtable_params jobid_params = {
+	.key_len	= sizeof(struct pid *),
+	.key_offset	= offsetof(struct session_jobid, session),
+	.head_offset	= offsetof(struct session_jobid, linkage),
+};
+static struct rhashtable session_jobids;
+
+/*
+ * jobid_current must be called with rcu_read_lock held.
+ * if it returns non-NULL, the string can only be used
+ * until rcu_read_unlock is called.
+ */
+char *jobid_current(void)
+{
+	struct pid *sid = current->signal->pids[PIDTYPE_SID];
+	struct session_jobid *sj;
+
+	sj = rhashtable_lookup_fast(&session_jobids, &sid, jobid_params);
+	if (sj)
+		return sj->jobid;
+	return NULL;
+}
+
+static void jobid_prune_expedite(void);
+/*
+ * jobid_set_current will try to add a new entry
+ * to the table.  If one exists with the same key, the
+ * jobid will be replaced
+ */
+int jobid_set_current(char *jobid)
+{
+	struct pid *sid = current->signal->pids[PIDTYPE_SID];
+	struct session_jobid *sj, *origsj;
+	int ret;
+
+	sj = kmalloc(sizeof(*sj) + strlen(jobid), GFP_KERNEL);
+	if (!sj)
+		return -ENOMEM;
+	rcu_read_lock();
+	sj->session = get_pid(sid);
+	strcpy(sj->jobid, jobid);
+	origsj = rhashtable_lookup_get_insert_fast(&session_jobids,
+						   &sj->linkage,
+						   jobid_params);
+	if (origsj == NULL) {
+		/* successful insert */
+		rcu_read_unlock();
+		jobid_prune_expedite();
+		return 0;
+	}
+
+	if (IS_ERR(origsj)) {
+		put_pid(sj->session);
+		kfree(sj);
+		rcu_read_unlock();
+		return PTR_ERR(origsj);
+	}
+	ret = rhashtable_replace_fast(&session_jobids,
+				      &origsj->linkage,
+				      &sj->linkage,
+				      jobid_params);
+	if (ret) {
+		put_pid(sj->session);
+		kfree(sj);
+		rcu_read_unlock();
+		return ret;
+	}
+	put_pid(origsj->session);
+	rcu_read_unlock();
+	kfree_rcu(origsj, rcu);
+	jobid_prune_expedite();
+
+	return 0;
+}
+
+static void jobid_free(void *vsj, void *arg)
+{
+	struct session_jobid *sj = vsj;
+	put_pid(sj->session);
+	kfree(sj);
+}
+
+static void jobid_prune(struct work_struct *work);
+static DECLARE_DELAYED_WORK(jobid_prune_work, jobid_prune);
+static int jobid_prune_expedited;
+static void jobid_prune(struct work_struct *work)
+{
+	int remaining = 0;
+	struct rhashtable_iter iter;
+	struct session_jobid *sj;
+
+	jobid_prune_expedited = 0;
+	rhashtable_walk_enter(&session_jobids, &iter);
+	rhashtable_walk_start(&iter);
+	while ((sj = rhashtable_walk_next(&iter)) != NULL) {
+		if (!hlist_empty(&sj->session->tasks[PIDTYPE_SID])) {
+			remaining++;
+			continue;
+		}
+		if (rhashtable_remove_fast(&session_jobids,
+					   &sj->linkage, jobid_params) == 0) {
+			put_pid(sj->session);
+			kfree_rcu(sj, rcu);
+		}
+	}
+	rhashtable_walk_stop(&iter);
+	rhashtable_walk_exit(&iter);
+	if (remaining)
+		schedule_delayed_work(&jobid_prune_work, JOBID_BACKGROUND_CLEAN);
+}
+
+static void jobid_prune_expedite(void)
+{
+	if (!jobid_prune_expedited) {
+		jobid_prune_expedited = 1;
+		mod_delayed_work(system_wq, &jobid_prune_work, JOBID_EXPEDITED_CLEAN);
+	}
+}
+
 /* Get jobid of current process from stored variable or calculate
  * it from pid and user_id.
  *
@@ -108,6 +246,17 @@ int lustre_get_jobid(char *jobid)
 		goto out_cache_jobid;
 	}
 
+	if (strcmp(obd_jobid_var, JOBSTATS_MANUAL) == 0) {
+		char *jid;
+		rcu_read_lock();
+		jid = jobid_current();
+		if (jid)
+			strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
+		rcu_read_unlock();
+		if (jid)
+			goto out_cache_jobid;
+	}
+
 	return -ENOENT;
 
 out_cache_jobid:
@@ -663,10 +812,13 @@ static int __init obdclass_init(void)
 	if (err)
 		goto cleanup_zombie_impexp;
 
+	err = rhashtable_init(&session_jobids, &jobid_params);
+	if (err)
+		goto cleanup_class_handle;
 	err = misc_register(&obd_psdev);
 	if (err) {
 		CERROR("cannot register OBD miscdevices: err %d\n", err);
-		goto cleanup_class_handle;
+		goto cleanup_session_jobids;
 	}
 
 	/* Default the dirty page cache cap to 1/2 of system memory.
@@ -724,6 +876,9 @@ static int __init obdclass_init(void)
 cleanup_deregister:
 	misc_deregister(&obd_psdev);
 
+cleanup_session_jobids:
+	rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
+
 cleanup_class_handle:
 	class_handle_cleanup();
 
@@ -743,6 +898,9 @@ static void obdclass_exit(void)
 	cl_global_fini();
 	lu_global_fini();
 
+	cancel_delayed_work_sync(&jobid_prune_work);
+	rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
+
 	obd_cleanup_caches();
 
 	class_procfs_clean();
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
index 69ccc6a55947..112782e56793 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
@@ -220,6 +220,7 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
 		JOBSTATS_DISABLE,
 		JOBSTATS_PROCNAME_UID,
 		JOBSTATS_NODELOCAL,
+		JOBSTATS_MANUAL,
 		NULL
 	};
 	int i;
@@ -263,6 +264,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
 	return count;
 }
 
+static ssize_t jobid_this_session_show(struct kobject *kobj,
+				       struct attribute *attr,
+				       char *buf)
+{
+	char *jid;
+	int ret = -ENOENT;
+
+	rcu_read_lock();
+	jid = jobid_current();
+	if (jid)
+		ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
+	rcu_read_unlock();
+	return ret;
+}
+
+static ssize_t jobid_this_session_store(struct kobject *kobj,
+					struct attribute *attr,
+					const char *buffer,
+					size_t count)
+{
+	char *jobid;
+	int len;
+	int ret;
+
+	if (!count || count > LUSTRE_JOBID_SIZE)
+		return -EINVAL;
+
+	jobid = kstrndup(buffer, count, GFP_KERNEL);
+	if (!jobid)
+		return -ENOMEM;
+	len = strcspn(jobid, " \n");
+	jobid[len] = '\0';
+	ret = jobid_set_current(jobid);
+	kfree(jobid);
+
+	return ret ?: count;
+}
+
 /* Root for /sys/kernel/debug/lustre */
 struct dentry *debugfs_lustre_root;
 EXPORT_SYMBOL_GPL(debugfs_lustre_root);
@@ -272,6 +311,7 @@ LUSTRE_RO_ATTR(pinger);
 LUSTRE_RO_ATTR(health_check);
 LUSTRE_RW_ATTR(jobid_var);
 LUSTRE_RW_ATTR(jobid_name);
+LUSTRE_RW_ATTR(jobid_this_session);
 
 static struct attribute *lustre_attrs[] = {
 	&lustre_attr_version.attr,
@@ -279,6 +319,7 @@ static struct attribute *lustre_attrs[] = {
 	&lustre_attr_health_check.attr,
 	&lustre_attr_jobid_name.attr,
 	&lustre_attr_jobid_var.attr,
+	&lustre_attr_jobid_this_session.attr,
 	&lustre_sattr_timeout.u.attr,
 	&lustre_attr_max_dirty_mb.attr,
 	&lustre_sattr_debug_peer_on_timeout.u.attr,
-- 
2.14.0.rc0.dirty

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190301/2a1dee12/attachment.sig>

^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 27/37] lustre: discard lu_ref
  2019-02-27  5:35       ` Andreas Dilger
@ 2019-03-01  6:45         ` Mike Pershin
  0 siblings, 0 replies; 105+ messages in thread
From: Mike Pershin @ 2019-03-01  6:45 UTC (permalink / raw)
  To: lustre-devel

On 2/27/19 8:35 AM, Andreas Dilger wrote:
>> On Feb 26, 2019, at 18:17, NeilBrown<neilb@suse.com>  wrote:
>>
>> On Sun, Feb 24 2019, James Simmons wrote:
>>
>>>> struct lu_ref is always an empty structure, and the functions
>>>> which manipulate it do nothing.
>>>> So this is not being tested and so cannot be trusted.
>>>> So remove all these calls and field declarations.
>>> Or we can make lu_ref really work and always test with it :-)
>> We could ... though a lot of the code has been removed already, I was
>> just finishing the job.
>>
>> How useful is this stuff?
>> Has it actually helped to find any bugs?
>> Does it do any run-time checks, or it is just
>> there to help you pull apart a crash-dump?
>>
>> I think there is a real cost in having these extra linkages.  I'd like
>> to be clear what the benefit is.
> I've never used it myself, though I know a few developers that did in the
> past.  That said, most of the time they needed to use it to debug some
> issue they had to push a patch to fix it first...
>
> Mike, Alex, you are most likely to use this code - do you think it is
> still useful?
>
> Cheers, Andreas
> ---
> Andreas Dilger
> Principal Lustre Architect
> Whamcloud
>
I've used that is past to track reference leaks, that can be useful but 
as you said each time I had to fix it first. I think it would be 
reasonable to keep that feature if it is enabled by default on developer 
systems, without that it is not so useful.

Mike

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-03-01  2:35     ` NeilBrown
@ 2019-03-01  8:32       ` Andreas Dilger
  2019-03-01 14:30         ` Patrick Farrell
  0 siblings, 1 reply; 105+ messages in thread
From: Andreas Dilger @ 2019-03-01  8:32 UTC (permalink / raw)
  To: lustre-devel

On Feb 28, 2019, at 19:35, NeilBrown <neilb@suse.com> wrote:
> 
> On Wed, Feb 27 2019, Andreas Dilger wrote:
> 
>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>>> 
>>> 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.
>>> 
>>> Signed-off-by: NeilBrown <neilb@suse.com>
>> 
>> This will no longer be true once https://review.whamcloud.com/31691
>> commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")
> 
> Actually it will.  That patch changes the use of jobid_name, my patch
> restricts the values of jobid_var.
> 
> I just realized why it is called "jobid_var" - in OpenSFS lustre, it can
> be an environment variable name.  In drivers/staging lustre it cannot,
> so the name is a little odd.
> 
>> 
>> Currently the "%j" function was removed from the kernel client, even
>> though there is no technical reason it can't work (i.e. all of the code
>> to implement it is available and exported).  This is actually super
>> useful for HPC cluster administrators to monitor per-job IO bandwidth
>> and IOPS on the server, and something that I think should be restored.
> 
> I think that you probably need to let go of that desire - I don't think
> it is going to happen.  While the code may, as you say, work - it is
> easy to dislike that approach, and would be hard to push against such
> resistance.
> 
> I have an alternate approach, patch below.  Instead of
> export LUSTRE_JOBID=foobar
> and process can run
> echo foobar > /sys/fs/lustre/jobid_this_session
> 
> and it will affect all processes in the current "session".
> 
> Could you warm to this approach at all?

This is the best alternative that I've seen so far.  That said, the choice
of storing the JobID as an environment variable wasn't something that we
invented ourselves, but rather this is what the various job schedulers do
when a job is first started, and the code to extract the JobID out of the
process environment was what we implemented to work within the constraints
that were given to us.  The benefit of course is that we don't depend on
some external process to be run for every process to extract the environment
variable from the kernel memory and send it back to us.

Allowing different processes to have different JobIDs on a single node is
definitely a requirement for most environments these days, and so far this
is the only solution that has allowed that to work.

James is more familiar with the production side of the house, so I'll let
him comment on how easy/hard it would be to get this kind of change added
to the per-job preamble script so that it is set for all processes.

Cheers, Andreas

> From: NeilBrown <neilb@suse.com>
> Subject: [PATCH] lustre: obdclass: allow per-session jobids.
> 
> Lustre includes a jobid in all RPC message sent to the server.  This
> is used to collected per-job statistics, where a "job" can involve
> multiple processes on multiple nodes in a cluster.
> 
> Nodes in a cluster can be running processes for multiple jobs, so it
> is best if different processes can have different jobids, and that
> processes on different nodes can have the same job id.
> 
> This is not currently possible with the drivers/staging code.
> 
> Lustre traditionally uses an environment variable to name a job, but
> having the kernel reach into the address space of a process to find
> that environment variable is seen by some developers to be an
> unacceptable design choice.
> 
> This patch provides an alternate method, leveraging the concept of a
> "session id", as set with setsid().  Each login session already gets a
> unique sid which is preserved for all processes in that session unless
> explicitly changed (with setsid(1)).
> When a process in a session writes to
> /sys/fs/lustre/jobid_this_session, the string becomes the name for
> that session.
> If jobid_var is set to "manual", then the per-session jobid is used
> for the jobid for all requests from processes in that session.
> 
> When a session ends, the jobid information will be purged within 5
> minutes.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> .../staging/lustre/lustre/include/lprocfs_status.h |   1 +
> drivers/staging/lustre/lustre/include/obd_class.h  |   3 +
> drivers/staging/lustre/lustre/obdclass/class_obd.c | 160 ++++++++++++++++++++-
> drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |  41 ++++++
> 4 files changed, 204 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> index 8565c28f08ee..1335a5722903 100644
> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> @@ -370,6 +370,7 @@ static inline void s2dhms(struct dhms *ts, time64_t secs64)
> #define JOBSTATS_DISABLE		"disable"
> #define JOBSTATS_PROCNAME_UID		"procname_uid"
> #define JOBSTATS_NODELOCAL		"nodelocal"
> +#define JOBSTATS_MANUAL			"manual"
> 
> /* obd_config.c */
> void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index 50b08c89ecc5..08003f3dd467 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -55,6 +55,9 @@ extern rwlock_t obd_dev_lock;
> struct obd_device *class_exp2obd(struct obd_export *exp);
> int class_handle_ioctl(unsigned int cmd, unsigned long arg);
> int lustre_get_jobid(char *jobid);
> +char *jobid_current(void);
> +int jobid_set_current(char *jobid);
> +
> 
> struct lu_device_type;
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> index 1fcbda128a58..19ce3c858e59 100644
> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> @@ -79,6 +79,144 @@ EXPORT_SYMBOL(at_extra);
> char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
> char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
> 
> +/*
> + * Jobid can be set for a session (see setsid(2)) by writing to
> + * a sysfs file from any process in that session.
> + * The jobids are stored in a hash table indexed by the relevant
> + * struct pid.  We periodically look for entries where the pid has
> + * no PIDTYPE_SID tasks any more, and prune them.  This happens within
> + * 5 seconds of a jobid being added, and every 5 minutes when jobids exist,
> + * but none are added.
> + */
> +#define JOBID_EXPEDITED_CLEAN (5 * HZ)
> +#define JOBID_BACKGROUND_CLEAN (5 * 60 * HZ)
> +
> +struct session_jobid {
> +	struct pid		*session;
> +	struct rhash_head	linkage;
> +	struct rcu_head		rcu;
> +	char			jobid[1];
> +};
> +
> +const static struct rhashtable_params jobid_params = {
> +	.key_len	= sizeof(struct pid *),
> +	.key_offset	= offsetof(struct session_jobid, session),
> +	.head_offset	= offsetof(struct session_jobid, linkage),
> +};
> +static struct rhashtable session_jobids;
> +
> +/*
> + * jobid_current must be called with rcu_read_lock held.
> + * if it returns non-NULL, the string can only be used
> + * until rcu_read_unlock is called.
> + */
> +char *jobid_current(void)
> +{
> +	struct pid *sid = current->signal->pids[PIDTYPE_SID];
> +	struct session_jobid *sj;
> +
> +	sj = rhashtable_lookup_fast(&session_jobids, &sid, jobid_params);
> +	if (sj)
> +		return sj->jobid;
> +	return NULL;
> +}
> +
> +static void jobid_prune_expedite(void);
> +/*
> + * jobid_set_current will try to add a new entry
> + * to the table.  If one exists with the same key, the
> + * jobid will be replaced
> + */
> +int jobid_set_current(char *jobid)
> +{
> +	struct pid *sid = current->signal->pids[PIDTYPE_SID];
> +	struct session_jobid *sj, *origsj;
> +	int ret;
> +
> +	sj = kmalloc(sizeof(*sj) + strlen(jobid), GFP_KERNEL);
> +	if (!sj)
> +		return -ENOMEM;
> +	rcu_read_lock();
> +	sj->session = get_pid(sid);
> +	strcpy(sj->jobid, jobid);
> +	origsj = rhashtable_lookup_get_insert_fast(&session_jobids,
> +						   &sj->linkage,
> +						   jobid_params);
> +	if (origsj == NULL) {
> +		/* successful insert */
> +		rcu_read_unlock();
> +		jobid_prune_expedite();
> +		return 0;
> +	}
> +
> +	if (IS_ERR(origsj)) {
> +		put_pid(sj->session);
> +		kfree(sj);
> +		rcu_read_unlock();
> +		return PTR_ERR(origsj);
> +	}
> +	ret = rhashtable_replace_fast(&session_jobids,
> +				      &origsj->linkage,
> +				      &sj->linkage,
> +				      jobid_params);
> +	if (ret) {
> +		put_pid(sj->session);
> +		kfree(sj);
> +		rcu_read_unlock();
> +		return ret;
> +	}
> +	put_pid(origsj->session);
> +	rcu_read_unlock();
> +	kfree_rcu(origsj, rcu);
> +	jobid_prune_expedite();
> +
> +	return 0;
> +}
> +
> +static void jobid_free(void *vsj, void *arg)
> +{
> +	struct session_jobid *sj = vsj;
> +	put_pid(sj->session);
> +	kfree(sj);
> +}
> +
> +static void jobid_prune(struct work_struct *work);
> +static DECLARE_DELAYED_WORK(jobid_prune_work, jobid_prune);
> +static int jobid_prune_expedited;
> +static void jobid_prune(struct work_struct *work)
> +{
> +	int remaining = 0;
> +	struct rhashtable_iter iter;
> +	struct session_jobid *sj;
> +
> +	jobid_prune_expedited = 0;
> +	rhashtable_walk_enter(&session_jobids, &iter);
> +	rhashtable_walk_start(&iter);
> +	while ((sj = rhashtable_walk_next(&iter)) != NULL) {
> +		if (!hlist_empty(&sj->session->tasks[PIDTYPE_SID])) {
> +			remaining++;
> +			continue;
> +		}
> +		if (rhashtable_remove_fast(&session_jobids,
> +					   &sj->linkage, jobid_params) == 0) {
> +			put_pid(sj->session);
> +			kfree_rcu(sj, rcu);
> +		}
> +	}
> +	rhashtable_walk_stop(&iter);
> +	rhashtable_walk_exit(&iter);
> +	if (remaining)
> +		schedule_delayed_work(&jobid_prune_work, JOBID_BACKGROUND_CLEAN);
> +}
> +
> +static void jobid_prune_expedite(void)
> +{
> +	if (!jobid_prune_expedited) {
> +		jobid_prune_expedited = 1;
> +		mod_delayed_work(system_wq, &jobid_prune_work, JOBID_EXPEDITED_CLEAN);
> +	}
> +}
> +
> /* Get jobid of current process from stored variable or calculate
>  * it from pid and user_id.
>  *
> @@ -108,6 +246,17 @@ int lustre_get_jobid(char *jobid)
> 		goto out_cache_jobid;
> 	}
> 
> +	if (strcmp(obd_jobid_var, JOBSTATS_MANUAL) == 0) {
> +		char *jid;
> +		rcu_read_lock();
> +		jid = jobid_current();
> +		if (jid)
> +			strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
> +		rcu_read_unlock();
> +		if (jid)
> +			goto out_cache_jobid;
> +	}
> +
> 	return -ENOENT;
> 
> out_cache_jobid:
> @@ -663,10 +812,13 @@ static int __init obdclass_init(void)
> 	if (err)
> 		goto cleanup_zombie_impexp;
> 
> +	err = rhashtable_init(&session_jobids, &jobid_params);
> +	if (err)
> +		goto cleanup_class_handle;
> 	err = misc_register(&obd_psdev);
> 	if (err) {
> 		CERROR("cannot register OBD miscdevices: err %d\n", err);
> -		goto cleanup_class_handle;
> +		goto cleanup_session_jobids;
> 	}
> 
> 	/* Default the dirty page cache cap to 1/2 of system memory.
> @@ -724,6 +876,9 @@ static int __init obdclass_init(void)
> cleanup_deregister:
> 	misc_deregister(&obd_psdev);
> 
> +cleanup_session_jobids:
> +	rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
> +
> cleanup_class_handle:
> 	class_handle_cleanup();
> 
> @@ -743,6 +898,9 @@ static void obdclass_exit(void)
> 	cl_global_fini();
> 	lu_global_fini();
> 
> +	cancel_delayed_work_sync(&jobid_prune_work);
> +	rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
> +
> 	obd_cleanup_caches();
> 
> 	class_procfs_clean();
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> index 69ccc6a55947..112782e56793 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> @@ -220,6 +220,7 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
> 		JOBSTATS_DISABLE,
> 		JOBSTATS_PROCNAME_UID,
> 		JOBSTATS_NODELOCAL,
> +		JOBSTATS_MANUAL,
> 		NULL
> 	};
> 	int i;
> @@ -263,6 +264,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
> 	return count;
> }
> 
> +static ssize_t jobid_this_session_show(struct kobject *kobj,
> +				       struct attribute *attr,
> +				       char *buf)
> +{
> +	char *jid;
> +	int ret = -ENOENT;
> +
> +	rcu_read_lock();
> +	jid = jobid_current();
> +	if (jid)
> +		ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
> +	rcu_read_unlock();
> +	return ret;
> +}
> +
> +static ssize_t jobid_this_session_store(struct kobject *kobj,
> +					struct attribute *attr,
> +					const char *buffer,
> +					size_t count)
> +{
> +	char *jobid;
> +	int len;
> +	int ret;
> +
> +	if (!count || count > LUSTRE_JOBID_SIZE)
> +		return -EINVAL;
> +
> +	jobid = kstrndup(buffer, count, GFP_KERNEL);
> +	if (!jobid)
> +		return -ENOMEM;
> +	len = strcspn(jobid, " \n");
> +	jobid[len] = '\0';
> +	ret = jobid_set_current(jobid);
> +	kfree(jobid);
> +
> +	return ret ?: count;
> +}
> +
> /* Root for /sys/kernel/debug/lustre */
> struct dentry *debugfs_lustre_root;
> EXPORT_SYMBOL_GPL(debugfs_lustre_root);
> @@ -272,6 +311,7 @@ LUSTRE_RO_ATTR(pinger);
> LUSTRE_RO_ATTR(health_check);
> LUSTRE_RW_ATTR(jobid_var);
> LUSTRE_RW_ATTR(jobid_name);
> +LUSTRE_RW_ATTR(jobid_this_session);
> 
> static struct attribute *lustre_attrs[] = {
> 	&lustre_attr_version.attr,
> @@ -279,6 +319,7 @@ static struct attribute *lustre_attrs[] = {
> 	&lustre_attr_health_check.attr,
> 	&lustre_attr_jobid_name.attr,
> 	&lustre_attr_jobid_var.attr,
> +	&lustre_attr_jobid_this_session.attr,
> 	&lustre_sattr_timeout.u.attr,
> 	&lustre_attr_max_dirty_mb.attr,
> 	&lustre_sattr_debug_peer_on_timeout.u.attr,
> -- 
> 2.14.0.rc0.dirty
> 

Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-03-01  8:32       ` Andreas Dilger
@ 2019-03-01 14:30         ` Patrick Farrell
  2019-03-14  0:34           ` NeilBrown
  0 siblings, 1 reply; 105+ messages in thread
From: Patrick Farrell @ 2019-03-01 14:30 UTC (permalink / raw)
  To: lustre-devel

The definition of "session" matters here.  It is increasingly common to run multiple jobs on a node at the same time, and the desire to distinguish between them is also significant.  So we can't have just one session.

I believe this is part of why it was chosen to put this information in user space, associated with a particular process.

So we need a solution that can meet that requirement or the broader HPC world will just ignore us.

Perhaps we could use the new jobid cache functionality here.  A sketch:

Have the parent - I believe there would be a unique parent for every set of job processes - register the ID (via this proc variable) and we would apply it to all children (what about grandchildren, etc...).  Then set timeouts to something like 24 or 48 hours, and but also use (or add if it's not present?) the functionality to deregister job ids at job exit.  So the timeout is only for cleanup.

Although, the more I talk about this, the more this feels like something that should live in struct_task and be set from user space and managed by the kernel...
________________________________
From: lustre-devel <lustre-devel-bounces@lists.lustre.org> on behalf of Andreas Dilger <adilger@whamcloud.com>
Sent: Friday, March 1, 2019 2:32:00 AM
To: NeilBrown
Cc: Lustre Development List
Subject: Re: [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var

On Feb 28, 2019, at 19:35, NeilBrown <neilb@suse.com> wrote:
>
> On Wed, Feb 27 2019, Andreas Dilger wrote:
>
>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>>>
>>> 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.
>>>
>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>
>> This will no longer be true once https://review.whamcloud.com/31691
>> commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")
>
> Actually it will.  That patch changes the use of jobid_name, my patch
> restricts the values of jobid_var.
>
> I just realized why it is called "jobid_var" - in OpenSFS lustre, it can
> be an environment variable name.  In drivers/staging lustre it cannot,
> so the name is a little odd.
>
>>
>> Currently the "%j" function was removed from the kernel client, even
>> though there is no technical reason it can't work (i.e. all of the code
>> to implement it is available and exported).  This is actually super
>> useful for HPC cluster administrators to monitor per-job IO bandwidth
>> and IOPS on the server, and something that I think should be restored.
>
> I think that you probably need to let go of that desire - I don't think
> it is going to happen.  While the code may, as you say, work - it is
> easy to dislike that approach, and would be hard to push against such
> resistance.
>
> I have an alternate approach, patch below.  Instead of
> export LUSTRE_JOBID=foobar
> and process can run
> echo foobar > /sys/fs/lustre/jobid_this_session
>
> and it will affect all processes in the current "session".
>
> Could you warm to this approach at all?

This is the best alternative that I've seen so far.  That said, the choice
of storing the JobID as an environment variable wasn't something that we
invented ourselves, but rather this is what the various job schedulers do
when a job is first started, and the code to extract the JobID out of the
process environment was what we implemented to work within the constraints
that were given to us.  The benefit of course is that we don't depend on
some external process to be run for every process to extract the environment
variable from the kernel memory and send it back to us.

Allowing different processes to have different JobIDs on a single node is
definitely a requirement for most environments these days, and so far this
is the only solution that has allowed that to work.

James is more familiar with the production side of the house, so I'll let
him comment on how easy/hard it would be to get this kind of change added
to the per-job preamble script so that it is set for all processes.

Cheers, Andreas

> From: NeilBrown <neilb@suse.com>
> Subject: [PATCH] lustre: obdclass: allow per-session jobids.
>
> Lustre includes a jobid in all RPC message sent to the server.  This
> is used to collected per-job statistics, where a "job" can involve
> multiple processes on multiple nodes in a cluster.
>
> Nodes in a cluster can be running processes for multiple jobs, so it
> is best if different processes can have different jobids, and that
> processes on different nodes can have the same job id.
>
> This is not currently possible with the drivers/staging code.
>
> Lustre traditionally uses an environment variable to name a job, but
> having the kernel reach into the address space of a process to find
> that environment variable is seen by some developers to be an
> unacceptable design choice.
>
> This patch provides an alternate method, leveraging the concept of a
> "session id", as set with setsid().  Each login session already gets a
> unique sid which is preserved for all processes in that session unless
> explicitly changed (with setsid(1)).
> When a process in a session writes to
> /sys/fs/lustre/jobid_this_session, the string becomes the name for
> that session.
> If jobid_var is set to "manual", then the per-session jobid is used
> for the jobid for all requests from processes in that session.
>
> When a session ends, the jobid information will be purged within 5
> minutes.
>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> .../staging/lustre/lustre/include/lprocfs_status.h |   1 +
> drivers/staging/lustre/lustre/include/obd_class.h  |   3 +
> drivers/staging/lustre/lustre/obdclass/class_obd.c | 160 ++++++++++++++++++++-
> drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |  41 ++++++
> 4 files changed, 204 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> index 8565c28f08ee..1335a5722903 100644
> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> @@ -370,6 +370,7 @@ static inline void s2dhms(struct dhms *ts, time64_t secs64)
> #define JOBSTATS_DISABLE              "disable"
> #define JOBSTATS_PROCNAME_UID         "procname_uid"
> #define JOBSTATS_NODELOCAL            "nodelocal"
> +#define JOBSTATS_MANUAL                      "manual"
>
> /* obd_config.c */
> void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index 50b08c89ecc5..08003f3dd467 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -55,6 +55,9 @@ extern rwlock_t obd_dev_lock;
> struct obd_device *class_exp2obd(struct obd_export *exp);
> int class_handle_ioctl(unsigned int cmd, unsigned long arg);
> int lustre_get_jobid(char *jobid);
> +char *jobid_current(void);
> +int jobid_set_current(char *jobid);
> +
>
> struct lu_device_type;
>
> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> index 1fcbda128a58..19ce3c858e59 100644
> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> @@ -79,6 +79,144 @@ EXPORT_SYMBOL(at_extra);
> char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
> char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
>
> +/*
> + * Jobid can be set for a session (see setsid(2)) by writing to
> + * a sysfs file from any process in that session.
> + * The jobids are stored in a hash table indexed by the relevant
> + * struct pid.  We periodically look for entries where the pid has
> + * no PIDTYPE_SID tasks any more, and prune them.  This happens within
> + * 5 seconds of a jobid being added, and every 5 minutes when jobids exist,
> + * but none are added.
> + */
> +#define JOBID_EXPEDITED_CLEAN (5 * HZ)
> +#define JOBID_BACKGROUND_CLEAN (5 * 60 * HZ)
> +
> +struct session_jobid {
> +     struct pid              *session;
> +     struct rhash_head       linkage;
> +     struct rcu_head         rcu;
> +     char                    jobid[1];
> +};
> +
> +const static struct rhashtable_params jobid_params = {
> +     .key_len        = sizeof(struct pid *),
> +     .key_offset     = offsetof(struct session_jobid, session),
> +     .head_offset    = offsetof(struct session_jobid, linkage),
> +};
> +static struct rhashtable session_jobids;
> +
> +/*
> + * jobid_current must be called with rcu_read_lock held.
> + * if it returns non-NULL, the string can only be used
> + * until rcu_read_unlock is called.
> + */
> +char *jobid_current(void)
> +{
> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
> +     struct session_jobid *sj;
> +
> +     sj = rhashtable_lookup_fast(&session_jobids, &sid, jobid_params);
> +     if (sj)
> +             return sj->jobid;
> +     return NULL;
> +}
> +
> +static void jobid_prune_expedite(void);
> +/*
> + * jobid_set_current will try to add a new entry
> + * to the table.  If one exists with the same key, the
> + * jobid will be replaced
> + */
> +int jobid_set_current(char *jobid)
> +{
> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
> +     struct session_jobid *sj, *origsj;
> +     int ret;
> +
> +     sj = kmalloc(sizeof(*sj) + strlen(jobid), GFP_KERNEL);
> +     if (!sj)
> +             return -ENOMEM;
> +     rcu_read_lock();
> +     sj->session = get_pid(sid);
> +     strcpy(sj->jobid, jobid);
> +     origsj = rhashtable_lookup_get_insert_fast(&session_jobids,
> +                                                &sj->linkage,
> +                                                jobid_params);
> +     if (origsj == NULL) {
> +             /* successful insert */
> +             rcu_read_unlock();
> +             jobid_prune_expedite();
> +             return 0;
> +     }
> +
> +     if (IS_ERR(origsj)) {
> +             put_pid(sj->session);
> +             kfree(sj);
> +             rcu_read_unlock();
> +             return PTR_ERR(origsj);
> +     }
> +     ret = rhashtable_replace_fast(&session_jobids,
> +                                   &origsj->linkage,
> +                                   &sj->linkage,
> +                                   jobid_params);
> +     if (ret) {
> +             put_pid(sj->session);
> +             kfree(sj);
> +             rcu_read_unlock();
> +             return ret;
> +     }
> +     put_pid(origsj->session);
> +     rcu_read_unlock();
> +     kfree_rcu(origsj, rcu);
> +     jobid_prune_expedite();
> +
> +     return 0;
> +}
> +
> +static void jobid_free(void *vsj, void *arg)
> +{
> +     struct session_jobid *sj = vsj;
> +     put_pid(sj->session);
> +     kfree(sj);
> +}
> +
> +static void jobid_prune(struct work_struct *work);
> +static DECLARE_DELAYED_WORK(jobid_prune_work, jobid_prune);
> +static int jobid_prune_expedited;
> +static void jobid_prune(struct work_struct *work)
> +{
> +     int remaining = 0;
> +     struct rhashtable_iter iter;
> +     struct session_jobid *sj;
> +
> +     jobid_prune_expedited = 0;
> +     rhashtable_walk_enter(&session_jobids, &iter);
> +     rhashtable_walk_start(&iter);
> +     while ((sj = rhashtable_walk_next(&iter)) != NULL) {
> +             if (!hlist_empty(&sj->session->tasks[PIDTYPE_SID])) {
> +                     remaining++;
> +                     continue;
> +             }
> +             if (rhashtable_remove_fast(&session_jobids,
> +                                        &sj->linkage, jobid_params) == 0) {
> +                     put_pid(sj->session);
> +                     kfree_rcu(sj, rcu);
> +             }
> +     }
> +     rhashtable_walk_stop(&iter);
> +     rhashtable_walk_exit(&iter);
> +     if (remaining)
> +             schedule_delayed_work(&jobid_prune_work, JOBID_BACKGROUND_CLEAN);
> +}
> +
> +static void jobid_prune_expedite(void)
> +{
> +     if (!jobid_prune_expedited) {
> +             jobid_prune_expedited = 1;
> +             mod_delayed_work(system_wq, &jobid_prune_work, JOBID_EXPEDITED_CLEAN);
> +     }
> +}
> +
> /* Get jobid of current process from stored variable or calculate
>  * it from pid and user_id.
>  *
> @@ -108,6 +246,17 @@ int lustre_get_jobid(char *jobid)
>                goto out_cache_jobid;
>        }
>
> +     if (strcmp(obd_jobid_var, JOBSTATS_MANUAL) == 0) {
> +             char *jid;
> +             rcu_read_lock();
> +             jid = jobid_current();
> +             if (jid)
> +                     strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
> +             rcu_read_unlock();
> +             if (jid)
> +                     goto out_cache_jobid;
> +     }
> +
>        return -ENOENT;
>
> out_cache_jobid:
> @@ -663,10 +812,13 @@ static int __init obdclass_init(void)
>        if (err)
>                goto cleanup_zombie_impexp;
>
> +     err = rhashtable_init(&session_jobids, &jobid_params);
> +     if (err)
> +             goto cleanup_class_handle;
>        err = misc_register(&obd_psdev);
>        if (err) {
>                CERROR("cannot register OBD miscdevices: err %d\n", err);
> -             goto cleanup_class_handle;
> +             goto cleanup_session_jobids;
>        }
>
>        /* Default the dirty page cache cap to 1/2 of system memory.
> @@ -724,6 +876,9 @@ static int __init obdclass_init(void)
> cleanup_deregister:
>        misc_deregister(&obd_psdev);
>
> +cleanup_session_jobids:
> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
> +
> cleanup_class_handle:
>        class_handle_cleanup();
>
> @@ -743,6 +898,9 @@ static void obdclass_exit(void)
>        cl_global_fini();
>        lu_global_fini();
>
> +     cancel_delayed_work_sync(&jobid_prune_work);
> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
> +
>        obd_cleanup_caches();
>
>        class_procfs_clean();
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> index 69ccc6a55947..112782e56793 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> @@ -220,6 +220,7 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
>                JOBSTATS_DISABLE,
>                JOBSTATS_PROCNAME_UID,
>                JOBSTATS_NODELOCAL,
> +             JOBSTATS_MANUAL,
>                NULL
>        };
>        int i;
> @@ -263,6 +264,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
>        return count;
> }
>
> +static ssize_t jobid_this_session_show(struct kobject *kobj,
> +                                    struct attribute *attr,
> +                                    char *buf)
> +{
> +     char *jid;
> +     int ret = -ENOENT;
> +
> +     rcu_read_lock();
> +     jid = jobid_current();
> +     if (jid)
> +             ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
> +     rcu_read_unlock();
> +     return ret;
> +}
> +
> +static ssize_t jobid_this_session_store(struct kobject *kobj,
> +                                     struct attribute *attr,
> +                                     const char *buffer,
> +                                     size_t count)
> +{
> +     char *jobid;
> +     int len;
> +     int ret;
> +
> +     if (!count || count > LUSTRE_JOBID_SIZE)
> +             return -EINVAL;
> +
> +     jobid = kstrndup(buffer, count, GFP_KERNEL);
> +     if (!jobid)
> +             return -ENOMEM;
> +     len = strcspn(jobid, " \n");
> +     jobid[len] = '\0';
> +     ret = jobid_set_current(jobid);
> +     kfree(jobid);
> +
> +     return ret ?: count;
> +}
> +
> /* Root for /sys/kernel/debug/lustre */
> struct dentry *debugfs_lustre_root;
> EXPORT_SYMBOL_GPL(debugfs_lustre_root);
> @@ -272,6 +311,7 @@ LUSTRE_RO_ATTR(pinger);
> LUSTRE_RO_ATTR(health_check);
> LUSTRE_RW_ATTR(jobid_var);
> LUSTRE_RW_ATTR(jobid_name);
> +LUSTRE_RW_ATTR(jobid_this_session);
>
> static struct attribute *lustre_attrs[] = {
>        &lustre_attr_version.attr,
> @@ -279,6 +319,7 @@ static struct attribute *lustre_attrs[] = {
>        &lustre_attr_health_check.attr,
>        &lustre_attr_jobid_name.attr,
>        &lustre_attr_jobid_var.attr,
> +     &lustre_attr_jobid_this_session.attr,
>        &lustre_sattr_timeout.u.attr,
>        &lustre_attr_max_dirty_mb.attr,
>        &lustre_sattr_debug_peer_on_timeout.u.attr,
> --
> 2.14.0.rc0.dirty
>

Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud




_______________________________________________
lustre-devel mailing list
lustre-devel at lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190301/f922ce8e/attachment-0001.html>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-03-01 14:30         ` Patrick Farrell
@ 2019-03-14  0:34           ` NeilBrown
  2019-03-14 14:12             ` Patrick Farrell
  0 siblings, 1 reply; 105+ messages in thread
From: NeilBrown @ 2019-03-14  0:34 UTC (permalink / raw)
  To: lustre-devel


Hi Patrick,
 I agree that "something that should live in struct_task" is the sort of
 answer that would be nice, but I don't think it can be justified.

 A "session" in the sense of "getsid" and "setsid" is traditionally a
 login session, but since the invention of windowing systems it is one
 terminal window.
 So if you
    grep NSsid /proc/self/status
 in different windows you will see different session ids.  All processes
 in that window will have the same session id unless something
 explicitly creates a new session - few things do that.

 If you want to explicitly create a new session, you can use "setsid".
 So
    setsid grep NSsid /proc/self/status
 will always show a new session id.

 Considering you sketch, the "unique parent" is already very likely to
 be in a session that no other job is in.
 If you run multiple jobs from the one terminal window (is they likely?)
 then the will all be in the same session unless you run
    setsid run-my-job

 The session (and anything we associated with it) will apply to all
 children and grandchild etc.
 There is no need for a timeout beyond what the code already has - it
 checks every 5 minutes to see if the session is still active, and
 forgets any inactive session.  There is no risk of a new session being
 confused with an old session that no longer exists, even if they have
 the same number.

 I hope that clarifies for you.

Thanks,
NeilBrown


On Fri, Mar 01 2019, Patrick Farrell wrote:

> The definition of "session" matters here.  It is increasingly common to run multiple jobs on a node at the same time, and the desire to distinguish between them is also significant.  So we can't have just one session.
>
> I believe this is part of why it was chosen to put this information in user space, associated with a particular process.
>
> So we need a solution that can meet that requirement or the broader HPC world will just ignore us.
>
> Perhaps we could use the new jobid cache functionality here.  A sketch:
>
> Have the parent - I believe there would be a unique parent for every set of job processes - register the ID (via this proc variable) and we would apply it to all children (what about grandchildren, etc...).  Then set timeouts to something like 24 or 48 hours, and but also use (or add if it's not present?) the functionality to deregister job ids at job exit.  So the timeout is only for cleanup.
>
> Although, the more I talk about this, the more this feels like something that should live in struct_task and be set from user space and managed by the kernel...
> ________________________________
> From: lustre-devel <lustre-devel-bounces@lists.lustre.org> on behalf of Andreas Dilger <adilger@whamcloud.com>
> Sent: Friday, March 1, 2019 2:32:00 AM
> To: NeilBrown
> Cc: Lustre Development List
> Subject: Re: [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
>
> On Feb 28, 2019, at 19:35, NeilBrown <neilb@suse.com> wrote:
>>
>> On Wed, Feb 27 2019, Andreas Dilger wrote:
>>
>>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>>>>
>>>> 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.
>>>>
>>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>>
>>> This will no longer be true once https://review.whamcloud.com/31691
>>> commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")
>>
>> Actually it will.  That patch changes the use of jobid_name, my patch
>> restricts the values of jobid_var.
>>
>> I just realized why it is called "jobid_var" - in OpenSFS lustre, it can
>> be an environment variable name.  In drivers/staging lustre it cannot,
>> so the name is a little odd.
>>
>>>
>>> Currently the "%j" function was removed from the kernel client, even
>>> though there is no technical reason it can't work (i.e. all of the code
>>> to implement it is available and exported).  This is actually super
>>> useful for HPC cluster administrators to monitor per-job IO bandwidth
>>> and IOPS on the server, and something that I think should be restored.
>>
>> I think that you probably need to let go of that desire - I don't think
>> it is going to happen.  While the code may, as you say, work - it is
>> easy to dislike that approach, and would be hard to push against such
>> resistance.
>>
>> I have an alternate approach, patch below.  Instead of
>> export LUSTRE_JOBID=foobar
>> and process can run
>> echo foobar > /sys/fs/lustre/jobid_this_session
>>
>> and it will affect all processes in the current "session".
>>
>> Could you warm to this approach at all?
>
> This is the best alternative that I've seen so far.  That said, the choice
> of storing the JobID as an environment variable wasn't something that we
> invented ourselves, but rather this is what the various job schedulers do
> when a job is first started, and the code to extract the JobID out of the
> process environment was what we implemented to work within the constraints
> that were given to us.  The benefit of course is that we don't depend on
> some external process to be run for every process to extract the environment
> variable from the kernel memory and send it back to us.
>
> Allowing different processes to have different JobIDs on a single node is
> definitely a requirement for most environments these days, and so far this
> is the only solution that has allowed that to work.
>
> James is more familiar with the production side of the house, so I'll let
> him comment on how easy/hard it would be to get this kind of change added
> to the per-job preamble script so that it is set for all processes.
>
> Cheers, Andreas
>
>> From: NeilBrown <neilb@suse.com>
>> Subject: [PATCH] lustre: obdclass: allow per-session jobids.
>>
>> Lustre includes a jobid in all RPC message sent to the server.  This
>> is used to collected per-job statistics, where a "job" can involve
>> multiple processes on multiple nodes in a cluster.
>>
>> Nodes in a cluster can be running processes for multiple jobs, so it
>> is best if different processes can have different jobids, and that
>> processes on different nodes can have the same job id.
>>
>> This is not currently possible with the drivers/staging code.
>>
>> Lustre traditionally uses an environment variable to name a job, but
>> having the kernel reach into the address space of a process to find
>> that environment variable is seen by some developers to be an
>> unacceptable design choice.
>>
>> This patch provides an alternate method, leveraging the concept of a
>> "session id", as set with setsid().  Each login session already gets a
>> unique sid which is preserved for all processes in that session unless
>> explicitly changed (with setsid(1)).
>> When a process in a session writes to
>> /sys/fs/lustre/jobid_this_session, the string becomes the name for
>> that session.
>> If jobid_var is set to "manual", then the per-session jobid is used
>> for the jobid for all requests from processes in that session.
>>
>> When a session ends, the jobid information will be purged within 5
>> minutes.
>>
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>> .../staging/lustre/lustre/include/lprocfs_status.h |   1 +
>> drivers/staging/lustre/lustre/include/obd_class.h  |   3 +
>> drivers/staging/lustre/lustre/obdclass/class_obd.c | 160 ++++++++++++++++++++-
>> drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |  41 ++++++
>> 4 files changed, 204 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
>> index 8565c28f08ee..1335a5722903 100644
>> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
>> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
>> @@ -370,6 +370,7 @@ static inline void s2dhms(struct dhms *ts, time64_t secs64)
>> #define JOBSTATS_DISABLE              "disable"
>> #define JOBSTATS_PROCNAME_UID         "procname_uid"
>> #define JOBSTATS_NODELOCAL            "nodelocal"
>> +#define JOBSTATS_MANUAL                      "manual"
>>
>> /* obd_config.c */
>> void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
>> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
>> index 50b08c89ecc5..08003f3dd467 100644
>> --- a/drivers/staging/lustre/lustre/include/obd_class.h
>> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
>> @@ -55,6 +55,9 @@ extern rwlock_t obd_dev_lock;
>> struct obd_device *class_exp2obd(struct obd_export *exp);
>> int class_handle_ioctl(unsigned int cmd, unsigned long arg);
>> int lustre_get_jobid(char *jobid);
>> +char *jobid_current(void);
>> +int jobid_set_current(char *jobid);
>> +
>>
>> struct lu_device_type;
>>
>> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> index 1fcbda128a58..19ce3c858e59 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> @@ -79,6 +79,144 @@ EXPORT_SYMBOL(at_extra);
>> char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
>> char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
>>
>> +/*
>> + * Jobid can be set for a session (see setsid(2)) by writing to
>> + * a sysfs file from any process in that session.
>> + * The jobids are stored in a hash table indexed by the relevant
>> + * struct pid.  We periodically look for entries where the pid has
>> + * no PIDTYPE_SID tasks any more, and prune them.  This happens within
>> + * 5 seconds of a jobid being added, and every 5 minutes when jobids exist,
>> + * but none are added.
>> + */
>> +#define JOBID_EXPEDITED_CLEAN (5 * HZ)
>> +#define JOBID_BACKGROUND_CLEAN (5 * 60 * HZ)
>> +
>> +struct session_jobid {
>> +     struct pid              *session;
>> +     struct rhash_head       linkage;
>> +     struct rcu_head         rcu;
>> +     char                    jobid[1];
>> +};
>> +
>> +const static struct rhashtable_params jobid_params = {
>> +     .key_len        = sizeof(struct pid *),
>> +     .key_offset     = offsetof(struct session_jobid, session),
>> +     .head_offset    = offsetof(struct session_jobid, linkage),
>> +};
>> +static struct rhashtable session_jobids;
>> +
>> +/*
>> + * jobid_current must be called with rcu_read_lock held.
>> + * if it returns non-NULL, the string can only be used
>> + * until rcu_read_unlock is called.
>> + */
>> +char *jobid_current(void)
>> +{
>> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
>> +     struct session_jobid *sj;
>> +
>> +     sj = rhashtable_lookup_fast(&session_jobids, &sid, jobid_params);
>> +     if (sj)
>> +             return sj->jobid;
>> +     return NULL;
>> +}
>> +
>> +static void jobid_prune_expedite(void);
>> +/*
>> + * jobid_set_current will try to add a new entry
>> + * to the table.  If one exists with the same key, the
>> + * jobid will be replaced
>> + */
>> +int jobid_set_current(char *jobid)
>> +{
>> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
>> +     struct session_jobid *sj, *origsj;
>> +     int ret;
>> +
>> +     sj = kmalloc(sizeof(*sj) + strlen(jobid), GFP_KERNEL);
>> +     if (!sj)
>> +             return -ENOMEM;
>> +     rcu_read_lock();
>> +     sj->session = get_pid(sid);
>> +     strcpy(sj->jobid, jobid);
>> +     origsj = rhashtable_lookup_get_insert_fast(&session_jobids,
>> +                                                &sj->linkage,
>> +                                                jobid_params);
>> +     if (origsj == NULL) {
>> +             /* successful insert */
>> +             rcu_read_unlock();
>> +             jobid_prune_expedite();
>> +             return 0;
>> +     }
>> +
>> +     if (IS_ERR(origsj)) {
>> +             put_pid(sj->session);
>> +             kfree(sj);
>> +             rcu_read_unlock();
>> +             return PTR_ERR(origsj);
>> +     }
>> +     ret = rhashtable_replace_fast(&session_jobids,
>> +                                   &origsj->linkage,
>> +                                   &sj->linkage,
>> +                                   jobid_params);
>> +     if (ret) {
>> +             put_pid(sj->session);
>> +             kfree(sj);
>> +             rcu_read_unlock();
>> +             return ret;
>> +     }
>> +     put_pid(origsj->session);
>> +     rcu_read_unlock();
>> +     kfree_rcu(origsj, rcu);
>> +     jobid_prune_expedite();
>> +
>> +     return 0;
>> +}
>> +
>> +static void jobid_free(void *vsj, void *arg)
>> +{
>> +     struct session_jobid *sj = vsj;
>> +     put_pid(sj->session);
>> +     kfree(sj);
>> +}
>> +
>> +static void jobid_prune(struct work_struct *work);
>> +static DECLARE_DELAYED_WORK(jobid_prune_work, jobid_prune);
>> +static int jobid_prune_expedited;
>> +static void jobid_prune(struct work_struct *work)
>> +{
>> +     int remaining = 0;
>> +     struct rhashtable_iter iter;
>> +     struct session_jobid *sj;
>> +
>> +     jobid_prune_expedited = 0;
>> +     rhashtable_walk_enter(&session_jobids, &iter);
>> +     rhashtable_walk_start(&iter);
>> +     while ((sj = rhashtable_walk_next(&iter)) != NULL) {
>> +             if (!hlist_empty(&sj->session->tasks[PIDTYPE_SID])) {
>> +                     remaining++;
>> +                     continue;
>> +             }
>> +             if (rhashtable_remove_fast(&session_jobids,
>> +                                        &sj->linkage, jobid_params) == 0) {
>> +                     put_pid(sj->session);
>> +                     kfree_rcu(sj, rcu);
>> +             }
>> +     }
>> +     rhashtable_walk_stop(&iter);
>> +     rhashtable_walk_exit(&iter);
>> +     if (remaining)
>> +             schedule_delayed_work(&jobid_prune_work, JOBID_BACKGROUND_CLEAN);
>> +}
>> +
>> +static void jobid_prune_expedite(void)
>> +{
>> +     if (!jobid_prune_expedited) {
>> +             jobid_prune_expedited = 1;
>> +             mod_delayed_work(system_wq, &jobid_prune_work, JOBID_EXPEDITED_CLEAN);
>> +     }
>> +}
>> +
>> /* Get jobid of current process from stored variable or calculate
>>  * it from pid and user_id.
>>  *
>> @@ -108,6 +246,17 @@ int lustre_get_jobid(char *jobid)
>>                goto out_cache_jobid;
>>        }
>>
>> +     if (strcmp(obd_jobid_var, JOBSTATS_MANUAL) == 0) {
>> +             char *jid;
>> +             rcu_read_lock();
>> +             jid = jobid_current();
>> +             if (jid)
>> +                     strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
>> +             rcu_read_unlock();
>> +             if (jid)
>> +                     goto out_cache_jobid;
>> +     }
>> +
>>        return -ENOENT;
>>
>> out_cache_jobid:
>> @@ -663,10 +812,13 @@ static int __init obdclass_init(void)
>>        if (err)
>>                goto cleanup_zombie_impexp;
>>
>> +     err = rhashtable_init(&session_jobids, &jobid_params);
>> +     if (err)
>> +             goto cleanup_class_handle;
>>        err = misc_register(&obd_psdev);
>>        if (err) {
>>                CERROR("cannot register OBD miscdevices: err %d\n", err);
>> -             goto cleanup_class_handle;
>> +             goto cleanup_session_jobids;
>>        }
>>
>>        /* Default the dirty page cache cap to 1/2 of system memory.
>> @@ -724,6 +876,9 @@ static int __init obdclass_init(void)
>> cleanup_deregister:
>>        misc_deregister(&obd_psdev);
>>
>> +cleanup_session_jobids:
>> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
>> +
>> cleanup_class_handle:
>>        class_handle_cleanup();
>>
>> @@ -743,6 +898,9 @@ static void obdclass_exit(void)
>>        cl_global_fini();
>>        lu_global_fini();
>>
>> +     cancel_delayed_work_sync(&jobid_prune_work);
>> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
>> +
>>        obd_cleanup_caches();
>>
>>        class_procfs_clean();
>> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>> index 69ccc6a55947..112782e56793 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>> @@ -220,6 +220,7 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
>>                JOBSTATS_DISABLE,
>>                JOBSTATS_PROCNAME_UID,
>>                JOBSTATS_NODELOCAL,
>> +             JOBSTATS_MANUAL,
>>                NULL
>>        };
>>        int i;
>> @@ -263,6 +264,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
>>        return count;
>> }
>>
>> +static ssize_t jobid_this_session_show(struct kobject *kobj,
>> +                                    struct attribute *attr,
>> +                                    char *buf)
>> +{
>> +     char *jid;
>> +     int ret = -ENOENT;
>> +
>> +     rcu_read_lock();
>> +     jid = jobid_current();
>> +     if (jid)
>> +             ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
>> +     rcu_read_unlock();
>> +     return ret;
>> +}
>> +
>> +static ssize_t jobid_this_session_store(struct kobject *kobj,
>> +                                     struct attribute *attr,
>> +                                     const char *buffer,
>> +                                     size_t count)
>> +{
>> +     char *jobid;
>> +     int len;
>> +     int ret;
>> +
>> +     if (!count || count > LUSTRE_JOBID_SIZE)
>> +             return -EINVAL;
>> +
>> +     jobid = kstrndup(buffer, count, GFP_KERNEL);
>> +     if (!jobid)
>> +             return -ENOMEM;
>> +     len = strcspn(jobid, " \n");
>> +     jobid[len] = '\0';
>> +     ret = jobid_set_current(jobid);
>> +     kfree(jobid);
>> +
>> +     return ret ?: count;
>> +}
>> +
>> /* Root for /sys/kernel/debug/lustre */
>> struct dentry *debugfs_lustre_root;
>> EXPORT_SYMBOL_GPL(debugfs_lustre_root);
>> @@ -272,6 +311,7 @@ LUSTRE_RO_ATTR(pinger);
>> LUSTRE_RO_ATTR(health_check);
>> LUSTRE_RW_ATTR(jobid_var);
>> LUSTRE_RW_ATTR(jobid_name);
>> +LUSTRE_RW_ATTR(jobid_this_session);
>>
>> static struct attribute *lustre_attrs[] = {
>>        &lustre_attr_version.attr,
>> @@ -279,6 +319,7 @@ static struct attribute *lustre_attrs[] = {
>>        &lustre_attr_health_check.attr,
>>        &lustre_attr_jobid_name.attr,
>>        &lustre_attr_jobid_var.attr,
>> +     &lustre_attr_jobid_this_session.attr,
>>        &lustre_sattr_timeout.u.attr,
>>        &lustre_attr_max_dirty_mb.attr,
>>        &lustre_sattr_debug_peer_on_timeout.u.attr,
>> --
>> 2.14.0.rc0.dirty
>>
>
> Cheers, Andreas
> ---
> Andreas Dilger
> CTO Whamcloud
>
>
>
>
> _______________________________________________
> lustre-devel mailing list
> lustre-devel at lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190314/0833fd0c/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-03-14  0:34           ` NeilBrown
@ 2019-03-14 14:12             ` Patrick Farrell
  2019-03-14 22:56               ` NeilBrown
  2019-03-14 23:05               ` Andreas Dilger
  0 siblings, 2 replies; 105+ messages in thread
From: Patrick Farrell @ 2019-03-14 14:12 UTC (permalink / raw)
  To: lustre-devel

So can we set session ids?  Can we make them the same across many nodes?  It doesn't sound like it.  That's a basic requirement.  We need more than just "kernel provided ID which is unique to process set on a node".  The point of jobstats is to be able to collect info on all of a job, and many jobs will span many nodes.  (We also have > 1 job per node in other cases.)


- Patrick

________________________________
From: NeilBrown <neilb@suse.com>
Sent: Wednesday, March 13, 2019 7:34:05 PM
To: Patrick Farrell; Andreas Dilger
Cc: Lustre Development List
Subject: Re: [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var


Hi Patrick,
 I agree that "something that should live in struct_task" is the sort of
 answer that would be nice, but I don't think it can be justified.

 A "session" in the sense of "getsid" and "setsid" is traditionally a
 login session, but since the invention of windowing systems it is one
 terminal window.
 So if you
    grep NSsid /proc/self/status
 in different windows you will see different session ids.  All processes
 in that window will have the same session id unless something
 explicitly creates a new session - few things do that.

 If you want to explicitly create a new session, you can use "setsid".
 So
    setsid grep NSsid /proc/self/status
 will always show a new session id.

 Considering you sketch, the "unique parent" is already very likely to
 be in a session that no other job is in.
 If you run multiple jobs from the one terminal window (is they likely?)
 then the will all be in the same session unless you run
    setsid run-my-job

 The session (and anything we associated with it) will apply to all
 children and grandchild etc.
 There is no need for a timeout beyond what the code already has - it
 checks every 5 minutes to see if the session is still active, and
 forgets any inactive session.  There is no risk of a new session being
 confused with an old session that no longer exists, even if they have
 the same number.

 I hope that clarifies for you.

Thanks,
NeilBrown


On Fri, Mar 01 2019, Patrick Farrell wrote:

> The definition of "session" matters here.  It is increasingly common to run multiple jobs on a node at the same time, and the desire to distinguish between them is also significant.  So we can't have just one session.
>
> I believe this is part of why it was chosen to put this information in user space, associated with a particular process.
>
> So we need a solution that can meet that requirement or the broader HPC world will just ignore us.
>
> Perhaps we could use the new jobid cache functionality here.  A sketch:
>
> Have the parent - I believe there would be a unique parent for every set of job processes - register the ID (via this proc variable) and we would apply it to all children (what about grandchildren, etc...).  Then set timeouts to something like 24 or 48 hours, and but also use (or add if it's not present?) the functionality to deregister job ids at job exit.  So the timeout is only for cleanup.
>
> Although, the more I talk about this, the more this feels like something that should live in struct_task and be set from user space and managed by the kernel...
> ________________________________
> From: lustre-devel <lustre-devel-bounces@lists.lustre.org> on behalf of Andreas Dilger <adilger@whamcloud.com>
> Sent: Friday, March 1, 2019 2:32:00 AM
> To: NeilBrown
> Cc: Lustre Development List
> Subject: Re: [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
>
> On Feb 28, 2019, at 19:35, NeilBrown <neilb@suse.com> wrote:
>>
>> On Wed, Feb 27 2019, Andreas Dilger wrote:
>>
>>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>>>>
>>>> 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.
>>>>
>>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>>
>>> This will no longer be true once https://review.whamcloud.com/31691
>>> commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")
>>
>> Actually it will.  That patch changes the use of jobid_name, my patch
>> restricts the values of jobid_var.
>>
>> I just realized why it is called "jobid_var" - in OpenSFS lustre, it can
>> be an environment variable name.  In drivers/staging lustre it cannot,
>> so the name is a little odd.
>>
>>>
>>> Currently the "%j" function was removed from the kernel client, even
>>> though there is no technical reason it can't work (i.e. all of the code
>>> to implement it is available and exported).  This is actually super
>>> useful for HPC cluster administrators to monitor per-job IO bandwidth
>>> and IOPS on the server, and something that I think should be restored.
>>
>> I think that you probably need to let go of that desire - I don't think
>> it is going to happen.  While the code may, as you say, work - it is
>> easy to dislike that approach, and would be hard to push against such
>> resistance.
>>
>> I have an alternate approach, patch below.  Instead of
>> export LUSTRE_JOBID=foobar
>> and process can run
>> echo foobar > /sys/fs/lustre/jobid_this_session
>>
>> and it will affect all processes in the current "session".
>>
>> Could you warm to this approach at all?
>
> This is the best alternative that I've seen so far.  That said, the choice
> of storing the JobID as an environment variable wasn't something that we
> invented ourselves, but rather this is what the various job schedulers do
> when a job is first started, and the code to extract the JobID out of the
> process environment was what we implemented to work within the constraints
> that were given to us.  The benefit of course is that we don't depend on
> some external process to be run for every process to extract the environment
> variable from the kernel memory and send it back to us.
>
> Allowing different processes to have different JobIDs on a single node is
> definitely a requirement for most environments these days, and so far this
> is the only solution that has allowed that to work.
>
> James is more familiar with the production side of the house, so I'll let
> him comment on how easy/hard it would be to get this kind of change added
> to the per-job preamble script so that it is set for all processes.
>
> Cheers, Andreas
>
>> From: NeilBrown <neilb@suse.com>
>> Subject: [PATCH] lustre: obdclass: allow per-session jobids.
>>
>> Lustre includes a jobid in all RPC message sent to the server.  This
>> is used to collected per-job statistics, where a "job" can involve
>> multiple processes on multiple nodes in a cluster.
>>
>> Nodes in a cluster can be running processes for multiple jobs, so it
>> is best if different processes can have different jobids, and that
>> processes on different nodes can have the same job id.
>>
>> This is not currently possible with the drivers/staging code.
>>
>> Lustre traditionally uses an environment variable to name a job, but
>> having the kernel reach into the address space of a process to find
>> that environment variable is seen by some developers to be an
>> unacceptable design choice.
>>
>> This patch provides an alternate method, leveraging the concept of a
>> "session id", as set with setsid().  Each login session already gets a
>> unique sid which is preserved for all processes in that session unless
>> explicitly changed (with setsid(1)).
>> When a process in a session writes to
>> /sys/fs/lustre/jobid_this_session, the string becomes the name for
>> that session.
>> If jobid_var is set to "manual", then the per-session jobid is used
>> for the jobid for all requests from processes in that session.
>>
>> When a session ends, the jobid information will be purged within 5
>> minutes.
>>
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>> .../staging/lustre/lustre/include/lprocfs_status.h |   1 +
>> drivers/staging/lustre/lustre/include/obd_class.h  |   3 +
>> drivers/staging/lustre/lustre/obdclass/class_obd.c | 160 ++++++++++++++++++++-
>> drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |  41 ++++++
>> 4 files changed, 204 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
>> index 8565c28f08ee..1335a5722903 100644
>> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
>> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
>> @@ -370,6 +370,7 @@ static inline void s2dhms(struct dhms *ts, time64_t secs64)
>> #define JOBSTATS_DISABLE              "disable"
>> #define JOBSTATS_PROCNAME_UID         "procname_uid"
>> #define JOBSTATS_NODELOCAL            "nodelocal"
>> +#define JOBSTATS_MANUAL                      "manual"
>>
>> /* obd_config.c */
>> void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
>> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
>> index 50b08c89ecc5..08003f3dd467 100644
>> --- a/drivers/staging/lustre/lustre/include/obd_class.h
>> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
>> @@ -55,6 +55,9 @@ extern rwlock_t obd_dev_lock;
>> struct obd_device *class_exp2obd(struct obd_export *exp);
>> int class_handle_ioctl(unsigned int cmd, unsigned long arg);
>> int lustre_get_jobid(char *jobid);
>> +char *jobid_current(void);
>> +int jobid_set_current(char *jobid);
>> +
>>
>> struct lu_device_type;
>>
>> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> index 1fcbda128a58..19ce3c858e59 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> @@ -79,6 +79,144 @@ EXPORT_SYMBOL(at_extra);
>> char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
>> char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
>>
>> +/*
>> + * Jobid can be set for a session (see setsid(2)) by writing to
>> + * a sysfs file from any process in that session.
>> + * The jobids are stored in a hash table indexed by the relevant
>> + * struct pid.  We periodically look for entries where the pid has
>> + * no PIDTYPE_SID tasks any more, and prune them.  This happens within
>> + * 5 seconds of a jobid being added, and every 5 minutes when jobids exist,
>> + * but none are added.
>> + */
>> +#define JOBID_EXPEDITED_CLEAN (5 * HZ)
>> +#define JOBID_BACKGROUND_CLEAN (5 * 60 * HZ)
>> +
>> +struct session_jobid {
>> +     struct pid              *session;
>> +     struct rhash_head       linkage;
>> +     struct rcu_head         rcu;
>> +     char                    jobid[1];
>> +};
>> +
>> +const static struct rhashtable_params jobid_params = {
>> +     .key_len        = sizeof(struct pid *),
>> +     .key_offset     = offsetof(struct session_jobid, session),
>> +     .head_offset    = offsetof(struct session_jobid, linkage),
>> +};
>> +static struct rhashtable session_jobids;
>> +
>> +/*
>> + * jobid_current must be called with rcu_read_lock held.
>> + * if it returns non-NULL, the string can only be used
>> + * until rcu_read_unlock is called.
>> + */
>> +char *jobid_current(void)
>> +{
>> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
>> +     struct session_jobid *sj;
>> +
>> +     sj = rhashtable_lookup_fast(&session_jobids, &sid, jobid_params);
>> +     if (sj)
>> +             return sj->jobid;
>> +     return NULL;
>> +}
>> +
>> +static void jobid_prune_expedite(void);
>> +/*
>> + * jobid_set_current will try to add a new entry
>> + * to the table.  If one exists with the same key, the
>> + * jobid will be replaced
>> + */
>> +int jobid_set_current(char *jobid)
>> +{
>> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
>> +     struct session_jobid *sj, *origsj;
>> +     int ret;
>> +
>> +     sj = kmalloc(sizeof(*sj) + strlen(jobid), GFP_KERNEL);
>> +     if (!sj)
>> +             return -ENOMEM;
>> +     rcu_read_lock();
>> +     sj->session = get_pid(sid);
>> +     strcpy(sj->jobid, jobid);
>> +     origsj = rhashtable_lookup_get_insert_fast(&session_jobids,
>> +                                                &sj->linkage,
>> +                                                jobid_params);
>> +     if (origsj == NULL) {
>> +             /* successful insert */
>> +             rcu_read_unlock();
>> +             jobid_prune_expedite();
>> +             return 0;
>> +     }
>> +
>> +     if (IS_ERR(origsj)) {
>> +             put_pid(sj->session);
>> +             kfree(sj);
>> +             rcu_read_unlock();
>> +             return PTR_ERR(origsj);
>> +     }
>> +     ret = rhashtable_replace_fast(&session_jobids,
>> +                                   &origsj->linkage,
>> +                                   &sj->linkage,
>> +                                   jobid_params);
>> +     if (ret) {
>> +             put_pid(sj->session);
>> +             kfree(sj);
>> +             rcu_read_unlock();
>> +             return ret;
>> +     }
>> +     put_pid(origsj->session);
>> +     rcu_read_unlock();
>> +     kfree_rcu(origsj, rcu);
>> +     jobid_prune_expedite();
>> +
>> +     return 0;
>> +}
>> +
>> +static void jobid_free(void *vsj, void *arg)
>> +{
>> +     struct session_jobid *sj = vsj;
>> +     put_pid(sj->session);
>> +     kfree(sj);
>> +}
>> +
>> +static void jobid_prune(struct work_struct *work);
>> +static DECLARE_DELAYED_WORK(jobid_prune_work, jobid_prune);
>> +static int jobid_prune_expedited;
>> +static void jobid_prune(struct work_struct *work)
>> +{
>> +     int remaining = 0;
>> +     struct rhashtable_iter iter;
>> +     struct session_jobid *sj;
>> +
>> +     jobid_prune_expedited = 0;
>> +     rhashtable_walk_enter(&session_jobids, &iter);
>> +     rhashtable_walk_start(&iter);
>> +     while ((sj = rhashtable_walk_next(&iter)) != NULL) {
>> +             if (!hlist_empty(&sj->session->tasks[PIDTYPE_SID])) {
>> +                     remaining++;
>> +                     continue;
>> +             }
>> +             if (rhashtable_remove_fast(&session_jobids,
>> +                                        &sj->linkage, jobid_params) == 0) {
>> +                     put_pid(sj->session);
>> +                     kfree_rcu(sj, rcu);
>> +             }
>> +     }
>> +     rhashtable_walk_stop(&iter);
>> +     rhashtable_walk_exit(&iter);
>> +     if (remaining)
>> +             schedule_delayed_work(&jobid_prune_work, JOBID_BACKGROUND_CLEAN);
>> +}
>> +
>> +static void jobid_prune_expedite(void)
>> +{
>> +     if (!jobid_prune_expedited) {
>> +             jobid_prune_expedited = 1;
>> +             mod_delayed_work(system_wq, &jobid_prune_work, JOBID_EXPEDITED_CLEAN);
>> +     }
>> +}
>> +
>> /* Get jobid of current process from stored variable or calculate
>>  * it from pid and user_id.
>>  *
>> @@ -108,6 +246,17 @@ int lustre_get_jobid(char *jobid)
>>                goto out_cache_jobid;
>>        }
>>
>> +     if (strcmp(obd_jobid_var, JOBSTATS_MANUAL) == 0) {
>> +             char *jid;
>> +             rcu_read_lock();
>> +             jid = jobid_current();
>> +             if (jid)
>> +                     strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
>> +             rcu_read_unlock();
>> +             if (jid)
>> +                     goto out_cache_jobid;
>> +     }
>> +
>>        return -ENOENT;
>>
>> out_cache_jobid:
>> @@ -663,10 +812,13 @@ static int __init obdclass_init(void)
>>        if (err)
>>                goto cleanup_zombie_impexp;
>>
>> +     err = rhashtable_init(&session_jobids, &jobid_params);
>> +     if (err)
>> +             goto cleanup_class_handle;
>>        err = misc_register(&obd_psdev);
>>        if (err) {
>>                CERROR("cannot register OBD miscdevices: err %d\n", err);
>> -             goto cleanup_class_handle;
>> +             goto cleanup_session_jobids;
>>        }
>>
>>        /* Default the dirty page cache cap to 1/2 of system memory.
>> @@ -724,6 +876,9 @@ static int __init obdclass_init(void)
>> cleanup_deregister:
>>        misc_deregister(&obd_psdev);
>>
>> +cleanup_session_jobids:
>> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
>> +
>> cleanup_class_handle:
>>        class_handle_cleanup();
>>
>> @@ -743,6 +898,9 @@ static void obdclass_exit(void)
>>        cl_global_fini();
>>        lu_global_fini();
>>
>> +     cancel_delayed_work_sync(&jobid_prune_work);
>> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
>> +
>>        obd_cleanup_caches();
>>
>>        class_procfs_clean();
>> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>> index 69ccc6a55947..112782e56793 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>> @@ -220,6 +220,7 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
>>                JOBSTATS_DISABLE,
>>                JOBSTATS_PROCNAME_UID,
>>                JOBSTATS_NODELOCAL,
>> +             JOBSTATS_MANUAL,
>>                NULL
>>        };
>>        int i;
>> @@ -263,6 +264,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
>>        return count;
>> }
>>
>> +static ssize_t jobid_this_session_show(struct kobject *kobj,
>> +                                    struct attribute *attr,
>> +                                    char *buf)
>> +{
>> +     char *jid;
>> +     int ret = -ENOENT;
>> +
>> +     rcu_read_lock();
>> +     jid = jobid_current();
>> +     if (jid)
>> +             ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
>> +     rcu_read_unlock();
>> +     return ret;
>> +}
>> +
>> +static ssize_t jobid_this_session_store(struct kobject *kobj,
>> +                                     struct attribute *attr,
>> +                                     const char *buffer,
>> +                                     size_t count)
>> +{
>> +     char *jobid;
>> +     int len;
>> +     int ret;
>> +
>> +     if (!count || count > LUSTRE_JOBID_SIZE)
>> +             return -EINVAL;
>> +
>> +     jobid = kstrndup(buffer, count, GFP_KERNEL);
>> +     if (!jobid)
>> +             return -ENOMEM;
>> +     len = strcspn(jobid, " \n");
>> +     jobid[len] = '\0';
>> +     ret = jobid_set_current(jobid);
>> +     kfree(jobid);
>> +
>> +     return ret ?: count;
>> +}
>> +
>> /* Root for /sys/kernel/debug/lustre */
>> struct dentry *debugfs_lustre_root;
>> EXPORT_SYMBOL_GPL(debugfs_lustre_root);
>> @@ -272,6 +311,7 @@ LUSTRE_RO_ATTR(pinger);
>> LUSTRE_RO_ATTR(health_check);
>> LUSTRE_RW_ATTR(jobid_var);
>> LUSTRE_RW_ATTR(jobid_name);
>> +LUSTRE_RW_ATTR(jobid_this_session);
>>
>> static struct attribute *lustre_attrs[] = {
>>        &lustre_attr_version.attr,
>> @@ -279,6 +319,7 @@ static struct attribute *lustre_attrs[] = {
>>        &lustre_attr_health_check.attr,
>>        &lustre_attr_jobid_name.attr,
>>        &lustre_attr_jobid_var.attr,
>> +     &lustre_attr_jobid_this_session.attr,
>>        &lustre_sattr_timeout.u.attr,
>>        &lustre_attr_max_dirty_mb.attr,
>>        &lustre_sattr_debug_peer_on_timeout.u.attr,
>> --
>> 2.14.0.rc0.dirty
>>
>
> Cheers, Andreas
> ---
> Andreas Dilger
> CTO Whamcloud
>
>
>
>
> _______________________________________________
> lustre-devel mailing list
> lustre-devel at lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190314/36fbde09/attachment-0001.html>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-03-14 14:12             ` Patrick Farrell
@ 2019-03-14 22:56               ` NeilBrown
  2019-03-14 23:05               ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: NeilBrown @ 2019-03-14 22:56 UTC (permalink / raw)
  To: lustre-devel

On Thu, Mar 14 2019, Patrick Farrell wrote:

> So can we set session ids?  Can we make them the same across many
> nodes?  It doesn't sound like it.  That's a basic requirement.  We
> need more than just "kernel provided ID which is unique to process set
> on a node".  The point of jobstats is to be able to collect info on
> all of a job, and many jobs will span many nodes.  (We also have > 1
> job per node in other cases.) 

This is where my patch some in.
You cannot choose the session-id, but my patch allows you to associate
an arbitrary string with a given session id.  Then all processes in that
session will use the string for tagging RPCs.
The current approach is to store the string in the environment, and this
gets copied from parent to child.
My approach is to store the string in a hash table in the kernel
associated with the session-id.  The session-id already gets copied from
parent to child.
So the result is the same.  An arbitrary string gets associated with all
processes in a job.  If multiple sessions, even on multiple hosts, are
al in the one job, it is simple to associated the same arbitrary string
with all the different session ids.

NeilBrown


>
>
> - Patrick
>
> ________________________________
> From: NeilBrown <neilb@suse.com>
> Sent: Wednesday, March 13, 2019 7:34:05 PM
> To: Patrick Farrell; Andreas Dilger
> Cc: Lustre Development List
> Subject: Re: [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
>
>
> Hi Patrick,
>  I agree that "something that should live in struct_task" is the sort of
>  answer that would be nice, but I don't think it can be justified.
>
>  A "session" in the sense of "getsid" and "setsid" is traditionally a
>  login session, but since the invention of windowing systems it is one
>  terminal window.
>  So if you
>     grep NSsid /proc/self/status
>  in different windows you will see different session ids.  All processes
>  in that window will have the same session id unless something
>  explicitly creates a new session - few things do that.
>
>  If you want to explicitly create a new session, you can use "setsid".
>  So
>     setsid grep NSsid /proc/self/status
>  will always show a new session id.
>
>  Considering you sketch, the "unique parent" is already very likely to
>  be in a session that no other job is in.
>  If you run multiple jobs from the one terminal window (is they likely?)
>  then the will all be in the same session unless you run
>     setsid run-my-job
>
>  The session (and anything we associated with it) will apply to all
>  children and grandchild etc.
>  There is no need for a timeout beyond what the code already has - it
>  checks every 5 minutes to see if the session is still active, and
>  forgets any inactive session.  There is no risk of a new session being
>  confused with an old session that no longer exists, even if they have
>  the same number.
>
>  I hope that clarifies for you.
>
> Thanks,
> NeilBrown
>
>
> On Fri, Mar 01 2019, Patrick Farrell wrote:
>
>> The definition of "session" matters here.  It is increasingly common to run multiple jobs on a node at the same time, and the desire to distinguish between them is also significant.  So we can't have just one session.
>>
>> I believe this is part of why it was chosen to put this information in user space, associated with a particular process.
>>
>> So we need a solution that can meet that requirement or the broader HPC world will just ignore us.
>>
>> Perhaps we could use the new jobid cache functionality here.  A sketch:
>>
>> Have the parent - I believe there would be a unique parent for every set of job processes - register the ID (via this proc variable) and we would apply it to all children (what about grandchildren, etc...).  Then set timeouts to something like 24 or 48 hours, and but also use (or add if it's not present?) the functionality to deregister job ids at job exit.  So the timeout is only for cleanup.
>>
>> Although, the more I talk about this, the more this feels like something that should live in struct_task and be set from user space and managed by the kernel...
>> ________________________________
>> From: lustre-devel <lustre-devel-bounces@lists.lustre.org> on behalf of Andreas Dilger <adilger@whamcloud.com>
>> Sent: Friday, March 1, 2019 2:32:00 AM
>> To: NeilBrown
>> Cc: Lustre Development List
>> Subject: Re: [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
>>
>> On Feb 28, 2019, at 19:35, NeilBrown <neilb@suse.com> wrote:
>>>
>>> On Wed, Feb 27 2019, Andreas Dilger wrote:
>>>
>>>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
>>>>>
>>>>> 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.
>>>>>
>>>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>>>
>>>> This will no longer be true once https://review.whamcloud.com/31691
>>>> commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")
>>>
>>> Actually it will.  That patch changes the use of jobid_name, my patch
>>> restricts the values of jobid_var.
>>>
>>> I just realized why it is called "jobid_var" - in OpenSFS lustre, it can
>>> be an environment variable name.  In drivers/staging lustre it cannot,
>>> so the name is a little odd.
>>>
>>>>
>>>> Currently the "%j" function was removed from the kernel client, even
>>>> though there is no technical reason it can't work (i.e. all of the code
>>>> to implement it is available and exported).  This is actually super
>>>> useful for HPC cluster administrators to monitor per-job IO bandwidth
>>>> and IOPS on the server, and something that I think should be restored.
>>>
>>> I think that you probably need to let go of that desire - I don't think
>>> it is going to happen.  While the code may, as you say, work - it is
>>> easy to dislike that approach, and would be hard to push against such
>>> resistance.
>>>
>>> I have an alternate approach, patch below.  Instead of
>>> export LUSTRE_JOBID=foobar
>>> and process can run
>>> echo foobar > /sys/fs/lustre/jobid_this_session
>>>
>>> and it will affect all processes in the current "session".
>>>
>>> Could you warm to this approach at all?
>>
>> This is the best alternative that I've seen so far.  That said, the choice
>> of storing the JobID as an environment variable wasn't something that we
>> invented ourselves, but rather this is what the various job schedulers do
>> when a job is first started, and the code to extract the JobID out of the
>> process environment was what we implemented to work within the constraints
>> that were given to us.  The benefit of course is that we don't depend on
>> some external process to be run for every process to extract the environment
>> variable from the kernel memory and send it back to us.
>>
>> Allowing different processes to have different JobIDs on a single node is
>> definitely a requirement for most environments these days, and so far this
>> is the only solution that has allowed that to work.
>>
>> James is more familiar with the production side of the house, so I'll let
>> him comment on how easy/hard it would be to get this kind of change added
>> to the per-job preamble script so that it is set for all processes.
>>
>> Cheers, Andreas
>>
>>> From: NeilBrown <neilb@suse.com>
>>> Subject: [PATCH] lustre: obdclass: allow per-session jobids.
>>>
>>> Lustre includes a jobid in all RPC message sent to the server.  This
>>> is used to collected per-job statistics, where a "job" can involve
>>> multiple processes on multiple nodes in a cluster.
>>>
>>> Nodes in a cluster can be running processes for multiple jobs, so it
>>> is best if different processes can have different jobids, and that
>>> processes on different nodes can have the same job id.
>>>
>>> This is not currently possible with the drivers/staging code.
>>>
>>> Lustre traditionally uses an environment variable to name a job, but
>>> having the kernel reach into the address space of a process to find
>>> that environment variable is seen by some developers to be an
>>> unacceptable design choice.
>>>
>>> This patch provides an alternate method, leveraging the concept of a
>>> "session id", as set with setsid().  Each login session already gets a
>>> unique sid which is preserved for all processes in that session unless
>>> explicitly changed (with setsid(1)).
>>> When a process in a session writes to
>>> /sys/fs/lustre/jobid_this_session, the string becomes the name for
>>> that session.
>>> If jobid_var is set to "manual", then the per-session jobid is used
>>> for the jobid for all requests from processes in that session.
>>>
>>> When a session ends, the jobid information will be purged within 5
>>> minutes.
>>>
>>> Signed-off-by: NeilBrown <neilb@suse.com>
>>> ---
>>> .../staging/lustre/lustre/include/lprocfs_status.h |   1 +
>>> drivers/staging/lustre/lustre/include/obd_class.h  |   3 +
>>> drivers/staging/lustre/lustre/obdclass/class_obd.c | 160 ++++++++++++++++++++-
>>> drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |  41 ++++++
>>> 4 files changed, 204 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
>>> index 8565c28f08ee..1335a5722903 100644
>>> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
>>> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
>>> @@ -370,6 +370,7 @@ static inline void s2dhms(struct dhms *ts, time64_t secs64)
>>> #define JOBSTATS_DISABLE              "disable"
>>> #define JOBSTATS_PROCNAME_UID         "procname_uid"
>>> #define JOBSTATS_NODELOCAL            "nodelocal"
>>> +#define JOBSTATS_MANUAL                      "manual"
>>>
>>> /* obd_config.c */
>>> void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
>>> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
>>> index 50b08c89ecc5..08003f3dd467 100644
>>> --- a/drivers/staging/lustre/lustre/include/obd_class.h
>>> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
>>> @@ -55,6 +55,9 @@ extern rwlock_t obd_dev_lock;
>>> struct obd_device *class_exp2obd(struct obd_export *exp);
>>> int class_handle_ioctl(unsigned int cmd, unsigned long arg);
>>> int lustre_get_jobid(char *jobid);
>>> +char *jobid_current(void);
>>> +int jobid_set_current(char *jobid);
>>> +
>>>
>>> struct lu_device_type;
>>>
>>> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>>> index 1fcbda128a58..19ce3c858e59 100644
>>> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
>>> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>>> @@ -79,6 +79,144 @@ EXPORT_SYMBOL(at_extra);
>>> char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
>>> char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
>>>
>>> +/*
>>> + * Jobid can be set for a session (see setsid(2)) by writing to
>>> + * a sysfs file from any process in that session.
>>> + * The jobids are stored in a hash table indexed by the relevant
>>> + * struct pid.  We periodically look for entries where the pid has
>>> + * no PIDTYPE_SID tasks any more, and prune them.  This happens within
>>> + * 5 seconds of a jobid being added, and every 5 minutes when jobids exist,
>>> + * but none are added.
>>> + */
>>> +#define JOBID_EXPEDITED_CLEAN (5 * HZ)
>>> +#define JOBID_BACKGROUND_CLEAN (5 * 60 * HZ)
>>> +
>>> +struct session_jobid {
>>> +     struct pid              *session;
>>> +     struct rhash_head       linkage;
>>> +     struct rcu_head         rcu;
>>> +     char                    jobid[1];
>>> +};
>>> +
>>> +const static struct rhashtable_params jobid_params = {
>>> +     .key_len        = sizeof(struct pid *),
>>> +     .key_offset     = offsetof(struct session_jobid, session),
>>> +     .head_offset    = offsetof(struct session_jobid, linkage),
>>> +};
>>> +static struct rhashtable session_jobids;
>>> +
>>> +/*
>>> + * jobid_current must be called with rcu_read_lock held.
>>> + * if it returns non-NULL, the string can only be used
>>> + * until rcu_read_unlock is called.
>>> + */
>>> +char *jobid_current(void)
>>> +{
>>> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
>>> +     struct session_jobid *sj;
>>> +
>>> +     sj = rhashtable_lookup_fast(&session_jobids, &sid, jobid_params);
>>> +     if (sj)
>>> +             return sj->jobid;
>>> +     return NULL;
>>> +}
>>> +
>>> +static void jobid_prune_expedite(void);
>>> +/*
>>> + * jobid_set_current will try to add a new entry
>>> + * to the table.  If one exists with the same key, the
>>> + * jobid will be replaced
>>> + */
>>> +int jobid_set_current(char *jobid)
>>> +{
>>> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
>>> +     struct session_jobid *sj, *origsj;
>>> +     int ret;
>>> +
>>> +     sj = kmalloc(sizeof(*sj) + strlen(jobid), GFP_KERNEL);
>>> +     if (!sj)
>>> +             return -ENOMEM;
>>> +     rcu_read_lock();
>>> +     sj->session = get_pid(sid);
>>> +     strcpy(sj->jobid, jobid);
>>> +     origsj = rhashtable_lookup_get_insert_fast(&session_jobids,
>>> +                                                &sj->linkage,
>>> +                                                jobid_params);
>>> +     if (origsj == NULL) {
>>> +             /* successful insert */
>>> +             rcu_read_unlock();
>>> +             jobid_prune_expedite();
>>> +             return 0;
>>> +     }
>>> +
>>> +     if (IS_ERR(origsj)) {
>>> +             put_pid(sj->session);
>>> +             kfree(sj);
>>> +             rcu_read_unlock();
>>> +             return PTR_ERR(origsj);
>>> +     }
>>> +     ret = rhashtable_replace_fast(&session_jobids,
>>> +                                   &origsj->linkage,
>>> +                                   &sj->linkage,
>>> +                                   jobid_params);
>>> +     if (ret) {
>>> +             put_pid(sj->session);
>>> +             kfree(sj);
>>> +             rcu_read_unlock();
>>> +             return ret;
>>> +     }
>>> +     put_pid(origsj->session);
>>> +     rcu_read_unlock();
>>> +     kfree_rcu(origsj, rcu);
>>> +     jobid_prune_expedite();
>>> +
>>> +     return 0;
>>> +}
>>> +
>>> +static void jobid_free(void *vsj, void *arg)
>>> +{
>>> +     struct session_jobid *sj = vsj;
>>> +     put_pid(sj->session);
>>> +     kfree(sj);
>>> +}
>>> +
>>> +static void jobid_prune(struct work_struct *work);
>>> +static DECLARE_DELAYED_WORK(jobid_prune_work, jobid_prune);
>>> +static int jobid_prune_expedited;
>>> +static void jobid_prune(struct work_struct *work)
>>> +{
>>> +     int remaining = 0;
>>> +     struct rhashtable_iter iter;
>>> +     struct session_jobid *sj;
>>> +
>>> +     jobid_prune_expedited = 0;
>>> +     rhashtable_walk_enter(&session_jobids, &iter);
>>> +     rhashtable_walk_start(&iter);
>>> +     while ((sj = rhashtable_walk_next(&iter)) != NULL) {
>>> +             if (!hlist_empty(&sj->session->tasks[PIDTYPE_SID])) {
>>> +                     remaining++;
>>> +                     continue;
>>> +             }
>>> +             if (rhashtable_remove_fast(&session_jobids,
>>> +                                        &sj->linkage, jobid_params) == 0) {
>>> +                     put_pid(sj->session);
>>> +                     kfree_rcu(sj, rcu);
>>> +             }
>>> +     }
>>> +     rhashtable_walk_stop(&iter);
>>> +     rhashtable_walk_exit(&iter);
>>> +     if (remaining)
>>> +             schedule_delayed_work(&jobid_prune_work, JOBID_BACKGROUND_CLEAN);
>>> +}
>>> +
>>> +static void jobid_prune_expedite(void)
>>> +{
>>> +     if (!jobid_prune_expedited) {
>>> +             jobid_prune_expedited = 1;
>>> +             mod_delayed_work(system_wq, &jobid_prune_work, JOBID_EXPEDITED_CLEAN);
>>> +     }
>>> +}
>>> +
>>> /* Get jobid of current process from stored variable or calculate
>>>  * it from pid and user_id.
>>>  *
>>> @@ -108,6 +246,17 @@ int lustre_get_jobid(char *jobid)
>>>                goto out_cache_jobid;
>>>        }
>>>
>>> +     if (strcmp(obd_jobid_var, JOBSTATS_MANUAL) == 0) {
>>> +             char *jid;
>>> +             rcu_read_lock();
>>> +             jid = jobid_current();
>>> +             if (jid)
>>> +                     strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
>>> +             rcu_read_unlock();
>>> +             if (jid)
>>> +                     goto out_cache_jobid;
>>> +     }
>>> +
>>>        return -ENOENT;
>>>
>>> out_cache_jobid:
>>> @@ -663,10 +812,13 @@ static int __init obdclass_init(void)
>>>        if (err)
>>>                goto cleanup_zombie_impexp;
>>>
>>> +     err = rhashtable_init(&session_jobids, &jobid_params);
>>> +     if (err)
>>> +             goto cleanup_class_handle;
>>>        err = misc_register(&obd_psdev);
>>>        if (err) {
>>>                CERROR("cannot register OBD miscdevices: err %d\n", err);
>>> -             goto cleanup_class_handle;
>>> +             goto cleanup_session_jobids;
>>>        }
>>>
>>>        /* Default the dirty page cache cap to 1/2 of system memory.
>>> @@ -724,6 +876,9 @@ static int __init obdclass_init(void)
>>> cleanup_deregister:
>>>        misc_deregister(&obd_psdev);
>>>
>>> +cleanup_session_jobids:
>>> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
>>> +
>>> cleanup_class_handle:
>>>        class_handle_cleanup();
>>>
>>> @@ -743,6 +898,9 @@ static void obdclass_exit(void)
>>>        cl_global_fini();
>>>        lu_global_fini();
>>>
>>> +     cancel_delayed_work_sync(&jobid_prune_work);
>>> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
>>> +
>>>        obd_cleanup_caches();
>>>
>>>        class_procfs_clean();
>>> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>>> index 69ccc6a55947..112782e56793 100644
>>> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>>> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
>>> @@ -220,6 +220,7 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
>>>                JOBSTATS_DISABLE,
>>>                JOBSTATS_PROCNAME_UID,
>>>                JOBSTATS_NODELOCAL,
>>> +             JOBSTATS_MANUAL,
>>>                NULL
>>>        };
>>>        int i;
>>> @@ -263,6 +264,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
>>>        return count;
>>> }
>>>
>>> +static ssize_t jobid_this_session_show(struct kobject *kobj,
>>> +                                    struct attribute *attr,
>>> +                                    char *buf)
>>> +{
>>> +     char *jid;
>>> +     int ret = -ENOENT;
>>> +
>>> +     rcu_read_lock();
>>> +     jid = jobid_current();
>>> +     if (jid)
>>> +             ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
>>> +     rcu_read_unlock();
>>> +     return ret;
>>> +}
>>> +
>>> +static ssize_t jobid_this_session_store(struct kobject *kobj,
>>> +                                     struct attribute *attr,
>>> +                                     const char *buffer,
>>> +                                     size_t count)
>>> +{
>>> +     char *jobid;
>>> +     int len;
>>> +     int ret;
>>> +
>>> +     if (!count || count > LUSTRE_JOBID_SIZE)
>>> +             return -EINVAL;
>>> +
>>> +     jobid = kstrndup(buffer, count, GFP_KERNEL);
>>> +     if (!jobid)
>>> +             return -ENOMEM;
>>> +     len = strcspn(jobid, " \n");
>>> +     jobid[len] = '\0';
>>> +     ret = jobid_set_current(jobid);
>>> +     kfree(jobid);
>>> +
>>> +     return ret ?: count;
>>> +}
>>> +
>>> /* Root for /sys/kernel/debug/lustre */
>>> struct dentry *debugfs_lustre_root;
>>> EXPORT_SYMBOL_GPL(debugfs_lustre_root);
>>> @@ -272,6 +311,7 @@ LUSTRE_RO_ATTR(pinger);
>>> LUSTRE_RO_ATTR(health_check);
>>> LUSTRE_RW_ATTR(jobid_var);
>>> LUSTRE_RW_ATTR(jobid_name);
>>> +LUSTRE_RW_ATTR(jobid_this_session);
>>>
>>> static struct attribute *lustre_attrs[] = {
>>>        &lustre_attr_version.attr,
>>> @@ -279,6 +319,7 @@ static struct attribute *lustre_attrs[] = {
>>>        &lustre_attr_health_check.attr,
>>>        &lustre_attr_jobid_name.attr,
>>>        &lustre_attr_jobid_var.attr,
>>> +     &lustre_attr_jobid_this_session.attr,
>>>        &lustre_sattr_timeout.u.attr,
>>>        &lustre_attr_max_dirty_mb.attr,
>>>        &lustre_sattr_debug_peer_on_timeout.u.attr,
>>> --
>>> 2.14.0.rc0.dirty
>>>
>>
>> Cheers, Andreas
>> ---
>> Andreas Dilger
>> CTO Whamcloud
>>
>>
>>
>>
>> _______________________________________________
>> lustre-devel mailing list
>> lustre-devel at lists.lustre.org
>> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190315/4e7fde1f/attachment.sig>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
  2019-03-14 14:12             ` Patrick Farrell
  2019-03-14 22:56               ` NeilBrown
@ 2019-03-14 23:05               ` Andreas Dilger
  1 sibling, 0 replies; 105+ messages in thread
From: Andreas Dilger @ 2019-03-14 23:05 UTC (permalink / raw)
  To: lustre-devel

I think what Neil proposes is that the JobID be attached to the session,
and then used by Lustre in the kernel from the session.  Not quite the
same as a per-process JobID, but in most cases that would be enough (if a
process wants its own JobID it can always start a new session itself).  It
would allow multiple JobIDs for a single node, and with the "complex jobid"
support it would still be possible to specify a per-session JobID with e.g.
"%p", "%e", "%h", "%u", in the global "jobid_name" and use the per-session
"jobid_this_session" for the "%j" value.

The main difference is that the job scheduler preamble script would have to
call "lctl set_param jobid_this_session=NNNN" before launching the user job,
rather than not having to do anything beyond the existing "setenv".

Cheers, Andreas

> On Mar 14, 2019, at 08:12, Patrick Farrell <pfarrell@whamcloud.com> wrote:
> 
> So can we set session ids?  Can we make them the same across many nodes?  It doesn't sound like it.  That's a basic requirement.  We need more than just "kernel provided ID which is unique to process set on a node".  The point of jobstats is to be able to collect info on all of a job, and many jobs will span many nodes.  (We also have > 1 job per node in other cases.)
> 
> - Patrick
>> From: NeilBrown <neilb@suse.com>
>> Sent: Wednesday, March 13, 2019 7:34:05 PM
>> To: Patrick Farrell; Andreas Dilger
>> Cc: Lustre Development List
>> Subject: Re: [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
>>  
>> 
>> Hi Patrick,
>>  I agree that "something that should live in struct_task" is the sort of
>>  answer that would be nice, but I don't think it can be justified.
>> 
>>  A "session" in the sense of "getsid" and "setsid" is traditionally a
>>  login session, but since the invention of windowing systems it is one
>>  terminal window.
>>  So if you
>>     grep NSsid /proc/self/status
>>  in different windows you will see different session ids.  All processes
>>  in that window will have the same session id unless something
>>  explicitly creates a new session - few things do that.
>> 
>>  If you want to explicitly create a new session, you can use "setsid".
>>  So
>>     setsid grep NSsid /proc/self/status
>>  will always show a new session id.
>> 
>>  Considering you sketch, the "unique parent" is already very likely to
>>  be in a session that no other job is in.
>>  If you run multiple jobs from the one terminal window (is they likely?)
>>  then the will all be in the same session unless you run
>>     setsid run-my-job
>> 
>>  The session (and anything we associated with it) will apply to all
>>  children and grandchild etc.
>>  There is no need for a timeout beyond what the code already has - it
>>  checks every 5 minutes to see if the session is still active, and
>>  forgets any inactive session.  There is no risk of a new session being
>>  confused with an old session that no longer exists, even if they have
>>  the same number.
>> 
>>  I hope that clarifies for you.
>> 
> Thanks,
> NeilBrown
> 
> 
> On Fri, Mar 01 2019, Patrick Farrell wrote:
> 
> > The definition of "session" matters here.  It is increasingly common to run multiple jobs on a node at the same time, and the desire to distinguish between them is also significant.  So we can't have just one session.
> >
> > I believe this is part of why it was chosen to put this information in user space, associated with a particular process.
> >
> > So we need a solution that can meet that requirement or the broader HPC world will just ignore us.
> >
> > Perhaps we could use the new jobid cache functionality here.  A sketch:
> >
> > Have the parent - I believe there would be a unique parent for every set of job processes - register the ID (via this proc variable) and we would apply it to all children (what about grandchildren, etc...).  Then set timeouts to something like 24 or 48 hours, and but also use (or add if it's not present?) the functionality to deregister job ids at job exit.  So the timeout is only for cleanup.
> >
> > Although, the more I talk about this, the more this feels like something that should live in struct_task and be set from user space and managed by the kernel...
> > ________________________________
> > From: lustre-devel <lustre-devel-bounces@lists.lustre.org> on behalf of Andreas Dilger <adilger@whamcloud.com>
> > Sent: Friday, March 1, 2019 2:32:00 AM
> > To: NeilBrown
> > Cc: Lustre Development List
> > Subject: Re: [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var
> >
> > On Feb 28, 2019, at 19:35, NeilBrown <neilb@suse.com> wrote:
> >>
> >> On Wed, Feb 27 2019, Andreas Dilger wrote:
> >>
> >>> On Feb 18, 2019, at 17:09, NeilBrown <neilb@suse.com> wrote:
> >>>>
> >>>> 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.
> >>>>
> >>>> Signed-off-by: NeilBrown <neilb@suse.com>
> >>>
> >>> This will no longer be true once https://review.whamcloud.com/31691
> >>> commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids")
> >>
> >> Actually it will.  That patch changes the use of jobid_name, my patch
> >> restricts the values of jobid_var.
> >>
> >> I just realized why it is called "jobid_var" - in OpenSFS lustre, it can
> >> be an environment variable name.  In drivers/staging lustre it cannot,
> >> so the name is a little odd.
> >>
> >>>
> >>> Currently the "%j" function was removed from the kernel client, even
> >>> though there is no technical reason it can't work (i.e. all of the code
> >>> to implement it is available and exported).  This is actually super
> >>> useful for HPC cluster administrators to monitor per-job IO bandwidth
> >>> and IOPS on the server, and something that I think should be restored.
> >>
> >> I think that you probably need to let go of that desire - I don't think
> >> it is going to happen.  While the code may, as you say, work - it is
> >> easy to dislike that approach, and would be hard to push against such
> >> resistance.
> >>
> >> I have an alternate approach, patch below.  Instead of
> >> export LUSTRE_JOBID=foobar
> >> and process can run
> >> echo foobar > /sys/fs/lustre/jobid_this_session
> >>
> >> and it will affect all processes in the current "session".
> >>
> >> Could you warm to this approach at all?
> >
> > This is the best alternative that I've seen so far.  That said, the choice
> > of storing the JobID as an environment variable wasn't something that we
> > invented ourselves, but rather this is what the various job schedulers do
> > when a job is first started, and the code to extract the JobID out of the
> > process environment was what we implemented to work within the constraints
> > that were given to us.  The benefit of course is that we don't depend on
> > some external process to be run for every process to extract the environment
> > variable from the kernel memory and send it back to us.
> >
> > Allowing different processes to have different JobIDs on a single node is
> > definitely a requirement for most environments these days, and so far this
> > is the only solution that has allowed that to work.
> >
> > James is more familiar with the production side of the house, so I'll let
> > him comment on how easy/hard it would be to get this kind of change added
> > to the per-job preamble script so that it is set for all processes.
> >
> > Cheers, Andreas
> >
> >> From: NeilBrown <neilb@suse.com>
> >> Subject: [PATCH] lustre: obdclass: allow per-session jobids.
> >>
> >> Lustre includes a jobid in all RPC message sent to the server.  This
> >> is used to collected per-job statistics, where a "job" can involve
> >> multiple processes on multiple nodes in a cluster.
> >>
> >> Nodes in a cluster can be running processes for multiple jobs, so it
> >> is best if different processes can have different jobids, and that
> >> processes on different nodes can have the same job id.
> >>
> >> This is not currently possible with the drivers/staging code.
> >>
> >> Lustre traditionally uses an environment variable to name a job, but
> >> having the kernel reach into the address space of a process to find
> >> that environment variable is seen by some developers to be an
> >> unacceptable design choice.
> >>
> >> This patch provides an alternate method, leveraging the concept of a
> >> "session id", as set with setsid().  Each login session already gets a
> >> unique sid which is preserved for all processes in that session unless
> >> explicitly changed (with setsid(1)).
> >> When a process in a session writes to
> >> /sys/fs/lustre/jobid_this_session, the string becomes the name for
> >> that session.
> >> If jobid_var is set to "manual", then the per-session jobid is used
> >> for the jobid for all requests from processes in that session.
> >>
> >> When a session ends, the jobid information will be purged within 5
> >> minutes.
> >>
> >> Signed-off-by: NeilBrown <neilb@suse.com>
> >> ---
> >> .../staging/lustre/lustre/include/lprocfs_status.h |   1 +
> >> drivers/staging/lustre/lustre/include/obd_class.h  |   3 +
> >> drivers/staging/lustre/lustre/obdclass/class_obd.c | 160 ++++++++++++++++++++-
> >> drivers/staging/lustre/lustre/obdclass/obd_sysfs.c |  41 ++++++
> >> 4 files changed, 204 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> >> index 8565c28f08ee..1335a5722903 100644
> >> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
> >> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> >> @@ -370,6 +370,7 @@ static inline void s2dhms(struct dhms *ts, time64_t secs64)
> >> #define JOBSTATS_DISABLE              "disable"
> >> #define JOBSTATS_PROCNAME_UID         "procname_uid"
> >> #define JOBSTATS_NODELOCAL            "nodelocal"
> >> +#define JOBSTATS_MANUAL                      "manual"
> >>
> >> /* obd_config.c */
> >> void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
> >> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> >> index 50b08c89ecc5..08003f3dd467 100644
> >> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> >> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> >> @@ -55,6 +55,9 @@ extern rwlock_t obd_dev_lock;
> >> struct obd_device *class_exp2obd(struct obd_export *exp);
> >> int class_handle_ioctl(unsigned int cmd, unsigned long arg);
> >> int lustre_get_jobid(char *jobid);
> >> +char *jobid_current(void);
> >> +int jobid_set_current(char *jobid);
> >> +
> >>
> >> struct lu_device_type;
> >>
> >> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> >> index 1fcbda128a58..19ce3c858e59 100644
> >> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
> >> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> >> @@ -79,6 +79,144 @@ EXPORT_SYMBOL(at_extra);
> >> char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
> >> char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
> >>
> >> +/*
> >> + * Jobid can be set for a session (see setsid(2)) by writing to
> >> + * a sysfs file from any process in that session.
> >> + * The jobids are stored in a hash table indexed by the relevant
> >> + * struct pid.  We periodically look for entries where the pid has
> >> + * no PIDTYPE_SID tasks any more, and prune them.  This happens within
> >> + * 5 seconds of a jobid being added, and every 5 minutes when jobids exist,
> >> + * but none are added.
> >> + */
> >> +#define JOBID_EXPEDITED_CLEAN (5 * HZ)
> >> +#define JOBID_BACKGROUND_CLEAN (5 * 60 * HZ)
> >> +
> >> +struct session_jobid {
> >> +     struct pid              *session;
> >> +     struct rhash_head       linkage;
> >> +     struct rcu_head         rcu;
> >> +     char                    jobid[1];
> >> +};
> >> +
> >> +const static struct rhashtable_params jobid_params = {
> >> +     .key_len        = sizeof(struct pid *),
> >> +     .key_offset     = offsetof(struct session_jobid, session),
> >> +     .head_offset    = offsetof(struct session_jobid, linkage),
> >> +};
> >> +static struct rhashtable session_jobids;
> >> +
> >> +/*
> >> + * jobid_current must be called with rcu_read_lock held.
> >> + * if it returns non-NULL, the string can only be used
> >> + * until rcu_read_unlock is called.
> >> + */
> >> +char *jobid_current(void)
> >> +{
> >> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
> >> +     struct session_jobid *sj;
> >> +
> >> +     sj = rhashtable_lookup_fast(&session_jobids, &sid, jobid_params);
> >> +     if (sj)
> >> +             return sj->jobid;
> >> +     return NULL;
> >> +}
> >> +
> >> +static void jobid_prune_expedite(void);
> >> +/*
> >> + * jobid_set_current will try to add a new entry
> >> + * to the table.  If one exists with the same key, the
> >> + * jobid will be replaced
> >> + */
> >> +int jobid_set_current(char *jobid)
> >> +{
> >> +     struct pid *sid = current->signal->pids[PIDTYPE_SID];
> >> +     struct session_jobid *sj, *origsj;
> >> +     int ret;
> >> +
> >> +     sj = kmalloc(sizeof(*sj) + strlen(jobid), GFP_KERNEL);
> >> +     if (!sj)
> >> +             return -ENOMEM;
> >> +     rcu_read_lock();
> >> +     sj->session = get_pid(sid);
> >> +     strcpy(sj->jobid, jobid);
> >> +     origsj = rhashtable_lookup_get_insert_fast(&session_jobids,
> >> +                                                &sj->linkage,
> >> +                                                jobid_params);
> >> +     if (origsj == NULL) {
> >> +             /* successful insert */
> >> +             rcu_read_unlock();
> >> +             jobid_prune_expedite();
> >> +             return 0;
> >> +     }
> >> +
> >> +     if (IS_ERR(origsj)) {
> >> +             put_pid(sj->session);
> >> +             kfree(sj);
> >> +             rcu_read_unlock();
> >> +             return PTR_ERR(origsj);
> >> +     }
> >> +     ret = rhashtable_replace_fast(&session_jobids,
> >> +                                   &origsj->linkage,
> >> +                                   &sj->linkage,
> >> +                                   jobid_params);
> >> +     if (ret) {
> >> +             put_pid(sj->session);
> >> +             kfree(sj);
> >> +             rcu_read_unlock();
> >> +             return ret;
> >> +     }
> >> +     put_pid(origsj->session);
> >> +     rcu_read_unlock();
> >> +     kfree_rcu(origsj, rcu);
> >> +     jobid_prune_expedite();
> >> +
> >> +     return 0;
> >> +}
> >> +
> >> +static void jobid_free(void *vsj, void *arg)
> >> +{
> >> +     struct session_jobid *sj = vsj;
> >> +     put_pid(sj->session);
> >> +     kfree(sj);
> >> +}
> >> +
> >> +static void jobid_prune(struct work_struct *work);
> >> +static DECLARE_DELAYED_WORK(jobid_prune_work, jobid_prune);
> >> +static int jobid_prune_expedited;
> >> +static void jobid_prune(struct work_struct *work)
> >> +{
> >> +     int remaining = 0;
> >> +     struct rhashtable_iter iter;
> >> +     struct session_jobid *sj;
> >> +
> >> +     jobid_prune_expedited = 0;
> >> +     rhashtable_walk_enter(&session_jobids, &iter);
> >> +     rhashtable_walk_start(&iter);
> >> +     while ((sj = rhashtable_walk_next(&iter)) != NULL) {
> >> +             if (!hlist_empty(&sj->session->tasks[PIDTYPE_SID])) {
> >> +                     remaining++;
> >> +                     continue;
> >> +             }
> >> +             if (rhashtable_remove_fast(&session_jobids,
> >> +                                        &sj->linkage, jobid_params) == 0) {
> >> +                     put_pid(sj->session);
> >> +                     kfree_rcu(sj, rcu);
> >> +             }
> >> +     }
> >> +     rhashtable_walk_stop(&iter);
> >> +     rhashtable_walk_exit(&iter);
> >> +     if (remaining)
> >> +             schedule_delayed_work(&jobid_prune_work, JOBID_BACKGROUND_CLEAN);
> >> +}
> >> +
> >> +static void jobid_prune_expedite(void)
> >> +{
> >> +     if (!jobid_prune_expedited) {
> >> +             jobid_prune_expedited = 1;
> >> +             mod_delayed_work(system_wq, &jobid_prune_work, JOBID_EXPEDITED_CLEAN);
> >> +     }
> >> +}
> >> +
> >> /* Get jobid of current process from stored variable or calculate
> >>  * it from pid and user_id.
> >>  *
> >> @@ -108,6 +246,17 @@ int lustre_get_jobid(char *jobid)
> >>                goto out_cache_jobid;
> >>        }
> >>
> >> +     if (strcmp(obd_jobid_var, JOBSTATS_MANUAL) == 0) {
> >> +             char *jid;
> >> +             rcu_read_lock();
> >> +             jid = jobid_current();
> >> +             if (jid)
> >> +                     strlcpy(tmp_jobid, jid, sizeof(tmp_jobid));
> >> +             rcu_read_unlock();
> >> +             if (jid)
> >> +                     goto out_cache_jobid;
> >> +     }
> >> +
> >>        return -ENOENT;
> >>
> >> out_cache_jobid:
> >> @@ -663,10 +812,13 @@ static int __init obdclass_init(void)
> >>        if (err)
> >>                goto cleanup_zombie_impexp;
> >>
> >> +     err = rhashtable_init(&session_jobids, &jobid_params);
> >> +     if (err)
> >> +             goto cleanup_class_handle;
> >>        err = misc_register(&obd_psdev);
> >>        if (err) {
> >>                CERROR("cannot register OBD miscdevices: err %d\n", err);
> >> -             goto cleanup_class_handle;
> >> +             goto cleanup_session_jobids;
> >>        }
> >>
> >>        /* Default the dirty page cache cap to 1/2 of system memory.
> >> @@ -724,6 +876,9 @@ static int __init obdclass_init(void)
> >> cleanup_deregister:
> >>        misc_deregister(&obd_psdev);
> >>
> >> +cleanup_session_jobids:
> >> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
> >> +
> >> cleanup_class_handle:
> >>        class_handle_cleanup();
> >>
> >> @@ -743,6 +898,9 @@ static void obdclass_exit(void)
> >>        cl_global_fini();
> >>        lu_global_fini();
> >>
> >> +     cancel_delayed_work_sync(&jobid_prune_work);
> >> +     rhashtable_free_and_destroy(&session_jobids, jobid_free, NULL);
> >> +
> >>        obd_cleanup_caches();
> >>
> >>        class_procfs_clean();
> >> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> >> index 69ccc6a55947..112782e56793 100644
> >> --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> >> +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c
> >> @@ -220,6 +220,7 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
> >>                JOBSTATS_DISABLE,
> >>                JOBSTATS_PROCNAME_UID,
> >>                JOBSTATS_NODELOCAL,
> >> +             JOBSTATS_MANUAL,
> >>                NULL
> >>        };
> >>        int i;
> >> @@ -263,6 +264,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
> >>        return count;
> >> }
> >>
> >> +static ssize_t jobid_this_session_show(struct kobject *kobj,
> >> +                                    struct attribute *attr,
> >> +                                    char *buf)
> >> +{
> >> +     char *jid;
> >> +     int ret = -ENOENT;
> >> +
> >> +     rcu_read_lock();
> >> +     jid = jobid_current();
> >> +     if (jid)
> >> +             ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
> >> +     rcu_read_unlock();
> >> +     return ret;
> >> +}
> >> +
> >> +static ssize_t jobid_this_session_store(struct kobject *kobj,
> >> +                                     struct attribute *attr,
> >> +                                     const char *buffer,
> >> +                                     size_t count)
> >> +{
> >> +     char *jobid;
> >> +     int len;
> >> +     int ret;
> >> +
> >> +     if (!count || count > LUSTRE_JOBID_SIZE)
> >> +             return -EINVAL;
> >> +
> >> +     jobid = kstrndup(buffer, count, GFP_KERNEL);
> >> +     if (!jobid)
> >> +             return -ENOMEM;
> >> +     len = strcspn(jobid, " \n");
> >> +     jobid[len] = '\0';
> >> +     ret = jobid_set_current(jobid);
> >> +     kfree(jobid);
> >> +
> >> +     return ret ?: count;
> >> +}
> >> +
> >> /* Root for /sys/kernel/debug/lustre */
> >> struct dentry *debugfs_lustre_root;
> >> EXPORT_SYMBOL_GPL(debugfs_lustre_root);
> >> @@ -272,6 +311,7 @@ LUSTRE_RO_ATTR(pinger);
> >> LUSTRE_RO_ATTR(health_check);
> >> LUSTRE_RW_ATTR(jobid_var);
> >> LUSTRE_RW_ATTR(jobid_name);
> >> +LUSTRE_RW_ATTR(jobid_this_session);
> >>
> >> static struct attribute *lustre_attrs[] = {
> >>        &lustre_attr_version.attr,
> >> @@ -279,6 +319,7 @@ static struct attribute *lustre_attrs[] = {
> >>        &lustre_attr_health_check.attr,
> >>        &lustre_attr_jobid_name.attr,
> >>        &lustre_attr_jobid_var.attr,
> >> +     &lustre_attr_jobid_this_session.attr,
> >>        &lustre_sattr_timeout.u.attr,
> >>        &lustre_attr_max_dirty_mb.attr,
> >>        &lustre_sattr_debug_peer_on_timeout.u.attr,
> >> --
> >> 2.14.0.rc0.dirty
> >>
> >
> > Cheers, Andreas
> > ---
> > Andreas Dilger
> > CTO Whamcloud
> >
> >
> >
> >
> > _______________________________________________
> > lustre-devel mailing list
> > lustre-devel at lists.lustre.org
> > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud

^ permalink raw reply	[flat|nested] 105+ messages in thread

end of thread, other threads:[~2019-03-14 23:05 UTC | newest]

Thread overview: 105+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19  0:09 [lustre-devel] [PATCH 00/37] More lustre patches from obdclass NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type NeilBrown
2019-02-24 18:35   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() NeilBrown
2019-02-24 16:35   ` James Simmons
2019-02-25 22:27     ` NeilBrown
2019-02-26 22:18       ` James Simmons
2019-02-24 16:52   ` [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type James Simmons
2019-02-25 22:38     ` NeilBrown
2019-02-26 20:41       ` Simmons, James A.
2019-02-19  0:09 ` [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref NeilBrown
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock NeilBrown
2019-02-24 20:29   ` James Simmons
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock NeilBrown
2019-02-24 17:02   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type NeilBrown
2019-02-24 17:03   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance NeilBrown
2019-02-24 17:39   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name NeilBrown
2019-02-24 16:56   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking NeilBrown
2019-02-24 17:04   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper NeilBrown
2019-02-24 17:52   ` James Simmons
2019-02-26 23:59     ` NeilBrown
2019-02-27  1:06       ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release NeilBrown
2019-02-24 17:53   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea NeilBrown
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc NeilBrown
2019-02-24 17:05   ` James Simmons
2019-02-25 18:16     ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines NeilBrown
2019-02-24 19:07   ` James Simmons
2019-02-27  0:41     ` NeilBrown
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr() NeilBrown
2019-02-24 17:53   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t NeilBrown
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static NeilBrown
2019-02-24 17:15   ` James Simmons
2019-02-26 23:45     ` NeilBrown
2019-02-27 22:36       ` James Simmons
2019-02-27 22:37   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type NeilBrown
2019-02-24 16:54   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list NeilBrown
2019-02-24 17:00   ` James Simmons
2019-02-19  0:09 ` [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock NeilBrown
2019-02-25 18:16   ` Andreas Dilger
2019-02-27  0:22     ` NeilBrown
2019-02-27  1:00       ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 32/37] lustre: portals_handle: rename ops to owner NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop NeilBrown
2019-02-24 18:09   ` James Simmons
2019-02-26 20:55   ` James Simmons
2019-02-27  0:51     ` NeilBrown
2019-02-27  0:54       ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 NeilBrown
2019-02-24 20:02   ` James Simmons
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle NeilBrown
2019-02-27  6:32   ` Andreas Dilger
2019-02-27 21:48     ` NeilBrown
2019-02-27 22:14       ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref NeilBrown
2019-02-27  6:52   ` Andreas Dilger
2019-02-28  0:39     ` NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2 NeilBrown
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment NeilBrown
2019-02-24 18:51   ` James Simmons
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 27/37] lustre: discard lu_ref NeilBrown
2019-02-24 20:28   ` James Simmons
2019-02-27  1:17     ` NeilBrown
2019-02-27  5:35       ` Andreas Dilger
2019-03-01  6:45         ` Mike Pershin
2019-02-19  0:09 ` [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops NeilBrown
2019-02-27  6:37   ` Andreas Dilger
2019-02-27 21:41     ` NeilBrown
2019-02-28  6:41       ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 33/37] lustre: portals_handle: remove locking from class_handle2object() NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 34/37] lustre: portals_handle: use hlist for hash lists NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 31/37] lustre: discard OBD_FREE_RCU NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing NeilBrown
2019-02-24 19:08   ` James Simmons
2019-02-25 18:16   ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 35/37] lustre: portals_handle: discard h_lock NeilBrown
2019-02-19  0:09 ` [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var NeilBrown
2019-02-27  6:17   ` Andreas Dilger
2019-03-01  2:35     ` NeilBrown
2019-03-01  8:32       ` Andreas Dilger
2019-03-01 14:30         ` Patrick Farrell
2019-03-14  0:34           ` NeilBrown
2019-03-14 14:12             ` Patrick Farrell
2019-03-14 22:56               ` NeilBrown
2019-03-14 23:05               ` Andreas Dilger
2019-02-19  0:09 ` [lustre-devel] [PATCH 36/37] lustre: remove unused fields from struct obd_device NeilBrown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.