More lustre patches from obdclass
cover More lustre patches from obdclass
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
PATCH 1/37 lustre: obdclass: char obd_ioctl_getdata type.
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.
--- 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(-)
drivers/staging/lustre/lustre/include/obd_class.h +2 -1
@@ -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 */
drivers/staging/lustre/lustre/llite/dir.c +6 -12
@@ -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; }
drivers/staging/lustre/lustre/llite/llite_lib.c +3 -5
@@ -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; }
drivers/staging/lustre/lustre/lov/lov_obd.c +6 -9
@@ -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 : {
drivers/staging/lustre/lustre/obdclass/class_obd.c +8 -10
@@ -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 */
PATCH 1/37 lustre: obdclass: char obd_ioctl_getdata type.
Quoted 6 lines
Instead of having
obd_ioctl_getdata()return the allocated data as a "char *", return it as it really is,
structobd_ioctl_data*This avoids the need for extra variables and casts.
Quoted 268 lines
Signed-off-by NeilBrown <[email protected]>--- 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(-)drivers/staging/lustre/lustre/include/obd_class.h +2
-1@@ -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 */ drivers/staging/lustre/lustre/llite/dir.c +6
-12@@ -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; }drivers/staging/lustre/lustre/llite/llite_lib.c +3
-5@@ -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; }drivers/staging/lustre/lustre/lov/lov_obd.c +6
-9@@ -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 : {drivers/staging/lustre/lustre/obdclass/class_obd.c +8
-10@@ -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 */
PATCH 2/37 lustre: llite: don't use class_setup_tunables()
In reply to NeilBrownllite_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 toclass_setup_tunables().
--- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -1
@@ -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);
James Simmons
NAKPATCH 2/37 lustre: llite: don't use class_setup_tunables()
y
Quoted 3 lines
llite_kobjdoes not benefit from being in thelustre_ksetkset (though it does needlustre_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.
Quoted 18 lines
It also does not need the
class_ktypetype, asdynamic_kobj_ktypeis 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 <[email protected]>--- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/llite/lproc_llite.c +0
-0
drivers/staging/lustre/lustre/llite/lproc_llite.c int llite_tunables_register(void) · line 52
Quoted 8 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +1
-1@@ -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);
Quoted 1 line
In llite_tunables_unregister() the call for kobject_put() should really be replaced with kobject_del(). This is a bug in my original work.
PATCH 2/37 lustre: llite: don't use class_setup_tunables()
Quoted 25 lines · James Simmons
y
Quoted 3 lines
llite_kobjdoes not benefit from being in thelustre_ksetkset (though it does needlustre_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 'lctlset_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 pathLCFG_PARAM, which handles theconf_paramcase' the main function isclass_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 calllustre_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.
Quoted 6 lines
With
LCFG_SET_PARAM, which handles the 'set_param-P' case the master function isprocess_param2_config(). For this case we always send attribute changes with uevents. Besides the requirement of the kobject belonging to the kset this function useskset_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
Quoted 31 lines
Quoted 19 lines
It also does not need the
class_ktypetype, asdynamic_kobj_ktypeis 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 <[email protected]>--- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/llite/lproc_llite.c +0
-0drivers/staging/lustre/lustre/llite/lproc_llite.c int llite_tunables_register(void) · line 52
Quoted 8 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +1
-1@@ -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);Quoted 1 line
Quoted 3 lines
In
llite_tunables_unregister()the call forkobject_put()should really be replaced withkobject_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>
PATCH 2/37 lustre: llite: don't use class_setup_tunables()
Quoted 32 lines
Quoted 25 lines
Quoted 4 lines
llite_kobjdoes not benefit from being in thelustre_ksetkset (though it does needlustre_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 'lctlset_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 pathLCFG_PARAM, which handles theconf_paramcase' the main function isclass_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 calllustre_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.Quoted 6 lines
With
LCFG_SET_PARAM, which handles the 'set_param-P' case the master function isprocess_param2_config(). For this case we always send attribute changes with uevents. Besides the requirement of the kobject belonging to the kset this function useskset_find_object()directly which if llite is not in the kset will never be found.
Quoted 4 lines
Thanks a lot for the explanation - there are definitely things I missed there.
I'll drop this patch, and keepclass_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.
Quoted 34 lines
Quoted 33 lines
Quoted 18 lines
It also does not need the
class_ktypetype, asdynamic_kobj_ktypeis 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 <[email protected]>--- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/llite/lproc_llite.c +0
-0drivers/staging/lustre/lustre/llite/lproc_llite.c int llite_tunables_register(void) · line 52
Quoted 8 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +1
-1@@ -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);Quoted 1 line
In
llite_tunables_unregister()the call forkobject_put()should really be replaced withkobject_del(). This is a bug in my original work.
PATCH 3/37 lustre: embed typ_kobj if obd_type
In reply to NeilBrownFor 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 :-(
PATCH 3/37 lustre: embed typ_kobj if obd_type
Quoted 5 lines · James Simmons
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_ktypewith its own ktype. Thusclass_sysfs_release()will never be called with llite.
Quoted 8 lines
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?
Quoted 6 lines
--------------------------------------------------------
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
Quoted 2 lines
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>
Simmons
PATCH 3/37 lustre: embed typ_kobj if obd_type
Quoted 7 lines · James Simmons
Quoted 7 lines
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_ktypewith its own ktype. Thusclass_sysfs_release()will never be called with llite.What does need fixing is
Quoted 8 lines
Quoted 6 lines
--------------------------------------------------------
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.
Quoted 4 lines
Quoted 4 lines
--------------------------------------------------------
Next change needed it change all the
Quoted 8 lines
Quoted 2 lines
kobject_put(&type->typ_kobj); ->kobject_del(&type->typ_kobj);Why?
kobject_del()removed from sysfs.kobject_put()callskobject_release()on the last put. This callskobject_cleanup()which callskobject_del()if needed.
So why do we need to callkobject_del()?
You are right. I missed that kobject_cleanup() calls kobject_del(). I noticed It latter when you pointed out.
PATCH 3/37 lustre: embed typ_kobj if obd_type
In reply to NeilBrownAs 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.
--- 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(-)
drivers/staging/lustre/lustre/include/obd.h +1 -1
@@ -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 {
drivers/staging/lustre/lustre/include/obd_class.h +0 -1
@@ -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);
drivers/staging/lustre/lustre/obdclass/genops.c +14 -32
94 lines not on this page · raw message
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1 -1
@@ -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);
PATCH 4/37 lustre: collect all resource releasing for obj_type.
In reply to NeilBrownNow that obj_type is managed as a kobject, move all the freeing and deregistering into class_sysfs_release().
--- drivers/staging/lustre/lustre/obdclass/genops.c | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +13 -14
@@ -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 ;
PATCH 4/37 lustre: collect all resource releasing for obj_type.
Quoted 3 lines
Now that
obj_typeis managed as a kobject, move all the freeing and deregistering intoclass_sysfs_release().
This is a really nice change. I would have never considered that.
Quoted 67 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lustre/obdclass/genops.c | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-)drivers/staging/lustre/lustre/obdclass/genops.c +13
-14@@ -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 ;
PATCH 5/37 lustre: obd_type: use typ_kobj.name as typ_name
In reply to NeilBrownAs 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.
--- 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(-)
drivers/staging/lustre/lustre/include/lustre_net.h +2 -2
@@ -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);
drivers/staging/lustre/lustre/include/obd.h +1 -1
@@ -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.namestruct brw_page {u64 off;
drivers/staging/lustre/lustre/include/obd_class.h +1 -1
@@ -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);
drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +1 -1
@@ -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 ,
drivers/staging/lustre/lustre/obdclass/genops.c +10 -15
@@ -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
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -1
@@ -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;
PATCH 5/37 lustre: obd_type: use typ_kobj.name as typ_name
Quoted 7 lines
As the kobject has a name (after
kobject_addhas been called), we don't need to also store it intyp_name.
So use typ_kobj.name instead oftyp_name.This requires changing some "char *" to "const char *" as typ.kobj.name is const.
Quoted 177 lines
Signed-off-by NeilBrown <[email protected]>--- 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(-)drivers/staging/lustre/lustre/include/lustre_net.h +2
-2@@ -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);drivers/staging/lustre/lustre/include/obd.h +1
-1@@ -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.namestruct brw_page {u64 off;drivers/staging/lustre/lustre/include/obd_class.h +1
-1@@ -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);drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +1
-1@@ -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 ,drivers/staging/lustre/lustre/obdclass/genops.c +10
-15@@ -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 drivers/staging/lustre/lustre/ptlrpc/client.c +1
-1@@ -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;
PATCH 6/37 lustre: obd_type: discard obd_types linked list.
In reply to NeilBrownAs 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.
--- drivers/staging/lustre/lustre/include/obd.h | 1 - drivers/staging/lustre/lustre/obdclass/genops.c | 41 +++++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-)
drivers/staging/lustre/lustre/include/obd.h +0 -1
@@ -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;
drivers/staging/lustre/lustre/obdclass/genops.c +19 -22
99 lines not on this page · raw message
PATCH 6/37 lustre: obd_type: discard obd_types linked list.
Quoted 125 lines
As all
obd_typesare kobjects in thelustre_ksetkset, 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 <[email protected]>--- drivers/staging/lustre/lustre/include/obd.h | 1 - drivers/staging/lustre/lustre/obdclass/genops.c | 41 +++++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-)drivers/staging/lustre/lustre/include/obd.h +0
-1@@ -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;drivers/staging/lustre/lustre/obdclass/genops.c +15
-22@@ -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 */
drivers/staging/lustre/lustre/obdclass/genops.c int class_unregister_type(const char *name) · line 241
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/genops.c +4
-0kfree (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.
Quoted 4 lines
drivers/staging/lustre/lustre/obdclass/genops.c +0
-0return 0 ;
PATCH 7/37 lustre: obd_type: discard obd_type_lock
In reply to NeilBrownThis 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.
--- 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(-)
drivers/staging/lustre/lustre/include/obd.h +1 -2
@@ -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
drivers/staging/lustre/lustre/mdc/mdc_request.c +1 -1
@@ -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);
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -1
@@ -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 ();
drivers/staging/lustre/lustre/obdclass/genops.c +14 -16
@@ -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);
drivers/staging/lustre/lustre/obdclass/lu_object.c +1 -1
@@ -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); } }
PATCH 7/37 lustre: obd_type: discard obd_type_lock
Quoted 10 lines
This lock is only used to protect
typ_refcnt, so change that to arefcount_tand discard the lock.The lock also covers calls to
try_module_getandmodule_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_getis ignored, which is not safe.
Looks good. I do need to test this work tho.
Quoted 128 lines
Signed-off-by NeilBrown <[email protected]>--- 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(-)drivers/staging/lustre/lustre/include/obd.h +1
-2@@ -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.namedrivers/staging/lustre/lustre/mdc/mdc_request.c +1
-1@@ -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);drivers/staging/lustre/lustre/mgc/mgc_request.c +1
-1@@ -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 ();drivers/staging/lustre/lustre/obdclass/genops.c +14
-16@@ -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);drivers/staging/lustre/lustre/obdclass/lu_object.c +1
-1@@ -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); } }
PATCH 8/37 lustre: obdclass: don't copy ops structures in to new type.
In reply to NeilBrownThe 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.
--- 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(-)
drivers/staging/lustre/lustre/include/obd.h +2 -2
@@ -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;
drivers/staging/lustre/lustre/include/obd_class.h +2 -1
@@ -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);
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -2
@@ -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,
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -1
@@ -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,
drivers/staging/lustre/lustre/mdc/mdc_request.c +2 -2
@@ -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,
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -1
@@ -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,
drivers/staging/lustre/lustre/obdclass/genops.c +6 -16
@@ -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 ; }
drivers/staging/lustre/lustre/obdecho/echo_client.c +1 -1
@@ -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,
drivers/staging/lustre/lustre/osc/osc_request.c +1 -1
@@ -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,
PATCH 8/37 lustre: obdclass: don't copy ops structures in to new type.
Quoted 10 lines
The
obd_opsandmd_opsstructures passed toclass_register_type()are read-only, and have a lifetime that is exceeds the lifetime of theobd_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.
Quoted 195 lines
Signed-off-by NeilBrown <[email protected]>--- 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(-)drivers/staging/lustre/lustre/include/obd.h +2
-2@@ -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;drivers/staging/lustre/lustre/include/obd_class.h +2
-1@@ -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);drivers/staging/lustre/lustre/lmv/lmv_obd.c +2
-2@@ -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,drivers/staging/lustre/lustre/lov/lov_obd.c +1
-1@@ -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,drivers/staging/lustre/lustre/mdc/mdc_request.c +2
-2@@ -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,drivers/staging/lustre/lustre/mgc/mgc_request.c +1
-1@@ -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,drivers/staging/lustre/lustre/obdclass/genops.c +6
-16@@ -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 ; }drivers/staging/lustre/lustre/obdecho/echo_client.c +1
-1@@ -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,drivers/staging/lustre/lustre/osc/osc_request.c +1
-1@@ -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,
PATCH 9/37 lustre: obdclass: fix module load locking.
In reply to NeilBrownSafe 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().
--- drivers/staging/lustre/lustre/obdclass/genops.c | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +21 -3
@@ -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 ;
PATCH 9/37 lustre: obdclass: fix module load locking.
Quoted 6 lines
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 inclass_get_type().
Quoted 6 lines
As
free_module()callssynchronize_rcu()between calling the exit function and freeing the module, we can usercu_read_lock()to check if the exit function has been called, andtry_module_get()if it hasn't.We must also check the return status of
try_module_get().
Quoted 74 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lustre/obdclass/genops.c | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)drivers/staging/lustre/lustre/obdclass/genops.c +21
-3@@ -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 ;
PATCH 10/37 lustre: kernelcomm: pass correct gfp_t to kmalloc.
In reply to NeilBrownPassing 0 as the gfp_t for kmalloc() is not meaningful, and could change behaviour.
Use an explicit GFP_KERNEL instead.
--- .../staging/lustre/lustre/obdclass/kernelcomm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +1 -1
@@ -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 ;
PATCH 10/37 lustre: kernelcomm: pass correct gfp_t to kmalloc.
Quoted 4 lines
Passing 0 as the
gfp_tforkmalloc()is not meaningful, and could change behaviour.
Use an explicitGFP_KERNELinstead.
Why did it every do this ??????
Quoted 21 lines
Signed-off-by NeilBrown <[email protected]>--- .../staging/lustre/lustre/obdclass/kernelcomm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/obdclass/kernelcomm.c +1
-1@@ -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 ;
PATCH 10/37 lustre: kernelcomm: pass correct gfp_t to kmalloc.
Quoted 7 lines · James Simmons
Quoted 5 lines
Passing 0 as the
gfp_tforkmalloc()is not meaningful, and could change behaviour.
Use an explicitGFP_KERNELinstead.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
PATCH 11/37 lustre: kernelcomm: make libcfs_kkuc_msg_put static.
In reply to NeilBrownlibcfs_kkuc_msg_put() is never used outside of kernelcomm.c, so make it static.
--- .../lustre/lustre/include/lustre_kernelcomm.h | 1 - .../staging/lustre/lustre/obdclass/kernelcomm.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/include/lustre_kernelcomm.h +0 -1
@@ -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);
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +1 -2
@@ -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;
PATCH 11/37 lustre: kernelcomm: make libcfs_kkuc_msg_put static.
Quoted 3 lines
libcfs_kkuc_msg_put()is never used outside ofkernelcomm.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:
Quoted 11 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/include/lustre_kernelcomm.h | 1 - .../staging/lustre/lustre/obdclass/kernelcomm.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)drivers/staging/lustre/lustre/include/lustre_kernelcomm.h +0
-0
drivers/staging/lustre/lustre/include/lustre_kernelcomm.h typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg); · line 48
Quoted 3 lines
drivers/staging/lustre/lustre/include/lustre_kernelcomm.h +0
-0@@ -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
drivers/staging/lustre/lustre/include/lustre_kernelcomm.h typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg); · line 49
Quoted 1 line
drivers/staging/lustre/lustre/include/lustre_kernelcomm.h +0
-1-int libcfs_kkuc_msg_put (struct file *fp,void *payload);
#endif
drivers/staging/lustre/lustre/obdclass/kernelcomm.c line 51
Quoted 11 lines
drivers/staging/lustre/lustre/include/lustre_kernelcomm.h +0
-0int 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);drivers/staging/lustre/lustre/obdclass/kernelcomm.c +0
-0@@ -49,7 +49,7 @@* @param payload Payload data. First field of payload is always * struct kuc_hdr */
#ifndef CONFIG_LUSTRE_SERVER
drivers/staging/lustre/lustre/obdclass/kernelcomm.c line 52
Quoted 1 line
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +0
-1-int libcfs_kkuc_msg_put (struct file *filp,void *payload)
#else
drivers/staging/lustre/lustre/obdclass/kernelcomm.c line 52
Quoted 1 line
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +1
-0+static int libcfs_kkuc_msg_put (struct file *filp,void *payload)
#endif
drivers/staging/lustre/lustre/obdclass/kernelcomm.c int libcfs_kkuc_msg_put(struct file *filp, void *payload) · line 82
Quoted 7 lines
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +0
-0{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
drivers/staging/lustre/lustre/obdclass/kernelcomm.c int libcfs_kkuc_msg_put(struct file *filp, void *payload) · line 83
Quoted 1 line
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +0
-1-EXPORT_SYMBOL (libcfs_kkuc_msg_put);
#endif
drivers/staging/lustre/lustre/obdclass/kernelcomm.c int libcfs_kkuc_msg_put(struct file *filp, void *payload) · line 85
Quoted 2 lines
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +0
-0/* * Broadcast groups are global across all mounted filesystems;
I do say the ifdef do look messy.
PATCH 11/37 lustre: kernelcomm: make libcfs_kkuc_msg_put static.
Quoted 8 lines · James Simmons
Quoted 2 lines
libcfs_kkuc_msg_put()is never used outside ofkernelcomm.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>
PATCH 11/37 lustre: kernelcomm: make libcfs_kkuc_msg_put static.
Quoted 22 lines
Quoted 9 lines
Quoted 3 lines
libcfs_kkuc_msg_put()is never used outside ofkernelcomm.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
Commitf7155420024e("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);
Quoted 2 lines
libcfs_kkuc_msg_put()is only called fromlibcfs_kkuc_group_put(). What am I missing?
I'm remembering older code. You are correct. Let me give it a proper review.
PATCH 11/37 lustre: kernelcomm: make libcfs_kkuc_msg_put static.
In reply to NeilBrownQuoted 3 lines
libcfs_kkuc_msg_put()is never used outside ofkernelcomm.c, so make it static.
Quoted 42 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/include/lustre_kernelcomm.h | 1 - .../staging/lustre/lustre/obdclass/kernelcomm.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)drivers/staging/lustre/lustre/include/lustre_kernelcomm.h +0
-1@@ -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);drivers/staging/lustre/lustre/obdclass/kernelcomm.c +1
-2@@ -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;
PATCH 12/37 lustre: remove unused function in linkea.
In reply to NeilBrownMuch of the linkea functionality is server-only. Keep the parts used on the client, but remove the rest.
--- .../staging/lustre/lustre/include/lustre_linkea.h | 8 - drivers/staging/lustre/lustre/obdclass/linkea.c | 150 -------------------- 2 files changed, 1 insertion(+), 157 deletions(-)
drivers/staging/lustre/lustre/include/lustre_linkea.h +0 -8
@@ -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) {
drivers/staging/lustre/lustre/obdclass/linkea.c +1 -149
171 lines not on this page · raw message
PATCH 12/37 lustre: remove unused function in linkea.
Quoted 5 lines · NeilBrown
Much of the linkea functionality is server-only. Keep the parts used on the client, but remove the rest.
Signed-off-by NeilBrown <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 13/37 lustre: llog: remove lgh_hdr_lock.
In reply to NeilBrownThis lock is unused on the client (and on the server, it has been changed to a mutex).
--- drivers/staging/lustre/lustre/include/lustre_log.h | 1 - drivers/staging/lustre/lustre/obdclass/llog.c | 1 - 2 files changed, 2 deletions(-)
drivers/staging/lustre/lustre/include/lustre_log.h +0 -1
@@ -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;
drivers/staging/lustre/lustre/obdclass/llog.c +0 -1
@@ -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 );
PATCH 13/37 lustre: llog: remove lgh_hdr_lock.
Quoted 3 lines
This lock is unused on the client (and on the server, it has been changed to a mutex).
Quoted 33 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lustre/include/lustre_log.h | 1 - drivers/staging/lustre/lustre/obdclass/llog.c | 1 - 2 files changed, 2 deletions(-)drivers/staging/lustre/lustre/include/lustre_log.h +0
-1@@ -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;drivers/staging/lustre/lustre/obdclass/llog.c +0
-1@@ -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 );
PATCH 13/37 lustre: llog: remove lgh_hdr_lock.
In reply to NeilBrownQuoted 8 lines · NeilBrown
This lock is unused on the client (and on the server, it has been changed to a mutex).
Signed-off-by NeilBrown <[email protected]>
Quoted 24 lines
---
drivers/staging/lustre/lustre/include/lustre_log.h | 1 - drivers/staging/lustre/lustre/obdclass/llog.c | 1 - 2 files changed, 2 deletions(-)drivers/staging/lustre/lustre/include/lustre_log.h +0
-1@@ -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;drivers/staging/lustre/lustre/obdclass/llog.c +0
-0
drivers/staging/lustre/lustre/obdclass/llog.c static struct llog_handle *llog_alloc_handle(void) · line 69
Quoted 7 lines
drivers/staging/lustre/lustre/obdclass/llog.c +0
-1@@ -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
PATCH 14/37 lustre: llog: change lgh_refcount to struct kref.
In reply to NeilBrownThis is a refcount that perfectly fits the
pattern for kref, so change it to a kref.
--- drivers/staging/lustre/lustre/include/lustre_log.h | 9 +-------- drivers/staging/lustre/lustre/obdclass/llog.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 15 deletions(-)
drivers/staging/lustre/lustre/include/lustre_log.h +1 -8
@@ -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,
drivers/staging/lustre/lustre/obdclass/llog.c +9 -7
@@ -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;
PATCH 14/37 lustre: llog: change lgh_refcount to struct kref.
Quoted 5 lines · NeilBrown
This is a refcount that perfectly fits the
pattern for kref, so change it to a kref.Signed-off-by NeilBrown <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 15/37 lustre: llog_obd: Convert loc_refcount to refcount_t
In reply to NeilBrownMake this a refcount_t for clarity, and also use refcount_dec_and_lock() rather than having separate lock and dec calls.
--- 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(-)
drivers/staging/lustre/lustre/include/lustre_log.h +6 -5
@@ -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); }
drivers/staging/lustre/lustre/obdclass/llog_obd.c +5 -7
@@ -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);/*
PATCH 15/37 lustre: llog_obd: Convert loc_refcount to refcount_t
Quoted 6 lines · NeilBrown
Make this a
refcount_tfor clarity, and also userefcount_dec_and_lock()rather than having separate lock and dec calls.Signed-off-by NeilBrown <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 16/37 lustre: obdclass: typo: Banlance -> Balance
In reply to NeilBrownFix mistyped "Balance" in a comment.
--- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/llog_obd.c +1 -1
@@ -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 );
PATCH 16/37 lustre: obdclass: typo: Banlance -> Balance
Quoted 2 lines
Fix mistyped "Balance" in a comment.
Quoted 21 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/obdclass/llog_obd.c +1
-1@@ -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 );
PATCH 17/37 lustre: simplify lprocfs_read_frac_helper.
In reply to NeilBrownThis function seems overly complex, the same functionality is available with much less effort.
--- .../lustre/lustre/obdclass/lprocfs_status.c | 47 +++----------------- 1 file changed, 7 insertions(+), 40 deletions(-)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +7 -40
@@ -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; }
PATCH 17/37 lustre: simplify lprocfs_read_frac_helper.
Quoted 3 lines
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.
Quoted 73 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/obdclass/lprocfs_status.c | 47 +++----------------- 1 file changed, 7 insertions(+), 40 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +7
-40@@ -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; }
PATCH 17/37 lustre: simplify lprocfs_read_frac_helper.
Quoted 22 lines · James Simmons
Quoted 2 lines
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.
Quoted 9 lines
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*_mbfiles 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 formax_dirty_mbwhich I can push. The other*_mbfiles 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
Quoted 66 lines
Quoted 66 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/obdclass/lprocfs_status.c | 47 +++----------------- 1 file changed, 7 insertions(+), 40 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +7
-38@@ -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 ; - } - }
Quoted 8 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c static void obd_connect_data_seqprint(struct seq_file *m, · line 224
Quoted 8 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0
-2- 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>
PATCH 17/37 lustre: simplify lprocfs_read_frac_helper.
Quoted 35 lines · NeilBrown
Quoted 22 lines · James Simmons
Quoted 2 lines
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.Quoted 9 lines
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*_mbfiles 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 formax_dirty_mbwhich I can push. The other*_mbfiles 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.
Quoted 2 lines
My recommendation would be to deprecate all
_mbfiles and instead have_bytesfiles 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.
Quoted 5 lines
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
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Signed-off-by NeilBrown <[email protected]>---
.../lustre/lustre/obdclass/lprocfs_status.c| 47 +++-----------------1 file changed, 7 insertions(+), 40 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +7
-35@@ -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--;
Quoted 8 lines
Quoted 8 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c static void obd_connect_data_seqprint(struct seq_file *m, · line 224
Quoted 8 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0
-5-break ; - } - } - prtn++; - } buffer[prtn++] ='\n' ;return prtn; }
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 18/37 lustre: obdclass: discard lprocfs_single/seq_release
In reply to NeilBrownNeither 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.
--- .../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(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +2 -5
@@ -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 {
drivers/staging/lustre/lustre/lov/lproc_lov.c +1 -1
@@ -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[] = {
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1 -13
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -1
@@ -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,
PATCH 18/37 lustre: obdclass: discard lprocfs_single/seq_release
Quoted 5 lines
Neither
lprocfs_single_release()orlprocfs_seq_release()add any value tosingle_release()orseq_release()which they wrap.
So just use the base functions and discard the wrapper.
Quoted 101 lines
Signed-off-by NeilBrown <[email protected]>--- .../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(-)drivers/staging/lustre/lustre/include/lprocfs_status.h +2
-5@@ -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 {drivers/staging/lustre/lustre/lov/lproc_lov.c +1
-1@@ -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[] = {drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1
-13@@ -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);drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1
-1@@ -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,
PATCH 19/37 lustre: discard lprocfs_strnstr()
In reply to NeilBrownThis is identical to strnstr() in lib/string.h,
so just use that.
--- .../lustre/lustre/obdclass/lprocfs_status.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1 -18
@@ -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;
PATCH 19/37 lustre: discard lprocfs_strnstr()
Quoted 3 lines
This is identical to
strnstr()inlib/string.h,
so just use that.
Quoted 45 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/obdclass/lprocfs_status.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1
-18@@ -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;
PATCH 20/37 lustre: convert rsi_sem to a spinlock.
In reply to NeilBrownThis lock is never held over code that sleeps, and is only ever held for short periods of time.
So a simple spinlock is best.
--- 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(-)
drivers/staging/lustre/lustre/include/obd_class.h +1 -2
@@ -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 */
drivers/staging/lustre/lustre/llite/llite_lib.c +3 -3
@@ -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); }/**
drivers/staging/lustre/lustre/llite/lproc_llite.c +2 -2
@@ -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 ; }
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +4 -4
@@ -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;
PATCH 20/37 lustre: convert rsi_sem to a spinlock.
Quoted 25 lines · NeilBrown
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 <[email protected]>---
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-2@@ -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);
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, · line 1747
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-2@@ -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
PATCH 20/37 lustre: convert rsi_sem to a spinlock.
Quoted 29 lines · Andreas Dilger
Quoted 28 lines · NeilBrown
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 <[email protected]>---
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-2@@ -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 ;
Quoted 12 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, · line 1747
Quoted 7 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-2-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 tokfree()internally. I don't think it is acceptable to hold a spinlock overkfree()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.cida_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
Quoted 6 lines
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>
PATCH 20/37 lustre: convert rsi_sem to a spinlock.
Quoted 45 lines · NeilBrown
Quoted 29 lines · Andreas Dilger
Quoted 28 lines · NeilBrown
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 <[email protected]>---
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-2@@ -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 ;Quoted 12 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, · line 1747
Quoted 7 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2
-2-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 tokfree()internally. I don't think it is acceptable to hold a spinlock overkfree()these days?
Quoted 8 lines
I have not heard that, and have myself called kfree inside a spinlock before. A quick look finds some examples in
lib/idr.cida_free()callskfree()while holding a spinlock (xas_unlock_irqrestoreis a wrapper aroundspin_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
PATCH 21/37 lustre: remove several MAX_STRING_SIZE defines.
In reply to NeilBrownSome of these are unused.
One is used in a minimal way where it is easier to use an explicit number.
--- 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(-)
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +0 -2
@@ -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);
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -4
@@ -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()
drivers/staging/lustre/lustre/llite/lproc_llite.c +0 -4
@@ -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,
drivers/staging/lustre/lustre/lmv/lmv_obd.c +0 -2
@@ -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;
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0 -2
@@ -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 = { };
PATCH 21/37 lustre: remove several MAX_STRING_SIZE defines.
Quoted 4 lines
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) :-)
Quoted 104 lines
Signed-off-by NeilBrown <[email protected]>--- 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(-)drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +0
-2@@ -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);drivers/staging/lustre/lustre/llite/llite_lib.c +2
-4@@ -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() drivers/staging/lustre/lustre/llite/lproc_llite.c +0
-4@@ -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,drivers/staging/lustre/lustre/lmv/lmv_obd.c +0
-2@@ -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;drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0
-2@@ -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 = { };
PATCH 21/37 lustre: remove several MAX_STRING_SIZE defines.
Quoted 11 lines · James Simmons
Quoted 3 lines
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_SIZEI 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 likeMAX_STRING_SIZEwhich provides no real meaning to why the magically number 128 is used.
Quoted 6 lines
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 byMAX_OBD_NAME. What do you knowMAX_OBD_NAMEis equal tooMAX_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 <[email protected]>
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(-)
drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +0 -2
@@ -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;
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +4 -12
@@ -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; }
Signature · 9 lines
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>
PATCH 21/37 lustre: remove several MAX_STRING_SIZE defines.
In reply to NeilBrownQuoted 6 lines · NeilBrown
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 <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 22/37 lustre: lprocfs: use log2.h macros instead of shift loop.
In reply to NeilBrownThese 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.
--- .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +3 -7
@@ -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); }
PATCH 22/37 lustre: lprocfs: use log2.h macros instead of shift loop.
Quoted 6 lines
These shift loops seem to be trying to avoid doing a multiplication.
We same effect can be achieved more transparently usingrounddown_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.
Quoted 43 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +3
-7@@ -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); }
PATCH 22/37 lustre: lprocfs: use log2.h macros instead of shift loop.
In reply to NeilBrownQuoted 6 lines
These shift loops seem to be trying to avoid doing a multiplication.
We same effect can be achieved more transparently usingrounddown_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".
Quoted 43 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +3
-7@@ -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); }
PATCH 22/37 lustre: lprocfs: use log2.h macros instead of shift loop.
Quoted 7 lines · James Simmons
Quoted 5 lines
These shift loops seem to be trying to avoid doing a multiplication.
We same effect can be achieved more transparently usingrounddown_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
Quoted 39 lines
Quoted 39 lines
Signed-off-by NeilBrown <[email protected]>--- .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +3
-7@@ -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);
Quoted 5 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, · line 390
Quoted 5 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0
-0return 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>
PATCH 22/37 lustre: lprocfs: use log2.h macros instead of shift loop.
Quoted 9 lines · NeilBrown
Quoted 6 lines · James Simmons
Quoted 5 lines
These shift loops seem to be trying to avoid doing a multiplication.
We same effect can be achieved more transparently usingrounddown_pow_of_two(). Even though there is a multiplication in the C code, the resulting machine code just does a single shift.
Quoted 4 lines
Quoted 1 line
Be aware
rounddown_pow_of_two(n)is undefined when "n == 0".Hmm... can
os_bsizeever 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.
Quoted 6 lines
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
Quoted 44 lines
Thanks,
NeilBrownQuoted 39 lines
Quoted 39 lines
Signed-off-by NeilBrown <[email protected]>---
.../lustre/lustre/obdclass/lprocfs_status.c| 10 +++-------1 file changed, 3 insertions(+), 7 deletions(-)drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +3
-7@@ -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);
Quoted 5 lines
Quoted 5 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, · line 390
Quoted 5 lines
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0
-0return sprintf (buf,"%llu\n" , result); }
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
PATCH 23/37 lustre: prefer to use tabs for alignment.
In reply to NeilBrownThis 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.
--- .../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(-)
drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +1 -1
@@ -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 */
drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +5 -5
@@ -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 };
drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +15 -15
@@ -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.
drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h +6 -6
@@ -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,
drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +12 -12
@@ -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,
drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +1 -1
@@ -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 */
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +2 -2
@@ -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);
drivers/staging/lustre/include/linux/lnet/socklnd.h +1 -1
@@ -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 */
drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h +62 -62
145 lines not on this page · raw message
drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h +28 -28
69 lines not on this page · raw message
drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +5 -5
@@ -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.
drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h +7 -7
@@ -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 */ };
drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h +3 -3
@@ -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 );
drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h +1 -1
@@ -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)
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +175 -175
590 lines not on this page · raw message
drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h +189 -189
605 lines not on this page · raw message
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +30 -30
94 lines not on this page · raw message
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +16 -16
@@ -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;
drivers/staging/lustre/lnet/lnet/nidstrings.c +2 -2
@@ -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>] ']'
drivers/staging/lustre/lnet/selftest/timer.c +4 -4
@@ -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;
drivers/staging/lustre/lustre/fld/lproc_fld.c +1 -1
@@ -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, };
drivers/staging/lustre/lustre/include/lustre_import.h +3 -3
@@ -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 */ };
drivers/staging/lustre/lustre/include/obd.h +5 -5
@@ -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;
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +3 -3
@@ -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)
drivers/staging/lustre/lustre/llite/file.c +1 -1
@@ -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);
drivers/staging/lustre/lustre/llite/vvp_internal.h +1 -1
@@ -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
drivers/staging/lustre/lustre/llite/xattr.c +1 -1
@@ -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 ) {
drivers/staging/lustre/lustre/lov/lov_ea.c +1 -1
@@ -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 )
drivers/staging/lustre/lustre/lov/lov_obd.c +13 -13
@@ -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;
drivers/staging/lustre/lustre/mgc/mgc_request.c +12 -12
@@ -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 )
drivers/staging/lustre/lustre/obdclass/genops.c +3 -3
@@ -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 ;
drivers/staging/lustre/lustre/obdclass/lu_object.c +4 -4
@@ -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)
drivers/staging/lustre/lustre/obdclass/obd_sysfs.c +1 -1
@@ -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 }
drivers/staging/lustre/lustre/osc/osc_request.c +20 -20
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/wiretest.c +1 -1
@@ -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",
PATCH 23/37 lustre: prefer to use tabs for alignment.
Quoted 4 lines
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.
Quoted 2,418 lines
Signed-off-by NeilBrown <[email protected]>--- .../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(-)drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +1
-1@@ -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 */ drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +5
-5@@ -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 };drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +15
-15@@ -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. drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h +6
-6@@ -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,drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +12
-12@@ -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,drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +1
-1@@ -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 */ drivers/staging/lustre/include/linux/lnet/lib-lnet.h +2
-2@@ -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);drivers/staging/lustre/include/linux/lnet/socklnd.h +1
-1@@ -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 */ drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h +62
-62@@ -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"drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h +28
-28@@ -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. drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +5
-5@@ -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. drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h +7
-7@@ -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 */ };drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h +3
-3@@ -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 );drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h +1
-1@@ -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)drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +175
-175@@ -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 4struct 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_v3struct 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_REPLYenum 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 8enum 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 32struct 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 */ drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h +189
-189@@ -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_v1struct 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 64struct 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 0x02struct hsm_progress {struct lu_fid hp_fid;drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +30
-30@@ -74,25 +74,25 @@#define IBLND_N_SCHED_HIGH 4struct 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;drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +16
-16@@ -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;drivers/staging/lustre/lnet/lnet/nidstrings.c +2
-2@@ -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>] ']' drivers/staging/lustre/lnet/selftest/timer.c +4
-4@@ -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;drivers/staging/lustre/lustre/fld/lproc_fld.c +1
-1@@ -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, };drivers/staging/lustre/lustre/include/lustre_import.h +3
-3@@ -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 */ };drivers/staging/lustre/lustre/include/obd.h +5
-5@@ -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;drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +3
-3@@ -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)drivers/staging/lustre/lustre/llite/file.c +1
-1@@ -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);drivers/staging/lustre/lustre/llite/vvp_internal.h +1
-1@@ -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 drivers/staging/lustre/lustre/llite/xattr.c +1
-1@@ -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 ) {drivers/staging/lustre/lustre/lov/lov_ea.c +1
-1@@ -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 )drivers/staging/lustre/lustre/lov/lov_obd.c +13
-13@@ -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;drivers/staging/lustre/lustre/mgc/mgc_request.c +12
-12@@ -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 )drivers/staging/lustre/lustre/obdclass/genops.c +3
-3@@ -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 ;drivers/staging/lustre/lustre/obdclass/lu_object.c +4
-4@@ -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)drivers/staging/lustre/lustre/obdclass/obd_sysfs.c +1
-1@@ -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 }drivers/staging/lustre/lustre/osc/osc_request.c +20
-20@@ -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);drivers/staging/lustre/lustre/ptlrpc/wiretest.c +1
-1@@ -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",
PATCH 23/37 lustre: prefer to use tabs for alignment.
In reply to NeilBrownQuoted 6 lines · NeilBrown
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 <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 24/37 lustre: lu_object: remove extra newline from debug printing.
In reply to NeilBrownIn 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.
--- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/lu_object.c +1 -1
@@ -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);
PATCH 24/37 lustre: lu_object: remove extra newline from debug printing.
Quoted 4 lines
In
lu_cdebug_printer(), is "complete" is true, thenkey->lck_areaends 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.
Quoted 21 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/lustre/lustre/obdclass/lu_object.c +1
-1@@ -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);
PATCH 24/37 lustre: lu_object: remove extra newline from debug printing.
In reply to NeilBrownQuoted 6 lines · NeilBrown
In
lu_cdebug_printer(), is "complete" is true, thenkey->lck_areaends with a newline, so there is no need to include on in the format too.Signed-off-by NeilBrown <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 25/37 lustre: deprecate libcfs_debug_vmsg2
In reply to NeilBrownSince 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().
--- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 176 ++++++++++---------- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 42 +++-- 2 files changed, 115 insertions(+), 103 deletions(-)
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +92 -84
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +23 -19
54 lines not on this page · raw message
PATCH 25/37 lustre: deprecate libcfs_debug_vmsg2
Quoted 10 lines
Since 2.6.36, Linux' vsprintf has supported %pV which supports "recursive sprintf" - exactly the task that
libcfs_debug_vmsg2aims to provide.Instead of calling
libcfs_debug_vmsg2(), we can put the fmt and args in a 'structva_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.
Quoted 285 lines
Signed-off-by NeilBrown <[email protected]>--- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 176 ++++++++++---------- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 42 +++-- 2 files changed, 115 insertions(+), 103 deletions(-)drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +92
-84@@ -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);drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +23
-19@@ -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);
PATCH 25/37 lustre: deprecate libcfs_debug_vmsg2
In reply to NeilBrownQuoted 10 lines · NeilBrown
Since 2.6.36, Linux' vsprintf has supported %pV which supports "recursive sprintf" - exactly the task that
libcfs_debug_vmsg2aims to provide.Instead of calling
libcfs_debug_vmsg2(), we can put the fmt and args in a 'structva_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.
Quoted 1 line
Signed-off-by NeilBrown <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 26/37 lustre: remove libcfs_debug_vmsg2
In reply to NeilBrownNow 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.
--- .../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(-)
drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +0 -5
@@ -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);
drivers/staging/lustre/lnet/libcfs/tracefile.c +17 -46
97 lines not on this page · raw message
drivers/staging/lustre/lnet/libcfs/tracefile.h +1 -1
@@ -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;
PATCH 26/37 lustre: remove libcfs_debug_vmsg2
Quoted 6 lines · NeilBrown
Now that
libcfs_debug_vmsg2has no (external) users, we can remove it. It is used to implementlibcfs_debug_msg(), so simply move the body of the function (suitably modified) into that one caller.Signed-off-by NeilBrown <[email protected]>
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 27/37 lustre: discard lu_ref
In reply to NeilBrownstruct 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.
--- 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
drivers/staging/lustre/lustre/include/cl_object.h +0 -6
@@ -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; };
drivers/staging/lustre/lustre/include/lu_object.h +0 -45
81 lines not on this page · raw message
drivers/staging/lustre/lustre/include/lu_ref.h deleted +0 -178
178 lines not on this page · raw message
drivers/staging/lustre/lustre/include/lustre_dlm.h +0 -20
@@ -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
drivers/staging/lustre/lustre/include/obd.h +0 -7
@@ -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;
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +7 -29
@@ -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) {
drivers/staging/lustre/lustre/ldlm/ldlm_request.c +0 -12
@@ -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; }
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +0 -4
@@ -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);
drivers/staging/lustre/lustre/llite/lcommon_cl.c +0 -2
@@ -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)
drivers/staging/lustre/lustre/llite/rw.c +0 -6
@@ -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);
drivers/staging/lustre/lustre/llite/rw26.c +1 -5
@@ -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 */
drivers/staging/lustre/lustre/llite/vvp_dev.c +6 -14
@@ -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);
drivers/staging/lustre/lustre/llite/vvp_io.c +0 -5
@@ -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:
drivers/staging/lustre/lustre/lov/lov_object.c +0 -2
@@ -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
drivers/staging/lustre/lustre/lov/lovsub_dev.c +0 -1
@@ -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; }
drivers/staging/lustre/lustre/mdc/mdc_reint.c +0 -2
@@ -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; }
drivers/staging/lustre/lustre/obdclass/Makefile +1 -1
@@ -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
drivers/staging/lustre/lustre/obdclass/cl_io.c +0 -8
@@ -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); } }
drivers/staging/lustre/lustre/obdclass/cl_object.c +0 -2
@@ -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);
drivers/staging/lustre/lustre/obdclass/cl_page.c +0 -5
@@ -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,
drivers/staging/lustre/lustre/obdclass/genops.c +0 -3
@@ -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 ;
drivers/staging/lustre/lustre/obdclass/lu_object.c +4 -30
@@ -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)
drivers/staging/lustre/lustre/obdclass/lu_ref.c deleted +0 -45
45 lines not on this page · raw message
drivers/staging/lustre/lustre/obdclass/obd_config.c +0 -2
@@ -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;
drivers/staging/lustre/lustre/osc/osc_cache.c +0 -12
@@ -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)
drivers/staging/lustre/lustre/osc/osc_lock.c +0 -2
@@ -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 ; }
drivers/staging/lustre/lustre/osc/osc_page.c +0 -2
@@ -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); } }
drivers/staging/lustre/lustre/osc/osc_request.c +0 -2
@@ -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; }
PATCH 27/37 lustre: discard lu_ref
Quoted 5 lines
struct
lu_refis 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 :-)
Quoted 1,429 lines
Signed-off-by NeilBrown <[email protected]>--- 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.cdrivers/staging/lustre/lustre/include/cl_object.h +0
-6@@ -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; };drivers/staging/lustre/lustre/include/lu_object.h +0
-45@@ -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) \drivers/staging/lustre/lustre/include/lu_ref.h deleted +0
-178@@ -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 <[email protected]> -* -* 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 */ drivers/staging/lustre/lustre/include/lustre_dlm.h +0
-20@@ -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 drivers/staging/lustre/lustre/include/obd.h +0
-7@@ -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;drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +7
-29@@ -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) {drivers/staging/lustre/lustre/ldlm/ldlm_request.c +0
-12@@ -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; }drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +0
-4@@ -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);drivers/staging/lustre/lustre/llite/lcommon_cl.c +0
-2@@ -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)drivers/staging/lustre/lustre/llite/rw.c +0
-6@@ -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);drivers/staging/lustre/lustre/llite/rw26.c +1
-5@@ -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 */ drivers/staging/lustre/lustre/llite/vvp_dev.c +6
-14@@ -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);drivers/staging/lustre/lustre/llite/vvp_io.c +0
-5@@ -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:drivers/staging/lustre/lustre/lov/lov_object.c +0
-2@@ -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 drivers/staging/lustre/lustre/lov/lovsub_dev.c +0
-1@@ -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; }drivers/staging/lustre/lustre/mdc/mdc_reint.c +0
-2@@ -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; }drivers/staging/lustre/lustre/obdclass/Makefile +1
-1@@ -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.odrivers/staging/lustre/lustre/obdclass/cl_io.c +0
-8@@ -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); } }drivers/staging/lustre/lustre/obdclass/cl_object.c +0
-2@@ -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);drivers/staging/lustre/lustre/obdclass/cl_page.c +0
-5@@ -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,drivers/staging/lustre/lustre/obdclass/genops.c +0
-3@@ -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 ;drivers/staging/lustre/lustre/obdclass/lu_object.c +4
-30@@ -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)drivers/staging/lustre/lustre/obdclass/lu_ref.c deleted +0
-45@@ -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 <[email protected]> -*/ - -#define DEBUG_SUBSYSTEM S_CLASS - -#include <obd.h> -#include <obd_class.h> -#include <obd_support.h> -#include <lu_ref.h> drivers/staging/lustre/lustre/obdclass/obd_config.c +0
-2@@ -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;drivers/staging/lustre/lustre/osc/osc_cache.c +0
-12@@ -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)drivers/staging/lustre/lustre/osc/osc_lock.c +0
-2@@ -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 ; }drivers/staging/lustre/lustre/osc/osc_page.c +0
-2@@ -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); } }drivers/staging/lustre/lustre/osc/osc_request.c +0
-2@@ -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; }
PATCH 27/37 lustre: discard lu_ref
Quoted 6 lines · James Simmons
Quoted 4 lines
struct
lu_refis 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_refreally 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>
PATCH 27/37 lustre: discard lu_ref
Quoted 16 lines · NeilBrown
Quoted 6 lines · James Simmons
Quoted 4 lines
struct
lu_refis 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_refreally work and always test with it :-)We could ... though a lot of the code has been removed already, I was just finishing the job.
Quoted 7 lines
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
PATCH 27/37 lustre: discard lu_ref
Quoted 23 lines · Andreas Dilger
Quoted 12 lines · NeilBrown
Quoted 5 lines · James Simmons
Quoted 4 lines
struct
lu_refis 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_refreally work and always test with it :-)We could ... though a lot of the code has been removed already, I was just finishing the job.
Quoted 7 lines
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...
Quoted 9 lines
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
PATCH 28/37 lustre: remove scope and source from class_incref and class_decref.
In reply to NeilBrownThese arguments are no longer used, so we can discard them.
--- 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(-)
drivers/staging/lustre/lustre/include/obd_class.h +2 -4
@@ -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);
drivers/staging/lustre/lustre/obdclass/genops.c +6 -6
@@ -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);
drivers/staging/lustre/lustre/obdclass/obd_config.c +8 -9
@@ -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);
drivers/staging/lustre/lustre/obdclass/obd_sysfs.c +2 -2
@@ -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);
PATCH 28/37 lustre: remove scope and source from class_incref and class_decref.
Quoted 4 lines · NeilBrown
These arguments are no longer used, so we can discard them.
Signed-off-by NeilBrown <[email protected]>
Well, they are no longer used, because you've removed the users.
Quoted 9 lines
drivers/staging/lustre/lustre/obdclass/obd_config.c +1
-2-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,drivers/staging/lustre/lustre/obdclass/obd_config.c +0
-0@@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd, }EXPORT_SYMBOL (class_incref);
drivers/staging/lustre/lustre/obdclass/obd_config.c struct obd_device *class_incref(struct obd_device *obd, · line 535
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/obd_config.c +3
-3-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
PATCH 28/37 lustre: remove scope and source from class_incref and class_decref.
Quoted 7 lines · Andreas Dilger
Quoted 4 lines · NeilBrown
These arguments are no longer used, so we can discard them.
Signed-off-by NeilBrown <[email protected]>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
Quoted 27 lines
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/obd_config.c +1
-2-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,drivers/staging/lustre/lustre/obdclass/obd_config.c +0
-0@@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd, }EXPORT_SYMBOL (class_incref);drivers/staging/lustre/lustre/obdclass/obd_config.c struct obd_device *class_incref(struct obd_device *obd, · line 535
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/obd_config.c +3
-3-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()andclass_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.
Quoted 5 lines
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>
PATCH 29/37 lustre: handles: discard h_owner in favour of h_ops
In reply to NeilBrownlustre_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.
--- .../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(-)
drivers/staging/lustre/lustre/include/lustre_handles.h +3 -4
@@ -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 );
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +1 -1
@@ -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 ;
drivers/staging/lustre/lustre/obdclass/genops.c +2 -1
@@ -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);
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +3 -3
@@ -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);
PATCH 29/37 lustre: handles: discard h_owner in favour of h_ops
Quoted 9 lines · NeilBrown
lustre_handlesassigned 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.
Quoted 7 lines
Eahc object also contains an
h_opspointer which can be used to reliably identify an owner.So discard
h_owner, pass and 'ops' pointer toclass_handle2object(), and only return objects for which theh_opsmatches.Signed-off-by NeilBrown <[email protected]>
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
PATCH 29/37 lustre: handles: discard h_owner in favour of h_ops
Quoted 16 lines · Andreas Dilger
Quoted 15 lines · NeilBrown
lustre_handlesassigned 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_opspointer which can be used to reliably identify an owner.So discard
h_owner, pass and 'ops' pointer toclass_handle2object(), and only return objects for which theh_opsmatches.
Quoted 8 lines
Quoted 1 line
Signed-off-by NeilBrown <[email protected]>The
h_owneris 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. Theh_ownerin this case is an MDS-local pointer to the client export data, so just using theh_opspointer (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
Quoted 6 lines
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>
PATCH 29/37 lustre: handles: discard h_owner in favour of h_ops
Quoted 32 lines · NeilBrown
Quoted 16 lines · Andreas Dilger
Quoted 15 lines · NeilBrown
lustre_handlesassigned 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_opspointer which can be used to reliably identify an owner.So discard
h_owner, pass and 'ops' pointer toclass_handle2object(), and only return objects for which theh_opsmatches.Quoted 8 lines
Quoted 1 line
Signed-off-by NeilBrown <[email protected]>The
h_owneris 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. Theh_ownerin this case is an MDS-local pointer to the client export data, so just using theh_opspointer (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.
Quoted 5 lines
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 structmdt_file_datarather 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
PATCH 30/37 lustre: handle: move refcount into the lustre_handle.
In reply to NeilBrownEvery 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.
--- 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(-)
drivers/staging/lustre/lustre/include/lustre_dlm.h +0 -6
@@ -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.
drivers/staging/lustre/lustre/include/lustre_export.h +0 -1
@@ -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,
drivers/staging/lustre/lustre/include/lustre_handles.h +1 -1
@@ -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;
drivers/staging/lustre/lustre/include/lustre_import.h +0 -2
@@ -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;
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +14 -21
@@ -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 ;
drivers/staging/lustre/lustre/obdclass/genops.c +16 -28
117 lines not on this page · raw message
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +1 -1
@@ -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);
drivers/staging/lustre/lustre/obdecho/echo_client.c +1 -1
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/service.c +2 -2
@@ -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),
PATCH 30/37 lustre: handle: move refcount into the lustre_handle.
Quoted 7 lines · NeilBrown
Every object with a
lustre_handlehas (and must have) a refcount. Thelustre_handlescode needs a call-out to increment this. To simplify things, move the refcount into thelustre_handleand discard the call-out.Signed-off-by NeilBrown <[email protected]>
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).
Quoted 9 lines
struct
obd_export*class_export_get(structobd_export*exp) {drivers/staging/lustre/lustre/obdclass/genops.c +1
-1-refcount_inc (&exp->exp_refcount); +refcount_inc (&exp->exp_handle.h_ref);CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
drivers/staging/lustre/lustre/obdclass/genops.c +1
-1- 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.
Quoted 10 lines
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +1
-1@@ -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
PATCH 30/37 lustre: handle: move refcount into the lustre_handle.
Quoted 33 lines · Andreas Dilger
Quoted 7 lines · NeilBrown
Every object with a
lustre_handlehas (and must have) a refcount. Thelustre_handlescode needs a call-out to increment this. To simplify things, move the refcount into thelustre_handleand discard the call-out.Signed-off-by NeilBrown <[email protected]>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).Quoted 9 lines
struct
obd_export*class_export_get(structobd_export*exp) {drivers/staging/lustre/lustre/obdclass/genops.c +1
-1-refcount_inc (&exp->exp_refcount); +refcount_inc (&exp->exp_handle.h_ref);CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
drivers/staging/lustre/lustre/obdclass/genops.c +1
-1- refcount_read(&exp->exp_refcount)); + refcount_read(&exp->exp_handle.h_ref));return exp; }For example, with the existing callback mechanism,
class_export_get()andclass_export_put()would be called for every reference added and removed to this structobd_export(e.g. when a valid lock handle is looked up), so withD_INFOlogging enabled we can trace all of the reference counting of the data structures involved.Quoted 3 lines
(quoted diff) +0
-0@@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)
Quoted 11 lines
Quoted 7 lines
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +1
-1spin_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
Quoted 6 lines
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>
PATCH 30/37 lustre: handle: move refcount into the lustre_handle.
Quoted 48 lines · NeilBrown
Quoted 33 lines · Andreas Dilger
Quoted 7 lines · NeilBrown
Every object with a
lustre_handlehas (and must have) a refcount. Thelustre_handlescode needs a call-out to increment this. To simplify things, move the refcount into thelustre_handleand discard the call-out.Signed-off-by NeilBrown <[email protected]>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).Quoted 9 lines
struct
obd_export*class_export_get(structobd_export*exp) {drivers/staging/lustre/lustre/obdclass/genops.c +1
-1-refcount_inc (&exp->exp_refcount); +refcount_inc (&exp->exp_handle.h_ref);CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
drivers/staging/lustre/lustre/obdclass/genops.c +1
-1- refcount_read(&exp->exp_refcount)); + refcount_read(&exp->exp_handle.h_ref));return exp; }For example, with the existing callback mechanism,
class_export_get()andclass_export_put()would be called for every reference added and removed to this structobd_export(e.g. when a valid lock handle is looked up), so withD_INFOlogging enabled we can trace all of the reference counting of the data structures involved.Quoted 3 lines
(quoted diff) +0
-0@@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)Quoted 11 lines
Quoted 7 lines
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +1
-1spin_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.
Quoted 4 lines
To restore the debugability, would it be sufficient to add a
CDEBUG(D_INFO)toclass_handle2object()where it increments the ref? We could even add a type name topowers_handle_opsto 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
PATCH 31/37 lustre: discard OBD_FREE_RCU
In reply to NeilBrownOBD_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.
--- .../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(-)
drivers/staging/lustre/lustre/include/lustre_handles.h +0 -3
@@ -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 );
drivers/staging/lustre/lustre/include/obd_support.h +0 -10
@@ -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)
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +8 -8
@@ -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, };/**
drivers/staging/lustre/lustre/obdclass/genops.c +2 -4
@@ -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)
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +0 -15
@@ -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;
PATCH 32/37 lustre: portals_handle: rename ops to owner
In reply to NeilBrownNow 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*
--- .../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(-)
drivers/staging/lustre/lustre/include/lustre_handles.h +3 -7
@@ -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 );
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +3 -4
@@ -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 ;
drivers/staging/lustre/lustre/obdclass/genops.c +6 -9
@@ -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
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +6 -7
@@ -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++;
PATCH 33/37 lustre: portals_handle: remove locking from class_handle2object()
In reply to NeilBrownThere 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.
--- .../lustre/lustre/obdclass/lustre_handles.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/obdclass/lustre_handles.c +2 -6
@@ -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 ();