summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/staging/lustre
diff options
context:
space:
mode:
authorJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-04-11 10:41:07 +0300
committerJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-04-13 08:17:18 +0300
commite09b41010ba33a20a87472ee821fa407a5b8da36 (patch)
treed10dc367189862e7ca5c592f033dc3726e1df4e3 /kernel/drivers/staging/lustre
parentf93b97fd65072de626c074dbe099a1fff05ce060 (diff)
These changes are the raw update to linux-4.4.6-rt14. Kernel sources
are taken from kernel.org, and rt patch from the rt wiki download page. During the rebasing, the following patch collided: Force tick interrupt and get rid of softirq magic(I70131fb85). Collisions have been removed because its logic was found on the source already. Change-Id: I7f57a4081d9deaa0d9ccfc41a6c8daccdee3b769 Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'kernel/drivers/staging/lustre')
-rw-r--r--kernel/drivers/staging/lustre/README.txt16
-rw-r--r--kernel/drivers/staging/lustre/TODO2
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs.h68
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h2
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h18
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h189
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h3
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h13
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h100
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h7
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h49
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h4
-rw-r--r--kernel/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h35
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/api-support.h44
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/api.h49
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/lib-lnet.h291
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/lib-types.h667
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/linux/api-support.h42
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h71
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-types.h45
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/linux/lnet.h56
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h49
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/lnet.h17
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/lnetctl.h7
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/lnetst.h490
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/nidstr.h114
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/ptllnd.h93
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h119
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/socklnd.h68
-rw-r--r--kernel/drivers/staging/lustre/include/linux/lnet/types.h292
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c737
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h784
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c622
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c53
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/Makefile2
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c543
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h743
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c422
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h86
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c (renamed from kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c)172
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c34
-rw-r--r--kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c171
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/Makefile7
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/acceptor.c93
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/api-ni.c341
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/config.c314
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lib-eq.c58
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lib-md.c32
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lib-me.c26
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lib-move.c271
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lib-msg.c52
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lib-ptl.c120
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lib-socket.c (renamed from kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c)315
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/lo.c2
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/module.c28
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/nidstrings.c1260
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/peer.c50
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/router.c370
-rw-r--r--kernel/drivers/staging/lustre/lnet/lnet/router_proc.c264
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/brw_test.c66
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/conctl.c58
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/conrpc.c142
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/conrpc.h39
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/console.c264
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/console.h277
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/framework.c182
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/module.c11
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/ping_test.c36
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/rpc.c165
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/rpc.h142
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/selftest.h336
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/timer.c37
-rw-r--r--kernel/drivers/staging/lustre/lnet/selftest/timer.h16
-rw-r--r--kernel/drivers/staging/lustre/lustre/fid/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/fid/fid_internal.h6
-rw-r--r--kernel/drivers/staging/lustre/lustre/fid/fid_request.c210
-rw-r--r--kernel/drivers/staging/lustre/lustre/fid/lproc_fid.c58
-rw-r--r--kernel/drivers/staging/lustre/lustre/fld/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/fld/fld_cache.c21
-rw-r--r--kernel/drivers/staging/lustre/lustre/fld/fld_internal.h8
-rw-r--r--kernel/drivers/staging/lustre/lustre/fld/fld_request.c77
-rw-r--r--kernel/drivers/staging/lustre/lustre/fld/lproc_fld.c44
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/cl_object.h59
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/dt_object.h1499
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/interval_tree.h36
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lclient.h28
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h135
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/linux/lustre_lite.h5
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h17
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/linux/obd.h12
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lprocfs_status.h578
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lu_object.h63
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lu_ref.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre/libiam.h145
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h3
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h208
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre/lustre_lfsck_user.h95
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre/lustre_user.h41
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_capa.h305
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_cfg.h10
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_debug.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_disk.h159
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_dlm.h182
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h245
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_eacl.h5
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_export.h68
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_fid.h101
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_fld.h21
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_ha.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_handles.h3
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_import.h24
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_lib.h34
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_lite.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_log.h167
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_mdc.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_mds.h5
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_net.h189
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_param.h12
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_quota.h241
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_req_layout.h11
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/lustre_sec.h56
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/obd.h212
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/obd_cache.h39
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/obd_cksum.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/obd_class.h287
-rw-r--r--kernel/drivers/staging/lustre/lustre/include/obd_support.h350
-rw-r--r--kernel/drivers/staging/lustre/lustre/lclient/glimpse.c6
-rw-r--r--kernel/drivers/staging/lustre/lustre/lclient/lcommon_cl.c149
-rw-r--r--kernel/drivers/staging/lustre/lustre/lclient/lcommon_misc.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/interval_tree.c274
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/l_lock.c7
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c27
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c278
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h112
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c51
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c417
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c209
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c621
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_request.c384
-rw-r--r--kernel/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c560
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/Makefile4
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/debug.c154
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/fail.c8
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/hash.c163
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c2
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c8
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c10
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/libcfs_string.c148
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c5
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c3
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c13
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c2
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c59
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c7
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c70
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c45
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/module.c541
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/nidstrings.c842
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/tracefile.c22
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/tracefile.h36
-rw-r--r--kernel/drivers/staging/lustre/lustre/libcfs/workitem.c16
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/Makefile5
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/dcache.c10
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/dir.c149
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/file.c189
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/llite_capa.c654
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/llite_close.c15
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/llite_internal.h111
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/llite_lib.c274
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/llite_mmap.c2
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/llite_nfs.c11
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/llite_rmtacl.c5
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/lloop.c27
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/lproc_llite.c749
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/namei.c72
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/remote_perm.c33
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/rw.c42
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/rw26.c25
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/statahead.c61
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/super25.c67
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/symlink.c26
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/vvp_dev.c34
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/vvp_internal.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/vvp_io.c15
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/vvp_lock.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/vvp_object.c13
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/vvp_page.c28
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/xattr.c23
-rw-r--r--kernel/drivers/staging/lustre/lustre/llite/xattr_cache.c32
-rw-r--r--kernel/drivers/staging/lustre/lustre/lmv/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/lmv/lmv_intent.c6
-rw-r--r--kernel/drivers/staging/lustre/lustre/lmv/lmv_internal.h8
-rw-r--r--kernel/drivers/staging/lustre/lustre/lmv/lmv_obd.c204
-rw-r--r--kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c109
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_cl_internal.h5
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_dev.c36
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_ea.c14
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_internal.h49
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_io.c34
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_lock.c26
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_merge.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_obd.c154
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_object.c23
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_pack.c33
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_page.c2
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_pool.c87
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lov_request.c83
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lovsub_dev.c9
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lovsub_lock.c4
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lovsub_object.c6
-rw-r--r--kernel/drivers/staging/lustre/lustre/lov/lproc_lov.c63
-rw-r--r--kernel/drivers/staging/lustre/lustre/mdc/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/mdc/lproc_mdc.c92
-rw-r--r--kernel/drivers/staging/lustre/lustre/mdc/mdc_internal.h25
-rw-r--r--kernel/drivers/staging/lustre/lustre/mdc/mdc_lib.c52
-rw-r--r--kernel/drivers/staging/lustre/lustre/mdc/mdc_locks.c53
-rw-r--r--kernel/drivers/staging/lustre/lustre/mdc/mdc_reint.c24
-rw-r--r--kernel/drivers/staging/lustre/lustre/mdc/mdc_request.c307
-rw-r--r--kernel/drivers/staging/lustre/lustre/mgc/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/mgc/lproc_mgc.c10
-rw-r--r--kernel/drivers/staging/lustre/lustre/mgc/mgc_internal.h11
-rw-r--r--kernel/drivers/staging/lustre/lustre/mgc/mgc_request.c95
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/Makefile6
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/acl.c146
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/capa.c421
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/cl_io.c119
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/cl_lock.c49
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/cl_object.c74
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/cl_page.c55
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/class_obd.c147
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/debug.c10
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/dt_object.c1059
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/genops.c689
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c166
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c137
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c401
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/llog.c576
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/llog_cat.c592
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/llog_internal.h21
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/llog_obd.c35
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/llog_swab.c7
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c9
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c1011
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/lu_object.c401
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/lustre_handles.c29
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/lustre_peer.c8
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/obd_config.c616
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/obd_mount.c287
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/obdo.c173
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/statfs_pack.c14
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdclass/uuid.c34
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdecho/Makefile2
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdecho/echo_client.c134
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdecho/echo_internal.h1
-rw-r--r--kernel/drivers/staging/lustre/lustre/obdecho/lproc_echo.c57
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c454
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_cache.c246
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h3
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_dev.c26
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_internal.h15
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_io.c136
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_lock.c155
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_object.c24
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_page.c49
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_quota.c25
-rw-r--r--kernel/drivers/staging/lustre/lustre/osc/osc_request.c463
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/Makefile3
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/client.c610
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/connection.c16
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/events.c74
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/import.c84
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/layout.c206
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/llog_client.c113
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c495
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/niobuf.c84
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/nrs.c293
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c10
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c380
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/pers.c1
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/pinger.c196
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h40
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c8
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c752
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/sec.c269
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c398
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/sec_config.c154
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c27
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c45
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/sec_null.c28
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c111
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/service.c880
-rw-r--r--kernel/drivers/staging/lustre/lustre/ptlrpc/wiretest.c6
-rw-r--r--kernel/drivers/staging/lustre/sysfs-fs-lustre646
299 files changed, 13925 insertions, 29507 deletions
diff --git a/kernel/drivers/staging/lustre/README.txt b/kernel/drivers/staging/lustre/README.txt
index cf0ca50ff..0676243ee 100644
--- a/kernel/drivers/staging/lustre/README.txt
+++ b/kernel/drivers/staging/lustre/README.txt
@@ -14,10 +14,8 @@ Unlike shared disk storage cluster filesystems (e.g. OCFS2, GFS, GPFS),
Lustre has independent Metadata and Data servers that clients can access
in parallel to maximize performance.
-In order to use Lustre client you will need to download lustre client
-tools from
-https://downloads.hpdd.intel.com/public/lustre/latest-feature-release/
-the package name is lustre-client.
+In order to use Lustre client you will need to download the "lustre-client"
+package that contains the userspace tools from http://lustre.org/download/
You will need to install and configure your Lustre servers separately.
@@ -76,12 +74,10 @@ Mount Options
More Information
================
-You can get more information at
-OpenSFS website: http://lustre.opensfs.org/about/
-Intel HPDD wiki: https://wiki.hpdd.intel.com
+You can get more information at the Lustre website: http://wiki.lustre.org/
-Out of tree Lustre client and server code is available at:
-http://git.whamcloud.com/fs/lustre-release.git
+Source for the userspace tools and out-of-tree client and server code
+is available at: http://git.hpdd.intel.com/fs/lustre-release.git
Latest binary packages:
-http://lustre.opensfs.org/download-lustre/
+http://lustre.org/download/
diff --git a/kernel/drivers/staging/lustre/TODO b/kernel/drivers/staging/lustre/TODO
index 0512594b5..f194417d0 100644
--- a/kernel/drivers/staging/lustre/TODO
+++ b/kernel/drivers/staging/lustre/TODO
@@ -1,6 +1,6 @@
* Possible remaining coding style fix.
* Remove deadcode.
-* Seperate client/server functionality. Functions only used by server can be
+* Separate client/server functionality. Functions only used by server can be
removed from client.
* Clean up libcfs layer. Ideally we can remove include/linux/libcfs entirely.
* Clean up CLIO layer. Lustre client readahead/writeback control needs to better
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 4410d7fdc..4d74e8af5 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -37,34 +37,11 @@
#ifndef __LIBCFS_LIBCFS_H__
#define __LIBCFS_LIBCFS_H__
-#if !__GNUC__
-#define __attribute__(x)
-#endif
-
#include "linux/libcfs.h"
#include <linux/gfp.h>
#include "curproc.h"
-#ifndef offsetof
-# define offsetof(typ, memb) ((long)(long_ptr_t)((char *)&(((typ *)0)->memb)))
-#endif
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) ((sizeof(a)) / (sizeof((a)[0])))
-#endif
-
-#if !defined(swap)
-#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
-#endif
-
-#if !defined(container_of)
-/* given a pointer @ptr to the field @member embedded into type (usually
- * struct) @type, return pointer to the embedding instance of @type. */
-#define container_of(ptr, type, member) \
- ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
-#endif
-
static inline int __is_po2(unsigned long long val)
{
return !(val & (val - 1));
@@ -85,26 +62,6 @@ static inline int __is_po2(unsigned long long val)
#include <linux/list.h>
-int libcfs_arch_init(void);
-void libcfs_arch_cleanup(void);
-
-/* libcfs tcpip */
-int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
-int libcfs_ipif_enumerate(char ***names);
-void libcfs_ipif_free_enumeration(char **names, int n);
-int libcfs_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
-int libcfs_sock_accept(struct socket **newsockp, struct socket *sock);
-void libcfs_sock_abort_accept(struct socket *sock);
-int libcfs_sock_connect(struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port,
- __u32 peer_ip, int peer_port);
-int libcfs_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
-int libcfs_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
-int libcfs_sock_getaddr(struct socket *socket, int remote, __u32 *ip, int *port);
-int libcfs_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
-int libcfs_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
-void libcfs_sock_release(struct socket *sock);
-
/* need both kernel and user-land acceptor */
#define LNET_ACCEPTOR_MIN_RESERVED_PORT 512
#define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023
@@ -174,7 +131,7 @@ void cfs_get_random_bytes(void *buf, int size);
/* container_of depends on "likely" which is defined in libcfs_private.h */
static inline void *__container_of(void *ptr, unsigned long shift)
{
- if (unlikely(IS_ERR(ptr) || ptr == NULL))
+ if (IS_ERR_OR_NULL(ptr))
return ptr;
return (char *)ptr - shift;
}
@@ -184,4 +141,27 @@ static inline void *__container_of(void *ptr, unsigned long shift)
#define _LIBCFS_H
+void *libcfs_kvzalloc(size_t size, gfp_t flags);
+void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
+ gfp_t flags);
+
+extern struct miscdevice libcfs_dev;
+/**
+ * The path of debug log dump upcall script.
+ */
+extern char lnet_upcall[1024];
+extern char lnet_debug_log_upcall[1024];
+
+extern struct cfs_psdev_ops libcfs_psdev_ops;
+
+extern struct cfs_wi_sched *cfs_sched_rehash;
+
+struct lnet_debugfs_symlink_def {
+ char *name;
+ char *target;
+};
+
+void lustre_insert_debugfs(struct ctl_table *table,
+ const struct lnet_debugfs_symlink_def *symlinks);
+
#endif /* _LIBCFS_H */
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 8251ac932..a1787bb43 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -50,7 +50,6 @@ extern unsigned int libcfs_stack;
extern unsigned int libcfs_debug;
extern unsigned int libcfs_printk;
extern unsigned int libcfs_console_ratelimit;
-extern unsigned int libcfs_watchdog_ratelimit;
extern unsigned int libcfs_console_max_delay;
extern unsigned int libcfs_console_min_delay;
extern unsigned int libcfs_console_backoff;
@@ -74,6 +73,7 @@ struct ptldebug_header {
__u32 ph_mask;
__u16 ph_cpu_id;
__u16 ph_type;
+ /* time_t overflow in 2106 */
__u32 ph_sec;
__u64 ph_usec;
__u32 ph_stack;
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
index eea55d94e..aa69c6a33 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
@@ -79,14 +79,16 @@ static inline int cfs_fail_check_set(__u32 id, __u32 value,
{
int ret = 0;
- if (unlikely(CFS_FAIL_PRECHECK(id) &&
- (ret = __cfs_fail_check_set(id, value, set)))) {
- if (quiet) {
- CDEBUG(D_INFO, "*** cfs_fail_loc=%x, val=%u***\n",
- id, value);
- } else {
- LCONSOLE_INFO("*** cfs_fail_loc=%x, val=%u***\n",
- id, value);
+ if (unlikely(CFS_FAIL_PRECHECK(id))) {
+ ret = __cfs_fail_check_set(id, value, set);
+ if (ret) {
+ if (quiet) {
+ CDEBUG(D_INFO, "*** cfs_fail_loc=%x, val=%u***\n",
+ id, value);
+ } else {
+ LCONSOLE_INFO("*** cfs_fail_loc=%x, val=%u***\n",
+ id, value);
+ }
}
}
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
index c40814591..70b8b29e8 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
@@ -88,10 +88,10 @@ union cfs_hash_lock {
* cfs_hash_bucket is a container of:
* - lock, counter ...
* - array of hash-head starting from hsb_head[0], hash-head can be one of
- * . cfs_hash_head_t
- * . cfs_hash_head_dep_t
- * . cfs_hash_dhead_t
- * . cfs_hash_dhead_dep_t
+ * . struct cfs_hash_head
+ * . struct cfs_hash_head_dep
+ * . struct cfs_hash_dhead
+ * . struct cfs_hash_dhead_dep
* which depends on requirement of user
* - some extra bytes (caller can require it while creating hash)
*/
@@ -211,13 +211,13 @@ enum cfs_hash_tag {
struct cfs_hash {
/** serialize with rehash, or serialize all operations if
* the hash-table has CFS_HASH_NO_BKTLOCK */
- union cfs_hash_lock hs_lock;
+ union cfs_hash_lock hs_lock;
/** hash operations */
- struct cfs_hash_ops *hs_ops;
+ struct cfs_hash_ops *hs_ops;
/** hash lock operations */
- struct cfs_hash_lock_ops *hs_lops;
+ struct cfs_hash_lock_ops *hs_lops;
/** hash list operations */
- struct cfs_hash_hlist_ops *hs_hops;
+ struct cfs_hash_hlist_ops *hs_hops;
/** hash buckets-table */
struct cfs_hash_bucket **hs_buckets;
/** total number of items on this hash-table */
@@ -272,7 +272,7 @@ struct cfs_hash {
char hs_name[0];
};
-typedef struct cfs_hash_lock_ops {
+struct cfs_hash_lock_ops {
/** lock the hash table */
void (*hs_lock)(union cfs_hash_lock *lock, int exclusive);
/** unlock the hash table */
@@ -281,24 +281,26 @@ typedef struct cfs_hash_lock_ops {
void (*hs_bkt_lock)(union cfs_hash_lock *lock, int exclusive);
/** unlock the hash bucket */
void (*hs_bkt_unlock)(union cfs_hash_lock *lock, int exclusive);
-} cfs_hash_lock_ops_t;
+};
-typedef struct cfs_hash_hlist_ops {
+struct cfs_hash_hlist_ops {
/** return hlist_head of hash-head of @bd */
- struct hlist_head *(*hop_hhead)(struct cfs_hash *hs, struct cfs_hash_bd *bd);
+ struct hlist_head *(*hop_hhead)(struct cfs_hash *hs,
+ struct cfs_hash_bd *bd);
/** return hash-head size */
int (*hop_hhead_size)(struct cfs_hash *hs);
/** add @hnode to hash-head of @bd */
- int (*hop_hnode_add)(struct cfs_hash *hs,
- struct cfs_hash_bd *bd, struct hlist_node *hnode);
+ int (*hop_hnode_add)(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ struct hlist_node *hnode);
/** remove @hnode from hash-head of @bd */
- int (*hop_hnode_del)(struct cfs_hash *hs,
- struct cfs_hash_bd *bd, struct hlist_node *hnode);
-} cfs_hash_hlist_ops_t;
+ int (*hop_hnode_del)(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ struct hlist_node *hnode);
+};
-typedef struct cfs_hash_ops {
+struct cfs_hash_ops {
/** return hashed value from @key */
- unsigned (*hs_hash)(struct cfs_hash *hs, const void *key, unsigned mask);
+ unsigned (*hs_hash)(struct cfs_hash *hs, const void *key,
+ unsigned mask);
/** return key address of @hnode */
void * (*hs_key)(struct hlist_node *hnode);
/** copy key from @hnode to @key */
@@ -315,10 +317,11 @@ typedef struct cfs_hash_ops {
/** release refcount of item */
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);
-} cfs_hash_ops_t;
+};
/** total number of buckets in @hs */
#define CFS_HASH_NBKT(hs) \
@@ -546,22 +549,26 @@ static inline void cfs_hash_bd_unlock(struct cfs_hash *hs,
* operations on cfs_hash bucket (bd: bucket descriptor),
* they are normally for hash-table without rehash
*/
-void cfs_hash_bd_get(struct cfs_hash *hs, const void *key, struct cfs_hash_bd *bd);
+void cfs_hash_bd_get(struct cfs_hash *hs, const void *key,
+ struct cfs_hash_bd *bd);
-static inline void cfs_hash_bd_get_and_lock(struct cfs_hash *hs, const void *key,
- struct cfs_hash_bd *bd, int excl)
+static inline void
+cfs_hash_bd_get_and_lock(struct cfs_hash *hs, const void *key,
+ struct cfs_hash_bd *bd, int excl)
{
cfs_hash_bd_get(hs, key, bd);
cfs_hash_bd_lock(hs, bd, excl);
}
-static inline unsigned cfs_hash_bd_index_get(struct cfs_hash *hs, struct cfs_hash_bd *bd)
+static inline unsigned
+cfs_hash_bd_index_get(struct cfs_hash *hs, struct cfs_hash_bd *bd)
{
return bd->bd_offset | (bd->bd_bucket->hsb_index << hs->hs_bkt_bits);
}
-static inline void cfs_hash_bd_index_set(struct cfs_hash *hs,
- unsigned index, struct cfs_hash_bd *bd)
+static inline void
+cfs_hash_bd_index_set(struct cfs_hash *hs, unsigned index,
+ struct cfs_hash_bd *bd)
{
bd->bd_bucket = hs->hs_buckets[index >> hs->hs_bkt_bits];
bd->bd_offset = index & (CFS_HASH_BKT_NHLIST(hs) - 1U);
@@ -611,67 +618,73 @@ void cfs_hash_bd_add_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
void cfs_hash_bd_del_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnode);
void cfs_hash_bd_move_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd_old,
- struct cfs_hash_bd *bd_new, struct hlist_node *hnode);
+ struct cfs_hash_bd *bd_new,
+ struct hlist_node *hnode);
-static inline int cfs_hash_bd_dec_and_lock(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- atomic_t *condition)
+static inline int
+cfs_hash_bd_dec_and_lock(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ atomic_t *condition)
{
LASSERT(cfs_hash_with_spin_bktlock(hs));
- return atomic_dec_and_lock(condition,
- &bd->bd_bucket->hsb_lock.spin);
+ return atomic_dec_and_lock(condition, &bd->bd_bucket->hsb_lock.spin);
}
-static inline struct hlist_head *cfs_hash_bd_hhead(struct cfs_hash *hs,
- struct cfs_hash_bd *bd)
+static inline struct hlist_head *
+cfs_hash_bd_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd)
{
return hs->hs_hops->hop_hhead(hs, bd);
}
-struct hlist_node *cfs_hash_bd_lookup_locked(struct cfs_hash *hs,
- struct cfs_hash_bd *bd, const void *key);
-struct hlist_node *cfs_hash_bd_peek_locked(struct cfs_hash *hs,
- struct cfs_hash_bd *bd, const void *key);
-struct hlist_node *cfs_hash_bd_findadd_locked(struct cfs_hash *hs,
- struct cfs_hash_bd *bd, const void *key,
- struct hlist_node *hnode,
- int insist_add);
-struct hlist_node *cfs_hash_bd_finddel_locked(struct cfs_hash *hs,
- struct cfs_hash_bd *bd, const void *key,
- struct hlist_node *hnode);
+struct hlist_node *
+cfs_hash_bd_lookup_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ const void *key);
+struct hlist_node *
+cfs_hash_bd_peek_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ const void *key);
+struct hlist_node *
+cfs_hash_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ const void *key, struct hlist_node *hnode,
+ int insist_add);
+struct hlist_node *
+cfs_hash_bd_finddel_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ const void *key, struct hlist_node *hnode);
/**
* operations on cfs_hash bucket (bd: bucket descriptor),
* they are safe for hash-table with rehash
*/
-void cfs_hash_dual_bd_get(struct cfs_hash *hs, const void *key, struct cfs_hash_bd *bds);
-void cfs_hash_dual_bd_lock(struct cfs_hash *hs, struct cfs_hash_bd *bds, int excl);
-void cfs_hash_dual_bd_unlock(struct cfs_hash *hs, struct cfs_hash_bd *bds, int excl);
+void cfs_hash_dual_bd_get(struct cfs_hash *hs, const void *key,
+ struct cfs_hash_bd *bds);
+void cfs_hash_dual_bd_lock(struct cfs_hash *hs, struct cfs_hash_bd *bds,
+ int excl);
+void cfs_hash_dual_bd_unlock(struct cfs_hash *hs, struct cfs_hash_bd *bds,
+ int excl);
-static inline void cfs_hash_dual_bd_get_and_lock(struct cfs_hash *hs, const void *key,
- struct cfs_hash_bd *bds, int excl)
+static inline void
+cfs_hash_dual_bd_get_and_lock(struct cfs_hash *hs, const void *key,
+ struct cfs_hash_bd *bds, int excl)
{
cfs_hash_dual_bd_get(hs, key, bds);
cfs_hash_dual_bd_lock(hs, bds, excl);
}
-struct hlist_node *cfs_hash_dual_bd_lookup_locked(struct cfs_hash *hs,
- struct cfs_hash_bd *bds,
- const void *key);
-struct hlist_node *cfs_hash_dual_bd_findadd_locked(struct cfs_hash *hs,
- struct cfs_hash_bd *bds,
- const void *key,
- struct hlist_node *hnode,
- int insist_add);
-struct hlist_node *cfs_hash_dual_bd_finddel_locked(struct cfs_hash *hs,
- struct cfs_hash_bd *bds,
- const void *key,
- struct hlist_node *hnode);
+struct hlist_node *
+cfs_hash_dual_bd_lookup_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds,
+ const void *key);
+struct hlist_node *
+cfs_hash_dual_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds,
+ const void *key, struct hlist_node *hnode,
+ int insist_add);
+struct hlist_node *
+cfs_hash_dual_bd_finddel_locked(struct cfs_hash *hs, struct cfs_hash_bd *bds,
+ const void *key, struct hlist_node *hnode);
/* Hash init/cleanup functions */
-struct cfs_hash *cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits,
- unsigned bkt_bits, unsigned extra_bytes,
- unsigned min_theta, unsigned max_theta,
- cfs_hash_ops_t *ops, unsigned flags);
+struct cfs_hash *
+cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits,
+ unsigned bkt_bits, unsigned extra_bytes,
+ unsigned min_theta, unsigned max_theta,
+ struct cfs_hash_ops *ops, unsigned flags);
struct cfs_hash *cfs_hash_getref(struct cfs_hash *hs);
void cfs_hash_putref(struct cfs_hash *hs);
@@ -685,28 +698,39 @@ void *cfs_hash_findadd_unique(struct cfs_hash *hs, const void *key,
struct hlist_node *hnode);
/* Hash deletion functions */
-void *cfs_hash_del(struct cfs_hash *hs, const void *key, struct hlist_node *hnode);
+void *cfs_hash_del(struct cfs_hash *hs, const void *key,
+ struct hlist_node *hnode);
void *cfs_hash_del_key(struct cfs_hash *hs, const void *key);
/* Hash lookup/for_each functions */
#define CFS_HASH_LOOP_HOG 1024
-typedef int (*cfs_hash_for_each_cb_t)(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *node, void *data);
-void *cfs_hash_lookup(struct cfs_hash *hs, const void *key);
-void cfs_hash_for_each(struct cfs_hash *hs, cfs_hash_for_each_cb_t, void *data);
-void cfs_hash_for_each_safe(struct cfs_hash *hs, cfs_hash_for_each_cb_t, void *data);
-int cfs_hash_for_each_nolock(struct cfs_hash *hs,
- cfs_hash_for_each_cb_t, void *data);
-int cfs_hash_for_each_empty(struct cfs_hash *hs,
- cfs_hash_for_each_cb_t, void *data);
-void cfs_hash_for_each_key(struct cfs_hash *hs, const void *key,
- cfs_hash_for_each_cb_t, void *data);
+typedef int (*cfs_hash_for_each_cb_t)(struct cfs_hash *hs,
+ struct cfs_hash_bd *bd,
+ struct hlist_node *node,
+ void *data);
+void *
+cfs_hash_lookup(struct cfs_hash *hs, const void *key);
+void
+cfs_hash_for_each(struct cfs_hash *hs, cfs_hash_for_each_cb_t, void *data);
+void
+cfs_hash_for_each_safe(struct cfs_hash *hs, cfs_hash_for_each_cb_t, void *data);
+int
+cfs_hash_for_each_nolock(struct cfs_hash *hs, cfs_hash_for_each_cb_t,
+ void *data);
+int
+cfs_hash_for_each_empty(struct cfs_hash *hs, cfs_hash_for_each_cb_t,
+ void *data);
+void
+cfs_hash_for_each_key(struct cfs_hash *hs, const void *key,
+ cfs_hash_for_each_cb_t, void *data);
typedef int (*cfs_hash_cond_opt_cb_t)(void *obj, void *data);
-void cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t, void *data);
+void
+cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t, void *data);
-void cfs_hash_hlist_for_each(struct cfs_hash *hs, unsigned hindex,
- cfs_hash_for_each_cb_t, void *data);
+void
+cfs_hash_hlist_for_each(struct cfs_hash *hs, unsigned hindex,
+ cfs_hash_for_each_cb_t, void *data);
int cfs_hash_is_empty(struct cfs_hash *hs);
__u64 cfs_hash_size_get(struct cfs_hash *hs);
@@ -776,7 +800,8 @@ static inline int __cfs_hash_theta(struct cfs_hash *hs)
CFS_HASH_THETA_BITS) >> hs->hs_cur_bits;
}
-static inline void __cfs_hash_set_theta(struct cfs_hash *hs, int min, int max)
+static inline void
+__cfs_hash_set_theta(struct cfs_hash *hs, int min, int max)
{
LASSERT(min < max);
hs->hs_min_theta = (__u16)min;
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index 3ee38782a..485ab2670 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -110,7 +110,6 @@ struct libcfs_ioctl_handler {
#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, long)
#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, long)
#define IOC_LIBCFS_MEMHOG _IOWR('e', 36, long)
-#define IOC_LIBCFS_PING_TEST _IOWR('e', 37, long)
/* lnet ioctls */
#define IOC_LIBCFS_GET_NI _IOWR('e', 50, long)
#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, long)
@@ -134,7 +133,7 @@ struct libcfs_ioctl_handler {
#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, long)
#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, long)
#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, long)
-#define IOC_LIBCFS_GET_TXDESC _IOWR('e', 77, long)
+/* ioctl 77 is free for use */
#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, long)
#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, long)
#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, long)
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
index 978d3e2f1..082fe6de9 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h
@@ -40,21 +40,8 @@
#ifndef __LIBCFS_PRIM_H__
#define __LIBCFS_PRIM_H__
-/*
- * Timer
- */
-typedef void (cfs_timer_func_t)(ulong_ptr_t);
-
void add_wait_queue_exclusive_head(wait_queue_head_t *, wait_queue_t *);
-void cfs_init_timer(struct timer_list *t);
-void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg);
-void cfs_timer_done(struct timer_list *t);
-void cfs_timer_arm(struct timer_list *t, unsigned long deadline);
-void cfs_timer_disarm(struct timer_list *t);
-int cfs_timer_is_armed(struct timer_list *t);
-unsigned long cfs_timer_deadline(struct timer_list *t);
-
/*
* Memory
*/
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index fef882530..f0b0423a7 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -42,14 +42,10 @@
#ifndef __LIBCFS_PRIVATE_H__
#define __LIBCFS_PRIVATE_H__
-/* XXX this layering violation is for nidstrings */
-#include "../lnet/types.h"
-
#ifndef DEBUG_SUBSYSTEM
# define DEBUG_SUBSYSTEM S_UNDEFINED
#endif
-
/*
* When this is on, LASSERT macro includes check for assignment used instead
* of equality check, but doesn't have unlikely(). Turn this on from time to
@@ -83,7 +79,7 @@ do { \
#define KLASSERT(e) LASSERT(e)
-void lbug_with_loc(struct libcfs_debug_msg_data *)__attribute__((noreturn));
+void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *);
#define LBUG() \
do { \
@@ -91,24 +87,6 @@ do { \
lbug_with_loc(&msgdata); \
} while (0)
-extern atomic_t libcfs_kmemory;
-/*
- * Memory
- */
-
-# define libcfs_kmem_inc(ptr, size) \
-do { \
- atomic_add(size, &libcfs_kmemory); \
-} while (0)
-
-# define libcfs_kmem_dec(ptr, size) \
-do { \
- atomic_sub(size, &libcfs_kmemory); \
-} while (0)
-
-# define libcfs_kmem_read() \
- atomic_read(&libcfs_kmemory)
-
#ifndef LIBCFS_VMALLOC_SIZE
#define LIBCFS_VMALLOC_SIZE (2 << PAGE_CACHE_SHIFT) /* 2 pages */
#endif
@@ -117,7 +95,7 @@ do { \
do { \
LASSERT(!in_interrupt() || \
((size) <= LIBCFS_VMALLOC_SIZE && \
- ((mask) & __GFP_WAIT) == 0)); \
+ !gfpflags_allow_blocking(mask))); \
} while (0)
#define LIBCFS_ALLOC_POST(ptr, size) \
@@ -125,14 +103,9 @@ do { \
if (unlikely((ptr) == NULL)) { \
CERROR("LNET: out of memory at %s:%d (tried to alloc '" \
#ptr "' = %d)\n", __FILE__, __LINE__, (int)(size)); \
- CERROR("LNET: %d total bytes allocated by lnet\n", \
- libcfs_kmem_read()); \
} else { \
memset((ptr), 0, (size)); \
- libcfs_kmem_inc((ptr), (size)); \
- CDEBUG(D_MALLOC, "alloc '" #ptr "': %d at %p (tot %d).\n", \
- (int)(size), (ptr), libcfs_kmem_read()); \
- } \
+ } \
} while (0)
/**
@@ -184,9 +157,6 @@ do { \
"%s:%d\n", s, __FILE__, __LINE__); \
break; \
} \
- libcfs_kmem_dec((ptr), s); \
- CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n", \
- s, (ptr), libcfs_kmem_read()); \
if (unlikely(s > LIBCFS_VMALLOC_SIZE)) \
vfree(ptr); \
else \
@@ -410,36 +380,6 @@ int cfs_percpt_atomic_summary(atomic_t **refs);
*/
#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
-/* support decl needed both by kernel and liblustre */
-int libcfs_isknown_lnd(int type);
-char *libcfs_lnd2modname(int type);
-char *libcfs_lnd2str(int type);
-int libcfs_str2lnd(const char *str);
-char *libcfs_net2str(__u32 net);
-char *libcfs_nid2str(lnet_nid_t nid);
-__u32 libcfs_str2net(const char *str);
-lnet_nid_t libcfs_str2nid(const char *str);
-int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
-char *libcfs_id2str(lnet_process_id_t id);
-void cfs_free_nidlist(struct list_head *list);
-int cfs_parse_nidlist(char *str, int len, struct list_head *list);
-int cfs_match_nid(lnet_nid_t nid, struct list_head *list);
-
-/** \addtogroup lnet_addr
- * @{ */
-/* how an LNET NID encodes net:address */
-/** extract the address part of an lnet_nid_t */
-#define LNET_NIDADDR(nid) ((__u32)((nid) & 0xffffffff))
-/** extract the network part of an lnet_nid_t */
-#define LNET_NIDNET(nid) ((__u32)(((nid) >> 32)) & 0xffffffff)
-/** make an lnet_nid_t from a network part and an address part */
-#define LNET_MKNID(net, addr) ((((__u64)(net))<<32)|((__u64)(addr)))
-/* how net encodes type:number */
-#define LNET_NETNUM(net) ((net) & 0xffff)
-#define LNET_NETTYP(net) (((net) >> 16) & 0xffff)
-#define LNET_MKNET(typ, num) ((((__u32)(typ))<<16)|((__u32)(num)))
-/** @} lnet_addr */
-
/* max value for numeric network address */
#define MAX_NUMERIC_VALUE 0xffffffff
@@ -496,19 +436,6 @@ static inline size_t cfs_round_strlen(char *fset)
return (size_t)cfs_size_round((int)strlen(fset) + 1);
}
-/* roundup \a val to power2 */
-static inline unsigned int cfs_power2_roundup(unsigned int val)
-{
- if (val != LOWEST_BIT_SET(val)) { /* not a power of 2 already */
- do {
- val &= ~LOWEST_BIT_SET(val);
- } while (val != LOWEST_BIT_SET(val));
- /* ...and round up */
- val <<= 1;
- }
- return val;
-}
-
#define LOGL(var, len, ptr) \
do { \
if (var) \
@@ -532,25 +459,4 @@ do { \
ptr += cfs_size_round(len + 1); \
} while (0)
-/**
- * Lustre Network Driver types.
- */
-enum {
- /* Only add to these values (i.e. don't ever change or redefine them):
- * network addresses depend on them... */
- QSWLND = 1,
- SOCKLND = 2,
- GMLND = 3, /* obsolete, keep it so that libcfs_nid2str works */
- PTLLND = 4,
- O2IBLND = 5,
- CIBLND = 6,
- OPENIBLND = 7,
- IIBLND = 8,
- LOLND = 9,
- RALND = 10,
- VIBLND = 11,
- MXLND = 12,
- GNILND = 13,
-};
-
#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
index 509dc1e5c..d8d2e7dc2 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h
@@ -83,6 +83,8 @@ int cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res);
int cfs_str2num_check(char *str, int nob, unsigned *num,
unsigned min, unsigned max);
int cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list);
+int cfs_expr_list_print(char *buffer, int count,
+ struct cfs_expr_list *expr_list);
int cfs_expr_list_values(struct cfs_expr_list *expr_list,
int max, __u32 **values);
static inline void
@@ -98,10 +100,5 @@ void cfs_expr_list_free(struct cfs_expr_list *expr_list);
int cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max,
struct cfs_expr_list **elpp);
void cfs_expr_list_free_list(struct list_head *list);
-int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
-int cfs_ip_addr_match(__u32 addr, struct list_head *list);
-void cfs_ip_addr_free(struct list_head *list);
-
-#define strtoul(str, endp, base) simple_strtoul(str, endp, base)
#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 5de6da085..2c7ec2d28 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -68,55 +68,6 @@ static inline unsigned long cfs_time_shift(int seconds)
return cfs_time_add(cfs_time_current(), cfs_time_seconds(seconds));
}
-static inline long cfs_timeval_sub(struct timeval *large, struct timeval *small,
- struct timeval *result)
-{
- long r = (long)(
- (large->tv_sec - small->tv_sec) * ONE_MILLION +
- (large->tv_usec - small->tv_usec));
- if (result != NULL) {
- result->tv_usec = r % ONE_MILLION;
- result->tv_sec = r / ONE_MILLION;
- }
- return r;
-}
-
-static inline void cfs_slow_warning(unsigned long now, int seconds, char *msg)
-{
- if (cfs_time_after(cfs_time_current(),
- cfs_time_add(now, cfs_time_seconds(15))))
- CERROR("slow %s "CFS_TIME_T" sec\n", msg,
- cfs_duration_sec(cfs_time_sub(cfs_time_current(), now)));
-}
-
-#define CFS_RATELIMIT(seconds) \
-({ \
- /* \
- * XXX nikita: non-portable initializer \
- */ \
- static time_t __next_message; \
- int result; \
- \
- if (cfs_time_after(cfs_time_current(), __next_message)) \
- result = 1; \
- else { \
- __next_message = cfs_time_shift(seconds); \
- result = 0; \
- } \
- result; \
-})
-
-/*
- * helper function similar to do_gettimeofday() of Linux kernel
- */
-static inline void cfs_fs_timeval(struct timeval *tv)
-{
- struct timespec time;
-
- cfs_fs_time_current(&time);
- cfs_fs_time_usec(&time, tv);
-}
-
/*
* return valid time-out based on user supplied one. Currently we only check
* that time-out is not shorted than allowed.
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/kernel/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 4fe50841e..aac59008a 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -41,7 +41,6 @@
#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
#endif
-
#include <linux/bitops.h>
#include <linux/compiler.h>
#include <linux/ctype.h>
@@ -61,7 +60,6 @@
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
-#include <linux/proc_fs.h>
#include <linux/random.h>
#include <linux/rbtree.h>
#include <linux/rwsem.h>
@@ -87,7 +85,6 @@
#include "linux-time.h"
#include "linux-mem.h"
-
#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
#if !defined(__x86_64__)
@@ -143,5 +140,4 @@ typedef long long_ptr_t;
#define WITH_WATCHDOG
#endif
-
#endif /* _LINUX_LIBCFS_H */
diff --git a/kernel/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/kernel/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 0fc490bac..ed8764b11 100644
--- a/kernel/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/kernel/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -59,13 +59,6 @@
#include <linux/jiffies.h>
-
-static inline void cfs_fs_time_usec(struct timespec *t, struct timeval *v)
-{
- v->tv_sec = t->tv_sec;
- v->tv_usec = t->tv_nsec / 1000;
-}
-
/*
* Generic kernel stuff
*/
@@ -75,41 +68,16 @@ static inline unsigned long cfs_time_current(void)
return jiffies;
}
-static inline void cfs_fs_time_current(struct timespec *t)
-{
- *t = CURRENT_TIME;
-}
-
-static inline time_t cfs_fs_time_sec(struct timespec *t)
-{
- return t->tv_sec;
-}
-
static inline long cfs_time_seconds(int seconds)
{
return ((long)seconds) * HZ;
}
-static inline time_t cfs_duration_sec(long d)
+static inline long cfs_duration_sec(long d)
{
return d / HZ;
}
-static inline void cfs_duration_usec(long d, struct timeval *s)
-{
-#if (BITS_PER_LONG == 32) && (HZ > 4096)
- __u64 t;
-
- s->tv_sec = d / HZ;
- t = (d - (long)s->tv_sec * HZ) * ONE_MILLION;
- do_div(t, HZ);
- s->tv_usec = t;
-#else
- s->tv_sec = d / HZ;
- s->tv_usec = ((d - (long)s->tv_sec * HZ) * ONE_MILLION) / HZ;
-#endif
-}
-
#define cfs_time_current_64 get_jiffies_64
static inline __u64 cfs_time_add_64(__u64 t, __u64 d)
@@ -138,7 +106,6 @@ static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2)
*/
#define CFS_TICK (1)
-#define CFS_TIME_T "%lu"
#define CFS_DURATION_T "%ld"
#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/api-support.h b/kernel/drivers/staging/lustre/include/linux/lnet/api-support.h
deleted file mode 100644
index 8f7fa28b5..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/api-support.h
+++ /dev/null
@@ -1,44 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LNET_API_SUPPORT_H__
-#define __LNET_API_SUPPORT_H__
-
-#include "linux/api-support.h"
-
-#include "../libcfs/libcfs.h"
-#include "types.h"
-#include "lnet.h"
-
-#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/api.h b/kernel/drivers/staging/lustre/include/linux/lnet/api.h
index cd8651757..9493d5e23 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/api.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/api.h
@@ -15,21 +15,19 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011 - 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*/
#ifndef __LNET_API_H__
@@ -41,9 +39,8 @@
*
* LNet is an asynchronous message-passing API, which provides an unreliable
* connectionless service that can't guarantee any order. It supports OFA IB,
- * TCP/IP, and Cray Portals, and routes between heterogeneous networks.
+ * TCP/IP, and Cray Interconnects, and routes between heterogeneous networks.
*
- * LNet can run both in OS kernel space and in userspace as a library.
* @{
*/
@@ -52,9 +49,6 @@
/** \defgroup lnet_init_fini Initialization and cleanup
* The LNet must be properly initialized before any LNet calls can be made.
* @{ */
-int LNetInit(void);
-void LNetFini(void);
-
int LNetNIInit(lnet_pid_t requested_pid);
int LNetNIFini(void);
/** @} lnet_init_fini */
@@ -98,16 +92,16 @@ void LNetSnprintHandle(char *str, int str_len, lnet_handle_any_t handle);
* @{ */
int LNetMEAttach(unsigned int portal,
lnet_process_id_t match_id_in,
- __u64 match_bits_in,
- __u64 ignore_bits_in,
+ __u64 match_bits_in,
+ __u64 ignore_bits_in,
lnet_unlink_t unlink_in,
lnet_ins_pos_t pos_in,
lnet_handle_me_t *handle_out);
int LNetMEInsert(lnet_handle_me_t current_in,
lnet_process_id_t match_id_in,
- __u64 match_bits_in,
- __u64 ignore_bits_in,
+ __u64 match_bits_in,
+ __u64 ignore_bits_in,
lnet_unlink_t unlink_in,
lnet_ins_pos_t position_in,
lnet_handle_me_t *handle_out);
@@ -128,13 +122,13 @@ int LNetMEUnlink(lnet_handle_me_t current_in);
* associated with a MD: LNetMDUnlink().
* @{ */
int LNetMDAttach(lnet_handle_me_t current_in,
- lnet_md_t md_in,
+ lnet_md_t md_in,
lnet_unlink_t unlink_in,
lnet_handle_md_t *handle_out);
-int LNetMDBind(lnet_md_t md_in,
- lnet_unlink_t unlink_in,
- lnet_handle_md_t *handle_out);
+int LNetMDBind(lnet_md_t md_in,
+ lnet_unlink_t unlink_in,
+ lnet_handle_md_t *handle_out);
int LNetMDUnlink(lnet_handle_md_t md_in);
/** @} lnet_md */
@@ -174,10 +168,10 @@ int LNetEQWait(lnet_handle_eq_t eventq_in,
lnet_event_t *event_out);
int LNetEQPoll(lnet_handle_eq_t *eventqs_in,
- int neq_in,
- int timeout_ms,
+ int neq_in,
+ int timeout_ms,
lnet_event_t *event_out,
- int *which_eq_out);
+ int *which_eq_out);
/** @} lnet_eq */
/** \defgroup lnet_data Data movement operations
@@ -185,20 +179,20 @@ int LNetEQPoll(lnet_handle_eq_t *eventqs_in,
* The LNet API provides two data movement operations: LNetPut()
* and LNetGet().
* @{ */
-int LNetPut(lnet_nid_t self,
+int LNetPut(lnet_nid_t self,
lnet_handle_md_t md_in,
lnet_ack_req_t ack_req_in,
lnet_process_id_t target_in,
unsigned int portal_in,
- __u64 match_bits_in,
+ __u64 match_bits_in,
unsigned int offset_in,
- __u64 hdr_data_in);
+ __u64 hdr_data_in);
-int LNetGet(lnet_nid_t self,
+int LNetGet(lnet_nid_t self,
lnet_handle_md_t md_in,
lnet_process_id_t target_in,
unsigned int portal_in,
- __u64 match_bits_in,
+ __u64 match_bits_in,
unsigned int offset_in);
/** @} lnet_data */
@@ -209,7 +203,6 @@ int LNetGet(lnet_nid_t self,
int LNetSetLazyPortal(int portal);
int LNetClearLazyPortal(int portal);
int LNetCtl(unsigned int cmd, void *arg);
-int LNetSetAsync(lnet_process_id_t id, int nasync);
/** @} lnet_misc */
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/kernel/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 0038d29a3..b61d5045a 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -15,11 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
@@ -27,56 +23,46 @@
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012 - 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*
* lnet/include/lnet/lib-lnet.h
- *
- * Top level include for library side routines
*/
#ifndef __LNET_LIB_LNET_H__
#define __LNET_LIB_LNET_H__
-#include "linux/lib-lnet.h"
#include "../libcfs/libcfs.h"
-#include "types.h"
+#include "api.h"
#include "lnet.h"
#include "lib-types.h"
-extern lnet_t the_lnet; /* THE network */
-
-#if defined(LNET_USE_LIB_FREELIST)
-/* 1 CPT, simplify implementation... */
-# define LNET_CPT_MAX_BITS 0
-
-#else /* KERNEL and no freelist */
+extern lnet_t the_lnet; /* THE network */
-# if (BITS_PER_LONG == 32)
+#if (BITS_PER_LONG == 32)
/* 2 CPTs, allowing more CPTs might make us under memory pressure */
-# define LNET_CPT_MAX_BITS 1
+#define LNET_CPT_MAX_BITS 1
-# else /* 64-bit system */
+#else /* 64-bit system */
/*
* 256 CPTs for thousands of CPUs, allowing more CPTs might make us
* under risk of consuming all lh_cookie.
*/
-# define LNET_CPT_MAX_BITS 8
-# endif /* BITS_PER_LONG == 32 */
-#endif
+#define LNET_CPT_MAX_BITS 8
+#endif /* BITS_PER_LONG == 32 */
/* max allowed CPT number */
-#define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS)
+#define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS)
-#define LNET_CPT_NUMBER (the_lnet.ln_cpt_number)
-#define LNET_CPT_BITS (the_lnet.ln_cpt_bits)
-#define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1)
+#define LNET_CPT_NUMBER (the_lnet.ln_cpt_number)
+#define LNET_CPT_BITS (the_lnet.ln_cpt_bits)
+#define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1)
/** exclusive lock */
-#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX
+#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX
static inline int lnet_is_wire_handle_none(lnet_handle_wire_t *wh)
{
@@ -172,196 +158,12 @@ lnet_net_lock_current(void)
#define lnet_eq_wait_unlock() spin_unlock(&the_lnet.ln_eq_wait_lock)
#define lnet_ni_lock(ni) spin_lock(&(ni)->ni_lock)
#define lnet_ni_unlock(ni) spin_unlock(&(ni)->ni_lock)
-#define LNET_MUTEX_LOCK(m) mutex_lock(m)
-#define LNET_MUTEX_UNLOCK(m) mutex_unlock(m)
-
-#define MAX_PORTALS 64
-
-/* these are only used by code with LNET_USE_LIB_FREELIST, but we still
- * exported them to !LNET_USE_LIB_FREELIST for easy implementation */
-#define LNET_FL_MAX_MES 2048
-#define LNET_FL_MAX_MDS 2048
-#define LNET_FL_MAX_EQS 512
-#define LNET_FL_MAX_MSGS 2048 /* Outstanding messages */
-
-#ifdef LNET_USE_LIB_FREELIST
-
-int lnet_freelist_init(lnet_freelist_t *fl, int n, int size);
-void lnet_freelist_fini(lnet_freelist_t *fl);
-
-static inline void *
-lnet_freelist_alloc(lnet_freelist_t *fl)
-{
- /* ALWAYS called with liblock held */
- lnet_freeobj_t *o;
-
- if (list_empty(&fl->fl_list))
- return NULL;
-
- o = list_entry(fl->fl_list.next, lnet_freeobj_t, fo_list);
- list_del(&o->fo_list);
- return (void *)&o->fo_contents;
-}
-
-static inline void
-lnet_freelist_free(lnet_freelist_t *fl, void *obj)
-{
- /* ALWAYS called with liblock held */
- lnet_freeobj_t *o = list_entry(obj, lnet_freeobj_t, fo_contents);
-
- list_add(&o->fo_list, &fl->fl_list);
-}
-
-static inline lnet_eq_t *
-lnet_eq_alloc(void)
-{
- /* NEVER called with resource lock held */
- struct lnet_res_container *rec = &the_lnet.ln_eq_container;
- lnet_eq_t *eq;
-
- LASSERT(LNET_CPT_NUMBER == 1);
-
- lnet_res_lock(0);
- eq = (lnet_eq_t *)lnet_freelist_alloc(&rec->rec_freelist);
- lnet_res_unlock(0);
-
- return eq;
-}
-
-static inline void
-lnet_eq_free_locked(lnet_eq_t *eq)
-{
- /* ALWAYS called with resource lock held */
- struct lnet_res_container *rec = &the_lnet.ln_eq_container;
-
- LASSERT(LNET_CPT_NUMBER == 1);
- lnet_freelist_free(&rec->rec_freelist, eq);
-}
-
-static inline void
-lnet_eq_free(lnet_eq_t *eq)
-{
- lnet_res_lock(0);
- lnet_eq_free_locked(eq);
- lnet_res_unlock(0);
-}
-
-static inline lnet_libmd_t *
-lnet_md_alloc(lnet_md_t *umd)
-{
- /* NEVER called with resource lock held */
- struct lnet_res_container *rec = the_lnet.ln_md_containers[0];
- lnet_libmd_t *md;
-
- LASSERT(LNET_CPT_NUMBER == 1);
-
- lnet_res_lock(0);
- md = (lnet_libmd_t *)lnet_freelist_alloc(&rec->rec_freelist);
- lnet_res_unlock(0);
-
- if (md != NULL)
- INIT_LIST_HEAD(&md->md_list);
-
- return md;
-}
-
-static inline void
-lnet_md_free_locked(lnet_libmd_t *md)
-{
- /* ALWAYS called with resource lock held */
- struct lnet_res_container *rec = the_lnet.ln_md_containers[0];
-
- LASSERT(LNET_CPT_NUMBER == 1);
- lnet_freelist_free(&rec->rec_freelist, md);
-}
-
-static inline void
-lnet_md_free(lnet_libmd_t *md)
-{
- lnet_res_lock(0);
- lnet_md_free_locked(md);
- lnet_res_unlock(0);
-}
-
-static inline lnet_me_t *
-lnet_me_alloc(void)
-{
- /* NEVER called with resource lock held */
- struct lnet_res_container *rec = the_lnet.ln_me_containers[0];
- lnet_me_t *me;
-
- LASSERT(LNET_CPT_NUMBER == 1);
-
- lnet_res_lock(0);
- me = (lnet_me_t *)lnet_freelist_alloc(&rec->rec_freelist);
- lnet_res_unlock(0);
-
- return me;
-}
-
-static inline void
-lnet_me_free_locked(lnet_me_t *me)
-{
- /* ALWAYS called with resource lock held */
- struct lnet_res_container *rec = the_lnet.ln_me_containers[0];
-
- LASSERT(LNET_CPT_NUMBER == 1);
- lnet_freelist_free(&rec->rec_freelist, me);
-}
-
-static inline void
-lnet_me_free(lnet_me_t *me)
-{
- lnet_res_lock(0);
- lnet_me_free_locked(me);
- lnet_res_unlock(0);
-}
-
-static inline lnet_msg_t *
-lnet_msg_alloc(void)
-{
- /* NEVER called with network lock held */
- struct lnet_msg_container *msc = the_lnet.ln_msg_containers[0];
- lnet_msg_t *msg;
-
- LASSERT(LNET_CPT_NUMBER == 1);
-
- lnet_net_lock(0);
- msg = (lnet_msg_t *)lnet_freelist_alloc(&msc->msc_freelist);
- lnet_net_unlock(0);
- if (msg != NULL) {
- /* NULL pointers, clear flags etc */
- memset(msg, 0, sizeof(*msg));
- }
- return msg;
-}
-
-static inline void
-lnet_msg_free_locked(lnet_msg_t *msg)
-{
- /* ALWAYS called with network lock held */
- struct lnet_msg_container *msc = the_lnet.ln_msg_containers[0];
-
- LASSERT(LNET_CPT_NUMBER == 1);
- LASSERT(!msg->msg_onactivelist);
- lnet_freelist_free(&msc->msc_freelist, msg);
-}
-
-static inline void
-lnet_msg_free(lnet_msg_t *msg)
-{
- lnet_net_lock(0);
- lnet_msg_free_locked(msg);
- lnet_net_unlock(0);
-}
-
-#else /* !LNET_USE_LIB_FREELIST */
+#define MAX_PORTALS 64
static inline lnet_eq_t *
lnet_eq_alloc(void)
{
- /* NEVER called with liblock held */
lnet_eq_t *eq;
LIBCFS_ALLOC(eq, sizeof(*eq));
@@ -371,17 +173,15 @@ lnet_eq_alloc(void)
static inline void
lnet_eq_free(lnet_eq_t *eq)
{
- /* ALWAYS called with resource lock held */
LIBCFS_FREE(eq, sizeof(*eq));
}
static inline lnet_libmd_t *
lnet_md_alloc(lnet_md_t *umd)
{
- /* NEVER called with liblock held */
lnet_libmd_t *md;
- unsigned int size;
- unsigned int niov;
+ unsigned int size;
+ unsigned int niov;
if ((umd->options & LNET_MD_KIOV) != 0) {
niov = umd->length;
@@ -407,8 +207,7 @@ lnet_md_alloc(lnet_md_t *umd)
static inline void
lnet_md_free(lnet_libmd_t *md)
{
- /* ALWAYS called with resource lock held */
- unsigned int size;
+ unsigned int size;
if ((md->md_options & LNET_MD_KIOV) != 0)
size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]);
@@ -421,7 +220,6 @@ lnet_md_free(lnet_libmd_t *md)
static inline lnet_me_t *
lnet_me_alloc(void)
{
- /* NEVER called with liblock held */
lnet_me_t *me;
LIBCFS_ALLOC(me, sizeof(*me));
@@ -431,14 +229,12 @@ lnet_me_alloc(void)
static inline void
lnet_me_free(lnet_me_t *me)
{
- /* ALWAYS called with resource lock held */
LIBCFS_FREE(me, sizeof(*me));
}
static inline lnet_msg_t *
lnet_msg_alloc(void)
{
- /* NEVER called with liblock held */
lnet_msg_t *msg;
LIBCFS_ALLOC(msg, sizeof(*msg));
@@ -450,18 +246,10 @@ lnet_msg_alloc(void)
static inline void
lnet_msg_free(lnet_msg_t *msg)
{
- /* ALWAYS called with network lock held */
LASSERT(!msg->msg_onactivelist);
LIBCFS_FREE(msg, sizeof(*msg));
}
-#define lnet_eq_free_locked(eq) lnet_eq_free(eq)
-#define lnet_md_free_locked(md) lnet_md_free(md)
-#define lnet_me_free_locked(me) lnet_me_free(me)
-#define lnet_msg_free_locked(msg) lnet_msg_free(msg)
-
-#endif /* LNET_USE_LIB_FREELIST */
-
lnet_libhandle_t *lnet_res_lh_lookup(struct lnet_res_container *rec,
__u64 cookie);
void lnet_res_lh_initialize(struct lnet_res_container *rec,
@@ -469,7 +257,6 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec,
static inline void
lnet_res_lh_invalidate(lnet_libhandle_t *lh)
{
- /* ALWAYS called with resource lock held */
/* NB: cookie is still useful, don't reset it */
list_del(&lh->lh_hash_chain);
}
@@ -488,7 +275,6 @@ lnet_eq2handle(lnet_handle_eq_t *handle, lnet_eq_t *eq)
static inline lnet_eq_t *
lnet_handle2eq(lnet_handle_eq_t *handle)
{
- /* ALWAYS called with resource lock held */
lnet_libhandle_t *lh;
lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie);
@@ -509,7 +295,7 @@ lnet_handle2md(lnet_handle_md_t *handle)
{
/* ALWAYS called with resource lock held */
lnet_libhandle_t *lh;
- int cpt;
+ int cpt;
cpt = lnet_cpt_of_cookie(handle->cookie);
lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
@@ -525,7 +311,7 @@ lnet_wire_handle2md(lnet_handle_wire_t *wh)
{
/* ALWAYS called with resource lock held */
lnet_libhandle_t *lh;
- int cpt;
+ int cpt;
if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie)
return NULL;
@@ -550,7 +336,7 @@ lnet_handle2me(lnet_handle_me_t *handle)
{
/* ALWAYS called with resource lock held */
lnet_libhandle_t *lh;
- int cpt;
+ int cpt;
cpt = lnet_cpt_of_cookie(handle->cookie);
lh = lnet_res_lh_lookup(the_lnet.ln_me_containers[cpt],
@@ -644,6 +430,9 @@ lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt);
lnet_ni_t *lnet_net2ni(__u32 net);
+int lnet_init(void);
+void lnet_fini(void);
+
int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, unsigned long when);
void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive,
unsigned long when);
@@ -654,8 +443,8 @@ int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
void lnet_destroy_routes(void);
int lnet_get_route(int idx, __u32 *net, __u32 *hops,
lnet_nid_t *gateway, __u32 *alive, __u32 *priority);
-void lnet_proc_init(void);
-void lnet_proc_fini(void);
+void lnet_router_debugfs_init(void);
+void lnet_router_debugfs_fini(void);
int lnet_rtrpools_alloc(int im_a_router);
void lnet_rtrpools_free(void);
lnet_remotenet_t *lnet_find_net_locked(__u32 net);
@@ -737,7 +526,9 @@ void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
unsigned int offset, unsigned int mlen, unsigned int rlen);
lnet_msg_t *lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *get_msg);
void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len);
+
void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc);
+
void lnet_drop_delayed_msg_list(struct list_head *head, char *reason);
void lnet_recv_delayed_msg_list(struct list_head *head);
@@ -830,7 +621,6 @@ void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd);
void lnet_register_lnd(lnd_t *lnd);
void lnet_unregister_lnd(lnd_t *lnd);
-int lnet_set_ip_niaddr(lnet_ni_t *ni);
int lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
__u32 local_ip, __u32 peer_ip, int peer_port);
@@ -846,7 +636,22 @@ int lnet_acceptor_port(void);
int lnet_acceptor_start(void);
void lnet_acceptor_stop(void);
-void lnet_get_tunables(void);
+int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
+int lnet_ipif_enumerate(char ***names);
+void lnet_ipif_free_enumeration(char **names, int n);
+int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
+int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
+int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port);
+int lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
+int lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
+
+int lnet_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
+int lnet_sock_accept(struct socket **newsockp, struct socket *sock);
+int lnet_sock_connect(struct socket **sockp, int *fatal,
+ __u32 local_ip, int local_port,
+ __u32 peer_ip, int peer_port);
+void libcfs_sock_release(struct socket *sock);
+
int lnet_peers_start_down(void);
int lnet_peer_buffer_credits(lnet_ni_t *ni);
@@ -872,12 +677,12 @@ void lnet_peer_tables_destroy(void);
int lnet_peer_tables_create(void);
void lnet_debug_peer(lnet_nid_t nid);
-static inline void lnet_peer_set_alive(lnet_peer_t *lp)
+static inline void
+lnet_peer_set_alive(lnet_peer_t *lp)
{
- lp->lp_last_alive = lp->lp_last_query = get_seconds();
+ lp->lp_last_alive = lp->lp_last_query = jiffies;
if (!lp->lp_alive)
lnet_notify_locked(lp, 0, 1, lp->lp_last_alive);
}
-
#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/lib-types.h b/kernel/drivers/staging/lustre/include/linux/lnet/lib-types.h
index 50537668f..d792c4adb 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -15,11 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
@@ -27,155 +23,41 @@
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012 - 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*
* lnet/include/lnet/lib-types.h
- *
- * Types used by the library side routines that do not need to be
- * exposed to the user application
*/
#ifndef __LNET_LIB_TYPES_H__
#define __LNET_LIB_TYPES_H__
-#include "linux/lib-types.h"
+#include <linux/kthread.h>
+#include <linux/uio.h>
+#include <linux/types.h>
+#include <net/sock.h>
-#include "../libcfs/libcfs.h"
-#include <linux/list.h>
#include "types.h"
-#define WIRE_ATTR __attribute__((packed))
-
-/* Packed version of lnet_process_id_t to transfer via network */
-typedef struct {
- lnet_nid_t nid;
- lnet_pid_t pid; /* node id / process id */
-} WIRE_ATTR lnet_process_id_packed_t;
-
-/* The wire handle's interface cookie only matches one network interface in
- * one epoch (i.e. new cookie when the interface restarts or the node
- * reboots). The object cookie only matches one object on that interface
- * during that object's lifetime (i.e. no cookie re-use). */
-typedef struct {
- __u64 wh_interface_cookie;
- __u64 wh_object_cookie;
-} WIRE_ATTR lnet_handle_wire_t;
-
-typedef enum {
- LNET_MSG_ACK = 0,
- LNET_MSG_PUT,
- LNET_MSG_GET,
- LNET_MSG_REPLY,
- LNET_MSG_HELLO,
-} lnet_msg_type_t;
-
-/* The variant fields of the portals message header are aligned on an 8
- * byte boundary in the message header. Note that all types used in these
- * wire structs MUST be fixed size and the smaller types are placed at the
- * end. */
-typedef struct lnet_ack {
- lnet_handle_wire_t dst_wmd;
- __u64 match_bits;
- __u32 mlength;
-} WIRE_ATTR lnet_ack_t;
-
-typedef struct lnet_put {
- lnet_handle_wire_t ack_wmd;
- __u64 match_bits;
- __u64 hdr_data;
- __u32 ptl_index;
- __u32 offset;
-} WIRE_ATTR lnet_put_t;
-
-typedef struct lnet_get {
- lnet_handle_wire_t return_wmd;
- __u64 match_bits;
- __u32 ptl_index;
- __u32 src_offset;
- __u32 sink_length;
-} WIRE_ATTR lnet_get_t;
-
-typedef struct lnet_reply {
- lnet_handle_wire_t dst_wmd;
-} WIRE_ATTR lnet_reply_t;
-
-typedef struct lnet_hello {
- __u64 incarnation;
- __u32 type;
-} WIRE_ATTR lnet_hello_t;
-
-typedef struct {
- lnet_nid_t dest_nid;
- lnet_nid_t src_nid;
- lnet_pid_t dest_pid;
- lnet_pid_t src_pid;
- __u32 type; /* lnet_msg_type_t */
- __u32 payload_length; /* payload data to follow */
- /*<------__u64 aligned------->*/
- union {
- lnet_ack_t ack;
- lnet_put_t put;
- lnet_get_t get;
- lnet_reply_t reply;
- lnet_hello_t hello;
- } msg;
-} WIRE_ATTR lnet_hdr_t;
-
-/* A HELLO message contains a magic number and protocol version
- * code in the header's dest_nid, the peer's NID in the src_nid, and
- * LNET_MSG_HELLO in the type field. All other common fields are zero
- * (including payload_size; i.e. no payload).
- * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is
- * running the same protocol and to find out its NID. These LNDs should
- * exchange HELLO messages when a connection is first established. Individual
- * LNDs can put whatever else they fancy in lnet_hdr_t::msg.
- */
-typedef struct {
- __u32 magic; /* LNET_PROTO_TCP_MAGIC */
- __u16 version_major; /* increment on incompatible change */
- __u16 version_minor; /* increment on compatible change */
-} WIRE_ATTR lnet_magicversion_t;
-
-/* PROTO MAGIC for LNDs */
-#define LNET_PROTO_IB_MAGIC 0x0be91b91
-#define LNET_PROTO_RA_MAGIC 0x0be91b92
-#define LNET_PROTO_QSW_MAGIC 0x0be91b93
-#define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */
-#define LNET_PROTO_TCP_MAGIC 0xeebc0ded
-#define LNET_PROTO_PTL_MAGIC 0x50746C4E /* 'PtlN' unique magic */
-#define LNET_PROTO_MX_MAGIC 0x4d583130 /* 'MX10'! */
-#define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100
-#define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */
-
-/* Placeholder for a future "unified" protocol across all LNDs */
-/* Current LNDs that receive a request with this magic will respond with a
- * "stub" reply using their current protocol */
-#define LNET_PROTO_MAGIC 0x45726963 /* ! */
-
-#define LNET_PROTO_TCP_VERSION_MAJOR 1
-#define LNET_PROTO_TCP_VERSION_MINOR 0
-
-/* Acceptor connection request */
-typedef struct {
- __u32 acr_magic; /* PTL_ACCEPTOR_PROTO_MAGIC */
- __u32 acr_version; /* protocol version */
- __u64 acr_nid; /* target NID */
-} WIRE_ATTR lnet_acceptor_connreq_t;
-
-#define LNET_PROTO_ACCEPTOR_VERSION 1
+/* Max payload size */
+#define LNET_MAX_PAYLOAD CONFIG_LNET_MAX_PAYLOAD
+#if (LNET_MAX_PAYLOAD < LNET_MTU)
+# error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb"
+#elif (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV))
+# error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb"
+#endif
/* forward refs */
struct lnet_libmd;
typedef struct lnet_msg {
- struct list_head msg_activelist;
- struct list_head msg_list; /* Q for credits/MD */
+ struct list_head msg_activelist;
+ struct list_head msg_list; /* Q for credits/MD */
- lnet_process_id_t msg_target;
+ lnet_process_id_t msg_target;
/* where is it from, it's only for building event */
lnet_nid_t msg_from;
__u32 msg_type;
@@ -195,127 +77,114 @@ typedef struct lnet_msg {
/* ready for pending on RX delay list */
unsigned int msg_rx_ready_delay:1;
- unsigned int msg_vmflush:1; /* VM trying to free memory */
- unsigned int msg_target_is_router:1; /* sending to a router */
- unsigned int msg_routing:1; /* being forwarded */
- unsigned int msg_ack:1; /* ack on finalize (PUT) */
- unsigned int msg_sending:1; /* outgoing message */
- unsigned int msg_receiving:1; /* being received */
- unsigned int msg_txcredit:1; /* taken an NI send credit */
- unsigned int msg_peertxcredit:1; /* taken a peer send credit */
- unsigned int msg_rtrcredit:1; /* taken a global router credit */
- unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
- unsigned int msg_onactivelist:1; /* on the activelist */
-
- struct lnet_peer *msg_txpeer; /* peer I'm sending to */
- struct lnet_peer *msg_rxpeer; /* peer I received from */
-
- void *msg_private;
- struct lnet_libmd *msg_md;
-
- unsigned int msg_len;
- unsigned int msg_wanted;
- unsigned int msg_offset;
- unsigned int msg_niov;
- struct kvec *msg_iov;
- lnet_kiov_t *msg_kiov;
-
- lnet_event_t msg_ev;
- lnet_hdr_t msg_hdr;
+ unsigned int msg_vmflush:1; /* VM trying to free memory */
+ unsigned int msg_target_is_router:1; /* sending to a router */
+ unsigned int msg_routing:1; /* being forwarded */
+ unsigned int msg_ack:1; /* ack on finalize (PUT) */
+ unsigned int msg_sending:1; /* outgoing message */
+ unsigned int msg_receiving:1; /* being received */
+ unsigned int msg_txcredit:1; /* taken an NI send credit */
+ unsigned int msg_peertxcredit:1; /* taken a peer send credit */
+ unsigned int msg_rtrcredit:1; /* taken a global
+ router credit */
+ unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
+ unsigned int msg_onactivelist:1; /* on the activelist */
+
+ struct lnet_peer *msg_txpeer; /* peer I'm sending to */
+ struct lnet_peer *msg_rxpeer; /* peer I received from */
+
+ void *msg_private;
+ struct lnet_libmd *msg_md;
+
+ unsigned int msg_len;
+ unsigned int msg_wanted;
+ unsigned int msg_offset;
+ unsigned int msg_niov;
+ struct kvec *msg_iov;
+ lnet_kiov_t *msg_kiov;
+
+ lnet_event_t msg_ev;
+ lnet_hdr_t msg_hdr;
} lnet_msg_t;
typedef struct lnet_libhandle {
- struct list_head lh_hash_chain;
- __u64 lh_cookie;
+ struct list_head lh_hash_chain;
+ __u64 lh_cookie;
} lnet_libhandle_t;
#define lh_entry(ptr, type, member) \
((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
typedef struct lnet_eq {
- struct list_head eq_list;
- lnet_libhandle_t eq_lh;
- lnet_seq_t eq_enq_seq;
- lnet_seq_t eq_deq_seq;
- unsigned int eq_size;
- lnet_eq_handler_t eq_callback;
- lnet_event_t *eq_events;
+ struct list_head eq_list;
+ lnet_libhandle_t eq_lh;
+ lnet_seq_t eq_enq_seq;
+ lnet_seq_t eq_deq_seq;
+ unsigned int eq_size;
+ lnet_eq_handler_t eq_callback;
+ lnet_event_t *eq_events;
int **eq_refs; /* percpt refcount for EQ */
} lnet_eq_t;
typedef struct lnet_me {
- struct list_head me_list;
- lnet_libhandle_t me_lh;
- lnet_process_id_t me_match_id;
- unsigned int me_portal;
- unsigned int me_pos; /* hash offset in mt_hash */
- __u64 me_match_bits;
- __u64 me_ignore_bits;
- lnet_unlink_t me_unlink;
- struct lnet_libmd *me_md;
+ struct list_head me_list;
+ lnet_libhandle_t me_lh;
+ lnet_process_id_t me_match_id;
+ unsigned int me_portal;
+ unsigned int me_pos; /* hash offset in mt_hash */
+ __u64 me_match_bits;
+ __u64 me_ignore_bits;
+ lnet_unlink_t me_unlink;
+ struct lnet_libmd *me_md;
} lnet_me_t;
typedef struct lnet_libmd {
- struct list_head md_list;
- lnet_libhandle_t md_lh;
- lnet_me_t *md_me;
- char *md_start;
- unsigned int md_offset;
- unsigned int md_length;
- unsigned int md_max_size;
- int md_threshold;
- int md_refcount;
- unsigned int md_options;
- unsigned int md_flags;
- void *md_user_ptr;
- lnet_eq_t *md_eq;
- unsigned int md_niov; /* # frags */
+ struct list_head md_list;
+ lnet_libhandle_t md_lh;
+ lnet_me_t *md_me;
+ char *md_start;
+ unsigned int md_offset;
+ unsigned int md_length;
+ unsigned int md_max_size;
+ int md_threshold;
+ int md_refcount;
+ unsigned int md_options;
+ unsigned int md_flags;
+ void *md_user_ptr;
+ lnet_eq_t *md_eq;
+ unsigned int md_niov; /* # frags */
union {
- struct kvec iov[LNET_MAX_IOV];
- lnet_kiov_t kiov[LNET_MAX_IOV];
+ struct kvec iov[LNET_MAX_IOV];
+ lnet_kiov_t kiov[LNET_MAX_IOV];
} md_iov;
} lnet_libmd_t;
-#define LNET_MD_FLAG_ZOMBIE (1 << 0)
-#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1)
-#define LNET_MD_FLAG_ABORTED (1 << 2)
-
-#ifdef LNET_USE_LIB_FREELIST
-typedef struct {
- void *fl_objs; /* single contiguous array of objects */
- int fl_nobjs; /* the number of them */
- int fl_objsize; /* the size (including overhead) of each of them */
- struct list_head fl_list; /* where they are enqueued */
-} lnet_freelist_t;
-
-typedef struct {
- struct list_head fo_list; /* enqueue on fl_list */
- void *fo_contents; /* aligned contents */
-} lnet_freeobj_t;
-#endif
+#define LNET_MD_FLAG_ZOMBIE (1 << 0)
+#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1)
+#define LNET_MD_FLAG_ABORTED (1 << 2)
typedef struct {
/* info about peers we are trying to fail */
- struct list_head tp_list; /* ln_test_peers */
- lnet_nid_t tp_nid; /* matching nid */
- unsigned int tp_threshold; /* # failures to simulate */
+ struct list_head tp_list; /* ln_test_peers */
+ lnet_nid_t tp_nid; /* matching nid */
+ unsigned int tp_threshold; /* # failures to simulate */
} lnet_test_peer_t;
-#define LNET_COOKIE_TYPE_MD 1
-#define LNET_COOKIE_TYPE_ME 2
-#define LNET_COOKIE_TYPE_EQ 3
-#define LNET_COOKIE_TYPE_BITS 2
+#define LNET_COOKIE_TYPE_MD 1
+#define LNET_COOKIE_TYPE_ME 2
+#define LNET_COOKIE_TYPE_EQ 3
+#define LNET_COOKIE_TYPE_BITS 2
#define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL)
-struct lnet_ni; /* forward ref */
+struct lnet_ni; /* forward ref */
typedef struct lnet_lnd {
/* fields managed by portals */
- struct list_head lnd_list; /* stash in the LND table */
- int lnd_refcount; /* # active instances */
+ struct list_head lnd_list; /* stash in the LND table */
+ int lnd_refcount; /* # active instances */
/* fields initialised by the LND */
- unsigned int lnd_type;
+ __u32 lnd_type;
int (*lnd_startup)(struct lnet_ni *ni);
void (*lnd_shutdown)(struct lnet_ni *ni);
@@ -347,7 +216,8 @@ typedef struct lnet_lnd {
int (*lnd_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg,
int delayed, unsigned int niov,
struct kvec *iov, lnet_kiov_t *kiov,
- unsigned int offset, unsigned int mlen, unsigned int rlen);
+ unsigned int offset, unsigned int mlen,
+ unsigned int rlen);
/* lnet_parse() has had to delay processing of this message
* (e.g. waiting for a forwarding buffer or send credits). Give the
@@ -355,60 +225,49 @@ typedef struct lnet_lnd {
* for success and do NOT give back a receive credit; that has to wait
* until lnd_recv() gets called. On failure return < 0 and
* release resources; lnd_recv() will not be called. */
- int (*lnd_eager_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg,
- void **new_privatep);
+ int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
+ lnet_msg_t *msg, void **new_privatep);
/* notification of peer health */
void (*lnd_notify)(struct lnet_ni *ni, lnet_nid_t peer, int alive);
/* query of peer aliveness */
- void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, unsigned long *when);
+ void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer,
+ unsigned long *when);
/* accept a new connection */
int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
-
} lnd_t;
-#define LNET_NI_STATUS_UP 0x15aac0de
-#define LNET_NI_STATUS_DOWN 0xdeadface
-#define LNET_NI_STATUS_INVALID 0x00000000
-typedef struct {
- lnet_nid_t ns_nid;
- __u32 ns_status;
- __u32 ns_unused;
-} WIRE_ATTR lnet_ni_status_t;
-
struct lnet_tx_queue {
int tq_credits; /* # tx credits free */
int tq_credits_min; /* lowest it's been */
int tq_credits_max; /* total # tx credits */
- struct list_head tq_delayed; /* delayed TXs */
+ struct list_head tq_delayed; /* delayed TXs */
};
-#define LNET_MAX_INTERFACES 16
-
typedef struct lnet_ni {
- spinlock_t ni_lock;
- struct list_head ni_list; /* chain on ln_nis */
- struct list_head ni_cptlist; /* chain on ln_nis_cpt */
- int ni_maxtxcredits; /* # tx credits */
+ spinlock_t ni_lock;
+ struct list_head ni_list; /* chain on ln_nis */
+ struct list_head ni_cptlist; /* chain on ln_nis_cpt */
+ int ni_maxtxcredits; /* # tx credits */
/* # per-peer send credits */
- int ni_peertxcredits;
+ int ni_peertxcredits;
/* # per-peer router buffer credits */
- int ni_peerrtrcredits;
+ int ni_peerrtrcredits;
/* seconds to consider peer dead */
- int ni_peertimeout;
- int ni_ncpts; /* number of CPTs */
- __u32 *ni_cpts; /* bond NI on some CPTs */
- lnet_nid_t ni_nid; /* interface's NID */
- void *ni_data; /* instance-specific data */
- lnd_t *ni_lnd; /* procedural interface */
+ int ni_peertimeout;
+ int ni_ncpts; /* number of CPTs */
+ __u32 *ni_cpts; /* bond NI on some CPTs */
+ lnet_nid_t ni_nid; /* interface's NID */
+ void *ni_data; /* instance-specific data */
+ lnd_t *ni_lnd; /* procedural interface */
struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */
int **ni_refs; /* percpt reference count */
- long ni_last_alive; /* when I was last alive */
- lnet_ni_status_t *ni_status; /* my health status */
+ time64_t ni_last_alive;/* when I was last alive */
+ lnet_ni_status_t *ni_status; /* my health status */
/* equivalent interfaces to use */
- char *ni_interfaces[LNET_MAX_INTERFACES];
+ char *ni_interfaces[LNET_MAX_INTERFACES];
} lnet_ni_t;
#define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
@@ -422,68 +281,70 @@ typedef struct lnet_ni {
#define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \
LNET_PING_FEAT_NI_STATUS)
-typedef struct {
- __u32 pi_magic;
- __u32 pi_features;
- lnet_pid_t pi_pid;
- __u32 pi_nnis;
- lnet_ni_status_t pi_ni[0];
-} WIRE_ATTR lnet_ping_info_t;
-
/* router checker data, per router */
#define LNET_MAX_RTR_NIS 16
#define LNET_PINGINFO_SIZE offsetof(lnet_ping_info_t, pi_ni[LNET_MAX_RTR_NIS])
typedef struct {
/* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */
- struct list_head rcd_list;
- lnet_handle_md_t rcd_mdh; /* ping buffer MD */
+ struct list_head rcd_list;
+ lnet_handle_md_t rcd_mdh; /* ping buffer MD */
struct lnet_peer *rcd_gateway; /* reference to gateway */
lnet_ping_info_t *rcd_pinginfo; /* ping buffer */
} lnet_rc_data_t;
typedef struct lnet_peer {
- struct list_head lp_hashlist; /* chain on peer hash */
- struct list_head lp_txq; /* messages blocking for tx credits */
- struct list_head lp_rtrq; /* messages blocking for router credits */
- struct list_head lp_rtr_list; /* chain on router list */
- int lp_txcredits; /* # tx credits available */
- int lp_mintxcredits; /* low water mark */
- int lp_rtrcredits; /* # router credits */
- int lp_minrtrcredits; /* low water mark */
- unsigned int lp_alive:1; /* alive/dead? */
- unsigned int lp_notify:1; /* notification outstanding? */
- unsigned int lp_notifylnd:1; /* outstanding notification for LND? */
- unsigned int lp_notifying:1; /* some thread is handling notification */
- unsigned int lp_ping_notsent; /* SEND event outstanding from ping */
- int lp_alive_count; /* # times router went dead<->alive */
- long lp_txqnob; /* bytes queued for sending */
- unsigned long lp_timestamp; /* time of last aliveness news */
- unsigned long lp_ping_timestamp; /* time of last ping attempt */
- unsigned long lp_ping_deadline; /* != 0 if ping reply expected */
- unsigned long lp_last_alive; /* when I was last alive */
- unsigned long lp_last_query; /* when lp_ni was queried last time */
- lnet_ni_t *lp_ni; /* interface peer is on */
- lnet_nid_t lp_nid; /* peer's NID */
- int lp_refcount; /* # refs */
- int lp_cpt; /* CPT this peer attached on */
+ struct list_head lp_hashlist; /* chain on peer hash */
+ struct list_head lp_txq; /* messages blocking for
+ tx credits */
+ struct list_head lp_rtrq; /* messages blocking for
+ router credits */
+ struct list_head lp_rtr_list; /* chain on router list */
+ int lp_txcredits; /* # tx credits available */
+ int lp_mintxcredits; /* low water mark */
+ int lp_rtrcredits; /* # router credits */
+ int lp_minrtrcredits; /* low water mark */
+ unsigned int lp_alive:1; /* alive/dead? */
+ unsigned int lp_notify:1; /* notification outstanding? */
+ unsigned int lp_notifylnd:1;/* outstanding notification
+ for LND? */
+ unsigned int lp_notifying:1; /* some thread is handling
+ notification */
+ unsigned int lp_ping_notsent;/* SEND event outstanding
+ from ping */
+ int lp_alive_count; /* # times router went
+ dead<->alive */
+ long lp_txqnob; /* bytes queued for sending */
+ unsigned long lp_timestamp; /* time of last aliveness
+ news */
+ unsigned long lp_ping_timestamp;/* time of last ping
+ attempt */
+ unsigned long lp_ping_deadline; /* != 0 if ping reply
+ expected */
+ unsigned long lp_last_alive; /* when I was last alive */
+ unsigned long lp_last_query; /* when lp_ni was queried
+ last time */
+ lnet_ni_t *lp_ni; /* interface peer is on */
+ lnet_nid_t lp_nid; /* peer's NID */
+ int lp_refcount; /* # refs */
+ int lp_cpt; /* CPT this peer attached on */
/* # refs from lnet_route_t::lr_gateway */
- int lp_rtr_refcount;
+ int lp_rtr_refcount;
/* returned RC ping features */
- unsigned int lp_ping_feats;
- struct list_head lp_routes; /* routers on this peer */
+ unsigned int lp_ping_feats;
+ struct list_head lp_routes; /* routers on this peer */
lnet_rc_data_t *lp_rcd; /* router checker state */
} lnet_peer_t;
/* peer hash size */
-#define LNET_PEER_HASH_BITS 9
-#define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
+#define LNET_PEER_HASH_BITS 9
+#define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
/* peer hash table */
struct lnet_peer_table {
- int pt_version; /* /proc validity stamp */
- int pt_number; /* # peers extant */
- struct list_head pt_deathrow; /* zombie peers */
- struct list_head *pt_hash; /* NID->peer hash */
+ int pt_version; /* /proc validity stamp */
+ int pt_number; /* # peers extant */
+ struct list_head pt_deathrow; /* zombie peers */
+ struct list_head *pt_hash; /* NID->peer hash */
};
/* peer aliveness is enabled only on routers for peers in a network where the
@@ -492,14 +353,14 @@ struct lnet_peer_table {
(lp)->lp_ni->ni_peertimeout > 0)
typedef struct {
- struct list_head lr_list; /* chain on net */
- struct list_head lr_gwlist; /* chain on gateway */
+ struct list_head lr_list; /* chain on net */
+ struct list_head lr_gwlist; /* chain on gateway */
lnet_peer_t *lr_gateway; /* router node */
- __u32 lr_net; /* remote network number */
- int lr_seq; /* sequence for round-robin */
- unsigned int lr_downis; /* number of down NIs */
- unsigned int lr_hops; /* how far I am */
- unsigned int lr_priority; /* route priority */
+ __u32 lr_net; /* remote network number */
+ int lr_seq; /* sequence for round-robin */
+ unsigned int lr_downis; /* number of down NIs */
+ unsigned int lr_hops; /* how far I am */
+ unsigned int lr_priority; /* route priority */
} lnet_route_t;
#define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
@@ -507,43 +368,37 @@ typedef struct {
#define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
typedef struct {
- struct list_head lrn_list; /* chain on ln_remote_nets_hash */
- struct list_head lrn_routes; /* routes to me */
- __u32 lrn_net; /* my net number */
+ struct list_head lrn_list; /* chain on
+ ln_remote_nets_hash */
+ struct list_head lrn_routes; /* routes to me */
+ __u32 lrn_net; /* my net number */
} lnet_remotenet_t;
+/** lnet message has credit and can be submitted to lnd for send/receive */
+#define LNET_CREDIT_OK 0
+/** lnet message is waiting for credit */
+#define LNET_CREDIT_WAIT 1
+
typedef struct {
- struct list_head rbp_bufs; /* my free buffer pool */
- struct list_head rbp_msgs; /* messages blocking for a buffer */
- int rbp_npages; /* # pages in each buffer */
- int rbp_nbuffers; /* # buffers */
- int rbp_credits; /* # free buffers / blocked messages */
- int rbp_mincredits; /* low water mark */
+ struct list_head rbp_bufs; /* my free buffer pool */
+ struct list_head rbp_msgs; /* messages blocking
+ for a buffer */
+ int rbp_npages; /* # pages in each buffer */
+ int rbp_nbuffers; /* # buffers */
+ int rbp_credits; /* # free buffers /
+ blocked messages */
+ int rbp_mincredits; /* low water mark */
} lnet_rtrbufpool_t;
typedef struct {
- struct list_head rb_list; /* chain on rbp_bufs */
- lnet_rtrbufpool_t *rb_pool; /* owning pool */
- lnet_kiov_t rb_kiov[0]; /* the buffer space */
+ struct list_head rb_list; /* chain on rbp_bufs */
+ lnet_rtrbufpool_t *rb_pool; /* owning pool */
+ lnet_kiov_t rb_kiov[0]; /* the buffer space */
} lnet_rtrbuf_t;
-typedef struct {
- __u32 msgs_alloc;
- __u32 msgs_max;
- __u32 errors;
- __u32 send_count;
- __u32 recv_count;
- __u32 route_count;
- __u32 drop_count;
- __u64 send_length;
- __u64 recv_length;
- __u64 route_length;
- __u64 drop_length;
-} WIRE_ATTR lnet_counters_t;
-
-#define LNET_PEER_HASHSIZE 503 /* prime! */
-
-#define LNET_NRBPOOLS 3 /* # different router buffer pools */
+#define LNET_PEER_HASHSIZE 503 /* prime! */
+
+#define LNET_NRBPOOLS 3 /* # different router buffer pools */
enum {
/* Didn't match anything */
@@ -553,15 +408,16 @@ enum {
/* Must be discarded */
LNET_MATCHMD_DROP = (1 << 2),
/* match and buffer is exhausted */
- LNET_MATCHMD_EXHAUSTED = (1 << 3),
+ LNET_MATCHMD_EXHAUSTED = (1 << 3),
/* match or drop */
- LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
+ LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
};
/* Options for lnet_portal_t::ptl_options */
-#define LNET_PTL_LAZY (1 << 0)
-#define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */
-#define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, request portal */
+#define LNET_PTL_LAZY (1 << 0)
+#define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */
+#define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match,
+ request portal */
/* parameter for matching operations (GET, PUT) */
struct lnet_match_info {
@@ -590,14 +446,14 @@ struct lnet_match_info {
/* portal match table */
struct lnet_match_table {
/* reserved for upcoming patches, CPU partition ID */
- unsigned int mt_cpt;
- unsigned int mt_portal; /* portal index */
+ unsigned int mt_cpt;
+ unsigned int mt_portal; /* portal index */
/* match table is set as "enabled" if there's non-exhausted MD
* attached on mt_mhash, it's only valid for wildcard portal */
- unsigned int mt_enabled;
+ unsigned int mt_enabled;
/* bitmap to flag whether MEs on mt_hash are exhausted or not */
- __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
- struct list_head *mt_mhash; /* matching hash */
+ __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
+ struct list_head *mt_mhash; /* matching hash */
};
/* these are only useful for wildcard portal */
@@ -611,22 +467,22 @@ struct lnet_match_table {
#define LNET_PTL_ROTOR_HASH_RT 3
typedef struct lnet_portal {
- spinlock_t ptl_lock;
- unsigned int ptl_index; /* portal ID, reserved */
+ spinlock_t ptl_lock;
+ unsigned int ptl_index; /* portal ID, reserved */
/* flags on this portal: lazy, unique... */
- unsigned int ptl_options;
+ unsigned int ptl_options;
/* list of messages which are stealing buffer */
- struct list_head ptl_msg_stealing;
+ struct list_head ptl_msg_stealing;
/* messages blocking for MD */
- struct list_head ptl_msg_delayed;
+ struct list_head ptl_msg_delayed;
/* Match table for each CPT */
struct lnet_match_table **ptl_mtables;
/* spread rotor of incoming "PUT" */
- unsigned int ptl_rotor;
+ unsigned int ptl_rotor;
/* # active entries for this portal */
- int ptl_mt_nmaps;
+ int ptl_mt_nmaps;
/* array of active entries' cpu-partition-id */
- int ptl_mt_maps[0];
+ int ptl_mt_maps[0];
} lnet_portal_t;
#define LNET_LH_HASH_BITS 12
@@ -635,28 +491,22 @@ typedef struct lnet_portal {
/* resource container (ME, MD, EQ) */
struct lnet_res_container {
- unsigned int rec_type; /* container type */
- __u64 rec_lh_cookie; /* cookie generator */
- struct list_head rec_active; /* active resource list */
- struct list_head *rec_lh_hash; /* handle hash */
-#ifdef LNET_USE_LIB_FREELIST
- lnet_freelist_t rec_freelist; /* freelist for resources */
-#endif
+ unsigned int rec_type; /* container type */
+ __u64 rec_lh_cookie; /* cookie generator */
+ struct list_head rec_active; /* active resource list */
+ struct list_head *rec_lh_hash; /* handle hash */
};
/* message container */
struct lnet_msg_container {
- int msc_init; /* initialized or not */
+ int msc_init; /* initialized or not */
/* max # threads finalizing */
- int msc_nfinalizers;
+ int msc_nfinalizers;
/* msgs waiting to complete finalizing */
- struct list_head msc_finalizing;
- struct list_head msc_active; /* active message list */
+ struct list_head msc_finalizing;
+ struct list_head msc_active; /* active message list */
/* threads doing finalization */
void **msc_finalizers;
-#ifdef LNET_USE_LIB_FREELIST
- lnet_freelist_t msc_freelist; /* freelist for messages */
-#endif
};
/* Router Checker states */
@@ -666,15 +516,15 @@ struct lnet_msg_container {
typedef struct {
/* CPU partition table of LNet */
- struct cfs_cpt_table *ln_cpt_table;
+ struct cfs_cpt_table *ln_cpt_table;
/* number of CPTs in ln_cpt_table */
- unsigned int ln_cpt_number;
- unsigned int ln_cpt_bits;
+ unsigned int ln_cpt_number;
+ unsigned int ln_cpt_bits;
/* protect LNet resources (ME/MD/EQ) */
- struct cfs_percpt_lock *ln_res_lock;
+ struct cfs_percpt_lock *ln_res_lock;
/* # portals */
- int ln_nportals;
+ int ln_nportals;
/* the vector of portals */
lnet_portal_t **ln_portals;
/* percpt ME containers */
@@ -683,77 +533,78 @@ typedef struct {
struct lnet_res_container **ln_md_containers;
/* Event Queue container */
- struct lnet_res_container ln_eq_container;
- wait_queue_head_t ln_eq_waitq;
- spinlock_t ln_eq_wait_lock;
- unsigned int ln_remote_nets_hbits;
+ struct lnet_res_container ln_eq_container;
+ wait_queue_head_t ln_eq_waitq;
+ spinlock_t ln_eq_wait_lock;
+ unsigned int ln_remote_nets_hbits;
/* protect NI, peer table, credits, routers, rtrbuf... */
- struct cfs_percpt_lock *ln_net_lock;
+ struct cfs_percpt_lock *ln_net_lock;
/* percpt message containers for active/finalizing/freed message */
struct lnet_msg_container **ln_msg_containers;
lnet_counters_t **ln_counters;
struct lnet_peer_table **ln_peer_tables;
/* failure simulation */
- struct list_head ln_test_peers;
+ struct list_head ln_test_peers;
- struct list_head ln_nis; /* LND instances */
+ struct list_head ln_nis; /* LND instances */
/* NIs bond on specific CPT(s) */
- struct list_head ln_nis_cpt;
+ struct list_head ln_nis_cpt;
/* dying LND instances */
- struct list_head ln_nis_zombie;
- lnet_ni_t *ln_loni; /* the loopback NI */
+ struct list_head ln_nis_zombie;
+ lnet_ni_t *ln_loni; /* the loopback NI */
/* NI to wait for events in */
- lnet_ni_t *ln_eq_waitni;
+ lnet_ni_t *ln_eq_waitni;
/* remote networks with routes to them */
- struct list_head *ln_remote_nets_hash;
+ struct list_head *ln_remote_nets_hash;
/* validity stamp */
- __u64 ln_remote_nets_version;
+ __u64 ln_remote_nets_version;
/* list of all known routers */
- struct list_head ln_routers;
+ struct list_head ln_routers;
/* validity stamp */
- __u64 ln_routers_version;
+ __u64 ln_routers_version;
/* percpt router buffer pools */
lnet_rtrbufpool_t **ln_rtrpools;
- lnet_handle_md_t ln_ping_target_md;
- lnet_handle_eq_t ln_ping_target_eq;
- lnet_ping_info_t *ln_ping_info;
+ lnet_handle_md_t ln_ping_target_md;
+ lnet_handle_eq_t ln_ping_target_eq;
+ lnet_ping_info_t *ln_ping_info;
/* router checker startup/shutdown state */
- int ln_rc_state;
+ int ln_rc_state;
/* router checker's event queue */
- lnet_handle_eq_t ln_rc_eqh;
+ lnet_handle_eq_t ln_rc_eqh;
/* rcd still pending on net */
- struct list_head ln_rcd_deathrow;
+ struct list_head ln_rcd_deathrow;
/* rcd ready for free */
- struct list_head ln_rcd_zombie;
+ struct list_head ln_rcd_zombie;
/* serialise startup/shutdown */
- struct semaphore ln_rc_signal;
+ struct semaphore ln_rc_signal;
- struct mutex ln_api_mutex;
- struct mutex ln_lnd_mutex;
- int ln_init; /* LNetInit() called? */
+ struct mutex ln_api_mutex;
+ struct mutex ln_lnd_mutex;
+ int ln_init; /* lnet_init()
+ called? */
/* Have I called LNetNIInit myself? */
- int ln_niinit_self;
+ int ln_niinit_self;
/* LNetNIInit/LNetNIFini counter */
- int ln_refcount;
+ int ln_refcount;
/* shutdown in progress */
- int ln_shutdown;
+ int ln_shutdown;
- int ln_routing; /* am I a router? */
- lnet_pid_t ln_pid; /* requested pid */
+ int ln_routing; /* am I a router? */
+ lnet_pid_t ln_pid; /* requested pid */
/* uniquely identifies this ni in this epoch */
- __u64 ln_interface_cookie;
+ __u64 ln_interface_cookie;
/* registered LNDs */
- struct list_head ln_lnds;
+ struct list_head ln_lnds;
/* space for network names */
- char *ln_network_tokens;
- int ln_network_tokens_nob;
+ char *ln_network_tokens;
+ int ln_network_tokens_nob;
/* test protocol compatibility flags */
- int ln_testprotocompat;
+ int ln_testprotocompat;
} lnet_t;
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/linux/api-support.h b/kernel/drivers/staging/lustre/include/linux/lnet/linux/api-support.h
deleted file mode 100644
index e237ad6af..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/linux/api-support.h
+++ /dev/null
@@ -1,42 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LINUX_API_SUPPORT_H__
-#define __LINUX_API_SUPPORT_H__
-
-#ifndef __LNET_API_SUPPORT_H__
-#error Do not #include this file directly. #include <lnet /api-support.h> instead
-#endif
-
-#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h b/kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h
deleted file mode 100644
index 0f8f04d1e..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-lnet.h
+++ /dev/null
@@ -1,71 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LNET_LINUX_LIB_LNET_H__
-#define __LNET_LINUX_LIB_LNET_H__
-
-#ifndef __LNET_LIB_LNET_H__
-#error Do not #include this file directly. #include <linux/lnet/lib-lnet.h> instead
-#endif
-
-# include <asm/page.h>
-# include <linux/string.h>
-# include <asm/io.h>
-#include "../../libcfs/libcfs.h"
-
-static inline __u64
-lnet_page2phys(struct page *p)
-{
- /* compiler optimizer will elide unused branches */
-
- switch (sizeof(typeof(page_to_phys(p)))) {
- case 4:
- /* page_to_phys returns a 32 bit physical address. This must
- * be a 32 bit machine with <= 4G memory and we must ensure we
- * don't sign extend when converting to 64 bits. */
- return (unsigned long)page_to_phys(p);
-
- case 8:
- /* page_to_phys returns a 64 bit physical address :) */
- return page_to_phys(p);
-
- default:
- LBUG();
- return 0;
- }
-}
-
-#define LNET_ROUTER
-
-#endif /* __LNET_LINUX_LIB_LNET_H__ */
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-types.h b/kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-types.h
deleted file mode 100644
index 669e8c038..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/linux/lib-types.h
+++ /dev/null
@@ -1,45 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LNET_LINUX_LIB_TYPES_H__
-#define __LNET_LINUX_LIB_TYPES_H__
-
-#ifndef __LNET_LIB_TYPES_H__
-#error Do not #include this file directly. #include <linux/lnet/lib-types.h> instead
-#endif
-
-# include <linux/uio.h>
-# include <linux/types.h>
-
-#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/linux/lnet.h b/kernel/drivers/staging/lustre/include/linux/lnet/linux/lnet.h
deleted file mode 100644
index 1e888f1ef..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/linux/lnet.h
+++ /dev/null
@@ -1,56 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LNET_LINUX_LNET_H__
-#define __LNET_LINUX_LNET_H__
-
-#ifndef __LNET_H__
-#error Do not #include this file directly. #include <linux/lnet/lnet.h> instead
-#endif
-
-/*
- * lnet.h
- *
- * User application interface file
- */
-
-#include <linux/uio.h>
-#include <linux/types.h>
-
-#define cfs_tcp_sendpage(sk, page, offset, size, flags) \
- tcp_sendpage(sk, page, offset, size, flags)
-
-#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h b/kernel/drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h
deleted file mode 100644
index 2dee1b97f..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/lnet-sysctl.h
+++ /dev/null
@@ -1,49 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LNET_SYSCTL_H__
-#define __LNET_SYSCTL_H__
-
-#if defined(CONFIG_SYSCTL)
-
-#define CTL_KRANAL 201
-#define CTL_O2IBLND 205
-#define CTL_PTLLND 206
-#define CTL_QSWNAL 207
-#define CTL_SOCKLND 208
-#define CTL_GNILND 210
-
-#endif
-
-#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/lnet.h b/kernel/drivers/staging/lustre/include/linux/lnet/lnet.h
index 75c0ab919..5d1559a26 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/lnet.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/lnet.h
@@ -15,21 +15,19 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012 - 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*/
#ifndef __LNET_H__
@@ -40,12 +38,7 @@
*
* User application interface file
*/
-#include "linux/lnet.h"
-
#include "types.h"
-#include "api.h"
-
-#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */
-#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */
+#include "nidstr.h"
#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/lnetctl.h b/kernel/drivers/staging/lustre/include/linux/lnet/lnetctl.h
index 98181d389..bdd69b2af 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/lnetctl.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/lnetctl.h
@@ -14,12 +14,11 @@
* along with Portals; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * header for libptlctl.a
+ * header for lnet ioctl
*/
-#ifndef _PTLCTL_H_
-#define _PTLCTL_H_
+#ifndef _LNETCTL_H_
+#define _LNETCTL_H_
-#include "../libcfs/libcfs.h"
#include "types.h"
#define LNET_DEV_ID 0
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/lnetst.h b/kernel/drivers/staging/lustre/include/linux/lnet/lnetst.h
index 885f708d4..fd1e0fd36 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/lnetst.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/lnetst.h
@@ -15,11 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
@@ -27,23 +23,21 @@
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, Intel Corporation.
+ * Copyright (c) 2011 - 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*
* lnet/include/lnet/lnetst.h
*
- * Author: Liang Zhen <liangzhen@clusterfs.com>
+ * Author: Liang Zhen <liang.zhen@intel.com>
*/
#ifndef __LNET_ST_H__
#define __LNET_ST_H__
-#include "../libcfs/libcfs.h"
-#include "lnet.h"
-#include "lib-types.h"
+#include <linux/types.h>
#define LST_FEAT_NONE (0)
#define LST_FEAT_BULK_LEN (1 << 0) /* enable variable page size */
@@ -51,99 +45,107 @@
#define LST_FEATS_EMPTY (LST_FEAT_NONE)
#define LST_FEATS_MASK (LST_FEAT_NONE | LST_FEAT_BULK_LEN)
-#define LST_NAME_SIZE 32 /* max name buffer length */
-
-#define LSTIO_DEBUG 0xC00 /* debug */
-#define LSTIO_SESSION_NEW 0xC01 /* create session */
-#define LSTIO_SESSION_END 0xC02 /* end session */
-#define LSTIO_SESSION_INFO 0xC03 /* query session */
-#define LSTIO_GROUP_ADD 0xC10 /* add group */
-#define LSTIO_GROUP_LIST 0xC11 /* list all groups in session */
-#define LSTIO_GROUP_INFO 0xC12 /* query default information of specified group */
-#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_BATCH_ADD 0xC20 /* add batch */
-#define LSTIO_BATCH_START 0xC21 /* start batch */
-#define LSTIO_BATCH_STOP 0xC22 /* stop batch */
-#define LSTIO_BATCH_DEL 0xC23 /* delete batch */
-#define LSTIO_BATCH_LIST 0xC24 /* show all batches in the session */
-#define LSTIO_BATCH_INFO 0xC25 /* show defail of specified batch */
-#define LSTIO_TEST_ADD 0xC26 /* add test (to batch) */
-#define LSTIO_BATCH_QUERY 0xC27 /* query batch status */
-#define LSTIO_STAT_QUERY 0xC30 /* get stats */
-
-typedef struct {
- lnet_nid_t ses_nid; /* nid of console node */
- __u64 ses_stamp; /* time stamp */
-} lst_sid_t; /*** session id */
+#define LST_NAME_SIZE 32 /* max name buffer length */
+
+#define LSTIO_DEBUG 0xC00 /* debug */
+#define LSTIO_SESSION_NEW 0xC01 /* create session */
+#define LSTIO_SESSION_END 0xC02 /* end session */
+#define LSTIO_SESSION_INFO 0xC03 /* query session */
+#define LSTIO_GROUP_ADD 0xC10 /* add group */
+#define LSTIO_GROUP_LIST 0xC11 /* list all groups in session */
+#define LSTIO_GROUP_INFO 0xC12 /* query default information of
+ * specified group */
+#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_BATCH_ADD 0xC20 /* add batch */
+#define LSTIO_BATCH_START 0xC21 /* start batch */
+#define LSTIO_BATCH_STOP 0xC22 /* stop batch */
+#define LSTIO_BATCH_DEL 0xC23 /* delete batch */
+#define LSTIO_BATCH_LIST 0xC24 /* show all batches in the session */
+#define LSTIO_BATCH_INFO 0xC25 /* show defail of specified batch */
+#define LSTIO_TEST_ADD 0xC26 /* add test (to batch) */
+#define LSTIO_BATCH_QUERY 0xC27 /* query batch status */
+#define LSTIO_STAT_QUERY 0xC30 /* get stats */
+
+typedef struct {
+ lnet_nid_t ses_nid; /* nid of console node */
+ __u64 ses_stamp; /* time stamp */
+} lst_sid_t; /*** session id */
extern lst_sid_t LST_INVALID_SID;
typedef struct {
- __u64 bat_id; /* unique id in session */
-} lst_bid_t; /*** batch id (group of tests) */
+ __u64 bat_id; /* unique id in session */
+} lst_bid_t; /*** batch id (group of tests) */
/* Status of test node */
-#define LST_NODE_ACTIVE 0x1 /* node in this session */
-#define LST_NODE_BUSY 0x2 /* node is taken by other session */
-#define LST_NODE_DOWN 0x4 /* node is down */
-#define LST_NODE_UNKNOWN 0x8 /* node not in session */
+#define LST_NODE_ACTIVE 0x1 /* node in this session */
+#define LST_NODE_BUSY 0x2 /* node is taken by other session */
+#define LST_NODE_DOWN 0x4 /* node is down */
+#define LST_NODE_UNKNOWN 0x8 /* node not in session */
typedef struct {
- lnet_process_id_t nde_id; /* id of node */
- int nde_state; /* state of node */
-} lstcon_node_ent_t; /*** node entry, for list_group command */
+ lnet_process_id_t nde_id; /* id of node */
+ int nde_state; /* state of node */
+} lstcon_node_ent_t; /*** node entry, for list_group command */
typedef struct {
- int nle_nnode; /* # of nodes */
- int nle_nactive; /* # of active nodes */
- int nle_nbusy; /* # of busy nodes */
- int nle_ndown; /* # of down nodes */
- int nle_nunknown; /* # of unknown nodes */
-} lstcon_ndlist_ent_t; /*** node_list entry, for list_batch command */
+ int nle_nnode; /* # of nodes */
+ int nle_nactive; /* # of active nodes */
+ int nle_nbusy; /* # of busy nodes */
+ int nle_ndown; /* # of down nodes */
+ int nle_nunknown; /* # of unknown nodes */
+} lstcon_ndlist_ent_t; /*** node_list entry, for list_batch command */
typedef struct {
- int tse_type; /* test type */
- int tse_loop; /* loop count */
- int tse_concur; /* concurrency of test */
-} lstcon_test_ent_t; /*** test summary entry, for list_batch command */
+ int tse_type; /* test type */
+ int tse_loop; /* loop count */
+ int tse_concur; /* concurrency of test */
+} lstcon_test_ent_t; /*** test summary entry, for
+ *** list_batch command */
typedef struct {
- int bae_state; /* batch status */
- int bae_timeout; /* batch timeout */
- int bae_ntest; /* # of tests in the batch */
-} lstcon_batch_ent_t; /*** batch summary entry, for list_batch command */
+ int bae_state; /* batch status */
+ int bae_timeout; /* batch timeout */
+ int bae_ntest; /* # of tests in the batch */
+} lstcon_batch_ent_t; /*** batch summary entry, for
+ *** list_batch command */
typedef struct {
- lstcon_ndlist_ent_t tbe_cli_nle; /* client (group) node_list entry */
- lstcon_ndlist_ent_t tbe_srv_nle; /* server (group) node_list entry */
+ lstcon_ndlist_ent_t tbe_cli_nle; /* client (group) node_list
+ * entry */
+ lstcon_ndlist_ent_t tbe_srv_nle; /* server (group) node_list
+ * entry */
union {
- lstcon_test_ent_t tbe_test; /* test entry */
- lstcon_batch_ent_t tbe_batch; /* batch entry */
+ lstcon_test_ent_t tbe_test; /* test entry */
+ lstcon_batch_ent_t tbe_batch; /* batch entry */
} u;
-} lstcon_test_batch_ent_t; /*** test/batch verbose information entry,
- *** for list_batch command */
+} lstcon_test_batch_ent_t; /*** test/batch verbose information entry,
+ *** for list_batch command */
typedef struct {
- struct list_head rpe_link; /* link chain */
- lnet_process_id_t rpe_peer; /* peer's id */
- struct timeval rpe_stamp; /* time stamp of RPC */
- int rpe_state; /* peer's state */
- int rpe_rpc_errno; /* RPC errno */
+ struct list_head rpe_link; /* link chain */
+ lnet_process_id_t rpe_peer; /* peer's id */
+ struct timeval rpe_stamp; /* time stamp of RPC */
+ int rpe_state; /* peer's state */
+ int rpe_rpc_errno; /* RPC errno */
- lst_sid_t rpe_sid; /* peer's session id */
- int rpe_fwk_errno; /* framework errno */
- int rpe_priv[4]; /* private data */
- char rpe_payload[0]; /* private reply payload */
+ lst_sid_t rpe_sid; /* peer's session id */
+ int rpe_fwk_errno; /* framework errno */
+ int rpe_priv[4]; /* private data */
+ char rpe_payload[0]; /* private reply payload */
} lstcon_rpc_ent_t;
typedef struct {
- int trs_rpc_stat[4]; /* RPCs stat (0: total, 1: failed, 2: finished, 4: reserved */
- int trs_rpc_errno; /* RPC errno */
- int trs_fwk_stat[8]; /* framework stat */
- int trs_fwk_errno; /* errno of the first remote error */
- void *trs_fwk_private; /* private framework stat */
+ int trs_rpc_stat[4]; /* RPCs stat (0: total
+ 1: failed
+ 2: finished
+ 4: reserved */
+ int trs_rpc_errno; /* RPC errno */
+ int trs_fwk_stat[8]; /* framework stat */
+ int trs_fwk_errno; /* errno of the first remote error */
+ void *trs_fwk_private; /* private framework stat */
} lstcon_trans_stat_t;
static inline int
@@ -238,237 +240,265 @@ lstcon_statqry_stat_failure(lstcon_trans_stat_t *stat, int inc)
/* create a session */
typedef struct {
- int lstio_ses_key; /* IN: local key */
- int lstio_ses_timeout; /* IN: session timeout */
- int lstio_ses_force; /* IN: force create ? */
+ int lstio_ses_key; /* IN: local key */
+ int lstio_ses_timeout; /* IN: session timeout */
+ int lstio_ses_force; /* IN: force create ? */
/** IN: session features */
- unsigned lstio_ses_feats;
- lst_sid_t *lstio_ses_idp; /* OUT: session id */
- int lstio_ses_nmlen; /* IN: name length */
- char *lstio_ses_namep; /* IN: session name */
+ unsigned lstio_ses_feats;
+ lst_sid_t *lstio_ses_idp; /* OUT: session id */
+ int lstio_ses_nmlen; /* IN: name length */
+ char *lstio_ses_namep; /* IN: session name */
} lstio_session_new_args_t;
/* query current session */
typedef struct {
- lst_sid_t *lstio_ses_idp; /* OUT: session id */
- int *lstio_ses_keyp; /* OUT: local key */
+ lst_sid_t *lstio_ses_idp; /* OUT: session id */
+ int *lstio_ses_keyp; /* OUT: local key */
/** OUT: session features */
- unsigned *lstio_ses_featp;
- lstcon_ndlist_ent_t *lstio_ses_ndinfo; /* OUT: */
- int lstio_ses_nmlen; /* IN: name length */
- char *lstio_ses_namep; /* OUT: session name */
+ unsigned *lstio_ses_featp;
+ lstcon_ndlist_ent_t *lstio_ses_ndinfo; /* OUT: */
+ int lstio_ses_nmlen; /* IN: name length */
+ char *lstio_ses_namep; /* OUT: session name */
} lstio_session_info_args_t;
/* delete a session */
typedef struct {
- int lstio_ses_key; /* IN: session key */
+ int lstio_ses_key; /* IN: session key */
} lstio_session_end_args_t;
-#define LST_OPC_SESSION 1
-#define LST_OPC_GROUP 2
-#define LST_OPC_NODES 3
+#define LST_OPC_SESSION 1
+#define LST_OPC_GROUP 2
+#define LST_OPC_NODES 3
#define LST_OPC_BATCHCLI 4
#define LST_OPC_BATCHSRV 5
typedef struct {
- int lstio_dbg_key; /* IN: session key */
- int lstio_dbg_type; /* IN: debug sessin|batch|group|nodes list */
- int lstio_dbg_flags; /* IN: reserved debug flags */
- int lstio_dbg_timeout; /* IN: timeout of debug */
-
- int lstio_dbg_nmlen; /* IN: len of name */
- char *lstio_dbg_namep; /* IN: name of group|batch */
- int lstio_dbg_count; /* IN: # of test nodes to debug */
- lnet_process_id_t *lstio_dbg_idsp; /* IN: id of test nodes */
- struct list_head *lstio_dbg_resultp; /* OUT: list head of result buffer */
+ int lstio_dbg_key; /* IN: session key */
+ int lstio_dbg_type; /* IN: debug
+ session|batch|
+ group|nodes
+ list */
+ int lstio_dbg_flags; /* IN: reserved debug
+ flags */
+ int lstio_dbg_timeout; /* IN: timeout of
+ debug */
+ int lstio_dbg_nmlen; /* IN: len of name */
+ char *lstio_dbg_namep; /* IN: name of
+ group|batch */
+ int lstio_dbg_count; /* IN: # of test nodes
+ to debug */
+ lnet_process_id_t *lstio_dbg_idsp; /* IN: id of test
+ nodes */
+ struct list_head *lstio_dbg_resultp; /* OUT: list head of
+ result buffer */
} lstio_debug_args_t;
typedef struct {
- int lstio_grp_key; /* IN: session key */
- int lstio_grp_nmlen; /* IN: name length */
- char *lstio_grp_namep; /* IN: group name */
+ int lstio_grp_key; /* IN: session key */
+ int lstio_grp_nmlen; /* IN: name length */
+ char *lstio_grp_namep; /* IN: group name */
} lstio_group_add_args_t;
typedef struct {
- int lstio_grp_key; /* IN: session key */
- int lstio_grp_nmlen; /* IN: name length */
- char *lstio_grp_namep; /* IN: group name */
+ int lstio_grp_key; /* IN: session key */
+ int lstio_grp_nmlen; /* IN: name length */
+ char *lstio_grp_namep; /* IN: group name */
} lstio_group_del_args_t;
-#define LST_GROUP_CLEAN 1 /* remove inactive nodes in the group */
-#define LST_GROUP_REFRESH 2 /* refresh inactive nodes in the group */
-#define LST_GROUP_RMND 3 /* delete nodes from the group */
-
-typedef struct {
- int lstio_grp_key; /* IN: session key */
- int lstio_grp_opc; /* IN: OPC */
- int lstio_grp_args; /* IN: arguments */
- int lstio_grp_nmlen; /* IN: name length */
- char *lstio_grp_namep; /* IN: group name */
- int lstio_grp_count; /* IN: # of nodes id */
- lnet_process_id_t *lstio_grp_idsp; /* IN: array of nodes */
- struct list_head *lstio_grp_resultp; /* OUT: list head of result buffer */
+#define LST_GROUP_CLEAN 1 /* remove inactive nodes in the group */
+#define LST_GROUP_REFRESH 2 /* refresh inactive nodes
+ * in the group */
+#define LST_GROUP_RMND 3 /* delete nodes from the group */
+
+typedef struct {
+ int lstio_grp_key; /* IN: session key */
+ int lstio_grp_opc; /* IN: OPC */
+ int lstio_grp_args; /* IN: arguments */
+ int lstio_grp_nmlen; /* IN: name length */
+ char *lstio_grp_namep; /* IN: group name */
+ int lstio_grp_count; /* IN: # of nodes id */
+ lnet_process_id_t *lstio_grp_idsp; /* IN: array of nodes */
+ struct list_head *lstio_grp_resultp; /* OUT: list head of
+ result buffer */
} lstio_group_update_args_t;
typedef struct {
- int lstio_grp_key; /* IN: session key */
- int lstio_grp_nmlen; /* IN: name length */
- char *lstio_grp_namep; /* IN: group name */
- int lstio_grp_count; /* IN: # of nodes */
+ int lstio_grp_key; /* IN: session key */
+ int lstio_grp_nmlen; /* IN: name length */
+ char *lstio_grp_namep; /* IN: group name */
+ int lstio_grp_count; /* IN: # of nodes */
/** OUT: session features */
- unsigned *lstio_grp_featp;
- lnet_process_id_t *lstio_grp_idsp; /* IN: nodes */
- struct list_head *lstio_grp_resultp; /* OUT: list head of result buffer */
+ unsigned *lstio_grp_featp;
+ lnet_process_id_t *lstio_grp_idsp; /* IN: nodes */
+ struct list_head *lstio_grp_resultp; /* OUT: list head of
+ result buffer */
} lstio_group_nodes_args_t;
typedef struct {
- int lstio_grp_key; /* IN: session key */
- int lstio_grp_idx; /* IN: group idx */
- int lstio_grp_nmlen; /* IN: name len */
- char *lstio_grp_namep; /* OUT: name */
+ int lstio_grp_key; /* IN: session key */
+ int lstio_grp_idx; /* IN: group idx */
+ int lstio_grp_nmlen; /* IN: name len */
+ char *lstio_grp_namep; /* OUT: name */
} lstio_group_list_args_t;
typedef struct {
- int lstio_grp_key; /* IN: session key */
- int lstio_grp_nmlen; /* IN: name len */
- char *lstio_grp_namep; /* IN: name */
- lstcon_ndlist_ent_t *lstio_grp_entp; /* OUT: description of group */
-
- int *lstio_grp_idxp; /* IN/OUT: node index */
- int *lstio_grp_ndentp; /* IN/OUT: # of nodent */
- lstcon_node_ent_t *lstio_grp_dentsp; /* OUT: nodent array */
+ int lstio_grp_key; /* IN: session key */
+ int lstio_grp_nmlen; /* IN: name len */
+ char *lstio_grp_namep; /* IN: name */
+ lstcon_ndlist_ent_t *lstio_grp_entp; /* OUT: description of
+ group */
+ int *lstio_grp_idxp; /* IN/OUT: node index */
+ int *lstio_grp_ndentp; /* IN/OUT: # of nodent */
+ lstcon_node_ent_t *lstio_grp_dentsp; /* OUT: nodent array */
} lstio_group_info_args_t;
-#define LST_DEFAULT_BATCH "batch" /* default batch name */
+#define LST_DEFAULT_BATCH "batch" /* default batch name */
typedef struct {
- int lstio_bat_key; /* IN: session key */
- int lstio_bat_nmlen; /* IN: name length */
- char *lstio_bat_namep; /* IN: batch name */
+ int lstio_bat_key; /* IN: session key */
+ int lstio_bat_nmlen; /* IN: name length */
+ char *lstio_bat_namep; /* IN: batch name */
} lstio_batch_add_args_t;
typedef struct {
- int lstio_bat_key; /* IN: session key */
- int lstio_bat_nmlen; /* IN: name length */
- char *lstio_bat_namep; /* IN: batch name */
+ int lstio_bat_key; /* IN: session key */
+ int lstio_bat_nmlen; /* IN: name length */
+ char *lstio_bat_namep; /* IN: batch name */
} lstio_batch_del_args_t;
typedef struct {
- int lstio_bat_key; /* IN: session key */
- int lstio_bat_timeout; /* IN: timeout for the batch */
- int lstio_bat_nmlen; /* IN: name length */
- char *lstio_bat_namep; /* IN: batch name */
- struct list_head *lstio_bat_resultp; /* OUT: list head of result buffer */
+ int lstio_bat_key; /* IN: session key */
+ int lstio_bat_timeout; /* IN: timeout for
+ the batch */
+ int lstio_bat_nmlen; /* IN: name length */
+ char *lstio_bat_namep; /* IN: batch name */
+ struct list_head *lstio_bat_resultp; /* OUT: list head of
+ result buffer */
} lstio_batch_run_args_t;
typedef struct {
- int lstio_bat_key; /* IN: session key */
- int lstio_bat_force; /* IN: abort unfinished test RPC */
- int lstio_bat_nmlen; /* IN: name length */
- char *lstio_bat_namep; /* IN: batch name */
- struct list_head *lstio_bat_resultp; /* OUT: list head of result buffer */
+ int lstio_bat_key; /* IN: session key */
+ int lstio_bat_force; /* IN: abort unfinished
+ test RPC */
+ int lstio_bat_nmlen; /* IN: name length */
+ char *lstio_bat_namep; /* IN: batch name */
+ struct list_head *lstio_bat_resultp; /* OUT: list head of
+ result buffer */
} lstio_batch_stop_args_t;
typedef struct {
- int lstio_bat_key; /* IN: session key */
- int lstio_bat_testidx; /* IN: test index */
- int lstio_bat_client; /* IN: is test client? */
- int lstio_bat_timeout; /* IN: timeout for waiting */
- int lstio_bat_nmlen; /* IN: name length */
- char *lstio_bat_namep; /* IN: batch name */
- struct list_head *lstio_bat_resultp; /* OUT: list head of result buffer */
+ int lstio_bat_key; /* IN: session key */
+ int lstio_bat_testidx; /* IN: test index */
+ int lstio_bat_client; /* IN: we testing
+ client? */
+ int lstio_bat_timeout; /* IN: timeout for
+ waiting */
+ int lstio_bat_nmlen; /* IN: name length */
+ char *lstio_bat_namep; /* IN: batch name */
+ struct list_head *lstio_bat_resultp; /* OUT: list head of
+ result buffer */
} lstio_batch_query_args_t;
typedef struct {
- int lstio_bat_key; /* IN: session key */
- int lstio_bat_idx; /* IN: index */
- int lstio_bat_nmlen; /* IN: name length */
- char *lstio_bat_namep; /* IN: batch name */
+ int lstio_bat_key; /* IN: session key */
+ int lstio_bat_idx; /* IN: index */
+ int lstio_bat_nmlen; /* IN: name length */
+ char *lstio_bat_namep; /* IN: batch name */
} lstio_batch_list_args_t;
typedef struct {
- int lstio_bat_key; /* IN: session key */
- int lstio_bat_nmlen; /* IN: name length */
- char *lstio_bat_namep; /* IN: name */
- int lstio_bat_server; /* IN: query server or not */
- int lstio_bat_testidx; /* IN: test index */
- lstcon_test_batch_ent_t *lstio_bat_entp; /* OUT: batch ent */
+ int lstio_bat_key; /* IN: session key */
+ int lstio_bat_nmlen; /* IN: name length */
+ char *lstio_bat_namep; /* IN: name */
+ int lstio_bat_server; /* IN: query server
+ or not */
+ int lstio_bat_testidx; /* IN: test index */
+ lstcon_test_batch_ent_t *lstio_bat_entp; /* OUT: batch ent */
- int *lstio_bat_idxp; /* IN/OUT: index of node */
- int *lstio_bat_ndentp; /* IN/OUT: # of nodent */
- lstcon_node_ent_t *lstio_bat_dentsp; /* array of nodent */
+ int *lstio_bat_idxp; /* IN/OUT: index of node */
+ int *lstio_bat_ndentp; /* IN/OUT: # of nodent */
+ lstcon_node_ent_t *lstio_bat_dentsp; /* array of nodent */
} lstio_batch_info_args_t;
/* add stat in session */
typedef struct {
- int lstio_sta_key; /* IN: session key */
- int lstio_sta_timeout; /* IN: timeout for stat request */
- int lstio_sta_nmlen; /* IN: group name length */
- char *lstio_sta_namep; /* IN: group name */
- int lstio_sta_count; /* IN: # of pid */
- lnet_process_id_t *lstio_sta_idsp; /* IN: pid */
- struct list_head *lstio_sta_resultp; /* OUT: list head of result buffer */
+ int lstio_sta_key; /* IN: session key */
+ int lstio_sta_timeout; /* IN: timeout for
+ stat request */
+ int lstio_sta_nmlen; /* IN: group name
+ length */
+ char *lstio_sta_namep; /* IN: group name */
+ int lstio_sta_count; /* IN: # of pid */
+ lnet_process_id_t *lstio_sta_idsp; /* IN: pid */
+ struct list_head *lstio_sta_resultp; /* OUT: list head of
+ result buffer */
} lstio_stat_args_t;
typedef enum {
- LST_TEST_BULK = 1,
- LST_TEST_PING = 2
+ LST_TEST_BULK = 1,
+ LST_TEST_PING = 2
} lst_test_type_t;
/* create a test in a batch */
-#define LST_MAX_CONCUR 1024 /* Max concurrency of test */
-
-typedef struct {
- int lstio_tes_key; /* IN: session key */
- int lstio_tes_bat_nmlen; /* IN: batch name len */
- char *lstio_tes_bat_name; /* IN: batch name */
- int lstio_tes_type; /* IN: test type */
- int lstio_tes_oneside; /* IN: one sided test */
- int lstio_tes_loop; /* IN: loop count */
- int lstio_tes_concur; /* IN: concurrency */
-
- int lstio_tes_dist; /* IN: node distribution in destination groups */
- int lstio_tes_span; /* IN: node span in destination groups */
- int lstio_tes_sgrp_nmlen; /* IN: source group name length */
- char *lstio_tes_sgrp_name; /* IN: group name */
- int lstio_tes_dgrp_nmlen; /* IN: destination group name length */
- char *lstio_tes_dgrp_name; /* IN: group name */
-
- int lstio_tes_param_len; /* IN: param buffer len */
- void *lstio_tes_param; /* IN: parameter for specified test:
- lstio_bulk_param_t,
- lstio_ping_param_t,
- ... more */
- int *lstio_tes_retp; /* OUT: private returned value */
- struct list_head *lstio_tes_resultp; /* OUT: list head of result buffer */
+#define LST_MAX_CONCUR 1024 /* Max concurrency of test */
+
+typedef struct {
+ int lstio_tes_key; /* IN: session key */
+ int lstio_tes_bat_nmlen; /* IN: batch name len */
+ char *lstio_tes_bat_name; /* IN: batch name */
+ int lstio_tes_type; /* IN: test type */
+ int lstio_tes_oneside; /* IN: one sided test */
+ int lstio_tes_loop; /* IN: loop count */
+ int lstio_tes_concur; /* IN: concurrency */
+
+ int lstio_tes_dist; /* IN: node distribution in
+ destination groups */
+ int lstio_tes_span; /* IN: node span in
+ destination groups */
+ int lstio_tes_sgrp_nmlen; /* IN: source group
+ name length */
+ char *lstio_tes_sgrp_name; /* IN: group name */
+ int lstio_tes_dgrp_nmlen; /* IN: destination group
+ name length */
+ char *lstio_tes_dgrp_name; /* IN: group name */
+
+ int lstio_tes_param_len; /* IN: param buffer len */
+ void *lstio_tes_param; /* IN: parameter for specified
+ test:
+ lstio_bulk_param_t,
+ lstio_ping_param_t,
+ ... more */
+ int *lstio_tes_retp; /* OUT: private returned
+ value */
+ struct list_head *lstio_tes_resultp; /* OUT: list head of
+ result buffer */
} lstio_test_args_t;
typedef enum {
- LST_BRW_READ = 1,
- LST_BRW_WRITE = 2
+ LST_BRW_READ = 1,
+ LST_BRW_WRITE = 2
} lst_brw_type_t;
typedef enum {
- LST_BRW_CHECK_NONE = 1,
- LST_BRW_CHECK_SIMPLE = 2,
- LST_BRW_CHECK_FULL = 3
+ LST_BRW_CHECK_NONE = 1,
+ LST_BRW_CHECK_SIMPLE = 2,
+ LST_BRW_CHECK_FULL = 3
} lst_brw_flags_t;
typedef struct {
- 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_opc; /* bulk operation code */
+ int blk_size; /* size (bytes) */
+ int blk_time; /* time of running the test*/
+ int blk_flags; /* reserved flags */
} lst_test_bulk_param_t;
typedef struct {
- int png_size; /* size of ping message */
- int png_time; /* time */
- int png_loop; /* loop */
- int png_flags; /* reserved flags */
+ int png_size; /* size of ping message */
+ int png_time; /* time */
+ int png_loop; /* loop */
+ int png_flags; /* reserved flags */
} lst_test_ping_param_t;
-/* more tests */
typedef struct {
__u32 errors;
__u32 rpcs_sent;
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/nidstr.h b/kernel/drivers/staging/lustre/include/linux/lnet/nidstr.h
new file mode 100644
index 000000000..46ad9147a
--- /dev/null
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/nidstr.h
@@ -0,0 +1,114 @@
+/*
+ * 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011 - 2015, Intel Corporation.
+ */
+#ifndef _LNET_NIDSTRINGS_H
+#define _LNET_NIDSTRINGS_H
+
+#include "types.h"
+
+/**
+ * Lustre Network Driver types.
+ */
+enum {
+ /* Only add to these values (i.e. don't ever change or redefine them):
+ * network addresses depend on them... */
+ QSWLND = 1,
+ SOCKLND = 2,
+ GMLND = 3,
+ PTLLND = 4,
+ O2IBLND = 5,
+ CIBLND = 6,
+ OPENIBLND = 7,
+ IIBLND = 8,
+ LOLND = 9,
+ RALND = 10,
+ VIBLND = 11,
+ MXLND = 12,
+ GNILND = 13,
+ GNIIPLND = 14,
+};
+
+struct list_head;
+
+#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);
+int libcfs_isknown_lnd(__u32 lnd);
+char *libcfs_lnd2modname(__u32 lnd);
+char *libcfs_lnd2str_r(__u32 lnd, char *buf, size_t buf_size);
+static inline char *libcfs_lnd2str(__u32 lnd)
+{
+ return libcfs_lnd2str_r(lnd, libcfs_next_nidstring(),
+ LNET_NIDSTR_SIZE);
+}
+int libcfs_str2lnd(const char *str);
+char *libcfs_net2str_r(__u32 net, char *buf, size_t buf_size);
+static inline char *libcfs_net2str(__u32 net)
+{
+ return libcfs_net2str_r(net, libcfs_next_nidstring(),
+ LNET_NIDSTR_SIZE);
+}
+char *libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size);
+static inline char *libcfs_nid2str(lnet_nid_t nid)
+{
+ return libcfs_nid2str_r(nid, libcfs_next_nidstring(),
+ LNET_NIDSTR_SIZE);
+}
+__u32 libcfs_str2net(const char *str);
+lnet_nid_t libcfs_str2nid(const char *str);
+int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
+char *libcfs_id2str(lnet_process_id_t id);
+void cfs_free_nidlist(struct list_head *list);
+int cfs_parse_nidlist(char *str, int len, struct list_head *list);
+int cfs_print_nidlist(char *buffer, int count, struct list_head *list);
+int cfs_match_nid(lnet_nid_t nid, struct list_head *list);
+
+int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
+int cfs_ip_addr_match(__u32 addr, struct list_head *list);
+bool cfs_nidrange_is_contiguous(struct list_head *nidlist);
+void cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid,
+ char *max_nid, size_t nidstr_length);
+
+struct netstrfns {
+ __u32 nf_type;
+ char *nf_name;
+ char *nf_modname;
+ void (*nf_addr2str)(__u32 addr, char *str, size_t size);
+ int (*nf_str2addr)(const char *str, int nob, __u32 *addr);
+ int (*nf_parse_addrlist)(char *str, int len,
+ struct list_head *list);
+ int (*nf_print_addrlist)(char *buffer, int count,
+ struct list_head *list);
+ int (*nf_match_addr)(__u32 addr, struct list_head *list);
+ bool (*nf_is_contiguous)(struct list_head *nidlist);
+ void (*nf_min_max)(struct list_head *nidlist, __u32 *min_nid,
+ __u32 *max_nid);
+};
+
+#endif /* _LNET_NIDSTRINGS_H */
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/ptllnd.h b/kernel/drivers/staging/lustre/include/linux/lnet/ptllnd.h
deleted file mode 100644
index c91d65329..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/ptllnd.h
+++ /dev/null
@@ -1,93 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lnet/include/lnet/ptllnd.h
- *
- * Author: PJ Kirner <pjkirner@clusterfs.com>
- */
-
-/*
- * The PTLLND was designed to support Portals with
- * Lustre and non-lustre UNLINK semantics.
- * However for now the two targets are Cray Portals
- * on the XT3 and Lustre Portals (for testing) both
- * have Lustre UNLINK semantics, so this is defined
- * by default.
- */
-#define LUSTRE_PORTALS_UNLINK_SEMANTICS
-
-#ifdef _USING_LUSTRE_PORTALS_
-
-/* NIDs are 64-bits on Lustre Portals */
-#define FMT_NID "%llu"
-#define FMT_PID "%d"
-
-/* When using Lustre Portals Lustre completion semantics are imlicit*/
-#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS 0
-
-#else /* _USING_CRAY_PORTALS_ */
-
-/* NIDs are integers on Cray Portals */
-#define FMT_NID "%u"
-#define FMT_PID "%d"
-
-/* When using Cray Portals this is defined in the Cray Portals Header*/
-/*#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS */
-
-/* Can compare handles directly on Cray Portals */
-#define PtlHandleIsEqual(a, b) ((a) == (b))
-
-/* Different error types on Cray Portals*/
-#define ptl_err_t ptl_ni_fail_t
-
-/*
- * The Cray Portals has no maximum number of IOVs. The
- * maximum is limited only by memory and size of the
- * int parameters (2^31-1).
- * Lustre only really require that the underyling
- * implementation to support at least LNET_MAX_IOV,
- * so for Cray portals we can safely just use that
- * value here.
- *
- */
-#define PTL_MD_MAX_IOV LNET_MAX_IOV
-
-#endif
-
-#define FMT_PTLID "ptlid:"FMT_PID"-"FMT_NID
-
-/* Align incoming small request messages to an 8 byte boundary if this is
- * supported to avoid alignment issues on some architectures */
-#ifndef PTL_MD_LOCAL_ALIGN8
-# define PTL_MD_LOCAL_ALIGN8 0
-#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h b/kernel/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h
deleted file mode 100644
index 808f37b64..000000000
--- a/kernel/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h
+++ /dev/null
@@ -1,119 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lnet/include/lnet/ptllnd_wire.h
- *
- * Author: PJ Kirner <pjkirner@clusterfs.com>
- */
-
-/* Minimum buffer size that any peer will post to receive ptllnd messages */
-#define PTLLND_MIN_BUFFER_SIZE 256
-
-/************************************************************************
- * Tunable defaults that {u,k}lnds/ptllnd should have in common.
- */
-
-#define PTLLND_PORTAL 9 /* The same portal PTLPRC used when talking to cray portals */
-#define PTLLND_PID 9 /* The Portals PID */
-#define PTLLND_PEERCREDITS 8 /* concurrent sends to 1 peer */
-
-/* Default buffer size for kernel ptllnds (guaranteed eager) */
-#define PTLLND_MAX_KLND_MSG_SIZE 512
-
-/* Default buffer size for catamount ptllnds (not guaranteed eager) - large
- * enough to avoid RDMA for anything sent while control is not in liblustre */
-#define PTLLND_MAX_ULND_MSG_SIZE 512
-
-/************************************************************************
- * Portals LND Wire message format.
- * These are sent in sender's byte order (i.e. receiver flips).
- */
-
-#define PTL_RESERVED_MATCHBITS 0x100 /* below this value is reserved
- * above is for bulk data transfer */
-#define LNET_MSG_MATCHBITS 0 /* the value for the message channel */
-
-typedef struct {
- lnet_hdr_t kptlim_hdr; /* portals header */
- char kptlim_payload[0]; /* piggy-backed payload */
-} WIRE_ATTR kptl_immediate_msg_t;
-
-typedef struct {
- lnet_hdr_t kptlrm_hdr; /* portals header */
- __u64 kptlrm_matchbits; /* matchbits */
-} WIRE_ATTR kptl_rdma_msg_t;
-
-typedef struct {
- __u64 kptlhm_matchbits; /* matchbits */
- __u32 kptlhm_max_msg_size; /* max message size */
-} WIRE_ATTR kptl_hello_msg_t;
-
-typedef struct {
- /* First 2 fields fixed FOR ALL TIME */
- __u32 ptlm_magic; /* I'm a Portals LND message */
- __u16 ptlm_version; /* this is my version number */
- __u8 ptlm_type; /* the message type */
- __u8 ptlm_credits; /* returned credits */
- __u32 ptlm_nob; /* # bytes in whole message */
- __u32 ptlm_cksum; /* checksum (0 == no checksum) */
- __u64 ptlm_srcnid; /* sender's NID */
- __u64 ptlm_srcstamp; /* sender's incarnation */
- __u64 ptlm_dstnid; /* destination's NID */
- __u64 ptlm_dststamp; /* destination's incarnation */
- __u32 ptlm_srcpid; /* sender's PID */
- __u32 ptlm_dstpid; /* destination's PID */
-
- union {
- kptl_immediate_msg_t immediate;
- kptl_rdma_msg_t rdma;
- kptl_hello_msg_t hello;
- } WIRE_ATTR ptlm_u;
-
-} kptl_msg_t;
-
-/* kptl_msg_t::ptlm_credits is only a __u8 */
-#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t *)0)->ptlm_credits)) - 1)
-
-#define PTLLND_MSG_MAGIC LNET_PROTO_PTL_MAGIC
-#define PTLLND_MSG_VERSION 0x04
-
-#define PTLLND_RDMA_OK 0x00
-#define PTLLND_RDMA_FAIL 0x01
-
-#define PTLLND_MSG_TYPE_INVALID 0x00
-#define PTLLND_MSG_TYPE_PUT 0x01
-#define PTLLND_MSG_TYPE_GET 0x02
-#define PTLLND_MSG_TYPE_IMMEDIATE 0x03 /* No bulk data xfer*/
-#define PTLLND_MSG_TYPE_NOOP 0x04
-#define PTLLND_MSG_TYPE_HELLO 0x05
-#define PTLLND_MSG_TYPE_NAK 0x06
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/socklnd.h b/kernel/drivers/staging/lustre/include/linux/lnet/socklnd.h
index 389038b12..599c9f662 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/socklnd.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/socklnd.h
@@ -15,57 +15,52 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012 - 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*
* lnet/include/lnet/socklnd.h
- *
- * #defines shared between socknal implementation and utilities
*/
#ifndef __LNET_LNET_SOCKLND_H__
#define __LNET_LNET_SOCKLND_H__
#include "types.h"
-#include "lib-types.h"
#define SOCKLND_CONN_NONE (-1)
#define SOCKLND_CONN_ANY 0
-#define SOCKLND_CONN_CONTROL 1
-#define SOCKLND_CONN_BULK_IN 2
-#define SOCKLND_CONN_BULK_OUT 3
-#define SOCKLND_CONN_NTYPES 4
+#define SOCKLND_CONN_CONTROL 1
+#define SOCKLND_CONN_BULK_IN 2
+#define SOCKLND_CONN_BULK_OUT 3
+#define SOCKLND_CONN_NTYPES 4
#define SOCKLND_CONN_ACK SOCKLND_CONN_BULK_IN
typedef struct {
- __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_dst_nid; /* destination nid */
- lnet_pid_t kshm_src_pid; /* sender's pid */
- lnet_pid_t kshm_dst_pid; /* destination pid */
- __u64 kshm_src_incarnation; /* sender's incarnation */
- __u64 kshm_dst_incarnation; /* destination's incarnation */
- __u32 kshm_ctype; /* connection type */
- __u32 kshm_nips; /* # IP addrs */
- __u32 kshm_ips[0]; /* IP addrs */
+ __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_dst_nid; /* destination nid */
+ lnet_pid_t kshm_src_pid; /* sender's pid */
+ lnet_pid_t kshm_dst_pid; /* destination pid */
+ __u64 kshm_src_incarnation; /* sender's incarnation */
+ __u64 kshm_dst_incarnation; /* destination's incarnation */
+ __u32 kshm_ctype; /* connection type */
+ __u32 kshm_nips; /* # IP addrs */
+ __u32 kshm_ips[0]; /* IP addrs */
} WIRE_ATTR ksock_hello_msg_t;
typedef struct {
- lnet_hdr_t ksnm_hdr; /* lnet hdr */
+ lnet_hdr_t ksnm_hdr; /* lnet hdr */
/*
* ksnm_payload is removed because of winnt compiler's limitation:
@@ -76,28 +71,29 @@ typedef struct {
} WIRE_ATTR ksock_lnet_msg_t;
typedef struct {
- __u32 ksm_type; /* type of socklnd message */
- __u32 ksm_csum; /* checksum if != 0 */
- __u64 ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */
+ __u32 ksm_type; /* type of socklnd message */
+ __u32 ksm_csum; /* checksum if != 0 */
+ __u64 ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */
union {
- ksock_lnet_msg_t lnetmsg; /* lnet message, it's empty if it's NOOP */
+ ksock_lnet_msg_t lnetmsg;/* lnet message, it's empty if
+ * it's NOOP */
} WIRE_ATTR ksm_u;
} WIRE_ATTR ksock_msg_t;
static inline void
socklnd_init_msg(ksock_msg_t *msg, int type)
{
- msg->ksm_csum = 0;
- msg->ksm_type = type;
- msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0;
+ msg->ksm_csum = 0;
+ msg->ksm_type = type;
+ msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0;
}
-#define KSOCK_MSG_NOOP 0xc0 /* ksm_u empty */
-#define KSOCK_MSG_LNET 0xc1 /* lnet msg */
+#define KSOCK_MSG_NOOP 0xC0 /* ksm_u empty */
+#define KSOCK_MSG_LNET 0xC1 /* lnet msg */
/* We need to know this number to parse hello msg from ksocklnd in
* other LND (usocklnd, for example) */
-#define KSOCK_PROTO_V2 2
-#define KSOCK_PROTO_V3 3
+#define KSOCK_PROTO_V2 2
+#define KSOCK_PROTO_V3 3
#endif
diff --git a/kernel/drivers/staging/lustre/include/linux/lnet/types.h b/kernel/drivers/staging/lustre/include/linux/lnet/types.h
index 68d8139a2..11630180c 100644
--- a/kernel/drivers/staging/lustre/include/linux/lnet/types.h
+++ b/kernel/drivers/staging/lustre/include/linux/lnet/types.h
@@ -15,11 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
@@ -27,28 +23,28 @@
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012 - 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*/
#ifndef __LNET_TYPES_H__
#define __LNET_TYPES_H__
+#include <linux/types.h>
+
/** \addtogroup lnet
* @{ */
-#include "../libcfs/libcfs.h"
-
/** \addtogroup lnet_addr
* @{ */
/** Portal reserved for LNet's own use.
* \see lustre/include/lustre/lustre_idl.h for Lustre portal assignments.
*/
-#define LNET_RESERVED_PORTAL 0
+#define LNET_RESERVED_PORTAL 0
/**
* Address of an end-point in an LNet network.
@@ -68,16 +64,201 @@ typedef __u64 lnet_nid_t;
typedef __u32 lnet_pid_t;
/** wildcard NID that matches any end-point address */
-#define LNET_NID_ANY ((lnet_nid_t) -1)
+#define LNET_NID_ANY ((lnet_nid_t) -1)
/** wildcard PID that matches any lnet_pid_t */
-#define LNET_PID_ANY ((lnet_pid_t) -1)
+#define LNET_PID_ANY ((lnet_pid_t) -1)
#define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
#define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
+#define LNET_PID_LUSTRE 12345
-#define LNET_TIME_FOREVER (-1)
+#define LNET_TIME_FOREVER (-1)
-/**
+/* how an LNET NID encodes net:address */
+/** extract the address part of an lnet_nid_t */
+
+static inline __u32 LNET_NIDADDR(lnet_nid_t nid)
+{
+ return nid & 0xffffffff;
+}
+
+static inline __u32 LNET_NIDNET(lnet_nid_t nid)
+{
+ return (nid >> 32) & 0xffffffff;
+}
+
+static inline lnet_nid_t LNET_MKNID(__u32 net, __u32 addr)
+{
+ return (((__u64)net) << 32) | addr;
+}
+
+static inline __u32 LNET_NETNUM(__u32 net)
+{
+ return net & 0xffff;
+}
+
+static inline __u32 LNET_NETTYP(__u32 net)
+{
+ return (net >> 16) & 0xffff;
+}
+
+static inline __u32 LNET_MKNET(__u32 type, __u32 num)
+{
+ return (type << 16) | num;
+}
+
+#define WIRE_ATTR __packed
+
+/* Packed version of lnet_process_id_t to transfer via network */
+typedef struct {
+ /* node id / process id */
+ lnet_nid_t nid;
+ lnet_pid_t pid;
+} WIRE_ATTR lnet_process_id_packed_t;
+
+/* The wire handle's interface cookie only matches one network interface in
+ * one epoch (i.e. new cookie when the interface restarts or the node
+ * reboots). The object cookie only matches one object on that interface
+ * during that object's lifetime (i.e. no cookie re-use). */
+typedef struct {
+ __u64 wh_interface_cookie;
+ __u64 wh_object_cookie;
+} WIRE_ATTR lnet_handle_wire_t;
+
+typedef enum {
+ LNET_MSG_ACK = 0,
+ LNET_MSG_PUT,
+ LNET_MSG_GET,
+ LNET_MSG_REPLY,
+ LNET_MSG_HELLO,
+} lnet_msg_type_t;
+
+/* The variant fields of the portals message header are aligned on an 8
+ * byte boundary in the message header. Note that all types used in these
+ * wire structs MUST be fixed size and the smaller types are placed at the
+ * end. */
+typedef struct lnet_ack {
+ lnet_handle_wire_t dst_wmd;
+ __u64 match_bits;
+ __u32 mlength;
+} WIRE_ATTR lnet_ack_t;
+
+typedef struct lnet_put {
+ lnet_handle_wire_t ack_wmd;
+ __u64 match_bits;
+ __u64 hdr_data;
+ __u32 ptl_index;
+ __u32 offset;
+} WIRE_ATTR lnet_put_t;
+
+typedef struct lnet_get {
+ lnet_handle_wire_t return_wmd;
+ __u64 match_bits;
+ __u32 ptl_index;
+ __u32 src_offset;
+ __u32 sink_length;
+} WIRE_ATTR lnet_get_t;
+
+typedef struct lnet_reply {
+ lnet_handle_wire_t dst_wmd;
+} WIRE_ATTR lnet_reply_t;
+
+typedef struct lnet_hello {
+ __u64 incarnation;
+ __u32 type;
+} WIRE_ATTR lnet_hello_t;
+
+typedef struct {
+ lnet_nid_t dest_nid;
+ lnet_nid_t src_nid;
+ lnet_pid_t dest_pid;
+ lnet_pid_t src_pid;
+ __u32 type; /* lnet_msg_type_t */
+ __u32 payload_length; /* payload data to follow */
+ /*<------__u64 aligned------->*/
+ union {
+ lnet_ack_t ack;
+ lnet_put_t put;
+ lnet_get_t get;
+ lnet_reply_t reply;
+ lnet_hello_t hello;
+ } msg;
+} WIRE_ATTR lnet_hdr_t;
+
+/* A HELLO message contains a magic number and protocol version
+ * code in the header's dest_nid, the peer's NID in the src_nid, and
+ * LNET_MSG_HELLO in the type field. All other common fields are zero
+ * (including payload_size; i.e. no payload).
+ * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is
+ * running the same protocol and to find out its NID. These LNDs should
+ * exchange HELLO messages when a connection is first established. Individual
+ * LNDs can put whatever else they fancy in lnet_hdr_t::msg.
+ */
+typedef struct {
+ __u32 magic; /* LNET_PROTO_TCP_MAGIC */
+ __u16 version_major; /* increment on incompatible change */
+ __u16 version_minor; /* increment on compatible change */
+} WIRE_ATTR lnet_magicversion_t;
+
+/* PROTO MAGIC for LNDs */
+#define LNET_PROTO_IB_MAGIC 0x0be91b91
+#define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */
+#define LNET_PROTO_TCP_MAGIC 0xeebc0ded
+#define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100
+#define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */
+
+/* Placeholder for a future "unified" protocol across all LNDs */
+/* Current LNDs that receive a request with this magic will respond with a
+ * "stub" reply using their current protocol */
+#define LNET_PROTO_MAGIC 0x45726963 /* ! */
+
+#define LNET_PROTO_TCP_VERSION_MAJOR 1
+#define LNET_PROTO_TCP_VERSION_MINOR 0
+
+/* Acceptor connection request */
+typedef struct {
+ __u32 acr_magic; /* PTL_ACCEPTOR_PROTO_MAGIC */
+ __u32 acr_version; /* protocol version */
+ __u64 acr_nid; /* target NID */
+} WIRE_ATTR lnet_acceptor_connreq_t;
+
+#define LNET_PROTO_ACCEPTOR_VERSION 1
+
+typedef struct {
+ lnet_nid_t ns_nid;
+ __u32 ns_status;
+ __u32 ns_unused;
+} WIRE_ATTR lnet_ni_status_t;
+
+typedef struct {
+ __u32 pi_magic;
+ __u32 pi_features;
+ lnet_pid_t pi_pid;
+ __u32 pi_nnis;
+ lnet_ni_status_t pi_ni[0];
+} WIRE_ATTR lnet_ping_info_t;
+
+typedef struct lnet_counters {
+ __u32 msgs_alloc;
+ __u32 msgs_max;
+ __u32 errors;
+ __u32 send_count;
+ __u32 recv_count;
+ __u32 route_count;
+ __u32 drop_count;
+ __u64 send_length;
+ __u64 recv_length;
+ __u64 route_length;
+ __u64 drop_length;
+} WIRE_ATTR lnet_counters_t;
+
+#define LNET_NI_STATUS_UP 0x15aac0de
+#define LNET_NI_STATUS_DOWN 0xdeadface
+#define LNET_NI_STATUS_INVALID 0x00000000
+
+#define LNET_MAX_INTERFACES 16
+
+/*
* Objects maintained by the LNet are accessed through handles. Handle types
* have names of the form lnet_handle_xx_t, where xx is one of the two letter
* object type codes ('eq' for event queue, 'md' for memory descriptor, and
@@ -122,7 +303,7 @@ static inline int LNetHandleIsEqual(lnet_handle_any_t h1, lnet_handle_any_t h2)
*/
static inline int LNetHandleIsInvalid(lnet_handle_any_t h)
{
- return LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie;
+ return h.cookie == LNET_WIRE_HANDLE_COOKIE_NONE;
}
/**
@@ -195,8 +376,8 @@ typedef struct {
* one must start on page boundary, and all but the last must end on
* page boundary.
*/
- void *start;
- unsigned int length;
+ void *start;
+ unsigned int length;
/**
* Specifies the maximum number of operations that can be performed
* on the memory descriptor. An operation is any action that could
@@ -207,7 +388,7 @@ typedef struct {
* there is no bound on the number of operations that may be applied
* to a MD.
*/
- int threshold;
+ int threshold;
/**
* Specifies the largest incoming request that the memory descriptor
* should respond to. When the unused portion of a MD (length -
@@ -215,7 +396,7 @@ typedef struct {
* does not respond to further operations. This value is only used
* if the LNET_MD_MAX_SIZE option is set.
*/
- int max_size;
+ int max_size;
/**
* Specifies the behavior of the memory descriptor. A bitwise OR
* of the following values can be used:
@@ -252,14 +433,14 @@ typedef struct {
* region (i.e. sum of all fragment lengths) must not be less than
* \a max_size.
*/
- unsigned int options;
+ unsigned int options;
/**
* A user-specified value that is associated with the memory
* descriptor. The value does not need to be a pointer, but must fit
* in the space used by a pointer. This value is recorded in events
* associated with operations on this MD.
*/
- void *user_ptr;
+ void *user_ptr;
/**
* A handle for the event queue used to log the operations performed on
* the memory region. If this argument is a NULL handle (i.e. nullified
@@ -276,44 +457,33 @@ typedef struct {
#define LNET_MTU (1 << LNET_MTU_BITS)
/** limit on the number of fragments in discontiguous MDs */
-#define LNET_MAX_IOV 256
-
-/* Max payload size */
-# define LNET_MAX_PAYLOAD CONFIG_LNET_MAX_PAYLOAD
-# if (LNET_MAX_PAYLOAD < LNET_MTU)
-# error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb"
-# else
-# if (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV))
-/* PAGE_SIZE is a constant: check with cpp! */
-# error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb"
-# endif
-# endif
+#define LNET_MAX_IOV 256
/**
* Options for the MD structure. See lnet_md_t::options.
*/
-#define LNET_MD_OP_PUT (1 << 0)
+#define LNET_MD_OP_PUT (1 << 0)
/** See lnet_md_t::options. */
-#define LNET_MD_OP_GET (1 << 1)
+#define LNET_MD_OP_GET (1 << 1)
/** See lnet_md_t::options. */
#define LNET_MD_MANAGE_REMOTE (1 << 2)
-/* unused (1 << 3) */
+/* unused (1 << 3) */
/** See lnet_md_t::options. */
-#define LNET_MD_TRUNCATE (1 << 4)
+#define LNET_MD_TRUNCATE (1 << 4)
/** See lnet_md_t::options. */
-#define LNET_MD_ACK_DISABLE (1 << 5)
+#define LNET_MD_ACK_DISABLE (1 << 5)
/** See lnet_md_t::options. */
#define LNET_MD_IOVEC (1 << 6)
/** See lnet_md_t::options. */
-#define LNET_MD_MAX_SIZE (1 << 7)
+#define LNET_MD_MAX_SIZE (1 << 7)
/** See lnet_md_t::options. */
-#define LNET_MD_KIOV (1 << 8)
+#define LNET_MD_KIOV (1 << 8)
/* For compatibility with Cray Portals */
-#define LNET_MD_PHYS 0
+#define LNET_MD_PHYS 0
/** Infinite threshold on MD operations. See lnet_md_t::threshold */
-#define LNET_MD_THRESH_INF (-1)
+#define LNET_MD_THRESH_INF (-1)
/* NB lustre portals uses struct iovec internally! */
typedef struct iovec lnet_md_iovec_t;
@@ -323,15 +493,15 @@ typedef struct iovec lnet_md_iovec_t;
*/
typedef struct {
/** Pointer to the page where the fragment resides */
- struct page *kiov_page;
+ struct page *kiov_page;
/** Length in bytes of the fragment */
- unsigned int kiov_len;
+ unsigned int kiov_len;
/**
* Starting offset of the fragment within the page. Note that the
* end of the fragment must not pass the end of the page; i.e.,
* kiov_len + kiov_offset <= PAGE_CACHE_SIZE.
*/
- unsigned int kiov_offset;
+ unsigned int kiov_offset;
} lnet_kiov_t;
/** @} lnet_md */
@@ -379,7 +549,7 @@ typedef enum {
LNET_EVENT_UNLINK,
} lnet_event_kind_t;
-#define LNET_SEQ_BASETYPE long
+#define LNET_SEQ_BASETYPE long
typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
#define LNET_SEQ_GT(a, b) (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
@@ -388,23 +558,23 @@ typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
*/
typedef struct {
/** The identifier (nid, pid) of the target. */
- lnet_process_id_t target;
+ lnet_process_id_t target;
/** The identifier (nid, pid) of the initiator. */
- lnet_process_id_t initiator;
+ lnet_process_id_t initiator;
/**
* The NID of the immediate sender. If the request has been forwarded
* by routers, this is the NID of the last hop; otherwise it's the
* same as the initiator.
*/
- lnet_nid_t sender;
+ lnet_nid_t sender;
/** Indicates the type of the event. */
- lnet_event_kind_t type;
+ lnet_event_kind_t type;
/** The portal table index specified in the request */
- unsigned int pt_index;
+ unsigned int pt_index;
/** A copy of the match bits specified in the request. */
- __u64 match_bits;
+ __u64 match_bits;
/** The length (in bytes) specified in the request. */
- unsigned int rlength;
+ unsigned int rlength;
/**
* The length (in bytes) of the data that was manipulated by the
* operation. For truncated operations, the manipulated length will be
@@ -412,47 +582,47 @@ typedef struct {
* see lnet_md_t). For all other operations, the manipulated length
* will be the length of the requested operation, i.e. rlength.
*/
- unsigned int mlength;
+ unsigned int mlength;
/**
* The handle to the MD associated with the event. The handle may be
* invalid if the MD has been unlinked.
*/
- lnet_handle_md_t md_handle;
+ lnet_handle_md_t md_handle;
/**
* A snapshot of the state of the MD immediately after the event has
* been processed. In particular, the threshold field in md will
* reflect the value of the threshold after the operation occurred.
*/
- lnet_md_t md;
+ lnet_md_t md;
/**
* 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT.
* \see LNetPut
*/
- __u64 hdr_data;
+ __u64 hdr_data;
/**
* Indicates the completion status of the operation. It's 0 for
* successful operations, otherwise it's an error code.
*/
- int status;
+ int status;
/**
* Indicates whether the MD has been unlinked. Note that:
* - An event with unlinked set is the last event on the MD.
* - This field is also set for an explicit LNET_EVENT_UNLINK event.
* \see LNetMDUnlink
*/
- int unlinked;
+ int unlinked;
/**
* The displacement (in bytes) into the memory region that the
* operation used. The offset can be determined by the operation for
* a remote managed MD or by the local MD.
* \see lnet_md_t::options
*/
- unsigned int offset;
+ unsigned int offset;
/**
* The sequence number for this event. Sequence numbers are unique
* to each event.
*/
- volatile lnet_seq_t sequence;
+ volatile lnet_seq_t sequence;
} lnet_event_t;
/**
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 3bad441de..7c730e3f7 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -38,25 +38,26 @@
* Author: Eric Barton <eric@bartonsoftware.com>
*/
-#include "o2iblnd.h"
#include <asm/div64.h>
+#include <asm/page.h>
+#include "o2iblnd.h"
static lnd_t the_o2iblnd = {
- .lnd_type = O2IBLND,
- .lnd_startup = kiblnd_startup,
- .lnd_shutdown = kiblnd_shutdown,
- .lnd_ctl = kiblnd_ctl,
- .lnd_query = kiblnd_query,
- .lnd_send = kiblnd_send,
- .lnd_recv = kiblnd_recv,
+ .lnd_type = O2IBLND,
+ .lnd_startup = kiblnd_startup,
+ .lnd_shutdown = kiblnd_shutdown,
+ .lnd_ctl = kiblnd_ctl,
+ .lnd_query = kiblnd_query,
+ .lnd_send = kiblnd_send,
+ .lnd_recv = kiblnd_recv,
};
-kib_data_t kiblnd_data;
+kib_data_t kiblnd_data;
static __u32 kiblnd_cksum(void *ptr, int nob)
{
- char *c = ptr;
- __u32 sum = 0;
+ char *c = ptr;
+ __u32 sum = 0;
while (nob-- > 0)
sum = ((sum << 1) | (sum >> 31)) + *c++;
@@ -138,10 +139,10 @@ static int kiblnd_msgtype2size(int type)
static int kiblnd_unpack_rd(kib_msg_t *msg, int flip)
{
- kib_rdma_desc_t *rd;
- int nob;
- int n;
- int i;
+ kib_rdma_desc_t *rd;
+ int nob;
+ int n;
+ int i;
LASSERT(msg->ibm_type == IBLND_MSG_GET_REQ ||
msg->ibm_type == IBLND_MSG_PUT_ACK);
@@ -210,10 +211,10 @@ void kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version,
int kiblnd_unpack_msg(kib_msg_t *msg, int nob)
{
const int hdr_size = offsetof(kib_msg_t, ibm_u);
- __u32 msg_cksum;
- __u16 version;
- int msg_nob;
- int flip;
+ __u32 msg_cksum;
+ __u16 version;
+ int msg_nob;
+ int flip;
/* 6 bytes are enough to have received magic + version */
if (nob < 6) {
@@ -320,10 +321,10 @@ int kiblnd_unpack_msg(kib_msg_t *msg, int nob)
int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
{
- kib_peer_t *peer;
- kib_net_t *net = ni->ni_data;
- int cpt = lnet_cpt_of_nid(nid);
- unsigned long flags;
+ kib_peer_t *peer;
+ kib_net_t *net = ni->ni_data;
+ int cpt = lnet_cpt_of_nid(nid);
+ unsigned long flags;
LASSERT(net != NULL);
LASSERT(nid != LNET_NID_ANY);
@@ -385,9 +386,9 @@ kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid)
{
/* the caller is responsible for accounting the additional reference
* that this creates */
- struct list_head *peer_list = kiblnd_nid2peerlist(nid);
- struct list_head *tmp;
- kib_peer_t *peer;
+ struct list_head *peer_list = kiblnd_nid2peerlist(nid);
+ struct list_head *tmp;
+ kib_peer_t *peer;
list_for_each(tmp, peer_list) {
@@ -422,10 +423,10 @@ void kiblnd_unlink_peer_locked(kib_peer_t *peer)
static int kiblnd_get_peer_info(lnet_ni_t *ni, int index,
lnet_nid_t *nidp, int *count)
{
- kib_peer_t *peer;
- struct list_head *ptmp;
- int i;
- unsigned long flags;
+ kib_peer_t *peer;
+ struct list_head *ptmp;
+ int i;
+ unsigned long flags;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -459,9 +460,9 @@ static int kiblnd_get_peer_info(lnet_ni_t *ni, int index,
static void kiblnd_del_peer_locked(kib_peer_t *peer)
{
- struct list_head *ctmp;
- struct list_head *cnxt;
- kib_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ kib_conn_t *conn;
if (list_empty(&peer->ibp_conns)) {
kiblnd_unlink_peer_locked(peer);
@@ -480,14 +481,14 @@ static void kiblnd_del_peer_locked(kib_peer_t *peer)
static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
{
LIST_HEAD(zombies);
- struct list_head *ptmp;
- struct list_head *pnxt;
- kib_peer_t *peer;
- int lo;
- int hi;
- int i;
- unsigned long flags;
- int rc = -ENOENT;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ kib_peer_t *peer;
+ int lo;
+ int hi;
+ int i;
+ unsigned long flags;
+ int rc = -ENOENT;
write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -532,12 +533,12 @@ static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
static kib_conn_t *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
{
- kib_peer_t *peer;
- struct list_head *ptmp;
- kib_conn_t *conn;
- struct list_head *ctmp;
- int i;
- unsigned long flags;
+ kib_peer_t *peer;
+ struct list_head *ptmp;
+ kib_conn_t *conn;
+ struct list_head *ctmp;
+ int i;
+ unsigned long flags;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -593,7 +594,7 @@ int kiblnd_translate_mtu(int value)
static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
{
- int mtu;
+ int mtu;
/* XXX There is no path record for iWARP, set by netdev->change_mtu? */
if (cmid->route.path_rec == NULL)
@@ -607,11 +608,11 @@ static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
static int kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
{
- cpumask_t *mask;
- int vectors;
- int off;
- int i;
- lnet_nid_t nid = conn->ibc_peer->ibp_nid;
+ cpumask_t *mask;
+ int vectors;
+ int off;
+ int i;
+ lnet_nid_t nid = conn->ibc_peer->ibp_nid;
vectors = conn->ibc_cmid->device->num_comp_vectors;
if (vectors <= 1)
@@ -642,17 +643,18 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
* she must dispose of 'cmid'. (Actually I'd block forever if I tried
* to destroy 'cmid' here since I'm called from the CM which still has
* its ref on 'cmid'). */
- rwlock_t *glock = &kiblnd_data.kib_global_lock;
- kib_net_t *net = peer->ibp_ni->ni_data;
- kib_dev_t *dev;
+ rwlock_t *glock = &kiblnd_data.kib_global_lock;
+ kib_net_t *net = peer->ibp_ni->ni_data;
+ kib_dev_t *dev;
struct ib_qp_init_attr *init_qp_attr;
- struct kib_sched_info *sched;
- kib_conn_t *conn;
- struct ib_cq *cq;
- unsigned long flags;
- int cpt;
- int rc;
- int i;
+ struct kib_sched_info *sched;
+ struct ib_cq_init_attr cq_attr = {};
+ kib_conn_t *conn;
+ struct ib_cq *cq;
+ unsigned long flags;
+ int cpt;
+ int rc;
+ int i;
LASSERT(net != NULL);
LASSERT(!in_interrupt());
@@ -742,10 +744,11 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
kiblnd_map_rx_descs(conn);
+ cq_attr.cqe = IBLND_CQ_ENTRIES(version);
+ cq_attr.comp_vector = kiblnd_get_completion_vector(conn, cpt);
cq = ib_create_cq(cmid->device,
kiblnd_cq_completion, kiblnd_cq_event, conn,
- IBLND_CQ_ENTRIES(version),
- kiblnd_get_completion_vector(conn, cpt));
+ &cq_attr);
if (IS_ERR(cq)) {
CERROR("Can't create CQ: %ld, cqe: %d\n",
PTR_ERR(cq), IBLND_CQ_ENTRIES(version));
@@ -837,8 +840,8 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
void kiblnd_destroy_conn(kib_conn_t *conn)
{
struct rdma_cm_id *cmid = conn->ibc_cmid;
- kib_peer_t *peer = conn->ibc_peer;
- int rc;
+ kib_peer_t *peer = conn->ibc_peer;
+ int rc;
LASSERT(!in_interrupt());
LASSERT(atomic_read(&conn->ibc_refcount) == 0);
@@ -904,10 +907,10 @@ void kiblnd_destroy_conn(kib_conn_t *conn)
int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why)
{
- kib_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
- int count = 0;
+ kib_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ int count = 0;
list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
conn = list_entry(ctmp, kib_conn_t, ibc_list);
@@ -926,10 +929,10 @@ int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why)
int kiblnd_close_stale_conns_locked(kib_peer_t *peer,
int version, __u64 incarnation)
{
- kib_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
- int count = 0;
+ kib_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ int count = 0;
list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
conn = list_entry(ctmp, kib_conn_t, ibc_list);
@@ -953,14 +956,14 @@ int kiblnd_close_stale_conns_locked(kib_peer_t *peer,
static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
{
- kib_peer_t *peer;
- struct list_head *ptmp;
- struct list_head *pnxt;
- int lo;
- int hi;
- int i;
- unsigned long flags;
- int count = 0;
+ kib_peer_t *peer;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ int lo;
+ int hi;
+ int i;
+ unsigned long flags;
+ int count = 0;
write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -1001,17 +1004,17 @@ static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
{
struct libcfs_ioctl_data *data = arg;
- int rc = -EINVAL;
+ int rc = -EINVAL;
switch (cmd) {
case IOC_LIBCFS_GET_PEER: {
- lnet_nid_t nid = 0;
- int count = 0;
+ lnet_nid_t nid = 0;
+ int count = 0;
rc = kiblnd_get_peer_info(ni, data->ioc_count,
&nid, &count);
- data->ioc_nid = nid;
- data->ioc_count = count;
+ data->ioc_nid = nid;
+ data->ioc_count = count;
break;
}
@@ -1053,11 +1056,11 @@ int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
{
- unsigned long last_alive = 0;
- unsigned long now = cfs_time_current();
- rwlock_t *glock = &kiblnd_data.kib_global_lock;
- kib_peer_t *peer;
- unsigned long flags;
+ unsigned long last_alive = 0;
+ unsigned long now = cfs_time_current();
+ rwlock_t *glock = &kiblnd_data.kib_global_lock;
+ kib_peer_t *peer;
+ unsigned long flags;
read_lock_irqsave(glock, flags);
@@ -1086,8 +1089,8 @@ void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
void kiblnd_free_pages(kib_pages_t *p)
{
- int npages = p->ibp_npages;
- int i;
+ int npages = p->ibp_npages;
+ int i;
for (i = 0; i < npages; i++) {
if (p->ibp_pages[i] != NULL)
@@ -1099,8 +1102,8 @@ void kiblnd_free_pages(kib_pages_t *p)
int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
{
- kib_pages_t *p;
- int i;
+ kib_pages_t *p;
+ int i;
LIBCFS_CPT_ALLOC(p, lnet_cpt_table(), cpt,
offsetof(kib_pages_t, ibp_pages[npages]));
@@ -1130,7 +1133,7 @@ int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
void kiblnd_unmap_rx_descs(kib_conn_t *conn)
{
kib_rx_t *rx;
- int i;
+ int i;
LASSERT(conn->ibc_rxs != NULL);
LASSERT(conn->ibc_hdev != NULL);
@@ -1153,14 +1156,13 @@ void kiblnd_unmap_rx_descs(kib_conn_t *conn)
void kiblnd_map_rx_descs(kib_conn_t *conn)
{
- kib_rx_t *rx;
- struct page *pg;
- int pg_off;
- int ipg;
- int i;
+ kib_rx_t *rx;
+ struct page *pg;
+ int pg_off;
+ int ipg;
+ int i;
- for (pg_off = ipg = i = 0;
- i < IBLND_RX_MSGS(conn->ibc_version); i++) {
+ for (pg_off = ipg = i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++) {
pg = conn->ibc_rx_pages->ibp_pages[ipg];
rx = &conn->ibc_rxs[i];
@@ -1177,7 +1179,7 @@ void kiblnd_map_rx_descs(kib_conn_t *conn)
CDEBUG(D_NET, "rx %d: %p %#llx(%#llx)\n",
i, rx->rx_msg, rx->rx_msgaddr,
- lnet_page2phys(pg) + pg_off);
+ (__u64)(page_to_phys(pg) + pg_off));
pg_off += IBLND_MSG_SIZE;
LASSERT(pg_off <= PAGE_SIZE);
@@ -1192,9 +1194,9 @@ void kiblnd_map_rx_descs(kib_conn_t *conn)
static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
{
- kib_hca_dev_t *hdev = tpo->tpo_hdev;
- kib_tx_t *tx;
- int i;
+ kib_hca_dev_t *hdev = tpo->tpo_hdev;
+ kib_tx_t *tx;
+ int i;
LASSERT(tpo->tpo_pool.po_allocated == 0);
@@ -1216,8 +1218,8 @@ static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev)
{
kib_hca_dev_t *hdev;
- unsigned long flags;
- int i = 0;
+ unsigned long flags;
+ int i = 0;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
while (dev->ibd_failover) {
@@ -1240,15 +1242,15 @@ static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev)
static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
{
- kib_pages_t *txpgs = tpo->tpo_tx_pages;
- kib_pool_t *pool = &tpo->tpo_pool;
- kib_net_t *net = pool->po_owner->ps_net;
- kib_dev_t *dev;
- struct page *page;
- kib_tx_t *tx;
- int page_offset;
- int ipage;
- int i;
+ kib_pages_t *txpgs = tpo->tpo_tx_pages;
+ kib_pool_t *pool = &tpo->tpo_pool;
+ kib_net_t *net = pool->po_owner->ps_net;
+ kib_dev_t *dev;
+ struct page *page;
+ kib_tx_t *tx;
+ int page_offset;
+ int ipage;
+ int i;
LASSERT(net != NULL);
@@ -1291,7 +1293,7 @@ static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
struct ib_mr *kiblnd_find_dma_mr(kib_hca_dev_t *hdev, __u64 addr, __u64 size)
{
- __u64 index;
+ __u64 index;
LASSERT(hdev->ibh_mrs[0] != NULL);
@@ -1311,7 +1313,7 @@ struct ib_mr *kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd)
{
struct ib_mr *prev_mr;
struct ib_mr *mr;
- int i;
+ int i;
LASSERT(hdev->ibh_mrs[0] != NULL);
@@ -1382,18 +1384,18 @@ static int kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps,
kib_fmr_pool_t **pp_fpo)
{
/* FMR pool for RDMA */
- kib_dev_t *dev = fps->fps_net->ibn_dev;
- kib_fmr_pool_t *fpo;
+ kib_dev_t *dev = fps->fps_net->ibn_dev;
+ kib_fmr_pool_t *fpo;
struct ib_fmr_pool_param param = {
.max_pages_per_fmr = LNET_MAX_PAYLOAD/PAGE_SIZE,
- .page_shift = PAGE_SHIFT,
- .access = (IB_ACCESS_LOCAL_WRITE |
+ .page_shift = PAGE_SHIFT,
+ .access = (IB_ACCESS_LOCAL_WRITE |
IB_ACCESS_REMOTE_WRITE),
- .pool_size = fps->fps_pool_size,
+ .pool_size = fps->fps_pool_size,
.dirty_watermark = fps->fps_flush_trigger,
.flush_function = NULL,
- .flush_arg = NULL,
- .cache = !!*kiblnd_tunables.kib_fmr_cache};
+ .flush_arg = NULL,
+ .cache = !!*kiblnd_tunables.kib_fmr_cache};
int rc;
LIBCFS_CPT_ALLOC(fpo, lnet_cpt_table(), fps->fps_cpt, sizeof(*fpo));
@@ -1454,7 +1456,7 @@ static int kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt,
int flush_trigger)
{
kib_fmr_pool_t *fpo;
- int rc;
+ int rc;
memset(fps, 0, sizeof(kib_fmr_poolset_t));
@@ -1485,11 +1487,11 @@ static int kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now)
void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
{
LIST_HEAD(zombies);
- kib_fmr_pool_t *fpo = fmr->fmr_pool;
+ kib_fmr_pool_t *fpo = fmr->fmr_pool;
kib_fmr_poolset_t *fps = fpo->fpo_owner;
- unsigned long now = cfs_time_current();
- kib_fmr_pool_t *tmp;
- int rc;
+ unsigned long now = cfs_time_current();
+ kib_fmr_pool_t *tmp;
+ int rc;
rc = ib_fmr_pool_unmap(fmr->fmr_pfmr);
LASSERT(rc == 0);
@@ -1525,9 +1527,9 @@ int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
__u64 iov, kib_fmr_t *fmr)
{
struct ib_pool_fmr *pfmr;
- kib_fmr_pool_t *fpo;
- __u64 version;
- int rc;
+ kib_fmr_pool_t *fpo;
+ __u64 version;
+ int rc;
again:
spin_lock(&fps->fps_lock);
@@ -1658,13 +1660,13 @@ static int kiblnd_init_poolset(kib_poolset_t *ps, int cpt,
kib_ps_node_init_t nd_init,
kib_ps_node_fini_t nd_fini)
{
- kib_pool_t *pool;
- int rc;
+ kib_pool_t *pool;
+ int rc;
memset(ps, 0, sizeof(kib_poolset_t));
- ps->ps_cpt = cpt;
- ps->ps_net = net;
+ ps->ps_cpt = cpt;
+ ps->ps_net = net;
ps->ps_pool_create = po_create;
ps->ps_pool_destroy = po_destroy;
ps->ps_node_init = nd_init;
@@ -1698,9 +1700,9 @@ static int kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now)
void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
{
LIST_HEAD(zombies);
- kib_poolset_t *ps = pool->po_owner;
- kib_pool_t *tmp;
- unsigned long now = cfs_time_current();
+ kib_poolset_t *ps = pool->po_owner;
+ kib_pool_t *tmp;
+ unsigned long now = cfs_time_current();
spin_lock(&ps->ps_lock);
@@ -1727,9 +1729,9 @@ void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps)
{
- struct list_head *node;
- kib_pool_t *pool;
- int rc;
+ struct list_head *node;
+ kib_pool_t *pool;
+ int rc;
again:
spin_lock(&ps->ps_lock);
@@ -1787,144 +1789,10 @@ struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps)
goto again;
}
-void kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr)
-{
- kib_pmr_pool_t *ppo = pmr->pmr_pool;
- struct ib_mr *mr = pmr->pmr_mr;
-
- pmr->pmr_mr = NULL;
- kiblnd_pool_free_node(&ppo->ppo_pool, &pmr->pmr_list);
- if (mr != NULL)
- ib_dereg_mr(mr);
-}
-
-int kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
- kib_rdma_desc_t *rd, __u64 *iova, kib_phys_mr_t **pp_pmr)
-{
- kib_phys_mr_t *pmr;
- struct list_head *node;
- int rc;
- int i;
-
- node = kiblnd_pool_alloc_node(&pps->pps_poolset);
- if (node == NULL) {
- CERROR("Failed to allocate PMR descriptor\n");
- return -ENOMEM;
- }
-
- pmr = container_of(node, kib_phys_mr_t, pmr_list);
- if (pmr->pmr_pool->ppo_hdev != hdev) {
- kiblnd_pool_free_node(&pmr->pmr_pool->ppo_pool, node);
- return -EAGAIN;
- }
-
- for (i = 0; i < rd->rd_nfrags; i++) {
- pmr->pmr_ipb[i].addr = rd->rd_frags[i].rf_addr;
- pmr->pmr_ipb[i].size = rd->rd_frags[i].rf_nob;
- }
-
- pmr->pmr_mr = ib_reg_phys_mr(hdev->ibh_pd,
- pmr->pmr_ipb, rd->rd_nfrags,
- IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_WRITE,
- iova);
- if (!IS_ERR(pmr->pmr_mr)) {
- pmr->pmr_iova = *iova;
- *pp_pmr = pmr;
- return 0;
- }
-
- rc = PTR_ERR(pmr->pmr_mr);
- CERROR("Failed ib_reg_phys_mr: %d\n", rc);
-
- pmr->pmr_mr = NULL;
- kiblnd_pool_free_node(&pmr->pmr_pool->ppo_pool, node);
-
- return rc;
-}
-
-static void kiblnd_destroy_pmr_pool(kib_pool_t *pool)
-{
- kib_pmr_pool_t *ppo = container_of(pool, kib_pmr_pool_t, ppo_pool);
- kib_phys_mr_t *pmr;
- kib_phys_mr_t *tmp;
-
- LASSERT(pool->po_allocated == 0);
-
- list_for_each_entry_safe(pmr, tmp, &pool->po_free_list, pmr_list) {
- LASSERT(pmr->pmr_mr == NULL);
- list_del(&pmr->pmr_list);
-
- if (pmr->pmr_ipb != NULL) {
- LIBCFS_FREE(pmr->pmr_ipb,
- IBLND_MAX_RDMA_FRAGS *
- sizeof(struct ib_phys_buf));
- }
-
- LIBCFS_FREE(pmr, sizeof(kib_phys_mr_t));
- }
-
- kiblnd_fini_pool(pool);
- if (ppo->ppo_hdev != NULL)
- kiblnd_hdev_decref(ppo->ppo_hdev);
-
- LIBCFS_FREE(ppo, sizeof(kib_pmr_pool_t));
-}
-
-static inline int kiblnd_pmr_pool_size(int ncpts)
-{
- int size = *kiblnd_tunables.kib_pmr_pool_size / ncpts;
-
- return max(IBLND_PMR_POOL, size);
-}
-
-static int kiblnd_create_pmr_pool(kib_poolset_t *ps, int size,
- kib_pool_t **pp_po)
-{
- struct kib_pmr_pool *ppo;
- struct kib_pool *pool;
- kib_phys_mr_t *pmr;
- int i;
-
- LIBCFS_CPT_ALLOC(ppo, lnet_cpt_table(),
- ps->ps_cpt, sizeof(kib_pmr_pool_t));
- if (ppo == NULL) {
- CERROR("Failed to allocate PMR pool\n");
- return -ENOMEM;
- }
-
- pool = &ppo->ppo_pool;
- kiblnd_init_pool(ps, pool, size);
-
- for (i = 0; i < size; i++) {
- LIBCFS_CPT_ALLOC(pmr, lnet_cpt_table(),
- ps->ps_cpt, sizeof(kib_phys_mr_t));
- if (pmr == NULL)
- break;
-
- pmr->pmr_pool = ppo;
- LIBCFS_CPT_ALLOC(pmr->pmr_ipb, lnet_cpt_table(), ps->ps_cpt,
- IBLND_MAX_RDMA_FRAGS * sizeof(*pmr->pmr_ipb));
- if (pmr->pmr_ipb == NULL)
- break;
-
- list_add(&pmr->pmr_list, &pool->po_free_list);
- }
-
- if (i < size) {
- ps->ps_pool_destroy(pool);
- return -ENOMEM;
- }
-
- ppo->ppo_hdev = kiblnd_current_hdev(ps->ps_net->ibn_dev);
- *pp_po = pool;
- return 0;
-}
-
static void kiblnd_destroy_tx_pool(kib_pool_t *pool)
{
- kib_tx_pool_t *tpo = container_of(pool, kib_tx_pool_t, tpo_pool);
- int i;
+ kib_tx_pool_t *tpo = container_of(pool, kib_tx_pool_t, tpo_pool);
+ int i;
LASSERT(pool->po_allocated == 0);
@@ -1979,9 +1847,9 @@ static int kiblnd_tx_pool_size(int ncpts)
static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size,
kib_pool_t **pp_po)
{
- int i;
- int npg;
- kib_pool_t *pool;
+ int i;
+ int npg;
+ kib_pool_t *pool;
kib_tx_pool_t *tpo;
LIBCFS_CPT_ALLOC(tpo, lnet_cpt_table(), ps->ps_cpt, sizeof(*tpo));
@@ -2064,19 +1932,18 @@ static void kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
{
kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t,
tps_poolset);
- kib_tx_t *tx = list_entry(node, kib_tx_t, tx_list);
+ kib_tx_t *tx = list_entry(node, kib_tx_t, tx_list);
tx->tx_cookie = tps->tps_next_tx_cookie++;
}
static void kiblnd_net_fini_pools(kib_net_t *net)
{
- int i;
+ int i;
cfs_cpt_for_each(i, lnet_cpt_table()) {
- kib_tx_poolset_t *tps;
- kib_fmr_poolset_t *fps;
- kib_pmr_poolset_t *pps;
+ kib_tx_poolset_t *tps;
+ kib_fmr_poolset_t *fps;
if (net->ibn_tx_ps != NULL) {
tps = net->ibn_tx_ps[i];
@@ -2087,11 +1954,6 @@ static void kiblnd_net_fini_pools(kib_net_t *net)
fps = net->ibn_fmr_ps[i];
kiblnd_fini_fmr_poolset(fps);
}
-
- if (net->ibn_pmr_ps != NULL) {
- pps = net->ibn_pmr_ps[i];
- kiblnd_fini_poolset(&pps->pps_poolset);
- }
}
if (net->ibn_tx_ps != NULL) {
@@ -2103,25 +1965,19 @@ static void kiblnd_net_fini_pools(kib_net_t *net)
cfs_percpt_free(net->ibn_fmr_ps);
net->ibn_fmr_ps = NULL;
}
-
- if (net->ibn_pmr_ps != NULL) {
- cfs_percpt_free(net->ibn_pmr_ps);
- net->ibn_pmr_ps = NULL;
- }
}
static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
{
- unsigned long flags;
- int cpt;
- int rc;
- int i;
+ unsigned long flags;
+ int cpt;
+ int rc = 0;
+ int i;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
if (*kiblnd_tunables.kib_map_on_demand == 0 &&
net->ibn_dev->ibd_hdev->ibh_nmrs == 1) {
- read_unlock_irqrestore(&kiblnd_data.kib_global_lock,
- flags);
+ read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
goto create_tx_pool;
}
@@ -2136,12 +1992,16 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
goto failed;
}
- /* TX pool must be created later than FMR/PMR, see LU-2268
- * for details */
+ /*
+ * TX pool must be created later than FMR, see LU-2268
+ * for details
+ */
LASSERT(net->ibn_tx_ps == NULL);
- /* premapping can fail if ibd_nmr > 1, so we always create
- * FMR/PMR pool and map-on-demand if premapping failed */
+ /*
+ * premapping can fail if ibd_nmr > 1, so we always create
+ * FMR pool and map-on-demand if premapping failed
+ */
net->ibn_fmr_ps = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(kib_fmr_poolset_t));
@@ -2157,7 +2017,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
kiblnd_fmr_pool_size(ncpts),
kiblnd_fmr_flush_trigger(ncpts));
if (rc == -ENOSYS && i == 0) /* no FMR */
- break; /* create PMR pool */
+ break;
if (rc != 0) { /* a real error */
CERROR("Can't initialize FMR pool for CPT %d: %d\n",
@@ -2174,38 +2034,8 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
cfs_percpt_free(net->ibn_fmr_ps);
net->ibn_fmr_ps = NULL;
- CWARN("Device does not support FMR, failing back to PMR\n");
-
- if (*kiblnd_tunables.kib_pmr_pool_size <
- *kiblnd_tunables.kib_ntx / 4) {
- CERROR("Can't set pmr pool size (%d) < ntx / 4(%d)\n",
- *kiblnd_tunables.kib_pmr_pool_size,
- *kiblnd_tunables.kib_ntx / 4);
- rc = -EINVAL;
- goto failed;
- }
-
- net->ibn_pmr_ps = cfs_percpt_alloc(lnet_cpt_table(),
- sizeof(kib_pmr_poolset_t));
- if (net->ibn_pmr_ps == NULL) {
- CERROR("Failed to allocate PMR pool array\n");
- rc = -ENOMEM;
- goto failed;
- }
-
- for (i = 0; i < ncpts; i++) {
- cpt = (cpts == NULL) ? i : cpts[i];
- rc = kiblnd_init_poolset(&net->ibn_pmr_ps[cpt]->pps_poolset,
- cpt, net, "PMR",
- kiblnd_pmr_pool_size(ncpts),
- kiblnd_create_pmr_pool,
- kiblnd_destroy_pmr_pool, NULL, NULL);
- if (rc != 0) {
- CERROR("Can't initialize PMR pool for CPT %d: %d\n",
- cpt, rc);
+ CWARN("Device does not support FMR\n");
goto failed;
- }
- }
create_tx_pool:
net->ibn_tx_ps = cfs_percpt_alloc(lnet_cpt_table(),
@@ -2241,7 +2071,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
{
struct ib_device_attr *attr;
- int rc;
+ int rc;
/* It's safe to assume a HCA can handle a page size
* matching that of the native system */
@@ -2284,7 +2114,7 @@ static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
static void kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev)
{
- int i;
+ int i;
if (hdev->ibh_nmrs == 0 || hdev->ibh_mrs == NULL)
return;
@@ -2317,83 +2147,31 @@ void kiblnd_hdev_destroy(kib_hca_dev_t *hdev)
static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev)
{
struct ib_mr *mr;
- int i;
- int rc;
- __u64 mm_size;
- __u64 mr_size;
- int acflags = IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_WRITE;
+ int rc;
+ int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE;
rc = kiblnd_hdev_get_attr(hdev);
if (rc != 0)
return rc;
- if (hdev->ibh_mr_shift == 64) {
- LIBCFS_ALLOC(hdev->ibh_mrs, 1 * sizeof(*hdev->ibh_mrs));
- if (hdev->ibh_mrs == NULL) {
- CERROR("Failed to allocate MRs table\n");
- return -ENOMEM;
- }
-
- hdev->ibh_mrs[0] = NULL;
- hdev->ibh_nmrs = 1;
-
- mr = ib_get_dma_mr(hdev->ibh_pd, acflags);
- if (IS_ERR(mr)) {
- CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr));
- kiblnd_hdev_cleanup_mrs(hdev);
- return PTR_ERR(mr);
- }
-
- hdev->ibh_mrs[0] = mr;
-
- goto out;
- }
-
- mr_size = 1ULL << hdev->ibh_mr_shift;
- mm_size = (unsigned long)high_memory - PAGE_OFFSET;
-
- hdev->ibh_nmrs = (int)((mm_size + mr_size - 1) >> hdev->ibh_mr_shift);
-
- if (hdev->ibh_mr_shift < 32 || hdev->ibh_nmrs > 1024) {
- /* it's 4T..., assume we will re-code at that time */
- CERROR("Can't support memory size: x%#llx with MR size: x%#llx\n",
- mm_size, mr_size);
- return -EINVAL;
- }
-
- /* create an array of MRs to cover all memory */
- LIBCFS_ALLOC(hdev->ibh_mrs, sizeof(*hdev->ibh_mrs) * hdev->ibh_nmrs);
+ LIBCFS_ALLOC(hdev->ibh_mrs, 1 * sizeof(*hdev->ibh_mrs));
if (hdev->ibh_mrs == NULL) {
- CERROR("Failed to allocate MRs' table\n");
+ CERROR("Failed to allocate MRs table\n");
return -ENOMEM;
}
- for (i = 0; i < hdev->ibh_nmrs; i++) {
- struct ib_phys_buf ipb;
- __u64 iova;
-
- ipb.size = hdev->ibh_mr_size;
- ipb.addr = i * mr_size;
- iova = ipb.addr;
-
- mr = ib_reg_phys_mr(hdev->ibh_pd, &ipb, 1, acflags, &iova);
- if (IS_ERR(mr)) {
- CERROR("Failed ib_reg_phys_mr addr %#llx size %#llx : %ld\n",
- ipb.addr, ipb.size, PTR_ERR(mr));
- kiblnd_hdev_cleanup_mrs(hdev);
- return PTR_ERR(mr);
- }
-
- LASSERT(iova == ipb.addr);
+ hdev->ibh_mrs[0] = NULL;
+ hdev->ibh_nmrs = 1;
- hdev->ibh_mrs[i] = mr;
+ mr = ib_get_dma_mr(hdev->ibh_pd, acflags);
+ if (IS_ERR(mr)) {
+ CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr));
+ kiblnd_hdev_cleanup_mrs(hdev);
+ return PTR_ERR(mr);
}
-out:
- if (hdev->ibh_mr_size != ~0ULL || hdev->ibh_nmrs != 1)
- LCONSOLE_INFO("Register global MR array, MR size: %#llx, array size: %d\n",
- hdev->ibh_mr_size, hdev->ibh_nmrs);
+ hdev->ibh_mrs[0] = mr;
+
return 0;
}
@@ -2406,10 +2184,10 @@ static int kiblnd_dummy_callback(struct rdma_cm_id *cmid,
static int kiblnd_dev_need_failover(kib_dev_t *dev)
{
- struct rdma_cm_id *cmid;
- struct sockaddr_in srcaddr;
- struct sockaddr_in dstaddr;
- int rc;
+ struct rdma_cm_id *cmid;
+ struct sockaddr_in srcaddr;
+ struct sockaddr_in dstaddr;
+ int rc;
if (dev->ibd_hdev == NULL || /* initializing */
dev->ibd_hdev->ibh_cmid == NULL || /* listener is dead */
@@ -2435,7 +2213,7 @@ static int kiblnd_dev_need_failover(kib_dev_t *dev)
}
memset(&srcaddr, 0, sizeof(srcaddr));
- srcaddr.sin_family = AF_INET;
+ srcaddr.sin_family = AF_INET;
srcaddr.sin_addr.s_addr = (__force u32)htonl(dev->ibd_ifip);
memset(&dstaddr, 0, sizeof(dstaddr));
@@ -2450,13 +2228,10 @@ static int kiblnd_dev_need_failover(kib_dev_t *dev)
return rc;
}
- if (dev->ibd_hdev->ibh_ibdev == cmid->device) {
- /* don't need device failover */
- rdma_destroy_id(cmid);
- return 0;
- }
+ rc = dev->ibd_hdev->ibh_ibdev != cmid->device; /* true for failover */
+ rdma_destroy_id(cmid);
- return 1;
+ return rc;
}
int kiblnd_dev_failover(kib_dev_t *dev)
@@ -2464,15 +2239,14 @@ int kiblnd_dev_failover(kib_dev_t *dev)
LIST_HEAD(zombie_tpo);
LIST_HEAD(zombie_ppo);
LIST_HEAD(zombie_fpo);
- struct rdma_cm_id *cmid = NULL;
- kib_hca_dev_t *hdev = NULL;
- kib_hca_dev_t *old;
- struct ib_pd *pd;
- kib_net_t *net;
- struct sockaddr_in addr;
- unsigned long flags;
- int rc = 0;
- int i;
+ struct rdma_cm_id *cmid = NULL;
+ kib_hca_dev_t *hdev = NULL;
+ struct ib_pd *pd;
+ kib_net_t *net;
+ struct sockaddr_in addr;
+ unsigned long flags;
+ int rc = 0;
+ int i;
LASSERT(*kiblnd_tunables.kib_dev_failover > 1 ||
dev->ibd_can_failover ||
@@ -2558,23 +2332,16 @@ int kiblnd_dev_failover(kib_dev_t *dev)
write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
- old = dev->ibd_hdev;
- dev->ibd_hdev = hdev; /* take over the refcount */
- hdev = old;
+ swap(dev->ibd_hdev, hdev); /* take over the refcount */
list_for_each_entry(net, &dev->ibd_nets, ibn_list) {
cfs_cpt_for_each(i, lnet_cpt_table()) {
kiblnd_fail_poolset(&net->ibn_tx_ps[i]->tps_poolset,
&zombie_tpo);
- if (net->ibn_fmr_ps != NULL) {
+ if (net->ibn_fmr_ps)
kiblnd_fail_fmr_poolset(net->ibn_fmr_ps[i],
&zombie_fpo);
-
- } else if (net->ibn_pmr_ps != NULL) {
- kiblnd_fail_poolset(&net->ibn_pmr_ps[i]->
- pps_poolset, &zombie_ppo);
- }
}
}
@@ -2614,13 +2381,13 @@ void kiblnd_destroy_dev(kib_dev_t *dev)
static kib_dev_t *kiblnd_create_dev(char *ifname)
{
struct net_device *netdev;
- kib_dev_t *dev;
- __u32 netmask;
- __u32 ip;
- int up;
- int rc;
+ kib_dev_t *dev;
+ __u32 netmask;
+ __u32 ip;
+ int up;
+ int rc;
- rc = libcfs_ipif_query(ifname, &up, &ip, &netmask);
+ rc = lnet_ipif_query(ifname, &up, &ip, &netmask);
if (rc != 0) {
CERROR("Can't query IPoIB interface %s: %d\n",
ifname, rc);
@@ -2665,14 +2432,11 @@ static kib_dev_t *kiblnd_create_dev(char *ifname)
static void kiblnd_base_shutdown(void)
{
- struct kib_sched_info *sched;
- int i;
+ struct kib_sched_info *sched;
+ int i;
LASSERT(list_empty(&kiblnd_data.kib_devs));
- CDEBUG(D_MALLOC, "before LND base cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
switch (kiblnd_data.kib_init) {
default:
LBUG();
@@ -2723,28 +2487,22 @@ static void kiblnd_base_shutdown(void)
if (kiblnd_data.kib_scheds != NULL)
cfs_percpt_free(kiblnd_data.kib_scheds);
- CDEBUG(D_MALLOC, "after LND base cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
kiblnd_data.kib_init = IBLND_INIT_NOTHING;
module_put(THIS_MODULE);
}
void kiblnd_shutdown(lnet_ni_t *ni)
{
- kib_net_t *net = ni->ni_data;
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- int i;
- unsigned long flags;
+ kib_net_t *net = ni->ni_data;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ int i;
+ unsigned long flags;
LASSERT(kiblnd_data.kib_init == IBLND_INIT_ALL);
if (net == NULL)
goto out;
- CDEBUG(D_MALLOC, "before LND net cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
write_lock_irqsave(g_lock, flags);
net->ibn_shutdown = 1;
write_unlock_irqrestore(g_lock, flags);
@@ -2789,9 +2547,6 @@ void kiblnd_shutdown(lnet_ni_t *ni)
break;
}
- CDEBUG(D_MALLOC, "after LND net cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
net->ibn_init = IBLND_INIT_NOTHING;
ni->ni_data = NULL;
@@ -2804,9 +2559,9 @@ out:
static int kiblnd_base_startup(void)
{
- struct kib_sched_info *sched;
- int rc;
- int i;
+ struct kib_sched_info *sched;
+ int rc;
+ int i;
LASSERT(kiblnd_data.kib_init == IBLND_INIT_NOTHING);
@@ -2821,8 +2576,7 @@ static int kiblnd_base_startup(void)
kiblnd_data.kib_peer_hash_size = IBLND_PEER_HASH_SIZE;
LIBCFS_ALLOC(kiblnd_data.kib_peers,
- sizeof(struct list_head) *
- kiblnd_data.kib_peer_hash_size);
+ sizeof(struct list_head) * kiblnd_data.kib_peer_hash_size);
if (kiblnd_data.kib_peers == NULL)
goto failed;
for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++)
@@ -2840,7 +2594,7 @@ static int kiblnd_base_startup(void)
goto failed;
cfs_percpt_for_each(sched, i, kiblnd_data.kib_scheds) {
- int nthrs;
+ int nthrs;
spin_lock_init(&sched->ibs_lock);
INIT_LIST_HEAD(&sched->ibs_conns);
@@ -2893,9 +2647,9 @@ static int kiblnd_base_startup(void)
static int kiblnd_start_schedulers(struct kib_sched_info *sched)
{
- int rc = 0;
- int nthrs;
- int i;
+ int rc = 0;
+ int nthrs;
+ int i;
if (sched->ibs_nthreads == 0) {
if (*kiblnd_tunables.kib_nscheds > 0) {
@@ -2913,8 +2667,8 @@ static int kiblnd_start_schedulers(struct kib_sched_info *sched)
}
for (i = 0; i < nthrs; i++) {
- long id;
- char name[20];
+ long id;
+ char name[20];
id = KIB_THREAD_ID(sched->ibs_cpt, sched->ibs_nthreads + i);
snprintf(name, sizeof(name), "kiblnd_sd_%02ld_%02ld",
@@ -2935,9 +2689,9 @@ static int kiblnd_start_schedulers(struct kib_sched_info *sched)
static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts,
int ncpts)
{
- int cpt;
- int rc;
- int i;
+ int cpt;
+ int rc;
+ int i;
for (i = 0; i < ncpts; i++) {
struct kib_sched_info *sched;
@@ -2960,10 +2714,10 @@ static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts,
static kib_dev_t *kiblnd_dev_search(char *ifname)
{
- kib_dev_t *alias = NULL;
- kib_dev_t *dev;
- char *colon;
- char *colon2;
+ kib_dev_t *alias = NULL;
+ kib_dev_t *dev;
+ char *colon;
+ char *colon2;
colon = strchr(ifname, ':');
list_for_each_entry(dev, &kiblnd_data.kib_devs, ibd_list) {
@@ -2992,13 +2746,13 @@ static kib_dev_t *kiblnd_dev_search(char *ifname)
int kiblnd_startup(lnet_ni_t *ni)
{
- char *ifname;
- kib_dev_t *ibdev = NULL;
- kib_net_t *net;
- struct timeval tv;
- unsigned long flags;
- int rc;
- int newdev;
+ char *ifname;
+ kib_dev_t *ibdev = NULL;
+ kib_net_t *net;
+ struct timespec64 tv;
+ unsigned long flags;
+ int rc;
+ int newdev;
LASSERT(ni->ni_lnd == &the_o2iblnd);
@@ -3013,8 +2767,9 @@ int kiblnd_startup(lnet_ni_t *ni)
if (net == NULL)
goto net_failed;
- do_gettimeofday(&tv);
- net->ibn_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec;
+ ktime_get_real_ts64(&tv);
+ net->ibn_incarnation = tv.tv_sec * USEC_PER_SEC +
+ tv.tv_nsec / NSEC_PER_USEC;
ni->ni_peertimeout = *kiblnd_tunables.kib_peertimeout;
ni->ni_maxtxcredits = *kiblnd_tunables.kib_credits;
@@ -3091,7 +2846,7 @@ static void __exit kiblnd_module_fini(void)
static int __init kiblnd_module_init(void)
{
- int rc;
+ int rc;
CLASSERT(sizeof(kib_msg_t) <= IBLND_MSG_SIZE);
CLASSERT(offsetof(kib_msg_t,
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index cd664d025..263db37de 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -48,7 +48,7 @@
#include <linux/uio.h>
#include <linux/uaccess.h>
-#include <asm/io.h>
+#include <linux/io.h>
#include <linux/fs.h>
#include <linux/file.h>
@@ -65,7 +65,6 @@
#include "../../../include/linux/libcfs/libcfs.h"
#include "../../../include/linux/lnet/lnet.h"
#include "../../../include/linux/lnet/lib-lnet.h"
-#include "../../../include/linux/lnet/lnet-sysctl.h"
#include <rdma/rdma_cm.h>
#include <rdma/ib_cm.h>
@@ -80,43 +79,42 @@
#define IBLND_N_SCHED_HIGH 4
typedef struct {
- 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 kib_msg_t? */
- int *kib_timeout; /* comms timeout (seconds) */
- int *kib_keepalive; /* keepalive timeout (seconds) */
- int *kib_ntx; /* # tx descs */
- int *kib_credits; /* # concurrent sends */
- int *kib_peertxcredits; /* # concurrent sends to 1 peer */
- int *kib_peerrtrcredits; /* # per-peer router buffer credits */
- int *kib_peercredits_hiw; /* # when eagerly to return credits */
- int *kib_peertimeout; /* seconds to consider peer dead */
- char **kib_default_ipif; /* default IPoIB interface */
- int *kib_retry_count;
- int *kib_rnr_retry_count;
- int *kib_concurrent_sends; /* send work queue sizing */
- int *kib_ib_mtu; /* IB MTU */
- int *kib_map_on_demand; /* map-on-demand if RD has more fragments
- * than this value, 0 disable map-on-demand */
- int *kib_pmr_pool_size; /* # physical MR in pool */
- int *kib_fmr_pool_size; /* # FMRs in pool */
- int *kib_fmr_flush_trigger; /* When to trigger FMR flush */
- int *kib_fmr_cache; /* enable FMR pool cache? */
- int *kib_require_priv_port;/* accept only privileged ports */
- int *kib_use_priv_port; /* use privileged port for active connect */
- /* # threads on each CPT */
- int *kib_nscheds;
+ 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 kib_msg_t? */
+ int *kib_timeout; /* comms timeout (seconds) */
+ int *kib_keepalive; /* keepalive timeout (seconds) */
+ int *kib_ntx; /* # tx descs */
+ int *kib_credits; /* # concurrent sends */
+ int *kib_peertxcredits; /* # concurrent sends to 1 peer */
+ int *kib_peerrtrcredits; /* # per-peer router buffer credits */
+ int *kib_peercredits_hiw; /* # when eagerly to return credits */
+ int *kib_peertimeout; /* seconds to consider peer dead */
+ char **kib_default_ipif; /* default IPoIB interface */
+ int *kib_retry_count;
+ int *kib_rnr_retry_count;
+ int *kib_concurrent_sends; /* send work queue sizing */
+ int *kib_ib_mtu; /* IB MTU */
+ int *kib_map_on_demand; /* map-on-demand if RD has more */
+ /* fragments than this value, 0 */
+ /* disable map-on-demand */
+ int *kib_fmr_pool_size; /* # FMRs in pool */
+ int *kib_fmr_flush_trigger; /* When to trigger FMR flush */
+ int *kib_fmr_cache; /* enable FMR pool cache? */
+ 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 */
} kib_tunables_t;
extern kib_tunables_t kiblnd_tunables;
-#define IBLND_MSG_QUEUE_SIZE_V1 8 /* V1 only : # messages/RDMAs in-flight */
-#define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */
+#define IBLND_MSG_QUEUE_SIZE_V1 8 /* V1 only : # messages/RDMAs in-flight */
+#define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */
-#define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */
-#define IBLND_CREDITS_MAX ((typeof(((kib_msg_t*) 0)->ibm_credits)) - 1) /* Max # of peer credits */
+#define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */
+#define IBLND_CREDITS_MAX ((typeof(((kib_msg_t *) 0)->ibm_credits)) - 1) /* Max # of peer credits */
#define IBLND_MSG_QUEUE_SIZE(v) ((v) == IBLND_MSG_VERSION_1 ? \
IBLND_MSG_QUEUE_SIZE_V1 : \
@@ -125,7 +123,9 @@ extern kib_tunables_t kiblnd_tunables;
IBLND_CREDIT_HIGHWATER_V1 : \
*kiblnd_tunables.kib_peercredits_hiw) /* when eagerly to return credits */
-#define kiblnd_rdma_create_id(cb, dev, ps, qpt) rdma_create_id(cb, dev, ps, qpt)
+#define kiblnd_rdma_create_id(cb, dev, ps, qpt) rdma_create_id(&init_net, \
+ cb, dev, \
+ ps, qpt)
static inline int
kiblnd_concurrent_sends_v1(void)
@@ -159,7 +159,6 @@ kiblnd_concurrent_sends_v1(void)
/* Pools (shared by connections on each CPT) */
/* These pools can grow at runtime, so don't need give a very large value */
#define IBLND_TX_POOL 256
-#define IBLND_PMR_POOL 256
#define IBLND_FMR_POOL 256
#define IBLND_FMR_POOL_FLUSH 192
@@ -186,34 +185,35 @@ struct kib_hca_dev;
#endif
typedef struct {
- struct list_head ibd_list; /* chain on kib_devs */
- struct list_head ibd_fail_list; /* chain on kib_failed_devs */
- __u32 ibd_ifip; /* IPoIB interface IP */
- /** IPoIB interface name */
- char ibd_ifname[KIB_IFNAME_SIZE];
- int ibd_nnets; /* # nets extant */
-
- unsigned long 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 */
- struct list_head ibd_nets;
- struct kib_hca_dev *ibd_hdev;
+ struct list_head ibd_list; /* chain on kib_devs */
+ struct list_head ibd_fail_list; /* chain on kib_failed_devs */
+ __u32 ibd_ifip; /* IPoIB interface IP */
+
+ /* IPoIB interface name */
+ char ibd_ifname[KIB_IFNAME_SIZE];
+ int ibd_nnets; /* # nets extant */
+
+ unsigned long 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 */
+ struct list_head ibd_nets;
+ struct kib_hca_dev *ibd_hdev;
} kib_dev_t;
typedef struct kib_hca_dev {
- struct rdma_cm_id *ibh_cmid; /* listener cmid */
- struct ib_device *ibh_ibdev; /* IB device */
- int ibh_page_shift; /* page shift of current HCA */
- int ibh_page_size; /* page size of current HCA */
- __u64 ibh_page_mask; /* page mask of current HCA */
- int ibh_mr_shift; /* bits shift of max MR size */
- __u64 ibh_mr_size; /* size of MR */
- int ibh_nmrs; /* # of global MRs */
- struct ib_mr **ibh_mrs; /* global MR */
- struct ib_pd *ibh_pd; /* PD */
- kib_dev_t *ibh_dev; /* owner */
- atomic_t ibh_ref; /* refcount */
+ struct rdma_cm_id *ibh_cmid; /* listener cmid */
+ struct ib_device *ibh_ibdev; /* IB device */
+ int ibh_page_shift; /* page shift of current HCA */
+ int ibh_page_size; /* page size of current HCA */
+ __u64 ibh_page_mask; /* page mask of current HCA */
+ int ibh_mr_shift; /* bits shift of max MR size */
+ __u64 ibh_mr_size; /* size of MR */
+ int ibh_nmrs; /* # of global MRs */
+ struct ib_mr **ibh_mrs; /* global MR */
+ struct ib_pd *ibh_pd; /* PD */
+ kib_dev_t *ibh_dev; /* owner */
+ atomic_t ibh_ref; /* refcount */
} kib_hca_dev_t;
/** # of seconds to keep pool alive */
@@ -222,21 +222,10 @@ typedef struct kib_hca_dev {
#define IBLND_POOL_RETRY 1
typedef struct {
- int ibp_npages; /* # pages */
- struct page *ibp_pages[0]; /* page array */
+ int ibp_npages; /* # pages */
+ struct page *ibp_pages[0]; /* page array */
} kib_pages_t;
-struct kib_pmr_pool;
-
-typedef struct {
- struct list_head pmr_list; /* chain node */
- struct ib_phys_buf *pmr_ipb; /* physical buffer */
- struct ib_mr *pmr_mr; /* IB MR */
- struct kib_pmr_pool *pmr_pool; /* owner of this MR */
- __u64 pmr_iova; /* Virtual I/O address */
- int pmr_refcount; /* reference count */
-} kib_phys_mr_t;
-
struct kib_pool;
struct kib_poolset;
@@ -251,97 +240,87 @@ struct kib_net;
#define IBLND_POOL_NAME_LEN 32
typedef struct kib_poolset {
- spinlock_t ps_lock; /* serialize */
- struct kib_net *ps_net; /* network it belongs to */
- char ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */
- struct list_head ps_pool_list; /* list of pools */
- struct list_head ps_failed_pool_list; /* failed pool list */
- unsigned long ps_next_retry; /* time stamp for retry if failed to allocate */
- int ps_increasing; /* is allocating new pool */
- int ps_pool_size; /* new pool size */
- int ps_cpt; /* CPT id */
-
- kib_ps_pool_create_t ps_pool_create; /* create a new pool */
- kib_ps_pool_destroy_t ps_pool_destroy; /* destroy a pool */
- kib_ps_node_init_t ps_node_init; /* initialize new allocated node */
- kib_ps_node_fini_t ps_node_fini; /* finalize node */
+ spinlock_t ps_lock; /* serialize */
+ struct kib_net *ps_net; /* network it belongs to */
+ char ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */
+ struct list_head ps_pool_list; /* list of pools */
+ struct list_head ps_failed_pool_list;/* failed pool list */
+ unsigned long ps_next_retry; /* time stamp for retry if */
+ /* failed to allocate */
+ int ps_increasing; /* is allocating new pool */
+ int ps_pool_size; /* new pool size */
+ int ps_cpt; /* CPT id */
+
+ kib_ps_pool_create_t ps_pool_create; /* create a new pool */
+ kib_ps_pool_destroy_t ps_pool_destroy; /* destroy a pool */
+ kib_ps_node_init_t ps_node_init; /* initialize new allocated node */
+ kib_ps_node_fini_t ps_node_fini; /* finalize node */
} kib_poolset_t;
typedef struct kib_pool {
- struct list_head po_list; /* chain on pool list */
- struct list_head po_free_list; /* pre-allocated node */
- kib_poolset_t *po_owner; /* pool_set of this pool */
- unsigned long po_deadline; /* deadline of this pool */
- int po_allocated; /* # of elements in use */
- int po_failed; /* pool is created on failed HCA */
- int po_size; /* # of pre-allocated elements */
+ struct list_head po_list; /* chain on pool list */
+ struct list_head po_free_list; /* pre-allocated node */
+ kib_poolset_t *po_owner; /* pool_set of this pool */
+ unsigned long po_deadline; /* deadline of this pool */
+ int po_allocated; /* # of elements in use */
+ int po_failed; /* pool is created on failed HCA */
+ int po_size; /* # of pre-allocated elements */
} kib_pool_t;
typedef struct {
- kib_poolset_t tps_poolset; /* pool-set */
- __u64 tps_next_tx_cookie; /* cookie of TX */
+ kib_poolset_t tps_poolset; /* pool-set */
+ __u64 tps_next_tx_cookie; /* cookie of TX */
} kib_tx_poolset_t;
typedef struct {
- kib_pool_t tpo_pool; /* pool */
- struct kib_hca_dev *tpo_hdev; /* device for this pool */
- struct kib_tx *tpo_tx_descs; /* all the tx descriptors */
- kib_pages_t *tpo_tx_pages; /* premapped tx msg pages */
+ kib_pool_t tpo_pool; /* pool */
+ struct kib_hca_dev *tpo_hdev; /* device for this pool */
+ struct kib_tx *tpo_tx_descs; /* all the tx descriptors */
+ kib_pages_t *tpo_tx_pages; /* premapped tx msg pages */
} kib_tx_pool_t;
typedef struct {
- kib_poolset_t pps_poolset; /* pool-set */
-} kib_pmr_poolset_t;
-
-typedef struct kib_pmr_pool {
- struct kib_hca_dev *ppo_hdev; /* device for this pool */
- kib_pool_t ppo_pool; /* pool */
-} kib_pmr_pool_t;
-
-typedef struct {
- spinlock_t fps_lock; /* serialize */
- struct kib_net *fps_net; /* IB network */
- struct list_head fps_pool_list; /* FMR pool list */
- struct list_head fps_failed_pool_list; /* FMR pool list */
- __u64 fps_version; /* validity stamp */
- int fps_cpt; /* CPT id */
- int fps_pool_size;
- int fps_flush_trigger;
- /* is allocating new pool */
- int fps_increasing;
- /* time stamp for retry if failed to allocate */
- unsigned long fps_next_retry;
+ spinlock_t fps_lock; /* serialize */
+ struct kib_net *fps_net; /* IB network */
+ struct list_head fps_pool_list; /* FMR pool list */
+ struct list_head fps_failed_pool_list;/* FMR pool list */
+ __u64 fps_version; /* validity stamp */
+ int fps_cpt; /* CPT id */
+ int fps_pool_size;
+ int fps_flush_trigger;
+ int fps_increasing; /* is allocating new pool */
+ unsigned long fps_next_retry; /* time stamp for retry if*/
+ /* failed to allocate */
} kib_fmr_poolset_t;
typedef struct {
- struct list_head fpo_list; /* chain on pool list */
- struct kib_hca_dev *fpo_hdev; /* device for this pool */
- kib_fmr_poolset_t *fpo_owner; /* owner of this pool */
- struct ib_fmr_pool *fpo_fmr_pool; /* IB FMR pool */
- unsigned long fpo_deadline; /* deadline of this pool */
- int fpo_failed; /* fmr pool is failed */
- int fpo_map_count; /* # of mapped FMR */
+ struct list_head fpo_list; /* chain on pool list */
+ struct kib_hca_dev *fpo_hdev; /* device for this pool */
+ kib_fmr_poolset_t *fpo_owner; /* owner of this pool */
+ struct ib_fmr_pool *fpo_fmr_pool; /* IB FMR pool */
+ unsigned long fpo_deadline; /* deadline of this pool */
+ int fpo_failed; /* fmr pool is failed */
+ int fpo_map_count; /* # of mapped FMR */
} kib_fmr_pool_t;
typedef struct {
- struct ib_pool_fmr *fmr_pfmr; /* IB pool fmr */
- kib_fmr_pool_t *fmr_pool; /* pool of FMR */
+ struct ib_pool_fmr *fmr_pfmr; /* IB pool fmr */
+ kib_fmr_pool_t *fmr_pool; /* pool of FMR */
} kib_fmr_t;
typedef struct kib_net {
- struct list_head ibn_list; /* chain on kib_dev_t::ibd_nets */
- __u64 ibn_incarnation; /* my epoch */
- int ibn_init; /* initialisation state */
- int ibn_shutdown; /* shutting down? */
+ struct list_head ibn_list; /* chain on kib_dev_t::ibd_nets */
+ __u64 ibn_incarnation;/* my epoch */
+ int ibn_init; /* initialisation state */
+ int ibn_shutdown; /* shutting down? */
- atomic_t ibn_npeers; /* # peers extant */
- atomic_t ibn_nconns; /* # connections extant */
+ atomic_t ibn_npeers; /* # peers extant */
+ atomic_t ibn_nconns; /* # connections extant */
- kib_tx_poolset_t **ibn_tx_ps; /* tx pool-set */
- kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */
- kib_pmr_poolset_t **ibn_pmr_ps; /* pmr pool-set */
+ kib_tx_poolset_t **ibn_tx_ps; /* tx pool-set */
+ kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */
- kib_dev_t *ibn_dev; /* underlying IB device */
+ kib_dev_t *ibn_dev; /* underlying IB device */
} kib_net_t;
#define KIB_THREAD_SHIFT 16
@@ -350,51 +329,36 @@ typedef struct kib_net {
#define KIB_THREAD_TID(id) ((id) & ((1UL << KIB_THREAD_SHIFT) - 1))
struct kib_sched_info {
- /* serialise */
- spinlock_t ibs_lock;
- /* schedulers sleep here */
- wait_queue_head_t ibs_waitq;
- /* conns to check for rx completions */
- struct list_head ibs_conns;
- /* number of scheduler threads */
- int ibs_nthreads;
- /* max allowed scheduler threads */
- int ibs_nthreads_max;
- int ibs_cpt; /* CPT id */
+ spinlock_t ibs_lock; /* serialise */
+ wait_queue_head_t ibs_waitq; /* schedulers sleep here */
+ struct list_head ibs_conns; /* conns to check for rx completions */
+ int ibs_nthreads; /* number of scheduler threads */
+ int ibs_nthreads_max; /* max allowed scheduler threads */
+ int ibs_cpt; /* CPT id */
};
typedef struct {
- int kib_init; /* initialisation state */
- int kib_shutdown; /* shut down? */
- struct list_head kib_devs; /* IB devices extant */
- /* list head of failed devices */
- struct list_head kib_failed_devs;
- /* schedulers sleep here */
- wait_queue_head_t kib_failover_waitq;
- atomic_t kib_nthreads; /* # live threads */
- /* stabilize net/dev/peer/conn ops */
- rwlock_t kib_global_lock;
- /* hash table of all my known peers */
- struct list_head *kib_peers;
- /* size of kib_peers */
- int kib_peer_hash_size;
- /* the connd task (serialisation assertions) */
- void *kib_connd;
- /* connections to setup/teardown */
- struct list_head kib_connd_conns;
- /* connections with zero refcount */
- struct list_head kib_connd_zombies;
- /* connection daemon sleeps here */
- wait_queue_head_t kib_connd_waitq;
- spinlock_t kib_connd_lock; /* serialise */
- struct ib_qp_attr kib_error_qpa; /* QP->ERROR */
- /* percpt data for schedulers */
- struct kib_sched_info **kib_scheds;
+ int kib_init; /* initialisation state */
+ 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 */
+ rwlock_t kib_global_lock; /* stabilize net/dev/peer/conn ops */
+ struct list_head *kib_peers; /* hash table of all my known peers */
+ int kib_peer_hash_size; /* size of kib_peers */
+ void *kib_connd; /* the connd task (serialisation assertions) */
+ struct list_head kib_connd_conns; /* connections to setup/teardown */
+ struct list_head kib_connd_zombies; /* connections with zero refcount */
+ wait_queue_head_t kib_connd_waitq; /* connection daemon sleeps here */
+ spinlock_t kib_connd_lock; /* serialise */
+ struct ib_qp_attr kib_error_qpa; /* QP->ERROR */
+ struct kib_sched_info **kib_scheds; /* percpt data for schedulers */
} kib_data_t;
-#define IBLND_INIT_NOTHING 0
-#define IBLND_INIT_DATA 1
-#define IBLND_INIT_ALL 2
+#define IBLND_INIT_NOTHING 0
+#define IBLND_INIT_DATA 1
+#define IBLND_INIT_ALL 2
/************************************************************************
* IB Wire message format.
@@ -402,242 +366,241 @@ typedef struct {
*/
typedef struct kib_connparams {
- __u16 ibcp_queue_depth;
- __u16 ibcp_max_frags;
- __u32 ibcp_max_msg_size;
+ __u16 ibcp_queue_depth;
+ __u16 ibcp_max_frags;
+ __u32 ibcp_max_msg_size;
} WIRE_ATTR kib_connparams_t;
typedef struct {
- lnet_hdr_t ibim_hdr; /* portals header */
- char ibim_payload[0]; /* piggy-backed payload */
+ lnet_hdr_t ibim_hdr; /* portals header */
+ char ibim_payload[0]; /* piggy-backed payload */
} WIRE_ATTR kib_immediate_msg_t;
typedef struct {
- __u32 rf_nob; /* # bytes this frag */
- __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */
+ __u32 rf_nob; /* # bytes this frag */
+ __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */
} WIRE_ATTR kib_rdma_frag_t;
typedef struct {
- __u32 rd_key; /* local/remote key */
- __u32 rd_nfrags; /* # fragments */
- kib_rdma_frag_t rd_frags[0]; /* buffer frags */
+ __u32 rd_key; /* local/remote key */
+ __u32 rd_nfrags; /* # fragments */
+ kib_rdma_frag_t rd_frags[0]; /* buffer frags */
} WIRE_ATTR kib_rdma_desc_t;
typedef struct {
- lnet_hdr_t ibprm_hdr; /* portals header */
- __u64 ibprm_cookie; /* opaque completion cookie */
+ lnet_hdr_t ibprm_hdr; /* portals header */
+ __u64 ibprm_cookie; /* opaque completion cookie */
} WIRE_ATTR kib_putreq_msg_t;
typedef struct {
- __u64 ibpam_src_cookie; /* reflected completion cookie */
- __u64 ibpam_dst_cookie; /* opaque completion cookie */
- kib_rdma_desc_t ibpam_rd; /* sender's sink buffer */
+ __u64 ibpam_src_cookie; /* reflected completion cookie */
+ __u64 ibpam_dst_cookie; /* opaque completion cookie */
+ kib_rdma_desc_t ibpam_rd; /* sender's sink buffer */
} WIRE_ATTR kib_putack_msg_t;
typedef struct {
- lnet_hdr_t ibgm_hdr; /* portals header */
- __u64 ibgm_cookie; /* opaque completion cookie */
- kib_rdma_desc_t ibgm_rd; /* rdma descriptor */
+ lnet_hdr_t ibgm_hdr; /* portals header */
+ __u64 ibgm_cookie; /* opaque completion cookie */
+ kib_rdma_desc_t ibgm_rd; /* rdma descriptor */
} WIRE_ATTR kib_get_msg_t;
typedef struct {
- __u64 ibcm_cookie; /* opaque completion cookie */
- __s32 ibcm_status; /* < 0 failure: >= 0 length */
+ __u64 ibcm_cookie; /* opaque completion cookie */
+ __s32 ibcm_status; /* < 0 failure: >= 0 length */
} WIRE_ATTR kib_completion_msg_t;
typedef struct {
/* First 2 fields fixed FOR ALL TIME */
- __u32 ibm_magic; /* I'm an ibnal message */
- __u16 ibm_version; /* this is my version number */
-
- __u8 ibm_type; /* msg type */
- __u8 ibm_credits; /* returned credits */
- __u32 ibm_nob; /* # bytes in whole message */
- __u32 ibm_cksum; /* checksum (0 == no checksum) */
- __u64 ibm_srcnid; /* sender's NID */
- __u64 ibm_srcstamp; /* sender's incarnation */
- __u64 ibm_dstnid; /* destination's NID */
- __u64 ibm_dststamp; /* destination's incarnation */
+ __u32 ibm_magic; /* I'm an ibnal message */
+ __u16 ibm_version; /* this is my version number */
+
+ __u8 ibm_type; /* msg type */
+ __u8 ibm_credits; /* returned credits */
+ __u32 ibm_nob; /* # bytes in whole message */
+ __u32 ibm_cksum; /* checksum (0 == no checksum) */
+ __u64 ibm_srcnid; /* sender's NID */
+ __u64 ibm_srcstamp; /* sender's incarnation */
+ __u64 ibm_dstnid; /* destination's NID */
+ __u64 ibm_dststamp; /* destination's incarnation */
union {
- kib_connparams_t connparams;
- kib_immediate_msg_t immediate;
- kib_putreq_msg_t putreq;
- kib_putack_msg_t putack;
- kib_get_msg_t get;
- kib_completion_msg_t completion;
+ kib_connparams_t connparams;
+ kib_immediate_msg_t immediate;
+ kib_putreq_msg_t putreq;
+ kib_putack_msg_t putack;
+ kib_get_msg_t get;
+ kib_completion_msg_t completion;
} WIRE_ATTR ibm_u;
} WIRE_ATTR kib_msg_t;
-#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */
+#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */
-#define IBLND_MSG_VERSION_1 0x11
-#define IBLND_MSG_VERSION_2 0x12
-#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2
+#define IBLND_MSG_VERSION_1 0x11
+#define IBLND_MSG_VERSION_2 0x12
+#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2
-#define IBLND_MSG_CONNREQ 0xc0 /* connection request */
-#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */
-#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */
-#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */
-#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */
-#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */
-#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */
-#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */
-#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */
-#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */
+#define IBLND_MSG_CONNREQ 0xc0 /* connection request */
+#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */
+#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */
+#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */
+#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */
+#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */
+#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */
+#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */
+#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */
+#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */
typedef struct {
- __u32 ibr_magic; /* sender's magic */
- __u16 ibr_version; /* sender's version */
- __u8 ibr_why; /* reject reason */
- __u8 ibr_padding; /* padding */
- __u64 ibr_incarnation; /* incarnation of peer */
- kib_connparams_t ibr_cp; /* connection parameters */
+ __u32 ibr_magic; /* sender's magic */
+ __u16 ibr_version; /* sender's version */
+ __u8 ibr_why; /* reject reason */
+ __u8 ibr_padding; /* padding */
+ __u64 ibr_incarnation; /* incarnation of peer */
+ kib_connparams_t ibr_cp; /* connection parameters */
} WIRE_ATTR kib_rej_t;
/* connection rejection reasons */
-#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */
-#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */
-#define IBLND_REJECT_FATAL 3 /* Anything else */
-
-#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer */
-#define IBLND_REJECT_CONN_STALE 5 /* stale peer */
-
-#define IBLND_REJECT_RDMA_FRAGS 6 /* Fatal: peer's rdma frags can't match mine */
-#define IBLND_REJECT_MSG_QUEUE_SIZE 7 /* Fatal: peer's msg queue size can't match mine */
+#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */
+#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */
+#define IBLND_REJECT_FATAL 3 /* Anything else */
+#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer */
+#define IBLND_REJECT_CONN_STALE 5 /* stale peer */
+#define IBLND_REJECT_RDMA_FRAGS 6 /* Fatal: peer's rdma frags can't match */
+ /* mine */
+#define IBLND_REJECT_MSG_QUEUE_SIZE 7 /* Fatal: peer's msg queue size can't */
+ /* match mine */
/***********************************************************************/
-typedef struct kib_rx /* receive message */
+typedef struct kib_rx /* receive message */
{
- struct list_head rx_list; /* queue for attention */
- struct kib_conn *rx_conn; /* owning conn */
- int rx_nob; /* # bytes received (-1 while posted) */
- enum ib_wc_status rx_status; /* completion status */
- kib_msg_t *rx_msg; /* message buffer (host vaddr) */
- __u64 rx_msgaddr; /* message buffer (I/O addr) */
- DECLARE_PCI_UNMAP_ADDR (rx_msgunmap); /* for dma_unmap_single() */
- struct ib_recv_wr rx_wrq; /* receive work item... */
- struct ib_sge rx_sge; /* ...and its memory */
+ struct list_head rx_list; /* queue for attention */
+ struct kib_conn *rx_conn; /* owning conn */
+ int rx_nob; /* # bytes received (-1 while posted) */
+ enum ib_wc_status rx_status; /* completion status */
+ kib_msg_t *rx_msg; /* message buffer (host vaddr) */
+ __u64 rx_msgaddr; /* message buffer (I/O addr) */
+ DECLARE_PCI_UNMAP_ADDR(rx_msgunmap); /* for dma_unmap_single() */
+ struct ib_recv_wr rx_wrq; /* receive work item... */
+ struct ib_sge rx_sge; /* ...and its memory */
} kib_rx_t;
-#define IBLND_POSTRX_DONT_POST 0 /* don't post */
-#define IBLND_POSTRX_NO_CREDIT 1 /* post: no credits */
-#define IBLND_POSTRX_PEER_CREDIT 2 /* post: give peer back 1 credit */
-#define IBLND_POSTRX_RSRVD_CREDIT 3 /* post: give myself back 1 reserved credit */
+#define IBLND_POSTRX_DONT_POST 0 /* don't post */
+#define IBLND_POSTRX_NO_CREDIT 1 /* post: no credits */
+#define IBLND_POSTRX_PEER_CREDIT 2 /* post: give peer back 1 credit */
+#define IBLND_POSTRX_RSRVD_CREDIT 3 /* post: give self back 1 reserved credit */
-typedef struct kib_tx /* transmit message */
+typedef struct kib_tx /* transmit message */
{
- struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */
- kib_tx_pool_t *tx_pool; /* pool I'm from */
- struct kib_conn *tx_conn; /* owning conn */
- short tx_sending; /* # tx callbacks outstanding */
- short tx_queued; /* queued for sending */
- short tx_waiting; /* waiting for peer */
- int tx_status; /* LNET completion status */
- unsigned long tx_deadline; /* completion deadline */
- __u64 tx_cookie; /* completion cookie */
- lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on completion */
- kib_msg_t *tx_msg; /* message buffer (host vaddr) */
- __u64 tx_msgaddr; /* message buffer (I/O addr) */
- DECLARE_PCI_UNMAP_ADDR (tx_msgunmap); /* for dma_unmap_single() */
- int tx_nwrq; /* # send work items */
- struct ib_send_wr *tx_wrq; /* send work items... */
- struct ib_sge *tx_sge; /* ...and their memory */
- kib_rdma_desc_t *tx_rd; /* rdma descriptor */
- int tx_nfrags; /* # entries in... */
- struct scatterlist *tx_frags; /* dma_map_sg descriptor */
- __u64 *tx_pages; /* rdma phys page addrs */
- union {
- kib_phys_mr_t *pmr; /* MR for physical buffer */
- kib_fmr_t fmr; /* FMR */
- } tx_u;
- int tx_dmadir; /* dma direction */
+ struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */
+ kib_tx_pool_t *tx_pool; /* pool I'm from */
+ struct kib_conn *tx_conn; /* owning conn */
+ short tx_sending; /* # tx callbacks outstanding */
+ short tx_queued; /* queued for sending */
+ short tx_waiting; /* waiting for peer */
+ int tx_status; /* LNET completion status */
+ unsigned long tx_deadline; /* completion deadline */
+ __u64 tx_cookie; /* completion cookie */
+ lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on completion */
+ kib_msg_t *tx_msg; /* message buffer (host vaddr) */
+ __u64 tx_msgaddr; /* message buffer (I/O addr) */
+ DECLARE_PCI_UNMAP_ADDR(tx_msgunmap); /* for dma_unmap_single() */
+ int tx_nwrq; /* # send work items */
+ struct ib_rdma_wr *tx_wrq; /* send work items... */
+ struct ib_sge *tx_sge; /* ...and their memory */
+ kib_rdma_desc_t *tx_rd; /* rdma descriptor */
+ int tx_nfrags; /* # entries in... */
+ struct scatterlist *tx_frags; /* dma_map_sg descriptor */
+ __u64 *tx_pages; /* rdma phys page addrs */
+ kib_fmr_t fmr; /* FMR */
+ int tx_dmadir; /* dma direction */
} kib_tx_t;
typedef struct kib_connvars {
- /* connection-in-progress variables */
- kib_msg_t cv_msg;
+ kib_msg_t cv_msg; /* connection-in-progress variables */
} kib_connvars_t;
typedef struct kib_conn {
- struct kib_sched_info *ibc_sched; /* scheduler information */
- struct kib_peer *ibc_peer; /* owning peer */
- kib_hca_dev_t *ibc_hdev; /* HCA bound on */
- struct list_head ibc_list; /* stash on peer's conn list */
- struct list_head ibc_sched_list; /* schedule for attention */
- __u16 ibc_version; /* version of connection */
- __u64 ibc_incarnation; /* which instance of the peer */
- atomic_t ibc_refcount; /* # users */
- 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_outstanding_credits; /* # credits to return */
- int ibc_reserved_credits;/* # ACK/DONE msg credits */
- int ibc_comms_error; /* set on comms error */
- unsigned int ibc_nrx:16; /* receive buffers owned */
- unsigned int ibc_scheduled:1; /* scheduled for attention */
- unsigned int ibc_ready:1; /* CQ callback fired */
- /* time of last send */
- unsigned long ibc_last_send;
- /** link chain for kiblnd_check_conns only */
- struct list_head ibc_connd_list;
- /** rxs completed before ESTABLISHED */
- struct list_head ibc_early_rxs;
- /** IBLND_MSG_NOOPs for IBLND_MSG_VERSION_1 */
- struct list_head ibc_tx_noops;
- struct list_head ibc_tx_queue; /* sends that need a credit */
- struct list_head ibc_tx_queue_nocred;/* sends that don't need a credit */
- struct list_head ibc_tx_queue_rsrvd; /* sends that need to reserve an ACK/DONE msg */
- struct list_head ibc_active_txs; /* active tx awaiting completion */
- spinlock_t ibc_lock; /* serialise */
- kib_rx_t *ibc_rxs; /* the rx descs */
- kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */
-
- struct rdma_cm_id *ibc_cmid; /* CM id */
- struct ib_cq *ibc_cq; /* completion queue */
-
- kib_connvars_t *ibc_connvars; /* in-progress connection state */
+ struct kib_sched_info *ibc_sched; /* scheduler information */
+ struct kib_peer *ibc_peer; /* owning peer */
+ kib_hca_dev_t *ibc_hdev; /* HCA bound on */
+ struct list_head ibc_list; /* stash on peer's conn list */
+ struct list_head ibc_sched_list; /* schedule for attention */
+ __u16 ibc_version; /* version of connection */
+ __u64 ibc_incarnation; /* which instance of the peer */
+ atomic_t ibc_refcount; /* # users */
+ 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_outstanding_credits; /* # credits to return */
+ int ibc_reserved_credits; /* # ACK/DONE msg credits */
+ int ibc_comms_error; /* set on comms error */
+ unsigned int ibc_nrx:16; /* receive buffers owned */
+ unsigned int ibc_scheduled:1; /* scheduled for attention */
+ unsigned int ibc_ready:1; /* CQ callback fired */
+ unsigned long ibc_last_send; /* time of last send */
+ struct list_head ibc_connd_list; /* link chain for */
+ /* kiblnd_check_conns only */
+ struct list_head ibc_early_rxs; /* rxs completed before ESTABLISHED */
+ struct list_head ibc_tx_noops; /* IBLND_MSG_NOOPs for */
+ /* IBLND_MSG_VERSION_1 */
+ struct list_head ibc_tx_queue; /* sends that need a credit */
+ struct list_head ibc_tx_queue_nocred; /* sends that don't need a */
+ /* credit */
+ struct list_head ibc_tx_queue_rsrvd; /* sends that need to */
+ /* reserve an ACK/DONE msg */
+ struct list_head ibc_active_txs; /* active tx awaiting completion */
+ spinlock_t ibc_lock; /* serialise */
+ kib_rx_t *ibc_rxs; /* the rx descs */
+ kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */
+
+ struct rdma_cm_id *ibc_cmid; /* CM id */
+ struct ib_cq *ibc_cq; /* completion queue */
+
+ kib_connvars_t *ibc_connvars; /* in-progress connection state */
} kib_conn_t;
-#define IBLND_CONN_INIT 0 /* being initialised */
-#define IBLND_CONN_ACTIVE_CONNECT 1 /* active sending req */
-#define IBLND_CONN_PASSIVE_WAIT 2 /* passive waiting for rtu */
-#define IBLND_CONN_ESTABLISHED 3 /* connection established */
-#define IBLND_CONN_CLOSING 4 /* being closed */
-#define IBLND_CONN_DISCONNECTED 5 /* disconnected */
+#define IBLND_CONN_INIT 0 /* being initialised */
+#define IBLND_CONN_ACTIVE_CONNECT 1 /* active sending req */
+#define IBLND_CONN_PASSIVE_WAIT 2 /* passive waiting for rtu */
+#define IBLND_CONN_ESTABLISHED 3 /* connection established */
+#define IBLND_CONN_CLOSING 4 /* being closed */
+#define IBLND_CONN_DISCONNECTED 5 /* disconnected */
typedef struct kib_peer {
- struct list_head ibp_list; /* stash on global peer list */
- lnet_nid_t ibp_nid; /* who's on the other end(s) */
- lnet_ni_t *ibp_ni; /* LNet interface */
- atomic_t ibp_refcount; /* # users */
- struct list_head ibp_conns; /* all active connections */
- struct list_head ibp_tx_queue; /* msgs waiting for a conn */
- __u16 ibp_version; /* version of peer */
- __u64 ibp_incarnation; /* incarnation of peer */
- int ibp_connecting; /* current active connection attempts */
- int ibp_accepting; /* current passive connection attempts */
- int ibp_error; /* errno on closing this peer */
- unsigned long ibp_last_alive; /* when (in jiffies) I was last alive */
+ struct list_head ibp_list; /* stash on global peer list */
+ lnet_nid_t ibp_nid; /* who's on the other end(s) */
+ lnet_ni_t *ibp_ni; /* LNet interface */
+ atomic_t ibp_refcount; /* # users */
+ struct list_head ibp_conns; /* all active connections */
+ struct list_head ibp_tx_queue; /* msgs waiting for a conn */
+ __u16 ibp_version; /* version of peer */
+ __u64 ibp_incarnation; /* incarnation of peer */
+ int ibp_connecting; /* current active connection attempts
+ */
+ int ibp_accepting; /* current passive connection attempts
+ */
+ int ibp_error; /* errno on closing this peer */
+ unsigned long ibp_last_alive; /* when (in jiffies) I was last alive
+ */
} kib_peer_t;
-extern kib_data_t kiblnd_data;
+extern kib_data_t kiblnd_data;
-extern void kiblnd_hdev_destroy(kib_hca_dev_t *hdev);
+void kiblnd_hdev_destroy(kib_hca_dev_t *hdev);
static inline void
kiblnd_hdev_addref_locked(kib_hca_dev_t *hdev)
{
- LASSERT (atomic_read(&hdev->ibh_ref) > 0);
+ LASSERT(atomic_read(&hdev->ibh_ref) > 0);
atomic_inc(&hdev->ibh_ref);
}
static inline void
kiblnd_hdev_decref(kib_hca_dev_t *hdev)
{
- LASSERT (atomic_read(&hdev->ibh_ref) > 0);
+ LASSERT(atomic_read(&hdev->ibh_ref) > 0);
if (atomic_dec_and_test(&hdev->ibh_ref))
kiblnd_hdev_destroy(hdev);
}
@@ -684,7 +647,7 @@ do { \
do { \
CDEBUG(D_NET, "peer[%p] -> %s (%d)++\n", \
(peer), libcfs_nid2str((peer)->ibp_nid), \
- atomic_read (&(peer)->ibp_refcount)); \
+ atomic_read(&(peer)->ibp_refcount)); \
atomic_inc(&(peer)->ibp_refcount); \
} while (0)
@@ -692,32 +655,32 @@ do { \
do { \
CDEBUG(D_NET, "peer[%p] -> %s (%d)--\n", \
(peer), libcfs_nid2str((peer)->ibp_nid), \
- atomic_read (&(peer)->ibp_refcount)); \
+ atomic_read(&(peer)->ibp_refcount)); \
LASSERT_ATOMIC_POS(&(peer)->ibp_refcount); \
if (atomic_dec_and_test(&(peer)->ibp_refcount)) \
kiblnd_destroy_peer(peer); \
} while (0)
static inline struct list_head *
-kiblnd_nid2peerlist (lnet_nid_t nid)
+kiblnd_nid2peerlist(lnet_nid_t nid)
{
unsigned int hash =
((unsigned int)nid) % kiblnd_data.kib_peer_hash_size;
- return (&kiblnd_data.kib_peers [hash]);
+ return &kiblnd_data.kib_peers[hash];
}
static inline int
-kiblnd_peer_active (kib_peer_t *peer)
+kiblnd_peer_active(kib_peer_t *peer)
{
/* Am I in the peer hash table? */
- return (!list_empty(&peer->ibp_list));
+ return !list_empty(&peer->ibp_list);
}
static inline kib_conn_t *
-kiblnd_get_conn_locked (kib_peer_t *peer)
+kiblnd_get_conn_locked(kib_peer_t *peer)
{
- LASSERT (!list_empty(&peer->ibp_conns));
+ LASSERT(!list_empty(&peer->ibp_conns));
/* just return the first connection */
return list_entry(peer->ibp_conns.next, kib_conn_t, ibc_list);
@@ -734,7 +697,7 @@ kiblnd_send_keepalive(kib_conn_t *conn)
static inline int
kiblnd_need_noop(kib_conn_t *conn)
{
- LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
+ LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
if (conn->ibc_outstanding_credits <
IBLND_CREDITS_HIGHWATER(conn->ibc_version) &&
@@ -771,7 +734,7 @@ kiblnd_abort_receives(kib_conn_t *conn)
}
static inline const char *
-kiblnd_queue2str (kib_conn_t *conn, struct list_head *q)
+kiblnd_queue2str(kib_conn_t *conn, struct list_head *q)
{
if (q == &conn->ibc_tx_queue)
return "tx_queue";
@@ -789,8 +752,8 @@ kiblnd_queue2str (kib_conn_t *conn, struct list_head *q)
return NULL;
}
-/* CAVEAT EMPTOR: We rely on descriptor alignment to allow us to use the
- * lowest bits of the work request id to stash the work item type. */
+/* CAVEAT EMPTOR: We rely on descriptor alignment to allow us to use the */
+/* lowest bits of the work request id to stash the work item type. */
#define IBLND_WID_TX 0
#define IBLND_WID_RDMA 1
@@ -798,43 +761,43 @@ kiblnd_queue2str (kib_conn_t *conn, struct list_head *q)
#define IBLND_WID_MASK 3UL
static inline __u64
-kiblnd_ptr2wreqid (void *ptr, int type)
+kiblnd_ptr2wreqid(void *ptr, int type)
{
unsigned long lptr = (unsigned long)ptr;
- LASSERT ((lptr & IBLND_WID_MASK) == 0);
- LASSERT ((type & ~IBLND_WID_MASK) == 0);
+ LASSERT((lptr & IBLND_WID_MASK) == 0);
+ LASSERT((type & ~IBLND_WID_MASK) == 0);
return (__u64)(lptr | type);
}
static inline void *
-kiblnd_wreqid2ptr (__u64 wreqid)
+kiblnd_wreqid2ptr(__u64 wreqid)
{
return (void *)(((unsigned long)wreqid) & ~IBLND_WID_MASK);
}
static inline int
-kiblnd_wreqid2type (__u64 wreqid)
+kiblnd_wreqid2type(__u64 wreqid)
{
- return (wreqid & IBLND_WID_MASK);
+ return wreqid & IBLND_WID_MASK;
}
static inline void
-kiblnd_set_conn_state (kib_conn_t *conn, int state)
+kiblnd_set_conn_state(kib_conn_t *conn, int state)
{
conn->ibc_state = state;
mb();
}
static inline void
-kiblnd_init_msg (kib_msg_t *msg, int type, int body_nob)
+kiblnd_init_msg(kib_msg_t *msg, int type, int body_nob)
{
msg->ibm_type = type;
msg->ibm_nob = offsetof(kib_msg_t, ibm_u) + body_nob;
}
static inline int
-kiblnd_rd_size (kib_rdma_desc_t *rd)
+kiblnd_rd_size(kib_rdma_desc_t *rd)
{
int i;
int size;
@@ -870,7 +833,7 @@ kiblnd_rd_consume_frag(kib_rdma_desc_t *rd, int index, __u32 nob)
rd->rd_frags[index].rf_addr += nob;
rd->rd_frags[index].rf_nob -= nob;
} else {
- index ++;
+ index++;
}
return index;
@@ -879,15 +842,14 @@ kiblnd_rd_consume_frag(kib_rdma_desc_t *rd, int index, __u32 nob)
static inline int
kiblnd_rd_msg_size(kib_rdma_desc_t *rd, int msgtype, int n)
{
- LASSERT (msgtype == IBLND_MSG_GET_REQ ||
- msgtype == IBLND_MSG_PUT_ACK);
+ LASSERT(msgtype == IBLND_MSG_GET_REQ ||
+ msgtype == IBLND_MSG_PUT_ACK);
return msgtype == IBLND_MSG_GET_REQ ?
offsetof(kib_get_msg_t, ibgm_rd.rd_frags[n]) :
offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[n]);
}
-
static inline __u64
kiblnd_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
{
@@ -937,13 +899,12 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev,
return ib_sg_dma_len(dev, sg);
}
-/* XXX We use KIBLND_CONN_PARAM(e) as writable buffer, it's not strictly
- * right because OFED1.2 defines it as const, to use it we have to add
- * (void *) cast to overcome "const" */
-
-#define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data)
-#define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len)
+/* XXX We use KIBLND_CONN_PARAM(e) as writable buffer, it's not strictly */
+/* right because OFED1.2 defines it as const, to use it we have to add */
+/* (void *) cast to overcome "const" */
+#define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data)
+#define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len)
struct ib_mr *kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev,
kib_rdma_desc_t *rd);
@@ -951,9 +912,6 @@ struct ib_mr *kiblnd_find_dma_mr(kib_hca_dev_t *hdev,
__u64 addr, __u64 size);
void kiblnd_map_rx_descs(kib_conn_t *conn);
void kiblnd_unmap_rx_descs(kib_conn_t *conn);
-int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
- kib_rdma_desc_t *rd, int nfrags);
-void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx);
void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node);
struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps);
@@ -961,57 +919,53 @@ int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages,
int npages, __u64 iov, kib_fmr_t *fmr);
void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status);
-int kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
- kib_rdma_desc_t *rd, __u64 *iova, kib_phys_mr_t **pp_pmr);
-void kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr);
-
-int kiblnd_startup (lnet_ni_t *ni);
-void kiblnd_shutdown (lnet_ni_t *ni);
-int kiblnd_ctl (lnet_ni_t *ni, unsigned int cmd, void *arg);
-void kiblnd_query (struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when);
+int kiblnd_startup(lnet_ni_t *ni);
+void kiblnd_shutdown(lnet_ni_t *ni);
+int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
+void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when);
int kiblnd_tunables_init(void);
void kiblnd_tunables_fini(void);
-int kiblnd_connd (void *arg);
+int kiblnd_connd(void *arg);
int kiblnd_scheduler(void *arg);
int kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name);
-int kiblnd_failover_thread (void *arg);
+int kiblnd_failover_thread(void *arg);
int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages);
-void kiblnd_free_pages (kib_pages_t *p);
+void kiblnd_free_pages(kib_pages_t *p);
int kiblnd_cm_callback(struct rdma_cm_id *cmid,
struct rdma_cm_event *event);
int kiblnd_translate_mtu(int value);
int kiblnd_dev_failover(kib_dev_t *dev);
-int kiblnd_create_peer (lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid);
-void kiblnd_destroy_peer (kib_peer_t *peer);
-void kiblnd_destroy_dev (kib_dev_t *dev);
-void kiblnd_unlink_peer_locked (kib_peer_t *peer);
-void kiblnd_peer_alive (kib_peer_t *peer);
-kib_peer_t *kiblnd_find_peer_locked (lnet_nid_t nid);
-void kiblnd_peer_connect_failed (kib_peer_t *peer, int active, int error);
-int kiblnd_close_stale_conns_locked (kib_peer_t *peer,
+int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid);
+void kiblnd_destroy_peer(kib_peer_t *peer);
+void kiblnd_destroy_dev(kib_dev_t *dev);
+void kiblnd_unlink_peer_locked(kib_peer_t *peer);
+void kiblnd_peer_alive(kib_peer_t *peer);
+kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid);
+void kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error);
+int kiblnd_close_stale_conns_locked(kib_peer_t *peer,
int version, __u64 incarnation);
-int kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why);
+int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why);
void kiblnd_connreq_done(kib_conn_t *conn, int status);
-kib_conn_t *kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid,
+kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
int state, int version);
-void kiblnd_destroy_conn (kib_conn_t *conn);
-void kiblnd_close_conn (kib_conn_t *conn, int error);
-void kiblnd_close_conn_locked (kib_conn_t *conn, int error);
+void kiblnd_destroy_conn(kib_conn_t *conn);
+void kiblnd_close_conn(kib_conn_t *conn, int error);
+void kiblnd_close_conn_locked(kib_conn_t *conn, int error);
-int kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
+int kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
int nob, kib_rdma_desc_t *dstrd, __u64 dstcookie);
-void kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid);
-void kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn);
-void kiblnd_queue_tx (kib_tx_t *tx, kib_conn_t *conn);
-void kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob);
-void kiblnd_txlist_done (lnet_ni_t *ni, struct list_head *txlist,
+void kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid);
+void kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn);
+void kiblnd_queue_tx(kib_tx_t *tx, kib_conn_t *conn);
+void kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob);
+void kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist,
int status);
void kiblnd_check_sends (kib_conn_t *conn);
@@ -1019,10 +973,10 @@ void kiblnd_qp_event(struct ib_event *event, void *arg);
void kiblnd_cq_event(struct ib_event *event, void *arg);
void kiblnd_cq_completion(struct ib_cq *cq, void *arg);
-void kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg, int version,
+void kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version,
int credits, lnet_nid_t dstnid, __u64 dststamp);
int kiblnd_unpack_msg(kib_msg_t *msg, int nob);
-int kiblnd_post_rx (kib_rx_t *rx, int credit);
+int kiblnd_post_rx(kib_rx_t *rx, int credit);
int kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
int kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index dbf374983..260750354 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -40,13 +40,15 @@
#include "o2iblnd.h"
+static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx);
+
static void
kiblnd_tx_done(lnet_ni_t *ni, kib_tx_t *tx)
{
lnet_msg_t *lntmsg[2];
- kib_net_t *net = ni->ni_data;
- int rc;
- int i;
+ kib_net_t *net = ni->ni_data;
+ int rc;
+ int i;
LASSERT(net != NULL);
LASSERT(!in_interrupt());
@@ -102,10 +104,10 @@ kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status)
static kib_tx_t *
kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target)
{
- kib_net_t *net = (kib_net_t *)ni->ni_data;
- struct list_head *node;
- kib_tx_t *tx;
- kib_tx_poolset_t *tps;
+ kib_net_t *net = (kib_net_t *)ni->ni_data;
+ struct list_head *node;
+ kib_tx_t *tx;
+ kib_tx_poolset_t *tps;
tps = net->ibn_tx_ps[lnet_cpt_of_nid(target)];
node = kiblnd_pool_alloc_node(&tps->tps_poolset);
@@ -121,7 +123,6 @@ kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target)
LASSERT(tx->tx_conn == NULL);
LASSERT(tx->tx_lntmsg[0] == NULL);
LASSERT(tx->tx_lntmsg[1] == NULL);
- LASSERT(tx->tx_u.pmr == NULL);
LASSERT(tx->tx_nfrags == 0);
return tx;
@@ -130,9 +131,9 @@ kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target)
static void
kiblnd_drop_rx(kib_rx_t *rx)
{
- kib_conn_t *conn = rx->rx_conn;
- struct kib_sched_info *sched = conn->ibc_sched;
- unsigned long flags;
+ kib_conn_t *conn = rx->rx_conn;
+ struct kib_sched_info *sched = conn->ibc_sched;
+ unsigned long flags;
spin_lock_irqsave(&sched->ibs_lock, flags);
LASSERT(conn->ibc_nrx > 0);
@@ -145,11 +146,11 @@ kiblnd_drop_rx(kib_rx_t *rx)
int
kiblnd_post_rx(kib_rx_t *rx, int credit)
{
- kib_conn_t *conn = rx->rx_conn;
- kib_net_t *net = conn->ibc_peer->ibp_ni->ni_data;
- struct ib_recv_wr *bad_wrq = NULL;
- struct ib_mr *mr;
- int rc;
+ kib_conn_t *conn = rx->rx_conn;
+ kib_net_t *net = conn->ibc_peer->ibp_ni->ni_data;
+ struct ib_recv_wr *bad_wrq = NULL;
+ struct ib_mr *mr;
+ int rc;
LASSERT(net != NULL);
LASSERT(!in_interrupt());
@@ -164,10 +165,10 @@ kiblnd_post_rx(kib_rx_t *rx, int credit)
rx->rx_sge.addr = rx->rx_msgaddr;
rx->rx_sge.length = IBLND_MSG_SIZE;
- rx->rx_wrq.next = NULL;
+ rx->rx_wrq.next = NULL;
rx->rx_wrq.sg_list = &rx->rx_sge;
rx->rx_wrq.num_sge = 1;
- rx->rx_wrq.wr_id = kiblnd_ptr2wreqid(rx, IBLND_WID_RX);
+ rx->rx_wrq.wr_id = kiblnd_ptr2wreqid(rx, IBLND_WID_RX);
LASSERT(conn->ibc_state >= IBLND_CONN_INIT);
LASSERT(rx->rx_nob >= 0); /* not posted */
@@ -179,24 +180,28 @@ kiblnd_post_rx(kib_rx_t *rx, int credit)
rx->rx_nob = -1; /* flag posted */
+ /* NB: need an extra reference after ib_post_recv because we don't
+ * own this rx (and rx::rx_conn) anymore, LU-5678.
+ */
+ kiblnd_conn_addref(conn);
rc = ib_post_recv(conn->ibc_cmid->qp, &rx->rx_wrq, &bad_wrq);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
CERROR("Can't post rx for %s: %d, bad_wrq: %p\n",
libcfs_nid2str(conn->ibc_peer->ibp_nid), rc, bad_wrq);
rx->rx_nob = 0;
}
if (conn->ibc_state < IBLND_CONN_ESTABLISHED) /* Initial post */
- return rc;
+ goto out;
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
kiblnd_close_conn(conn, rc);
kiblnd_drop_rx(rx); /* No more posts for this rx */
- return rc;
+ goto out;
}
if (credit == IBLND_POSTRX_NO_CREDIT)
- return 0;
+ goto out;
spin_lock(&conn->ibc_lock);
if (credit == IBLND_POSTRX_PEER_CREDIT)
@@ -206,13 +211,15 @@ kiblnd_post_rx(kib_rx_t *rx, int credit)
spin_unlock(&conn->ibc_lock);
kiblnd_check_sends(conn);
- return 0;
+out:
+ kiblnd_conn_decref(conn);
+ return rc;
}
static kib_tx_t *
kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie)
{
- struct list_head *tmp;
+ struct list_head *tmp;
list_for_each(tmp, &conn->ibc_active_txs) {
kib_tx_t *tx = list_entry(tmp, kib_tx_t, tx_list);
@@ -237,9 +244,9 @@ kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie)
static void
kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie)
{
- kib_tx_t *tx;
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- int idle;
+ kib_tx_t *tx;
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ int idle;
spin_lock(&conn->ibc_lock);
@@ -254,11 +261,10 @@ kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie)
}
if (tx->tx_status == 0) { /* success so far */
- if (status < 0) { /* failed? */
+ if (status < 0) /* failed? */
tx->tx_status = status;
- } else if (txtype == IBLND_MSG_GET_REQ) {
+ else if (txtype == IBLND_MSG_GET_REQ)
lnet_set_reply_msg_len(ni, tx->tx_lntmsg[1], status);
- }
}
tx->tx_waiting = 0;
@@ -276,8 +282,8 @@ kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie)
static void
kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie)
{
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- kib_tx_t *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid);
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ kib_tx_t *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid);
if (tx == NULL) {
CERROR("Can't get tx for completion %x for %s\n",
@@ -295,14 +301,14 @@ kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie)
static void
kiblnd_handle_rx(kib_rx_t *rx)
{
- kib_msg_t *msg = rx->rx_msg;
- kib_conn_t *conn = rx->rx_conn;
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- int credits = msg->ibm_credits;
- kib_tx_t *tx;
- int rc = 0;
- int rc2;
- int post_credit;
+ kib_msg_t *msg = rx->rx_msg;
+ kib_conn_t *conn = rx->rx_conn;
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ int credits = msg->ibm_credits;
+ kib_tx_t *tx;
+ int rc = 0;
+ int rc2;
+ int post_credit;
LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
@@ -456,12 +462,12 @@ kiblnd_handle_rx(kib_rx_t *rx)
static void
kiblnd_rx_complete(kib_rx_t *rx, int status, int nob)
{
- kib_msg_t *msg = rx->rx_msg;
- kib_conn_t *conn = rx->rx_conn;
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- kib_net_t *net = ni->ni_data;
- int rc;
- int err = -EIO;
+ kib_msg_t *msg = rx->rx_msg;
+ kib_conn_t *conn = rx->rx_conn;
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ kib_net_t *net = ni->ni_data;
+ int rc;
+ int err = -EIO;
LASSERT(net != NULL);
LASSERT(rx->rx_nob < 0); /* was posted */
@@ -502,8 +508,8 @@ kiblnd_rx_complete(kib_rx_t *rx, int status, int nob)
/* racing with connection establishment/teardown! */
if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- unsigned long flags;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ unsigned long flags;
write_lock_irqsave(g_lock, flags);
/* must check holding global lock to eliminate race */
@@ -550,19 +556,19 @@ kiblnd_kvaddr_to_page(unsigned long vaddr)
static int
kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
{
- kib_hca_dev_t *hdev;
- __u64 *pages = tx->tx_pages;
- kib_fmr_poolset_t *fps;
- int npages;
- int size;
- int cpt;
- int rc;
- int i;
+ kib_hca_dev_t *hdev;
+ __u64 *pages = tx->tx_pages;
+ kib_fmr_poolset_t *fps;
+ int npages;
+ int size;
+ int cpt;
+ int rc;
+ int i;
LASSERT(tx->tx_pool != NULL);
LASSERT(tx->tx_pool->tpo_pool.po_owner != NULL);
- hdev = tx->tx_pool->tpo_hdev;
+ hdev = tx->tx_pool->tpo_hdev;
for (i = 0, npages = 0; i < rd->rd_nfrags; i++) {
for (size = 0; size < rd->rd_frags[i].rf_nob;
@@ -575,7 +581,7 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
cpt = tx->tx_pool->tpo_pool.po_owner->ps_cpt;
fps = net->ibn_fmr_ps[cpt];
- rc = kiblnd_fmr_pool_map(fps, pages, npages, 0, &tx->tx_u.fmr);
+ rc = kiblnd_fmr_pool_map(fps, pages, npages, 0, &tx->fmr);
if (rc != 0) {
CERROR("Can't map %d pages: %d\n", npages, rc);
return rc;
@@ -583,65 +589,24 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
/* If rd is not tx_rd, it's going to get sent to a peer, who will need
* the rkey */
- rd->rd_key = (rd != tx->tx_rd) ? tx->tx_u.fmr.fmr_pfmr->fmr->rkey :
- tx->tx_u.fmr.fmr_pfmr->fmr->lkey;
+ rd->rd_key = (rd != tx->tx_rd) ? tx->fmr.fmr_pfmr->fmr->rkey :
+ tx->fmr.fmr_pfmr->fmr->lkey;
rd->rd_frags[0].rf_addr &= ~hdev->ibh_page_mask;
- rd->rd_frags[0].rf_nob = nob;
+ rd->rd_frags[0].rf_nob = nob;
rd->rd_nfrags = 1;
return 0;
}
-static int
-kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
+static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
{
- kib_hca_dev_t *hdev;
- kib_pmr_poolset_t *pps;
- __u64 iova;
- int cpt;
- int rc;
-
- LASSERT(tx->tx_pool != NULL);
- LASSERT(tx->tx_pool->tpo_pool.po_owner != NULL);
-
- hdev = tx->tx_pool->tpo_hdev;
-
- iova = rd->rd_frags[0].rf_addr & ~hdev->ibh_page_mask;
-
- cpt = tx->tx_pool->tpo_pool.po_owner->ps_cpt;
-
- pps = net->ibn_pmr_ps[cpt];
- rc = kiblnd_pmr_pool_map(pps, hdev, rd, &iova, &tx->tx_u.pmr);
- if (rc != 0) {
- CERROR("Failed to create MR by phybuf: %d\n", rc);
- return rc;
- }
-
- /* If rd is not tx_rd, it's going to get sent to a peer, who will need
- * the rkey */
- rd->rd_key = (rd != tx->tx_rd) ? tx->tx_u.pmr->pmr_mr->rkey :
- tx->tx_u.pmr->pmr_mr->lkey;
- rd->rd_nfrags = 1;
- rd->rd_frags[0].rf_addr = iova;
- rd->rd_frags[0].rf_nob = nob;
-
- return 0;
-}
-
-void
-kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
-{
- kib_net_t *net = ni->ni_data;
+ kib_net_t *net = ni->ni_data;
LASSERT(net != NULL);
- if (net->ibn_fmr_ps != NULL && tx->tx_u.fmr.fmr_pfmr != NULL) {
- kiblnd_fmr_pool_unmap(&tx->tx_u.fmr, tx->tx_status);
- tx->tx_u.fmr.fmr_pfmr = NULL;
-
- } else if (net->ibn_pmr_ps != NULL && tx->tx_u.pmr != NULL) {
- kiblnd_pmr_pool_unmap(tx->tx_u.pmr);
- tx->tx_u.pmr = NULL;
+ if (net->ibn_fmr_ps && tx->fmr.fmr_pfmr) {
+ kiblnd_fmr_pool_unmap(&tx->fmr, tx->tx_status);
+ tx->fmr.fmr_pfmr = NULL;
}
if (tx->tx_nfrags != 0) {
@@ -651,24 +616,22 @@ kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
}
}
-int
-kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
- kib_rdma_desc_t *rd, int nfrags)
+static int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
+ int nfrags)
{
- kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
- kib_net_t *net = ni->ni_data;
- struct ib_mr *mr = NULL;
- __u32 nob;
- int i;
+ kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
+ kib_net_t *net = ni->ni_data;
+ struct ib_mr *mr = NULL;
+ __u32 nob;
+ int i;
/* If rd is not tx_rd, it's going to get sent to a peer and I'm the
* RDMA sink */
tx->tx_dmadir = (rd != tx->tx_rd) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
tx->tx_nfrags = nfrags;
- rd->rd_nfrags =
- kiblnd_dma_map_sg(hdev->ibh_ibdev,
- tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);
+ rd->rd_nfrags = kiblnd_dma_map_sg(hdev->ibh_ibdev, tx->tx_frags,
+ tx->tx_nfrags, tx->tx_dmadir);
for (i = 0, nob = 0; i < rd->rd_nfrags; i++) {
rd->rd_frags[i].rf_nob = kiblnd_sg_dma_len(
@@ -688,23 +651,20 @@ kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
if (net->ibn_fmr_ps != NULL)
return kiblnd_fmr_map_tx(net, tx, rd, nob);
- else if (net->ibn_pmr_ps != NULL)
- return kiblnd_pmr_map_tx(net, tx, rd, nob);
return -EINVAL;
}
-
static int
kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
unsigned int niov, struct kvec *iov, int offset, int nob)
{
- kib_net_t *net = ni->ni_data;
- struct page *page;
+ kib_net_t *net = ni->ni_data;
+ struct page *page;
struct scatterlist *sg;
- unsigned long vaddr;
- int fragnob;
- int page_offset;
+ unsigned long vaddr;
+ int fragnob;
+ int page_offset;
LASSERT(nob > 0);
LASSERT(niov > 0);
@@ -752,9 +712,9 @@ static int
kiblnd_setup_rd_kiov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
int nkiov, lnet_kiov_t *kiov, int offset, int nob)
{
- kib_net_t *net = ni->ni_data;
+ kib_net_t *net = ni->ni_data;
struct scatterlist *sg;
- int fragnob;
+ int fragnob;
CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob);
@@ -793,11 +753,11 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
__releases(conn->ibc_lock)
__acquires(conn->ibc_lock)
{
- kib_msg_t *msg = tx->tx_msg;
- kib_peer_t *peer = conn->ibc_peer;
- int ver = conn->ibc_version;
- int rc;
- int done;
+ kib_msg_t *msg = tx->tx_msg;
+ kib_peer_t *peer = conn->ibc_peer;
+ int ver = conn->ibc_version;
+ int rc;
+ int done;
struct ib_send_wr *bad_wrq;
LASSERT(tx->tx_queued);
@@ -878,8 +838,7 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
/* close_conn will launch failover */
rc = -ENETDOWN;
} else {
- rc = ib_post_send(conn->ibc_cmid->qp,
- tx->tx_wrq, &bad_wrq);
+ rc = ib_post_send(conn->ibc_cmid->qp, &tx->tx_wrq->wr, &bad_wrq);
}
conn->ibc_last_send = jiffies;
@@ -925,9 +884,9 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
void
kiblnd_check_sends(kib_conn_t *conn)
{
- int ver = conn->ibc_version;
+ int ver = conn->ibc_version;
lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- kib_tx_t *tx;
+ kib_tx_t *tx;
/* Don't send anything until after the connection is established */
if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
@@ -997,9 +956,9 @@ kiblnd_check_sends(kib_conn_t *conn)
static void
kiblnd_tx_complete(kib_tx_t *tx, int status)
{
- int failed = (status != IB_WC_SUCCESS);
- kib_conn_t *conn = tx->tx_conn;
- int idle;
+ int failed = (status != IB_WC_SUCCESS);
+ kib_conn_t *conn = tx->tx_conn;
+ int idle;
LASSERT(tx->tx_sending > 0);
@@ -1051,11 +1010,11 @@ kiblnd_tx_complete(kib_tx_t *tx, int status)
void
kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
{
- kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
- struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq];
- struct ib_send_wr *wrq = &tx->tx_wrq[tx->tx_nwrq];
- int nob = offsetof(kib_msg_t, ibm_u) + body_nob;
- struct ib_mr *mr;
+ kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
+ struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq];
+ struct ib_rdma_wr *wrq = &tx->tx_wrq[tx->tx_nwrq];
+ int nob = offsetof(kib_msg_t, ibm_u) + body_nob;
+ struct ib_mr *mr;
LASSERT(tx->tx_nwrq >= 0);
LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1);
@@ -1072,12 +1031,12 @@ kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
memset(wrq, 0, sizeof(*wrq));
- wrq->next = NULL;
- wrq->wr_id = kiblnd_ptr2wreqid(tx, IBLND_WID_TX);
- wrq->sg_list = sge;
- wrq->num_sge = 1;
- wrq->opcode = IB_WR_SEND;
- wrq->send_flags = IB_SEND_SIGNALED;
+ wrq->wr.next = NULL;
+ wrq->wr.wr_id = kiblnd_ptr2wreqid(tx, IBLND_WID_TX);
+ wrq->wr.sg_list = sge;
+ wrq->wr.num_sge = 1;
+ wrq->wr.opcode = IB_WR_SEND;
+ wrq->wr.send_flags = IB_SEND_SIGNALED;
tx->tx_nwrq++;
}
@@ -1086,14 +1045,14 @@ int
kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
int resid, kib_rdma_desc_t *dstrd, __u64 dstcookie)
{
- kib_msg_t *ibmsg = tx->tx_msg;
- kib_rdma_desc_t *srcrd = tx->tx_rd;
- struct ib_sge *sge = &tx->tx_sge[0];
- struct ib_send_wr *wrq = &tx->tx_wrq[0];
- int rc = resid;
- int srcidx;
- int dstidx;
- int wrknob;
+ kib_msg_t *ibmsg = tx->tx_msg;
+ kib_rdma_desc_t *srcrd = tx->tx_rd;
+ struct ib_sge *sge = &tx->tx_sge[0];
+ struct ib_rdma_wr *wrq = &tx->tx_wrq[0], *next;
+ int rc = resid;
+ int srcidx;
+ int dstidx;
+ int wrknob;
LASSERT(!in_interrupt());
LASSERT(tx->tx_nwrq == 0);
@@ -1135,16 +1094,17 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
sge->length = wrknob;
wrq = &tx->tx_wrq[tx->tx_nwrq];
+ next = wrq + 1;
- wrq->next = wrq + 1;
- wrq->wr_id = kiblnd_ptr2wreqid(tx, IBLND_WID_RDMA);
- wrq->sg_list = sge;
- wrq->num_sge = 1;
- wrq->opcode = IB_WR_RDMA_WRITE;
- wrq->send_flags = 0;
+ wrq->wr.next = &next->wr;
+ wrq->wr.wr_id = kiblnd_ptr2wreqid(tx, IBLND_WID_RDMA);
+ wrq->wr.sg_list = sge;
+ wrq->wr.num_sge = 1;
+ wrq->wr.opcode = IB_WR_RDMA_WRITE;
+ wrq->wr.send_flags = 0;
- wrq->wr.rdma.remote_addr = kiblnd_rd_frag_addr(dstrd, dstidx);
- wrq->wr.rdma.rkey = kiblnd_rd_frag_key(dstrd, dstidx);
+ wrq->remote_addr = kiblnd_rd_frag_addr(dstrd, dstidx);
+ wrq->rkey = kiblnd_rd_frag_key(dstrd, dstidx);
srcidx = kiblnd_rd_consume_frag(srcrd, srcidx, wrknob);
dstidx = kiblnd_rd_consume_frag(dstrd, dstidx, wrknob);
@@ -1170,7 +1130,7 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
void
kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn)
{
- struct list_head *q;
+ struct list_head *q;
LASSERT(tx->tx_nwrq > 0); /* work items set up */
LASSERT(!tx->tx_queued); /* not queued for sending already */
@@ -1271,11 +1231,11 @@ static void
kiblnd_connect_peer(kib_peer_t *peer)
{
struct rdma_cm_id *cmid;
- kib_dev_t *dev;
- kib_net_t *net = peer->ibp_ni->ni_data;
+ kib_dev_t *dev;
+ kib_net_t *net = peer->ibp_ni->ni_data;
struct sockaddr_in srcaddr;
struct sockaddr_in dstaddr;
- int rc;
+ int rc;
LASSERT(net != NULL);
LASSERT(peer->ibp_connecting > 0);
@@ -1335,12 +1295,12 @@ kiblnd_connect_peer(kib_peer_t *peer)
void
kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
{
- kib_peer_t *peer;
- kib_peer_t *peer2;
- kib_conn_t *conn;
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- unsigned long flags;
- int rc;
+ kib_peer_t *peer;
+ kib_peer_t *peer2;
+ kib_conn_t *conn;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ unsigned long flags;
+ int rc;
/* If I get here, I've committed to send, so I complete the tx with
* failure on any problems */
@@ -1456,20 +1416,21 @@ kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
int
kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
{
- lnet_hdr_t *hdr = &lntmsg->msg_hdr;
- int type = lntmsg->msg_type;
+ lnet_hdr_t *hdr = &lntmsg->msg_hdr;
+ int type = lntmsg->msg_type;
lnet_process_id_t target = lntmsg->msg_target;
- int target_is_router = lntmsg->msg_target_is_router;
- int routing = lntmsg->msg_routing;
- unsigned int payload_niov = lntmsg->msg_niov;
- struct kvec *payload_iov = lntmsg->msg_iov;
- lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
- unsigned int payload_offset = lntmsg->msg_offset;
- unsigned int payload_nob = lntmsg->msg_len;
- kib_msg_t *ibmsg;
- kib_tx_t *tx;
- int nob;
- int rc;
+ int target_is_router = lntmsg->msg_target_is_router;
+ int routing = lntmsg->msg_routing;
+ unsigned int payload_niov = lntmsg->msg_niov;
+ struct kvec *payload_iov = lntmsg->msg_iov;
+ lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
+ unsigned int payload_offset = lntmsg->msg_offset;
+ unsigned int payload_nob = lntmsg->msg_len;
+ kib_msg_t *ibmsg;
+ kib_rdma_desc_t *rd;
+ kib_tx_t *tx;
+ int nob;
+ int rc;
/* NB 'private' is different depending on what we're sending.... */
@@ -1510,16 +1471,14 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
}
ibmsg = tx->tx_msg;
-
+ rd = &ibmsg->ibm_u.get.ibgm_rd;
if ((lntmsg->msg_md->md_options & LNET_MD_KIOV) == 0)
- rc = kiblnd_setup_rd_iov(ni, tx,
- &ibmsg->ibm_u.get.ibgm_rd,
+ rc = kiblnd_setup_rd_iov(ni, tx, rd,
lntmsg->msg_md->md_niov,
lntmsg->msg_md->md_iov.iov,
0, lntmsg->msg_md->md_length);
else
- rc = kiblnd_setup_rd_kiov(ni, tx,
- &ibmsg->ibm_u.get.ibgm_rd,
+ rc = kiblnd_setup_rd_kiov(ni, tx, rd,
lntmsg->msg_md->md_niov,
lntmsg->msg_md->md_iov.kiov,
0, lntmsg->msg_md->md_length);
@@ -1530,7 +1489,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
return -EIO;
}
- nob = offsetof(kib_get_msg_t, ibgm_rd.rd_frags[tx->tx_nfrags]);
+ nob = offsetof(kib_get_msg_t, ibgm_rd.rd_frags[rd->rd_nfrags]);
ibmsg->ibm_u.get.ibgm_cookie = tx->tx_cookie;
ibmsg->ibm_u.get.ibgm_hdr = *hdr;
@@ -1628,13 +1587,13 @@ static void
kiblnd_reply(lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
{
lnet_process_id_t target = lntmsg->msg_target;
- unsigned int niov = lntmsg->msg_niov;
- struct kvec *iov = lntmsg->msg_iov;
- lnet_kiov_t *kiov = lntmsg->msg_kiov;
- unsigned int offset = lntmsg->msg_offset;
- unsigned int nob = lntmsg->msg_len;
- kib_tx_t *tx;
- int rc;
+ unsigned int niov = lntmsg->msg_niov;
+ struct kvec *iov = lntmsg->msg_iov;
+ lnet_kiov_t *kiov = lntmsg->msg_kiov;
+ unsigned int offset = lntmsg->msg_offset;
+ unsigned int nob = lntmsg->msg_len;
+ kib_tx_t *tx;
+ int rc;
tx = kiblnd_get_idle_tx(ni, rx->rx_conn->ibc_peer->ibp_nid);
if (tx == NULL) {
@@ -1691,14 +1650,13 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
- kib_rx_t *rx = private;
- kib_msg_t *rxmsg = rx->rx_msg;
- kib_conn_t *conn = rx->rx_conn;
- kib_tx_t *tx;
- kib_msg_t *txmsg;
- int nob;
- int post_credit = IBLND_POSTRX_PEER_CREDIT;
- int rc = 0;
+ kib_rx_t *rx = private;
+ kib_msg_t *rxmsg = rx->rx_msg;
+ kib_conn_t *conn = rx->rx_conn;
+ kib_tx_t *tx;
+ int nob;
+ int post_credit = IBLND_POSTRX_PEER_CREDIT;
+ int rc = 0;
LASSERT(mlen <= rlen);
LASSERT(!in_interrupt());
@@ -1732,7 +1690,10 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
lnet_finalize(ni, lntmsg, 0);
break;
- case IBLND_MSG_PUT_REQ:
+ case IBLND_MSG_PUT_REQ: {
+ kib_msg_t *txmsg;
+ kib_rdma_desc_t *rd;
+
if (mlen == 0) {
lnet_finalize(ni, lntmsg, 0);
kiblnd_send_completion(rx->rx_conn, IBLND_MSG_PUT_NAK, 0,
@@ -1750,13 +1711,12 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
}
txmsg = tx->tx_msg;
+ rd = &txmsg->ibm_u.putack.ibpam_rd;
if (kiov == NULL)
- rc = kiblnd_setup_rd_iov(ni, tx,
- &txmsg->ibm_u.putack.ibpam_rd,
+ rc = kiblnd_setup_rd_iov(ni, tx, rd,
niov, iov, offset, mlen);
else
- rc = kiblnd_setup_rd_kiov(ni, tx,
- &txmsg->ibm_u.putack.ibpam_rd,
+ rc = kiblnd_setup_rd_kiov(ni, tx, rd,
niov, kiov, offset, mlen);
if (rc != 0) {
CERROR("Can't setup PUT sink for %s: %d\n",
@@ -1768,7 +1728,7 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
break;
}
- nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[tx->tx_nfrags]);
+ nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[rd->rd_nfrags]);
txmsg->ibm_u.putack.ibpam_src_cookie = rxmsg->ibm_u.putreq.ibprm_cookie;
txmsg->ibm_u.putack.ibpam_dst_cookie = tx->tx_cookie;
@@ -1781,6 +1741,7 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
/* reposted buffer reserved for PUT_DONE */
post_credit = IBLND_POSTRX_NO_CREDIT;
break;
+ }
case IBLND_MSG_GET_REQ:
if (lntmsg != NULL) {
@@ -1828,8 +1789,8 @@ kiblnd_peer_alive(kib_peer_t *peer)
static void
kiblnd_peer_notify(kib_peer_t *peer)
{
- int error = 0;
- unsigned long last_alive = 0;
+ int error = 0;
+ unsigned long last_alive = 0;
unsigned long flags;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -1860,9 +1821,9 @@ kiblnd_close_conn_locked(kib_conn_t *conn, int error)
* connection to be finished off by the connd. Otherwise the connd is
* already dealing with it (either to set it up or tear it down).
* Caller holds kib_global_lock exclusively in irq context */
- kib_peer_t *peer = conn->ibc_peer;
- kib_dev_t *dev;
- unsigned long flags;
+ kib_peer_t *peer = conn->ibc_peer;
+ kib_dev_t *dev;
+ unsigned long flags;
LASSERT(error != 0 || conn->ibc_state >= IBLND_CONN_ESTABLISHED);
@@ -1934,8 +1895,8 @@ kiblnd_close_conn(kib_conn_t *conn, int error)
static void
kiblnd_handle_early_rxs(kib_conn_t *conn)
{
- unsigned long flags;
- kib_rx_t *rx;
+ unsigned long flags;
+ kib_rx_t *rx;
kib_rx_t *tmp;
LASSERT(!in_interrupt());
@@ -1957,9 +1918,9 @@ static void
kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
{
LIST_HEAD(zombies);
- struct list_head *tmp;
- struct list_head *nxt;
- kib_tx_t *tx;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ kib_tx_t *tx;
spin_lock(&conn->ibc_lock);
@@ -2018,7 +1979,7 @@ void
kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error)
{
LIST_HEAD(zombies);
- unsigned long flags;
+ unsigned long flags;
LASSERT(error != 0);
LASSERT(!in_interrupt());
@@ -2071,12 +2032,12 @@ kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error)
void
kiblnd_connreq_done(kib_conn_t *conn, int status)
{
- kib_peer_t *peer = conn->ibc_peer;
- kib_tx_t *tx;
+ kib_peer_t *peer = conn->ibc_peer;
+ kib_tx_t *tx;
kib_tx_t *tmp;
- struct list_head txs;
- unsigned long flags;
- int active;
+ struct list_head txs;
+ unsigned long flags;
+ int active;
active = (conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
@@ -2166,7 +2127,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
static void
kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej)
{
- int rc;
+ int rc;
rc = rdma_reject(cmid, rej, sizeof(*rej));
@@ -2177,22 +2138,23 @@ kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej)
static int
kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
{
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- kib_msg_t *reqmsg = priv;
- kib_msg_t *ackmsg;
- kib_dev_t *ibdev;
- kib_peer_t *peer;
- kib_peer_t *peer2;
- kib_conn_t *conn;
- lnet_ni_t *ni = NULL;
- kib_net_t *net = NULL;
- lnet_nid_t nid;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ kib_msg_t *reqmsg = priv;
+ kib_msg_t *ackmsg;
+ kib_dev_t *ibdev;
+ kib_peer_t *peer;
+ kib_peer_t *peer2;
+ kib_conn_t *conn;
+ lnet_ni_t *ni = NULL;
+ kib_net_t *net = NULL;
+ lnet_nid_t nid;
struct rdma_conn_param cp;
- kib_rej_t rej;
- int version = IBLND_MSG_VERSION;
- unsigned long flags;
- int rc;
- struct sockaddr_in *peer_addr;
+ kib_rej_t rej;
+ int version = IBLND_MSG_VERSION;
+ unsigned long flags;
+ int rc;
+ struct sockaddr_in *peer_addr;
+
LASSERT(!in_interrupt());
/* cmid inherits 'context' from the corresponding listener id */
@@ -2200,14 +2162,15 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
LASSERT(ibdev != NULL);
memset(&rej, 0, sizeof(rej));
- rej.ibr_magic = IBLND_MSG_MAGIC;
- rej.ibr_why = IBLND_REJECT_FATAL;
+ rej.ibr_magic = IBLND_MSG_MAGIC;
+ rej.ibr_why = IBLND_REJECT_FATAL;
rej.ibr_cp.ibcp_max_msg_size = IBLND_MSG_SIZE;
peer_addr = (struct sockaddr_in *)&(cmid->route.addr.dst_addr);
if (*kiblnd_tunables.kib_require_priv_port &&
ntohs(peer_addr->sin_port) >= PROT_SOCK) {
__u32 ip = ntohl(peer_addr->sin_addr.s_addr);
+
CERROR("Peer's port (%pI4h:%hu) is not privileged\n",
&ip, ntohs(peer_addr->sin_port));
goto failed;
@@ -2243,7 +2206,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
}
nid = reqmsg->ibm_srcnid;
- ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid));
+ ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid));
if (ni != NULL) {
net = (kib_net_t *)ni->ni_data;
@@ -2394,7 +2357,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
* CM callback doesn't destroy cmid. */
conn->ibc_incarnation = reqmsg->ibm_srcstamp;
- conn->ibc_credits = IBLND_MSG_QUEUE_SIZE(version);
+ conn->ibc_credits = IBLND_MSG_QUEUE_SIZE(version);
conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(version);
LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(version)
<= IBLND_RX_MSGS(version));
@@ -2412,12 +2375,12 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
memset(&cp, 0, sizeof(cp));
cp.private_data = ackmsg;
- cp.private_data_len = ackmsg->ibm_nob;
+ cp.private_data_len = ackmsg->ibm_nob;
cp.responder_resources = 0; /* No atomic ops or RDMA reads */
- cp.initiator_depth = 0;
+ cp.initiator_depth = 0;
cp.flow_control = 1;
- cp.retry_count = *kiblnd_tunables.kib_retry_count;
- cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count;
+ cp.retry_count = *kiblnd_tunables.kib_retry_count;
+ cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count;
CDEBUG(D_NET, "Accept %s\n", libcfs_nid2str(nid));
@@ -2439,7 +2402,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
if (ni != NULL)
lnet_ni_decref(ni);
- rej.ibr_version = version;
+ rej.ibr_version = version;
rej.ibr_cp.ibcp_queue_depth = IBLND_MSG_QUEUE_SIZE(version);
rej.ibr_cp.ibcp_max_frags = IBLND_RDMA_FRAGS(version);
kiblnd_reject(cmid, &rej);
@@ -2451,10 +2414,10 @@ static void
kiblnd_reconnect(kib_conn_t *conn, int version,
__u64 incarnation, int why, kib_connparams_t *cp)
{
- kib_peer_t *peer = conn->ibc_peer;
- char *reason;
- int retry = 0;
- unsigned long flags;
+ kib_peer_t *peer = conn->ibc_peer;
+ char *reason;
+ int retry = 0;
+ unsigned long flags;
LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
LASSERT(peer->ibp_connecting > 0); /* 'conn' at least */
@@ -2513,7 +2476,7 @@ kiblnd_reconnect(kib_conn_t *conn, int version,
static void
kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob)
{
- kib_peer_t *peer = conn->ibc_peer;
+ kib_peer_t *peer = conn->ibc_peer;
LASSERT(!in_interrupt());
LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
@@ -2532,10 +2495,10 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob)
case IB_CM_REJ_CONSUMER_DEFINED:
if (priv_nob >= offsetof(kib_rej_t, ibr_padding)) {
- kib_rej_t *rej = priv;
- kib_connparams_t *cp = NULL;
- int flip = 0;
- __u64 incarnation = -1;
+ kib_rej_t *rej = priv;
+ kib_connparams_t *cp = NULL;
+ int flip = 0;
+ __u64 incarnation = -1;
/* NB. default incarnation is -1 because:
* a) V1 will ignore dst incarnation in connreq.
@@ -2652,13 +2615,13 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob)
static void
kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob)
{
- kib_peer_t *peer = conn->ibc_peer;
- lnet_ni_t *ni = peer->ibp_ni;
- kib_net_t *net = ni->ni_data;
- kib_msg_t *msg = priv;
- int ver = conn->ibc_version;
- int rc = kiblnd_unpack_msg(msg, priv_nob);
- unsigned long flags;
+ kib_peer_t *peer = conn->ibc_peer;
+ lnet_ni_t *ni = peer->ibp_ni;
+ kib_net_t *net = ni->ni_data;
+ kib_msg_t *msg = priv;
+ int ver = conn->ibc_version;
+ int rc = kiblnd_unpack_msg(msg, priv_nob);
+ unsigned long flags;
LASSERT(net != NULL);
@@ -2726,8 +2689,8 @@ kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob)
goto failed;
}
- conn->ibc_incarnation = msg->ibm_srcstamp;
- conn->ibc_credits =
+ conn->ibc_incarnation = msg->ibm_srcstamp;
+ conn->ibc_credits =
conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(ver);
LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(ver)
<= IBLND_RX_MSGS(ver));
@@ -2749,20 +2712,20 @@ kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob)
static int
kiblnd_active_connect(struct rdma_cm_id *cmid)
{
- kib_peer_t *peer = (kib_peer_t *)cmid->context;
- kib_conn_t *conn;
- kib_msg_t *msg;
- struct rdma_conn_param cp;
- int version;
- __u64 incarnation;
- unsigned long flags;
- int rc;
+ kib_peer_t *peer = (kib_peer_t *)cmid->context;
+ kib_conn_t *conn;
+ kib_msg_t *msg;
+ struct rdma_conn_param cp;
+ int version;
+ __u64 incarnation;
+ unsigned long flags;
+ int rc;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
incarnation = peer->ibp_incarnation;
- version = (peer->ibp_version == 0) ? IBLND_MSG_VERSION :
- peer->ibp_version;
+ version = (peer->ibp_version == 0) ? IBLND_MSG_VERSION :
+ peer->ibp_version;
read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
@@ -2793,8 +2756,8 @@ kiblnd_active_connect(struct rdma_cm_id *cmid)
cp.private_data_len = msg->ibm_nob;
cp.responder_resources = 0; /* No atomic ops or RDMA reads */
cp.initiator_depth = 0;
- cp.flow_control = 1;
- cp.retry_count = *kiblnd_tunables.kib_retry_count;
+ cp.flow_control = 1;
+ cp.retry_count = *kiblnd_tunables.kib_retry_count;
cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count;
LASSERT(cmid->context == (void *)conn);
@@ -2814,9 +2777,9 @@ kiblnd_active_connect(struct rdma_cm_id *cmid)
int
kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
{
- kib_peer_t *peer;
- kib_conn_t *conn;
- int rc;
+ kib_peer_t *peer;
+ kib_conn_t *conn;
+ int rc;
switch (event->event) {
default:
@@ -2983,8 +2946,8 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
static int
kiblnd_check_txs_locked(kib_conn_t *conn, struct list_head *txs)
{
- kib_tx_t *tx;
- struct list_head *ttmp;
+ kib_tx_t *tx;
+ struct list_head *ttmp;
list_for_each(ttmp, txs) {
tx = list_entry(ttmp, kib_tx_t, tx_list);
@@ -3022,13 +2985,13 @@ kiblnd_check_conns(int idx)
{
LIST_HEAD(closes);
LIST_HEAD(checksends);
- struct list_head *peers = &kiblnd_data.kib_peers[idx];
- struct list_head *ptmp;
- kib_peer_t *peer;
- kib_conn_t *conn;
+ struct list_head *peers = &kiblnd_data.kib_peers[idx];
+ struct list_head *ptmp;
+ kib_peer_t *peer;
+ kib_conn_t *conn;
kib_conn_t *tmp;
- struct list_head *ctmp;
- unsigned long flags;
+ struct list_head *ctmp;
+ unsigned long flags;
/* NB. We expect to have a look at all the peers and not find any
* RDMAs to time out, so we just use a shared lock while we
@@ -3114,14 +3077,14 @@ kiblnd_disconnect_conn(kib_conn_t *conn)
int
kiblnd_connd(void *arg)
{
- wait_queue_t wait;
- unsigned long flags;
- kib_conn_t *conn;
- int timeout;
- int i;
- int dropped_lock;
- int peer_index = 0;
- unsigned long deadline = jiffies;
+ wait_queue_t wait;
+ unsigned long flags;
+ kib_conn_t *conn;
+ int timeout;
+ int i;
+ int dropped_lock;
+ int peer_index = 0;
+ unsigned long deadline = jiffies;
cfs_block_allsigs();
@@ -3135,8 +3098,7 @@ kiblnd_connd(void *arg)
dropped_lock = 0;
if (!list_empty(&kiblnd_data.kib_connd_zombies)) {
- conn = list_entry(kiblnd_data. \
- kib_connd_zombies.next,
+ conn = list_entry(kiblnd_data.kib_connd_zombies.next,
kib_conn_t, ibc_list);
list_del(&conn->ibc_list);
@@ -3169,7 +3131,7 @@ kiblnd_connd(void *arg)
if (timeout <= 0) {
const int n = 4;
const int p = 1;
- int chunk = kiblnd_data.kib_peer_hash_size;
+ int chunk = kiblnd_data.kib_peer_hash_size;
spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags);
dropped_lock = 1;
@@ -3273,9 +3235,9 @@ kiblnd_cq_completion(struct ib_cq *cq, void *arg)
* consuming my CQ I could be called after all completions have
* occurred. But in this case, ibc_nrx == 0 && ibc_nsends_posted == 0
* and this CQ is about to be destroyed so I NOOP. */
- kib_conn_t *conn = (kib_conn_t *)arg;
- struct kib_sched_info *sched = conn->ibc_sched;
- unsigned long flags;
+ kib_conn_t *conn = arg;
+ struct kib_sched_info *sched = conn->ibc_sched;
+ unsigned long flags;
LASSERT(cq == conn->ibc_cq);
@@ -3309,15 +3271,15 @@ kiblnd_cq_event(struct ib_event *event, void *arg)
int
kiblnd_scheduler(void *arg)
{
- long id = (long)arg;
- struct kib_sched_info *sched;
- kib_conn_t *conn;
- wait_queue_t wait;
- unsigned long flags;
- struct ib_wc wc;
- int did_something;
- int busy_loops = 0;
- int rc;
+ long id = (long)arg;
+ struct kib_sched_info *sched;
+ kib_conn_t *conn;
+ wait_queue_t wait;
+ unsigned long flags;
+ struct ib_wc wc;
+ int did_something;
+ int busy_loops = 0;
+ int rc;
cfs_block_allsigs();
@@ -3432,11 +3394,11 @@ kiblnd_scheduler(void *arg)
int
kiblnd_failover_thread(void *arg)
{
- rwlock_t *glock = &kiblnd_data.kib_global_lock;
- kib_dev_t *dev;
- wait_queue_t wait;
- unsigned long flags;
- int rc;
+ rwlock_t *glock = &kiblnd_data.kib_global_lock;
+ kib_dev_t *dev;
+ wait_queue_t wait;
+ unsigned long flags;
+ int rc;
LASSERT(*kiblnd_tunables.kib_dev_failover != 0);
@@ -3446,8 +3408,8 @@ kiblnd_failover_thread(void *arg)
write_lock_irqsave(glock, flags);
while (!kiblnd_data.kib_shutdown) {
- int do_failover = 0;
- int long_sleep;
+ int do_failover = 0;
+ int long_sleep;
list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
ibd_fail_list) {
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index eedf01afd..1d4e7efb5 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -126,11 +126,6 @@ static int fmr_cache = 1;
module_param(fmr_cache, int, 0444);
MODULE_PARM_DESC(fmr_cache, "non-zero to enable FMR caching");
-/* NB: this value is shared by all CPTs, it can grow at runtime */
-static int pmr_pool_size = 512;
-module_param(pmr_pool_size, int, 0444);
-MODULE_PARM_DESC(pmr_pool_size, "size of MR cache pmr pool on each CPT");
-
/*
* 0: disable failover
* 1: enable failover if necessary
@@ -140,7 +135,6 @@ static int dev_failover;
module_param(dev_failover, int, 0444);
MODULE_PARM_DESC(dev_failover, "HCA failover for bonding (0 off, 1 on, other values reserved)");
-
static int require_privileged_port;
module_param(require_privileged_port, int, 0644);
MODULE_PARM_DESC(require_privileged_port, "require privileged port when accepting connection");
@@ -150,30 +144,29 @@ module_param(use_privileged_port, int, 0644);
MODULE_PARM_DESC(use_privileged_port, "use privileged port when initiating connection");
kib_tunables_t kiblnd_tunables = {
- .kib_dev_failover = &dev_failover,
- .kib_service = &service,
- .kib_cksum = &cksum,
- .kib_timeout = &timeout,
- .kib_keepalive = &keepalive,
- .kib_ntx = &ntx,
- .kib_credits = &credits,
- .kib_peertxcredits = &peer_credits,
- .kib_peercredits_hiw = &peer_credits_hiw,
- .kib_peerrtrcredits = &peer_buffer_credits,
- .kib_peertimeout = &peer_timeout,
- .kib_default_ipif = &ipif_name,
- .kib_retry_count = &retry_count,
- .kib_rnr_retry_count = &rnr_retry_count,
- .kib_concurrent_sends = &concurrent_sends,
- .kib_ib_mtu = &ib_mtu,
- .kib_map_on_demand = &map_on_demand,
- .kib_fmr_pool_size = &fmr_pool_size,
- .kib_fmr_flush_trigger = &fmr_flush_trigger,
- .kib_fmr_cache = &fmr_cache,
- .kib_pmr_pool_size = &pmr_pool_size,
- .kib_require_priv_port = &require_privileged_port,
- .kib_use_priv_port = &use_privileged_port,
- .kib_nscheds = &nscheds
+ .kib_dev_failover = &dev_failover,
+ .kib_service = &service,
+ .kib_cksum = &cksum,
+ .kib_timeout = &timeout,
+ .kib_keepalive = &keepalive,
+ .kib_ntx = &ntx,
+ .kib_credits = &credits,
+ .kib_peertxcredits = &peer_credits,
+ .kib_peercredits_hiw = &peer_credits_hiw,
+ .kib_peerrtrcredits = &peer_buffer_credits,
+ .kib_peertimeout = &peer_timeout,
+ .kib_default_ipif = &ipif_name,
+ .kib_retry_count = &retry_count,
+ .kib_rnr_retry_count = &rnr_retry_count,
+ .kib_concurrent_sends = &concurrent_sends,
+ .kib_ib_mtu = &ib_mtu,
+ .kib_map_on_demand = &map_on_demand,
+ .kib_fmr_pool_size = &fmr_pool_size,
+ .kib_fmr_flush_trigger = &fmr_flush_trigger,
+ .kib_fmr_cache = &fmr_cache,
+ .kib_require_priv_port = &require_privileged_port,
+ .kib_use_priv_port = &use_privileged_port,
+ .kib_nscheds = &nscheds
};
int
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/Makefile b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/Makefile
index f3fb8778c..c011581d3 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/Makefile
+++ b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/Makefile
@@ -1,3 +1,3 @@
obj-$(CONFIG_LNET) += ksocklnd.o
-ksocklnd-y := socklnd.o socklnd_cb.o socklnd_proto.o socklnd_modparams.o socklnd_lib-linux.o
+ksocklnd-y := socklnd.o socklnd_cb.o socklnd_proto.o socklnd_modparams.o socklnd_lib.o
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7586b7e40..ecfe73302 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -49,8 +49,8 @@ ksock_nal_data_t ksocknal_data;
static ksock_interface_t *
ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip)
{
- ksock_net_t *net = ni->ni_data;
- int i;
+ ksock_net_t *net = ni->ni_data;
+ int i;
ksock_interface_t *iface;
for (i = 0; i < net->ksnn_ninterfaces; i++) {
@@ -102,8 +102,8 @@ ksocknal_destroy_route(ksock_route_t *route)
static int
ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
{
- ksock_net_t *net = ni->ni_data;
- ksock_peer_t *peer;
+ ksock_net_t *net = ni->ni_data;
+ ksock_peer_t *peer;
LASSERT(id.nid != LNET_NID_ANY);
LASSERT(id.pid != LNET_PID_ANY);
@@ -149,7 +149,7 @@ ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
void
ksocknal_destroy_peer(ksock_peer_t *peer)
{
- ksock_net_t *net = peer->ksnp_ni->ni_data;
+ ksock_net_t *net = peer->ksnp_ni->ni_data;
CDEBUG(D_NET, "peer %s %p deleted\n",
libcfs_id2str(peer->ksnp_id), peer);
@@ -175,9 +175,9 @@ ksocknal_destroy_peer(ksock_peer_t *peer)
ksock_peer_t *
ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id)
{
- struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
- struct list_head *tmp;
- ksock_peer_t *peer;
+ struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
+ struct list_head *tmp;
+ ksock_peer_t *peer;
list_for_each(tmp, peer_list) {
@@ -203,7 +203,7 @@ ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id)
ksock_peer_t *
ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id)
{
- ksock_peer_t *peer;
+ ksock_peer_t *peer;
read_lock(&ksocknal_data.ksnd_global_lock);
peer = ksocknal_find_peer_locked(ni, id);
@@ -217,8 +217,8 @@ ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id)
static void
ksocknal_unlink_peer_locked(ksock_peer_t *peer)
{
- int i;
- __u32 ip;
+ int i;
+ __u32 ip;
ksock_interface_t *iface;
for (i = 0; i < peer->ksnp_n_passive_ips; i++) {
@@ -249,13 +249,13 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index,
lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip,
int *port, int *conn_count, int *share_count)
{
- ksock_peer_t *peer;
- struct list_head *ptmp;
- ksock_route_t *route;
- struct list_head *rtmp;
- int i;
- int j;
- int rc = -ENOENT;
+ ksock_peer_t *peer;
+ struct list_head *ptmp;
+ ksock_route_t *route;
+ struct list_head *rtmp;
+ int i;
+ int j;
+ int rc = -ENOENT;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -322,8 +322,8 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index,
static void
ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn)
{
- ksock_peer_t *peer = route->ksnr_peer;
- int type = conn->ksnc_type;
+ ksock_peer_t *peer = route->ksnr_peer;
+ int type = conn->ksnc_type;
ksock_interface_t *iface;
conn->ksnc_route = route;
@@ -366,9 +366,9 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn)
static void
ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route)
{
- struct list_head *tmp;
- ksock_conn_t *conn;
- ksock_route_t *route2;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
+ ksock_route_t *route2;
LASSERT(!peer->ksnp_closing);
LASSERT(route->ksnr_peer == NULL);
@@ -407,11 +407,11 @@ ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route)
static void
ksocknal_del_route_locked(ksock_route_t *route)
{
- ksock_peer_t *peer = route->ksnr_peer;
+ ksock_peer_t *peer = route->ksnr_peer;
ksock_interface_t *iface;
- ksock_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
LASSERT(!route->ksnr_deleted);
@@ -447,12 +447,12 @@ ksocknal_del_route_locked(ksock_route_t *route)
int
ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
{
- struct list_head *tmp;
- ksock_peer_t *peer;
- ksock_peer_t *peer2;
- ksock_route_t *route;
- ksock_route_t *route2;
- int rc;
+ struct list_head *tmp;
+ ksock_peer_t *peer;
+ ksock_peer_t *peer2;
+ ksock_route_t *route;
+ ksock_route_t *route2;
+ int rc;
if (id.nid == LNET_NID_ANY ||
id.pid == LNET_PID_ANY)
@@ -509,11 +509,11 @@ ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
static void
ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip)
{
- ksock_conn_t *conn;
- ksock_route_t *route;
- struct list_head *tmp;
- struct list_head *nxt;
- int nshared;
+ ksock_conn_t *conn;
+ ksock_route_t *route;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ int nshared;
LASSERT(!peer->ksnp_closing);
@@ -565,13 +565,13 @@ static int
ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
{
LIST_HEAD(zombies);
- struct list_head *ptmp;
- struct list_head *pnxt;
- ksock_peer_t *peer;
- int lo;
- int hi;
- int i;
- int rc = -ENOENT;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ ksock_peer_t *peer;
+ int lo;
+ int hi;
+ int i;
+ int rc = -ENOENT;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -623,11 +623,11 @@ ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
static ksock_conn_t *
ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index)
{
- ksock_peer_t *peer;
- struct list_head *ptmp;
- ksock_conn_t *conn;
- struct list_head *ctmp;
- int i;
+ ksock_peer_t *peer;
+ struct list_head *ptmp;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
+ int i;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -661,8 +661,8 @@ static ksock_sched_t *
ksocknal_choose_scheduler_locked(unsigned int cpt)
{
struct ksock_sched_info *info = ksocknal_data.ksnd_sched_info[cpt];
- ksock_sched_t *sched;
- int i;
+ ksock_sched_t *sched;
+ int i;
LASSERT(info->ksi_nthreads > 0);
@@ -683,9 +683,9 @@ ksocknal_choose_scheduler_locked(unsigned int cpt)
static int
ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs)
{
- ksock_net_t *net = ni->ni_data;
- int i;
- int nip;
+ ksock_net_t *net = ni->ni_data;
+ int i;
+ int nip;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -711,12 +711,12 @@ ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs)
static int
ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips)
{
- int best_netmatch = 0;
- int best_xor = 0;
- int best = -1;
- int this_xor;
- int this_netmatch;
- int i;
+ int best_netmatch = 0;
+ int best_xor = 0;
+ int best = -1;
+ int this_xor;
+ int this_netmatch;
+ int i;
for (i = 0; i < nips; i++) {
if (ips[i] == 0)
@@ -743,19 +743,19 @@ ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips)
static int
ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
{
- rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
- ksock_net_t *net = peer->ksnp_ni->ni_data;
- ksock_interface_t *iface;
- ksock_interface_t *best_iface;
- int n_ips;
- int i;
- int j;
- int k;
- __u32 ip;
- __u32 xor;
- int this_netmatch;
- int best_netmatch;
- int best_npeers;
+ rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
+ ksock_net_t *net = peer->ksnp_ni->ni_data;
+ ksock_interface_t *iface;
+ ksock_interface_t *best_iface;
+ int n_ips;
+ int i;
+ int j;
+ int k;
+ __u32 ip;
+ __u32 xor;
+ int this_netmatch;
+ int best_netmatch;
+ int best_npeers;
/* CAVEAT EMPTOR: We do all our interface matching with an
* exclusive hold of global lock at IRQ priority. We're only
@@ -846,19 +846,19 @@ static void
ksocknal_create_routes(ksock_peer_t *peer, int port,
__u32 *peer_ipaddrs, int npeer_ipaddrs)
{
- ksock_route_t *newroute = NULL;
- rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
- lnet_ni_t *ni = peer->ksnp_ni;
- ksock_net_t *net = ni->ni_data;
- struct list_head *rtmp;
- ksock_route_t *route;
- ksock_interface_t *iface;
- ksock_interface_t *best_iface;
- int best_netmatch;
- int this_netmatch;
- int best_nroutes;
- int i;
- int j;
+ ksock_route_t *newroute = NULL;
+ rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
+ lnet_ni_t *ni = peer->ksnp_ni;
+ ksock_net_t *net = ni->ni_data;
+ struct list_head *rtmp;
+ ksock_route_t *route;
+ ksock_interface_t *iface;
+ ksock_interface_t *best_iface;
+ int best_netmatch;
+ int this_netmatch;
+ int best_nroutes;
+ int i;
+ int j;
/* CAVEAT EMPTOR: We do all our interface matching with an
* exclusive hold of global lock at IRQ priority. We're only
@@ -963,12 +963,12 @@ ksocknal_create_routes(ksock_peer_t *peer, int port,
int
ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
{
- ksock_connreq_t *cr;
- int rc;
- __u32 peer_ip;
- int peer_port;
+ ksock_connreq_t *cr;
+ int rc;
+ __u32 peer_ip;
+ int peer_port;
- rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
+ rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
LASSERT(rc == 0); /* we succeeded before */
LIBCFS_ALLOC(cr, sizeof(*cr));
@@ -994,7 +994,7 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
static int
ksocknal_connecting(ksock_peer_t *peer, __u32 ipaddr)
{
- ksock_route_t *route;
+ ksock_route_t *route;
list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) {
@@ -1008,23 +1008,23 @@ int
ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
struct socket *sock, int type)
{
- rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
+ rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
LIST_HEAD(zombies);
- lnet_process_id_t peerid;
- struct list_head *tmp;
- __u64 incarnation;
- ksock_conn_t *conn;
- ksock_conn_t *conn2;
- ksock_peer_t *peer = NULL;
- ksock_peer_t *peer2;
- ksock_sched_t *sched;
+ lnet_process_id_t peerid;
+ struct list_head *tmp;
+ __u64 incarnation;
+ ksock_conn_t *conn;
+ ksock_conn_t *conn2;
+ ksock_peer_t *peer = NULL;
+ ksock_peer_t *peer2;
+ ksock_sched_t *sched;
ksock_hello_msg_t *hello;
- int cpt;
- ksock_tx_t *tx;
- ksock_tx_t *txtmp;
- int rc;
- int active;
- char *warn = NULL;
+ int cpt;
+ ksock_tx_t *tx;
+ ksock_tx_t *txtmp;
+ int rc;
+ int active;
+ char *warn = NULL;
active = (route != NULL);
@@ -1378,15 +1378,15 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
ksocknal_txlist_done(ni, &zombies, 1);
ksocknal_peer_decref(peer);
- failed_1:
+failed_1:
if (hello != NULL)
LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t,
kshm_ips[LNET_MAX_INTERFACES]));
LIBCFS_FREE(conn, sizeof(*conn));
- failed_0:
- libcfs_sock_release(sock);
+failed_0:
+ sock_release(sock);
return rc;
}
@@ -1396,10 +1396,10 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error)
/* This just does the immmediate housekeeping, and queues the
* connection for the reaper to terminate.
* Caller holds ksnd_global_lock exclusively in irq context */
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_route_t *route;
- ksock_conn_t *conn2;
- struct list_head *tmp;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_route_t *route;
+ ksock_conn_t *conn2;
+ struct list_head *tmp;
LASSERT(peer->ksnp_error == 0);
LASSERT(!conn->ksnc_closing);
@@ -1479,7 +1479,7 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error)
void
ksocknal_peer_failed(ksock_peer_t *peer)
{
- int notify = 0;
+ int notify = 0;
unsigned long last_alive = 0;
/* There has been a connection failure or comms error; but I'll only
@@ -1506,9 +1506,9 @@ ksocknal_peer_failed(ksock_peer_t *peer)
void
ksocknal_finalize_zcreq(ksock_conn_t *conn)
{
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_tx_t *tx;
- ksock_tx_t *tmp;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_tx_t *tx;
+ ksock_tx_t *tmp;
LIST_HEAD(zlist);
/* NB safe to finalize TXs because closing of socket will
@@ -1546,9 +1546,9 @@ ksocknal_terminate_conn(ksock_conn_t *conn)
* disengage the socket from its callbacks and close it.
* ksnc_refcount will eventually hit zero, and then the reaper will
* destroy it. */
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_sched_t *sched = conn->ksnc_scheduler;
- int failed = 0;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_sched_t *sched = conn->ksnc_scheduler;
+ int failed = 0;
LASSERT(conn->ksnc_closing);
@@ -1617,7 +1617,7 @@ ksocknal_queue_zombie_conn(ksock_conn_t *conn)
void
ksocknal_destroy_conn(ksock_conn_t *conn)
{
- unsigned long last_rcv;
+ unsigned long last_rcv;
/* Final coup-de-grace of the reaper */
CDEBUG(D_NET, "connection %p\n", conn);
@@ -1677,10 +1677,10 @@ ksocknal_destroy_conn(ksock_conn_t *conn)
int
ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why)
{
- ksock_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
- int count = 0;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ int count = 0;
list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) {
conn = list_entry(ctmp, ksock_conn_t, ksnc_list);
@@ -1698,9 +1698,9 @@ ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why)
int
ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why)
{
- ksock_peer_t *peer = conn->ksnc_peer;
- __u32 ipaddr = conn->ksnc_ipaddr;
- int count;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ __u32 ipaddr = conn->ksnc_ipaddr;
+ int count;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -1714,13 +1714,13 @@ ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why)
int
ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr)
{
- ksock_peer_t *peer;
- struct list_head *ptmp;
- struct list_head *pnxt;
- int lo;
- int hi;
- int i;
- int count = 0;
+ ksock_peer_t *peer;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ int lo;
+ int hi;
+ int i;
+ int count = 0;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -1762,7 +1762,7 @@ ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
{
/* The router is telling me she's been notified of a change in
* gateway state.... */
- lnet_process_id_t id = {0};
+ lnet_process_id_t id = {0};
id.nid = gw_nid;
id.pid = LNET_PID_ANY;
@@ -1783,20 +1783,20 @@ ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
void
ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
{
- int connect = 1;
- unsigned long last_alive = 0;
- unsigned long now = cfs_time_current();
- ksock_peer_t *peer = NULL;
- rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
- lnet_process_id_t id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID};
+ int connect = 1;
+ unsigned long last_alive = 0;
+ unsigned long now = cfs_time_current();
+ ksock_peer_t *peer = NULL;
+ rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
+ lnet_process_id_t id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID};
read_lock(glock);
peer = ksocknal_find_peer_locked(ni, id);
if (peer != NULL) {
- struct list_head *tmp;
- ksock_conn_t *conn;
- int bufnob;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
+ int bufnob;
list_for_each(tmp, &peer->ksnp_conns) {
conn = list_entry(tmp, ksock_conn_t, ksnc_list);
@@ -1838,16 +1838,15 @@ ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
ksocknal_launch_all_connections_locked(peer);
write_unlock_bh(glock);
- return;
}
static void
ksocknal_push_peer(ksock_peer_t *peer)
{
- int index;
- int i;
- struct list_head *tmp;
- ksock_conn_t *conn;
+ int index;
+ int i;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
for (index = 0; ; index++) {
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -1874,67 +1873,66 @@ ksocknal_push_peer(ksock_peer_t *peer)
}
}
-static int
-ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id)
+static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id)
{
- ksock_peer_t *peer;
- struct list_head *tmp;
- int index;
- int i;
- int j;
- int rc = -ENOENT;
-
- for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
- for (j = 0; ; j++) {
- read_lock(&ksocknal_data.ksnd_global_lock);
+ struct list_head *start;
+ struct list_head *end;
+ struct list_head *tmp;
+ int rc = -ENOENT;
+ unsigned int hsize = ksocknal_data.ksnd_peer_hash_size;
+
+ if (id.nid == LNET_NID_ANY) {
+ start = &ksocknal_data.ksnd_peers[0];
+ end = &ksocknal_data.ksnd_peers[hsize - 1];
+ } else {
+ start = end = ksocknal_nid2peerlist(id.nid);
+ }
- index = 0;
- peer = NULL;
+ for (tmp = start; tmp <= end; tmp++) {
+ int peer_off; /* searching offset in peer hash table */
- list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) {
- peer = list_entry(tmp, ksock_peer_t,
- ksnp_list);
+ for (peer_off = 0; ; peer_off++) {
+ ksock_peer_t *peer;
+ int i = 0;
+ read_lock(&ksocknal_data.ksnd_global_lock);
+ list_for_each_entry(peer, tmp, ksnp_list) {
if (!((id.nid == LNET_NID_ANY ||
id.nid == peer->ksnp_id.nid) &&
(id.pid == LNET_PID_ANY ||
- id.pid == peer->ksnp_id.pid))) {
- peer = NULL;
+ id.pid == peer->ksnp_id.pid)))
continue;
- }
- if (index++ == j) {
+ if (i++ == peer_off) {
ksocknal_peer_addref(peer);
break;
}
}
-
read_unlock(&ksocknal_data.ksnd_global_lock);
- if (peer != NULL) {
- rc = 0;
- ksocknal_push_peer(peer);
- ksocknal_peer_decref(peer);
- }
- }
+ if (i == 0) /* no match */
+ break;
+ rc = 0;
+ ksocknal_push_peer(peer);
+ ksocknal_peer_decref(peer);
+ }
}
-
return rc;
}
static int
ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
{
- ksock_net_t *net = ni->ni_data;
+ ksock_net_t *net = ni->ni_data;
ksock_interface_t *iface;
- int rc;
- int i;
- int j;
- struct list_head *ptmp;
- ksock_peer_t *peer;
- struct list_head *rtmp;
- ksock_route_t *route;
+ int rc;
+ int i;
+ int j;
+ struct list_head *ptmp;
+ ksock_peer_t *peer;
+ struct list_head *rtmp;
+ ksock_route_t *route;
if (ipaddress == 0 ||
netmask == 0)
@@ -1988,12 +1986,12 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
static void
ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
{
- struct list_head *tmp;
- struct list_head *nxt;
- ksock_route_t *route;
- ksock_conn_t *conn;
- int i;
- int j;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ ksock_route_t *route;
+ ksock_conn_t *conn;
+ int i;
+ int j;
for (i = 0; i < peer->ksnp_n_passive_ips; i++)
if (peer->ksnp_passive_ips[i] == ipaddr) {
@@ -2029,14 +2027,14 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
static int
ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress)
{
- ksock_net_t *net = ni->ni_data;
- int rc = -ENOENT;
- struct list_head *tmp;
- struct list_head *nxt;
- ksock_peer_t *peer;
- __u32 this_ip;
- int i;
- int j;
+ ksock_net_t *net = ni->ni_data;
+ int rc = -ENOENT;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ ksock_peer_t *peer;
+ __u32 this_ip;
+ int i;
+ int j;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -2114,11 +2112,11 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
data->ioc_u32[0]); /* IP address */
case IOC_LIBCFS_GET_PEER: {
- __u32 myip = 0;
- __u32 ip = 0;
- int port = 0;
- int conn_count = 0;
- int share_count = 0;
+ __u32 myip = 0;
+ __u32 ip = 0;
+ int port = 0;
+ int conn_count = 0;
+ int share_count = 0;
rc = ksocknal_get_peer_info(ni, data->ioc_count,
&id, &myip, &ip, &port,
@@ -2150,9 +2148,9 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
data->ioc_u32[0]); /* IP */
case IOC_LIBCFS_GET_CONN: {
- int txmem;
- int rxmem;
- int nagle;
+ int txmem;
+ int rxmem;
+ int nagle;
ksock_conn_t *conn = ksocknal_get_conn_by_idx(ni, data->ioc_count);
if (conn == NULL)
@@ -2207,8 +2205,8 @@ ksocknal_free_buffers(void)
LASSERT(atomic_read(&ksocknal_data.ksnd_nactive_txs) == 0);
if (ksocknal_data.ksnd_sched_info != NULL) {
- struct ksock_sched_info *info;
- int i;
+ struct ksock_sched_info *info;
+ int i;
cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) {
if (info->ksi_scheds != NULL) {
@@ -2227,8 +2225,8 @@ ksocknal_free_buffers(void)
spin_lock(&ksocknal_data.ksnd_tx_lock);
if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
- struct list_head zlist;
- ksock_tx_t *tx;
+ struct list_head zlist;
+ ksock_tx_t *tx;
list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs);
list_del_init(&ksocknal_data.ksnd_idle_noop_txs);
@@ -2248,12 +2246,10 @@ static void
ksocknal_base_shutdown(void)
{
struct ksock_sched_info *info;
- ksock_sched_t *sched;
- int i;
- int j;
+ ksock_sched_t *sched;
+ int i;
+ int j;
- CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
LASSERT(ksocknal_data.ksnd_nnets == 0);
switch (ksocknal_data.ksnd_init) {
@@ -2263,9 +2259,8 @@ ksocknal_base_shutdown(void)
case SOCKNAL_INIT_ALL:
case SOCKNAL_INIT_DATA:
LASSERT(ksocknal_data.ksnd_peers != NULL);
- for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
+ for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++)
LASSERT(list_empty(&ksocknal_data.ksnd_peers[i]));
- }
LASSERT(list_empty(&ksocknal_data.ksnd_nets));
LASSERT(list_empty(&ksocknal_data.ksnd_enomem_conns));
@@ -2331,9 +2326,6 @@ ksocknal_base_shutdown(void)
break;
}
- CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
module_put(THIS_MODULE);
}
@@ -2351,8 +2343,8 @@ static int
ksocknal_base_startup(void)
{
struct ksock_sched_info *info;
- int rc;
- int i;
+ int rc;
+ int i;
LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_NOTHING);
LASSERT(ksocknal_data.ksnd_nnets == 0);
@@ -2398,8 +2390,8 @@ ksocknal_base_startup(void)
goto failed;
cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) {
- ksock_sched_t *sched;
- int nthrs;
+ ksock_sched_t *sched;
+ int nthrs;
nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
if (*ksocknal_tunables.ksnd_nscheds > 0) {
@@ -2430,9 +2422,9 @@ ksocknal_base_startup(void)
}
}
- ksocknal_data.ksnd_connd_starting = 0;
- ksocknal_data.ksnd_connd_failed_stamp = 0;
- ksocknal_data.ksnd_connd_starting_stamp = get_seconds();
+ ksocknal_data.ksnd_connd_starting = 0;
+ ksocknal_data.ksnd_connd_failed_stamp = 0;
+ ksocknal_data.ksnd_connd_starting_stamp = ktime_get_real_seconds();
/* must have at least 2 connds to remain responsive to accepts while
* connecting */
if (*ksocknal_tunables.ksnd_nconnds < SOCKNAL_CONND_RESV + 1)
@@ -2446,11 +2438,11 @@ ksocknal_base_startup(void)
for (i = 0; i < *ksocknal_tunables.ksnd_nconnds; i++) {
char name[16];
+
spin_lock_bh(&ksocknal_data.ksnd_connd_lock);
ksocknal_data.ksnd_connd_starting++;
spin_unlock_bh(&ksocknal_data.ksnd_connd_lock);
-
snprintf(name, sizeof(name), "socknal_cd%02d", i);
rc = ksocknal_thread_start(ksocknal_connd,
(void *)((ulong_ptr_t)i), name);
@@ -2482,9 +2474,9 @@ ksocknal_base_startup(void)
static void
ksocknal_debug_peerhash(lnet_ni_t *ni)
{
- ksock_peer_t *peer = NULL;
- struct list_head *tmp;
- int i;
+ ksock_peer_t *peer = NULL;
+ struct list_head *tmp;
+ int i;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -2536,12 +2528,12 @@ ksocknal_debug_peerhash(lnet_ni_t *ni)
void
ksocknal_shutdown(lnet_ni_t *ni)
{
- ksock_net_t *net = ni->ni_data;
- int i;
+ ksock_net_t *net = ni->ni_data;
+ int i;
lnet_process_id_t anyid = {0};
- anyid.nid = LNET_NID_ANY;
- anyid.pid = LNET_PID_ANY;
+ anyid.nid = LNET_NID_ANY;
+ anyid.pid = LNET_PID_ANY;
LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_ALL);
LASSERT(ksocknal_data.ksnd_nnets > 0);
@@ -2588,27 +2580,27 @@ ksocknal_shutdown(lnet_ni_t *ni)
static int
ksocknal_enumerate_interfaces(ksock_net_t *net)
{
- char **names;
- int i;
- int j;
- int rc;
- int n;
+ char **names;
+ int i;
+ int j;
+ int rc;
+ int n;
- n = libcfs_ipif_enumerate(&names);
+ n = lnet_ipif_enumerate(&names);
if (n <= 0) {
CERROR("Can't enumerate interfaces: %d\n", n);
return n;
}
for (i = j = 0; i < n; i++) {
- int up;
- __u32 ip;
- __u32 mask;
+ int up;
+ __u32 ip;
+ __u32 mask;
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
continue;
- rc = libcfs_ipif_query(names[i], &up, &ip, &mask);
+ rc = lnet_ipif_query(names[i], &up, &ip, &mask);
if (rc != 0) {
CWARN("Can't get interface %s info: %d\n",
names[i], rc);
@@ -2634,7 +2626,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
j++;
}
- libcfs_ipif_free_enumeration(names, n);
+ lnet_ipif_free_enumeration(names, n);
if (j == 0)
CERROR("Can't find any usable interfaces\n");
@@ -2645,15 +2637,15 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
static int
ksocknal_search_new_ipif(ksock_net_t *net)
{
- int new_ipif = 0;
- int i;
+ int new_ipif = 0;
+ int i;
for (i = 0; i < net->ksnn_ninterfaces; i++) {
- char *ifnam = &net->ksnn_interfaces[i].ksni_name[0];
- char *colon = strchr(ifnam, ':');
- int found = 0;
- ksock_net_t *tmp;
- int j;
+ char *ifnam = &net->ksnn_interfaces[i].ksni_name[0];
+ char *colon = strchr(ifnam, ':');
+ int found = 0;
+ ksock_net_t *tmp;
+ int j;
if (colon != NULL) /* ignore alias device */
*colon = 0;
@@ -2687,9 +2679,9 @@ ksocknal_search_new_ipif(ksock_net_t *net)
static int
ksocknal_start_schedulers(struct ksock_sched_info *info)
{
- int nthrs;
- int rc = 0;
- int i;
+ int nthrs;
+ int rc = 0;
+ int i;
if (info->ksi_nthreads == 0) {
if (*ksocknal_tunables.ksnd_nscheds > 0) {
@@ -2708,9 +2700,10 @@ ksocknal_start_schedulers(struct ksock_sched_info *info)
}
for (i = 0; i < nthrs; i++) {
- long id;
- char name[20];
- ksock_sched_t *sched;
+ long id;
+ char name[20];
+ ksock_sched_t *sched;
+
id = KSOCK_THREAD_ID(info->ksi_cpt, info->ksi_nthreads + i);
sched = &info->ksi_scheds[KSOCK_THREAD_SID(id)];
snprintf(name, sizeof(name), "socknal_sd%02d_%02d",
@@ -2733,14 +2726,14 @@ ksocknal_start_schedulers(struct ksock_sched_info *info)
static int
ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts)
{
- int newif = ksocknal_search_new_ipif(net);
- int rc;
- int i;
+ int newif = ksocknal_search_new_ipif(net);
+ int rc;
+ int i;
LASSERT(ncpts > 0 && ncpts <= cfs_cpt_number(lnet_cpt_table()));
for (i = 0; i < ncpts; i++) {
- struct ksock_sched_info *info;
+ struct ksock_sched_info *info;
int cpt = (cpts == NULL) ? i : cpts[i];
LASSERT(cpt < cfs_cpt_number(lnet_cpt_table()));
@@ -2759,9 +2752,9 @@ ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts)
int
ksocknal_startup(lnet_ni_t *ni)
{
- ksock_net_t *net;
- int rc;
- int i;
+ ksock_net_t *net;
+ int rc;
+ int i;
LASSERT(ni->ni_lnd == &the_ksocklnd);
@@ -2791,13 +2784,12 @@ ksocknal_startup(lnet_ni_t *ni)
net->ksnn_ninterfaces = 1;
} else {
for (i = 0; i < LNET_MAX_INTERFACES; i++) {
- int up;
+ int up;
if (ni->ni_interfaces[i] == NULL)
break;
- rc = libcfs_ipif_query(
- ni->ni_interfaces[i], &up,
+ rc = lnet_ipif_query(ni->ni_interfaces[i], &up,
&net->ksnn_interfaces[i].ksni_ipaddr,
&net->ksnn_interfaces[i].ksni_netmask);
@@ -2841,7 +2833,6 @@ ksocknal_startup(lnet_ni_t *ni)
return -ENETDOWN;
}
-
static void __exit
ksocknal_module_fini(void)
{
@@ -2851,7 +2842,7 @@ ksocknal_module_fini(void)
static int __init
ksocknal_module_init(void)
{
- int rc;
+ int rc;
/* check ksnr_connected/connecting field large enough */
CLASSERT(SOCKLND_CONN_NTYPES <= 4);
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index c54c99551..b349847f9 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -25,26 +25,49 @@
*
*/
+#ifndef _SOCKLND_SOCKLND_H_
+#define _SOCKLND_SOCKLND_H_
+
#define DEBUG_PORTAL_ALLOC
#define DEBUG_SUBSYSTEM S_LND
-#include "socklnd_lib-linux.h"
+#include <linux/crc32.h>
+#include <linux/errno.h>
+#include <linux/if.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/kmod.h>
+#include <linux/list.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/stat.h>
+#include <linux/string.h>
+#include <linux/syscalls.h>
+#include <linux/sysctl.h>
+#include <linux/uio.h>
+#include <linux/unistd.h>
+#include <asm/irq.h>
+#include <net/sock.h>
+#include <net/tcp.h>
#include "../../../include/linux/libcfs/libcfs.h"
#include "../../../include/linux/lnet/lnet.h"
#include "../../../include/linux/lnet/lib-lnet.h"
#include "../../../include/linux/lnet/socklnd.h"
-#include "../../../include/linux/lnet/lnet-sysctl.h"
-#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */
-#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */
-#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */
-#define SOCKNAL_ENOMEM_RETRY CFS_TICK /* jiffies between retries */
+/* assume one thread for each connection type */
+#define SOCKNAL_NSCHEDS 3
+#define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1)
+
+#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */
+#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */
+#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */
+#define SOCKNAL_ENOMEM_RETRY CFS_TICK /* jiffies 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).
* no risk if we're not running on a CONFIG_HIGHMEM platform. */
@@ -58,33 +81,31 @@ struct ksock_sched_info;
typedef struct /* per scheduler state */
{
- spinlock_t kss_lock; /* serialise */
- struct list_head kss_rx_conns; /* conn waiting to be read */
- /* conn waiting to be written */
- struct list_head kss_tx_conns;
- /* zombie noop tx list */
- struct list_head kss_zombie_noop_txs;
- wait_queue_head_t kss_waitq; /* where scheduler sleeps */
- /* # connections assigned to this scheduler */
- int kss_nconns;
- struct ksock_sched_info *kss_info; /* owner of it */
- struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
- struct kvec kss_scratch_iov[LNET_MAX_IOV];
+ spinlock_t kss_lock; /* serialise */
+ struct list_head kss_rx_conns; /* conn waiting to be read */
+ struct list_head kss_tx_conns; /* conn waiting to be written */
+ struct list_head kss_zombie_noop_txs; /* zombie noop tx list */
+ wait_queue_head_t kss_waitq; /* where scheduler sleeps */
+ int kss_nconns; /* # connections assigned to
+ * this scheduler */
+ struct ksock_sched_info *kss_info; /* owner of it */
+ struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
+ struct kvec kss_scratch_iov[LNET_MAX_IOV];
} ksock_sched_t;
struct ksock_sched_info {
- int ksi_nthreads_max; /* max allowed threads */
- int ksi_nthreads; /* number of threads */
- int ksi_cpt; /* CPT id */
- ksock_sched_t *ksi_scheds; /* array of schedulers */
+ int ksi_nthreads_max; /* max allowed threads */
+ int ksi_nthreads; /* number of threads */
+ int ksi_cpt; /* CPT id */
+ ksock_sched_t *ksi_scheds; /* array of schedulers */
};
-#define KSOCK_CPT_SHIFT 16
-#define KSOCK_THREAD_ID(cpt, sid) (((cpt) << KSOCK_CPT_SHIFT) | (sid))
-#define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT)
-#define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1))
+#define KSOCK_CPT_SHIFT 16
+#define KSOCK_THREAD_ID(cpt, sid) (((cpt) << KSOCK_CPT_SHIFT) | (sid))
+#define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT)
+#define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1))
-typedef struct /* in-use interface */
+typedef struct /* in-use interface */
{
__u32 ksni_ipaddr; /* interface's IP address */
__u32 ksni_netmask; /* interface's network mask */
@@ -94,35 +115,48 @@ typedef struct /* in-use interface */
} ksock_interface_t;
typedef struct {
- /* "stuck" socket timeout (seconds) */
- int *ksnd_timeout;
- /* # scheduler threads in each pool while starting */
- int *ksnd_nscheds;
- int *ksnd_nconnds; /* # connection daemons */
- int *ksnd_nconnds_max; /* max # connection daemons */
- int *ksnd_min_reconnectms; /* first connection retry after (ms)... */
- int *ksnd_max_reconnectms; /* ...exponentially increasing to this */
- int *ksnd_eager_ack; /* make TCP ack eagerly? */
- int *ksnd_typed_conns; /* drive sockets by type? */
- int *ksnd_min_bulk; /* smallest "large" message */
- int *ksnd_tx_buffer_size; /* socket tx buffer size */
- int *ksnd_rx_buffer_size; /* socket rx buffer size */
- int *ksnd_nagle; /* enable NAGLE? */
- int *ksnd_round_robin; /* round robin for multiple interfaces */
- int *ksnd_keepalive; /* # secs for sending keepalive NOOP */
- int *ksnd_keepalive_idle; /* # idle secs before 1st probe */
- int *ksnd_keepalive_count; /* # probes */
- int *ksnd_keepalive_intvl; /* time between probes */
- int *ksnd_credits; /* # concurrent sends */
- int *ksnd_peertxcredits; /* # concurrent sends to 1 peer */
- int *ksnd_peerrtrcredits; /* # per-peer router buffer credits */
- int *ksnd_peertimeout; /* seconds to consider peer dead */
- int *ksnd_enable_csum; /* enable check sum */
- int *ksnd_inject_csum_error; /* set non-zero to inject checksum error */
- int *ksnd_nonblk_zcack; /* always send zc-ack on non-blocking connection */
- unsigned int *ksnd_zc_min_payload; /* minimum zero copy payload size */
- int *ksnd_zc_recv; /* enable ZC receive (for Chelsio TOE) */
- int *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to enable ZC receive */
+ int *ksnd_timeout; /* "stuck" socket timeout
+ * (seconds) */
+ int *ksnd_nscheds; /* # scheduler threads in each
+ * pool while starting */
+ int *ksnd_nconnds; /* # connection daemons */
+ int *ksnd_nconnds_max; /* max # connection daemons */
+ int *ksnd_min_reconnectms; /* first connection retry after
+ * (ms)... */
+ int *ksnd_max_reconnectms; /* ...exponentially increasing to
+ * this */
+ int *ksnd_eager_ack; /* make TCP ack eagerly? */
+ int *ksnd_typed_conns; /* drive sockets by type? */
+ int *ksnd_min_bulk; /* smallest "large" message */
+ int *ksnd_tx_buffer_size; /* socket tx buffer size */
+ int *ksnd_rx_buffer_size; /* socket rx buffer size */
+ int *ksnd_nagle; /* enable NAGLE? */
+ int *ksnd_round_robin; /* round robin for multiple
+ * interfaces */
+ int *ksnd_keepalive; /* # secs for sending keepalive
+ * NOOP */
+ int *ksnd_keepalive_idle; /* # idle secs before 1st probe
+ */
+ int *ksnd_keepalive_count; /* # probes */
+ int *ksnd_keepalive_intvl; /* time between probes */
+ int *ksnd_credits; /* # concurrent sends */
+ int *ksnd_peertxcredits; /* # concurrent sends to 1 peer
+ */
+ int *ksnd_peerrtrcredits; /* # per-peer router buffer
+ * credits */
+ int *ksnd_peertimeout; /* seconds to consider peer dead
+ */
+ int *ksnd_enable_csum; /* enable check sum */
+ int *ksnd_inject_csum_error; /* set non-zero to inject
+ * checksum error */
+ int *ksnd_nonblk_zcack; /* always send zc-ack on
+ * non-blocking connection */
+ unsigned int *ksnd_zc_min_payload; /* minimum zero copy payload
+ * size */
+ int *ksnd_zc_recv; /* enable ZC receive (for
+ * Chelsio TOE) */
+ int *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to
+ * enable ZC receive */
} ksock_tunables_t;
typedef struct {
@@ -141,55 +175,67 @@ typedef struct {
#define SOCKNAL_CONND_RESV 1
typedef struct {
- int ksnd_init; /* initialisation state */
- int ksnd_nnets; /* # networks set up */
- struct list_head ksnd_nets; /* list of nets */
- /* stabilize peer/conn ops */
- rwlock_t ksnd_global_lock;
- /* hash table of all my known peers */
- struct list_head *ksnd_peers;
- int ksnd_peer_hash_size; /* size of ksnd_peers */
-
- int ksnd_nthreads; /* # live threads */
- int ksnd_shuttingdown; /* tell threads to exit */
- /* schedulers information */
- struct ksock_sched_info **ksnd_sched_info;
-
- atomic_t ksnd_nactive_txs; /* #active txs */
-
- struct list_head ksnd_deathrow_conns; /* conns to close: reaper_lock*/
- struct list_head ksnd_zombie_conns; /* conns to free: reaper_lock */
- struct list_head ksnd_enomem_conns; /* conns to retry: reaper_lock*/
- wait_queue_head_t ksnd_reaper_waitq; /* reaper sleeps here */
- unsigned long ksnd_reaper_waketime;/* when reaper will wake */
- spinlock_t ksnd_reaper_lock; /* serialise */
-
- int ksnd_enomem_tx; /* test ENOMEM sender */
- int ksnd_stall_tx; /* test sluggish sender */
- int ksnd_stall_rx; /* test sluggish receiver */
-
- struct list_head ksnd_connd_connreqs; /* incoming connection requests */
- struct list_head ksnd_connd_routes; /* routes waiting to be connected */
- wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */
- int ksnd_connd_connecting;/* # connds connecting */
- /** time stamp of the last failed connecting attempt */
- long ksnd_connd_failed_stamp;
- /** # starting connd */
- unsigned ksnd_connd_starting;
- /** time stamp of the last starting connd */
- long ksnd_connd_starting_stamp;
- /** # running connd */
- unsigned ksnd_connd_running;
- spinlock_t ksnd_connd_lock; /* serialise */
-
- struct list_head ksnd_idle_noop_txs; /* list head for freed noop tx */
- spinlock_t ksnd_tx_lock; /* serialise, g_lock unsafe */
+ int ksnd_init; /* initialisation state
+ */
+ int ksnd_nnets; /* # networks set up */
+ struct list_head ksnd_nets; /* list of nets */
+ rwlock_t ksnd_global_lock; /* stabilize peer/conn
+ * ops */
+ struct list_head *ksnd_peers; /* hash table of all my
+ * known peers */
+ int ksnd_peer_hash_size; /* size of ksnd_peers */
+
+ int ksnd_nthreads; /* # live threads */
+ int ksnd_shuttingdown; /* tell threads to exit
+ */
+ struct ksock_sched_info **ksnd_sched_info; /* schedulers info */
+
+ atomic_t ksnd_nactive_txs; /* #active txs */
+
+ struct list_head ksnd_deathrow_conns; /* conns to close:
+ * reaper_lock*/
+ struct list_head ksnd_zombie_conns; /* conns to free:
+ * reaper_lock */
+ struct list_head ksnd_enomem_conns; /* conns to retry:
+ * reaper_lock*/
+ wait_queue_head_t ksnd_reaper_waitq; /* reaper sleeps here */
+ unsigned long ksnd_reaper_waketime; /* when reaper will wake
+ */
+ spinlock_t ksnd_reaper_lock; /* serialise */
+
+ int ksnd_enomem_tx; /* test ENOMEM sender */
+ int ksnd_stall_tx; /* test sluggish sender
+ */
+ int ksnd_stall_rx; /* test sluggish
+ * receiver */
+
+ struct list_head ksnd_connd_connreqs; /* incoming connection
+ * requests */
+ struct list_head ksnd_connd_routes; /* routes waiting to be
+ * connected */
+ wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */
+ int ksnd_connd_connecting; /* # connds connecting
+ */
+ time64_t ksnd_connd_failed_stamp;/* time stamp of the
+ * last failed
+ * connecting attempt */
+ time64_t ksnd_connd_starting_stamp;/* time stamp of the
+ * last starting connd
+ */
+ unsigned ksnd_connd_starting; /* # starting connd */
+ unsigned ksnd_connd_running; /* # running connd */
+ spinlock_t ksnd_connd_lock; /* serialise */
+
+ struct list_head ksnd_idle_noop_txs; /* list head for freed
+ * noop tx */
+ spinlock_t ksnd_tx_lock; /* serialise, g_lock
+ * unsafe */
} ksock_nal_data_t;
-#define SOCKNAL_INIT_NOTHING 0
-#define SOCKNAL_INIT_DATA 1
-#define SOCKNAL_INIT_ALL 2
+#define SOCKNAL_INIT_NOTHING 0
+#define SOCKNAL_INIT_DATA 1
+#define SOCKNAL_INIT_ALL 2
/* A packet just assembled for transmission is represented by 1 or more
* struct iovec fragments (the first frag contains the portals header),
@@ -200,43 +246,45 @@ typedef struct {
* received into either struct iovec or lnet_kiov_t fragments, depending on
* what the header matched or whether the message needs forwarding. */
-struct ksock_conn; /* forward ref */
-struct ksock_peer; /* forward ref */
-struct ksock_route; /* forward ref */
-struct ksock_proto; /* forward ref */
+struct ksock_conn; /* forward ref */
+struct ksock_peer; /* forward ref */
+struct ksock_route; /* forward ref */
+struct ksock_proto; /* forward ref */
-typedef struct /* transmit packet */
+typedef struct /* transmit packet */
{
- struct list_head tx_list; /* queue on conn for transmission etc */
- struct list_head tx_zc_list; /* queue on peer for ZC request */
- atomic_t tx_refcount; /* tx reference count */
- int tx_nob; /* # packet bytes */
- int tx_resid; /* residual bytes */
- int tx_niov; /* # packet iovec frags */
- struct kvec *tx_iov; /* packet iovec frags */
- int tx_nkiov; /* # packet page frags */
- unsigned short tx_zc_aborted; /* aborted ZC request */
- unsigned short tx_zc_capable:1; /* payload is large enough for ZC */
- unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */
- unsigned short tx_nonblk:1; /* it's a non-blocking ACK */
- lnet_kiov_t *tx_kiov; /* packet page frags */
- struct ksock_conn *tx_conn; /* owning conn */
- lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize() */
- unsigned long tx_deadline; /* when (in jiffies) tx times out */
- ksock_msg_t tx_msg; /* socklnd message buffer */
- int tx_desc_size; /* size of this descriptor */
+ struct list_head tx_list; /* queue on conn for transmission etc
+ */
+ struct list_head tx_zc_list; /* queue on peer for ZC request */
+ atomic_t tx_refcount; /* tx reference count */
+ int tx_nob; /* # packet bytes */
+ int tx_resid; /* residual bytes */
+ int tx_niov; /* # packet iovec frags */
+ struct kvec *tx_iov; /* packet iovec frags */
+ int tx_nkiov; /* # packet page frags */
+ unsigned short tx_zc_aborted; /* aborted ZC request */
+ unsigned short tx_zc_capable:1; /* payload is large enough for ZC */
+ unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */
+ unsigned short tx_nonblk:1; /* it's a non-blocking ACK */
+ lnet_kiov_t *tx_kiov; /* packet page frags */
+ struct ksock_conn *tx_conn; /* owning conn */
+ lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize()
+ */
+ unsigned long tx_deadline; /* when (in jiffies) tx times out */
+ ksock_msg_t tx_msg; /* socklnd message buffer */
+ int tx_desc_size; /* size of this descriptor */
union {
struct {
- struct kvec iov; /* virt hdr */
- lnet_kiov_t kiov[0]; /* paged payload */
- } paged;
+ struct kvec iov; /* virt hdr */
+ lnet_kiov_t kiov[0]; /* paged payload */
+ } paged;
struct {
- struct kvec iov[1]; /* virt hdr + payload */
- } virt;
- } tx_frags;
+ struct kvec iov[1]; /* virt hdr + payload */
+ } virt;
+ } tx_frags;
} ksock_tx_t;
-#define KSOCK_NOOP_TX_SIZE ((int)offsetof(ksock_tx_t, tx_frags.paged.kiov[0]))
+#define KSOCK_NOOP_TX_SIZE ((int)offsetof(ksock_tx_t, tx_frags.paged.kiov[0]))
/* network zero copy callback descriptor embedded in ksock_tx_t */
@@ -247,153 +295,205 @@ typedef union {
lnet_kiov_t kiov[LNET_MAX_IOV];
} ksock_rxiovspace_t;
-#define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */
-#define SOCKNAL_RX_LNET_HEADER 2 /* reading lnet message header */
-#define SOCKNAL_RX_PARSE 3 /* Calling lnet_parse() */
-#define SOCKNAL_RX_PARSE_WAIT 4 /* waiting to be told to read the body */
-#define SOCKNAL_RX_LNET_PAYLOAD 5 /* reading lnet payload (to deliver here) */
-#define SOCKNAL_RX_SLOP 6 /* skipping body */
+#define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */
+#define SOCKNAL_RX_LNET_HEADER 2 /* reading lnet message header */
+#define SOCKNAL_RX_PARSE 3 /* Calling lnet_parse() */
+#define SOCKNAL_RX_PARSE_WAIT 4 /* waiting to be told to read the body */
+#define SOCKNAL_RX_LNET_PAYLOAD 5 /* reading lnet payload (to deliver here) */
+#define SOCKNAL_RX_SLOP 6 /* skipping body */
typedef struct ksock_conn {
- struct ksock_peer *ksnc_peer; /* owning peer */
- struct ksock_route *ksnc_route; /* owning route */
- struct list_head ksnc_list; /* stash on peer's conn list */
- struct socket *ksnc_sock; /* actual socket */
- void *ksnc_saved_data_ready; /* socket's original data_ready() callback */
- void *ksnc_saved_write_space; /* socket's original write_space() callback */
- atomic_t ksnc_conn_refcount; /* conn refcount */
- atomic_t ksnc_sock_refcount; /* sock refcount */
- ksock_sched_t *ksnc_scheduler; /* who schedules this connection */
- __u32 ksnc_myipaddr; /* my IP */
- __u32 ksnc_ipaddr; /* peer's IP */
- int ksnc_port; /* peer's port */
- signed int ksnc_type:3; /* type of connection,
- * should be signed value */
- unsigned int ksnc_closing:1; /* being shut down */
- unsigned int ksnc_flip:1; /* flip or not, only for V2.x */
- unsigned int ksnc_zc_capable:1; /* enable to ZC */
- struct ksock_proto *ksnc_proto; /* protocol for the connection */
+ struct ksock_peer *ksnc_peer; /* owning peer */
+ struct ksock_route *ksnc_route; /* owning route */
+ struct list_head ksnc_list; /* stash on peer's conn list */
+ struct socket *ksnc_sock; /* actual socket */
+ void *ksnc_saved_data_ready; /* socket's original
+ * data_ready() callback */
+ void *ksnc_saved_write_space; /* socket's original
+ * write_space() callback */
+ atomic_t ksnc_conn_refcount;/* conn refcount */
+ atomic_t ksnc_sock_refcount;/* sock refcount */
+ ksock_sched_t *ksnc_scheduler; /* who schedules this connection
+ */
+ __u32 ksnc_myipaddr; /* my IP */
+ __u32 ksnc_ipaddr; /* peer's IP */
+ int ksnc_port; /* peer's port */
+ signed int ksnc_type:3; /* type of connection, should be
+ * signed value */
+ unsigned int ksnc_closing:1; /* being shut down */
+ unsigned int ksnc_flip:1; /* flip or not, only for V2.x */
+ unsigned int ksnc_zc_capable:1; /* enable to ZC */
+ struct ksock_proto *ksnc_proto; /* protocol for the connection */
/* reader */
- struct list_head ksnc_rx_list; /* where I enq waiting input or a forwarding descriptor */
- unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times out */
- __u8 ksnc_rx_started; /* started receiving a message */
- __u8 ksnc_rx_ready; /* data ready to read */
- __u8 ksnc_rx_scheduled;/* being progressed */
- __u8 ksnc_rx_state; /* what is being read */
- int ksnc_rx_nob_left; /* # bytes to next hdr/body */
- int ksnc_rx_nob_wanted; /* bytes actually wanted */
- int ksnc_rx_niov; /* # iovec frags */
- struct kvec *ksnc_rx_iov; /* the iovec frags */
- int ksnc_rx_nkiov; /* # page frags */
- lnet_kiov_t *ksnc_rx_kiov; /* the page frags */
- ksock_rxiovspace_t ksnc_rx_iov_space;/* space for frag descriptors */
- __u32 ksnc_rx_csum; /* partial checksum for incoming data */
- void *ksnc_cookie; /* rx lnet_finalize passthru arg */
- ksock_msg_t ksnc_msg; /* incoming message buffer:
- * V2.x message takes the
- * whole struct
- * V1.x message is a bare
- * lnet_hdr_t, it's stored in
- * ksnc_msg.ksm_u.lnetmsg */
+ struct list_head ksnc_rx_list; /* where I enq waiting input or a
+ * forwarding descriptor */
+ unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times
+ * out */
+ __u8 ksnc_rx_started; /* started receiving a message */
+ __u8 ksnc_rx_ready; /* data ready to read */
+ __u8 ksnc_rx_scheduled; /* being progressed */
+ __u8 ksnc_rx_state; /* what is being read */
+ int ksnc_rx_nob_left; /* # bytes to next hdr/body */
+ int ksnc_rx_nob_wanted;/* bytes actually wanted */
+ int ksnc_rx_niov; /* # iovec frags */
+ struct kvec *ksnc_rx_iov; /* the iovec frags */
+ int ksnc_rx_nkiov; /* # page frags */
+ lnet_kiov_t *ksnc_rx_kiov; /* the page frags */
+ ksock_rxiovspace_t ksnc_rx_iov_space; /* space for frag descriptors */
+ __u32 ksnc_rx_csum; /* partial checksum for incoming
+ * data */
+ void *ksnc_cookie; /* rx lnet_finalize passthru arg
+ */
+ ksock_msg_t ksnc_msg; /* incoming message buffer:
+ * V2.x message takes the
+ * whole struct
+ * V1.x message is a bare
+ * lnet_hdr_t, it's stored in
+ * ksnc_msg.ksm_u.lnetmsg */
/* WRITER */
- struct list_head ksnc_tx_list; /* where I enq waiting for output space */
- struct list_head ksnc_tx_queue; /* packets waiting to be sent */
- ksock_tx_t *ksnc_tx_carrier; /* next TX that can carry a LNet message or ZC-ACK */
- unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out */
- int ksnc_tx_bufnob; /* send buffer marker */
- atomic_t ksnc_tx_nob; /* # bytes queued */
- int ksnc_tx_ready; /* write space */
- int ksnc_tx_scheduled; /* being progressed */
- unsigned long ksnc_tx_last_post; /* time stamp of the last posted TX */
+ struct list_head ksnc_tx_list; /* where I enq waiting for output
+ * space */
+ struct list_head ksnc_tx_queue; /* packets waiting to be sent */
+ ksock_tx_t *ksnc_tx_carrier; /* next TX that can carry a LNet
+ * message or ZC-ACK */
+ unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out
+ */
+ int ksnc_tx_bufnob; /* send buffer marker */
+ atomic_t ksnc_tx_nob; /* # bytes queued */
+ int ksnc_tx_ready; /* write space */
+ int ksnc_tx_scheduled; /* being progressed */
+ unsigned long ksnc_tx_last_post; /* time stamp of the last posted
+ * TX */
} ksock_conn_t;
typedef struct ksock_route {
- struct list_head ksnr_list; /* chain on peer route list */
- struct list_head ksnr_connd_list; /* chain on ksnr_connd_routes */
- struct ksock_peer *ksnr_peer; /* owning peer */
- atomic_t ksnr_refcount; /* # users */
- unsigned long ksnr_timeout; /* when (in jiffies) reconnection can happen next */
- long ksnr_retry_interval; /* how long between retries */
- __u32 ksnr_myipaddr; /* my IP */
- __u32 ksnr_ipaddr; /* IP address to connect to */
- int ksnr_port; /* port to connect to */
- unsigned int ksnr_scheduled:1; /* scheduled for attention */
- unsigned int ksnr_connecting:1;/* connection establishment in progress */
- unsigned int ksnr_connected:4; /* connections established by type */
- unsigned int ksnr_deleted:1; /* been removed from peer? */
- unsigned int ksnr_share_count; /* created explicitly? */
- int ksnr_conn_count; /* # conns established by this route */
+ struct list_head ksnr_list; /* chain on peer route list */
+ struct list_head ksnr_connd_list; /* chain on ksnr_connd_routes */
+ struct ksock_peer *ksnr_peer; /* owning peer */
+ atomic_t ksnr_refcount; /* # users */
+ unsigned long ksnr_timeout; /* when (in jiffies) reconnection
+ * can happen next */
+ long ksnr_retry_interval; /* how long between retries */
+ __u32 ksnr_myipaddr; /* my IP */
+ __u32 ksnr_ipaddr; /* IP address to connect to */
+ int ksnr_port; /* port to connect to */
+ unsigned int ksnr_scheduled:1; /* scheduled for attention */
+ unsigned int ksnr_connecting:1; /* connection establishment in
+ * progress */
+ unsigned int ksnr_connected:4; /* connections established by
+ * type */
+ unsigned int ksnr_deleted:1; /* been removed from peer? */
+ unsigned int ksnr_share_count; /* created explicitly? */
+ int ksnr_conn_count; /* # conns established by this
+ * route */
} ksock_route_t;
-#define SOCKNAL_KEEPALIVE_PING 1 /* cookie for keepalive ping */
+#define SOCKNAL_KEEPALIVE_PING 1 /* cookie for keepalive ping */
typedef struct ksock_peer {
- struct list_head ksnp_list; /* stash on global peer list */
- unsigned long ksnp_last_alive; /* when (in jiffies) I was last alive */
- lnet_process_id_t ksnp_id; /* who's on the other end(s) */
- atomic_t ksnp_refcount; /* # users */
- int ksnp_sharecount; /* lconf usage counter */
- int ksnp_closing; /* being closed */
- int ksnp_accepting;/* # passive connections pending */
- int ksnp_error; /* errno on closing last conn */
- __u64 ksnp_zc_next_cookie;/* ZC completion cookie */
- __u64 ksnp_incarnation; /* latest known peer incarnation */
- struct ksock_proto *ksnp_proto; /* latest known peer protocol */
- struct list_head ksnp_conns; /* all active connections */
- struct list_head ksnp_routes; /* routes */
- struct list_head ksnp_tx_queue; /* waiting packets */
- spinlock_t ksnp_lock; /* serialize, g_lock unsafe */
- struct list_head ksnp_zc_req_list; /* zero copy requests wait for ACK */
- unsigned long ksnp_send_keepalive; /* time to send keepalive */
- lnet_ni_t *ksnp_ni; /* which network */
- int ksnp_n_passive_ips; /* # of... */
- __u32 ksnp_passive_ips[LNET_MAX_INTERFACES]; /* preferred local interfaces */
+ struct list_head ksnp_list; /* stash on global peer list */
+ unsigned long ksnp_last_alive; /* when (in jiffies) I was last
+ * alive */
+ lnet_process_id_t ksnp_id; /* who's on the other end(s) */
+ atomic_t ksnp_refcount; /* # users */
+ int ksnp_sharecount; /* lconf usage counter */
+ int ksnp_closing; /* being closed */
+ int ksnp_accepting; /* # passive connections pending
+ */
+ int ksnp_error; /* errno on closing last conn */
+ __u64 ksnp_zc_next_cookie; /* ZC completion cookie */
+ __u64 ksnp_incarnation; /* latest known peer incarnation
+ */
+ struct ksock_proto *ksnp_proto; /* latest known peer protocol */
+ struct list_head ksnp_conns; /* all active connections */
+ struct list_head ksnp_routes; /* routes */
+ struct list_head ksnp_tx_queue; /* waiting packets */
+ spinlock_t ksnp_lock; /* serialize, g_lock unsafe */
+ struct list_head ksnp_zc_req_list; /* zero copy requests wait for
+ * ACK */
+ unsigned long ksnp_send_keepalive; /* time to send keepalive */
+ lnet_ni_t *ksnp_ni; /* which network */
+ int ksnp_n_passive_ips; /* # of... */
+
+ /* preferred local interfaces */
+ __u32 ksnp_passive_ips[LNET_MAX_INTERFACES];
} ksock_peer_t;
typedef struct ksock_connreq {
- struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */
- lnet_ni_t *ksncr_ni; /* chosen NI */
- struct socket *ksncr_sock; /* accepted socket */
+ struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */
+ lnet_ni_t *ksncr_ni; /* chosen NI */
+ struct socket *ksncr_sock; /* accepted socket */
} ksock_connreq_t;
extern ksock_nal_data_t ksocknal_data;
extern ksock_tunables_t ksocknal_tunables;
-#define SOCKNAL_MATCH_NO 0 /* TX can't match type of connection */
-#define SOCKNAL_MATCH_YES 1 /* TX matches type of connection */
-#define SOCKNAL_MATCH_MAY 2 /* TX can be sent on the connection, but not preferred */
+#define SOCKNAL_MATCH_NO 0 /* TX can't match type of connection */
+#define SOCKNAL_MATCH_YES 1 /* TX matches type of connection */
+#define SOCKNAL_MATCH_MAY 2 /* TX can be sent on the connection, but not
+ * preferred */
typedef struct ksock_proto {
- int pro_version; /* version number of protocol */
- int (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *); /* handshake function */
- int (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int);/* handshake function */
- void (*pro_pack)(ksock_tx_t *); /* message pack */
- void (*pro_unpack)(ksock_msg_t *); /* message unpack */
- ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *); /* queue tx on the connection */
- int (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64); /* queue ZC ack on the connection */
- int (*pro_handle_zcreq)(ksock_conn_t *, __u64, int); /* handle ZC request */
- int (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64); /* handle ZC ACK */
- int (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int); /* msg type matches the connection type:
- * return value:
- * return MATCH_NO : no
- * return MATCH_YES : matching type
- * return MATCH_MAY : can be backup */
+ /* version number of protocol */
+ int pro_version;
+
+ /* handshake function */
+ int (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *);
+
+ /* handshake function */
+ int (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int);
+
+ /* message pack */
+ void (*pro_pack)(ksock_tx_t *);
+
+ /* message unpack */
+ void (*pro_unpack)(ksock_msg_t *);
+
+ /* queue tx on the connection */
+ ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *);
+
+ /* queue ZC ack on the connection */
+ int (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64);
+
+ /* handle ZC request */
+ int (*pro_handle_zcreq)(ksock_conn_t *, __u64, int);
+
+ /* handle ZC ACK */
+ int (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64);
+
+ /* msg type matches the connection type:
+ * return value:
+ * return MATCH_NO : no
+ * return MATCH_YES : matching type
+ * return MATCH_MAY : can be backup */
+ int (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int);
} ksock_proto_t;
extern ksock_proto_t ksocknal_protocol_v1x;
extern ksock_proto_t ksocknal_protocol_v2x;
extern ksock_proto_t ksocknal_protocol_v3x;
-#define KSOCK_PROTO_V1_MAJOR LNET_PROTO_TCP_VERSION_MAJOR
-#define KSOCK_PROTO_V1_MINOR LNET_PROTO_TCP_VERSION_MINOR
-#define KSOCK_PROTO_V1 KSOCK_PROTO_V1_MAJOR
+#define KSOCK_PROTO_V1_MAJOR LNET_PROTO_TCP_VERSION_MAJOR
+#define KSOCK_PROTO_V1_MINOR LNET_PROTO_TCP_VERSION_MINOR
+#define KSOCK_PROTO_V1 KSOCK_PROTO_V1_MAJOR
#ifndef CPU_MASK_NONE
#define CPU_MASK_NONE 0UL
#endif
+static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len)
+{
+#if 1
+ return crc32_le(crc, p, len);
+#else
+ while (len-- > 0)
+ crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ;
+ return crc;
+#endif
+}
+
static inline int
ksocknal_route_mask(void)
{
@@ -420,8 +520,8 @@ ksocknal_conn_addref(ksock_conn_t *conn)
atomic_inc(&conn->ksnc_conn_refcount);
}
-extern void ksocknal_queue_zombie_conn(ksock_conn_t *conn);
-extern void ksocknal_finalize_zcreq(ksock_conn_t *conn);
+void ksocknal_queue_zombie_conn(ksock_conn_t *conn);
+void ksocknal_finalize_zcreq(ksock_conn_t *conn);
static inline void
ksocknal_conn_decref(ksock_conn_t *conn)
@@ -434,7 +534,7 @@ ksocknal_conn_decref(ksock_conn_t *conn)
static inline int
ksocknal_connsock_addref(ksock_conn_t *conn)
{
- int rc = -ESHUTDOWN;
+ int rc = -ESHUTDOWN;
read_lock(&ksocknal_data.ksnd_global_lock);
if (!conn->ksnc_closing) {
@@ -453,7 +553,7 @@ ksocknal_connsock_decref(ksock_conn_t *conn)
LASSERT(atomic_read(&conn->ksnc_sock_refcount) > 0);
if (atomic_dec_and_test(&conn->ksnc_sock_refcount)) {
LASSERT(conn->ksnc_closing);
- libcfs_sock_release(conn->ksnc_sock);
+ sock_release(conn->ksnc_sock);
conn->ksnc_sock = NULL;
ksocknal_finalize_zcreq(conn);
}
@@ -466,8 +566,8 @@ ksocknal_tx_addref(ksock_tx_t *tx)
atomic_inc(&tx->tx_refcount);
}
-extern void ksocknal_tx_prep(ksock_conn_t *, ksock_tx_t *tx);
-extern void ksocknal_tx_done(lnet_ni_t *ni, ksock_tx_t *tx);
+void ksocknal_tx_prep(ksock_conn_t *, ksock_tx_t *tx);
+void ksocknal_tx_done(lnet_ni_t *ni, ksock_tx_t *tx);
static inline void
ksocknal_tx_decref(ksock_tx_t *tx)
@@ -484,7 +584,7 @@ ksocknal_route_addref(ksock_route_t *route)
atomic_inc(&route->ksnr_refcount);
}
-extern void ksocknal_destroy_route(ksock_route_t *route);
+void ksocknal_destroy_route(ksock_route_t *route);
static inline void
ksocknal_route_decref(ksock_route_t *route)
@@ -501,7 +601,7 @@ ksocknal_peer_addref(ksock_peer_t *peer)
atomic_inc(&peer->ksnp_refcount);
}
-extern void ksocknal_destroy_peer(ksock_peer_t *peer);
+void ksocknal_destroy_peer(ksock_peer_t *peer);
static inline void
ksocknal_peer_decref(ksock_peer_t *peer)
@@ -521,68 +621,69 @@ int ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
unsigned int offset, unsigned int mlen, unsigned int rlen);
int ksocknal_accept(lnet_ni_t *ni, struct socket *sock);
-extern int ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip, int port);
-extern ksock_peer_t *ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id);
-extern ksock_peer_t *ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id);
-extern void ksocknal_peer_failed(ksock_peer_t *peer);
-extern int ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
- struct socket *sock, int type);
-extern void ksocknal_close_conn_locked(ksock_conn_t *conn, int why);
-extern void ksocknal_terminate_conn(ksock_conn_t *conn);
-extern void ksocknal_destroy_conn(ksock_conn_t *conn);
-extern int ksocknal_close_peer_conns_locked(ksock_peer_t *peer,
- __u32 ipaddr, int why);
-extern int ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why);
-extern int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr);
-extern ksock_conn_t *ksocknal_find_conn_locked(ksock_peer_t *peer,
- ksock_tx_t *tx, int nonblk);
-
-extern int ksocknal_launch_packet(lnet_ni_t *ni, ksock_tx_t *tx,
- lnet_process_id_t id);
-extern ksock_tx_t *ksocknal_alloc_tx(int type, int size);
-extern void ksocknal_free_tx(ksock_tx_t *tx);
-extern ksock_tx_t *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk);
-extern void ksocknal_next_tx_carrier(ksock_conn_t *conn);
-extern void ksocknal_queue_tx_locked(ksock_tx_t *tx, ksock_conn_t *conn);
-extern void ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist,
- int error);
-extern void ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive);
-extern void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when);
-extern int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name);
-extern void ksocknal_thread_fini(void);
-extern void ksocknal_launch_all_connections_locked(ksock_peer_t *peer);
-extern ksock_route_t *ksocknal_find_connectable_route_locked(ksock_peer_t *peer);
-extern ksock_route_t *ksocknal_find_connecting_route_locked(ksock_peer_t *peer);
-extern int ksocknal_new_packet(ksock_conn_t *conn, int skip);
-extern int ksocknal_scheduler(void *arg);
-extern int ksocknal_connd(void *arg);
-extern int ksocknal_reaper(void *arg);
-extern int ksocknal_send_hello(lnet_ni_t *ni, ksock_conn_t *conn,
- lnet_nid_t peer_nid, ksock_hello_msg_t *hello);
-extern int ksocknal_recv_hello(lnet_ni_t *ni, ksock_conn_t *conn,
- ksock_hello_msg_t *hello, lnet_process_id_t *id,
- __u64 *incarnation);
-extern void ksocknal_read_callback(ksock_conn_t *conn);
-extern void ksocknal_write_callback(ksock_conn_t *conn);
-
-extern int ksocknal_lib_zc_capable(ksock_conn_t *conn);
-extern void ksocknal_lib_save_callback(struct socket *sock, ksock_conn_t *conn);
-extern void ksocknal_lib_set_callback(struct socket *sock, ksock_conn_t *conn);
-extern void ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn);
-extern void ksocknal_lib_push_conn(ksock_conn_t *conn);
-extern int ksocknal_lib_get_conn_addrs(ksock_conn_t *conn);
-extern int ksocknal_lib_setup_sock(struct socket *so);
-extern int ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx);
-extern int ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx);
-extern void ksocknal_lib_eager_ack(ksock_conn_t *conn);
-extern int ksocknal_lib_recv_iov(ksock_conn_t *conn);
-extern int ksocknal_lib_recv_kiov(ksock_conn_t *conn);
-extern int ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem,
- int *rxmem, int *nagle);
-
-extern int ksocknal_tunables_init(void);
-
-extern void ksocknal_lib_csum_tx(ksock_tx_t *tx);
-
-extern int ksocknal_lib_memory_pressure(ksock_conn_t *conn);
-extern int ksocknal_lib_bind_thread_to_cpu(int id);
+int ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip, int port);
+ksock_peer_t *ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id);
+ksock_peer_t *ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id);
+void ksocknal_peer_failed(ksock_peer_t *peer);
+int ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
+ struct socket *sock, int type);
+void ksocknal_close_conn_locked(ksock_conn_t *conn, int why);
+void ksocknal_terminate_conn(ksock_conn_t *conn);
+void ksocknal_destroy_conn(ksock_conn_t *conn);
+int ksocknal_close_peer_conns_locked(ksock_peer_t *peer,
+ __u32 ipaddr, int why);
+int ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why);
+int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr);
+ksock_conn_t *ksocknal_find_conn_locked(ksock_peer_t *peer,
+ ksock_tx_t *tx, int nonblk);
+
+int ksocknal_launch_packet(lnet_ni_t *ni, ksock_tx_t *tx,
+ lnet_process_id_t id);
+ksock_tx_t *ksocknal_alloc_tx(int type, int size);
+void ksocknal_free_tx(ksock_tx_t *tx);
+ksock_tx_t *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk);
+void ksocknal_next_tx_carrier(ksock_conn_t *conn);
+void ksocknal_queue_tx_locked(ksock_tx_t *tx, ksock_conn_t *conn);
+void ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int error);
+void ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive);
+void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when);
+int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name);
+void ksocknal_thread_fini(void);
+void ksocknal_launch_all_connections_locked(ksock_peer_t *peer);
+ksock_route_t *ksocknal_find_connectable_route_locked(ksock_peer_t *peer);
+ksock_route_t *ksocknal_find_connecting_route_locked(ksock_peer_t *peer);
+int ksocknal_new_packet(ksock_conn_t *conn, int skip);
+int ksocknal_scheduler(void *arg);
+int ksocknal_connd(void *arg);
+int ksocknal_reaper(void *arg);
+int ksocknal_send_hello(lnet_ni_t *ni, ksock_conn_t *conn,
+ lnet_nid_t peer_nid, ksock_hello_msg_t *hello);
+int ksocknal_recv_hello(lnet_ni_t *ni, ksock_conn_t *conn,
+ ksock_hello_msg_t *hello, lnet_process_id_t *id,
+ __u64 *incarnation);
+void ksocknal_read_callback(ksock_conn_t *conn);
+void ksocknal_write_callback(ksock_conn_t *conn);
+
+int ksocknal_lib_zc_capable(ksock_conn_t *conn);
+void ksocknal_lib_save_callback(struct socket *sock, ksock_conn_t *conn);
+void ksocknal_lib_set_callback(struct socket *sock, ksock_conn_t *conn);
+void ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn);
+void ksocknal_lib_push_conn(ksock_conn_t *conn);
+int ksocknal_lib_get_conn_addrs(ksock_conn_t *conn);
+int ksocknal_lib_setup_sock(struct socket *so);
+int ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx);
+int ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx);
+void ksocknal_lib_eager_ack(ksock_conn_t *conn);
+int ksocknal_lib_recv_iov(ksock_conn_t *conn);
+int ksocknal_lib_recv_kiov(ksock_conn_t *conn);
+int ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem,
+ int *rxmem, int *nagle);
+
+int ksocknal_tunables_init(void);
+
+void ksocknal_lib_csum_tx(ksock_tx_t *tx);
+
+int ksocknal_lib_memory_pressure(ksock_conn_t *conn);
+int ksocknal_lib_bind_thread_to_cpu(int id);
+
+#endif /* _SOCKLND_SOCKLND_H_ */
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index fa7ad883b..477b385f1 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -75,13 +75,13 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk)
return NULL;
}
- tx->tx_conn = NULL;
- tx->tx_lnetmsg = NULL;
- tx->tx_kiov = NULL;
- tx->tx_nkiov = 0;
- tx->tx_iov = tx->tx_frags.virt.iov;
- tx->tx_niov = 1;
- tx->tx_nonblk = nonblk;
+ tx->tx_conn = NULL;
+ tx->tx_lnetmsg = NULL;
+ tx->tx_kiov = NULL;
+ tx->tx_nkiov = 0;
+ tx->tx_iov = tx->tx_frags.virt.iov;
+ tx->tx_niov = 1;
+ tx->tx_nonblk = nonblk;
socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP);
tx->tx_msg.ksm_zc_cookies[1] = cookie;
@@ -89,7 +89,6 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk)
return tx;
}
-
void
ksocknal_free_tx (ksock_tx_t *tx)
{
@@ -110,11 +109,11 @@ ksocknal_free_tx (ksock_tx_t *tx)
static int
ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
{
- struct kvec *iov = tx->tx_iov;
- int nob;
- int rc;
+ struct kvec *iov = tx->tx_iov;
+ int nob;
+ int rc;
- LASSERT (tx->tx_niov > 0);
+ LASSERT(tx->tx_niov > 0);
/* Never touch tx->tx_iov inside ksocknal_lib_send_iov() */
rc = ksocknal_lib_send_iov(conn, tx);
@@ -128,7 +127,7 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
/* "consume" iov */
do {
- LASSERT (tx->tx_niov > 0);
+ LASSERT(tx->tx_niov > 0);
if (nob < (int) iov->iov_len) {
iov->iov_base = (void *)((char *)iov->iov_base + nob);
@@ -147,12 +146,12 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
static int
ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
{
- lnet_kiov_t *kiov = tx->tx_kiov;
- int nob;
- int rc;
+ lnet_kiov_t *kiov = tx->tx_kiov;
+ int nob;
+ int rc;
- LASSERT (tx->tx_niov == 0);
- LASSERT (tx->tx_nkiov > 0);
+ LASSERT(tx->tx_niov == 0);
+ LASSERT(tx->tx_nkiov > 0);
/* Never touch tx->tx_kiov inside ksocknal_lib_send_kiov() */
rc = ksocknal_lib_send_kiov(conn, tx);
@@ -185,15 +184,15 @@ ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
static int
ksocknal_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
{
- int rc;
- int bufnob;
+ int rc;
+ int bufnob;
if (ksocknal_data.ksnd_stall_tx != 0) {
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(cfs_time_seconds(ksocknal_data.ksnd_stall_tx));
}
- LASSERT (tx->tx_resid != 0);
+ LASSERT(tx->tx_resid != 0);
rc = ksocknal_connsock_addref(conn);
if (rc != 0) {
@@ -252,10 +251,10 @@ static int
ksocknal_recv_iov (ksock_conn_t *conn)
{
struct kvec *iov = conn->ksnc_rx_iov;
- int nob;
- int rc;
+ int nob;
+ int rc;
- LASSERT (conn->ksnc_rx_niov > 0);
+ LASSERT(conn->ksnc_rx_niov > 0);
/* Never touch conn->ksnc_rx_iov or change connection
* status inside ksocknal_lib_recv_iov */
@@ -277,7 +276,7 @@ ksocknal_recv_iov (ksock_conn_t *conn)
conn->ksnc_rx_nob_left -= nob;
do {
- LASSERT (conn->ksnc_rx_niov > 0);
+ LASSERT(conn->ksnc_rx_niov > 0);
if (nob < (int)iov->iov_len) {
iov->iov_len -= nob;
@@ -296,10 +295,11 @@ ksocknal_recv_iov (ksock_conn_t *conn)
static int
ksocknal_recv_kiov (ksock_conn_t *conn)
{
- lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
- int nob;
- int rc;
- LASSERT (conn->ksnc_rx_nkiov > 0);
+ lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
+ int nob;
+ int rc;
+
+ LASSERT(conn->ksnc_rx_nkiov > 0);
/* Never touch conn->ksnc_rx_kiov or change connection
* status inside ksocknal_lib_recv_iov */
@@ -321,7 +321,7 @@ ksocknal_recv_kiov (ksock_conn_t *conn)
conn->ksnc_rx_nob_left -= nob;
do {
- LASSERT (conn->ksnc_rx_nkiov > 0);
+ LASSERT(conn->ksnc_rx_nkiov > 0);
if (nob < (int) kiov->kiov_len) {
kiov->kiov_offset += nob;
@@ -343,7 +343,7 @@ ksocknal_receive (ksock_conn_t *conn)
/* Return 1 on success, 0 on EOF, < 0 on error.
* Caller checks ksnc_rx_nob_wanted to determine
* progress/completion. */
- int rc;
+ int rc;
if (ksocknal_data.ksnd_stall_rx != 0) {
set_current_state(TASK_UNINTERRUPTIBLE);
@@ -388,8 +388,8 @@ ksocknal_receive (ksock_conn_t *conn)
void
ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx)
{
- lnet_msg_t *lnetmsg = tx->tx_lnetmsg;
- int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO;
+ lnet_msg_t *lnetmsg = tx->tx_lnetmsg;
+ int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO;
LASSERT(ni != NULL || tx->tx_conn != NULL);
@@ -410,7 +410,7 @@ ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error)
ksock_tx_t *tx;
while (!list_empty (txlist)) {
- tx = list_entry (txlist->next, ksock_tx_t, tx_list);
+ tx = list_entry(txlist->next, ksock_tx_t, tx_list);
if (error && tx->tx_lnetmsg != NULL) {
CNETERR("Deleting packet type %d len %d %s->%s\n",
@@ -422,18 +422,18 @@ ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error)
CNETERR("Deleting noop packet\n");
}
- list_del (&tx->tx_list);
+ list_del(&tx->tx_list);
- LASSERT (atomic_read(&tx->tx_refcount) == 1);
- ksocknal_tx_done (ni, tx);
+ LASSERT(atomic_read(&tx->tx_refcount) == 1);
+ ksocknal_tx_done(ni, tx);
}
}
static void
ksocknal_check_zc_req(ksock_tx_t *tx)
{
- ksock_conn_t *conn = tx->tx_conn;
- ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_conn_t *conn = tx->tx_conn;
+ ksock_peer_t *peer = conn->ksnc_peer;
/* Set tx_msg.ksm_zc_cookies[0] to a unique non-zero cookie and add tx
* to ksnp_zc_req_list if some fragment of this message should be sent
@@ -441,8 +441,8 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
* she has received this message to tell us we can signal completion.
* tx_msg.ksm_zc_cookies[0] remains non-zero while tx is on
* ksnp_zc_req_list. */
- LASSERT (tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
- LASSERT (tx->tx_zc_capable);
+ LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
+ LASSERT(tx->tx_zc_capable);
tx->tx_zc_checked = 1;
@@ -461,7 +461,7 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
tx->tx_deadline =
cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
- LASSERT (tx->tx_msg.ksm_zc_cookies[0] == 0);
+ LASSERT(tx->tx_msg.ksm_zc_cookies[0] == 0);
tx->tx_msg.ksm_zc_cookies[0] = peer->ksnp_zc_next_cookie++;
@@ -476,7 +476,7 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
static void
ksocknal_uncheck_zc_req(ksock_tx_t *tx)
{
- ksock_peer_t *peer = tx->tx_conn->ksnc_peer;
+ ksock_peer_t *peer = tx->tx_conn->ksnc_peer;
LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
LASSERT(tx->tx_zc_capable);
@@ -502,14 +502,14 @@ ksocknal_uncheck_zc_req(ksock_tx_t *tx)
static int
ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
{
- int rc;
+ int rc;
if (tx->tx_zc_capable && !tx->tx_zc_checked)
ksocknal_check_zc_req(tx);
rc = ksocknal_transmit (conn, tx);
- CDEBUG (D_NET, "send(%d) %d\n", tx->tx_resid, rc);
+ CDEBUG(D_NET, "send(%d) %d\n", tx->tx_resid, rc);
if (tx->tx_resid == 0) {
/* Sent everything OK */
@@ -526,8 +526,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
counter++; /* exponential backoff warnings */
if ((counter & (-counter)) == counter)
- CWARN("%u ENOMEM tx %p (%u allocated)\n",
- counter, conn, atomic_read(&libcfs_kmemory));
+ CWARN("%u ENOMEM tx %p\n", counter, conn);
/* Queue on ksnd_enomem_conns for retry after a timeout */
spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
@@ -546,7 +545,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
}
/* Actual error */
- LASSERT (rc < 0);
+ LASSERT(rc < 0);
if (!conn->ksnc_closing) {
switch (rc) {
@@ -582,9 +581,9 @@ ksocknal_launch_connection_locked (ksock_route_t *route)
/* called holding write lock on ksnd_global_lock */
- LASSERT (!route->ksnr_scheduled);
- LASSERT (!route->ksnr_connecting);
- LASSERT ((ksocknal_route_mask() & ~route->ksnr_connected) != 0);
+ LASSERT(!route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting);
+ LASSERT((ksocknal_route_mask() & ~route->ksnr_connected) != 0);
route->ksnr_scheduled = 1; /* scheduling conn for connd */
ksocknal_route_addref(route); /* extra ref for connd */
@@ -617,22 +616,22 @@ ksocknal_launch_all_connections_locked (ksock_peer_t *peer)
ksock_conn_t *
ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk)
{
- struct list_head *tmp;
- ksock_conn_t *conn;
- ksock_conn_t *typed = NULL;
- ksock_conn_t *fallback = NULL;
- int tnob = 0;
- int fnob = 0;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
+ ksock_conn_t *typed = NULL;
+ ksock_conn_t *fallback = NULL;
+ int tnob = 0;
+ int fnob = 0;
list_for_each (tmp, &peer->ksnp_conns) {
ksock_conn_t *c = list_entry(tmp, ksock_conn_t, ksnc_list);
- int nob = atomic_read(&c->ksnc_tx_nob) +
- c->ksnc_sock->sk->sk_wmem_queued;
- int rc;
+ int nob = atomic_read(&c->ksnc_tx_nob) +
+ c->ksnc_sock->sk->sk_wmem_queued;
+ int rc;
- LASSERT (!c->ksnc_closing);
- LASSERT (c->ksnc_proto != NULL &&
- c->ksnc_proto->pro_match_tx != NULL);
+ LASSERT(!c->ksnc_closing);
+ LASSERT(c->ksnc_proto != NULL &&
+ c->ksnc_proto->pro_match_tx != NULL);
rc = c->ksnc_proto->pro_match_tx(c, tx, nonblk);
@@ -656,7 +655,7 @@ ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk)
(fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
fallback = c;
- fnob = nob;
+ fnob = nob;
}
break;
}
@@ -685,9 +684,9 @@ void
ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
{
ksock_sched_t *sched = conn->ksnc_scheduler;
- ksock_msg_t *msg = &tx->tx_msg;
- ksock_tx_t *ztx = NULL;
- int bufnob = 0;
+ ksock_msg_t *msg = &tx->tx_msg;
+ ksock_tx_t *ztx = NULL;
+ int bufnob = 0;
/* called holding global lock (read or irq-write) and caller may
* not have dropped this lock between finding conn and calling me,
@@ -708,14 +707,14 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
*
* We always expect at least 1 mapped fragment containing the
* complete ksocknal message header. */
- LASSERT (lnet_iov_nob (tx->tx_niov, tx->tx_iov) +
- lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
- (unsigned int)tx->tx_nob);
- LASSERT (tx->tx_niov >= 1);
- LASSERT (tx->tx_resid == tx->tx_nob);
+ LASSERT(lnet_iov_nob (tx->tx_niov, tx->tx_iov) +
+ lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
+ (unsigned int)tx->tx_nob);
+ LASSERT(tx->tx_niov >= 1);
+ LASSERT(tx->tx_resid == tx->tx_nob);
CDEBUG (D_NET, "Packet %p type %d, nob %d niov %d nkiov %d\n",
- tx, (tx->tx_lnetmsg != NULL) ? tx->tx_lnetmsg->msg_hdr.type:
+ tx, (tx->tx_lnetmsg != NULL) ? tx->tx_lnetmsg->msg_hdr.type :
KSOCK_MSG_NOOP,
tx->tx_nob, tx->tx_niov, tx->tx_nkiov);
@@ -739,8 +738,8 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
if (msg->ksm_type == KSOCK_MSG_NOOP) {
/* The packet is noop ZC ACK, try to piggyback the ack_cookie
* on a normal packet so I don't need to send it */
- LASSERT (msg->ksm_zc_cookies[1] != 0);
- LASSERT (conn->ksnc_proto->pro_queue_tx_zcack != NULL);
+ LASSERT(msg->ksm_zc_cookies[1] != 0);
+ LASSERT(conn->ksnc_proto->pro_queue_tx_zcack != NULL);
if (conn->ksnc_proto->pro_queue_tx_zcack(conn, tx, 0))
ztx = tx; /* ZC ACK piggybacked on ztx release tx later */
@@ -748,8 +747,8 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
} else {
/* It's a normal packet - can it piggback a noop zc-ack that
* has been queued already? */
- LASSERT (msg->ksm_zc_cookies[1] == 0);
- LASSERT (conn->ksnc_proto->pro_queue_tx_msg != NULL);
+ LASSERT(msg->ksm_zc_cookies[1] == 0);
+ LASSERT(conn->ksnc_proto->pro_queue_tx_msg != NULL);
ztx = conn->ksnc_proto->pro_queue_tx_msg(conn, tx);
/* ztx will be released later */
@@ -773,18 +772,17 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
spin_unlock_bh(&sched->kss_lock);
}
-
ksock_route_t *
ksocknal_find_connectable_route_locked (ksock_peer_t *peer)
{
- unsigned long now = cfs_time_current();
- struct list_head *tmp;
+ unsigned long now = cfs_time_current();
+ struct list_head *tmp;
ksock_route_t *route;
list_for_each (tmp, &peer->ksnp_routes) {
route = list_entry (tmp, ksock_route_t, ksnr_list);
- LASSERT (!route->ksnr_connecting || route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting || route->ksnr_scheduled);
if (route->ksnr_scheduled) /* connections being established */
continue;
@@ -813,13 +811,13 @@ ksocknal_find_connectable_route_locked (ksock_peer_t *peer)
ksock_route_t *
ksocknal_find_connecting_route_locked (ksock_peer_t *peer)
{
- struct list_head *tmp;
- ksock_route_t *route;
+ struct list_head *tmp;
+ ksock_route_t *route;
list_for_each (tmp, &peer->ksnp_routes) {
route = list_entry (tmp, ksock_route_t, ksnr_list);
- LASSERT (!route->ksnr_connecting || route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting || route->ksnr_scheduled);
if (route->ksnr_scheduled)
return route;
@@ -831,13 +829,13 @@ ksocknal_find_connecting_route_locked (ksock_peer_t *peer)
int
ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
{
- ksock_peer_t *peer;
- ksock_conn_t *conn;
- rwlock_t *g_lock;
- int retry;
- int rc;
+ ksock_peer_t *peer;
+ ksock_conn_t *conn;
+ rwlock_t *g_lock;
+ int retry;
+ int rc;
- LASSERT (tx->tx_conn == NULL);
+ LASSERT(tx->tx_conn == NULL);
g_lock = &ksocknal_data.ksnd_global_lock;
@@ -922,17 +920,17 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
int
ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
{
- int mpflag = 1;
- int type = lntmsg->msg_type;
+ int mpflag = 1;
+ int type = lntmsg->msg_type;
lnet_process_id_t target = lntmsg->msg_target;
- unsigned int payload_niov = lntmsg->msg_niov;
- struct kvec *payload_iov = lntmsg->msg_iov;
- lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
- unsigned int payload_offset = lntmsg->msg_offset;
- unsigned int payload_nob = lntmsg->msg_len;
- ksock_tx_t *tx;
- int desc_size;
- int rc;
+ unsigned int payload_niov = lntmsg->msg_niov;
+ struct kvec *payload_iov = lntmsg->msg_iov;
+ lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
+ unsigned int payload_offset = lntmsg->msg_offset;
+ unsigned int payload_nob = lntmsg->msg_len;
+ ksock_tx_t *tx;
+ int desc_size;
+ int rc;
/* NB 'private' is different depending on what we're sending.
* Just ignore it... */
@@ -940,8 +938,8 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
CDEBUG(D_NET, "sending %u bytes in %d frags to %s\n",
payload_nob, payload_niov, libcfs_id2str(target));
- LASSERT (payload_nob == 0 || payload_niov > 0);
- LASSERT (payload_niov <= LNET_MAX_IOV);
+ LASSERT(payload_nob == 0 || payload_niov > 0);
+ LASSERT(payload_niov <= LNET_MAX_IOV);
/* payload is either all vaddrs or all pages */
LASSERT (!(payload_kiov != NULL && payload_iov != NULL));
LASSERT (!in_interrupt ());
@@ -1028,9 +1026,9 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
{
static char ksocknal_slop_buffer[4096];
- int nob;
- unsigned int niov;
- int skipped;
+ int nob;
+ unsigned int niov;
+ int skipped;
LASSERT(conn->ksnc_proto != NULL);
@@ -1063,7 +1061,7 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space;
conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg.ksm_u.lnetmsg;
- conn->ksnc_rx_iov[0].iov_len = sizeof (lnet_hdr_t);
+ conn->ksnc_rx_iov[0].iov_len = sizeof (lnet_hdr_t);
break;
default:
@@ -1093,7 +1091,7 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
conn->ksnc_rx_iov[niov].iov_len = nob;
niov++;
skipped += nob;
- nob_to_skip -=nob;
+ nob_to_skip -= nob;
} while (nob_to_skip != 0 && /* mustn't overflow conn's rx iov */
niov < sizeof(conn->ksnc_rx_iov_space) / sizeof (struct iovec));
@@ -1108,18 +1106,18 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
static int
ksocknal_process_receive (ksock_conn_t *conn)
{
- lnet_hdr_t *lhdr;
+ lnet_hdr_t *lhdr;
lnet_process_id_t *id;
- int rc;
+ int rc;
LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0);
/* NB: sched lock NOT held */
/* SOCKNAL_RX_LNET_HEADER is here for backward compatibility */
- LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER ||
- conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD ||
- conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER ||
- conn->ksnc_rx_state == SOCKNAL_RX_SLOP);
+ LASSERT(conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER ||
+ conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD ||
+ conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER ||
+ conn->ksnc_rx_state == SOCKNAL_RX_SLOP);
again:
if (conn->ksnc_rx_nob_wanted != 0) {
rc = ksocknal_receive(conn);
@@ -1229,7 +1227,7 @@ ksocknal_process_receive (ksock_conn_t *conn)
if ((conn->ksnc_peer->ksnp_id.pid & LNET_PID_USERFLAG) != 0) {
/* Userspace peer */
lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
- id = &conn->ksnc_peer->ksnp_id;
+ id = &conn->ksnc_peer->ksnp_id;
/* Substitute process ID assigned at connection time */
lhdr->src_pid = cpu_to_le32(id->pid);
@@ -1277,7 +1275,7 @@ ksocknal_process_receive (ksock_conn_t *conn)
LASSERT(conn->ksnc_proto != &ksocknal_protocol_v1x);
lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
- id = &conn->ksnc_peer->ksnp_id;
+ id = &conn->ksnc_peer->ksnp_id;
rc = conn->ksnc_proto->pro_handle_zcreq(conn,
conn->ksnc_msg.ksm_zc_cookies[0],
@@ -1305,7 +1303,7 @@ ksocknal_process_receive (ksock_conn_t *conn)
}
/* Not Reached */
- LBUG ();
+ LBUG();
return -EINVAL; /* keep gcc happy */
}
@@ -1314,15 +1312,15 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
- ksock_conn_t *conn = (ksock_conn_t *)private;
+ ksock_conn_t *conn = private;
ksock_sched_t *sched = conn->ksnc_scheduler;
- LASSERT (mlen <= rlen);
- LASSERT (niov <= LNET_MAX_IOV);
+ LASSERT(mlen <= rlen);
+ LASSERT(niov <= LNET_MAX_IOV);
conn->ksnc_cookie = msg;
conn->ksnc_rx_nob_wanted = mlen;
- conn->ksnc_rx_nob_left = rlen;
+ conn->ksnc_rx_nob_left = rlen;
if (mlen == 0 || iov != NULL) {
conn->ksnc_rx_nkiov = 0;
@@ -1333,18 +1331,18 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
niov, iov, offset, mlen);
} else {
conn->ksnc_rx_niov = 0;
- conn->ksnc_rx_iov = NULL;
+ conn->ksnc_rx_iov = NULL;
conn->ksnc_rx_kiov = conn->ksnc_rx_iov_space.kiov;
conn->ksnc_rx_nkiov =
lnet_extract_kiov(LNET_MAX_IOV, conn->ksnc_rx_kiov,
niov, kiov, offset, mlen);
}
- LASSERT (mlen ==
- lnet_iov_nob (conn->ksnc_rx_niov, conn->ksnc_rx_iov) +
- lnet_kiov_nob (conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov));
+ LASSERT(mlen ==
+ lnet_iov_nob(conn->ksnc_rx_niov, conn->ksnc_rx_iov) +
+ lnet_kiov_nob(conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov));
- LASSERT (conn->ksnc_rx_scheduled);
+ LASSERT(conn->ksnc_rx_scheduled);
spin_lock_bh(&sched->kss_lock);
@@ -1370,7 +1368,7 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
static inline int
ksocknal_sched_cansleep(ksock_sched_t *sched)
{
- int rc;
+ int rc;
spin_lock_bh(&sched->kss_lock);
@@ -1384,13 +1382,13 @@ ksocknal_sched_cansleep(ksock_sched_t *sched)
int ksocknal_scheduler(void *arg)
{
- struct ksock_sched_info *info;
- ksock_sched_t *sched;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
- int rc;
- int nloops = 0;
- long id = (long)arg;
+ struct ksock_sched_info *info;
+ ksock_sched_t *sched;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
+ int rc;
+ int nloops = 0;
+ long id = (long)arg;
info = ksocknal_data.ksnd_sched_info[KSOCK_THREAD_CPT(id)];
sched = &info->ksi_scheds[KSOCK_THREAD_SID(id)];
@@ -1455,7 +1453,7 @@ int ksocknal_scheduler(void *arg)
}
if (!list_empty (&sched->kss_tx_conns)) {
- LIST_HEAD (zlist);
+ LIST_HEAD(zlist);
if (!list_empty(&sched->kss_zombie_noop_txs)) {
list_add(&zlist,
@@ -1513,9 +1511,9 @@ int ksocknal_scheduler(void *arg)
/* Do nothing; after a short timeout, this
* conn will be reposted on kss_tx_conns. */
} else if (conn->ksnc_tx_ready &&
- !list_empty (&conn->ksnc_tx_queue)) {
+ !list_empty(&conn->ksnc_tx_queue)) {
/* reschedule for tx */
- list_add_tail (&conn->ksnc_tx_list,
+ list_add_tail(&conn->ksnc_tx_list,
&sched->kss_tx_conns);
} else {
conn->ksnc_tx_scheduled = 0;
@@ -1606,7 +1604,7 @@ void ksocknal_write_callback (ksock_conn_t *conn)
static ksock_proto_t *
ksocknal_parse_proto_version (ksock_hello_msg_t *hello)
{
- __u32 version = 0;
+ __u32 version = 0;
if (hello->kshm_magic == LNET_PROTO_MAGIC)
version = hello->kshm_version;
@@ -1634,8 +1632,8 @@ ksocknal_parse_proto_version (ksock_hello_msg_t *hello)
if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) {
lnet_magicversion_t *hmv = (lnet_magicversion_t *)hello;
- CLASSERT (sizeof (lnet_magicversion_t) ==
- offsetof (ksock_hello_msg_t, kshm_src_nid));
+ CLASSERT(sizeof (lnet_magicversion_t) ==
+ offsetof (ksock_hello_msg_t, kshm_src_nid));
if (hmv->version_major == cpu_to_le16 (KSOCK_PROTO_V1_MAJOR) &&
hmv->version_minor == cpu_to_le16 (KSOCK_PROTO_V1_MINOR))
@@ -1650,19 +1648,19 @@ ksocknal_send_hello (lnet_ni_t *ni, ksock_conn_t *conn,
lnet_nid_t peer_nid, ksock_hello_msg_t *hello)
{
/* CAVEAT EMPTOR: this byte flips 'ipaddrs' */
- ksock_net_t *net = (ksock_net_t *)ni->ni_data;
+ ksock_net_t *net = (ksock_net_t *)ni->ni_data;
- LASSERT (hello->kshm_nips <= LNET_MAX_INTERFACES);
+ LASSERT(hello->kshm_nips <= LNET_MAX_INTERFACES);
/* rely on caller to hold a ref on socket so it wouldn't disappear */
- LASSERT (conn->ksnc_proto != NULL);
+ LASSERT(conn->ksnc_proto != NULL);
- hello->kshm_src_nid = ni->ni_nid;
- hello->kshm_dst_nid = peer_nid;
- hello->kshm_src_pid = the_lnet.ln_pid;
+ hello->kshm_src_nid = ni->ni_nid;
+ hello->kshm_dst_nid = peer_nid;
+ hello->kshm_src_pid = the_lnet.ln_pid;
hello->kshm_src_incarnation = net->ksnn_incarnation;
- hello->kshm_ctype = conn->ksnc_type;
+ hello->kshm_ctype = conn->ksnc_type;
return conn->ksnc_proto->pro_send_hello(conn, hello);
}
@@ -1693,21 +1691,21 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
* EALREADY lost connection race
* EPROTO protocol version mismatch
*/
- struct socket *sock = conn->ksnc_sock;
- int active = (conn->ksnc_proto != NULL);
- int timeout;
- int proto_match;
- int rc;
- ksock_proto_t *proto;
- lnet_process_id_t recv_id;
+ struct socket *sock = conn->ksnc_sock;
+ int active = (conn->ksnc_proto != NULL);
+ int timeout;
+ int proto_match;
+ int rc;
+ ksock_proto_t *proto;
+ lnet_process_id_t recv_id;
/* socket type set on active connections - not set on passive */
- LASSERT (!active == !(conn->ksnc_type != SOCKLND_CONN_NONE));
+ LASSERT(!active == !(conn->ksnc_type != SOCKLND_CONN_NONE));
timeout = active ? *ksocknal_tunables.ksnd_timeout :
lnet_acceptor_timeout();
- rc = libcfs_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
+ rc = lnet_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout);
if (rc != 0) {
CERROR("Error %d reading HELLO from %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -1726,12 +1724,12 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
return -EPROTO;
}
- rc = libcfs_sock_read(sock, &hello->kshm_version,
- sizeof(hello->kshm_version), timeout);
+ rc = lnet_sock_read(sock, &hello->kshm_version,
+ sizeof(hello->kshm_version), timeout);
if (rc != 0) {
CERROR("Error %d reading HELLO from %pI4h\n",
rc, &conn->ksnc_ipaddr);
- LASSERT (rc < 0);
+ LASSERT(rc < 0);
return rc;
}
@@ -1765,7 +1763,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
if (rc != 0) {
CERROR("Error %d reading or checking hello from from %pI4h\n",
rc, &conn->ksnc_ipaddr);
- LASSERT (rc < 0);
+ LASSERT(rc < 0);
return rc;
}
@@ -1830,22 +1828,22 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
static int
ksocknal_connect (ksock_route_t *route)
{
- LIST_HEAD (zombies);
- ksock_peer_t *peer = route->ksnr_peer;
- int type;
- int wanted;
- struct socket *sock;
- unsigned long deadline;
- int retry_later = 0;
- int rc = 0;
+ LIST_HEAD(zombies);
+ ksock_peer_t *peer = route->ksnr_peer;
+ int type;
+ int wanted;
+ struct socket *sock;
+ unsigned long deadline;
+ int retry_later = 0;
+ int rc = 0;
deadline = cfs_time_add(cfs_time_current(),
cfs_time_seconds(*ksocknal_tunables.ksnd_timeout));
write_lock_bh(&ksocknal_data.ksnd_global_lock);
- LASSERT (route->ksnr_scheduled);
- LASSERT (!route->ksnr_connecting);
+ LASSERT(route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting);
route->ksnr_connecting = 1;
@@ -1999,7 +1997,7 @@ ksocknal_connect (ksock_route_t *route)
* running out of resource.
*/
static int
-ksocknal_connd_check_start(long sec, long *timeout)
+ksocknal_connd_check_start(time64_t sec, long *timeout)
{
char name[16];
int rc;
@@ -2049,7 +2047,7 @@ ksocknal_connd_check_start(long sec, long *timeout)
/* we tried ... */
LASSERT(ksocknal_data.ksnd_connd_starting > 0);
ksocknal_data.ksnd_connd_starting--;
- ksocknal_data.ksnd_connd_failed_stamp = get_seconds();
+ ksocknal_data.ksnd_connd_failed_stamp = ktime_get_real_seconds();
return 1;
}
@@ -2061,7 +2059,7 @@ ksocknal_connd_check_start(long sec, long *timeout)
* again to recheck these conditions.
*/
static int
-ksocknal_connd_check_stop(long sec, long *timeout)
+ksocknal_connd_check_stop(time64_t sec, long *timeout)
{
int val;
@@ -2101,7 +2099,7 @@ static ksock_route_t *
ksocknal_connd_get_route_locked(signed long *timeout_p)
{
ksock_route_t *route;
- unsigned long now;
+ unsigned long now;
now = cfs_time_current();
@@ -2124,13 +2122,13 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
int
ksocknal_connd (void *arg)
{
- spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock;
- ksock_connreq_t *cr;
- wait_queue_t wait;
- int nloops = 0;
- int cons_retry = 0;
+ spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock;
+ ksock_connreq_t *cr;
+ wait_queue_t wait;
+ int nloops = 0;
+ int cons_retry = 0;
- cfs_block_allsigs ();
+ cfs_block_allsigs();
init_waitqueue_entry(&wait, current);
@@ -2142,9 +2140,9 @@ ksocknal_connd (void *arg)
while (!ksocknal_data.ksnd_shuttingdown) {
ksock_route_t *route = NULL;
- long sec = get_seconds();
+ time64_t sec = ktime_get_real_seconds();
long timeout = MAX_SCHEDULE_TIMEOUT;
- int dropped_lock = 0;
+ int dropped_lock = 0;
if (ksocknal_connd_check_stop(sec, &timeout)) {
/* wakeup another one to check stop */
@@ -2236,15 +2234,16 @@ static ksock_conn_t *
ksocknal_find_timed_out_conn (ksock_peer_t *peer)
{
/* We're called with a shared lock on ksnd_global_lock */
- ksock_conn_t *conn;
- struct list_head *ctmp;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
list_for_each (ctmp, &peer->ksnp_conns) {
- int error;
+ int error;
+
conn = list_entry (ctmp, ksock_conn_t, ksnc_list);
/* Don't need the {get,put}connsock dance to deref ksnc_sock */
- LASSERT (!conn->ksnc_closing);
+ LASSERT(!conn->ksnc_closing);
/* SOCK_ERROR will reset error code of socket in
* some platform (like Darwin8.x) */
@@ -2313,8 +2312,8 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer)
static inline void
ksocknal_flush_stale_txs(ksock_peer_t *peer)
{
- ksock_tx_t *tx;
- LIST_HEAD (stale_txs);
+ ksock_tx_t *tx;
+ LIST_HEAD(stale_txs);
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -2338,9 +2337,9 @@ ksocknal_flush_stale_txs(ksock_peer_t *peer)
static int
ksocknal_send_keepalive_locked(ksock_peer_t *peer)
{
- ksock_sched_t *sched;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
+ ksock_sched_t *sched;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
if (list_empty(&peer->ksnp_conns)) /* last_alive will be updated by create_conn */
return 0;
@@ -2395,14 +2394,13 @@ ksocknal_send_keepalive_locked(ksock_peer_t *peer)
return -EIO;
}
-
static void
ksocknal_check_peer_timeouts (int idx)
{
- struct list_head *peers = &ksocknal_data.ksnd_peers[idx];
- ksock_peer_t *peer;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
+ struct list_head *peers = &ksocknal_data.ksnd_peers[idx];
+ ksock_peer_t *peer;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
again:
/* NB. We expect to have a look at all the peers and not find any
@@ -2411,9 +2409,9 @@ ksocknal_check_peer_timeouts (int idx)
read_lock(&ksocknal_data.ksnd_global_lock);
list_for_each_entry(peer, peers, ksnp_list) {
- unsigned long deadline = 0;
- int resid = 0;
- int n = 0;
+ unsigned long deadline = 0;
+ int resid = 0;
+ int n = 0;
if (ksocknal_send_keepalive_locked(peer) != 0) {
read_unlock(&ksocknal_data.ksnd_global_lock);
@@ -2476,8 +2474,8 @@ ksocknal_check_peer_timeouts (int idx)
tx = list_entry(peer->ksnp_zc_req_list.next,
ksock_tx_t, tx_zc_list);
deadline = tx->tx_deadline;
- resid = tx->tx_resid;
- conn = tx->tx_conn;
+ resid = tx->tx_resid;
+ conn = tx->tx_conn;
ksocknal_conn_addref(conn);
spin_unlock(&peer->ksnp_lock);
@@ -2499,17 +2497,17 @@ ksocknal_check_peer_timeouts (int idx)
int
ksocknal_reaper (void *arg)
{
- wait_queue_t wait;
- ksock_conn_t *conn;
- ksock_sched_t *sched;
- struct list_head enomem_conns;
- int nenomem_conns;
- long timeout;
- int i;
- int peer_index = 0;
- unsigned long deadline = cfs_time_current();
-
- cfs_block_allsigs ();
+ wait_queue_t wait;
+ ksock_conn_t *conn;
+ ksock_sched_t *sched;
+ struct list_head enomem_conns;
+ int nenomem_conns;
+ long timeout;
+ int i;
+ int peer_index = 0;
+ unsigned long deadline = cfs_time_current();
+
+ cfs_block_allsigs();
INIT_LIST_HEAD(&enomem_conns);
init_waitqueue_entry(&wait, current);
@@ -2580,7 +2578,7 @@ ksocknal_reaper (void *arg)
cfs_time_current())) <= 0) {
const int n = 4;
const int p = 1;
- int chunk = ksocknal_data.ksnd_peer_hash_size;
+ int chunk = ksocknal_data.ksnd_peer_hash_size;
/* Time to check for timeouts on a few more peers: I do
* checks every 'p' seconds on a proportion of the peer
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h
deleted file mode 100644
index f5563881b..000000000
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h
+++ /dev/null
@@ -1,86 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2005, 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.
- */
-
-#define DEBUG_PORTAL_ALLOC
-
-#ifndef __LINUX_SOCKNAL_LIB_H__
-#define __LINUX_SOCKNAL_LIB_H__
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/unistd.h>
-#include <net/sock.h>
-#include <net/tcp.h>
-#include <linux/uio.h>
-#include <linux/if.h>
-#include <linux/uaccess.h>
-
-#include <asm/irq.h>
-
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/list.h>
-#include <linux/kmod.h>
-#include <linux/sysctl.h>
-#include <asm/div64.h>
-#include <linux/syscalls.h>
-
-#include "../../../include/linux/libcfs/libcfs.h"
-
-#include <linux/crc32.h>
-static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len)
-{
-#if 1
- return crc32_le(crc, p, len);
-#else
- while (len-- > 0)
- crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ;
- return crc;
-#endif
-}
-
-#define SOCKNAL_WSPACE(sk) sk_stream_wspace(sk)
-#define SOCKNAL_MIN_WSPACE(sk) sk_stream_min_wspace(sk)
-
-/* assume one thread for each connection type */
-#define SOCKNAL_NSCHEDS 3
-#define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1)
-
-#endif
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index f5e8ab060..679785b02 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -39,9 +39,8 @@
int
ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
{
- int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1,
- &conn->ksnc_ipaddr,
- &conn->ksnc_port);
+ int rc = lnet_sock_getaddr(conn->ksnc_sock, 1, &conn->ksnc_ipaddr,
+ &conn->ksnc_port);
/* Didn't need the {get,put}connsock dance to deref ksnc_sock... */
LASSERT(!conn->ksnc_closing);
@@ -51,8 +50,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
return rc;
}
- rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
- &conn->ksnc_myipaddr, NULL);
+ rc = lnet_sock_getaddr(conn->ksnc_sock, 0, &conn->ksnc_myipaddr, NULL);
if (rc != 0) {
CERROR("Error %d getting sock local IP\n", rc);
return rc;
@@ -64,7 +62,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
int
ksocknal_lib_zc_capable(ksock_conn_t *conn)
{
- int caps = conn->ksnc_sock->sk->sk_route_caps;
+ int caps = conn->ksnc_sock->sk->sk_route_caps;
if (conn->ksnc_proto == &ksocknal_protocol_v1x)
return 0;
@@ -78,8 +76,8 @@ int
ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
{
struct socket *sock = conn->ksnc_sock;
- int nob;
- int rc;
+ int nob;
+ int rc;
if (*ksocknal_tunables.ksnd_enable_csum && /* checksum enabled */
conn->ksnc_proto == &ksocknal_protocol_v2x && /* V2.x connection */
@@ -92,15 +90,15 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
{
#if SOCKNAL_SINGLE_FRAG_TX
- struct kvec scratch;
- struct kvec *scratchiov = &scratch;
- unsigned int niov = 1;
+ struct kvec scratch;
+ struct kvec *scratchiov = &scratch;
+ unsigned int niov = 1;
#else
- struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- unsigned int niov = tx->tx_niov;
+ struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+ unsigned int niov = tx->tx_niov;
#endif
struct msghdr msg = {.msg_flags = MSG_DONTWAIT};
- int i;
+ int i;
for (nob = i = 0; i < niov; i++) {
scratchiov[i] = tx->tx_iov[i];
@@ -120,9 +118,9 @@ int
ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
{
struct socket *sock = conn->ksnc_sock;
- lnet_kiov_t *kiov = tx->tx_kiov;
- int rc;
- int nob;
+ lnet_kiov_t *kiov = tx->tx_kiov;
+ int rc;
+ int nob;
/* Not NOOP message */
LASSERT(tx->tx_lnetmsg != NULL);
@@ -131,11 +129,11 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
* or leave them alone. */
if (tx->tx_msg.ksm_zc_cookies[0] != 0) {
/* Zero copy is enabled */
- struct sock *sk = sock->sk;
- struct page *page = kiov->kiov_page;
- int offset = kiov->kiov_offset;
- int fragsize = kiov->kiov_len;
- int msgflg = MSG_DONTWAIT;
+ struct sock *sk = sock->sk;
+ struct page *page = kiov->kiov_page;
+ int offset = kiov->kiov_offset;
+ int fragsize = kiov->kiov_len;
+ int msgflg = MSG_DONTWAIT;
CDEBUG(D_NET, "page %p + offset %x for %d\n",
page, offset, kiov->kiov_len);
@@ -148,23 +146,22 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
rc = sk->sk_prot->sendpage(sk, page,
offset, fragsize, msgflg);
} else {
- rc = cfs_tcp_sendpage(sk, page, offset, fragsize,
- msgflg);
+ rc = tcp_sendpage(sk, page, offset, fragsize, msgflg);
}
} else {
#if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
- struct kvec scratch;
+ struct kvec scratch;
struct kvec *scratchiov = &scratch;
- unsigned int niov = 1;
+ unsigned int niov = 1;
#else
#ifdef CONFIG_HIGHMEM
#warning "XXX risk of kmap deadlock on multiple frags..."
#endif
struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- unsigned int niov = tx->tx_nkiov;
+ unsigned int niov = tx->tx_nkiov;
#endif
struct msghdr msg = {.msg_flags = MSG_DONTWAIT};
- int i;
+ int i;
for (nob = i = 0; i < niov; i++) {
scratchiov[i].iov_base = kmap(kiov[i].kiov_page) +
@@ -187,7 +184,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
void
ksocknal_lib_eager_ack(ksock_conn_t *conn)
{
- int opt = 1;
+ int opt = 1;
struct socket *sock = conn->ksnc_sock;
/* Remind the socket to ACK eagerly. If I don't, the socket might
@@ -203,23 +200,23 @@ int
ksocknal_lib_recv_iov(ksock_conn_t *conn)
{
#if SOCKNAL_SINGLE_FRAG_RX
- struct kvec scratch;
+ struct kvec scratch;
struct kvec *scratchiov = &scratch;
- unsigned int niov = 1;
+ unsigned int niov = 1;
#else
struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- unsigned int niov = conn->ksnc_rx_niov;
+ unsigned int niov = conn->ksnc_rx_niov;
#endif
struct kvec *iov = conn->ksnc_rx_iov;
struct msghdr msg = {
- .msg_flags = 0
+ .msg_flags = 0
};
- int nob;
- int i;
- int rc;
- int fragnob;
- int sum;
- __u32 saved_csum;
+ int nob;
+ int i;
+ int rc;
+ int fragnob;
+ int sum;
+ __u32 saved_csum;
/* NB we can't trust socket ops to either consume our iovs
* or leave them alone. */
@@ -271,9 +268,9 @@ static void *
ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
struct kvec *iov, struct page **pages)
{
- void *addr;
- int nob;
- int i;
+ void *addr;
+ int nob;
+ int i;
if (!*ksocknal_tunables.ksnd_zc_recv || pages == NULL)
return NULL;
@@ -307,29 +304,29 @@ int
ksocknal_lib_recv_kiov(ksock_conn_t *conn)
{
#if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK
- struct kvec scratch;
- struct kvec *scratchiov = &scratch;
- struct page **pages = NULL;
- unsigned int niov = 1;
+ struct kvec scratch;
+ struct kvec *scratchiov = &scratch;
+ struct page **pages = NULL;
+ unsigned int niov = 1;
#else
#ifdef CONFIG_HIGHMEM
#warning "XXX risk of kmap deadlock on multiple frags..."
#endif
- struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- struct page **pages = conn->ksnc_scheduler->kss_rx_scratch_pgs;
- unsigned int niov = conn->ksnc_rx_nkiov;
+ struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+ struct page **pages = conn->ksnc_scheduler->kss_rx_scratch_pgs;
+ unsigned int niov = conn->ksnc_rx_nkiov;
#endif
lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
struct msghdr msg = {
- .msg_flags = 0
+ .msg_flags = 0
};
- int nob;
- int i;
- int rc;
- void *base;
- void *addr;
- int sum;
- int fragnob;
+ int nob;
+ int i;
+ int rc;
+ void *base;
+ void *addr;
+ int sum;
+ int fragnob;
int n;
/* NB we can't trust socket ops to either consume our iovs
@@ -357,10 +354,10 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn)
for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
LASSERT(i < niov);
- /* Dang! have to kmap again because I have nowhere to stash the
- * mapped address. But by doing it while the page is still
- * mapped, the kernel just bumps the map count and returns me
- * the address it stashed. */
+ /* Dang! have to kmap again because I have nowhere to
+ * stash the mapped address. But by doing it while the
+ * page is still mapped, the kernel just bumps the map
+ * count and returns me the address it stashed. */
base = kmap(kiov[i].kiov_page) + kiov[i].kiov_offset;
fragnob = kiov[i].kiov_len;
if (fragnob > sum)
@@ -386,9 +383,9 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn)
void
ksocknal_lib_csum_tx(ksock_tx_t *tx)
{
- int i;
- __u32 csum;
- void *base;
+ int i;
+ __u32 csum;
+ void *base;
LASSERT(tx->tx_iov[0].iov_base == &tx->tx_msg);
LASSERT(tx->tx_conn != NULL);
@@ -426,8 +423,8 @@ int
ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle)
{
struct socket *sock = conn->ksnc_sock;
- int len;
- int rc;
+ int len;
+ int rc;
rc = ksocknal_connsock_addref(conn);
if (rc != 0) {
@@ -436,7 +433,7 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *
return -ESHUTDOWN;
}
- rc = libcfs_sock_getbuf(sock, txmem, rxmem);
+ rc = lnet_sock_getbuf(sock, txmem, rxmem);
if (rc == 0) {
len = sizeof(*nagle);
rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY,
@@ -456,13 +453,13 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *
int
ksocknal_lib_setup_sock(struct socket *sock)
{
- int rc;
- int option;
- int keep_idle;
- int keep_intvl;
- int keep_count;
- int do_keepalive;
- struct linger linger;
+ int rc;
+ int option;
+ int keep_idle;
+ int keep_intvl;
+ int keep_count;
+ int do_keepalive;
+ struct linger linger;
sock->sk->sk_allocation = GFP_NOFS;
@@ -498,9 +495,8 @@ ksocknal_lib_setup_sock(struct socket *sock)
}
}
- rc = libcfs_sock_setbuf(sock,
- *ksocknal_tunables.ksnd_tx_buffer_size,
- *ksocknal_tunables.ksnd_rx_buffer_size);
+ rc = lnet_sock_setbuf(sock, *ksocknal_tunables.ksnd_tx_buffer_size,
+ *ksocknal_tunables.ksnd_rx_buffer_size);
if (rc != 0) {
CERROR("Can't set buffer tx %d, rx %d buffers: %d\n",
*ksocknal_tunables.ksnd_tx_buffer_size,
@@ -555,11 +551,11 @@ ksocknal_lib_setup_sock(struct socket *sock)
void
ksocknal_lib_push_conn(ksock_conn_t *conn)
{
- struct sock *sk;
+ struct sock *sk;
struct tcp_sock *tp;
- int nonagle;
- int val = 1;
- int rc;
+ int nonagle;
+ int val = 1;
+ int rc;
rc = ksocknal_connsock_addref(conn);
if (rc != 0) /* being shut down */
@@ -592,7 +588,7 @@ extern void ksocknal_write_callback(ksock_conn_t *conn);
static void
ksocknal_data_ready(struct sock *sk)
{
- ksock_conn_t *conn;
+ ksock_conn_t *conn;
/* interleave correctly with closing sockets... */
LASSERT(!in_irq());
@@ -611,17 +607,17 @@ ksocknal_data_ready(struct sock *sk)
static void
ksocknal_write_space(struct sock *sk)
{
- ksock_conn_t *conn;
- int wspace;
- int min_wpace;
+ ksock_conn_t *conn;
+ int wspace;
+ int min_wpace;
/* interleave correctly with closing sockets... */
LASSERT(!in_irq());
read_lock(&ksocknal_data.ksnd_global_lock);
conn = sk->sk_user_data;
- wspace = SOCKNAL_WSPACE(sk);
- min_wpace = SOCKNAL_MIN_WSPACE(sk);
+ wspace = sk_stream_wspace(sk);
+ min_wpace = sk_stream_min_wspace(sk);
CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n",
sk, wspace, min_wpace, conn,
@@ -689,7 +685,7 @@ ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn)
int
ksocknal_lib_memory_pressure(ksock_conn_t *conn)
{
- int rc = 0;
+ int rc = 0;
ksock_sched_t *sched;
sched = conn->ksnc_scheduler;
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
index 86b88db1c..fdb2b23e2 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
@@ -134,7 +134,6 @@ static unsigned int zc_recv_min_nfrags = 16;
module_param(zc_recv_min_nfrags, int, 0644);
MODULE_PARM_DESC(zc_recv_min_nfrags, "minimum # of fragments to enable ZC recv");
-
#if SOCKNAL_VERSION_DEBUG
static int protocol = 3;
module_param(protocol, int, 0644);
@@ -145,40 +144,37 @@ ksock_tunables_t ksocknal_tunables;
int ksocknal_tunables_init(void)
{
-
/* initialize ksocknal_tunables structure */
- ksocknal_tunables.ksnd_timeout = &sock_timeout;
- ksocknal_tunables.ksnd_nscheds = &nscheds;
- ksocknal_tunables.ksnd_nconnds = &nconnds;
- ksocknal_tunables.ksnd_nconnds_max = &nconnds_max;
+ ksocknal_tunables.ksnd_timeout = &sock_timeout;
+ ksocknal_tunables.ksnd_nscheds = &nscheds;
+ ksocknal_tunables.ksnd_nconnds = &nconnds;
+ ksocknal_tunables.ksnd_nconnds_max = &nconnds_max;
ksocknal_tunables.ksnd_min_reconnectms = &min_reconnectms;
ksocknal_tunables.ksnd_max_reconnectms = &max_reconnectms;
- ksocknal_tunables.ksnd_eager_ack = &eager_ack;
- ksocknal_tunables.ksnd_typed_conns = &typed_conns;
- ksocknal_tunables.ksnd_min_bulk = &min_bulk;
+ ksocknal_tunables.ksnd_eager_ack = &eager_ack;
+ ksocknal_tunables.ksnd_typed_conns = &typed_conns;
+ ksocknal_tunables.ksnd_min_bulk = &min_bulk;
ksocknal_tunables.ksnd_tx_buffer_size = &tx_buffer_size;
ksocknal_tunables.ksnd_rx_buffer_size = &rx_buffer_size;
- ksocknal_tunables.ksnd_nagle = &nagle;
- ksocknal_tunables.ksnd_round_robin = &round_robin;
- ksocknal_tunables.ksnd_keepalive = &keepalive;
+ ksocknal_tunables.ksnd_nagle = &nagle;
+ ksocknal_tunables.ksnd_round_robin = &round_robin;
+ ksocknal_tunables.ksnd_keepalive = &keepalive;
ksocknal_tunables.ksnd_keepalive_idle = &keepalive_idle;
ksocknal_tunables.ksnd_keepalive_count = &keepalive_count;
ksocknal_tunables.ksnd_keepalive_intvl = &keepalive_intvl;
- ksocknal_tunables.ksnd_credits = &credits;
+ ksocknal_tunables.ksnd_credits = &credits;
ksocknal_tunables.ksnd_peertxcredits = &peer_credits;
ksocknal_tunables.ksnd_peerrtrcredits = &peer_buffer_credits;
- ksocknal_tunables.ksnd_peertimeout = &peer_timeout;
- ksocknal_tunables.ksnd_enable_csum = &enable_csum;
+ ksocknal_tunables.ksnd_peertimeout = &peer_timeout;
+ ksocknal_tunables.ksnd_enable_csum = &enable_csum;
ksocknal_tunables.ksnd_inject_csum_error = &inject_csum_error;
ksocknal_tunables.ksnd_nonblk_zcack = &nonblk_zcack;
ksocknal_tunables.ksnd_zc_min_payload = &zc_min_payload;
- ksocknal_tunables.ksnd_zc_recv = &zc_recv;
+ ksocknal_tunables.ksnd_zc_recv = &zc_recv;
ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags;
-
-
#if SOCKNAL_VERSION_DEBUG
- ksocknal_tunables.ksnd_protocol = &protocol;
+ ksocknal_tunables.ksnd_protocol = &protocol;
#endif
if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10))
diff --git a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
index 8596581f5..986bce4c9 100644
--- a/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
+++ b/kernel/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
@@ -52,7 +52,7 @@ ksocknal_queue_tx_msg_v1(ksock_conn_t *conn, ksock_tx_t *tx_msg)
void
ksocknal_next_tx_carrier(ksock_conn_t *conn)
{
- ksock_tx_t *tx = conn->ksnc_tx_carrier;
+ ksock_tx_t *tx = conn->ksnc_tx_carrier;
/* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
LASSERT(!list_empty(&conn->ksnc_tx_queue));
@@ -119,7 +119,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
static ksock_tx_t *
ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg)
{
- ksock_tx_t *tx = conn->ksnc_tx_carrier;
+ ksock_tx_t *tx = conn->ksnc_tx_carrier;
/*
* Enqueue tx_msg:
@@ -361,10 +361,10 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk)
static int
ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote)
{
- ksock_peer_t *peer = c->ksnc_peer;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
- int rc;
+ ksock_peer_t *peer = c->ksnc_peer;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
+ int rc;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -405,11 +405,11 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote)
static int
ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
{
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_tx_t *tx;
- ksock_tx_t *tmp;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_tx_t *tx;
+ ksock_tx_t *tmp;
LIST_HEAD(zlist);
- int count;
+ int count;
if (cookie1 == 0)
cookie1 = cookie2;
@@ -452,11 +452,11 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
static int
ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
{
- struct socket *sock = conn->ksnc_sock;
- lnet_hdr_t *hdr;
+ struct socket *sock = conn->ksnc_sock;
+ lnet_hdr_t *hdr;
lnet_magicversion_t *hmv;
- int rc;
- int i;
+ int rc;
+ int i;
CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid));
@@ -470,7 +470,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
/* Re-organize V2.x message header to V1.x (lnet_hdr_t)
* header and send out */
- hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
+ hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
hmv->version_major = cpu_to_le16 (KSOCK_PROTO_V1_MAJOR);
hmv->version_minor = cpu_to_le16 (KSOCK_PROTO_V1_MINOR);
@@ -488,16 +488,14 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
LNET_UNLOCK();
}
- hdr->src_nid = cpu_to_le64 (hello->kshm_src_nid);
- hdr->src_pid = cpu_to_le32 (hello->kshm_src_pid);
- hdr->type = cpu_to_le32 (LNET_MSG_HELLO);
+ hdr->src_nid = cpu_to_le64 (hello->kshm_src_nid);
+ hdr->src_pid = cpu_to_le32 (hello->kshm_src_pid);
+ hdr->type = cpu_to_le32 (LNET_MSG_HELLO);
hdr->payload_length = cpu_to_le32 (hello->kshm_nips * sizeof(__u32));
hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
- rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),
- lnet_acceptor_timeout());
-
+ rc = lnet_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
@@ -511,9 +509,9 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]);
}
- rc = libcfs_sock_write(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32),
- lnet_acceptor_timeout());
+ rc = lnet_sock_write(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32),
+ lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
rc, hello->kshm_nips,
@@ -529,7 +527,7 @@ static int
ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
{
struct socket *sock = conn->ksnc_sock;
- int rc;
+ int rc;
hello->kshm_magic = LNET_PROTO_MAGIC;
hello->kshm_version = conn->ksnc_proto->pro_version;
@@ -544,9 +542,8 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
LNET_UNLOCK();
}
- rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
- lnet_acceptor_timeout());
-
+ rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
+ lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
rc, &conn->ksnc_ipaddr, conn->ksnc_port);
@@ -556,9 +553,9 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
if (hello->kshm_nips == 0)
return 0;
- rc = libcfs_sock_write(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32),
- lnet_acceptor_timeout());
+ rc = lnet_sock_write(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32),
+ lnet_acceptor_timeout());
if (rc != 0) {
CNETERR("Error %d sending HELLO payload (%d) to %pI4h/%d\n",
rc, hello->kshm_nips,
@@ -572,10 +569,10 @@ static int
ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
int timeout)
{
- struct socket *sock = conn->ksnc_sock;
- lnet_hdr_t *hdr;
- int rc;
- int i;
+ struct socket *sock = conn->ksnc_sock;
+ lnet_hdr_t *hdr;
+ int rc;
+ int i;
LIBCFS_ALLOC(hdr, sizeof(*hdr));
if (hdr == NULL) {
@@ -583,9 +580,9 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
return -ENOMEM;
}
- rc = libcfs_sock_read(sock, &hdr->src_nid,
- sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
- timeout);
+ rc = lnet_sock_read(sock, &hdr->src_nid,
+ sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
+ timeout);
if (rc != 0) {
CERROR("Error %d reading rest of HELLO hdr from %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -602,12 +599,12 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
goto out;
}
- hello->kshm_src_nid = le64_to_cpu(hdr->src_nid);
- hello->kshm_src_pid = le32_to_cpu(hdr->src_pid);
+ hello->kshm_src_nid = le64_to_cpu(hdr->src_nid);
+ hello->kshm_src_pid = le32_to_cpu(hdr->src_pid);
hello->kshm_src_incarnation = le64_to_cpu(hdr->msg.hello.incarnation);
- hello->kshm_ctype = le32_to_cpu(hdr->msg.hello.type);
- hello->kshm_nips = le32_to_cpu(hdr->payload_length) /
- sizeof(__u32);
+ hello->kshm_ctype = le32_to_cpu(hdr->msg.hello.type);
+ hello->kshm_nips = le32_to_cpu(hdr->payload_length) /
+ sizeof(__u32);
if (hello->kshm_nips > LNET_MAX_INTERFACES) {
CERROR("Bad nips %d from ip %pI4h\n",
@@ -619,8 +616,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
if (hello->kshm_nips == 0)
goto out;
- rc = libcfs_sock_read(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32), timeout);
+ rc = lnet_sock_read(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32), timeout);
if (rc != 0) {
CERROR("Error %d reading IPs from ip %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -647,19 +644,19 @@ out:
static int
ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout)
{
- struct socket *sock = conn->ksnc_sock;
- int rc;
- int i;
+ struct socket *sock = conn->ksnc_sock;
+ int rc;
+ int i;
if (hello->kshm_magic == LNET_PROTO_MAGIC)
conn->ksnc_flip = 0;
else
conn->ksnc_flip = 1;
- rc = libcfs_sock_read(sock, &hello->kshm_src_nid,
- offsetof(ksock_hello_msg_t, kshm_ips) -
- offsetof(ksock_hello_msg_t, kshm_src_nid),
- timeout);
+ rc = lnet_sock_read(sock, &hello->kshm_src_nid,
+ offsetof(ksock_hello_msg_t, kshm_ips) -
+ offsetof(ksock_hello_msg_t, kshm_src_nid),
+ timeout);
if (rc != 0) {
CERROR("Error %d reading HELLO from %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -687,8 +684,8 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout
if (hello->kshm_nips == 0)
return 0;
- rc = libcfs_sock_read(sock, hello->kshm_ips,
- hello->kshm_nips * sizeof(__u32), timeout);
+ rc = lnet_sock_read(sock, hello->kshm_ips,
+ hello->kshm_nips * sizeof(__u32), timeout);
if (rc != 0) {
CERROR("Error %d reading IPs from ip %pI4h\n",
rc, &conn->ksnc_ipaddr);
@@ -746,9 +743,9 @@ ksocknal_pack_msg_v2(ksock_tx_t *tx)
static void
ksocknal_unpack_msg_v1(ksock_msg_t *msg)
{
- msg->ksm_csum = 0;
- msg->ksm_type = KSOCK_MSG_LNET;
- msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0;
+ msg->ksm_csum = 0;
+ msg->ksm_type = KSOCK_MSG_LNET;
+ msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0;
}
static void
@@ -758,40 +755,40 @@ ksocknal_unpack_msg_v2(ksock_msg_t *msg)
}
ksock_proto_t ksocknal_protocol_v1x = {
- .pro_version = KSOCK_PROTO_V1,
- .pro_send_hello = ksocknal_send_hello_v1,
- .pro_recv_hello = ksocknal_recv_hello_v1,
- .pro_pack = ksocknal_pack_msg_v1,
- .pro_unpack = ksocknal_unpack_msg_v1,
- .pro_queue_tx_msg = ksocknal_queue_tx_msg_v1,
- .pro_handle_zcreq = NULL,
- .pro_handle_zcack = NULL,
- .pro_queue_tx_zcack = NULL,
- .pro_match_tx = ksocknal_match_tx
+ .pro_version = KSOCK_PROTO_V1,
+ .pro_send_hello = ksocknal_send_hello_v1,
+ .pro_recv_hello = ksocknal_recv_hello_v1,
+ .pro_pack = ksocknal_pack_msg_v1,
+ .pro_unpack = ksocknal_unpack_msg_v1,
+ .pro_queue_tx_msg = ksocknal_queue_tx_msg_v1,
+ .pro_handle_zcreq = NULL,
+ .pro_handle_zcack = NULL,
+ .pro_queue_tx_zcack = NULL,
+ .pro_match_tx = ksocknal_match_tx
};
ksock_proto_t ksocknal_protocol_v2x = {
- .pro_version = KSOCK_PROTO_V2,
- .pro_send_hello = ksocknal_send_hello_v2,
- .pro_recv_hello = ksocknal_recv_hello_v2,
- .pro_pack = ksocknal_pack_msg_v2,
- .pro_unpack = ksocknal_unpack_msg_v2,
- .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
- .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v2,
- .pro_handle_zcreq = ksocknal_handle_zcreq,
- .pro_handle_zcack = ksocknal_handle_zcack,
- .pro_match_tx = ksocknal_match_tx
+ .pro_version = KSOCK_PROTO_V2,
+ .pro_send_hello = ksocknal_send_hello_v2,
+ .pro_recv_hello = ksocknal_recv_hello_v2,
+ .pro_pack = ksocknal_pack_msg_v2,
+ .pro_unpack = ksocknal_unpack_msg_v2,
+ .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
+ .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v2,
+ .pro_handle_zcreq = ksocknal_handle_zcreq,
+ .pro_handle_zcack = ksocknal_handle_zcack,
+ .pro_match_tx = ksocknal_match_tx
};
ksock_proto_t ksocknal_protocol_v3x = {
- .pro_version = KSOCK_PROTO_V3,
- .pro_send_hello = ksocknal_send_hello_v2,
- .pro_recv_hello = ksocknal_recv_hello_v2,
- .pro_pack = ksocknal_pack_msg_v2,
- .pro_unpack = ksocknal_unpack_msg_v2,
- .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
- .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v3,
- .pro_handle_zcreq = ksocknal_handle_zcreq,
- .pro_handle_zcack = ksocknal_handle_zcack,
- .pro_match_tx = ksocknal_match_tx_v3
+ .pro_version = KSOCK_PROTO_V3,
+ .pro_send_hello = ksocknal_send_hello_v2,
+ .pro_recv_hello = ksocknal_recv_hello_v2,
+ .pro_pack = ksocknal_pack_msg_v2,
+ .pro_unpack = ksocknal_unpack_msg_v2,
+ .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
+ .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v3,
+ .pro_handle_zcreq = ksocknal_handle_zcreq,
+ .pro_handle_zcack = ksocknal_handle_zcack,
+ .pro_match_tx = ksocknal_match_tx_v3
};
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/Makefile b/kernel/drivers/staging/lustre/lnet/lnet/Makefile
index 336b8ea4f..e276fe2bf 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/Makefile
+++ b/kernel/drivers/staging/lustre/lnet/lnet/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_LNET) += lnet.o
-lnet-y := api-ni.o config.o lib-me.o lib-msg.o lib-eq.o \
- lib-md.o lib-ptl.o lib-move.o module.o lo.o router.o \
- router_proc.o acceptor.o peer.o
+lnet-y := api-ni.o config.o nidstrings.o \
+ lib-me.o lib-msg.o lib-eq.o lib-md.o lib-ptl.o \
+ lib-socket.o lib-move.o module.o lo.o \
+ router.o router_proc.o acceptor.o peer.o
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/acceptor.c b/kernel/drivers/staging/lustre/lnet/lnet/acceptor.c
index 72fd1bf70..92ca1dd64 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/acceptor.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/acceptor.c
@@ -35,9 +35,9 @@
*/
#define DEBUG_SUBSYSTEM S_LNET
+#include <linux/completion.h>
#include "../../include/linux/lnet/lib-lnet.h"
-
static int accept_port = 988;
static int accept_backlog = 127;
static int accept_timeout = 5;
@@ -143,10 +143,10 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
__u32 local_ip, __u32 peer_ip, int peer_port)
{
lnet_acceptor_connreq_t cr;
- struct socket *sock;
- int rc;
- int port;
- int fatal;
+ struct socket *sock;
+ int rc;
+ int port;
+ int fatal;
CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */
@@ -155,9 +155,8 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
--port) {
/* Iterate through reserved ports. */
- rc = libcfs_sock_connect(&sock, &fatal,
- local_ip, port,
- peer_ip, peer_port);
+ rc = lnet_sock_connect(&sock, &fatal, local_ip, port, peer_ip,
+ peer_port);
if (rc != 0) {
if (fatal)
goto failed;
@@ -184,8 +183,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
lnet_net_unlock(LNET_LOCK_EX);
}
- rc = libcfs_sock_write(sock, &cr, sizeof(cr),
- accept_timeout);
+ rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
if (rc != 0)
goto failed_sock;
@@ -197,30 +195,29 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
goto failed;
failed_sock:
- libcfs_sock_release(sock);
+ sock_release(sock);
failed:
lnet_connect_console_error(rc, peer_nid, peer_ip, peer_port);
return rc;
}
EXPORT_SYMBOL(lnet_connect);
-
/* Below is the code common for both kernel and MT user-space */
static int
lnet_accept(struct socket *sock, __u32 magic)
{
lnet_acceptor_connreq_t cr;
- __u32 peer_ip;
- int peer_port;
- int rc;
- int flip;
- lnet_ni_t *ni;
- char *str;
+ __u32 peer_ip;
+ int peer_port;
+ int rc;
+ int flip;
+ lnet_ni_t *ni;
+ char *str;
LASSERT(sizeof(cr) <= 16); /* not too big for the stack */
- rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
+ rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port);
LASSERT(rc == 0); /* we succeeded before */
if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) {
@@ -234,8 +231,8 @@ lnet_accept(struct socket *sock, __u32 magic)
memset(&cr, 0, sizeof(cr));
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
- rc = libcfs_sock_write(sock, &cr, sizeof(cr),
- accept_timeout);
+ rc = lnet_sock_write(sock, &cr, sizeof(cr),
+ accept_timeout);
if (rc != 0)
CERROR("Error sending magic+version in response to LNET magic from %pI4h: %d\n",
@@ -245,8 +242,6 @@ lnet_accept(struct socket *sock, __u32 magic)
if (magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC))
str = "'old' socknal/tcpnal";
- else if (lnet_accept_magic(magic, LNET_PROTO_RA_MAGIC))
- str = "'old' ranal";
else
str = "unrecognised";
@@ -257,9 +252,8 @@ lnet_accept(struct socket *sock, __u32 magic)
flip = (magic != LNET_PROTO_ACCEPTOR_MAGIC);
- rc = libcfs_sock_read(sock, &cr.acr_version,
- sizeof(cr.acr_version),
- accept_timeout);
+ rc = lnet_sock_read(sock, &cr.acr_version, sizeof(cr.acr_version),
+ accept_timeout);
if (rc != 0) {
CERROR("Error %d reading connection request version from %pI4h\n",
rc, &peer_ip);
@@ -280,19 +274,17 @@ lnet_accept(struct socket *sock, __u32 magic)
cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC;
cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
- rc = libcfs_sock_write(sock, &cr, sizeof(cr),
- accept_timeout);
-
+ rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout);
if (rc != 0)
CERROR("Error sending magic+version in response to version %d from %pI4h: %d\n",
peer_version, &peer_ip, rc);
return -EPROTO;
}
- rc = libcfs_sock_read(sock, &cr.acr_nid,
- sizeof(cr) -
- offsetof(lnet_acceptor_connreq_t, acr_nid),
- accept_timeout);
+ rc = lnet_sock_read(sock, &cr.acr_nid,
+ sizeof(cr) -
+ offsetof(lnet_acceptor_connreq_t, acr_nid),
+ accept_timeout);
if (rc != 0) {
CERROR("Error %d reading connection request from %pI4h\n",
rc, &peer_ip);
@@ -333,18 +325,18 @@ static int
lnet_acceptor(void *arg)
{
struct socket *newsock;
- int rc;
- __u32 magic;
- __u32 peer_ip;
- int peer_port;
- int secure = (int)((long_ptr_t)arg);
+ int rc;
+ __u32 magic;
+ __u32 peer_ip;
+ int peer_port;
+ int secure = (int)((long_ptr_t)arg);
LASSERT(lnet_acceptor_state.pta_sock == NULL);
cfs_block_allsigs();
- rc = libcfs_sock_listen(&lnet_acceptor_state.pta_sock,
- 0, accept_port, accept_backlog);
+ rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock, 0, accept_port,
+ accept_backlog);
if (rc != 0) {
if (rc == -EADDRINUSE)
LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port %d: port already in use\n",
@@ -367,7 +359,7 @@ lnet_acceptor(void *arg)
while (!lnet_acceptor_state.pta_shutdown) {
- rc = libcfs_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
+ rc = lnet_sock_accept(&newsock, lnet_acceptor_state.pta_sock);
if (rc != 0) {
if (rc != -EAGAIN) {
CWARN("Accept error %d: pausing...\n", rc);
@@ -377,13 +369,13 @@ lnet_acceptor(void *arg)
continue;
}
- /* maybe we're waken up with libcfs_sock_abort_accept() */
+ /* maybe the LNet acceptor thread has been waken */
if (lnet_acceptor_state.pta_shutdown) {
- libcfs_sock_release(newsock);
+ sock_release(newsock);
break;
}
- rc = libcfs_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
+ rc = lnet_sock_getaddr(newsock, 1, &peer_ip, &peer_port);
if (rc != 0) {
CERROR("Can't determine new connection's address\n");
goto failed;
@@ -395,8 +387,8 @@ lnet_acceptor(void *arg)
goto failed;
}
- rc = libcfs_sock_read(newsock, &magic, sizeof(magic),
- accept_timeout);
+ rc = lnet_sock_read(newsock, &magic, sizeof(magic),
+ accept_timeout);
if (rc != 0) {
CERROR("Error %d reading connection request from %pI4h\n",
rc, &peer_ip);
@@ -410,10 +402,10 @@ lnet_acceptor(void *arg)
continue;
failed:
- libcfs_sock_release(newsock);
+ sock_release(newsock);
}
- libcfs_sock_release(lnet_acceptor_state.pta_sock);
+ sock_release(lnet_acceptor_state.pta_sock);
lnet_acceptor_state.pta_sock = NULL;
CDEBUG(D_NET, "Acceptor stopping\n");
@@ -444,7 +436,7 @@ accept2secure(const char *acc, long *sec)
int
lnet_acceptor_start(void)
{
- int rc;
+ int rc;
long rc2;
long secure;
@@ -454,7 +446,6 @@ lnet_acceptor_start(void)
if (rc != 0)
return rc;
-
init_completion(&lnet_acceptor_state.pta_signal);
rc = accept2secure(accept_type, &secure);
if (rc <= 0)
@@ -493,7 +484,7 @@ lnet_acceptor_stop(void)
return;
lnet_acceptor_state.pta_shutdown = 1;
- libcfs_sock_abort_accept(lnet_acceptor_state.pta_sock);
+ wake_up_all(sk_sleep(lnet_acceptor_state.pta_sock->sk));
/* block until acceptor signals exit */
wait_for_completion(&lnet_acceptor_state.pta_signal);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/api-ni.c b/kernel/drivers/staging/lustre/lnet/lnet/api-ni.c
index 4a14e5109..395412639 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -35,16 +35,16 @@
*/
#define DEBUG_SUBSYSTEM S_LNET
-#include "../../include/linux/lnet/lib-lnet.h"
#include <linux/log2.h>
#include <linux/ktime.h>
+#include "../../include/linux/lnet/lib-lnet.h"
+
#define D_LNI D_CONSOLE
-lnet_t the_lnet; /* THE state of the network */
+lnet_t the_lnet; /* THE state of the network */
EXPORT_SYMBOL(the_lnet);
-
static char *ip2nets = "";
module_param(ip2nets, charp, 0444);
MODULE_PARM_DESC(ip2nets, "LNET network <- IP table");
@@ -70,8 +70,8 @@ lnet_get_routes(void)
static char *
lnet_get_networks(void)
{
- char *nets;
- int rc;
+ char *nets;
+ int rc;
if (*networks != 0 && *ip2nets != 0) {
LCONSOLE_ERROR_MSG(0x101, "Please specify EITHER 'networks' or 'ip2nets' but not both at once\n");
@@ -98,17 +98,11 @@ lnet_init_locks(void)
mutex_init(&the_lnet.ln_api_mutex);
}
-static void
-lnet_fini_locks(void)
-{
-}
-
-
static int
lnet_create_remote_nets_table(void)
{
- int i;
- struct list_head *hash;
+ int i;
+ struct list_head *hash;
LASSERT(the_lnet.ln_remote_nets_hash == NULL);
LASSERT(the_lnet.ln_remote_nets_hbits > 0);
@@ -153,8 +147,6 @@ lnet_destroy_locks(void)
cfs_percpt_lock_free(the_lnet.ln_net_lock);
the_lnet.ln_net_lock = NULL;
}
-
- lnet_fini_locks();
}
static int
@@ -271,16 +263,16 @@ static void lnet_assert_wire_constants(void)
}
static lnd_t *
-lnet_find_lnd_by_type(int type)
+lnet_find_lnd_by_type(__u32 type)
{
- lnd_t *lnd;
- struct list_head *tmp;
+ lnd_t *lnd;
+ struct list_head *tmp;
/* holding lnd mutex */
list_for_each(tmp, &the_lnet.ln_lnds) {
lnd = list_entry(tmp, lnd_t, lnd_list);
- if ((int)lnd->lnd_type == type)
+ if (lnd->lnd_type == type)
return lnd;
}
@@ -290,7 +282,7 @@ lnet_find_lnd_by_type(int type)
void
lnet_register_lnd(lnd_t *lnd)
{
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
LASSERT(the_lnet.ln_init);
LASSERT(libcfs_isknown_lnd(lnd->lnd_type));
@@ -301,14 +293,14 @@ lnet_register_lnd(lnd_t *lnd)
CDEBUG(D_NET, "%s LND registered\n", libcfs_lnd2str(lnd->lnd_type));
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
}
EXPORT_SYMBOL(lnet_register_lnd);
void
lnet_unregister_lnd(lnd_t *lnd)
{
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
LASSERT(the_lnet.ln_init);
LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == lnd);
@@ -317,7 +309,7 @@ lnet_unregister_lnd(lnd_t *lnd)
list_del(&lnd->lnd_list);
CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type));
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
}
EXPORT_SYMBOL(lnet_unregister_lnd);
@@ -325,7 +317,7 @@ void
lnet_counters_get(lnet_counters_t *counters)
{
lnet_counters_t *ctr;
- int i;
+ int i;
memset(counters, 0, sizeof(*counters));
@@ -353,7 +345,7 @@ void
lnet_counters_reset(void)
{
lnet_counters_t *counters;
- int i;
+ int i;
lnet_net_lock(LNET_LOCK_EX);
@@ -364,56 +356,6 @@ lnet_counters_reset(void)
}
EXPORT_SYMBOL(lnet_counters_reset);
-#ifdef LNET_USE_LIB_FREELIST
-
-int
-lnet_freelist_init(lnet_freelist_t *fl, int n, int size)
-{
- char *space;
-
- LASSERT(n > 0);
-
- size += offsetof(lnet_freeobj_t, fo_contents);
-
- LIBCFS_ALLOC(space, n * size);
- if (space == NULL)
- return -ENOMEM;
-
- INIT_LIST_HEAD(&fl->fl_list);
- fl->fl_objs = space;
- fl->fl_nobjs = n;
- fl->fl_objsize = size;
-
- do {
- memset(space, 0, size);
- list_add((struct list_head *)space, &fl->fl_list);
- space += size;
- } while (--n != 0);
-
- return 0;
-}
-
-void
-lnet_freelist_fini(lnet_freelist_t *fl)
-{
- struct list_head *el;
- int count;
-
- if (fl->fl_nobjs == 0)
- return;
-
- count = 0;
- for (el = fl->fl_list.next; el != &fl->fl_list; el = el->next)
- count++;
-
- LASSERT(count == fl->fl_nobjs);
-
- LIBCFS_FREE(fl->fl_objs, fl->fl_nobjs * fl->fl_objsize);
- memset(fl, 0, sizeof(*fl));
-}
-
-#endif /* LNET_USE_LIB_FREELIST */
-
static __u64
lnet_create_interface_cookie(void)
{
@@ -441,7 +383,7 @@ lnet_res_type2str(int type)
static void
lnet_res_container_cleanup(struct lnet_res_container *rec)
{
- int count = 0;
+ int count = 0;
if (rec->rec_type == 0) /* not set yet, it's uninitialized */
return;
@@ -470,9 +412,6 @@ lnet_res_container_cleanup(struct lnet_res_container *rec)
count, lnet_res_type2str(rec->rec_type));
}
-#ifdef LNET_USE_LIB_FREELIST
- lnet_freelist_fini(&rec->rec_freelist);
-#endif
if (rec->rec_lh_hash != NULL) {
LIBCFS_FREE(rec->rec_lh_hash,
LNET_LH_HASH_SIZE * sizeof(rec->rec_lh_hash[0]));
@@ -483,23 +422,15 @@ lnet_res_container_cleanup(struct lnet_res_container *rec)
}
static int
-lnet_res_container_setup(struct lnet_res_container *rec,
- int cpt, int type, int objnum, int objsz)
+lnet_res_container_setup(struct lnet_res_container *rec, int cpt, int type)
{
- int rc = 0;
- int i;
+ int rc = 0;
+ int i;
LASSERT(rec->rec_type == 0);
rec->rec_type = type;
INIT_LIST_HEAD(&rec->rec_active);
-
-#ifdef LNET_USE_LIB_FREELIST
- memset(&rec->rec_freelist, 0, sizeof(rec->rec_freelist));
- rc = lnet_freelist_init(&rec->rec_freelist, objnum, objsz);
- if (rc != 0)
- goto out;
-#endif
rec->rec_lh_cookie = (cpt << LNET_COOKIE_TYPE_BITS) | type;
/* Arbitrary choice of hash table size */
@@ -525,8 +456,8 @@ out:
static void
lnet_res_containers_destroy(struct lnet_res_container **recs)
{
- struct lnet_res_container *rec;
- int i;
+ struct lnet_res_container *rec;
+ int i;
cfs_percpt_for_each(rec, i, recs)
lnet_res_container_cleanup(rec);
@@ -535,12 +466,12 @@ lnet_res_containers_destroy(struct lnet_res_container **recs)
}
static struct lnet_res_container **
-lnet_res_containers_create(int type, int objnum, int objsz)
+lnet_res_containers_create(int type)
{
- struct lnet_res_container **recs;
- struct lnet_res_container *rec;
- int rc;
- int i;
+ struct lnet_res_container **recs;
+ struct lnet_res_container *rec;
+ int rc;
+ int i;
recs = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*rec));
if (recs == NULL) {
@@ -550,7 +481,7 @@ lnet_res_containers_create(int type, int objnum, int objsz)
}
cfs_percpt_for_each(rec, i, recs) {
- rc = lnet_res_container_setup(rec, i, type, objnum, objsz);
+ rc = lnet_res_container_setup(rec, i, type);
if (rc != 0) {
lnet_res_containers_destroy(recs);
return NULL;
@@ -564,9 +495,9 @@ lnet_libhandle_t *
lnet_res_lh_lookup(struct lnet_res_container *rec, __u64 cookie)
{
/* ALWAYS called with lnet_res_lock held */
- struct list_head *head;
- lnet_libhandle_t *lh;
- unsigned int hash;
+ struct list_head *head;
+ lnet_libhandle_t *lh;
+ unsigned int hash;
if ((cookie & LNET_COOKIE_MASK) != rec->rec_type)
return NULL;
@@ -586,8 +517,8 @@ void
lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_libhandle_t *lh)
{
/* ALWAYS called with lnet_res_lock held */
- unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS;
- unsigned int hash;
+ unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS;
+ unsigned int hash;
lh->lh_cookie = rec->rec_lh_cookie;
rec->rec_lh_cookie += 1 << ibits;
@@ -597,7 +528,6 @@ lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_libhandle_t *lh)
list_add(&lh->lh_hash_chain, &rec->rec_lh_hash[hash]);
}
-
int lnet_unprepare(void);
static int
@@ -605,7 +535,7 @@ lnet_prepare(lnet_pid_t requested_pid)
{
/* Prepare to bring up the network */
struct lnet_res_container **recs;
- int rc = 0;
+ int rc = 0;
LASSERT(the_lnet.ln_refcount == 0);
@@ -643,13 +573,11 @@ lnet_prepare(lnet_pid_t requested_pid)
goto failed;
rc = lnet_res_container_setup(&the_lnet.ln_eq_container, 0,
- LNET_COOKIE_TYPE_EQ, LNET_FL_MAX_EQS,
- sizeof(lnet_eq_t));
+ LNET_COOKIE_TYPE_EQ);
if (rc != 0)
goto failed;
- recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, LNET_FL_MAX_MES,
- sizeof(lnet_me_t));
+ recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME);
if (recs == NULL) {
rc = -ENOMEM;
goto failed;
@@ -657,8 +585,7 @@ lnet_prepare(lnet_pid_t requested_pid)
the_lnet.ln_me_containers = recs;
- recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS,
- sizeof(lnet_libmd_t));
+ recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD);
if (recs == NULL) {
rc = -ENOMEM;
goto failed;
@@ -725,8 +652,8 @@ lnet_unprepare(void)
lnet_ni_t *
lnet_net2ni_locked(__u32 net, int cpt)
{
- struct list_head *tmp;
- lnet_ni_t *ni;
+ struct list_head *tmp;
+ lnet_ni_t *ni;
LASSERT(cpt != LNET_LOCK_EX);
@@ -758,8 +685,8 @@ EXPORT_SYMBOL(lnet_net2ni);
static unsigned int
lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
{
- __u64 key = nid;
- unsigned int val;
+ __u64 key = nid;
+ unsigned int val;
LASSERT(number >= 1 && number <= LNET_CPT_NUMBER);
@@ -801,8 +728,8 @@ lnet_cpt_of_nid_locked(lnet_nid_t nid)
int
lnet_cpt_of_nid(lnet_nid_t nid)
{
- int cpt;
- int cpt2;
+ int cpt;
+ int cpt2;
if (LNET_CPT_NUMBER == 1)
return 0; /* the only one */
@@ -821,8 +748,8 @@ EXPORT_SYMBOL(lnet_cpt_of_nid);
int
lnet_islocalnet(__u32 net)
{
- struct lnet_ni *ni;
- int cpt;
+ struct lnet_ni *ni;
+ int cpt;
cpt = lnet_net_lock_current();
@@ -838,8 +765,8 @@ lnet_islocalnet(__u32 net)
lnet_ni_t *
lnet_nid2ni_locked(lnet_nid_t nid, int cpt)
{
- struct lnet_ni *ni;
- struct list_head *tmp;
+ struct lnet_ni *ni;
+ struct list_head *tmp;
LASSERT(cpt != LNET_LOCK_EX);
@@ -858,8 +785,8 @@ lnet_nid2ni_locked(lnet_nid_t nid, int cpt)
int
lnet_islocalnid(lnet_nid_t nid)
{
- struct lnet_ni *ni;
- int cpt;
+ struct lnet_ni *ni;
+ int cpt;
cpt = lnet_net_lock_current();
ni = lnet_nid2ni_locked(nid, cpt);
@@ -874,10 +801,10 @@ int
lnet_count_acceptor_nis(void)
{
/* Return the # of NIs that need the acceptor. */
- int count = 0;
- struct list_head *tmp;
- struct lnet_ni *ni;
- int cpt;
+ int count = 0;
+ struct list_head *tmp;
+ struct lnet_ni *ni;
+ int cpt;
cpt = lnet_net_lock_current();
list_for_each(tmp, &the_lnet.ln_nis) {
@@ -895,7 +822,7 @@ lnet_count_acceptor_nis(void)
static int
lnet_ni_tq_credits(lnet_ni_t *ni)
{
- int credits;
+ int credits;
LASSERT(ni->ni_ncpts >= 1);
@@ -912,9 +839,9 @@ lnet_ni_tq_credits(lnet_ni_t *ni)
static void
lnet_shutdown_lndnis(void)
{
- int i;
- int islo;
- lnet_ni_t *ni;
+ int i;
+ int islo;
+ lnet_ni_t *ni;
/* NB called holding the global mutex */
@@ -968,8 +895,8 @@ lnet_shutdown_lndnis(void)
* and shut them down in guaranteed thread context */
i = 2;
while (!list_empty(&the_lnet.ln_nis_zombie)) {
- int *ref;
- int j;
+ int *ref;
+ int j;
ni = list_entry(the_lnet.ln_nis_zombie.next,
lnet_ni_t, ni_list);
@@ -1029,15 +956,15 @@ lnet_shutdown_lndnis(void)
static int
lnet_startup_lndnis(void)
{
- lnd_t *lnd;
- struct lnet_ni *ni;
- struct lnet_tx_queue *tq;
- struct list_head nilist;
- int i;
- int rc = 0;
- int lnd_type;
- int nicount = 0;
- char *nets = lnet_get_networks();
+ lnd_t *lnd;
+ struct lnet_ni *ni;
+ struct lnet_tx_queue *tq;
+ struct list_head nilist;
+ int i;
+ int rc = 0;
+ __u32 lnd_type;
+ int nicount = 0;
+ char *nets = lnet_get_networks();
INIT_LIST_HEAD(&nilist);
@@ -1063,18 +990,18 @@ lnet_startup_lndnis(void)
goto failed;
}
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type);
if (lnd == NULL) {
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
rc = request_module("%s",
libcfs_lnd2modname(lnd_type));
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type);
if (lnd == NULL) {
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
CERROR("Can't load LND %s, module %s, rc=%d\n",
libcfs_lnd2str(lnd_type),
libcfs_lnd2modname(lnd_type), rc);
@@ -1090,7 +1017,7 @@ lnet_startup_lndnis(void)
rc = (lnd->lnd_startup)(ni);
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
if (rc != 0) {
LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s\n",
@@ -1172,16 +1099,16 @@ lnet_startup_lndnis(void)
* Initialize LNet library.
*
* Only userspace program needs to call this function - it's automatically
- * called in the kernel at module loading time. Caller has to call LNetFini()
- * after a call to LNetInit(), if and only if the latter returned 0. It must
+ * called in the kernel at module loading time. Caller has to call lnet_fini()
+ * after a call to lnet_init(), if and only if the latter returned 0. It must
* be called exactly once.
*
* \return 0 on success, and -ve on failures.
*/
int
-LNetInit(void)
+lnet_init(void)
{
- int rc;
+ int rc;
lnet_assert_wire_constants();
LASSERT(!the_lnet.ln_init);
@@ -1232,7 +1159,7 @@ LNetInit(void)
lnet_register_lnd(&the_lolnd);
return 0;
}
-EXPORT_SYMBOL(LNetInit);
+EXPORT_SYMBOL(lnet_init);
/**
* Finalize LNet library.
@@ -1240,11 +1167,11 @@ EXPORT_SYMBOL(LNetInit);
* Only userspace program needs to call this function. It can be called
* at most once.
*
- * \pre LNetInit() called with success.
+ * \pre lnet_init() called with success.
* \pre All LNet users called LNetNIFini() for matching LNetNIInit() calls.
*/
void
-LNetFini(void)
+lnet_fini(void)
{
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount == 0);
@@ -1256,12 +1183,12 @@ LNetFini(void)
the_lnet.ln_init = 0;
}
-EXPORT_SYMBOL(LNetFini);
+EXPORT_SYMBOL(lnet_fini);
/**
* Set LNet PID and start LNet interfaces, routing, and forwarding.
*
- * Userspace program should call this after a successful call to LNetInit().
+ * Userspace program should call this after a successful call to lnet_init().
* Users must call this function at least once before any other functions.
* For each successful call there must be a corresponding call to
* LNetNIFini(). For subsequent calls to LNetNIInit(), \a requested_pid is
@@ -1277,10 +1204,10 @@ EXPORT_SYMBOL(LNetFini);
int
LNetNIInit(lnet_pid_t requested_pid)
{
- int im_a_router = 0;
- int rc;
+ int im_a_router = 0;
+ int rc;
- LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
+ mutex_lock(&the_lnet.ln_api_mutex);
LASSERT(the_lnet.ln_init);
CDEBUG(D_OTHER, "refs %d\n", the_lnet.ln_refcount);
@@ -1290,8 +1217,6 @@ LNetNIInit(lnet_pid_t requested_pid)
goto out;
}
- lnet_get_tunables();
-
if (requested_pid == LNET_PID_ANY) {
/* Don't instantiate LNET just for me */
rc = -ENETDOWN;
@@ -1335,7 +1260,7 @@ LNetNIInit(lnet_pid_t requested_pid)
if (rc != 0)
goto failed4;
- lnet_proc_init();
+ lnet_router_debugfs_init();
goto out;
failed4:
@@ -1351,7 +1276,7 @@ LNetNIInit(lnet_pid_t requested_pid)
failed0:
LASSERT(rc < 0);
out:
- LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
+ mutex_unlock(&the_lnet.ln_api_mutex);
return rc;
}
EXPORT_SYMBOL(LNetNIInit);
@@ -1368,7 +1293,7 @@ EXPORT_SYMBOL(LNetNIInit);
int
LNetNIFini(void)
{
- LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
+ mutex_lock(&the_lnet.ln_api_mutex);
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -1378,7 +1303,7 @@ LNetNIFini(void)
} else {
LASSERT(!the_lnet.ln_niinit_self);
- lnet_proc_fini();
+ lnet_router_debugfs_fini();
lnet_router_checker_stop();
lnet_ping_target_fini();
@@ -1391,7 +1316,7 @@ LNetNIFini(void)
lnet_unprepare();
}
- LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
+ mutex_unlock(&the_lnet.ln_api_mutex);
return 0;
}
EXPORT_SYMBOL(LNetNIFini);
@@ -1413,9 +1338,10 @@ int
LNetCtl(unsigned int cmd, void *arg)
{
struct libcfs_ioctl_data *data = arg;
- lnet_process_id_t id = {0};
- lnet_ni_t *ni;
- int rc;
+ lnet_process_id_t id = {0};
+ lnet_ni_t *ni;
+ int rc;
+ unsigned long secs_passed;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -1443,10 +1369,9 @@ LNetCtl(unsigned int cmd, void *arg)
&data->ioc_nid, &data->ioc_flags,
&data->ioc_priority);
case IOC_LIBCFS_NOTIFY_ROUTER:
+ secs_passed = (ktime_get_real_seconds() - data->ioc_u64[0]);
return lnet_notify(NULL, data->ioc_nid, data->ioc_flags,
- cfs_time_current() -
- cfs_time_seconds(get_seconds() -
- (time_t)data->ioc_u64[0]));
+ jiffies - secs_passed * HZ);
case IOC_LIBCFS_PORTALS_COMPATIBILITY:
/* This can be removed once lustre stops calling it */
@@ -1531,10 +1456,10 @@ EXPORT_SYMBOL(LNetCtl);
int
LNetGetId(unsigned int index, lnet_process_id_t *id)
{
- struct lnet_ni *ni;
- struct list_head *tmp;
- int cpt;
- int rc = -ENOENT;
+ struct lnet_ni *ni;
+ struct list_head *tmp;
+ int cpt;
+ int rc = -ENOENT;
LASSERT(the_lnet.ln_init);
@@ -1575,11 +1500,11 @@ EXPORT_SYMBOL(LNetSnprintHandle);
static int
lnet_create_ping_info(void)
{
- int i;
- int n;
- int rc;
- unsigned int infosz;
- lnet_ni_t *ni;
+ int i;
+ int n;
+ int rc;
+ unsigned int infosz;
+ lnet_ni_t *ni;
lnet_process_id_t id;
lnet_ping_info_t *pinfo;
@@ -1633,7 +1558,7 @@ lnet_create_ping_info(void)
static void
lnet_destroy_ping_info(void)
{
- struct lnet_ni *ni;
+ struct lnet_ni *ni;
lnet_net_lock(0);
@@ -1654,12 +1579,12 @@ lnet_destroy_ping_info(void)
int
lnet_ping_target_init(void)
{
- lnet_md_t md = { NULL };
- lnet_handle_me_t meh;
+ lnet_md_t md = { NULL };
+ lnet_handle_me_t meh;
lnet_process_id_t id;
- int rc;
- int rc2;
- int infosz;
+ int rc;
+ int rc2;
+ int infosz;
rc = lnet_create_ping_info();
if (rc != 0)
@@ -1722,11 +1647,11 @@ lnet_ping_target_init(void)
void
lnet_ping_target_fini(void)
{
- lnet_event_t event;
- int rc;
- int which;
- int timeout_ms = 1000;
- sigset_t blocked = cfs_block_allsigs();
+ lnet_event_t event;
+ int rc;
+ int which;
+ int timeout_ms = 1000;
+ sigset_t blocked = cfs_block_allsigs();
LNetMDUnlink(the_lnet.ln_ping_target_md);
/* NB md could be busy; this just starts the unlink */
@@ -1759,22 +1684,22 @@ lnet_ping_target_fini(void)
int
lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_ids)
{
- lnet_handle_eq_t eqh;
- lnet_handle_md_t mdh;
- lnet_event_t event;
- lnet_md_t md = { NULL };
- int which;
- int unlinked = 0;
- int replied = 0;
- const int a_long_time = 60000; /* mS */
- int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]);
- lnet_ping_info_t *info;
- lnet_process_id_t tmpid;
- int i;
- int nob;
- int rc;
- int rc2;
- sigset_t blocked;
+ lnet_handle_eq_t eqh;
+ lnet_handle_md_t mdh;
+ lnet_event_t event;
+ lnet_md_t md = { NULL };
+ int which;
+ int unlinked = 0;
+ int replied = 0;
+ const int a_long_time = 60000; /* mS */
+ int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]);
+ lnet_ping_info_t *info;
+ lnet_process_id_t tmpid;
+ int i;
+ int nob;
+ int rc;
+ int rc2;
+ sigset_t blocked;
if (n_ids <= 0 ||
id.nid == LNET_NID_ANY ||
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/config.c b/kernel/drivers/staging/lustre/lnet/lnet/config.c
index 2dc4c4a1a..1b3bc8386 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/config.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/config.c
@@ -38,9 +38,9 @@
#include "../../include/linux/lnet/lib-lnet.h"
struct lnet_text_buf_t { /* tmp struct for parsing routes */
- struct list_head ltb_list; /* stash on lists */
- int ltb_size; /* allocated size */
- char ltb_text[0]; /* text buffer */
+ struct list_head ltb_list; /* stash on lists */
+ int ltb_size; /* allocated size */
+ char ltb_text[0]; /* text buffer */
};
static int lnet_tbnob; /* track text buf allocation */
@@ -80,8 +80,8 @@ lnet_issep(char c)
static int
lnet_net_unique(__u32 net, struct list_head *nilist)
{
- struct list_head *tmp;
- lnet_ni_t *ni;
+ struct list_head *tmp;
+ lnet_ni_t *ni;
list_for_each(tmp, nilist) {
ni = list_entry(tmp, lnet_ni_t, ni_list);
@@ -111,10 +111,10 @@ lnet_ni_free(struct lnet_ni *ni)
static lnet_ni_t *
lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
{
- struct lnet_tx_queue *tq;
- struct lnet_ni *ni;
- int rc;
- int i;
+ struct lnet_tx_queue *tq;
+ struct lnet_ni *ni;
+ int rc;
+ int i;
if (!lnet_net_unique(net, nilist)) {
LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
@@ -166,7 +166,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
/* LND will fill in the address part of the NID */
ni->ni_nid = LNET_MKNID(net, 0);
- ni->ni_last_alive = get_seconds();
+ ni->ni_last_alive = ktime_get_real_seconds();
list_add_tail(&ni->ni_list, nilist);
return ni;
failed:
@@ -178,13 +178,13 @@ int
lnet_parse_networks(struct list_head *nilist, char *networks)
{
struct cfs_expr_list *el = NULL;
- int tokensize = strlen(networks) + 1;
- char *tokens;
- char *str;
- char *tmp;
- struct lnet_ni *ni;
- __u32 net;
- int nnets = 0;
+ int tokensize = strlen(networks) + 1;
+ char *tokens;
+ char *str;
+ char *tmp;
+ struct lnet_ni *ni;
+ __u32 net;
+ int nnets = 0;
if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
/* _WAY_ conservative */
@@ -210,12 +210,12 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
goto failed;
while (str != NULL && *str != 0) {
- char *comma = strchr(str, ',');
- char *bracket = strchr(str, '(');
- char *square = strchr(str, '[');
- char *iface;
- int niface;
- int rc;
+ char *comma = strchr(str, ',');
+ char *bracket = strchr(str, '(');
+ char *square = strchr(str, '[');
+ char *iface;
+ int niface;
+ int rc;
/* NB we don't check interface conflicts here; it's the LNDs
* responsibility (if it cares at all) */
@@ -369,7 +369,7 @@ static struct lnet_text_buf_t *
lnet_new_text_buf(int str_len)
{
struct lnet_text_buf_t *ltb;
- int nob;
+ int nob;
/* NB allocate space for the terminating 0 */
nob = offsetof(struct lnet_text_buf_t, ltb_text[str_len + 1]);
@@ -404,7 +404,7 @@ lnet_free_text_buf(struct lnet_text_buf_t *ltb)
static void
lnet_free_text_bufs(struct list_head *tbs)
{
- struct lnet_text_buf_t *ltb;
+ struct lnet_text_buf_t *ltb;
while (!list_empty(tbs)) {
ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list);
@@ -417,11 +417,11 @@ lnet_free_text_bufs(struct list_head *tbs)
static int
lnet_str2tbs_sep(struct list_head *tbs, char *str)
{
- struct list_head pending;
- char *sep;
- int nob;
- int i;
- struct lnet_text_buf_t *ltb;
+ struct list_head pending;
+ char *sep;
+ int nob;
+ int i;
+ struct lnet_text_buf_t *ltb;
INIT_LIST_HEAD(&pending);
@@ -477,8 +477,8 @@ lnet_expand1tb(struct list_head *list,
char *str, char *sep1, char *sep2,
char *item, int itemlen)
{
- int len1 = (int)(sep1 - str);
- int len2 = strlen(sep2 + 1);
+ int len1 = (int)(sep1 - str);
+ int len2 = strlen(sep2 + 1);
struct lnet_text_buf_t *ltb;
LASSERT(*sep1 == '[');
@@ -500,18 +500,18 @@ lnet_expand1tb(struct list_head *list,
static int
lnet_str2tbs_expand(struct list_head *tbs, char *str)
{
- char num[16];
- struct list_head pending;
- char *sep;
- char *sep2;
- char *parsed;
- char *enditem;
- int lo;
- int hi;
- int stride;
- int i;
- int nob;
- int scanned;
+ char num[16];
+ struct list_head pending;
+ char *sep;
+ char *sep2;
+ char *parsed;
+ char *enditem;
+ int lo;
+ int hi;
+ int stride;
+ int i;
+ int nob;
+ int scanned;
INIT_LIST_HEAD(&pending);
@@ -584,8 +584,8 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str)
static int
lnet_parse_hops(char *str, unsigned int *hops)
{
- int len = strlen(str);
- int nob = len;
+ int len = strlen(str);
+ int nob = len;
return (sscanf(str, "%u%n", hops, &nob) >= 1 &&
nob == len &&
@@ -597,9 +597,9 @@ lnet_parse_hops(char *str, unsigned int *hops)
static int
lnet_parse_priority(char *str, unsigned int *priority, char **token)
{
- int nob;
+ int nob;
char *sep;
- int len;
+ int len;
sep = strchr(str, LNET_PRIORITY_SEPARATOR);
if (sep == NULL) {
@@ -628,23 +628,23 @@ static int
lnet_parse_route(char *str, int *im_a_router)
{
/* static scratch buffer OK (single threaded) */
- static char cmd[LNET_SINGLE_TEXTBUF_NOB];
-
- struct list_head nets;
- struct list_head gateways;
- struct list_head *tmp1;
- struct list_head *tmp2;
- __u32 net;
- lnet_nid_t nid;
- struct lnet_text_buf_t *ltb;
- int rc;
- char *sep;
- char *token = str;
- int ntokens = 0;
- int myrc = -1;
- unsigned int hops;
- int got_hops = 0;
- unsigned int priority = 0;
+ static char cmd[LNET_SINGLE_TEXTBUF_NOB];
+
+ struct list_head nets;
+ struct list_head gateways;
+ struct list_head *tmp1;
+ struct list_head *tmp2;
+ __u32 net;
+ lnet_nid_t nid;
+ struct lnet_text_buf_t *ltb;
+ int rc;
+ char *sep;
+ char *token = str;
+ int ntokens = 0;
+ int myrc = -1;
+ unsigned int hops;
+ int got_hops = 0;
+ unsigned int priority = 0;
INIT_LIST_HEAD(&gateways);
INIT_LIST_HEAD(&nets);
@@ -772,7 +772,7 @@ lnet_parse_route(char *str, int *im_a_router)
static int
lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
{
- struct lnet_text_buf_t *ltb;
+ struct lnet_text_buf_t *ltb;
while (!list_empty(tbs)) {
ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list);
@@ -792,8 +792,8 @@ lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
int
lnet_parse_routes(char *routes, int *im_a_router)
{
- struct list_head tbs;
- int rc = 0;
+ struct list_head tbs;
+ int rc = 0;
*im_a_router = 0;
@@ -814,8 +814,8 @@ static int
lnet_match_network_token(char *token, int len, __u32 *ipaddrs, int nip)
{
LIST_HEAD(list);
- int rc;
- int i;
+ int rc;
+ int i;
rc = cfs_ip_addr_parse(token, len, &list);
if (rc != 0)
@@ -824,7 +824,7 @@ lnet_match_network_token(char *token, int len, __u32 *ipaddrs, int nip)
for (rc = i = 0; !rc && i < nip; i++)
rc = cfs_ip_addr_match(ipaddrs[i], &list);
- cfs_ip_addr_free(&list);
+ cfs_expr_list_free_list(&list);
return rc;
}
@@ -834,13 +834,13 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
{
static char tokens[LNET_SINGLE_TEXTBUF_NOB];
- int matched = 0;
- int ntokens = 0;
- int len;
+ int matched = 0;
+ int ntokens = 0;
+ int len;
char *net = NULL;
char *sep;
char *token;
- int rc;
+ int rc;
LASSERT(strlen(net_entry) < sizeof(tokens));
@@ -889,8 +889,8 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
static __u32
lnet_netspec2net(char *netspec)
{
- char *bracket = strchr(netspec, '(');
- __u32 net;
+ char *bracket = strchr(netspec, '(');
+ __u32 net;
if (bracket != NULL)
*bracket = 0;
@@ -906,15 +906,15 @@ lnet_netspec2net(char *netspec)
static int
lnet_splitnets(char *source, struct list_head *nets)
{
- int offset = 0;
- int offset2;
- int len;
- struct lnet_text_buf_t *tb;
- struct lnet_text_buf_t *tb2;
- struct list_head *t;
- char *sep;
- char *bracket;
- __u32 net;
+ int offset = 0;
+ int offset2;
+ int len;
+ struct lnet_text_buf_t *tb;
+ struct lnet_text_buf_t *tb2;
+ struct list_head *t;
+ char *sep;
+ char *bracket;
+ __u32 net;
LASSERT(!list_empty(nets));
LASSERT(nets->next == nets->prev); /* single entry */
@@ -986,22 +986,22 @@ lnet_splitnets(char *source, struct list_head *nets)
static int
lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
{
- static char networks[LNET_SINGLE_TEXTBUF_NOB];
- static char source[LNET_SINGLE_TEXTBUF_NOB];
-
- struct list_head raw_entries;
- struct list_head matched_nets;
- struct list_head current_nets;
- struct list_head *t;
- struct list_head *t2;
- struct lnet_text_buf_t *tb;
- struct lnet_text_buf_t *tb2;
- __u32 net1;
- __u32 net2;
- int len;
- int count;
- int dup;
- int rc;
+ static char networks[LNET_SINGLE_TEXTBUF_NOB];
+ static char source[LNET_SINGLE_TEXTBUF_NOB];
+
+ struct list_head raw_entries;
+ struct list_head matched_nets;
+ struct list_head current_nets;
+ struct list_head *t;
+ struct list_head *t2;
+ struct lnet_text_buf_t *tb;
+ struct lnet_text_buf_t *tb2;
+ __u32 net1;
+ __u32 net2;
+ int len;
+ int count;
+ int dup;
+ int rc;
INIT_LIST_HEAD(&raw_entries);
if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) {
@@ -1112,15 +1112,15 @@ lnet_ipaddr_free_enumeration(__u32 *ipaddrs, int nip)
static int
lnet_ipaddr_enumerate(__u32 **ipaddrsp)
{
- int up;
- __u32 netmask;
- __u32 *ipaddrs;
- __u32 *ipaddrs2;
- int nip;
- char **ifnames;
- int nif = libcfs_ipif_enumerate(&ifnames);
- int i;
- int rc;
+ int up;
+ __u32 netmask;
+ __u32 *ipaddrs;
+ __u32 *ipaddrs2;
+ int nip;
+ char **ifnames;
+ int nif = lnet_ipif_enumerate(&ifnames);
+ int i;
+ int rc;
if (nif <= 0)
return nif;
@@ -1128,7 +1128,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
if (ipaddrs == NULL) {
CERROR("Can't allocate ipaddrs[%d]\n", nif);
- libcfs_ipif_free_enumeration(ifnames, nif);
+ lnet_ipif_free_enumeration(ifnames, nif);
return -ENOMEM;
}
@@ -1136,8 +1136,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
if (!strcmp(ifnames[i], "lo"))
continue;
- rc = libcfs_ipif_query(ifnames[i], &up,
- &ipaddrs[nip], &netmask);
+ rc = lnet_ipif_query(ifnames[i], &up, &ipaddrs[nip], &netmask);
if (rc != 0) {
CWARN("Can't query interface %s: %d\n",
ifnames[i], rc);
@@ -1153,7 +1152,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
nip++;
}
- libcfs_ipif_free_enumeration(ifnames, nif);
+ lnet_ipif_free_enumeration(ifnames, nif);
if (nip == nif) {
*ipaddrsp = ipaddrs;
@@ -1178,9 +1177,9 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
int
lnet_parse_ip2nets(char **networksp, char *ip2nets)
{
- __u32 *ipaddrs = NULL;
- int nip = lnet_ipaddr_enumerate(&ipaddrs);
- int rc;
+ __u32 *ipaddrs = NULL;
+ int nip = lnet_ipaddr_enumerate(&ipaddrs);
+ int rc;
if (nip < 0) {
LCONSOLE_ERROR_MSG(0x117,
@@ -1211,82 +1210,3 @@ lnet_parse_ip2nets(char **networksp, char *ip2nets)
return 0;
}
-
-int
-lnet_set_ip_niaddr(lnet_ni_t *ni)
-{
- __u32 net = LNET_NIDNET(ni->ni_nid);
- char **names;
- int n;
- __u32 ip;
- __u32 netmask;
- int up;
- int i;
- int rc;
-
- /* Convenience for LNDs that use the IP address of a local interface as
- * the local address part of their NID */
-
- if (ni->ni_interfaces[0] != NULL) {
-
- CLASSERT(LNET_MAX_INTERFACES > 1);
-
- if (ni->ni_interfaces[1] != NULL) {
- CERROR("Net %s doesn't support multiple interfaces\n",
- libcfs_net2str(net));
- return -EPERM;
- }
-
- rc = libcfs_ipif_query(ni->ni_interfaces[0],
- &up, &ip, &netmask);
- if (rc != 0) {
- CERROR("Net %s can't query interface %s: %d\n",
- libcfs_net2str(net), ni->ni_interfaces[0], rc);
- return -EPERM;
- }
-
- if (!up) {
- CERROR("Net %s can't use interface %s: it's down\n",
- libcfs_net2str(net), ni->ni_interfaces[0]);
- return -ENETDOWN;
- }
-
- ni->ni_nid = LNET_MKNID(net, ip);
- return 0;
- }
-
- n = libcfs_ipif_enumerate(&names);
- if (n <= 0) {
- CERROR("Net %s can't enumerate interfaces: %d\n",
- libcfs_net2str(net), n);
- return 0;
- }
-
- for (i = 0; i < n; i++) {
- if (!strcmp(names[i], "lo")) /* skip the loopback IF */
- continue;
-
- rc = libcfs_ipif_query(names[i], &up, &ip, &netmask);
-
- if (rc != 0) {
- CWARN("Net %s can't query interface %s: %d\n",
- libcfs_net2str(net), names[i], rc);
- continue;
- }
-
- if (!up) {
- CWARN("Net %s ignoring interface %s (down)\n",
- libcfs_net2str(net), names[i]);
- continue;
- }
-
- libcfs_ipif_free_enumeration(names, n);
- ni->ni_nid = LNET_MKNID(net, ip);
- return 0;
- }
-
- CERROR("Net %s can't find any interfaces\n", libcfs_net2str(net));
- libcfs_ipif_free_enumeration(names, n);
- return -ENOENT;
-}
-EXPORT_SYMBOL(lnet_set_ip_niaddr);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/lib-eq.c b/kernel/drivers/staging/lustre/lnet/lnet/lib-eq.c
index 5470148f5..60889ebd2 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/lib-eq.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lib-eq.c
@@ -70,7 +70,7 @@ int
LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
lnet_handle_eq_t *handle)
{
- lnet_eq_t *eq;
+ lnet_eq_t *eq;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -79,7 +79,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
* overflow, they don't skip entries, so the queue has the same
* apparent capacity at all times */
- count = cfs_power2_roundup(count);
+ count = roundup_pow_of_two(count);
if (callback != LNET_EQ_HANDLER_NONE && count != 0)
CWARN("EQ callback is guaranteed to get every event, do you still want to set eqcount %d for polling event which will have locking overhead? Please contact with developer to confirm\n", count);
@@ -151,13 +151,13 @@ EXPORT_SYMBOL(LNetEQAlloc);
int
LNetEQFree(lnet_handle_eq_t eqh)
{
- struct lnet_eq *eq;
- lnet_event_t *events = NULL;
- int **refs = NULL;
- int *ref;
- int rc = 0;
- int size = 0;
- int i;
+ struct lnet_eq *eq;
+ lnet_event_t *events = NULL;
+ int **refs = NULL;
+ int *ref;
+ int rc = 0;
+ int size = 0;
+ int i;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -185,13 +185,13 @@ LNetEQFree(lnet_handle_eq_t eqh)
}
/* stash for free after lock dropped */
- events = eq->eq_events;
- size = eq->eq_size;
- refs = eq->eq_refs;
+ events = eq->eq_events;
+ size = eq->eq_size;
+ refs = eq->eq_refs;
lnet_res_lh_invalidate(&eq->eq_lh);
list_del(&eq->eq_list);
- lnet_eq_free_locked(eq);
+ lnet_eq_free(eq);
out:
lnet_eq_wait_unlock();
lnet_res_unlock(LNET_LOCK_EX);
@@ -237,9 +237,9 @@ lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev)
static int
lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev)
{
- int new_index = eq->eq_deq_seq & (eq->eq_size - 1);
- lnet_event_t *new_event = &eq->eq_events[new_index];
- int rc;
+ int new_index = eq->eq_deq_seq & (eq->eq_size - 1);
+ lnet_event_t *new_event = &eq->eq_events[new_index];
+ int rc;
/* must called with lnet_eq_wait_lock hold */
if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence))
@@ -318,15 +318,14 @@ LNetEQWait(lnet_handle_eq_t eventq, lnet_event_t *event)
}
EXPORT_SYMBOL(LNetEQWait);
-
static int
lnet_eq_wait_locked(int *timeout_ms)
__must_hold(&the_lnet.ln_eq_wait_lock)
{
- int tms = *timeout_ms;
- int wait;
- wait_queue_t wl;
- unsigned long now;
+ int tms = *timeout_ms;
+ int wait;
+ wait_queue_t wl;
+ unsigned long now;
if (tms == 0)
return -1; /* don't want to wait and no new event */
@@ -341,12 +340,9 @@ __must_hold(&the_lnet.ln_eq_wait_lock)
schedule();
} else {
- struct timeval tv;
-
- now = cfs_time_current();
- schedule_timeout(cfs_time_seconds(tms) / 1000);
- cfs_duration_usec(cfs_time_sub(cfs_time_current(), now), &tv);
- tms -= (int)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
+ now = jiffies;
+ schedule_timeout(msecs_to_jiffies(tms));
+ tms -= jiffies_to_msecs(jiffies - now);
if (tms < 0) /* no more wait but may have new event */
tms = 0;
}
@@ -360,8 +356,6 @@ __must_hold(&the_lnet.ln_eq_wait_lock)
return wait;
}
-
-
/**
* Block the calling process until there's an event from a set of EQs or
* timeout happens.
@@ -392,9 +386,9 @@ int
LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms,
lnet_event_t *event, int *which)
{
- int wait = 1;
- int rc;
- int i;
+ int wait = 1;
+ int rc;
+ int i;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/lib-md.c b/kernel/drivers/staging/lustre/lnet/lnet/lib-md.c
index 89d660fef..758f5bede 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -74,7 +74,7 @@ lnet_md_unlink(lnet_libmd_t *md)
CDEBUG(D_NET, "Unlinking md %p\n", md);
if (md->md_eq != NULL) {
- int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie);
+ int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie);
LASSERT(*md->md_eq->eq_refs[cpt] > 0);
(*md->md_eq->eq_refs[cpt])--;
@@ -82,15 +82,15 @@ lnet_md_unlink(lnet_libmd_t *md)
LASSERT(!list_empty(&md->md_list));
list_del_init(&md->md_list);
- lnet_md_free_locked(md);
+ lnet_md_free(md);
}
static int
lnet_md_build(lnet_libmd_t *lmd, lnet_md_t *umd, int unlink)
{
- int i;
+ int i;
unsigned int niov;
- int total_length = 0;
+ int total_length = 0;
lmd->md_me = NULL;
lmd->md_start = umd->start;
@@ -268,10 +268,10 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
{
LIST_HEAD(matches);
LIST_HEAD(drops);
- struct lnet_me *me;
- struct lnet_libmd *md;
- int cpt;
- int rc;
+ struct lnet_me *me;
+ struct lnet_libmd *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -320,7 +320,7 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
return 0;
failed:
- lnet_md_free_locked(md);
+ lnet_md_free(md);
lnet_res_unlock(cpt);
return rc;
@@ -346,9 +346,9 @@ EXPORT_SYMBOL(LNetMDAttach);
int
LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle)
{
- lnet_libmd_t *md;
- int cpt;
- int rc;
+ lnet_libmd_t *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -381,7 +381,7 @@ LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle)
return 0;
failed:
- lnet_md_free_locked(md);
+ lnet_md_free(md);
lnet_res_unlock(cpt);
return rc;
@@ -421,9 +421,9 @@ EXPORT_SYMBOL(LNetMDBind);
int
LNetMDUnlink(lnet_handle_md_t mdh)
{
- lnet_event_t ev;
- lnet_libmd_t *md;
- int cpt;
+ lnet_event_t ev;
+ lnet_libmd_t *md;
+ int cpt;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/lib-me.c b/kernel/drivers/staging/lustre/lnet/lnet/lib-me.c
index a3f929244..42fc99ef9 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/lib-me.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lib-me.c
@@ -80,8 +80,8 @@ LNetMEAttach(unsigned int portal,
lnet_handle_me_t *handle)
{
struct lnet_match_table *mtable;
- struct lnet_me *me;
- struct list_head *head;
+ struct lnet_me *me;
+ struct list_head *head;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -151,10 +151,10 @@ LNetMEInsert(lnet_handle_me_t current_meh,
lnet_unlink_t unlink, lnet_ins_pos_t pos,
lnet_handle_me_t *handle)
{
- struct lnet_me *current_me;
- struct lnet_me *new_me;
- struct lnet_portal *ptl;
- int cpt;
+ struct lnet_me *current_me;
+ struct lnet_me *new_me;
+ struct lnet_portal *ptl;
+ int cpt;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -172,7 +172,7 @@ LNetMEInsert(lnet_handle_me_t current_meh,
current_me = lnet_handle2me(&current_meh);
if (current_me == NULL) {
- lnet_me_free_locked(new_me);
+ lnet_me_free(new_me);
lnet_res_unlock(cpt);
return -ENOENT;
@@ -183,7 +183,7 @@ LNetMEInsert(lnet_handle_me_t current_meh,
ptl = the_lnet.ln_portals[current_me->me_portal];
if (lnet_ptl_is_unique(ptl)) {
/* nosense to insertion on unique portal */
- lnet_me_free_locked(new_me);
+ lnet_me_free(new_me);
lnet_res_unlock(cpt);
return -EPERM;
}
@@ -228,10 +228,10 @@ EXPORT_SYMBOL(LNetMEInsert);
int
LNetMEUnlink(lnet_handle_me_t meh)
{
- lnet_me_t *me;
- lnet_libmd_t *md;
- lnet_event_t ev;
- int cpt;
+ lnet_me_t *me;
+ lnet_libmd_t *md;
+ lnet_event_t ev;
+ int cpt;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -276,7 +276,7 @@ lnet_me_unlink(lnet_me_t *me)
}
lnet_res_lh_invalidate(&me->me_lh);
- lnet_me_free_locked(me);
+ lnet_me_free(me);
}
#if 0
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/lib-move.c b/kernel/drivers/staging/lustre/lnet/lnet/lib-move.c
index c2fb70e5f..5631f60a3 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -49,10 +49,10 @@ MODULE_PARM_DESC(local_nid_dist_zero, "Reserved");
int
lnet_fail_nid(lnet_nid_t nid, unsigned int threshold)
{
- lnet_test_peer_t *tp;
- struct list_head *el;
- struct list_head *next;
- struct list_head cull;
+ lnet_test_peer_t *tp;
+ struct list_head *el;
+ struct list_head *next;
+ struct list_head cull;
LASSERT(the_lnet.ln_init);
@@ -103,10 +103,10 @@ static int
fail_peer(lnet_nid_t nid, int outgoing)
{
lnet_test_peer_t *tp;
- struct list_head *el;
- struct list_head *next;
- struct list_head cull;
- int fail = 0;
+ struct list_head *el;
+ struct list_head *next;
+ struct list_head cull;
+ int fail = 0;
INIT_LIST_HEAD(&cull);
@@ -175,7 +175,7 @@ lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset,
unsigned int nob)
{
/* NB diov, siov are READ-ONLY */
- unsigned int this_nob;
+ unsigned int this_nob;
if (nob == 0)
return;
@@ -236,8 +236,8 @@ lnet_extract_iov(int dst_niov, struct kvec *dst,
/* Initialise 'dst' to the subset of 'src' starting at 'offset',
* for exactly 'len' bytes, and return the number of entries.
* NB not destructive to 'src' */
- unsigned int frag_len;
- unsigned int niov;
+ unsigned int frag_len;
+ unsigned int niov;
if (len == 0) /* no data => */
return 0; /* no frags */
@@ -275,11 +275,10 @@ lnet_extract_iov(int dst_niov, struct kvec *dst,
}
EXPORT_SYMBOL(lnet_extract_iov);
-
unsigned int
lnet_kiov_nob(unsigned int niov, lnet_kiov_t *kiov)
{
- unsigned int nob = 0;
+ unsigned int nob = 0;
while (niov-- > 0)
nob += (kiov++)->kiov_len;
@@ -294,9 +293,9 @@ lnet_copy_kiov2kiov(unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset,
unsigned int nob)
{
/* NB diov, siov are READ-ONLY */
- unsigned int this_nob;
- char *daddr = NULL;
- char *saddr = NULL;
+ unsigned int this_nob;
+ char *daddr = NULL;
+ char *saddr = NULL;
if (nob == 0)
return;
@@ -376,8 +375,8 @@ lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov, unsigned int iovoffset,
unsigned int kiovoffset, unsigned int nob)
{
/* NB iov, kiov are READ-ONLY */
- unsigned int this_nob;
- char *addr = NULL;
+ unsigned int this_nob;
+ char *addr = NULL;
if (nob == 0)
return;
@@ -447,8 +446,8 @@ lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int nob)
{
/* NB kiov, iov are READ-ONLY */
- unsigned int this_nob;
- char *addr = NULL;
+ unsigned int this_nob;
+ char *addr = NULL;
if (nob == 0)
return;
@@ -518,8 +517,8 @@ lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
/* Initialise 'dst' to the subset of 'src' starting at 'offset',
* for exactly 'len' bytes, and return the number of entries.
* NB not destructive to 'src' */
- unsigned int frag_len;
- unsigned int niov;
+ unsigned int frag_len;
+ unsigned int niov;
if (len == 0) /* no data => */
return 0; /* no frags */
@@ -565,10 +564,10 @@ static void
lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
- unsigned int niov = 0;
+ unsigned int niov = 0;
struct kvec *iov = NULL;
- lnet_kiov_t *kiov = NULL;
- int rc;
+ lnet_kiov_t *kiov = NULL;
+ int rc;
LASSERT(!in_interrupt());
LASSERT(mlen == 0 || msg != NULL);
@@ -642,8 +641,8 @@ lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
static void
lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
{
- void *priv = msg->msg_private;
- int rc;
+ void *priv = msg->msg_private;
+ int rc;
LASSERT(!in_interrupt());
LASSERT(LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND ||
@@ -657,7 +656,7 @@ lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg)
{
- int rc;
+ int rc;
LASSERT(!msg->msg_sending);
LASSERT(msg->msg_receiving);
@@ -700,7 +699,7 @@ lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp)
static inline int
lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now)
{
- int alive;
+ int alive;
unsigned long deadline;
LASSERT(lnet_peer_aliveness_enabled(lp));
@@ -727,7 +726,6 @@ lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now)
return alive;
}
-
/* NB: returns 1 when alive, 0 when dead, negative when error;
* may drop the lnet_net_lock */
static int
@@ -785,10 +783,10 @@ lnet_peer_alive_locked(lnet_peer_t *lp)
static int
lnet_post_send_locked(lnet_msg_t *msg, int do_send)
{
- lnet_peer_t *lp = msg->msg_txpeer;
- lnet_ni_t *ni = lp->lp_ni;
- int cpt = msg->msg_tx_cpt;
- struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt];
+ lnet_peer_t *lp = msg->msg_txpeer;
+ lnet_ni_t *ni = lp->lp_ni;
+ int cpt = msg->msg_tx_cpt;
+ struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt];
/* non-lnet_send() callers have checked before */
LASSERT(!do_send || msg->msg_tx_delayed);
@@ -867,12 +865,11 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
return 0;
}
-
static lnet_rtrbufpool_t *
lnet_msg2bufpool(lnet_msg_t *msg)
{
- lnet_rtrbufpool_t *rbp;
- int cpt;
+ lnet_rtrbufpool_t *rbp;
+ int cpt;
LASSERT(msg->msg_rx_committed);
@@ -894,9 +891,9 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv)
/* lnet_parse is going to lnet_net_unlock immediately after this, so it
* sets do_recv FALSE and I don't do the unlock/send/lock bit. I
* return EAGAIN if msg blocked and 0 if received or OK to receive */
- lnet_peer_t *lp = msg->msg_rxpeer;
- lnet_rtrbufpool_t *rbp;
- lnet_rtrbuf_t *rb;
+ lnet_peer_t *lp = msg->msg_rxpeer;
+ lnet_rtrbufpool_t *rbp;
+ lnet_rtrbuf_t *rb;
LASSERT(msg->msg_iov == NULL);
LASSERT(msg->msg_kiov == NULL);
@@ -967,11 +964,11 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv)
void
lnet_return_tx_credits_locked(lnet_msg_t *msg)
{
- lnet_peer_t *txpeer = msg->msg_txpeer;
- lnet_msg_t *msg2;
+ lnet_peer_t *txpeer = msg->msg_txpeer;
+ lnet_msg_t *msg2;
if (msg->msg_txcredit) {
- struct lnet_ni *ni = txpeer->lp_ni;
+ struct lnet_ni *ni = txpeer->lp_ni;
struct lnet_tx_queue *tq = ni->ni_tx_queues[msg->msg_tx_cpt];
/* give back NI txcredits */
@@ -1025,12 +1022,12 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg)
void
lnet_return_rx_credits_locked(lnet_msg_t *msg)
{
- lnet_peer_t *rxpeer = msg->msg_rxpeer;
- lnet_msg_t *msg2;
+ lnet_peer_t *rxpeer = msg->msg_rxpeer;
+ lnet_msg_t *msg2;
if (msg->msg_rtrcredit) {
/* give back global router credits */
- lnet_rtrbuf_t *rb;
+ lnet_rtrbuf_t *rb;
lnet_rtrbufpool_t *rbp;
/* NB If a msg ever blocks for a buffer in rbp_msgs, it stays
@@ -1122,13 +1119,13 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2)
static lnet_peer_t *
lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid)
{
- lnet_remotenet_t *rnet;
- lnet_route_t *rtr;
- lnet_route_t *rtr_best;
- lnet_route_t *rtr_last;
- struct lnet_peer *lp_best;
- struct lnet_peer *lp;
- int rc;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *rtr;
+ lnet_route_t *rtr_best;
+ lnet_route_t *rtr_last;
+ struct lnet_peer *lp_best;
+ struct lnet_peer *lp;
+ int rc;
/* If @rtr_nid is not LNET_NID_ANY, return the gateway with
* rtr_nid nid, otherwise find the best gateway I can use */
@@ -1182,13 +1179,13 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid)
int
lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid)
{
- lnet_nid_t dst_nid = msg->msg_target.nid;
- struct lnet_ni *src_ni;
- struct lnet_ni *local_ni;
- struct lnet_peer *lp;
- int cpt;
- int cpt2;
- int rc;
+ lnet_nid_t dst_nid = msg->msg_target.nid;
+ struct lnet_ni *src_ni;
+ struct lnet_ni *local_ni;
+ struct lnet_peer *lp;
+ int cpt;
+ int cpt2;
+ int rc;
/* NB: rtr_nid is set to LNET_NID_ANY for all current use-cases,
* but we might want to use pre-determined router for ACK/REPLY
@@ -1364,7 +1361,7 @@ lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, unsigned int nob)
static void
lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
if (msg->msg_wanted != 0)
lnet_setpayloadbuffer(msg);
@@ -1383,9 +1380,9 @@ lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
- struct lnet_match_info info;
- int rc;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
+ struct lnet_match_info info;
+ int rc;
/* Convert put fields to host byte order */
hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits);
@@ -1433,24 +1430,24 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get)
{
- struct lnet_match_info info;
- lnet_hdr_t *hdr = &msg->msg_hdr;
- lnet_handle_wire_t reply_wmd;
- int rc;
+ struct lnet_match_info info;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_handle_wire_t reply_wmd;
+ int rc;
/* Convert get fields to host byte order */
- hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits);
- hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index);
- hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length);
- hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset);
-
- info.mi_id.nid = hdr->src_nid;
- info.mi_id.pid = hdr->src_pid;
- info.mi_opc = LNET_MD_OP_GET;
- info.mi_portal = hdr->msg.get.ptl_index;
- info.mi_rlength = hdr->msg.get.sink_length;
- info.mi_roffset = hdr->msg.get.src_offset;
- info.mi_mbits = hdr->msg.get.match_bits;
+ hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits);
+ hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index);
+ hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length);
+ hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset);
+
+ info.mi_id.nid = hdr->src_nid;
+ info.mi_id.pid = hdr->src_pid;
+ info.mi_opc = LNET_MD_OP_GET;
+ info.mi_portal = hdr->msg.get.ptl_index;
+ info.mi_rlength = hdr->msg.get.sink_length;
+ info.mi_roffset = hdr->msg.get.src_offset;
+ info.mi_mbits = hdr->msg.get.match_bits;
rc = lnet_ptl_match_md(&info, msg);
if (rc == LNET_MATCHMD_DROP) {
@@ -1497,13 +1494,13 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get)
static int
lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
{
- void *private = msg->msg_private;
- lnet_hdr_t *hdr = &msg->msg_hdr;
+ void *private = msg->msg_private;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
lnet_process_id_t src = {0};
- lnet_libmd_t *md;
- int rlength;
- int mlength;
- int cpt;
+ lnet_libmd_t *md;
+ int rlength;
+ int mlength;
+ int cpt;
cpt = lnet_cpt_of_cookie(hdr->msg.reply.dst_wmd.wh_object_cookie);
lnet_res_lock(cpt);
@@ -1562,10 +1559,10 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
lnet_process_id_t src = {0};
- lnet_libmd_t *md;
- int cpt;
+ lnet_libmd_t *md;
+ int cpt;
src.nid = hdr->src_nid;
src.pid = hdr->src_pid;
@@ -1612,7 +1609,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg)
{
- int rc = 0;
+ int rc = 0;
if (msg->msg_rxpeer->lp_rtrcredits <= 0 ||
lnet_msg2bufpool(msg)->rbp_credits <= 0) {
@@ -1713,15 +1710,15 @@ int
lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
void *private, int rdma_req)
{
- int rc = 0;
- int cpt;
- int for_me;
- struct lnet_msg *msg;
- lnet_pid_t dest_pid;
- lnet_nid_t dest_nid;
- lnet_nid_t src_nid;
- __u32 payload_length;
- __u32 type;
+ int rc = 0;
+ int cpt;
+ int for_me;
+ struct lnet_msg *msg;
+ lnet_pid_t dest_pid;
+ lnet_nid_t dest_nid;
+ lnet_nid_t src_nid;
+ __u32 payload_length;
+ __u32 type;
LASSERT(!in_interrupt());
@@ -1768,11 +1765,11 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
}
if (the_lnet.ln_routing &&
- ni->ni_last_alive != get_seconds()) {
+ ni->ni_last_alive != ktime_get_real_seconds()) {
lnet_ni_lock(ni);
/* NB: so far here is the only place to set NI status to "up */
- ni->ni_last_alive = get_seconds();
+ ni->ni_last_alive = ktime_get_real_seconds();
if (ni->ni_status != NULL &&
ni->ni_status->ns_status == LNET_NI_STATUS_DOWN)
ni->ni_status->ns_status = LNET_NI_STATUS_UP;
@@ -1945,8 +1942,8 @@ void
lnet_drop_delayed_msg_list(struct list_head *head, char *reason)
{
while (!list_empty(head)) {
- lnet_process_id_t id = {0};
- lnet_msg_t *msg;
+ lnet_process_id_t id = {0};
+ lnet_msg_t *msg;
msg = list_entry(head->next, lnet_msg_t, msg_list);
list_del(&msg->msg_list);
@@ -1986,8 +1983,8 @@ void
lnet_recv_delayed_msg_list(struct list_head *head)
{
while (!list_empty(head)) {
- lnet_msg_t *msg;
- lnet_process_id_t id;
+ lnet_msg_t *msg;
+ lnet_process_id_t id;
msg = list_entry(head->next, lnet_msg_t, msg_list);
list_del(&msg->msg_list);
@@ -2063,10 +2060,10 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack,
__u64 match_bits, unsigned int offset,
__u64 hdr_data)
{
- struct lnet_msg *msg;
- struct lnet_libmd *md;
- int cpt;
- int rc;
+ struct lnet_msg *msg;
+ struct lnet_libmd *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -2153,10 +2150,10 @@ lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *getmsg)
* CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when
* lnet_finalize() is called on it, so the LND must call this first */
- struct lnet_msg *msg = lnet_msg_alloc();
- struct lnet_libmd *getmd = getmsg->msg_md;
- lnet_process_id_t peer_id = getmsg->msg_target;
- int cpt;
+ struct lnet_msg *msg = lnet_msg_alloc();
+ struct lnet_libmd *getmd = getmsg->msg_md;
+ lnet_process_id_t peer_id = getmsg->msg_target;
+ int cpt;
LASSERT(!getmsg->msg_target_is_router);
LASSERT(!getmsg->msg_routing);
@@ -2263,10 +2260,10 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh,
lnet_process_id_t target, unsigned int portal,
__u64 match_bits, unsigned int offset)
{
- struct lnet_msg *msg;
- struct lnet_libmd *md;
- int cpt;
- int rc;
+ struct lnet_msg *msg;
+ struct lnet_libmd *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -2353,14 +2350,14 @@ EXPORT_SYMBOL(LNetGet);
int
LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
{
- struct list_head *e;
- struct lnet_ni *ni;
- lnet_remotenet_t *rnet;
- __u32 dstnet = LNET_NIDNET(dstnid);
- int hops;
- int cpt;
- __u32 order = 2;
- struct list_head *rn_list;
+ struct list_head *e;
+ struct lnet_ni *ni;
+ lnet_remotenet_t *rnet;
+ __u32 dstnet = LNET_NIDNET(dstnid);
+ int hops;
+ int cpt;
+ __u32 order = 2;
+ struct list_head *rn_list;
/* if !local_nid_dist_zero, I don't return a distance of 0 ever
* (when lustre sees a distance of 0, it substitutes 0@lo), so I
@@ -2434,27 +2431,3 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
return -EHOSTUNREACH;
}
EXPORT_SYMBOL(LNetDist);
-
-/**
- * Set the number of asynchronous messages expected from a target process.
- *
- * This function is only meaningful for userspace callers. It's a no-op when
- * called from kernel.
- *
- * Asynchronous messages are those that can come from a target when the
- * userspace process is not waiting for IO to complete; e.g., AST callbacks
- * from Lustre servers. Specifying the expected number of such messages
- * allows them to be eagerly received when user process is not running in
- * LNet; otherwise network errors may occur.
- *
- * \param id Process ID of the target process.
- * \param nasync Number of asynchronous messages expected from the target.
- *
- * \return 0 on success, and an error code otherwise.
- */
-int
-LNetSetAsync(lnet_process_id_t id, int nasync)
-{
- return 0;
-}
-EXPORT_SYMBOL(LNetSetAsync);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/lib-msg.c b/kernel/drivers/staging/lustre/lnet/lnet/lib-msg.c
index a46ccbf66..43977e8df 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/lib-msg.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lib-msg.c
@@ -60,8 +60,8 @@ lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev)
void
lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
- lnet_event_t *ev = &msg->msg_ev;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_event_t *ev = &msg->msg_ev;
LASSERT(!msg->msg_routing);
@@ -73,7 +73,7 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
ev->target.pid = le32_to_cpu(hdr->dest_pid);
ev->initiator.nid = LNET_NID_ANY;
ev->initiator.pid = the_lnet.ln_pid;
- ev->sender = LNET_NID_ANY;
+ ev->sender = LNET_NID_ANY;
} else {
/* event for passive message */
@@ -82,9 +82,9 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
ev->initiator.pid = hdr->src_pid;
ev->initiator.nid = hdr->src_nid;
ev->rlength = hdr->payload_length;
- ev->sender = msg->msg_from;
- ev->mlength = msg->msg_wanted;
- ev->offset = msg->msg_offset;
+ ev->sender = msg->msg_from;
+ ev->mlength = msg->msg_wanted;
+ ev->offset = msg->msg_offset;
}
switch (ev_type) {
@@ -137,7 +137,7 @@ void
lnet_msg_commit(lnet_msg_t *msg, int cpt)
{
struct lnet_msg_container *container = the_lnet.ln_msg_containers[cpt];
- lnet_counters_t *counters = the_lnet.ln_counters[cpt];
+ lnet_counters_t *counters = the_lnet.ln_counters[cpt];
/* routed message can be committed for both receiving and sending */
LASSERT(!msg->msg_tx_committed);
@@ -170,7 +170,7 @@ static void
lnet_msg_decommit_tx(lnet_msg_t *msg, int status)
{
lnet_counters_t *counters;
- lnet_event_t *ev = &msg->msg_ev;
+ lnet_event_t *ev = &msg->msg_ev;
LASSERT(msg->msg_tx_committed);
if (status != 0)
@@ -219,8 +219,8 @@ lnet_msg_decommit_tx(lnet_msg_t *msg, int status)
static void
lnet_msg_decommit_rx(lnet_msg_t *msg, int status)
{
- lnet_counters_t *counters;
- lnet_event_t *ev = &msg->msg_ev;
+ lnet_counters_t *counters;
+ lnet_event_t *ev = &msg->msg_ev;
LASSERT(!msg->msg_tx_committed); /* decommitted or never committed */
LASSERT(msg->msg_rx_committed);
@@ -273,7 +273,7 @@ lnet_msg_decommit_rx(lnet_msg_t *msg, int status)
void
lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status)
{
- int cpt2 = cpt;
+ int cpt2 = cpt;
LASSERT(msg->msg_tx_committed || msg->msg_rx_committed);
LASSERT(msg->msg_onactivelist);
@@ -335,8 +335,8 @@ lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md,
void
lnet_msg_detach_md(lnet_msg_t *msg, int status)
{
- lnet_libmd_t *md = msg->msg_md;
- int unlink;
+ lnet_libmd_t *md = msg->msg_md;
+ int unlink;
/* Now it's safe to drop my caller's ref */
md->md_refcount--;
@@ -359,8 +359,8 @@ static int
lnet_complete_msg_locked(lnet_msg_t *msg, int cpt)
{
lnet_handle_wire_t ack_wmd;
- int rc;
- int status = msg->msg_ev.status;
+ int rc;
+ int status = msg->msg_ev.status;
LASSERT(msg->msg_onactivelist);
@@ -427,18 +427,18 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt)
}
lnet_msg_decommit(msg, cpt, status);
- lnet_msg_free_locked(msg);
+ lnet_msg_free(msg);
return 0;
}
void
lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status)
{
- struct lnet_msg_container *container;
- int my_slot;
- int cpt;
- int rc;
- int i;
+ struct lnet_msg_container *container;
+ int my_slot;
+ int cpt;
+ int rc;
+ int i;
LASSERT(!in_interrupt());
@@ -534,7 +534,7 @@ EXPORT_SYMBOL(lnet_finalize);
void
lnet_msg_container_cleanup(struct lnet_msg_container *container)
{
- int count = 0;
+ int count = 0;
if (container->msc_init == 0)
return;
@@ -568,7 +568,7 @@ lnet_msg_container_cleanup(struct lnet_msg_container *container)
int
lnet_msg_container_setup(struct lnet_msg_container *container, int cpt)
{
- int rc;
+ int rc;
container->msc_init = 1;
@@ -608,7 +608,7 @@ void
lnet_msg_containers_destroy(void)
{
struct lnet_msg_container *container;
- int i;
+ int i;
if (the_lnet.ln_msg_containers == NULL)
return;
@@ -624,8 +624,8 @@ int
lnet_msg_containers_create(void)
{
struct lnet_msg_container *container;
- int rc;
- int i;
+ int rc;
+ int i;
the_lnet.ln_msg_containers = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*container));
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/kernel/drivers/staging/lustre/lnet/lnet/lib-ptl.c
index 3ba0da919..b4f573ab6 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/lib-ptl.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lib-ptl.c
@@ -39,7 +39,7 @@
#include "../../include/linux/lnet/lib-lnet.h"
/* NB: add /proc interfaces in upcoming patches */
-int portal_rotor = LNET_PTL_ROTOR_HASH_RT;
+int portal_rotor = LNET_PTL_ROTOR_HASH_RT;
module_param(portal_rotor, int, 0644);
MODULE_PARM_DESC(portal_rotor, "redirect PUTs to different cpu-partitions");
@@ -47,8 +47,8 @@ static int
lnet_ptl_match_type(unsigned int index, lnet_process_id_t match_id,
__u64 mbits, __u64 ignore_bits)
{
- struct lnet_portal *ptl = the_lnet.ln_portals[index];
- int unique;
+ struct lnet_portal *ptl = the_lnet.ln_portals[index];
+ int unique;
unique = ignore_bits == 0 &&
match_id.nid != LNET_NID_ANY &&
@@ -89,7 +89,7 @@ static void
lnet_ptl_enable_mt(struct lnet_portal *ptl, int cpt)
{
struct lnet_match_table *mtable = ptl->ptl_mtables[cpt];
- int i;
+ int i;
/* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */
LASSERT(lnet_ptl_is_wildcard(ptl));
@@ -114,7 +114,7 @@ static void
lnet_ptl_disable_mt(struct lnet_portal *ptl, int cpt)
{
struct lnet_match_table *mtable = ptl->ptl_mtables[cpt];
- int i;
+ int i;
/* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */
LASSERT(lnet_ptl_is_wildcard(ptl));
@@ -141,9 +141,9 @@ lnet_try_match_md(lnet_libmd_t *md,
{
/* ALWAYS called holding the lnet_res_lock, and can't lnet_res_unlock;
* lnet_match_blocked_msg() relies on this to avoid races */
- unsigned int offset;
- unsigned int mlength;
- lnet_me_t *me = md->md_me;
+ unsigned int offset;
+ unsigned int mlength;
+ lnet_me_t *me = md->md_me;
/* MD exhausted */
if (lnet_md_exhausted(md))
@@ -227,7 +227,7 @@ struct lnet_match_table *
lnet_mt_of_attach(unsigned int index, lnet_process_id_t id,
__u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos)
{
- struct lnet_portal *ptl;
+ struct lnet_portal *ptl;
struct lnet_match_table *mtable;
/* NB: called w/o lock */
@@ -261,11 +261,11 @@ static struct lnet_match_table *
lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg)
{
struct lnet_match_table *mtable;
- struct lnet_portal *ptl;
- unsigned int nmaps;
- unsigned int rotor;
- unsigned int cpt;
- bool routed;
+ struct lnet_portal *ptl;
+ unsigned int nmaps;
+ unsigned int rotor;
+ unsigned int cpt;
+ bool routed;
/* NB: called w/o lock */
LASSERT(info->mi_portal < the_lnet.ln_nportals);
@@ -312,8 +312,8 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg)
static int
lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos)
{
- __u64 *bmap;
- int i;
+ __u64 *bmap;
+ int i;
if (!lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal]))
return 0;
@@ -337,7 +337,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos)
static void
lnet_mt_set_exhausted(struct lnet_match_table *mtable, int pos, int exhausted)
{
- __u64 *bmap;
+ __u64 *bmap;
LASSERT(lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal]));
LASSERT(pos <= LNET_MT_HASH_IGNORE);
@@ -373,11 +373,11 @@ int
lnet_mt_match_md(struct lnet_match_table *mtable,
struct lnet_match_info *info, struct lnet_msg *msg)
{
- struct list_head *head;
- lnet_me_t *me;
- lnet_me_t *tmp;
- int exhausted = 0;
- int rc;
+ struct list_head *head;
+ lnet_me_t *me;
+ lnet_me_t *tmp;
+ int exhausted = 0;
+ int rc;
/* any ME with ignore bits? */
if (!list_empty(&mtable->mt_mhash[LNET_MT_HASH_IGNORE]))
@@ -420,15 +420,15 @@ lnet_mt_match_md(struct lnet_match_table *mtable,
if (info->mi_opc == LNET_MD_OP_GET ||
!lnet_ptl_is_lazy(the_lnet.ln_portals[info->mi_portal]))
- return LNET_MATCHMD_DROP | exhausted;
+ return exhausted | LNET_MATCHMD_DROP;
- return LNET_MATCHMD_NONE | exhausted;
+ return exhausted | LNET_MATCHMD_NONE;
}
static int
lnet_ptl_match_early(struct lnet_portal *ptl, struct lnet_msg *msg)
{
- int rc;
+ int rc;
/* message arrived before any buffer posting on this portal,
* simply delay or drop this message */
@@ -461,9 +461,9 @@ static int
lnet_ptl_match_delay(struct lnet_portal *ptl,
struct lnet_match_info *info, struct lnet_msg *msg)
{
- int first = ptl->ptl_mt_maps[0]; /* read w/o lock */
- int rc = 0;
- int i;
+ int first = ptl->ptl_mt_maps[0]; /* read w/o lock */
+ int rc = 0;
+ int i;
/* steal buffer from other CPTs, and delay it if nothing to steal,
* this function is more expensive than a regular match, but we
@@ -472,7 +472,7 @@ lnet_ptl_match_delay(struct lnet_portal *ptl,
for (i = 0; i < LNET_CPT_NUMBER; i++) {
struct lnet_match_table *mtable;
- int cpt;
+ int cpt;
cpt = (first + i) % LNET_CPT_NUMBER;
mtable = ptl->ptl_mtables[cpt];
@@ -536,8 +536,8 @@ int
lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg)
{
struct lnet_match_table *mtable;
- struct lnet_portal *ptl;
- int rc;
+ struct lnet_portal *ptl;
+ int rc;
CDEBUG(D_NET, "Request from %s of length %d into portal %d MB=%#llx\n",
libcfs_id2str(info->mi_id), info->mi_rlength, info->mi_portal,
@@ -622,13 +622,13 @@ void
lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
struct list_head *matches, struct list_head *drops)
{
- struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal];
+ struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal];
struct lnet_match_table *mtable;
- struct list_head *head;
- lnet_msg_t *tmp;
- lnet_msg_t *msg;
- int exhausted = 0;
- int cpt;
+ struct list_head *head;
+ lnet_msg_t *tmp;
+ lnet_msg_t *msg;
+ int exhausted = 0;
+ int cpt;
LASSERT(md->md_refcount == 0); /* a brand new MD */
@@ -647,20 +647,20 @@ lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
head = &ptl->ptl_msg_stealing;
again:
list_for_each_entry_safe(msg, tmp, head, msg_list) {
- struct lnet_match_info info;
- lnet_hdr_t *hdr;
- int rc;
+ struct lnet_match_info info;
+ lnet_hdr_t *hdr;
+ int rc;
LASSERT(msg->msg_rx_delayed || head == &ptl->ptl_msg_stealing);
- hdr = &msg->msg_hdr;
- info.mi_id.nid = hdr->src_nid;
- info.mi_id.pid = hdr->src_pid;
- info.mi_opc = LNET_MD_OP_PUT;
- info.mi_portal = hdr->msg.put.ptl_index;
- info.mi_rlength = hdr->payload_length;
- info.mi_roffset = hdr->msg.put.offset;
- info.mi_mbits = hdr->msg.put.match_bits;
+ hdr = &msg->msg_hdr;
+ info.mi_id.nid = hdr->src_nid;
+ info.mi_id.pid = hdr->src_pid;
+ info.mi_opc = LNET_MD_OP_PUT;
+ info.mi_portal = hdr->msg.put.ptl_index;
+ info.mi_rlength = hdr->payload_length;
+ info.mi_roffset = hdr->msg.put.offset;
+ info.mi_mbits = hdr->msg.put.match_bits;
rc = lnet_try_match_md(md, &info, msg);
@@ -715,7 +715,7 @@ static void
lnet_ptl_cleanup(struct lnet_portal *ptl)
{
struct lnet_match_table *mtable;
- int i;
+ int i;
if (ptl->ptl_mtables == NULL) /* uninitialized portal */
return;
@@ -723,9 +723,9 @@ lnet_ptl_cleanup(struct lnet_portal *ptl)
LASSERT(list_empty(&ptl->ptl_msg_delayed));
LASSERT(list_empty(&ptl->ptl_msg_stealing));
cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) {
- struct list_head *mhash;
- lnet_me_t *me;
- int j;
+ struct list_head *mhash;
+ lnet_me_t *me;
+ int j;
if (mtable->mt_mhash == NULL) /* uninitialized match-table */
continue;
@@ -753,9 +753,9 @@ static int
lnet_ptl_setup(struct lnet_portal *ptl, int index)
{
struct lnet_match_table *mtable;
- struct list_head *mhash;
- int i;
- int j;
+ struct list_head *mhash;
+ int i;
+ int j;
ptl->ptl_mtables = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(struct lnet_match_table));
@@ -798,7 +798,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index)
void
lnet_portals_destroy(void)
{
- int i;
+ int i;
if (the_lnet.ln_portals == NULL)
return;
@@ -813,8 +813,8 @@ lnet_portals_destroy(void)
int
lnet_portals_create(void)
{
- int size;
- int i;
+ int size;
+ int i;
size = offsetof(struct lnet_portal, ptl_mt_maps[LNET_CPT_NUMBER]);
@@ -898,8 +898,8 @@ EXPORT_SYMBOL(LNetSetLazyPortal);
int
LNetClearLazyPortal(int portal)
{
- struct lnet_portal *ptl;
- LIST_HEAD (zombies);
+ struct lnet_portal *ptl;
+ LIST_HEAD(zombies);
if (portal < 0 || portal >= the_lnet.ln_nportals)
return -EINVAL;
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/kernel/drivers/staging/lustre/lnet/lnet/lib-socket.c
index f2462e7f0..6f7ef4c73 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -15,11 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
@@ -27,33 +23,49 @@
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2015 Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * Lustre is a trademark of Seagate, Inc.
*/
#define DEBUG_SUBSYSTEM S_LNET
-#include "../../../include/linux/libcfs/libcfs.h"
-
#include <linux/if.h>
#include <linux/in.h>
+#include <linux/net.h>
#include <linux/file.h>
+#include <linux/pagemap.h>
/* For sys_open & sys_close */
#include <linux/syscalls.h>
+#include <net/sock.h>
+
+#include "../../include/linux/libcfs/libcfs.h"
+#include "../../include/linux/lnet/lib-lnet.h"
+
+static int
+kernel_sock_unlocked_ioctl(struct file *filp, int cmd, unsigned long arg)
+{
+ mm_segment_t oldfs = get_fs();
+ int err;
+
+ set_fs(KERNEL_DS);
+ err = filp->f_op->unlocked_ioctl(filp, cmd, arg);
+ set_fs(oldfs);
+
+ return err;
+}
static int
-libcfs_sock_ioctl(int cmd, unsigned long arg)
+lnet_sock_ioctl(int cmd, unsigned long arg)
{
- mm_segment_t oldmm = get_fs();
- struct socket *sock;
- int rc;
- struct file *sock_filp;
+ struct file *sock_filp;
+ struct socket *sock;
+ int rc;
- rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
+ rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock);
if (rc != 0) {
- CERROR ("Can't create socket: %d\n", rc);
+ CERROR("Can't create socket: %d\n", rc);
return rc;
}
@@ -64,10 +76,7 @@ libcfs_sock_ioctl(int cmd, unsigned long arg)
goto out;
}
- set_fs(KERNEL_DS);
- if (sock_filp->f_op->unlocked_ioctl)
- rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg);
- set_fs(oldmm);
+ rc = kernel_sock_unlocked_ioctl(sock_filp, cmd, arg);
fput(sock_filp);
out:
@@ -75,12 +84,12 @@ out:
}
int
-libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
+lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask)
{
- struct ifreq ifr;
- int nob;
- int rc;
- __u32 val;
+ struct ifreq ifr;
+ int nob;
+ int rc;
+ __u32 val;
nob = strnlen(name, IFNAMSIZ);
if (nob == IFNAMSIZ) {
@@ -88,11 +97,10 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
return -EINVAL;
}
- CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
+ CLASSERT(sizeof(ifr.ifr_name) >= IFNAMSIZ);
strcpy(ifr.ifr_name, name);
- rc = libcfs_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
-
+ rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
if (rc != 0) {
CERROR("Can't get flags for interface %s\n", name);
return rc;
@@ -104,13 +112,11 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
*ip = *mask = 0;
return 0;
}
-
*up = 1;
strcpy(ifr.ifr_name, name);
ifr.ifr_addr.sa_family = AF_INET;
- rc = libcfs_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
-
+ rc = lnet_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
if (rc != 0) {
CERROR("Can't get IP address for interface %s\n", name);
return rc;
@@ -121,8 +127,7 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
strcpy(ifr.ifr_name, name);
ifr.ifr_addr.sa_family = AF_INET;
- rc = libcfs_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
-
+ rc = lnet_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
if (rc != 0) {
CERROR("Can't get netmask for interface %s\n", name);
return rc;
@@ -133,23 +138,21 @@ libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
return 0;
}
-
-EXPORT_SYMBOL(libcfs_ipif_query);
+EXPORT_SYMBOL(lnet_ipif_query);
int
-libcfs_ipif_enumerate (char ***namesp)
+lnet_ipif_enumerate(char ***namesp)
{
/* Allocate and fill in 'names', returning # interfaces/error */
- char **names;
- int toobig;
- int nalloc;
- int nfound;
- struct ifreq *ifr;
- struct ifconf ifc;
- int rc;
- int nob;
- int i;
-
+ char **names;
+ int toobig;
+ int nalloc;
+ int nfound;
+ struct ifreq *ifr;
+ struct ifconf ifc;
+ int rc;
+ int nob;
+ int i;
nalloc = 16; /* first guess at max interfaces */
toobig = 0;
@@ -163,7 +166,8 @@ libcfs_ipif_enumerate (char ***namesp)
LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr));
if (ifr == NULL) {
- CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc);
+ CERROR("ENOMEM enumerating up to %d interfaces\n",
+ nalloc);
rc = -ENOMEM;
goto out0;
}
@@ -171,17 +175,16 @@ libcfs_ipif_enumerate (char ***namesp)
ifc.ifc_buf = (char *)ifr;
ifc.ifc_len = nalloc * sizeof(*ifr);
- rc = libcfs_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
-
+ rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc);
if (rc < 0) {
- CERROR ("Error %d enumerating interfaces\n", rc);
+ CERROR("Error %d enumerating interfaces\n", rc);
goto out1;
}
- LASSERT (rc == 0);
+ LASSERT(rc == 0);
nfound = ifc.ifc_len/sizeof(*ifr);
- LASSERT (nfound <= nalloc);
+ LASSERT(nfound <= nalloc);
if (nfound < nalloc || toobig)
break;
@@ -200,8 +203,7 @@ libcfs_ipif_enumerate (char ***namesp)
}
for (i = 0; i < nfound; i++) {
-
- nob = strnlen (ifr[i].ifr_name, IFNAMSIZ);
+ nob = strnlen(ifr[i].ifr_name, IFNAMSIZ);
if (nob == IFNAMSIZ) {
/* no space for terminating NULL */
CERROR("interface name %.*s too long (%d max)\n",
@@ -223,41 +225,39 @@ libcfs_ipif_enumerate (char ***namesp)
*namesp = names;
rc = nfound;
- out2:
+out2:
if (rc < 0)
- libcfs_ipif_free_enumeration(names, nfound);
- out1:
+ lnet_ipif_free_enumeration(names, nfound);
+out1:
LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
- out0:
+out0:
return rc;
}
-
-EXPORT_SYMBOL(libcfs_ipif_enumerate);
+EXPORT_SYMBOL(lnet_ipif_enumerate);
void
-libcfs_ipif_free_enumeration (char **names, int n)
+lnet_ipif_free_enumeration(char **names, int n)
{
- int i;
+ int i;
- LASSERT (n > 0);
+ LASSERT(n > 0);
for (i = 0; i < n && names[i] != NULL; i++)
LIBCFS_FREE(names[i], IFNAMSIZ);
LIBCFS_FREE(names, n * sizeof(*names));
}
-
-EXPORT_SYMBOL(libcfs_ipif_free_enumeration);
+EXPORT_SYMBOL(lnet_ipif_free_enumeration);
int
-libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
+lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
{
- int rc;
- long ticks = timeout * HZ;
- unsigned long then;
+ int rc;
+ long ticks = timeout * HZ;
+ unsigned long then;
struct timeval tv;
- LASSERT (nob > 0);
+ LASSERT(nob > 0);
/* Caller may pass a zero timeout if she thinks the socket buffer is
* empty enough to take the whole message immediately */
@@ -277,7 +277,7 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
.tv_usec = ((ticks % HZ) * 1000000) / HZ
};
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
- (char *)&tv, sizeof(tv));
+ (char *)&tv, sizeof(tv));
if (rc != 0) {
CERROR("Can't set socket send timeout %ld.%06d: %d\n",
(long)tv.tv_sec, (int)tv.tv_usec, rc);
@@ -296,7 +296,7 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
return rc;
if (rc == 0) {
- CERROR ("Unexpected zero rc\n");
+ CERROR("Unexpected zero rc\n");
return -ECONNABORTED;
}
@@ -306,21 +306,20 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
buffer = ((char *)buffer) + rc;
nob -= rc;
}
-
return 0;
}
-EXPORT_SYMBOL(libcfs_sock_write);
+EXPORT_SYMBOL(lnet_sock_write);
int
-libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
+lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
{
- int rc;
- long ticks = timeout * HZ;
- unsigned long then;
+ int rc;
+ long ticks = timeout * HZ;
+ unsigned long then;
struct timeval tv;
- LASSERT (nob > 0);
- LASSERT (ticks > 0);
+ LASSERT(nob > 0);
+ LASSERT(ticks > 0);
for (;;) {
struct kvec iov = {
@@ -328,7 +327,7 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
.iov_len = nob
};
struct msghdr msg = {
- .msg_flags = 0
+ .msg_flags = 0
};
/* Set receive timeout to remaining time */
@@ -337,7 +336,7 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
.tv_usec = ((ticks % HZ) * 1000000) / HZ
};
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
- (char *)&tv, sizeof(tv));
+ (char *)&tv, sizeof(tv));
if (rc != 0) {
CERROR("Can't set socket recv timeout %ld.%06d: %d\n",
(long)tv.tv_sec, (int)tv.tv_usec, rc);
@@ -364,31 +363,30 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
return -ETIMEDOUT;
}
}
-
-EXPORT_SYMBOL(libcfs_sock_read);
+EXPORT_SYMBOL(lnet_sock_read);
static int
-libcfs_sock_create (struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port)
+lnet_sock_create(struct socket **sockp, int *fatal, __u32 local_ip,
+ int local_port)
{
- struct sockaddr_in locaddr;
- struct socket *sock;
- int rc;
- int option;
+ struct sockaddr_in locaddr;
+ struct socket *sock;
+ int rc;
+ int option;
/* All errors are fatal except bind failure if the port is in use */
*fatal = 1;
- rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock);
+ rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock);
*sockp = sock;
if (rc != 0) {
- CERROR ("Can't create socket: %d\n", rc);
+ CERROR("Can't create socket: %d\n", rc);
return rc;
}
option = 1;
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
- (char *)&option, sizeof (option));
+ (char *)&option, sizeof(option));
if (rc != 0) {
CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc);
goto failed;
@@ -401,8 +399,8 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
locaddr.sin_addr.s_addr = (local_ip == 0) ?
INADDR_ANY : htonl(local_ip);
- rc = sock->ops->bind(sock, (struct sockaddr *)&locaddr,
- sizeof(locaddr));
+ rc = kernel_bind(sock, (struct sockaddr *)&locaddr,
+ sizeof(locaddr));
if (rc == -EADDRINUSE) {
CDEBUG(D_NET, "Port %d already in use\n", local_port);
*fatal = 0;
@@ -414,27 +412,26 @@ libcfs_sock_create (struct socket **sockp, int *fatal,
goto failed;
}
}
-
return 0;
- failed:
+failed:
sock_release(sock);
return rc;
}
int
-libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
+lnet_sock_setbuf(struct socket *sock, int txbufsize, int rxbufsize)
{
- int option;
- int rc;
+ int option;
+ int rc;
if (txbufsize != 0) {
option = txbufsize;
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
- (char *)&option, sizeof (option));
+ (char *)&option, sizeof(option));
if (rc != 0) {
- CERROR ("Can't set send buffer %d: %d\n",
- option, rc);
+ CERROR("Can't set send buffer %d: %d\n",
+ option, rc);
return rc;
}
}
@@ -442,70 +439,65 @@ libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
if (rxbufsize != 0) {
option = rxbufsize;
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
- (char *)&option, sizeof (option));
+ (char *)&option, sizeof(option));
if (rc != 0) {
- CERROR ("Can't set receive buffer %d: %d\n",
- option, rc);
+ CERROR("Can't set receive buffer %d: %d\n",
+ option, rc);
return rc;
}
}
-
return 0;
}
-
-EXPORT_SYMBOL(libcfs_sock_setbuf);
+EXPORT_SYMBOL(lnet_sock_setbuf);
int
-libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
+lnet_sock_getaddr(struct socket *sock, bool remote, __u32 *ip, int *port)
{
struct sockaddr_in sin;
- int len = sizeof (sin);
- int rc;
+ int len = sizeof(sin);
+ int rc;
- rc = sock->ops->getname (sock, (struct sockaddr *)&sin, &len,
- remote ? 2 : 0);
+ if (remote)
+ rc = kernel_getpeername(sock, (struct sockaddr *)&sin, &len);
+ else
+ rc = kernel_getsockname(sock, (struct sockaddr *)&sin, &len);
if (rc != 0) {
- CERROR ("Error %d getting sock %s IP/port\n",
- rc, remote ? "peer" : "local");
+ CERROR("Error %d getting sock %s IP/port\n",
+ rc, remote ? "peer" : "local");
return rc;
}
if (ip != NULL)
- *ip = ntohl (sin.sin_addr.s_addr);
+ *ip = ntohl(sin.sin_addr.s_addr);
if (port != NULL)
- *port = ntohs (sin.sin_port);
+ *port = ntohs(sin.sin_port);
return 0;
}
-
-EXPORT_SYMBOL(libcfs_sock_getaddr);
+EXPORT_SYMBOL(lnet_sock_getaddr);
int
-libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
+lnet_sock_getbuf(struct socket *sock, int *txbufsize, int *rxbufsize)
{
-
- if (txbufsize != NULL) {
+ if (txbufsize != NULL)
*txbufsize = sock->sk->sk_sndbuf;
- }
- if (rxbufsize != NULL) {
+ if (rxbufsize != NULL)
*rxbufsize = sock->sk->sk_rcvbuf;
- }
return 0;
}
-
-EXPORT_SYMBOL(libcfs_sock_getbuf);
+EXPORT_SYMBOL(lnet_sock_getbuf);
int
-libcfs_sock_listen (struct socket **sockp,
- __u32 local_ip, int local_port, int backlog)
+lnet_sock_listen(struct socket **sockp, __u32 local_ip, int local_port,
+ int backlog)
{
- int fatal;
- int rc;
+ int fatal;
+ int rc;
- rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port);
+ rc = lnet_sock_create(sockp, &fatal, local_ip, local_port);
if (rc != 0) {
if (!fatal)
CERROR("Can't create socket: port %d already in use\n",
@@ -513,7 +505,7 @@ libcfs_sock_listen (struct socket **sockp,
return rc;
}
- rc = (*sockp)->ops->listen(*sockp, backlog);
+ rc = kernel_listen(*sockp, backlog);
if (rc == 0)
return 0;
@@ -521,15 +513,14 @@ libcfs_sock_listen (struct socket **sockp,
sock_release(*sockp);
return rc;
}
-
-EXPORT_SYMBOL(libcfs_sock_listen);
+EXPORT_SYMBOL(lnet_sock_listen);
int
-libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
+lnet_sock_accept(struct socket **newsockp, struct socket *sock)
{
- wait_queue_t wait;
+ wait_queue_t wait;
struct socket *newsock;
- int rc;
+ int rc;
init_waitqueue_entry(&wait, current);
@@ -560,41 +551,30 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
*newsockp = newsock;
return 0;
- failed:
+failed:
sock_release(newsock);
return rc;
}
-
-EXPORT_SYMBOL(libcfs_sock_accept);
-
-void
-libcfs_sock_abort_accept (struct socket *sock)
-{
- wake_up_all(sk_sleep(sock->sk));
-}
-
-EXPORT_SYMBOL(libcfs_sock_abort_accept);
+EXPORT_SYMBOL(lnet_sock_accept);
int
-libcfs_sock_connect (struct socket **sockp, int *fatal,
- __u32 local_ip, int local_port,
- __u32 peer_ip, int peer_port)
+lnet_sock_connect(struct socket **sockp, int *fatal, __u32 local_ip,
+ int local_port, __u32 peer_ip, int peer_port)
{
- struct sockaddr_in srvaddr;
- int rc;
+ struct sockaddr_in srvaddr;
+ int rc;
- rc = libcfs_sock_create(sockp, fatal, local_ip, local_port);
+ rc = lnet_sock_create(sockp, fatal, local_ip, local_port);
if (rc != 0)
return rc;
- memset (&srvaddr, 0, sizeof (srvaddr));
+ memset(&srvaddr, 0, sizeof(srvaddr));
srvaddr.sin_family = AF_INET;
srvaddr.sin_port = htons(peer_port);
srvaddr.sin_addr.s_addr = htonl(peer_ip);
- rc = (*sockp)->ops->connect(*sockp,
- (struct sockaddr *)&srvaddr, sizeof(srvaddr),
- 0);
+ rc = kernel_connect(*sockp, (struct sockaddr *)&srvaddr,
+ sizeof(srvaddr), 0);
if (rc == 0)
return 0;
@@ -605,19 +585,10 @@ libcfs_sock_connect (struct socket **sockp, int *fatal,
*fatal = !(rc == -EADDRNOTAVAIL);
CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET,
- "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc,
- &local_ip, local_port, &peer_ip, peer_port);
+ "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc,
+ &local_ip, local_port, &peer_ip, peer_port);
sock_release(*sockp);
return rc;
}
-
-EXPORT_SYMBOL(libcfs_sock_connect);
-
-void
-libcfs_sock_release (struct socket *sock)
-{
- sock_release(sock);
-}
-
-EXPORT_SYMBOL(libcfs_sock_release);
+EXPORT_SYMBOL(lnet_sock_connect);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/lo.c b/kernel/drivers/staging/lustre/lnet/lnet/lo.c
index f708c2e64..2a137f468 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/lo.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/lo.c
@@ -111,7 +111,7 @@ lnd_t the_lolnd = {
/* .lnd_type = */ LOLND,
/* .lnd_startup = */ lolnd_startup,
/* .lnd_shutdown = */ lolnd_shutdown,
- /* .lnt_ctl = */ NULL,
+ /* .lnt_ctl = */ NULL,
/* .lnd_send = */ lolnd_send,
/* .lnd_recv = */ lolnd_recv,
/* .lnd_eager_recv = */ NULL,
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/module.c b/kernel/drivers/staging/lustre/lnet/lnet/module.c
index 72b7fbc83..576201a83 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/module.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/module.c
@@ -47,9 +47,9 @@ static int
lnet_configure(void *arg)
{
/* 'arg' only there so I can be passed to cfs_create_thread() */
- int rc = 0;
+ int rc = 0;
- LNET_MUTEX_LOCK(&lnet_config_mutex);
+ mutex_lock(&lnet_config_mutex);
if (!the_lnet.ln_niinit_self) {
rc = LNetNIInit(LUSTRE_SRV_LNET_PID);
@@ -59,34 +59,34 @@ lnet_configure(void *arg)
}
}
- LNET_MUTEX_UNLOCK(&lnet_config_mutex);
+ mutex_unlock(&lnet_config_mutex);
return rc;
}
static int
lnet_unconfigure(void)
{
- int refcount;
+ int refcount;
- LNET_MUTEX_LOCK(&lnet_config_mutex);
+ mutex_lock(&lnet_config_mutex);
if (the_lnet.ln_niinit_self) {
the_lnet.ln_niinit_self = 0;
LNetNIFini();
}
- LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
+ mutex_lock(&the_lnet.ln_api_mutex);
refcount = the_lnet.ln_refcount;
- LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
+ mutex_unlock(&the_lnet.ln_api_mutex);
- LNET_MUTEX_UNLOCK(&lnet_config_mutex);
+ mutex_unlock(&lnet_config_mutex);
return (refcount == 0) ? 0 : -EBUSY;
}
static int
lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
{
- int rc;
+ int rc;
switch (cmd) {
case IOC_LIBCFS_CONFIGURE:
@@ -113,13 +113,13 @@ static DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
static int __init
init_lnet(void)
{
- int rc;
+ int rc;
mutex_init(&lnet_config_mutex);
- rc = LNetInit();
+ rc = lnet_init();
if (rc != 0) {
- CERROR("LNetInit: error %d\n", rc);
+ CERROR("lnet_init: error %d\n", rc);
return rc;
}
@@ -143,11 +143,11 @@ fini_lnet(void)
rc = libcfs_deregister_ioctl(&lnet_ioctl_handler);
LASSERT(rc == 0);
- LNetFini();
+ lnet_fini();
}
MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
-MODULE_DESCRIPTION("Portals v3.1");
+MODULE_DESCRIPTION("LNet v3.1");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0.0");
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/nidstrings.c b/kernel/drivers/staging/lustre/lnet/lnet/nidstrings.c
new file mode 100644
index 000000000..80f585afa
--- /dev/null
+++ b/kernel/drivers/staging/lustre/lnet/lnet/nidstrings.c
@@ -0,0 +1,1260 @@
+/*
+ * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lnet/lnet/nidstrings.c
+ *
+ * Author: Phil Schwan <phil@clusterfs.com>
+ */
+
+#define DEBUG_SUBSYSTEM S_LNET
+
+#include "../../include/linux/libcfs/libcfs.h"
+#include "../../include/linux/lnet/lnet.h"
+
+/* max value for numeric network address */
+#define MAX_NUMERIC_VALUE 0xffffffff
+
+#define IPSTRING_LENGTH 16
+
+/* CAVEAT VENDITOR! Keep the canonical string representation of nets/nids
+ * consistent in all conversion functions. Some code fragments are copied
+ * around for the sake of clarity...
+ */
+
+/* CAVEAT EMPTOR! Racey temporary buffer allocation!
+ * Choose the number of nidstrings to support the MAXIMUM expected number of
+ * concurrent users. If there are more, the returned string will be volatile.
+ * NB this number must allow for a process to be descheduled for a timeslice
+ * between getting its string and using it.
+ */
+
+static char libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE];
+static int libcfs_nidstring_idx;
+
+static DEFINE_SPINLOCK(libcfs_nidstring_lock);
+
+static struct netstrfns *libcfs_namenum2netstrfns(const char *name);
+
+char *
+libcfs_next_nidstring(void)
+{
+ char *str;
+ unsigned long flags;
+
+ spin_lock_irqsave(&libcfs_nidstring_lock, flags);
+
+ str = libcfs_nidstrings[libcfs_nidstring_idx++];
+ if (libcfs_nidstring_idx == ARRAY_SIZE(libcfs_nidstrings))
+ libcfs_nidstring_idx = 0;
+
+ spin_unlock_irqrestore(&libcfs_nidstring_lock, flags);
+ return str;
+}
+EXPORT_SYMBOL(libcfs_next_nidstring);
+
+/**
+ * Nid range list syntax.
+ * \verbatim
+ *
+ * <nidlist> :== <nidrange> [ ' ' <nidrange> ]
+ * <nidrange> :== <addrrange> '@' <net>
+ * <addrrange> :== '*' |
+ * <ipaddr_range> |
+ * <cfs_expr_list>
+ * <ipaddr_range> :== <cfs_expr_list>.<cfs_expr_list>.<cfs_expr_list>.
+ * <cfs_expr_list>
+ * <cfs_expr_list> :== <number> |
+ * <expr_list>
+ * <expr_list> :== '[' <range_expr> [ ',' <range_expr>] ']'
+ * <range_expr> :== <number> |
+ * <number> '-' <number> |
+ * <number> '-' <number> '/' <number>
+ * <net> :== <netname> | <netname><number>
+ * <netname> :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" |
+ * "vib" | "ra" | "elan" | "mx" | "ptl"
+ * \endverbatim
+ */
+
+/**
+ * Structure to represent \<nidrange\> token of the syntax.
+ *
+ * One of this is created for each \<net\> parsed.
+ */
+struct nidrange {
+ /**
+ * Link to list of this structures which is built on nid range
+ * list parsing.
+ */
+ struct list_head nr_link;
+ /**
+ * List head for addrrange::ar_link.
+ */
+ struct list_head nr_addrranges;
+ /**
+ * Flag indicating that *@<net> is found.
+ */
+ int nr_all;
+ /**
+ * Pointer to corresponding element of libcfs_netstrfns.
+ */
+ struct netstrfns *nr_netstrfns;
+ /**
+ * Number of network. E.g. 5 if \<net\> is "elan5".
+ */
+ int nr_netnum;
+};
+
+/**
+ * Structure to represent \<addrrange\> token of the syntax.
+ */
+struct addrrange {
+ /**
+ * Link to nidrange::nr_addrranges.
+ */
+ struct list_head ar_link;
+ /**
+ * List head for cfs_expr_list::el_list.
+ */
+ struct list_head ar_numaddr_ranges;
+};
+
+/**
+ * Parses \<addrrange\> token on the syntax.
+ *
+ * Allocates struct addrrange and links to \a nidrange via
+ * (nidrange::nr_addrranges)
+ *
+ * \retval 0 if \a src parses to '*' | \<ipaddr_range\> | \<cfs_expr_list\>
+ * \retval -errno otherwise
+ */
+static int
+parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange)
+{
+ struct addrrange *addrrange;
+
+ if (src->ls_len == 1 && src->ls_str[0] == '*') {
+ nidrange->nr_all = 1;
+ return 0;
+ }
+
+ LIBCFS_ALLOC(addrrange, sizeof(struct addrrange));
+ if (addrrange == NULL)
+ return -ENOMEM;
+ list_add_tail(&addrrange->ar_link, &nidrange->nr_addrranges);
+ INIT_LIST_HEAD(&addrrange->ar_numaddr_ranges);
+
+ return nidrange->nr_netstrfns->nf_parse_addrlist(src->ls_str,
+ src->ls_len,
+ &addrrange->ar_numaddr_ranges);
+}
+
+/**
+ * Finds or creates struct nidrange.
+ *
+ * Checks if \a src is a valid network name, looks for corresponding
+ * nidrange on the ist of nidranges (\a nidlist), creates new struct
+ * nidrange if it is not found.
+ *
+ * \retval pointer to struct nidrange matching network specified via \a src
+ * \retval NULL if \a src does not match any network
+ */
+static struct nidrange *
+add_nidrange(const struct cfs_lstr *src,
+ struct list_head *nidlist)
+{
+ struct netstrfns *nf;
+ struct nidrange *nr;
+ int endlen;
+ unsigned netnum;
+
+ if (src->ls_len >= LNET_NIDSTR_SIZE)
+ return NULL;
+
+ nf = libcfs_namenum2netstrfns(src->ls_str);
+ if (nf == NULL)
+ return NULL;
+ endlen = src->ls_len - strlen(nf->nf_name);
+ if (endlen == 0)
+ /* network name only, e.g. "elan" or "tcp" */
+ netnum = 0;
+ else {
+ /* e.g. "elan25" or "tcp23", refuse to parse if
+ * network name is not appended with decimal or
+ * hexadecimal number */
+ if (!cfs_str2num_check(src->ls_str + strlen(nf->nf_name),
+ endlen, &netnum, 0, MAX_NUMERIC_VALUE))
+ return NULL;
+ }
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ if (nr->nr_netstrfns != nf)
+ continue;
+ if (nr->nr_netnum != netnum)
+ continue;
+ return nr;
+ }
+
+ LIBCFS_ALLOC(nr, sizeof(struct nidrange));
+ if (nr == NULL)
+ return NULL;
+ list_add_tail(&nr->nr_link, nidlist);
+ INIT_LIST_HEAD(&nr->nr_addrranges);
+ nr->nr_netstrfns = nf;
+ nr->nr_all = 0;
+ nr->nr_netnum = netnum;
+
+ return nr;
+}
+
+/**
+ * Parses \<nidrange\> token of the syntax.
+ *
+ * \retval 1 if \a src parses to \<addrrange\> '@' \<net\>
+ * \retval 0 otherwise
+ */
+static int
+parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist)
+{
+ struct cfs_lstr addrrange;
+ struct cfs_lstr net;
+ struct cfs_lstr tmp;
+ struct nidrange *nr;
+
+ tmp = *src;
+ if (cfs_gettok(src, '@', &addrrange) == 0)
+ goto failed;
+
+ if (cfs_gettok(src, '@', &net) == 0 || src->ls_str != NULL)
+ goto failed;
+
+ nr = add_nidrange(&net, nidlist);
+ if (nr == NULL)
+ goto failed;
+
+ if (parse_addrange(&addrrange, nr) != 0)
+ goto failed;
+
+ return 1;
+failed:
+ CWARN("can't parse nidrange: \"%.*s\"\n", tmp.ls_len, tmp.ls_str);
+ return 0;
+}
+
+/**
+ * Frees addrrange structures of \a list.
+ *
+ * For each struct addrrange structure found on \a list it frees
+ * cfs_expr_list list attached to it and frees the addrrange itself.
+ *
+ * \retval none
+ */
+static void
+free_addrranges(struct list_head *list)
+{
+ while (!list_empty(list)) {
+ struct addrrange *ar;
+
+ ar = list_entry(list->next, struct addrrange, ar_link);
+
+ cfs_expr_list_free_list(&ar->ar_numaddr_ranges);
+ list_del(&ar->ar_link);
+ LIBCFS_FREE(ar, sizeof(struct addrrange));
+ }
+}
+
+/**
+ * Frees nidrange strutures of \a list.
+ *
+ * For each struct nidrange structure found on \a list it frees
+ * addrrange list attached to it and frees the nidrange itself.
+ *
+ * \retval none
+ */
+void
+cfs_free_nidlist(struct list_head *list)
+{
+ struct list_head *pos, *next;
+ struct nidrange *nr;
+
+ list_for_each_safe(pos, next, list) {
+ nr = list_entry(pos, struct nidrange, nr_link);
+ free_addrranges(&nr->nr_addrranges);
+ list_del(pos);
+ LIBCFS_FREE(nr, sizeof(struct nidrange));
+ }
+}
+EXPORT_SYMBOL(cfs_free_nidlist);
+
+/**
+ * Parses nid range list.
+ *
+ * Parses with rigorous syntax and overflow checking \a str into
+ * \<nidrange\> [ ' ' \<nidrange\> ], compiles \a str into set of
+ * structures and links that structure to \a nidlist. The resulting
+ * list can be used to match a NID againts set of NIDS defined by \a
+ * str.
+ * \see cfs_match_nid
+ *
+ * \retval 1 on success
+ * \retval 0 otherwise
+ */
+int
+cfs_parse_nidlist(char *str, int len, struct list_head *nidlist)
+{
+ struct cfs_lstr src;
+ struct cfs_lstr res;
+ int rc;
+
+ src.ls_str = str;
+ src.ls_len = len;
+ INIT_LIST_HEAD(nidlist);
+ while (src.ls_str) {
+ rc = cfs_gettok(&src, ' ', &res);
+ if (rc == 0) {
+ cfs_free_nidlist(nidlist);
+ return 0;
+ }
+ rc = parse_nidrange(&res, nidlist);
+ if (rc == 0) {
+ cfs_free_nidlist(nidlist);
+ return 0;
+ }
+ }
+ return 1;
+}
+EXPORT_SYMBOL(cfs_parse_nidlist);
+
+/**
+ * Matches a nid (\a nid) against the compiled list of nidranges (\a nidlist).
+ *
+ * \see cfs_parse_nidlist()
+ *
+ * \retval 1 on match
+ * \retval 0 otherwises
+ */
+int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist)
+{
+ struct nidrange *nr;
+ struct addrrange *ar;
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid)))
+ continue;
+ if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid)))
+ continue;
+ if (nr->nr_all)
+ return 1;
+ list_for_each_entry(ar, &nr->nr_addrranges, ar_link)
+ if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid),
+ &ar->ar_numaddr_ranges))
+ return 1;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(cfs_match_nid);
+
+/**
+ * Print the network part of the nidrange \a nr into the specified \a buffer.
+ *
+ * \retval number of characters written
+ */
+static int
+cfs_print_network(char *buffer, int count, struct nidrange *nr)
+{
+ struct netstrfns *nf = nr->nr_netstrfns;
+
+ if (nr->nr_netnum == 0)
+ return scnprintf(buffer, count, "@%s", nf->nf_name);
+ else
+ return scnprintf(buffer, count, "@%s%u",
+ nf->nf_name, nr->nr_netnum);
+}
+
+/**
+ * Print a list of addrrange (\a addrranges) into the specified \a buffer.
+ * At max \a count characters can be printed into \a buffer.
+ *
+ * \retval number of characters written
+ */
+static int
+cfs_print_addrranges(char *buffer, int count, struct list_head *addrranges,
+ struct nidrange *nr)
+{
+ int i = 0;
+ struct addrrange *ar;
+ struct netstrfns *nf = nr->nr_netstrfns;
+
+ list_for_each_entry(ar, addrranges, ar_link) {
+ if (i != 0)
+ i += scnprintf(buffer + i, count - i, " ");
+ i += nf->nf_print_addrlist(buffer + i, count - i,
+ &ar->ar_numaddr_ranges);
+ i += cfs_print_network(buffer + i, count - i, nr);
+ }
+ return i;
+}
+
+/**
+ * Print a list of nidranges (\a nidlist) into the specified \a buffer.
+ * At max \a count characters can be printed into \a buffer.
+ * Nidranges are separated by a space character.
+ *
+ * \retval number of characters written
+ */
+int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist)
+{
+ int i = 0;
+ struct nidrange *nr;
+
+ if (count <= 0)
+ return 0;
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ if (i != 0)
+ i += scnprintf(buffer + i, count - i, " ");
+
+ if (nr->nr_all != 0) {
+ LASSERT(list_empty(&nr->nr_addrranges));
+ i += scnprintf(buffer + i, count - i, "*");
+ i += cfs_print_network(buffer + i, count - i, nr);
+ } else {
+ i += cfs_print_addrranges(buffer + i, count - i,
+ &nr->nr_addrranges, nr);
+ }
+ }
+ return i;
+}
+EXPORT_SYMBOL(cfs_print_nidlist);
+
+/**
+ * Determines minimum and maximum addresses for a single
+ * numeric address range
+ *
+ * \param ar
+ * \param min_nid
+ * \param max_nid
+ */
+static void cfs_ip_ar_min_max(struct addrrange *ar, __u32 *min_nid,
+ __u32 *max_nid)
+{
+ struct cfs_expr_list *el;
+ struct cfs_range_expr *re;
+ __u32 tmp_ip_addr = 0;
+ unsigned int min_ip[4] = {0};
+ unsigned int max_ip[4] = {0};
+ int re_count = 0;
+
+ list_for_each_entry(el, &ar->ar_numaddr_ranges, el_link) {
+ list_for_each_entry(re, &el->el_exprs, re_link) {
+ min_ip[re_count] = re->re_lo;
+ max_ip[re_count] = re->re_hi;
+ re_count++;
+ }
+ }
+
+ tmp_ip_addr = ((min_ip[0] << 24) | (min_ip[1] << 16) |
+ (min_ip[2] << 8) | min_ip[3]);
+
+ if (min_nid != NULL)
+ *min_nid = tmp_ip_addr;
+
+ tmp_ip_addr = ((max_ip[0] << 24) | (max_ip[1] << 16) |
+ (max_ip[2] << 8) | max_ip[3]);
+
+ if (max_nid != NULL)
+ *max_nid = tmp_ip_addr;
+}
+
+/**
+ * Determines minimum and maximum addresses for a single
+ * numeric address range
+ *
+ * \param ar
+ * \param min_nid
+ * \param max_nid
+ */
+static void cfs_num_ar_min_max(struct addrrange *ar, __u32 *min_nid,
+ __u32 *max_nid)
+{
+ struct cfs_expr_list *el;
+ struct cfs_range_expr *re;
+ unsigned int min_addr = 0;
+ unsigned int max_addr = 0;
+
+ list_for_each_entry(el, &ar->ar_numaddr_ranges, el_link) {
+ list_for_each_entry(re, &el->el_exprs, re_link) {
+ if (re->re_lo < min_addr || min_addr == 0)
+ min_addr = re->re_lo;
+ if (re->re_hi > max_addr)
+ max_addr = re->re_hi;
+ }
+ }
+
+ if (min_nid != NULL)
+ *min_nid = min_addr;
+ if (max_nid != NULL)
+ *max_nid = max_addr;
+}
+
+/**
+ * Determines whether an expression list in an nidrange contains exactly
+ * one contiguous address range. Calls the correct netstrfns for the LND
+ *
+ * \param *nidlist
+ *
+ * \retval true if contiguous
+ * \retval false if not contiguous
+ */
+bool cfs_nidrange_is_contiguous(struct list_head *nidlist)
+{
+ struct nidrange *nr;
+ struct netstrfns *nf = NULL;
+ char *lndname = NULL;
+ int netnum = -1;
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ nf = nr->nr_netstrfns;
+ if (lndname == NULL)
+ lndname = nf->nf_name;
+ if (netnum == -1)
+ netnum = nr->nr_netnum;
+
+ if (strcmp(lndname, nf->nf_name) != 0 ||
+ netnum != nr->nr_netnum)
+ return false;
+ }
+
+ if (nf == NULL)
+ return false;
+
+ if (!nf->nf_is_contiguous(nidlist))
+ return false;
+
+ return true;
+}
+EXPORT_SYMBOL(cfs_nidrange_is_contiguous);
+
+/**
+ * Determines whether an expression list in an num nidrange contains exactly
+ * one contiguous address range.
+ *
+ * \param *nidlist
+ *
+ * \retval true if contiguous
+ * \retval false if not contiguous
+ */
+static bool cfs_num_is_contiguous(struct list_head *nidlist)
+{
+ struct nidrange *nr;
+ struct addrrange *ar;
+ struct cfs_expr_list *el;
+ struct cfs_range_expr *re;
+ int last_hi = 0;
+ __u32 last_end_nid = 0;
+ __u32 current_start_nid = 0;
+ __u32 current_end_nid = 0;
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ list_for_each_entry(ar, &nr->nr_addrranges, ar_link) {
+ cfs_num_ar_min_max(ar, &current_start_nid,
+ &current_end_nid);
+ if (last_end_nid != 0 &&
+ (current_start_nid - last_end_nid != 1))
+ return false;
+ last_end_nid = current_end_nid;
+ list_for_each_entry(el, &ar->ar_numaddr_ranges,
+ el_link) {
+ list_for_each_entry(re, &el->el_exprs,
+ re_link) {
+ if (re->re_stride > 1)
+ return false;
+ else if (last_hi != 0 &&
+ re->re_hi - last_hi != 1)
+ return false;
+ last_hi = re->re_hi;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Determines whether an expression list in an ip nidrange contains exactly
+ * one contiguous address range.
+ *
+ * \param *nidlist
+ *
+ * \retval true if contiguous
+ * \retval false if not contiguous
+ */
+static bool cfs_ip_is_contiguous(struct list_head *nidlist)
+{
+ struct nidrange *nr;
+ struct addrrange *ar;
+ struct cfs_expr_list *el;
+ struct cfs_range_expr *re;
+ int expr_count;
+ int last_hi = 255;
+ int last_diff = 0;
+ __u32 last_end_nid = 0;
+ __u32 current_start_nid = 0;
+ __u32 current_end_nid = 0;
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ list_for_each_entry(ar, &nr->nr_addrranges, ar_link) {
+ last_hi = 255;
+ last_diff = 0;
+ cfs_ip_ar_min_max(ar, &current_start_nid,
+ &current_end_nid);
+ if (last_end_nid != 0 &&
+ (current_start_nid - last_end_nid != 1))
+ return false;
+ last_end_nid = current_end_nid;
+ list_for_each_entry(el, &ar->ar_numaddr_ranges,
+ el_link) {
+ expr_count = 0;
+ list_for_each_entry(re, &el->el_exprs,
+ re_link) {
+ expr_count++;
+ if (re->re_stride > 1 ||
+ (last_diff > 0 && last_hi != 255) ||
+ (last_diff > 0 && last_hi == 255 &&
+ re->re_lo > 0))
+ return false;
+ last_hi = re->re_hi;
+ last_diff = re->re_hi - re->re_lo;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Takes a linked list of nidrange expressions, determines the minimum
+ * and maximum nid and creates appropriate nid structures
+ *
+ * \param *nidlist
+ * \param *min_nid
+ * \param *max_nid
+ */
+void cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid,
+ char *max_nid, size_t nidstr_length)
+{
+ struct nidrange *nr;
+ struct netstrfns *nf = NULL;
+ int netnum = -1;
+ __u32 min_addr;
+ __u32 max_addr;
+ char *lndname = NULL;
+ char min_addr_str[IPSTRING_LENGTH];
+ char max_addr_str[IPSTRING_LENGTH];
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ nf = nr->nr_netstrfns;
+ lndname = nf->nf_name;
+ if (netnum == -1)
+ netnum = nr->nr_netnum;
+
+ nf->nf_min_max(nidlist, &min_addr, &max_addr);
+ }
+ nf->nf_addr2str(min_addr, min_addr_str, sizeof(min_addr_str));
+ nf->nf_addr2str(max_addr, max_addr_str, sizeof(max_addr_str));
+
+ snprintf(min_nid, nidstr_length, "%s@%s%d", min_addr_str, lndname,
+ netnum);
+ snprintf(max_nid, nidstr_length, "%s@%s%d", max_addr_str, lndname,
+ netnum);
+}
+EXPORT_SYMBOL(cfs_nidrange_find_min_max);
+
+/**
+ * Determines the min and max NID values for num LNDs
+ *
+ * \param *nidlist
+ * \param *min_nid
+ * \param *max_nid
+ */
+static void cfs_num_min_max(struct list_head *nidlist, __u32 *min_nid,
+ __u32 *max_nid)
+{
+ struct nidrange *nr;
+ struct addrrange *ar;
+ unsigned int tmp_min_addr = 0;
+ unsigned int tmp_max_addr = 0;
+ unsigned int min_addr = 0;
+ unsigned int max_addr = 0;
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ list_for_each_entry(ar, &nr->nr_addrranges, ar_link) {
+ cfs_num_ar_min_max(ar, &tmp_min_addr,
+ &tmp_max_addr);
+ if (tmp_min_addr < min_addr || min_addr == 0)
+ min_addr = tmp_min_addr;
+ if (tmp_max_addr > max_addr)
+ max_addr = tmp_min_addr;
+ }
+ }
+ *max_nid = max_addr;
+ *min_nid = min_addr;
+}
+
+/**
+ * Takes an nidlist and determines the minimum and maximum
+ * ip addresses.
+ *
+ * \param *nidlist
+ * \param *min_nid
+ * \param *max_nid
+ */
+static void cfs_ip_min_max(struct list_head *nidlist, __u32 *min_nid,
+ __u32 *max_nid)
+{
+ struct nidrange *nr;
+ struct addrrange *ar;
+ __u32 tmp_min_ip_addr = 0;
+ __u32 tmp_max_ip_addr = 0;
+ __u32 min_ip_addr = 0;
+ __u32 max_ip_addr = 0;
+
+ list_for_each_entry(nr, nidlist, nr_link) {
+ list_for_each_entry(ar, &nr->nr_addrranges, ar_link) {
+ cfs_ip_ar_min_max(ar, &tmp_min_ip_addr,
+ &tmp_max_ip_addr);
+ if (tmp_min_ip_addr < min_ip_addr || min_ip_addr == 0)
+ min_ip_addr = tmp_min_ip_addr;
+ if (tmp_max_ip_addr > max_ip_addr)
+ max_ip_addr = tmp_max_ip_addr;
+ }
+ }
+
+ if (min_nid != NULL)
+ *min_nid = min_ip_addr;
+ if (max_nid != NULL)
+ *max_nid = max_ip_addr;
+}
+
+static int
+libcfs_lo_str2addr(const char *str, int nob, __u32 *addr)
+{
+ *addr = 0;
+ return 1;
+}
+
+static void
+libcfs_ip_addr2str(__u32 addr, char *str, size_t size)
+{
+ snprintf(str, size, "%u.%u.%u.%u",
+ (addr >> 24) & 0xff, (addr >> 16) & 0xff,
+ (addr >> 8) & 0xff, addr & 0xff);
+}
+
+/* CAVEAT EMPTOR XscanfX
+ * I use "%n" at the end of a sscanf format to detect trailing junk. However
+ * sscanf may return immediately if it sees the terminating '0' in a string, so
+ * I initialise the %n variable to the expected length. If sscanf sets it;
+ * fine, if it doesn't, then the scan ended at the end of the string, which is
+ * fine too :) */
+static int
+libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
+{
+ unsigned int a;
+ unsigned int b;
+ unsigned int c;
+ unsigned int d;
+ int n = nob; /* XscanfX */
+
+ /* numeric IP? */
+ if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
+ n == nob &&
+ (a & ~0xff) == 0 && (b & ~0xff) == 0 &&
+ (c & ~0xff) == 0 && (d & ~0xff) == 0) {
+ *addr = ((a<<24)|(b<<16)|(c<<8)|d);
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Used by lnet/config.c so it can't be static */
+int
+cfs_ip_addr_parse(char *str, int len, struct list_head *list)
+{
+ struct cfs_expr_list *el;
+ struct cfs_lstr src;
+ int rc;
+ int i;
+
+ src.ls_str = str;
+ src.ls_len = len;
+ i = 0;
+
+ while (src.ls_str != NULL) {
+ struct cfs_lstr res;
+
+ if (!cfs_gettok(&src, '.', &res)) {
+ rc = -EINVAL;
+ goto out;
+ }
+
+ rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
+ if (rc != 0)
+ goto out;
+
+ list_add_tail(&el->el_link, list);
+ i++;
+ }
+
+ if (i == 4)
+ return 0;
+
+ rc = -EINVAL;
+out:
+ cfs_expr_list_free_list(list);
+
+ return rc;
+}
+
+static int
+libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list)
+{
+ int i = 0, j = 0;
+ struct cfs_expr_list *el;
+
+ list_for_each_entry(el, list, el_link) {
+ LASSERT(j++ < 4);
+ if (i != 0)
+ i += scnprintf(buffer + i, count - i, ".");
+ i += cfs_expr_list_print(buffer + i, count - i, el);
+ }
+ return i;
+}
+
+/**
+ * Matches address (\a addr) against address set encoded in \a list.
+ *
+ * \retval 1 if \a addr matches
+ * \retval 0 otherwise
+ */
+int
+cfs_ip_addr_match(__u32 addr, struct list_head *list)
+{
+ struct cfs_expr_list *el;
+ int i = 0;
+
+ list_for_each_entry_reverse(el, list, el_link) {
+ if (!cfs_expr_list_match(addr & 0xff, el))
+ return 0;
+ addr >>= 8;
+ i++;
+ }
+
+ return i == 4;
+}
+
+static void
+libcfs_decnum_addr2str(__u32 addr, char *str, size_t size)
+{
+ snprintf(str, size, "%u", addr);
+}
+
+static int
+libcfs_num_str2addr(const char *str, int nob, __u32 *addr)
+{
+ int n;
+
+ n = nob;
+ if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob)
+ return 1;
+
+ n = nob;
+ if (sscanf(str, "0X%x%n", addr, &n) >= 1 && n == nob)
+ return 1;
+
+ n = nob;
+ if (sscanf(str, "%u%n", addr, &n) >= 1 && n == nob)
+ return 1;
+
+ return 0;
+}
+
+/**
+ * Nf_parse_addrlist method for networks using numeric addresses.
+ *
+ * Examples of such networks are gm and elan.
+ *
+ * \retval 0 if \a str parsed to numeric address
+ * \retval errno otherwise
+ */
+static int
+libcfs_num_parse(char *str, int len, struct list_head *list)
+{
+ struct cfs_expr_list *el;
+ int rc;
+
+ rc = cfs_expr_list_parse(str, len, 0, MAX_NUMERIC_VALUE, &el);
+ if (rc == 0)
+ list_add_tail(&el->el_link, list);
+
+ return rc;
+}
+
+static int
+libcfs_num_addr_range_print(char *buffer, int count, struct list_head *list)
+{
+ int i = 0, j = 0;
+ struct cfs_expr_list *el;
+
+ list_for_each_entry(el, list, el_link) {
+ LASSERT(j++ < 1);
+ i += cfs_expr_list_print(buffer + i, count - i, el);
+ }
+ return i;
+}
+
+/*
+ * Nf_match_addr method for networks using numeric addresses
+ *
+ * \retval 1 on match
+ * \retval 0 otherwise
+ */
+static int
+libcfs_num_match(__u32 addr, struct list_head *numaddr)
+{
+ struct cfs_expr_list *el;
+
+ LASSERT(!list_empty(numaddr));
+ el = list_entry(numaddr->next, struct cfs_expr_list, el_link);
+
+ return cfs_expr_list_match(addr, el);
+}
+
+static struct netstrfns libcfs_netstrfns[] = {
+ { .nf_type = LOLND,
+ .nf_name = "lo",
+ .nf_modname = "klolnd",
+ .nf_addr2str = libcfs_decnum_addr2str,
+ .nf_str2addr = libcfs_lo_str2addr,
+ .nf_parse_addrlist = libcfs_num_parse,
+ .nf_print_addrlist = libcfs_num_addr_range_print,
+ .nf_match_addr = libcfs_num_match,
+ .nf_is_contiguous = cfs_num_is_contiguous,
+ .nf_min_max = cfs_num_min_max },
+ { .nf_type = SOCKLND,
+ .nf_name = "tcp",
+ .nf_modname = "ksocklnd",
+ .nf_addr2str = libcfs_ip_addr2str,
+ .nf_str2addr = libcfs_ip_str2addr,
+ .nf_parse_addrlist = cfs_ip_addr_parse,
+ .nf_print_addrlist = libcfs_ip_addr_range_print,
+ .nf_match_addr = cfs_ip_addr_match,
+ .nf_is_contiguous = cfs_ip_is_contiguous,
+ .nf_min_max = cfs_ip_min_max },
+ { .nf_type = O2IBLND,
+ .nf_name = "o2ib",
+ .nf_modname = "ko2iblnd",
+ .nf_addr2str = libcfs_ip_addr2str,
+ .nf_str2addr = libcfs_ip_str2addr,
+ .nf_parse_addrlist = cfs_ip_addr_parse,
+ .nf_print_addrlist = libcfs_ip_addr_range_print,
+ .nf_match_addr = cfs_ip_addr_match,
+ .nf_is_contiguous = cfs_ip_is_contiguous,
+ .nf_min_max = cfs_ip_min_max },
+ { .nf_type = GNILND,
+ .nf_name = "gni",
+ .nf_modname = "kgnilnd",
+ .nf_addr2str = libcfs_decnum_addr2str,
+ .nf_str2addr = libcfs_num_str2addr,
+ .nf_parse_addrlist = libcfs_num_parse,
+ .nf_print_addrlist = libcfs_num_addr_range_print,
+ .nf_match_addr = libcfs_num_match,
+ .nf_is_contiguous = cfs_num_is_contiguous,
+ .nf_min_max = cfs_num_min_max },
+ { .nf_type = GNIIPLND,
+ .nf_name = "gip",
+ .nf_modname = "kgnilnd",
+ .nf_addr2str = libcfs_ip_addr2str,
+ .nf_str2addr = libcfs_ip_str2addr,
+ .nf_parse_addrlist = cfs_ip_addr_parse,
+ .nf_print_addrlist = libcfs_ip_addr_range_print,
+ .nf_match_addr = cfs_ip_addr_match,
+ .nf_is_contiguous = cfs_ip_is_contiguous,
+ .nf_min_max = cfs_ip_min_max },
+};
+
+static const size_t libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns);
+
+static struct netstrfns *
+libcfs_lnd2netstrfns(__u32 lnd)
+{
+ int i;
+
+ for (i = 0; i < libcfs_nnetstrfns; i++)
+ if (lnd == libcfs_netstrfns[i].nf_type)
+ return &libcfs_netstrfns[i];
+
+ return NULL;
+}
+
+static struct netstrfns *
+libcfs_namenum2netstrfns(const char *name)
+{
+ struct netstrfns *nf;
+ int i;
+
+ for (i = 0; i < libcfs_nnetstrfns; i++) {
+ nf = &libcfs_netstrfns[i];
+ if (!strncmp(name, nf->nf_name, strlen(nf->nf_name)))
+ return nf;
+ }
+ return NULL;
+}
+
+static struct netstrfns *
+libcfs_name2netstrfns(const char *name)
+{
+ int i;
+
+ for (i = 0; i < libcfs_nnetstrfns; i++)
+ if (!strcmp(libcfs_netstrfns[i].nf_name, name))
+ return &libcfs_netstrfns[i];
+
+ return NULL;
+}
+
+int
+libcfs_isknown_lnd(__u32 lnd)
+{
+ return libcfs_lnd2netstrfns(lnd) != NULL;
+}
+EXPORT_SYMBOL(libcfs_isknown_lnd);
+
+char *
+libcfs_lnd2modname(__u32 lnd)
+{
+ struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
+
+ return (nf == NULL) ? NULL : nf->nf_modname;
+}
+EXPORT_SYMBOL(libcfs_lnd2modname);
+
+int
+libcfs_str2lnd(const char *str)
+{
+ struct netstrfns *nf = libcfs_name2netstrfns(str);
+
+ if (nf != NULL)
+ return nf->nf_type;
+
+ return -1;
+}
+EXPORT_SYMBOL(libcfs_str2lnd);
+
+char *
+libcfs_lnd2str_r(__u32 lnd, char *buf, size_t buf_size)
+{
+ struct netstrfns *nf;
+
+ nf = libcfs_lnd2netstrfns(lnd);
+ if (nf == NULL)
+ snprintf(buf, buf_size, "?%u?", lnd);
+ else
+ snprintf(buf, buf_size, "%s", nf->nf_name);
+
+ return buf;
+}
+EXPORT_SYMBOL(libcfs_lnd2str_r);
+
+char *
+libcfs_net2str_r(__u32 net, char *buf, size_t buf_size)
+{
+ __u32 nnum = LNET_NETNUM(net);
+ __u32 lnd = LNET_NETTYP(net);
+ struct netstrfns *nf;
+
+ nf = libcfs_lnd2netstrfns(lnd);
+ if (nf == NULL)
+ snprintf(buf, buf_size, "<%u:%u>", lnd, nnum);
+ else if (nnum == 0)
+ snprintf(buf, buf_size, "%s", nf->nf_name);
+ else
+ snprintf(buf, buf_size, "%s%u", nf->nf_name, nnum);
+
+ return buf;
+}
+EXPORT_SYMBOL(libcfs_net2str_r);
+
+char *
+libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size)
+{
+ __u32 addr = LNET_NIDADDR(nid);
+ __u32 net = LNET_NIDNET(nid);
+ __u32 nnum = LNET_NETNUM(net);
+ __u32 lnd = LNET_NETTYP(net);
+ struct netstrfns *nf;
+
+ if (nid == LNET_NID_ANY) {
+ strncpy(buf, "<?>", buf_size);
+ buf[buf_size - 1] = '\0';
+ return buf;
+ }
+
+ nf = libcfs_lnd2netstrfns(lnd);
+ if (nf == NULL)
+ snprintf(buf, buf_size, "%x@<%u:%u>", addr, lnd, nnum);
+ else {
+ size_t addr_len;
+
+ nf->nf_addr2str(addr, buf, buf_size);
+ addr_len = strlen(buf);
+ if (nnum == 0)
+ snprintf(buf + addr_len, buf_size - addr_len, "@%s",
+ nf->nf_name);
+ else
+ snprintf(buf + addr_len, buf_size - addr_len, "@%s%u",
+ nf->nf_name, nnum);
+ }
+
+ return buf;
+}
+EXPORT_SYMBOL(libcfs_nid2str_r);
+
+static struct netstrfns *
+libcfs_str2net_internal(const char *str, __u32 *net)
+{
+ struct netstrfns *uninitialized_var(nf);
+ int nob;
+ unsigned int netnum;
+ int i;
+
+ for (i = 0; i < libcfs_nnetstrfns; i++) {
+ nf = &libcfs_netstrfns[i];
+ if (!strncmp(str, nf->nf_name, strlen(nf->nf_name)))
+ break;
+ }
+
+ if (i == libcfs_nnetstrfns)
+ return NULL;
+
+ nob = strlen(nf->nf_name);
+
+ if (strlen(str) == (unsigned int)nob) {
+ netnum = 0;
+ } else {
+ if (nf->nf_type == LOLND) /* net number not allowed */
+ return NULL;
+
+ str += nob;
+ i = strlen(str);
+ if (sscanf(str, "%u%n", &netnum, &i) < 1 ||
+ i != (int)strlen(str))
+ return NULL;
+ }
+
+ *net = LNET_MKNET(nf->nf_type, netnum);
+ return nf;
+}
+
+__u32
+libcfs_str2net(const char *str)
+{
+ __u32 net;
+
+ if (libcfs_str2net_internal(str, &net) != NULL)
+ return net;
+
+ return LNET_NIDNET(LNET_NID_ANY);
+}
+EXPORT_SYMBOL(libcfs_str2net);
+
+lnet_nid_t
+libcfs_str2nid(const char *str)
+{
+ const char *sep = strchr(str, '@');
+ struct netstrfns *nf;
+ __u32 net;
+ __u32 addr;
+
+ if (sep != NULL) {
+ nf = libcfs_str2net_internal(sep + 1, &net);
+ if (nf == NULL)
+ return LNET_NID_ANY;
+ } else {
+ sep = str + strlen(str);
+ net = LNET_MKNET(SOCKLND, 0);
+ nf = libcfs_lnd2netstrfns(SOCKLND);
+ LASSERT(nf != NULL);
+ }
+
+ if (!nf->nf_str2addr(str, (int)(sep - str), &addr))
+ return LNET_NID_ANY;
+
+ return LNET_MKNID(net, addr);
+}
+EXPORT_SYMBOL(libcfs_str2nid);
+
+char *
+libcfs_id2str(lnet_process_id_t id)
+{
+ char *str = libcfs_next_nidstring();
+
+ if (id.pid == LNET_PID_ANY) {
+ snprintf(str, LNET_NIDSTR_SIZE,
+ "LNET_PID_ANY-%s", libcfs_nid2str(id.nid));
+ return str;
+ }
+
+ snprintf(str, LNET_NIDSTR_SIZE, "%s%u-%s",
+ ((id.pid & LNET_PID_USERFLAG) != 0) ? "U" : "",
+ (id.pid & ~LNET_PID_USERFLAG), libcfs_nid2str(id.nid));
+ return str;
+}
+EXPORT_SYMBOL(libcfs_id2str);
+
+int
+libcfs_str2anynid(lnet_nid_t *nidp, const char *str)
+{
+ if (!strcmp(str, "*")) {
+ *nidp = LNET_NID_ANY;
+ return 1;
+ }
+
+ *nidp = libcfs_str2nid(str);
+ return *nidp != LNET_NID_ANY;
+}
+EXPORT_SYMBOL(libcfs_str2anynid);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/peer.c b/kernel/drivers/staging/lustre/lnet/lnet/peer.c
index 45b5742f1..1fceed3c8 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/peer.c
@@ -43,10 +43,10 @@
int
lnet_peer_tables_create(void)
{
- struct lnet_peer_table *ptable;
- struct list_head *hash;
- int i;
- int j;
+ struct lnet_peer_table *ptable;
+ struct list_head *hash;
+ int i;
+ int j;
the_lnet.ln_peer_tables = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*ptable));
@@ -77,10 +77,10 @@ lnet_peer_tables_create(void)
void
lnet_peer_tables_destroy(void)
{
- struct lnet_peer_table *ptable;
- struct list_head *hash;
- int i;
- int j;
+ struct lnet_peer_table *ptable;
+ struct list_head *hash;
+ int i;
+ int j;
if (the_lnet.ln_peer_tables == NULL)
return;
@@ -106,9 +106,9 @@ lnet_peer_tables_destroy(void)
void
lnet_peer_tables_cleanup(void)
{
- struct lnet_peer_table *ptable;
- int i;
- int j;
+ struct lnet_peer_table *ptable;
+ int i;
+ int j;
LASSERT(the_lnet.ln_shutdown); /* i.e. no new peers */
@@ -133,7 +133,7 @@ lnet_peer_tables_cleanup(void)
cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) {
LIST_HEAD(deathrow);
- lnet_peer_t *lp;
+ lnet_peer_t *lp;
lnet_net_lock(i);
@@ -186,8 +186,8 @@ lnet_destroy_peer_locked(lnet_peer_t *lp)
lnet_peer_t *
lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid)
{
- struct list_head *peers;
- lnet_peer_t *lp;
+ struct list_head *peers;
+ lnet_peer_t *lp;
LASSERT(!the_lnet.ln_shutdown);
@@ -205,11 +205,11 @@ lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid)
int
lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
{
- struct lnet_peer_table *ptable;
- lnet_peer_t *lp = NULL;
- lnet_peer_t *lp2;
- int cpt2;
- int rc = 0;
+ struct lnet_peer_table *ptable;
+ lnet_peer_t *lp = NULL;
+ lnet_peer_t *lp2;
+ int cpt2;
+ int rc = 0;
*lpp = NULL;
if (the_lnet.ln_shutdown) /* it's shutting down */
@@ -287,8 +287,8 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
goto out;
}
- lp->lp_txcredits =
- lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
+ lp->lp_txcredits =
+ lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
lp->lp_rtrcredits =
lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
@@ -308,10 +308,10 @@ out:
void
lnet_debug_peer(lnet_nid_t nid)
{
- char *aliveness = "NA";
- lnet_peer_t *lp;
- int rc;
- int cpt;
+ char *aliveness = "NA";
+ lnet_peer_t *lp;
+ int rc;
+ int cpt;
cpt = lnet_cpt_of_nid(nid);
lnet_net_lock(cpt);
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/router.c b/kernel/drivers/staging/lustre/lnet/lnet/router.c
index 8510bae48..4ea651c6d 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/router.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/router.c
@@ -24,8 +24,6 @@
#define DEBUG_SUBSYSTEM S_LNET
#include "../../include/linux/lnet/lib-lnet.h"
-#if defined(LNET_ROUTER)
-
#define LNET_NRB_TINY_MIN 512 /* min value for each CPT */
#define LNET_NRB_TINY (LNET_NRB_TINY_MIN * 4)
#define LNET_NRB_SMALL_MIN 4096 /* min value for each CPT */
@@ -70,15 +68,6 @@ lnet_peer_buffer_credits(lnet_ni_t *ni)
/* forward ref's */
static int lnet_router_checker(void *);
-#else
-
-int
-lnet_peer_buffer_credits(lnet_ni_t *ni)
-{
- return 0;
-}
-
-#endif
static int check_routers_before_use;
module_param(check_routers_before_use, int, 0444);
@@ -139,8 +128,8 @@ lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive,
static void
lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
{
- int alive;
- int notifylnd;
+ int alive;
+ int notifylnd;
/* Notify only in 1 thread at any time to ensure ordered notification.
* NB individual events can be missed; the only guarantee is that you
@@ -152,7 +141,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
lp->lp_notifying = 1;
while (lp->lp_notify) {
- alive = lp->lp_alive;
+ alive = lp->lp_alive;
notifylnd = lp->lp_notifylnd;
lp->lp_notifylnd = 0;
@@ -173,7 +162,6 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
lp->lp_notifying = 0;
}
-
static void
lnet_rtr_addref_locked(lnet_peer_t *lp)
{
@@ -228,9 +216,9 @@ lnet_rtr_decref_locked(lnet_peer_t *lp)
lnet_remotenet_t *
lnet_find_net_locked(__u32 net)
{
- lnet_remotenet_t *rnet;
- struct list_head *tmp;
- struct list_head *rn_list;
+ lnet_remotenet_t *rnet;
+ struct list_head *tmp;
+ struct list_head *rn_list;
LASSERT(!the_lnet.ln_shutdown);
@@ -247,8 +235,8 @@ lnet_find_net_locked(__u32 net)
static void lnet_shuffle_seed(void)
{
static int seeded;
- int lnd_type, seed[2];
- struct timeval tv;
+ __u32 lnd_type, seed[2];
+ struct timespec64 ts;
lnet_ni_t *ni;
struct list_head *tmp;
@@ -267,8 +255,8 @@ static void lnet_shuffle_seed(void)
seed[0] ^= (LNET_NIDADDR(ni->ni_nid) | lnd_type);
}
- do_gettimeofday(&tv);
- cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
+ ktime_get_ts64(&ts);
+ cfs_srand(ts.tv_sec ^ seed[0], ts.tv_nsec ^ seed[1]);
seeded = 1;
}
@@ -276,9 +264,9 @@ static void lnet_shuffle_seed(void)
static void
lnet_add_route_to_rnet(lnet_remotenet_t *rnet, lnet_route_t *route)
{
- unsigned int len = 0;
- unsigned int offset = 0;
- struct list_head *e;
+ unsigned int len = 0;
+ unsigned int offset = 0;
+ struct list_head *e;
lnet_shuffle_seed();
@@ -304,13 +292,13 @@ int
lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
unsigned int priority)
{
- struct list_head *e;
- lnet_remotenet_t *rnet;
- lnet_remotenet_t *rnet2;
- lnet_route_t *route;
- lnet_ni_t *ni;
- int add_route;
- int rc;
+ struct list_head *e;
+ lnet_remotenet_t *rnet;
+ lnet_remotenet_t *rnet2;
+ lnet_route_t *route;
+ lnet_ni_t *ni;
+ int add_route;
+ int rc;
CDEBUG(D_NET, "Add route: net %s hops %u priority %u gw %s\n",
libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway));
@@ -416,14 +404,14 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
int
lnet_check_routes(void)
{
- lnet_remotenet_t *rnet;
- lnet_route_t *route;
- lnet_route_t *route2;
- struct list_head *e1;
- struct list_head *e2;
- int cpt;
- struct list_head *rn_list;
- int i;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *route;
+ lnet_route_t *route2;
+ struct list_head *e1;
+ struct list_head *e2;
+ int cpt;
+ struct list_head *rn_list;
+ int i;
cpt = lnet_net_lock_current();
@@ -434,9 +422,9 @@ lnet_check_routes(void)
route2 = NULL;
list_for_each(e2, &rnet->lrn_routes) {
- lnet_nid_t nid1;
- lnet_nid_t nid2;
- int net;
+ lnet_nid_t nid1;
+ lnet_nid_t nid2;
+ int net;
route = list_entry(e2, lnet_route_t,
lr_list);
@@ -472,14 +460,14 @@ lnet_check_routes(void)
int
lnet_del_route(__u32 net, lnet_nid_t gw_nid)
{
- struct lnet_peer *gateway;
- lnet_remotenet_t *rnet;
- lnet_route_t *route;
- struct list_head *e1;
- struct list_head *e2;
- int rc = -ENOENT;
- struct list_head *rn_list;
- int idx = 0;
+ struct lnet_peer *gateway;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *route;
+ struct list_head *e1;
+ struct list_head *e2;
+ int rc = -ENOENT;
+ struct list_head *rn_list;
+ int idx = 0;
CDEBUG(D_NET, "Del route: net %s : gw %s\n",
libcfs_net2str(net), libcfs_nid2str(gw_nid));
@@ -554,13 +542,13 @@ int
lnet_get_route(int idx, __u32 *net, __u32 *hops,
lnet_nid_t *gateway, __u32 *alive, __u32 *priority)
{
- struct list_head *e1;
- struct list_head *e2;
- lnet_remotenet_t *rnet;
- lnet_route_t *route;
- int cpt;
- int i;
- struct list_head *rn_list;
+ struct list_head *e1;
+ struct list_head *e2;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *route;
+ int cpt;
+ int i;
+ struct list_head *rn_list;
cpt = lnet_net_lock_current();
@@ -574,11 +562,11 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,
lr_list);
if (idx-- == 0) {
- *net = rnet->lrn_net;
- *hops = route->lr_hops;
+ *net = rnet->lrn_net;
+ *hops = route->lr_hops;
*priority = route->lr_priority;
*gateway = route->lr_gateway->lp_nid;
- *alive = route->lr_gateway->lp_alive;
+ *alive = route->lr_gateway->lp_alive;
lnet_net_unlock(cpt);
return 0;
}
@@ -593,7 +581,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,
void
lnet_swap_pinginfo(lnet_ping_info_t *info)
{
- int i;
+ int i;
lnet_ni_status_t *stat;
__swab32s(&info->pi_magic);
@@ -614,9 +602,9 @@ lnet_swap_pinginfo(lnet_ping_info_t *info)
static void
lnet_parse_rc_info(lnet_rc_data_t *rcd)
{
- lnet_ping_info_t *info = rcd->rcd_pinginfo;
- struct lnet_peer *gw = rcd->rcd_gateway;
- lnet_route_t *rtr;
+ lnet_ping_info_t *info = rcd->rcd_pinginfo;
+ struct lnet_peer *gw = rcd->rcd_gateway;
+ lnet_route_t *rtr;
if (!gw->lp_alive)
return;
@@ -643,14 +631,14 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd)
return; /* can't carry NI status info */
list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) {
- int ptl_status = LNET_NI_STATUS_INVALID;
- int down = 0;
- int up = 0;
- int i;
+ int ptl_status = LNET_NI_STATUS_INVALID;
+ int down = 0;
+ int up = 0;
+ int i;
for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) {
lnet_ni_status_t *stat = &info->pi_ni[i];
- lnet_nid_t nid = stat->ns_nid;
+ lnet_nid_t nid = stat->ns_nid;
if (nid == LNET_NID_ANY) {
CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n",
@@ -699,8 +687,8 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd)
static void
lnet_router_checker_event(lnet_event_t *event)
{
- lnet_rc_data_t *rcd = event->md.user_ptr;
- struct lnet_peer *lp;
+ lnet_rc_data_t *rcd = event->md.user_ptr;
+ struct lnet_peer *lp;
LASSERT(rcd != NULL);
@@ -752,14 +740,14 @@ lnet_router_checker_event(lnet_event_t *event)
static void
lnet_wait_known_routerstate(void)
{
- lnet_peer_t *rtr;
- struct list_head *entry;
- int all_known;
+ lnet_peer_t *rtr;
+ struct list_head *entry;
+ int all_known;
LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
for (;;) {
- int cpt = lnet_net_lock_current();
+ int cpt = lnet_net_lock_current();
all_known = 1;
list_for_each(entry, &the_lnet.ln_routers) {
@@ -799,16 +787,16 @@ lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net)
static void
lnet_update_ni_status_locked(void)
{
- lnet_ni_t *ni;
- long now;
- int timeout;
+ lnet_ni_t *ni;
+ time64_t now;
+ int timeout;
LASSERT(the_lnet.ln_routing);
timeout = router_ping_timeout +
max(live_router_check_interval, dead_router_check_interval);
- now = get_seconds();
+ now = ktime_get_real_seconds();
list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) {
if (ni->ni_lnd->lnd_type == LOLND)
continue;
@@ -860,10 +848,10 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd)
static lnet_rc_data_t *
lnet_create_rc_data_locked(lnet_peer_t *gateway)
{
- lnet_rc_data_t *rcd = NULL;
- lnet_ping_info_t *pi;
- int rc;
- int i;
+ lnet_rc_data_t *rcd = NULL;
+ lnet_ping_info_t *pi;
+ int rc;
+ int i;
lnet_net_unlock(gateway->lp_cpt);
@@ -943,8 +931,8 @@ static void
lnet_ping_router_locked(lnet_peer_t *rtr)
{
lnet_rc_data_t *rcd = NULL;
- unsigned long now = cfs_time_current();
- int secs;
+ unsigned long now = cfs_time_current();
+ int secs;
lnet_peer_addref_locked(rtr);
@@ -979,9 +967,9 @@ lnet_ping_router_locked(lnet_peer_t *rtr)
if (secs != 0 && !rtr->lp_ping_notsent &&
cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
cfs_time_seconds(secs)))) {
- int rc;
+ int rc;
lnet_process_id_t id;
- lnet_handle_md_t mdh;
+ lnet_handle_md_t mdh;
id.nid = rtr->lp_nid;
id.pid = LUSTRE_SRV_LNET_PID;
@@ -1013,8 +1001,8 @@ lnet_ping_router_locked(lnet_peer_t *rtr)
int
lnet_router_checker_start(void)
{
- int rc;
- int eqsz;
+ int rc;
+ int eqsz;
LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
@@ -1085,11 +1073,11 @@ lnet_router_checker_stop(void)
static void
lnet_prune_rc_data(int wait_unlink)
{
- lnet_rc_data_t *rcd;
- lnet_rc_data_t *tmp;
- lnet_peer_t *lp;
- struct list_head head;
- int i = 2;
+ lnet_rc_data_t *rcd;
+ lnet_rc_data_t *tmp;
+ lnet_peer_t *lp;
+ struct list_head head;
+ int i = 2;
if (likely(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING &&
list_empty(&the_lnet.ln_rcd_deathrow) &&
@@ -1163,23 +1151,20 @@ lnet_prune_rc_data(int wait_unlink)
lnet_net_unlock(LNET_LOCK_EX);
}
-
-#if defined(LNET_ROUTER)
-
static int
lnet_router_checker(void *arg)
{
- lnet_peer_t *rtr;
- struct list_head *entry;
+ lnet_peer_t *rtr;
+ struct list_head *entry;
cfs_block_allsigs();
LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
- __u64 version;
- int cpt;
- int cpt2;
+ __u64 version;
+ int cpt;
+ int cpt2;
cpt = lnet_net_lock_current();
rescan:
@@ -1245,11 +1230,11 @@ lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages)
static lnet_rtrbuf_t *
lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
{
- int npages = rbp->rbp_npages;
- int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
- struct page *page;
+ int npages = rbp->rbp_npages;
+ int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
+ struct page *page;
lnet_rtrbuf_t *rb;
- int i;
+ int i;
LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz);
if (rb == NULL)
@@ -1260,7 +1245,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
for (i = 0; i < npages; i++) {
page = alloc_pages_node(
cfs_cpt_spread_node(lnet_cpt_table(), cpt),
- __GFP_ZERO | GFP_IOFS, 0);
+ GFP_KERNEL | __GFP_ZERO, 0);
if (page == NULL) {
while (--i >= 0)
__free_page(rb->rb_kiov[i].kiov_page);
@@ -1280,9 +1265,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
static void
lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp)
{
- int npages = rbp->rbp_npages;
- int nbuffers = 0;
- lnet_rtrbuf_t *rb;
+ int npages = rbp->rbp_npages;
+ int nbuffers = 0;
+ lnet_rtrbuf_t *rb;
if (rbp->rbp_nbuffers == 0) /* not initialized or already freed */
return;
@@ -1310,7 +1295,7 @@ static int
lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt)
{
lnet_rtrbuf_t *rb;
- int i;
+ int i;
if (rbp->rbp_nbuffers != 0) {
LASSERT(rbp->rbp_nbuffers == nbufs);
@@ -1355,7 +1340,7 @@ void
lnet_rtrpools_free(void)
{
lnet_rtrbufpool_t *rtrp;
- int i;
+ int i;
if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */
return;
@@ -1373,7 +1358,7 @@ lnet_rtrpools_free(void)
static int
lnet_nrb_tiny_calculate(int npages)
{
- int nrbs = LNET_NRB_TINY;
+ int nrbs = LNET_NRB_TINY;
if (tiny_router_buffers < 0) {
LCONSOLE_ERROR_MSG(0x10c,
@@ -1392,7 +1377,7 @@ lnet_nrb_tiny_calculate(int npages)
static int
lnet_nrb_small_calculate(int npages)
{
- int nrbs = LNET_NRB_SMALL;
+ int nrbs = LNET_NRB_SMALL;
if (small_router_buffers < 0) {
LCONSOLE_ERROR_MSG(0x10c,
@@ -1411,7 +1396,7 @@ lnet_nrb_small_calculate(int npages)
static int
lnet_nrb_large_calculate(int npages)
{
- int nrbs = LNET_NRB_LARGE;
+ int nrbs = LNET_NRB_LARGE;
if (large_router_buffers < 0) {
LCONSOLE_ERROR_MSG(0x10c,
@@ -1431,13 +1416,13 @@ int
lnet_rtrpools_alloc(int im_a_router)
{
lnet_rtrbufpool_t *rtrp;
- int large_pages;
- int small_pages = 1;
- int nrb_tiny;
- int nrb_small;
- int nrb_large;
- int rc;
- int i;
+ int large_pages;
+ int small_pages = 1;
+ int nrb_tiny;
+ int nrb_small;
+ int nrb_large;
+ int rc;
+ int i;
large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
@@ -1507,11 +1492,11 @@ lnet_rtrpools_alloc(int im_a_router)
int
lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
{
- struct lnet_peer *lp = NULL;
- unsigned long now = cfs_time_current();
- int cpt = lnet_cpt_of_nid(nid);
+ struct lnet_peer *lp = NULL;
+ unsigned long now = cfs_time_current();
+ int cpt = lnet_cpt_of_nid(nid);
- LASSERT(!in_interrupt ());
+ LASSERT(!in_interrupt());
CDEBUG(D_NET, "%s notifying %s: %s\n",
(ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
@@ -1573,134 +1558,3 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
return 0;
}
EXPORT_SYMBOL(lnet_notify);
-
-void
-lnet_get_tunables(void)
-{
-}
-
-#else
-
-int
-lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
-{
- return -EOPNOTSUPP;
-}
-
-void
-lnet_router_checker(void)
-{
- static time_t last;
- static int running;
-
- time_t now = get_seconds();
- int interval = now - last;
- int rc;
- __u64 version;
- lnet_peer_t *rtr;
-
- /* It's no use to call me again within a sec - all intervals and
- * timeouts are measured in seconds */
- if (last != 0 && interval < 2)
- return;
-
- if (last != 0 &&
- interval > max(live_router_check_interval,
- dead_router_check_interval))
- CNETERR("Checker(%d/%d) not called for %d seconds\n",
- live_router_check_interval, dead_router_check_interval,
- interval);
-
- LASSERT(LNET_CPT_NUMBER == 1);
-
- lnet_net_lock(0);
- LASSERT(!running); /* recursion check */
- running = 1;
- lnet_net_unlock(0);
-
- last = now;
-
- if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING)
- lnet_prune_rc_data(0); /* unlink all rcd and nowait */
-
- /* consume all pending events */
- while (1) {
- int i;
- lnet_event_t ev;
-
- /* NB ln_rc_eqh must be the 1st in 'eventqs' otherwise the
- * recursion breaker in LNetEQPoll would fail */
- rc = LNetEQPoll(&the_lnet.ln_rc_eqh, 1, 0, &ev, &i);
- if (rc == 0) /* no event pending */
- break;
-
- /* NB a lost SENT prevents me from pinging a router again */
- if (rc == -EOVERFLOW) {
- CERROR("Dropped an event!!!\n");
- abort();
- }
-
- LASSERT(rc == 1);
-
- lnet_router_checker_event(&ev);
- }
-
- if (the_lnet.ln_rc_state == LNET_RC_STATE_STOPPING) {
- lnet_prune_rc_data(1); /* release rcd */
- the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
- running = 0;
- return;
- }
-
- LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
-
- lnet_net_lock(0);
-
- version = the_lnet.ln_routers_version;
- list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) {
- lnet_ping_router_locked(rtr);
- LASSERT(version == the_lnet.ln_routers_version);
- }
-
- lnet_net_unlock(0);
-
- running = 0; /* lock only needed for the recursion check */
-}
-
-/* NB lnet_peers_start_down depends on me,
- * so must be called before any peer creation */
-void
-lnet_get_tunables(void)
-{
- char *s;
-
- s = getenv("LNET_ROUTER_PING_TIMEOUT");
- if (s != NULL)
- router_ping_timeout = atoi(s);
-
- s = getenv("LNET_LIVE_ROUTER_CHECK_INTERVAL");
- if (s != NULL)
- live_router_check_interval = atoi(s);
-
- s = getenv("LNET_DEAD_ROUTER_CHECK_INTERVAL");
- if (s != NULL)
- dead_router_check_interval = atoi(s);
-
- /* This replaces old lnd_notify mechanism */
- check_routers_before_use = 1;
- if (dead_router_check_interval <= 0)
- dead_router_check_interval = 30;
-}
-
-void
-lnet_rtrpools_free(void)
-{
-}
-
-int
-lnet_rtrpools_alloc(int im_a_arouter)
-{
- return 0;
-}
-
-#endif
diff --git a/kernel/drivers/staging/lustre/lnet/lnet/router_proc.c b/kernel/drivers/staging/lustre/lnet/lnet/router_proc.c
index c055afc86..396c7c4e5 100644
--- a/kernel/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/kernel/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -25,24 +25,9 @@
#include "../../include/linux/libcfs/libcfs.h"
#include "../../include/linux/lnet/lib-lnet.h"
-#if defined(LNET_ROUTER)
-
/* This is really lnet_proc.c. You might need to update sanity test 215
* if any file format is changed. */
-static struct ctl_table_header *lnet_table_header;
-
-#define CTL_LNET (0x100)
-enum {
- PSDEV_LNET_STATS = 100,
- PSDEV_LNET_ROUTES,
- PSDEV_LNET_ROUTERS,
- PSDEV_LNET_PEERS,
- PSDEV_LNET_BUFFERS,
- PSDEV_LNET_NIS,
- PSDEV_LNET_PTL_ROTOR,
-};
-
#define LNET_LOFFT_BITS (sizeof(loff_t) * 8)
/*
* NB: max allowed LNET_CPT_BITS is 8 on 64-bit system and 2 on 32-bit system
@@ -112,11 +97,11 @@ static int proc_call_handler(void *data, int write, loff_t *ppos,
static int __proc_lnet_stats(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
- int rc;
+ int rc;
lnet_counters_t *ctrs;
- int len;
- char *tmpstr;
- const int tmpsiz = 256; /* 7 %u and 4 %llu */
+ int len;
+ char *tmpstr;
+ const int tmpsiz = 256; /* 7 %u and 4 %llu */
if (write) {
lnet_counters_reset();
@@ -167,13 +152,13 @@ static int proc_lnet_stats(struct ctl_table *table, int write,
static int proc_lnet_routes(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- const int tmpsiz = 256;
- char *tmpstr;
- char *s;
- int rc = 0;
- int len;
- int ver;
- int off;
+ const int tmpsiz = 256;
+ char *tmpstr;
+ char *s;
+ int rc = 0;
+ int len;
+ int ver;
+ int off;
CLASSERT(sizeof(loff_t) >= 4);
@@ -205,13 +190,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
lnet_net_unlock(0);
*ppos = LNET_PROC_POS_MAKE(0, ver, 0, off);
} else {
- struct list_head *n;
- struct list_head *r;
- lnet_route_t *route = NULL;
- lnet_remotenet_t *rnet = NULL;
- int skip = off - 1;
- struct list_head *rn_list;
- int i;
+ struct list_head *n;
+ struct list_head *r;
+ lnet_route_t *route = NULL;
+ lnet_remotenet_t *rnet = NULL;
+ int skip = off - 1;
+ struct list_head *rn_list;
+ int i;
lnet_net_lock(0);
@@ -251,11 +236,11 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
}
if (route != NULL) {
- __u32 net = rnet->lrn_net;
- unsigned int hops = route->lr_hops;
- unsigned int priority = route->lr_priority;
- lnet_nid_t nid = route->lr_gateway->lp_nid;
- int alive = route->lr_gateway->lp_alive;
+ __u32 net = rnet->lrn_net;
+ unsigned int hops = route->lr_hops;
+ unsigned int priority = route->lr_priority;
+ lnet_nid_t nid = route->lr_gateway->lp_nid;
+ int alive = route->lr_gateway->lp_alive;
s += snprintf(s, tmpstr + tmpsiz - s,
"%-8s %4u %8u %7s %s\n",
@@ -293,13 +278,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
static int proc_lnet_routers(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- int rc = 0;
- char *tmpstr;
- char *s;
- const int tmpsiz = 256;
- int len;
- int ver;
- int off;
+ int rc = 0;
+ char *tmpstr;
+ char *s;
+ const int tmpsiz = 256;
+ int len;
+ int ver;
+ int off;
off = LNET_PROC_HOFF_GET(*ppos);
ver = LNET_PROC_VER_GET(*ppos);
@@ -328,9 +313,9 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
lnet_net_unlock(0);
*ppos = LNET_PROC_POS_MAKE(0, ver, 0, off);
} else {
- struct list_head *r;
- struct lnet_peer *peer = NULL;
- int skip = off - 1;
+ struct list_head *r;
+ struct lnet_peer *peer = NULL;
+ int skip = off - 1;
lnet_net_lock(0);
@@ -360,14 +345,14 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
lnet_nid_t nid = peer->lp_nid;
unsigned long now = cfs_time_current();
unsigned long deadline = peer->lp_ping_deadline;
- int nrefs = peer->lp_refcount;
- int nrtrrefs = peer->lp_rtr_refcount;
+ int nrefs = peer->lp_refcount;
+ int nrtrrefs = peer->lp_rtr_refcount;
int alive_cnt = peer->lp_alive_count;
- int alive = peer->lp_alive;
- int pingsent = !peer->lp_ping_notsent;
+ int alive = peer->lp_alive;
+ int pingsent = !peer->lp_ping_notsent;
int last_ping = cfs_duration_sec(cfs_time_sub(now,
peer->lp_ping_timestamp));
- int down_ni = 0;
+ int down_ni = 0;
lnet_route_t *rtr;
if ((peer->lp_ping_feats &
@@ -428,16 +413,16 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
static int proc_lnet_peers(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- const int tmpsiz = 256;
- struct lnet_peer_table *ptable;
- char *tmpstr;
- char *s;
- int cpt = LNET_PROC_CPT_GET(*ppos);
- int ver = LNET_PROC_VER_GET(*ppos);
- int hash = LNET_PROC_HASH_GET(*ppos);
- int hoff = LNET_PROC_HOFF_GET(*ppos);
- int rc = 0;
- int len;
+ const int tmpsiz = 256;
+ struct lnet_peer_table *ptable;
+ char *tmpstr;
+ char *s;
+ int cpt = LNET_PROC_CPT_GET(*ppos);
+ int ver = LNET_PROC_VER_GET(*ppos);
+ int hash = LNET_PROC_HASH_GET(*ppos);
+ int hoff = LNET_PROC_HOFF_GET(*ppos);
+ int rc = 0;
+ int len;
CLASSERT(LNET_PROC_HASH_BITS >= LNET_PEER_HASH_BITS);
LASSERT(!write);
@@ -465,9 +450,9 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
hoff++;
} else {
- struct lnet_peer *peer;
- struct list_head *p;
- int skip;
+ struct lnet_peer *peer;
+ struct list_head *p;
+ int skip;
again:
p = NULL;
peer = NULL;
@@ -521,23 +506,23 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
}
if (peer != NULL) {
- lnet_nid_t nid = peer->lp_nid;
- int nrefs = peer->lp_refcount;
- int lastalive = -1;
- char *aliveness = "NA";
- int maxcr = peer->lp_ni->ni_peertxcredits;
- int txcr = peer->lp_txcredits;
- int mintxcr = peer->lp_mintxcredits;
- int rtrcr = peer->lp_rtrcredits;
- int minrtrcr = peer->lp_minrtrcredits;
- int txqnob = peer->lp_txqnob;
+ lnet_nid_t nid = peer->lp_nid;
+ int nrefs = peer->lp_refcount;
+ int lastalive = -1;
+ char *aliveness = "NA";
+ int maxcr = peer->lp_ni->ni_peertxcredits;
+ int txcr = peer->lp_txcredits;
+ int mintxcr = peer->lp_mintxcredits;
+ int rtrcr = peer->lp_rtrcredits;
+ int minrtrcr = peer->lp_minrtrcredits;
+ int txqnob = peer->lp_txqnob;
if (lnet_isrouter(peer) ||
lnet_peer_aliveness_enabled(peer))
aliveness = peer->lp_alive ? "up" : "down";
if (lnet_peer_aliveness_enabled(peer)) {
- unsigned long now = cfs_time_current();
+ unsigned long now = cfs_time_current();
long delta;
delta = cfs_time_sub(now, peer->lp_last_alive);
@@ -595,13 +580,13 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
static int __proc_lnet_buffers(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
- char *s;
- char *tmpstr;
- int tmpsiz;
- int idx;
- int len;
- int rc;
- int i;
+ char *s;
+ char *tmpstr;
+ int tmpsiz;
+ int idx;
+ int len;
+ int rc;
+ int i;
LASSERT(!write);
@@ -660,11 +645,11 @@ static int proc_lnet_buffers(struct ctl_table *table, int write,
static int proc_lnet_nis(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- int tmpsiz = 128 * LNET_CPT_NUMBER;
- int rc = 0;
- char *tmpstr;
- char *s;
- int len;
+ int tmpsiz = 128 * LNET_CPT_NUMBER;
+ int rc = 0;
+ char *tmpstr;
+ char *s;
+ int len;
LASSERT(!write);
@@ -684,9 +669,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
"rtr", "max", "tx", "min");
LASSERT(tmpstr + tmpsiz - s > 0);
} else {
- struct list_head *n;
- lnet_ni_t *ni = NULL;
- int skip = *ppos - 1;
+ struct list_head *n;
+ lnet_ni_t *ni = NULL;
+ int skip = *ppos - 1;
lnet_net_lock(0);
@@ -705,12 +690,12 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
}
if (ni != NULL) {
- struct lnet_tx_queue *tq;
- char *stat;
- long now = get_seconds();
- int last_alive = -1;
- int i;
- int j;
+ struct lnet_tx_queue *tq;
+ char *stat;
+ time64_t now = ktime_get_real_seconds();
+ int last_alive = -1;
+ int i;
+ int j;
if (the_lnet.ln_routing)
last_alive = now - ni->ni_last_alive;
@@ -777,9 +762,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
}
struct lnet_portal_rotors {
- int pr_value;
- const char *pr_name;
- const char *pr_desc;
+ int pr_value;
+ const char *pr_name;
+ const char *pr_desc;
};
static struct lnet_portal_rotors portal_rotors[] = {
@@ -815,11 +800,11 @@ extern int portal_rotor;
static int __proc_lnet_portal_rotor(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
- const int buf_len = 128;
- char *buf;
- char *tmp;
- int rc;
- int i;
+ const int buf_len = 128;
+ char *buf;
+ char *tmp;
+ int rc;
+ int i;
LIBCFS_ALLOC(buf, buf_len);
if (buf == NULL)
@@ -887,82 +872,49 @@ static struct ctl_table lnet_table[] = {
* to go via /proc for portability.
*/
{
- .procname = "stats",
- .mode = 0644,
+ .procname = "stats",
+ .mode = 0644,
.proc_handler = &proc_lnet_stats,
},
{
- .procname = "routes",
- .mode = 0444,
+ .procname = "routes",
+ .mode = 0444,
.proc_handler = &proc_lnet_routes,
},
{
- .procname = "routers",
- .mode = 0444,
+ .procname = "routers",
+ .mode = 0444,
.proc_handler = &proc_lnet_routers,
},
{
- .procname = "peers",
- .mode = 0444,
+ .procname = "peers",
+ .mode = 0444,
.proc_handler = &proc_lnet_peers,
},
{
- .procname = "buffers",
- .mode = 0444,
+ .procname = "buffers",
+ .mode = 0444,
.proc_handler = &proc_lnet_buffers,
},
{
- .procname = "nis",
- .mode = 0444,
+ .procname = "nis",
+ .mode = 0444,
.proc_handler = &proc_lnet_nis,
},
{
- .procname = "portal_rotor",
- .mode = 0644,
+ .procname = "portal_rotor",
+ .mode = 0644,
.proc_handler = &proc_lnet_portal_rotor,
},
{
}
};
-static struct ctl_table top_table[] = {
- {
- .procname = "lnet",
- .mode = 0555,
- .data = NULL,
- .maxlen = 0,
- .child = lnet_table,
- },
- {
- }
-};
-
-void
-lnet_proc_init(void)
+void lnet_router_debugfs_init(void)
{
- if (lnet_table_header == NULL)
- lnet_table_header = register_sysctl_table(top_table);
+ lustre_insert_debugfs(lnet_table, NULL);
}
-void
-lnet_proc_fini(void)
-{
- if (lnet_table_header != NULL)
- unregister_sysctl_table(lnet_table_header);
-
- lnet_table_header = NULL;
-}
-
-#else
-
-void
-lnet_proc_init(void)
+void lnet_router_debugfs_fini(void)
{
}
-
-void
-lnet_proc_fini(void)
-{
-}
-
-#endif
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/brw_test.c b/kernel/drivers/staging/lustre/lnet/selftest/brw_test.c
index 658f4584f..0605c651f 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/brw_test.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/brw_test.c
@@ -91,7 +91,7 @@ brw_client_init(sfw_test_instance_t *tsi)
len = npg * PAGE_CACHE_SIZE;
} else {
- test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
+ test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
/* I should never get this step if it's unknown feature
* because make_session will reject unknown feature */
@@ -134,14 +134,14 @@ brw_client_init(sfw_test_instance_t *tsi)
static int
brw_inject_one_error(void)
{
- struct timeval tv;
+ struct timespec64 ts;
if (brw_inject_errors <= 0)
return 0;
- do_gettimeofday(&tv);
+ ktime_get_ts64(&ts);
- if ((tv.tv_usec & 1) == 0)
+ if (((ts.tv_nsec / NSEC_PER_USEC) & 1) == 0)
return 0;
return brw_inject_errors--;
@@ -223,7 +223,7 @@ bad_data:
static void
brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
{
- int i;
+ int i;
struct page *pg;
for (i = 0; i < bk->bk_niov; i++) {
@@ -235,7 +235,7 @@ brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
static int
brw_check_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
{
- int i;
+ int i;
struct page *pg;
for (i = 0; i < bk->bk_niov; i++) {
@@ -254,16 +254,16 @@ static int
brw_client_prep_rpc(sfw_test_unit_t *tsu,
lnet_process_id_t dest, srpc_client_rpc_t **rpcpp)
{
- srpc_bulk_t *bulk = tsu->tsu_private;
+ srpc_bulk_t *bulk = tsu->tsu_private;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- srpc_client_rpc_t *rpc;
- srpc_brw_reqst_t *req;
- int flags;
- int npg;
- int len;
- int opc;
- int rc;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ srpc_client_rpc_t *rpc;
+ srpc_brw_reqst_t *req;
+ int flags;
+ int npg;
+ int len;
+ int opc;
+ int rc;
LASSERT(sn != NULL);
LASSERT(bulk != NULL);
@@ -277,7 +277,7 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu,
len = npg * PAGE_CACHE_SIZE;
} else {
- test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
+ test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
/* I should never get this step if it's unknown feature
* because make_session will reject unknown feature */
@@ -311,12 +311,12 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu,
static void
brw_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
{
- __u64 magic = BRW_MAGIC;
+ __u64 magic = BRW_MAGIC;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- srpc_msg_t *msg = &rpc->crpc_replymsg;
- srpc_brw_reply_t *reply = &msg->msg_body.brw_reply;
- srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ srpc_msg_t *msg = &rpc->crpc_replymsg;
+ srpc_brw_reply_t *reply = &msg->msg_body.brw_reply;
+ srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst;
LASSERT(sn != NULL);
@@ -380,10 +380,10 @@ brw_server_rpc_done(srpc_server_rpc_t *rpc)
static int
brw_bulk_ready(srpc_server_rpc_t *rpc, int status)
{
- __u64 magic = BRW_MAGIC;
+ __u64 magic = BRW_MAGIC;
srpc_brw_reply_t *reply = &rpc->srpc_replymsg.msg_body.brw_reply;
srpc_brw_reqst_t *reqst;
- srpc_msg_t *reqstmsg;
+ srpc_msg_t *reqstmsg;
LASSERT(rpc->srpc_bulk != NULL);
LASSERT(rpc->srpc_reqstbuf != NULL);
@@ -416,13 +416,13 @@ brw_bulk_ready(srpc_server_rpc_t *rpc, int status)
static int
brw_server_handle(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- srpc_msg_t *replymsg = &rpc->srpc_replymsg;
- srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ srpc_msg_t *replymsg = &rpc->srpc_replymsg;
+ srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
srpc_brw_reply_t *reply = &replymsg->msg_body.brw_reply;
srpc_brw_reqst_t *reqst = &reqstmsg->msg_body.brw_reqst;
- int npg;
- int rc;
+ int npg;
+ int rc;
LASSERT(sv->sv_id == SRPC_SERVICE_BRW);
@@ -490,17 +490,17 @@ brw_server_handle(struct srpc_server_rpc *rpc)
sfw_test_client_ops_t brw_test_client;
void brw_init_test_client(void)
{
- brw_test_client.tso_init = brw_client_init;
- brw_test_client.tso_fini = brw_client_fini;
- brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
- brw_test_client.tso_done_rpc = brw_client_done_rpc;
+ brw_test_client.tso_init = brw_client_init;
+ brw_test_client.tso_fini = brw_client_fini;
+ brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
+ brw_test_client.tso_done_rpc = brw_client_done_rpc;
};
srpc_service_t brw_test_service;
void brw_init_test_service(void)
{
- brw_test_service.sv_id = SRPC_SERVICE_BRW;
+ brw_test_service.sv_id = SRPC_SERVICE_BRW;
brw_test_service.sv_name = "brw_test";
brw_test_service.sv_handler = brw_server_handle;
brw_test_service.sv_bulk_ready = brw_bulk_ready;
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/conctl.c b/kernel/drivers/staging/lustre/lnet/selftest/conctl.c
index 045fe295a..556c837cf 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -48,11 +48,11 @@
static int
lst_session_new_ioctl(lstio_session_new_args_t *args)
{
- char *name;
- int rc;
+ char *name;
+ int rc;
if (args->lstio_ses_idp == NULL || /* address for output sid */
- args->lstio_ses_key == 0 || /* no key is specified */
+ args->lstio_ses_key == 0 || /* no key is specified */
args->lstio_ses_namep == NULL || /* session name */
args->lstio_ses_nmlen <= 0 ||
args->lstio_ses_nmlen > LST_NAME_SIZE)
@@ -96,12 +96,12 @@ lst_session_info_ioctl(lstio_session_info_args_t *args)
{
/* no checking of key */
- if (args->lstio_ses_idp == NULL || /* address for output sid */
- args->lstio_ses_keyp == NULL || /* address for output key */
+ if (args->lstio_ses_idp == NULL || /* address for output sid */
+ args->lstio_ses_keyp == NULL || /* address for output key */
args->lstio_ses_featp == NULL || /* address for output features */
args->lstio_ses_ndinfo == NULL || /* address for output ndinfo */
- args->lstio_ses_namep == NULL || /* address for output name */
- args->lstio_ses_nmlen <= 0 ||
+ args->lstio_ses_namep == NULL || /* address for output name */
+ args->lstio_ses_nmlen <= 0 ||
args->lstio_ses_nmlen > LST_NAME_SIZE)
return -EINVAL;
@@ -197,8 +197,8 @@ out:
static int
lst_group_add_ioctl(lstio_group_add_args_t *args)
{
- char *name;
- int rc;
+ char *name;
+ int rc;
if (args->lstio_grp_key != console_session.ses_key)
return -EACCES;
@@ -324,8 +324,8 @@ static int
lst_nodes_add_ioctl(lstio_group_nodes_args_t *args)
{
unsigned feats;
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_grp_key != console_session.ses_key)
return -EACCES;
@@ -385,10 +385,10 @@ lst_group_list_ioctl(lstio_group_list_args_t *args)
static int
lst_group_info_ioctl(lstio_group_info_args_t *args)
{
- char *name;
- int ndent;
- int index;
- int rc;
+ char *name;
+ int ndent;
+ int index;
+ int rc;
if (args->lstio_grp_key != console_session.ses_key)
return -EACCES;
@@ -441,7 +441,7 @@ lst_group_info_ioctl(lstio_group_info_args_t *args)
if (args->lstio_grp_dentsp != NULL &&
(copy_to_user(args->lstio_grp_idxp, &index, sizeof(index)) ||
copy_to_user(args->lstio_grp_ndentp, &ndent, sizeof(ndent))))
- rc = -EFAULT;
+ return -EFAULT;
return 0;
}
@@ -449,8 +449,8 @@ lst_group_info_ioctl(lstio_group_info_args_t *args)
static int
lst_batch_add_ioctl(lstio_batch_add_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -483,8 +483,8 @@ lst_batch_add_ioctl(lstio_batch_add_args_t *args)
static int
lst_batch_run_ioctl(lstio_batch_run_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -518,8 +518,8 @@ lst_batch_run_ioctl(lstio_batch_run_args_t *args)
static int
lst_batch_stop_ioctl(lstio_batch_stop_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -613,10 +613,10 @@ lst_batch_list_ioctl(lstio_batch_list_args_t *args)
static int
lst_batch_info_ioctl(lstio_batch_info_args_t *args)
{
- char *name;
- int rc;
- int index;
- int ndent;
+ char *name;
+ int rc;
+ int index;
+ int ndent;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -678,8 +678,8 @@ lst_batch_info_ioctl(lstio_batch_info_args_t *args)
static int
lst_stat_query_ioctl(lstio_stat_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
/* TODO: not finished */
if (args->lstio_sta_key != console_session.ses_key)
@@ -837,7 +837,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data)
mutex_lock(&console_session.ses_mutex);
- console_session.ses_laststamp = get_seconds();
+ console_session.ses_laststamp = ktime_get_real_seconds();
if (console_session.ses_shutdown) {
rc = -ESHUTDOWN;
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/conrpc.c b/kernel/drivers/staging/lustre/lnet/selftest/conrpc.c
index 77f02b761..64a033593 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -40,7 +40,6 @@
* Author: Liang Zhen <liang@whamcloud.com>
*/
-
#include "../../include/linux/libcfs/libcfs.h"
#include "../../include/linux/lnet/lib-lnet.h"
#include "timer.h"
@@ -117,8 +116,8 @@ static int
lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
int bulk_npg, int bulk_len, lstcon_rpc_t **crpcpp)
{
- lstcon_rpc_t *crpc = NULL;
- int rc;
+ lstcon_rpc_t *crpc = NULL;
+ int rc;
spin_lock(&console_session.ses_rpc_lock);
@@ -151,7 +150,7 @@ void
lstcon_rpc_put(lstcon_rpc_t *crpc)
{
srpc_bulk_t *bulk = &crpc->crp_rpc->crpc_bulk;
- int i;
+ int i;
LASSERT(list_empty(&crpc->crp_link));
@@ -336,8 +335,8 @@ lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
int
lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
{
- lstcon_rpc_t *crpc;
- int rc;
+ lstcon_rpc_t *crpc;
+ int rc;
if (list_empty(&trans->tas_rpcs_list))
return 0;
@@ -386,8 +385,8 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
static int
lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
{
- lstcon_node_t *nd = crpc->crp_node;
- srpc_client_rpc_t *rpc = crpc->crp_rpc;
+ lstcon_node_t *nd = crpc->crp_node;
+ srpc_client_rpc_t *rpc = crpc->crp_rpc;
srpc_generic_reply_t *rep;
LASSERT(nd != NULL && rpc != NULL);
@@ -423,9 +422,9 @@ lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
void
lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
{
- lstcon_rpc_t *crpc;
- srpc_msg_t *rep;
- int error;
+ lstcon_rpc_t *crpc;
+ srpc_msg_t *rep;
+ int error;
LASSERT(stat != NULL);
@@ -470,16 +469,16 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
struct list_head *head_up,
lstcon_rpc_readent_func_t readent)
{
- struct list_head tmp;
- struct list_head *next;
- lstcon_rpc_ent_t *ent;
+ struct list_head tmp;
+ struct list_head *next;
+ lstcon_rpc_ent_t *ent;
srpc_generic_reply_t *rep;
- lstcon_rpc_t *crpc;
- srpc_msg_t *msg;
- lstcon_node_t *nd;
- long dur;
- struct timeval tv;
- int error;
+ lstcon_rpc_t *crpc;
+ srpc_msg_t *msg;
+ lstcon_node_t *nd;
+ long dur;
+ struct timeval tv;
+ int error;
LASSERT(head_up != NULL);
@@ -505,7 +504,7 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
dur = (long)cfs_time_sub(crpc->crp_stamp,
(unsigned long)console_session.ses_id.ses_stamp);
- cfs_duration_usec(dur, &tv);
+ jiffies_to_timeval(dur, &tv);
if (copy_to_user(&ent->rpe_peer,
&nd->nd_id, sizeof(lnet_process_id_t)) ||
@@ -544,9 +543,9 @@ void
lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
{
srpc_client_rpc_t *rpc;
- lstcon_rpc_t *crpc;
- lstcon_rpc_t *tmp;
- int count = 0;
+ lstcon_rpc_t *crpc;
+ lstcon_rpc_t *tmp;
+ int count = 0;
list_for_each_entry_safe(crpc, tmp, &trans->tas_rpcs_list,
crp_link) {
@@ -601,7 +600,7 @@ lstcon_sesrpc_prep(lstcon_node_t *nd, int transop,
{
srpc_mksn_reqst_t *msrq;
srpc_rmsn_reqst_t *rsrq;
- int rc;
+ int rc;
switch (transop) {
case LST_TRANS_SESNEW:
@@ -638,7 +637,7 @@ int
lstcon_dbgrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
{
srpc_debug_reqst_t *drq;
- int rc;
+ int rc;
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_DEBUG, feats, 0, 0, crpc);
if (rc != 0)
@@ -707,7 +706,7 @@ static lnet_process_id_packed_t *
lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov)
{
lnet_process_id_packed_t *pid;
- int i;
+ int i;
i = idx / SFW_ID_PER_PAGE;
@@ -723,11 +722,11 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
int dist, int span, int nkiov, lnet_kiov_t *kiov)
{
lnet_process_id_packed_t *pid;
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- int start;
- int end;
- int i = 0;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ int start;
+ int end;
+ int i = 0;
LASSERT(dist >= 1);
LASSERT(span >= 1);
@@ -777,8 +776,8 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req)
{
test_ping_req_t *prq = &req->tsr_u.ping;
- prq->png_size = param->png_size;
- prq->png_flags = param->png_flags;
+ prq->png_size = param->png_size;
+ prq->png_flags = param->png_flags;
/* TODO dest */
return 0;
}
@@ -788,9 +787,10 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
{
test_bulk_req_t *brq = &req->tsr_u.bulk_v0;
- brq->blk_opc = param->blk_opc;
- brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE;
- brq->blk_flags = param->blk_flags;
+ brq->blk_opc = param->blk_opc;
+ brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) /
+ PAGE_CACHE_SIZE;
+ brq->blk_flags = param->blk_flags;
return 0;
}
@@ -816,7 +816,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
lstcon_group_t *dgrp = test->tes_dst_grp;
srpc_test_reqst_t *trq;
srpc_bulk_t *bulk;
- int i;
+ int i;
int npg = 0;
int nob = 0;
int rc = 0;
@@ -835,8 +835,10 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
trq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.tes_reqst;
if (transop == LST_TRANS_TSBSRVADD) {
- int ndist = (sgrp->grp_nnode + test->tes_dist - 1) / test->tes_dist;
- int nspan = (dgrp->grp_nnode + test->tes_span - 1) / test->tes_span;
+ int ndist = (sgrp->grp_nnode + test->tes_dist - 1) /
+ test->tes_dist;
+ int nspan = (dgrp->grp_nnode + test->tes_span - 1) /
+ test->tes_span;
int nmax = (ndist + nspan - 1) / nspan;
trq->tsr_ndest = 0;
@@ -851,13 +853,14 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
LASSERT(nob > 0);
len = (feats & LST_FEAT_BULK_LEN) == 0 ?
- PAGE_CACHE_SIZE : min_t(int, nob, PAGE_CACHE_SIZE);
+ PAGE_CACHE_SIZE :
+ min_t(int, nob, PAGE_CACHE_SIZE);
nob -= len;
bulk->bk_iovs[i].kiov_offset = 0;
bulk->bk_iovs[i].kiov_len = len;
bulk->bk_iovs[i].kiov_page =
- alloc_page(GFP_IOFS);
+ alloc_page(GFP_KERNEL);
if (bulk->bk_iovs[i].kiov_page == NULL) {
lstcon_rpc_put(*crpc);
@@ -883,8 +886,8 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
trq->tsr_loop = test->tes_loop;
}
- trq->tsr_sid = console_session.ses_id;
- trq->tsr_bid = test->tes_hdr.tsb_id;
+ trq->tsr_sid = console_session.ses_id;
+ trq->tsr_bid = test->tes_hdr.tsb_id;
trq->tsr_concur = test->tes_concur;
trq->tsr_is_client = (transop == LST_TRANS_TSBCLIADD) ? 1 : 0;
trq->tsr_stop_onerr = !!test->tes_stop_onerr;
@@ -966,7 +969,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
srpc_batch_reply_t *bat_rep;
srpc_test_reply_t *test_rep;
srpc_stat_reply_t *stat_rep;
- int rc = 0;
+ int rc = 0;
switch (trans->tas_opc) {
case LST_TRANS_SESNEW:
@@ -1084,11 +1087,11 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
lstcon_rpc_trans_t **transpp)
{
lstcon_rpc_trans_t *trans;
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- lstcon_rpc_t *rpc;
- unsigned feats;
- int rc;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ lstcon_rpc_t *rpc;
+ unsigned feats;
+ int rc;
/* Creating session RPG for list of nodes */
@@ -1165,16 +1168,16 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
static void
lstcon_rpc_pinger(void *arg)
{
- stt_timer_t *ptimer = (stt_timer_t *)arg;
+ stt_timer_t *ptimer = (stt_timer_t *)arg;
lstcon_rpc_trans_t *trans;
- lstcon_rpc_t *crpc;
- srpc_msg_t *rep;
+ lstcon_rpc_t *crpc;
+ srpc_msg_t *rep;
srpc_debug_reqst_t *drq;
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- time_t intv;
- int count = 0;
- int rc;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ int intv;
+ int count = 0;
+ int rc;
/* RPC pinger is a special case of transaction,
* it's called by timer at 8 seconds interval.
@@ -1187,8 +1190,8 @@ lstcon_rpc_pinger(void *arg)
}
if (!console_session.ses_expired &&
- get_seconds() - console_session.ses_laststamp >
- (time_t)console_session.ses_timeout)
+ ktime_get_real_seconds() - console_session.ses_laststamp >
+ (time64_t)console_session.ses_timeout)
console_session.ses_expired = 1;
trans = console_session.ses_ping;
@@ -1244,9 +1247,8 @@ lstcon_rpc_pinger(void *arg)
if (nd->nd_state != LST_NODE_ACTIVE)
continue;
- intv = cfs_duration_sec(cfs_time_sub(cfs_time_current(),
- nd->nd_stamp));
- if (intv < (time_t)nd->nd_timeout / 2)
+ intv = (jiffies - nd->nd_stamp) / HZ;
+ if (intv < nd->nd_timeout / 2)
continue;
rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
@@ -1274,7 +1276,7 @@ lstcon_rpc_pinger(void *arg)
CDEBUG(D_NET, "Ping %d nodes in session\n", count);
- ptimer->stt_expires = (unsigned long)(get_seconds() + LST_PING_INTERVAL);
+ ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL;
stt_add_timer(ptimer);
mutex_unlock(&console_session.ses_mutex);
@@ -1283,8 +1285,8 @@ lstcon_rpc_pinger(void *arg)
int
lstcon_rpc_pinger_start(void)
{
- stt_timer_t *ptimer;
- int rc;
+ stt_timer_t *ptimer;
+ int rc;
LASSERT(list_empty(&console_session.ses_rpc_freelist));
LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
@@ -1297,7 +1299,7 @@ lstcon_rpc_pinger_start(void)
}
ptimer = &console_session.ses_ping_timer;
- ptimer->stt_expires = (unsigned long)(get_seconds() + LST_PING_INTERVAL);
+ ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL;
stt_add_timer(ptimer);
@@ -1324,9 +1326,9 @@ void
lstcon_rpc_cleanup_wait(void)
{
lstcon_rpc_trans_t *trans;
- lstcon_rpc_t *crpc;
- struct list_head *pacer;
- struct list_head zlist;
+ lstcon_rpc_t *crpc;
+ struct list_head *pacer;
+ struct list_head zlist;
/* Called with hold of global mutex */
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/conrpc.h b/kernel/drivers/staging/lustre/lnet/selftest/conrpc.h
index 2353889c6..95c832ff7 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/conrpc.h
+++ b/kernel/drivers/staging/lustre/lnet/selftest/conrpc.h
@@ -64,31 +64,29 @@ struct lstcon_test;
struct lstcon_node;
typedef struct lstcon_rpc {
- struct list_head crp_link; /* chain on rpc transaction */
+ struct list_head crp_link; /* chain on rpc transaction */
srpc_client_rpc_t *crp_rpc; /* client rpc */
- struct lstcon_node *crp_node; /* destination node */
+ struct lstcon_node *crp_node; /* destination node */
struct lstcon_rpc_trans *crp_trans; /* conrpc transaction */
- unsigned int crp_posted:1; /* rpc is posted */
- unsigned int crp_finished:1; /* rpc is finished */
- unsigned int crp_unpacked:1; /* reply is unpacked */
+ unsigned int crp_posted:1; /* rpc is posted */
+ unsigned int crp_finished:1; /* rpc is finished */
+ unsigned int crp_unpacked:1; /* reply is unpacked */
/** RPC is embedded in other structure and can't free it */
- unsigned int crp_embedded:1;
- int crp_status; /* console rpc errors */
- unsigned long crp_stamp; /* replied time stamp */
+ unsigned int crp_embedded:1;
+ int crp_status; /* console rpc errors */
+ unsigned long crp_stamp; /* replied time stamp */
} lstcon_rpc_t;
typedef struct lstcon_rpc_trans {
- struct list_head tas_olink; /* link chain on owner list */
- struct list_head tas_link; /* link chain on global list */
- int tas_opc; /* operation code of transaction */
- /* features mask is uptodate */
- unsigned tas_feats_updated;
- /* test features mask */
- unsigned tas_features;
- wait_queue_head_t tas_waitq; /* wait queue head */
- atomic_t tas_remaining; /* # of un-scheduled rpcs */
- struct list_head tas_rpcs_list; /* queued requests */
+ struct list_head tas_olink; /* link chain on owner list */
+ struct list_head tas_link; /* link chain on global list */
+ int tas_opc; /* operation code of transaction */
+ unsigned tas_feats_updated; /* features mask is uptodate */
+ unsigned tas_features; /* test features mask */
+ wait_queue_head_t tas_waitq; /* wait queue head */
+ atomic_t tas_remaining; /* # of un-scheduled rpcs */
+ struct list_head tas_rpcs_list; /* queued requests */
} lstcon_rpc_trans_t;
#define LST_TRANS_PRIVATE 0x1000
@@ -107,8 +105,8 @@ typedef struct lstcon_rpc_trans {
#define LST_TRANS_STATQRY 0x21
-typedef int (* lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
-typedef int (* lstcon_rpc_readent_func_t)(int, srpc_msg_t *, lstcon_rpc_ent_t *);
+typedef int (*lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
+typedef int (*lstcon_rpc_readent_func_t)(int, srpc_msg_t *, lstcon_rpc_ent_t *);
int lstcon_sesrpc_prep(struct lstcon_node *nd, int transop,
unsigned version, lstcon_rpc_t **crpc);
@@ -142,5 +140,4 @@ void lstcon_rpc_cleanup_wait(void);
int lstcon_rpc_module_init(void);
void lstcon_rpc_module_fini(void);
-
#endif
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/console.c b/kernel/drivers/staging/lustre/lnet/selftest/console.c
index 2b5f53c7a..d315dd44a 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/console.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/console.c
@@ -40,7 +40,6 @@
* Author: Liang Zhen <liangzhen@clusterfs.com>
*/
-
#include "../../include/linux/libcfs/libcfs.h"
#include "../../include/linux/lnet/lib-lnet.h"
#include "console.h"
@@ -59,7 +58,7 @@ do { \
(p)->nle_nnode++; \
} while (0)
-lstcon_session_t console_session;
+lstcon_session_t console_session;
static void
lstcon_node_get(lstcon_node_t *nd)
@@ -73,7 +72,7 @@ static int
lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create)
{
lstcon_ndlink_t *ndl;
- unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE;
+ unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE;
LASSERT(id.nid != LNET_NID_ANY);
@@ -117,7 +116,7 @@ lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create)
static void
lstcon_node_put(lstcon_node_t *nd)
{
- lstcon_ndlink_t *ndl;
+ lstcon_ndlink_t *ndl;
LASSERT(nd->nd_ref > 0);
@@ -140,10 +139,10 @@ static int
lstcon_ndlink_find(struct list_head *hash,
lnet_process_id_t id, lstcon_ndlink_t **ndlpp, int create)
{
- unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
+ unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- int rc;
+ lstcon_node_t *nd;
+ int rc;
if (id.nid == LNET_NID_ANY)
return -EINVAL;
@@ -197,7 +196,7 @@ static int
lstcon_group_alloc(char *name, lstcon_group_t **grpp)
{
lstcon_group_t *grp;
- int i;
+ int i;
LIBCFS_ALLOC(grp, offsetof(lstcon_group_t,
grp_ndl_hash[LST_NODE_HASHSIZE]));
@@ -243,7 +242,7 @@ lstcon_group_drain(lstcon_group_t *grp, int keep)
static void
lstcon_group_decref(lstcon_group_t *grp)
{
- int i;
+ int i;
if (--grp->grp_ref > 0)
return;
@@ -264,7 +263,7 @@ lstcon_group_decref(lstcon_group_t *grp)
static int
lstcon_group_find(const char *name, lstcon_group_t **grpp)
{
- lstcon_group_t *grp;
+ lstcon_group_t *grp;
list_for_each_entry(grp, &console_session.ses_grp_list, grp_link) {
if (strncmp(grp->grp_name, name, LST_NAME_SIZE) != 0)
@@ -288,7 +287,7 @@ static int
lstcon_group_ndlink_find(lstcon_group_t *grp, lnet_process_id_t id,
lstcon_ndlink_t **ndlpp, int create)
{
- int rc;
+ int rc;
rc = lstcon_ndlink_find(&grp->grp_ndl_hash[0], id, ndlpp, create);
if (rc != 0)
@@ -308,7 +307,7 @@ lstcon_group_ndlink_release(lstcon_group_t *grp, lstcon_ndlink_t *ndl)
{
list_del_init(&ndl->ndl_link);
lstcon_ndlink_release(ndl);
- grp->grp_nnode --;
+ grp->grp_nnode--;
}
static void
@@ -320,7 +319,7 @@ lstcon_group_ndlink_move(lstcon_group_t *old,
list_del(&ndl->ndl_hlink);
list_del(&ndl->ndl_link);
- old->grp_nnode --;
+ old->grp_nnode--;
list_add_tail(&ndl->ndl_hlink, &new->grp_ndl_hash[idx]);
list_add_tail(&ndl->ndl_link, &new->grp_ndl_list);
@@ -404,12 +403,12 @@ lstcon_group_nodes_add(lstcon_group_t *grp,
int count, lnet_process_id_t *ids_up,
unsigned *featp, struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_ndlink_t *ndl;
- lstcon_group_t *tmp;
- lnet_process_id_t id;
- int i;
- int rc;
+ lstcon_rpc_trans_t *trans;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *tmp;
+ lnet_process_id_t id;
+ int i;
+ int rc;
rc = lstcon_group_alloc(NULL, &tmp);
if (rc != 0) {
@@ -471,12 +470,12 @@ lstcon_group_nodes_remove(lstcon_group_t *grp,
int count, lnet_process_id_t *ids_up,
struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_ndlink_t *ndl;
- lstcon_group_t *tmp;
- lnet_process_id_t id;
- int rc;
- int i;
+ lstcon_rpc_trans_t *trans;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *tmp;
+ lnet_process_id_t id;
+ int rc;
+ int i;
/* End session and remove node from the group */
@@ -525,9 +524,9 @@ int
lstcon_group_add(char *name)
{
lstcon_group_t *grp;
- int rc;
+ int rc;
- rc = (lstcon_group_find(name, &grp) == 0)? -EEXIST: 0;
+ rc = (lstcon_group_find(name, &grp) == 0) ? -EEXIST : 0;
if (rc != 0) {
/* find a group with same name */
lstcon_group_put(grp);
@@ -549,8 +548,8 @@ int
lstcon_nodes_add(char *name, int count, lnet_process_id_t *ids_up,
unsigned *featp, struct list_head *result_up)
{
- lstcon_group_t *grp;
- int rc;
+ lstcon_group_t *grp;
+ int rc;
LASSERT(count > 0);
LASSERT(ids_up != NULL);
@@ -580,8 +579,8 @@ int
lstcon_group_del(char *name)
{
lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- int rc;
+ lstcon_group_t *grp;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -621,7 +620,7 @@ int
lstcon_group_clean(char *name, int args)
{
lstcon_group_t *grp = NULL;
- int rc;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -654,7 +653,7 @@ lstcon_nodes_remove(char *name, int count,
lnet_process_id_t *ids_up, struct list_head *result_up)
{
lstcon_group_t *grp = NULL;
- int rc;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -682,9 +681,9 @@ lstcon_nodes_remove(char *name, int count,
int
lstcon_group_refresh(char *name, struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- int rc;
+ lstcon_rpc_trans_t *trans;
+ lstcon_group_t *grp;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -743,10 +742,10 @@ static int
lstcon_nodes_getent(struct list_head *head, int *index_p,
int *count_p, lstcon_node_ent_t *dents_up)
{
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- int count = 0;
- int index = 0;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ int count = 0;
+ int index = 0;
LASSERT(index_p != NULL && count_p != NULL);
LASSERT(dents_up != NULL);
@@ -784,9 +783,9 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t *gents_p,
int *index_p, int *count_p, lstcon_node_ent_t *dents_up)
{
lstcon_ndlist_ent_t *gentp;
- lstcon_group_t *grp;
- lstcon_ndlink_t *ndl;
- int rc;
+ lstcon_group_t *grp;
+ lstcon_ndlink_t *ndl;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -816,7 +815,7 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t *gents_p,
LST_NODE_STATE_COUNTER(ndl->ndl_node, gentp);
rc = copy_to_user(gents_p, gentp,
- sizeof(lstcon_ndlist_ent_t)) ? -EFAULT: 0;
+ sizeof(lstcon_ndlist_ent_t)) ? -EFAULT : 0;
LIBCFS_FREE(gentp, sizeof(lstcon_ndlist_ent_t));
@@ -828,7 +827,7 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t *gents_p,
static int
lstcon_batch_find(const char *name, lstcon_batch_t **batpp)
{
- lstcon_batch_t *bat;
+ lstcon_batch_t *bat;
list_for_each_entry(bat, &console_session.ses_bat_list, bat_link) {
if (strncmp(bat->bat_name, name, LST_NAME_SIZE) == 0) {
@@ -843,11 +842,11 @@ lstcon_batch_find(const char *name, lstcon_batch_t **batpp)
int
lstcon_batch_add(char *name)
{
- lstcon_batch_t *bat;
- int i;
- int rc;
+ lstcon_batch_t *bat;
+ int i;
+ int rc;
- rc = (lstcon_batch_find(name, &bat) == 0)? -EEXIST: 0;
+ rc = (lstcon_batch_find(name, &bat) == 0) ? -EEXIST : 0;
if (rc != 0) {
CDEBUG(D_NET, "Batch %s already exists\n", name);
return rc;
@@ -903,7 +902,7 @@ lstcon_batch_add(char *name)
int
lstcon_batch_list(int index, int len, char *name_up)
{
- lstcon_batch_t *bat;
+ lstcon_batch_t *bat;
LASSERT(name_up != NULL);
LASSERT(index >= 0);
@@ -911,7 +910,7 @@ lstcon_batch_list(int index, int len, char *name_up)
list_for_each_entry(bat, &console_session.ses_bat_list, bat_link) {
if (index-- == 0) {
return copy_to_user(name_up, bat->bat_name, len) ?
- -EFAULT: 0;
+ -EFAULT : 0;
}
}
@@ -924,12 +923,12 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up, int server,
lstcon_node_ent_t *dents_up)
{
lstcon_test_batch_ent_t *entp;
- struct list_head *clilst;
- struct list_head *srvlst;
- lstcon_test_t *test = NULL;
- lstcon_batch_t *bat;
- lstcon_ndlink_t *ndl;
- int rc;
+ struct list_head *clilst;
+ struct list_head *srvlst;
+ lstcon_test_t *test = NULL;
+ lstcon_batch_t *bat;
+ lstcon_ndlink_t *ndl;
+ int rc;
rc = lstcon_batch_find(name, &bat);
if (rc != 0) {
@@ -956,7 +955,7 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up, int server,
&test->tes_dst_grp->grp_ndl_list;
if (dents_up != NULL) {
- rc = lstcon_nodes_getent((server ? srvlst: clilst),
+ rc = lstcon_nodes_getent((server ? srvlst : clilst),
index_p, ndent_p, dents_up);
return rc;
}
@@ -1018,7 +1017,7 @@ lstcon_batch_op(lstcon_batch_t *bat, int transop,
struct list_head *result_up)
{
lstcon_rpc_trans_t *trans;
- int rc;
+ int rc;
rc = lstcon_rpc_trans_ndlist(&bat->bat_cli_list,
&bat->bat_trans_list, transop,
@@ -1041,7 +1040,7 @@ int
lstcon_batch_run(char *name, int timeout, struct list_head *result_up)
{
lstcon_batch_t *bat;
- int rc;
+ int rc;
if (lstcon_batch_find(name, &bat) != 0) {
CDEBUG(D_NET, "Can't find batch %s\n", name);
@@ -1063,7 +1062,7 @@ int
lstcon_batch_stop(char *name, int force, struct list_head *result_up)
{
lstcon_batch_t *bat;
- int rc;
+ int rc;
if (lstcon_batch_find(name, &bat) != 0) {
CDEBUG(D_NET, "Can't find batch %s\n", name);
@@ -1084,9 +1083,9 @@ lstcon_batch_stop(char *name, int force, struct list_head *result_up)
static void
lstcon_batch_destroy(lstcon_batch_t *bat)
{
- lstcon_ndlink_t *ndl;
- lstcon_test_t *test;
- int i;
+ lstcon_ndlink_t *ndl;
+ lstcon_test_t *test;
+ int i;
list_del(&bat->bat_link);
@@ -1137,11 +1136,11 @@ lstcon_batch_destroy(lstcon_batch_t *bat)
static int
lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg)
{
- lstcon_test_t *test;
- lstcon_batch_t *batch;
- lstcon_ndlink_t *ndl;
- struct list_head *hash;
- struct list_head *head;
+ lstcon_test_t *test;
+ lstcon_batch_t *batch;
+ lstcon_ndlink_t *ndl;
+ struct list_head *hash;
+ struct list_head *head;
test = (lstcon_test_t *)arg;
LASSERT(test != NULL);
@@ -1181,10 +1180,10 @@ lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg)
static int
lstcon_test_nodes_add(lstcon_test_t *test, struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- int transop;
- int rc;
+ lstcon_rpc_trans_t *trans;
+ lstcon_group_t *grp;
+ int transop;
+ int rc;
LASSERT(test->tes_src_grp != NULL);
LASSERT(test->tes_dst_grp != NULL);
@@ -1251,8 +1250,8 @@ lstcon_verify_batch(const char *name, lstcon_batch_t **batch)
static int
lstcon_verify_group(const char *name, lstcon_group_t **grp)
{
- int rc;
- lstcon_ndlink_t *ndl;
+ int rc;
+ lstcon_ndlink_t *ndl;
rc = lstcon_group_find(name, grp);
if (rc != 0) {
@@ -1398,13 +1397,13 @@ lstcon_test_batch_query(char *name, int testidx, int client,
int timeout, struct list_head *result_up)
{
lstcon_rpc_trans_t *trans;
- struct list_head *translist;
- struct list_head *ndlist;
- lstcon_tsb_hdr_t *hdr;
- lstcon_batch_t *batch;
- lstcon_test_t *test = NULL;
- int transop;
- int rc;
+ struct list_head *translist;
+ struct list_head *ndlist;
+ lstcon_tsb_hdr_t *hdr;
+ lstcon_batch_t *batch;
+ lstcon_test_t *test = NULL;
+ int transop;
+ int rc;
rc = lstcon_batch_find(name, &batch);
if (rc != 0) {
@@ -1460,9 +1459,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg,
lstcon_rpc_ent_t *ent_up)
{
srpc_stat_reply_t *rep = &msg->msg_body.stat_reply;
- sfw_counters_t *sfwk_stat;
- srpc_counters_t *srpc_stat;
- lnet_counters_t *lnet_stat;
+ sfw_counters_t *sfwk_stat;
+ srpc_counters_t *srpc_stat;
+ lnet_counters_t *lnet_stat;
if (rep->str_status != 0)
return 0;
@@ -1483,9 +1482,9 @@ static int
lstcon_ndlist_stat(struct list_head *ndlist,
int timeout, struct list_head *result_up)
{
- struct list_head head;
+ struct list_head head;
lstcon_rpc_trans_t *trans;
- int rc;
+ int rc;
INIT_LIST_HEAD(&head);
@@ -1508,8 +1507,8 @@ lstcon_ndlist_stat(struct list_head *ndlist,
int
lstcon_group_stat(char *grp_name, int timeout, struct list_head *result_up)
{
- lstcon_group_t *grp;
- int rc;
+ lstcon_group_t *grp;
+ int rc;
rc = lstcon_group_find(grp_name, &grp);
if (rc != 0) {
@@ -1528,11 +1527,11 @@ int
lstcon_nodes_stat(int count, lnet_process_id_t *ids_up,
int timeout, struct list_head *result_up)
{
- lstcon_ndlink_t *ndl;
- lstcon_group_t *tmp;
- lnet_process_id_t id;
- int i;
- int rc;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *tmp;
+ lnet_process_id_t id;
+ int i;
+ int rc;
rc = lstcon_group_alloc(NULL, &tmp);
if (rc != 0) {
@@ -1604,7 +1603,7 @@ lstcon_batch_debug(int timeout, char *name,
int client, struct list_head *result_up)
{
lstcon_batch_t *bat;
- int rc;
+ int rc;
rc = lstcon_batch_find(name, &bat);
if (rc != 0)
@@ -1622,7 +1621,7 @@ lstcon_group_debug(int timeout, char *name,
struct list_head *result_up)
{
lstcon_group_t *grp;
- int rc;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0)
@@ -1640,11 +1639,11 @@ lstcon_nodes_debug(int timeout,
int count, lnet_process_id_t *ids_up,
struct list_head *result_up)
{
- lnet_process_id_t id;
- lstcon_ndlink_t *ndl;
- lstcon_group_t *grp;
- int i;
- int rc;
+ lnet_process_id_t id;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *grp;
+ int i;
+ int rc;
rc = lstcon_group_alloc(NULL, &grp);
if (rc != 0) {
@@ -1683,13 +1682,13 @@ int
lstcon_session_match(lst_sid_t sid)
{
return (console_session.ses_id.ses_nid == sid.ses_nid &&
- console_session.ses_id.ses_stamp == sid.ses_stamp) ? 1: 0;
+ console_session.ses_id.ses_stamp == sid.ses_stamp) ? 1 : 0;
}
static void
lstcon_new_session_id(lst_sid_t *sid)
{
- lnet_process_id_t id;
+ lnet_process_id_t id;
LASSERT(console_session.ses_state == LST_SESSION_NONE);
@@ -1704,8 +1703,8 @@ int
lstcon_session_new(char *name, int key, unsigned feats,
int timeout, int force, lst_sid_t *sid_up)
{
- int rc = 0;
- int i;
+ int rc = 0;
+ int i;
if (console_session.ses_state != LST_SESSION_NONE) {
/* session exists */
@@ -1733,9 +1732,9 @@ lstcon_session_new(char *name, int key, unsigned feats,
lstcon_new_session_id(&console_session.ses_id);
- console_session.ses_key = key;
- console_session.ses_state = LST_SESSION_ACTIVE;
- console_session.ses_force = !!force;
+ console_session.ses_key = key;
+ console_session.ses_state = LST_SESSION_ACTIVE;
+ console_session.ses_force = !!force;
console_session.ses_features = feats;
console_session.ses_feats_updated = 0;
console_session.ses_timeout = (timeout <= 0) ?
@@ -1770,8 +1769,8 @@ lstcon_session_info(lst_sid_t *sid_up, int *key_up, unsigned *featp,
lstcon_ndlist_ent_t *ndinfo_up, char *name_up, int len)
{
lstcon_ndlist_ent_t *entp;
- lstcon_ndlink_t *ndl;
- int rc = 0;
+ lstcon_ndlink_t *ndl;
+ int rc = 0;
if (console_session.ses_state != LST_SESSION_ACTIVE)
return -ESRCH;
@@ -1802,9 +1801,9 @@ int
lstcon_session_end(void)
{
lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- lstcon_batch_t *bat;
- int rc = 0;
+ lstcon_group_t *grp;
+ lstcon_batch_t *bat;
+ int rc = 0;
LASSERT(console_session.ses_state == LST_SESSION_ACTIVE);
@@ -1894,13 +1893,13 @@ lstcon_session_feats_check(unsigned feats)
static int
lstcon_acceptor_handle(srpc_server_rpc_t *rpc)
{
- srpc_msg_t *rep = &rpc->srpc_replymsg;
- srpc_msg_t *req = &rpc->srpc_reqstbuf->buf_msg;
+ srpc_msg_t *rep = &rpc->srpc_replymsg;
+ srpc_msg_t *req = &rpc->srpc_reqstbuf->buf_msg;
srpc_join_reqst_t *jreq = &req->msg_body.join_reqst;
srpc_join_reply_t *jrep = &rep->msg_body.join_reply;
- lstcon_group_t *grp = NULL;
- lstcon_ndlink_t *ndl;
- int rc = 0;
+ lstcon_group_t *grp = NULL;
+ lstcon_ndlink_t *ndl;
+ int rc = 0;
sfw_unpack_message(req);
@@ -1978,9 +1977,9 @@ srpc_service_t lstcon_acceptor_service;
static void lstcon_init_acceptor_service(void)
{
/* initialize selftest console acceptor service table */
- lstcon_acceptor_service.sv_name = "join session";
- lstcon_acceptor_service.sv_handler = lstcon_acceptor_handle;
- lstcon_acceptor_service.sv_id = SRPC_SERVICE_JOIN;
+ lstcon_acceptor_service.sv_name = "join session";
+ lstcon_acceptor_service.sv_handler = lstcon_acceptor_handle;
+ lstcon_acceptor_service.sv_id = SRPC_SERVICE_JOIN;
lstcon_acceptor_service.sv_wi_total = SFW_FRWK_WI_MAX;
}
@@ -1992,19 +1991,19 @@ static DECLARE_IOCTL_HANDLER(lstcon_ioctl_handler, lstcon_ioctl_entry);
int
lstcon_console_init(void)
{
- int i;
- int rc;
+ int i;
+ int rc;
memset(&console_session, 0, sizeof(lstcon_session_t));
- console_session.ses_id = LST_INVALID_SID;
- console_session.ses_state = LST_SESSION_NONE;
- console_session.ses_timeout = 0;
- console_session.ses_force = 0;
- console_session.ses_expired = 0;
- console_session.ses_feats_updated = 0;
- console_session.ses_features = LST_FEATS_MASK;
- console_session.ses_laststamp = get_seconds();
+ console_session.ses_id = LST_INVALID_SID;
+ console_session.ses_state = LST_SESSION_NONE;
+ console_session.ses_timeout = 0;
+ console_session.ses_force = 0;
+ console_session.ses_expired = 0;
+ console_session.ses_feats_updated = 0;
+ console_session.ses_features = LST_FEATS_MASK;
+ console_session.ses_laststamp = ktime_get_real_seconds();
mutex_init(&console_session.ses_mutex);
@@ -2021,7 +2020,6 @@ lstcon_console_init(void)
for (i = 0; i < LST_GLOBAL_HASHSIZE; i++)
INIT_LIST_HEAD(&console_session.ses_ndl_hash[i]);
-
/* initialize acceptor service table */
lstcon_init_acceptor_service();
@@ -2062,7 +2060,7 @@ out:
int
lstcon_console_fini(void)
{
- int i;
+ int i;
libcfs_deregister_ioctl(&lstcon_ioctl_handler);
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/console.h b/kernel/drivers/staging/lustre/lnet/selftest/console.h
index e41ca89f1..3f3286c0c 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/console.h
+++ b/kernel/drivers/staging/lustre/lnet/selftest/console.h
@@ -43,7 +43,6 @@
#ifndef __LST_CONSOLE_H__
#define __LST_CONSOLE_H__
-
#include "../../include/linux/libcfs/libcfs.h"
#include "../../include/linux/lnet/lnet.h"
#include "../../include/linux/lnet/lib-types.h"
@@ -52,119 +51,121 @@
#include "conrpc.h"
typedef struct lstcon_node {
- lnet_process_id_t nd_id; /* id of the node */
- int nd_ref; /* reference count */
- int nd_state; /* state of the node */
- int nd_timeout; /* session timeout */
- unsigned long nd_stamp; /* timestamp of last replied RPC */
- struct lstcon_rpc nd_ping; /* ping rpc */
-} lstcon_node_t; /*** node descriptor */
+ lnet_process_id_t nd_id; /* id of the node */
+ int nd_ref; /* reference count */
+ int nd_state; /* state of the node */
+ int nd_timeout; /* session timeout */
+ unsigned long nd_stamp; /* timestamp of last replied RPC */
+ struct lstcon_rpc nd_ping; /* ping rpc */
+} lstcon_node_t; /* node descriptor */
typedef struct {
- struct list_head ndl_link; /* chain on list */
- struct list_head ndl_hlink; /* chain on hash */
- lstcon_node_t *ndl_node; /* pointer to node */
-} lstcon_ndlink_t; /*** node link descriptor */
+ struct list_head ndl_link; /* chain on list */
+ struct list_head ndl_hlink; /* chain on hash */
+ lstcon_node_t *ndl_node; /* pointer to node */
+} lstcon_ndlink_t; /* node link descriptor */
typedef struct {
- struct list_head grp_link; /* chain on global group list */
- int grp_ref; /* reference count */
- int grp_userland; /* has userland nodes */
- int grp_nnode; /* # of nodes */
- char grp_name[LST_NAME_SIZE]; /* group name */
+ struct list_head grp_link; /* chain on global group list
+ */
+ int grp_ref; /* reference count */
+ int grp_userland; /* has userland nodes */
+ int grp_nnode; /* # of nodes */
+ char grp_name[LST_NAME_SIZE]; /* group name */
- struct list_head grp_trans_list; /* transaction list */
- struct list_head grp_ndl_list; /* nodes list */
- struct list_head grp_ndl_hash[0];/* hash table for nodes */
-} lstcon_group_t; /*** (alias of nodes) group descriptor */
+ struct list_head grp_trans_list; /* transaction list */
+ struct list_head grp_ndl_list; /* nodes list */
+ struct list_head grp_ndl_hash[0]; /* hash table for nodes */
+} lstcon_group_t; /* (alias of nodes) group descriptor */
-#define LST_BATCH_IDLE 0xB0 /* idle batch */
-#define LST_BATCH_RUNNING 0xB1 /* running batch */
+#define LST_BATCH_IDLE 0xB0 /* idle batch */
+#define LST_BATCH_RUNNING 0xB1 /* running batch */
typedef struct lstcon_tsb_hdr {
- lst_bid_t tsb_id; /* batch ID */
- int tsb_index; /* test index */
+ lst_bid_t tsb_id; /* batch ID */
+ int tsb_index; /* test index */
} lstcon_tsb_hdr_t;
typedef struct {
- lstcon_tsb_hdr_t bat_hdr; /* test_batch header */
- struct list_head bat_link; /* chain on session's batches list */
- int bat_ntest; /* # of test */
- int bat_state; /* state of the batch */
- int bat_arg; /* parameter for run|stop, timeout for run, force for stop */
- char bat_name[LST_NAME_SIZE]; /* name of batch */
-
- struct list_head bat_test_list; /* list head of tests (lstcon_test_t) */
- struct list_head bat_trans_list; /* list head of transaction */
- struct list_head bat_cli_list; /* list head of client nodes (lstcon_node_t) */
- struct list_head *bat_cli_hash; /* hash table of client nodes */
- struct list_head bat_srv_list; /* list head of server nodes */
- struct list_head *bat_srv_hash; /* hash table of server nodes */
-} lstcon_batch_t; /*** (tests ) batch descriptor */
+ lstcon_tsb_hdr_t bat_hdr; /* test_batch header */
+ struct list_head bat_link; /* chain on session's batches list */
+ int bat_ntest; /* # of test */
+ int bat_state; /* state of the batch */
+ int bat_arg; /* parameter for run|stop, timeout
+ * for run, force for stop */
+ char bat_name[LST_NAME_SIZE];/* name of batch */
+
+ struct list_head bat_test_list; /* list head of tests (lstcon_test_t)
+ */
+ struct list_head bat_trans_list; /* list head of transaction */
+ struct list_head bat_cli_list; /* list head of client nodes
+ * (lstcon_node_t) */
+ struct list_head *bat_cli_hash; /* hash table of client nodes */
+ struct list_head bat_srv_list; /* list head of server nodes */
+ struct list_head *bat_srv_hash; /* hash table of server nodes */
+} lstcon_batch_t; /* (tests ) batch descriptor */
typedef struct lstcon_test {
- lstcon_tsb_hdr_t tes_hdr; /* test batch header */
- struct list_head tes_link; /* chain on batch's tests list */
- lstcon_batch_t *tes_batch; /* pointer to batch */
+ lstcon_tsb_hdr_t tes_hdr; /* test batch header */
+ struct list_head tes_link; /* chain on batch's tests list */
+ lstcon_batch_t *tes_batch; /* pointer to batch */
- int tes_type; /* type of the test, i.e: bulk, ping */
- int tes_stop_onerr; /* stop on error */
- int tes_oneside; /* one-sided test */
- int tes_concur; /* concurrency */
- int tes_loop; /* loop count */
- int tes_dist; /* nodes distribution of target group */
- int tes_span; /* nodes span of target group */
- int tes_cliidx; /* client index, used for RPC creating */
+ int tes_type; /* type of the test, i.e: bulk, ping */
+ int tes_stop_onerr; /* stop on error */
+ int tes_oneside; /* one-sided test */
+ int tes_concur; /* concurrency */
+ int tes_loop; /* loop count */
+ int tes_dist; /* nodes distribution of target group */
+ int tes_span; /* nodes span of target group */
+ int tes_cliidx; /* client index, used for RPC creating */
- struct list_head tes_trans_list; /* transaction list */
- lstcon_group_t *tes_src_grp; /* group run the test */
- lstcon_group_t *tes_dst_grp; /* target group */
+ struct list_head tes_trans_list; /* transaction list */
+ lstcon_group_t *tes_src_grp; /* group run the test */
+ lstcon_group_t *tes_dst_grp; /* target group */
- int tes_paramlen; /* test parameter length */
- char tes_param[0]; /* test parameter */
-} lstcon_test_t; /*** a single test descriptor */
+ int tes_paramlen; /* test parameter length */
+ char tes_param[0]; /* test parameter */
+} lstcon_test_t; /* a single test descriptor */
-#define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
-#define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
+#define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
+#define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
-#define LST_SESSION_NONE 0x0 /* no session */
-#define LST_SESSION_ACTIVE 0x1 /* working session */
+#define LST_SESSION_NONE 0x0 /* no session */
+#define LST_SESSION_ACTIVE 0x1 /* working session */
-#define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
+#define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
typedef struct {
- struct mutex ses_mutex; /* only 1 thread in session */
- lst_sid_t ses_id; /* global session id */
- int ses_key; /* local session key */
- int ses_state; /* state of session */
- int ses_timeout; /* timeout in seconds */
- time_t ses_laststamp; /* last operation stamp (seconds) */
- /** tests features of the session */
- unsigned ses_features;
- /** features are synced with remote test nodes */
- unsigned ses_feats_updated:1;
- /** force creating */
- unsigned ses_force:1;
- /** session is shutting down */
- unsigned ses_shutdown:1;
- /** console is timedout */
- unsigned ses_expired:1;
- __u64 ses_id_cookie; /* batch id cookie */
- char ses_name[LST_NAME_SIZE]; /* session name */
- lstcon_rpc_trans_t *ses_ping; /* session pinger */
- stt_timer_t ses_ping_timer; /* timer for pinger */
- lstcon_trans_stat_t ses_trans_stat; /* transaction stats */
-
- struct list_head ses_trans_list; /* global list of transaction */
- struct list_head ses_grp_list; /* global list of groups */
- struct list_head ses_bat_list; /* global list of batches */
- struct list_head ses_ndl_list; /* global list of nodes */
- struct list_head *ses_ndl_hash; /* hash table of nodes */
-
- spinlock_t ses_rpc_lock; /* serialize */
- atomic_t ses_rpc_counter;/* # of initialized RPCs */
- struct list_head ses_rpc_freelist; /* idle console rpc */
-} lstcon_session_t; /*** session descriptor */
+ struct mutex ses_mutex; /* only 1 thread in session */
+ lst_sid_t ses_id; /* global session id */
+ int ses_key; /* local session key */
+ int ses_state; /* state of session */
+ int ses_timeout; /* timeout in seconds */
+ time64_t ses_laststamp; /* last operation stamp (seconds)
+ */
+ unsigned ses_features; /* tests features of the session
+ */
+ unsigned ses_feats_updated:1; /* features are synced with
+ * remote test nodes */
+ unsigned ses_force:1; /* force creating */
+ unsigned ses_shutdown:1; /* session is shutting down */
+ unsigned ses_expired:1; /* console is timedout */
+ __u64 ses_id_cookie; /* batch id cookie */
+ char ses_name[LST_NAME_SIZE];/* session name */
+ lstcon_rpc_trans_t *ses_ping; /* session pinger */
+ stt_timer_t ses_ping_timer; /* timer for pinger */
+ lstcon_trans_stat_t ses_trans_stat; /* transaction stats */
+
+ struct list_head ses_trans_list; /* global list of transaction */
+ struct list_head ses_grp_list; /* global list of groups */
+ struct list_head ses_bat_list; /* global list of batches */
+ struct list_head ses_ndl_list; /* global list of nodes */
+ struct list_head *ses_ndl_hash; /* hash table of nodes */
+
+ spinlock_t ses_rpc_lock; /* serialize */
+ atomic_t ses_rpc_counter; /* # of initialized RPCs */
+ struct list_head ses_rpc_freelist; /* idle console rpc */
+} lstcon_session_t; /* session descriptor */
extern lstcon_session_t console_session;
@@ -185,51 +186,49 @@ lstcon_id2hash (lnet_process_id_t id, struct list_head *hash)
int lstcon_console_init(void);
int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data);
int lstcon_console_fini(void);
-extern int lstcon_session_match(lst_sid_t sid);
-extern int lstcon_session_new(char *name, int key, unsigned version,
- int timeout, int flags, lst_sid_t *sid_up);
-extern int lstcon_session_info(lst_sid_t *sid_up, int *key, unsigned *verp,
- lstcon_ndlist_ent_t *entp, char *name_up, int len);
-extern int lstcon_session_end(void);
-extern int lstcon_session_debug(int timeout, struct list_head *result_up);
-extern int lstcon_session_feats_check(unsigned feats);
-extern int lstcon_batch_debug(int timeout, char *name,
- int client, struct list_head *result_up);
-extern int lstcon_group_debug(int timeout, char *name,
- struct list_head *result_up);
-extern int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t *nds_up,
- struct list_head *result_up);
-extern int lstcon_group_add(char *name);
-extern int lstcon_group_del(char *name);
-extern int lstcon_group_clean(char *name, int args);
-extern int lstcon_group_refresh(char *name, struct list_head *result_up);
-extern int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t *nds_up,
- unsigned *featp, struct list_head *result_up);
-extern int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t *nds_up,
- struct list_head *result_up);
-extern int lstcon_group_info(char *name, lstcon_ndlist_ent_t *gent_up,
- int *index_p, int *ndent_p, lstcon_node_ent_t *ndents_up);
-extern int lstcon_group_list(int idx, int len, char *name_up);
-extern int lstcon_batch_add(char *name);
-extern int lstcon_batch_run(char *name, int timeout,
+int lstcon_session_match(lst_sid_t sid);
+int lstcon_session_new(char *name, int key, unsigned version,
+ int timeout, int flags, lst_sid_t *sid_up);
+int lstcon_session_info(lst_sid_t *sid_up, int *key, unsigned *verp,
+ lstcon_ndlist_ent_t *entp, char *name_up, int len);
+int lstcon_session_end(void);
+int lstcon_session_debug(int timeout, struct list_head *result_up);
+int lstcon_session_feats_check(unsigned feats);
+int lstcon_batch_debug(int timeout, char *name,
+ int client, struct list_head *result_up);
+int lstcon_group_debug(int timeout, char *name,
+ struct list_head *result_up);
+int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t *nds_up,
+ struct list_head *result_up);
+int lstcon_group_add(char *name);
+int lstcon_group_del(char *name);
+int lstcon_group_clean(char *name, int args);
+int lstcon_group_refresh(char *name, struct list_head *result_up);
+int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t *nds_up,
+ unsigned *featp, struct list_head *result_up);
+int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t *nds_up,
+ struct list_head *result_up);
+int lstcon_group_info(char *name, lstcon_ndlist_ent_t *gent_up,
+ int *index_p, int *ndent_p, lstcon_node_ent_t *ndents_up);
+int lstcon_group_list(int idx, int len, char *name_up);
+int lstcon_batch_add(char *name);
+int lstcon_batch_run(char *name, int timeout, struct list_head *result_up);
+int lstcon_batch_stop(char *name, int force, struct list_head *result_up);
+int lstcon_test_batch_query(char *name, int testidx,
+ int client, int timeout,
struct list_head *result_up);
-extern int lstcon_batch_stop(char *name, int force,
- struct list_head *result_up);
-extern int lstcon_test_batch_query(char *name, int testidx,
- int client, int timeout,
- struct list_head *result_up);
-extern int lstcon_batch_del(char *name);
-extern int lstcon_batch_list(int idx, int namelen, char *name_up);
-extern int lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up,
- int server, int testidx, int *index_p,
- int *ndent_p, lstcon_node_ent_t *dents_up);
-extern int lstcon_group_stat(char *grp_name, int timeout,
- struct list_head *result_up);
-extern int lstcon_nodes_stat(int count, lnet_process_id_t *ids_up,
- int timeout, struct list_head *result_up);
-extern int lstcon_test_add(char *batch_name, int type, int loop,
- int concur, int dist, int span,
- char *src_name, char *dst_name,
- void *param, int paramlen, int *retp,
- struct list_head *result_up);
+int lstcon_batch_del(char *name);
+int lstcon_batch_list(int idx, int namelen, char *name_up);
+int lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up,
+ int server, int testidx, int *index_p,
+ int *ndent_p, lstcon_node_ent_t *dents_up);
+int lstcon_group_stat(char *grp_name, int timeout,
+ struct list_head *result_up);
+int lstcon_nodes_stat(int count, lnet_process_id_t *ids_up,
+ int timeout, struct list_head *result_up);
+int lstcon_test_add(char *batch_name, int type, int loop,
+ int concur, int dist, int span,
+ char *src_name, char *dst_name,
+ void *param, int paramlen, int *retp,
+ struct list_head *result_up);
#endif
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/framework.c b/kernel/drivers/staging/lustre/lnet/selftest/framework.c
index a93a90de0..f18e50036 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/framework.c
@@ -53,20 +53,20 @@ static int rpc_timeout = 64;
module_param(rpc_timeout, int, 0644);
MODULE_PARM_DESC(rpc_timeout, "rpc timeout in seconds (64 by default, 0 == never)");
-#define sfw_unpack_id(id) \
-do { \
+#define sfw_unpack_id(id) \
+do { \
__swab64s(&(id).nid); \
__swab32s(&(id).pid); \
} while (0)
-#define sfw_unpack_sid(sid) \
-do { \
+#define sfw_unpack_sid(sid) \
+do { \
__swab64s(&(sid).ses_nid); \
__swab64s(&(sid).ses_stamp); \
} while (0)
-#define sfw_unpack_fw_counters(fc) \
-do { \
+#define sfw_unpack_fw_counters(fc) \
+do { \
__swab32s(&(fc).running_ms); \
__swab32s(&(fc).active_batches); \
__swab32s(&(fc).zombie_sessions); \
@@ -75,7 +75,7 @@ do { \
} while (0)
#define sfw_unpack_rpc_counters(rc) \
-do { \
+do { \
__swab32s(&(rc).errors); \
__swab32s(&(rc).rpcs_sent); \
__swab32s(&(rc).rpcs_rcvd); \
@@ -86,7 +86,7 @@ do { \
} while (0)
#define sfw_unpack_lnet_counters(lc) \
-do { \
+do { \
__swab32s(&(lc).errors); \
__swab32s(&(lc).msgs_max); \
__swab32s(&(lc).msgs_alloc); \
@@ -104,14 +104,14 @@ do { \
#define sfw_batch_active(b) (atomic_read(&(b)->bat_nactive) != 0)
static struct smoketest_framework {
- struct list_head fw_zombie_rpcs; /* RPCs to be recycled */
- struct list_head fw_zombie_sessions; /* stopping sessions */
- struct list_head fw_tests; /* registered test cases */
- atomic_t fw_nzombies; /* # zombie sessions */
- spinlock_t fw_lock; /* serialise */
- sfw_session_t *fw_session; /* _the_ session */
- int fw_shuttingdown; /* shutdown in progress */
- srpc_server_rpc_t *fw_active_srpc; /* running RPC */
+ struct list_head fw_zombie_rpcs; /* RPCs to be recycled */
+ struct list_head fw_zombie_sessions; /* stopping sessions */
+ struct list_head fw_tests; /* registered test cases */
+ atomic_t fw_nzombies; /* # zombie sessions */
+ spinlock_t fw_lock; /* serialise */
+ sfw_session_t *fw_session; /* _the_ session */
+ int fw_shuttingdown; /* shutdown in progress */
+ srpc_server_rpc_t *fw_active_srpc; /* running RPC */
} sfw_data;
/* forward ref's */
@@ -160,7 +160,7 @@ static void
sfw_add_session_timer(void)
{
sfw_session_t *sn = sfw_data.fw_session;
- stt_timer_t *timer = &sn->sn_timer;
+ stt_timer_t *timer = &sn->sn_timer;
LASSERT(!sfw_data.fw_shuttingdown);
@@ -170,8 +170,7 @@ sfw_add_session_timer(void)
LASSERT(!sn->sn_timer_active);
sn->sn_timer_active = 1;
- timer->stt_expires = cfs_time_add(sn->sn_timeout,
- get_seconds());
+ timer->stt_expires = ktime_get_real_seconds() + sn->sn_timeout;
stt_add_timer(timer);
return;
}
@@ -199,11 +198,12 @@ sfw_deactivate_session(void)
__must_hold(&sfw_data.fw_lock)
{
sfw_session_t *sn = sfw_data.fw_session;
- int nactive = 0;
- sfw_batch_t *tsb;
+ int nactive = 0;
+ sfw_batch_t *tsb;
sfw_test_case_t *tsc;
- if (sn == NULL) return;
+ if (sn == NULL)
+ return;
LASSERT(!sn->sn_timer_active);
@@ -237,7 +237,6 @@ sfw_deactivate_session(void)
spin_lock(&sfw_data.fw_lock);
}
-
static void
sfw_session_expired(void *data)
{
@@ -273,7 +272,7 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid,
strlcpy(&sn->sn_name[0], name, sizeof(sn->sn_name));
sn->sn_timer_active = 0;
- sn->sn_id = sid;
+ sn->sn_id = sid;
sn->sn_features = features;
sn->sn_timeout = session_timeout;
sn->sn_started = cfs_time_current();
@@ -287,8 +286,8 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid,
static void
sfw_server_rpc_done(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- int status = rpc->srpc_status;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ int status = rpc->srpc_status;
CDEBUG(D_NET,
"Incoming framework RPC done: service %s, peer %s, status %s:%d\n",
@@ -327,7 +326,7 @@ static sfw_batch_t *
sfw_find_batch(lst_bid_t bid)
{
sfw_session_t *sn = sfw_data.fw_session;
- sfw_batch_t *bat;
+ sfw_batch_t *bat;
LASSERT(sn != NULL);
@@ -343,7 +342,7 @@ static sfw_batch_t *
sfw_bid2batch(lst_bid_t bid)
{
sfw_session_t *sn = sfw_data.fw_session;
- sfw_batch_t *bat;
+ sfw_batch_t *bat;
LASSERT(sn != NULL);
@@ -368,10 +367,9 @@ sfw_bid2batch(lst_bid_t bid)
static int
sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
{
- sfw_session_t *sn = sfw_data.fw_session;
+ sfw_session_t *sn = sfw_data.fw_session;
sfw_counters_t *cnt = &reply->str_fw;
- sfw_batch_t *bat;
- struct timeval tv;
+ sfw_batch_t *bat;
reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -390,10 +388,7 @@ sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
/* send over the msecs since the session was started
- with 32 bits to send, this is ~49 days */
- cfs_duration_usec(cfs_time_sub(cfs_time_current(),
- sn->sn_started), &tv);
-
- cnt->running_ms = (__u32)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
+ cnt->running_ms = jiffies_to_msecs(jiffies - sn->sn_started);
cnt->brw_errors = atomic_read(&sn->sn_brw_errors);
cnt->ping_errors = atomic_read(&sn->sn_ping_errors);
cnt->zombie_sessions = atomic_read(&sfw_data.fw_nzombies);
@@ -412,9 +407,9 @@ int
sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply)
{
sfw_session_t *sn = sfw_data.fw_session;
- srpc_msg_t *msg = container_of(request, srpc_msg_t,
+ srpc_msg_t *msg = container_of(request, srpc_msg_t,
msg_body.mksn_reqst);
- int cplen = 0;
+ int cplen = 0;
if (request->mksn_sid.ses_nid == LNET_NID_ANY) {
reply->mksn_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -533,7 +528,7 @@ sfw_debug_session(srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
static void
sfw_test_rpc_fini(srpc_client_rpc_t *rpc)
{
- sfw_test_unit_t *tsu = rpc->crpc_priv;
+ sfw_test_unit_t *tsu = rpc->crpc_priv;
sfw_test_instance_t *tsi = tsu->tsu_instance;
/* Called with hold of tsi->tsi_lock */
@@ -544,9 +539,9 @@ sfw_test_rpc_fini(srpc_client_rpc_t *rpc)
static inline int
sfw_test_buffers(sfw_test_instance_t *tsi)
{
- struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service);
- struct srpc_service *svc = tsc->tsc_srv_service;
- int nbuf;
+ struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service);
+ struct srpc_service *svc = tsc->tsc_srv_service;
+ int nbuf;
nbuf = min(svc->sv_wi_total, tsi->tsi_loop) / svc->sv_ncpts;
return max(SFW_TEST_WI_MIN, nbuf + SFW_TEST_WI_EXTRA);
@@ -555,10 +550,10 @@ sfw_test_buffers(sfw_test_instance_t *tsi)
static int
sfw_load_test(struct sfw_test_instance *tsi)
{
- struct sfw_test_case *tsc;
- struct srpc_service *svc;
- int nbuf;
- int rc;
+ struct sfw_test_case *tsc;
+ struct srpc_service *svc;
+ int nbuf;
+ int rc;
LASSERT(tsi != NULL);
tsc = sfw_find_test_case(tsi->tsi_service);
@@ -611,9 +606,10 @@ static void
sfw_destroy_test_instance(sfw_test_instance_t *tsi)
{
srpc_client_rpc_t *rpc;
- sfw_test_unit_t *tsu;
+ sfw_test_unit_t *tsu;
- if (!tsi->tsi_is_client) goto clean;
+ if (!tsi->tsi_is_client)
+ goto clean;
tsi->tsi_ops->tso_fini(tsi);
@@ -728,14 +724,14 @@ sfw_unpack_addtest_req(srpc_msg_t *msg)
static int
sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
{
- srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg;
- srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
- srpc_bulk_t *bk = rpc->srpc_bulk;
- int ndest = req->tsr_ndest;
- sfw_test_unit_t *tsu;
+ srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg;
+ srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
+ srpc_bulk_t *bk = rpc->srpc_bulk;
+ int ndest = req->tsr_ndest;
+ sfw_test_unit_t *tsu;
sfw_test_instance_t *tsi;
- int i;
- int rc;
+ int i;
+ int rc;
LIBCFS_ALLOC(tsi, sizeof(*tsi));
if (tsi == NULL) {
@@ -751,9 +747,9 @@ sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
INIT_LIST_HEAD(&tsi->tsi_active_rpcs);
tsi->tsi_stopping = 0;
- tsi->tsi_batch = tsb;
- tsi->tsi_loop = req->tsr_loop;
- tsi->tsi_concur = req->tsr_concur;
+ tsi->tsi_batch = tsb;
+ tsi->tsi_loop = req->tsr_loop;
+ tsi->tsi_concur = req->tsr_concur;
tsi->tsi_service = req->tsr_service;
tsi->tsi_is_client = !!(req->tsr_is_client);
tsi->tsi_stoptsu_onerr = !!(req->tsr_stop_onerr);
@@ -782,8 +778,8 @@ sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
for (i = 0; i < ndest; i++) {
lnet_process_id_packed_t *dests;
- lnet_process_id_packed_t id;
- int j;
+ lnet_process_id_packed_t id;
+ int j;
dests = page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page);
LASSERT(dests != NULL); /* my pages are within KVM always */
@@ -824,8 +820,8 @@ static void
sfw_test_unit_done(sfw_test_unit_t *tsu)
{
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_batch_t *tsb = tsi->tsi_batch;
- sfw_session_t *sn = tsb->bat_session;
+ sfw_batch_t *tsb = tsi->tsi_batch;
+ sfw_session_t *sn = tsb->bat_session;
LASSERT(sfw_test_active(tsi));
@@ -866,9 +862,9 @@ sfw_test_unit_done(sfw_test_unit_t *tsu)
static void
sfw_test_rpc_done(srpc_client_rpc_t *rpc)
{
- sfw_test_unit_t *tsu = rpc->crpc_priv;
+ sfw_test_unit_t *tsu = rpc->crpc_priv;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- int done = 0;
+ int done = 0;
tsi->tsi_ops->tso_done_rpc(tsu, rpc);
@@ -904,7 +900,7 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
unsigned features, int nblk, int blklen,
srpc_client_rpc_t **rpcpp)
{
- srpc_client_rpc_t *rpc = NULL;
+ srpc_client_rpc_t *rpc = NULL;
sfw_test_instance_t *tsi = tsu->tsu_instance;
spin_lock(&tsi->tsi_lock);
@@ -945,9 +941,9 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
static int
sfw_run_test(swi_workitem_t *wi)
{
- sfw_test_unit_t *tsu = wi->swi_workitem.wi_data;
+ sfw_test_unit_t *tsu = wi->swi_workitem.wi_data;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- srpc_client_rpc_t *rpc = NULL;
+ srpc_client_rpc_t *rpc = NULL;
LASSERT(wi == &tsu->tsu_worker);
@@ -995,8 +991,8 @@ test_done:
static int
sfw_run_batch(sfw_batch_t *tsb)
{
- swi_workitem_t *wi;
- sfw_test_unit_t *tsu;
+ swi_workitem_t *wi;
+ sfw_test_unit_t *tsu;
sfw_test_instance_t *tsi;
if (sfw_batch_active(tsb)) {
@@ -1032,7 +1028,7 @@ int
sfw_stop_batch(sfw_batch_t *tsb, int force)
{
sfw_test_instance_t *tsi;
- srpc_client_rpc_t *rpc;
+ srpc_client_rpc_t *rpc;
if (!sfw_batch_active(tsb)) {
CDEBUG(D_NET, "Batch %llu inactive\n", tsb->bat_id.bat_id);
@@ -1118,11 +1114,11 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len,
static int
sfw_add_test(srpc_server_rpc_t *rpc)
{
- sfw_session_t *sn = sfw_data.fw_session;
+ sfw_session_t *sn = sfw_data.fw_session;
srpc_test_reply_t *reply = &rpc->srpc_replymsg.msg_body.tes_reply;
srpc_test_reqst_t *request;
- int rc;
- sfw_batch_t *bat;
+ int rc;
+ sfw_batch_t *bat;
request = &rpc->srpc_reqstbuf->buf_msg.msg_body.tes_reqst;
reply->tsr_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -1160,8 +1156,8 @@ sfw_add_test(srpc_server_rpc_t *rpc)
if (request->tsr_is_client && rpc->srpc_bulk == NULL) {
/* rpc will be resumed later in sfw_bulk_ready */
- int npg = sfw_id_pages(request->tsr_ndest);
- int len;
+ int npg = sfw_id_pages(request->tsr_ndest);
+ int len;
if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) {
len = npg * PAGE_CACHE_SIZE;
@@ -1189,8 +1185,8 @@ static int
sfw_control_batch(srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
{
sfw_session_t *sn = sfw_data.fw_session;
- int rc = 0;
- sfw_batch_t *bat;
+ int rc = 0;
+ sfw_batch_t *bat;
reply->bar_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -1229,11 +1225,11 @@ sfw_control_batch(srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
static int
sfw_handle_server_rpc(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- srpc_msg_t *reply = &rpc->srpc_replymsg;
- srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg;
- unsigned features = LST_FEATS_MASK;
- int rc = 0;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ srpc_msg_t *reply = &rpc->srpc_replymsg;
+ srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg;
+ unsigned features = LST_FEATS_MASK;
+ int rc = 0;
LASSERT(sfw_data.fw_active_srpc == NULL);
LASSERT(sv->sv_id <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
@@ -1334,8 +1330,8 @@ sfw_handle_server_rpc(struct srpc_server_rpc *rpc)
static int
sfw_bulk_ready(struct srpc_server_rpc *rpc, int status)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- int rc;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ int rc;
LASSERT(rpc->srpc_bulk != NULL);
LASSERT(sv->sv_id == SRPC_SERVICE_TEST);
@@ -1636,17 +1632,15 @@ extern srpc_service_t brw_test_service;
extern void brw_init_test_client(void);
extern void brw_init_test_service(void);
-
int
sfw_startup(void)
{
- int i;
- int rc;
- int error;
- srpc_service_t *sv;
+ int i;
+ int rc;
+ int error;
+ srpc_service_t *sv;
sfw_test_case_t *tsc;
-
if (session_timeout < 0) {
CERROR("Session timeout must be non-negative: %d\n",
session_timeout);
@@ -1700,7 +1694,8 @@ sfw_startup(void)
for (i = 0; ; i++) {
sv = &sfw_services[i];
- if (sv->sv_name == NULL) break;
+ if (sv->sv_name == NULL)
+ break;
sv->sv_bulk_ready = NULL;
sv->sv_handler = sfw_handle_server_rpc;
@@ -1717,7 +1712,8 @@ sfw_startup(void)
}
/* about to sfw_shutdown, no need to add buffer */
- if (error) continue;
+ if (error)
+ continue;
rc = srpc_service_add_buffers(sv, sv->sv_wi_total);
if (rc != 0) {
@@ -1735,9 +1731,9 @@ sfw_startup(void)
void
sfw_shutdown(void)
{
- srpc_service_t *sv;
+ srpc_service_t *sv;
sfw_test_case_t *tsc;
- int i;
+ int i;
spin_lock(&sfw_data.fw_lock);
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/module.c b/kernel/drivers/staging/lustre/lnet/selftest/module.c
index 7ad62f167..46cbdf045 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/module.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/module.c
@@ -39,7 +39,7 @@
#include "selftest.h"
enum {
- LST_INIT_NONE = 0,
+ LST_INIT_NONE = 0,
LST_INIT_WI_SERIAL,
LST_INIT_WI_TEST,
LST_INIT_RPC,
@@ -58,7 +58,7 @@ struct cfs_wi_sched **lst_sched_test;
static void
lnet_selftest_fini(void)
{
- int i;
+ int i;
switch (lst_init_step) {
case LST_INIT_CONSOLE:
@@ -92,9 +92,9 @@ lnet_selftest_fini(void)
static int
lnet_selftest_init(void)
{
- int nscheds;
- int rc;
- int i;
+ int nscheds;
+ int rc;
+ int i;
rc = cfs_wi_sched_create("lst_s", lnet_cpt_table(), CFS_CPT_ANY,
1, &lst_sched_serial);
@@ -150,7 +150,6 @@ error:
return rc;
}
-
MODULE_DESCRIPTION("LNet Selftest");
MODULE_LICENSE("GPL");
MODULE_VERSION("0.9.0");
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/ping_test.c b/kernel/drivers/staging/lustre/lnet/selftest/ping_test.c
index 644069a9f..d42653654 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/ping_test.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/ping_test.c
@@ -73,7 +73,7 @@ static void
ping_client_fini(sfw_test_instance_t *tsi)
{
sfw_session_t *sn = tsi->tsi_batch->bat_session;
- int errors;
+ int errors;
LASSERT(sn != NULL);
LASSERT(tsi->tsi_is_client);
@@ -89,11 +89,11 @@ static int
ping_client_prep_rpc(sfw_test_unit_t *tsu,
lnet_process_id_t dest, srpc_client_rpc_t **rpc)
{
- srpc_ping_reqst_t *req;
+ srpc_ping_reqst_t *req;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- struct timeval tv;
- int rc;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ struct timespec64 ts;
+ int rc;
LASSERT(sn != NULL);
LASSERT((sn->sn_features & ~LST_FEATS_MASK) == 0);
@@ -110,9 +110,9 @@ ping_client_prep_rpc(sfw_test_unit_t *tsu,
req->pnr_seq = lst_ping_data.pnd_counter++;
spin_unlock(&lst_ping_data.pnd_lock);
- cfs_fs_timeval(&tv);
- req->pnr_time_sec = tv.tv_sec;
- req->pnr_time_usec = tv.tv_usec;
+ ktime_get_real_ts64(&ts);
+ req->pnr_time_sec = ts.tv_sec;
+ req->pnr_time_usec = ts.tv_nsec / NSEC_PER_USEC;
return rc;
}
@@ -121,10 +121,10 @@ static void
ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
{
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- srpc_ping_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.ping_reqst;
- srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply;
- struct timeval tv;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ srpc_ping_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.ping_reqst;
+ srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply;
+ struct timespec64 ts;
LASSERT(sn != NULL);
@@ -161,19 +161,19 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
return;
}
- cfs_fs_timeval(&tv);
+ ktime_get_real_ts64(&ts);
CDEBUG(D_NET, "%d reply in %u usec\n", reply->pnr_seq,
- (unsigned)((tv.tv_sec - (unsigned)reqst->pnr_time_sec) * 1000000
- + (tv.tv_usec - reqst->pnr_time_usec)));
+ (unsigned)((ts.tv_sec - reqst->pnr_time_sec) * 1000000 +
+ (ts.tv_nsec / NSEC_PER_USEC - reqst->pnr_time_usec)));
return;
}
static int
ping_server_handle(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
- srpc_msg_t *replymsg = &rpc->srpc_replymsg;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
+ srpc_msg_t *replymsg = &rpc->srpc_replymsg;
srpc_ping_reqst_t *req = &reqstmsg->msg_body.ping_reqst;
srpc_ping_reply_t *rep = &rpc->srpc_replymsg.msg_body.ping_reply;
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/rpc.c b/kernel/drivers/staging/lustre/lnet/selftest/rpc.c
index 080788ab7..7005002c1 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/rpc.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/rpc.c
@@ -90,7 +90,7 @@ void srpc_set_counters(const srpc_counters_t *cnt)
static int
srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob)
{
- nob = min(nob, (int)PAGE_CACHE_SIZE);
+ nob = min_t(int, nob, PAGE_CACHE_SIZE);
LASSERT(nob > 0);
LASSERT(i >= 0 && i < bk->bk_niov);
@@ -104,7 +104,7 @@ srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob)
void
srpc_free_bulk(srpc_bulk_t *bk)
{
- int i;
+ int i;
struct page *pg;
LASSERT(bk != NULL);
@@ -124,8 +124,8 @@ srpc_free_bulk(srpc_bulk_t *bk)
srpc_bulk_t *
srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
{
- srpc_bulk_t *bk;
- int i;
+ srpc_bulk_t *bk;
+ int i;
LASSERT(bulk_npg > 0 && bulk_npg <= LNET_MAX_IOV);
@@ -143,10 +143,10 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
for (i = 0; i < bulk_npg; i++) {
struct page *pg;
- int nob;
+ int nob;
pg = alloc_pages_node(cfs_cpt_spread_node(lnet_cpt_table(), cpt),
- GFP_IOFS, 0);
+ GFP_KERNEL, 0);
if (pg == NULL) {
CERROR("Can't allocate page %d of %d\n", i, bulk_npg);
srpc_free_bulk(bk);
@@ -193,11 +193,11 @@ srpc_init_server_rpc(struct srpc_server_rpc *rpc,
static void
srpc_service_fini(struct srpc_service *svc)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- struct srpc_buffer *buf;
- struct list_head *q;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ struct srpc_buffer *buf;
+ struct list_head *q;
+ int i;
if (svc->sv_cpt_data == NULL)
return;
@@ -249,11 +249,11 @@ int srpc_add_buffer(struct swi_workitem *wi);
static int
srpc_service_init(struct srpc_service *svc)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- int nrpcs;
- int i;
- int j;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ int nrpcs;
+ int i;
+ int j;
svc->sv_shuttingdown = 0;
@@ -357,8 +357,8 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf,
int len, int options, lnet_process_id_t peer,
lnet_handle_md_t *mdh, srpc_event_t *ev)
{
- int rc;
- lnet_md_t md;
+ int rc;
+ lnet_md_t md;
lnet_handle_me_t meh;
rc = LNetMEAttach(portal, peer, matchbits, 0, LNET_UNLINK,
@@ -397,7 +397,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
int options, lnet_process_id_t peer, lnet_nid_t self,
lnet_handle_md_t *mdh, srpc_event_t *ev)
{
- int rc;
+ int rc;
lnet_md_t md;
md.user_ptr = ev;
@@ -471,9 +471,9 @@ static int
srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf)
__must_hold(&scd->scd_lock)
{
- struct srpc_service *sv = scd->scd_svc;
- struct srpc_msg *msg = &buf->buf_msg;
- int rc;
+ struct srpc_service *sv = scd->scd_svc;
+ struct srpc_msg *msg = &buf->buf_msg;
+ int rc;
LNetInvalidateHandle(&buf->buf_mdh);
list_add(&buf->buf_list, &scd->scd_buf_posted);
@@ -519,9 +519,9 @@ srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf)
int
srpc_add_buffer(struct swi_workitem *wi)
{
- struct srpc_service_cd *scd = wi->swi_workitem.wi_data;
- struct srpc_buffer *buf;
- int rc = 0;
+ struct srpc_service_cd *scd = wi->swi_workitem.wi_data;
+ struct srpc_buffer *buf;
+ int rc = 0;
/* it's called by workitem scheduler threads, these threads
* should have been set CPT affinity, so buffers will be posted
@@ -565,7 +565,7 @@ srpc_add_buffer(struct swi_workitem *wi)
}
if (rc != 0) {
- scd->scd_buf_err_stamp = get_seconds();
+ scd->scd_buf_err_stamp = ktime_get_real_seconds();
scd->scd_buf_err = rc;
LASSERT(scd->scd_buf_posting > 0);
@@ -579,9 +579,9 @@ srpc_add_buffer(struct swi_workitem *wi)
int
srpc_service_add_buffers(struct srpc_service *sv, int nbuffer)
{
- struct srpc_service_cd *scd;
- int rc = 0;
- int i;
+ struct srpc_service_cd *scd;
+ int rc = 0;
+ int i;
LASSERTF(nbuffer > 0, "nbuffer must be positive: %d\n", nbuffer);
@@ -633,9 +633,9 @@ srpc_service_add_buffers(struct srpc_service *sv, int nbuffer)
void
srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer)
{
- struct srpc_service_cd *scd;
- int num;
- int i;
+ struct srpc_service_cd *scd;
+ int num;
+ int i;
LASSERT(!sv->sv_shuttingdown);
@@ -653,9 +653,9 @@ srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer)
int
srpc_finish_service(struct srpc_service *sv)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ int i;
LASSERT(sv->sv_shuttingdown); /* srpc_shutdown_service called */
@@ -731,9 +731,9 @@ srpc_service_recycle_buffer(struct srpc_service_cd *scd, srpc_buffer_t *buf)
void
srpc_abort_service(struct srpc_service *sv)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ int i;
CDEBUG(D_NET, "Aborting service: id %d, name %s\n",
sv->sv_id, sv->sv_name);
@@ -756,10 +756,10 @@ srpc_abort_service(struct srpc_service *sv)
void
srpc_shutdown_service(srpc_service_t *sv)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- srpc_buffer_t *buf;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ srpc_buffer_t *buf;
+ int i;
CDEBUG(D_NET, "Shutting down service: id %d, name %s\n",
sv->sv_id, sv->sv_name);
@@ -792,7 +792,7 @@ static int
srpc_send_request(srpc_client_rpc_t *rpc)
{
srpc_event_t *ev = &rpc->crpc_reqstev;
- int rc;
+ int rc;
ev->ev_fired = 0;
ev->ev_data = rpc;
@@ -812,8 +812,8 @@ static int
srpc_prepare_reply(srpc_client_rpc_t *rpc)
{
srpc_event_t *ev = &rpc->crpc_replyev;
- __u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.rpyid;
- int rc;
+ __u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.rpyid;
+ int rc;
ev->ev_fired = 0;
ev->ev_data = rpc;
@@ -835,11 +835,11 @@ srpc_prepare_reply(srpc_client_rpc_t *rpc)
static int
srpc_prepare_bulk(srpc_client_rpc_t *rpc)
{
- srpc_bulk_t *bk = &rpc->crpc_bulk;
+ srpc_bulk_t *bk = &rpc->crpc_bulk;
srpc_event_t *ev = &rpc->crpc_bulkev;
__u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.bulkid;
- int rc;
- int opt;
+ int rc;
+ int opt;
LASSERT(bk->bk_niov <= LNET_MAX_IOV);
@@ -868,11 +868,11 @@ srpc_prepare_bulk(srpc_client_rpc_t *rpc)
static int
srpc_do_bulk(srpc_server_rpc_t *rpc)
{
- srpc_event_t *ev = &rpc->srpc_ev;
- srpc_bulk_t *bk = rpc->srpc_bulk;
- __u64 id = rpc->srpc_reqstbuf->buf_msg.msg_body.reqst.bulkid;
- int rc;
- int opt;
+ srpc_event_t *ev = &rpc->srpc_ev;
+ srpc_bulk_t *bk = rpc->srpc_bulk;
+ __u64 id = rpc->srpc_reqstbuf->buf_msg.msg_body.reqst.bulkid;
+ int rc;
+ int opt;
LASSERT(bk != NULL);
@@ -896,9 +896,9 @@ srpc_do_bulk(srpc_server_rpc_t *rpc)
static void
srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status)
{
- struct srpc_service_cd *scd = rpc->srpc_scd;
- struct srpc_service *sv = scd->scd_svc;
- srpc_buffer_t *buffer;
+ struct srpc_service_cd *scd = rpc->srpc_scd;
+ struct srpc_service *sv = scd->scd_svc;
+ srpc_buffer_t *buffer;
LASSERT(status != 0 || rpc->srpc_wi.swi_state == SWI_STATE_DONE);
@@ -959,11 +959,11 @@ srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status)
int
srpc_handle_rpc(swi_workitem_t *wi)
{
- struct srpc_server_rpc *rpc = wi->swi_workitem.wi_data;
- struct srpc_service_cd *scd = rpc->srpc_scd;
- struct srpc_service *sv = scd->scd_svc;
- srpc_event_t *ev = &rpc->srpc_ev;
- int rc = 0;
+ struct srpc_server_rpc *rpc = wi->swi_workitem.wi_data;
+ struct srpc_service_cd *scd = rpc->srpc_scd;
+ struct srpc_service *sv = scd->scd_svc;
+ srpc_event_t *ev = &rpc->srpc_ev;
+ int rc = 0;
LASSERT(wi == &rpc->srpc_wi);
@@ -989,7 +989,7 @@ srpc_handle_rpc(swi_workitem_t *wi)
default:
LBUG();
case SWI_STATE_NEWBORN: {
- srpc_msg_t *msg;
+ srpc_msg_t *msg;
srpc_generic_reply_t *reply;
msg = &rpc->srpc_reqstbuf->buf_msg;
@@ -1100,8 +1100,7 @@ srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc)
INIT_LIST_HEAD(&timer->stt_list);
timer->stt_data = rpc;
timer->stt_func = srpc_client_rpc_expired;
- timer->stt_expires = cfs_time_add(rpc->crpc_timeout,
- get_seconds());
+ timer->stt_expires = ktime_get_real_seconds() + rpc->crpc_timeout;
stt_add_timer(timer);
return;
}
@@ -1173,10 +1172,10 @@ srpc_client_rpc_done(srpc_client_rpc_t *rpc, int status)
int
srpc_send_rpc(swi_workitem_t *wi)
{
- int rc = 0;
+ int rc = 0;
srpc_client_rpc_t *rpc;
- srpc_msg_t *reply;
- int do_bulk;
+ srpc_msg_t *reply;
+ int do_bulk;
LASSERT(wi != NULL);
@@ -1355,17 +1354,16 @@ srpc_post_rpc(srpc_client_rpc_t *rpc)
return;
}
-
int
srpc_send_reply(struct srpc_server_rpc *rpc)
{
- srpc_event_t *ev = &rpc->srpc_ev;
- struct srpc_msg *msg = &rpc->srpc_replymsg;
- struct srpc_buffer *buffer = rpc->srpc_reqstbuf;
- struct srpc_service_cd *scd = rpc->srpc_scd;
- struct srpc_service *sv = scd->scd_svc;
- __u64 rpyid;
- int rc;
+ srpc_event_t *ev = &rpc->srpc_ev;
+ struct srpc_msg *msg = &rpc->srpc_replymsg;
+ struct srpc_buffer *buffer = rpc->srpc_reqstbuf;
+ struct srpc_service_cd *scd = rpc->srpc_scd;
+ struct srpc_service *sv = scd->scd_svc;
+ __u64 rpyid;
+ int rc;
LASSERT(buffer != NULL);
rpyid = buffer->buf_msg.msg_body.reqst.rpyid;
@@ -1403,14 +1401,14 @@ srpc_send_reply(struct srpc_server_rpc *rpc)
static void
srpc_lnet_ev_handler(lnet_event_t *ev)
{
- struct srpc_service_cd *scd;
- srpc_event_t *rpcev = ev->md.user_ptr;
+ struct srpc_service_cd *scd;
+ srpc_event_t *rpcev = ev->md.user_ptr;
srpc_client_rpc_t *crpc;
srpc_server_rpc_t *srpc;
- srpc_buffer_t *buffer;
- srpc_service_t *sv;
- srpc_msg_t *msg;
- srpc_msg_type_t type;
+ srpc_buffer_t *buffer;
+ srpc_service_t *sv;
+ srpc_msg_t *msg;
+ srpc_msg_type_t type;
LASSERT(!in_interrupt());
@@ -1488,7 +1486,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
}
if (scd->scd_buf_err_stamp != 0 &&
- scd->scd_buf_err_stamp < get_seconds()) {
+ scd->scd_buf_err_stamp < ktime_get_real_seconds()) {
/* re-enable adding buffer */
scd->scd_buf_err_stamp = 0;
scd->scd_buf_err = 0;
@@ -1581,7 +1579,6 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
}
}
-
int
srpc_startup(void)
{
@@ -1593,7 +1590,7 @@ srpc_startup(void)
/* 1 second pause to avoid timestamp reuse */
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(cfs_time_seconds(1));
- srpc_data.rpc_matchbits = ((__u64) get_seconds()) << 48;
+ srpc_data.rpc_matchbits = ((__u64)ktime_get_real_seconds()) << 48;
srpc_data.rpc_state = SRPC_STATE_NONE;
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/rpc.h b/kernel/drivers/staging/lustre/lnet/selftest/rpc.h
index fbeb75fe5..6b4a32a90 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/rpc.h
+++ b/kernel/drivers/staging/lustre/lnet/selftest/rpc.h
@@ -65,7 +65,6 @@ typedef enum {
SRPC_MSG_JOIN_REPLY = 17,
} srpc_msg_type_t;
-
/* CAVEAT EMPTOR:
* All srpc_*_reqst_t's 1st field must be matchbits of reply buffer,
* and 2nd field matchbits of bulk buffer if any.
@@ -79,60 +78,61 @@ typedef struct {
} WIRE_ATTR srpc_generic_reqst_t;
typedef struct {
- __u32 status;
- lst_sid_t sid;
+ __u32 status;
+ lst_sid_t sid;
} WIRE_ATTR srpc_generic_reply_t;
/* FRAMEWORK RPCs */
typedef struct {
- __u64 mksn_rpyid; /* reply buffer matchbits */
- lst_sid_t mksn_sid; /* session id */
- __u32 mksn_force; /* use brute force */
+ __u64 mksn_rpyid; /* reply buffer matchbits */
+ lst_sid_t mksn_sid; /* session id */
+ __u32 mksn_force; /* use brute force */
char mksn_name[LST_NAME_SIZE];
-} WIRE_ATTR srpc_mksn_reqst_t; /* make session request */
+} WIRE_ATTR srpc_mksn_reqst_t; /* make session request */
typedef struct {
- __u32 mksn_status; /* session status */
- lst_sid_t mksn_sid; /* session id */
- __u32 mksn_timeout; /* session timeout */
- char mksn_name[LST_NAME_SIZE];
+ __u32 mksn_status; /* session status */
+ lst_sid_t mksn_sid; /* session id */
+ __u32 mksn_timeout; /* session timeout */
+ char mksn_name[LST_NAME_SIZE];
} WIRE_ATTR srpc_mksn_reply_t; /* make session reply */
typedef struct {
- __u64 rmsn_rpyid; /* reply buffer matchbits */
- lst_sid_t rmsn_sid; /* session id */
+ __u64 rmsn_rpyid; /* reply buffer matchbits */
+ lst_sid_t rmsn_sid; /* session id */
} WIRE_ATTR srpc_rmsn_reqst_t; /* remove session request */
typedef struct {
- __u32 rmsn_status;
- lst_sid_t rmsn_sid; /* session id */
+ __u32 rmsn_status;
+ lst_sid_t rmsn_sid; /* session id */
} WIRE_ATTR srpc_rmsn_reply_t; /* remove session reply */
typedef struct {
- __u64 join_rpyid; /* reply buffer matchbits */
- lst_sid_t join_sid; /* session id to join */
- char join_group[LST_NAME_SIZE]; /* group name */
+ __u64 join_rpyid; /* reply buffer matchbits */
+ lst_sid_t join_sid; /* session id to join */
+ char join_group[LST_NAME_SIZE]; /* group name */
} WIRE_ATTR srpc_join_reqst_t;
typedef struct {
- __u32 join_status; /* returned status */
- lst_sid_t join_sid; /* session id */
- __u32 join_timeout; /* # seconds' inactivity to expire */
- char join_session[LST_NAME_SIZE]; /* session name */
+ __u32 join_status; /* returned status */
+ lst_sid_t join_sid; /* session id */
+ __u32 join_timeout; /* # seconds' inactivity to
+ * expire */
+ char join_session[LST_NAME_SIZE]; /* session name */
} WIRE_ATTR srpc_join_reply_t;
typedef struct {
- __u64 dbg_rpyid; /* reply buffer matchbits */
- lst_sid_t dbg_sid; /* session id */
- __u32 dbg_flags; /* bitmap of debug */
+ __u64 dbg_rpyid; /* reply buffer matchbits */
+ lst_sid_t dbg_sid; /* session id */
+ __u32 dbg_flags; /* bitmap of debug */
} WIRE_ATTR srpc_debug_reqst_t;
typedef struct {
- __u32 dbg_status; /* returned code */
- lst_sid_t dbg_sid; /* session id */
- __u32 dbg_timeout; /* session timeout */
- __u32 dbg_nbatch; /* # of batches in the node */
- char dbg_name[LST_NAME_SIZE]; /* session name */
+ __u32 dbg_status; /* returned code */
+ lst_sid_t dbg_sid; /* session id */
+ __u32 dbg_timeout; /* session timeout */
+ __u32 dbg_nbatch; /* # of batches in the node */
+ char dbg_name[LST_NAME_SIZE]; /* session name */
} WIRE_ATTR srpc_debug_reply_t;
#define SRPC_BATCH_OPC_RUN 1
@@ -140,55 +140,51 @@ typedef struct {
#define SRPC_BATCH_OPC_QUERY 3
typedef struct {
- __u64 bar_rpyid; /* reply buffer matchbits */
- lst_sid_t bar_sid; /* session id */
- lst_bid_t bar_bid; /* batch id */
- __u32 bar_opc; /* create/start/stop batch */
- __u32 bar_testidx; /* index of test */
- __u32 bar_arg; /* parameters */
+ __u64 bar_rpyid; /* reply buffer matchbits */
+ lst_sid_t bar_sid; /* session id */
+ lst_bid_t bar_bid; /* batch id */
+ __u32 bar_opc; /* create/start/stop batch */
+ __u32 bar_testidx; /* index of test */
+ __u32 bar_arg; /* parameters */
} WIRE_ATTR srpc_batch_reqst_t;
typedef struct {
- __u32 bar_status; /* status of request */
- lst_sid_t bar_sid; /* session id */
- __u32 bar_active; /* # of active tests in batch/test */
- __u32 bar_time; /* remained time */
+ __u32 bar_status; /* status of request */
+ lst_sid_t bar_sid; /* session id */
+ __u32 bar_active; /* # of active tests in batch/test */
+ __u32 bar_time; /* remained time */
} WIRE_ATTR srpc_batch_reply_t;
typedef struct {
- __u64 str_rpyid; /* reply buffer matchbits */
- lst_sid_t str_sid; /* session id */
- __u32 str_type; /* type of stat */
+ __u64 str_rpyid; /* reply buffer matchbits */
+ lst_sid_t str_sid; /* session id */
+ __u32 str_type; /* type of stat */
} WIRE_ATTR srpc_stat_reqst_t;
typedef struct {
- __u32 str_status;
- lst_sid_t str_sid;
- sfw_counters_t str_fw;
- srpc_counters_t str_rpc;
- lnet_counters_t str_lnet;
+ __u32 str_status;
+ lst_sid_t str_sid;
+ sfw_counters_t str_fw;
+ srpc_counters_t str_rpc;
+ lnet_counters_t str_lnet;
} WIRE_ATTR srpc_stat_reply_t;
typedef struct {
- __u32 blk_opc; /* bulk operation code */
- __u32 blk_npg; /* # of pages */
- __u32 blk_flags; /* reserved flags */
+ __u32 blk_opc; /* bulk operation code */
+ __u32 blk_npg; /* # of pages */
+ __u32 blk_flags; /* reserved flags */
} WIRE_ATTR test_bulk_req_t;
typedef struct {
- /** bulk operation code */
- __u16 blk_opc;
- /** data check flags */
- __u16 blk_flags;
- /** data length */
- __u32 blk_len;
- /** reserved: offset */
- __u32 blk_offset;
+ __u16 blk_opc; /* bulk operation code */
+ __u16 blk_flags; /* data check flags */
+ __u32 blk_len; /* data length */
+ __u32 blk_offset; /* reserved: offset */
} WIRE_ATTR test_bulk_req_v1_t;
typedef struct {
- __u32 png_size; /* size of ping message */
- __u32 png_flags; /* reserved flags */
+ __u32 png_size; /* size of ping message */
+ __u32 png_flags; /* reserved flags */
} WIRE_ATTR test_ping_req_t;
typedef struct {
@@ -197,8 +193,8 @@ typedef struct {
lst_sid_t tsr_sid; /* session id */
lst_bid_t tsr_bid; /* batch id */
__u32 tsr_service; /* test type: bulk|ping|... */
- /* test client loop count or # server buffers needed */
- __u32 tsr_loop;
+ __u32 tsr_loop; /* test client loop count or
+ * # server buffers needed */
__u32 tsr_concur; /* concurrency of test */
__u8 tsr_is_client; /* is test client or not */
__u8 tsr_stop_onerr; /* stop on error */
@@ -234,8 +230,8 @@ typedef struct {
typedef struct {
__u64 brw_rpyid; /* reply buffer matchbits */
__u64 brw_bulkid; /* bulk buffer matchbits */
- __u32 brw_rw; /* read or write */
- __u32 brw_len; /* bulk data len */
+ __u32 brw_rw; /* read or write */
+ __u32 brw_len; /* bulk data len */
__u32 brw_flags; /* bulk data patterns */
} WIRE_ATTR srpc_brw_reqst_t; /* bulk r/w request */
@@ -243,20 +239,16 @@ typedef struct {
__u32 brw_status;
} WIRE_ATTR srpc_brw_reply_t; /* bulk r/w reply */
-#define SRPC_MSG_MAGIC 0xeeb0f00d
-#define SRPC_MSG_VERSION 1
+#define SRPC_MSG_MAGIC 0xeeb0f00d
+#define SRPC_MSG_VERSION 1
typedef struct srpc_msg {
- /** magic number */
- __u32 msg_magic;
- /** message version number */
- __u32 msg_version;
- /** type of message body: srpc_msg_type_t */
- __u32 msg_type;
+ __u32 msg_magic; /* magic number */
+ __u32 msg_version; /* message version number */
+ __u32 msg_type; /* type of message body: srpc_msg_type_t */
__u32 msg_reserved0;
__u32 msg_reserved1;
- /** test session features */
- __u32 msg_ses_feats;
+ __u32 msg_ses_feats; /* test session features */
union {
srpc_generic_reqst_t reqst;
srpc_generic_reply_t reply;
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/selftest.h b/kernel/drivers/staging/lustre/lnet/selftest/selftest.h
index d48701834..8a77d3fdf 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/kernel/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -56,15 +56,14 @@
#define MADE_WITHOUT_COMPROMISE
#endif
-
-#define SWI_STATE_NEWBORN 0
-#define SWI_STATE_REPLY_SUBMITTED 1
-#define SWI_STATE_REPLY_SENT 2
-#define SWI_STATE_REQUEST_SUBMITTED 3
-#define SWI_STATE_REQUEST_SENT 4
-#define SWI_STATE_REPLY_RECEIVED 5
-#define SWI_STATE_BULK_STARTED 6
-#define SWI_STATE_DONE 10
+#define SWI_STATE_NEWBORN 0
+#define SWI_STATE_REPLY_SUBMITTED 1
+#define SWI_STATE_REPLY_SENT 2
+#define SWI_STATE_REQUEST_SUBMITTED 3
+#define SWI_STATE_REQUEST_SENT 4
+#define SWI_STATE_REPLY_RECEIVED 5
+#define SWI_STATE_BULK_STARTED 6
+#define SWI_STATE_DONE 10
/* forward refs */
struct srpc_service;
@@ -75,24 +74,24 @@ struct sfw_test_instance;
/* services below SRPC_FRAMEWORK_SERVICE_MAX_ID are framework
* services, e.g. create/modify session.
*/
-#define SRPC_SERVICE_DEBUG 0
-#define SRPC_SERVICE_MAKE_SESSION 1
-#define SRPC_SERVICE_REMOVE_SESSION 2
-#define SRPC_SERVICE_BATCH 3
-#define SRPC_SERVICE_TEST 4
-#define SRPC_SERVICE_QUERY_STAT 5
-#define SRPC_SERVICE_JOIN 6
-#define SRPC_FRAMEWORK_SERVICE_MAX_ID 10
+#define SRPC_SERVICE_DEBUG 0
+#define SRPC_SERVICE_MAKE_SESSION 1
+#define SRPC_SERVICE_REMOVE_SESSION 2
+#define SRPC_SERVICE_BATCH 3
+#define SRPC_SERVICE_TEST 4
+#define SRPC_SERVICE_QUERY_STAT 5
+#define SRPC_SERVICE_JOIN 6
+#define SRPC_FRAMEWORK_SERVICE_MAX_ID 10
/* other services start from SRPC_FRAMEWORK_SERVICE_MAX_ID+1 */
-#define SRPC_SERVICE_BRW 11
-#define SRPC_SERVICE_PING 12
-#define SRPC_SERVICE_MAX_ID 12
+#define SRPC_SERVICE_BRW 11
+#define SRPC_SERVICE_PING 12
+#define SRPC_SERVICE_MAX_ID 12
-#define SRPC_REQUEST_PORTAL 50
+#define SRPC_REQUEST_PORTAL 50
/* a lazy portal for framework RPC requests */
-#define SRPC_FRAMEWORK_REQUEST_PORTAL 51
+#define SRPC_FRAMEWORK_REQUEST_PORTAL 51
/* all reply/bulk RDMAs go to this portal */
-#define SRPC_RDMA_PORTAL 52
+#define SRPC_RDMA_PORTAL 52
static inline srpc_msg_type_t
srpc_service2request (int service)
@@ -136,7 +135,8 @@ srpc_service2reply (int service)
}
typedef enum {
- SRPC_BULK_REQ_RCVD = 1, /* passive bulk request(PUT sink/GET source) received */
+ SRPC_BULK_REQ_RCVD = 1, /* passive bulk request(PUT sink/GET source)
+ * received */
SRPC_BULK_PUT_SENT = 2, /* active bulk PUT sent (source) */
SRPC_BULK_GET_RPLD = 3, /* active bulk GET replied (sink) */
SRPC_REPLY_RCVD = 4, /* incoming reply received */
@@ -149,114 +149,114 @@ typedef enum {
typedef struct {
srpc_event_type_t ev_type; /* what's up */
lnet_event_kind_t ev_lnet; /* LNet event type */
- int ev_fired; /* LNet event fired? */
- int ev_status; /* LNet event status */
- void *ev_data; /* owning server/client RPC */
+ int ev_fired; /* LNet event fired? */
+ int ev_status; /* LNet event status */
+ void *ev_data; /* owning server/client RPC */
} srpc_event_t;
typedef struct {
- int bk_len; /* len of bulk data */
+ int bk_len; /* len of bulk data */
lnet_handle_md_t bk_mdh;
- int bk_sink; /* sink/source */
- int bk_niov; /* # iov in bk_iovs */
+ int bk_sink; /* sink/source */
+ int bk_niov; /* # iov in bk_iovs */
lnet_kiov_t bk_iovs[0];
} srpc_bulk_t; /* bulk descriptor */
/* message buffer descriptor */
typedef struct srpc_buffer {
- struct list_head buf_list; /* chain on srpc_service::*_msgq */
- srpc_msg_t buf_msg;
- lnet_handle_md_t buf_mdh;
- lnet_nid_t buf_self;
- lnet_process_id_t buf_peer;
+ struct list_head buf_list; /* chain on srpc_service::*_msgq */
+ srpc_msg_t buf_msg;
+ lnet_handle_md_t buf_mdh;
+ lnet_nid_t buf_self;
+ lnet_process_id_t buf_peer;
} srpc_buffer_t;
struct swi_workitem;
typedef int (*swi_action_t) (struct swi_workitem *);
typedef struct swi_workitem {
- struct cfs_wi_sched *swi_sched;
- cfs_workitem_t swi_workitem;
- swi_action_t swi_action;
- int swi_state;
+ struct cfs_wi_sched *swi_sched;
+ cfs_workitem_t swi_workitem;
+ swi_action_t swi_action;
+ int swi_state;
} swi_workitem_t;
/* server-side state of a RPC */
typedef struct srpc_server_rpc {
/* chain on srpc_service::*_rpcq */
- struct list_head srpc_list;
+ struct list_head srpc_list;
struct srpc_service_cd *srpc_scd;
- swi_workitem_t srpc_wi;
- srpc_event_t srpc_ev; /* bulk/reply event */
- lnet_nid_t srpc_self;
- lnet_process_id_t srpc_peer;
- srpc_msg_t srpc_replymsg;
- lnet_handle_md_t srpc_replymdh;
- srpc_buffer_t *srpc_reqstbuf;
- srpc_bulk_t *srpc_bulk;
-
- unsigned int srpc_aborted; /* being given up */
- int srpc_status;
- void (*srpc_done)(struct srpc_server_rpc *);
+ swi_workitem_t srpc_wi;
+ srpc_event_t srpc_ev; /* bulk/reply event */
+ lnet_nid_t srpc_self;
+ lnet_process_id_t srpc_peer;
+ srpc_msg_t srpc_replymsg;
+ lnet_handle_md_t srpc_replymdh;
+ srpc_buffer_t *srpc_reqstbuf;
+ srpc_bulk_t *srpc_bulk;
+
+ unsigned int srpc_aborted; /* being given up */
+ int srpc_status;
+ void (*srpc_done)(struct srpc_server_rpc *);
} srpc_server_rpc_t;
/* client-side state of a RPC */
typedef struct srpc_client_rpc {
- struct list_head crpc_list; /* chain on user's lists */
- spinlock_t crpc_lock; /* serialize */
- int crpc_service;
- atomic_t crpc_refcount;
- int crpc_timeout; /* # seconds to wait for reply */
- stt_timer_t crpc_timer;
- swi_workitem_t crpc_wi;
- lnet_process_id_t crpc_dest;
-
- void (*crpc_done)(struct srpc_client_rpc *);
- void (*crpc_fini)(struct srpc_client_rpc *);
- int crpc_status; /* completion status */
- void *crpc_priv; /* caller data */
+ struct list_head crpc_list; /* chain on user's lists */
+ spinlock_t crpc_lock; /* serialize */
+ int crpc_service;
+ atomic_t crpc_refcount;
+ int crpc_timeout; /* # seconds to wait for reply */
+ stt_timer_t crpc_timer;
+ swi_workitem_t crpc_wi;
+ lnet_process_id_t crpc_dest;
+
+ void (*crpc_done)(struct srpc_client_rpc *);
+ void (*crpc_fini)(struct srpc_client_rpc *);
+ int crpc_status; /* completion status */
+ void *crpc_priv; /* caller data */
/* state flags */
- unsigned int crpc_aborted:1; /* being given up */
- unsigned int crpc_closed:1; /* completed */
+ unsigned int crpc_aborted:1; /* being given up */
+ unsigned int crpc_closed:1; /* completed */
/* RPC events */
- srpc_event_t crpc_bulkev; /* bulk event */
- srpc_event_t crpc_reqstev; /* request event */
- srpc_event_t crpc_replyev; /* reply event */
+ srpc_event_t crpc_bulkev; /* bulk event */
+ srpc_event_t crpc_reqstev; /* request event */
+ srpc_event_t crpc_replyev; /* reply event */
/* bulk, request(reqst), and reply exchanged on wire */
- srpc_msg_t crpc_reqstmsg;
- srpc_msg_t crpc_replymsg;
- lnet_handle_md_t crpc_reqstmdh;
- lnet_handle_md_t crpc_replymdh;
- srpc_bulk_t crpc_bulk;
+ srpc_msg_t crpc_reqstmsg;
+ srpc_msg_t crpc_replymsg;
+ lnet_handle_md_t crpc_reqstmdh;
+ lnet_handle_md_t crpc_replymdh;
+ srpc_bulk_t crpc_bulk;
} srpc_client_rpc_t;
-#define srpc_client_rpc_size(rpc) \
+#define srpc_client_rpc_size(rpc) \
offsetof(srpc_client_rpc_t, crpc_bulk.bk_iovs[(rpc)->crpc_bulk.bk_niov])
-#define srpc_client_rpc_addref(rpc) \
-do { \
- CDEBUG(D_NET, "RPC[%p] -> %s (%d)++\n", \
- (rpc), libcfs_id2str((rpc)->crpc_dest), \
- atomic_read(&(rpc)->crpc_refcount)); \
- LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
- atomic_inc(&(rpc)->crpc_refcount); \
+#define srpc_client_rpc_addref(rpc) \
+do { \
+ CDEBUG(D_NET, "RPC[%p] -> %s (%d)++\n", \
+ (rpc), libcfs_id2str((rpc)->crpc_dest), \
+ atomic_read(&(rpc)->crpc_refcount)); \
+ LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
+ atomic_inc(&(rpc)->crpc_refcount); \
} while (0)
-#define srpc_client_rpc_decref(rpc) \
-do { \
- CDEBUG(D_NET, "RPC[%p] -> %s (%d)--\n", \
- (rpc), libcfs_id2str((rpc)->crpc_dest), \
- atomic_read(&(rpc)->crpc_refcount)); \
- LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
- if (atomic_dec_and_test(&(rpc)->crpc_refcount)) \
- srpc_destroy_client_rpc(rpc); \
+#define srpc_client_rpc_decref(rpc) \
+do { \
+ CDEBUG(D_NET, "RPC[%p] -> %s (%d)--\n", \
+ (rpc), libcfs_id2str((rpc)->crpc_dest), \
+ atomic_read(&(rpc)->crpc_refcount)); \
+ LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
+ if (atomic_dec_and_test(&(rpc)->crpc_refcount)) \
+ srpc_destroy_client_rpc(rpc); \
} while (0)
-#define srpc_event_pending(rpc) ((rpc)->crpc_bulkev.ev_fired == 0 || \
- (rpc)->crpc_reqstev.ev_fired == 0 || \
+#define srpc_event_pending(rpc) ((rpc)->crpc_bulkev.ev_fired == 0 || \
+ (rpc)->crpc_reqstev.ev_fired == 0 || \
(rpc)->crpc_replyev.ev_fired == 0)
/* CPU partition data of srpc service */
@@ -268,9 +268,9 @@ struct srpc_service_cd {
/** event buffer */
srpc_event_t scd_ev;
/** free RPC descriptors */
- struct list_head scd_rpc_free;
+ struct list_head scd_rpc_free;
/** in-flight RPCs */
- struct list_head scd_rpc_active;
+ struct list_head scd_rpc_active;
/** workitem for posting buffer */
swi_workitem_t scd_buf_wi;
/** CPT id */
@@ -278,7 +278,7 @@ struct srpc_service_cd {
/** error code for scd_buf_wi */
int scd_buf_err;
/** timestamp for scd_buf_err */
- unsigned long scd_buf_err_stamp;
+ time64_t scd_buf_err_stamp;
/** total # request buffers */
int scd_buf_total;
/** # posted request buffers */
@@ -290,9 +290,9 @@ struct srpc_service_cd {
/** increase/decrease some buffers */
int scd_buf_adjust;
/** posted message buffers */
- struct list_head scd_buf_posted;
+ struct list_head scd_buf_posted;
/** blocked for RPC descriptor */
- struct list_head scd_buf_blocked;
+ struct list_head scd_buf_blocked;
};
/* number of server workitems (mini-thread) for testing service */
@@ -318,40 +318,42 @@ typedef struct srpc_service {
* - sv_handler: process incoming RPC request
* - sv_bulk_ready: notify bulk data
*/
- int (*sv_handler) (srpc_server_rpc_t *);
- int (*sv_bulk_ready) (srpc_server_rpc_t *, int);
+ int (*sv_handler) (srpc_server_rpc_t *);
+ int (*sv_bulk_ready) (srpc_server_rpc_t *, int);
} srpc_service_t;
typedef struct {
- struct list_head sn_list; /* chain on fw_zombie_sessions */
- lst_sid_t sn_id; /* unique identifier */
- unsigned int sn_timeout; /* # seconds' inactivity to expire */
- int sn_timer_active;
- unsigned int sn_features;
- stt_timer_t sn_timer;
- struct list_head sn_batches; /* list of batches */
- char sn_name[LST_NAME_SIZE];
- atomic_t sn_refcount;
- atomic_t sn_brw_errors;
- atomic_t sn_ping_errors;
- unsigned long sn_started;
+ struct list_head sn_list; /* chain on fw_zombie_sessions */
+ lst_sid_t sn_id; /* unique identifier */
+ unsigned int sn_timeout; /* # seconds' inactivity to expire */
+ int sn_timer_active;
+ unsigned int sn_features;
+ stt_timer_t sn_timer;
+ struct list_head sn_batches; /* list of batches */
+ char sn_name[LST_NAME_SIZE];
+ atomic_t sn_refcount;
+ atomic_t sn_brw_errors;
+ atomic_t sn_ping_errors;
+ unsigned long sn_started;
} sfw_session_t;
#define sfw_sid_equal(sid0, sid1) ((sid0).ses_nid == (sid1).ses_nid && \
(sid0).ses_stamp == (sid1).ses_stamp)
typedef struct {
- struct list_head bat_list; /* chain on sn_batches */
- lst_bid_t bat_id; /* batch id */
- int bat_error; /* error code of batch */
- sfw_session_t *bat_session; /* batch's session */
- atomic_t bat_nactive; /* # of active tests */
- struct list_head bat_tests; /* test instances */
+ struct list_head bat_list; /* chain on sn_batches */
+ lst_bid_t bat_id; /* batch id */
+ int bat_error; /* error code of batch */
+ sfw_session_t *bat_session; /* batch's session */
+ atomic_t bat_nactive; /* # of active tests */
+ struct list_head bat_tests; /* test instances */
} sfw_batch_t;
typedef struct {
- int (*tso_init)(struct sfw_test_instance *tsi); /* initialize test client */
- void (*tso_fini)(struct sfw_test_instance *tsi); /* finalize test client */
+ int (*tso_init)(struct sfw_test_instance *tsi); /* initialize test
+ * client */
+ void (*tso_fini)(struct sfw_test_instance *tsi); /* finalize test
+ * client */
int (*tso_prep_rpc)(struct sfw_test_unit *tsu,
lnet_process_id_t dest,
srpc_client_rpc_t **rpc); /* prep a tests rpc */
@@ -360,29 +362,31 @@ typedef struct {
} sfw_test_client_ops_t;
typedef struct sfw_test_instance {
- struct list_head tsi_list; /* chain on batch */
- int tsi_service; /* test type */
- sfw_batch_t *tsi_batch; /* batch */
- sfw_test_client_ops_t *tsi_ops; /* test client operations */
+ struct list_head tsi_list; /* chain on batch */
+ int tsi_service; /* test type */
+ sfw_batch_t *tsi_batch; /* batch */
+ sfw_test_client_ops_t *tsi_ops; /* test client operation
+ */
/* public parameter for all test units */
- unsigned int tsi_is_client:1; /* is test client */
- unsigned int tsi_stoptsu_onerr:1; /* stop tsu on error */
- int tsi_concur; /* concurrency */
- int tsi_loop; /* loop count */
+ unsigned int tsi_is_client:1; /* is test client */
+ unsigned int tsi_stoptsu_onerr:1; /* stop tsu on error */
+ int tsi_concur; /* concurrency */
+ int tsi_loop; /* loop count */
/* status of test instance */
- spinlock_t tsi_lock; /* serialize */
- unsigned int tsi_stopping:1; /* test is stopping */
- atomic_t tsi_nactive; /* # of active test unit */
- struct list_head tsi_units; /* test units */
- struct list_head tsi_free_rpcs; /* free rpcs */
- struct list_head tsi_active_rpcs; /* active rpcs */
+ spinlock_t tsi_lock; /* serialize */
+ unsigned int tsi_stopping:1; /* test is stopping */
+ atomic_t tsi_nactive; /* # of active test
+ * unit */
+ struct list_head tsi_units; /* test units */
+ struct list_head tsi_free_rpcs; /* free rpcs */
+ struct list_head tsi_active_rpcs; /* active rpcs */
union {
- test_ping_req_t ping; /* ping parameter */
- test_bulk_req_t bulk_v0; /* bulk parameter */
- test_bulk_req_v1_t bulk_v1; /* bulk v1 parameter */
+ test_ping_req_t ping; /* ping parameter */
+ test_bulk_req_t bulk_v0; /* bulk parameter */
+ test_bulk_req_v1_t bulk_v1; /* bulk v1 parameter */
} tsi_u;
} sfw_test_instance_t;
@@ -394,18 +398,18 @@ typedef struct sfw_test_instance {
#define sfw_id_pages(n) (((n) + SFW_ID_PER_PAGE - 1) / SFW_ID_PER_PAGE)
typedef struct sfw_test_unit {
- struct list_head tsu_list; /* chain on lst_test_instance */
- lnet_process_id_t tsu_dest; /* id of dest node */
- int tsu_loop; /* loop count of the test */
- sfw_test_instance_t *tsu_instance; /* pointer to test instance */
- void *tsu_private; /* private data */
- swi_workitem_t tsu_worker; /* workitem of the test unit */
+ struct list_head tsu_list; /* chain on lst_test_instance */
+ lnet_process_id_t tsu_dest; /* id of dest node */
+ int tsu_loop; /* loop count of the test */
+ sfw_test_instance_t *tsu_instance; /* pointer to test instance */
+ void *tsu_private; /* private data */
+ swi_workitem_t tsu_worker; /* workitem of the test unit */
} sfw_test_unit_t;
typedef struct sfw_test_case {
- struct list_head tsc_list; /* chain on fw_tests */
- srpc_service_t *tsc_srv_service; /* test service */
- sfw_test_client_ops_t *tsc_cli_ops; /* ops of test client */
+ struct list_head tsc_list; /* chain on fw_tests */
+ srpc_service_t *tsc_srv_service; /* test service */
+ sfw_test_client_ops_t *tsc_cli_ops; /* ops of test client */
} sfw_test_case_t;
srpc_client_rpc_t *
@@ -492,7 +496,6 @@ swi_deschedule_workitem(swi_workitem_t *swi)
return cfs_wi_deschedule(swi->swi_sched, &swi->swi_workitem);
}
-
int sfw_startup(void);
int srpc_startup(void);
void sfw_shutdown(void);
@@ -501,9 +504,9 @@ void srpc_shutdown(void);
static inline void
srpc_destroy_client_rpc (srpc_client_rpc_t *rpc)
{
- LASSERT (rpc != NULL);
- LASSERT (!srpc_event_pending(rpc));
- LASSERT (atomic_read(&rpc->crpc_refcount) == 0);
+ LASSERT(rpc != NULL);
+ LASSERT(!srpc_event_pending(rpc));
+ LASSERT(atomic_read(&rpc->crpc_refcount) == 0);
if (rpc->crpc_fini == NULL) {
LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
@@ -520,7 +523,7 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer,
void (*rpc_done)(srpc_client_rpc_t *),
void (*rpc_fini)(srpc_client_rpc_t *), void *priv)
{
- LASSERT (nbulkiov <= LNET_MAX_IOV);
+ LASSERT(nbulkiov <= LNET_MAX_IOV);
memset(rpc, 0, offsetof(srpc_client_rpc_t,
crpc_bulk.bk_iovs[nbulkiov]));
@@ -531,13 +534,13 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer,
spin_lock_init(&rpc->crpc_lock);
atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */
- rpc->crpc_dest = peer;
- rpc->crpc_priv = priv;
+ rpc->crpc_dest = peer;
+ rpc->crpc_priv = priv;
rpc->crpc_service = service;
rpc->crpc_bulk.bk_len = bulklen;
rpc->crpc_bulk.bk_niov = nbulkiov;
- rpc->crpc_done = rpc_done;
- rpc->crpc_fini = rpc_fini;
+ rpc->crpc_done = rpc_done;
+ rpc->crpc_fini = rpc_fini;
LNetInvalidateHandle(&rpc->crpc_reqstmdh);
LNetInvalidateHandle(&rpc->crpc_replymdh);
LNetInvalidateHandle(&rpc->crpc_bulk.bk_mdh);
@@ -557,17 +560,17 @@ static inline const char *
swi_state2str (int state)
{
#define STATE2STR(x) case x: return #x
- switch(state) {
- default:
- LBUG();
- STATE2STR(SWI_STATE_NEWBORN);
- STATE2STR(SWI_STATE_REPLY_SUBMITTED);
- STATE2STR(SWI_STATE_REPLY_SENT);
- STATE2STR(SWI_STATE_REQUEST_SUBMITTED);
- STATE2STR(SWI_STATE_REQUEST_SENT);
- STATE2STR(SWI_STATE_REPLY_RECEIVED);
- STATE2STR(SWI_STATE_BULK_STARTED);
- STATE2STR(SWI_STATE_DONE);
+ switch (state) {
+ default:
+ LBUG();
+ STATE2STR(SWI_STATE_NEWBORN);
+ STATE2STR(SWI_STATE_REPLY_SUBMITTED);
+ STATE2STR(SWI_STATE_REPLY_SENT);
+ STATE2STR(SWI_STATE_REQUEST_SUBMITTED);
+ STATE2STR(SWI_STATE_REQUEST_SENT);
+ STATE2STR(SWI_STATE_REPLY_RECEIVED);
+ STATE2STR(SWI_STATE_BULK_STARTED);
+ STATE2STR(SWI_STATE_DONE);
}
#undef STATE2STR
}
@@ -578,7 +581,6 @@ swi_state2str (int state)
schedule_timeout(cfs_time_seconds(1) / 10); \
} while (0)
-
#define lst_wait_until(cond, lock, fmt, ...) \
do { \
int __I = 2; \
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/timer.c b/kernel/drivers/staging/lustre/lnet/selftest/timer.c
index 441f9472a..b98c08a10 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/kernel/drivers/staging/lustre/lnet/selftest/timer.c
@@ -42,7 +42,6 @@
#include "selftest.h"
-
/*
* Timers are implemented as a sorted queue of expiry times. The queue
* is slotted, with each slot holding timers which expire in a
@@ -50,7 +49,7 @@
* 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 (1 << STTIMER_MINPOLL)
#define STTIMER_SLOTTIMEMASK (~(STTIMER_SLOTTIME - 1))
#define STTIMER_NSLOTS (1 << 7)
@@ -58,13 +57,13 @@
(STTIMER_NSLOTS - 1))])
static struct st_timer_data {
- spinlock_t stt_lock;
- /* start time of the slot processed previously */
- unsigned long stt_prev_slot;
- struct list_head stt_hash[STTIMER_NSLOTS];
- int stt_shuttingdown;
- wait_queue_head_t stt_waitq;
- int stt_nthreads;
+ spinlock_t stt_lock;
+ unsigned long stt_prev_slot; /* start time of the slot processed
+ * previously */
+ struct list_head stt_hash[STTIMER_NSLOTS];
+ int stt_shuttingdown;
+ wait_queue_head_t stt_waitq;
+ int stt_nthreads;
} stt_data;
void
@@ -78,13 +77,13 @@ stt_add_timer(stt_timer_t *timer)
LASSERT(!stt_data.stt_shuttingdown);
LASSERT(timer->stt_func != NULL);
LASSERT(list_empty(&timer->stt_list));
- LASSERT(cfs_time_after(timer->stt_expires, get_seconds()));
+ LASSERT(timer->stt_expires > ktime_get_real_seconds());
/* a simple insertion sort */
list_for_each_prev(pos, STTIMER_SLOT(timer->stt_expires)) {
stt_timer_t *old = list_entry(pos, stt_timer_t, stt_list);
- if (cfs_time_aftereq(timer->stt_expires, old->stt_expires))
+ if (timer->stt_expires >= old->stt_expires)
break;
}
list_add(&timer->stt_list, pos);
@@ -122,15 +121,15 @@ stt_del_timer(stt_timer_t *timer)
/* called with stt_data.stt_lock held */
static int
-stt_expire_list(struct list_head *slot, unsigned long now)
+stt_expire_list(struct list_head *slot, time64_t now)
{
- int expired = 0;
+ int expired = 0;
stt_timer_t *timer;
while (!list_empty(slot)) {
timer = list_entry(slot->next, stt_timer_t, stt_list);
- if (cfs_time_after(timer->stt_expires, now))
+ if (timer->stt_expires > now)
break;
list_del_init(&timer->stt_list);
@@ -148,11 +147,11 @@ stt_expire_list(struct list_head *slot, unsigned long now)
static int
stt_check_timers(unsigned long *last)
{
- int expired = 0;
- unsigned long now;
+ int expired = 0;
+ time64_t now;
unsigned long this_slot;
- now = get_seconds();
+ now = ktime_get_real_seconds();
this_slot = now & STTIMER_SLOTTIMEMASK;
spin_lock(&stt_data.stt_lock);
@@ -167,7 +166,6 @@ stt_check_timers(unsigned long *last)
return expired;
}
-
static int
stt_timer_main(void *arg)
{
@@ -204,7 +202,6 @@ stt_start_timer_thread(void)
return 0;
}
-
int
stt_startup(void)
{
@@ -212,7 +209,7 @@ stt_startup(void)
int i;
stt_data.stt_shuttingdown = 0;
- stt_data.stt_prev_slot = get_seconds() & STTIMER_SLOTTIMEMASK;
+ stt_data.stt_prev_slot = ktime_get_real_seconds() & STTIMER_SLOTTIMEMASK;
spin_lock_init(&stt_data.stt_lock);
for (i = 0; i < STTIMER_NSLOTS; i++)
diff --git a/kernel/drivers/staging/lustre/lnet/selftest/timer.h b/kernel/drivers/staging/lustre/lnet/selftest/timer.h
index d727c1e2b..03e2ee294 100644
--- a/kernel/drivers/staging/lustre/lnet/selftest/timer.h
+++ b/kernel/drivers/staging/lustre/lnet/selftest/timer.h
@@ -39,15 +39,15 @@
#define __SELFTEST_TIMER_H__
typedef struct {
- struct list_head stt_list;
- unsigned long stt_expires;
- void (*stt_func) (void *);
- void *stt_data;
+ struct list_head stt_list;
+ time64_t stt_expires;
+ void (*stt_func) (void *);
+ void *stt_data;
} stt_timer_t;
-void stt_add_timer (stt_timer_t *timer);
-int stt_del_timer (stt_timer_t *timer);
-int stt_startup (void);
-void stt_shutdown (void);
+void stt_add_timer(stt_timer_t *timer);
+int stt_del_timer(stt_timer_t *timer);
+int stt_startup(void);
+void stt_shutdown(void);
#endif /* __SELFTEST_TIMER_H__ */
diff --git a/kernel/drivers/staging/lustre/lustre/fid/Makefile b/kernel/drivers/staging/lustre/lustre/fid/Makefile
index 5513ce416..b7ef314b4 100644
--- a/kernel/drivers/staging/lustre/lustre/fid/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/fid/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += fid.o
-fid-y := fid_request.o fid_lib.o
-fid-$(CONFIG_PROC_FS) += lproc_fid.o
+fid-y := fid_request.o fid_lib.o lproc_fid.o
diff --git a/kernel/drivers/staging/lustre/lustre/fid/fid_internal.h b/kernel/drivers/staging/lustre/lustre/fid/fid_internal.h
index b5e8da895..84daee115 100644
--- a/kernel/drivers/staging/lustre/lustre/fid/fid_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/fid/fid_internal.h
@@ -47,10 +47,6 @@
int seq_client_alloc_super(struct lu_client_seq *seq,
const struct lu_env *env);
-#if defined(CONFIG_PROC_FS)
-extern struct lprocfs_vars seq_client_proc_list[];
-#endif
-
-extern struct proc_dir_entry *seq_type_proc_dir;
+extern struct lprocfs_vars seq_client_debugfs_list[];
#endif /* __FID_INTERNAL_H */
diff --git a/kernel/drivers/staging/lustre/lustre/fid/fid_request.c b/kernel/drivers/staging/lustre/lustre/fid/fid_request.c
index 063441abf..7c45e7479 100644
--- a/kernel/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/kernel/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -53,6 +53,8 @@
#include "../include/lustre_mdc.h"
#include "fid_internal.h"
+static struct dentry *seq_debugfs_dir;
+
static int seq_client_rpc(struct lu_client_seq *seq,
struct lu_seq_range *output, __u32 opc,
const char *opcname)
@@ -148,19 +150,15 @@ int seq_client_alloc_super(struct lu_client_seq *seq,
mutex_lock(&seq->lcs_mutex);
- if (seq->lcs_srv) {
- rc = 0;
- } else {
- /* Check whether the connection to seq controller has been
- * setup (lcs_exp != NULL) */
- if (seq->lcs_exp == NULL) {
- mutex_unlock(&seq->lcs_mutex);
- return -EINPROGRESS;
- }
-
- rc = seq_client_rpc(seq, &seq->lcs_space,
- SEQ_ALLOC_SUPER, "super");
+ /* Check whether the connection to seq controller has been
+ * setup (lcs_exp != NULL) */
+ if (!seq->lcs_exp) {
+ mutex_unlock(&seq->lcs_mutex);
+ return -EINPROGRESS;
}
+
+ rc = seq_client_rpc(seq, &seq->lcs_space,
+ SEQ_ALLOC_SUPER, "super");
mutex_unlock(&seq->lcs_mutex);
return rc;
}
@@ -171,18 +169,14 @@ static int seq_client_alloc_meta(const struct lu_env *env,
{
int rc;
- if (seq->lcs_srv) {
- rc = 0;
- } else {
- do {
- /* If meta server return -EINPROGRESS or EAGAIN,
- * it means meta server might not be ready to
- * allocate super sequence from sequence controller
- * (MDT0)yet */
- rc = seq_client_rpc(seq, &seq->lcs_space,
- SEQ_ALLOC_META, "meta");
- } while (rc == -EINPROGRESS || rc == -EAGAIN);
- }
+ do {
+ /* If meta server return -EINPROGRESS or EAGAIN,
+ * it means meta server might not be ready to
+ * allocate super sequence from sequence controller
+ * (MDT0)yet */
+ rc = seq_client_rpc(seq, &seq->lcs_space,
+ SEQ_ALLOC_META, "meta");
+ } while (rc == -EINPROGRESS || rc == -EAGAIN);
return rc;
}
@@ -201,10 +195,9 @@ static int seq_client_alloc_seq(const struct lu_env *env,
CERROR("%s: Can't allocate new meta-sequence, rc %d\n",
seq->lcs_name, rc);
return rc;
- } else {
- CDEBUG(D_INFO, "%s: New range - "DRANGE"\n",
- seq->lcs_name, PRANGE(&seq->lcs_space));
}
+ CDEBUG(D_INFO, "%s: New range - "DRANGE"\n",
+ seq->lcs_name, PRANGE(&seq->lcs_space));
} else {
rc = 0;
}
@@ -247,57 +240,6 @@ static void seq_fid_alloc_fini(struct lu_client_seq *seq)
wake_up(&seq->lcs_waitq);
}
-/**
- * Allocate the whole seq to the caller.
- **/
-int seq_client_get_seq(const struct lu_env *env,
- struct lu_client_seq *seq, u64 *seqnr)
-{
- wait_queue_t link;
- int rc;
-
- LASSERT(seqnr != NULL);
- mutex_lock(&seq->lcs_mutex);
- init_waitqueue_entry(&link, current);
-
- while (1) {
- rc = seq_fid_alloc_prep(seq, &link);
- if (rc == 0)
- break;
- }
-
- rc = seq_client_alloc_seq(env, seq, seqnr);
- if (rc) {
- CERROR("%s: Can't allocate new sequence, rc %d\n",
- seq->lcs_name, rc);
- seq_fid_alloc_fini(seq);
- mutex_unlock(&seq->lcs_mutex);
- return rc;
- }
-
- CDEBUG(D_INFO, "%s: allocate sequence [0x%16.16Lx]\n",
- seq->lcs_name, *seqnr);
-
- /* Since the caller require the whole seq,
- * so marked this seq to be used */
- if (seq->lcs_type == LUSTRE_SEQ_METADATA)
- seq->lcs_fid.f_oid = LUSTRE_METADATA_SEQ_MAX_WIDTH;
- else
- seq->lcs_fid.f_oid = LUSTRE_DATA_SEQ_MAX_WIDTH;
-
- seq->lcs_fid.f_seq = *seqnr;
- seq->lcs_fid.f_ver = 0;
- /*
- * Inform caller that sequence switch is performed to allow it
- * to setup FLD for it.
- */
- seq_fid_alloc_fini(seq);
- mutex_unlock(&seq->lcs_mutex);
-
- return rc;
-}
-EXPORT_SYMBOL(seq_client_get_seq);
-
/* Allocate new fid on passed client @seq and save it to @fid. */
int seq_client_alloc_fid(const struct lu_env *env,
struct lu_client_seq *seq, struct lu_fid *fid)
@@ -400,37 +342,32 @@ void seq_client_flush(struct lu_client_seq *seq)
}
EXPORT_SYMBOL(seq_client_flush);
-static void seq_client_proc_fini(struct lu_client_seq *seq)
+static void seq_client_debugfs_fini(struct lu_client_seq *seq)
{
-#if defined(CONFIG_PROC_FS)
- if (seq->lcs_proc_dir) {
- if (!IS_ERR(seq->lcs_proc_dir))
- lprocfs_remove(&seq->lcs_proc_dir);
- seq->lcs_proc_dir = NULL;
- }
-#endif /* CONFIG_PROC_FS */
+ if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry))
+ ldebugfs_remove(&seq->lcs_debugfs_entry);
}
-static int seq_client_proc_init(struct lu_client_seq *seq)
+static int seq_client_debugfs_init(struct lu_client_seq *seq)
{
-#if defined(CONFIG_PROC_FS)
int rc;
- seq->lcs_proc_dir = lprocfs_register(seq->lcs_name,
- seq_type_proc_dir,
- NULL, NULL);
+ seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name,
+ seq_debugfs_dir,
+ NULL, NULL);
- if (IS_ERR(seq->lcs_proc_dir)) {
- CERROR("%s: LProcFS failed in seq-init\n",
- seq->lcs_name);
- rc = PTR_ERR(seq->lcs_proc_dir);
+ if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) {
+ CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name);
+ rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry)
+ : -ENOMEM;
+ seq->lcs_debugfs_entry = NULL;
return rc;
}
- rc = lprocfs_add_vars(seq->lcs_proc_dir,
- seq_client_proc_list, seq);
+ rc = ldebugfs_add_vars(seq->lcs_debugfs_entry,
+ seq_client_debugfs_list, seq);
if (rc) {
- CERROR("%s: Can't init sequence manager proc, rc %d\n",
+ CERROR("%s: Can't init sequence manager debugfs, rc %d\n",
seq->lcs_name, rc);
goto out_cleanup;
}
@@ -438,26 +375,30 @@ static int seq_client_proc_init(struct lu_client_seq *seq)
return 0;
out_cleanup:
- seq_client_proc_fini(seq);
+ seq_client_debugfs_fini(seq);
return rc;
+}
-#else /* CONFIG_PROC_FS */
- return 0;
-#endif
+static void seq_client_fini(struct lu_client_seq *seq)
+{
+ seq_client_debugfs_fini(seq);
+
+ if (seq->lcs_exp) {
+ class_export_put(seq->lcs_exp);
+ seq->lcs_exp = NULL;
+ }
}
-int seq_client_init(struct lu_client_seq *seq,
- struct obd_export *exp,
- enum lu_cli_type type,
- const char *prefix,
- struct lu_server_seq *srv)
+static int seq_client_init(struct lu_client_seq *seq,
+ struct obd_export *exp,
+ enum lu_cli_type type,
+ const char *prefix)
{
int rc;
LASSERT(seq != NULL);
LASSERT(prefix != NULL);
- seq->lcs_srv = srv;
seq->lcs_type = type;
mutex_init(&seq->lcs_mutex);
@@ -470,33 +411,16 @@ int seq_client_init(struct lu_client_seq *seq,
/* Make sure that things are clear before work is started. */
seq_client_flush(seq);
- if (exp != NULL)
- seq->lcs_exp = class_export_get(exp);
- else if (type == LUSTRE_SEQ_METADATA)
- LASSERT(seq->lcs_srv != NULL);
+ seq->lcs_exp = class_export_get(exp);
snprintf(seq->lcs_name, sizeof(seq->lcs_name),
"cli-%s", prefix);
- rc = seq_client_proc_init(seq);
+ rc = seq_client_debugfs_init(seq);
if (rc)
seq_client_fini(seq);
return rc;
}
-EXPORT_SYMBOL(seq_client_init);
-
-void seq_client_fini(struct lu_client_seq *seq)
-{
- seq_client_proc_fini(seq);
-
- if (seq->lcs_exp != NULL) {
- class_export_put(seq->lcs_exp);
- seq->lcs_exp = NULL;
- }
-
- seq->lcs_srv = NULL;
-}
-EXPORT_SYMBOL(seq_client_fini);
int client_fid_init(struct obd_device *obd,
struct obd_export *exp, enum lu_cli_type type)
@@ -505,12 +429,12 @@ int client_fid_init(struct obd_device *obd,
char *prefix;
int rc;
- OBD_ALLOC_PTR(cli->cl_seq);
- if (cli->cl_seq == NULL)
+ cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS);
+ if (!cli->cl_seq)
return -ENOMEM;
- OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
- if (prefix == NULL) {
+ prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS);
+ if (!prefix) {
rc = -ENOMEM;
goto out_free_seq;
}
@@ -518,14 +442,14 @@ int client_fid_init(struct obd_device *obd,
snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name);
/* Init client side sequence-manager */
- rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL);
- OBD_FREE(prefix, MAX_OBD_NAME + 5);
+ rc = seq_client_init(cli->cl_seq, exp, type, prefix);
+ kfree(prefix);
if (rc)
goto out_free_seq;
return rc;
out_free_seq:
- OBD_FREE_PTR(cli->cl_seq);
+ kfree(cli->cl_seq);
cli->cl_seq = NULL;
return rc;
}
@@ -537,7 +461,7 @@ int client_fid_fini(struct obd_device *obd)
if (cli->cl_seq != NULL) {
seq_client_fini(cli->cl_seq);
- OBD_FREE_PTR(cli->cl_seq);
+ kfree(cli->cl_seq);
cli->cl_seq = NULL;
}
@@ -545,22 +469,18 @@ int client_fid_fini(struct obd_device *obd)
}
EXPORT_SYMBOL(client_fid_fini);
-struct proc_dir_entry *seq_type_proc_dir;
-
static int __init fid_mod_init(void)
{
- seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME,
- proc_lustre_root,
- NULL, NULL);
- return PTR_ERR_OR_ZERO(seq_type_proc_dir);
+ seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME,
+ debugfs_lustre_root,
+ NULL, NULL);
+ return PTR_ERR_OR_ZERO(seq_debugfs_dir);
}
static void __exit fid_mod_exit(void)
{
- if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) {
- lprocfs_remove(&seq_type_proc_dir);
- seq_type_proc_dir = NULL;
- }
+ if (!IS_ERR_OR_NULL(seq_debugfs_dir))
+ ldebugfs_remove(&seq_debugfs_dir);
}
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
diff --git a/kernel/drivers/staging/lustre/lustre/fid/lproc_fid.c b/kernel/drivers/staging/lustre/lustre/fid/lproc_fid.c
index 783939dbd..ce90c1c54 100644
--- a/kernel/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/kernel/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -47,7 +47,6 @@
#include "../include/obd.h"
#include "../include/obd_class.h"
-#include "../include/dt_object.h"
#include "../include/obd_support.h"
#include "../include/lustre_req_layout.h"
#include "../include/lustre_fid.h"
@@ -59,8 +58,9 @@
* Note: this function is only used for testing, it is no safe for production
* use.
*/
-static int lprocfs_fid_write_common(const char __user *buffer, size_t count,
- struct lu_seq_range *range)
+static int
+ldebugfs_fid_write_common(const char __user *buffer, size_t count,
+ struct lu_seq_range *range)
{
struct lu_seq_range tmp;
int rc;
@@ -92,10 +92,11 @@ static int lprocfs_fid_write_common(const char __user *buffer, size_t count,
return count;
}
-/* Client side procfs stuff */
-static ssize_t lprocfs_fid_space_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+/* Client side debugfs stuff */
+static ssize_t
+ldebugfs_fid_space_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct lu_client_seq *seq;
int rc;
@@ -104,7 +105,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file,
LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex);
- rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space);
+ rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space);
if (rc == 0) {
CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
@@ -117,7 +118,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file,
}
static int
-lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
@@ -130,9 +131,10 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
return 0;
}
-static ssize_t lprocfs_fid_width_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t
+ldebugfs_fid_width_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct lu_client_seq *seq;
__u64 max;
@@ -154,10 +156,8 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file,
if (val <= max && val > 0) {
seq->lcs_width = val;
- if (rc == 0) {
- CDEBUG(D_INFO, "%s: Sequence size: %llu\n",
- seq->lcs_name, seq->lcs_width);
- }
+ CDEBUG(D_INFO, "%s: Sequence size: %llu\n", seq->lcs_name,
+ seq->lcs_width);
}
mutex_unlock(&seq->lcs_mutex);
@@ -166,7 +166,7 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file,
}
static int
-lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_width_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
@@ -180,7 +180,7 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
}
static int
-lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_fid_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
@@ -194,7 +194,7 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
}
static int
-lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_server_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
struct client_obd *cli;
@@ -204,22 +204,20 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
if (seq->lcs_exp != NULL) {
cli = &seq->lcs_exp->exp_obd->u.cli;
seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
- } else {
- seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
}
return 0;
}
-LPROC_SEQ_FOPS(lprocfs_fid_space);
-LPROC_SEQ_FOPS(lprocfs_fid_width);
-LPROC_SEQ_FOPS_RO(lprocfs_fid_server);
-LPROC_SEQ_FOPS_RO(lprocfs_fid_fid);
+LPROC_SEQ_FOPS(ldebugfs_fid_space);
+LPROC_SEQ_FOPS(ldebugfs_fid_width);
+LPROC_SEQ_FOPS_RO(ldebugfs_fid_server);
+LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid);
-struct lprocfs_vars seq_client_proc_list[] = {
- { "space", &lprocfs_fid_space_fops },
- { "width", &lprocfs_fid_width_fops },
- { "server", &lprocfs_fid_server_fops },
- { "fid", &lprocfs_fid_fid_fops },
+struct lprocfs_vars seq_client_debugfs_list[] = {
+ { "space", &ldebugfs_fid_space_fops },
+ { "width", &ldebugfs_fid_width_fops },
+ { "server", &ldebugfs_fid_server_fops },
+ { "fid", &ldebugfs_fid_fid_fops },
{ NULL }
};
diff --git a/kernel/drivers/staging/lustre/lustre/fld/Makefile b/kernel/drivers/staging/lustre/lustre/fld/Makefile
index 2bbf08433..646e315d1 100644
--- a/kernel/drivers/staging/lustre/lustre/fld/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/fld/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += fld.o
-fld-y := fld_request.o fld_cache.o
-fld-$(CONFIG_PROC_FS) += lproc_fld.o
+fld-y := fld_request.o fld_cache.o lproc_fld.o
diff --git a/kernel/drivers/staging/lustre/lustre/fld/fld_cache.c b/kernel/drivers/staging/lustre/lustre/fld/fld_cache.c
index 0d0a73745..446917484 100644
--- a/kernel/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/kernel/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -53,7 +53,6 @@
#include "../include/obd_support.h"
#include "../include/lprocfs_status.h"
-#include "../include/dt_object.h"
#include "../include/lustre_req_layout.h"
#include "../include/lustre_fld.h"
#include "fld_internal.h"
@@ -69,8 +68,8 @@ struct fld_cache *fld_cache_init(const char *name,
LASSERT(name != NULL);
LASSERT(cache_threshold < cache_size);
- OBD_ALLOC_PTR(cache);
- if (cache == NULL)
+ cache = kzalloc(sizeof(*cache), GFP_NOFS);
+ if (!cache)
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&cache->fci_entries_head);
@@ -116,7 +115,7 @@ void fld_cache_fini(struct fld_cache *cache)
CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache);
CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct);
- OBD_FREE_PTR(cache);
+ kfree(cache);
}
/**
@@ -128,7 +127,7 @@ void fld_cache_entry_delete(struct fld_cache *cache,
list_del(&node->fce_list);
list_del(&node->fce_lru);
cache->fci_cache_count--;
- OBD_FREE_PTR(node);
+ kfree(node);
}
/**
@@ -266,9 +265,9 @@ static void fld_cache_punch_hole(struct fld_cache *cache,
const u64 new_end = range->lsr_end;
struct fld_cache_entry *fldt;
- OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC);
+ fldt = kzalloc(sizeof(*fldt), GFP_ATOMIC);
if (!fldt) {
- OBD_FREE_PTR(f_new);
+ kfree(f_new);
/* overlap is not allowed, so dont mess up list. */
return;
}
@@ -315,7 +314,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache,
f_curr->fce_range.lsr_end = max(f_curr->fce_range.lsr_end,
new_end);
- OBD_FREE_PTR(f_new);
+ kfree(f_new);
fld_fix_new_list(cache);
} else if (new_start <= f_curr->fce_range.lsr_start &&
@@ -324,7 +323,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache,
* e.g. whole range migrated. update fld cache entry */
f_curr->fce_range = *range;
- OBD_FREE_PTR(f_new);
+ kfree(f_new);
fld_fix_new_list(cache);
} else if (f_curr->fce_range.lsr_start < new_start &&
@@ -364,7 +363,7 @@ struct fld_cache_entry
LASSERT(range_is_sane(range));
- OBD_ALLOC_PTR(f_new);
+ f_new = kzalloc(sizeof(*f_new), GFP_NOFS);
if (!f_new)
return ERR_PTR(-ENOMEM);
@@ -440,7 +439,7 @@ int fld_cache_insert(struct fld_cache *cache,
rc = fld_cache_insert_nolock(cache, flde);
write_unlock(&cache->fci_lock);
if (rc)
- OBD_FREE_PTR(flde);
+ kfree(flde);
return rc;
}
diff --git a/kernel/drivers/staging/lustre/lustre/fld/fld_internal.h b/kernel/drivers/staging/lustre/lustre/fld/fld_internal.h
index 68bec7658..fbb232de6 100644
--- a/kernel/drivers/staging/lustre/lustre/fld/fld_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/fld/fld_internal.h
@@ -42,7 +42,6 @@
#define __FLD_INTERNAL_H
#include "../include/lustre/lustre_idl.h"
-#include "../include/dt_object.h"
#include "../../include/linux/libcfs/libcfs.h"
#include "../include/lustre_req_layout.h"
@@ -142,10 +141,7 @@ extern struct lu_fld_hash fld_hash[];
int fld_client_rpc(struct obd_export *exp,
struct lu_seq_range *range, __u32 fld_op);
-#if defined(CONFIG_PROC_FS)
-extern struct lprocfs_vars fld_client_proc_list[];
-#endif
-
+extern struct lprocfs_vars fld_client_debugfs_list[];
struct fld_cache *fld_cache_init(const char *name,
int cache_size, int cache_threshold);
@@ -178,8 +174,6 @@ void fld_dump_cache_entries(struct fld_cache *cache);
struct fld_cache_entry
*fld_cache_entry_lookup_nolock(struct fld_cache *cache,
struct lu_seq_range *range);
-int fld_write_range(const struct lu_env *env, struct dt_object *dt,
- const struct lu_seq_range *range, struct thandle *th);
static inline const char *
fld_target_name(struct lu_fld_target *tar)
diff --git a/kernel/drivers/staging/lustre/lustre/fld/fld_request.c b/kernel/drivers/staging/lustre/lustre/fld/fld_request.c
index 6ac225e90..3fd91bc77 100644
--- a/kernel/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/kernel/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -52,7 +52,6 @@
#include "../include/obd_support.h"
#include "../include/lprocfs_status.h"
-#include "../include/dt_object.h"
#include "../include/lustre_req_layout.h"
#include "../include/lustre_fld.h"
#include "../include/lustre_mdc.h"
@@ -221,15 +220,15 @@ int fld_client_add_target(struct lu_client_fld *fld,
CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n",
fld->lcf_name, name, tar->ft_idx);
- OBD_ALLOC_PTR(target);
- if (target == NULL)
+ target = kzalloc(sizeof(*target), GFP_NOFS);
+ if (!target)
return -ENOMEM;
spin_lock(&fld->lcf_lock);
list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) {
if (tmp->ft_idx == tar->ft_idx) {
spin_unlock(&fld->lcf_lock);
- OBD_FREE_PTR(target);
+ kfree(target);
CERROR("Target %s exists in FLD and known as %s:#%llu\n",
name, fld_target_name(tmp), tmp->ft_idx);
return -EEXIST;
@@ -268,7 +267,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
if (target->ft_exp != NULL)
class_export_put(target->ft_exp);
- OBD_FREE_PTR(target);
+ kfree(target);
return 0;
}
}
@@ -277,58 +276,44 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
}
EXPORT_SYMBOL(fld_client_del_target);
-static struct proc_dir_entry *fld_type_proc_dir;
+static struct dentry *fld_debugfs_dir;
-#if defined(CONFIG_PROC_FS)
-static int fld_client_proc_init(struct lu_client_fld *fld)
+static int fld_client_debugfs_init(struct lu_client_fld *fld)
{
int rc;
- fld->lcf_proc_dir = lprocfs_register(fld->lcf_name,
- fld_type_proc_dir,
- NULL, NULL);
+ fld->lcf_debugfs_entry = ldebugfs_register(fld->lcf_name,
+ fld_debugfs_dir,
+ NULL, NULL);
- if (IS_ERR(fld->lcf_proc_dir)) {
- CERROR("%s: LProcFS failed in fld-init\n",
- fld->lcf_name);
- rc = PTR_ERR(fld->lcf_proc_dir);
+ if (IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) {
+ CERROR("%s: LdebugFS failed in fld-init\n", fld->lcf_name);
+ rc = fld->lcf_debugfs_entry ? PTR_ERR(fld->lcf_debugfs_entry)
+ : -ENOMEM;
+ fld->lcf_debugfs_entry = NULL;
return rc;
}
- rc = lprocfs_add_vars(fld->lcf_proc_dir,
- fld_client_proc_list, fld);
+ rc = ldebugfs_add_vars(fld->lcf_debugfs_entry,
+ fld_client_debugfs_list, fld);
if (rc) {
- CERROR("%s: Can't init FLD proc, rc %d\n",
- fld->lcf_name, rc);
+ CERROR("%s: Can't init FLD debufs, rc %d\n", fld->lcf_name, rc);
goto out_cleanup;
}
return 0;
out_cleanup:
- fld_client_proc_fini(fld);
+ fld_client_debugfs_fini(fld);
return rc;
}
-void fld_client_proc_fini(struct lu_client_fld *fld)
+void fld_client_debugfs_fini(struct lu_client_fld *fld)
{
- if (fld->lcf_proc_dir) {
- if (!IS_ERR(fld->lcf_proc_dir))
- lprocfs_remove(&fld->lcf_proc_dir);
- fld->lcf_proc_dir = NULL;
- }
-}
-#else
-static int fld_client_proc_init(struct lu_client_fld *fld)
-{
- return 0;
+ if (!IS_ERR_OR_NULL(fld->lcf_debugfs_entry))
+ ldebugfs_remove(&fld->lcf_debugfs_entry);
}
-
-void fld_client_proc_fini(struct lu_client_fld *fld)
-{
-}
-#endif
-EXPORT_SYMBOL(fld_client_proc_fini);
+EXPORT_SYMBOL(fld_client_debugfs_fini);
static inline int hash_is_sane(int hash)
{
@@ -372,7 +357,7 @@ int fld_client_init(struct lu_client_fld *fld,
goto out;
}
- rc = fld_client_proc_init(fld);
+ rc = fld_client_debugfs_init(fld);
if (rc)
goto out;
out:
@@ -396,7 +381,7 @@ void fld_client_fini(struct lu_client_fld *fld)
list_del(&target->ft_chain);
if (target->ft_exp != NULL)
class_export_put(target->ft_exp);
- OBD_FREE_PTR(target);
+ kfree(target);
}
spin_unlock(&fld->lcf_lock);
@@ -504,18 +489,16 @@ EXPORT_SYMBOL(fld_client_flush);
static int __init fld_mod_init(void)
{
- fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME,
- proc_lustre_root,
- NULL, NULL);
- return PTR_ERR_OR_ZERO(fld_type_proc_dir);
+ fld_debugfs_dir = ldebugfs_register(LUSTRE_FLD_NAME,
+ debugfs_lustre_root,
+ NULL, NULL);
+ return PTR_ERR_OR_ZERO(fld_debugfs_dir);
}
static void __exit fld_mod_exit(void)
{
- if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) {
- lprocfs_remove(&fld_type_proc_dir);
- fld_type_proc_dir = NULL;
- }
+ if (!IS_ERR_OR_NULL(fld_debugfs_dir))
+ ldebugfs_remove(&fld_debugfs_dir);
}
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
diff --git a/kernel/drivers/staging/lustre/lustre/fld/lproc_fld.c b/kernel/drivers/staging/lustre/lustre/fld/lproc_fld.c
index f53fdcfae..603f56e60 100644
--- a/kernel/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/kernel/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -48,7 +48,6 @@
#include "../include/obd.h"
#include "../include/obd_class.h"
-#include "../include/dt_object.h"
#include "../include/obd_support.h"
#include "../include/lustre_req_layout.h"
#include "../include/lustre_fld.h"
@@ -56,7 +55,7 @@
#include "fld_internal.h"
static int
-fld_proc_targets_seq_show(struct seq_file *m, void *unused)
+fld_debugfs_targets_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
struct lu_fld_target *target;
@@ -73,7 +72,7 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused)
}
static int
-fld_proc_hash_seq_show(struct seq_file *m, void *unused)
+fld_debugfs_hash_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
@@ -87,9 +86,9 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
}
static ssize_t
-fld_proc_hash_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+fld_debugfs_hash_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct lu_client_fld *fld;
struct lu_fld_hash *hash = NULL;
@@ -128,8 +127,8 @@ fld_proc_hash_seq_write(struct file *file,
}
static ssize_t
-fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *pos)
+fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer,
+ size_t count, loff_t *pos)
{
struct lu_client_fld *fld = file->private_data;
@@ -142,31 +141,26 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
return count;
}
-static int fld_proc_cache_flush_open(struct inode *inode, struct file *file)
-{
- file->private_data = PDE_DATA(inode);
- return 0;
-}
-
-static int fld_proc_cache_flush_release(struct inode *inode, struct file *file)
+static int
+fld_debugfs_cache_flush_release(struct inode *inode, struct file *file)
{
file->private_data = NULL;
return 0;
}
-static struct file_operations fld_proc_cache_flush_fops = {
+static struct file_operations fld_debugfs_cache_flush_fops = {
.owner = THIS_MODULE,
- .open = fld_proc_cache_flush_open,
- .write = fld_proc_cache_flush_write,
- .release = fld_proc_cache_flush_release,
+ .open = simple_open,
+ .write = fld_debugfs_cache_flush_write,
+ .release = fld_debugfs_cache_flush_release,
};
-LPROC_SEQ_FOPS_RO(fld_proc_targets);
-LPROC_SEQ_FOPS(fld_proc_hash);
+LPROC_SEQ_FOPS_RO(fld_debugfs_targets);
+LPROC_SEQ_FOPS(fld_debugfs_hash);
-struct lprocfs_vars fld_client_proc_list[] = {
- { "targets", &fld_proc_targets_fops },
- { "hash", &fld_proc_hash_fops },
- { "cache_flush", &fld_proc_cache_flush_fops },
+struct lprocfs_vars fld_client_debugfs_list[] = {
+ { "targets", &fld_debugfs_targets_fops },
+ { "hash", &fld_debugfs_hash_fops },
+ { "cache_flush", &fld_debugfs_cache_flush_fops },
{ NULL }
};
diff --git a/kernel/drivers/staging/lustre/lustre/include/cl_object.h b/kernel/drivers/staging/lustre/lustre/include/cl_object.h
index d56c8bea8..73564f8e3 100644
--- a/kernel/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/kernel/drivers/staging/lustre/lustre/include/cl_object.h
@@ -173,11 +173,11 @@ struct cl_attr {
*/
loff_t cat_kms;
/** Modification time. Measured in seconds since epoch. */
- time_t cat_mtime;
+ time64_t cat_mtime;
/** Access time. Measured in seconds since epoch. */
- time_t cat_atime;
+ time64_t cat_atime;
/** Change time. Measured in seconds since epoch. */
- time_t cat_ctime;
+ time64_t cat_ctime;
/**
* Blocks allocated to this cl_object on the server file system.
*
@@ -1095,7 +1095,7 @@ do { \
\
if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
cl_page_print(env, &msgdata, lu_cdebug_printer, page); \
- CDEBUG(mask, format , ## __VA_ARGS__); \
+ CDEBUG(mask, format, ## __VA_ARGS__); \
} \
} while (0)
@@ -1108,7 +1108,7 @@ do { \
\
if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
cl_page_header_print(env, &msgdata, lu_cdebug_printer, page); \
- CDEBUG(mask, format , ## __VA_ARGS__); \
+ CDEBUG(mask, format, ## __VA_ARGS__); \
} \
} while (0)
@@ -1119,6 +1119,7 @@ static inline int __page_in_use(const struct cl_page *page, int refc)
LASSERT(atomic_read(&page->cp_ref) > 0);
return (atomic_read(&page->cp_ref) > refc);
}
+
#define cl_page_in_use(pg) __page_in_use(pg, 1)
#define cl_page_in_use_noref(pg) __page_in_use(pg, 0)
@@ -1475,13 +1476,13 @@ enum cl_lock_flags {
* lock has been cancelled. This flag is never cleared once set (by
* cl_lock_cancel0()).
*/
- CLF_CANCELLED = 1 << 0,
+ CLF_CANCELLED = 1 << 0,
/** cancellation is pending for this lock. */
- CLF_CANCELPEND = 1 << 1,
+ CLF_CANCELPEND = 1 << 1,
/** destruction is pending for this lock. */
- CLF_DOOMED = 1 << 2,
+ CLF_DOOMED = 1 << 2,
/** from enqueue RPC reply upcall. */
- CLF_FROM_UPCALL= 1 << 3,
+ CLF_FROM_UPCALL = 1 << 3,
};
/**
@@ -1833,7 +1834,7 @@ do { \
\
if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
cl_lock_print(env, &msgdata, lu_cdebug_printer, lock); \
- CDEBUG(mask, format , ## __VA_ARGS__); \
+ CDEBUG(mask, format, ## __VA_ARGS__); \
} \
} while (0)
@@ -2020,7 +2021,6 @@ struct cl_io_slice {
struct list_head cis_linkage;
};
-
/**
* Per-layer io operations.
* \see vvp_io_ops, lov_io_ops, lovsub_io_ops, osc_io_ops
@@ -2294,7 +2294,6 @@ struct cl_io_rw_common {
int crw_nonblock;
};
-
/**
* State for io.
*
@@ -2335,7 +2334,6 @@ struct cl_io {
struct cl_setattr_io {
struct ost_lvb sa_attr;
unsigned int sa_valid;
- struct obd_capa *sa_capa;
} ci_setattr;
struct cl_fault_io {
/** page index within file. */
@@ -2354,7 +2352,6 @@ struct cl_io {
struct cl_fsync_io {
loff_t fi_start;
loff_t fi_end;
- struct obd_capa *fi_capa;
/** file system level fid */
struct lu_fid *fi_fid;
enum cl_fsync_mode fi_mode;
@@ -2473,8 +2470,6 @@ struct cl_io {
struct cl_req_attr {
/** Generic attributes for the server consumption. */
struct obdo *cra_oa;
- /** Capability. */
- struct obd_capa *cra_capa;
/** Jobid */
char cra_jobid[JOBSTATS_JOBID_SIZE];
};
@@ -2737,7 +2732,6 @@ struct cl_object *cl_object_find(const struct lu_env *env, struct cl_device *cd,
const struct cl_object_conf *c);
int cl_object_header_init(struct cl_object_header *h);
-void cl_object_header_fini(struct cl_object_header *h);
void cl_object_put (const struct lu_env *env, struct cl_object *o);
void cl_object_get (struct cl_object *o);
void cl_object_attr_lock (struct cl_object *o);
@@ -2752,7 +2746,6 @@ int cl_conf_set (const struct lu_env *env, struct cl_object *obj,
const struct cl_object_conf *conf);
void cl_object_prune (const struct lu_env *env, struct cl_object *obj);
void cl_object_kill (const struct lu_env *env, struct cl_object *obj);
-int cl_object_has_locks (struct cl_object *obj);
/**
* Returns true, iff \a o0 and \a o1 are slices of the same object.
@@ -2864,7 +2857,6 @@ int cl_page_flush (const struct lu_env *env, struct cl_io *io,
/** @} transfer */
-
/**
* \name helper routines
* Functions to discard, delete and export a cl_page.
@@ -2939,10 +2931,6 @@ void cl_lock_release (const struct lu_env *env, struct cl_lock *lock,
void cl_lock_user_add (const struct lu_env *env, struct cl_lock *lock);
void cl_lock_user_del (const struct lu_env *env, struct cl_lock *lock);
-enum cl_lock_state cl_lock_intransit(const struct lu_env *env,
- struct cl_lock *lock);
-void cl_lock_extransit(const struct lu_env *env, struct cl_lock *lock,
- enum cl_lock_state state);
int cl_lock_is_intransit(struct cl_lock *lock);
int cl_lock_enqueue_wait(const struct lu_env *env, struct cl_lock *lock,
@@ -2980,8 +2968,6 @@ int cl_lock_enqueue_wait(const struct lu_env *env, struct cl_lock *lock,
*
* @{ */
-int cl_enqueue (const struct lu_env *env, struct cl_lock *lock,
- struct cl_io *io, __u32 flags);
int cl_wait (const struct lu_env *env, struct cl_lock *lock);
void cl_unuse (const struct lu_env *env, struct cl_lock *lock);
int cl_enqueue_try(const struct lu_env *env, struct cl_lock *lock,
@@ -3000,7 +2986,6 @@ int cl_queue_match (const struct list_head *queue,
const struct cl_lock_descr *need);
void cl_lock_mutex_get (const struct lu_env *env, struct cl_lock *lock);
-int cl_lock_mutex_try (const struct lu_env *env, struct cl_lock *lock);
void cl_lock_mutex_put (const struct lu_env *env, struct cl_lock *lock);
int cl_lock_is_mutexed (struct cl_lock *lock);
int cl_lock_nr_mutexed (const struct lu_env *env);
@@ -3066,10 +3051,6 @@ int cl_io_submit_rw (const struct lu_env *env, struct cl_io *io,
int cl_io_submit_sync (const struct lu_env *env, struct cl_io *io,
enum cl_req_type iot, struct cl_2queue *queue,
long timeout);
-void cl_io_rw_advance (const struct lu_env *env, struct cl_io *io,
- size_t nob);
-int cl_io_cancel (const struct lu_env *env, struct cl_io *io,
- struct cl_page_list *queue);
int cl_io_is_going (const struct lu_env *env);
/**
@@ -3101,9 +3082,6 @@ static inline int cl_io_is_trunc(const struct cl_io *io)
struct cl_io *cl_io_top(struct cl_io *io);
-void cl_io_print(const struct lu_env *env, void *cookie,
- lu_printer_t printer, const struct cl_io *io);
-
#define CL_IO_SLICE_CLEAN(foo_io, base) \
do { \
typeof(foo_io) __foo_io = (foo_io); \
@@ -3145,26 +3123,13 @@ void cl_page_list_move (struct cl_page_list *dst, struct cl_page_list *src,
struct cl_page *page);
void cl_page_list_splice (struct cl_page_list *list,
struct cl_page_list *head);
-void cl_page_list_del (const struct lu_env *env,
- struct cl_page_list *plist, struct cl_page *page);
void cl_page_list_disown (const struct lu_env *env,
struct cl_io *io, struct cl_page_list *plist);
-int cl_page_list_own (const struct lu_env *env,
- struct cl_io *io, struct cl_page_list *plist);
-void cl_page_list_assume (const struct lu_env *env,
- struct cl_io *io, struct cl_page_list *plist);
-void cl_page_list_discard(const struct lu_env *env,
- struct cl_io *io, struct cl_page_list *plist);
-int cl_page_list_unmap (const struct lu_env *env,
- struct cl_io *io, struct cl_page_list *plist);
-void cl_page_list_fini (const struct lu_env *env, struct cl_page_list *plist);
void cl_2queue_init (struct cl_2queue *queue);
void cl_2queue_add (struct cl_2queue *queue, struct cl_page *page);
void cl_2queue_disown (const struct lu_env *env,
struct cl_io *io, struct cl_2queue *queue);
-void cl_2queue_assume (const struct lu_env *env,
- struct cl_io *io, struct cl_2queue *queue);
void cl_2queue_discard (const struct lu_env *env,
struct cl_io *io, struct cl_2queue *queue);
void cl_2queue_fini (const struct lu_env *env, struct cl_2queue *queue);
@@ -3257,7 +3222,6 @@ struct cl_env_nest {
void *cen_cookie;
};
-struct lu_env *cl_env_peek (int *refcheck);
struct lu_env *cl_env_get (int *refcheck);
struct lu_env *cl_env_alloc (int *refcheck, __u32 tags);
struct lu_env *cl_env_nested_get (struct cl_env_nest *nest);
@@ -3273,7 +3237,6 @@ void cl_env_unplant (struct lu_env *env, int *refcheck);
/*
* Misc
*/
-void cl_attr2lvb(struct ost_lvb *lvb, const struct cl_attr *attr);
void cl_lvb2attr(struct cl_attr *attr, const struct ost_lvb *lvb);
struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site,
diff --git a/kernel/drivers/staging/lustre/lustre/include/dt_object.h b/kernel/drivers/staging/lustre/lustre/include/dt_object.h
deleted file mode 100644
index be4c7d95e..000000000
--- a/kernel/drivers/staging/lustre/lustre/include/dt_object.h
+++ /dev/null
@@ -1,1499 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LUSTRE_DT_OBJECT_H
-#define __LUSTRE_DT_OBJECT_H
-
-/** \defgroup dt dt
- * Sub-class of lu_object with methods common for "data" objects in OST stack.
- *
- * Data objects behave like regular files: you can read/write them, get and
- * set their attributes. Implementation of dt interface is supposed to
- * implement some form of garbage collection, normally reference counting
- * (nlink) based one.
- *
- * Examples: osd (lustre/osd) is an implementation of dt interface.
- * @{
- */
-
-
-/*
- * super-class definitions.
- */
-#include "lu_object.h"
-
-#include "../../include/linux/libcfs/libcfs.h"
-
-struct seq_file;
-struct proc_dir_entry;
-struct lustre_cfg;
-
-struct thandle;
-struct dt_device;
-struct dt_object;
-struct dt_index_features;
-struct niobuf_local;
-struct niobuf_remote;
-struct ldlm_enqueue_info;
-
-typedef enum {
- MNTOPT_USERXATTR = 0x00000001,
- MNTOPT_ACL = 0x00000002,
-} mntopt_t;
-
-struct dt_device_param {
- unsigned ddp_max_name_len;
- unsigned ddp_max_nlink;
- unsigned ddp_block_shift;
- mntopt_t ddp_mntopts;
- unsigned ddp_max_ea_size;
- void *ddp_mnt; /* XXX: old code can retrieve mnt -bzzz */
- int ddp_mount_type;
- unsigned long long ddp_maxbytes;
- /* percentage of available space to reserve for grant error margin */
- int ddp_grant_reserved;
- /* per-inode space consumption */
- short ddp_inodespace;
- /* per-fragment grant overhead to be used by client for grant
- * calculation */
- int ddp_grant_frag;
-};
-
-/**
- * Per-transaction commit callback function
- */
-struct dt_txn_commit_cb;
-typedef void (*dt_cb_t)(struct lu_env *env, struct thandle *th,
- struct dt_txn_commit_cb *cb, int err);
-/**
- * Special per-transaction callback for cases when just commit callback
- * is needed and per-device callback are not convenient to use
- */
-#define TRANS_COMMIT_CB_MAGIC 0xa0a00a0a
-#define MAX_COMMIT_CB_STR_LEN 32
-
-struct dt_txn_commit_cb {
- struct list_head dcb_linkage;
- dt_cb_t dcb_func;
- __u32 dcb_magic;
- char dcb_name[MAX_COMMIT_CB_STR_LEN];
-};
-
-/**
- * Operations on dt device.
- */
-struct dt_device_operations {
- /**
- * Return device-wide statistics.
- */
- int (*dt_statfs)(const struct lu_env *env,
- struct dt_device *dev, struct obd_statfs *osfs);
- /**
- * Create transaction, described by \a param.
- */
- struct thandle *(*dt_trans_create)(const struct lu_env *env,
- struct dt_device *dev);
- /**
- * Start transaction, described by \a param.
- */
- int (*dt_trans_start)(const struct lu_env *env,
- struct dt_device *dev, struct thandle *th);
- /**
- * Finish previously started transaction.
- */
- int (*dt_trans_stop)(const struct lu_env *env,
- struct thandle *th);
- /**
- * Add commit callback to the transaction.
- */
- int (*dt_trans_cb_add)(struct thandle *th,
- struct dt_txn_commit_cb *dcb);
- /**
- * Return fid of root index object.
- */
- int (*dt_root_get)(const struct lu_env *env,
- struct dt_device *dev, struct lu_fid *f);
- /**
- * Return device configuration data.
- */
- void (*dt_conf_get)(const struct lu_env *env,
- const struct dt_device *dev,
- struct dt_device_param *param);
- /**
- * handling device state, mostly for tests
- */
- int (*dt_sync)(const struct lu_env *env, struct dt_device *dev);
- int (*dt_ro)(const struct lu_env *env, struct dt_device *dev);
- /**
- * Start a transaction commit asynchronously
- *
- * \param env environment
- * \param dev dt_device to start commit on
- *
- * \return 0 success, negative value if error
- */
- int (*dt_commit_async)(const struct lu_env *env,
- struct dt_device *dev);
- /**
- * Initialize capability context.
- */
- int (*dt_init_capa_ctxt)(const struct lu_env *env,
- struct dt_device *dev,
- int mode, unsigned long timeout,
- __u32 alg, struct lustre_capa_key *keys);
-};
-
-struct dt_index_features {
- /** required feature flags from enum dt_index_flags */
- __u32 dif_flags;
- /** minimal required key size */
- size_t dif_keysize_min;
- /** maximal required key size, 0 if no limit */
- size_t dif_keysize_max;
- /** minimal required record size */
- size_t dif_recsize_min;
- /** maximal required record size, 0 if no limit */
- size_t dif_recsize_max;
- /** pointer size for record */
- size_t dif_ptrsize;
-};
-
-enum dt_index_flags {
- /** index supports variable sized keys */
- DT_IND_VARKEY = 1 << 0,
- /** index supports variable sized records */
- DT_IND_VARREC = 1 << 1,
- /** index can be modified */
- DT_IND_UPDATE = 1 << 2,
- /** index supports records with non-unique (duplicate) keys */
- DT_IND_NONUNQ = 1 << 3,
- /**
- * index support fixed-size keys sorted with natural numerical way
- * and is able to return left-side value if no exact value found
- */
- DT_IND_RANGE = 1 << 4,
-};
-
-/**
- * Features, required from index to support file system directories (mapping
- * names to fids).
- */
-extern const struct dt_index_features dt_directory_features;
-extern const struct dt_index_features dt_otable_features;
-extern const struct dt_index_features dt_lfsck_features;
-
-/* index features supported by the accounting objects */
-extern const struct dt_index_features dt_acct_features;
-
-/* index features supported by the quota global indexes */
-extern const struct dt_index_features dt_quota_glb_features;
-
-/* index features supported by the quota slave indexes */
-extern const struct dt_index_features dt_quota_slv_features;
-
-/**
- * This is a general purpose dt allocation hint.
- * It now contains the parent object.
- * It can contain any allocation hint in the future.
- */
-struct dt_allocation_hint {
- struct dt_object *dah_parent;
- __u32 dah_mode;
-};
-
-/**
- * object type specifier.
- */
-
-enum dt_format_type {
- DFT_REGULAR,
- DFT_DIR,
- /** for mknod */
- DFT_NODE,
- /** for special index */
- DFT_INDEX,
- /** for symbolic link */
- DFT_SYM,
-};
-
-/**
- * object format specifier.
- */
-struct dt_object_format {
- /** type for dt object */
- enum dt_format_type dof_type;
- union {
- struct dof_regular {
- int striped;
- } dof_reg;
- struct dof_dir {
- } dof_dir;
- struct dof_node {
- } dof_node;
- /**
- * special index need feature as parameter to create
- * special idx
- */
- struct dof_index {
- const struct dt_index_features *di_feat;
- } dof_idx;
- } u;
-};
-
-enum dt_format_type dt_mode_to_dft(__u32 mode);
-
-typedef __u64 dt_obj_version_t;
-
-/**
- * Per-dt-object operations.
- */
-struct dt_object_operations {
- void (*do_read_lock)(const struct lu_env *env,
- struct dt_object *dt, unsigned role);
- void (*do_write_lock)(const struct lu_env *env,
- struct dt_object *dt, unsigned role);
- void (*do_read_unlock)(const struct lu_env *env,
- struct dt_object *dt);
- void (*do_write_unlock)(const struct lu_env *env,
- struct dt_object *dt);
- int (*do_write_locked)(const struct lu_env *env,
- struct dt_object *dt);
- /**
- * Note: following ->do_{x,}attr_{set,get}() operations are very
- * similar to ->moo_{x,}attr_{set,get}() operations in struct
- * md_object_operations (see md_object.h). These operations are not in
- * lu_object_operations, because ->do_{x,}attr_set() versions take
- * transaction handle as an argument (this transaction is started by
- * caller). We might factor ->do_{x,}attr_get() into
- * lu_object_operations, but that would break existing symmetry.
- */
-
- /**
- * Return standard attributes.
- *
- * precondition: lu_object_exists(&dt->do_lu);
- */
- int (*do_attr_get)(const struct lu_env *env,
- struct dt_object *dt, struct lu_attr *attr,
- struct lustre_capa *capa);
- /**
- * Set standard attributes.
- *
- * precondition: dt_object_exists(dt);
- */
- int (*do_declare_attr_set)(const struct lu_env *env,
- struct dt_object *dt,
- const struct lu_attr *attr,
- struct thandle *handle);
- int (*do_attr_set)(const struct lu_env *env,
- struct dt_object *dt,
- const struct lu_attr *attr,
- struct thandle *handle,
- struct lustre_capa *capa);
- /**
- * Return a value of an extended attribute.
- *
- * precondition: dt_object_exists(dt);
- */
- int (*do_xattr_get)(const struct lu_env *env, struct dt_object *dt,
- struct lu_buf *buf, const char *name,
- struct lustre_capa *capa);
- /**
- * Set value of an extended attribute.
- *
- * \a fl - flags from enum lu_xattr_flags
- *
- * precondition: dt_object_exists(dt);
- */
- int (*do_declare_xattr_set)(const struct lu_env *env,
- struct dt_object *dt,
- const struct lu_buf *buf,
- const char *name, int fl,
- struct thandle *handle);
- int (*do_xattr_set)(const struct lu_env *env,
- struct dt_object *dt, const struct lu_buf *buf,
- const char *name, int fl, struct thandle *handle,
- struct lustre_capa *capa);
- /**
- * Delete existing extended attribute.
- *
- * precondition: dt_object_exists(dt);
- */
- int (*do_declare_xattr_del)(const struct lu_env *env,
- struct dt_object *dt,
- const char *name, struct thandle *handle);
- int (*do_xattr_del)(const struct lu_env *env,
- struct dt_object *dt,
- const char *name, struct thandle *handle,
- struct lustre_capa *capa);
- /**
- * Place list of existing extended attributes into \a buf (which has
- * length len).
- *
- * precondition: dt_object_exists(dt);
- */
- int (*do_xattr_list)(const struct lu_env *env,
- struct dt_object *dt, struct lu_buf *buf,
- struct lustre_capa *capa);
- /**
- * Init allocation hint using parent object and child mode.
- * (1) The \a parent might be NULL if this is a partial creation for
- * remote object.
- * (2) The type of child is in \a child_mode.
- * (3) The result hint is stored in \a ah;
- */
- void (*do_ah_init)(const struct lu_env *env,
- struct dt_allocation_hint *ah,
- struct dt_object *parent,
- struct dt_object *child,
- umode_t child_mode);
- /**
- * Create new object on this device.
- *
- * precondition: !dt_object_exists(dt);
- * postcondition: ergo(result == 0, dt_object_exists(dt));
- */
- int (*do_declare_create)(const struct lu_env *env,
- struct dt_object *dt,
- struct lu_attr *attr,
- struct dt_allocation_hint *hint,
- struct dt_object_format *dof,
- struct thandle *th);
- int (*do_create)(const struct lu_env *env, struct dt_object *dt,
- struct lu_attr *attr,
- struct dt_allocation_hint *hint,
- struct dt_object_format *dof,
- struct thandle *th);
-
- /**
- Destroy object on this device
- * precondition: !dt_object_exists(dt);
- * postcondition: ergo(result == 0, dt_object_exists(dt));
- */
- int (*do_declare_destroy)(const struct lu_env *env,
- struct dt_object *dt,
- struct thandle *th);
- int (*do_destroy)(const struct lu_env *env, struct dt_object *dt,
- struct thandle *th);
-
- /**
- * Announce that this object is going to be used as an index. This
- * operation check that object supports indexing operations and
- * installs appropriate dt_index_operations vector on success.
- *
- * Also probes for features. Operation is successful if all required
- * features are supported.
- */
- int (*do_index_try)(const struct lu_env *env,
- struct dt_object *dt,
- const struct dt_index_features *feat);
- /**
- * Add nlink of the object
- * precondition: dt_object_exists(dt);
- */
- int (*do_declare_ref_add)(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th);
- int (*do_ref_add)(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th);
- /**
- * Del nlink of the object
- * precondition: dt_object_exists(dt);
- */
- int (*do_declare_ref_del)(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th);
- int (*do_ref_del)(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th);
-
- struct obd_capa *(*do_capa_get)(const struct lu_env *env,
- struct dt_object *dt,
- struct lustre_capa *old,
- __u64 opc);
- int (*do_object_sync)(const struct lu_env *env, struct dt_object *obj,
- __u64 start, __u64 end);
- /**
- * Get object info of next level. Currently, only get inode from osd.
- * This is only used by quota b=16542
- * precondition: dt_object_exists(dt);
- */
- int (*do_data_get)(const struct lu_env *env, struct dt_object *dt,
- void **data);
-
- /**
- * Lock object.
- */
- int (*do_object_lock)(const struct lu_env *env, struct dt_object *dt,
- struct lustre_handle *lh,
- struct ldlm_enqueue_info *einfo,
- void *policy);
-};
-
-/**
- * Per-dt-object operations on "file body".
- */
-struct dt_body_operations {
- /**
- * precondition: dt_object_exists(dt);
- */
- ssize_t (*dbo_read)(const struct lu_env *env, struct dt_object *dt,
- struct lu_buf *buf, loff_t *pos,
- struct lustre_capa *capa);
- /**
- * precondition: dt_object_exists(dt);
- */
- ssize_t (*dbo_declare_write)(const struct lu_env *env,
- struct dt_object *dt,
- const loff_t size, loff_t pos,
- struct thandle *handle);
- ssize_t (*dbo_write)(const struct lu_env *env, struct dt_object *dt,
- const struct lu_buf *buf, loff_t *pos,
- struct thandle *handle, struct lustre_capa *capa,
- int ignore_quota);
- /*
- * methods for zero-copy IO
- */
-
- /*
- * precondition: dt_object_exists(dt);
- * returns:
- * < 0 - error code
- * = 0 - illegal
- * > 0 - number of local buffers prepared
- */
- int (*dbo_bufs_get)(const struct lu_env *env, struct dt_object *dt,
- loff_t pos, ssize_t len, struct niobuf_local *lb,
- int rw, struct lustre_capa *capa);
- /*
- * precondition: dt_object_exists(dt);
- */
- int (*dbo_bufs_put)(const struct lu_env *env, struct dt_object *dt,
- struct niobuf_local *lb, int nr);
- /*
- * precondition: dt_object_exists(dt);
- */
- int (*dbo_write_prep)(const struct lu_env *env, struct dt_object *dt,
- struct niobuf_local *lb, int nr);
- /*
- * precondition: dt_object_exists(dt);
- */
- int (*dbo_declare_write_commit)(const struct lu_env *env,
- struct dt_object *dt,
- struct niobuf_local *,
- int, struct thandle *);
- /*
- * precondition: dt_object_exists(dt);
- */
- int (*dbo_write_commit)(const struct lu_env *env, struct dt_object *dt,
- struct niobuf_local *, int, struct thandle *);
- /*
- * precondition: dt_object_exists(dt);
- */
- int (*dbo_read_prep)(const struct lu_env *env, struct dt_object *dt,
- struct niobuf_local *lnb, int nr);
- int (*dbo_fiemap_get)(const struct lu_env *env, struct dt_object *dt,
- struct ll_user_fiemap *fm);
- /**
- * Punch object's content
- * precondition: regular object, not index
- */
- int (*dbo_declare_punch)(const struct lu_env *, struct dt_object *,
- __u64, __u64, struct thandle *th);
- int (*dbo_punch)(const struct lu_env *env, struct dt_object *dt,
- __u64 start, __u64 end, struct thandle *th,
- struct lustre_capa *capa);
-};
-
-/**
- * Incomplete type of index record.
- */
-struct dt_rec;
-
-/**
- * Incomplete type of index key.
- */
-struct dt_key;
-
-/**
- * Incomplete type of dt iterator.
- */
-struct dt_it;
-
-/**
- * Per-dt-object operations on object as index.
- */
-struct dt_index_operations {
- /**
- * precondition: dt_object_exists(dt);
- */
- int (*dio_lookup)(const struct lu_env *env, struct dt_object *dt,
- struct dt_rec *rec, const struct dt_key *key,
- struct lustre_capa *capa);
- /**
- * precondition: dt_object_exists(dt);
- */
- int (*dio_declare_insert)(const struct lu_env *env,
- struct dt_object *dt,
- const struct dt_rec *rec,
- const struct dt_key *key,
- struct thandle *handle);
- int (*dio_insert)(const struct lu_env *env, struct dt_object *dt,
- const struct dt_rec *rec, const struct dt_key *key,
- struct thandle *handle, struct lustre_capa *capa,
- int ignore_quota);
- /**
- * precondition: dt_object_exists(dt);
- */
- int (*dio_declare_delete)(const struct lu_env *env,
- struct dt_object *dt,
- const struct dt_key *key,
- struct thandle *handle);
- int (*dio_delete)(const struct lu_env *env, struct dt_object *dt,
- const struct dt_key *key, struct thandle *handle,
- struct lustre_capa *capa);
- /**
- * Iterator interface
- */
- struct dt_it_ops {
- /**
- * Allocate and initialize new iterator.
- *
- * precondition: dt_object_exists(dt);
- */
- struct dt_it *(*init)(const struct lu_env *env,
- struct dt_object *dt,
- __u32 attr,
- struct lustre_capa *capa);
- void (*fini)(const struct lu_env *env,
- struct dt_it *di);
- int (*get)(const struct lu_env *env,
- struct dt_it *di,
- const struct dt_key *key);
- void (*put)(const struct lu_env *env,
- struct dt_it *di);
- int (*next)(const struct lu_env *env,
- struct dt_it *di);
- struct dt_key *(*key)(const struct lu_env *env,
- const struct dt_it *di);
- int (*key_size)(const struct lu_env *env,
- const struct dt_it *di);
- int (*rec)(const struct lu_env *env,
- const struct dt_it *di,
- struct dt_rec *rec,
- __u32 attr);
- __u64 (*store)(const struct lu_env *env,
- const struct dt_it *di);
- int (*load)(const struct lu_env *env,
- const struct dt_it *di, __u64 hash);
- int (*key_rec)(const struct lu_env *env,
- const struct dt_it *di, void *key_rec);
- } dio_it;
-};
-
-enum dt_otable_it_valid {
- DOIV_ERROR_HANDLE = 0x0001,
-};
-
-enum dt_otable_it_flags {
- /* Exit when fail. */
- DOIF_FAILOUT = 0x0001,
-
- /* Reset iteration position to the device beginning. */
- DOIF_RESET = 0x0002,
-
- /* There is up layer component uses the iteration. */
- DOIF_OUTUSED = 0x0004,
-};
-
-/* otable based iteration needs to use the common DT interation APIs.
- * To initialize the iteration, it needs call dio_it::init() firstly.
- * Here is how the otable based iteration should prepare arguments to
- * call dt_it_ops::init().
- *
- * For otable based iteration, the 32-bits 'attr' for dt_it_ops::init()
- * is composed of two parts:
- * low 16-bits is for valid bits, high 16-bits is for flags bits. */
-#define DT_OTABLE_IT_FLAGS_SHIFT 16
-#define DT_OTABLE_IT_FLAGS_MASK 0xffff0000
-
-struct dt_device {
- struct lu_device dd_lu_dev;
- const struct dt_device_operations *dd_ops;
-
- /**
- * List of dt_txn_callback (see below). This is not protected in any
- * way, because callbacks are supposed to be added/deleted only during
- * single-threaded start-up shut-down procedures.
- */
- struct list_head dd_txn_callbacks;
-};
-
-int dt_device_init(struct dt_device *dev, struct lu_device_type *t);
-void dt_device_fini(struct dt_device *dev);
-
-static inline int lu_device_is_dt(const struct lu_device *d)
-{
- return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_DT);
-}
-
-static inline struct dt_device *lu2dt_dev(struct lu_device *l)
-{
- LASSERT(lu_device_is_dt(l));
- return container_of0(l, struct dt_device, dd_lu_dev);
-}
-
-struct dt_object {
- struct lu_object do_lu;
- const struct dt_object_operations *do_ops;
- const struct dt_body_operations *do_body_ops;
- const struct dt_index_operations *do_index_ops;
-};
-
-/*
- * In-core representation of per-device local object OID storage
- */
-struct local_oid_storage {
- /* all initialized llog systems on this node linked by this */
- struct list_head los_list;
-
- /* how many handle's reference this los has */
- atomic_t los_refcount;
- struct dt_device *los_dev;
- struct dt_object *los_obj;
-
- /* data used to generate new fids */
- struct mutex los_id_lock;
- __u64 los_seq;
- __u32 los_last_oid;
-};
-
-static inline struct dt_object *lu2dt(struct lu_object *l)
-{
- LASSERT(l == NULL || IS_ERR(l) || lu_device_is_dt(l->lo_dev));
- return container_of0(l, struct dt_object, do_lu);
-}
-
-int dt_object_init(struct dt_object *obj,
- struct lu_object_header *h, struct lu_device *d);
-
-void dt_object_fini(struct dt_object *obj);
-
-static inline int dt_object_exists(const struct dt_object *dt)
-{
- return lu_object_exists(&dt->do_lu);
-}
-
-static inline int dt_object_remote(const struct dt_object *dt)
-{
- return lu_object_remote(&dt->do_lu);
-}
-
-static inline struct dt_object *lu2dt_obj(struct lu_object *o)
-{
- LASSERT(ergo(o != NULL, lu_device_is_dt(o->lo_dev)));
- return container_of0(o, struct dt_object, do_lu);
-}
-
-/**
- * This is the general purpose transaction handle.
- * 1. Transaction Life Cycle
- * This transaction handle is allocated upon starting a new transaction,
- * and deallocated after this transaction is committed.
- * 2. Transaction Nesting
- * We do _NOT_ support nested transaction. So, every thread should only
- * have one active transaction, and a transaction only belongs to one
- * thread. Due to this, transaction handle need no reference count.
- * 3. Transaction & dt_object locking
- * dt_object locks should be taken inside transaction.
- * 4. Transaction & RPC
- * No RPC request should be issued inside transaction.
- */
-struct thandle {
- /** the dt device on which the transactions are executed */
- struct dt_device *th_dev;
-
- /** context for this transaction, tag is LCT_TX_HANDLE */
- struct lu_context th_ctx;
-
- /** additional tags (layers can add in declare) */
- __u32 th_tags;
-
- /** the last operation result in this transaction.
- * this value is used in recovery */
- __s32 th_result;
-
- /** whether we need sync commit */
- unsigned int th_sync:1;
-
- /* local transation, no need to inform other layers */
- unsigned int th_local:1;
-
- /* In DNE, one transaction can be disassemblied into
- * updates on several different MDTs, and these updates
- * will be attached to th_remote_update_list per target.
- * Only single thread will access the list, no need lock
- */
- struct list_head th_remote_update_list;
- struct update_request *th_current_request;
-};
-
-/**
- * Transaction call-backs.
- *
- * These are invoked by osd (or underlying transaction engine) when
- * transaction changes state.
- *
- * Call-backs are used by upper layers to modify transaction parameters and to
- * perform some actions on for each transaction state transition. Typical
- * example is mdt registering call-back to write into last-received file
- * before each transaction commit.
- */
-struct dt_txn_callback {
- int (*dtc_txn_start)(const struct lu_env *env,
- struct thandle *txn, void *cookie);
- int (*dtc_txn_stop)(const struct lu_env *env,
- struct thandle *txn, void *cookie);
- void (*dtc_txn_commit)(struct thandle *txn, void *cookie);
- void *dtc_cookie;
- __u32 dtc_tag;
- struct list_head dtc_linkage;
-};
-
-void dt_txn_callback_add(struct dt_device *dev, struct dt_txn_callback *cb);
-void dt_txn_callback_del(struct dt_device *dev, struct dt_txn_callback *cb);
-
-int dt_txn_hook_start(const struct lu_env *env,
- struct dt_device *dev, struct thandle *txn);
-int dt_txn_hook_stop(const struct lu_env *env, struct thandle *txn);
-void dt_txn_hook_commit(struct thandle *txn);
-
-int dt_try_as_dir(const struct lu_env *env, struct dt_object *obj);
-
-/**
- * Callback function used for parsing path.
- * \see llo_store_resolve
- */
-typedef int (*dt_entry_func_t)(const struct lu_env *env,
- const char *name,
- void *pvt);
-
-#define DT_MAX_PATH 1024
-
-int dt_path_parser(const struct lu_env *env,
- char *local, dt_entry_func_t entry_func,
- void *data);
-
-struct dt_object *
-dt_store_resolve(const struct lu_env *env, struct dt_device *dt,
- const char *path, struct lu_fid *fid);
-
-struct dt_object *dt_store_open(const struct lu_env *env,
- struct dt_device *dt,
- const char *dirname,
- const char *filename,
- struct lu_fid *fid);
-
-struct dt_object *dt_find_or_create(const struct lu_env *env,
- struct dt_device *dt,
- const struct lu_fid *fid,
- struct dt_object_format *dof,
- struct lu_attr *attr);
-
-struct dt_object *dt_locate_at(const struct lu_env *env,
- struct dt_device *dev,
- const struct lu_fid *fid,
- struct lu_device *top_dev);
-static inline struct dt_object *
-dt_locate(const struct lu_env *env, struct dt_device *dev,
- const struct lu_fid *fid)
-{
- return dt_locate_at(env, dev, fid, dev->dd_lu_dev.ld_site->ls_top_dev);
-}
-
-
-int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev,
- const struct lu_fid *first_fid,
- struct local_oid_storage **los);
-void local_oid_storage_fini(const struct lu_env *env,
- struct local_oid_storage *los);
-int local_object_fid_generate(const struct lu_env *env,
- struct local_oid_storage *los,
- struct lu_fid *fid);
-int local_object_declare_create(const struct lu_env *env,
- struct local_oid_storage *los,
- struct dt_object *o,
- struct lu_attr *attr,
- struct dt_object_format *dof,
- struct thandle *th);
-int local_object_create(const struct lu_env *env,
- struct local_oid_storage *los,
- struct dt_object *o,
- struct lu_attr *attr, struct dt_object_format *dof,
- struct thandle *th);
-struct dt_object *local_file_find_or_create(const struct lu_env *env,
- struct local_oid_storage *los,
- struct dt_object *parent,
- const char *name, __u32 mode);
-struct dt_object *local_file_find_or_create_with_fid(const struct lu_env *env,
- struct dt_device *dt,
- const struct lu_fid *fid,
- struct dt_object *parent,
- const char *name,
- __u32 mode);
-struct dt_object *
-local_index_find_or_create(const struct lu_env *env,
- struct local_oid_storage *los,
- struct dt_object *parent,
- const char *name, __u32 mode,
- const struct dt_index_features *ft);
-struct dt_object *
-local_index_find_or_create_with_fid(const struct lu_env *env,
- struct dt_device *dt,
- const struct lu_fid *fid,
- struct dt_object *parent,
- const char *name, __u32 mode,
- const struct dt_index_features *ft);
-int local_object_unlink(const struct lu_env *env, struct dt_device *dt,
- struct dt_object *parent, const char *name);
-
-static inline int dt_object_lock(const struct lu_env *env,
- struct dt_object *o, struct lustre_handle *lh,
- struct ldlm_enqueue_info *einfo,
- void *policy)
-{
- LASSERT(o);
- LASSERT(o->do_ops);
- LASSERT(o->do_ops->do_object_lock);
- return o->do_ops->do_object_lock(env, o, lh, einfo, policy);
-}
-
-int dt_lookup_dir(const struct lu_env *env, struct dt_object *dir,
- const char *name, struct lu_fid *fid);
-
-static inline int dt_object_sync(const struct lu_env *env, struct dt_object *o,
- __u64 start, __u64 end)
-{
- LASSERT(o);
- LASSERT(o->do_ops);
- LASSERT(o->do_ops->do_object_sync);
- return o->do_ops->do_object_sync(env, o, start, end);
-}
-
-int dt_declare_version_set(const struct lu_env *env, struct dt_object *o,
- struct thandle *th);
-void dt_version_set(const struct lu_env *env, struct dt_object *o,
- dt_obj_version_t version, struct thandle *th);
-dt_obj_version_t dt_version_get(const struct lu_env *env, struct dt_object *o);
-
-
-int dt_read(const struct lu_env *env, struct dt_object *dt,
- struct lu_buf *buf, loff_t *pos);
-int dt_record_read(const struct lu_env *env, struct dt_object *dt,
- struct lu_buf *buf, loff_t *pos);
-int dt_record_write(const struct lu_env *env, struct dt_object *dt,
- const struct lu_buf *buf, loff_t *pos, struct thandle *th);
-typedef int (*dt_index_page_build_t)(const struct lu_env *env,
- union lu_page *lp, int nob,
- const struct dt_it_ops *iops,
- struct dt_it *it, __u32 attr, void *arg);
-int dt_index_walk(const struct lu_env *env, struct dt_object *obj,
- const struct lu_rdpg *rdpg, dt_index_page_build_t filler,
- void *arg);
-int dt_index_read(const struct lu_env *env, struct dt_device *dev,
- struct idx_info *ii, const struct lu_rdpg *rdpg);
-
-static inline struct thandle *dt_trans_create(const struct lu_env *env,
- struct dt_device *d)
-{
- LASSERT(d->dd_ops->dt_trans_create);
- return d->dd_ops->dt_trans_create(env, d);
-}
-
-static inline int dt_trans_start(const struct lu_env *env,
- struct dt_device *d, struct thandle *th)
-{
- LASSERT(d->dd_ops->dt_trans_start);
- return d->dd_ops->dt_trans_start(env, d, th);
-}
-
-/* for this transaction hooks shouldn't be called */
-static inline int dt_trans_start_local(const struct lu_env *env,
- struct dt_device *d, struct thandle *th)
-{
- LASSERT(d->dd_ops->dt_trans_start);
- th->th_local = 1;
- return d->dd_ops->dt_trans_start(env, d, th);
-}
-
-static inline int dt_trans_stop(const struct lu_env *env,
- struct dt_device *d, struct thandle *th)
-{
- LASSERT(d->dd_ops->dt_trans_stop);
- return d->dd_ops->dt_trans_stop(env, th);
-}
-
-static inline int dt_trans_cb_add(struct thandle *th,
- struct dt_txn_commit_cb *dcb)
-{
- LASSERT(th->th_dev->dd_ops->dt_trans_cb_add);
- dcb->dcb_magic = TRANS_COMMIT_CB_MAGIC;
- return th->th_dev->dd_ops->dt_trans_cb_add(th, dcb);
-}
-/** @} dt */
-
-
-static inline int dt_declare_record_write(const struct lu_env *env,
- struct dt_object *dt,
- int size, loff_t pos,
- struct thandle *th)
-{
- int rc;
-
- LASSERTF(dt != NULL, "dt is NULL when we want to write record\n");
- LASSERT(th != NULL);
- LASSERT(dt->do_body_ops);
- LASSERT(dt->do_body_ops->dbo_declare_write);
- rc = dt->do_body_ops->dbo_declare_write(env, dt, size, pos, th);
- return rc;
-}
-
-static inline int dt_declare_create(const struct lu_env *env,
- struct dt_object *dt,
- struct lu_attr *attr,
- struct dt_allocation_hint *hint,
- struct dt_object_format *dof,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_declare_create);
- return dt->do_ops->do_declare_create(env, dt, attr, hint, dof, th);
-}
-
-static inline int dt_create(const struct lu_env *env,
- struct dt_object *dt,
- struct lu_attr *attr,
- struct dt_allocation_hint *hint,
- struct dt_object_format *dof,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_create);
- return dt->do_ops->do_create(env, dt, attr, hint, dof, th);
-}
-
-static inline int dt_declare_destroy(const struct lu_env *env,
- struct dt_object *dt,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_declare_destroy);
- return dt->do_ops->do_declare_destroy(env, dt, th);
-}
-
-static inline int dt_destroy(const struct lu_env *env,
- struct dt_object *dt,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_destroy);
- return dt->do_ops->do_destroy(env, dt, th);
-}
-
-static inline void dt_read_lock(const struct lu_env *env,
- struct dt_object *dt,
- unsigned role)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_read_lock);
- dt->do_ops->do_read_lock(env, dt, role);
-}
-
-static inline void dt_write_lock(const struct lu_env *env,
- struct dt_object *dt,
- unsigned role)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_write_lock);
- dt->do_ops->do_write_lock(env, dt, role);
-}
-
-static inline void dt_read_unlock(const struct lu_env *env,
- struct dt_object *dt)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_read_unlock);
- dt->do_ops->do_read_unlock(env, dt);
-}
-
-static inline void dt_write_unlock(const struct lu_env *env,
- struct dt_object *dt)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_write_unlock);
- dt->do_ops->do_write_unlock(env, dt);
-}
-
-static inline int dt_write_locked(const struct lu_env *env,
- struct dt_object *dt)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_write_locked);
- return dt->do_ops->do_write_locked(env, dt);
-}
-
-static inline int dt_attr_get(const struct lu_env *env, struct dt_object *dt,
- struct lu_attr *la, void *arg)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_attr_get);
- return dt->do_ops->do_attr_get(env, dt, la, arg);
-}
-
-static inline int dt_declare_attr_set(const struct lu_env *env,
- struct dt_object *dt,
- const struct lu_attr *la,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_declare_attr_set);
- return dt->do_ops->do_declare_attr_set(env, dt, la, th);
-}
-
-static inline int dt_attr_set(const struct lu_env *env, struct dt_object *dt,
- const struct lu_attr *la, struct thandle *th,
- struct lustre_capa *capa)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_attr_set);
- return dt->do_ops->do_attr_set(env, dt, la, th, capa);
-}
-
-static inline int dt_declare_ref_add(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_declare_ref_add);
- return dt->do_ops->do_declare_ref_add(env, dt, th);
-}
-
-static inline int dt_ref_add(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_ref_add);
- return dt->do_ops->do_ref_add(env, dt, th);
-}
-
-static inline int dt_declare_ref_del(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_declare_ref_del);
- return dt->do_ops->do_declare_ref_del(env, dt, th);
-}
-
-static inline int dt_ref_del(const struct lu_env *env,
- struct dt_object *dt, struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_ref_del);
- return dt->do_ops->do_ref_del(env, dt, th);
-}
-
-static inline struct obd_capa *dt_capa_get(const struct lu_env *env,
- struct dt_object *dt,
- struct lustre_capa *old, __u64 opc)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_ref_del);
- return dt->do_ops->do_capa_get(env, dt, old, opc);
-}
-
-static inline int dt_bufs_get(const struct lu_env *env, struct dt_object *d,
- struct niobuf_remote *rnb,
- struct niobuf_local *lnb, int rw,
- struct lustre_capa *capa)
-{
- LASSERT(d);
- LASSERT(d->do_body_ops);
- LASSERT(d->do_body_ops->dbo_bufs_get);
- return d->do_body_ops->dbo_bufs_get(env, d, rnb->offset,
- rnb->len, lnb, rw, capa);
-}
-
-static inline int dt_bufs_put(const struct lu_env *env, struct dt_object *d,
- struct niobuf_local *lnb, int n)
-{
- LASSERT(d);
- LASSERT(d->do_body_ops);
- LASSERT(d->do_body_ops->dbo_bufs_put);
- return d->do_body_ops->dbo_bufs_put(env, d, lnb, n);
-}
-
-static inline int dt_write_prep(const struct lu_env *env, struct dt_object *d,
- struct niobuf_local *lnb, int n)
-{
- LASSERT(d);
- LASSERT(d->do_body_ops);
- LASSERT(d->do_body_ops->dbo_write_prep);
- return d->do_body_ops->dbo_write_prep(env, d, lnb, n);
-}
-
-static inline int dt_declare_write_commit(const struct lu_env *env,
- struct dt_object *d,
- struct niobuf_local *lnb,
- int n, struct thandle *th)
-{
- LASSERTF(d != NULL, "dt is NULL when we want to declare write\n");
- LASSERT(th != NULL);
- return d->do_body_ops->dbo_declare_write_commit(env, d, lnb, n, th);
-}
-
-
-static inline int dt_write_commit(const struct lu_env *env,
- struct dt_object *d, struct niobuf_local *lnb,
- int n, struct thandle *th)
-{
- LASSERT(d);
- LASSERT(d->do_body_ops);
- LASSERT(d->do_body_ops->dbo_write_commit);
- return d->do_body_ops->dbo_write_commit(env, d, lnb, n, th);
-}
-
-static inline int dt_read_prep(const struct lu_env *env, struct dt_object *d,
- struct niobuf_local *lnb, int n)
-{
- LASSERT(d);
- LASSERT(d->do_body_ops);
- LASSERT(d->do_body_ops->dbo_read_prep);
- return d->do_body_ops->dbo_read_prep(env, d, lnb, n);
-}
-
-static inline int dt_declare_punch(const struct lu_env *env,
- struct dt_object *dt, __u64 start,
- __u64 end, struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_body_ops);
- LASSERT(dt->do_body_ops->dbo_declare_punch);
- return dt->do_body_ops->dbo_declare_punch(env, dt, start, end, th);
-}
-
-static inline int dt_punch(const struct lu_env *env, struct dt_object *dt,
- __u64 start, __u64 end, struct thandle *th,
- struct lustre_capa *capa)
-{
- LASSERT(dt);
- LASSERT(dt->do_body_ops);
- LASSERT(dt->do_body_ops->dbo_punch);
- return dt->do_body_ops->dbo_punch(env, dt, start, end, th, capa);
-}
-
-static inline int dt_fiemap_get(const struct lu_env *env, struct dt_object *d,
- struct ll_user_fiemap *fm)
-{
- LASSERT(d);
- if (d->do_body_ops == NULL)
- return -EPROTO;
- if (d->do_body_ops->dbo_fiemap_get == NULL)
- return -EOPNOTSUPP;
- return d->do_body_ops->dbo_fiemap_get(env, d, fm);
-}
-
-static inline int dt_statfs(const struct lu_env *env, struct dt_device *dev,
- struct obd_statfs *osfs)
-{
- LASSERT(dev);
- LASSERT(dev->dd_ops);
- LASSERT(dev->dd_ops->dt_statfs);
- return dev->dd_ops->dt_statfs(env, dev, osfs);
-}
-
-static inline int dt_root_get(const struct lu_env *env, struct dt_device *dev,
- struct lu_fid *f)
-{
- LASSERT(dev);
- LASSERT(dev->dd_ops);
- LASSERT(dev->dd_ops->dt_root_get);
- return dev->dd_ops->dt_root_get(env, dev, f);
-}
-
-static inline void dt_conf_get(const struct lu_env *env,
- const struct dt_device *dev,
- struct dt_device_param *param)
-{
- LASSERT(dev);
- LASSERT(dev->dd_ops);
- LASSERT(dev->dd_ops->dt_conf_get);
- return dev->dd_ops->dt_conf_get(env, dev, param);
-}
-
-static inline int dt_sync(const struct lu_env *env, struct dt_device *dev)
-{
- LASSERT(dev);
- LASSERT(dev->dd_ops);
- LASSERT(dev->dd_ops->dt_sync);
- return dev->dd_ops->dt_sync(env, dev);
-}
-
-static inline int dt_ro(const struct lu_env *env, struct dt_device *dev)
-{
- LASSERT(dev);
- LASSERT(dev->dd_ops);
- LASSERT(dev->dd_ops->dt_ro);
- return dev->dd_ops->dt_ro(env, dev);
-}
-
-static inline int dt_declare_insert(const struct lu_env *env,
- struct dt_object *dt,
- const struct dt_rec *rec,
- const struct dt_key *key,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_index_ops);
- LASSERT(dt->do_index_ops->dio_declare_insert);
- return dt->do_index_ops->dio_declare_insert(env, dt, rec, key, th);
-}
-
-static inline int dt_insert(const struct lu_env *env,
- struct dt_object *dt,
- const struct dt_rec *rec,
- const struct dt_key *key,
- struct thandle *th,
- struct lustre_capa *capa,
- int noquota)
-{
- LASSERT(dt);
- LASSERT(dt->do_index_ops);
- LASSERT(dt->do_index_ops->dio_insert);
- return dt->do_index_ops->dio_insert(env, dt, rec, key, th,
- capa, noquota);
-}
-
-static inline int dt_declare_xattr_del(const struct lu_env *env,
- struct dt_object *dt,
- const char *name,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_declare_xattr_del);
- return dt->do_ops->do_declare_xattr_del(env, dt, name, th);
-}
-
-static inline int dt_xattr_del(const struct lu_env *env,
- struct dt_object *dt, const char *name,
- struct thandle *th,
- struct lustre_capa *capa)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_xattr_del);
- return dt->do_ops->do_xattr_del(env, dt, name, th, capa);
-}
-
-static inline int dt_declare_xattr_set(const struct lu_env *env,
- struct dt_object *dt,
- const struct lu_buf *buf,
- const char *name, int fl,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_declare_xattr_set);
- return dt->do_ops->do_declare_xattr_set(env, dt, buf, name, fl, th);
-}
-
-static inline int dt_xattr_set(const struct lu_env *env,
- struct dt_object *dt, const struct lu_buf *buf,
- const char *name, int fl, struct thandle *th,
- struct lustre_capa *capa)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_xattr_set);
- return dt->do_ops->do_xattr_set(env, dt, buf, name, fl, th, capa);
-}
-
-static inline int dt_xattr_get(const struct lu_env *env,
- struct dt_object *dt, struct lu_buf *buf,
- const char *name, struct lustre_capa *capa)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_xattr_get);
- return dt->do_ops->do_xattr_get(env, dt, buf, name, capa);
-}
-
-static inline int dt_xattr_list(const struct lu_env *env,
- struct dt_object *dt, struct lu_buf *buf,
- struct lustre_capa *capa)
-{
- LASSERT(dt);
- LASSERT(dt->do_ops);
- LASSERT(dt->do_ops->do_xattr_list);
- return dt->do_ops->do_xattr_list(env, dt, buf, capa);
-}
-
-static inline int dt_declare_delete(const struct lu_env *env,
- struct dt_object *dt,
- const struct dt_key *key,
- struct thandle *th)
-{
- LASSERT(dt);
- LASSERT(dt->do_index_ops);
- LASSERT(dt->do_index_ops->dio_declare_delete);
- return dt->do_index_ops->dio_declare_delete(env, dt, key, th);
-}
-
-static inline int dt_delete(const struct lu_env *env,
- struct dt_object *dt,
- const struct dt_key *key,
- struct thandle *th,
- struct lustre_capa *capa)
-{
- LASSERT(dt);
- LASSERT(dt->do_index_ops);
- LASSERT(dt->do_index_ops->dio_delete);
- return dt->do_index_ops->dio_delete(env, dt, key, th, capa);
-}
-
-static inline int dt_commit_async(const struct lu_env *env,
- struct dt_device *dev)
-{
- LASSERT(dev);
- LASSERT(dev->dd_ops);
- LASSERT(dev->dd_ops->dt_commit_async);
- return dev->dd_ops->dt_commit_async(env, dev);
-}
-
-static inline int dt_init_capa_ctxt(const struct lu_env *env,
- struct dt_device *dev,
- int mode, unsigned long timeout,
- __u32 alg, struct lustre_capa_key *keys)
-{
- LASSERT(dev);
- LASSERT(dev->dd_ops);
- LASSERT(dev->dd_ops->dt_init_capa_ctxt);
- return dev->dd_ops->dt_init_capa_ctxt(env, dev, mode,
- timeout, alg, keys);
-}
-
-static inline int dt_lookup(const struct lu_env *env,
- struct dt_object *dt,
- struct dt_rec *rec,
- const struct dt_key *key,
- struct lustre_capa *capa)
-{
- int ret;
-
- LASSERT(dt);
- LASSERT(dt->do_index_ops);
- LASSERT(dt->do_index_ops->dio_lookup);
-
- ret = dt->do_index_ops->dio_lookup(env, dt, rec, key, capa);
- if (ret > 0)
- ret = 0;
- else if (ret == 0)
- ret = -ENOENT;
- return ret;
-}
-
-#define LU221_BAD_TIME (0x80000000U + 24 * 3600)
-
-struct dt_find_hint {
- struct lu_fid *dfh_fid;
- struct dt_device *dfh_dt;
- struct dt_object *dfh_o;
-};
-
-struct dt_thread_info {
- char dti_buf[DT_MAX_PATH];
- struct dt_find_hint dti_dfh;
- struct lu_attr dti_attr;
- struct lu_fid dti_fid;
- struct dt_object_format dti_dof;
- struct lustre_mdt_attrs dti_lma;
- struct lu_buf dti_lb;
- loff_t dti_off;
-};
-
-extern struct lu_context_key dt_key;
-
-static inline struct dt_thread_info *dt_info(const struct lu_env *env)
-{
- struct dt_thread_info *dti;
-
- dti = lu_context_key_get(&env->le_ctx, &dt_key);
- LASSERT(dti);
- return dti;
-}
-
-int dt_global_init(void);
-void dt_global_fini(void);
-
-#if defined (CONFIG_PROC_FS)
-int lprocfs_dt_rd_blksize(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-int lprocfs_dt_rd_kbytesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-int lprocfs_dt_rd_kbytesavail(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-#endif /* CONFIG_PROC_FS */
-
-#endif /* __LUSTRE_DT_OBJECT_H */
diff --git a/kernel/drivers/staging/lustre/lustre/include/interval_tree.h b/kernel/drivers/staging/lustre/lustre/include/interval_tree.h
index bf9027d5f..f6df3f33e 100644
--- a/kernel/drivers/staging/lustre/lustre/include/interval_tree.h
+++ b/kernel/drivers/staging/lustre/lustre/include/interval_tree.h
@@ -67,11 +67,6 @@ static inline int interval_is_intree(struct interval_node *node)
return node->in_intree == 1;
}
-static inline __u64 interval_low(struct interval_node *node)
-{
- return node->in_extent.start;
-}
-
static inline __u64 interval_high(struct interval_node *node)
{
return node->in_extent.end;
@@ -86,39 +81,8 @@ static inline void interval_set(struct interval_node *node,
node->in_max_high = end;
}
-/* Rules to write an interval callback.
- * - the callback returns INTERVAL_ITER_STOP when it thinks the iteration
- * should be stopped. It will then cause the iteration function to return
- * immediately with return value INTERVAL_ITER_STOP.
- * - callbacks for interval_iterate and interval_iterate_reverse: Every
- * nodes in the tree will be set to @node before the callback being called
- * - callback for interval_search: Only overlapped node will be set to @node
- * before the callback being called.
- */
-typedef enum interval_iter (*interval_callback_t)(struct interval_node *node,
- void *args);
-
struct interval_node *interval_insert(struct interval_node *node,
struct interval_node **root);
void interval_erase(struct interval_node *node, struct interval_node **root);
-/* Search the extents in the tree and call @func for each overlapped
- * extents. */
-enum interval_iter interval_search(struct interval_node *root,
- struct interval_node_extent *ex,
- interval_callback_t func, void *data);
-
-/* Iterate every node in the tree - by reverse order or regular order. */
-enum interval_iter interval_iterate(struct interval_node *root,
- interval_callback_t func, void *data);
-enum interval_iter interval_iterate_reverse(struct interval_node *root,
- interval_callback_t func, void *data);
-
-void interval_expand(struct interval_node *root,
- struct interval_node_extent *ext,
- struct interval_node_extent *limiter);
-int interval_is_overlapped(struct interval_node *root,
- struct interval_node_extent *ex);
-struct interval_node *interval_find(struct interval_node *root,
- struct interval_node_extent *ex);
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/include/lclient.h b/kernel/drivers/staging/lustre/lustre/include/lclient.h
index c5c3a8d9e..36e7a6767 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lclient.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lclient.h
@@ -71,7 +71,6 @@ enum ccc_setattr_lock_type {
SETATTR_MATCH_LOCK
};
-
/**
* IO state private to vvp or slp layers.
*/
@@ -233,8 +232,6 @@ static inline struct ccc_page *cl2ccc_page(const struct cl_page_slice *slice)
return container_of(slice, struct ccc_page, cpg_cl);
}
-struct cl_page *ccc_vmpage_page_transient(struct page *vmpage);
-
struct ccc_device {
struct cl_device cdv_cl;
struct super_block *cdv_sb;
@@ -289,33 +286,13 @@ void ccc_object_free(const struct lu_env *env, struct lu_object *obj);
int ccc_lock_init(const struct lu_env *env, struct cl_object *obj,
struct cl_lock *lock, const struct cl_io *io,
const struct cl_lock_operations *lkops);
-int ccc_attr_set(const struct lu_env *env, struct cl_object *obj,
- const struct cl_attr *attr, unsigned valid);
int ccc_object_glimpse(const struct lu_env *env,
const struct cl_object *obj, struct ost_lvb *lvb);
-int ccc_conf_set(const struct lu_env *env, struct cl_object *obj,
- const struct cl_object_conf *conf);
struct page *ccc_page_vmpage(const struct lu_env *env,
const struct cl_page_slice *slice);
int ccc_page_is_under_lock(const struct lu_env *env,
const struct cl_page_slice *slice, struct cl_io *io);
int ccc_fail(const struct lu_env *env, const struct cl_page_slice *slice);
-void ccc_transient_page_verify(const struct cl_page *page);
-int ccc_transient_page_own(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *io, int nonblock);
-void ccc_transient_page_assume(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *io);
-void ccc_transient_page_unassume(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *io);
-void ccc_transient_page_disown(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *io);
-void ccc_transient_page_discard(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *io);
int ccc_transient_page_prep(const struct lu_env *env,
const struct cl_page_slice *slice,
struct cl_io *io);
@@ -336,7 +313,6 @@ void ccc_lock_state(const struct lu_env *env,
const struct cl_lock_slice *slice,
enum cl_lock_state state);
-void ccc_io_fini(const struct lu_env *env, const struct cl_io_slice *ios);
int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io,
__u32 enqflags, enum cl_lock_mode mode,
pgoff_t start, pgoff_t end);
@@ -371,10 +347,8 @@ struct page *cl2vm_page (const struct cl_page_slice *slice);
struct inode *ccc_object_inode(const struct cl_object *obj);
struct ccc_object *cl_inode2ccc (struct inode *inode);
-int cl_setattr_ost(struct inode *inode, const struct iattr *attr,
- struct obd_capa *capa);
+int cl_setattr_ost(struct inode *inode, const struct iattr *attr);
-struct cl_page *ccc_vmpage_page_transient(struct page *vmpage);
int ccc_object_invariant(const struct cl_object *obj);
int cl_file_inode_init(struct inode *inode, struct lustre_md *md);
void cl_inode_fini(struct inode *inode);
diff --git a/kernel/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/kernel/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h
index 3925db160..79d8f9307 100644
--- a/kernel/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h
+++ b/kernel/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h
@@ -61,101 +61,8 @@
#define module_init(a) late_initcall(a)
#endif
-
#define LTIME_S(time) (time.tv_sec)
-/* inode_dio_wait(i) use as-is for write lock */
-# define inode_dio_write_done(i) do {} while (0) /* for write unlock */
-# define inode_dio_read(i) atomic_inc(&(i)->i_dio_count)
-/* inode_dio_done(i) use as-is for read unlock */
-
-
-#ifndef FS_HAS_FIEMAP
-#define FS_HAS_FIEMAP (0)
-#endif
-
-#define ll_vfs_rmdir(dir, entry, mnt) vfs_rmdir(dir, entry)
-#define ll_vfs_mkdir(inode, dir, mnt, mode) vfs_mkdir(inode, dir, mode)
-#define ll_vfs_link(old, mnt, dir, new, mnt1) vfs_link(old, dir, new)
-#define ll_vfs_unlink(inode, entry, mnt) vfs_unlink(inode, entry)
-#define ll_vfs_mknod(dir, entry, mnt, mode, dev) \
- vfs_mknod(dir, entry, mode, dev)
-#define ll_security_inode_unlink(dir, entry, mnt) \
- security_inode_unlink(dir, entry)
-#define ll_vfs_rename(old, old_dir, mnt, new, new_dir, mnt1) \
- vfs_rename(old, old_dir, new, new_dir, NULL, 0)
-
-#define cfs_bio_io_error(a, b) bio_io_error((a))
-#define cfs_bio_endio(a, b, c) bio_endio((a), (c))
-
-#define cfs_path_put(nd) path_put(&(nd)->path)
-
-
-#ifndef SLAB_DESTROY_BY_RCU
-#define SLAB_DESTROY_BY_RCU 0
-#endif
-
-
-
-static inline int
-ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
-{
- int rc;
-
- if (sb->s_qcop->quota_on) {
- struct path path;
-
- rc = kern_path(name, LOOKUP_FOLLOW, &path);
- if (!rc)
- return rc;
- rc = sb->s_qcop->quota_on(sb, off, ver
- , &path
- );
- path_put(&path);
- return rc;
- } else
- return -ENOSYS;
-}
-
-static inline int ll_quota_off(struct super_block *sb, int off, int remount)
-{
- if (sb->s_qcop->quota_off) {
- return sb->s_qcop->quota_off(sb, off
- );
- } else
- return -ENOSYS;
-}
-
-
-# define ll_vfs_dq_init dquot_initialize
-# define ll_vfs_dq_drop dquot_drop
-# define ll_vfs_dq_transfer dquot_transfer
-# define ll_vfs_dq_off(sb, remount) dquot_suspend(sb, -1)
-
-
-
-
-
-#define queue_max_phys_segments(rq) queue_max_segments(rq)
-#define queue_max_hw_segments(rq) queue_max_segments(rq)
-
-
-#define ll_d_hlist_node hlist_node
-#define ll_d_hlist_empty(list) hlist_empty(list)
-#define ll_d_hlist_entry(ptr, type, name) hlist_entry(ptr.first, type, name)
-#define ll_d_hlist_for_each(tmp, i_dentry) hlist_for_each(tmp, i_dentry)
-#define ll_d_hlist_for_each_entry(dentry, p, i_dentry, alias) \
- p = NULL; hlist_for_each_entry(dentry, i_dentry, alias)
-
-
-#define bio_hw_segments(q, bio) 0
-
-
-#define ll_pagevec_init(pv, cold) do {} while (0)
-#define ll_pagevec_add(pv, pg) (0)
-#define ll_pagevec_lru_add_file(pv) do {} while (0)
-
-
#ifndef QUOTA_OK
# define QUOTA_OK 0
#endif
@@ -163,17 +70,6 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount)
# define NO_QUOTA (-EDQUOT)
#endif
-#ifndef SEEK_DATA
-#define SEEK_DATA 3 /* seek to the next data */
-#endif
-#ifndef SEEK_HOLE
-#define SEEK_HOLE 4 /* seek to the next hole */
-#endif
-
-#ifndef FMODE_UNSIGNED_OFFSET
-#define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000)
-#endif
-
#if !defined(_ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_) && !defined(ext2_set_bit)
# define ext2_set_bit __test_and_set_bit_le
# define ext2_clear_bit __test_and_clear_bit_le
@@ -182,35 +78,4 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount)
# define ext2_find_next_zero_bit find_next_zero_bit_le
#endif
-#ifdef ATTR_TIMES_SET
-# define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
-#else
-# define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET)
-#endif
-
-
-
-/*
- * After 3.1, kernel's nameidata.intent.open.flags is different
- * with lustre's lookup_intent.it_flags, as lustre's it_flags'
- * lower bits equal to FMODE_xxx while kernel doesn't transliterate
- * lower bits of nameidata.intent.open.flags to FMODE_xxx.
- * */
-#include <linux/version.h>
-static inline int ll_namei_to_lookup_intent_flag(int flag)
-{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
- flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag);
-#endif
- return flag;
-}
-
-#include <linux/fs.h>
-
-# define ll_umode_t umode_t
-
-#include <linux/dcache.h>
-
-# define ll_dirty_inode(inode, flag) (inode)->i_sb->s_op->dirty_inode((inode), flag)
-
#endif /* _COMPAT25_H */
diff --git a/kernel/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/kernel/drivers/staging/lustre/lustre/include/linux/lustre_lite.h
index a7658a99a..3420cfd12 100644
--- a/kernel/drivers/staging/lustre/lustre/include/linux/lustre_lite.h
+++ b/kernel/drivers/staging/lustre/lustre/include/linux/lustre_lite.h
@@ -39,12 +39,10 @@
#error Do not #include this file directly. #include <lustre_lite.h> instead
#endif
-
-#include <asm/statfs.h>
+#include <linux/statfs.h>
#include <linux/fs.h>
#include <linux/dcache.h>
-#include <linux/proc_fs.h>
#include "../obd_class.h"
#include "../lustre_net.h"
@@ -94,5 +92,4 @@ enum {
LPROC_LL_FILE_OPCODES
};
-
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/kernel/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h
index d72605864..33e0b99e1 100644
--- a/kernel/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h
+++ b/kernel/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h
@@ -43,7 +43,6 @@
#include <linux/mm.h>
#include <linux/hash.h>
-
#define ll_delete_from_page_cache(page) delete_from_page_cache(page)
static inline void
@@ -55,25 +54,11 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
if (PagePrivate(page))
page->mapping->a_ops->invalidatepage(page, 0, PAGE_CACHE_SIZE);
- if (TestClearPageDirty(page))
- account_page_cleaned(page, mapping);
-
+ cancel_dirty_page(page);
ClearPageMappedToDisk(page);
ll_delete_from_page_cache(page);
}
-#ifdef ATTR_OPEN
-# define ATTR_FROM_OPEN ATTR_OPEN
-#else
-# ifndef ATTR_FROM_OPEN
-# define ATTR_FROM_OPEN 0
-# endif
-#endif /* ATTR_OPEN */
-
-#ifndef ATTR_RAW
-#define ATTR_RAW 0
-#endif
-
#ifndef ATTR_CTIME_SET
/*
* set ATTR_CTIME_SET to a high value to avoid any risk of collision with other
diff --git a/kernel/drivers/staging/lustre/lustre/include/linux/obd.h b/kernel/drivers/staging/lustre/lustre/include/linux/obd.h
index 9cd868357..468bc28be 100644
--- a/kernel/drivers/staging/lustre/lustre/include/linux/obd.h
+++ b/kernel/drivers/staging/lustre/lustre/include/linux/obd.h
@@ -43,11 +43,11 @@
#include "../obd_support.h"
-# include <linux/fs.h>
-# include <linux/list.h>
-# include <linux/sched.h> /* for struct task_struct, for current.h */
-# include <linux/proc_fs.h>
-# include <linux/mount.h>
+#include <linux/fs.h>
+#include <linux/list.h>
+#include <linux/sched.h> /* for struct task_struct, for current.h */
+#include <linux/mount.h>
+
#include "../lustre_intent.h"
struct ll_iattr {
@@ -70,6 +70,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock,
const char *func, int line)
{
unsigned long cur = jiffies;
+
while (1) {
if (spin_trylock(&lock->lock)) {
LASSERT(lock->task == NULL);
@@ -113,7 +114,6 @@ static inline void client_obd_list_unlock(client_obd_lock_t *lock)
spin_unlock(&lock->lock);
}
-
static inline void client_obd_list_lock_init(client_obd_lock_t *lock)
{
spin_lock_init(&lock->lock);
diff --git a/kernel/drivers/staging/lustre/lustre/include/lprocfs_status.h b/kernel/drivers/staging/lustre/lustre/include/lprocfs_status.h
index d030847e5..9e654b218 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -42,7 +42,7 @@
#ifndef _LPROCFS_SNMP_H
#define _LPROCFS_SNMP_H
-#include <linux/proc_fs.h>
+#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/types.h>
@@ -60,8 +60,8 @@ struct lprocfs_vars {
};
struct lprocfs_static_vars {
- struct lprocfs_vars *module_vars;
struct lprocfs_vars *obd_vars;
+ struct attribute_group *sysfs_vars;
};
/* if we find more consumers this could be generalized */
@@ -158,6 +158,7 @@ struct lprocfs_counter {
*/
__s64 lc_array_sum[1];
};
+
#define lc_sum lc_array_sum[0]
#define lc_sum_irq lc_array_sum[1]
@@ -206,7 +207,8 @@ struct lprocfs_stats {
#define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
/* Pack all opcodes down into a single monotonically increasing index */
-static inline int opcode_offset(__u32 opc) {
+static inline int opcode_offset(__u32 opc)
+{
if (opc < OST_LAST_OPC) {
/* OST opcode */
return (opc - OST_FIRST_OPC);
@@ -301,7 +303,6 @@ static inline int opcode_offset(__u32 opc) {
}
}
-
#define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
OPC_RANGE(MDS) + \
OPC_RANGE(LDLM) + \
@@ -348,7 +349,8 @@ enum {
#define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
/* class_obd.c */
-extern struct proc_dir_entry *proc_lustre_root;
+extern struct dentry *debugfs_lustre_root;
+extern struct kobject *lustre_kobj;
struct obd_device;
struct obd_histogram;
@@ -357,15 +359,18 @@ struct obd_histogram;
struct dhms {
int d, h, m, s;
};
-static inline void s2dhms(struct dhms *ts, time_t secs)
+
+static inline void s2dhms(struct dhms *ts, time64_t secs64)
{
- ts->d = secs / 86400;
- secs = secs % 86400;
+ unsigned int secs;
+
+ ts->d = div_u64_rem(secs64, 86400, &secs);
ts->h = secs / 3600;
secs = secs % 3600;
ts->m = secs / 60;
ts->s = secs % 60;
}
+
#define DHMS_FMT "%dd%dh%02dm%02ds"
#define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
@@ -374,14 +379,11 @@ static inline void s2dhms(struct dhms *ts, time_t secs)
#define JOBSTATS_PROCNAME_UID "procname_uid"
#define JOBSTATS_NODELOCAL "nodelocal"
-extern int lprocfs_write_frac_helper(const char __user *buffer,
- unsigned long count, int *val, int mult);
-extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
- long val, int mult);
-#if defined (CONFIG_PROC_FS)
-
-extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
- unsigned int cpuid);
+int lprocfs_write_frac_helper(const char __user *buffer,
+ unsigned long count, int *val, int mult);
+int lprocfs_read_frac_helper(char *buffer, unsigned long count,
+ long val, int mult);
+int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid);
/*
* \return value
* < 0 : on error (only possible for opc as LPROCFS_GET_SMP_ID)
@@ -422,9 +424,8 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
else
spin_lock(&stats->ls_lock);
return 1;
- } else {
- return stats->ls_biggest_alloc_num;
}
+ return stats->ls_biggest_alloc_num;
}
}
@@ -499,20 +500,18 @@ lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
* count itself to reside within a single cache line.
*/
-extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
- long amount);
-extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
- long amount);
+void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount);
+void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx, long amount);
#define lprocfs_counter_incr(stats, idx) \
lprocfs_counter_add(stats, idx, 1)
#define lprocfs_counter_decr(stats, idx) \
lprocfs_counter_sub(stats, idx, 1)
-extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
- struct lprocfs_counter_header *header,
- enum lprocfs_stats_flags flags,
- enum lprocfs_fields_flags field);
+__s64 lprocfs_read_helper(struct lprocfs_counter *lc,
+ struct lprocfs_counter_header *header,
+ enum lprocfs_stats_flags flags,
+ enum lprocfs_fields_flags field);
static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
int idx,
enum lprocfs_fields_flags field)
@@ -539,124 +538,81 @@ static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
extern struct lprocfs_stats *
lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
-extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
-extern void lprocfs_free_stats(struct lprocfs_stats **stats);
-extern void lprocfs_init_ops_stats(int num_private_stats,
- struct lprocfs_stats *stats);
-extern void lprocfs_init_mps_stats(int num_private_stats,
- struct lprocfs_stats *stats);
-extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
-extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
- unsigned int num_private_stats);
-extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
- unsigned int num_private_stats);
-extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
- unsigned conf, const char *name,
- const char *units);
-extern void lprocfs_free_obd_stats(struct obd_device *obddev);
-extern void lprocfs_free_md_stats(struct obd_device *obddev);
+void lprocfs_clear_stats(struct lprocfs_stats *stats);
+void lprocfs_free_stats(struct lprocfs_stats **stats);
+void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
+ unsigned conf, const char *name, const char *units);
struct obd_export;
-struct nid_stat;
-extern int lprocfs_add_clear_entry(struct obd_device *obd,
- struct proc_dir_entry *entry);
-extern int lprocfs_exp_setup(struct obd_export *exp,
- lnet_nid_t *peer_nid, int *newnid);
-extern int lprocfs_exp_cleanup(struct obd_export *exp);
-extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
- char *name,
- void *data,
- struct file_operations *fops);
-extern struct proc_dir_entry *
-lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
- const char *format, ...);
-extern void lprocfs_free_per_client_stats(struct obd_device *obd);
-extern int
-lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data);
+int lprocfs_exp_cleanup(struct obd_export *exp);
+struct dentry *ldebugfs_add_simple(struct dentry *root,
+ char *name,
+ void *data,
+ struct file_operations *fops);
-extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
- struct lprocfs_stats *stats);
+int ldebugfs_register_stats(struct dentry *parent,
+ const char *name,
+ struct lprocfs_stats *stats);
/* lprocfs_status.c */
-extern int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
+int ldebugfs_add_vars(struct dentry *parent,
+ struct lprocfs_vars *var,
+ void *data);
+
+struct dentry *ldebugfs_register(const char *name,
+ struct dentry *parent,
+ struct lprocfs_vars *list,
+ void *data);
+
+void ldebugfs_remove(struct dentry **entryp);
+
+int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
+ struct attribute_group *attrs);
+int lprocfs_obd_cleanup(struct obd_device *obd);
+
+int ldebugfs_seq_create(struct dentry *parent,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
+ void *data);
+int ldebugfs_obd_seq_create(struct obd_device *dev,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
void *data);
-extern struct proc_dir_entry *lprocfs_register(const char *name,
- struct proc_dir_entry *parent,
- struct lprocfs_vars *list,
- void *data);
-
-extern void lprocfs_remove(struct proc_dir_entry **root);
-extern void lprocfs_remove_proc_entry(const char *name,
- struct proc_dir_entry *parent);
-
-extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
-extern int lprocfs_obd_cleanup(struct obd_device *obd);
-
-extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
- umode_t mode,
- const struct file_operations *seq_fops,
- void *data);
-extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
- umode_t mode,
- const struct file_operations *seq_fops,
- void *data);
-
/* Generic callbacks */
-extern int lprocfs_rd_u64(struct seq_file *m, void *data);
-extern int lprocfs_rd_atomic(struct seq_file *m, void *data);
-extern int lprocfs_wr_atomic(struct file *file, const char __user *buffer,
- unsigned long count, void *data);
-extern int lprocfs_rd_uint(struct seq_file *m, void *data);
-extern int lprocfs_wr_uint(struct file *file, const char __user *buffer,
- unsigned long count, void *data);
-extern int lprocfs_rd_uuid(struct seq_file *m, void *data);
-extern int lprocfs_rd_name(struct seq_file *m, void *data);
-extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data);
-extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data);
-extern int lprocfs_rd_import(struct seq_file *m, void *data);
-extern int lprocfs_rd_state(struct seq_file *m, void *data);
-extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data);
-extern int lprocfs_rd_num_exports(struct seq_file *m, void *data);
-extern int lprocfs_rd_numrefs(struct seq_file *m, void *data);
+int lprocfs_rd_uint(struct seq_file *m, void *data);
+int lprocfs_wr_uint(struct file *file, const char __user *buffer,
+ unsigned long count, void *data);
+int lprocfs_rd_server_uuid(struct seq_file *m, void *data);
+int lprocfs_rd_conn_uuid(struct seq_file *m, void *data);
+int lprocfs_rd_import(struct seq_file *m, void *data);
+int lprocfs_rd_state(struct seq_file *m, void *data);
+int lprocfs_rd_connect_flags(struct seq_file *m, void *data);
struct adaptive_timeout;
-extern int lprocfs_at_hist_helper(struct seq_file *m,
- struct adaptive_timeout *at);
-extern int lprocfs_rd_timeouts(struct seq_file *m, void *data);
-extern int lprocfs_wr_timeouts(struct file *file, const char __user *buffer,
- unsigned long count, void *data);
-extern int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
- size_t count, loff_t *off);
-extern int lprocfs_wr_ping(struct file *file, const char __user *buffer,
- size_t count, loff_t *off);
-extern int lprocfs_wr_import(struct file *file, const char __user *buffer,
+int lprocfs_at_hist_helper(struct seq_file *m, struct adaptive_timeout *at);
+int lprocfs_rd_timeouts(struct seq_file *m, void *data);
+int lprocfs_wr_ping(struct file *file, const char __user *buffer,
+ size_t count, loff_t *off);
+int lprocfs_wr_import(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
-extern int lprocfs_rd_pinger_recov(struct seq_file *m, void *n);
-extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
- size_t count, loff_t *off);
+int lprocfs_rd_pinger_recov(struct seq_file *m, void *n);
+int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
+ size_t count, loff_t *off);
/* Statfs helpers */
-extern int lprocfs_rd_blksize(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytestotal(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytesfree(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data);
-extern int lprocfs_rd_filestotal(struct seq_file *m, void *data);
-extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
-
-extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
- int *val);
-extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
-extern int lprocfs_write_u64_helper(const char __user *buffer,
- unsigned long count, __u64 *val);
-extern int lprocfs_write_frac_u64_helper(const char *buffer,
- unsigned long count,
- __u64 *val, int mult);
-extern char *lprocfs_find_named_value(const char *buffer, const char *name,
- size_t *count);
+
+int lprocfs_write_helper(const char __user *buffer, unsigned long count,
+ int *val);
+int lprocfs_write_u64_helper(const char __user *buffer,
+ unsigned long count, __u64 *val);
+int lprocfs_write_frac_u64_helper(const char *buffer,
+ unsigned long count,
+ __u64 *val, int mult);
+char *lprocfs_find_named_value(const char *buffer, const char *name,
+ size_t *count);
void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
void lprocfs_oh_clear(struct obd_histogram *oh);
@@ -665,31 +621,20 @@ unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
struct lprocfs_counter *cnt);
-extern int lprocfs_single_release(struct inode *, struct file *);
-extern int lprocfs_seq_release(struct inode *, struct file *);
-
-/* You must use these macros when you want to refer to
- * the import in a client obd_device for a lprocfs entry */
-#define LPROCFS_CLIMP_CHECK(obd) do { \
- typecheck(struct obd_device *, obd); \
- down_read(&(obd)->u.cli.cl_sem); \
- if ((obd)->u.cli.cl_import == NULL) { \
- up_read(&(obd)->u.cli.cl_sem); \
- return -ENODEV; \
- } \
-} while (0)
+int lprocfs_single_release(struct inode *, struct file *);
+int lprocfs_seq_release(struct inode *, struct file *);
+
#define LPROCFS_CLIMP_EXIT(obd) \
up_read(&(obd)->u.cli.cl_sem)
-
/* 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,
- call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
+ call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
#define __LPROC_SEQ_FOPS(name, custom_seq_write) \
static int name##_single_open(struct inode *inode, struct file *file) \
{ \
- return single_open(file, name##_seq_show, PDE_DATA(inode)); \
+ return single_open(file, name##_seq_show, inode->i_private); \
} \
static struct file_operations name##_fops = { \
.owner = THIS_MODULE, \
@@ -734,7 +679,7 @@ static struct file_operations name##_fops = { \
} \
static int name##_##type##_open(struct inode *inode, struct file *file) \
{ \
- return single_open(file, NULL, PDE_DATA(inode)); \
+ return single_open(file, NULL, inode->i_private); \
} \
static struct file_operations name##_##type##_fops = { \
.open = name##_##type##_open, \
@@ -742,274 +687,79 @@ static struct file_operations name##_fops = { \
.release = lprocfs_single_release, \
}
-/* lproc_ptlrpc.c */
-struct ptlrpc_request;
-extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
-
-/* lproc_status.c */
-int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data);
-int lprocfs_obd_wr_max_pages_per_rpc(struct file *file, const char *buffer,
- size_t count, loff_t *off);
-
-/* all quota proc functions */
-extern int lprocfs_quota_rd_bunit(char *page, char **start,
- loff_t off, int count,
- int *eof, void *data);
-extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_btune(char *page, char **start,
- loff_t off, int count,
- int *eof, void *data);
-extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_iunit(char *page, char **start,
- loff_t off, int count,
- int *eof, void *data);
-extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_itune(char *page, char **start,
- loff_t off, int count,
- int *eof, void *data);
-extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_type(char *page, char **start, loff_t off, int count,
- int *eof, void *data);
-extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, loff_t off,
- int count, int *eof, void *data);
-extern int lprocfs_quota_wr_switch_seconds(struct file *file,
- const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_sync_blk(char *page, char **start, loff_t off,
- int count, int *eof, void *data);
-extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_switch_qs(char *page, char **start, loff_t off,
- int count, int *eof, void *data);
-extern int lprocfs_quota_wr_switch_qs(struct file *file,
- const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, loff_t off,
- int count, int *eof, void *data);
-extern int lprocfs_quota_wr_boundary_factor(struct file *file,
- const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_least_bunit(char *page, char **start, loff_t off,
- int count, int *eof, void *data);
-extern int lprocfs_quota_wr_least_bunit(struct file *file,
- const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_least_iunit(char *page, char **start, loff_t off,
- int count, int *eof, void *data);
-extern int lprocfs_quota_wr_least_iunit(struct file *file,
- const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off,
- int count, int *eof, void *data);
-extern int lprocfs_quota_wr_qs_factor(struct file *file,
- const char *buffer,
- unsigned long count, void *data);
-#else
-/* CONFIG_PROC_FS is not defined */
-
-#define proc_lustre_root NULL
-
-static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
- int index, long amount)
-{ return; }
-static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
- int index)
-{ return; }
-static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
- int index, long amount)
-{ return; }
-static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
- int index)
-{ return; }
-static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
- int index, unsigned conf,
- const char *name, const char *units)
-{ return; }
-
-static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
- enum lprocfs_fields_flags field)
-{ return 0; }
-
-/* NB: we return !NULL to satisfy error checker */
-static inline struct lprocfs_stats *
-lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
-{ return (struct lprocfs_stats *)1; }
-static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
-{ return; }
-static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
-{ return; }
-static inline int lprocfs_register_stats(struct proc_dir_entry *root,
- const char *name,
- struct lprocfs_stats *stats)
-{ return 0; }
-static inline void lprocfs_init_ops_stats(int num_private_stats,
- struct lprocfs_stats *stats)
-{ return; }
-static inline void lprocfs_init_mps_stats(int num_private_stats,
- struct lprocfs_stats *stats)
-{ return; }
-static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
-{ return; }
-static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
- unsigned int num_private_stats)
-{ return 0; }
-static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
- unsigned int num_private_stats)
-{ return 0; }
-static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
-{ return; }
-static inline void lprocfs_free_md_stats(struct obd_device *obddev)
-{ return; }
-
-struct obd_export;
-static inline int lprocfs_add_clear_entry(struct obd_export *exp)
-{ return 0; }
-static inline int lprocfs_exp_setup(struct obd_export *exp,
- lnet_nid_t *peer_nid,
- int *newnid)
-{ return 0; }
-static inline int lprocfs_exp_cleanup(struct obd_export *exp)
-{ return 0; }
-static inline struct proc_dir_entry *
-lprocfs_add_simple(struct proc_dir_entry *root, char *name,
- void *data, struct file_operations *fops)
-{return 0; }
-static inline struct proc_dir_entry *
-lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
- const char *format, ...)
-{return NULL; }
-static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
-{ return; }
-static inline
-int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{return count;}
-static inline
-int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
-{ return 0; }
-
-static inline struct proc_dir_entry *
-lprocfs_register(const char *name, struct proc_dir_entry *parent,
- struct lprocfs_vars *list, void *data)
-{ return NULL; }
-static inline int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
- void *data)
-{ return 0; }
-static inline void lprocfs_remove(struct proc_dir_entry **root)
-{ return; }
-static inline void lprocfs_remove_proc_entry(const char *name,
- struct proc_dir_entry *parent)
-{ return; }
-static inline int lprocfs_obd_setup(struct obd_device *dev,
- struct lprocfs_vars *list)
-{ return 0; }
-static inline int lprocfs_obd_cleanup(struct obd_device *dev)
-{ return 0; }
-static inline int lprocfs_rd_u64(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_uuid(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_name(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_import(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
-{ return 0; }
-static inline int lprocfs_rd_state(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_num_exports(struct seq_file *m, void *data)
-{ return 0; }
-extern inline int lprocfs_rd_numrefs(struct seq_file *m, void *data)
-{ return 0; }
-struct adaptive_timeout;
-static inline int lprocfs_at_hist_helper(struct seq_file *m,
- struct adaptive_timeout *at)
-{ return 0; }
-static inline int lprocfs_rd_timeouts(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_wr_timeouts(struct file *file,
- const char __user *buffer,
- unsigned long count, void *data)
-{ return 0; }
-static inline int lprocfs_wr_evict_client(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-static inline int lprocfs_wr_ping(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-static inline int lprocfs_wr_import(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-static inline int lprocfs_wr_pinger_recov(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-
-/* Statfs helpers */
-static inline
-int lprocfs_rd_blksize(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_filestotal(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_filesfree(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
-{ return; }
-static inline
-void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
-{ return; }
-static inline
-void lprocfs_oh_clear(struct obd_histogram *oh)
-{ return; }
-static inline
-unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
-{ return 0; }
-static inline
-void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
- struct lprocfs_counter *cnt)
-{ return; }
-static inline
-__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
- enum lprocfs_fields_flags field)
-{ return (__u64)0; }
+struct lustre_attr {
+ struct attribute attr;
+ ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len);
+};
-#define LPROC_SEQ_FOPS_RO(name)
-#define LPROC_SEQ_FOPS(name)
-#define LPROC_SEQ_FOPS_RO_TYPE(name, type)
-#define LPROC_SEQ_FOPS_RW_TYPE(name, type)
-#define LPROC_SEQ_FOPS_WR_ONLY(name, type)
+#define LUSTRE_ATTR(name, mode, show, store) \
+static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
-/* lproc_ptlrpc.c */
-#define target_print_req NULL
+#define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
+#define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
-#endif /* CONFIG_PROC_FS */
+extern const struct sysfs_ops lustre_sysfs_ops;
+/* all quota proc functions */
+int lprocfs_quota_rd_bunit(char *page, char **start,
+ loff_t off, int count,
+ int *eof, void *data);
+int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+int lprocfs_quota_rd_btune(char *page, char **start,
+ loff_t off, int count,
+ int *eof, void *data);
+int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+int lprocfs_quota_rd_iunit(char *page, char **start,
+ loff_t off, int count,
+ int *eof, void *data);
+int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+int lprocfs_quota_rd_itune(char *page, char **start,
+ loff_t off, int count,
+ int *eof, void *data);
+int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+int lprocfs_quota_rd_type(char *page, char **start, loff_t off, int count,
+ int *eof, void *data);
+int lprocfs_quota_wr_type(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+int lprocfs_quota_rd_switch_seconds(char *page, char **start, loff_t off,
+ int count, int *eof, void *data);
+int lprocfs_quota_wr_switch_seconds(struct file *file,
+ const char *buffer,
+ unsigned long count, void *data);
+int lprocfs_quota_rd_sync_blk(char *page, char **start, loff_t off,
+ int count, int *eof, void *data);
+int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+int lprocfs_quota_rd_switch_qs(char *page, char **start, loff_t off,
+ int count, int *eof, void *data);
+int lprocfs_quota_wr_switch_qs(struct file *file,
+ const char *buffer, unsigned long count,
+ void *data);
+int lprocfs_quota_rd_boundary_factor(char *page, char **start, loff_t off,
+ int count, int *eof, void *data);
+int lprocfs_quota_wr_boundary_factor(struct file *file,
+ const char *buffer, unsigned long count,
+ void *data);
+int lprocfs_quota_rd_least_bunit(char *page, char **start, loff_t off,
+ int count, int *eof, void *data);
+int lprocfs_quota_wr_least_bunit(struct file *file,
+ const char *buffer, unsigned long count,
+ void *data);
+int lprocfs_quota_rd_least_iunit(char *page, char **start, loff_t off,
+ int count, int *eof, void *data);
+int lprocfs_quota_wr_least_iunit(struct file *file,
+ const char *buffer, unsigned long count,
+ void *data);
+int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off,
+ int count, int *eof, void *data);
+int lprocfs_quota_wr_qs_factor(struct file *file,
+ const char *buffer, unsigned long count,
+ void *data);
#endif /* LPROCFS_SNMP_H */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lu_object.h b/kernel/drivers/staging/lustre/lustre/include/lu_object.h
index c8cc48f00..fa7868974 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lu_object.h
@@ -43,7 +43,6 @@
#include "lu_ref.h"
struct seq_file;
-struct proc_dir_entry;
struct lustre_cfg;
struct lprocfs_stats;
@@ -277,7 +276,6 @@ struct lu_device {
* Stack this device belongs to.
*/
struct lu_site *ld_site;
- struct proc_dir_entry *ld_proc_entry;
/** \todo XXX: temporary back pointer into obd. */
struct obd_device *ld_obd;
@@ -556,9 +554,9 @@ struct fld;
struct lu_site_bkt_data {
/**
- * number of busy object on this bucket
+ * number of object in this bucket on the lsb_lru list.
*/
- long lsb_busy;
+ long lsb_lru_len;
/**
* LRU list, updated on each access to object. Protected by
* bucket lock of lu_site::ls_obj_hash.
@@ -586,6 +584,7 @@ enum {
LU_SS_CACHE_RACE,
LU_SS_CACHE_DEATH_RACE,
LU_SS_LRU_PURGED,
+ LU_SS_LRU_LEN, /* # of objects in lsb_lru lists */
LU_SS_LAST_STAT
};
@@ -672,9 +671,6 @@ void lu_object_fini (struct lu_object *o);
void lu_object_add_top (struct lu_object_header *h, struct lu_object *o);
void lu_object_add (struct lu_object *before, struct lu_object *o);
-void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d);
-void lu_dev_del_linkage(struct lu_site *s, struct lu_device *d);
-
/**
* Helpers to initialize and finalize device types.
*/
@@ -711,16 +707,12 @@ static inline int lu_object_is_dying(const struct lu_object_header *h)
}
void lu_object_put(const struct lu_env *env, struct lu_object *o);
-void lu_object_put_nocache(const struct lu_env *env, struct lu_object *o);
void lu_object_unhash(const struct lu_env *env, struct lu_object *o);
int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr);
void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie,
lu_printer_t printer);
-struct lu_object *lu_object_find(const struct lu_env *env,
- struct lu_device *dev, const struct lu_fid *f,
- const struct lu_object_conf *conf);
struct lu_object *lu_object_find_at(const struct lu_env *env,
struct lu_device *dev,
const struct lu_fid *f,
@@ -792,7 +784,7 @@ do { \
\
if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
lu_object_print(env, &msgdata, lu_cdebug_printer, object);\
- CDEBUG(mask, format , ## __VA_ARGS__); \
+ CDEBUG(mask, format, ## __VA_ARGS__); \
} \
} while (0)
@@ -807,7 +799,7 @@ do { \
lu_object_header_print(env, &msgdata, lu_cdebug_printer,\
(object)->lo_header); \
lu_cdebug_printer(env, &msgdata, "\n"); \
- CDEBUG(mask, format , ## __VA_ARGS__); \
+ CDEBUG(mask, format, ## __VA_ARGS__); \
} \
} while (0)
@@ -822,7 +814,6 @@ void lu_object_header_print(const struct lu_env *env, void *cookie,
*/
int lu_object_invariant(const struct lu_object *o);
-
/**
* Check whether object exists, no matter on local or remote storage.
* Note: LOHA_EXISTS will be set once some one created the object,
@@ -1127,13 +1118,13 @@ struct lu_context_key {
\
CLASSERT(PAGE_CACHE_SIZE >= sizeof (*value)); \
\
- OBD_ALLOC_PTR(value); \
+ value = kzalloc(sizeof(*value), GFP_NOFS); \
if (value == NULL) \
value = ERR_PTR(-ENOMEM); \
\
return value; \
} \
- struct __##mod##__dummy_init {;} /* semicolon catcher */
+ struct __##mod##__dummy_init {; } /* semicolon catcher */
#define LU_KEY_FINI(mod, type) \
static void mod##_key_fini(const struct lu_context *ctx, \
@@ -1141,9 +1132,9 @@ struct lu_context_key {
{ \
type *info = data; \
\
- OBD_FREE_PTR(info); \
+ kfree(info); \
} \
- struct __##mod##__dummy_fini {;} /* semicolon catcher */
+ struct __##mod##__dummy_fini {; } /* semicolon catcher */
#define LU_KEY_INIT_FINI(mod, type) \
LU_KEY_INIT(mod, type); \
@@ -1168,7 +1159,6 @@ void *lu_context_key_get (const struct lu_context *ctx,
void lu_context_key_quiesce (struct lu_context_key *key);
void lu_context_key_revive (struct lu_context_key *key);
-
/*
* LU_KEY_INIT_GENERIC() has to be a macro to correctly determine an
* owning module.
@@ -1195,30 +1185,28 @@ void lu_context_key_revive (struct lu_context_key *key);
mod##_key_init_generic(__VA_ARGS__, NULL); \
return lu_context_key_register_many(__VA_ARGS__, NULL); \
} \
- struct __##mod##_dummy_type_init {;}
+ struct __##mod##_dummy_type_init {; }
#define LU_TYPE_FINI(mod, ...) \
static void mod##_type_fini(struct lu_device_type *t) \
{ \
lu_context_key_degister_many(__VA_ARGS__, NULL); \
} \
- struct __##mod##_dummy_type_fini {;}
+ struct __##mod##_dummy_type_fini {; }
#define LU_TYPE_START(mod, ...) \
static void mod##_type_start(struct lu_device_type *t) \
{ \
lu_context_key_revive_many(__VA_ARGS__, NULL); \
} \
- struct __##mod##_dummy_type_start {;}
+ struct __##mod##_dummy_type_start {; }
#define LU_TYPE_STOP(mod, ...) \
static void mod##_type_stop(struct lu_device_type *t) \
{ \
lu_context_key_quiesce_many(__VA_ARGS__, NULL); \
} \
- struct __##mod##_dummy_type_stop {;}
-
-
+ struct __##mod##_dummy_type_stop {; }
#define LU_TYPE_INIT_FINI(mod, ...) \
LU_TYPE_INIT(mod, __VA_ARGS__); \
@@ -1242,14 +1230,6 @@ void lu_context_key_degister_many(struct lu_context_key *k, ...);
void lu_context_key_revive_many (struct lu_context_key *k, ...);
void lu_context_key_quiesce_many (struct lu_context_key *k, ...);
-/*
- * update/clear ctx/ses tags.
- */
-void lu_context_tags_update(__u32 tags);
-void lu_context_tags_clear(__u32 tags);
-void lu_session_tags_update(__u32 tags);
-void lu_session_tags_clear(__u32 tags);
-
/**
* Environment.
*/
@@ -1267,7 +1247,6 @@ struct lu_env {
int lu_env_init (struct lu_env *env, __u32 tags);
void lu_env_fini (struct lu_env *env);
int lu_env_refill(struct lu_env *env);
-int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags, __u32 stags);
/** @} lu_context */
@@ -1320,21 +1299,5 @@ struct lu_kmem_descr {
int lu_kmem_init(struct lu_kmem_descr *caches);
void lu_kmem_fini(struct lu_kmem_descr *caches);
-void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
- const struct lu_fid *fid);
-struct lu_object *lu_object_anon(const struct lu_env *env,
- struct lu_device *dev,
- const struct lu_object_conf *conf);
-
-/** null buffer */
-extern struct lu_buf LU_BUF_NULL;
-
-void lu_buf_free(struct lu_buf *buf);
-void lu_buf_alloc(struct lu_buf *buf, int size);
-void lu_buf_realloc(struct lu_buf *buf, int size);
-
-int lu_buf_check_and_grow(struct lu_buf *buf, int len);
-struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, int len);
-
/** @} lu */
#endif /* __LUSTRE_LU_OBJECT_H */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lu_ref.h b/kernel/drivers/staging/lustre/lustre/include/lu_ref.h
index b451a888c..97cd157dd 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lu_ref.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lu_ref.h
@@ -107,7 +107,6 @@
* @{
*/
-
/*
* dummy data structures/functions to pass compile for now.
* We need to reimplement them with kref.
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre/libiam.h b/kernel/drivers/staging/lustre/lustre/include/lustre/libiam.h
deleted file mode 100644
index e8e0b084a..000000000
--- a/kernel/drivers/staging/lustre/lustre/include/lustre/libiam.h
+++ /dev/null
@@ -1,145 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/include/lustre/libiam.h
- *
- * iam user level library
- *
- * Author: Wang Di <wangdi@clusterfs.com>
- * Author: Nikita Danilov <nikita@clusterfs.com>
- * Author: Fan Yong <fanyong@clusterfs.com>
- */
-
-/*
- * lustre/libiam.h
- */
-
-#ifndef __IAM_ULIB_H__
-#define __IAM_ULIB_H__
-
-/** \defgroup libiam libiam
- *
- * @{
- */
-
-
-#define DX_FMT_NAME_LEN 16
-
-enum iam_fmt_t {
- FMT_LFIX,
- FMT_LVAR
-};
-
-struct iam_uapi_info {
- __u16 iui_keysize;
- __u16 iui_recsize;
- __u16 iui_ptrsize;
- __u16 iui_height;
- char iui_fmt_name[DX_FMT_NAME_LEN];
-};
-
-/*
- * Creat an iam file, but do NOT open it.
- * Return 0 if success, else -1.
- */
-int iam_creat(char *filename, enum iam_fmt_t fmt,
- int blocksize, int keysize, int recsize, int ptrsize);
-
-/*
- * Open an iam file, but do NOT creat it if the file doesn't exist.
- * Please use iam_creat for creating the file before use iam_open.
- * Return file id (fd) if success, else -1.
- */
-int iam_open(char *filename, struct iam_uapi_info *ua);
-
-/*
- * Close file opened by iam_open.
- */
-int iam_close(int fd);
-
-/*
- * Please use iam_open before use this function.
- */
-int iam_insert(int fd, struct iam_uapi_info *ua,
- int key_need_convert, char *keybuf,
- int rec_need_convert, char *recbuf);
-
-/*
- * Please use iam_open before use this function.
- */
-int iam_lookup(int fd, struct iam_uapi_info *ua,
- int key_need_convert, char *key_buf,
- int *keysize, char *save_key,
- int rec_need_convert, char *rec_buf,
- int *recsize, char *save_rec);
-
-/*
- * Please use iam_open before use this function.
- */
-int iam_delete(int fd, struct iam_uapi_info *ua,
- int key_need_convert, char *keybuf,
- int rec_need_convert, char *recbuf);
-
-/*
- * Please use iam_open before use this function.
- */
-int iam_it_start(int fd, struct iam_uapi_info *ua,
- int key_need_convert, char *key_buf,
- int *keysize, char *save_key,
- int rec_need_convert, char *rec_buf,
- int *recsize, char *save_rec);
-
-/*
- * Please use iam_open before use this function.
- */
-int iam_it_next(int fd, struct iam_uapi_info *ua,
- int key_need_convert, char *key_buf,
- int *keysize, char *save_key,
- int rec_need_convert, char *rec_buf,
- int *recsize, char *save_rec);
-
-/*
- * Please use iam_open before use this function.
- */
-int iam_it_stop(int fd, struct iam_uapi_info *ua,
- int key_need_convert, char *keybuf,
- int rec_need_convert, char *recbuf);
-
-/*
- * Change iam file mode.
- */
-int iam_polymorph(char *filename, unsigned long mode);
-
-/** @} libiam */
-
-#endif
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h b/kernel/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h
index ad253c6de..06ce8c9ae 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h
@@ -43,8 +43,6 @@
#ifndef _LUSTRE_FIEMAP_H
#define _LUSTRE_FIEMAP_H
-
-
struct ll_fiemap_extent {
__u64 fe_logical; /* logical offset in bytes for the start of
* the extent from the beginning of the file */
@@ -94,7 +92,6 @@ struct ll_user_fiemap {
* support extents. Result
* merged for efficiency. */
-
static inline size_t fiemap_count_to_size(size_t extent_count)
{
return (sizeof(struct ll_user_fiemap) + extent_count *
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 305ecbee9..0b721c65c 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -92,6 +92,7 @@
#define _LUSTRE_IDL_H_
#include "../../../include/linux/libcfs/libcfs.h"
+#include "../../../include/linux/lnet/types.h"
/* Defn's shared with user-space. */
#include "lustre_user.h"
@@ -153,10 +154,7 @@
#define PTL_RPC_MSG_REPLY 4713
/* DON'T use swabbed values of MAGIC as magic! */
-#define LUSTRE_MSG_MAGIC_V1 0x0BD00BD0
#define LUSTRE_MSG_MAGIC_V2 0x0BD00BD3
-
-#define LUSTRE_MSG_MAGIC_V1_SWABBED 0xD00BD00B
#define LUSTRE_MSG_MAGIC_V2_SWABBED 0xD30BD00B
#define LUSTRE_MSG_MAGIC LUSTRE_MSG_MAGIC_V2
@@ -296,7 +294,6 @@ static inline int range_compare_loc(const struct lu_seq_range *r1,
(range)->lsr_index, \
fld_range_is_mdt(range) ? "mdt" : "ost"
-
/** \defgroup lu_fid lu_fid
* @{ */
@@ -324,6 +321,7 @@ enum lma_incompat {
LMAI_REMOTE_PARENT = 0x00000004, /* the parent of the object
is on the remote MDT */
};
+
#define LMA_INCOMPAT_SUPP (LMAI_AGENT | LMAI_REMOTE_PARENT)
/**
@@ -364,6 +362,13 @@ static inline __u64 fid_ver_oid(const struct lu_fid *fid)
return ((__u64)fid_ver(fid) << 32 | fid_oid(fid));
}
+/* copytool uses a 32b bitmask field to encode archive-Ids during register
+ * with MDT thru kuc.
+ * archive num = 0 => all
+ * archive num from 1 to 32
+ */
+#define LL_HSM_MAX_ARCHIVE (sizeof(__u32) * 8)
+
/**
* Note that reserved SEQ numbers below 12 will conflict with ldiskfs
* inodes in the IGIF namespace, so these reserved SEQ numbers can be
@@ -746,7 +751,7 @@ static inline ino_t lu_igif_ino(const struct lu_fid *fid)
return fid_seq(fid);
}
-extern void lustre_swab_ost_id(struct ost_id *oid);
+void lustre_swab_ost_id(struct ost_id *oid);
/**
* Get inode generation from a igif.
@@ -813,8 +818,8 @@ static inline int fid_is_zero(const struct lu_fid *fid)
return fid_seq(fid) == 0 && fid_oid(fid) == 0;
}
-extern void lustre_swab_lu_fid(struct lu_fid *fid);
-extern void lustre_swab_lu_seq_range(struct lu_seq_range *range);
+void lustre_swab_lu_fid(struct lu_fid *fid);
+void lustre_swab_lu_seq_range(struct lu_seq_range *range);
static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1)
{
@@ -826,7 +831,7 @@ static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1)
typeof(val0) __val0 = (val0); \
typeof(val1) __val1 = (val1); \
\
- (__val0 == __val1 ? 0 : __val0 > __val1 ? +1 : -1); \
+ (__val0 == __val1 ? 0 : __val0 > __val1 ? 1 : -1); \
})
static inline int lu_fid_cmp(const struct lu_fid *f0,
@@ -955,7 +960,6 @@ struct luda_type {
#define DTTOIF(dirtype) ((dirtype) << IFSHIFT)
#endif
-
struct lu_dirpage {
__u64 ldp_hash_start;
__u64 ldp_hash_end;
@@ -1001,6 +1005,7 @@ static inline int lu_dirent_calc_size(int namelen, __u16 attr)
if (attr & LUDA_TYPE) {
const unsigned align = sizeof(struct luda_type) - 1;
+
size = (sizeof(struct lu_dirent) + namelen + align) & ~align;
size += sizeof(struct luda_type);
} else
@@ -1040,6 +1045,7 @@ static inline int lu_dirent_size(struct lu_dirent *ent)
struct lustre_handle {
__u64 cookie;
};
+
#define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabeULL
static inline int lustre_handle_is_used(struct lustre_handle *lh)
@@ -1104,6 +1110,7 @@ struct ptlrpc_body_v3 {
__u64 pb_padding[4];
char pb_jobid[JOBSTATS_JOBID_SIZE];
};
+
#define ptlrpc_body ptlrpc_body_v3
struct ptlrpc_body_v2 {
@@ -1130,7 +1137,7 @@ struct ptlrpc_body_v2 {
__u64 pb_padding[4];
};
-extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
+void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
/* message body offset for lustre_msg_v2 */
/* ptlrpc body offset in all request/reply messages */
@@ -1268,7 +1275,6 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
#define OCD_HAS_FLAG(ocd, flg) \
(!!((ocd)->ocd_connect_flags & OBD_CONNECT_##flg))
-
#define LRU_RESIZE_CONNECT_FLAG OBD_CONNECT_LRU_RESIZE
#define MDT_CONNECT_SUPPORTED (OBD_CONNECT_RDONLY | OBD_CONNECT_VERSION | \
@@ -1385,6 +1391,7 @@ struct obd_connect_data {
__u64 paddingE; /* added 2.1.0. also fix lustre_swab_connect */
__u64 paddingF; /* added 2.1.0. also fix lustre_swab_connect */
};
+
/* XXX README XXX:
* Please DO NOT use any fields here before first ensuring that this same
* field is not in use on some other branch. Please clear any such changes
@@ -1393,8 +1400,7 @@ struct obd_connect_data {
* the matching OBD_CONNECT flag, so that can be approved and landed easily to
* reserve the flag for future use. */
-
-extern void lustre_swab_connect(struct obd_connect_data *ocd);
+void lustre_swab_connect(struct obd_connect_data *ocd);
/*
* Supported checksum algorithms. Up to 32 checksum types are supported.
@@ -1403,9 +1409,9 @@ extern void lustre_swab_connect(struct obd_connect_data *ocd);
* algorithm and also the OBD_FL_CKSUM* flags.
*/
typedef enum {
- OBD_CKSUM_CRC32 = 0x00000001,
- OBD_CKSUM_ADLER = 0x00000002,
- OBD_CKSUM_CRC32C= 0x00000004,
+ OBD_CKSUM_CRC32 = 0x00000001,
+ OBD_CKSUM_ADLER = 0x00000002,
+ OBD_CKSUM_CRC32C = 0x00000004,
} cksum_type_t;
/*
@@ -1443,7 +1449,7 @@ enum obdo_flags {
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_RECREATE_OBJS = 0x00000020, /* recreate missing obj */
OBD_FL_DEBUG_CHECK = 0x00000040, /* echo client/server debug check */
OBD_FL_NO_USRQUOTA = 0x00000100, /* the object's owner is over quota */
OBD_FL_NO_GRPQUOTA = 0x00000200, /* the object's group is over quota */
@@ -1736,10 +1742,10 @@ struct hsm_state_set {
__u64 hss_clearmask;
};
-extern void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
-extern void lustre_swab_hsm_state_set(struct hsm_state_set *hss);
+void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
+void lustre_swab_hsm_state_set(struct hsm_state_set *hss);
-extern void lustre_swab_obd_statfs (struct obd_statfs *os);
+void lustre_swab_obd_statfs(struct obd_statfs *os);
/* ost_body.data values for OST_BRW */
@@ -1779,7 +1785,7 @@ struct obd_ioobj {
#define ioobj_max_brw_set(ioo, num) \
do { (ioo)->ioo_max_brw = ((num) - 1) << IOOBJ_MAX_BRW_BITS; } while (0)
-extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
+void lustre_swab_obd_ioobj(struct obd_ioobj *ioo);
/* multiple of 8 bytes => can array */
struct niobuf_remote {
@@ -1788,7 +1794,7 @@ struct niobuf_remote {
__u32 flags;
};
-extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
+void lustre_swab_niobuf_remote(struct niobuf_remote *nbr);
/* lock value block communicated between the filter and llite */
@@ -1810,7 +1816,7 @@ struct ost_lvb_v1 {
__u64 lvb_blocks;
};
-extern void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb);
+void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb);
struct ost_lvb {
__u64 lvb_size;
@@ -1824,7 +1830,7 @@ struct ost_lvb {
__u32 lvb_padding;
};
-extern void lustre_swab_ost_lvb(struct ost_lvb *lvb);
+void lustre_swab_ost_lvb(struct ost_lvb *lvb);
/*
* lquota data structures
@@ -1863,7 +1869,7 @@ struct obd_quotactl {
struct obd_dqblk qc_dqblk;
};
-extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
+void lustre_swab_obd_quotactl(struct obd_quotactl *q);
#define Q_QUOTACHECK 0x800100 /* deprecated as of 2.4 */
#define Q_INITQUOTA 0x800101 /* deprecated as of 2.4 */
@@ -1912,7 +1918,7 @@ struct quota_body {
#define QUOTA_DQACQ_FL_REL 0x4 /* release quota */
#define QUOTA_DQACQ_FL_REPORT 0x8 /* report usage */
-extern void lustre_swab_quota_body(struct quota_body *b);
+void lustre_swab_quota_body(struct quota_body *b);
/* Quota types currently supported */
enum {
@@ -1930,6 +1936,7 @@ enum {
LQUOTA_LAST_RES,
LQUOTA_FIRST_RES = LQUOTA_RES_MD
};
+
#define LQUOTA_NR_RES (LQUOTA_LAST_RES - LQUOTA_FIRST_RES + 1)
/*
@@ -1977,6 +1984,7 @@ struct ldlm_gl_lquota_desc {
__u64 gl_time;
__u64 gl_pad2;
};
+
#define gl_qunit gl_hardlimit /* current qunit value used when
* glimpsing per-ID quota locks */
@@ -1992,7 +2000,7 @@ struct lquota_lvb {
__u64 lvb_pad1;
};
-extern void lustre_swab_lquota_lvb(struct lquota_lvb *lvb);
+void lustre_swab_lquota_lvb(struct lquota_lvb *lvb);
/* LVB used with global quota lock */
#define lvb_glb_ver lvb_id_may_rel /* current version of the global index */
@@ -2045,7 +2053,6 @@ typedef enum {
#define MDS_FIRST_OPC MDS_GETATTR
-
/* opcodes for object update */
typedef enum {
UPDATE_OBJ = 1000,
@@ -2071,7 +2078,7 @@ typedef enum {
REINT_MAX
} mds_reint_t, mdt_reint_t;
-extern void lustre_swab_generic_32s (__u32 *val);
+void lustre_swab_generic_32s(__u32 *val);
/* the disposition of the intent outlines what was executed */
#define DISP_IT_EXECD 0x00000001
@@ -2111,8 +2118,6 @@ extern void lustre_swab_generic_32s (__u32 *val);
/* This FULL lock is useful to take on unlink sort of operations */
#define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1)
-extern void lustre_swab_ll_fid (struct ll_fid *fid);
-
/* NOTE: until Lustre 1.8.7/2.1.1 the fid_ver() was packed into name[2],
* but was moved into name[1] along with the OID to avoid consuming the
* name[2,3] fields that need to be used for the quota id (also a FID). */
@@ -2230,7 +2235,7 @@ struct mdt_body {
__u64 padding_10;
}; /* 216 */
-extern void lustre_swab_mdt_body (struct mdt_body *b);
+void lustre_swab_mdt_body(struct mdt_body *b);
struct mdt_ioepoch {
struct lustre_handle handle;
@@ -2239,7 +2244,7 @@ struct mdt_ioepoch {
__u32 padding;
};
-extern void lustre_swab_mdt_ioepoch (struct mdt_ioepoch *b);
+void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b);
/* permissions for md_perm.mp_perm */
enum {
@@ -2263,7 +2268,7 @@ struct mdt_remote_perm {
__u32 rp_padding;
};
-extern void lustre_swab_mdt_remote_perm(struct mdt_remote_perm *p);
+void lustre_swab_mdt_remote_perm(struct mdt_remote_perm *p);
struct mdt_rec_setattr {
__u32 sa_opcode;
@@ -2293,7 +2298,7 @@ struct mdt_rec_setattr {
__u32 sa_padding_5;
};
-extern void lustre_swab_mdt_rec_setattr (struct mdt_rec_setattr *sa);
+void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa);
/*
* Attribute flags used in mdt_rec_setattr::sa_valid.
@@ -2365,23 +2370,6 @@ extern void lustre_swab_mdt_rec_setattr (struct mdt_rec_setattr *sa);
*/
#define MDS_OPEN_RELEASE 02000000000000ULL /* Open the file for HSM release */
-/* permission for create non-directory file */
-#define MAY_CREATE (1 << 7)
-/* permission for create directory file */
-#define MAY_LINK (1 << 8)
-/* permission for delete from the directory */
-#define MAY_UNLINK (1 << 9)
-/* source's permission for rename */
-#define MAY_RENAME_SRC (1 << 10)
-/* target's permission for rename */
-#define MAY_RENAME_TAR (1 << 11)
-/* part (parent's) VTX permission check */
-#define MAY_VTX_PART (1 << 12)
-/* full VTX permission check */
-#define MAY_VTX_FULL (1 << 13)
-/* lfs rgetfacl permission check */
-#define MAY_RGETFACL (1 << 14)
-
enum mds_op_bias {
MDS_CHECK_SPLIT = 1 << 0,
MDS_CROSS_REF = 1 << 1,
@@ -2583,7 +2571,7 @@ struct mdt_rec_reint {
__u32 rr_padding_4; /* also fix lustre_swab_mdt_rec_reint */
};
-extern void lustre_swab_mdt_rec_reint(struct mdt_rec_reint *rr);
+void lustre_swab_mdt_rec_reint(struct mdt_rec_reint *rr);
struct lmv_desc {
__u32 ld_tgt_count; /* how many MDS's */
@@ -2599,8 +2587,6 @@ struct lmv_desc {
struct obd_uuid ld_uuid;
};
-extern void lustre_swab_lmv_desc (struct lmv_desc *ld);
-
/* TODO: lmv_stripe_md should contain mds capabilities for all slave fids */
struct lmv_stripe_md {
__u32 mea_magic;
@@ -2611,8 +2597,6 @@ struct lmv_stripe_md {
struct lu_fid mea_ids[0];
};
-extern void lustre_swab_lmv_stripe_md(struct lmv_stripe_md *mea);
-
/* lmv structures */
#define MEA_MAGIC_LAST_CHAR 0xb2221ca1
#define MEA_MAGIC_ALL_CHARS 0xb222a11c
@@ -2669,7 +2653,7 @@ struct lov_desc {
#define ld_magic ld_active_tgt_count /* for swabbing from llogs */
-extern void lustre_swab_lov_desc (struct lov_desc *ld);
+void lustre_swab_lov_desc(struct lov_desc *ld);
/*
* LDLM requests:
@@ -2696,8 +2680,6 @@ struct ldlm_res_id {
#define PLDLMRES(res) (res)->lr_name.name[0], (res)->lr_name.name[1], \
(res)->lr_name.name[2], (res)->lr_name.name[3]
-extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
-
static inline int ldlm_res_eq(const struct ldlm_res_id *res0,
const struct ldlm_res_id *res1)
{
@@ -2773,19 +2755,17 @@ typedef union {
struct ldlm_inodebits l_inodebits;
} ldlm_wire_policy_data_t;
-extern void lustre_swab_ldlm_policy_data (ldlm_wire_policy_data_t *d);
-
union ldlm_gl_desc {
struct ldlm_gl_lquota_desc lquota_desc;
};
-extern void lustre_swab_gl_desc(union ldlm_gl_desc *);
+void lustre_swab_gl_desc(union ldlm_gl_desc *);
struct ldlm_intent {
__u64 opc;
};
-extern void lustre_swab_ldlm_intent (struct ldlm_intent *i);
+void lustre_swab_ldlm_intent(struct ldlm_intent *i);
struct ldlm_resource_desc {
ldlm_type_t lr_type;
@@ -2793,8 +2773,6 @@ struct ldlm_resource_desc {
struct ldlm_res_id lr_name;
};
-extern void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r);
-
struct ldlm_lock_desc {
struct ldlm_resource_desc l_resource;
ldlm_mode_t l_req_mode;
@@ -2802,8 +2780,6 @@ struct ldlm_lock_desc {
ldlm_wire_policy_data_t l_policy_data;
};
-extern void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l);
-
#define LDLM_LOCKREQ_HANDLES 2
#define LDLM_ENQUEUE_CANCEL_OFF 1
@@ -2814,7 +2790,7 @@ struct ldlm_request {
struct lustre_handle lock_handle[LDLM_LOCKREQ_HANDLES];
};
-extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
+void lustre_swab_ldlm_request(struct ldlm_request *rq);
/* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available.
* Otherwise, 2 are available. */
@@ -2836,7 +2812,7 @@ struct ldlm_reply {
__u64 lock_policy_res2;
};
-extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
+void lustre_swab_ldlm_reply(struct ldlm_reply *r);
#define ldlm_flags_to_wire(flags) ((__u32)(flags))
#define ldlm_flags_from_wire(flags) ((__u64)(flags))
@@ -2880,7 +2856,8 @@ struct mgs_target_info {
__u64 mti_nids[MTI_NIDS_MAX]; /* host nids (lnet_nid_t)*/
char mti_params[MTI_PARAM_MAXLEN];
};
-extern void lustre_swab_mgs_target_info(struct mgs_target_info *oinfo);
+
+void lustre_swab_mgs_target_info(struct mgs_target_info *oinfo);
struct mgs_nidtbl_entry {
__u64 mne_version; /* table version of this entry */
@@ -2895,7 +2872,8 @@ struct mgs_nidtbl_entry {
lnet_nid_t nids[0]; /* variable size buffer for NIDs. */
} u;
};
-extern void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *oinfo);
+
+void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *oinfo);
struct mgs_config_body {
char mcb_name[MTI_NAME_MAXLEN]; /* logname */
@@ -2905,13 +2883,15 @@ struct mgs_config_body {
__u8 mcb_bits; /* bits unit size of config log */
__u32 mcb_units; /* # of units for bulk transfer */
};
-extern void lustre_swab_mgs_config_body(struct mgs_config_body *body);
+
+void lustre_swab_mgs_config_body(struct mgs_config_body *body);
struct mgs_config_res {
__u64 mcr_offset; /* index of last config log */
__u64 mcr_size; /* size of the log */
};
-extern void lustre_swab_mgs_config_res(struct mgs_config_res *body);
+
+void lustre_swab_mgs_config_res(struct mgs_config_res *body);
/* Config marker flags (in config log) */
#define CM_START 0x01
@@ -2932,8 +2912,7 @@ struct cfg_marker {
char cm_comment[MTI_NAME_MAXLEN];
};
-extern void lustre_swab_cfg_marker(struct cfg_marker *marker,
- int swab, int size);
+void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size);
/*
* Opcodes for multiple servers.
@@ -3333,8 +3312,6 @@ static inline void lustre_get_wire_obdo(struct obd_connect_data *ocd,
}
}
-extern void lustre_swab_obdo (struct obdo *o);
-
/* request structure for OST's */
struct ost_body {
struct obdo oa;
@@ -3347,30 +3324,28 @@ struct ll_fiemap_info_key {
struct ll_user_fiemap fiemap;
};
-extern void lustre_swab_ost_body (struct ost_body *b);
-extern void lustre_swab_ost_last_id(__u64 *id);
-extern void lustre_swab_fiemap(struct ll_user_fiemap *fiemap);
+void lustre_swab_ost_body(struct ost_body *b);
+void lustre_swab_ost_last_id(__u64 *id);
+void lustre_swab_fiemap(struct ll_user_fiemap *fiemap);
-extern void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum);
-extern void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum);
-extern void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
- int stripe_count);
-extern void lustre_swab_lov_mds_md(struct lov_mds_md *lmm);
+void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum);
+void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum);
+void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
+ int stripe_count);
+void lustre_swab_lov_mds_md(struct lov_mds_md *lmm);
/* llog_swab.c */
-extern void lustre_swab_llogd_body (struct llogd_body *d);
-extern void lustre_swab_llog_hdr (struct llog_log_hdr *h);
-extern void lustre_swab_llogd_conn_body (struct llogd_conn_body *d);
-extern void lustre_swab_llog_rec(struct llog_rec_hdr *rec);
-extern void lustre_swab_llog_id(struct llog_logid *lid);
+void lustre_swab_llogd_body(struct llogd_body *d);
+void lustre_swab_llog_hdr(struct llog_log_hdr *h);
+void lustre_swab_llogd_conn_body(struct llogd_conn_body *d);
+void lustre_swab_llog_rec(struct llog_rec_hdr *rec);
struct lustre_cfg;
-extern void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
+void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
/* Functions for dumping PTLRPC fields */
void dump_rniobuf(struct niobuf_remote *rnb);
void dump_ioo(struct obd_ioobj *nb);
-void dump_obdo(struct obdo *oa);
void dump_ost_body(struct ost_body *ob);
void dump_rcs(__u32 *rc);
@@ -3417,7 +3392,8 @@ struct idx_info {
__u64 ii_pad2;
__u64 ii_pad3;
};
-extern void lustre_swab_idx_info(struct idx_info *ii);
+
+void lustre_swab_idx_info(struct idx_info *ii);
#define II_END_OFF MDS_DIR_END_OFF /* all entries have been read */
@@ -3449,7 +3425,6 @@ struct lu_idxpage {
* For the time being, we only support fixed-size key & record. */
char lip_entries[0];
};
-extern void lustre_swab_lip_header(struct lu_idxpage *lip);
#define LIP_HDR_SIZE (offsetof(struct lu_idxpage, lip_entries))
@@ -3485,11 +3460,12 @@ struct lustre_capa {
__u32 lc_flags; /** HMAC algorithm & flags */
__u32 lc_keyid; /** key# used for the capability */
__u32 lc_timeout; /** capa timeout value (sec) */
+/* FIXME: y2038 time_t overflow: */
__u32 lc_expiry; /** expiry time (sec) */
__u8 lc_hmac[CAPA_HMAC_MAX_LEN]; /** HMAC */
} __attribute__((packed));
-extern void lustre_swab_lustre_capa(struct lustre_capa *c);
+void lustre_swab_lustre_capa(struct lustre_capa *c);
/** lustre_capa::lc_opc */
enum {
@@ -3516,30 +3492,6 @@ enum {
#define CAPA_OPC_MDS_DEFAULT ~CAPA_OPC_OSS_ONLY
#define CAPA_OPC_OSS_DEFAULT ~(CAPA_OPC_MDS_ONLY | CAPA_OPC_OSS_ONLY)
-/* MDS capability covers object capability for operations of body r/w
- * (dir readpage/sendpage), index lookup/insert/delete and meta data r/w,
- * while OSS capability only covers object capability for operations of
- * oss data(file content) r/w/truncate.
- */
-static inline int capa_for_mds(struct lustre_capa *c)
-{
- return (c->lc_opc & CAPA_OPC_INDEX_LOOKUP) != 0;
-}
-
-static inline int capa_for_oss(struct lustre_capa *c)
-{
- return (c->lc_opc & CAPA_OPC_INDEX_LOOKUP) == 0;
-}
-
-/* lustre_capa::lc_hmac_alg */
-enum {
- CAPA_HMAC_ALG_SHA1 = 1, /**< sha1 algorithm */
- CAPA_HMAC_ALG_MAX,
-};
-
-#define CAPA_FL_MASK 0x00ffffff
-#define CAPA_HMAC_ALG_MASK 0xff000000
-
struct lustre_capa_key {
__u64 lk_seq; /**< mds# */
__u32 lk_keyid; /**< key# */
@@ -3547,8 +3499,6 @@ struct lustre_capa_key {
__u8 lk_key[CAPA_HMAC_KEY_MAX_LEN]; /**< key */
} __attribute__((packed));
-extern void lustre_swab_lustre_capa_key(struct lustre_capa_key *k);
-
/** The link ea holds 1 \a link_ea_entry for each hardlink */
#define LINK_EA_MAGIC 0x11EAF1DFUL
struct link_ea_header {
@@ -3568,7 +3518,7 @@ struct link_ea_entry {
unsigned char lee_reclen[2];
unsigned char lee_parent_fid[sizeof(struct lu_fid)];
char lee_name[0];
-}__attribute__((packed));
+} __attribute__((packed));
/** fid2path request/reply structure */
struct getinfo_fid2path {
@@ -3619,12 +3569,12 @@ struct hsm_progress_kernel {
__u64 hpk_padding2;
} __attribute__((packed));
-extern void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
-extern void lustre_swab_hsm_current_action(struct hsm_current_action *action);
-extern void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk);
-extern void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
-extern void lustre_swab_hsm_user_item(struct hsm_user_item *hui);
-extern void lustre_swab_hsm_request(struct hsm_request *hr);
+void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
+void lustre_swab_hsm_current_action(struct hsm_current_action *action);
+void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk);
+void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
+void lustre_swab_hsm_user_item(struct hsm_user_item *hui);
+void lustre_swab_hsm_request(struct hsm_request *hr);
/**
* These are object update opcode under UPDATE_OBJ, which is currently
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_lfsck_user.h b/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_lfsck_user.h
deleted file mode 100644
index 1c87a61a7..000000000
--- a/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_lfsck_user.h
+++ /dev/null
@@ -1,95 +0,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 COPYING file that accompanied this code.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * lustre/include/lustre/lustre_lfsck_user.h
- *
- * Lustre LFSCK userspace interfaces.
- *
- * Author: Fan Yong <yong.fan@whamcloud.com>
- */
-
-#ifndef _LUSTRE_LFSCK_USER_H
-# define _LUSTRE_LFSCK_USER_H
-
-enum lfsck_param_flags {
- /* Reset LFSCK iterator position to the device beginning. */
- LPF_RESET = 0x0001,
-
- /* Exit when fail. */
- LPF_FAILOUT = 0x0002,
-
- /* Dryrun mode, only check without modification */
- LPF_DRYRUN = 0x0004,
-};
-
-enum lfsck_type {
- /* For MDT-OST consistency check/repair. */
- LT_LAYOUT = 0x0001,
-
- /* For MDT-MDT consistency check/repair. */
- LT_DNE = 0x0002,
-
- /* For FID-in-dirent and linkEA consistency check/repair. */
- LT_NAMESPACE = 0x0004,
-};
-
-#define LFSCK_VERSION_V1 1
-#define LFSCK_VERSION_V2 2
-
-#define LFSCK_TYPES_ALL ((__u16)(~0))
-#define LFSCK_TYPES_DEF ((__u16)0)
-#define LFSCK_TYPES_SUPPORTED LT_NAMESPACE
-
-#define LFSCK_SPEED_NO_LIMIT 0
-#define LFSCK_SPEED_LIMIT_DEF LFSCK_SPEED_NO_LIMIT
-
-enum lfsck_start_valid {
- LSV_SPEED_LIMIT = 0x00000001,
- LSV_ERROR_HANDLE = 0x00000002,
- LSV_DRYRUN = 0x00000004,
-};
-
-/* Arguments for starting lfsck. */
-struct lfsck_start {
- /* Which arguments are valid, see 'enum lfsck_start_valid'. */
- __u32 ls_valid;
-
- /* How many items can be scanned at most per second. */
- __u32 ls_speed_limit;
-
- /* For compatibility between user space tools and kernel service. */
- __u16 ls_version;
-
- /* Which LFSCK components to be (have been) started. */
- __u16 ls_active;
-
- /* Flags for the LFSCK, see 'enum lfsck_param_flags'. */
- __u16 ls_flags;
-
- /* For 64-bits aligned. */
- __u16 ls_padding;
-};
-
-#endif /* _LUSTRE_LFSCK_USER_H */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
index 89794fdfe..80f8ec529 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre/lustre_user.h
@@ -243,7 +243,6 @@ struct ost_id {
#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_REMOVE_ENTRY _IOWR('f', 242, __u64)
#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)
@@ -262,7 +261,6 @@ struct ost_id {
#define LL_IOC_OBD_STATFS IOC_OBD_STATFS
#define IOC_MDC_GETSTRIPE IOC_MDC_GETFILESTRIPE
-
#define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */
/* Define O_LOV_DELAY_CREATE to be a mask that is not useful for regular
@@ -314,7 +312,7 @@ 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 */
-} __attribute__((packed));
+} __packed;
#define lov_user_md lov_user_md_v1
struct lov_user_md_v1 { /* LOV EA user data (host-endian) */
@@ -346,7 +344,7 @@ struct lov_user_md_v3 { /* LOV EA user data (host-endian) */
};
char lmm_pool_name[LOV_MAXPOOLNAME]; /* pool name */
struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
-} __attribute__((packed));
+} __packed;
static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
{
@@ -366,12 +364,12 @@ static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
struct lov_user_mds_data_v1 {
lstat_t lmd_st; /* MDS stat struct */
struct lov_user_md_v1 lmd_lmm; /* LOV EA V1 user data */
-} __attribute__((packed));
+} __packed;
struct lov_user_mds_data_v3 {
lstat_t lmd_st; /* MDS stat struct */
struct lov_user_md_v3 lmd_lmm; /* LOV EA V3 user data */
-} __attribute__((packed));
+} __packed;
#endif
/* keep this to be the same size as lov_user_ost_data_v1 */
@@ -407,8 +405,6 @@ static inline int lmv_user_md_size(int stripes, int lmm_magic)
stripes * sizeof(struct lmv_user_mds_data);
}
-extern void lustre_swab_lmv_user_md(struct lmv_user_md *lum);
-
struct ll_recreate_obj {
__u64 lrc_id;
__u32 lrc_ost_idx;
@@ -450,6 +446,7 @@ static inline char *obd_uuid2str(const struct obd_uuid *uuid)
/* Obviously not safe, but for printfs, no real harm done...
we're always null-terminated, even in a race. */
static char temp[sizeof(*uuid)];
+
memcpy(temp, uuid->uuid, sizeof(*uuid) - 1);
temp[sizeof(*uuid) - 1] = '\0';
return temp;
@@ -490,7 +487,6 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen)
&((fid)->f_oid), \
&((fid)->f_ver)
-
/********* Quotas **********/
/* these must be explicitly translated into linux Q_* in ll_dir_ioctl */
@@ -632,7 +628,6 @@ struct lustre_swap_layouts {
__u64 sl_dv2;
};
-
/********* Changelogs **********/
/** Changelog record types */
enum changelog_rec_type {
@@ -659,7 +654,8 @@ enum changelog_rec_type {
CL_LAST
};
-static inline const char *changelog_type2str(int type) {
+static inline const char *changelog_type2str(int type)
+{
static const char *changelog_str[] = {
"MARK", "CREAT", "MKDIR", "HLINK", "SLINK", "MKNOD", "UNLNK",
"RMDIR", "RENME", "RNMTO", "OPEN", "CLOSE", "LYOUT", "TRUNC",
@@ -770,7 +766,7 @@ struct changelog_rec {
};
lustre_fid cr_pfid; /**< parent fid */
char cr_name[0]; /**< last element */
-} __attribute__((packed));
+} __packed;
/* changelog_ext_rec is 2*sizeof(lu_fid) bigger than changelog_rec, to save
* space, only rename uses changelog_ext_rec, while others use changelog_rec to
@@ -792,21 +788,21 @@ struct changelog_ext_rec {
lustre_fid cr_sfid; /**< source fid, or zero */
lustre_fid cr_spfid; /**< source parent fid, or zero */
char cr_name[0]; /**< last element */
-} __attribute__((packed));
+} __packed;
#define CHANGELOG_REC_EXTENDED(rec) \
(((rec)->cr_flags & CLF_VERMASK) == CLF_EXT_VERSION)
static inline int changelog_rec_size(struct changelog_rec *rec)
{
- return CHANGELOG_REC_EXTENDED(rec) ? sizeof(struct changelog_ext_rec):
+ return CHANGELOG_REC_EXTENDED(rec) ? sizeof(struct changelog_ext_rec) :
sizeof(*rec);
}
static inline char *changelog_rec_name(struct changelog_rec *rec)
{
return CHANGELOG_REC_EXTENDED(rec) ?
- ((struct changelog_ext_rec *)rec)->cr_name: rec->cr_name;
+ ((struct changelog_ext_rec *)rec)->cr_name : rec->cr_name;
}
static inline int changelog_rec_snamelen(struct changelog_ext_rec *rec)
@@ -837,6 +833,7 @@ struct ioc_data_version {
__u64 idv_version;
__u64 idv_flags; /* See LL_DV_xxx */
};
+
#define LL_DV_NOFLUSH 0x01 /* Do not take READ EXTENT LOCK before sampling
version. Dirty caches are left unchanged. */
@@ -846,7 +843,6 @@ struct ioc_data_version {
#define dot_lustre_name ".lustre"
-
/********* HSM **********/
/** HSM per-file state
@@ -882,6 +878,7 @@ enum hsm_progress_states {
HPS_RUNNING = 2,
HPS_DONE = 3,
};
+
#define HPS_NONE 0
static inline char *hsm_progress_state2name(enum hsm_progress_states s)
@@ -897,7 +894,7 @@ static inline char *hsm_progress_state2name(enum hsm_progress_states s)
struct hsm_extent {
__u64 offset;
__u64 length;
-} __attribute__((packed));
+} __packed;
/**
* Current HSM states of a Lustre file.
@@ -981,7 +978,7 @@ struct hsm_request {
struct hsm_user_item {
lustre_fid hui_fid;
struct hsm_extent hui_extent;
-} __attribute__((packed));
+} __packed;
struct hsm_user_request {
struct hsm_request hur_request;
@@ -989,7 +986,7 @@ struct hsm_user_request {
/* extra data blob at end of struct (after all
* hur_user_items), only use helpers to access it
*/
-} __attribute__((packed));
+} __packed;
/** Return pointer to data field in a hsm user request */
static inline void *hur_data(struct hsm_user_request *hur)
@@ -1055,7 +1052,7 @@ struct hsm_action_item {
__u64 hai_cookie; /* action cookie from coordinator */
__u64 hai_gid; /* grouplock id */
char hai_data[0]; /* variable length */
-} __attribute__((packed));
+} __packed;
/*
* helper function which print in hexa the first bytes of
@@ -1099,13 +1096,14 @@ struct hsm_action_list {
char hal_fsname[0]; /* null-terminated */
/* struct hsm_action_item[hal_count] follows, aligned on 8-byte
boundaries. See hai_zero */
-} __attribute__((packed));
+} __packed;
#ifndef HAVE_CFS_SIZE_ROUND
static inline int cfs_size_round (int val)
{
return (val + 7) & (~0x7);
}
+
#define HAVE_CFS_SIZE_ROUND
#endif
@@ -1117,6 +1115,7 @@ static inline struct hsm_action_item *hai_zero(struct hsm_action_list *hal)
hal_fsname)
+ 1));
}
+
/* Return pointer to next hai */
static inline struct hsm_action_item *hai_next(struct hsm_action_item *hai)
{
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_capa.h b/kernel/drivers/staging/lustre/lustre/include/lustre_capa.h
deleted file mode 100644
index fe19534eb..000000000
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_capa.h
+++ /dev/null
@@ -1,305 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 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/include/lustre_capa.h
- *
- * Author: Lai Siyao <lsy@clusterfs.com>
- */
-
-#ifndef __LINUX_CAPA_H_
-#define __LINUX_CAPA_H_
-
-/** \defgroup capa capa
- *
- * @{
- */
-
-/*
- * capability
- */
-#include <linux/crypto.h>
-#include "lustre/lustre_idl.h"
-
-#define CAPA_TIMEOUT 1800 /* sec, == 30 min */
-#define CAPA_KEY_TIMEOUT (24 * 60 * 60) /* sec, == 1 days */
-
-struct capa_hmac_alg {
- const char *ha_name;
- int ha_len;
- int ha_keylen;
-};
-
-#define DEF_CAPA_HMAC_ALG(name, type, len, keylen) \
-[CAPA_HMAC_ALG_ ## type] = { \
- .ha_name = name, \
- .ha_len = len, \
- .ha_keylen = keylen, \
-}
-
-struct client_capa {
- struct inode *inode;
- struct list_head lli_list; /* link to lli_oss_capas */
-};
-
-struct target_capa {
- struct hlist_node c_hash; /* link to capa hash */
-};
-
-struct obd_capa {
- struct list_head c_list; /* link to capa_list */
-
- struct lustre_capa c_capa; /* capa */
- atomic_t c_refc; /* ref count */
- unsigned long c_expiry; /* jiffies */
- spinlock_t c_lock; /* protect capa content */
- int c_site;
-
- union {
- struct client_capa cli;
- struct target_capa tgt;
- } u;
-};
-
-enum {
- CAPA_SITE_CLIENT = 0,
- CAPA_SITE_SERVER,
- CAPA_SITE_MAX
-};
-
-static inline struct lu_fid *capa_fid(struct lustre_capa *capa)
-{
- return &capa->lc_fid;
-}
-
-static inline __u64 capa_opc(struct lustre_capa *capa)
-{
- return capa->lc_opc;
-}
-
-static inline __u64 capa_uid(struct lustre_capa *capa)
-{
- return capa->lc_uid;
-}
-
-static inline __u64 capa_gid(struct lustre_capa *capa)
-{
- return capa->lc_gid;
-}
-
-static inline __u32 capa_flags(struct lustre_capa *capa)
-{
- return capa->lc_flags & 0xffffff;
-}
-
-static inline __u32 capa_alg(struct lustre_capa *capa)
-{
- return (capa->lc_flags >> 24);
-}
-
-static inline __u32 capa_keyid(struct lustre_capa *capa)
-{
- return capa->lc_keyid;
-}
-
-static inline __u64 capa_key_seq(struct lustre_capa_key *key)
-{
- return key->lk_seq;
-}
-
-static inline __u32 capa_key_keyid(struct lustre_capa_key *key)
-{
- return key->lk_keyid;
-}
-
-static inline __u32 capa_timeout(struct lustre_capa *capa)
-{
- return capa->lc_timeout;
-}
-
-static inline __u32 capa_expiry(struct lustre_capa *capa)
-{
- return capa->lc_expiry;
-}
-
-void _debug_capa(struct lustre_capa *, struct libcfs_debug_msg_data *,
- const char *fmt, ...);
-#define DEBUG_CAPA(level, capa, fmt, args...) \
-do { \
- if (((level) & D_CANTMASK) != 0 || \
- ((libcfs_debug & (level)) != 0 && \
- (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) { \
- LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, level, NULL); \
- _debug_capa((capa), &msgdata, fmt, ##args); \
- } \
-} while (0)
-
-#define DEBUG_CAPA_KEY(level, k, fmt, args...) \
-do { \
-CDEBUG(level, fmt " capability key@%p seq %llu keyid %u\n", \
- ##args, k, capa_key_seq(k), capa_key_keyid(k)); \
-} while (0)
-
-typedef int (* renew_capa_cb_t)(struct obd_capa *, struct lustre_capa *);
-
-/* obdclass/capa.c */
-extern struct list_head capa_list[];
-extern spinlock_t capa_lock;
-extern int capa_count[];
-extern struct kmem_cache *capa_cachep;
-
-struct hlist_head *init_capa_hash(void);
-void cleanup_capa_hash(struct hlist_head *hash);
-
-struct obd_capa *capa_add(struct hlist_head *hash,
- struct lustre_capa *capa);
-struct obd_capa *capa_lookup(struct hlist_head *hash,
- struct lustre_capa *capa, int alive);
-
-int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key);
-int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen);
-int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen);
-void capa_cpy(void *dst, struct obd_capa *ocapa);
-static inline struct obd_capa *alloc_capa(int site)
-{
- struct obd_capa *ocapa;
-
- if (unlikely(site != CAPA_SITE_CLIENT && site != CAPA_SITE_SERVER))
- return ERR_PTR(-EINVAL);
-
- OBD_SLAB_ALLOC_PTR(ocapa, capa_cachep);
- if (unlikely(!ocapa))
- return ERR_PTR(-ENOMEM);
-
- INIT_LIST_HEAD(&ocapa->c_list);
- atomic_set(&ocapa->c_refc, 1);
- spin_lock_init(&ocapa->c_lock);
- ocapa->c_site = site;
- if (ocapa->c_site == CAPA_SITE_CLIENT)
- INIT_LIST_HEAD(&ocapa->u.cli.lli_list);
- else
- INIT_HLIST_NODE(&ocapa->u.tgt.c_hash);
-
- return ocapa;
-}
-
-static inline struct obd_capa *capa_get(struct obd_capa *ocapa)
-{
- if (!ocapa)
- return NULL;
-
- atomic_inc(&ocapa->c_refc);
- return ocapa;
-}
-
-static inline void capa_put(struct obd_capa *ocapa)
-{
- if (!ocapa)
- return;
-
- if (atomic_read(&ocapa->c_refc) == 0) {
- DEBUG_CAPA(D_ERROR, &ocapa->c_capa, "refc is 0 for");
- LBUG();
- }
-
- if (atomic_dec_and_test(&ocapa->c_refc)) {
- LASSERT(list_empty(&ocapa->c_list));
- if (ocapa->c_site == CAPA_SITE_CLIENT) {
- LASSERT(list_empty(&ocapa->u.cli.lli_list));
- } else {
- struct hlist_node *hnode;
-
- hnode = &ocapa->u.tgt.c_hash;
- LASSERT(!hnode->next && !hnode->pprev);
- }
- OBD_SLAB_FREE(ocapa, capa_cachep, sizeof(*ocapa));
- }
-}
-
-static inline int open_flags_to_accmode(int flags)
-{
- int mode = flags;
-
- if ((mode + 1) & O_ACCMODE)
- mode++;
- if (mode & O_TRUNC)
- mode |= 2;
-
- return mode;
-}
-
-static inline __u64 capa_open_opc(int mode)
-{
- return mode & FMODE_WRITE ? CAPA_OPC_OSS_WRITE : CAPA_OPC_OSS_READ;
-}
-
-static inline void set_capa_expiry(struct obd_capa *ocapa)
-{
- unsigned long expiry = cfs_time_sub((unsigned long)ocapa->c_capa.lc_expiry,
- get_seconds());
- ocapa->c_expiry = cfs_time_add(cfs_time_current(),
- cfs_time_seconds(expiry));
-}
-
-static inline int capa_is_expired_sec(struct lustre_capa *capa)
-{
- return (capa->lc_expiry - get_seconds() <= 0);
-}
-
-static inline int capa_is_expired(struct obd_capa *ocapa)
-{
- return time_before_eq(ocapa->c_expiry, cfs_time_current());
-}
-
-static inline int capa_opc_supported(struct lustre_capa *capa, __u64 opc)
-{
- return (capa_opc(capa) & opc) == opc;
-}
-
-struct filter_capa_key {
- struct list_head k_list;
- struct lustre_capa_key k_key;
-};
-
-enum {
- LC_ID_NONE = 0,
- LC_ID_PLAIN = 1,
- LC_ID_CONVERT = 2
-};
-
-#define BYPASS_CAPA (struct lustre_capa *)ERR_PTR(-ENOENT)
-
-/** @} capa */
-
-#endif /* __LINUX_CAPA_H_ */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_cfg.h b/kernel/drivers/staging/lustre/lustre/include/lustre_cfg.h
index 7b385b872..eb6b292b7 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_cfg.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_cfg.h
@@ -157,6 +157,7 @@ static inline void *lustre_cfg_buf(struct lustre_cfg *lcfg, int index)
int i;
int offset;
int bufcount;
+
LASSERT (lcfg != NULL);
LASSERT (index >= 0);
@@ -174,6 +175,7 @@ static inline void lustre_cfg_bufs_init(struct lustre_cfg_bufs *bufs,
struct lustre_cfg *lcfg)
{
int i;
+
bufs->lcfg_bufcount = lcfg->lcfg_bufcount;
for (i = 0; i < bufs->lcfg_bufcount; i++) {
bufs->lcfg_buflen[i] = lcfg->lcfg_buflens[i];
@@ -200,6 +202,7 @@ static inline char *lustre_cfg_string(struct lustre_cfg *lcfg, int index)
int last = min((int)lcfg->lcfg_buflens[index],
cfs_size_round(lcfg->lcfg_buflens[index]) - 1);
char lost = s[last];
+
s[last] = '\0';
if (lost != '\0') {
CWARN("Truncated buf %d to '%s' (lost '%c'...)\n",
@@ -221,7 +224,6 @@ static inline int lustre_cfg_len(__u32 bufcount, __u32 *buflens)
return cfs_size_round(len);
}
-
#include "obd_support.h"
static inline struct lustre_cfg *lustre_cfg_new(int cmd,
@@ -231,8 +233,8 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd,
char *ptr;
int i;
- OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount,
- bufs->lcfg_buflen));
+ lcfg = kzalloc(lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen),
+ GFP_NOFS);
if (!lcfg)
return ERR_PTR(-ENOMEM);
@@ -254,7 +256,7 @@ static inline void lustre_cfg_free(struct lustre_cfg *lcfg)
len = lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens);
- OBD_FREE(lcfg, len);
+ kfree(lcfg);
return;
}
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_debug.h b/kernel/drivers/staging/lustre/lustre/include/lustre_debug.h
index 6c92d0bc9..8a089413c 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_debug.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_debug.h
@@ -46,7 +46,6 @@
#include "obd.h"
/* lib/debug.c */
-void dump_lniobuf(struct niobuf_local *lnb);
int dump_req(struct ptlrpc_request *req);
int block_debug_setup(void *addr, int len, __u64 off, __u64 id);
int block_debug_check(char *who, void *addr, int len, __u64 off, __u64 id);
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_disk.h b/kernel/drivers/staging/lustre/lustre/include/lustre_disk.h
index 9b2833131..5e1ac129a 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_disk.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_disk.h
@@ -52,24 +52,6 @@
#include "../../include/linux/lnet/types.h"
#include <linux/backing-dev.h>
-/****************** on-disk files *********************/
-
-#define MDT_LOGS_DIR "LOGS" /* COMPAT_146 */
-#define MOUNT_CONFIGS_DIR "CONFIGS"
-#define CONFIGS_FILE "mountdata"
-/** Persistent mount data are stored on the disk in this file. */
-#define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"/"CONFIGS_FILE
-#define LAST_RCVD "last_rcvd"
-#define LOV_OBJID "lov_objid"
-#define LOV_OBJSEQ "lov_objseq"
-#define HEALTH_CHECK "health_check"
-#define CAPA_KEYS "capa_keys"
-#define CHANGELOG_USERS "changelog_users"
-#define MGS_NIDTBL_DIR "NIDTBL_VERSIONS"
-#define QMT_DIR "quota_master"
-#define QSD_DIR "quota_slave"
-#define HSM_ACTIONS "hsm_actions"
-
/****************** persistent mount data *********************/
#define LDD_F_SV_TYPE_MDT 0x0001
@@ -79,130 +61,6 @@
LDD_F_SV_TYPE_OST | \
LDD_F_SV_TYPE_MGS)
#define LDD_F_SV_ALL 0x0008
-/** need an index assignment */
-#define LDD_F_NEED_INDEX 0x0010
-/** never registered */
-#define LDD_F_VIRGIN 0x0020
-/** update the config logs for this server */
-#define LDD_F_UPDATE 0x0040
-/** rewrite the LDD */
-#define LDD_F_REWRITE_LDD 0x0080
-/** regenerate config logs for this fs or server */
-#define LDD_F_WRITECONF 0x0100
-/** COMPAT_14 */
-#define LDD_F_UPGRADE14 0x0200
-/** process as lctl conf_param */
-#define LDD_F_PARAM 0x0400
-/** all nodes are specified as service nodes */
-#define LDD_F_NO_PRIMNODE 0x1000
-/** IR enable flag */
-#define LDD_F_IR_CAPABLE 0x2000
-/** the MGS refused to register the target. */
-#define LDD_F_ERROR 0x4000
-/** process at lctl conf_param */
-#define LDD_F_PARAM2 0x8000
-
-/* opc for target register */
-#define LDD_F_OPC_REG 0x10000000
-#define LDD_F_OPC_UNREG 0x20000000
-#define LDD_F_OPC_READY 0x40000000
-#define LDD_F_OPC_MASK 0xf0000000
-
-#define LDD_F_ONDISK_MASK (LDD_F_SV_TYPE_MASK)
-
-#define LDD_F_MASK 0xFFFF
-
-enum ldd_mount_type {
- LDD_MT_EXT3 = 0,
- LDD_MT_LDISKFS,
- LDD_MT_SMFS,
- LDD_MT_REISERFS,
- LDD_MT_LDISKFS2,
- LDD_MT_ZFS,
- LDD_MT_LAST
-};
-
-static inline char *mt_str(enum ldd_mount_type mt)
-{
- static char *mount_type_string[] = {
- "ext3",
- "ldiskfs",
- "smfs",
- "reiserfs",
- "ldiskfs2",
- "zfs",
- };
- return mount_type_string[mt];
-}
-
-static inline char *mt_type(enum ldd_mount_type mt)
-{
- static char *mount_type_string[] = {
- "osd-ldiskfs",
- "osd-ldiskfs",
- "osd-smfs",
- "osd-reiserfs",
- "osd-ldiskfs",
- "osd-zfs",
- };
- return mount_type_string[mt];
-}
-
-#define LDD_INCOMPAT_SUPP 0
-#define LDD_ROCOMPAT_SUPP 0
-
-#define LDD_MAGIC 0x1dd00001
-
-/* On-disk configuration file. In host-endian order. */
-struct lustre_disk_data {
- __u32 ldd_magic;
- __u32 ldd_feature_compat; /* compatible feature flags */
- __u32 ldd_feature_rocompat;/* read-only compatible feature flags */
- __u32 ldd_feature_incompat;/* incompatible feature flags */
-
- __u32 ldd_config_ver; /* config rewrite count - not used */
- __u32 ldd_flags; /* LDD_SV_TYPE */
- __u32 ldd_svindex; /* server index (0001), must match
- svname */
- __u32 ldd_mount_type; /* target fs type LDD_MT_* */
- char ldd_fsname[64]; /* filesystem this server is part of,
- MTI_NAME_MAXLEN */
- char ldd_svname[64]; /* this server's name (lustre-mdt0001)*/
- __u8 ldd_uuid[40]; /* server UUID (COMPAT_146) */
-
-/*200*/ char ldd_userdata[1024 - 200]; /* arbitrary user string */
-/*1024*/__u8 ldd_padding[4096 - 1024];
-/*4096*/char ldd_mount_opts[4096]; /* target fs mount opts */
-/*8192*/char ldd_params[4096]; /* key=value pairs */
-};
-
-
-#define IS_MDT(data) ((data)->lsi_flags & LDD_F_SV_TYPE_MDT)
-#define IS_OST(data) ((data)->lsi_flags & LDD_F_SV_TYPE_OST)
-#define IS_MGS(data) ((data)->lsi_flags & LDD_F_SV_TYPE_MGS)
-#define IS_SERVER(data) ((data)->lsi_flags & (LDD_F_SV_TYPE_MGS | \
- LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST))
-#define MT_STR(data) mt_str((data)->ldd_mount_type)
-
-/* Make the mdt/ost server obd name based on the filesystem name */
-static inline int server_make_name(__u32 flags, __u16 index, char *fs,
- char *name)
-{
- if (flags & (LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST)) {
- if (!(flags & LDD_F_SV_ALL))
- sprintf(name, "%.8s%c%s%04x", fs,
- (flags & LDD_F_VIRGIN) ? ':' :
- ((flags & LDD_F_WRITECONF) ? '=' : '-'),
- (flags & LDD_F_SV_TYPE_MDT) ? "MDT" : "OST",
- index);
- } else if (flags & LDD_F_SV_TYPE_MGS) {
- sprintf(name, "MGS");
- } else {
- CERROR("unknown server type %#x\n", flags);
- return 1;
- }
- return 0;
-}
/****************** mount command *********************/
@@ -249,7 +107,6 @@ struct lustre_mount_data {
#define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT)
-
/****************** last_rcvd file *********************/
/** version recovery epoch */
@@ -365,7 +222,8 @@ static inline void check_lcd(char *obd_name, int index,
struct lsd_client_data *lcd)
{
int length = sizeof(lcd->lcd_uuid);
- if (strnlen((char*)lcd->lcd_uuid, length) == length) {
+
+ if (strnlen((char *)lcd->lcd_uuid, length) == length) {
lcd->lcd_uuid[length - 1] = '\0';
LCONSOLE_ERROR("the client UUID (%s) on %s for exports stored in last_rcvd(index = %d) is bad!\n",
@@ -378,6 +236,7 @@ static inline void lsd_le_to_cpu(struct lr_server_data *buf,
struct lr_server_data *lsd)
{
int i;
+
memcpy(lsd->lsd_uuid, buf->lsd_uuid, sizeof(lsd->lsd_uuid));
lsd->lsd_last_transno = le64_to_cpu(buf->lsd_last_transno);
lsd->lsd_compat14 = le64_to_cpu(buf->lsd_compat14);
@@ -405,6 +264,7 @@ static inline void lsd_cpu_to_le(struct lr_server_data *lsd,
struct lr_server_data *buf)
{
int i;
+
memcpy(buf->lsd_uuid, lsd->lsd_uuid, sizeof(buf->lsd_uuid));
buf->lsd_last_transno = cpu_to_le64(lsd->lsd_last_transno);
buf->lsd_compat14 = cpu_to_le64(lsd->lsd_compat14);
@@ -512,7 +372,6 @@ struct lustre_sb_info {
#define get_mount_flags(sb) (s2lsi(sb)->lsi_lmd->lmd_flags)
#define get_mntdev_name(sb) (s2lsi(sb)->lsi_lmd->lmd_dev)
-
/****************** mount lookup info *********************/
struct lustre_mount_info {
@@ -525,21 +384,13 @@ struct lustre_mount_info {
/****************** prototypes *********************/
/* obd_mount.c */
-int server_name2fsname(const char *svname, char *fsname, const char **endptr);
-int server_name2index(const char *svname, __u32 *idx, const char **endptr);
-int server_name2svname(const char *label, char *svname, const char **endptr,
- size_t svsize);
-
-int lustre_put_lsi(struct super_block *sb);
-int lustre_start_simple(char *obdname, char *type, char *uuid,
- char *s1, char *s2, char *s3, char *s4);
+
int lustre_start_mgc(struct super_block *sb);
void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb,
struct vfsmount *mnt));
void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb));
int lustre_common_put_super(struct super_block *sb);
-
int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type);
/** @} disk */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_dlm.h b/kernel/drivers/staging/lustre/lustre/include/lustre_dlm.h
index bac9902b5..0e75a15fe 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -64,7 +64,6 @@ struct obd_device;
#define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus())
#define LDLM_DEFAULT_MAX_ALIVE (cfs_time_seconds(36000))
-#define LDLM_CTIME_AGE_LIMIT (10)
#define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024
/**
@@ -211,7 +210,6 @@ struct ldlm_pool_ops {
/** Cancel at least \a nr locks from pool \a pl */
int (*po_shrink)(struct ldlm_pool *pl, int nr,
gfp_t gfp_mask);
- int (*po_setup)(struct ldlm_pool *pl, int limit);
};
/** One second for pools thread check interval. Each pool has own period. */
@@ -232,8 +230,8 @@ struct ldlm_pool_ops {
* This feature is commonly referred to as lru_resize.
*/
struct ldlm_pool {
- /** Pool proc directory. */
- struct proc_dir_entry *pl_proc_dir;
+ /** Pool debugfs directory. */
+ struct dentry *pl_debugfs_entry;
/** Pool name, must be long enough to hold compound proc entry name. */
char pl_name[100];
/** Lock for protecting SLV/CLV updates. */
@@ -254,20 +252,20 @@ struct ldlm_pool {
* server_slv * lock_volume_factor. */
atomic_t pl_lock_volume_factor;
/** Time when last SLV from server was obtained. */
- time_t pl_recalc_time;
+ time64_t pl_recalc_time;
/** Recalculation period for pool. */
- time_t pl_recalc_period;
+ time64_t pl_recalc_period;
/** Recalculation and shrink operations. */
const struct ldlm_pool_ops *pl_ops;
/** Number of planned locks for next period. */
int pl_grant_plan;
/** Pool statistics. */
struct lprocfs_stats *pl_stats;
-};
-typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **,
- void *req_cookie, ldlm_mode_t mode, __u64 flags,
- void *data);
+ /* sysfs object */
+ struct kobject pl_kobj;
+ struct completion pl_kobj_unregister;
+};
typedef int (*ldlm_cancel_for_recovery)(struct ldlm_lock *lock);
@@ -302,14 +300,6 @@ typedef enum {
LDLM_NAMESPACE_MODEST = 1 << 1
} ldlm_appetite_t;
-/**
- * Default values for the "max_nolock_size", "contention_time" and
- * "contended_locks" namespace tunables.
- */
-#define NS_DEFAULT_MAX_NOLOCK_BYTES 0
-#define NS_DEFAULT_CONTENTION_SECONDS 2
-#define NS_DEFAULT_CONTENDED_LOCKS 32
-
struct ldlm_ns_bucket {
/** back pointer to namespace */
struct ldlm_namespace *nsb_namespace;
@@ -390,8 +380,8 @@ struct ldlm_namespace {
/** Client side original connect flags supported by server. */
__u64 ns_orig_connect_flags;
- /* namespace proc dir entry */
- struct proc_dir_entry *ns_proc_dir_entry;
+ /* namespace debugfs dir entry */
+ struct dentry *ns_debugfs_entry;
/**
* Position in global namespace list linking all namespaces on
@@ -421,18 +411,6 @@ struct ldlm_namespace {
unsigned int ns_max_unused;
/** Maximum allowed age (last used time) for locks in the LRU */
unsigned int ns_max_age;
- /**
- * Server only: number of times we evicted clients due to lack of reply
- * to ASTs.
- */
- unsigned int ns_timeouts;
- /**
- * Number of seconds since the file change time after which the
- * MDT will return an UPDATE lock along with a LOOKUP lock.
- * This allows the client to start caching negative dentries
- * for a directory and may save an RPC for a later stat.
- */
- unsigned int ns_ctime_age_limit;
/**
* Used to rate-limit ldlm_namespace_dump calls.
@@ -441,9 +419,6 @@ struct ldlm_namespace {
*/
unsigned long ns_next_dump;
- /** "policy" function that does actual lock conflict determination */
- ldlm_res_policy ns_policy;
-
/**
* LVB operations for this namespace.
* \see struct ldlm_valblock_ops
@@ -466,27 +441,6 @@ struct ldlm_namespace {
/** Definition of how eagerly unused locks will be released from LRU */
ldlm_appetite_t ns_appetite;
- /**
- * If more than \a ns_contended_locks are found, the resource is
- * considered to be contended. Lock enqueues might specify that no
- * contended locks should be granted
- */
- unsigned ns_contended_locks;
-
- /**
- * The resources in this namespace remember contended state during
- * \a ns_contention_time, in seconds.
- */
- unsigned ns_contention_time;
-
- /**
- * Limit size of contended extent locks, in bytes.
- * If extended lock is requested for more then this many bytes and
- * caller instructs us not to grant contended locks, we would disregard
- * such a request.
- */
- unsigned ns_max_nolock_size;
-
/** Limit of parallel AST RPC count. */
unsigned ns_max_parallel_ast;
@@ -501,33 +455,10 @@ struct ldlm_namespace {
* recalculation of LDLM pool statistics should be skipped.
*/
unsigned ns_stopping:1;
-};
-/**
- * Returns 1 if namespace \a ns is a client namespace.
- */
-static inline int ns_is_client(struct ldlm_namespace *ns)
-{
- LASSERT(ns != NULL);
- LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |
- LDLM_NAMESPACE_SERVER)));
- LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||
- ns->ns_client == LDLM_NAMESPACE_SERVER);
- return ns->ns_client == LDLM_NAMESPACE_CLIENT;
-}
-
-/**
- * Returns 1 if namespace \a ns is a server namespace.
- */
-static inline int ns_is_server(struct ldlm_namespace *ns)
-{
- LASSERT(ns != NULL);
- LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |
- LDLM_NAMESPACE_SERVER)));
- LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||
- ns->ns_client == LDLM_NAMESPACE_SERVER);
- return ns->ns_client == LDLM_NAMESPACE_SERVER;
-}
+ struct kobject ns_kobj; /* sysfs object */
+ struct completion ns_kobj_unregister;
+};
/**
* Returns 1 if namespace \a ns supports early lock cancel (ELC).
@@ -584,6 +515,7 @@ struct ldlm_interval {
struct list_head li_group; /* the locks which have the same
* policy - group of the policy */
};
+
#define to_ldlm_interval(n) container_of(n, struct ldlm_interval, li_node)
/**
@@ -627,9 +559,6 @@ typedef union {
struct ldlm_inodebits l_inodebits;
} ldlm_policy_data_t;
-void ldlm_convert_policy_to_wire(ldlm_type_t type,
- const ldlm_policy_data_t *lpolicy,
- ldlm_wire_policy_data_t *wpolicy);
void ldlm_convert_policy_to_local(struct obd_export *exp, ldlm_type_t type,
const ldlm_wire_policy_data_t *wpolicy,
ldlm_policy_data_t *lpolicy);
@@ -781,7 +710,7 @@ struct ldlm_lock {
* Seconds. It will be updated if there is any activity related to
* the lock, e.g. enqueue the lock or send blocking AST.
*/
- unsigned long l_last_activity;
+ time64_t l_last_activity;
/**
* Time last used by e.g. being matched by lock match.
@@ -915,8 +844,6 @@ struct ldlm_resource {
* @{ */
/** List of locks in granted state */
struct list_head lr_granted;
- /** List of locks waiting to change their granted mode (converted) */
- struct list_head lr_converting;
/**
* List of locks that could not be granted due to conflicts and
* that are waiting for conflicts to go away */
@@ -1048,8 +975,7 @@ struct ldlm_enqueue_info {
extern struct obd_ops ldlm_obd_ops;
extern char *ldlm_lockname[];
-extern char *ldlm_typename[];
-extern char *ldlm_it2str(int it);
+char *ldlm_it2str(int it);
/**
* Just a fancy CDEBUG call with log level preset to LDLM_DEBUG.
@@ -1057,7 +983,7 @@ extern char *ldlm_it2str(int it);
* with a debugging message that is ldlm-related
*/
#define LDLM_DEBUG_NOLOCK(format, a...) \
- CDEBUG(D_DLMTRACE, "### " format "\n" , ##a)
+ CDEBUG(D_DLMTRACE, "### " format "\n", ##a)
/**
* Support function for lock information printing into debug logs.
@@ -1083,7 +1009,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
#define LDLM_DEBUG_LIMIT(mask, lock, fmt, a...) do { \
static struct cfs_debug_limit_state _ldlm_cdls; \
LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, &_ldlm_cdls); \
- ldlm_lock_debug(&msgdata, mask, &_ldlm_cdls, lock, "### " fmt , ##a);\
+ ldlm_lock_debug(&msgdata, mask, &_ldlm_cdls, lock, "### " fmt, ##a);\
} while (0)
#define LDLM_ERROR(lock, fmt, a...) LDLM_DEBUG_LIMIT(D_ERROR, lock, fmt, ## a)
@@ -1094,7 +1020,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
if (likely(lock != NULL)) { \
LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_DLMTRACE, NULL); \
ldlm_lock_debug(&msgdata, D_DLMTRACE, NULL, lock, \
- "### " fmt , ##a); \
+ "### " fmt, ##a); \
} else { \
LDLM_DEBUG_NOLOCK("no dlm lock: " fmt, ##a); \
} \
@@ -1119,10 +1045,6 @@ typedef int (*ldlm_res_iterator_t)(struct ldlm_resource *, void *);
* LDLM provides for a way to iterate through every lock on a resource or
* namespace or every resource in a namespace.
* @{ */
-int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
- void *closure);
-void ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter,
- void *closure);
int ldlm_resource_iterate(struct ldlm_namespace *, const struct ldlm_res_id *,
ldlm_iterator_t iter, void *data);
/** @} ldlm_iterator */
@@ -1142,16 +1064,11 @@ struct ldlm_callback_suite {
};
/* ldlm_lockd.c */
-int ldlm_del_waiting_lock(struct ldlm_lock *lock);
-int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout);
int ldlm_get_ref(void);
void ldlm_put_ref(void);
-int ldlm_init_export(struct obd_export *exp);
-void ldlm_destroy_export(struct obd_export *exp);
struct ldlm_lock *ldlm_request_lock(struct ptlrpc_request *req);
/* ldlm_lock.c */
-void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg);
void ldlm_lock2handle(const struct ldlm_lock *lock,
struct lustre_handle *lockh);
struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *, __u64 flags);
@@ -1197,8 +1114,7 @@ static inline int ldlm_res_lvbo_update(struct ldlm_resource *res,
}
int ldlm_error2errno(ldlm_error_t error);
-ldlm_error_t ldlm_errno2error(int err_no); /* don't call it `errno': this
- * confuses user-space. */
+
#if LUSTRE_TRACKS_LOCK_EXP_REFS
void ldlm_dump_export_locks(struct obd_export *exp);
#endif
@@ -1246,14 +1162,12 @@ do { \
struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
void ldlm_lock_put(struct ldlm_lock *lock);
-void ldlm_lock_destroy(struct ldlm_lock *lock);
void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc);
void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode);
int ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode);
void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode);
void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode);
void ldlm_lock_fail_match_locked(struct ldlm_lock *lock);
-void ldlm_lock_fail_match(struct ldlm_lock *lock);
void ldlm_lock_allow_match(struct ldlm_lock *lock);
void ldlm_lock_allow_match_locked(struct ldlm_lock *lock);
ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags,
@@ -1262,12 +1176,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags,
struct lustre_handle *, int unref);
ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh,
__u64 *bits);
-struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
- __u32 *flags);
-void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode);
void ldlm_lock_cancel(struct ldlm_lock *lock);
-void ldlm_reprocess_all(struct ldlm_resource *res);
-void ldlm_reprocess_all_ns(struct ldlm_namespace *ns);
void ldlm_lock_dump_handle(int level, struct lustre_handle *);
void ldlm_unlink_lock_skiplist(struct ldlm_lock *req);
@@ -1277,26 +1186,16 @@ ldlm_namespace_new(struct obd_device *obd, char *name,
ldlm_side_t client, ldlm_appetite_t apt,
ldlm_ns_type_t ns_type);
int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags);
-void ldlm_namespace_free(struct ldlm_namespace *ns,
- struct obd_import *imp, int force);
-void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client);
-void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client);
void ldlm_namespace_get(struct ldlm_namespace *ns);
void ldlm_namespace_put(struct ldlm_namespace *ns);
-#if defined (CONFIG_PROC_FS)
-int ldlm_proc_setup(void);
-void ldlm_proc_cleanup(void);
-#else
-static inline int ldlm_proc_setup(void) { return 0; }
-static inline void ldlm_proc_cleanup(void) {}
-#endif
+int ldlm_debugfs_setup(void);
+void ldlm_debugfs_cleanup(void);
/* resource.c - internal */
struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
struct ldlm_resource *parent,
const struct ldlm_res_id *,
ldlm_type_t type, int create);
-struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res);
int ldlm_resource_putref(struct ldlm_resource *res);
void ldlm_resource_add_lock(struct ldlm_resource *res,
struct list_head *head,
@@ -1318,16 +1217,11 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
} while (0)
/* ldlm_request.c */
-int ldlm_expired_completion_wait(void *data);
/** \defgroup ldlm_local_ast Default AST handlers for local locks
* These AST handlers are typically used for server-side local locks and are
* also used by client-side lock handlers to perform minimum level base
* processing.
* @{ */
-int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock);
-int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
- void *data, int flag);
-int ldlm_glimpse_ast(struct ldlm_lock *lock, void *reqp);
int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data);
int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data);
/** @} ldlm_local_ast */
@@ -1351,27 +1245,10 @@ int ldlm_prep_elc_req(struct obd_export *exp,
int version, int opc, int canceloff,
struct list_head *cancels, int count);
-struct ptlrpc_request *ldlm_enqueue_pack(struct obd_export *exp, int lvb_len);
-int ldlm_handle_enqueue0(struct ldlm_namespace *ns, struct ptlrpc_request *req,
- const struct ldlm_request *dlm_req,
- const struct ldlm_callback_suite *cbs);
int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
ldlm_type_t type, __u8 with_policy, ldlm_mode_t mode,
__u64 *flags, void *lvb, __u32 lvb_len,
struct lustre_handle *lockh, int rc);
-int ldlm_cli_enqueue_local(struct ldlm_namespace *ns,
- const struct ldlm_res_id *res_id,
- ldlm_type_t type, ldlm_policy_data_t *policy,
- ldlm_mode_t mode, __u64 *flags,
- ldlm_blocking_callback blocking,
- ldlm_completion_callback completion,
- ldlm_glimpse_callback glimpse,
- void *data, __u32 lvb_len, enum lvb_type lvb_type,
- const __u64 *client_cookie,
- struct lustre_handle *lockh);
-int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new,
- void *data, __u32 data_len);
-int ldlm_cli_convert(struct lustre_handle *, int new_mode, __u32 *flags);
int ldlm_cli_update_pool(struct ptlrpc_request *req);
int ldlm_cli_cancel(struct lustre_handle *lockh,
ldlm_cancel_flags_t cancel_flags);
@@ -1383,8 +1260,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
ldlm_mode_t mode,
ldlm_cancel_flags_t flags,
void *opaque);
-int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *head,
- int count, ldlm_cancel_flags_t flags);
int ldlm_cancel_resource_local(struct ldlm_resource *res,
struct list_head *cancels,
ldlm_policy_data_t *policy,
@@ -1401,7 +1276,6 @@ int ldlm_cli_cancel_list(struct list_head *head, int count,
int intent_disposition(struct ldlm_reply *rep, int flag);
void intent_set_disposition(struct ldlm_reply *rep, int flag);
-
/* ioctls for trying requests */
#define IOC_LDLM_TYPE 'f'
#define IOC_LDLM_MIN_NR 40
@@ -1454,24 +1328,12 @@ void unlock_res_and_lock(struct ldlm_lock *lock);
* There are not used outside of ldlm.
* @{
*/
-int ldlm_pools_recalc(ldlm_side_t client);
int ldlm_pools_init(void);
void ldlm_pools_fini(void);
int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
int idx, ldlm_side_t client);
-int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
- gfp_t gfp_mask);
void ldlm_pool_fini(struct ldlm_pool *pl);
-int ldlm_pool_setup(struct ldlm_pool *pl, int limit);
-int ldlm_pool_recalc(struct ldlm_pool *pl);
-__u32 ldlm_pool_get_lvf(struct ldlm_pool *pl);
-__u64 ldlm_pool_get_slv(struct ldlm_pool *pl);
-__u64 ldlm_pool_get_clv(struct ldlm_pool *pl);
-__u32 ldlm_pool_get_limit(struct ldlm_pool *pl);
-void ldlm_pool_set_slv(struct ldlm_pool *pl, __u64 slv);
-void ldlm_pool_set_clv(struct ldlm_pool *pl, __u64 clv);
-void ldlm_pool_set_limit(struct ldlm_pool *pl, __u32 limit);
void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock);
void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock);
/** @} */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/kernel/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
index 16dcdbfae..0d3ed87d3 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
@@ -1,17 +1,10 @@
/* -*- buffer-read-only: t -*- vi: set ro:
*
- * DO NOT EDIT THIS FILE (lustre_dlm_flags.h)
+ * 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.
*
- * It has been AutoGen-ed
- * From the definitions lustre_dlm_flags.def
- * and the template file lustre_dlm_flags.tpl
- *
- * lustre is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * lustre is distributed in the hope that it will be useful, but
+ * 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.
@@ -22,8 +15,6 @@
/**
* \file lustre_dlm_flags.h
* The flags and collections of flags (masks) for \see struct ldlm_lock.
- * This file is derived from flag definitions in lustre_dlm_flags.def.
- * The format is defined in the lustre_dlm_flags.tpl template file.
*
* \addtogroup LDLM Lustre Distributed Lock Manager
* @{
@@ -59,59 +50,59 @@
#define LDLM_FL_ON_WIRE_MASK 0x00000000C08F932FULL
/** extent, mode, or resource changed */
-#define LDLM_FL_LOCK_CHANGED 0x0000000000000001ULL // bit 0
-#define ldlm_is_lock_changed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 0)
-#define ldlm_set_lock_changed(_l) LDLM_SET_FLAG(( _l), 1ULL << 0)
+#define LDLM_FL_LOCK_CHANGED 0x0000000000000001ULL /* bit 0 */
+#define ldlm_is_lock_changed(_l) LDLM_TEST_FLAG((_l), 1ULL << 0)
+#define ldlm_set_lock_changed(_l) LDLM_SET_FLAG((_l), 1ULL << 0)
#define ldlm_clear_lock_changed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 0)
/**
* Server placed lock on granted list, or a recovering client wants the
* lock added to the granted list, no questions asked. */
-#define LDLM_FL_BLOCK_GRANTED 0x0000000000000002ULL // bit 1
-#define ldlm_is_block_granted(_l) LDLM_TEST_FLAG(( _l), 1ULL << 1)
-#define ldlm_set_block_granted(_l) LDLM_SET_FLAG(( _l), 1ULL << 1)
+#define LDLM_FL_BLOCK_GRANTED 0x0000000000000002ULL /* bit 1 */
+#define ldlm_is_block_granted(_l) LDLM_TEST_FLAG((_l), 1ULL << 1)
+#define ldlm_set_block_granted(_l) LDLM_SET_FLAG((_l), 1ULL << 1)
#define ldlm_clear_block_granted(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 1)
/**
* Server placed lock on conv list, or a recovering client wants the lock
* added to the conv list, no questions asked. */
-#define LDLM_FL_BLOCK_CONV 0x0000000000000004ULL // bit 2
-#define ldlm_is_block_conv(_l) LDLM_TEST_FLAG(( _l), 1ULL << 2)
-#define ldlm_set_block_conv(_l) LDLM_SET_FLAG(( _l), 1ULL << 2)
+#define LDLM_FL_BLOCK_CONV 0x0000000000000004ULL /* bit 2 */
+#define ldlm_is_block_conv(_l) LDLM_TEST_FLAG((_l), 1ULL << 2)
+#define ldlm_set_block_conv(_l) LDLM_SET_FLAG((_l), 1ULL << 2)
#define ldlm_clear_block_conv(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 2)
/**
* Server placed lock on wait list, or a recovering client wants the lock
* added to the wait list, no questions asked. */
-#define LDLM_FL_BLOCK_WAIT 0x0000000000000008ULL // bit 3
-#define ldlm_is_block_wait(_l) LDLM_TEST_FLAG(( _l), 1ULL << 3)
-#define ldlm_set_block_wait(_l) LDLM_SET_FLAG(( _l), 1ULL << 3)
+#define LDLM_FL_BLOCK_WAIT 0x0000000000000008ULL /* bit 3 */
+#define ldlm_is_block_wait(_l) LDLM_TEST_FLAG((_l), 1ULL << 3)
+#define ldlm_set_block_wait(_l) LDLM_SET_FLAG((_l), 1ULL << 3)
#define ldlm_clear_block_wait(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 3)
/** blocking or cancel packet was queued for sending. */
-#define LDLM_FL_AST_SENT 0x0000000000000020ULL // bit 5
-#define ldlm_is_ast_sent(_l) LDLM_TEST_FLAG(( _l), 1ULL << 5)
-#define ldlm_set_ast_sent(_l) LDLM_SET_FLAG(( _l), 1ULL << 5)
+#define LDLM_FL_AST_SENT 0x0000000000000020ULL /* bit 5 */
+#define ldlm_is_ast_sent(_l) LDLM_TEST_FLAG((_l), 1ULL << 5)
+#define ldlm_set_ast_sent(_l) LDLM_SET_FLAG((_l), 1ULL << 5)
#define ldlm_clear_ast_sent(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 5)
/**
* Lock is being replayed. This could probably be implied by the fact that
* one of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */
-#define LDLM_FL_REPLAY 0x0000000000000100ULL // bit 8
-#define ldlm_is_replay(_l) LDLM_TEST_FLAG(( _l), 1ULL << 8)
-#define ldlm_set_replay(_l) LDLM_SET_FLAG(( _l), 1ULL << 8)
+#define LDLM_FL_REPLAY 0x0000000000000100ULL /* bit 8 */
+#define ldlm_is_replay(_l) LDLM_TEST_FLAG((_l), 1ULL << 8)
+#define ldlm_set_replay(_l) LDLM_SET_FLAG((_l), 1ULL << 8)
#define ldlm_clear_replay(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 8)
/** Don't grant lock, just do intent. */
-#define LDLM_FL_INTENT_ONLY 0x0000000000000200ULL // bit 9
-#define ldlm_is_intent_only(_l) LDLM_TEST_FLAG(( _l), 1ULL << 9)
-#define ldlm_set_intent_only(_l) LDLM_SET_FLAG(( _l), 1ULL << 9)
+#define LDLM_FL_INTENT_ONLY 0x0000000000000200ULL /* bit 9 */
+#define ldlm_is_intent_only(_l) LDLM_TEST_FLAG((_l), 1ULL << 9)
+#define ldlm_set_intent_only(_l) LDLM_SET_FLAG((_l), 1ULL << 9)
#define ldlm_clear_intent_only(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 9)
/** lock request has intent */
-#define LDLM_FL_HAS_INTENT 0x0000000000001000ULL // bit 12
-#define ldlm_is_has_intent(_l) LDLM_TEST_FLAG(( _l), 1ULL << 12)
-#define ldlm_set_has_intent(_l) LDLM_SET_FLAG(( _l), 1ULL << 12)
+#define LDLM_FL_HAS_INTENT 0x0000000000001000ULL /* bit 12 */
+#define ldlm_is_has_intent(_l) LDLM_TEST_FLAG((_l), 1ULL << 12)
+#define ldlm_set_has_intent(_l) LDLM_SET_FLAG((_l), 1ULL << 12)
#define ldlm_clear_has_intent(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 12)
/** flock deadlock detected */
@@ -121,29 +112,29 @@
#define ldlm_clear_flock_deadlock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 15)
/** discard (no writeback) on cancel */
-#define LDLM_FL_DISCARD_DATA 0x0000000000010000ULL // bit 16
-#define ldlm_is_discard_data(_l) LDLM_TEST_FLAG(( _l), 1ULL << 16)
-#define ldlm_set_discard_data(_l) LDLM_SET_FLAG(( _l), 1ULL << 16)
+#define LDLM_FL_DISCARD_DATA 0x0000000000010000ULL /* bit 16 */
+#define ldlm_is_discard_data(_l) LDLM_TEST_FLAG((_l), 1ULL << 16)
+#define ldlm_set_discard_data(_l) LDLM_SET_FLAG((_l), 1ULL << 16)
#define ldlm_clear_discard_data(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 16)
/** Blocked by group lock - wait indefinitely */
-#define LDLM_FL_NO_TIMEOUT 0x0000000000020000ULL // bit 17
-#define ldlm_is_no_timeout(_l) LDLM_TEST_FLAG(( _l), 1ULL << 17)
-#define ldlm_set_no_timeout(_l) LDLM_SET_FLAG(( _l), 1ULL << 17)
+#define LDLM_FL_NO_TIMEOUT 0x0000000000020000ULL /* bit 17 */
+#define ldlm_is_no_timeout(_l) LDLM_TEST_FLAG((_l), 1ULL << 17)
+#define ldlm_set_no_timeout(_l) LDLM_SET_FLAG((_l), 1ULL << 17)
#define ldlm_clear_no_timeout(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 17)
/**
* Server told not to wait if blocked. For AGL, OST will not send glimpse
* callback. */
-#define LDLM_FL_BLOCK_NOWAIT 0x0000000000040000ULL // bit 18
-#define ldlm_is_block_nowait(_l) LDLM_TEST_FLAG(( _l), 1ULL << 18)
-#define ldlm_set_block_nowait(_l) LDLM_SET_FLAG(( _l), 1ULL << 18)
+#define LDLM_FL_BLOCK_NOWAIT 0x0000000000040000ULL /* bit 18 */
+#define ldlm_is_block_nowait(_l) LDLM_TEST_FLAG((_l), 1ULL << 18)
+#define ldlm_set_block_nowait(_l) LDLM_SET_FLAG((_l), 1ULL << 18)
#define ldlm_clear_block_nowait(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 18)
/** return blocking lock */
-#define LDLM_FL_TEST_LOCK 0x0000000000080000ULL // bit 19
-#define ldlm_is_test_lock(_l) LDLM_TEST_FLAG(( _l), 1ULL << 19)
-#define ldlm_set_test_lock(_l) LDLM_SET_FLAG(( _l), 1ULL << 19)
+#define LDLM_FL_TEST_LOCK 0x0000000000080000ULL /* bit 19 */
+#define ldlm_is_test_lock(_l) LDLM_TEST_FLAG((_l), 1ULL << 19)
+#define ldlm_set_test_lock(_l) LDLM_SET_FLAG((_l), 1ULL << 19)
#define ldlm_clear_test_lock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 19)
/**
@@ -151,82 +142,82 @@
* cancel notification to original lock holder, but expect no reply. This
* is for clients (like liblustre) that cannot be expected to reliably
* response to blocking AST. */
-#define LDLM_FL_CANCEL_ON_BLOCK 0x0000000000800000ULL // bit 23
-#define ldlm_is_cancel_on_block(_l) LDLM_TEST_FLAG(( _l), 1ULL << 23)
-#define ldlm_set_cancel_on_block(_l) LDLM_SET_FLAG(( _l), 1ULL << 23)
+#define LDLM_FL_CANCEL_ON_BLOCK 0x0000000000800000ULL /* bit 23 */
+#define ldlm_is_cancel_on_block(_l) LDLM_TEST_FLAG((_l), 1ULL << 23)
+#define ldlm_set_cancel_on_block(_l) LDLM_SET_FLAG((_l), 1ULL << 23)
#define ldlm_clear_cancel_on_block(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 23)
/**
* measure lock contention and return -EUSERS if locking contention is high */
-#define LDLM_FL_DENY_ON_CONTENTION 0x0000000040000000ULL // bit 30
-#define ldlm_is_deny_on_contention(_l) LDLM_TEST_FLAG(( _l), 1ULL << 30)
-#define ldlm_set_deny_on_contention(_l) LDLM_SET_FLAG(( _l), 1ULL << 30)
+#define LDLM_FL_DENY_ON_CONTENTION 0x0000000040000000ULL /* bit 30 */
+#define ldlm_is_deny_on_contention(_l) LDLM_TEST_FLAG((_l), 1ULL << 30)
+#define ldlm_set_deny_on_contention(_l) LDLM_SET_FLAG((_l), 1ULL << 30)
#define ldlm_clear_deny_on_contention(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 30)
/**
* These are flags that are mapped into the flags and ASTs of blocking
* locks Add FL_DISCARD to blocking ASTs */
-#define LDLM_FL_AST_DISCARD_DATA 0x0000000080000000ULL // bit 31
-#define ldlm_is_ast_discard_data(_l) LDLM_TEST_FLAG(( _l), 1ULL << 31)
-#define ldlm_set_ast_discard_data(_l) LDLM_SET_FLAG(( _l), 1ULL << 31)
+#define LDLM_FL_AST_DISCARD_DATA 0x0000000080000000ULL /* bit 31 */
+#define ldlm_is_ast_discard_data(_l) LDLM_TEST_FLAG((_l), 1ULL << 31)
+#define ldlm_set_ast_discard_data(_l) LDLM_SET_FLAG((_l), 1ULL << 31)
#define ldlm_clear_ast_discard_data(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 31)
/**
* Used for marking lock as a target for -EINTR while cp_ast sleep emulation
* + race with upcoming bl_ast. */
-#define LDLM_FL_FAIL_LOC 0x0000000100000000ULL // bit 32
-#define ldlm_is_fail_loc(_l) LDLM_TEST_FLAG(( _l), 1ULL << 32)
-#define ldlm_set_fail_loc(_l) LDLM_SET_FLAG(( _l), 1ULL << 32)
+#define LDLM_FL_FAIL_LOC 0x0000000100000000ULL /* bit 32 */
+#define ldlm_is_fail_loc(_l) LDLM_TEST_FLAG((_l), 1ULL << 32)
+#define ldlm_set_fail_loc(_l) LDLM_SET_FLAG((_l), 1ULL << 32)
#define ldlm_clear_fail_loc(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 32)
/**
* Used while processing the unused list to know that we have already
* handled this lock and decided to skip it. */
-#define LDLM_FL_SKIPPED 0x0000000200000000ULL // bit 33
-#define ldlm_is_skipped(_l) LDLM_TEST_FLAG(( _l), 1ULL << 33)
-#define ldlm_set_skipped(_l) LDLM_SET_FLAG(( _l), 1ULL << 33)
+#define LDLM_FL_SKIPPED 0x0000000200000000ULL /* bit 33 */
+#define ldlm_is_skipped(_l) LDLM_TEST_FLAG((_l), 1ULL << 33)
+#define ldlm_set_skipped(_l) LDLM_SET_FLAG((_l), 1ULL << 33)
#define ldlm_clear_skipped(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 33)
/** this lock is being destroyed */
-#define LDLM_FL_CBPENDING 0x0000000400000000ULL // bit 34
-#define ldlm_is_cbpending(_l) LDLM_TEST_FLAG(( _l), 1ULL << 34)
-#define ldlm_set_cbpending(_l) LDLM_SET_FLAG(( _l), 1ULL << 34)
+#define LDLM_FL_CBPENDING 0x0000000400000000ULL /* bit 34 */
+#define ldlm_is_cbpending(_l) LDLM_TEST_FLAG((_l), 1ULL << 34)
+#define ldlm_set_cbpending(_l) LDLM_SET_FLAG((_l), 1ULL << 34)
#define ldlm_clear_cbpending(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 34)
/** not a real flag, not saved in lock */
-#define LDLM_FL_WAIT_NOREPROC 0x0000000800000000ULL // bit 35
-#define ldlm_is_wait_noreproc(_l) LDLM_TEST_FLAG(( _l), 1ULL << 35)
-#define ldlm_set_wait_noreproc(_l) LDLM_SET_FLAG(( _l), 1ULL << 35)
+#define LDLM_FL_WAIT_NOREPROC 0x0000000800000000ULL /* bit 35 */
+#define ldlm_is_wait_noreproc(_l) LDLM_TEST_FLAG((_l), 1ULL << 35)
+#define ldlm_set_wait_noreproc(_l) LDLM_SET_FLAG((_l), 1ULL << 35)
#define ldlm_clear_wait_noreproc(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 35)
/** cancellation callback already run */
-#define LDLM_FL_CANCEL 0x0000001000000000ULL // bit 36
-#define ldlm_is_cancel(_l) LDLM_TEST_FLAG(( _l), 1ULL << 36)
-#define ldlm_set_cancel(_l) LDLM_SET_FLAG(( _l), 1ULL << 36)
+#define LDLM_FL_CANCEL 0x0000001000000000ULL /* bit 36 */
+#define ldlm_is_cancel(_l) LDLM_TEST_FLAG((_l), 1ULL << 36)
+#define ldlm_set_cancel(_l) LDLM_SET_FLAG((_l), 1ULL << 36)
#define ldlm_clear_cancel(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 36)
/** whatever it might mean */
-#define LDLM_FL_LOCAL_ONLY 0x0000002000000000ULL // bit 37
-#define ldlm_is_local_only(_l) LDLM_TEST_FLAG(( _l), 1ULL << 37)
-#define ldlm_set_local_only(_l) LDLM_SET_FLAG(( _l), 1ULL << 37)
+#define LDLM_FL_LOCAL_ONLY 0x0000002000000000ULL /* bit 37 */
+#define ldlm_is_local_only(_l) LDLM_TEST_FLAG((_l), 1ULL << 37)
+#define ldlm_set_local_only(_l) LDLM_SET_FLAG((_l), 1ULL << 37)
#define ldlm_clear_local_only(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 37)
/** don't run the cancel callback under ldlm_cli_cancel_unused */
-#define LDLM_FL_FAILED 0x0000004000000000ULL // bit 38
-#define ldlm_is_failed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 38)
-#define ldlm_set_failed(_l) LDLM_SET_FLAG(( _l), 1ULL << 38)
+#define LDLM_FL_FAILED 0x0000004000000000ULL /* bit 38 */
+#define ldlm_is_failed(_l) LDLM_TEST_FLAG((_l), 1ULL << 38)
+#define ldlm_set_failed(_l) LDLM_SET_FLAG((_l), 1ULL << 38)
#define ldlm_clear_failed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 38)
/** lock cancel has already been sent */
-#define LDLM_FL_CANCELING 0x0000008000000000ULL // bit 39
-#define ldlm_is_canceling(_l) LDLM_TEST_FLAG(( _l), 1ULL << 39)
-#define ldlm_set_canceling(_l) LDLM_SET_FLAG(( _l), 1ULL << 39)
+#define LDLM_FL_CANCELING 0x0000008000000000ULL /* bit 39 */
+#define ldlm_is_canceling(_l) LDLM_TEST_FLAG((_l), 1ULL << 39)
+#define ldlm_set_canceling(_l) LDLM_SET_FLAG((_l), 1ULL << 39)
#define ldlm_clear_canceling(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 39)
/** local lock (ie, no srv/cli split) */
-#define LDLM_FL_LOCAL 0x0000010000000000ULL // bit 40
-#define ldlm_is_local(_l) LDLM_TEST_FLAG(( _l), 1ULL << 40)
-#define ldlm_set_local(_l) LDLM_SET_FLAG(( _l), 1ULL << 40)
+#define LDLM_FL_LOCAL 0x0000010000000000ULL /* bit 40 */
+#define ldlm_is_local(_l) LDLM_TEST_FLAG((_l), 1ULL << 40)
+#define ldlm_set_local(_l) LDLM_SET_FLAG((_l), 1ULL << 40)
#define ldlm_clear_local(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 40)
/**
@@ -241,9 +232,9 @@
* which can be replaced with a LVB-aware wrapping function for OSC locks.
* That change is pretty high-risk, though, and would need a lot more
* testing. */
-#define LDLM_FL_LVB_READY 0x0000020000000000ULL // bit 41
-#define ldlm_is_lvb_ready(_l) LDLM_TEST_FLAG(( _l), 1ULL << 41)
-#define ldlm_set_lvb_ready(_l) LDLM_SET_FLAG(( _l), 1ULL << 41)
+#define LDLM_FL_LVB_READY 0x0000020000000000ULL /* bit 41 */
+#define ldlm_is_lvb_ready(_l) LDLM_TEST_FLAG((_l), 1ULL << 41)
+#define ldlm_set_lvb_ready(_l) LDLM_SET_FLAG((_l), 1ULL << 41)
#define ldlm_clear_lvb_ready(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 41)
/**
@@ -253,29 +244,29 @@
* Threads racing to update the KMS after performing their writeback need
* to know to exclude each other's locks from the calculation as they walk
* the granted list. */
-#define LDLM_FL_KMS_IGNORE 0x0000040000000000ULL // bit 42
-#define ldlm_is_kms_ignore(_l) LDLM_TEST_FLAG(( _l), 1ULL << 42)
-#define ldlm_set_kms_ignore(_l) LDLM_SET_FLAG(( _l), 1ULL << 42)
+#define LDLM_FL_KMS_IGNORE 0x0000040000000000ULL /* bit 42 */
+#define ldlm_is_kms_ignore(_l) LDLM_TEST_FLAG((_l), 1ULL << 42)
+#define ldlm_set_kms_ignore(_l) LDLM_SET_FLAG((_l), 1ULL << 42)
#define ldlm_clear_kms_ignore(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 42)
/** completion AST to be executed */
-#define LDLM_FL_CP_REQD 0x0000080000000000ULL // bit 43
-#define ldlm_is_cp_reqd(_l) LDLM_TEST_FLAG(( _l), 1ULL << 43)
-#define ldlm_set_cp_reqd(_l) LDLM_SET_FLAG(( _l), 1ULL << 43)
+#define LDLM_FL_CP_REQD 0x0000080000000000ULL /* bit 43 */
+#define ldlm_is_cp_reqd(_l) LDLM_TEST_FLAG((_l), 1ULL << 43)
+#define ldlm_set_cp_reqd(_l) LDLM_SET_FLAG((_l), 1ULL << 43)
#define ldlm_clear_cp_reqd(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 43)
/** cleanup_resource has already handled the lock */
-#define LDLM_FL_CLEANED 0x0000100000000000ULL // bit 44
-#define ldlm_is_cleaned(_l) LDLM_TEST_FLAG(( _l), 1ULL << 44)
-#define ldlm_set_cleaned(_l) LDLM_SET_FLAG(( _l), 1ULL << 44)
+#define LDLM_FL_CLEANED 0x0000100000000000ULL /* bit 44 */
+#define ldlm_is_cleaned(_l) LDLM_TEST_FLAG((_l), 1ULL << 44)
+#define ldlm_set_cleaned(_l) LDLM_SET_FLAG((_l), 1ULL << 44)
#define ldlm_clear_cleaned(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 44)
/**
* optimization hint: LDLM can run blocking callback from current context
* w/o involving separate thread. in order to decrease cs rate */
-#define LDLM_FL_ATOMIC_CB 0x0000200000000000ULL // bit 45
-#define ldlm_is_atomic_cb(_l) LDLM_TEST_FLAG(( _l), 1ULL << 45)
-#define ldlm_set_atomic_cb(_l) LDLM_SET_FLAG(( _l), 1ULL << 45)
+#define LDLM_FL_ATOMIC_CB 0x0000200000000000ULL /* bit 45 */
+#define ldlm_is_atomic_cb(_l) LDLM_TEST_FLAG((_l), 1ULL << 45)
+#define ldlm_set_atomic_cb(_l) LDLM_SET_FLAG((_l), 1ULL << 45)
#define ldlm_clear_atomic_cb(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 45)
/**
@@ -290,33 +281,33 @@
* dropped to let ldlm_callback_handler() return EINVAL to the server. It
* is used when ELC RPC is already prepared and is waiting for rpc_lock,
* too late to send a separate CANCEL RPC. */
-#define LDLM_FL_BL_AST 0x0000400000000000ULL // bit 46
-#define ldlm_is_bl_ast(_l) LDLM_TEST_FLAG(( _l), 1ULL << 46)
-#define ldlm_set_bl_ast(_l) LDLM_SET_FLAG(( _l), 1ULL << 46)
+#define LDLM_FL_BL_AST 0x0000400000000000ULL /* bit 46 */
+#define ldlm_is_bl_ast(_l) LDLM_TEST_FLAG((_l), 1ULL << 46)
+#define ldlm_set_bl_ast(_l) LDLM_SET_FLAG((_l), 1ULL << 46)
#define ldlm_clear_bl_ast(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 46)
/** whatever it might mean */
-#define LDLM_FL_BL_DONE 0x0000800000000000ULL // bit 47
-#define ldlm_is_bl_done(_l) LDLM_TEST_FLAG(( _l), 1ULL << 47)
-#define ldlm_set_bl_done(_l) LDLM_SET_FLAG(( _l), 1ULL << 47)
+#define LDLM_FL_BL_DONE 0x0000800000000000ULL /* bit 47 */
+#define ldlm_is_bl_done(_l) LDLM_TEST_FLAG((_l), 1ULL << 47)
+#define ldlm_set_bl_done(_l) LDLM_SET_FLAG((_l), 1ULL << 47)
#define ldlm_clear_bl_done(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 47)
/**
* Don't put lock into the LRU list, so that it is not canceled due
* to aging. Used by MGC locks, they are cancelled only at unmount or
* by callback. */
-#define LDLM_FL_NO_LRU 0x0001000000000000ULL // bit 48
-#define ldlm_is_no_lru(_l) LDLM_TEST_FLAG(( _l), 1ULL << 48)
-#define ldlm_set_no_lru(_l) LDLM_SET_FLAG(( _l), 1ULL << 48)
+#define LDLM_FL_NO_LRU 0x0001000000000000ULL /* bit 48 */
+#define ldlm_is_no_lru(_l) LDLM_TEST_FLAG((_l), 1ULL << 48)
+#define ldlm_set_no_lru(_l) LDLM_SET_FLAG((_l), 1ULL << 48)
#define ldlm_clear_no_lru(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 48)
/**
* Set for locks that failed and where the server has been notified.
*
* Protected by lock and resource locks. */
-#define LDLM_FL_FAIL_NOTIFIED 0x0002000000000000ULL // bit 49
-#define ldlm_is_fail_notified(_l) LDLM_TEST_FLAG(( _l), 1ULL << 49)
-#define ldlm_set_fail_notified(_l) LDLM_SET_FLAG(( _l), 1ULL << 49)
+#define LDLM_FL_FAIL_NOTIFIED 0x0002000000000000ULL /* bit 49 */
+#define ldlm_is_fail_notified(_l) LDLM_TEST_FLAG((_l), 1ULL << 49)
+#define ldlm_set_fail_notified(_l) LDLM_SET_FLAG((_l), 1ULL << 49)
#define ldlm_clear_fail_notified(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 49)
/**
@@ -325,15 +316,15 @@
* ldlm_lock_destroy_internal().
*
* Protected by lock and resource locks. */
-#define LDLM_FL_DESTROYED 0x0004000000000000ULL // bit 50
-#define ldlm_is_destroyed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 50)
-#define ldlm_set_destroyed(_l) LDLM_SET_FLAG(( _l), 1ULL << 50)
+#define LDLM_FL_DESTROYED 0x0004000000000000ULL /* bit 50 */
+#define ldlm_is_destroyed(_l) LDLM_TEST_FLAG((_l), 1ULL << 50)
+#define ldlm_set_destroyed(_l) LDLM_SET_FLAG((_l), 1ULL << 50)
#define ldlm_clear_destroyed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 50)
/** flag whether this is a server namespace lock */
-#define LDLM_FL_SERVER_LOCK 0x0008000000000000ULL // bit 51
-#define ldlm_is_server_lock(_l) LDLM_TEST_FLAG(( _l), 1ULL << 51)
-#define ldlm_set_server_lock(_l) LDLM_SET_FLAG(( _l), 1ULL << 51)
+#define LDLM_FL_SERVER_LOCK 0x0008000000000000ULL /* bit 51 */
+#define ldlm_is_server_lock(_l) LDLM_TEST_FLAG((_l), 1ULL << 51)
+#define ldlm_set_server_lock(_l) LDLM_SET_FLAG((_l), 1ULL << 51)
#define ldlm_clear_server_lock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 51)
/**
@@ -343,9 +334,9 @@
* Also, spin_is_locked() is deprecated for kernel code; one reason is
* because it works only for SMP so user needs to add extra macros like
* LASSERT_SPIN_LOCKED for uniprocessor kernels. */
-#define LDLM_FL_RES_LOCKED 0x0010000000000000ULL // bit 52
-#define ldlm_is_res_locked(_l) LDLM_TEST_FLAG(( _l), 1ULL << 52)
-#define ldlm_set_res_locked(_l) LDLM_SET_FLAG(( _l), 1ULL << 52)
+#define LDLM_FL_RES_LOCKED 0x0010000000000000ULL /* bit 52 */
+#define ldlm_is_res_locked(_l) LDLM_TEST_FLAG((_l), 1ULL << 52)
+#define ldlm_set_res_locked(_l) LDLM_SET_FLAG((_l), 1ULL << 52)
#define ldlm_clear_res_locked(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 52)
/**
@@ -353,15 +344,15 @@
* lock-timeout timer and it will never be reset.
*
* Protected by lock and resource locks. */
-#define LDLM_FL_WAITED 0x0020000000000000ULL // bit 53
-#define ldlm_is_waited(_l) LDLM_TEST_FLAG(( _l), 1ULL << 53)
-#define ldlm_set_waited(_l) LDLM_SET_FLAG(( _l), 1ULL << 53)
+#define LDLM_FL_WAITED 0x0020000000000000ULL /* bit 53 */
+#define ldlm_is_waited(_l) LDLM_TEST_FLAG((_l), 1ULL << 53)
+#define ldlm_set_waited(_l) LDLM_SET_FLAG((_l), 1ULL << 53)
#define ldlm_clear_waited(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 53)
/** Flag whether this is a server namespace lock. */
-#define LDLM_FL_NS_SRV 0x0040000000000000ULL // bit 54
-#define ldlm_is_ns_srv(_l) LDLM_TEST_FLAG(( _l), 1ULL << 54)
-#define ldlm_set_ns_srv(_l) LDLM_SET_FLAG(( _l), 1ULL << 54)
+#define LDLM_FL_NS_SRV 0x0040000000000000ULL /* bit 54 */
+#define ldlm_is_ns_srv(_l) LDLM_TEST_FLAG((_l), 1ULL << 54)
+#define ldlm_set_ns_srv(_l) LDLM_SET_FLAG((_l), 1ULL << 54)
#define ldlm_clear_ns_srv(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 54)
/** Flag whether this lock can be reused. Used by exclusive open. */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_eacl.h b/kernel/drivers/staging/lustre/lustre/include/lustre_eacl.h
index 0f8f76c43..fee4d2c75 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_eacl.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_eacl.h
@@ -70,7 +70,6 @@ typedef struct {
#define CFS_ACL_XATTR_COUNT(size, prefix) \
(((size) - sizeof(prefix ## _header)) / sizeof(prefix ## _entry))
-
extern ext_acl_xattr_header *
lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size);
extern int
@@ -80,10 +79,6 @@ extern void
lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size);
extern void
lustre_ext_acl_xattr_free(ext_acl_xattr_header *header);
-extern int
-lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
- ext_acl_xattr_header *ext_header,
- posix_acl_xattr_header **out);
extern ext_acl_xattr_header *
lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
ext_acl_xattr_header *ext_header);
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_export.h b/kernel/drivers/staging/lustre/lustre/include/lustre_export.h
index 9c06a49f1..1daf4c572 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -106,34 +106,6 @@ struct mgs_export_data {
spinlock_t med_lock; /* protect med_clients */
};
-/**
- * per-NID statistics structure.
- * It tracks access patterns to this export on a per-client-NID basis
- */
-struct nid_stat {
- lnet_nid_t nid;
- struct hlist_node nid_hash;
- struct list_head nid_list;
- struct obd_device *nid_obd;
- struct proc_dir_entry *nid_proc;
- struct lprocfs_stats *nid_stats;
- struct lprocfs_stats *nid_ldlm_stats;
- atomic_t nid_exp_ref_count; /* for obd_nid_stats_hash
- exp_nid_stats */
-};
-
-#define nidstat_getref(nidstat) \
-do { \
- atomic_inc(&(nidstat)->nid_exp_ref_count); \
-} while (0)
-
-#define nidstat_putref(nidstat) \
-do { \
- atomic_dec(&(nidstat)->nid_exp_ref_count); \
- LASSERTF(atomic_read(&(nidstat)->nid_exp_ref_count) >= 0, \
- "stat %p nid_exp_ref_count < 0\n", nidstat); \
-} while (0)
-
enum obd_option {
OBD_OPT_FORCE = 0x0001,
OBD_OPT_FAILOVER = 0x0002,
@@ -175,14 +147,6 @@ struct obd_export {
/** To link all exports on an obd device */
struct list_head exp_obd_chain;
struct hlist_node exp_uuid_hash; /** uuid-export hash*/
- struct hlist_node exp_nid_hash; /** nid-export hash */
- /**
- * All exports eligible for ping evictor are linked into a list
- * through this field in "most time since last request on this export"
- * order
- * protected by obd_dev_lock
- */
- struct list_head exp_obd_chain_timed;
/** Obd device of this export */
struct obd_device *exp_obd;
/**
@@ -190,7 +154,6 @@ struct obd_export {
* exp_lock protect its change
*/
struct obd_import *exp_imp_reverse;
- struct nid_stat *exp_nid_stats;
struct lprocfs_stats *exp_md_stats;
/** Active connection */
struct ptlrpc_connection *exp_connection;
@@ -208,8 +171,6 @@ struct obd_export {
spinlock_t exp_uncommitted_replies_lock;
/** Last committed transno for this export */
__u64 exp_last_committed;
- /** When was last request received */
- unsigned long exp_last_request_time;
/** On replay all requests waiting for replay are linked here */
struct list_head exp_req_replay_queue;
/**
@@ -222,30 +183,15 @@ struct obd_export {
struct obd_connect_data exp_connect_data;
enum obd_option exp_flags;
unsigned long exp_failed:1,
- exp_in_recovery:1,
exp_disconnected:1,
exp_connecting:1,
- /** VBR: export missed recovery */
- exp_delayed:1,
- /** VBR: failed version checking */
- exp_vbr_failed:1,
- exp_req_replay_needed:1,
- exp_lock_replay_needed:1,
- exp_need_sync:1,
exp_flvr_changed:1,
- exp_flvr_adapt:1,
- exp_libclient:1, /* liblustre client? */
- /* client timed out and tried to reconnect,
- * but couldn't because of active rpcs */
- exp_abort_active_req:1,
- /* if to swap nidtbl entries for 2.2 clients.
- * Only used by the MGS to fix LU-1644. */
- exp_need_mne_swab:1;
+ exp_flvr_adapt:1;
/* also protected by exp_lock */
enum lustre_sec_part exp_sp_peer;
struct sptlrpc_flavor exp_flvr; /* current */
struct sptlrpc_flavor exp_flvr_old[2]; /* about-to-expire */
- unsigned long exp_flvr_expire[2]; /* seconds */
+ time64_t exp_flvr_expire[2]; /* seconds */
/** protects exp_hp_rpcs */
spinlock_t exp_rpc_lock;
@@ -294,13 +240,6 @@ static inline int exp_connect_multibulk(struct obd_export *exp)
return exp_max_brw_size(exp) > ONE_MB_BRW_SIZE;
}
-static inline int exp_expired(struct obd_export *exp, long age)
-{
- LASSERT(exp->exp_delayed);
- return time_before(cfs_time_add(exp->exp_last_request_time, age),
- get_seconds());
-}
-
static inline int exp_connect_cancelset(struct obd_export *exp)
{
LASSERT(exp != NULL);
@@ -397,8 +336,7 @@ static inline bool imp_connect_disp_stripe(struct obd_import *imp)
return ocd->ocd_connect_flags & OBD_CONNECT_DISP_STRIPE;
}
-extern struct obd_export *class_conn2export(struct lustre_handle *conn);
-extern struct obd_device *class_conn2obd(struct lustre_handle *conn);
+struct obd_export *class_conn2export(struct lustre_handle *conn);
/** @} export */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_fid.h b/kernel/drivers/staging/lustre/lustre/include/lustre_fid.h
index 0a0929fd9..47c3f3750 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_fid.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_fid.h
@@ -330,8 +330,6 @@ enum lu_mgr_type {
LUSTRE_SEQ_CONTROLLER
};
-struct lu_server_seq;
-
/* Client sequence manager interface. */
struct lu_client_seq {
/* Sequence-controller export. */
@@ -346,7 +344,7 @@ struct lu_client_seq {
struct lu_seq_range lcs_space;
/* Seq related proc */
- struct proc_dir_entry *lcs_proc_dir;
+ struct dentry *lcs_debugfs_entry;
/* This holds last allocated fid in last obtained seq */
struct lu_fid lcs_fid;
@@ -366,111 +364,16 @@ struct lu_client_seq {
*/
__u64 lcs_width;
- /* Seq-server for direct talking */
- struct lu_server_seq *lcs_srv;
-
/* wait queue for fid allocation and update indicator */
wait_queue_head_t lcs_waitq;
int lcs_update;
};
-/* server sequence manager interface */
-struct lu_server_seq {
- /* Available sequences space */
- struct lu_seq_range lss_space;
-
- /* keeps highwater in lsr_end for seq allocation algorithm */
- struct lu_seq_range lss_lowater_set;
- struct lu_seq_range lss_hiwater_set;
-
- /*
- * Device for server side seq manager needs (saving sequences to backing
- * store).
- */
- struct dt_device *lss_dev;
-
- /* /seq file object device */
- struct dt_object *lss_obj;
-
- /* Seq related proc */
- struct proc_dir_entry *lss_proc_dir;
-
- /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */
- enum lu_mgr_type lss_type;
-
- /* Client interface to request controller */
- struct lu_client_seq *lss_cli;
-
- /* Mutex for protecting allocation */
- struct mutex lss_mutex;
-
- /*
- * Service uuid, passed from MDT + seq name to form unique seq name to
- * use it with procfs.
- */
- char lss_name[LUSTRE_MDT_MAXNAMELEN];
-
- /*
- * Allocation chunks for super and meta sequences. Default values are
- * LUSTRE_SEQ_SUPER_WIDTH and LUSTRE_SEQ_META_WIDTH.
- */
- __u64 lss_width;
-
- /*
- * minimum lss_alloc_set size that should be allocated from
- * lss_space
- */
- __u64 lss_set_width;
-
- /* sync is needed for update operation */
- __u32 lss_need_sync;
-
- /**
- * Pointer to site object, required to access site fld.
- */
- struct seq_server_site *lss_site;
-};
-
-/* Server methods */
-
-int seq_server_init(struct lu_server_seq *seq,
- struct dt_device *dev,
- const char *prefix,
- enum lu_mgr_type type,
- struct seq_server_site *ss,
- const struct lu_env *env);
-
-void seq_server_fini(struct lu_server_seq *seq,
- const struct lu_env *env);
-
-int seq_server_alloc_super(struct lu_server_seq *seq,
- struct lu_seq_range *out,
- const struct lu_env *env);
-
-int seq_server_alloc_meta(struct lu_server_seq *seq,
- struct lu_seq_range *out,
- const struct lu_env *env);
-
-int seq_server_set_cli(struct lu_server_seq *seq,
- struct lu_client_seq *cli,
- const struct lu_env *env);
-
/* Client methods */
-int seq_client_init(struct lu_client_seq *seq,
- struct obd_export *exp,
- enum lu_cli_type type,
- const char *prefix,
- struct lu_server_seq *srv);
-
-void seq_client_fini(struct lu_client_seq *seq);
-
void seq_client_flush(struct lu_client_seq *seq);
int seq_client_alloc_fid(const struct lu_env *env, struct lu_client_seq *seq,
struct lu_fid *fid);
-int seq_client_get_seq(const struct lu_env *env, struct lu_client_seq *seq,
- u64 *seqnr);
-int seq_site_fini(const struct lu_env *env, struct seq_server_site *ss);
/* Fids common stuff */
int fid_is_local(const struct lu_env *env,
struct lu_site *site, const struct lu_fid *fid);
@@ -629,6 +532,7 @@ static inline void ost_fid_build_resid(const struct lu_fid *fid,
{
if (fid_is_mdt0(fid) || fid_is_idif(fid)) {
struct ost_id oi;
+
oi.oi.oi_id = 0; /* gcc 4.7.2 complains otherwise */
if (fid_to_ostid(fid, &oi) != 0)
return;
@@ -644,6 +548,7 @@ static inline void ost_fid_from_resid(struct lu_fid *fid,
if (fid_seq_is_mdt0(name->name[LUSTRE_RES_ID_VER_OID_OFF])) {
/* old resid */
struct ost_id oi;
+
ostid_set_seq(&oi, name->name[LUSTRE_RES_ID_VER_OID_OFF]);
ostid_set_id(&oi, name->name[LUSTRE_RES_ID_SEQ_OFF]);
ostid_to_fid(fid, &oi, 0);
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_fld.h b/kernel/drivers/staging/lustre/lustre/include/lustre_fld.h
index 5ee4b1ed0..d8b3db9cd 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_fld.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_fld.h
@@ -61,7 +61,6 @@ enum {
LUSTRE_CLI_FLD_HASH_RRB
};
-
struct lu_fld_target {
struct list_head ft_chain;
struct obd_export *ft_exp;
@@ -71,14 +70,6 @@ struct lu_fld_target {
struct lu_server_fld {
/**
- * Fld dir proc entry. */
- struct proc_dir_entry *lsf_proc_dir;
-
- /**
- * /fld file object device */
- struct dt_object *lsf_obj;
-
- /**
* super sequence controller export, needed to forward fld
* lookup request. */
struct obd_export *lsf_control_exp;
@@ -99,8 +90,8 @@ struct lu_server_fld {
struct lu_client_fld {
/**
- * Client side proc entry. */
- struct proc_dir_entry *lcf_proc_dir;
+ * Client side debugfs entry. */
+ struct dentry *lcf_debugfs_entry;
/**
* List of exports client FLD knows about. */
@@ -123,10 +114,10 @@ struct lu_client_fld {
struct fld_cache *lcf_cache;
/**
- * Client fld proc entry name. */
- char lcf_name[LUSTRE_MDT_MAXNAMELEN];
+ * Client fld debugfs entry name. */
+ char lcf_name[LUSTRE_MDT_MAXNAMELEN];
- int lcf_flags;
+ int lcf_flags;
};
/* Client methods */
@@ -153,7 +144,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
int fld_client_del_target(struct lu_client_fld *fld,
__u64 idx);
-void fld_client_proc_fini(struct lu_client_fld *fld);
+void fld_client_debugfs_fini(struct lu_client_fld *fld);
/** @} fld */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_ha.h b/kernel/drivers/staging/lustre/lustre/include/lustre_ha.h
index f3ae02b3e..49dfbb14f 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_ha.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_ha.h
@@ -47,7 +47,6 @@ struct obd_export;
struct obd_device;
struct ptlrpc_request;
-
int ptlrpc_replay(struct obd_import *imp);
int ptlrpc_resend(struct obd_import *imp);
void ptlrpc_free_committed(struct obd_import *imp);
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_handles.h b/kernel/drivers/staging/lustre/lustre/include/lustre_handles.h
index 726bbd3ea..f39780ae4 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -50,7 +50,6 @@
#include "../../include/linux/libcfs/libcfs.h"
-
struct portals_handle_ops {
void (*hop_addref)(void *object);
void (*hop_free)(void *object, int size);
@@ -78,6 +77,7 @@ struct portals_handle {
unsigned int h_size:31;
unsigned int h_in:1;
};
+
#define RCU2HANDLE(rcu) container_of(rcu, struct portals_handle, h_rcu)
/* handles.c */
@@ -86,7 +86,6 @@ struct portals_handle {
void class_handle_hash(struct portals_handle *,
struct portals_handle_ops *ops);
void class_handle_unhash(struct portals_handle *);
-void class_handle_hash_back(struct portals_handle *);
void *class_handle2object(__u64 cookie);
void class_handle_free_cb(struct rcu_head *rcu);
int class_handle_init(void);
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_import.h b/kernel/drivers/staging/lustre/lustre/include/lustre_import.h
index dcc807676..4e4230e94 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -50,7 +50,6 @@
#include "lustre_handles.h"
#include "lustre/lustre_idl.h"
-
/**
* Adaptive Timeout stuff
*
@@ -61,12 +60,12 @@
#define AT_FLG_NOHIST 0x1 /* use last reported value only */
struct adaptive_timeout {
- time_t at_binstart; /* bin start time */
+ time64_t at_binstart; /* bin start time */
unsigned int at_hist[AT_BINS]; /* timeout history bins */
unsigned int at_flags;
unsigned int at_current; /* current timeout value */
unsigned int at_worst_ever; /* worst-ever timeout value */
- time_t at_worst_time; /* worst-ever timeout timestamp */
+ time64_t at_worst_time; /* worst-ever timeout timestamp */
spinlock_t at_lock;
};
@@ -74,7 +73,7 @@ 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 */
- time_t paa_deadline; /** the earliest deadline of reqs */
+ time64_t paa_deadline; /** the earliest deadline of reqs */
__u32 *paa_reqs_count; /** the count of reqs in each entry */
};
@@ -85,7 +84,6 @@ struct imp_at {
struct adaptive_timeout iat_service_estimate[IMP_AT_MAX_PORTALS];
};
-
/** @} */
/** Possible import states */
@@ -148,7 +146,7 @@ struct obd_import_conn {
#define IMP_STATE_HIST_LEN 16
struct import_state_hist {
enum lustre_imp_state ish_state;
- time_t ish_time;
+ time64_t ish_time;
};
/**
@@ -200,7 +198,7 @@ struct obd_import {
*/
struct ptlrpc_sec *imp_sec;
struct mutex imp_sec_mutex;
- unsigned long imp_sec_expire;
+ time64_t imp_sec_expire;
/** @} */
/** Wait queue for those who need to wait for recovery completion */
@@ -306,10 +304,8 @@ struct obd_import {
__u32 imp_msg_magic;
__u32 imp_msghdr_flags; /* adjusted based on server capability */
- struct ptlrpc_request_pool *imp_rq_pool; /* emergency request pool */
-
struct imp_at imp_at; /* adaptive timeout data */
- time_t imp_last_reply_time; /* for health check */
+ time64_t imp_last_reply_time; /* for health check */
};
typedef void (*obd_import_callback)(struct obd_import *imp, void *closure,
@@ -353,9 +349,10 @@ static inline void at_reset(struct adaptive_timeout *at, int val)
spin_lock(&at->at_lock);
at->at_current = val;
at->at_worst_ever = val;
- at->at_worst_time = get_seconds();
+ at->at_worst_time = ktime_get_real_seconds();
spin_unlock(&at->at_lock);
}
+
static inline void at_init(struct adaptive_timeout *at, int val, int flags)
{
memset(at, 0, sizeof(*at));
@@ -363,11 +360,13 @@ static inline void at_init(struct adaptive_timeout *at, int val, int flags)
at->at_flags = flags;
at_reset(at, val);
}
+
extern unsigned int at_min;
static inline int at_get(struct adaptive_timeout *at)
{
return (at->at_current > at_min) ? at->at_current : at_min;
}
+
int at_measured(struct adaptive_timeout *at, unsigned int val);
int import_at_get_index(struct obd_import *imp, int portal);
extern unsigned int at_max;
@@ -375,8 +374,7 @@ extern unsigned int at_max;
/* genops.c */
struct obd_export;
-extern struct obd_import *class_exp2cliimp(struct obd_export *);
-extern struct obd_import *class_conn2cliimp(struct lustre_handle *);
+struct obd_import *class_exp2cliimp(struct obd_export *);
/** @} import */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_lib.h b/kernel/drivers/staging/lustre/lustre/include/lustre_lib.h
index bf135630c..428469fec 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_lib.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_lib.h
@@ -97,10 +97,10 @@ struct obd_client_handle {
__u32 och_magic;
fmode_t och_flags;
};
+
#define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed
/* statfs_pack.c */
-void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
/*
@@ -178,6 +178,7 @@ struct obd_ioctl_hdr {
static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
{
int len = cfs_size_round(sizeof(struct obd_ioctl_data));
+
len += cfs_size_round(data->ioc_inllen1);
len += cfs_size_round(data->ioc_inllen2);
len += cfs_size_round(data->ioc_inllen3);
@@ -185,7 +186,6 @@ static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
return len;
}
-
static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
{
if (data->ioc_len > OBD_MAX_IOCTL_BUFFER) {
@@ -249,7 +249,6 @@ static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
return 0;
}
-
#include "obd_support.h"
/* function defined in lustre/obdclass/<platform>/<platform>-module.c */
@@ -258,7 +257,7 @@ int obd_ioctl_popdata(void *arg, void *data, int len);
static inline void obd_ioctl_freedata(char *buf, int len)
{
- OBD_FREE_LARGE(buf, len);
+ kvfree(buf);
return;
}
@@ -289,7 +288,6 @@ static inline void obd_ioctl_freedata(char *buf, int len)
#define OBD_IOC_READ _IOWR('f', 109, OBD_IOC_DATA_TYPE)
#define OBD_IOC_WRITE _IOWR('f', 110, OBD_IOC_DATA_TYPE)
-
#define OBD_IOC_STATFS _IOWR('f', 113, OBD_IOC_DATA_TYPE)
#define OBD_IOC_SYNC _IOW ('f', 114, OBD_IOC_DATA_TYPE)
#define OBD_IOC_READ2 _IOWR('f', 115, OBD_IOC_DATA_TYPE)
@@ -313,7 +311,7 @@ static inline void obd_ioctl_freedata(char *buf, int len)
#define OBD_IOC_CLIENT_RECOVER _IOW ('f', 133, OBD_IOC_DATA_TYPE)
#define OBD_IOC_PING_TARGET _IOW ('f', 136, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 139 )
+#define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 139)
#define OBD_IOC_NO_TRANSNO _IOW ('f', 140, OBD_IOC_DATA_TYPE)
#define OBD_IOC_SET_READONLY _IOW ('f', 141, OBD_IOC_DATA_TYPE)
#define OBD_IOC_ABORT_RECOVERY _IOR ('f', 142, OBD_IOC_DATA_TYPE)
@@ -453,7 +451,7 @@ static inline void obd_ioctl_freedata(char *buf, int len)
* __wake_up_common(q, ...); (2.2)
* spin_unlock(&q->lock, flags); (2.3)
*
- * OBD_FREE_PTR(obj); (3)
+ * kfree(obj); (3)
*
* As l_wait_event() may "short-cut" execution and return without taking
* wait-queue spin-lock, some additional synchronization is necessary to
@@ -523,7 +521,6 @@ struct l_wait_info {
sigmask(SIGTERM) | sigmask(SIGQUIT) | \
sigmask(SIGALRM))
-
/*
* wait for @condition to become true, but no longer than timeout, specified
* by @info.
@@ -549,23 +546,17 @@ do { \
__blocked = cfs_block_sigsinv(0); \
\
for (;;) { \
- unsigned __wstate; \
- \
- __wstate = info->lwi_on_signal != NULL && \
- (__timeout == 0 || __allow_intr) ? \
- TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; \
- \
- set_current_state(TASK_INTERRUPTIBLE); \
- \
if (condition) \
break; \
\
+ set_current_state(TASK_INTERRUPTIBLE); \
+ \
if (__timeout == 0) { \
- schedule(); \
+ schedule(); \
} else { \
- long interval = info->lwi_interval? \
+ long interval = info->lwi_interval ? \
min_t(long, \
- info->lwi_interval,__timeout):\
+ info->lwi_interval, __timeout) : \
__timeout; \
long remaining = schedule_timeout(interval);\
__timeout = cfs_time_sub(__timeout, \
@@ -582,6 +573,8 @@ do { \
} \
} \
\
+ set_current_state(TASK_RUNNING); \
+ \
if (condition) \
break; \
if (cfs_signal_pending()) { \
@@ -605,12 +598,9 @@ do { \
\
cfs_restore_sigs(__blocked); \
\
- set_current_state(TASK_RUNNING); \
remove_wait_queue(&wq, &__wait); \
} while (0)
-
-
#define l_wait_event(wq, condition, info) \
({ \
int __ret; \
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_lite.h b/kernel/drivers/staging/lustre/lustre/include/lustre_lite.h
index df557c22a..f6d7aae3a 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_lite.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_lite.h
@@ -55,7 +55,6 @@
#include "lustre/lustre_user.h"
-
struct lustre_rw_params {
int lrp_lock_mode;
ldlm_policy_data_t lrp_policy;
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_log.h b/kernel/drivers/staging/lustre/lustre/include/lustre_log.h
index 2187fb615..1de0c4d6f 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_log.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_log.h
@@ -58,7 +58,6 @@
#include "obd_class.h"
#include "lustre/lustre_idl.h"
-#include "dt_object.h"
#define LOG_NAME_LIMIT(logname, name) \
snprintf(logname, sizeof(logname), "LOGS/%s", name)
@@ -81,60 +80,20 @@ struct cat_handle_data {
struct llog_handle *chd_next_log; /* llog to be used next */
};
-static inline void logid_to_fid(struct llog_logid *id, struct lu_fid *fid)
-{
- /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS)
- * logid's by non-zero ogen (inode generation) and convert them
- * into IGIF */
- if (id->lgl_ogen == 0) {
- fid->f_seq = id->lgl_oi.oi.oi_seq;
- fid->f_oid = id->lgl_oi.oi.oi_id;
- fid->f_ver = 0;
- } else {
- lu_igif_build(fid, id->lgl_oi.oi.oi_id, id->lgl_ogen);
- }
-}
-
-static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id)
-{
- id->lgl_oi.oi.oi_seq = fid->f_seq;
- id->lgl_oi.oi.oi_id = fid->f_oid;
- id->lgl_ogen = 0;
-}
-
-static inline void logid_set_id(struct llog_logid *log_id, __u64 id)
-{
- log_id->lgl_oi.oi.oi_id = id;
-}
-
-static inline __u64 logid_id(struct llog_logid *log_id)
-{
- return log_id->lgl_oi.oi.oi_id;
-}
-
struct llog_handle;
/* llog.c - general API */
int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
int flags, struct obd_uuid *uuid);
-int llog_copy_handler(const struct lu_env *env, struct llog_handle *llh,
- struct llog_rec_hdr *rec, void *data);
int llog_process(const struct lu_env *env, struct llog_handle *loghandle,
llog_cb_t cb, void *data, void *catdata);
int llog_process_or_fork(const struct lu_env *env,
struct llog_handle *loghandle,
llog_cb_t cb, void *data, void *catdata, bool fork);
-int llog_reverse_process(const struct lu_env *env,
- struct llog_handle *loghandle, llog_cb_t cb,
- void *data, void *catdata);
-int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle,
- int index);
int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt,
struct llog_handle **lgh, struct llog_logid *logid,
char *name, enum llog_open_param open_param);
int llog_close(const struct lu_env *env, struct llog_handle *cathandle);
-int llog_is_empty(const struct lu_env *env, struct llog_ctxt *ctxt,
- char *name);
int llog_backup(const struct lu_env *env, struct obd_device *obd,
struct llog_ctxt *ctxt, struct llog_ctxt *bak_ctxt,
char *name, char *backup);
@@ -172,29 +131,11 @@ struct llog_process_cat_data {
int lpcd_last_idx;
};
+struct thandle;
+
int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle);
-int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, struct llog_cookie *reccookie,
- void *buf, struct thandle *th);
-int llog_cat_declare_add_rec(const struct lu_env *env,
- struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, struct thandle *th);
-int llog_cat_add(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, struct llog_cookie *reccookie,
- void *buf);
-int llog_cat_cancel_records(const struct lu_env *env,
- struct llog_handle *cathandle, int count,
- struct llog_cookie *cookies);
-int llog_cat_process_or_fork(const struct lu_env *env,
- struct llog_handle *cat_llh, llog_cb_t cb,
- void *data, int startcat, int startidx, bool fork);
int llog_cat_process(const struct lu_env *env, struct llog_handle *cat_llh,
llog_cb_t cb, void *data, int startcat, int startidx);
-int llog_cat_reverse_process(const struct lu_env *env,
- struct llog_handle *cat_llh, llog_cb_t cb,
- void *data);
-int llog_cat_init_and_process(const struct lu_env *env,
- struct llog_handle *llh);
/* llog_obd.c */
int llog_setup(const struct lu_env *env, struct obd_device *obd,
@@ -202,16 +143,11 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd,
struct obd_device *disk_obd, struct llog_operations *op);
int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt);
int llog_cleanup(const struct lu_env *env, struct llog_ctxt *);
-int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags);
-int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt,
- struct llog_cookie *cookies, int flags);
/* llog_net.c */
int llog_initiator_connect(struct llog_ctxt *ctxt);
struct llog_operations {
- int (*lop_destroy)(const struct lu_env *env,
- struct llog_handle *handle);
int (*lop_next_block)(const struct lu_env *env, struct llog_handle *h,
int *curr_idx, int next_idx, __u64 *offset,
void *buf, int len);
@@ -254,8 +190,6 @@ struct llog_operations {
int (*lop_declare_create)(const struct lu_env *env,
struct llog_handle *handle,
struct thandle *th);
- int (*lop_create)(const struct lu_env *env, struct llog_handle *handle,
- struct thandle *th);
/**
* write new record in llog. It appends records usually but can edit
* existing records too.
@@ -287,8 +221,6 @@ struct llog_handle {
spinlock_t lgh_hdr_lock; /* protect lgh_hdr data */
struct llog_logid lgh_id; /* id of this log */
struct llog_log_hdr *lgh_hdr;
- struct file *lgh_file;
- struct dt_object *lgh_obj;
int lgh_last_idx;
int lgh_cur_idx; /* used during llog_process */
__u64 lgh_cur_offset; /* used during llog_process */
@@ -318,25 +250,11 @@ struct llog_ctxt {
struct mutex loc_mutex; /* protect loc_imp */
atomic_t loc_refcount;
long loc_flags; /* flags, see above defines */
- struct dt_object *loc_dir;
};
#define LLOG_PROC_BREAK 0x0001
#define LLOG_DEL_RECORD 0x0002
-static inline int llog_obd2ops(struct llog_ctxt *ctxt,
- struct llog_operations **lop)
-{
- if (ctxt == NULL)
- return -ENOTCONN;
-
- *lop = ctxt->loc_logops;
- if (*lop == NULL)
- return -EOPNOTSUPP;
-
- return 0;
-}
-
static inline int llog_handle2ops(struct llog_handle *loghandle,
struct llog_operations **lop)
{
@@ -347,18 +265,6 @@ static inline int llog_handle2ops(struct llog_handle *loghandle,
return 0;
}
-static inline int llog_data_len(int len)
-{
- return cfs_size_round(len);
-}
-
-static inline int llog_get_size(struct llog_handle *loghandle)
-{
- if (loghandle && loghandle->lgh_hdr)
- return loghandle->lgh_hdr->llh_count;
- return 0;
-}
-
static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt)
{
atomic_inc(&ctxt->loc_refcount);
@@ -440,22 +346,6 @@ static inline int llog_ctxt_null(struct obd_device *obd, int index)
return llog_group_ctxt_null(&obd->obd_olg, index);
}
-static inline int llog_destroy(const struct lu_env *env,
- struct llog_handle *handle)
-{
- struct llog_operations *lop;
- int rc;
-
- rc = llog_handle2ops(handle, &lop);
- if (rc)
- return rc;
- if (lop->lop_destroy == NULL)
- return -EOPNOTSUPP;
-
- rc = lop->lop_destroy(env, handle);
- return rc;
-}
-
static inline int llog_next_block(const struct lu_env *env,
struct llog_handle *loghandle, int *cur_idx,
int next_idx, __u64 *cur_offset, void *buf,
@@ -475,46 +365,7 @@ static inline int llog_next_block(const struct lu_env *env,
return rc;
}
-static inline int llog_prev_block(const struct lu_env *env,
- struct llog_handle *loghandle,
- int prev_idx, void *buf, int len)
-{
- struct llog_operations *lop;
- int rc;
-
- rc = llog_handle2ops(loghandle, &lop);
- if (rc)
- return rc;
- if (lop->lop_prev_block == NULL)
- return -EOPNOTSUPP;
-
- rc = lop->lop_prev_block(env, loghandle, prev_idx, buf, len);
- return rc;
-}
-
-static inline int llog_connect(struct llog_ctxt *ctxt,
- struct llog_logid *logid, struct llog_gen *gen,
- struct obd_uuid *uuid)
-{
- struct llog_operations *lop;
- int rc;
-
- rc = llog_obd2ops(ctxt, &lop);
- if (rc)
- return rc;
- if (lop->lop_connect == NULL)
- return -EOPNOTSUPP;
-
- rc = lop->lop_connect(ctxt, logid, gen, uuid);
- return rc;
-}
-
/* llog.c */
-int llog_exist(struct llog_handle *loghandle);
-int llog_declare_create(const struct lu_env *env,
- struct llog_handle *loghandle, struct thandle *th);
-int llog_create(const struct lu_env *env, struct llog_handle *handle,
- struct thandle *th);
int llog_declare_write_rec(const struct lu_env *env,
struct llog_handle *handle,
struct llog_rec_hdr *rec, int idx,
@@ -522,24 +373,10 @@ int llog_declare_write_rec(const struct lu_env *env,
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 llog_add(const struct lu_env *env, struct llog_handle *lgh,
- struct llog_rec_hdr *rec, struct llog_cookie *logcookies,
- void *buf, struct thandle *th);
-int llog_declare_add(const struct lu_env *env, struct llog_handle *lgh,
- struct llog_rec_hdr *rec, 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,
struct config_llog_instance *cfg);
-int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt,
- struct llog_handle **res, struct llog_logid *logid,
- char *name);
-int llog_erase(const struct lu_env *env, struct llog_ctxt *ctxt,
- struct llog_logid *logid, char *name);
-int llog_write(const struct lu_env *env, struct llog_handle *loghandle,
- struct llog_rec_hdr *rec, struct llog_cookie *reccookie,
- int cookiecount, void *buf, int idx);
-
/** @} log */
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_mdc.h b/kernel/drivers/staging/lustre/lustre/include/lustre_mdc.h
index b1b05c8a3..3da373315 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_mdc.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_mdc.h
@@ -163,7 +163,6 @@ static inline void mdc_update_max_ea_from_body(struct obd_export *exp,
}
}
-
struct mdc_cache_waiter {
struct list_head mcw_entry;
wait_queue_head_t mcw_waitq;
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_mds.h b/kernel/drivers/staging/lustre/lustre/include/lustre_mds.h
index f0cce41c5..a16eb8b61 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_mds.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_mds.h
@@ -59,11 +59,6 @@ struct mds_group_info {
int group;
};
-struct mds_capa_info {
- struct obd_uuid *uuid;
- struct lustre_capa_key *capa;
-};
-
#define MDD_OBD_NAME "mdd_obd"
#define MDD_OBD_UUID "mdd_obd_uuid"
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_net.h b/kernel/drivers/staging/lustre/lustre/include/lustre_net.h
index e2805bd1a..0127f45ca 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -46,7 +46,6 @@
* @{
*/
-
#ifndef _LUSTRE_NET_H
#define _LUSTRE_NET_H
@@ -56,8 +55,8 @@
*/
#include "../../include/linux/libcfs/libcfs.h"
-// #include <obd.h>
-#include "../../include/linux/lnet/lnet.h"
+#include "../../include/linux/lnet/nidstr.h"
+#include "../../include/linux/lnet/api.h"
#include "lustre/lustre_idl.h"
#include "lustre_ha.h"
#include "lustre_sec.h"
@@ -306,7 +305,7 @@ union ptlrpc_async_args {
/**
* Scratchpad for passing args to completion interpreter. Users
* cast to the struct of their choosing, and CLASSERT that this is
- * big enough. For _tons_ of context, OBD_ALLOC a struct and store
+ * big enough. For _tons_ of context, kmalloc a struct and store
* a pointer to it here. The pointer_arg ensures this struct is at
* least big enough for that.
*/
@@ -429,8 +428,7 @@ struct ptlrpc_reply_state {
unsigned long rs_on_net:1; /* reply_out_callback pending? */
unsigned long rs_prealloc:1; /* rs from prealloc list */
unsigned long rs_committed:1;/* the transaction was committed
- and the rs was dispatched
- by ptlrpc_commit_replies */
+ * and the rs was dispatched */
/** Size of the state */
int rs_size;
/** opcode */
@@ -500,7 +498,7 @@ struct ptlrpc_request_pool {
/** Maximum message size that would fit into a request from this pool */
int prp_rq_size;
/** Function to allocate more requests for this pool */
- void (*prp_populate)(struct ptlrpc_request_pool *, int);
+ int (*prp_populate)(struct ptlrpc_request_pool *, int);
};
struct lu_context;
@@ -643,7 +641,6 @@ struct ptlrpc_nrs_pol_ops {
*
* \see ptlrpc_nrs_req_initialize()
* \see ptlrpc_nrs_hpreq_add_nolock()
- * \see ptlrpc_nrs_req_hp_move()
*/
int (*op_res_get) (struct ptlrpc_nrs_policy *policy,
struct ptlrpc_nrs_request *nrq,
@@ -659,7 +656,6 @@ struct ptlrpc_nrs_pol_ops {
*
* \see ptlrpc_nrs_req_finalize()
* \see ptlrpc_nrs_hpreq_add_nolock()
- * \see ptlrpc_nrs_req_hp_move()
*/
void (*op_res_put) (struct ptlrpc_nrs_policy *policy,
const struct ptlrpc_nrs_resource *res);
@@ -704,8 +700,6 @@ struct ptlrpc_nrs_pol_ops {
*
* \param[in,out] policy The policy the request \a nrq belongs to
* \param[in,out] nrq The request to dequeue
- *
- * \see ptlrpc_nrs_req_del_nolock()
*/
void (*op_req_dequeue) (struct ptlrpc_nrs_policy *policy,
struct ptlrpc_nrs_request *nrq);
@@ -1292,7 +1286,7 @@ struct ptlrpc_request {
struct ptlrpc_nrs_request rq_nrq;
/** @} nrs */
/** the index of service's srv_at_array into which request is linked */
- time_t rq_at_index;
+ u32 rq_at_index;
/** Lock to protect request flags and some other important bits, like
* rq_list
*/
@@ -1440,7 +1434,7 @@ struct ptlrpc_request {
/* server-side... */
/** request arrival time */
- struct timeval rq_arrival_time;
+ struct timespec64 rq_arrival_time;
/** separated reply state */
struct ptlrpc_reply_state *rq_reply_state;
/** incoming request buffer */
@@ -1477,18 +1471,18 @@ struct ptlrpc_request {
/**
* when request/reply sent (secs), or time when request should be sent
*/
- time_t rq_sent;
+ time64_t rq_sent;
/** time for request really sent out */
- time_t rq_real_sent;
+ time64_t rq_real_sent;
/** when request must finish. volatile
* so that servers' early reply updates to the deadline aren't
* kept in per-cpu cache */
- volatile time_t rq_deadline;
+ volatile time64_t rq_deadline;
/** when req reply unlink must finish. */
- time_t rq_reply_deadline;
+ time64_t rq_reply_deadline;
/** when req bulk unlink must finish. */
- time_t rq_bulk_deadline;
+ time64_t rq_bulk_deadline;
/**
* service time estimate (secs)
* If the requestsis not served by this time, it is marked as timed out.
@@ -1533,15 +1527,6 @@ static inline int ptlrpc_req_interpret(const struct lu_env *env,
return rc;
}
-/** \addtogroup nrs
- * @{
- */
-int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf);
-int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf);
-void ptlrpc_nrs_req_hp_move(struct ptlrpc_request *req);
-void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy,
- struct ptlrpc_nrs_pol_info *info);
-
/*
* Can the request be moved from the regular NRS head to the high-priority NRS
* head (of the same PTLRPC service partition), if any?
@@ -1560,6 +1545,7 @@ static inline bool ptlrpc_nrs_req_can_move(struct ptlrpc_request *req)
*/
return nrq->nr_enqueued && !nrq->nr_started && !req->rq_hp;
}
+
/** @} nrs */
/**
@@ -1978,8 +1964,8 @@ struct ptlrpc_service {
int srv_nthrs_cpt_init;
/** limit of threads number for each partition */
int srv_nthrs_cpt_limit;
- /** Root of /proc dir tree for this service */
- struct proc_dir_entry *srv_procroot;
+ /** Root of debugfs dir tree for this service */
+ struct dentry *srv_debugfs_entry;
/** Pointer to statistic data for this service */
struct lprocfs_stats *srv_stats;
/** # hp per lp reqs to handle */
@@ -2016,6 +2002,10 @@ struct ptlrpc_service {
int srv_cpt_bits;
/** CPT table this service is running over */
struct cfs_cpt_table *srv_cptable;
+
+ /* sysfs object */
+ struct kobject srv_kobj;
+ struct completion srv_kobj_unregister;
/**
* partition data for ptlrpc service
*/
@@ -2061,7 +2051,7 @@ struct ptlrpc_service_part {
* rqbd list and incoming requests waiting for preprocess,
* threads starting & stopping are also protected by this lock.
*/
- spinlock_t scp_lock __cfs_cacheline_aligned;
+ spinlock_t scp_lock __cfs_cacheline_aligned;
/** total # req buffer descs allocated */
int scp_nrqbds_total;
/** # posted request buffers for receiving */
@@ -2179,7 +2169,7 @@ struct ptlrpcd_ctl {
*/
struct ptlrpc_request_set *pc_set;
/**
- * Thread name used in cfs_daemonize()
+ * Thread name used in kthread_run()
*/
char pc_name[16];
/**
@@ -2187,21 +2177,29 @@ struct ptlrpcd_ctl {
*/
struct lu_env pc_env;
/**
- * Index of ptlrpcd thread in the array.
+ * CPT the thread is bound on.
*/
- int pc_index;
+ int pc_cpt;
/**
- * Number of the ptlrpcd's partners.
+ * Index of ptlrpcd thread in the array.
*/
- int pc_npartners;
+ int pc_index;
/**
* Pointer to the array of partners' ptlrpcd_ctl structure.
*/
struct ptlrpcd_ctl **pc_partners;
/**
+ * Number of the ptlrpcd's partners.
+ */
+ int pc_npartners;
+ /**
* Record the partner index to be processed next.
*/
int pc_cursor;
+ /**
+ * Error code if the thread failed to fully start.
+ */
+ int pc_error;
};
/* Bits for pc_flags */
@@ -2224,10 +2222,6 @@ enum ptlrpcd_ctl_flags {
* This is a recovery ptlrpc thread.
*/
LIOD_RECOVERY = 1 << 3,
- /**
- * The ptlrpcd is bound to some CPU core.
- */
- LIOD_BIND = 1 << 4,
};
/**
@@ -2273,18 +2267,18 @@ static inline bool nrs_policy_compat_one(const struct ptlrpc_service *svc,
/* ptlrpc/events.c */
extern lnet_handle_eq_t ptlrpc_eq_h;
-extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
- lnet_process_id_t *peer, lnet_nid_t *self);
+int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
+ lnet_process_id_t *peer, lnet_nid_t *self);
/**
* These callbacks are invoked by LNet when something happened to
* underlying buffer
* @{
*/
-extern void request_out_callback(lnet_event_t *ev);
-extern void reply_in_callback(lnet_event_t *ev);
-extern void client_bulk_callback(lnet_event_t *ev);
-extern void request_in_callback(lnet_event_t *ev);
-extern void reply_out_callback(lnet_event_t *ev);
+void request_out_callback(lnet_event_t *ev);
+void reply_in_callback(lnet_event_t *ev);
+void client_bulk_callback(lnet_event_t *ev);
+void request_in_callback(lnet_event_t *ev);
+void reply_out_callback(lnet_event_t *ev);
/** @} */
/* ptlrpc/connection.c */
@@ -2295,7 +2289,6 @@ int ptlrpc_connection_put(struct ptlrpc_connection *c);
struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
int ptlrpc_connection_init(void);
void ptlrpc_connection_fini(void);
-extern lnet_pid_t ptl_get_pid(void);
/* ptlrpc/niobuf.c */
/**
@@ -2303,7 +2296,6 @@ extern lnet_pid_t ptl_get_pid(void);
* @{
*/
-int ptlrpc_register_bulk(struct ptlrpc_request *req);
int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async);
static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req)
@@ -2315,7 +2307,7 @@ static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req)
desc = req->rq_bulk;
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) &&
- req->rq_bulk_deadline > get_seconds())
+ req->rq_bulk_deadline > ktime_get_real_seconds())
return 1;
if (!desc)
@@ -2349,22 +2341,17 @@ void ptlrpc_request_committed(struct ptlrpc_request *req, int force);
void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
struct ptlrpc_client *);
-void ptlrpc_cleanup_client(struct obd_import *imp);
struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
int ptlrpc_queue_wait(struct ptlrpc_request *req);
int ptlrpc_replay_req(struct ptlrpc_request *req);
int ptlrpc_unregister_reply(struct ptlrpc_request *req, int async);
-void ptlrpc_restart_req(struct ptlrpc_request *req);
void ptlrpc_abort_inflight(struct obd_import *imp);
-void ptlrpc_cleanup_imp(struct obd_import *imp);
void ptlrpc_abort_set(struct ptlrpc_request_set *set);
struct ptlrpc_request_set *ptlrpc_prep_set(void);
struct ptlrpc_request_set *ptlrpc_prep_fcset(int max, set_producer_func func,
void *arg);
-int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
- set_interpreter_func fn, void *data);
int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set);
int ptlrpc_set_wait(struct ptlrpc_request_set *);
@@ -2377,11 +2364,11 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
struct ptlrpc_request *req);
void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool);
-void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
+int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
struct ptlrpc_request_pool *
ptlrpc_init_rq_pool(int, int,
- void (*populate_pool)(struct ptlrpc_request_pool *, int));
+ int (*populate_pool)(struct ptlrpc_request_pool *, int));
void ptlrpc_at_set_req_timeout(struct ptlrpc_request *req);
struct ptlrpc_request *ptlrpc_request_alloc(struct obd_import *imp,
@@ -2398,15 +2385,7 @@ struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp,
int ptlrpc_request_bufs_pack(struct ptlrpc_request *request,
__u32 version, int opcode, char **bufs,
struct ptlrpc_cli_ctx *ctx);
-struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, __u32 version,
- int opcode, int count, __u32 *lengths,
- char **bufs);
-struct ptlrpc_request *ptlrpc_prep_req_pool(struct obd_import *imp,
- __u32 version, int opcode,
- int count, __u32 *lengths, char **bufs,
- struct ptlrpc_request_pool *pool);
void ptlrpc_req_finished(struct ptlrpc_request *request);
-void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req,
unsigned npages, unsigned max_brw,
@@ -2416,10 +2395,12 @@ static inline void ptlrpc_free_bulk_pin(struct ptlrpc_bulk_desc *bulk)
{
__ptlrpc_free_bulk(bulk, 1);
}
+
static inline void ptlrpc_free_bulk_nopin(struct ptlrpc_bulk_desc *bulk)
{
__ptlrpc_free_bulk(bulk, 0);
}
+
void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
struct page *page, int pageoffset, int len, int);
static inline void ptlrpc_prep_bulk_page_pin(struct ptlrpc_bulk_desc *desc,
@@ -2517,25 +2498,16 @@ struct ptlrpc_service_conf {
*
* @{
*/
-void ptlrpc_save_lock(struct ptlrpc_request *req,
- struct lustre_handle *lock, int mode, int no_ack);
-void ptlrpc_commit_replies(struct obd_export *exp);
void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs);
void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs);
-int ptlrpc_hpreq_handler(struct ptlrpc_request *req);
struct ptlrpc_service *ptlrpc_register_service(
struct ptlrpc_service_conf *conf,
- struct proc_dir_entry *proc_entry);
-void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
+ struct kset *parent,
+ struct dentry *debugfs_entry);
int ptlrpc_start_threads(struct ptlrpc_service *svc);
int ptlrpc_unregister_service(struct ptlrpc_service *service);
int liblustre_check_services(void *arg);
-void ptlrpc_daemonize(char *name);
-int ptlrpc_service_health_check(struct ptlrpc_service *);
-void ptlrpc_server_drop_request(struct ptlrpc_request *req);
-void ptlrpc_request_change_export(struct ptlrpc_request *req,
- struct obd_export *export);
int ptlrpc_hr_init(void);
void ptlrpc_hr_fini(void);
@@ -2551,8 +2523,6 @@ int ptlrpc_connect_import(struct obd_import *imp);
int ptlrpc_init_import(struct obd_import *imp);
int ptlrpc_disconnect_import(struct obd_import *imp, int noclose);
int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
-void deuuidify(char *uuid, const char *prefix, char **uuid_start,
- int *uuid_len);
/* ptlrpc/pack_generic.c */
int ptlrpc_reconnect_import(struct obd_import *imp);
@@ -2570,7 +2540,6 @@ void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout,
int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len);
int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len);
-int lustre_msg_check_version(struct lustre_msg *msg, __u32 version);
void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens,
char **bufs);
int lustre_pack_request(struct ptlrpc_request *, __u32 magic, int count,
@@ -2594,7 +2563,6 @@ int lustre_msg_early_size(void);
void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size);
void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
int lustre_msg_buflen(struct lustre_msg *m, int n);
-void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len);
int lustre_msg_bufcount(struct lustre_msg *m);
char *lustre_msg_string(struct lustre_msg *m, int n, int max_len);
__u32 lustre_msghdr_get_flags(struct lustre_msg *msg);
@@ -2605,13 +2573,10 @@ void lustre_msg_set_flags(struct lustre_msg *msg, int flags);
void lustre_msg_clear_flags(struct lustre_msg *msg, int flags);
__u32 lustre_msg_get_op_flags(struct lustre_msg *msg);
void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags);
-void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags);
struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg);
__u32 lustre_msg_get_type(struct lustre_msg *msg);
-__u32 lustre_msg_get_version(struct lustre_msg *msg);
void lustre_msg_add_version(struct lustre_msg *msg, int version);
__u32 lustre_msg_get_opc(struct lustre_msg *msg);
-__u64 lustre_msg_get_last_xid(struct lustre_msg *msg);
__u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
__u64 *lustre_msg_get_versions(struct lustre_msg *msg);
__u64 lustre_msg_get_transno(struct lustre_msg *msg);
@@ -2621,25 +2586,19 @@ void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv);
void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit);
int lustre_msg_get_status(struct lustre_msg *msg);
__u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg);
-int lustre_msg_is_v1(struct lustre_msg *msg);
__u32 lustre_msg_get_magic(struct lustre_msg *msg);
__u32 lustre_msg_get_timeout(struct lustre_msg *msg);
__u32 lustre_msg_get_service_time(struct lustre_msg *msg);
-char *lustre_msg_get_jobid(struct lustre_msg *msg);
__u32 lustre_msg_get_cksum(struct lustre_msg *msg);
__u32 lustre_msg_calc_cksum(struct lustre_msg *msg);
void lustre_msg_set_handle(struct lustre_msg *msg,
struct lustre_handle *handle);
void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
-void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid);
-void lustre_msg_set_last_committed(struct lustre_msg *msg,
- __u64 last_committed);
void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions);
void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno);
void lustre_msg_set_status(struct lustre_msg *msg, __u32 status);
void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt);
-void ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, __u32 *sizes);
void ptlrpc_request_set_replen(struct ptlrpc_request *req);
void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout);
void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time);
@@ -2720,7 +2679,7 @@ static inline int
ptlrpc_client_early(struct ptlrpc_request *req)
{
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) &&
- req->rq_reply_deadline > get_seconds())
+ req->rq_reply_deadline > ktime_get_real_seconds())
return 0;
return req->rq_early;
}
@@ -2732,7 +2691,7 @@ static inline int
ptlrpc_client_replied(struct ptlrpc_request *req)
{
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) &&
- req->rq_reply_deadline > get_seconds())
+ req->rq_reply_deadline > ktime_get_real_seconds())
return 0;
return req->rq_replied;
}
@@ -2742,7 +2701,7 @@ static inline int
ptlrpc_client_recv(struct ptlrpc_request *req)
{
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) &&
- req->rq_reply_deadline > get_seconds())
+ req->rq_reply_deadline > ktime_get_real_seconds())
return 1;
return req->rq_receiving_reply;
}
@@ -2754,7 +2713,7 @@ ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req)
spin_lock(&req->rq_lock);
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) &&
- req->rq_reply_deadline > get_seconds()) {
+ req->rq_reply_deadline > ktime_get_real_seconds()) {
spin_unlock(&req->rq_lock);
return 1;
}
@@ -2873,7 +2832,6 @@ int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
void client_destroy_import(struct obd_import *imp);
/** @} */
-
/* ptlrpc/pinger.c */
/**
* Pinger API (client side only)
@@ -2882,6 +2840,7 @@ void client_destroy_import(struct obd_import *imp);
enum timeout_event {
TIMEOUT_GRANT = 1
};
+
struct timeout_item;
typedef int (*timeout_cb_t)(struct timeout_item *, void *);
int ptlrpc_pinger_add_import(struct obd_import *imp);
@@ -2893,51 +2852,16 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list,
enum timeout_event event);
struct ptlrpc_request *ptlrpc_prep_ping(struct obd_import *imp);
int ptlrpc_obd_ping(struct obd_device *obd);
-void ping_evictor_start(void);
-void ping_evictor_stop(void);
void ptlrpc_pinger_ir_up(void);
void ptlrpc_pinger_ir_down(void);
/** @} */
int ptlrpc_pinger_suppress_pings(void);
-/* ptlrpc daemon bind policy */
-typedef enum {
- /* all ptlrpcd threads are free mode */
- PDB_POLICY_NONE = 1,
- /* all ptlrpcd threads are bound mode */
- PDB_POLICY_FULL = 2,
- /* <free1 bound1> <free2 bound2> ... <freeN boundN> */
- PDB_POLICY_PAIR = 3,
- /* <free1 bound1> <bound1 free2> ... <freeN boundN> <boundN free1>,
- * means each ptlrpcd[X] has two partners: thread[X-1] and thread[X+1].
- * If kernel supports NUMA, pthrpcd threads are binded and
- * grouped by NUMA node */
- PDB_POLICY_NEIGHBOR = 4,
-} pdb_policy_t;
-
-/* ptlrpc daemon load policy
- * It is caller's duty to specify how to push the async RPC into some ptlrpcd
- * queue, but it is not enforced, affected by "ptlrpcd_bind_policy". If it is
- * "PDB_POLICY_FULL", then the RPC will be processed by the selected ptlrpcd,
- * Otherwise, the RPC may be processed by the selected ptlrpcd or its partner,
- * depends on which is scheduled firstly, to accelerate the RPC processing. */
-typedef enum {
- /* on the same CPU core as the caller */
- PDL_POLICY_SAME = 1,
- /* within the same CPU partition, but not the same core as the caller */
- PDL_POLICY_LOCAL = 2,
- /* round-robin on all CPU cores, but not the same core as the caller */
- PDL_POLICY_ROUND = 3,
- /* the specified CPU core is preferred, but not enforced */
- PDL_POLICY_PREFERRED = 4,
-} pdl_policy_t;
-
/* ptlrpc/ptlrpcd.c */
void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force);
void ptlrpcd_free(struct ptlrpcd_ctl *pc);
void ptlrpcd_wake(struct ptlrpc_request *req);
-void ptlrpcd_add_req(struct ptlrpc_request *req, pdl_policy_t policy, int idx);
-void ptlrpcd_add_rqset(struct ptlrpc_request_set *set);
+void ptlrpcd_add_req(struct ptlrpc_request *req);
int ptlrpcd_addref(void);
void ptlrpcd_decref(void);
@@ -2947,20 +2871,13 @@ void ptlrpcd_decref(void);
* @{
*/
const char *ll_opcode2str(__u32 opcode);
-#if defined (CONFIG_PROC_FS)
void ptlrpc_lprocfs_register_obd(struct obd_device *obd);
void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd);
void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes);
-#else
-static inline void ptlrpc_lprocfs_register_obd(struct obd_device *obd) {}
-static inline void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) {}
-static inline void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes) {}
-#endif
/** @} */
/* ptlrpc/llog_client.c */
extern struct llog_operations llog_client_ops;
-
/** @} net */
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_param.h b/kernel/drivers/staging/lustre/lustre/include/lustre_param.h
index ed654684c..8f6c0b26c 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_param.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_param.h
@@ -56,20 +56,8 @@ struct cfg_interop_param {
/* obd_config.c */
int class_find_param(char *buf, char *key, char **valp);
-struct cfg_interop_param *class_find_old_param(const char *param,
- struct cfg_interop_param *ptr);
-int class_get_next_param(char **params, char *copy);
-int class_match_param(char *buf, char *key, char **valp);
int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh);
int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh);
-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);
-/* obd_mount.c */
-int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
- char *s1, char *s2, char *s3, char *s4);
-
-
/****************** User-settable parameter keys *********************/
/* e.g.
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_quota.h b/kernel/drivers/staging/lustre/lustre/include/lustre_quota.h
deleted file mode 100644
index 2643f2807..000000000
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_quota.h
+++ /dev/null
@@ -1,241 +0,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, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2011, 2012, Intel Corporation.
- * Use is subject to license terms.
- */
-
-#ifndef _LUSTRE_QUOTA_H
-#define _LUSTRE_QUOTA_H
-
-/** \defgroup quota quota
- *
- */
-
-#include <linux/fs.h>
-#include <linux/quota.h>
-#include <linux/quotaops.h>
-
-#include "dt_object.h"
-#include "lustre_fid.h"
-#include "lustre_dlm.h"
-
-#ifndef MAX_IQ_TIME
-#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
-#endif
-
-#ifndef MAX_DQ_TIME
-#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
-#endif
-
-struct lquota_id_info;
-struct lquota_trans;
-
-/* Gather all quota record type in an union that can be used to read any records
- * from disk. All fields of these records must be 64-bit aligned, otherwise the
- * OSD layer may swab them incorrectly. */
-union lquota_rec {
- struct lquota_glb_rec lqr_glb_rec;
- struct lquota_slv_rec lqr_slv_rec;
- struct lquota_acct_rec lqr_acct_rec;
-};
-
-/* Index features supported by the global index objects
- * Only used for migration purpose and should be removed once on-disk migration
- * is no longer needed */
-extern struct dt_index_features dt_quota_iusr_features;
-extern struct dt_index_features dt_quota_busr_features;
-extern struct dt_index_features dt_quota_igrp_features;
-extern struct dt_index_features dt_quota_bgrp_features;
-
-/* Name used in the configuration logs to identify the default metadata pool
- * (composed of all the MDTs, with pool ID 0) and the default data pool (all
- * the OSTs, with pool ID 0 too). */
-#define QUOTA_METAPOOL_NAME "mdt="
-#define QUOTA_DATAPOOL_NAME "ost="
-
-/*
- * Quota Master Target support
- */
-
-/* Request handlers for quota master operations.
- * This is used by the MDT to pass quota/lock requests to the quota master
- * target. This won't be needed any more once the QMT is a real target and
- * does not rely any more on the MDT service threads and namespace. */
-struct qmt_handlers {
- /* Handle quotactl request from client. */
- int (*qmth_quotactl)(const struct lu_env *, struct lu_device *,
- struct obd_quotactl *);
-
- /* Handle dqacq/dqrel request from slave. */
- int (*qmth_dqacq)(const struct lu_env *, struct lu_device *,
- struct ptlrpc_request *);
-
- /* LDLM intent policy associated with quota locks */
- int (*qmth_intent_policy)(const struct lu_env *, struct lu_device *,
- struct ptlrpc_request *, struct ldlm_lock **,
- int);
-
- /* Initialize LVB of ldlm resource associated with quota objects */
- int (*qmth_lvbo_init)(struct lu_device *, struct ldlm_resource *);
-
- /* Update LVB of ldlm resource associated with quota objects */
- int (*qmth_lvbo_update)(struct lu_device *, struct ldlm_resource *,
- struct ptlrpc_request *, int);
-
- /* Return size of LVB to be packed in ldlm message */
- int (*qmth_lvbo_size)(struct lu_device *, struct ldlm_lock *);
-
- /* Fill request buffer with lvb */
- int (*qmth_lvbo_fill)(struct lu_device *, struct ldlm_lock *, void *,
- int);
-
- /* Free lvb associated with ldlm resource */
- int (*qmth_lvbo_free)(struct lu_device *, struct ldlm_resource *);
-};
-
-/* actual handlers are defined in lustre/quota/qmt_handler.c */
-extern struct qmt_handlers qmt_hdls;
-
-/*
- * Quota enforcement support on slaves
- */
-
-struct qsd_instance;
-
-/* The quota slave feature is implemented under the form of a library.
- * The API is the following:
- *
- * - qsd_init(): the user (mostly the OSD layer) should first allocate a qsd
- * instance via qsd_init(). This creates all required structures
- * to manage quota enforcement for this target and performs all
- * low-level initialization which does not involve any lustre
- * object. qsd_init() should typically be called when the OSD
- * is being set up.
- *
- * - qsd_prepare(): This sets up on-disk objects associated with the quota slave
- * feature and initiates the quota reintegration procedure if
- * needed. qsd_prepare() should typically be called when
- * ->ldo_prepare is invoked.
- *
- * - qsd_start(): a qsd instance should be started once recovery is completed
- * (i.e. when ->ldo_recovery_complete is called). This is used
- * to notify the qsd layer that quota should now be enforced
- * again via the qsd_op_begin/end functions. The last step of the
- * reintegration procedure (namely usage reconciliation) will be
- * completed during start.
- *
- * - qsd_fini(): is used to release a qsd_instance structure allocated with
- * qsd_init(). This releases all quota slave objects and frees the
- * structures associated with the qsd_instance.
- *
- * - qsd_op_begin(): is used to enforce quota, it must be called in the
- * declaration of each operation. qsd_op_end() should then be
- * invoked later once all operations have been completed in
- * order to release/adjust the quota space.
- * Running qsd_op_begin() before qsd_start() isn't fatal and
- * will return success.
- * Once qsd_start() has been run, qsd_op_begin() will block
- * until the reintegration procedure is completed.
- *
- * - qsd_op_end(): performs the post operation quota processing. This must be
- * called after the operation transaction stopped.
- * While qsd_op_begin() must be invoked each time a new
- * operation is declared, qsd_op_end() should be called only
- * once for the whole transaction.
- *
- * - qsd_op_adjust(): triggers pre-acquire/release if necessary.
- *
- * Below are the function prototypes to be used by OSD layer to manage quota
- * enforcement. Arguments are documented where each function is defined. */
-
-struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *,
- struct proc_dir_entry *);
-int qsd_prepare(const struct lu_env *, struct qsd_instance *);
-int qsd_start(const struct lu_env *, struct qsd_instance *);
-void qsd_fini(const struct lu_env *, struct qsd_instance *);
-int qsd_op_begin(const struct lu_env *, struct qsd_instance *,
- struct lquota_trans *, struct lquota_id_info *, int *);
-void qsd_op_end(const struct lu_env *, struct qsd_instance *,
- struct lquota_trans *);
-void qsd_op_adjust(const struct lu_env *, struct qsd_instance *,
- union lquota_id *, int);
-/* This is exported for the ldiskfs quota migration only,
- * see convert_quota_file() */
-int lquota_disk_write_glb(const struct lu_env *, struct dt_object *,
- __u64, struct lquota_glb_rec *);
-
-/*
- * Quota information attached to a transaction
- */
-
-struct lquota_entry;
-
-struct lquota_id_info {
- /* quota identifier */
- union lquota_id lqi_id;
-
- /* USRQUOTA or GRPQUOTA for now, could be expanded for
- * directory quota or other types later. */
- int lqi_type;
-
- /* inodes or kbytes to be consumed or released, it could
- * be negative when releasing space. */
- long long lqi_space;
-
- /* quota slave entry structure associated with this ID */
- struct lquota_entry *lqi_qentry;
-
- /* whether we are reporting blocks or inodes */
- bool lqi_is_blk;
-};
-
-/* Since we enforce only inode quota in meta pool (MDTs), and block quota in
- * data pool (OSTs), there are at most 4 quota ids being enforced in a single
- * transaction, which is chown transaction:
- * original uid and gid, new uid and gid.
- *
- * This value might need to be revised when directory quota is added. */
-#define QUOTA_MAX_TRANSIDS 4
-
-/* all qids involved in a single transaction */
-struct lquota_trans {
- unsigned short lqt_id_cnt;
- struct lquota_id_info lqt_ids[QUOTA_MAX_TRANSIDS];
-};
-
-/* flags for quota local enforcement */
-#define QUOTA_FL_OVER_USRQUOTA 0x01
-#define QUOTA_FL_OVER_GRPQUOTA 0x02
-#define QUOTA_FL_SYNC 0x04
-
-#define IS_LQUOTA_RES(res) \
- (res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA || \
- res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA_GLB)
-
-/* helper function used by MDT & OFD to retrieve quota accounting information
- * on slave */
-int lquotactl_slv(const struct lu_env *, struct dt_device *,
- struct obd_quotactl *);
-/** @} quota */
-#endif /* _LUSTRE_QUOTA_H */
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/kernel/drivers/staging/lustre/lustre/include/lustre_req_layout.h
index c6457b27c..df292f6d4 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_req_layout.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_req_layout.h
@@ -80,9 +80,6 @@ void req_capsule_init(struct req_capsule *pill, struct ptlrpc_request *req,
void req_capsule_fini(struct req_capsule *pill);
void req_capsule_set(struct req_capsule *pill, const struct req_format *fmt);
-void req_capsule_client_dump(struct req_capsule *pill);
-void req_capsule_server_dump(struct req_capsule *pill);
-void req_capsule_init_area(struct req_capsule *pill);
int req_capsule_filled_sizes(struct req_capsule *pill, enum req_location loc);
int req_capsule_server_pack(struct req_capsule *pill);
@@ -105,8 +102,6 @@ void *req_capsule_server_swab_get(struct req_capsule *pill,
void *req_capsule_server_sized_swab_get(struct req_capsule *pill,
const struct req_msg_field *field,
int len, void *swabber);
-const void *req_capsule_other_get(struct req_capsule *pill,
- const struct req_msg_field *field);
void req_capsule_set_size(struct req_capsule *pill,
const struct req_msg_field *field,
@@ -122,16 +117,10 @@ void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt);
int req_capsule_has_field(const struct req_capsule *pill,
const struct req_msg_field *field,
enum req_location loc);
-int req_capsule_field_present(const struct req_capsule *pill,
- const struct req_msg_field *field,
- enum req_location loc);
void req_capsule_shrink(struct req_capsule *pill,
const struct req_msg_field *field,
unsigned int newlen,
enum req_location loc);
-int req_capsule_server_grow(struct req_capsule *pill,
- const struct req_msg_field *field,
- unsigned int newlen);
int req_layout_init(void);
void req_layout_fini(void);
diff --git a/kernel/drivers/staging/lustre/lustre/include/lustre_sec.h b/kernel/drivers/staging/lustre/lustre/include/lustre_sec.h
index dff70a5b9..dd1033be6 100644
--- a/kernel/drivers/staging/lustre/lustre/include/lustre_sec.h
+++ b/kernel/drivers/staging/lustre/lustre/include/lustre_sec.h
@@ -295,7 +295,6 @@ enum lustre_sec_part {
LUSTRE_SP_ANY = 0xFF
};
-const char *sptlrpc_part2name(enum lustre_sec_part sp);
enum lustre_sec_part sptlrpc_target_sec_part(struct obd_device *obd);
/**
@@ -323,34 +322,19 @@ struct sptlrpc_rule_set {
};
int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr);
-int sptlrpc_flavor_has_bulk(struct sptlrpc_flavor *flvr);
+bool sptlrpc_flavor_has_bulk(struct sptlrpc_flavor *flvr);
static inline void sptlrpc_rule_set_init(struct sptlrpc_rule_set *set)
{
memset(set, 0, sizeof(*set));
}
-void sptlrpc_rule_set_free(struct sptlrpc_rule_set *set);
-int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *set);
-int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *set,
- struct sptlrpc_rule *rule);
-int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
- enum lustre_sec_part from,
- enum lustre_sec_part to,
- lnet_nid_t nid,
- struct sptlrpc_flavor *sf);
-void sptlrpc_rule_set_dump(struct sptlrpc_rule_set *set);
-
int sptlrpc_process_config(struct lustre_cfg *lcfg);
void sptlrpc_conf_log_start(const char *logname);
void sptlrpc_conf_log_stop(const char *logname);
void sptlrpc_conf_log_update_begin(const char *logname);
void sptlrpc_conf_log_update_end(const char *logname);
void sptlrpc_conf_client_adapt(struct obd_device *obd);
-void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
- enum lustre_sec_part from,
- lnet_nid_t nid,
- struct sptlrpc_flavor *flavor);
/* The maximum length of security payload. 1024 is enough for Kerberos 5,
* and should be enough for other future mechanisms but not sure.
@@ -358,7 +342,6 @@ void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
*/
#define SPTLRPC_MAX_PAYLOAD (1024)
-
struct vfs_cred {
uint32_t vc_uid;
uint32_t vc_gid;
@@ -833,7 +816,7 @@ struct ptlrpc_sec {
*/
struct list_head ps_gc_list;
unsigned long ps_gc_interval; /* in seconds */
- unsigned long ps_gc_next; /* in seconds */
+ time64_t ps_gc_next; /* in seconds */
};
static inline int sec_is_reverse(struct ptlrpc_sec *sec)
@@ -846,7 +829,6 @@ static inline int sec_is_rootonly(struct ptlrpc_sec *sec)
return (sec->ps_flvr.sf_flags & PTLRPC_SEC_FL_ROOTONLY);
}
-
struct ptlrpc_svc_ctx {
atomic_t sc_refcount;
struct ptlrpc_sec_policy *sc_policy;
@@ -898,7 +880,6 @@ struct ptlrpc_bulk_sec_desc {
__u8 bsd_data[0]; /* policy-specific token */
};
-
/*
* round size up to next power of 2, for slab allocation.
* @size must be sane (can't overflow after round up)
@@ -932,7 +913,6 @@ const char *sptlrpc_flavor2name_base(__u32 flvr);
char *sptlrpc_flavor2name_bulk(struct sptlrpc_flavor *sf,
char *buf, int bufsize);
char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize);
-char *sptlrpc_secflags2str(__u32 flags, char *buf, int bufsize);
static inline
struct ptlrpc_sec_policy *sptlrpc_policy_get(struct ptlrpc_sec_policy *policy)
@@ -995,23 +975,18 @@ int cli_ctx_is_eternal(struct ptlrpc_cli_ctx *ctx)
/*
* sec get/put
*/
-struct ptlrpc_sec *sptlrpc_sec_get(struct ptlrpc_sec *sec);
void sptlrpc_sec_put(struct ptlrpc_sec *sec);
/*
* internal apis which only used by policy implementation
*/
int sptlrpc_get_next_secid(void);
-void sptlrpc_sec_destroy(struct ptlrpc_sec *sec);
/*
* exported client context api
*/
struct ptlrpc_cli_ctx *sptlrpc_cli_ctx_get(struct ptlrpc_cli_ctx *ctx);
void sptlrpc_cli_ctx_put(struct ptlrpc_cli_ctx *ctx, int sync);
-void sptlrpc_cli_ctx_expire(struct ptlrpc_cli_ctx *ctx);
-void sptlrpc_cli_ctx_wakeup(struct ptlrpc_cli_ctx *ctx);
-int sptlrpc_cli_ctx_display(struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize);
/*
* exported client context wrap/buffers
@@ -1046,30 +1021,18 @@ void sptlrpc_import_flush_all_ctx(struct obd_import *imp);
int sptlrpc_req_get_ctx(struct ptlrpc_request *req);
void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync);
int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout);
-int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req);
void sptlrpc_req_set_flavor(struct ptlrpc_request *req, int opcode);
-int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule);
-
/* gc */
void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec);
void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec);
-void sptlrpc_gc_add_ctx(struct ptlrpc_cli_ctx *ctx);
/* misc */
const char *sec2target_str(struct ptlrpc_sec *sec);
/*
* lprocfs
*/
-#if defined (CONFIG_PROC_FS)
-struct proc_dir_entry;
-extern struct proc_dir_entry *sptlrpc_proc_root;
int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev);
-#else
-#define sptlrpc_proc_root NULL
-static inline int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
-{ return 0; }
-#endif
/*
* server side
@@ -1086,25 +1049,11 @@ int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req);
void sptlrpc_svc_free_rs(struct ptlrpc_reply_state *rs);
void sptlrpc_svc_ctx_addref(struct ptlrpc_request *req);
void sptlrpc_svc_ctx_decref(struct ptlrpc_request *req);
-void sptlrpc_svc_ctx_invalidate(struct ptlrpc_request *req);
int sptlrpc_target_export_check(struct obd_export *exp,
struct ptlrpc_request *req);
-void sptlrpc_target_update_exp_flavor(struct obd_device *obd,
- struct sptlrpc_rule_set *rset);
-
-/*
- * reverse context
- */
-int sptlrpc_svc_install_rvs_ctx(struct obd_import *imp,
- struct ptlrpc_svc_ctx *ctx);
-int sptlrpc_cli_install_rvs_ctx(struct obd_import *imp,
- struct ptlrpc_cli_ctx *ctx);
/* bulk security api */
-int sptlrpc_enc_pool_add_user(void);
-int sptlrpc_enc_pool_del_user(void);
-int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc);
void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc);
int sptlrpc_cli_wrap_bulk(struct ptlrpc_request *req,
@@ -1131,7 +1080,6 @@ int sptlrpc_current_user_desc_size(void);
int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset);
int sptlrpc_unpack_user_desc(struct lustre_msg *req, int offset, int swabbed);
-
#define CFS_CAP_CHOWN_MASK (1 << CFS_CAP_CHOWN)
#define CFS_CAP_SYS_RESOURCE_MASK (1 << CFS_CAP_SYS_RESOURCE)
diff --git a/kernel/drivers/staging/lustre/lustre/include/obd.h b/kernel/drivers/staging/lustre/lustre/include/obd.h
index 2a88b806f..5e93afca3 100644
--- a/kernel/drivers/staging/lustre/lustre/include/obd.h
+++ b/kernel/drivers/staging/lustre/lustre/include/obd.h
@@ -54,7 +54,6 @@
#include "lustre_export.h"
#include "lustre_fid.h"
#include "lustre_fld.h"
-#include "lustre_capa.h"
#define MAX_OBD_DEVICES 8192
@@ -144,10 +143,6 @@ typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
/* obd info for a particular level (lov, osc). */
struct obd_info {
- /* Lock policy. It keeps an extent which is specific for a particular
- * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy,
- * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */
- ldlm_policy_data_t oi_policy;
/* Flags used for set request specific flags:
- while lock handling, the flags obtained on the enqueue
request are set here.
@@ -155,8 +150,6 @@ struct obd_info {
- while setattr, the flags used for distinguish punch operation
*/
__u64 oi_flags;
- /* Lock handle specific for every OSC lock. */
- struct lustre_handle *oi_lockh;
/* lsm data specific for every OSC. */
struct lov_stripe_md *oi_md;
/* obdo data specific for every OSC, if needed at all. */
@@ -168,75 +161,8 @@ struct obd_info {
* request in osc level for enqueue requests. It is also possible to
* update some caller data from LOV layer if needed. */
obd_enqueue_update_f oi_cb_up;
- /* oss capability, its type is obd_capa in client to avoid copy.
- * in contrary its type is lustre_capa in OSS. */
- void *oi_capa;
- /* transfer jobid from ost_sync() to filter_sync()... */
- char *oi_jobid;
};
-/* compare all relevant fields. */
-static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
- struct lov_stripe_md *m2)
-{
- /*
- * ->lsm_wire contains padding, but it should be zeroed out during
- * allocation.
- */
- return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof(m1->lsm_wire));
-}
-
-static inline int lov_lum_lsm_cmp(struct lov_user_md *lum,
- struct lov_stripe_md *lsm)
-{
- if (lsm->lsm_magic != lum->lmm_magic)
- return 1;
- if ((lsm->lsm_stripe_count != 0) && (lum->lmm_stripe_count != 0) &&
- (lsm->lsm_stripe_count != lum->lmm_stripe_count))
- return 2;
- if ((lsm->lsm_stripe_size != 0) && (lum->lmm_stripe_size != 0) &&
- (lsm->lsm_stripe_size != lum->lmm_stripe_size))
- return 3;
- if ((lsm->lsm_pattern != 0) && (lum->lmm_pattern != 0) &&
- (lsm->lsm_pattern != lum->lmm_pattern))
- return 4;
- if ((lsm->lsm_magic == LOV_MAGIC_V3) &&
- (strncmp(lsm->lsm_pool_name,
- ((struct lov_user_md_v3 *)lum)->lmm_pool_name,
- LOV_MAXPOOLNAME) != 0))
- return 5;
- return 0;
-}
-
-static inline int lov_lum_swab_if_needed(struct lov_user_md_v3 *lumv3,
- int *lmm_magic,
- struct lov_user_md *lum)
-{
- if (lum && copy_from_user(lumv3, lum, sizeof(struct lov_user_md_v1)))
- return -EFAULT;
-
- *lmm_magic = lumv3->lmm_magic;
-
- if (*lmm_magic == __swab32(LOV_USER_MAGIC_V1)) {
- lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lumv3);
- *lmm_magic = LOV_USER_MAGIC_V1;
- } else if (*lmm_magic == LOV_USER_MAGIC_V3) {
- if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3)))
- return -EFAULT;
- } else if (*lmm_magic == __swab32(LOV_USER_MAGIC_V3)) {
- if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3)))
- return -EFAULT;
- lustre_swab_lov_user_md_v3(lumv3);
- *lmm_magic = LOV_USER_MAGIC_V3;
- } else if (*lmm_magic != LOV_USER_MAGIC_V1) {
- CDEBUG(D_IOCTL,
- "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n",
- *lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3);
- return -EINVAL;
- }
- return 0;
-}
-
void lov_stripe_lock(struct lov_stripe_md *md);
void lov_stripe_unlock(struct lov_stripe_md *md);
@@ -244,11 +170,12 @@ struct obd_type {
struct list_head typ_chain;
struct obd_ops *typ_dt_ops;
struct md_ops *typ_md_ops;
- struct proc_dir_entry *typ_procroot;
+ 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;
};
struct brw_page {
@@ -405,9 +332,6 @@ struct client_obd {
struct mdc_rpc_lock *cl_close_lock;
/* mgc datastruct */
- struct mutex cl_mgc_mutex;
- struct local_oid_storage *cl_mgc_los;
- struct dt_object *cl_mgc_configs_dir;
atomic_t cl_mgc_refcount;
struct obd_export *cl_mgc_mgsexp;
@@ -438,6 +362,7 @@ struct client_obd {
/* hash tables for osc_quota_info */
struct cfs_hash *cl_quota_hash[MAXQUOTAS];
};
+
#define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
struct obd_id_info {
@@ -454,25 +379,6 @@ struct echo_client_obd {
__u64 ec_unique;
};
-struct lov_qos_oss {
- struct obd_uuid lqo_uuid; /* ptlrpc's c_remote_uuid */
- struct list_head lqo_oss_list; /* link to lov_qos */
- __u64 lqo_bavail; /* total bytes avail on OSS */
- __u64 lqo_penalty; /* current penalty */
- __u64 lqo_penalty_per_obj;/* penalty decrease every obj*/
- time_t lqo_used; /* last used time, seconds */
- __u32 lqo_ost_count; /* number of osts on this oss */
-};
-
-struct ltd_qos {
- struct lov_qos_oss *ltq_oss; /* oss info */
- __u64 ltq_penalty; /* current penalty */
- __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/
- __u64 ltq_weight; /* net weighting */
- time_t ltq_used; /* last used time, seconds */
- unsigned int ltq_usable:1; /* usable for striping */
-};
-
/* Generic subset of OSTs */
struct ost_pool {
__u32 *op_array; /* array of index of
@@ -498,6 +404,7 @@ struct lov_statfs_data {
struct obd_info lsd_oi;
struct obd_statfs lsd_statfs;
};
+
/* Stripe placement optimization */
struct lov_qos {
struct list_head lq_oss_list; /* list of OSSs that targets use */
@@ -523,7 +430,6 @@ struct lov_tgt_desc {
struct obd_uuid ltd_uuid;
struct obd_device *ltd_obd;
struct obd_export *ltd_exp;
- struct ltd_qos ltd_qos; /* qos info per target */
__u32 ltd_gen;
__u32 ltd_index; /* index in lov_obd->tgts */
unsigned long ltd_active:1,/* is this target up for requests */
@@ -544,7 +450,7 @@ struct pool_desc {
struct lov_qos_rr pool_rr; /* round robin qos */
struct hlist_node pool_hash; /* access by poolname */
struct list_head pool_list; /* serial access */
- struct proc_dir_entry *pool_proc_entry; /* file in /proc */
+ struct dentry *pool_debugfs_entry; /* file in /proc */
struct obd_device *pool_lobd; /* obd of the lov/lod to which
* this pool belongs */
};
@@ -565,13 +471,15 @@ struct lov_obd {
int lov_pool_count;
struct cfs_hash *lov_pools_hash_body; /* used for key access */
struct list_head lov_pool_list; /* used for sequential access */
- struct proc_dir_entry *lov_pool_proc_entry;
+ struct dentry *lov_pool_debugfs_entry;
enum lustre_sec_part lov_sp_me;
/* Cached LRU pages from upper layer */
void *lov_cache;
struct rw_semaphore lov_notify_lock;
+
+ struct kobject *lov_tgts_kobj;
};
struct lmv_tgt_desc {
@@ -610,6 +518,7 @@ struct lmv_obd {
struct lmv_tgt_desc **tgts;
struct obd_connect_data conn_data;
+ struct kobject *lmv_tgts_kobj;
};
struct niobuf_local {
@@ -724,8 +633,8 @@ static inline void oti_alloc_cookies(struct obd_trans_info *oti,
if (num_cookies == 1)
oti->oti_logcookies = &oti->oti_onecookie;
else
- OBD_ALLOC_LARGE(oti->oti_logcookies,
- num_cookies * sizeof(oti->oti_onecookie));
+ oti->oti_logcookies = libcfs_kvzalloc(num_cookies * sizeof(oti->oti_onecookie),
+ GFP_NOFS);
oti->oti_numcookies = num_cookies;
}
@@ -738,8 +647,8 @@ static inline void oti_free_cookies(struct obd_trans_info *oti)
if (oti->oti_logcookies == &oti->oti_onecookie)
LASSERT(oti->oti_numcookies == 1);
else
- OBD_FREE_LARGE(oti->oti_logcookies,
- oti->oti_numcookies*sizeof(oti->oti_onecookie));
+ kvfree(oti->oti_logcookies);
+
oti->oti_logcookies = NULL;
oti->oti_numcookies = 0;
}
@@ -818,8 +727,6 @@ struct obd_device {
/* bitfield modification is protected by obd_dev_lock */
unsigned long obd_attached:1, /* finished attach */
obd_set_up:1, /* finished setup */
- obd_recovering:1, /* there are recoverable clients */
- obd_abort_recovery:1,/* recovery expired */
obd_version_recov:1, /* obd uses version checking */
obd_replayable:1, /* recovery is enabled; inform clients */
obd_no_transno:1, /* no committed-transno notification */
@@ -839,11 +746,6 @@ struct obd_device {
unsigned long obd_recovery_expired:1;
/* uuid-export hash body */
struct cfs_hash *obd_uuid_hash;
- /* nid-export hash body */
- struct cfs_hash *obd_nid_hash;
- /* nid stats body */
- struct cfs_hash *obd_nid_stats_hash;
- struct list_head obd_nid_stats;
atomic_t obd_refcount;
wait_queue_head_t obd_refcount_waitq;
struct list_head obd_exports;
@@ -866,39 +768,6 @@ struct obd_device {
struct rw_semaphore obd_observer_link_sem;
struct obd_notify_upcall obd_upcall;
struct obd_export *obd_self_export;
- /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
- struct list_head obd_exports_timed;
- time_t obd_eviction_timer; /* for ping evictor */
-
- int obd_max_recoverable_clients;
- atomic_t obd_connected_clients;
- int obd_stale_clients;
- int obd_delayed_clients;
- /* this lock protects all recovery list_heads, timer and
- * obd_next_recovery_transno value */
- spinlock_t obd_recovery_task_lock;
- __u64 obd_next_recovery_transno;
- int obd_replayed_requests;
- int obd_requests_queued_for_recovery;
- wait_queue_head_t obd_next_transno_waitq;
- /* protected by obd_recovery_task_lock */
- struct timer_list obd_recovery_timer;
- time_t obd_recovery_start; /* seconds */
- time_t obd_recovery_end; /* seconds, for lprocfs_status */
- int obd_recovery_time_hard;
- int obd_recovery_timeout;
- int obd_recovery_ir_factor;
-
- /* new recovery stuff from CMD2 */
- struct target_recovery_data obd_recovery_data;
- int obd_replayed_locks;
- atomic_t obd_req_replay_clients;
- atomic_t obd_lock_replay_clients;
- /* all lists are protected by obd_recovery_task_lock */
- struct list_head obd_req_replay_queue;
- struct list_head obd_lock_replay_queue;
- struct list_head obd_final_req_queue;
- int obd_recovery_stage;
union {
struct client_obd cli;
@@ -913,10 +782,8 @@ struct obd_device {
unsigned int md_cntr_base;
struct lprocfs_stats *md_stats;
- struct proc_dir_entry *obd_proc_entry;
- void *obd_proc_private; /* type private PDEs */
- struct proc_dir_entry *obd_proc_exports_entry;
- struct proc_dir_entry *obd_svc_procroot;
+ struct dentry *obd_debugfs_entry;
+ struct dentry *obd_svc_debugfs_entry;
struct lprocfs_stats *obd_svc_stats;
atomic_t obd_evict_inprogress;
wait_queue_head_t obd_evict_inprogress_waitq;
@@ -936,6 +803,9 @@ struct obd_device {
struct lu_ref obd_reference;
int obd_conn_inprogress;
+
+ struct kobject obd_kobj; /* sysfs object */
+ struct completion obd_kobj_unregister;
};
#define OBD_LLOG_FL_SENDNOW 0x0001
@@ -952,7 +822,6 @@ enum obd_cleanup_stage {
#define KEY_ASYNC "async"
#define KEY_BLOCKSIZE_BITS "blocksize_bits"
#define KEY_BLOCKSIZE "blocksize"
-#define KEY_CAPA_KEY "capa_key"
#define KEY_CHANGELOG_CLEAR "changelog_clear"
#define KEY_FID2PATH "fid2path"
#define KEY_CHECKSUM "checksum"
@@ -973,8 +842,6 @@ enum obd_cleanup_stage {
#define KEY_LOV_IDX "lov_idx"
#define KEY_MAX_EASIZE "max_easize"
#define KEY_DEFAULT_EASIZE "default_easize"
-#define KEY_MAX_COOKIESIZE "max_cookiesize"
-#define KEY_DEFAULT_COOKIESIZE "default_cookiesize"
#define KEY_MDS_CONN "mds_conn"
#define KEY_MGSSEC "mgssec"
#define KEY_NEXT_ID "next_id"
@@ -1055,10 +922,6 @@ struct md_op_data {
__u64 op_ioepoch;
__u32 op_flags;
- /* Capa fields */
- struct obd_capa *op_capa1;
- struct obd_capa *op_capa2;
-
/* Various operation flags. */
enum mds_op_bias op_bias;
@@ -1159,14 +1022,12 @@ struct obd_ops {
struct lov_stripe_md **mem_tgt,
struct lov_mds_md *disk_src, int disk_len);
int (*o_preallocate)(struct lustre_handle *, u32 *req, u64 *ids);
- /* FIXME: add fid capability support for create & destroy! */
int (*o_create)(const struct lu_env *env, struct obd_export *exp,
struct obdo *oa, struct lov_stripe_md **ea,
struct obd_trans_info *oti);
int (*o_destroy)(const struct lu_env *env, struct obd_export *exp,
struct obdo *oa, struct lov_stripe_md *ea,
- struct obd_trans_info *oti, struct obd_export *md_exp,
- void *capa);
+ struct obd_trans_info *oti, struct obd_export *md_exp);
int (*o_setattr)(const struct lu_env *, struct obd_export *exp,
struct obd_info *oinfo, struct obd_trans_info *oti);
int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
@@ -1182,7 +1043,7 @@ struct obd_ops {
struct obd_export *exp, struct obdo *oa, int objcount,
struct obd_ioobj *obj, struct niobuf_remote *remote,
int *nr_pages, struct niobuf_local *local,
- struct obd_trans_info *oti, struct lustre_capa *capa);
+ struct obd_trans_info *oti);
int (*o_commitrw)(const struct lu_env *env, int cmd,
struct obd_export *exp, struct obdo *oa,
int objcount, struct obd_ioobj *obj,
@@ -1250,8 +1111,6 @@ struct lustre_md {
struct posix_acl *posix_acl;
#endif
struct mdt_remote_perm *remote_perm;
- struct obd_capa *mds_capa;
- struct obd_capa *oss_capa;
};
struct md_open_data {
@@ -1265,8 +1124,7 @@ struct md_open_data {
struct lookup_intent;
struct md_ops {
- int (*m_getstatus)(struct obd_export *, struct lu_fid *,
- struct obd_capa **);
+ int (*m_getstatus)(struct obd_export *, struct lu_fid *);
int (*m_null_inode)(struct obd_export *, const struct lu_fid *);
int (*m_find_cbdata)(struct obd_export *, const struct lu_fid *,
ldlm_iterator_t, void *);
@@ -1298,10 +1156,10 @@ struct md_ops {
const struct lu_fid *,
struct ptlrpc_request **);
int (*m_setattr)(struct obd_export *, struct md_op_data *, void *,
- int , void *, int, struct ptlrpc_request **,
+ int, void *, int, struct ptlrpc_request **,
struct md_open_data **mod);
int (*m_sync)(struct obd_export *, const struct lu_fid *,
- struct obd_capa *, struct ptlrpc_request **);
+ struct ptlrpc_request **);
int (*m_readpage)(struct obd_export *, struct md_op_data *,
struct page **, struct ptlrpc_request **);
@@ -1309,13 +1167,11 @@ struct md_ops {
struct ptlrpc_request **);
int (*m_setxattr)(struct obd_export *, const struct lu_fid *,
- struct obd_capa *, u64, const char *,
- const char *, int, int, int, __u32,
+ u64, const char *, const char *, int, int, int, __u32,
struct ptlrpc_request **);
int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
- struct obd_capa *, u64, const char *,
- const char *, int, int, int,
+ u64, const char *, const char *, int, int, int,
struct ptlrpc_request **);
int (*m_init_ea_size)(struct obd_export *, int, int, int, int);
@@ -1341,14 +1197,9 @@ struct md_ops {
int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
ldlm_policy_data_t *, ldlm_mode_t,
ldlm_cancel_flags_t flags, void *opaque);
- int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
- renew_capa_cb_t cb);
- int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *,
- const struct req_msg_field *, struct obd_capa **);
int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
- struct obd_capa *, __u32,
- struct ptlrpc_request **);
+ __u32, struct ptlrpc_request **);
int (*m_intent_getattr_async)(struct obd_export *,
struct md_enqueue_info *,
@@ -1397,16 +1248,11 @@ static inline const struct lsm_operations *lsm_op_find(int magic)
#define OBD_CALC_STRIPE_START 1
#define OBD_CALC_STRIPE_END 2
-static inline struct lustre_capa *oinfo_capa(struct obd_info *oinfo)
-{
- return oinfo->oi_capa;
-}
-
static inline struct md_open_data *obd_mod_alloc(void)
{
struct md_open_data *mod;
- OBD_ALLOC_PTR(mod);
+ mod = kzalloc(sizeof(*mod), GFP_NOFS);
if (mod == NULL)
return NULL;
atomic_set(&mod->mod_refcount, 1);
@@ -1419,7 +1265,7 @@ static inline struct md_open_data *obd_mod_alloc(void)
if (atomic_dec_and_test(&(mod)->mod_refcount)) { \
if ((mod)->mod_open_req) \
ptlrpc_req_finished((mod)->mod_open_req); \
- OBD_FREE_PTR(mod); \
+ kfree(mod); \
} \
})
@@ -1470,7 +1316,7 @@ static inline bool filename_is_volatile(const char *name, int namelen, int *idx)
}
/* we have an idx, read it */
start = name + LUSTRE_VOLATILE_HDR_LEN + 1;
- *idx = strtoul(start, &end, 0);
+ *idx = simple_strtoul(start, &end, 0);
/* error cases:
* no digit, no trailing :, negative value
*/
diff --git a/kernel/drivers/staging/lustre/lustre/include/obd_cache.h b/kernel/drivers/staging/lustre/lustre/include/obd_cache.h
deleted file mode 100644
index c8249fbb0..000000000
--- a/kernel/drivers/staging/lustre/lustre/include/obd_cache.h
+++ /dev/null
@@ -1,39 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef _OBD_CACHE_H__
-#define _OBD_CACHE_H__
-
-
-#endif
diff --git a/kernel/drivers/staging/lustre/lustre/include/obd_cksum.h b/kernel/drivers/staging/lustre/lustre/include/obd_cksum.h
index 3a63462aa..a0099d717 100644
--- a/kernel/drivers/staging/lustre/lustre/include/obd_cksum.h
+++ b/kernel/drivers/staging/lustre/lustre/include/obd_cksum.h
@@ -156,7 +156,6 @@ static inline cksum_type_t cksum_types_supported_server(void)
return ret;
}
-
/* Select the best checksum algorithm among those supplied in the cksum_types
* input.
*
diff --git a/kernel/drivers/staging/lustre/lustre/include/obd_class.h b/kernel/drivers/staging/lustre/lustre/include/obd_class.h
index 34b5fa3f0..fd5f3731d 100644
--- a/kernel/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/kernel/drivers/staging/lustre/lustre/include/obd_class.h
@@ -36,7 +36,6 @@
#ifndef __CLASS_OBD_H
#define __CLASS_OBD_H
-
#include "obd_support.h"
#include "lustre_import.h"
#include "lustre_net.h"
@@ -64,10 +63,9 @@ extern struct obd_device *obd_devs[MAX_OBD_DEVICES];
extern rwlock_t obd_dev_lock;
/* OBD Operations Declarations */
-extern struct obd_device *class_conn2obd(struct lustre_handle *);
-extern struct obd_device *class_exp2obd(struct obd_export *);
-extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
-extern int lustre_get_jobid(char *jobid);
+struct obd_device *class_exp2obd(struct obd_export *);
+int class_handle_ioctl(unsigned int cmd, unsigned long arg);
+int lustre_get_jobid(char *jobid);
struct lu_device_type;
@@ -75,8 +73,7 @@ struct lu_device_type;
extern struct list_head obd_types;
struct obd_export *class_conn2export(struct lustre_handle *);
int class_register_type(struct obd_ops *, struct md_ops *,
- struct lprocfs_vars *, const char *nm,
- struct lu_device_type *ldt);
+ const char *nm, struct lu_device_type *ldt);
int class_unregister_type(const char *nm);
struct obd_device *class_newdev(const char *type_name, const char *name);
@@ -85,69 +82,40 @@ void class_release_dev(struct obd_device *obd);
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_uuid2obd(struct obd_uuid *uuid);
-void class_obd_list(void);
struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
const char *typ_name,
struct obd_uuid *grp_uuid);
struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid,
int *next);
struct obd_device *class_num2obd(int num);
-int get_devices_count(void);
int class_notify_sptlrpc_conf(const char *fsname, int namelen);
-char *obd_export_nid2str(struct obd_export *exp);
-
-int obd_export_evict_by_nid(struct obd_device *obd, const char *nid);
-int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid);
int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep);
int obd_zombie_impexp_init(void);
void obd_zombie_impexp_stop(void);
-void obd_zombie_impexp_cull(void);
void obd_zombie_barrier(void);
-void obd_exports_barrier(struct obd_device *obd);
-int kuc_len(int payload_len);
-struct kuc_hdr *kuc_ptr(void *p);
-int kuc_ispayload(void *p);
-void *kuc_alloc(int payload_len, int transport, int type);
-void kuc_free(void *p, int payload_len);
struct llog_handle;
struct llog_rec_hdr;
typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
struct llog_rec_hdr *, void *);
/* obd_config.c */
-struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
- const char *new_name);
int class_process_config(struct lustre_cfg *lcfg);
int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
struct lustre_cfg *lcfg, void *data);
-int class_attach(struct lustre_cfg *lcfg);
-int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
-int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
-int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
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);
-void dump_exports(struct obd_device *obd, int locks);
int class_config_llog_handler(const struct lu_env *env,
struct llog_handle *handle,
struct llog_rec_hdr *rec, void *data);
-int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
int class_add_uuid(const char *uuid, __u64 nid);
/*obdecho*/
-#if defined (CONFIG_PROC_FS)
-extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
+void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);
#define CFG_F_START 0x01 /* Set when we start updating from a log */
#define CFG_F_MARKER 0x02 /* We are within a maker */
@@ -165,11 +133,9 @@ struct config_llog_instance {
int cfg_last_idx; /* for partial llog processing */
int cfg_flags;
};
+
int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
char *name, struct config_llog_instance *cfg);
-int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
- char *name, struct config_llog_instance *cfg);
-
enum {
CONFIG_T_CONFIG = 0,
CONFIG_T_SPTLRPC = 1,
@@ -223,6 +189,25 @@ extern void (*class_export_dump_hook)(struct obd_export *);
#endif
+/* genops.c */
+struct obd_export *class_export_get(struct obd_export *exp);
+void class_export_put(struct obd_export *exp);
+struct obd_export *class_new_export(struct obd_device *obddev,
+ struct obd_uuid *cluuid);
+void class_unlink_export(struct obd_export *exp);
+
+struct obd_import *class_import_get(struct obd_import *);
+void class_import_put(struct obd_import *);
+struct obd_import *class_new_import(struct obd_device *obd);
+void class_destroy_import(struct obd_import *exp);
+
+void class_put_type(struct obd_type *type);
+int class_connect(struct lustre_handle *conn, struct obd_device *obd,
+ struct obd_uuid *cluuid);
+int class_disconnect(struct obd_export *exp);
+void class_fail_export(struct obd_export *exp);
+int class_manual_cleanup(struct obd_device *obd);
+
static inline void class_export_rpc_inc(struct obd_export *exp)
{
atomic_inc(&(exp)->exp_rpc_count);
@@ -238,93 +223,51 @@ static inline void class_export_rpc_dec(struct obd_export *exp)
(exp), atomic_read(&(exp)->exp_rpc_count));
}
-#define class_export_lock_get(exp, lock) \
-({ \
- atomic_inc(&(exp)->exp_locks_count); \
- __class_export_add_lock_ref(exp, lock); \
- CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \
- (exp), atomic_read(&(exp)->exp_locks_count)); \
- class_export_get(exp); \
-})
-
-#define class_export_lock_put(exp, lock) \
-({ \
- LASSERT_ATOMIC_POS(&exp->exp_locks_count); \
- atomic_dec(&(exp)->exp_locks_count); \
- __class_export_del_lock_ref(exp, lock); \
- CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \
- (exp), atomic_read(&(exp)->exp_locks_count)); \
- class_export_put(exp); \
-})
-
-#define class_export_cb_get(exp) \
-({ \
- atomic_inc(&(exp)->exp_cb_count); \
- CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\
- (exp), atomic_read(&(exp)->exp_cb_count)); \
- class_export_get(exp); \
-})
-
-#define class_export_cb_put(exp) \
-({ \
- LASSERT_ATOMIC_POS(&exp->exp_cb_count); \
- atomic_dec(&(exp)->exp_cb_count); \
- CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\
- (exp), atomic_read(&(exp)->exp_cb_count)); \
- class_export_put(exp); \
-})
-
-/* genops.c */
-struct obd_export *class_export_get(struct obd_export *exp);
-void class_export_put(struct obd_export *exp);
-struct obd_export *class_new_export(struct obd_device *obddev,
- struct obd_uuid *cluuid);
-void class_unlink_export(struct obd_export *exp);
+static inline struct obd_export *class_export_lock_get(struct obd_export *exp,
+ struct ldlm_lock *lock)
+{
+ atomic_inc(&(exp)->exp_locks_count);
+ __class_export_add_lock_ref(exp, lock);
+ CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n",
+ (exp), atomic_read(&(exp)->exp_locks_count));
+ return class_export_get(exp);
+}
-struct obd_import *class_import_get(struct obd_import *);
-void class_import_put(struct obd_import *);
-struct obd_import *class_new_import(struct obd_device *obd);
-void class_destroy_import(struct obd_import *exp);
+static inline void class_export_lock_put(struct obd_export *exp,
+ struct ldlm_lock *lock)
+{
+ LASSERT_ATOMIC_POS(&exp->exp_locks_count);
+ atomic_dec(&(exp)->exp_locks_count);
+ __class_export_del_lock_ref(exp, lock);
+ CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n",
+ (exp), atomic_read(&(exp)->exp_locks_count));
+ class_export_put(exp);
+}
-struct obd_type *class_search_type(const char *name);
-struct obd_type *class_get_type(const char *name);
-void class_put_type(struct obd_type *type);
-int class_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid);
-int class_disconnect(struct obd_export *exp);
-void class_fail_export(struct obd_export *exp);
-int class_connected_export(struct obd_export *exp);
-void class_disconnect_exports(struct obd_device *obddev);
-int class_manual_cleanup(struct obd_device *obd);
-void class_disconnect_stale_exports(struct obd_device *,
- int (*test_export)(struct obd_export *));
static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
{
return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
(obd->obd_force ? OBD_OPT_FORCE : 0) |
- (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) |
0);
}
+static inline int lprocfs_climp_check(struct obd_device *obd)
+{
+ down_read(&(obd)->u.cli.cl_sem);
+ if (!(obd)->u.cli.cl_import) {
+ up_read(&(obd)->u.cli.cl_sem);
+ return -ENODEV;
+ }
+ return 0;
+}
+
struct inode;
struct lu_attr;
struct obdo;
-void obdo_from_la(struct obdo *dst, struct lu_attr *la, __u64 valid);
-void la_from_obdo(struct lu_attr *la, struct obdo *dst, u32 valid);
void obdo_refresh_inode(struct inode *dst, struct obdo *src, u32 valid);
-void obdo_to_inode(struct inode *dst, struct obdo *src, u32 valid);
-void obdo_cpy_md(struct obdo *dst, struct obdo *src, u32 valid);
void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj);
-void obdo_from_iattr(struct obdo *oa, struct iattr *attr,
- unsigned int ia_valid);
-void iattr_from_obdo(struct iattr *attr, struct obdo *oa, u32 valid);
void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, u32 valid);
-void obdo_from_md(struct obdo *oa, struct md_op_data *op_data,
- unsigned int valid);
-
-void obdo_cpu_to_le(struct obdo *dobdo, struct obdo *sobdo);
-void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo);
#define OBT(dev) (dev)->obd_type
#define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op
@@ -357,7 +300,6 @@ static inline int obd_check_dev_active(struct obd_device *obd)
return rc;
}
-#if defined (CONFIG_PROC_FS)
#define OBD_COUNTER_OFFSET(op) \
((offsetof(struct obd_ops, o_ ## op) - \
offsetof(struct obd_ops, o_iocontrol)) \
@@ -379,10 +321,6 @@ static inline int obd_check_dev_active(struct obd_device *obd)
OBD_COUNTER_OFFSET(op); \
LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \
lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \
- if ((export)->exp_nid_stats != NULL && \
- (export)->exp_nid_stats->nid_stats != NULL) \
- lprocfs_counter_incr( \
- (export)->exp_nid_stats->nid_stats, coffset);\
}
#define MD_COUNTER_OFFSET(op) \
@@ -411,38 +349,6 @@ static inline int obd_check_dev_active(struct obd_device *obd)
(export)->exp_md_stats, coffset); \
}
-#else
-#define OBD_COUNTER_OFFSET(op)
-#define OBD_COUNTER_INCREMENT(obd, op)
-#define EXP_COUNTER_INCREMENT(exp, op)
-#define MD_COUNTER_INCREMENT(obd, op)
-#define EXP_MD_COUNTER_INCREMENT(exp, op)
-#endif
-
-static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp)
-{
- /* Always add in ldlm_stats */
- tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC
- ,LPROCFS_STATS_FLAG_NOPERCPU);
- if (tmp->nid_ldlm_stats == NULL)
- return -ENOMEM;
-
- lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
-
- return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats",
- tmp->nid_ldlm_stats);
-}
-
-#define OBD_CHECK_MD_OP(obd, op, err) \
-do { \
- if (!OBT(obd) || !MDP((obd), op)) { \
- if (err) \
- CERROR("md_" #op ": dev %s/%d no operation\n", \
- obd->obd_name, obd->obd_minor); \
- return err; \
- } \
-} while (0)
-
#define EXP_CHECK_MD_OP(exp, op) \
do { \
if ((exp) == NULL) { \
@@ -461,7 +367,6 @@ do { \
} \
} while (0)
-
#define OBD_CHECK_DT_OP(obd, op, err) \
do { \
if (!OBT(obd) || !OBP((obd), op)) { \
@@ -565,6 +470,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
if (ldt != NULL) {
struct lu_context session_ctx;
struct lu_env env;
+
lu_context_init(&session_ctx, LCT_SESSION);
session_ctx.lc_thread = NULL;
lu_context_enter(&session_ctx);
@@ -656,14 +562,11 @@ static inline void obd_cleanup_client_import(struct obd_device *obd)
down_write(&obd->u.cli.cl_sem);
if (obd->u.cli.cl_import) {
struct obd_import *imp;
+
imp = obd->u.cli.cl_import;
CDEBUG(D_CONFIG, "%s: client import never connected\n",
obd->obd_name);
ptlrpc_invalidate_import(imp);
- if (imp->imp_rq_pool) {
- ptlrpc_free_rq_pool(imp->imp_rq_pool);
- imp->imp_rq_pool = NULL;
- }
client_destroy_import(imp);
obd->u.cli.cl_import = NULL;
}
@@ -803,14 +706,14 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp,
static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp,
struct obdo *obdo, struct lov_stripe_md *ea,
struct obd_trans_info *oti,
- struct obd_export *md_exp, void *capa)
+ struct obd_export *md_exp)
{
int rc;
EXP_CHECK_DT_OP(exp, destroy);
EXP_COUNTER_INCREMENT(exp, destroy);
- rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp, capa);
+ rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp);
return rc;
}
@@ -1152,7 +1055,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
__u32 flags)
{
struct ptlrpc_request_set *set = NULL;
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info oinfo = { };
int rc = 0;
set = ptlrpc_prep_set();
@@ -1211,8 +1114,7 @@ static inline int obd_preprw(const struct lu_env *env, int cmd,
int objcount, struct obd_ioobj *obj,
struct niobuf_remote *remote, int *pages,
struct niobuf_local *local,
- struct obd_trans_info *oti,
- struct lustre_capa *capa)
+ struct obd_trans_info *oti)
{
int rc;
@@ -1220,7 +1122,7 @@ static inline int obd_preprw(const struct lu_env *env, int cmd,
EXP_COUNTER_INCREMENT(exp, preprw);
rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote,
- pages, local, oti, capa);
+ pages, local, oti);
return rc;
}
@@ -1468,14 +1370,13 @@ static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp,
#endif
/* metadata helpers */
-static inline int md_getstatus(struct obd_export *exp,
- struct lu_fid *fid, struct obd_capa **pc)
+static inline int md_getstatus(struct obd_export *exp, struct lu_fid *fid)
{
int rc;
EXP_CHECK_MD_OP(exp, getstatus);
EXP_MD_COUNTER_INCREMENT(exp, getstatus);
- rc = MDP(exp->exp_obd, getstatus)(exp, fid, pc);
+ rc = MDP(exp->exp_obd, getstatus)(exp, fid);
return rc;
}
@@ -1650,13 +1551,13 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,
}
static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, struct ptlrpc_request **request)
+ struct ptlrpc_request **request)
{
int rc;
EXP_CHECK_MD_OP(exp, sync);
EXP_MD_COUNTER_INCREMENT(exp, sync);
- rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request);
+ rc = MDP(exp->exp_obd, sync)(exp, fid, request);
return rc;
}
@@ -1702,8 +1603,7 @@ static inline int md_free_lustre_md(struct obd_export *exp,
return MDP(exp->exp_obd, free_lustre_md)(exp, md);
}
-static inline int md_setxattr(struct obd_export *exp,
- const struct lu_fid *fid, struct obd_capa *oc,
+static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
u64 valid, const char *name,
const char *input, int input_size,
int output_size, int flags, __u32 suppgid,
@@ -1711,13 +1611,12 @@ static inline int md_setxattr(struct obd_export *exp,
{
EXP_CHECK_MD_OP(exp, setxattr);
EXP_MD_COUNTER_INCREMENT(exp, setxattr);
- return MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input,
+ return MDP(exp->exp_obd, setxattr)(exp, fid, valid, name, input,
input_size, output_size, flags,
suppgid, request);
}
-static inline int md_getxattr(struct obd_export *exp,
- const struct lu_fid *fid, struct obd_capa *oc,
+static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
u64 valid, const char *name,
const char *input, int input_size,
int output_size, int flags,
@@ -1725,7 +1624,7 @@ static inline int md_getxattr(struct obd_export *exp,
{
EXP_CHECK_MD_OP(exp, getxattr);
EXP_MD_COUNTER_INCREMENT(exp, getxattr);
- return MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input,
+ return MDP(exp->exp_obd, getxattr)(exp, fid, valid, name, input,
input_size, output_size, flags,
request);
}
@@ -1796,40 +1695,15 @@ static inline int md_init_ea_size(struct obd_export *exp, int easize,
}
static inline int md_get_remote_perm(struct obd_export *exp,
- const struct lu_fid *fid,
- struct obd_capa *oc, __u32 suppgid,
+ const struct lu_fid *fid, __u32 suppgid,
struct ptlrpc_request **request)
{
EXP_CHECK_MD_OP(exp, get_remote_perm);
EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm);
- return MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid,
+ return MDP(exp->exp_obd, get_remote_perm)(exp, fid, suppgid,
request);
}
-static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa,
- renew_capa_cb_t cb)
-{
- int rc;
-
- EXP_CHECK_MD_OP(exp, renew_capa);
- EXP_MD_COUNTER_INCREMENT(exp, renew_capa);
- rc = MDP(exp->exp_obd, renew_capa)(exp, ocapa, cb);
- return rc;
-}
-
-static inline int md_unpack_capa(struct obd_export *exp,
- struct ptlrpc_request *req,
- const struct req_msg_field *field,
- struct obd_capa **oc)
-{
- int rc;
-
- EXP_CHECK_MD_OP(exp, unpack_capa);
- EXP_MD_COUNTER_INCREMENT(exp, unpack_capa);
- rc = MDP(exp->exp_obd, unpack_capa)(exp, req, field, oc);
- return rc;
-}
-
static inline int md_intent_getattr_async(struct obd_export *exp,
struct md_enqueue_info *minfo,
struct ldlm_enqueue_info *einfo)
@@ -1854,26 +1728,14 @@ static inline int md_revalidate_lock(struct obd_export *exp,
return rc;
}
-
/* OBD Metadata Support */
-extern int obd_init_caches(void);
-extern void obd_cleanup_caches(void);
+int obd_init_caches(void);
+void obd_cleanup_caches(void);
/* support routines */
extern struct kmem_cache *obdo_cachep;
-#define OBDO_ALLOC(ptr) \
-do { \
- OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \
-} while (0)
-
-#define OBDO_FREE(ptr) \
-do { \
- OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \
-} while (0)
-
-
static inline void obdo2fid(struct obdo *oa, struct lu_fid *fid)
{
/* something here */
@@ -1903,8 +1765,7 @@ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
/* obd_mount.c */
/* sysctl.c */
-extern void obd_sysctl_init (void);
-extern void obd_sysctl_clean (void);
+int obd_sysctl_init(void);
/* uuid.c */
typedef __u8 class_uuid_t[16];
diff --git a/kernel/drivers/staging/lustre/lustre/include/obd_support.h b/kernel/drivers/staging/lustre/lustre/include/obd_support.h
index 2991d2ee7..a22a5308f 100644
--- a/kernel/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/kernel/drivers/staging/lustre/lustre/include/obd_support.h
@@ -43,22 +43,13 @@
#include "lprocfs_status.h"
/* global variables */
-extern struct lprocfs_stats *obd_memory;
-enum {
- OBD_MEMORY_STAT = 0,
- OBD_MEMORY_PAGES_STAT = 1,
- OBD_STATS_NUM,
-};
-
extern unsigned int obd_debug_peer_on_timeout;
extern unsigned int obd_dump_on_timeout;
extern unsigned int obd_dump_on_eviction;
/* obd_timeout should only be used for recovery, not for
networking / disk / timings affected by load (use Adaptive Timeouts) */
extern unsigned int obd_timeout; /* seconds */
-extern unsigned int ldlm_timeout; /* seconds */
extern unsigned int obd_timeout_set;
-extern unsigned int ldlm_timeout_set;
extern unsigned int at_min;
extern unsigned int at_max;
extern unsigned int at_history;
@@ -68,13 +59,8 @@ extern unsigned int obd_sync_filter;
extern unsigned int obd_max_dirty_pages;
extern atomic_t obd_dirty_pages;
extern atomic_t obd_dirty_transit_pages;
-extern unsigned int obd_alloc_fail_rate;
extern char obd_jobid_var[];
-/* lvfs.c */
-int obd_alloc_fail(const void *ptr, const char *name, const char *type,
- size_t size, const char *file, int line);
-
/* Some hash init argument constants */
#define HASH_POOLS_BKT_BITS 3
#define HASH_POOLS_CUR_BITS 3
@@ -105,8 +91,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
/* Timeout definitions */
#define OBD_TIMEOUT_DEFAULT 100
-#define LDLM_TIMEOUT_DEFAULT 20
-#define MDS_LDLM_TIMEOUT_DEFAULT 6
/* Time to wait for all clients to reconnect during recovery (hard limit) */
#define OBD_RECOVERY_TIME_HARD (obd_timeout * 9)
/* Time to wait for all clients to reconnect during recovery (soft limit) */
@@ -432,8 +416,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
#define OBD_FAIL_LPROC_REMOVE 0xB00
-#define OBD_FAIL_GENERAL_ALLOC 0xC00
-
#define OBD_FAIL_SEQ 0x1000
#define OBD_FAIL_SEQ_QUERY_NET 0x1001
#define OBD_FAIL_SEQ_EXHAUST 0x1002
@@ -490,7 +472,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
#define OBD_FAIL_UPDATE_OBJ_NET 0x1700
#define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
-
/* Assign references to moved code to reduce code changes */
#define OBD_FAIL_PRECHECK(id) CFS_FAIL_PRECHECK(id)
#define OBD_FAIL_CHECK(id) CFS_FAIL_CHECK(id)
@@ -505,211 +486,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
#define OBD_FAIL_ONCE CFS_FAIL_ONCE
#define OBD_FAILED CFS_FAILED
-extern atomic_t libcfs_kmemory;
-
-extern void obd_update_maxusage(void);
-
-#if defined (CONFIG_PROC_FS)
-#define obd_memory_add(size) \
- lprocfs_counter_add(obd_memory, OBD_MEMORY_STAT, (long)(size))
-#define obd_memory_sub(size) \
- lprocfs_counter_sub(obd_memory, OBD_MEMORY_STAT, (long)(size))
-#define obd_memory_sum() \
- lprocfs_stats_collector(obd_memory, OBD_MEMORY_STAT, \
- LPROCFS_FIELDS_FLAGS_SUM)
-#define obd_pages_add(order) \
- lprocfs_counter_add(obd_memory, OBD_MEMORY_PAGES_STAT, \
- (long)(1 << (order)))
-#define obd_pages_sub(order) \
- lprocfs_counter_sub(obd_memory, OBD_MEMORY_PAGES_STAT, \
- (long)(1 << (order)))
-#define obd_pages_sum() \
- lprocfs_stats_collector(obd_memory, OBD_MEMORY_PAGES_STAT, \
- LPROCFS_FIELDS_FLAGS_SUM)
-
-extern __u64 obd_memory_max(void);
-extern __u64 obd_pages_max(void);
-
-#else
-
-extern __u64 obd_alloc;
-extern __u64 obd_pages;
-
-extern __u64 obd_max_alloc;
-extern __u64 obd_max_pages;
-
-static inline void obd_memory_add(long size)
-{
- obd_alloc += size;
- if (obd_alloc > obd_max_alloc)
- obd_max_alloc = obd_alloc;
-}
-
-static inline void obd_memory_sub(long size)
-{
- obd_alloc -= size;
-}
-
-static inline void obd_pages_add(int order)
-{
- obd_pages += 1<< order;
- if (obd_pages > obd_max_pages)
- obd_max_pages = obd_pages;
-}
-
-static inline void obd_pages_sub(int order)
-{
- obd_pages -= 1<< order;
-}
-
-#define obd_memory_sum() (obd_alloc)
-#define obd_pages_sum() (obd_pages)
-
-#define obd_memory_max() (obd_max_alloc)
-#define obd_pages_max() (obd_max_pages)
-
-#endif
-
-#define OBD_DEBUG_MEMUSAGE (1)
-
-#if OBD_DEBUG_MEMUSAGE
-#define OBD_ALLOC_POST(ptr, size, name) \
- obd_memory_add(size); \
- CDEBUG(D_MALLOC, name " '" #ptr "': %d at %p.\n", \
- (int)(size), ptr)
-
-#define OBD_FREE_PRE(ptr, size, name) \
- LASSERT(ptr); \
- obd_memory_sub(size); \
- CDEBUG(D_MALLOC, name " '" #ptr "': %d at %p.\n", \
- (int)(size), ptr); \
- POISON(ptr, 0x5a, size)
-
-#else /* !OBD_DEBUG_MEMUSAGE */
-
-#define OBD_ALLOC_POST(ptr, size, name) ((void)0)
-#define OBD_FREE_PRE(ptr, size, name) ((void)0)
-
-#endif /* !OBD_DEBUG_MEMUSAGE */
-
-#define HAS_FAIL_ALLOC_FLAG OBD_FAIL_CHECK(OBD_FAIL_GENERAL_ALLOC)
-
-#define OBD_ALLOC_FAIL_BITS 24
-#define OBD_ALLOC_FAIL_MASK ((1 << OBD_ALLOC_FAIL_BITS) - 1)
-#define OBD_ALLOC_FAIL_MULT (OBD_ALLOC_FAIL_MASK / 100)
-
-#if defined(LUSTRE_UTILS) /* this version is for utils only */
-#define __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, flags) \
-do { \
- (ptr) = (cptab) == NULL ? \
- kmalloc(size, flags) : \
- kmalloc_node(size, flags, cfs_cpt_spread_node(cptab, cpt)); \
- if (unlikely((ptr) == NULL)) { \
- CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
- (int)(size), __FILE__, __LINE__); \
- } else { \
- memset(ptr, 0, size); \
- CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p\n", \
- (int)(size), ptr); \
- } \
-} while (0)
-
-#else /* this version is for the kernel and liblustre */
-#define OBD_FREE_RTN0(ptr) \
-({ \
- kfree(ptr); \
- (ptr) = NULL; \
- 0; \
-})
-
-#define __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, flags) \
-do { \
- (ptr) = (cptab) == NULL ? \
- kmalloc(size, flags | __GFP_ZERO) : \
- kmalloc_node(size, flags | __GFP_ZERO, \
- cfs_cpt_spread_node(cptab, cpt)); \
- if (likely((ptr) != NULL && \
- (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 || \
- !obd_alloc_fail(ptr, #ptr, "km", size, \
- __FILE__, __LINE__) || \
- OBD_FREE_RTN0(ptr)))){ \
- OBD_ALLOC_POST(ptr, size, "kmalloced"); \
- } \
-} while (0)
-#endif
-
-#define OBD_ALLOC_GFP(ptr, size, gfp_mask) \
- __OBD_MALLOC_VERBOSE(ptr, NULL, 0, size, gfp_mask)
-
-#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_NOFS)
-#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_KERNEL)
-#define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof(*(ptr)))
-#define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof(*(ptr)))
-
-#define OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, gfp_mask) \
- __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, gfp_mask)
-
-#define OBD_CPT_ALLOC(ptr, cptab, cpt, size) \
- OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS)
-
-#define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt) \
- OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr)))
-
-# define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) \
-do { \
- (ptr) = cptab == NULL ? \
- vzalloc(size) : \
- vzalloc_node(size, cfs_cpt_spread_node(cptab, cpt)); \
- if (unlikely((ptr) == NULL)) { \
- CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \
- (int)(size)); \
- CERROR("%llu total bytes allocated by Lustre, %d by LNET\n", \
- obd_memory_sum(), atomic_read(&libcfs_kmemory)); \
- } else { \
- OBD_ALLOC_POST(ptr, size, "vmalloced"); \
- } \
-} while (0)
-
-# define OBD_VMALLOC(ptr, size) \
- __OBD_VMALLOC_VEROBSE(ptr, NULL, 0, size)
-# define OBD_CPT_VMALLOC(ptr, cptab, cpt, size) \
- __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size)
-
-
-/* Allocations above this size are considered too big and could not be done
- * atomically.
- *
- * Be very careful when changing this value, especially when decreasing it,
- * since vmalloc in Linux doesn't perform well on multi-cores system, calling
- * vmalloc in critical path would hurt performance badly. See LU-66.
- */
-#define OBD_ALLOC_BIG (4 * PAGE_CACHE_SIZE)
-
-#define OBD_ALLOC_LARGE(ptr, size) \
-do { \
- if (size > OBD_ALLOC_BIG) \
- OBD_VMALLOC(ptr, size); \
- else \
- OBD_ALLOC(ptr, size); \
-} while (0)
-
-#define OBD_CPT_ALLOC_LARGE(ptr, cptab, cpt, size) \
-do { \
- if (size > OBD_ALLOC_BIG) \
- OBD_CPT_VMALLOC(ptr, cptab, cpt, size); \
- else \
- OBD_CPT_ALLOC(ptr, cptab, cpt, size); \
-} while (0)
-
-#define OBD_FREE_LARGE(ptr, size) \
-do { \
- if (size > OBD_ALLOC_BIG) \
- OBD_VFREE(ptr, size); \
- else \
- OBD_FREE(ptr, size); \
-} while (0)
-
-
#ifdef CONFIG_DEBUG_SLAB
#define POISON(ptr, c, s) do {} while (0)
#define POISON_PTR(ptr) ((void)0)
@@ -719,20 +495,14 @@ do { \
#endif
#ifdef POISON_BULK
-#define POISON_PAGE(page, val) do { memset(kmap(page), val, PAGE_CACHE_SIZE); \
- kunmap(page); } while (0)
+#define POISON_PAGE(page, val) do { \
+ memset(kmap(page), val, PAGE_CACHE_SIZE); \
+ kunmap(page); \
+} while (0)
#else
#define POISON_PAGE(page, val) do { } while (0)
#endif
-#define OBD_FREE(ptr, size) \
-do { \
- OBD_FREE_PRE(ptr, size, "kfreed"); \
- kfree(ptr); \
- POISON_PTR(ptr); \
-} while (0)
-
-
#define OBD_FREE_RCU(ptr, size, handle) \
do { \
struct portals_handle *__h = (handle); \
@@ -744,119 +514,7 @@ do { \
POISON_PTR(ptr); \
} while (0)
-
-#define OBD_VFREE(ptr, size) \
- do { \
- OBD_FREE_PRE(ptr, size, "vfreed"); \
- vfree(ptr); \
- POISON_PTR(ptr); \
- } while (0)
-
-/* we memset() the slab object to 0 when allocation succeeds, so DO NOT
- * HAVE A CTOR THAT DOES ANYTHING. its work will be cleared here. we'd
- * love to assert on that, but slab.c keeps kmem_cache_s all to itself. */
-#define OBD_SLAB_FREE_RTN0(ptr, slab) \
-({ \
- kmem_cache_free((slab), (ptr)); \
- (ptr) = NULL; \
- 0; \
-})
-
-#define __OBD_SLAB_ALLOC_VERBOSE(ptr, slab, cptab, cpt, size, type) \
-do { \
- LASSERT(ergo((type) != GFP_ATOMIC, !in_interrupt())); \
- (ptr) = (cptab) == NULL ? \
- kmem_cache_alloc(slab, type | __GFP_ZERO) : \
- kmem_cache_alloc_node(slab, type | __GFP_ZERO, \
- cfs_cpt_spread_node(cptab, cpt)); \
- if (likely((ptr) != NULL && \
- (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 || \
- !obd_alloc_fail(ptr, #ptr, "slab-", size, \
- __FILE__, __LINE__) || \
- OBD_SLAB_FREE_RTN0(ptr, slab)))) { \
- OBD_ALLOC_POST(ptr, size, "slab-alloced"); \
- } \
-} while (0)
-
-#define OBD_SLAB_ALLOC_GFP(ptr, slab, size, flags) \
- __OBD_SLAB_ALLOC_VERBOSE(ptr, slab, NULL, 0, size, flags)
-#define OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, flags) \
- __OBD_SLAB_ALLOC_VERBOSE(ptr, slab, cptab, cpt, size, flags)
-
-#define OBD_FREE_PTR(ptr) OBD_FREE(ptr, sizeof(*(ptr)))
-
-#define OBD_SLAB_FREE(ptr, slab, size) \
-do { \
- OBD_FREE_PRE(ptr, size, "slab-freed"); \
- kmem_cache_free(slab, ptr); \
- POISON_PTR(ptr); \
-} while (0)
-
-#define OBD_SLAB_ALLOC(ptr, slab, size) \
- OBD_SLAB_ALLOC_GFP(ptr, slab, size, GFP_NOFS)
-
-#define OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, size) \
- OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, GFP_NOFS)
-
-#define OBD_SLAB_ALLOC_PTR(ptr, slab) \
- OBD_SLAB_ALLOC(ptr, slab, sizeof(*(ptr)))
-
-#define OBD_SLAB_CPT_ALLOC_PTR(ptr, slab, cptab, cpt) \
- OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, sizeof(*(ptr)))
-
-#define OBD_SLAB_ALLOC_PTR_GFP(ptr, slab, flags) \
- OBD_SLAB_ALLOC_GFP(ptr, slab, sizeof(*(ptr)), flags)
-
-#define OBD_SLAB_CPT_ALLOC_PTR_GFP(ptr, slab, cptab, cpt, flags) \
- OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, sizeof(*(ptr)), flags)
-
-#define OBD_SLAB_FREE_PTR(ptr, slab) \
- OBD_SLAB_FREE((ptr), (slab), sizeof(*(ptr)))
-
#define KEY_IS(str) \
(keylen >= (sizeof(str)-1) && memcmp(key, str, (sizeof(str)-1)) == 0)
-/* Wrapper for contiguous page frame allocation */
-#define __OBD_PAGE_ALLOC_VERBOSE(ptr, cptab, cpt, gfp_mask) \
-do { \
- (ptr) = (cptab) == NULL ? \
- alloc_page(gfp_mask) : \
- alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), gfp_mask, 0);\
- if (unlikely((ptr) == NULL)) { \
- CERROR("alloc_pages of '" #ptr "' %d page(s) / %llu bytes "\
- "failed\n", (int)1, \
- (__u64)(1 << PAGE_CACHE_SHIFT)); \
- CERROR("%llu total bytes and %llu total pages " \
- "(%llu bytes) allocated by Lustre, " \
- "%d total bytes by LNET\n", \
- obd_memory_sum(), \
- obd_pages_sum() << PAGE_CACHE_SHIFT, \
- obd_pages_sum(), \
- atomic_read(&libcfs_kmemory)); \
- } else { \
- obd_pages_add(0); \
- CDEBUG(D_MALLOC, "alloc_pages '" #ptr "': %d page(s) / " \
- "%llu bytes at %p.\n", \
- (int)1, \
- (__u64)(1 << PAGE_CACHE_SHIFT), ptr); \
- } \
-} while (0)
-
-#define OBD_PAGE_ALLOC(ptr, gfp_mask) \
- __OBD_PAGE_ALLOC_VERBOSE(ptr, NULL, 0, gfp_mask)
-#define OBD_PAGE_CPT_ALLOC(ptr, cptab, cpt, gfp_mask) \
- __OBD_PAGE_ALLOC_VERBOSE(ptr, cptab, cpt, gfp_mask)
-
-#define OBD_PAGE_FREE(ptr) \
-do { \
- LASSERT(ptr); \
- obd_pages_sub(0); \
- CDEBUG(D_MALLOC, "free_pages '" #ptr "': %d page(s) / %llu bytes " \
- "at %p.\n", \
- (int)1, (__u64)(1 << PAGE_CACHE_SHIFT), \
- ptr); \
- __free_page(ptr); \
- (ptr) = (void *)0xdeadbeef; \
-} while (0)
-
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/lclient/glimpse.c b/kernel/drivers/staging/lustre/lustre/lclient/glimpse.c
index b9f2bb66d..8533a1e53 100644
--- a/kernel/drivers/staging/lustre/lustre/lclient/glimpse.c
+++ b/kernel/drivers/staging/lustre/lustre/lclient/glimpse.c
@@ -73,7 +73,7 @@ blkcnt_t dirty_cnt(struct inode *inode)
struct ccc_object *vob = cl_inode2ccc(inode);
void *results[1];
- if (inode->i_mapping != NULL)
+ if (inode->i_mapping)
cnt += radix_tree_gang_lookup_tag(&inode->i_mapping->page_tree,
results, 0, 1,
PAGECACHE_TAG_DIRTY);
@@ -129,7 +129,7 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io,
current);
cio->cui_glimpse = 0;
- if (lock == NULL)
+ if (!lock)
return 0;
if (IS_ERR(lock))
@@ -255,7 +255,7 @@ int cl_local_size(struct inode *inode)
*descr = whole_file;
descr->cld_obj = clob;
lock = cl_lock_peek(env, io, descr, "localsize", current);
- if (lock != NULL) {
+ if (lock) {
cl_merge_lvb(env, inode);
cl_unuse(env, lock);
cl_lock_release(env, lock, "localsize", current);
diff --git a/kernel/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/kernel/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
index ab6cb4193..0b8e4d217 100644
--- a/kernel/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
+++ b/kernel/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
@@ -116,7 +116,7 @@ void *ccc_key_init(const struct lu_context *ctx, struct lu_context_key *key)
{
struct ccc_thread_info *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, ccc_thread_kmem, GFP_NOFS);
+ info = kmem_cache_alloc(ccc_thread_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
@@ -127,7 +127,7 @@ void ccc_key_fini(const struct lu_context *ctx,
{
struct ccc_thread_info *info = data;
- OBD_SLAB_FREE_PTR(info, ccc_thread_kmem);
+ kmem_cache_free(ccc_thread_kmem, info);
}
void *ccc_session_key_init(const struct lu_context *ctx,
@@ -135,7 +135,7 @@ void *ccc_session_key_init(const struct lu_context *ctx,
{
struct ccc_session *session;
- OBD_SLAB_ALLOC_PTR_GFP(session, ccc_session_kmem, GFP_NOFS);
+ session = kmem_cache_alloc(ccc_session_kmem, GFP_NOFS | __GFP_ZERO);
if (session == NULL)
session = ERR_PTR(-ENOMEM);
return session;
@@ -146,7 +146,7 @@ void ccc_session_key_fini(const struct lu_context *ctx,
{
struct ccc_session *session = data;
- OBD_SLAB_FREE_PTR(session, ccc_session_kmem);
+ kmem_cache_free(ccc_session_kmem, session);
}
struct lu_context_key ccc_key = {
@@ -161,7 +161,6 @@ struct lu_context_key ccc_session_key = {
.lct_fini = ccc_session_key_fini
};
-
/* type constructor/destructor: ccc_type_{init,fini,start,stop}(). */
/* LU_TYPE_INIT_FINI(ccc, &ccc_key, &ccc_session_key); */
@@ -202,8 +201,8 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env,
struct cl_site *site;
int rc;
- OBD_ALLOC_PTR(vdv);
- if (vdv == NULL)
+ vdv = kzalloc(sizeof(*vdv), GFP_NOFS);
+ if (!vdv)
return ERR_PTR(-ENOMEM);
lud = &vdv->cdv_cl.cd_lu_dev;
@@ -211,7 +210,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env,
ccc2lu_dev(vdv)->ld_ops = luops;
vdv->cdv_cl.cd_ops = clops;
- OBD_ALLOC_PTR(site);
+ site = kzalloc(sizeof(*site), GFP_NOFS);
if (site != NULL) {
rc = cl_site_init(site, &vdv->cdv_cl);
if (rc == 0)
@@ -219,7 +218,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env,
else {
LASSERT(lud->ld_site == NULL);
CERROR("Cannot init lu_site, rc %d.\n", rc);
- OBD_FREE_PTR(site);
+ kfree(site);
}
} else
rc = -ENOMEM;
@@ -239,10 +238,10 @@ struct lu_device *ccc_device_free(const struct lu_env *env,
if (d->ld_site != NULL) {
cl_site_fini(site);
- OBD_FREE_PTR(site);
+ kfree(site);
}
cl_device_fini(lu2cl_dev(d));
- OBD_FREE_PTR(vdv);
+ kfree(vdv);
return next;
}
@@ -252,7 +251,7 @@ int ccc_req_init(const struct lu_env *env, struct cl_device *dev,
struct ccc_req *vrq;
int result;
- OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, GFP_NOFS);
+ vrq = kmem_cache_alloc(ccc_req_kmem, GFP_NOFS | __GFP_ZERO);
if (vrq != NULL) {
cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops);
result = 0;
@@ -328,7 +327,7 @@ struct lu_object *ccc_object_alloc(const struct lu_env *env,
struct ccc_object *vob;
struct lu_object *obj;
- OBD_SLAB_ALLOC_PTR_GFP(vob, ccc_object_kmem, GFP_NOFS);
+ vob = kmem_cache_alloc(ccc_object_kmem, GFP_NOFS | __GFP_ZERO);
if (vob != NULL) {
struct cl_object_header *hdr;
@@ -384,7 +383,7 @@ void ccc_object_free(const struct lu_env *env, struct lu_object *obj)
lu_object_fini(obj);
lu_object_header_fini(obj->lo_header);
- OBD_SLAB_FREE_PTR(vob, ccc_object_kmem);
+ kmem_cache_free(ccc_object_kmem, vob);
}
int ccc_lock_init(const struct lu_env *env,
@@ -397,7 +396,7 @@ int ccc_lock_init(const struct lu_env *env,
CLOBINVRNT(env, obj, ccc_object_invariant(obj));
- OBD_SLAB_ALLOC_PTR_GFP(clk, ccc_lock_kmem, GFP_NOFS);
+ clk = kmem_cache_alloc(ccc_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (clk != NULL) {
cl_lock_slice_add(lock, &clk->clk_cl, obj, lkops);
result = 0;
@@ -406,12 +405,6 @@ int ccc_lock_init(const struct lu_env *env,
return result;
}
-int ccc_attr_set(const struct lu_env *env, struct cl_object *obj,
- const struct cl_attr *attr, unsigned valid)
-{
- return 0;
-}
-
int ccc_object_glimpse(const struct lu_env *env,
const struct cl_object *obj, struct ost_lvb *lvb)
{
@@ -430,15 +423,6 @@ int ccc_object_glimpse(const struct lu_env *env,
return 0;
}
-
-
-int ccc_conf_set(const struct lu_env *env, struct cl_object *obj,
- const struct cl_object_conf *conf)
-{
- /* TODO: destroy all pages attached to this object. */
- return 0;
-}
-
static void ccc_object_size_lock(struct cl_object *obj)
{
struct inode *inode = ccc_object_inode(obj);
@@ -503,54 +487,6 @@ int ccc_fail(const struct lu_env *env, const struct cl_page_slice *slice)
return 0;
}
-void ccc_transient_page_verify(const struct cl_page *page)
-{
-}
-
-int ccc_transient_page_own(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *unused,
- int nonblock)
-{
- ccc_transient_page_verify(slice->cpl_page);
- return 0;
-}
-
-void ccc_transient_page_assume(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *unused)
-{
- ccc_transient_page_verify(slice->cpl_page);
-}
-
-void ccc_transient_page_unassume(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *unused)
-{
- ccc_transient_page_verify(slice->cpl_page);
-}
-
-void ccc_transient_page_disown(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *unused)
-{
- ccc_transient_page_verify(slice->cpl_page);
-}
-
-void ccc_transient_page_discard(const struct lu_env *env,
- const struct cl_page_slice *slice,
- struct cl_io *unused)
-{
- struct cl_page *page = slice->cpl_page;
-
- ccc_transient_page_verify(slice->cpl_page);
-
- /*
- * For transient pages, remove it from the radix tree.
- */
- cl_page_delete(env, page);
-}
-
int ccc_transient_page_prep(const struct lu_env *env,
const struct cl_page_slice *slice,
struct cl_io *unused)
@@ -575,7 +511,7 @@ void ccc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice)
{
struct ccc_lock *clk = cl2ccc_lock(slice);
- OBD_SLAB_FREE_PTR(clk, ccc_lock_kmem);
+ kmem_cache_free(ccc_lock_kmem, clk);
}
int ccc_lock_enqueue(const struct lu_env *env,
@@ -690,13 +626,6 @@ void ccc_lock_state(const struct lu_env *env,
*
*/
-void ccc_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
-{
- struct cl_io *io = ios->cis_io;
-
- CLOBINVRNT(env, io->ci_obj, ccc_object_invariant(io->ci_obj));
-}
-
int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io,
__u32 enqflags, enum cl_lock_mode mode,
pgoff_t start, pgoff_t end)
@@ -836,25 +765,24 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
*exceed = 1;
}
return result;
- } else {
- /*
- * region is within kms and, hence, within real file
- * size (A). We need to increase i_size to cover the
- * read region so that generic_file_read() will do its
- * job, but that doesn't mean the kms size is
- * _correct_, it is only the _minimum_ size. If
- * someone does a stat they will get the correct size
- * which will always be >= the kms value here.
- * b=11081
- */
- if (cl_isize_read(inode) < kms) {
- cl_isize_write_nolock(inode, kms);
- CDEBUG(D_VFSTRACE,
- DFID" updating i_size %llu\n",
- PFID(lu_object_fid(&obj->co_lu)),
- (__u64)cl_isize_read(inode));
+ }
+ /*
+ * region is within kms and, hence, within real file
+ * size (A). We need to increase i_size to cover the
+ * read region so that generic_file_read() will do its
+ * job, but that doesn't mean the kms size is
+ * _correct_, it is only the _minimum_ size. If
+ * someone does a stat they will get the correct size
+ * which will always be >= the kms value here.
+ * b=11081
+ */
+ if (cl_isize_read(inode) < kms) {
+ cl_isize_write_nolock(inode, kms);
+ CDEBUG(D_VFSTRACE,
+ DFID" updating i_size %llu\n",
+ PFID(lu_object_fid(&obj->co_lu)),
+ (__u64)cl_isize_read(inode));
- }
}
}
ccc_object_size_unlock(obj);
@@ -876,7 +804,7 @@ void ccc_req_completion(const struct lu_env *env,
cl_stats_tally(slice->crs_dev, slice->crs_req->crq_type, ioret);
vrq = cl2ccc_req(slice);
- OBD_SLAB_FREE_PTR(vrq, ccc_req_kmem);
+ kmem_cache_free(ccc_req_kmem, vrq);
}
/**
@@ -897,7 +825,6 @@ void ccc_req_completion(const struct lu_env *env,
*
* - o_ioepoch,
*
- * and capability.
*/
void ccc_req_attr_set(const struct lu_env *env,
const struct cl_req_slice *slice,
@@ -912,12 +839,6 @@ void ccc_req_attr_set(const struct lu_env *env,
inode = ccc_object_inode(obj);
valid_flags = OBD_MD_FLTYPE;
- if ((flags & OBD_MD_FLOSSCAPA) != 0) {
- LASSERT(attr->cra_capa == NULL);
- attr->cra_capa = cl_capa_lookup(inode,
- slice->crs_req->crq_type);
- }
-
if (slice->crs_req->crq_type == CRT_WRITE) {
if (flags & OBD_MD_FLEPOCH) {
oa->o_valid |= OBD_MD_FLEPOCH;
@@ -937,8 +858,7 @@ static const struct cl_req_operations ccc_req_ops = {
.cro_completion = ccc_req_completion
};
-int cl_setattr_ost(struct inode *inode, const struct iattr *attr,
- struct obd_capa *capa)
+int cl_setattr_ost(struct inode *inode, const struct iattr *attr)
{
struct lu_env *env;
struct cl_io *io;
@@ -957,7 +877,6 @@ int cl_setattr_ost(struct inode *inode, const struct iattr *attr,
io->u.ci_setattr.sa_attr.lvb_ctime = LTIME_S(attr->ia_ctime);
io->u.ci_setattr.sa_attr.lvb_size = attr->ia_size;
io->u.ci_setattr.sa_valid = attr->ia_valid;
- io->u.ci_setattr.sa_capa = capa;
again:
if (cl_io_init(env, io, CIT_SETATTR, io->ci_obj) == 0) {
diff --git a/kernel/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/kernel/drivers/staging/lustre/lustre/lclient/lcommon_misc.c
index 01bf894d4..8389a0eda 100644
--- a/kernel/drivers/staging/lustre/lustre/lclient/lcommon_misc.c
+++ b/kernel/drivers/staging/lustre/lustre/lclient/lcommon_misc.c
@@ -45,7 +45,6 @@
#include "../include/lustre_lite.h"
-
/* Initialize the default and maximum LOV EA and cookie sizes. This allows
* us to make MDS RPCs with large enough reply buffers to hold the
* maximum-sized (= maximum striped) EA and cookie without having to
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/kernel/drivers/staging/lustre/lustre/ldlm/interval_tree.c
index eab2bd602..39b571721 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/interval_tree.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/interval_tree.c
@@ -96,12 +96,6 @@ static inline int extent_equal(struct interval_node_extent *e1,
return (e1->start == e2->start) && (e1->end == e2->end);
}
-static inline int extent_overlapped(struct interval_node_extent *e1,
- struct interval_node_extent *e2)
-{
- return (e1->start <= e2->end) && (e2->start <= e1->end);
-}
-
static inline int node_compare(struct interval_node *n1,
struct interval_node *n2)
{
@@ -119,19 +113,6 @@ static inline __u64 max_u64(__u64 x, __u64 y)
return x > y ? x : y;
}
-static inline __u64 min_u64(__u64 x, __u64 y)
-{
- return x < y ? x : y;
-}
-
-#define interval_for_each(node, root) \
-for (node = interval_first(root); node != NULL; \
- node = interval_next(node))
-
-#define interval_for_each_reverse(node, root) \
-for (node = interval_last(root); node != NULL; \
- node = interval_prev(node))
-
static struct interval_node *interval_first(struct interval_node *node)
{
if (!node)
@@ -141,15 +122,6 @@ static struct interval_node *interval_first(struct interval_node *node)
return node;
}
-static struct interval_node *interval_last(struct interval_node *node)
-{
- if (!node)
- return NULL;
- while (node->in_right)
- node = node->in_right;
- return node;
-}
-
static struct interval_node *interval_next(struct interval_node *node)
{
if (!node)
@@ -161,76 +133,6 @@ static struct interval_node *interval_next(struct interval_node *node)
return node->in_parent;
}
-static struct interval_node *interval_prev(struct interval_node *node)
-{
- if (!node)
- return NULL;
-
- if (node->in_left)
- return interval_last(node->in_left);
-
- while (node->in_parent && node_is_left_child(node))
- node = node->in_parent;
-
- return node->in_parent;
-}
-
-enum interval_iter interval_iterate(struct interval_node *root,
- interval_callback_t func,
- void *data)
-{
- struct interval_node *node;
- enum interval_iter rc = INTERVAL_ITER_CONT;
-
- interval_for_each(node, root) {
- rc = func(node, data);
- if (rc == INTERVAL_ITER_STOP)
- break;
- }
-
- return rc;
-}
-EXPORT_SYMBOL(interval_iterate);
-
-enum interval_iter interval_iterate_reverse(struct interval_node *root,
- interval_callback_t func,
- void *data)
-{
- struct interval_node *node;
- enum interval_iter rc = INTERVAL_ITER_CONT;
-
- interval_for_each_reverse(node, root) {
- rc = func(node, data);
- if (rc == INTERVAL_ITER_STOP)
- break;
- }
-
- return rc;
-}
-EXPORT_SYMBOL(interval_iterate_reverse);
-
-/* try to find a node with same interval in the tree,
- * if found, return the pointer to the node, otherwise return NULL*/
-struct interval_node *interval_find(struct interval_node *root,
- struct interval_node_extent *ex)
-{
- struct interval_node *walk = root;
- int rc;
-
- while (walk) {
- rc = extent_compare(ex, &walk->in_extent);
- if (rc == 0)
- break;
- else if (rc < 0)
- walk = walk->in_left;
- else
- walk = walk->in_right;
- }
-
- return walk;
-}
-EXPORT_SYMBOL(interval_find);
-
static void __rotate_change_maxhigh(struct interval_node *node,
struct interval_node *rotate)
{
@@ -392,7 +294,8 @@ struct interval_node *interval_insert(struct interval_node *node,
/* link node into the tree */
node->in_parent = parent;
node->in_color = INTERVAL_RED;
- node->in_left = node->in_right = NULL;
+ node->in_left = NULL;
+ node->in_right = NULL;
*p = node;
interval_insert_color(node, root);
@@ -576,176 +479,3 @@ color:
interval_erase_color(child, parent, root);
}
EXPORT_SYMBOL(interval_erase);
-
-static inline int interval_may_overlap(struct interval_node *node,
- struct interval_node_extent *ext)
-{
- return (ext->start <= node->in_max_high &&
- ext->end >= interval_low(node));
-}
-
-/*
- * This function finds all intervals that overlap interval ext,
- * and calls func to handle resulted intervals one by one.
- * in lustre, this function will find all conflicting locks in
- * the granted queue and add these locks to the ast work list.
- *
- * {
- * if (node == NULL)
- * return 0;
- * if (ext->end < interval_low(node)) {
- * interval_search(node->in_left, ext, func, data);
- * } else if (interval_may_overlap(node, ext)) {
- * if (extent_overlapped(ext, &node->in_extent))
- * func(node, data);
- * interval_search(node->in_left, ext, func, data);
- * interval_search(node->in_right, ext, func, data);
- * }
- * return 0;
- * }
- *
- */
-enum interval_iter interval_search(struct interval_node *node,
- struct interval_node_extent *ext,
- interval_callback_t func,
- void *data)
-{
- struct interval_node *parent;
- enum interval_iter rc = INTERVAL_ITER_CONT;
-
- LASSERT(ext != NULL);
- LASSERT(func != NULL);
-
- while (node) {
- if (ext->end < interval_low(node)) {
- if (node->in_left) {
- node = node->in_left;
- continue;
- }
- } else if (interval_may_overlap(node, ext)) {
- if (extent_overlapped(ext, &node->in_extent)) {
- rc = func(node, data);
- if (rc == INTERVAL_ITER_STOP)
- break;
- }
-
- if (node->in_left) {
- node = node->in_left;
- continue;
- }
- if (node->in_right) {
- node = node->in_right;
- continue;
- }
- }
-
- parent = node->in_parent;
- while (parent) {
- if (node_is_left_child(node) &&
- parent->in_right) {
- /* If we ever got the left, it means that the
- * parent met ext->end<interval_low(parent), or
- * may_overlap(parent). If the former is true,
- * we needn't go back. So stop early and check
- * may_overlap(parent) after this loop. */
- node = parent->in_right;
- break;
- }
- node = parent;
- parent = parent->in_parent;
- }
- if (parent == NULL || !interval_may_overlap(parent, ext))
- break;
- }
-
- return rc;
-}
-EXPORT_SYMBOL(interval_search);
-
-static enum interval_iter interval_overlap_cb(struct interval_node *n,
- void *args)
-{
- *(int *)args = 1;
- return INTERVAL_ITER_STOP;
-}
-
-int interval_is_overlapped(struct interval_node *root,
- struct interval_node_extent *ext)
-{
- int has = 0;
- (void)interval_search(root, ext, interval_overlap_cb, &has);
- return has;
-}
-EXPORT_SYMBOL(interval_is_overlapped);
-
-/* Don't expand to low. Expanding downwards is expensive, and meaningless to
- * some extents, because programs seldom do IO backward.
- *
- * The recursive algorithm of expanding low:
- * expand_low {
- * struct interval_node *tmp;
- * static __u64 res = 0;
- *
- * if (root == NULL)
- * return res;
- * if (root->in_max_high < low) {
- * res = max_u64(root->in_max_high + 1, res);
- * return res;
- * } else if (low < interval_low(root)) {
- * interval_expand_low(root->in_left, low);
- * return res;
- * }
- *
- * if (interval_high(root) < low)
- * res = max_u64(interval_high(root) + 1, res);
- * interval_expand_low(root->in_left, low);
- * interval_expand_low(root->in_right, low);
- *
- * return res;
- * }
- *
- * It's much easy to eliminate the recursion, see interval_search for
- * an example. -jay
- */
-static inline __u64 interval_expand_low(struct interval_node *root, __u64 low)
-{
- /* we only concern the empty tree right now. */
- if (root == NULL)
- return 0;
- return low;
-}
-
-static inline __u64 interval_expand_high(struct interval_node *node, __u64 high)
-{
- __u64 result = ~0;
-
- while (node != NULL) {
- if (node->in_max_high < high)
- break;
-
- if (interval_low(node) > high) {
- result = interval_low(node) - 1;
- node = node->in_left;
- } else {
- node = node->in_right;
- }
- }
-
- return result;
-}
-
-/* expanding the extent based on @ext. */
-void interval_expand(struct interval_node *root,
- struct interval_node_extent *ext,
- struct interval_node_extent *limiter)
-{
- /* The assertion of interval_is_overlapped is expensive because we may
- * travel many nodes to find the overlapped node. */
- LASSERT(interval_is_overlapped(root, ext) == 0);
- if (!limiter || limiter->start < ext->start)
- ext->start = interval_expand_low(root, ext->start);
- if (!limiter || limiter->end > ext->end)
- ext->end = interval_expand_high(root, ext->end);
- LASSERT(interval_is_overlapped(root, ext) == 0);
-}
-EXPORT_SYMBOL(interval_expand);
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/l_lock.c b/kernel/drivers/staging/lustre/lustre/ldlm/l_lock.c
index cd8ab40e3..e5d1344e8 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/l_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/l_lock.c
@@ -50,9 +50,7 @@
*/
struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock)
{
- /* on server-side resource of lock doesn't change */
- if ((lock->l_flags & LDLM_FL_NS_SRV) == 0)
- spin_lock(&lock->l_lock);
+ spin_lock(&lock->l_lock);
lock_res(lock->l_resource);
@@ -70,7 +68,6 @@ void unlock_res_and_lock(struct ldlm_lock *lock)
lock->l_flags &= ~LDLM_FL_RES_LOCKED;
unlock_res(lock->l_resource);
- if ((lock->l_flags & LDLM_FL_NS_SRV) == 0)
- spin_unlock(&lock->l_lock);
+ spin_unlock(&lock->l_lock);
}
EXPORT_SYMBOL(unlock_res_and_lock);
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index fd9b05936..c787888eb 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -58,7 +58,6 @@
#include "../include/lustre_lib.h"
#include "ldlm_internal.h"
-
/* When a lock is cancelled by a client, the KMS may undergo change if this
* is the "highest lock". This function returns the new KMS value.
* Caller must hold lr_lock already.
@@ -97,12 +96,23 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
EXPORT_SYMBOL(ldlm_extent_shift_kms);
struct kmem_cache *ldlm_interval_slab;
+
+/* interval tree, for LDLM_EXTENT. */
+static void ldlm_interval_attach(struct ldlm_interval *n, struct ldlm_lock *l)
+{
+ LASSERT(!l->l_tree_node);
+ LASSERT(l->l_resource->lr_type == LDLM_EXTENT);
+
+ list_add_tail(&l->l_sl_policy, &n->li_group);
+ l->l_tree_node = n;
+}
+
struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock)
{
struct ldlm_interval *node;
LASSERT(lock->l_resource->lr_type == LDLM_EXTENT);
- OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS);
+ node = kmem_cache_alloc(ldlm_interval_slab, GFP_NOFS | __GFP_ZERO);
if (node == NULL)
return NULL;
@@ -116,21 +126,10 @@ void ldlm_interval_free(struct ldlm_interval *node)
if (node) {
LASSERT(list_empty(&node->li_group));
LASSERT(!interval_is_intree(&node->li_node));
- OBD_SLAB_FREE(node, ldlm_interval_slab, sizeof(*node));
+ kmem_cache_free(ldlm_interval_slab, node);
}
}
-/* interval tree, for LDLM_EXTENT. */
-void ldlm_interval_attach(struct ldlm_interval *n,
- struct ldlm_lock *l)
-{
- LASSERT(l->l_tree_node == NULL);
- LASSERT(l->l_resource->lr_type == LDLM_EXTENT);
-
- list_add_tail(&l->l_sl_policy, &n->li_group);
- l->l_tree_node = n;
-}
-
struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l)
{
struct ldlm_interval *n = l->l_tree_node;
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index a4c252feb..4310154e1 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -63,9 +63,6 @@
#include <linux/list.h>
#include "ldlm_internal.h"
-int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
- void *data, int flag);
-
/**
* list_for_remaining_safe - iterate over the remaining entries in a list
* and safeguard against removal of a list entry.
@@ -94,40 +91,6 @@ ldlm_flocks_overlap(struct ldlm_lock *lock, struct ldlm_lock *new)
lock->l_policy_data.l_flock.start));
}
-static inline void ldlm_flock_blocking_link(struct ldlm_lock *req,
- struct ldlm_lock *lock)
-{
- /* For server only */
- if (req->l_export == NULL)
- return;
-
- LASSERT(hlist_unhashed(&req->l_exp_flock_hash));
-
- req->l_policy_data.l_flock.blocking_owner =
- lock->l_policy_data.l_flock.owner;
- req->l_policy_data.l_flock.blocking_export =
- lock->l_export;
- req->l_policy_data.l_flock.blocking_refs = 0;
-
- cfs_hash_add(req->l_export->exp_flock_hash,
- &req->l_policy_data.l_flock.owner,
- &req->l_exp_flock_hash);
-}
-
-static inline void ldlm_flock_blocking_unlink(struct ldlm_lock *req)
-{
- /* For server only */
- if (req->l_export == NULL)
- return;
-
- check_res_locked(req->l_resource);
- if (req->l_export->exp_flock_hash != NULL &&
- !hlist_unhashed(&req->l_exp_flock_hash))
- cfs_hash_del(req->l_export->exp_flock_hash,
- &req->l_policy_data.l_flock.owner,
- &req->l_exp_flock_hash);
-}
-
static inline void
ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags)
{
@@ -152,79 +115,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags)
}
/**
- * POSIX locks deadlock detection code.
- *
- * Given a new lock \a req and an existing lock \a bl_lock it conflicts
- * with, we need to iterate through all blocked POSIX locks for this
- * export and see if there is a deadlock condition arising. (i.e. when
- * one client holds a lock on something and want a lock on something
- * else and at the same time another client has the opposite situation).
- */
-static int
-ldlm_flock_deadlock(struct ldlm_lock *req, struct ldlm_lock *bl_lock)
-{
- struct obd_export *req_exp = req->l_export;
- struct obd_export *bl_exp = bl_lock->l_export;
- __u64 req_owner = req->l_policy_data.l_flock.owner;
- __u64 bl_owner = bl_lock->l_policy_data.l_flock.owner;
-
- /* For server only */
- if (req_exp == NULL)
- return 0;
-
- class_export_get(bl_exp);
- while (1) {
- struct obd_export *bl_exp_new;
- struct ldlm_lock *lock = NULL;
- struct ldlm_flock *flock;
-
- if (bl_exp->exp_flock_hash != NULL)
- lock = cfs_hash_lookup(bl_exp->exp_flock_hash,
- &bl_owner);
- if (lock == NULL)
- break;
-
- LASSERT(req != lock);
- flock = &lock->l_policy_data.l_flock;
- LASSERT(flock->owner == bl_owner);
- bl_owner = flock->blocking_owner;
- bl_exp_new = class_export_get(flock->blocking_export);
- class_export_put(bl_exp);
-
- cfs_hash_put(bl_exp->exp_flock_hash, &lock->l_exp_flock_hash);
- bl_exp = bl_exp_new;
-
- if (bl_owner == req_owner && bl_exp == req_exp) {
- class_export_put(bl_exp);
- return 1;
- }
- }
- class_export_put(bl_exp);
-
- return 0;
-}
-
-static void ldlm_flock_cancel_on_deadlock(struct ldlm_lock *lock,
- struct list_head *work_list)
-{
- CDEBUG(D_INFO, "reprocess deadlock req=%p\n", lock);
-
- if ((exp_connect_flags(lock->l_export) &
- OBD_CONNECT_FLOCK_DEAD) == 0) {
- CERROR(
- "deadlock found, but client doesn't support flock canceliation\n");
- } else {
- LASSERT(lock->l_completion_ast);
- LASSERT((lock->l_flags & LDLM_FL_AST_SENT) == 0);
- lock->l_flags |= LDLM_FL_AST_SENT | LDLM_FL_CANCEL_ON_BLOCK |
- LDLM_FL_FLOCK_DEADLOCK;
- ldlm_flock_blocking_unlink(lock);
- ldlm_resource_unlink_lock(lock);
- ldlm_add_ast_work_item(lock, NULL, work_list);
- }
-}
-
-/**
* Process a granting attempt for flock lock.
* Must be called under ns lock held.
*
@@ -242,9 +132,9 @@ static void ldlm_flock_cancel_on_deadlock(struct ldlm_lock *lock,
* - blocking ASTs have not been sent yet, so list of conflicting locks
* would be collected and ASTs sent.
*/
-int
-ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
- ldlm_error_t *err, struct list_head *work_list)
+static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags,
+ int first_enq, ldlm_error_t *err,
+ struct list_head *work_list)
{
struct ldlm_resource *res = req->l_resource;
struct ldlm_namespace *ns = ldlm_res_to_ns(res);
@@ -254,7 +144,6 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
struct ldlm_lock *new = req;
struct ldlm_lock *new2 = NULL;
ldlm_mode_t mode = req->l_req_mode;
- int local = ns_is_client(ns);
int added = (mode == LCK_NL);
int overlaps = 0;
int splitted = 0;
@@ -269,14 +158,9 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq,
*err = ELDLM_OK;
- if (local) {
- /* No blocking ASTs are sent to the clients for
- * Posix file & record locks */
- req->l_blocking_ast = NULL;
- } else {
- /* Called on the server for lock cancels. */
- req->l_blocking_ast = ldlm_flock_blocking_ast;
- }
+ /* No blocking ASTs are sent to the clients for
+ * Posix file & record locks */
+ req->l_blocking_ast = NULL;
reprocess:
if ((*flags == LDLM_FL_WAIT_NOREPROC) || (mode == LCK_NL)) {
@@ -316,11 +200,6 @@ reprocess:
if (!first_enq) {
reprocess_failed = 1;
- if (ldlm_flock_deadlock(req, lock)) {
- ldlm_flock_cancel_on_deadlock(req,
- work_list);
- return LDLM_ITER_CONTINUE;
- }
continue;
}
@@ -343,17 +222,6 @@ reprocess:
return LDLM_ITER_STOP;
}
- /* add lock to blocking list before deadlock
- * check to prevent race */
- ldlm_flock_blocking_link(req, lock);
-
- if (ldlm_flock_deadlock(req, lock)) {
- ldlm_flock_blocking_unlink(req);
- ldlm_flock_destroy(req, mode, *flags);
- *err = -EDEADLK;
- return LDLM_ITER_STOP;
- }
-
ldlm_resource_add_lock(res, &res->lr_waiting, req);
*flags |= LDLM_FL_BLOCK_GRANTED;
return LDLM_ITER_STOP;
@@ -369,10 +237,6 @@ reprocess:
return LDLM_ITER_STOP;
}
- /* In case we had slept on this lock request take it off of the
- * deadlock detection hash list. */
- ldlm_flock_blocking_unlink(req);
-
/* Scan the locks owned by this process that overlap this request.
* We may have to merge or split existing locks. */
@@ -523,7 +387,6 @@ reprocess:
/* At this point we're granting the lock request. */
req->l_granted_mode = req->l_req_mode;
- /* Add req to the granted queue before calling ldlm_reprocess_all(). */
if (!added) {
list_del_init(&req->l_res_link);
/* insert new lock before ownlocks in list. */
@@ -561,9 +424,7 @@ ldlm_flock_interrupted_wait(void *data)
lock = ((struct ldlm_flock_wait_data *)data)->fwd_lock;
- /* take lock off the deadlock detection hash list. */
lock_res_and_lock(lock);
- ldlm_flock_blocking_unlink(lock);
/* client side - set flag to prevent lock from being put on LRU list */
lock->l_flags |= LDLM_FL_CBPENDING;
@@ -602,7 +463,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
(LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) {
if (lock->l_req_mode == lock->l_granted_mode &&
lock->l_granted_mode != LCK_NL &&
- NULL == data)
+ data == NULL)
ldlm_lock_decref_internal(lock, lock->l_req_mode);
/* Need to wake up the waiter if we were evicted */
@@ -614,7 +475,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
LDLM_FL_BLOCK_CONV))) {
- if (NULL == data)
+ if (data == NULL)
/* mds granted the lock in the reply */
goto granted;
/* CP AST RPC: lock get granted, wake it up */
@@ -627,10 +488,10 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
obd = class_exp2obd(lock->l_conn_export);
/* if this is a local lock, there is no import */
- if (NULL != obd)
+ if (obd != NULL)
imp = obd->u.cli.cl_import;
- if (NULL != imp) {
+ if (imp != NULL) {
spin_lock(&imp->imp_lock);
fwd.fwd_generation = imp->imp_generation;
spin_unlock(&imp->imp_lock);
@@ -670,9 +531,6 @@ granted:
lock_res_and_lock(lock);
- /* take lock off the deadlock detection hash list. */
- ldlm_flock_blocking_unlink(lock);
-
/* ldlm_lock_enqueue() has already placed lock on the granted list. */
list_del_init(&lock->l_res_link);
@@ -709,19 +567,6 @@ granted:
}
EXPORT_SYMBOL(ldlm_flock_completion_ast);
-int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
- void *data, int flag)
-{
- LASSERT(lock);
- LASSERT(flag == LDLM_CB_CANCELING);
-
- /* take lock off the deadlock detection hash list. */
- lock_res_and_lock(lock);
- ldlm_flock_blocking_unlink(lock);
- unlock_res_and_lock(lock);
- return 0;
-}
-
void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy,
ldlm_policy_data_t *lpolicy)
{
@@ -735,7 +580,6 @@ void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy,
lpolicy->l_flock.owner = wpolicy->l_flock.lfw_pid;
}
-
void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy,
ldlm_policy_data_t *lpolicy)
{
@@ -755,105 +599,3 @@ void ldlm_flock_policy_local_to_wire(const ldlm_policy_data_t *lpolicy,
wpolicy->l_flock.lfw_pid = lpolicy->l_flock.pid;
wpolicy->l_flock.lfw_owner = lpolicy->l_flock.owner;
}
-
-/*
- * Export handle<->flock hash operations.
- */
-static unsigned
-ldlm_export_flock_hash(struct cfs_hash *hs, const void *key, unsigned mask)
-{
- return cfs_hash_u64_hash(*(__u64 *)key, mask);
-}
-
-static void *
-ldlm_export_flock_key(struct hlist_node *hnode)
-{
- struct ldlm_lock *lock;
-
- lock = hlist_entry(hnode, struct ldlm_lock, l_exp_flock_hash);
- return &lock->l_policy_data.l_flock.owner;
-}
-
-static int
-ldlm_export_flock_keycmp(const void *key, struct hlist_node *hnode)
-{
- return !memcmp(ldlm_export_flock_key(hnode), key, sizeof(__u64));
-}
-
-static void *
-ldlm_export_flock_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct ldlm_lock, l_exp_flock_hash);
-}
-
-static void
-ldlm_export_flock_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct ldlm_lock *lock;
- struct ldlm_flock *flock;
-
- lock = hlist_entry(hnode, struct ldlm_lock, l_exp_flock_hash);
- LDLM_LOCK_GET(lock);
-
- flock = &lock->l_policy_data.l_flock;
- LASSERT(flock->blocking_export != NULL);
- class_export_get(flock->blocking_export);
- flock->blocking_refs++;
-}
-
-static void
-ldlm_export_flock_put(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct ldlm_lock *lock;
- struct ldlm_flock *flock;
-
- lock = hlist_entry(hnode, struct ldlm_lock, l_exp_flock_hash);
- LDLM_LOCK_RELEASE(lock);
-
- flock = &lock->l_policy_data.l_flock;
- LASSERT(flock->blocking_export != NULL);
- class_export_put(flock->blocking_export);
- if (--flock->blocking_refs == 0) {
- flock->blocking_owner = 0;
- flock->blocking_export = NULL;
- }
-}
-
-static cfs_hash_ops_t ldlm_export_flock_ops = {
- .hs_hash = ldlm_export_flock_hash,
- .hs_key = ldlm_export_flock_key,
- .hs_keycmp = ldlm_export_flock_keycmp,
- .hs_object = ldlm_export_flock_object,
- .hs_get = ldlm_export_flock_get,
- .hs_put = ldlm_export_flock_put,
- .hs_put_locked = ldlm_export_flock_put,
-};
-
-int ldlm_init_flock_export(struct obd_export *exp)
-{
- if (strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MDT_NAME) != 0)
- return 0;
-
- exp->exp_flock_hash =
- cfs_hash_create(obd_uuid2str(&exp->exp_client_uuid),
- HASH_EXP_LOCK_CUR_BITS,
- HASH_EXP_LOCK_MAX_BITS,
- HASH_EXP_LOCK_BKT_BITS, 0,
- CFS_HASH_MIN_THETA, CFS_HASH_MAX_THETA,
- &ldlm_export_flock_ops,
- CFS_HASH_DEFAULT | CFS_HASH_NBLK_CHANGE);
- if (!exp->exp_flock_hash)
- return -ENOMEM;
-
- return 0;
-}
-EXPORT_SYMBOL(ldlm_init_flock_export);
-
-void ldlm_destroy_flock_export(struct obd_export *exp)
-{
- if (exp->exp_flock_hash) {
- cfs_hash_putref(exp->exp_flock_hash);
- exp->exp_flock_hash = NULL;
- }
-}
-EXPORT_SYMBOL(ldlm_destroy_flock_export);
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c
index 40d333850..b1bed1e17 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c
@@ -58,7 +58,6 @@
#include "../include/lustre_lib.h"
#include "ldlm_internal.h"
-
void ldlm_ibits_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
ldlm_policy_data_t *lpolicy)
{
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index 70b909f55..db3c9b7af 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -42,7 +42,6 @@ extern struct mutex ldlm_srv_namespace_lock;
extern struct list_head ldlm_srv_namespace_list;
extern struct mutex ldlm_cli_namespace_lock;
extern struct list_head ldlm_cli_active_namespace_list;
-extern struct list_head ldlm_cli_inactive_namespace_list;
static inline int ldlm_namespace_nr_read(ldlm_side_t client)
{
@@ -72,12 +71,6 @@ static inline struct list_head *ldlm_namespace_list(ldlm_side_t client)
&ldlm_srv_namespace_list : &ldlm_cli_active_namespace_list;
}
-static inline struct list_head *ldlm_namespace_inactive_list(ldlm_side_t client)
-{
- return client == LDLM_NAMESPACE_SERVER ?
- &ldlm_srv_namespace_list : &ldlm_cli_inactive_namespace_list;
-}
-
static inline struct mutex *ldlm_namespace_lock(ldlm_side_t client)
{
return client == LDLM_NAMESPACE_SERVER ?
@@ -109,15 +102,12 @@ enum {
int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr,
ldlm_cancel_flags_t sync, int flags);
int ldlm_cancel_lru_local(struct ldlm_namespace *ns,
- struct list_head *cancels, int count, int max,
- ldlm_cancel_flags_t cancel_flags, int flags);
+ struct list_head *cancels, int count, int max,
+ ldlm_cancel_flags_t cancel_flags, int flags);
extern int ldlm_enqueue_min;
-int ldlm_get_enq_timeout(struct ldlm_lock *lock);
/* ldlm_resource.c */
int ldlm_resource_putref_locked(struct ldlm_resource *res);
-void ldlm_resource_insert_lock_after(struct ldlm_lock *original,
- struct ldlm_lock *new);
void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
struct obd_import *imp, int force);
void ldlm_namespace_free_post(struct ldlm_namespace *ns);
@@ -152,20 +142,12 @@ void ldlm_lock_addref_internal(struct ldlm_lock *, __u32 mode);
void ldlm_lock_addref_internal_nolock(struct ldlm_lock *, __u32 mode);
void ldlm_lock_decref_internal(struct ldlm_lock *, __u32 mode);
void ldlm_lock_decref_internal_nolock(struct ldlm_lock *, __u32 mode);
-void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
- struct list_head *work_list);
int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
enum ldlm_desc_ast_t ast_type);
-int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq);
int ldlm_lock_remove_from_lru(struct ldlm_lock *lock);
int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock);
-void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock);
-void ldlm_lock_add_to_lru(struct ldlm_lock *lock);
-void ldlm_lock_touch_in_lru(struct ldlm_lock *lock);
void ldlm_lock_destroy_nolock(struct ldlm_lock *lock);
-void ldlm_cancel_locks_for_export(struct obd_export *export);
-
/* ldlm_lockd.c */
int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
struct ldlm_lock *lock);
@@ -178,6 +160,7 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
struct ldlm_lock_desc *ld, struct ldlm_lock *lock);
extern struct kmem_cache *ldlm_resource_slab;
+extern struct kset *ldlm_ns_kset;
/* ldlm_lockd.c & ldlm_lock.c */
extern struct kmem_cache *ldlm_lock_slab;
@@ -186,19 +169,11 @@ extern struct kmem_cache *ldlm_lock_slab;
void ldlm_extent_add_lock(struct ldlm_resource *res, struct ldlm_lock *lock);
void ldlm_extent_unlink_lock(struct ldlm_lock *lock);
-/* ldlm_flock.c */
-int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags,
- int first_enq, ldlm_error_t *err,
- struct list_head *work_list);
-int ldlm_init_flock_export(struct obd_export *exp);
-void ldlm_destroy_flock_export(struct obd_export *exp);
-
/* l_lock.c */
void l_check_ns_lock(struct ldlm_namespace *ns);
void l_check_no_ns_lock(struct ldlm_namespace *ns);
-extern struct proc_dir_entry *ldlm_svc_proc_dir;
-extern struct proc_dir_entry *ldlm_type_proc_dir;
+extern struct dentry *ldlm_svc_debugfs_dir;
struct ldlm_state {
struct ptlrpc_service *ldlm_cb_service;
@@ -208,9 +183,13 @@ struct ldlm_state {
struct ldlm_bl_pool *ldlm_bl_pool;
};
+/* ldlm_pool.c */
+__u64 ldlm_pool_get_slv(struct ldlm_pool *pl);
+void ldlm_pool_set_clv(struct ldlm_pool *pl, __u64 clv);
+__u32 ldlm_pool_get_lvf(struct ldlm_pool *pl);
+
/* interval tree, for LDLM_EXTENT. */
extern struct kmem_cache *ldlm_interval_slab; /* slab cache for ldlm_interval */
-extern void ldlm_interval_attach(struct ldlm_interval *n, struct ldlm_lock *l);
struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l);
struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock);
void ldlm_interval_free(struct ldlm_interval *node);
@@ -238,40 +217,85 @@ enum ldlm_policy_res {
typedef enum ldlm_policy_res ldlm_policy_res_t;
-#define LDLM_POOL_PROC_READER_SEQ_SHOW(var, type) \
- static int lprocfs_##var##_seq_show(struct seq_file *m, void *v) \
+#define LDLM_POOL_SYSFS_PRINT_int(v) sprintf(buf, "%d\n", v)
+#define LDLM_POOL_SYSFS_SET_int(a, b) { a = b; }
+#define LDLM_POOL_SYSFS_PRINT_u64(v) sprintf(buf, "%lld\n", v)
+#define LDLM_POOL_SYSFS_SET_u64(a, b) { a = b; }
+#define LDLM_POOL_SYSFS_PRINT_atomic(v) sprintf(buf, "%d\n", atomic_read(&v))
+#define LDLM_POOL_SYSFS_SET_atomic(a, b) atomic_set(&a, b)
+
+#define LDLM_POOL_SYSFS_READER_SHOW(var, type) \
+ static ssize_t var##_show(struct kobject *kobj, \
+ struct attribute *attr, \
+ char *buf) \
{ \
- struct ldlm_pool *pl = m->private; \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
type tmp; \
\
spin_lock(&pl->pl_lock); \
tmp = pl->pl_##var; \
spin_unlock(&pl->pl_lock); \
\
- return lprocfs_rd_uint(m, &tmp); \
+ return LDLM_POOL_SYSFS_PRINT_##type(tmp); \
} \
struct __##var##__dummy_read {; } /* semicolon catcher */
-#define LDLM_POOL_PROC_WRITER(var, type) \
- static int lprocfs_wr_##var(struct file *file, \
- const char __user *buffer, \
- unsigned long count, void *data) \
+#define LDLM_POOL_SYSFS_WRITER_STORE(var, type) \
+ static ssize_t var##_store(struct kobject *kobj, \
+ struct attribute *attr, \
+ const char *buffer, \
+ size_t count) \
{ \
- struct ldlm_pool *pl = data; \
- type tmp; \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
+ unsigned long tmp; \
int rc; \
\
- rc = lprocfs_wr_uint(file, buffer, count, &tmp); \
+ rc = kstrtoul(buffer, 10, &tmp); \
if (rc < 0) { \
- CERROR("Can't parse user input, rc = %d\n", rc); \
return rc; \
} \
\
spin_lock(&pl->pl_lock); \
- pl->pl_##var = tmp; \
+ LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \
spin_unlock(&pl->pl_lock); \
\
- return rc; \
+ return count; \
+ } \
+ struct __##var##__dummy_write {; } /* semicolon catcher */
+
+#define LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(var, type) \
+ static ssize_t var##_show(struct kobject *kobj, \
+ struct attribute *attr, \
+ char *buf) \
+ { \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
+ \
+ return LDLM_POOL_SYSFS_PRINT_##type(pl->pl_##var); \
+ } \
+ struct __##var##__dummy_read {; } /* semicolon catcher */
+
+#define LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(var, type) \
+ static ssize_t var##_store(struct kobject *kobj, \
+ struct attribute *attr, \
+ const char *buffer, \
+ size_t count) \
+ { \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
+ unsigned long tmp; \
+ int rc; \
+ \
+ rc = kstrtoul(buffer, 10, &tmp); \
+ if (rc < 0) { \
+ return rc; \
+ } \
+ \
+ LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \
+ \
+ return count; \
} \
struct __##var##__dummy_write {; } /* semicolon catcher */
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index c5c86e73c..ccce1e503 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -73,7 +73,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
}
if (create) {
- OBD_ALLOC(imp_conn, sizeof(*imp_conn));
+ imp_conn = kzalloc(sizeof(*imp_conn), GFP_NOFS);
if (!imp_conn) {
rc = -ENOMEM;
goto out_put;
@@ -119,8 +119,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
spin_unlock(&imp->imp_lock);
return 0;
out_free:
- if (imp_conn)
- OBD_FREE(imp_conn, sizeof(*imp_conn));
+ kfree(imp_conn);
out_put:
ptlrpc_connection_put(ptlrpc_conn);
return rc;
@@ -179,7 +178,7 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
list_del(&imp_conn->oic_item);
ptlrpc_connection_put(imp_conn->oic_conn);
- OBD_FREE(imp_conn, sizeof(*imp_conn));
+ kfree(imp_conn);
CDEBUG(D_HA, "imp %p@%s: remove connection %s\n",
imp, imp->imp_obd->obd_name, uuid->uuid);
rc = 0;
@@ -336,7 +335,6 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
}
init_rwsem(&cli->cl_sem);
- mutex_init(&cli->cl_mgc_mutex);
cli->cl_conn_count = 0;
memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2),
min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2),
@@ -628,7 +626,6 @@ out_disconnect:
}
EXPORT_SYMBOL(client_disconnect_export);
-
/**
* Packs current SLV and Limit into \a req.
*/
@@ -657,7 +654,8 @@ int target_pack_pool_reply(struct ptlrpc_request *req)
}
EXPORT_SYMBOL(target_pack_pool_reply);
-int target_send_reply_msg(struct ptlrpc_request *req, int rc, int fail_id)
+static int
+target_send_reply_msg(struct ptlrpc_request *req, int rc, int fail_id)
{
if (OBD_FAIL_CHECK_ORSET(fail_id & ~OBD_FAIL_ONCE, OBD_FAIL_ONCE)) {
DEBUG_REQ(D_ERROR, req, "dropping reply");
@@ -668,10 +666,9 @@ int target_send_reply_msg(struct ptlrpc_request *req, int rc, int fail_id)
DEBUG_REQ(D_NET, req, "processing error (%d)", rc);
req->rq_status = rc;
return ptlrpc_send_error(req, 1);
- } else {
- DEBUG_REQ(D_NET, req, "sending reply");
}
+ DEBUG_REQ(D_NET, req, "sending reply");
return ptlrpc_send_reply(req, PTLRPC_REPLY_MAYBE_DIFFICULT);
}
@@ -816,42 +813,6 @@ int ldlm_error2errno(ldlm_error_t error)
}
EXPORT_SYMBOL(ldlm_error2errno);
-/**
- * Dual to ldlm_error2errno(): maps errno values back to ldlm_error_t.
- */
-ldlm_error_t ldlm_errno2error(int err_no)
-{
- int error;
-
- switch (err_no) {
- case 0:
- error = ELDLM_OK;
- break;
- case -ESTALE:
- error = ELDLM_LOCK_CHANGED;
- break;
- case -ENAVAIL:
- error = ELDLM_LOCK_ABORTED;
- break;
- case -ESRCH:
- error = ELDLM_LOCK_REPLACED;
- break;
- case -ENOENT:
- error = ELDLM_NO_LOCK_DATA;
- break;
- case -EEXIST:
- error = ELDLM_NAMESPACE_EXISTS;
- break;
- case -EBADF:
- error = ELDLM_BAD_NAMESPACE;
- break;
- default:
- error = err_no;
- }
- return error;
-}
-EXPORT_SYMBOL(ldlm_errno2error);
-
#if LUSTRE_TRACKS_LOCK_EXP_REFS
void ldlm_dump_export_locks(struct obd_export *exp)
{
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 84b111eb4..7f8c70056 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -60,13 +60,12 @@ char *ldlm_lockname[] = {
};
EXPORT_SYMBOL(ldlm_lockname);
-char *ldlm_typename[] = {
+static char *ldlm_typename[] = {
[LDLM_PLAIN] = "PLN",
[LDLM_EXTENT] = "EXT",
[LDLM_FLOCK] = "FLK",
[LDLM_IBITS] = "IBT",
};
-EXPORT_SYMBOL(ldlm_typename);
static ldlm_policy_wire_to_local_t ldlm_policy_wire18_to_local[] = {
[LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local,
@@ -92,9 +91,9 @@ static ldlm_policy_local_to_wire_t ldlm_policy_local_to_wire[] = {
/**
* Converts lock policy from local format to on the wire lock_desc format
*/
-void ldlm_convert_policy_to_wire(ldlm_type_t type,
- const ldlm_policy_data_t *lpolicy,
- ldlm_wire_policy_data_t *wpolicy)
+static void ldlm_convert_policy_to_wire(ldlm_type_t type,
+ const ldlm_policy_data_t *lpolicy,
+ ldlm_wire_policy_data_t *wpolicy)
{
ldlm_policy_local_to_wire_t convert;
@@ -151,18 +150,10 @@ char *ldlm_it2str(int it)
}
EXPORT_SYMBOL(ldlm_it2str);
-
-void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg)
-{
- ns->ns_policy = arg;
-}
-EXPORT_SYMBOL(ldlm_register_intent);
-
/*
* REFCOUNTED LOCK OBJECTS
*/
-
/**
* Get a reference on a lock.
*
@@ -208,8 +199,7 @@ void ldlm_lock_put(struct ldlm_lock *lock)
lock->l_export = NULL;
}
- if (lock->l_lvb_data != NULL)
- OBD_FREE(lock->l_lvb_data, lock->l_lvb_len);
+ kfree(lock->l_lvb_data);
ldlm_interval_free(ldlm_interval_detach(lock));
lu_ref_fini(&lock->l_reference);
@@ -245,11 +235,6 @@ int ldlm_lock_remove_from_lru(struct ldlm_lock *lock)
struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
int rc;
- if (lock->l_flags & LDLM_FL_NS_SRV) {
- LASSERT(list_empty(&lock->l_lru));
- return 0;
- }
-
spin_lock(&ns->ns_lock);
rc = ldlm_lock_remove_from_lru_nolock(lock);
spin_unlock(&ns->ns_lock);
@@ -259,7 +244,7 @@ int ldlm_lock_remove_from_lru(struct ldlm_lock *lock)
/**
* Adds LDLM lock \a lock to namespace LRU. Assumes LRU is already locked.
*/
-void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
+static void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
{
struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
@@ -277,7 +262,7 @@ void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
* Adds LDLM lock \a lock to namespace LRU. Obtains necessary LRU locks
* first.
*/
-void ldlm_lock_add_to_lru(struct ldlm_lock *lock)
+static void ldlm_lock_add_to_lru(struct ldlm_lock *lock)
{
struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
@@ -290,15 +275,10 @@ void ldlm_lock_add_to_lru(struct ldlm_lock *lock)
* Moves LDLM lock \a lock that is already in namespace LRU to the tail of
* the LRU. Performs necessary LRU locking
*/
-void ldlm_lock_touch_in_lru(struct ldlm_lock *lock)
+static void ldlm_lock_touch_in_lru(struct ldlm_lock *lock)
{
struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
- if (lock->l_flags & LDLM_FL_NS_SRV) {
- LASSERT(list_empty(&lock->l_lru));
- return;
- }
-
spin_lock(&ns->ns_lock);
if (!list_empty(&lock->l_lru)) {
ldlm_lock_remove_from_lru_nolock(lock);
@@ -326,7 +306,7 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock)
* ldlm_lock_destroy, you can never drop your final references on this lock.
* Because it's not in the hash table anymore. -phil
*/
-int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
+static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
{
if (lock->l_readers || lock->l_writers) {
LDLM_ERROR(lock, "lock still has references");
@@ -373,7 +353,7 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
/**
* Destroys a LDLM lock \a lock. Performs necessary locking first.
*/
-void ldlm_lock_destroy(struct ldlm_lock *lock)
+static void ldlm_lock_destroy(struct ldlm_lock *lock)
{
int first;
@@ -412,10 +392,10 @@ static void lock_handle_addref(void *lock)
static void lock_handle_free(void *lock, int size)
{
LASSERT(size == sizeof(struct ldlm_lock));
- OBD_SLAB_FREE(lock, ldlm_lock_slab, size);
+ kmem_cache_free(ldlm_lock_slab, lock);
}
-struct portals_handle_ops lock_handle_ops = {
+static struct portals_handle_ops lock_handle_ops = {
.hop_addref = lock_handle_addref,
.hop_free = lock_handle_free,
};
@@ -435,7 +415,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
if (resource == NULL)
LBUG();
- OBD_SLAB_ALLOC_PTR_GFP(lock, ldlm_lock_slab, GFP_NOFS);
+ lock = kmem_cache_alloc(ldlm_lock_slab, GFP_NOFS | __GFP_ZERO);
if (lock == NULL)
return NULL;
@@ -488,8 +468,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock,
struct ldlm_resource *newres;
int type;
- LASSERT(ns_is_client(ns));
-
lock_res_and_lock(lock);
if (memcmp(new_resid, &lock->l_resource->lr_name,
sizeof(lock->l_resource->lr_name)) == 0) {
@@ -626,8 +604,8 @@ EXPORT_SYMBOL(ldlm_lock2desc);
*
* Only add if we have not sent a blocking AST to the lock yet.
*/
-void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
- struct list_head *work_list)
+static void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
+ struct list_head *work_list)
{
if ((lock->l_flags & LDLM_FL_AST_SENT) == 0) {
LDLM_DEBUG(lock, "lock incompatible; sending blocking AST.");
@@ -647,7 +625,8 @@ void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
/**
* Add a lock to list of just granted locks to send completion AST to.
*/
-void ldlm_add_cp_work_item(struct ldlm_lock *lock, struct list_head *work_list)
+static void ldlm_add_cp_work_item(struct ldlm_lock *lock,
+ struct list_head *work_list)
{
if ((lock->l_flags & LDLM_FL_CP_REQD) == 0) {
lock->l_flags |= LDLM_FL_CP_REQD;
@@ -664,8 +643,9 @@ void ldlm_add_cp_work_item(struct ldlm_lock *lock, struct list_head *work_list)
* adding function.
* Must be called with lr_lock held.
*/
-void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
- struct list_head *work_list)
+static void ldlm_add_ast_work_item(struct ldlm_lock *lock,
+ struct ldlm_lock *new,
+ struct list_head *work_list)
{
check_res_locked(lock->l_resource);
if (new)
@@ -809,8 +789,6 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode)
(lock->l_flags & LDLM_FL_CBPENDING)) {
/* If we received a blocked AST and this was the last reference,
* run the callback. */
- if ((lock->l_flags & LDLM_FL_NS_SRV) && lock->l_export)
- CERROR("FL_CBPENDING set on non-local lock--just a warning\n");
LDLM_DEBUG(lock, "final decref done on cbpending lock");
@@ -824,8 +802,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode)
if ((lock->l_flags & LDLM_FL_ATOMIC_CB) ||
ldlm_bl_to_thread_lock(ns, NULL, lock) != 0)
ldlm_handle_bl_callback(ns, NULL, lock);
- } else if (ns_is_client(ns) &&
- !lock->l_readers && !lock->l_writers &&
+ } else if (!lock->l_readers && !lock->l_writers &&
!(lock->l_flags & LDLM_FL_NO_LRU) &&
!(lock->l_flags & LDLM_FL_BL_AST)) {
@@ -932,7 +909,9 @@ static void search_granted_lock(struct list_head *queue,
prev->mode_link = &mode_end->l_sl_mode;
prev->policy_link = &req->l_sl_policy;
return;
- } else if (lock->l_resource->lr_type == LDLM_IBITS) {
+ }
+
+ if (lock->l_resource->lr_type == LDLM_IBITS) {
for (;;) {
policy_end =
list_entry(lock->l_sl_policy.prev,
@@ -968,11 +947,10 @@ static void search_granted_lock(struct list_head *queue,
prev->mode_link = &mode_end->l_sl_mode;
prev->policy_link = &req->l_sl_policy;
return;
- } else {
- LDLM_ERROR(lock,
- "is not LDLM_PLAIN or LDLM_IBITS lock");
- LBUG();
}
+
+ LDLM_ERROR(lock, "is not LDLM_PLAIN or LDLM_IBITS lock");
+ LBUG();
}
/* insert point is last lock on the queue,
@@ -1158,14 +1136,6 @@ void ldlm_lock_fail_match_locked(struct ldlm_lock *lock)
}
EXPORT_SYMBOL(ldlm_lock_fail_match_locked);
-void ldlm_lock_fail_match(struct ldlm_lock *lock)
-{
- lock_res_and_lock(lock);
- ldlm_lock_fail_match_locked(lock);
- unlock_res_and_lock(lock);
-}
-EXPORT_SYMBOL(ldlm_lock_fail_match);
-
/**
* Mark lock as "matchable" by OST.
*
@@ -1260,12 +1230,6 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags,
rc = 0;
goto out;
}
- lock = search_queue(&res->lr_converting, &mode, policy, old_lock,
- flags, unref);
- if (lock != NULL) {
- rc = 1;
- goto out;
- }
lock = search_queue(&res->lr_waiting, &mode, policy, old_lock,
flags, unref);
if (lock != NULL) {
@@ -1510,8 +1474,6 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
lock->l_req_mode = mode;
lock->l_ast_data = data;
lock->l_pid = current_pid();
- if (ns_is_server(ns))
- lock->l_flags |= LDLM_FL_NS_SRV;
if (cbs) {
lock->l_blocking_ast = cbs->lcs_blocking;
lock->l_completion_ast = cbs->lcs_completion;
@@ -1527,8 +1489,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
if (lvb_len) {
lock->l_lvb_len = lvb_len;
- OBD_ALLOC(lock->l_lvb_data, lvb_len);
- if (lock->l_lvb_data == NULL)
+ lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS);
+ if (!lock->l_lvb_data)
goto out;
}
@@ -1546,13 +1508,11 @@ out:
/**
* Enqueue (request) a lock.
+ * On the client this is called from ldlm_cli_enqueue_fini
+ * after we already got an initial reply from the server with some status.
*
* Does not block. As a result of enqueue the lock would be put
* into granted or waiting list.
- *
- * If namespace has intent policy sent and the lock has LDLM_FL_HAS_INTENT flag
- * set, skip all the enqueueing and delegate lock processing to intent policy
- * function.
*/
ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
struct ldlm_lock **lockp,
@@ -1560,43 +1520,11 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
{
struct ldlm_lock *lock = *lockp;
struct ldlm_resource *res = lock->l_resource;
- int local = ns_is_client(ldlm_res_to_ns(res));
- ldlm_error_t rc = ELDLM_OK;
- struct ldlm_interval *node = NULL;
-
- lock->l_last_activity = get_seconds();
- /* policies are not executed on the client or during replay */
- if ((*flags & (LDLM_FL_HAS_INTENT|LDLM_FL_REPLAY)) == LDLM_FL_HAS_INTENT
- && !local && ns->ns_policy) {
- rc = ns->ns_policy(ns, lockp, cookie, lock->l_req_mode, *flags,
- NULL);
- if (rc == ELDLM_LOCK_REPLACED) {
- /* The lock that was returned has already been granted,
- * and placed into lockp. If it's not the same as the
- * one we passed in, then destroy the old one and our
- * work here is done. */
- if (lock != *lockp) {
- ldlm_lock_destroy(lock);
- LDLM_LOCK_RELEASE(lock);
- }
- *flags |= LDLM_FL_LOCK_CHANGED;
- return 0;
- } else if (rc != ELDLM_OK ||
- (rc == ELDLM_OK && (*flags & LDLM_FL_INTENT_ONLY))) {
- ldlm_lock_destroy(lock);
- return rc;
- }
- }
- /* For a replaying lock, it might be already in granted list. So
- * unlinking the lock will cause the interval node to be freed, we
- * have to allocate the interval node early otherwise we can't regrant
- * this lock in the future. - jay */
- if (!local && (*flags & LDLM_FL_REPLAY) && res->lr_type == LDLM_EXTENT)
- OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS);
+ lock->l_last_activity = ktime_get_real_seconds();
lock_res_and_lock(lock);
- if (local && lock->l_req_mode == lock->l_granted_mode) {
+ if (lock->l_req_mode == lock->l_granted_mode) {
/* The server returned a blocked lock, but it was granted
* before we got a chance to actually enqueue it. We don't
* need to do anything else. */
@@ -1606,54 +1534,32 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
}
ldlm_resource_unlink_lock(lock);
- if (res->lr_type == LDLM_EXTENT && lock->l_tree_node == NULL) {
- if (node == NULL) {
- ldlm_lock_destroy_nolock(lock);
- rc = -ENOMEM;
- goto out;
- }
- INIT_LIST_HEAD(&node->li_group);
- ldlm_interval_attach(node, lock);
- node = NULL;
- }
+ /* Cannot happen unless on the server */
+ if (res->lr_type == LDLM_EXTENT && !lock->l_tree_node)
+ LBUG();
/* Some flags from the enqueue want to make it into the AST, via the
* lock's l_flags. */
lock->l_flags |= *flags & LDLM_FL_AST_DISCARD_DATA;
- /* This distinction between local lock trees is very important; a client
+ /*
+ * This distinction between local lock trees is very important; a client
* namespace only has information about locks taken by that client, and
* thus doesn't have enough information to decide for itself if it can
* be granted (below). In this case, we do exactly what the server
* tells us to do, as dictated by the 'flags'.
- *
- * We do exactly the same thing during recovery, when the server is
- * more or less trusting the clients not to lie.
- *
- * FIXME (bug 268): Detect obvious lies by checking compatibility in
- * granted/converting queues. */
- if (local) {
- if (*flags & LDLM_FL_BLOCK_CONV)
- ldlm_resource_add_lock(res, &res->lr_converting, lock);
- else if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED))
- ldlm_resource_add_lock(res, &res->lr_waiting, lock);
- else
- ldlm_grant_lock(lock, NULL);
- goto out;
- } else {
- CERROR("This is client-side-only module, cannot handle LDLM_NAMESPACE_SERVER resource type lock.\n");
- LBUG();
- }
+ */
+ if (*flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED))
+ ldlm_resource_add_lock(res, &res->lr_waiting, lock);
+ else
+ ldlm_grant_lock(lock, NULL);
out:
unlock_res_and_lock(lock);
- if (node)
- OBD_SLAB_FREE(node, ldlm_interval_slab, sizeof(*node));
- return rc;
+ return ELDLM_OK;
}
-
/**
* Process a call to blocking AST callback for a lock in ast_work list
*/
@@ -1765,7 +1671,7 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
/**
* Process a call to glimpse AST callback for a lock in ast_work list
*/
-int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
+static int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
{
struct ldlm_cb_set_arg *arg = opaq;
struct ldlm_glimpse_work *gl_work;
@@ -1791,7 +1697,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
LDLM_LOCK_RELEASE(lock);
if ((gl_work->gl_flags & LDLM_GL_WORK_NOFREE) == 0)
- OBD_FREE_PTR(gl_work);
+ kfree(gl_work);
return rc;
}
@@ -1812,8 +1718,8 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
if (list_empty(rpc_list))
return 0;
- OBD_ALLOC_PTR(arg);
- if (arg == NULL)
+ arg = kzalloc(sizeof(*arg), GFP_NOFS);
+ if (!arg)
return -ENOMEM;
atomic_set(&arg->restart, 0);
@@ -1857,58 +1763,10 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
rc = atomic_read(&arg->restart) ? -ERESTART : 0;
goto out;
out:
- OBD_FREE_PTR(arg);
+ kfree(arg);
return rc;
}
-static int reprocess_one_queue(struct ldlm_resource *res, void *closure)
-{
- ldlm_reprocess_all(res);
- return LDLM_ITER_CONTINUE;
-}
-
-static int ldlm_reprocess_res(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *hnode, void *arg)
-{
- struct ldlm_resource *res = cfs_hash_object(hs, hnode);
- int rc;
-
- rc = reprocess_one_queue(res, arg);
-
- return rc == LDLM_ITER_STOP;
-}
-
-/**
- * Iterate through all resources on a namespace attempting to grant waiting
- * locks.
- */
-void ldlm_reprocess_all_ns(struct ldlm_namespace *ns)
-{
- if (ns != NULL) {
- cfs_hash_for_each_nolock(ns->ns_rs_hash,
- ldlm_reprocess_res, NULL);
- }
-}
-EXPORT_SYMBOL(ldlm_reprocess_all_ns);
-
-/**
- * Try to grant all waiting locks on a resource.
- *
- * Calls ldlm_reprocess_queue on converting and waiting queues.
- *
- * Typically called after some resource locks are cancelled to see
- * if anything could be granted as a result of the cancellation.
- */
-void ldlm_reprocess_all(struct ldlm_resource *res)
-{
- LIST_HEAD(rpc_list);
-
- if (!ns_is_client(ldlm_res_to_ns(res))) {
- CERROR("This is client-side-only module, cannot handle LDLM_NAMESPACE_SERVER resource type lock.\n");
- LBUG();
- }
-}
-
/**
* Helper function to call blocking AST for LDLM lock \a lock in a
* "cancelling" mode.
@@ -1963,17 +1821,9 @@ void ldlm_lock_cancel(struct ldlm_lock *lock)
LBUG();
}
- if (lock->l_flags & LDLM_FL_WAITED)
- ldlm_del_waiting_lock(lock);
-
/* Releases cancel callback. */
ldlm_cancel_callback(lock);
- /* Yes, second time, just in case it was added again while we were
- * running with no res lock in ldlm_cancel_callback */
- if (lock->l_flags & LDLM_FL_WAITED)
- ldlm_del_waiting_lock(lock);
-
ldlm_resource_unlink_lock(lock);
ldlm_lock_destroy_nolock(lock);
@@ -2012,175 +1862,6 @@ struct export_cl_data {
};
/**
- * Iterator function for ldlm_cancel_locks_for_export.
- * Cancels passed locks.
- */
-int ldlm_cancel_locks_for_export_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *hnode, void *data)
-
-{
- struct export_cl_data *ecl = (struct export_cl_data *)data;
- struct obd_export *exp = ecl->ecl_exp;
- struct ldlm_lock *lock = cfs_hash_object(hs, hnode);
- struct ldlm_resource *res;
-
- res = ldlm_resource_getref(lock->l_resource);
- LDLM_LOCK_GET(lock);
-
- LDLM_DEBUG(lock, "export %p", exp);
- ldlm_res_lvbo_update(res, NULL, 1);
- ldlm_lock_cancel(lock);
- ldlm_reprocess_all(res);
- ldlm_resource_putref(res);
- LDLM_LOCK_RELEASE(lock);
-
- ecl->ecl_loop++;
- if ((ecl->ecl_loop & -ecl->ecl_loop) == ecl->ecl_loop) {
- CDEBUG(D_INFO,
- "Cancel lock %p for export %p (loop %d), still have %d locks left on hash table.\n",
- lock, exp, ecl->ecl_loop,
- atomic_read(&hs->hs_count));
- }
-
- return 0;
-}
-
-/**
- * Cancel all locks for given export.
- *
- * Typically called on client disconnection/eviction
- */
-void ldlm_cancel_locks_for_export(struct obd_export *exp)
-{
- struct export_cl_data ecl = {
- .ecl_exp = exp,
- .ecl_loop = 0,
- };
-
- cfs_hash_for_each_empty(exp->exp_lock_hash,
- ldlm_cancel_locks_for_export_cb, &ecl);
-}
-
-/**
- * Downgrade an exclusive lock.
- *
- * A fast variant of ldlm_lock_convert for conversion of exclusive
- * locks. The conversion is always successful.
- * Used by Commit on Sharing (COS) code.
- *
- * \param lock A lock to convert
- * \param new_mode new lock mode
- */
-void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode)
-{
- LASSERT(lock->l_granted_mode & (LCK_PW | LCK_EX));
- LASSERT(new_mode == LCK_COS);
-
- lock_res_and_lock(lock);
- ldlm_resource_unlink_lock(lock);
- /*
- * Remove the lock from pool as it will be added again in
- * ldlm_grant_lock() called below.
- */
- ldlm_pool_del(&ldlm_lock_to_ns(lock)->ns_pool, lock);
-
- lock->l_req_mode = new_mode;
- ldlm_grant_lock(lock, NULL);
- unlock_res_and_lock(lock);
- ldlm_reprocess_all(lock->l_resource);
-}
-EXPORT_SYMBOL(ldlm_lock_downgrade);
-
-/**
- * Attempt to convert already granted lock to a different mode.
- *
- * While lock conversion is not currently used, future client-side
- * optimizations could take advantage of it to avoid discarding cached
- * pages on a file.
- */
-struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
- __u32 *flags)
-{
- LIST_HEAD(rpc_list);
- struct ldlm_resource *res;
- struct ldlm_namespace *ns;
- int granted = 0;
- struct ldlm_interval *node;
-
- /* Just return if mode is unchanged. */
- if (new_mode == lock->l_granted_mode) {
- *flags |= LDLM_FL_BLOCK_GRANTED;
- return lock->l_resource;
- }
-
- /* I can't check the type of lock here because the bitlock of lock
- * is not held here, so do the allocation blindly. -jay */
- OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS);
- if (node == NULL)
- /* Actually, this causes EDEADLOCK to be returned */
- return NULL;
-
- LASSERTF((new_mode == LCK_PW && lock->l_granted_mode == LCK_PR),
- "new_mode %u, granted %u\n", new_mode, lock->l_granted_mode);
-
- lock_res_and_lock(lock);
-
- res = lock->l_resource;
- ns = ldlm_res_to_ns(res);
-
- lock->l_req_mode = new_mode;
- if (res->lr_type == LDLM_PLAIN || res->lr_type == LDLM_IBITS) {
- ldlm_resource_unlink_lock(lock);
- } else {
- ldlm_resource_unlink_lock(lock);
- if (res->lr_type == LDLM_EXTENT) {
- /* FIXME: ugly code, I have to attach the lock to a
- * interval node again since perhaps it will be granted
- * soon */
- INIT_LIST_HEAD(&node->li_group);
- ldlm_interval_attach(node, lock);
- node = NULL;
- }
- }
-
- /*
- * Remove old lock from the pool before adding the lock with new
- * mode below in ->policy()
- */
- ldlm_pool_del(&ns->ns_pool, lock);
-
- /* If this is a local resource, put it on the appropriate list. */
- if (ns_is_client(ldlm_res_to_ns(res))) {
- if (*flags & (LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_GRANTED)) {
- ldlm_resource_add_lock(res, &res->lr_converting, lock);
- } else {
- /* This should never happen, because of the way the
- * server handles conversions. */
- LDLM_ERROR(lock, "Erroneous flags %x on local lock\n",
- *flags);
- LBUG();
-
- ldlm_grant_lock(lock, &rpc_list);
- granted = 1;
- /* FIXME: completion handling not with lr_lock held ! */
- if (lock->l_completion_ast)
- lock->l_completion_ast(lock, 0, NULL);
- }
- } else {
- CERROR("This is client-side-only module, cannot handle LDLM_NAMESPACE_SERVER resource type lock.\n");
- LBUG();
- }
- unlock_res_and_lock(lock);
-
- if (granted)
- ldlm_run_ast_work(ns, &rpc_list, LDLM_WORK_CP_AST);
- if (node)
- OBD_SLAB_FREE(node, ldlm_interval_slab, sizeof(*node));
- return res;
-}
-EXPORT_SYMBOL(ldlm_lock_convert);
-
-/**
* Print lock with lock handle \a lockh description into debug log.
*
* Used when printing all locks on a resource for debug purposes.
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 08a91f5d9..ca1151195 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -58,6 +58,10 @@ MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on");
static struct mutex ldlm_ref_mutex;
static int ldlm_refcount;
+static struct kobject *ldlm_kobj;
+struct kset *ldlm_ns_kset;
+static struct kset *ldlm_svc_kset;
+
struct ldlm_cb_async_args {
struct ldlm_cb_set_arg *ca_set_arg;
struct ldlm_lock *ca_lock;
@@ -67,20 +71,6 @@ struct ldlm_cb_async_args {
static struct ldlm_state *ldlm_state;
-inline unsigned long round_timeout(unsigned long timeout)
-{
- return cfs_time_seconds((int)cfs_duration_sec(cfs_time_sub(timeout, 0)) + 1);
-}
-
-/* timeout for initial callback (AST) reply (bz10399) */
-static inline unsigned int ldlm_get_rq_timeout(void)
-{
- /* Non-AT value */
- unsigned int timeout = min(ldlm_timeout, obd_timeout / 3);
-
- return timeout < 1 ? 1 : timeout;
-}
-
#define ELT_STOPPED 0
#define ELT_READY 1
#define ELT_TERMINATE 2
@@ -121,19 +111,6 @@ struct ldlm_bl_work_item {
int blwi_mem_pressure;
};
-
-int ldlm_del_waiting_lock(struct ldlm_lock *lock)
-{
- return 0;
-}
-
-int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout)
-{
- return 0;
-}
-
-
-
/**
* Callback handler for receiving incoming blocking ASTs.
*
@@ -220,8 +197,8 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
* variable length */
void *lvb_data;
- OBD_ALLOC(lvb_data, lvb_len);
- if (lvb_data == NULL) {
+ lvb_data = kzalloc(lvb_len, GFP_NOFS);
+ if (!lvb_data) {
LDLM_ERROR(lock, "No memory: %d.\n", lvb_len);
rc = -ENOMEM;
goto out;
@@ -448,8 +425,8 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns,
if (cancel_flags & LCF_ASYNC) {
struct ldlm_bl_work_item *blwi;
- OBD_ALLOC(blwi, sizeof(*blwi));
- if (blwi == NULL)
+ blwi = kzalloc(sizeof(*blwi), GFP_NOFS);
+ if (!blwi)
return -ENOMEM;
init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags);
@@ -466,7 +443,6 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns,
}
}
-
int ldlm_bl_to_thread_lock(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
struct ldlm_lock *lock)
{
@@ -718,7 +694,6 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
return 0;
}
-
static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp)
{
struct ldlm_bl_work_item *blwi = NULL;
@@ -849,7 +824,7 @@ static int ldlm_bl_thread_main(void *arg)
memory_pressure_clr();
if (blwi->blwi_flags & LCF_ASYNC)
- OBD_FREE(blwi, sizeof(*blwi));
+ kfree(blwi);
else
complete(&blwi->blwi_comp);
}
@@ -860,7 +835,6 @@ static int ldlm_bl_thread_main(void *arg)
return 0;
}
-
static int ldlm_setup(void);
static int ldlm_cleanup(void);
@@ -897,110 +871,42 @@ void ldlm_put_ref(void)
}
EXPORT_SYMBOL(ldlm_put_ref);
-/*
- * Export handle<->lock hash operations.
- */
-static unsigned
-ldlm_export_lock_hash(struct cfs_hash *hs, const void *key, unsigned mask)
-{
- return cfs_hash_u64_hash(((struct lustre_handle *)key)->cookie, mask);
-}
+extern unsigned int ldlm_cancel_unused_locks_before_replay;
-static void *
-ldlm_export_lock_key(struct hlist_node *hnode)
+static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct ldlm_lock *lock;
-
- lock = hlist_entry(hnode, struct ldlm_lock, l_exp_hash);
- return &lock->l_remote_handle;
+ return sprintf(buf, "%d\n", ldlm_cancel_unused_locks_before_replay);
}
-static void
-ldlm_export_lock_keycpy(struct hlist_node *hnode, void *key)
-{
- struct ldlm_lock *lock;
-
- lock = hlist_entry(hnode, struct ldlm_lock, l_exp_hash);
- lock->l_remote_handle = *(struct lustre_handle *)key;
-}
-
-static int
-ldlm_export_lock_keycmp(const void *key, struct hlist_node *hnode)
-{
- return lustre_handle_equal(ldlm_export_lock_key(hnode), key);
-}
-
-static void *
-ldlm_export_lock_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct ldlm_lock, l_exp_hash);
-}
-
-static void
-ldlm_export_lock_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct ldlm_lock *lock;
-
- lock = hlist_entry(hnode, struct ldlm_lock, l_exp_hash);
- LDLM_LOCK_GET(lock);
-}
-
-static void
-ldlm_export_lock_put(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct ldlm_lock *lock;
-
- lock = hlist_entry(hnode, struct ldlm_lock, l_exp_hash);
- LDLM_LOCK_RELEASE(lock);
-}
-
-static cfs_hash_ops_t ldlm_export_lock_ops = {
- .hs_hash = ldlm_export_lock_hash,
- .hs_key = ldlm_export_lock_key,
- .hs_keycmp = ldlm_export_lock_keycmp,
- .hs_keycpy = ldlm_export_lock_keycpy,
- .hs_object = ldlm_export_lock_object,
- .hs_get = ldlm_export_lock_get,
- .hs_put = ldlm_export_lock_put,
- .hs_put_locked = ldlm_export_lock_put,
-};
-
-int ldlm_init_export(struct obd_export *exp)
+static ssize_t cancel_unused_locks_before_replay_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
int rc;
+ unsigned long val;
- exp->exp_lock_hash =
- cfs_hash_create(obd_uuid2str(&exp->exp_client_uuid),
- HASH_EXP_LOCK_CUR_BITS,
- HASH_EXP_LOCK_MAX_BITS,
- HASH_EXP_LOCK_BKT_BITS, 0,
- CFS_HASH_MIN_THETA, CFS_HASH_MAX_THETA,
- &ldlm_export_lock_ops,
- CFS_HASH_DEFAULT | CFS_HASH_REHASH_KEY |
- CFS_HASH_NBLK_CHANGE);
-
- if (!exp->exp_lock_hash)
- return -ENOMEM;
-
- rc = ldlm_init_flock_export(exp);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
- goto err;
+ return rc;
- return 0;
-err:
- ldlm_destroy_export(exp);
- return rc;
+ ldlm_cancel_unused_locks_before_replay = val;
+
+ return count;
}
-EXPORT_SYMBOL(ldlm_init_export);
+LUSTRE_RW_ATTR(cancel_unused_locks_before_replay);
-void ldlm_destroy_export(struct obd_export *exp)
-{
- cfs_hash_putref(exp->exp_lock_hash);
- exp->exp_lock_hash = NULL;
+/* These are for root of /sys/fs/lustre/ldlm */
+static struct attribute *ldlm_attrs[] = {
+ &lustre_attr_cancel_unused_locks_before_replay.attr,
+ NULL,
+};
- ldlm_destroy_flock_export(exp);
-}
-EXPORT_SYMBOL(ldlm_destroy_export);
+static struct attribute_group ldlm_attr_group = {
+ .attrs = ldlm_attrs,
+};
static int ldlm_setup(void)
{
@@ -1012,11 +918,33 @@ static int ldlm_setup(void)
if (ldlm_state != NULL)
return -EALREADY;
- OBD_ALLOC(ldlm_state, sizeof(*ldlm_state));
- if (ldlm_state == NULL)
+ ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS);
+ if (!ldlm_state)
return -ENOMEM;
- rc = ldlm_proc_setup();
+ ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj);
+ if (!ldlm_kobj) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ rc = sysfs_create_group(ldlm_kobj, &ldlm_attr_group);
+ if (rc)
+ goto out;
+
+ ldlm_ns_kset = kset_create_and_add("namespaces", NULL, ldlm_kobj);
+ if (!ldlm_ns_kset) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ ldlm_svc_kset = kset_create_and_add("services", NULL, ldlm_kobj);
+ if (!ldlm_svc_kset) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ rc = ldlm_debugfs_setup();
if (rc != 0)
goto out;
@@ -1050,7 +978,8 @@ static int ldlm_setup(void)
},
};
ldlm_state->ldlm_cb_service =
- ptlrpc_register_service(&conf, ldlm_svc_proc_dir);
+ ptlrpc_register_service(&conf, ldlm_svc_kset,
+ ldlm_svc_debugfs_dir);
if (IS_ERR(ldlm_state->ldlm_cb_service)) {
CERROR("failed to start service\n");
rc = PTR_ERR(ldlm_state->ldlm_cb_service);
@@ -1058,9 +987,8 @@ static int ldlm_setup(void)
goto out;
}
-
- OBD_ALLOC(blp, sizeof(*blp));
- if (blp == NULL) {
+ blp = kzalloc(sizeof(*blp), GFP_NOFS);
+ if (!blp) {
rc = -ENOMEM;
goto out;
}
@@ -1088,7 +1016,6 @@ static int ldlm_setup(void)
goto out;
}
-
rc = ldlm_pools_init();
if (rc) {
CERROR("Failed to initialize LDLM pools: %d\n", rc);
@@ -1129,16 +1056,22 @@ static int ldlm_cleanup(void)
wait_for_completion(&blp->blp_comp);
}
- OBD_FREE(blp, sizeof(*blp));
+ kfree(blp);
}
if (ldlm_state->ldlm_cb_service != NULL)
ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
- ldlm_proc_cleanup();
+ if (ldlm_ns_kset)
+ kset_unregister(ldlm_ns_kset);
+ if (ldlm_svc_kset)
+ kset_unregister(ldlm_svc_kset);
+ if (ldlm_kobj)
+ kobject_put(ldlm_kobj);
+ ldlm_debugfs_cleanup();
- OBD_FREE(ldlm_state, sizeof(*ldlm_state));
+ kfree(ldlm_state);
ldlm_state = NULL;
return 0;
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c
index a1fe2c161..0c1965dda 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c
@@ -58,7 +58,6 @@
#include "ldlm_internal.h"
-
void ldlm_plain_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
ldlm_policy_data_t *lpolicy)
{
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index a9f4833e0..1a4eef646 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -90,10 +90,10 @@
* pl_server_lock_volume - Current server lock volume (calculated);
*
* As it may be seen from list above, we have few possible tunables which may
- * affect behavior much. They all may be modified via proc. However, they also
+ * affect behavior much. They all may be modified via sysfs. However, they also
* give a possibility for constructing few pre-defined behavior policies. If
* none of predefines is suitable for a working pattern being used, new one may
- * be "constructed" via proc tunables.
+ * be "constructed" via sysfs tunables.
*/
#define DEBUG_SUBSYSTEM S_LDLM
@@ -104,7 +104,6 @@
#include "../include/obd_support.h"
#include "ldlm_internal.h"
-
/*
* 50 ldlm locks for 1MB of RAM.
*/
@@ -214,67 +213,19 @@ static inline int ldlm_pool_t2gsp(unsigned int t)
}
/**
- * Recalculates next grant limit on passed \a pl.
- *
- * \pre ->pl_lock is locked.
+ * Returns current \a pl limit.
*/
-static void ldlm_pool_recalc_grant_plan(struct ldlm_pool *pl)
+static __u32 ldlm_pool_get_limit(struct ldlm_pool *pl)
{
- int granted, grant_step, limit;
-
- limit = ldlm_pool_get_limit(pl);
- granted = atomic_read(&pl->pl_granted);
-
- grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period);
- grant_step = ((limit - granted) * grant_step) / 100;
- pl->pl_grant_plan = granted + grant_step;
- limit = (limit * 5) >> 2;
- if (pl->pl_grant_plan > limit)
- pl->pl_grant_plan = limit;
+ return atomic_read(&pl->pl_limit);
}
/**
- * Recalculates next SLV on passed \a pl.
- *
- * \pre ->pl_lock is locked.
+ * Sets passed \a limit to \a pl.
*/
-static void ldlm_pool_recalc_slv(struct ldlm_pool *pl)
+static void ldlm_pool_set_limit(struct ldlm_pool *pl, __u32 limit)
{
- int granted;
- int grant_plan;
- int round_up;
- __u64 slv;
- __u64 slv_factor;
- __u64 grant_usage;
- __u32 limit;
-
- slv = pl->pl_server_lock_volume;
- grant_plan = pl->pl_grant_plan;
- limit = ldlm_pool_get_limit(pl);
- granted = atomic_read(&pl->pl_granted);
- round_up = granted < limit;
-
- grant_usage = max_t(int, limit - (granted - grant_plan), 1);
-
- /*
- * Find out SLV change factor which is the ratio of grant usage
- * from limit. SLV changes as fast as the ratio of grant plan
- * consumption. The more locks from grant plan are not consumed
- * by clients in last interval (idle time), the faster grows
- * SLV. And the opposite, the more grant plan is over-consumed
- * (load time) the faster drops SLV.
- */
- slv_factor = grant_usage << LDLM_POOL_SLV_SHIFT;
- do_div(slv_factor, limit);
- slv = slv * slv_factor;
- slv = dru(slv, LDLM_POOL_SLV_SHIFT, round_up);
-
- if (slv > ldlm_pool_slv_max(limit))
- slv = ldlm_pool_slv_max(limit);
- else if (slv < ldlm_pool_slv_min(limit))
- slv = ldlm_pool_slv_min(limit);
-
- pl->pl_server_lock_volume = slv;
+ atomic_set(&pl->pl_limit, limit);
}
/**
@@ -303,147 +254,6 @@ static void ldlm_pool_recalc_stats(struct ldlm_pool *pl)
}
/**
- * Sets current SLV into obd accessible via ldlm_pl2ns(pl)->ns_obd.
- */
-static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl)
-{
- struct obd_device *obd;
-
- /*
- * Set new SLV in obd field for using it later without accessing the
- * pool. This is required to avoid race between sending reply to client
- * with new SLV and cleanup server stack in which we can't guarantee
- * that namespace is still alive. We know only that obd is alive as
- * long as valid export is alive.
- */
- obd = ldlm_pl2ns(pl)->ns_obd;
- LASSERT(obd != NULL);
- write_lock(&obd->obd_pool_lock);
- obd->obd_pool_slv = pl->pl_server_lock_volume;
- write_unlock(&obd->obd_pool_lock);
-}
-
-/**
- * Recalculates all pool fields on passed \a pl.
- *
- * \pre ->pl_lock is not locked.
- */
-static int ldlm_srv_pool_recalc(struct ldlm_pool *pl)
-{
- time_t recalc_interval_sec;
-
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
- if (recalc_interval_sec < pl->pl_recalc_period)
- return 0;
-
- spin_lock(&pl->pl_lock);
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
- if (recalc_interval_sec < pl->pl_recalc_period) {
- spin_unlock(&pl->pl_lock);
- return 0;
- }
- /*
- * Recalc SLV after last period. This should be done
- * _before_ recalculating new grant plan.
- */
- ldlm_pool_recalc_slv(pl);
-
- /*
- * Make sure that pool informed obd of last SLV changes.
- */
- ldlm_srv_pool_push_slv(pl);
-
- /*
- * Update grant_plan for new period.
- */
- ldlm_pool_recalc_grant_plan(pl);
-
- pl->pl_recalc_time = get_seconds();
- lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
- recalc_interval_sec);
- spin_unlock(&pl->pl_lock);
- return 0;
-}
-
-/**
- * This function is used on server side as main entry point for memory
- * pressure handling. It decreases SLV on \a pl according to passed
- * \a nr and \a gfp_mask.
- *
- * Our goal here is to decrease SLV such a way that clients hold \a nr
- * locks smaller in next 10h.
- */
-static int ldlm_srv_pool_shrink(struct ldlm_pool *pl,
- int nr, gfp_t gfp_mask)
-{
- __u32 limit;
-
- /*
- * VM is asking how many entries may be potentially freed.
- */
- if (nr == 0)
- return atomic_read(&pl->pl_granted);
-
- /*
- * Client already canceled locks but server is already in shrinker
- * and can't cancel anything. Let's catch this race.
- */
- if (atomic_read(&pl->pl_granted) == 0)
- return 0;
-
- spin_lock(&pl->pl_lock);
-
- /*
- * We want shrinker to possibly cause cancellation of @nr locks from
- * clients or grant approximately @nr locks smaller next intervals.
- *
- * This is why we decreased SLV by @nr. This effect will only be as
- * long as one re-calc interval (1s these days) and this should be
- * enough to pass this decreased SLV to all clients. On next recalc
- * interval pool will either increase SLV if locks load is not high
- * or will keep on same level or even decrease again, thus, shrinker
- * decreased SLV will affect next recalc intervals and this way will
- * make locking load lower.
- */
- if (nr < pl->pl_server_lock_volume) {
- pl->pl_server_lock_volume = pl->pl_server_lock_volume - nr;
- } else {
- limit = ldlm_pool_get_limit(pl);
- pl->pl_server_lock_volume = ldlm_pool_slv_min(limit);
- }
-
- /*
- * Make sure that pool informed obd of last SLV changes.
- */
- ldlm_srv_pool_push_slv(pl);
- spin_unlock(&pl->pl_lock);
-
- /*
- * We did not really free any memory here so far, it only will be
- * freed later may be, so that we return 0 to not confuse VM.
- */
- return 0;
-}
-
-/**
- * Setup server side pool \a pl with passed \a limit.
- */
-static int ldlm_srv_pool_setup(struct ldlm_pool *pl, int limit)
-{
- struct obd_device *obd;
-
- obd = ldlm_pl2ns(pl)->ns_obd;
- LASSERT(obd != NULL && obd != LP_POISON);
- LASSERT(obd->obd_type != LP_POISON);
- write_lock(&obd->obd_pool_lock);
- obd->obd_pool_limit = limit;
- write_unlock(&obd->obd_pool_lock);
-
- ldlm_pool_set_limit(pl, limit);
- return 0;
-}
-
-/**
* Sets SLV and Limit from ldlm_pl2ns(pl)->ns_obd tp passed \a pl.
*/
static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl)
@@ -467,10 +277,10 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl)
*/
static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
{
- time_t recalc_interval_sec;
+ time64_t recalc_interval_sec;
int ret;
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
+ recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time;
if (recalc_interval_sec < pl->pl_recalc_period)
return 0;
@@ -478,7 +288,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
/*
* Check if we need to recalc lists now.
*/
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
+ recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time;
if (recalc_interval_sec < pl->pl_recalc_period) {
spin_unlock(&pl->pl_lock);
return 0;
@@ -513,7 +323,7 @@ out:
* Time of LRU resizing might be longer than period,
* so update after LRU resizing rather than before it.
*/
- pl->pl_recalc_time = get_seconds();
+ pl->pl_recalc_time = ktime_get_real_seconds();
lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
recalc_interval_sec);
spin_unlock(&pl->pl_lock);
@@ -554,12 +364,6 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl,
return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK);
}
-static const struct ldlm_pool_ops ldlm_srv_pool_ops = {
- .po_recalc = ldlm_srv_pool_recalc,
- .po_shrink = ldlm_srv_pool_shrink,
- .po_setup = ldlm_srv_pool_setup
-};
-
static const struct ldlm_pool_ops ldlm_cli_pool_ops = {
.po_recalc = ldlm_cli_pool_recalc,
.po_shrink = ldlm_cli_pool_shrink
@@ -569,12 +373,12 @@ static const struct ldlm_pool_ops ldlm_cli_pool_ops = {
* Pool recalc wrapper. Will call either client or server pool recalc callback
* depending what pool \a pl is used.
*/
-int ldlm_pool_recalc(struct ldlm_pool *pl)
+static int ldlm_pool_recalc(struct ldlm_pool *pl)
{
- time_t recalc_interval_sec;
+ u32 recalc_interval_sec;
int count;
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
+ recalc_interval_sec = ktime_get_seconds() - pl->pl_recalc_time;
if (recalc_interval_sec <= 0)
goto recalc;
@@ -599,14 +403,14 @@ int ldlm_pool_recalc(struct ldlm_pool *pl)
lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT,
count);
}
- recalc_interval_sec = pl->pl_recalc_time - get_seconds() +
+ recalc_interval_sec = pl->pl_recalc_time - ktime_get_seconds() +
pl->pl_recalc_period;
if (recalc_interval_sec <= 0) {
/* Prevent too frequent recalculation. */
- CDEBUG(D_DLMTRACE, "Negative interval(%ld), "
- "too short period(%ld)",
+ CDEBUG(D_DLMTRACE,
+ "Negative interval(%d), too short period(%lld)",
recalc_interval_sec,
- pl->pl_recalc_period);
+ (s64)pl->pl_recalc_period);
recalc_interval_sec = 1;
}
@@ -618,8 +422,7 @@ int ldlm_pool_recalc(struct ldlm_pool *pl)
* depending what pool pl is used. When nr == 0, just return the number of
* freeable locks. Otherwise, return the number of canceled locks.
*/
-int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
- gfp_t gfp_mask)
+static int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, gfp_t gfp_mask)
{
int cancel = 0;
@@ -638,27 +441,11 @@ int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
}
return cancel;
}
-EXPORT_SYMBOL(ldlm_pool_shrink);
-
-/**
- * Pool setup wrapper. Will call either client or server pool recalc callback
- * depending what pool \a pl is used.
- *
- * Sets passed \a limit into pool \a pl.
- */
-int ldlm_pool_setup(struct ldlm_pool *pl, int limit)
-{
- if (pl->pl_ops->po_setup != NULL)
- return pl->pl_ops->po_setup(pl, limit);
- return 0;
-}
-EXPORT_SYMBOL(ldlm_pool_setup);
-#if defined(CONFIG_PROC_FS)
static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
{
- int granted, grant_rate, cancel_rate, grant_step;
- int grant_speed, grant_plan, lvf;
+ int granted, grant_rate, cancel_rate;
+ int grant_speed, lvf;
struct ldlm_pool *pl = m->private;
__u64 slv, clv;
__u32 limit;
@@ -667,13 +454,11 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
slv = pl->pl_server_lock_volume;
clv = pl->pl_client_lock_volume;
limit = ldlm_pool_get_limit(pl);
- grant_plan = pl->pl_grant_plan;
granted = atomic_read(&pl->pl_granted);
grant_rate = atomic_read(&pl->pl_grant_rate);
cancel_rate = atomic_read(&pl->pl_cancel_rate);
grant_speed = grant_rate - cancel_rate;
lvf = atomic_read(&pl->pl_lock_volume_factor);
- grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period);
spin_unlock(&pl->pl_lock);
seq_printf(m, "LDLM pool state (%s):\n"
@@ -682,11 +467,6 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
" LVF: %d\n",
pl->pl_name, slv, clv, lvf);
- if (ns_is_server(ldlm_pl2ns(pl))) {
- seq_printf(m, " GSP: %d%%\n"
- " GP: %d\n",
- grant_step, grant_plan);
- }
seq_printf(m, " GR: %d\n CR: %d\n GS: %d\n"
" G: %d\n L: %d\n",
grant_rate, cancel_rate, grant_speed,
@@ -694,11 +474,15 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
return 0;
}
+
LPROC_SEQ_FOPS_RO(lprocfs_pool_state);
-static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused)
+static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_pool *pl = m->private;
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool,
+ pl_kobj);
+
int grant_speed;
spin_lock(&pl->pl_lock);
@@ -706,63 +490,109 @@ static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused)
grant_speed = atomic_read(&pl->pl_grant_rate) -
atomic_read(&pl->pl_cancel_rate);
spin_unlock(&pl->pl_lock);
- return lprocfs_rd_uint(m, &grant_speed);
+ return sprintf(buf, "%d\n", grant_speed);
}
+LUSTRE_RO_ATTR(grant_speed);
-LDLM_POOL_PROC_READER_SEQ_SHOW(grant_plan, int);
-LPROC_SEQ_FOPS_RO(lprocfs_grant_plan);
+LDLM_POOL_SYSFS_READER_SHOW(grant_plan, int);
+LUSTRE_RO_ATTR(grant_plan);
-LDLM_POOL_PROC_READER_SEQ_SHOW(recalc_period, int);
-LDLM_POOL_PROC_WRITER(recalc_period, int);
-static ssize_t lprocfs_recalc_period_seq_write(struct file *file,
- const char __user *buf,
- size_t len, loff_t *off)
-{
- struct seq_file *seq = file->private_data;
+LDLM_POOL_SYSFS_READER_SHOW(recalc_period, int);
+LDLM_POOL_SYSFS_WRITER_STORE(recalc_period, int);
+LUSTRE_RW_ATTR(recalc_period);
- return lprocfs_wr_recalc_period(file, buf, len, seq->private);
-}
-LPROC_SEQ_FOPS(lprocfs_recalc_period);
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(server_lock_volume, u64);
+LUSTRE_RO_ATTR(server_lock_volume);
+
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(limit, atomic);
+LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(limit, atomic);
+LUSTRE_RW_ATTR(limit);
-LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, u64);
-LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, atomic);
-LPROC_SEQ_FOPS_RW_TYPE(ldlm_pool_rw, atomic);
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(granted, atomic);
+LUSTRE_RO_ATTR(granted);
-LPROC_SEQ_FOPS_RO(lprocfs_grant_speed);
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(cancel_rate, atomic);
+LUSTRE_RO_ATTR(cancel_rate);
+
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(grant_rate, atomic);
+LUSTRE_RO_ATTR(grant_rate);
+
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(lock_volume_factor, atomic);
+LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(lock_volume_factor, atomic);
+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].data = var; \
pool_vars[0].fops = ops; \
- lprocfs_add_vars(pl->pl_proc_dir, pool_vars, NULL);\
+ ldebugfs_add_vars(pl->pl_debugfs_entry, pool_vars, NULL);\
} while (0)
-static int ldlm_pool_proc_init(struct ldlm_pool *pl)
+/* These are for pools in /sys/fs/lustre/ldlm/namespaces/.../pool */
+static struct attribute *ldlm_pl_attrs[] = {
+ &lustre_attr_grant_speed.attr,
+ &lustre_attr_grant_plan.attr,
+ &lustre_attr_recalc_period.attr,
+ &lustre_attr_server_lock_volume.attr,
+ &lustre_attr_limit.attr,
+ &lustre_attr_granted.attr,
+ &lustre_attr_cancel_rate.attr,
+ &lustre_attr_grant_rate.attr,
+ &lustre_attr_lock_volume_factor.attr,
+ NULL,
+};
+
+static void ldlm_pl_release(struct kobject *kobj)
+{
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool,
+ pl_kobj);
+ complete(&pl->pl_kobj_unregister);
+}
+
+static struct kobj_type ldlm_pl_ktype = {
+ .default_attrs = ldlm_pl_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = ldlm_pl_release,
+};
+
+static int ldlm_pool_sysfs_init(struct ldlm_pool *pl)
{
struct ldlm_namespace *ns = ldlm_pl2ns(pl);
- struct proc_dir_entry *parent_ns_proc;
+ int err;
+
+ init_completion(&pl->pl_kobj_unregister);
+ err = kobject_init_and_add(&pl->pl_kobj, &ldlm_pl_ktype, &ns->ns_kobj,
+ "pool");
+
+ return err;
+}
+
+static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
+{
+ struct ldlm_namespace *ns = ldlm_pl2ns(pl);
+ struct dentry *debugfs_ns_parent;
struct lprocfs_vars pool_vars[2];
char *var_name = NULL;
int rc = 0;
- OBD_ALLOC(var_name, MAX_STRING_SIZE + 1);
+ var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS);
if (!var_name)
return -ENOMEM;
- parent_ns_proc = ns->ns_proc_dir_entry;
- if (parent_ns_proc == NULL) {
- CERROR("%s: proc entry is not initialized\n",
+ 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;
}
- pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc,
- NULL, NULL);
- if (IS_ERR(pl->pl_proc_dir)) {
- CERROR("LProcFS failed in ldlm-pool-init\n");
- rc = PTR_ERR(pl->pl_proc_dir);
- pl->pl_proc_dir = NULL;
+ pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent,
+ NULL, NULL);
+ if (IS_ERR(pl->pl_debugfs_entry)) {
+ CERROR("LdebugFS failed in ldlm-pool-init\n");
+ rc = PTR_ERR(pl->pl_debugfs_entry);
+ pl->pl_debugfs_entry = NULL;
goto out_free_name;
}
@@ -770,20 +600,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
memset(pool_vars, 0, sizeof(pool_vars));
pool_vars[0].name = var_name;
- LDLM_POOL_ADD_VAR("server_lock_volume", &pl->pl_server_lock_volume,
- &ldlm_pool_u64_fops);
- LDLM_POOL_ADD_VAR("limit", &pl->pl_limit, &ldlm_pool_rw_atomic_fops);
- LDLM_POOL_ADD_VAR("granted", &pl->pl_granted, &ldlm_pool_atomic_fops);
- LDLM_POOL_ADD_VAR("grant_speed", pl, &lprocfs_grant_speed_fops);
- LDLM_POOL_ADD_VAR("cancel_rate", &pl->pl_cancel_rate,
- &ldlm_pool_atomic_fops);
- LDLM_POOL_ADD_VAR("grant_rate", &pl->pl_grant_rate,
- &ldlm_pool_atomic_fops);
- LDLM_POOL_ADD_VAR("grant_plan", pl, &lprocfs_grant_plan_fops);
- LDLM_POOL_ADD_VAR("recalc_period", pl, &lprocfs_recalc_period_fops);
- LDLM_POOL_ADD_VAR("lock_volume_factor", &pl->pl_lock_volume_factor,
- &ldlm_pool_rw_atomic_fops);
- LDLM_POOL_ADD_VAR("state", pl, &lprocfs_pool_state_fops);
+ LDLM_POOL_ADD_VAR(state, pl, &lprocfs_pool_state_fops);
pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
LDLM_POOL_FIRST_STAT, 0);
@@ -825,32 +642,31 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
"recalc_timing", "sec");
- rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats);
+ rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats",
+ pl->pl_stats);
out_free_name:
- OBD_FREE(var_name, MAX_STRING_SIZE + 1);
+ kfree(var_name);
return rc;
}
-static void ldlm_pool_proc_fini(struct ldlm_pool *pl)
+static void ldlm_pool_sysfs_fini(struct ldlm_pool *pl)
+{
+ kobject_put(&pl->pl_kobj);
+ wait_for_completion(&pl->pl_kobj_unregister);
+}
+
+static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl)
{
if (pl->pl_stats != NULL) {
lprocfs_free_stats(&pl->pl_stats);
pl->pl_stats = NULL;
}
- if (pl->pl_proc_dir != NULL) {
- lprocfs_remove(&pl->pl_proc_dir);
- pl->pl_proc_dir = NULL;
+ if (pl->pl_debugfs_entry != NULL) {
+ ldebugfs_remove(&pl->pl_debugfs_entry);
+ pl->pl_debugfs_entry = NULL;
}
}
-#else /* !CONFIG_PROC_FS */
-static int ldlm_pool_proc_init(struct ldlm_pool *pl)
-{
- return 0;
-}
-
-static void ldlm_pool_proc_fini(struct ldlm_pool *pl) {}
-#endif /* CONFIG_PROC_FS */
int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
int idx, ldlm_side_t client)
@@ -859,7 +675,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
spin_lock_init(&pl->pl_lock);
atomic_set(&pl->pl_granted, 0);
- pl->pl_recalc_time = get_seconds();
+ pl->pl_recalc_time = ktime_get_seconds();
atomic_set(&pl->pl_lock_volume_factor, 1);
atomic_set(&pl->pl_grant_rate, 0);
@@ -869,19 +685,16 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
snprintf(pl->pl_name, sizeof(pl->pl_name), "ldlm-pool-%s-%d",
ldlm_ns_name(ns), idx);
- if (client == LDLM_NAMESPACE_SERVER) {
- pl->pl_ops = &ldlm_srv_pool_ops;
- ldlm_pool_set_limit(pl, LDLM_POOL_HOST_L);
- pl->pl_recalc_period = LDLM_POOL_SRV_DEF_RECALC_PERIOD;
- pl->pl_server_lock_volume = ldlm_pool_slv_max(LDLM_POOL_HOST_L);
- } else {
- ldlm_pool_set_limit(pl, 1);
- pl->pl_server_lock_volume = 0;
- pl->pl_ops = &ldlm_cli_pool_ops;
- pl->pl_recalc_period = LDLM_POOL_CLI_DEF_RECALC_PERIOD;
- }
+ ldlm_pool_set_limit(pl, 1);
+ pl->pl_server_lock_volume = 0;
+ pl->pl_ops = &ldlm_cli_pool_ops;
+ pl->pl_recalc_period = LDLM_POOL_CLI_DEF_RECALC_PERIOD;
pl->pl_client_lock_volume = 0;
- rc = ldlm_pool_proc_init(pl);
+ rc = ldlm_pool_debugfs_init(pl);
+ if (rc)
+ return rc;
+
+ rc = ldlm_pool_sysfs_init(pl);
if (rc)
return rc;
@@ -893,7 +706,8 @@ EXPORT_SYMBOL(ldlm_pool_init);
void ldlm_pool_fini(struct ldlm_pool *pl)
{
- ldlm_pool_proc_fini(pl);
+ ldlm_pool_sysfs_fini(pl);
+ ldlm_pool_debugfs_fini(pl);
/*
* Pool should not be used after this point. We can't free it here as
@@ -927,8 +741,6 @@ void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock)
* enqueue/cancel rpc. Also we do not want to run out of stack
* with too long call paths.
*/
- if (ns_is_server(ldlm_pl2ns(pl)))
- ldlm_pool_recalc(pl);
}
EXPORT_SYMBOL(ldlm_pool_add);
@@ -948,9 +760,6 @@ void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock)
atomic_inc(&pl->pl_cancel_rate);
lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_CANCEL_STAT);
-
- if (ns_is_server(ldlm_pl2ns(pl)))
- ldlm_pool_recalc(pl);
}
EXPORT_SYMBOL(ldlm_pool_del);
@@ -968,36 +777,6 @@ __u64 ldlm_pool_get_slv(struct ldlm_pool *pl)
spin_unlock(&pl->pl_lock);
return slv;
}
-EXPORT_SYMBOL(ldlm_pool_get_slv);
-
-/**
- * Sets passed \a slv to \a pl.
- *
- * \pre ->pl_lock is not locked.
- */
-void ldlm_pool_set_slv(struct ldlm_pool *pl, __u64 slv)
-{
- spin_lock(&pl->pl_lock);
- pl->pl_server_lock_volume = slv;
- spin_unlock(&pl->pl_lock);
-}
-EXPORT_SYMBOL(ldlm_pool_set_slv);
-
-/**
- * Returns current \a pl CLV.
- *
- * \pre ->pl_lock is not locked.
- */
-__u64 ldlm_pool_get_clv(struct ldlm_pool *pl)
-{
- __u64 slv;
-
- spin_lock(&pl->pl_lock);
- slv = pl->pl_client_lock_volume;
- spin_unlock(&pl->pl_lock);
- return slv;
-}
-EXPORT_SYMBOL(ldlm_pool_get_clv);
/**
* Sets passed \a clv to \a pl.
@@ -1010,25 +789,6 @@ void ldlm_pool_set_clv(struct ldlm_pool *pl, __u64 clv)
pl->pl_client_lock_volume = clv;
spin_unlock(&pl->pl_lock);
}
-EXPORT_SYMBOL(ldlm_pool_set_clv);
-
-/**
- * Returns current \a pl limit.
- */
-__u32 ldlm_pool_get_limit(struct ldlm_pool *pl)
-{
- return atomic_read(&pl->pl_limit);
-}
-EXPORT_SYMBOL(ldlm_pool_get_limit);
-
-/**
- * Sets passed \a limit to \a pl.
- */
-void ldlm_pool_set_limit(struct ldlm_pool *pl, __u32 limit)
-{
- atomic_set(&pl->pl_limit, limit);
-}
-EXPORT_SYMBOL(ldlm_pool_set_limit);
/**
* Returns current LVF from \a pl.
@@ -1037,7 +797,6 @@ __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl)
{
return atomic_read(&pl->pl_lock_volume_factor);
}
-EXPORT_SYMBOL(ldlm_pool_get_lvf);
static int ldlm_pool_granted(struct ldlm_pool *pl)
{
@@ -1150,20 +909,7 @@ static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, gfp_t gfp_mask)
* we only decrease the SLV in server pools shrinker, return
* SHRINK_STOP to kernel to avoid needless loop. LU-1128
*/
- return (client == LDLM_NAMESPACE_SERVER) ? SHRINK_STOP : freed;
-}
-
-static unsigned long ldlm_pools_srv_count(struct shrinker *s,
- struct shrink_control *sc)
-{
- return ldlm_pools_count(LDLM_NAMESPACE_SERVER, sc->gfp_mask);
-}
-
-static unsigned long ldlm_pools_srv_scan(struct shrinker *s,
- struct shrink_control *sc)
-{
- return ldlm_pools_scan(LDLM_NAMESPACE_SERVER, sc->nr_to_scan,
- sc->gfp_mask);
+ return freed;
}
static unsigned long ldlm_pools_cli_count(struct shrinker *s,
@@ -1179,82 +925,14 @@ static unsigned long ldlm_pools_cli_scan(struct shrinker *s,
sc->gfp_mask);
}
-int ldlm_pools_recalc(ldlm_side_t client)
+static int ldlm_pools_recalc(ldlm_side_t client)
{
- __u32 nr_l = 0, nr_p = 0, l;
struct ldlm_namespace *ns;
struct ldlm_namespace *ns_old = NULL;
- int nr, equal = 0;
+ int nr;
int time = 50; /* seconds of sleep if no active namespaces */
/*
- * No need to setup pool limit for client pools.
- */
- if (client == LDLM_NAMESPACE_SERVER) {
- /*
- * Check all modest namespaces first.
- */
- mutex_lock(ldlm_namespace_lock(client));
- list_for_each_entry(ns, ldlm_namespace_list(client),
- ns_list_chain) {
- if (ns->ns_appetite != LDLM_NAMESPACE_MODEST)
- continue;
-
- l = ldlm_pool_granted(&ns->ns_pool);
- if (l == 0)
- l = 1;
-
- /*
- * Set the modest pools limit equal to their avg granted
- * locks + ~6%.
- */
- l += dru(l, LDLM_POOLS_MODEST_MARGIN_SHIFT, 0);
- ldlm_pool_setup(&ns->ns_pool, l);
- nr_l += l;
- nr_p++;
- }
-
- /*
- * Make sure that modest namespaces did not eat more that 2/3
- * of limit.
- */
- if (nr_l >= 2 * (LDLM_POOL_HOST_L / 3)) {
- CWARN("\"Modest\" pools eat out 2/3 of server locks limit (%d of %lu). This means that you have too many clients for this amount of server RAM. Upgrade server!\n",
- nr_l, LDLM_POOL_HOST_L);
- equal = 1;
- }
-
- /*
- * The rest is given to greedy namespaces.
- */
- list_for_each_entry(ns, ldlm_namespace_list(client),
- ns_list_chain) {
- if (!equal && ns->ns_appetite != LDLM_NAMESPACE_GREEDY)
- continue;
-
- if (equal) {
- /*
- * In the case 2/3 locks are eaten out by
- * modest pools, we re-setup equal limit
- * for _all_ pools.
- */
- l = LDLM_POOL_HOST_L /
- ldlm_namespace_nr_read(client);
- } else {
- /*
- * All the rest of greedy pools will have
- * all locks in equal parts.
- */
- l = (LDLM_POOL_HOST_L - nr_l) /
- (ldlm_namespace_nr_read(client) -
- nr_p);
- }
- ldlm_pool_setup(&ns->ns_pool, l);
- }
- mutex_unlock(ldlm_namespace_lock(client));
- }
-
- /*
* Recalc at least ldlm_namespace_nr_read(client) namespaces.
*/
for (nr = ldlm_namespace_nr_read(client); nr > 0; nr--) {
@@ -1327,12 +1005,11 @@ int ldlm_pools_recalc(ldlm_side_t client)
}
return time;
}
-EXPORT_SYMBOL(ldlm_pools_recalc);
static int ldlm_pools_thread_main(void *arg)
{
struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
- int s_time, c_time;
+ int c_time;
thread_set_flags(thread, SVC_RUNNING);
wake_up(&thread->t_ctl_waitq);
@@ -1346,14 +1023,13 @@ static int ldlm_pools_thread_main(void *arg)
/*
* Recal all pools on this tick.
*/
- s_time = ldlm_pools_recalc(LDLM_NAMESPACE_SERVER);
c_time = ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT);
/*
* Wait until the next check time, or until we're
* stopped.
*/
- lwi = LWI_TIMEOUT(cfs_time_seconds(min(s_time, c_time)),
+ lwi = LWI_TIMEOUT(cfs_time_seconds(c_time),
NULL, NULL);
l_wait_event(thread->t_ctl_waitq,
thread_is_stopping(thread) ||
@@ -1362,8 +1038,7 @@ static int ldlm_pools_thread_main(void *arg)
if (thread_test_and_clear_flags(thread, SVC_STOPPING))
break;
- else
- thread_test_and_clear_flags(thread, SVC_EVENT);
+ thread_test_and_clear_flags(thread, SVC_EVENT);
}
thread_set_flags(thread, SVC_STOPPED);
@@ -1383,8 +1058,8 @@ static int ldlm_pools_thread_start(void)
if (ldlm_pools_thread != NULL)
return -EALREADY;
- OBD_ALLOC_PTR(ldlm_pools_thread);
- if (ldlm_pools_thread == NULL)
+ ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS);
+ if (!ldlm_pools_thread)
return -ENOMEM;
init_completion(&ldlm_pools_comp);
@@ -1394,7 +1069,7 @@ static int ldlm_pools_thread_start(void)
"ldlm_poold");
if (IS_ERR(task)) {
CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task));
- OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread));
+ kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
return PTR_ERR(task);
}
@@ -1417,16 +1092,10 @@ static void ldlm_pools_thread_stop(void)
* in pools thread.
*/
wait_for_completion(&ldlm_pools_comp);
- OBD_FREE_PTR(ldlm_pools_thread);
+ kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
}
-static struct shrinker ldlm_pools_srv_shrinker = {
- .count_objects = ldlm_pools_srv_count,
- .scan_objects = ldlm_pools_srv_scan,
- .seeks = DEFAULT_SEEKS,
-};
-
static struct shrinker ldlm_pools_cli_shrinker = {
.count_objects = ldlm_pools_cli_count,
.scan_objects = ldlm_pools_cli_scan,
@@ -1438,18 +1107,18 @@ int ldlm_pools_init(void)
int rc;
rc = ldlm_pools_thread_start();
- if (rc == 0) {
- register_shrinker(&ldlm_pools_srv_shrinker);
+ if (rc == 0)
register_shrinker(&ldlm_pools_cli_shrinker);
- }
+
return rc;
}
EXPORT_SYMBOL(ldlm_pools_init);
void ldlm_pools_fini(void)
{
- unregister_shrinker(&ldlm_pools_srv_shrinker);
- unregister_shrinker(&ldlm_pools_cli_shrinker);
+ if (ldlm_pools_thread)
+ unregister_shrinker(&ldlm_pools_cli_shrinker);
+
ldlm_pools_thread_stop();
}
EXPORT_SYMBOL(ldlm_pools_fini);
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 4f7131831..fdf81b87a 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -87,7 +87,7 @@ struct ldlm_async_args {
struct lustre_handle lock_handle;
};
-int ldlm_expired_completion_wait(void *data)
+static int ldlm_expired_completion_wait(void *data)
{
struct lock_wait_data *lwd = data;
struct ldlm_lock *lock = lwd->lwd_lock;
@@ -97,15 +97,14 @@ int ldlm_expired_completion_wait(void *data)
if (lock->l_conn_export == NULL) {
static unsigned long next_dump, last_dump;
- LCONSOLE_WARN("lock timed out (enqueued at "CFS_TIME_T", "
- CFS_DURATION_T"s ago)\n",
- lock->l_last_activity,
- cfs_time_sub(get_seconds(),
- lock->l_last_activity));
- LDLM_DEBUG(lock, "lock timed out (enqueued at " CFS_TIME_T ", " CFS_DURATION_T "s ago); not entering recovery in server code, just going back to sleep",
- lock->l_last_activity,
- cfs_time_sub(get_seconds(),
- lock->l_last_activity));
+ LCONSOLE_WARN("lock timed out (enqueued at %lld, %llds ago)\n",
+ (s64)lock->l_last_activity,
+ (s64)(ktime_get_real_seconds() -
+ lock->l_last_activity));
+ LDLM_DEBUG(lock, "lock timed out (enqueued at %lld, %llds ago); not entering recovery in server code, just going back to sleep",
+ (s64)lock->l_last_activity,
+ (s64)(ktime_get_real_seconds() -
+ lock->l_last_activity));
if (cfs_time_after(cfs_time_current(), next_dump)) {
last_dump = next_dump;
next_dump = cfs_time_shift(300);
@@ -120,19 +119,17 @@ int ldlm_expired_completion_wait(void *data)
obd = lock->l_conn_export->exp_obd;
imp = obd->u.cli.cl_import;
ptlrpc_fail_import(imp, lwd->lwd_conn_cnt);
- LDLM_ERROR(lock, "lock timed out (enqueued at "CFS_TIME_T", "
- CFS_DURATION_T"s ago), entering recovery for %s@%s",
- lock->l_last_activity,
- cfs_time_sub(get_seconds(), lock->l_last_activity),
- obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
+ LDLM_ERROR(lock, "lock timed out (enqueued at %lld, %llds ago), entering recovery for %s@%s",
+ (s64)lock->l_last_activity,
+ (s64)(ktime_get_real_seconds() - lock->l_last_activity),
+ obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
return 0;
}
-EXPORT_SYMBOL(ldlm_expired_completion_wait);
/* We use the same basis for both server side and client side functions
from a single node. */
-int ldlm_get_enq_timeout(struct ldlm_lock *lock)
+static int ldlm_get_enq_timeout(struct ldlm_lock *lock)
{
int timeout = at_get(ldlm_lock_to_ns_at(lock));
@@ -144,7 +141,6 @@ int ldlm_get_enq_timeout(struct ldlm_lock *lock)
timeout = min_t(int, at_max, timeout + (timeout >> 1)); /* 150% */
return max(timeout, ldlm_enqueue_min);
}
-EXPORT_SYMBOL(ldlm_get_enq_timeout);
/**
* Helper function for ldlm_completion_ast(), updating timings when lock is
@@ -159,10 +155,9 @@ static int ldlm_completion_tail(struct ldlm_lock *lock)
LDLM_DEBUG(lock, "client-side enqueue: destroyed");
result = -EIO;
} else {
- delay = cfs_time_sub(get_seconds(),
- lock->l_last_activity);
- LDLM_DEBUG(lock, "client-side enqueue: granted after "
- CFS_DURATION_T"s", delay);
+ delay = ktime_get_real_seconds() - lock->l_last_activity;
+ LDLM_DEBUG(lock, "client-side enqueue: granted after %lds",
+ delay);
/* Update our time estimate */
at_measured(ldlm_lock_to_ns_at(lock),
@@ -191,7 +186,6 @@ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
}
LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, going forward");
- ldlm_reprocess_all(lock->l_resource);
return 0;
}
EXPORT_SYMBOL(ldlm_completion_ast_async);
@@ -270,8 +264,7 @@ noreproc:
spin_unlock(&imp->imp_lock);
}
- if (ns_is_client(ldlm_lock_to_ns(lock)) &&
- OBD_FAIL_CHECK_RESET(OBD_FAIL_LDLM_INTR_CP_AST,
+ if (OBD_FAIL_CHECK_RESET(OBD_FAIL_LDLM_INTR_CP_AST,
OBD_FAIL_LDLM_CP_BL_RACE | OBD_FAIL_ONCE)) {
lock->l_flags |= LDLM_FL_FAIL_LOC;
rc = -EINTR;
@@ -291,172 +284,6 @@ noreproc:
}
EXPORT_SYMBOL(ldlm_completion_ast);
-/**
- * A helper to build a blocking AST function
- *
- * Perform a common operation for blocking ASTs:
- * deferred lock cancellation.
- *
- * \param lock the lock blocking or canceling AST was called on
- * \retval 0
- * \see mdt_blocking_ast
- * \see ldlm_blocking_ast
- */
-int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock)
-{
- int do_ast;
-
- lock->l_flags |= LDLM_FL_CBPENDING;
- do_ast = !lock->l_readers && !lock->l_writers;
- unlock_res_and_lock(lock);
-
- if (do_ast) {
- struct lustre_handle lockh;
- int rc;
-
- LDLM_DEBUG(lock, "already unused, calling ldlm_cli_cancel");
- ldlm_lock2handle(lock, &lockh);
- rc = ldlm_cli_cancel(&lockh, LCF_ASYNC);
- if (rc < 0)
- CERROR("ldlm_cli_cancel: %d\n", rc);
- } else {
- LDLM_DEBUG(lock, "Lock still has references, will be cancelled later");
- }
- return 0;
-}
-EXPORT_SYMBOL(ldlm_blocking_ast_nocheck);
-
-/**
- * Server blocking AST
- *
- * ->l_blocking_ast() callback for LDLM locks acquired by server-side
- * OBDs.
- *
- * \param lock the lock which blocks a request or cancelling lock
- * \param desc unused
- * \param data unused
- * \param flag indicates whether this cancelling or blocking callback
- * \retval 0
- * \see ldlm_blocking_ast_nocheck
- */
-int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
- void *data, int flag)
-{
- if (flag == LDLM_CB_CANCELING) {
- /* Don't need to do anything here. */
- return 0;
- }
-
- lock_res_and_lock(lock);
- /* Get this: if ldlm_blocking_ast is racing with intent_policy, such
- * that ldlm_blocking_ast is called just before intent_policy method
- * takes the lr_lock, then by the time we get the lock, we might not
- * be the correct blocking function anymore. So check, and return
- * early, if so. */
- if (lock->l_blocking_ast != ldlm_blocking_ast) {
- unlock_res_and_lock(lock);
- return 0;
- }
- return ldlm_blocking_ast_nocheck(lock);
-}
-EXPORT_SYMBOL(ldlm_blocking_ast);
-
-/**
- * ->l_glimpse_ast() for DLM extent locks acquired on the server-side. See
- * comment in filter_intent_policy() on why you may need this.
- */
-int ldlm_glimpse_ast(struct ldlm_lock *lock, void *reqp)
-{
- /*
- * Returning -ELDLM_NO_LOCK_DATA actually works, but the reason for
- * that is rather subtle: with OST-side locking, it may so happen that
- * _all_ extent locks are held by the OST. If client wants to obtain
- * current file size it calls ll{,u}_glimpse_size(), and (as locks are
- * on the server), dummy glimpse callback fires and does
- * nothing. Client still receives correct file size due to the
- * following fragment in filter_intent_policy():
- *
- * rc = l->l_glimpse_ast(l, NULL); // this will update the LVB
- * if (rc != 0 && res->lr_namespace->ns_lvbo &&
- * res->lr_namespace->ns_lvbo->lvbo_update) {
- * res->lr_namespace->ns_lvbo->lvbo_update(res, NULL, 0, 1);
- * }
- *
- * that is, after glimpse_ast() fails, filter_lvbo_update() runs, and
- * returns correct file size to the client.
- */
- return -ELDLM_NO_LOCK_DATA;
-}
-EXPORT_SYMBOL(ldlm_glimpse_ast);
-
-/**
- * Enqueue a local lock (typically on a server).
- */
-int ldlm_cli_enqueue_local(struct ldlm_namespace *ns,
- const struct ldlm_res_id *res_id,
- ldlm_type_t type, ldlm_policy_data_t *policy,
- ldlm_mode_t mode, __u64 *flags,
- ldlm_blocking_callback blocking,
- ldlm_completion_callback completion,
- ldlm_glimpse_callback glimpse,
- void *data, __u32 lvb_len, enum lvb_type lvb_type,
- const __u64 *client_cookie,
- struct lustre_handle *lockh)
-{
- struct ldlm_lock *lock;
- int err;
- const struct ldlm_callback_suite cbs = { .lcs_completion = completion,
- .lcs_blocking = blocking,
- .lcs_glimpse = glimpse,
- };
-
- LASSERT(!(*flags & LDLM_FL_REPLAY));
- if (unlikely(ns_is_client(ns))) {
- CERROR("Trying to enqueue local lock in a shadow namespace\n");
- LBUG();
- }
-
- lock = ldlm_lock_create(ns, res_id, type, mode, &cbs, data, lvb_len,
- lvb_type);
- if (unlikely(!lock)) {
- err = -ENOMEM;
- goto out_nolock;
- }
-
- ldlm_lock2handle(lock, lockh);
-
- /* NB: we don't have any lock now (lock_res_and_lock)
- * because it's a new lock */
- ldlm_lock_addref_internal_nolock(lock, mode);
- lock->l_flags |= LDLM_FL_LOCAL;
- if (*flags & LDLM_FL_ATOMIC_CB)
- lock->l_flags |= LDLM_FL_ATOMIC_CB;
-
- if (policy != NULL)
- lock->l_policy_data = *policy;
- if (client_cookie != NULL)
- lock->l_client_cookie = *client_cookie;
- if (type == LDLM_EXTENT)
- lock->l_req_extent = policy->l_extent;
-
- err = ldlm_lock_enqueue(ns, &lock, policy, flags);
- if (unlikely(err != ELDLM_OK))
- goto out;
-
- if (policy != NULL)
- *policy = lock->l_policy_data;
-
- if (lock->l_completion_ast)
- lock->l_completion_ast(lock, *flags, NULL);
-
- LDLM_DEBUG(lock, "client-side local enqueue handler, new lock created");
- out:
- LDLM_LOCK_RELEASE(lock);
- out_nolock:
- return err;
-}
-EXPORT_SYMBOL(ldlm_cli_enqueue_local);
-
static void failed_lock_cleanup(struct ldlm_namespace *ns,
struct ldlm_lock *lock, int mode)
{
@@ -813,27 +640,6 @@ int ldlm_prep_enqueue_req(struct obd_export *exp, struct ptlrpc_request *req,
}
EXPORT_SYMBOL(ldlm_prep_enqueue_req);
-struct ptlrpc_request *ldlm_enqueue_pack(struct obd_export *exp, int lvb_len)
-{
- struct ptlrpc_request *req;
- int rc;
-
- req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE);
- if (req == NULL)
- return ERR_PTR(-ENOMEM);
-
- rc = ldlm_prep_enqueue_req(exp, req, NULL, 0);
- if (rc) {
- ptlrpc_request_free(req);
- return ERR_PTR(rc);
- }
-
- req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, lvb_len);
- ptlrpc_request_set_replen(req);
- return req;
-}
-EXPORT_SYMBOL(ldlm_enqueue_pack);
-
/**
* Client-side lock enqueue.
*
@@ -977,107 +783,6 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
}
EXPORT_SYMBOL(ldlm_cli_enqueue);
-static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode,
- __u32 *flags)
-{
- struct ldlm_resource *res;
- int rc;
-
- if (ns_is_client(ldlm_lock_to_ns(lock))) {
- CERROR("Trying to cancel local lock\n");
- LBUG();
- }
- LDLM_DEBUG(lock, "client-side local convert");
-
- res = ldlm_lock_convert(lock, new_mode, flags);
- if (res) {
- ldlm_reprocess_all(res);
- rc = 0;
- } else {
- rc = LUSTRE_EDEADLK;
- }
- LDLM_DEBUG(lock, "client-side local convert handler END");
- LDLM_LOCK_PUT(lock);
- return rc;
-}
-
-/* FIXME: one of ldlm_cli_convert or the server side should reject attempted
- * conversion of locks which are on the waiting or converting queue */
-/* Caller of this code is supposed to take care of lock readers/writers
- accounting */
-int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags)
-{
- struct ldlm_request *body;
- struct ldlm_reply *reply;
- struct ldlm_lock *lock;
- struct ldlm_resource *res;
- struct ptlrpc_request *req;
- int rc;
-
- lock = ldlm_handle2lock(lockh);
- if (!lock) {
- LBUG();
- return -EINVAL;
- }
- *flags = 0;
-
- if (lock->l_conn_export == NULL)
- return ldlm_cli_convert_local(lock, new_mode, flags);
-
- LDLM_DEBUG(lock, "client-side convert");
-
- req = ptlrpc_request_alloc_pack(class_exp2cliimp(lock->l_conn_export),
- &RQF_LDLM_CONVERT, LUSTRE_DLM_VERSION,
- LDLM_CONVERT);
- if (req == NULL) {
- LDLM_LOCK_PUT(lock);
- return -ENOMEM;
- }
-
- body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ);
- body->lock_handle[0] = lock->l_remote_handle;
-
- body->lock_desc.l_req_mode = new_mode;
- body->lock_flags = ldlm_flags_to_wire(*flags);
-
-
- ptlrpc_request_set_replen(req);
- rc = ptlrpc_queue_wait(req);
- if (rc != ELDLM_OK)
- goto out;
-
- reply = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
- if (reply == NULL) {
- rc = -EPROTO;
- goto out;
- }
-
- if (req->rq_status) {
- rc = req->rq_status;
- goto out;
- }
-
- res = ldlm_lock_convert(lock, new_mode, &reply->lock_flags);
- if (res != NULL) {
- ldlm_reprocess_all(res);
- /* Go to sleep until the lock is granted. */
- /* FIXME: or cancelled. */
- if (lock->l_completion_ast) {
- rc = lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC,
- NULL);
- if (rc)
- goto out;
- }
- } else {
- rc = LUSTRE_EDEADLK;
- }
- out:
- LDLM_LOCK_PUT(lock);
- ptlrpc_req_finished(req);
- return rc;
-}
-EXPORT_SYMBOL(ldlm_cli_convert);
-
/**
* Cancel locks locally.
* Returns:
@@ -1109,13 +814,8 @@ static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock)
}
ldlm_lock_cancel(lock);
} else {
- if (ns_is_client(ldlm_lock_to_ns(lock))) {
- LDLM_ERROR(lock, "Trying to cancel local lock");
- LBUG();
- }
- LDLM_DEBUG(lock, "server-side local cancel");
- ldlm_lock_cancel(lock);
- ldlm_reprocess_all(lock->l_resource);
+ LDLM_ERROR(lock, "Trying to cancel local lock");
+ LBUG();
}
return rc;
@@ -1159,8 +859,9 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req,
/**
* Prepare and send a batched cancel RPC. It will include \a count lock
* handles of locks given in \a cancels list. */
-int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels,
- int count, ldlm_cancel_flags_t flags)
+static int ldlm_cli_cancel_req(struct obd_export *exp,
+ struct list_head *cancels,
+ int count, ldlm_cancel_flags_t flags)
{
struct ptlrpc_request *req = NULL;
struct obd_import *imp;
@@ -1212,12 +913,12 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels,
ptlrpc_request_set_replen(req);
if (flags & LCF_ASYNC) {
- ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+ ptlrpcd_add_req(req);
sent = count;
goto out;
- } else {
- rc = ptlrpc_queue_wait(req);
}
+
+ rc = ptlrpc_queue_wait(req);
if (rc == LUSTRE_ESTALE) {
CDEBUG(D_DLMTRACE, "client/server (nid %s) out of sync -- not fatal\n",
libcfs_nid2str(req->rq_import->
@@ -1242,7 +943,6 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels,
out:
return sent ? sent : rc;
}
-EXPORT_SYMBOL(ldlm_cli_cancel_req);
static inline struct ldlm_pool *ldlm_imp2pl(struct obd_import *imp)
{
@@ -1462,7 +1162,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
lock->l_last_used));
lv = lvf * la * unused;
- /* Inform pool about current CLV to see it via proc. */
+ /* Inform pool about current CLV to see it via debugfs. */
ldlm_pool_set_clv(pl, lv);
/* Stop when SLV is not yet come from server or lv is smaller than
@@ -1472,7 +1172,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
}
/**
- * Callback function for proc used policy. Makes decision whether to keep
+ * Callback function for debugfs used policy. Makes decision whether to keep
* \a lock in LRU for current \a LRU size \a unused, added in current scan \a
* added and number of locks to be preferably canceled \a count.
*
@@ -1723,9 +1423,9 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
return added;
}
-int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels,
- int count, int max, ldlm_cancel_flags_t cancel_flags,
- int flags)
+int ldlm_cancel_lru_local(struct ldlm_namespace *ns,
+ struct list_head *cancels, int count, int max,
+ ldlm_cancel_flags_t cancel_flags, int flags)
{
int added;
@@ -1962,8 +1662,8 @@ EXPORT_SYMBOL(ldlm_cli_cancel_unused);
/* Lock iterators. */
-int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
- void *closure)
+static int ldlm_resource_foreach(struct ldlm_resource *res,
+ ldlm_iterator_t iter, void *closure)
{
struct list_head *tmp, *next;
struct ldlm_lock *lock;
@@ -1982,15 +1682,6 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
}
}
- list_for_each_safe(tmp, next, &res->lr_converting) {
- lock = list_entry(tmp, struct ldlm_lock, l_res_link);
-
- if (iter(lock, closure) == LDLM_ITER_STOP) {
- rc = LDLM_ITER_STOP;
- goto out;
- }
- }
-
list_for_each_safe(tmp, next, &res->lr_waiting) {
lock = list_entry(tmp, struct ldlm_lock, l_res_link);
@@ -2003,7 +1694,6 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
unlock_res(res);
return rc;
}
-EXPORT_SYMBOL(ldlm_resource_foreach);
struct iter_helper_data {
ldlm_iterator_t iter;
@@ -2027,8 +1717,8 @@ static int ldlm_res_iter_helper(struct cfs_hash *hs, struct cfs_hash_bd *bd,
LDLM_ITER_STOP;
}
-void ldlm_namespace_foreach(struct ldlm_namespace *ns,
- ldlm_iterator_t iter, void *closure)
+static void ldlm_namespace_foreach(struct ldlm_namespace *ns,
+ ldlm_iterator_t iter, void *closure)
{
struct iter_helper_data helper = {
@@ -2040,7 +1730,6 @@ void ldlm_namespace_foreach(struct ldlm_namespace *ns,
ldlm_res_iter_helper, &helper);
}
-EXPORT_SYMBOL(ldlm_namespace_foreach);
/* non-blocking function to manipulate a lock whose cb_data is being put away.
* return 0: find no resource
@@ -2106,7 +1795,6 @@ static int replay_lock_interpret(const struct lu_env *env,
if (rc != ELDLM_OK)
goto out;
-
reply = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
if (reply == NULL) {
rc = -EPROTO;
@@ -2223,7 +1911,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
aa = ptlrpc_req_async_args(req);
aa->lock_handle = body->lock_handle[0];
req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret;
- ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+ ptlrpcd_add_req(req);
return 0;
}
diff --git a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index f750d42a7..c0a54bf40 100644
--- a/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/kernel/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -47,8 +47,8 @@
struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab;
-int ldlm_srv_namespace_nr = 0;
-int ldlm_cli_namespace_nr = 0;
+int ldlm_srv_namespace_nr;
+int ldlm_cli_namespace_nr;
struct mutex ldlm_srv_namespace_lock;
LIST_HEAD(ldlm_srv_namespace_list);
@@ -59,104 +59,104 @@ struct mutex ldlm_cli_namespace_lock;
* inactive list */
LIST_HEAD(ldlm_cli_active_namespace_list);
/* Client namespaces that don't have any locks in them */
-LIST_HEAD(ldlm_cli_inactive_namespace_list);
+static LIST_HEAD(ldlm_cli_inactive_namespace_list);
-struct proc_dir_entry *ldlm_type_proc_dir = NULL;
-static struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
-struct proc_dir_entry *ldlm_svc_proc_dir = NULL;
-
-extern unsigned int ldlm_cancel_unused_locks_before_replay;
+static struct dentry *ldlm_debugfs_dir;
+static struct dentry *ldlm_ns_debugfs_dir;
+struct dentry *ldlm_svc_debugfs_dir;
/* during debug dump certain amount of granted locks for one resource to avoid
* DDOS. */
-unsigned int ldlm_dump_granted_max = 256;
+static unsigned int ldlm_dump_granted_max = 256;
-#if defined(CONFIG_PROC_FS)
-static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t
+lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
+ size_t count, loff_t *off)
{
ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
return count;
}
+
LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns);
LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint);
-LPROC_SEQ_FOPS_RO_TYPE(ldlm, uint);
-int ldlm_proc_setup(void)
+static struct lprocfs_vars ldlm_debugfs_list[] = {
+ { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 },
+ { "dump_granted_max", &ldlm_rw_uint_fops, &ldlm_dump_granted_max },
+ { NULL }
+};
+
+int ldlm_debugfs_setup(void)
{
int rc;
- struct lprocfs_vars list[] = {
- { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 },
- { "dump_granted_max", &ldlm_rw_uint_fops,
- &ldlm_dump_granted_max },
- { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops,
- &ldlm_cancel_unused_locks_before_replay },
- { NULL } };
- LASSERT(ldlm_ns_proc_dir == NULL);
-
- ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME,
- proc_lustre_root,
- NULL, NULL);
- if (IS_ERR(ldlm_type_proc_dir)) {
+
+ ldlm_debugfs_dir = ldebugfs_register(OBD_LDLM_DEVICENAME,
+ debugfs_lustre_root,
+ NULL, NULL);
+ if (IS_ERR_OR_NULL(ldlm_debugfs_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
- rc = PTR_ERR(ldlm_type_proc_dir);
+ rc = ldlm_debugfs_dir ? PTR_ERR(ldlm_debugfs_dir) : -ENOMEM;
goto err;
}
- ldlm_ns_proc_dir = lprocfs_register("namespaces",
- ldlm_type_proc_dir,
- NULL, NULL);
- if (IS_ERR(ldlm_ns_proc_dir)) {
+ ldlm_ns_debugfs_dir = ldebugfs_register("namespaces",
+ ldlm_debugfs_dir,
+ NULL, NULL);
+ if (IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
- rc = PTR_ERR(ldlm_ns_proc_dir);
+ rc = ldlm_ns_debugfs_dir ? PTR_ERR(ldlm_ns_debugfs_dir)
+ : -ENOMEM;
goto err_type;
}
- ldlm_svc_proc_dir = lprocfs_register("services",
- ldlm_type_proc_dir,
- NULL, NULL);
- if (IS_ERR(ldlm_svc_proc_dir)) {
+ ldlm_svc_debugfs_dir = ldebugfs_register("services",
+ ldlm_debugfs_dir,
+ NULL, NULL);
+ if (IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
- rc = PTR_ERR(ldlm_svc_proc_dir);
+ rc = ldlm_svc_debugfs_dir ? PTR_ERR(ldlm_svc_debugfs_dir)
+ : -ENOMEM;
goto err_ns;
}
- rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL);
+ rc = ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL);
return 0;
err_ns:
- lprocfs_remove(&ldlm_ns_proc_dir);
+ ldebugfs_remove(&ldlm_ns_debugfs_dir);
err_type:
- lprocfs_remove(&ldlm_type_proc_dir);
+ ldebugfs_remove(&ldlm_debugfs_dir);
err:
- ldlm_svc_proc_dir = NULL;
- ldlm_type_proc_dir = NULL;
- ldlm_ns_proc_dir = NULL;
+ ldlm_svc_debugfs_dir = NULL;
+ ldlm_ns_debugfs_dir = NULL;
+ ldlm_debugfs_dir = NULL;
return rc;
}
-void ldlm_proc_cleanup(void)
+void ldlm_debugfs_cleanup(void)
{
- if (ldlm_svc_proc_dir)
- lprocfs_remove(&ldlm_svc_proc_dir);
+ if (!IS_ERR_OR_NULL(ldlm_svc_debugfs_dir))
+ ldebugfs_remove(&ldlm_svc_debugfs_dir);
- if (ldlm_ns_proc_dir)
- lprocfs_remove(&ldlm_ns_proc_dir);
+ if (!IS_ERR_OR_NULL(ldlm_ns_debugfs_dir))
+ ldebugfs_remove(&ldlm_ns_debugfs_dir);
- if (ldlm_type_proc_dir)
- lprocfs_remove(&ldlm_type_proc_dir);
+ if (!IS_ERR_OR_NULL(ldlm_debugfs_dir))
+ ldebugfs_remove(&ldlm_debugfs_dir);
- ldlm_svc_proc_dir = NULL;
- ldlm_type_proc_dir = NULL;
- ldlm_ns_proc_dir = NULL;
+ ldlm_svc_debugfs_dir = NULL;
+ ldlm_ns_debugfs_dir = NULL;
+ ldlm_debugfs_dir = NULL;
}
-static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
+static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
__u64 res = 0;
struct cfs_hash_bd bd;
int i;
@@ -164,46 +164,56 @@ static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
/* result is not strictly consistent */
cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i)
res += cfs_hash_bd_count_get(&bd);
- return lprocfs_rd_u64(m, &res);
+ return sprintf(buf, "%lld\n", res);
}
-LPROC_SEQ_FOPS_RO(lprocfs_ns_resources);
+LUSTRE_RO_ATTR(resource_count);
-static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v)
+static ssize_t lock_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
__u64 locks;
locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_FIELDS_FLAGS_SUM);
- return lprocfs_rd_u64(m, &locks);
+ return sprintf(buf, "%lld\n", locks);
+}
+LUSTRE_RO_ATTR(lock_count);
+
+static ssize_t lock_unused_count_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+
+ return sprintf(buf, "%d\n", ns->ns_nr_unused);
}
-LPROC_SEQ_FOPS_RO(lprocfs_ns_locks);
+LUSTRE_RO_ATTR(lock_unused_count);
-static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v)
+static ssize_t lru_size_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
__u32 *nr = &ns->ns_max_unused;
if (ns_connect_lru_resize(ns))
nr = &ns->ns_nr_unused;
- return lprocfs_rd_uint(m, nr);
+ return sprintf(buf, "%u", *nr);
}
-static ssize_t lprocfs_lru_size_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
- char dummy[MAX_STRING_SIZE + 1];
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
unsigned long tmp;
int lru_resize;
int err;
- dummy[MAX_STRING_SIZE] = '\0';
- if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
- return -EFAULT;
-
- if (strncmp(dummy, "clear", 5) == 0) {
+ if (strncmp(buffer, "clear", 5) == 0) {
CDEBUG(D_DLMTRACE,
"dropping all unused locks from namespace %s\n",
ldlm_ns_name(ns));
@@ -229,9 +239,9 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file,
return count;
}
- err = kstrtoul(dummy, 10, &tmp);
+ err = kstrtoul(buffer, 10, &tmp);
if (err != 0) {
- CERROR("invalid value written\n");
+ CERROR("lru_size: invalid value written\n");
return -EINVAL;
}
lru_resize = (tmp == 0);
@@ -277,25 +287,56 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(lprocfs_lru_size);
+LUSTRE_RW_ATTR(lru_size);
+
+static ssize_t lru_max_age_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+
+ return sprintf(buf, "%u", ns->ns_max_age);
+}
+
+static ssize_t lru_max_age_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+ unsigned long tmp;
+ int err;
+
+ err = kstrtoul(buffer, 10, &tmp);
+ if (err != 0)
+ return -EINVAL;
+
+ ns->ns_max_age = tmp;
+
+ return count;
+}
+LUSTRE_RW_ATTR(lru_max_age);
-static int lprocfs_elc_seq_show(struct seq_file *m, void *v)
+static ssize_t early_lock_cancel_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
- unsigned int supp = ns_connect_cancelset(ns);
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
- return lprocfs_rd_uint(m, &supp);
+ return sprintf(buf, "%d\n", ns_connect_cancelset(ns));
}
-static ssize_t lprocfs_elc_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t early_lock_cancel_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
- unsigned int supp = -1;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+ unsigned long supp = -1;
int rc;
- rc = lprocfs_wr_uint(file, buffer, count, &supp);
+ rc = kstrtoul(buffer, 10, &supp);
if (rc < 0)
return rc;
@@ -305,91 +346,99 @@ static ssize_t lprocfs_elc_seq_write(struct file *file,
ns->ns_connect_flags |= OBD_CONNECT_CANCELSET;
return count;
}
-LPROC_SEQ_FOPS(lprocfs_elc);
+LUSTRE_RW_ATTR(early_lock_cancel);
+
+/* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */
+static struct attribute *ldlm_ns_attrs[] = {
+ &lustre_attr_resource_count.attr,
+ &lustre_attr_lock_count.attr,
+ &lustre_attr_lock_unused_count.attr,
+ &lustre_attr_lru_size.attr,
+ &lustre_attr_lru_max_age.attr,
+ &lustre_attr_early_lock_cancel.attr,
+ NULL,
+};
+
+static void ldlm_ns_release(struct kobject *kobj)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+ complete(&ns->ns_kobj_unregister);
+}
+
+static struct kobj_type ldlm_ns_ktype = {
+ .default_attrs = ldlm_ns_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = ldlm_ns_release,
+};
-void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
+static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns)
{
- if (ns->ns_proc_dir_entry == NULL)
+ if (IS_ERR_OR_NULL(ns->ns_debugfs_entry))
CERROR("dlm namespace %s has no procfs dir?\n",
ldlm_ns_name(ns));
else
- lprocfs_remove(&ns->ns_proc_dir_entry);
+ ldebugfs_remove(&ns->ns_debugfs_entry);
if (ns->ns_stats != NULL)
lprocfs_free_stats(&ns->ns_stats);
}
-#define LDLM_NS_ADD_VAR(name, var, ops) \
- do { \
- snprintf(lock_name, MAX_STRING_SIZE, name); \
- lock_vars[0].data = var; \
- lock_vars[0].fops = ops; \
- lprocfs_add_vars(ns_pde, lock_vars, NULL); \
- } while (0)
+static void ldlm_namespace_sysfs_unregister(struct ldlm_namespace *ns)
+{
+ kobject_put(&ns->ns_kobj);
+ wait_for_completion(&ns->ns_kobj_unregister);
+}
-int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
+static int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns)
{
- struct lprocfs_vars lock_vars[2];
- char lock_name[MAX_STRING_SIZE + 1];
- struct proc_dir_entry *ns_pde;
+ int err;
- LASSERT(ns != NULL);
- LASSERT(ns->ns_rs_hash != NULL);
-
- if (ns->ns_proc_dir_entry != NULL) {
- ns_pde = ns->ns_proc_dir_entry;
- } else {
- ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir);
- if (ns_pde == NULL)
- return -ENOMEM;
- ns->ns_proc_dir_entry = ns_pde;
- }
+ ns->ns_kobj.kset = ldlm_ns_kset;
+ init_completion(&ns->ns_kobj_unregister);
+ err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL,
+ "%s", ldlm_ns_name(ns));
ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0);
- if (ns->ns_stats == NULL)
+ if (ns->ns_stats == NULL) {
+ kobject_put(&ns->ns_kobj);
return -ENOMEM;
+ }
lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_CNTR_AVGMINMAX, "locks", "locks");
- lock_name[MAX_STRING_SIZE] = '\0';
-
- memset(lock_vars, 0, sizeof(lock_vars));
- lock_vars[0].name = lock_name;
+ return err;
+}
- LDLM_NS_ADD_VAR("resource_count", ns, &lprocfs_ns_resources_fops);
- LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops);
+static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns)
+{
+ struct dentry *ns_entry;
- if (ns_is_client(ns)) {
- LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused,
- &ldlm_uint_fops);
- LDLM_NS_ADD_VAR("lru_size", ns, &lprocfs_lru_size_fops);
- LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops);
+ if (!IS_ERR_OR_NULL(ns->ns_debugfs_entry)) {
+ ns_entry = ns->ns_debugfs_entry;
} else {
- LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("lock_timeouts", &ns->ns_timeouts,
- &ldlm_uint_fops);
- LDLM_NS_ADD_VAR("max_nolock_bytes", &ns->ns_max_nolock_size,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("contention_seconds", &ns->ns_contention_time,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("contended_locks", &ns->ns_contended_locks,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("max_parallel_ast", &ns->ns_max_parallel_ast,
- &ldlm_rw_uint_fops);
+ ns_entry = debugfs_create_dir(ldlm_ns_name(ns),
+ ldlm_ns_debugfs_dir);
+ if (ns_entry == NULL)
+ return -ENOMEM;
+ ns->ns_debugfs_entry = ns_entry;
}
+
return 0;
}
-#undef MAX_STRING_SIZE
-#else /* CONFIG_PROC_FS */
-#define ldlm_namespace_proc_unregister(ns) ({; })
-#define ldlm_namespace_proc_register(ns) ({0; })
+#undef MAX_STRING_SIZE
-#endif /* CONFIG_PROC_FS */
+static struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
+{
+ LASSERT(res);
+ LASSERT(res != LP_POISON);
+ atomic_inc(&res->lr_refcount);
+ CDEBUG(D_INFO, "getref res: %p count: %d\n", res,
+ atomic_read(&res->lr_refcount));
+ return res;
+}
static unsigned ldlm_res_hop_hash(struct cfs_hash *hs,
const void *key, unsigned mask)
@@ -482,26 +531,26 @@ static void ldlm_res_hop_put(struct cfs_hash *hs, struct hlist_node *hnode)
ldlm_resource_putref(res);
}
-cfs_hash_ops_t ldlm_ns_hash_ops = {
+static struct cfs_hash_ops ldlm_ns_hash_ops = {
.hs_hash = ldlm_res_hop_hash,
- .hs_key = ldlm_res_hop_key,
+ .hs_key = ldlm_res_hop_key,
.hs_keycmp = ldlm_res_hop_keycmp,
.hs_keycpy = NULL,
.hs_object = ldlm_res_hop_object,
- .hs_get = ldlm_res_hop_get_locked,
+ .hs_get = ldlm_res_hop_get_locked,
.hs_put_locked = ldlm_res_hop_put_locked,
- .hs_put = ldlm_res_hop_put
+ .hs_put = ldlm_res_hop_put
};
-cfs_hash_ops_t ldlm_ns_fid_hash_ops = {
+static struct cfs_hash_ops ldlm_ns_fid_hash_ops = {
.hs_hash = ldlm_res_hop_fid_hash,
- .hs_key = ldlm_res_hop_key,
+ .hs_key = ldlm_res_hop_key,
.hs_keycmp = ldlm_res_hop_keycmp,
.hs_keycpy = NULL,
.hs_object = ldlm_res_hop_object,
- .hs_get = ldlm_res_hop_get_locked,
+ .hs_get = ldlm_res_hop_get_locked,
.hs_put_locked = ldlm_res_hop_put_locked,
- .hs_put = ldlm_res_hop_put
+ .hs_put = ldlm_res_hop_put
};
struct ldlm_ns_hash_def {
@@ -511,10 +560,10 @@ struct ldlm_ns_hash_def {
/** hash bits */
unsigned nsd_all_bits;
/** hash operations */
- cfs_hash_ops_t *nsd_hops;
+ struct cfs_hash_ops *nsd_hops;
};
-struct ldlm_ns_hash_def ldlm_ns_hash_defs[] = {
+static struct ldlm_ns_hash_def ldlm_ns_hash_defs[] = {
{
.nsd_type = LDLM_NS_TYPE_MDC,
.nsd_bkt_bits = 11,
@@ -556,6 +605,17 @@ struct ldlm_ns_hash_def ldlm_ns_hash_defs[] = {
},
};
+/** Register \a ns in the list of namespaces */
+static void ldlm_namespace_register(struct ldlm_namespace *ns,
+ ldlm_side_t client)
+{
+ mutex_lock(ldlm_namespace_lock(client));
+ LASSERT(list_empty(&ns->ns_list_chain));
+ list_add(&ns->ns_list_chain, &ldlm_cli_inactive_namespace_list);
+ ldlm_namespace_nr_inc(client);
+ mutex_unlock(ldlm_namespace_lock(client));
+}
+
/**
* Create and initialize new empty namespace.
*/
@@ -590,7 +650,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
break;
}
- OBD_ALLOC_PTR(ns);
+ ns = kzalloc(sizeof(*ns), GFP_NOFS);
if (!ns)
goto out_ref;
@@ -623,25 +683,26 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
atomic_set(&ns->ns_bref, 0);
init_waitqueue_head(&ns->ns_waitq);
- ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES;
- ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS;
- ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS;
-
ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT;
ns->ns_nr_unused = 0;
ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE;
- ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT;
- ns->ns_timeouts = 0;
ns->ns_orig_connect_flags = 0;
ns->ns_connect_flags = 0;
ns->ns_stopping = 0;
- rc = ldlm_namespace_proc_register(ns);
+
+ rc = ldlm_namespace_sysfs_register(ns);
if (rc != 0) {
- CERROR("Can't initialize ns proc, rc %d\n", rc);
+ CERROR("Can't initialize ns sysfs, rc %d\n", rc);
goto out_hash;
}
+ rc = ldlm_namespace_debugfs_register(ns);
+ if (rc != 0) {
+ CERROR("Can't initialize ns proc, rc %d\n", rc);
+ goto out_sysfs;
+ }
+
idx = ldlm_namespace_nr_read(client);
rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client);
if (rc) {
@@ -652,12 +713,14 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
ldlm_namespace_register(ns, client);
return ns;
out_proc:
- ldlm_namespace_proc_unregister(ns);
+ ldlm_namespace_debugfs_unregister(ns);
+out_sysfs:
+ ldlm_namespace_sysfs_unregister(ns);
ldlm_namespace_cleanup(ns, 0);
out_hash:
cfs_hash_putref(ns->ns_rs_hash);
out_ns:
- OBD_FREE_PTR(ns);
+ kfree(ns);
out_ref:
ldlm_put_ref();
return NULL;
@@ -678,11 +741,12 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
__u64 flags)
{
struct list_head *tmp;
- int rc = 0, client = ns_is_client(ldlm_res_to_ns(res));
+ int rc = 0;
bool local_only = !!(flags & LDLM_FL_LOCAL_ONLY);
do {
struct ldlm_lock *lock = NULL;
+ struct lustre_handle lockh;
/* First, we look for non-cleaned-yet lock
* all cleaned locks are marked by CLEANED flag. */
@@ -727,20 +791,11 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
continue;
}
- if (client) {
- struct lustre_handle lockh;
-
- unlock_res(res);
- ldlm_lock2handle(lock, &lockh);
- rc = ldlm_cli_cancel(&lockh, LCF_ASYNC);
- if (rc)
- CERROR("ldlm_cli_cancel: %d\n", rc);
- } else {
- ldlm_resource_unlink_lock(lock);
- unlock_res(res);
- LDLM_DEBUG(lock, "Freeing a lock still held by a client node");
- ldlm_lock_destroy(lock);
- }
+ unlock_res(res);
+ ldlm_lock2handle(lock, &lockh);
+ rc = ldlm_cli_cancel(&lockh, LCF_ASYNC);
+ if (rc)
+ CERROR("ldlm_cli_cancel: %d\n", rc);
LDLM_LOCK_RELEASE(lock);
} while (1);
}
@@ -752,7 +807,6 @@ static int ldlm_resource_clean(struct cfs_hash *hs, struct cfs_hash_bd *bd,
__u64 flags = *(__u64 *)arg;
cleanup_resource(res, &res->lr_granted, flags);
- cleanup_resource(res, &res->lr_converting, flags);
cleanup_resource(res, &res->lr_waiting, flags);
return 0;
@@ -881,6 +935,20 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
}
}
+/** Unregister \a ns from the list of namespaces. */
+static void ldlm_namespace_unregister(struct ldlm_namespace *ns,
+ ldlm_side_t client)
+{
+ mutex_lock(ldlm_namespace_lock(client));
+ LASSERT(!list_empty(&ns->ns_list_chain));
+ /* Some asserts and possibly other parts of the code are still
+ * using list_empty(&ns->ns_list_chain). This is why it is
+ * important to use list_del_init() here. */
+ list_del_init(&ns->ns_list_chain);
+ ldlm_namespace_nr_dec(client);
+ mutex_unlock(ldlm_namespace_lock(client));
+}
+
/**
* Performs freeing memory structures related to \a ns. This is only done
* when ldlm_namespce_free_prior() successfully removed all resources
@@ -898,43 +966,17 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
* Removing it after @dir may cause oops. */
ldlm_pool_fini(&ns->ns_pool);
- ldlm_namespace_proc_unregister(ns);
+ ldlm_namespace_debugfs_unregister(ns);
+ ldlm_namespace_sysfs_unregister(ns);
cfs_hash_putref(ns->ns_rs_hash);
/* Namespace \a ns should be not on list at this time, otherwise
* this will cause issues related to using freed \a ns in poold
* thread. */
LASSERT(list_empty(&ns->ns_list_chain));
- OBD_FREE_PTR(ns);
+ kfree(ns);
ldlm_put_ref();
}
-/**
- * Cleanup the resource, and free namespace.
- * bug 12864:
- * Deadlock issue:
- * proc1: destroy import
- * class_disconnect_export(grab cl_sem) ->
- * -> ldlm_namespace_free ->
- * -> lprocfs_remove(grab _lprocfs_lock).
- * proc2: read proc info
- * lprocfs_fops_read(grab _lprocfs_lock) ->
- * -> osc_rd_active, etc(grab cl_sem).
- *
- * So that I have to split the ldlm_namespace_free into two parts - the first
- * part ldlm_namespace_free_prior is used to cleanup the resource which is
- * being used; the 2nd part ldlm_namespace_free_post is used to unregister the
- * lprocfs entries, and then free memory. It will be called w/o cli->cl_sem
- * held.
- */
-void ldlm_namespace_free(struct ldlm_namespace *ns,
- struct obd_import *imp,
- int force)
-{
- ldlm_namespace_free_prior(ns, imp, force);
- ldlm_namespace_free_post(ns);
-}
-EXPORT_SYMBOL(ldlm_namespace_free);
-
void ldlm_namespace_get(struct ldlm_namespace *ns)
{
atomic_inc(&ns->ns_bref);
@@ -942,7 +984,7 @@ void ldlm_namespace_get(struct ldlm_namespace *ns)
EXPORT_SYMBOL(ldlm_namespace_get);
/* This is only for callers that care about refcount */
-int ldlm_namespace_get_return(struct ldlm_namespace *ns)
+static int ldlm_namespace_get_return(struct ldlm_namespace *ns)
{
return atomic_inc_return(&ns->ns_bref);
}
@@ -956,29 +998,6 @@ void ldlm_namespace_put(struct ldlm_namespace *ns)
}
EXPORT_SYMBOL(ldlm_namespace_put);
-/** Register \a ns in the list of namespaces */
-void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client)
-{
- mutex_lock(ldlm_namespace_lock(client));
- LASSERT(list_empty(&ns->ns_list_chain));
- list_add(&ns->ns_list_chain, ldlm_namespace_inactive_list(client));
- ldlm_namespace_nr_inc(client);
- mutex_unlock(ldlm_namespace_lock(client));
-}
-
-/** Unregister \a ns from the list of namespaces. */
-void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client)
-{
- mutex_lock(ldlm_namespace_lock(client));
- LASSERT(!list_empty(&ns->ns_list_chain));
- /* Some asserts and possibly other parts of the code are still
- * using list_empty(&ns->ns_list_chain). This is why it is
- * important to use list_del_init() here. */
- list_del_init(&ns->ns_list_chain);
- ldlm_namespace_nr_dec(client);
- mutex_unlock(ldlm_namespace_lock(client));
-}
-
/** Should be called with ldlm_namespace_lock(client) taken. */
void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *ns,
ldlm_side_t client)
@@ -994,8 +1013,7 @@ void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *ns,
{
LASSERT(!list_empty(&ns->ns_list_chain));
LASSERT(mutex_is_locked(ldlm_namespace_lock(client)));
- list_move_tail(&ns->ns_list_chain,
- ldlm_namespace_inactive_list(client));
+ list_move_tail(&ns->ns_list_chain, &ldlm_cli_inactive_namespace_list);
}
/** Should be called with ldlm_namespace_lock(client) taken. */
@@ -1013,12 +1031,11 @@ static struct ldlm_resource *ldlm_resource_new(void)
struct ldlm_resource *res;
int idx;
- OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, GFP_NOFS);
+ res = kmem_cache_alloc(ldlm_resource_slab, GFP_NOFS | __GFP_ZERO);
if (res == NULL)
return NULL;
INIT_LIST_HEAD(&res->lr_granted);
- INIT_LIST_HEAD(&res->lr_converting);
INIT_LIST_HEAD(&res->lr_waiting);
/* Initialize interval trees for each lock mode. */
@@ -1107,7 +1124,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
lu_ref_fini(&res->lr_reference);
/* We have taken lr_lvb_mutex. Drop it. */
mutex_unlock(&res->lr_lvb_mutex);
- OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof(*res));
+ kmem_cache_free(ldlm_resource_slab, res);
res = hlist_entry(hnode, struct ldlm_resource, lr_hash);
/* Synchronize with regard to resource creation. */
@@ -1137,10 +1154,8 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
CERROR("%s: lvbo_init failed for resource %#llx:%#llx: rc = %d\n",
ns->ns_obd->obd_name, name->name[0],
name->name[1], rc);
- if (res->lr_lvb_data) {
- OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
- res->lr_lvb_data = NULL;
- }
+ kfree(res->lr_lvb_data);
+ res->lr_lvb_data = NULL;
res->lr_lvb_len = rc;
mutex_unlock(&res->lr_lvb_mutex);
ldlm_resource_putref(res);
@@ -1155,7 +1170,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
* namespace. If so, and this is a client namespace, we need to move
* the namespace into the active namespaces list to be patrolled by
* the ldlm_poold. */
- if (ns_is_client(ns) && ns_refcount == 1) {
+ if (ns_refcount == 1) {
mutex_lock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT));
ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT);
mutex_unlock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT));
@@ -1165,16 +1180,6 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
}
EXPORT_SYMBOL(ldlm_resource_get);
-struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res)
-{
- LASSERT(res != NULL);
- LASSERT(res != LP_POISON);
- atomic_inc(&res->lr_refcount);
- CDEBUG(D_INFO, "getref res: %p count: %d\n", res,
- atomic_read(&res->lr_refcount));
- return res;
-}
-
static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
struct ldlm_resource *res)
{
@@ -1185,11 +1190,6 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
LBUG();
}
- if (!list_empty(&res->lr_converting)) {
- ldlm_resource_dump(D_ERROR, res);
- LBUG();
- }
-
if (!list_empty(&res->lr_waiting)) {
ldlm_resource_dump(D_ERROR, res);
LBUG();
@@ -1218,7 +1218,7 @@ int ldlm_resource_putref(struct ldlm_resource *res)
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);
- OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof(*res));
+ kmem_cache_free(ldlm_resource_slab, res);
return 1;
}
return 0;
@@ -1248,7 +1248,7 @@ int ldlm_resource_putref_locked(struct ldlm_resource *res)
*/
if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
ns->ns_lvbo->lvbo_free(res);
- OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof(*res));
+ kmem_cache_free(ldlm_resource_slab, res);
cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1);
return 1;
@@ -1276,32 +1276,6 @@ void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head,
list_add_tail(&lock->l_res_link, head);
}
-/**
- * Insert a lock into resource after specified lock.
- *
- * Obtain resource description from the lock we are inserting after.
- */
-void ldlm_resource_insert_lock_after(struct ldlm_lock *original,
- struct ldlm_lock *new)
-{
- struct ldlm_resource *res = original->l_resource;
-
- check_res_locked(res);
-
- ldlm_resource_dump(D_INFO, res);
- LDLM_DEBUG(new, "About to insert this lock after %p:\n", original);
-
- if (new->l_flags & LDLM_FL_DESTROYED) {
- CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n");
- goto out;
- }
-
- LASSERT(list_empty(&new->l_res_link));
-
- list_add(&new->l_res_link, &original->l_res_link);
- out:;
-}
-
void ldlm_resource_unlink_lock(struct ldlm_lock *lock)
{
int type = lock->l_resource->lr_type;
@@ -1367,9 +1341,8 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
if (!((libcfs_debug | D_ERROR) & level))
return;
- CDEBUG(level, "--- Namespace: %s (rc: %d, side: %s)\n",
- ldlm_ns_name(ns), atomic_read(&ns->ns_bref),
- ns_is_client(ns) ? "client" : "server");
+ CDEBUG(level, "--- Namespace: %s (rc: %d, side: client)\n",
+ ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
if (time_before(cfs_time_current(), ns->ns_next_dump))
return;
@@ -1412,11 +1385,6 @@ void ldlm_resource_dump(int level, struct ldlm_resource *res)
}
}
}
- if (!list_empty(&res->lr_converting)) {
- CDEBUG(level, "Converting locks:\n");
- list_for_each_entry(lock, &res->lr_converting, l_res_link)
- LDLM_DEBUG_LIMIT(level, lock, "###");
- }
if (!list_empty(&res->lr_waiting)) {
CDEBUG(level, "Waiting locks:\n");
list_for_each_entry(lock, &res->lr_waiting, l_res_link)
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/Makefile b/kernel/drivers/staging/lustre/lustre/libcfs/Makefile
index 2996a48a3..03d3f3d7b 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/Makefile
@@ -2,15 +2,15 @@ obj-$(CONFIG_LUSTRE_FS) += libcfs.o
libcfs-linux-objs := linux-tracefile.o linux-debug.o
libcfs-linux-objs += linux-prim.o linux-cpu.o
-libcfs-linux-objs += linux-tcpip.o
libcfs-linux-objs += linux-curproc.o
libcfs-linux-objs += linux-module.o
libcfs-linux-objs += linux-crypto.o
libcfs-linux-objs += linux-crypto-adler.o
+libcfs-linux-objs += linux-mem.o
libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
-libcfs-all-objs := debug.o fail.o nidstrings.o module.o tracefile.o \
+libcfs-all-objs := debug.o fail.o module.o tracefile.o \
libcfs_string.o hash.o kernel_user_comm.o \
prng.o workitem.o libcfs_cpu.o \
libcfs_mem.o libcfs_lock.o
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/debug.c b/kernel/drivers/staging/lustre/lustre/libcfs/debug.c
index 021c92fa0..1d1c67164 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -57,8 +57,42 @@ module_param(libcfs_debug, int, 0644);
MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
EXPORT_SYMBOL(libcfs_debug);
+static int libcfs_param_debug_mb_set(const char *val,
+ const struct kernel_param *kp)
+{
+ int rc;
+ unsigned num;
+
+ rc = kstrtouint(val, 0, &num);
+ if (rc < 0)
+ return rc;
+
+ if (!*((unsigned int *)kp->arg)) {
+ *((unsigned int *)kp->arg) = num;
+ return 0;
+ }
+
+ rc = cfs_trace_set_debug_mb(num);
+
+ if (!rc)
+ *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
+
+ return rc;
+}
+
+/* While debug_mb setting look like unsigned int, in fact
+ * it needs quite a bunch of extra processing, so we define special
+ * debugmb parameter type with corresponding methods to handle this case */
+static struct kernel_param_ops param_ops_debugmb = {
+ .set = libcfs_param_debug_mb_set,
+ .get = param_get_uint,
+};
+
+#define param_check_debugmb(name, p) \
+ __param_check(name, p, unsigned int)
+
static unsigned int libcfs_debug_mb;
-module_param(libcfs_debug_mb, uint, 0644);
+module_param(libcfs_debug_mb, debugmb, 0644);
MODULE_PARM_DESC(libcfs_debug_mb, "Total debug buffer size.");
EXPORT_SYMBOL(libcfs_debug_mb);
@@ -72,18 +106,106 @@ module_param(libcfs_console_ratelimit, uint, 0644);
MODULE_PARM_DESC(libcfs_console_ratelimit, "Lustre kernel debug console ratelimit (0 to disable)");
EXPORT_SYMBOL(libcfs_console_ratelimit);
+static int param_set_delay_minmax(const char *val,
+ const struct kernel_param *kp,
+ long min, long max)
+{
+ long d;
+ int sec;
+ int rc;
+
+ rc = kstrtoint(val, 0, &sec);
+ if (rc)
+ return -EINVAL;
+
+ d = cfs_time_seconds(sec) / 100;
+ if (d < min || d > max)
+ return -EINVAL;
+
+ *((unsigned int *)kp->arg) = d;
+
+ return 0;
+}
+
+static int param_get_delay(char *buffer, const struct kernel_param *kp)
+{
+ unsigned int d = *(unsigned int *)kp->arg;
+
+ return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
+}
+
unsigned int libcfs_console_max_delay;
-module_param(libcfs_console_max_delay, uint, 0644);
-MODULE_PARM_DESC(libcfs_console_max_delay, "Lustre kernel debug console max delay (jiffies)");
EXPORT_SYMBOL(libcfs_console_max_delay);
-
unsigned int libcfs_console_min_delay;
-module_param(libcfs_console_min_delay, uint, 0644);
-MODULE_PARM_DESC(libcfs_console_min_delay, "Lustre kernel debug console min delay (jiffies)");
EXPORT_SYMBOL(libcfs_console_min_delay);
+static int param_set_console_max_delay(const char *val,
+ const struct kernel_param *kp)
+{
+ return param_set_delay_minmax(val, kp,
+ libcfs_console_min_delay, INT_MAX);
+}
+
+static struct kernel_param_ops param_ops_console_max_delay = {
+ .set = param_set_console_max_delay,
+ .get = param_get_delay,
+};
+
+#define param_check_console_max_delay(name, p) \
+ __param_check(name, p, unsigned int)
+
+module_param(libcfs_console_max_delay, console_max_delay, 0644);
+MODULE_PARM_DESC(libcfs_console_max_delay, "Lustre kernel debug console max delay (jiffies)");
+
+static int param_set_console_min_delay(const char *val,
+ const struct kernel_param *kp)
+{
+ return param_set_delay_minmax(val, kp,
+ 1, libcfs_console_max_delay);
+}
+
+static struct kernel_param_ops param_ops_console_min_delay = {
+ .set = param_set_console_min_delay,
+ .get = param_get_delay,
+};
+
+#define param_check_console_min_delay(name, p) \
+ __param_check(name, p, unsigned int)
+
+module_param(libcfs_console_min_delay, console_min_delay, 0644);
+MODULE_PARM_DESC(libcfs_console_min_delay, "Lustre kernel debug console min delay (jiffies)");
+
+static int param_set_uint_minmax(const char *val,
+ const struct kernel_param *kp,
+ unsigned int min, unsigned int max)
+{
+ unsigned int num;
+ int ret;
+
+ if (!val)
+ return -EINVAL;
+ ret = kstrtouint(val, 0, &num);
+ if (ret < 0 || num < min || num > max)
+ return -EINVAL;
+ *((unsigned int *)kp->arg) = num;
+ return 0;
+}
+
+static int param_set_uintpos(const char *val, const struct kernel_param *kp)
+{
+ return param_set_uint_minmax(val, kp, 1, -1);
+}
+
+static struct kernel_param_ops param_ops_uintpos = {
+ .set = param_set_uintpos,
+ .get = param_get_uint,
+};
+
+#define param_check_uintpos(name, p) \
+ __param_check(name, p, unsigned int)
+
unsigned int libcfs_console_backoff = CDEBUG_DEFAULT_BACKOFF;
-module_param(libcfs_console_backoff, uint, 0644);
+module_param(libcfs_console_backoff, uintpos, 0644);
MODULE_PARM_DESC(libcfs_console_backoff, "Lustre kernel debug console backoff factor");
EXPORT_SYMBOL(libcfs_console_backoff);
@@ -93,23 +215,14 @@ EXPORT_SYMBOL(libcfs_debug_binary);
unsigned int libcfs_stack = 3 * THREAD_SIZE / 4;
EXPORT_SYMBOL(libcfs_stack);
-static unsigned int portal_enter_debugger;
-EXPORT_SYMBOL(portal_enter_debugger);
-
unsigned int libcfs_catastrophe;
EXPORT_SYMBOL(libcfs_catastrophe);
-unsigned int libcfs_watchdog_ratelimit = 300;
-EXPORT_SYMBOL(libcfs_watchdog_ratelimit);
-
unsigned int libcfs_panic_on_lbug = 1;
module_param(libcfs_panic_on_lbug, uint, 0644);
MODULE_PARM_DESC(libcfs_panic_on_lbug, "Lustre kernel panic on LBUG");
EXPORT_SYMBOL(libcfs_panic_on_lbug);
-atomic_t libcfs_kmemory = ATOMIC_INIT(0);
-EXPORT_SYMBOL(libcfs_kmemory);
-
static wait_queue_head_t debug_ctlwq;
char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT;
@@ -339,8 +452,8 @@ void libcfs_debug_dumplog_internal(void *arg)
if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) {
snprintf(debug_file_name, sizeof(debug_file_name) - 1,
- "%s.%ld.%ld", libcfs_debug_file_path_arr,
- get_seconds(), (long_ptr_t)arg);
+ "%s.%lld.%ld", libcfs_debug_file_path_arr,
+ (s64)ktime_get_real_seconds(), (long_ptr_t)arg);
pr_alert("LustreError: dumping log to %s\n",
debug_file_name);
cfs_tracefile_dump_all_pages(debug_file_name);
@@ -414,8 +527,10 @@ int libcfs_debug_init(unsigned long bufsize)
}
rc = cfs_tracefile_init(max);
- if (rc == 0)
+ if (rc == 0) {
libcfs_register_panic_notifier();
+ libcfs_debug_mb = cfs_trace_get_debug_mb();
+ }
return rc;
}
@@ -447,6 +562,7 @@ int libcfs_debug_mark_buffer(const char *text)
return 0;
}
+
#undef DEBUG_SUBSYSTEM
#define DEBUG_SUBSYSTEM S_LNET
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/fail.c b/kernel/drivers/staging/lustre/lustre/libcfs/fail.c
index 92444b0fe..d39fecebd 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/fail.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/fail.c
@@ -35,13 +35,13 @@
#include "../../include/linux/libcfs/libcfs.h"
-unsigned long cfs_fail_loc = 0;
+unsigned long cfs_fail_loc;
EXPORT_SYMBOL(cfs_fail_loc);
-unsigned int cfs_fail_val = 0;
+unsigned int cfs_fail_val;
EXPORT_SYMBOL(cfs_fail_val);
-wait_queue_head_t cfs_race_waitq;
+DECLARE_WAIT_QUEUE_HEAD(cfs_race_waitq);
EXPORT_SYMBOL(cfs_race_waitq);
int cfs_race_state;
@@ -123,7 +123,7 @@ EXPORT_SYMBOL(__cfs_fail_check_set);
int __cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
{
- int ret = 0;
+ int ret;
ret = __cfs_fail_check_set(id, value, set);
if (ret) {
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/hash.c b/kernel/drivers/staging/lustre/lustre/libcfs/hash.c
index a55567e0d..030874428 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/hash.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/hash.c
@@ -159,7 +159,7 @@ cfs_hash_rw_unlock(union cfs_hash_lock *lock, int exclusive)
}
/** No lock hash */
-static cfs_hash_lock_ops_t cfs_hash_nl_lops = {
+static struct cfs_hash_lock_ops cfs_hash_nl_lops = {
.hs_lock = cfs_hash_nl_lock,
.hs_unlock = cfs_hash_nl_unlock,
.hs_bkt_lock = cfs_hash_nl_lock,
@@ -167,7 +167,7 @@ static cfs_hash_lock_ops_t cfs_hash_nl_lops = {
};
/** no bucket lock, one spinlock to protect everything */
-static cfs_hash_lock_ops_t cfs_hash_nbl_lops = {
+static struct cfs_hash_lock_ops cfs_hash_nbl_lops = {
.hs_lock = cfs_hash_spin_lock,
.hs_unlock = cfs_hash_spin_unlock,
.hs_bkt_lock = cfs_hash_nl_lock,
@@ -175,7 +175,7 @@ static cfs_hash_lock_ops_t cfs_hash_nbl_lops = {
};
/** spin bucket lock, rehash is enabled */
-static cfs_hash_lock_ops_t cfs_hash_bkt_spin_lops = {
+static struct cfs_hash_lock_ops cfs_hash_bkt_spin_lops = {
.hs_lock = cfs_hash_rw_lock,
.hs_unlock = cfs_hash_rw_unlock,
.hs_bkt_lock = cfs_hash_spin_lock,
@@ -183,7 +183,7 @@ static cfs_hash_lock_ops_t cfs_hash_bkt_spin_lops = {
};
/** rw bucket lock, rehash is enabled */
-static cfs_hash_lock_ops_t cfs_hash_bkt_rw_lops = {
+static struct cfs_hash_lock_ops cfs_hash_bkt_rw_lops = {
.hs_lock = cfs_hash_rw_lock,
.hs_unlock = cfs_hash_rw_unlock,
.hs_bkt_lock = cfs_hash_rw_lock,
@@ -191,7 +191,7 @@ static cfs_hash_lock_ops_t cfs_hash_bkt_rw_lops = {
};
/** spin bucket lock, rehash is disabled */
-static cfs_hash_lock_ops_t cfs_hash_nr_bkt_spin_lops = {
+static struct cfs_hash_lock_ops cfs_hash_nr_bkt_spin_lops = {
.hs_lock = cfs_hash_nl_lock,
.hs_unlock = cfs_hash_nl_unlock,
.hs_bkt_lock = cfs_hash_spin_lock,
@@ -199,7 +199,7 @@ static cfs_hash_lock_ops_t cfs_hash_nr_bkt_spin_lops = {
};
/** rw bucket lock, rehash is disabled */
-static cfs_hash_lock_ops_t cfs_hash_nr_bkt_rw_lops = {
+static struct cfs_hash_lock_ops cfs_hash_nr_bkt_rw_lops = {
.hs_lock = cfs_hash_nl_lock,
.hs_unlock = cfs_hash_nl_unlock,
.hs_bkt_lock = cfs_hash_rw_lock,
@@ -239,21 +239,22 @@ cfs_hash_lock_setup(struct cfs_hash *hs)
* Simple hash head without depth tracking
* new element is always added to head of hlist
*/
-typedef struct {
+struct cfs_hash_head {
struct hlist_head hh_head; /**< entries list */
-} cfs_hash_head_t;
+};
static int
cfs_hash_hh_hhead_size(struct cfs_hash *hs)
{
- return sizeof(cfs_hash_head_t);
+ return sizeof(struct cfs_hash_head);
}
static struct hlist_head *
cfs_hash_hh_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd)
{
- cfs_hash_head_t *head = (cfs_hash_head_t *)&bd->bd_bucket->hsb_head[0];
+ struct cfs_hash_head *head;
+ head = (struct cfs_hash_head *)&bd->bd_bucket->hsb_head[0];
return &head[bd->bd_offset].hh_head;
}
@@ -277,23 +278,23 @@ cfs_hash_hh_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd,
* Simple hash head with depth tracking
* new element is always added to head of hlist
*/
-typedef struct {
+struct cfs_hash_head_dep {
struct hlist_head hd_head; /**< entries list */
- unsigned int hd_depth; /**< list length */
-} cfs_hash_head_dep_t;
+ unsigned int hd_depth; /**< list length */
+};
static int
cfs_hash_hd_hhead_size(struct cfs_hash *hs)
{
- return sizeof(cfs_hash_head_dep_t);
+ return sizeof(struct cfs_hash_head_dep);
}
static struct hlist_head *
cfs_hash_hd_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd)
{
- cfs_hash_head_dep_t *head;
+ struct cfs_hash_head_dep *head;
- head = (cfs_hash_head_dep_t *)&bd->bd_bucket->hsb_head[0];
+ head = (struct cfs_hash_head_dep *)&bd->bd_bucket->hsb_head[0];
return &head[bd->bd_offset].hd_head;
}
@@ -301,8 +302,10 @@ static int
cfs_hash_hd_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnode)
{
- cfs_hash_head_dep_t *hh = container_of(cfs_hash_hd_hhead(hs, bd),
- cfs_hash_head_dep_t, hd_head);
+ struct cfs_hash_head_dep *hh;
+
+ hh = container_of(cfs_hash_hd_hhead(hs, bd),
+ struct cfs_hash_head_dep, hd_head);
hlist_add_head(hnode, &hh->hd_head);
return ++hh->hd_depth;
}
@@ -311,8 +314,10 @@ static int
cfs_hash_hd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnode)
{
- cfs_hash_head_dep_t *hh = container_of(cfs_hash_hd_hhead(hs, bd),
- cfs_hash_head_dep_t, hd_head);
+ struct cfs_hash_head_dep *hh;
+
+ hh = container_of(cfs_hash_hd_hhead(hs, bd),
+ struct cfs_hash_head_dep, hd_head);
hlist_del_init(hnode);
return --hh->hd_depth;
}
@@ -321,23 +326,23 @@ cfs_hash_hd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd,
* double links hash head without depth tracking
* new element is always added to tail of hlist
*/
-typedef struct {
+struct cfs_hash_dhead {
struct hlist_head dh_head; /**< entries list */
struct hlist_node *dh_tail; /**< the last entry */
-} cfs_hash_dhead_t;
+};
static int
cfs_hash_dh_hhead_size(struct cfs_hash *hs)
{
- return sizeof(cfs_hash_dhead_t);
+ return sizeof(struct cfs_hash_dhead);
}
static struct hlist_head *
cfs_hash_dh_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd)
{
- cfs_hash_dhead_t *head;
+ struct cfs_hash_dhead *head;
- head = (cfs_hash_dhead_t *)&bd->bd_bucket->hsb_head[0];
+ head = (struct cfs_hash_dhead *)&bd->bd_bucket->hsb_head[0];
return &head[bd->bd_offset].dh_head;
}
@@ -345,9 +350,10 @@ static int
cfs_hash_dh_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnode)
{
- cfs_hash_dhead_t *dh = container_of(cfs_hash_dh_hhead(hs, bd),
- cfs_hash_dhead_t, dh_head);
+ struct cfs_hash_dhead *dh;
+ dh = container_of(cfs_hash_dh_hhead(hs, bd),
+ struct cfs_hash_dhead, dh_head);
if (dh->dh_tail != NULL) /* not empty */
hlist_add_behind(hnode, dh->dh_tail);
else /* empty list */
@@ -360,9 +366,10 @@ static int
cfs_hash_dh_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnd)
{
- cfs_hash_dhead_t *dh = container_of(cfs_hash_dh_hhead(hs, bd),
- cfs_hash_dhead_t, dh_head);
+ struct cfs_hash_dhead *dh;
+ dh = container_of(cfs_hash_dh_hhead(hs, bd),
+ struct cfs_hash_dhead, dh_head);
if (hnd->next == NULL) { /* it's the tail */
dh->dh_tail = (hnd->pprev == &dh->dh_head.first) ? NULL :
container_of(hnd->pprev, struct hlist_node, next);
@@ -375,24 +382,24 @@ cfs_hash_dh_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd,
* double links hash head with depth tracking
* new element is always added to tail of hlist
*/
-typedef struct {
+struct cfs_hash_dhead_dep {
struct hlist_head dd_head; /**< entries list */
struct hlist_node *dd_tail; /**< the last entry */
unsigned int dd_depth; /**< list length */
-} cfs_hash_dhead_dep_t;
+};
static int
cfs_hash_dd_hhead_size(struct cfs_hash *hs)
{
- return sizeof(cfs_hash_dhead_dep_t);
+ return sizeof(struct cfs_hash_dhead_dep);
}
static struct hlist_head *
cfs_hash_dd_hhead(struct cfs_hash *hs, struct cfs_hash_bd *bd)
{
- cfs_hash_dhead_dep_t *head;
+ struct cfs_hash_dhead_dep *head;
- head = (cfs_hash_dhead_dep_t *)&bd->bd_bucket->hsb_head[0];
+ head = (struct cfs_hash_dhead_dep *)&bd->bd_bucket->hsb_head[0];
return &head[bd->bd_offset].dd_head;
}
@@ -400,9 +407,10 @@ static int
cfs_hash_dd_hnode_add(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnode)
{
- cfs_hash_dhead_dep_t *dh = container_of(cfs_hash_dd_hhead(hs, bd),
- cfs_hash_dhead_dep_t, dd_head);
+ struct cfs_hash_dhead_dep *dh;
+ dh = container_of(cfs_hash_dd_hhead(hs, bd),
+ struct cfs_hash_dhead_dep, dd_head);
if (dh->dd_tail != NULL) /* not empty */
hlist_add_behind(hnode, dh->dd_tail);
else /* empty list */
@@ -415,9 +423,10 @@ static int
cfs_hash_dd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnd)
{
- cfs_hash_dhead_dep_t *dh = container_of(cfs_hash_dd_hhead(hs, bd),
- cfs_hash_dhead_dep_t, dd_head);
+ struct cfs_hash_dhead_dep *dh;
+ dh = container_of(cfs_hash_dd_hhead(hs, bd),
+ struct cfs_hash_dhead_dep, dd_head);
if (hnd->next == NULL) { /* it's the tail */
dh->dd_tail = (hnd->pprev == &dh->dd_head.first) ? NULL :
container_of(hnd->pprev, struct hlist_node, next);
@@ -426,32 +435,32 @@ cfs_hash_dd_hnode_del(struct cfs_hash *hs, struct cfs_hash_bd *bd,
return --dh->dd_depth;
}
-static cfs_hash_hlist_ops_t cfs_hash_hh_hops = {
- .hop_hhead = cfs_hash_hh_hhead,
- .hop_hhead_size = cfs_hash_hh_hhead_size,
- .hop_hnode_add = cfs_hash_hh_hnode_add,
- .hop_hnode_del = cfs_hash_hh_hnode_del,
+static struct cfs_hash_hlist_ops cfs_hash_hh_hops = {
+ .hop_hhead = cfs_hash_hh_hhead,
+ .hop_hhead_size = cfs_hash_hh_hhead_size,
+ .hop_hnode_add = cfs_hash_hh_hnode_add,
+ .hop_hnode_del = cfs_hash_hh_hnode_del,
};
-static cfs_hash_hlist_ops_t cfs_hash_hd_hops = {
- .hop_hhead = cfs_hash_hd_hhead,
- .hop_hhead_size = cfs_hash_hd_hhead_size,
- .hop_hnode_add = cfs_hash_hd_hnode_add,
- .hop_hnode_del = cfs_hash_hd_hnode_del,
+static struct cfs_hash_hlist_ops cfs_hash_hd_hops = {
+ .hop_hhead = cfs_hash_hd_hhead,
+ .hop_hhead_size = cfs_hash_hd_hhead_size,
+ .hop_hnode_add = cfs_hash_hd_hnode_add,
+ .hop_hnode_del = cfs_hash_hd_hnode_del,
};
-static cfs_hash_hlist_ops_t cfs_hash_dh_hops = {
- .hop_hhead = cfs_hash_dh_hhead,
- .hop_hhead_size = cfs_hash_dh_hhead_size,
- .hop_hnode_add = cfs_hash_dh_hnode_add,
- .hop_hnode_del = cfs_hash_dh_hnode_del,
+static struct cfs_hash_hlist_ops cfs_hash_dh_hops = {
+ .hop_hhead = cfs_hash_dh_hhead,
+ .hop_hhead_size = cfs_hash_dh_hhead_size,
+ .hop_hnode_add = cfs_hash_dh_hnode_add,
+ .hop_hnode_del = cfs_hash_dh_hnode_del,
};
-static cfs_hash_hlist_ops_t cfs_hash_dd_hops = {
- .hop_hhead = cfs_hash_dd_hhead,
- .hop_hhead_size = cfs_hash_dd_hhead_size,
- .hop_hnode_add = cfs_hash_dd_hnode_add,
- .hop_hnode_del = cfs_hash_dd_hnode_del,
+static struct cfs_hash_hlist_ops cfs_hash_dd_hops = {
+ .hop_hhead = cfs_hash_dd_hhead,
+ .hop_hhead_size = cfs_hash_dd_hhead_size,
+ .hop_hnode_add = cfs_hash_dd_hnode_add,
+ .hop_hnode_del = cfs_hash_dd_hnode_del,
};
static void
@@ -588,16 +597,16 @@ EXPORT_SYMBOL(cfs_hash_bd_move_locked);
enum {
/** always set, for sanity (avoid ZERO intent) */
- CFS_HS_LOOKUP_MASK_FIND = 1 << 0,
+ CFS_HS_LOOKUP_MASK_FIND = BIT(0),
/** return entry with a ref */
- CFS_HS_LOOKUP_MASK_REF = 1 << 1,
+ CFS_HS_LOOKUP_MASK_REF = BIT(1),
/** add entry if not existing */
- CFS_HS_LOOKUP_MASK_ADD = 1 << 2,
+ CFS_HS_LOOKUP_MASK_ADD = BIT(2),
/** delete entry, ignore other masks */
- CFS_HS_LOOKUP_MASK_DEL = 1 << 3,
+ CFS_HS_LOOKUP_MASK_DEL = BIT(3),
};
-typedef enum cfs_hash_lookup_intent {
+enum cfs_hash_lookup_intent {
/** return item w/o refcount */
CFS_HS_LOOKUP_IT_PEEK = CFS_HS_LOOKUP_MASK_FIND,
/** return item with refcount */
@@ -612,12 +621,12 @@ typedef enum cfs_hash_lookup_intent {
/** delete if existed */
CFS_HS_LOOKUP_IT_FINDDEL = (CFS_HS_LOOKUP_MASK_FIND |
CFS_HS_LOOKUP_MASK_DEL)
-} cfs_hash_lookup_intent_t;
+};
static struct hlist_node *
cfs_hash_bd_lookup_intent(struct cfs_hash *hs, struct cfs_hash_bd *bd,
const void *key, struct hlist_node *hnode,
- cfs_hash_lookup_intent_t intent)
+ enum cfs_hash_lookup_intent intent)
{
struct hlist_head *hhead = cfs_hash_bd_hhead(hs, bd);
@@ -677,8 +686,8 @@ cfs_hash_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
int noref)
{
return cfs_hash_bd_lookup_intent(hs, bd, key, hnode,
- CFS_HS_LOOKUP_IT_ADD |
- (!noref * CFS_HS_LOOKUP_MASK_REF));
+ (!noref * CFS_HS_LOOKUP_MASK_REF) |
+ CFS_HS_LOOKUP_IT_ADD);
}
EXPORT_SYMBOL(cfs_hash_bd_findadd_locked);
@@ -756,7 +765,7 @@ cfs_hash_multi_bd_findadd_locked(struct cfs_hash *hs,
unsigned i;
LASSERT(hnode != NULL);
- intent = CFS_HS_LOOKUP_IT_PEEK | (!noref * CFS_HS_LOOKUP_MASK_REF);
+ intent = (!noref * CFS_HS_LOOKUP_MASK_REF) | CFS_HS_LOOKUP_IT_PEEK;
cfs_hash_for_each_bd(bds, n, i) {
ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key,
@@ -1019,7 +1028,7 @@ struct cfs_hash *
cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits,
unsigned bkt_bits, unsigned extra_bytes,
unsigned min_theta, unsigned max_theta,
- cfs_hash_ops_t *ops, unsigned flags)
+ struct cfs_hash_ops *ops, unsigned flags)
{
struct cfs_hash *hs;
int len;
@@ -1480,16 +1489,16 @@ cfs_hash_for_each_tight(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
return count;
}
-typedef struct {
- cfs_hash_cond_opt_cb_t func;
- void *arg;
-} cfs_hash_cond_arg_t;
+struct cfs_hash_cond_arg {
+ cfs_hash_cond_opt_cb_t func;
+ void *arg;
+};
static int
cfs_hash_cond_del_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
struct hlist_node *hnode, void *data)
{
- cfs_hash_cond_arg_t *cond = data;
+ struct cfs_hash_cond_arg *cond = data;
if (cond->func(cfs_hash_object(hs, hnode), cond->arg))
cfs_hash_bd_del_locked(hs, bd, hnode);
@@ -1504,7 +1513,7 @@ cfs_hash_cond_del_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
void
cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t func, void *data)
{
- cfs_hash_cond_arg_t arg = {
+ struct cfs_hash_cond_arg arg = {
.func = func,
.arg = data,
};
@@ -1623,8 +1632,12 @@ cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
if (rc) /* callback wants to break iteration */
break;
}
+ if (rc) /* callback wants to break iteration */
+ break;
}
cfs_hash_bd_unlock(hs, &bd, 0);
+ if (rc) /* callback wants to break iteration */
+ break;
}
cfs_hash_unlock(hs, 0);
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/kernel/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c
index d9b7c6b69..ad661a33a 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c
@@ -100,6 +100,7 @@ struct kkuc_reg {
struct file *kr_fp;
__u32 kr_data;
};
+
static struct list_head kkuc_groups[KUC_GRP_MAX+1] = {};
/* Protect message sending against remove and adds */
static DECLARE_RWSEM(kg_sem);
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
index 31a558115..933525c73 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(cfs_cpt_table_free);
int
cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
- int rc = 0;
+ int rc;
rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
len -= rc;
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c
index 2c199c725..94bc00785 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c
@@ -34,7 +34,6 @@
#include "../../include/linux/libcfs/libcfs.h"
-
/** destroy cpu-partition lock, see libcfs_private.h for more detail */
void
cfs_percpt_lock_free(struct cfs_percpt_lock *pcl)
@@ -63,12 +62,12 @@ cfs_percpt_lock_alloc(struct cfs_cpt_table *cptab)
/* NB: cptab can be NULL, pcl will be for HW CPUs on that case */
LIBCFS_ALLOC(pcl, sizeof(*pcl));
- if (pcl == NULL)
+ if (!pcl)
return NULL;
pcl->pcl_cptab = cptab;
pcl->pcl_locks = cfs_percpt_alloc(cptab, sizeof(*lock));
- if (pcl->pcl_locks == NULL) {
+ if (!pcl->pcl_locks) {
LIBCFS_FREE(pcl, sizeof(*pcl));
return NULL;
}
@@ -146,7 +145,6 @@ cfs_percpt_unlock(struct cfs_percpt_lock *pcl, int index)
}
EXPORT_SYMBOL(cfs_percpt_unlock);
-
/** free cpu-partition refcount */
void
cfs_percpt_atomic_free(atomic_t **refs)
@@ -164,7 +162,7 @@ cfs_percpt_atomic_alloc(struct cfs_cpt_table *cptab, int init_val)
int i;
refs = cfs_percpt_alloc(cptab, sizeof(*ref));
- if (refs == NULL)
+ if (!refs)
return NULL;
cfs_percpt_for_each(ref, i, refs)
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c
index 1debdda72..f4e08daba 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c
@@ -84,7 +84,7 @@ cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size)
count = cfs_cpt_number(cptab);
LIBCFS_ALLOC(arr, offsetof(struct cfs_var_array, va_ptrs[count]));
- if (arr == NULL)
+ if (!arr)
return NULL;
arr->va_size = size = L1_CACHE_ALIGN(size);
@@ -93,7 +93,7 @@ cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size)
for (i = 0; i < count; i++) {
LIBCFS_CPT_ALLOC(arr->va_ptrs[i], cptab, i, size);
- if (arr->va_ptrs[i] == NULL) {
+ if (!arr->va_ptrs[i]) {
cfs_percpt_free((void *)&arr->va_ptrs[0]);
return NULL;
}
@@ -160,7 +160,7 @@ cfs_array_free(void *vars)
arr = container_of(vars, struct cfs_var_array, va_ptrs[0]);
for (i = 0; i < arr->va_count; i++) {
- if (arr->va_ptrs[i] == NULL)
+ if (!arr->va_ptrs[i])
continue;
LIBCFS_FREE(arr->va_ptrs[i], arr->va_size);
@@ -182,7 +182,7 @@ cfs_array_alloc(int count, unsigned int size)
int i;
LIBCFS_ALLOC(arr, offsetof(struct cfs_var_array, va_ptrs[count]));
- if (arr == NULL)
+ if (!arr)
return NULL;
arr->va_count = count;
@@ -191,7 +191,7 @@ cfs_array_alloc(int count, unsigned int size)
for (i = 0; i < count; i++) {
LIBCFS_ALLOC(arr->va_ptrs[i], size);
- if (arr->va_ptrs[i] == NULL) {
+ if (!arr->va_ptrs[i]) {
cfs_array_free((void *)&arr->va_ptrs[0]);
return NULL;
}
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
index 76d4392bd..d40be5396 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
@@ -214,6 +214,7 @@ cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res)
res->ls_len = end - res->ls_str + 1;
return 1;
}
+EXPORT_SYMBOL(cfs_gettok);
/**
* Converts string to integer.
@@ -231,7 +232,7 @@ cfs_str2num_check(char *str, int nob, unsigned *num,
char *endp;
str = cfs_trimwhite(str);
- *num = strtoul(str, &endp, 0);
+ *num = simple_strtoul(str, &endp, 0);
if (endp == str)
return 0;
@@ -242,6 +243,7 @@ cfs_str2num_check(char *str, int nob, unsigned *num,
return (*num >= min && *num <= max);
}
+EXPORT_SYMBOL(cfs_str2num_check);
/**
* Parses \<range_expr\> token of the syntax. If \a bracketed is false,
@@ -321,6 +323,73 @@ cfs_range_expr_parse(struct cfs_lstr *src, unsigned min, unsigned max,
}
/**
+ * Print the range expression \a re into specified \a buffer.
+ * If \a bracketed is true, expression does not need additional
+ * brackets.
+ *
+ * \retval number of characters written
+ */
+static int
+cfs_range_expr_print(char *buffer, int count, struct cfs_range_expr *expr,
+ bool bracketed)
+{
+ int i;
+ char s[] = "[";
+ char e[] = "]";
+
+ if (bracketed)
+ s[0] = e[0] = '\0';
+
+ if (expr->re_lo == expr->re_hi)
+ i = scnprintf(buffer, count, "%u", expr->re_lo);
+ else if (expr->re_stride == 1)
+ i = scnprintf(buffer, count, "%s%u-%u%s",
+ s, expr->re_lo, expr->re_hi, e);
+ else
+ i = scnprintf(buffer, count, "%s%u-%u/%u%s",
+ s, expr->re_lo, expr->re_hi,
+ expr->re_stride, e);
+ return i;
+}
+
+/**
+ * Print a list of range expressions (\a expr_list) into specified \a buffer.
+ * If the list contains several expressions, separate them with comma
+ * and surround the list with brackets.
+ *
+ * \retval number of characters written
+ */
+int
+cfs_expr_list_print(char *buffer, int count, struct cfs_expr_list *expr_list)
+{
+ struct cfs_range_expr *expr;
+ int i = 0, j = 0;
+ int numexprs = 0;
+
+ if (count <= 0)
+ return 0;
+
+ list_for_each_entry(expr, &expr_list->el_exprs, re_link)
+ numexprs++;
+
+ if (numexprs > 1)
+ i += scnprintf(buffer + i, count - i, "[");
+
+ list_for_each_entry(expr, &expr_list->el_exprs, re_link) {
+ if (j++ != 0)
+ i += scnprintf(buffer + i, count - i, ",");
+ i += cfs_range_expr_print(buffer + i, count - i, expr,
+ numexprs > 1);
+ }
+
+ if (numexprs > 1)
+ i += scnprintf(buffer + i, count - i, "]");
+
+ return i;
+}
+EXPORT_SYMBOL(cfs_expr_list_print);
+
+/**
* Matches value (\a value) against ranges expression list \a expr_list.
*
* \retval 1 if \a value matches
@@ -339,6 +408,7 @@ cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list)
return 0;
}
+EXPORT_SYMBOL(cfs_expr_list_match);
/**
* Convert express list (\a expr_list) to an array of all matched values
@@ -400,7 +470,7 @@ cfs_expr_list_free(struct cfs_expr_list *expr_list)
struct cfs_range_expr *expr;
expr = list_entry(expr_list->el_exprs.next,
- struct cfs_range_expr, re_link),
+ struct cfs_range_expr, re_link);
list_del(&expr->re_link);
LIBCFS_FREE(expr, sizeof(*expr));
}
@@ -412,8 +482,8 @@ EXPORT_SYMBOL(cfs_expr_list_free);
/**
* Parses \<cfs_expr_list\> token of the syntax.
*
- * \retval 1 if \a str parses to \<number\> | \<expr_list\>
- * \retval 0 otherwise
+ * \retval 0 if \a str parses to \<number\> | \<expr_list\>
+ * \retval -errno otherwise
*/
int
cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max,
@@ -491,72 +561,4 @@ cfs_expr_list_free_list(struct list_head *list)
cfs_expr_list_free(el);
}
}
-
-int
-cfs_ip_addr_parse(char *str, int len, struct list_head *list)
-{
- struct cfs_expr_list *el;
- struct cfs_lstr src;
- int rc;
- int i;
-
- src.ls_str = str;
- src.ls_len = len;
- i = 0;
-
- while (src.ls_str != NULL) {
- struct cfs_lstr res;
-
- if (!cfs_gettok(&src, '.', &res)) {
- rc = -EINVAL;
- goto out;
- }
-
- rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
- if (rc != 0)
- goto out;
-
- list_add_tail(&el->el_link, list);
- i++;
- }
-
- if (i == 4)
- return 0;
-
- rc = -EINVAL;
- out:
- cfs_expr_list_free_list(list);
-
- return rc;
-}
-EXPORT_SYMBOL(cfs_ip_addr_parse);
-
-/**
- * Matches address (\a addr) against address set encoded in \a list.
- *
- * \retval 1 if \a addr matches
- * \retval 0 otherwise
- */
-int
-cfs_ip_addr_match(__u32 addr, struct list_head *list)
-{
- struct cfs_expr_list *el;
- int i = 0;
-
- list_for_each_entry_reverse(el, list, el_link) {
- if (!cfs_expr_list_match(addr & 0xff, el))
- return 0;
- addr >>= 8;
- i++;
- }
-
- return i == 4;
-}
-EXPORT_SYMBOL(cfs_ip_addr_match);
-
-void
-cfs_ip_addr_free(struct list_head *list)
-{
- cfs_expr_list_free_list(list);
-}
-EXPORT_SYMBOL(cfs_ip_addr_free);
+EXPORT_SYMBOL(cfs_expr_list_free_list);
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
index cc3ab3519..209736454 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
@@ -87,7 +87,7 @@ static void cfs_cpu_core_siblings(int cpu, cpumask_t *mask)
/* return cpumask of HTs in the same core */
static void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask)
{
- cpumask_copy(mask, topology_thread_cpumask(cpu));
+ cpumask_copy(mask, topology_sibling_cpumask(cpu));
}
static void cfs_node_to_cpumask(int node, cpumask_t *mask)
@@ -699,7 +699,8 @@ cfs_cpt_num_estimate(void)
/* generate reasonable number of CPU partitions based on total number
* of CPUs, Preferred N should be power2 and match this condition:
* 2 * (N - 1)^2 < NCPUS <= 2 * N^2 */
- for (ncpt = 2; ncpu > 2 * ncpt * ncpt; ncpt <<= 1) {}
+ for (ncpt = 2; ncpu > 2 * ncpt * ncpt; ncpt <<= 1)
+ ;
if (ncpt <= nnode) { /* fat numa system */
while (nnode > ncpt)
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c
index 5e185fa59..5d8d8b79f 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c
@@ -82,6 +82,7 @@ static int adler32_update(struct shash_desc *desc, const u8 *data,
*cksump = __adler32(*cksump, data, len);
return 0;
}
+
static int __adler32_finup(u32 *cksump, const u8 *data, unsigned int len,
u8 *out)
{
@@ -109,6 +110,7 @@ static int adler32_digest(struct shash_desc *desc, const u8 *data,
return __adler32_finup(crypto_shash_ctx(desc->tfm), data, len,
out);
}
+
static struct shash_alg alg = {
.setkey = adler32_setkey,
.init = adler32_init,
@@ -129,7 +131,6 @@ static struct shash_alg alg = {
}
};
-
int cfs_crypto_adler32_register(void)
{
return crypto_register_shash(&alg);
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c
index aa3fffed1..079d50ebf 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c
@@ -36,8 +36,6 @@
*/
static int cfs_crypto_hash_speeds[CFS_HASH_ALG_MAX];
-
-
static int cfs_crypto_hash_alloc(unsigned char alg_id,
const struct cfs_crypto_hash_type **type,
struct hash_desc *desc, unsigned char *key,
@@ -71,13 +69,12 @@ static int cfs_crypto_hash_alloc(unsigned char alg_id,
* Skip this function for digest, because we use shash logic at
* cfs_crypto_hash_alloc.
*/
- if (key != NULL) {
+ if (key != NULL)
err = crypto_hash_setkey(desc->tfm, key, key_len);
- } else if ((*type)->cht_key != 0) {
+ else if ((*type)->cht_key != 0)
err = crypto_hash_setkey(desc->tfm,
(unsigned char *)&((*type)->cht_key),
(*type)->cht_size);
- }
if (err != 0) {
crypto_free_hash(desc->tfm);
@@ -114,7 +111,7 @@ int cfs_crypto_hash_digest(unsigned char alg_id,
crypto_free_hash(hdesc.tfm);
return -ENOSPC;
}
- sg_init_one(&sl, (void *)buf, buf_len);
+ sg_init_one(&sl, buf, buf_len);
hdesc.flags = 0;
err = crypto_hash_digest(&hdesc, &sl, sl.length, hash);
@@ -165,7 +162,7 @@ int cfs_crypto_hash_update(struct cfs_crypto_hash_desc *hdesc,
{
struct scatterlist sl;
- sg_init_one(&sl, (void *)buf, buf_len);
+ sg_init_one(&sl, buf, buf_len);
return crypto_hash_update((struct hash_desc *)hdesc, &sl, sl.length);
}
@@ -225,6 +222,7 @@ static void cfs_crypto_performance_test(unsigned char alg_id,
cfs_crypto_hash_name(alg_id), err);
} else {
unsigned long tmp;
+
tmp = ((bcount * buf_len / jiffies_to_msecs(end - start)) *
1000) / (1024 * 1024);
cfs_crypto_hash_speeds[alg_id] = (int)tmp;
@@ -282,6 +280,7 @@ int cfs_crypto_register(void)
cfs_crypto_test_hashes();
return 0;
}
+
void cfs_crypto_unregister(void)
{
if (adler32 == 0)
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
index 277f6b890..c74c80915 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
@@ -91,6 +91,7 @@ static void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap)
cfs_cap_t cfs_curproc_cap_pack(void)
{
cfs_cap_t cap;
+
cfs_kernel_cap_pack(current_cap(), &cap);
return cap;
}
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c
index 4545d54f7..8689ea757 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c
@@ -146,7 +146,7 @@ void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata)
}
/* coverity[+kill] */
-void lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
+void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
{
libcfs_catastrophe = 1;
libcfs_debug_msg(msgdata, "LBUG\n");
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c
new file mode 100644
index 000000000..025e2f002
--- /dev/null
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c
@@ -0,0 +1,59 @@
+/*
+ * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ */
+/*
+ * This file creates a memory allocation primitive for Lustre, that
+ * allows to fallback to vmalloc allocations should regular kernel allocations
+ * fail due to size or system memory fragmentation.
+ *
+ * Author: Oleg Drokin <green@linuxhacker.ru>
+ *
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Seagate Technology.
+ */
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+
+#include "../../../include/linux/libcfs/libcfs.h"
+
+void *libcfs_kvzalloc(size_t size, gfp_t flags)
+{
+ void *ret;
+
+ ret = kzalloc(size, flags | __GFP_NOWARN);
+ if (!ret)
+ ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL);
+ return ret;
+}
+EXPORT_SYMBOL(libcfs_kvzalloc);
+
+void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
+ gfp_t flags)
+{
+ void *ret;
+
+ ret = kzalloc_node(size, flags | __GFP_NOWARN,
+ cfs_cpt_spread_node(cptab, cpt));
+ if (!ret) {
+ WARN_ON(!(flags & (__GFP_FS|__GFP_HIGH)));
+ ret = vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt));
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(libcfs_kvzalloc_cpt);
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
index e962f8968..70a99cf01 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
@@ -49,7 +49,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
hdr = (struct libcfs_ioctl_hdr *)buf;
data = (struct libcfs_ioctl_data *)buf;
- if (copy_from_user(buf, (void *)arg, sizeof(*hdr)))
+ if (copy_from_user(buf, arg, sizeof(*hdr)))
return -EFAULT;
if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) {
@@ -62,14 +62,13 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
return -EINVAL;
}
-
if (hdr->ioc_len < sizeof(struct libcfs_ioctl_data)) {
CERROR("PORTALS: user buffer too small for ioctl\n");
return -EINVAL;
}
orig_len = hdr->ioc_len;
- if (copy_from_user(buf, (void *)arg, hdr->ioc_len))
+ if (copy_from_user(buf, arg, hdr->ioc_len))
return -EFAULT;
if (orig_len != data->ioc_len)
return -EINVAL;
@@ -96,8 +95,6 @@ int libcfs_ioctl_popdata(void *arg, void *data, int size)
return 0;
}
-extern struct cfs_psdev_ops libcfs_psdev_ops;
-
static int
libcfs_psdev_open(struct inode *inode, struct file *file)
{
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c
index 838f5f3bd..890844602 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c
@@ -70,61 +70,6 @@ add_wait_queue_exclusive_head(wait_queue_head_t *waitq, wait_queue_t *link)
}
EXPORT_SYMBOL(add_wait_queue_exclusive_head);
-void cfs_init_timer(struct timer_list *t)
-{
- init_timer(t);
-}
-EXPORT_SYMBOL(cfs_init_timer);
-
-void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg)
-{
- init_timer(t);
- t->function = func;
- t->data = (unsigned long)arg;
-}
-EXPORT_SYMBOL(cfs_timer_init);
-
-void cfs_timer_done(struct timer_list *t)
-{
- return;
-}
-EXPORT_SYMBOL(cfs_timer_done);
-
-void cfs_timer_arm(struct timer_list *t, unsigned long deadline)
-{
- mod_timer(t, deadline);
-}
-EXPORT_SYMBOL(cfs_timer_arm);
-
-void cfs_timer_disarm(struct timer_list *t)
-{
- del_timer(t);
-}
-EXPORT_SYMBOL(cfs_timer_disarm);
-
-int cfs_timer_is_armed(struct timer_list *t)
-{
- return timer_pending(t);
-}
-EXPORT_SYMBOL(cfs_timer_is_armed);
-
-unsigned long cfs_timer_deadline(struct timer_list *t)
-{
- return t->expires;
-}
-EXPORT_SYMBOL(cfs_timer_deadline);
-
-void cfs_enter_debugger(void)
-{
-#if defined(CONFIG_KGDB)
- /* BREAKPOINT(); */
-#else
- /* nothing */
-#endif
-}
-EXPORT_SYMBOL(cfs_enter_debugger);
-
-
sigset_t
cfs_block_allsigs(void)
{
@@ -200,18 +145,3 @@ cfs_clear_sigpending(void)
spin_unlock_irqrestore(&current->sighand->siglock, flags);
}
EXPORT_SYMBOL(cfs_clear_sigpending);
-
-int
-libcfs_arch_init(void)
-{
- return 0;
-}
-EXPORT_SYMBOL(libcfs_arch_init);
-
-void
-libcfs_arch_cleanup(void)
-{
- return;
-}
-EXPORT_SYMBOL(libcfs_arch_cleanup);
-
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
index c8e293002..64a136cd5 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
@@ -49,7 +49,7 @@ static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = {
char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
-struct rw_semaphore cfs_tracefile_sem;
+static DECLARE_RWSEM(cfs_tracefile_sem);
int cfs_tracefile_init_arch(void)
{
@@ -57,8 +57,6 @@ int cfs_tracefile_init_arch(void)
int j;
struct cfs_trace_cpu_data *tcd;
- init_rwsem(&cfs_tracefile_sem);
-
/* initialize trace_data */
memset(cfs_trace_data, 0, sizeof(cfs_trace_data));
for (i = 0; i < CFS_TCD_TYPE_MAX; i++) {
@@ -102,11 +100,10 @@ void cfs_tracefile_fini_arch(void)
int j;
for (i = 0; i < num_possible_cpus(); i++)
- for (j = 0; j < 3; j++)
- if (cfs_trace_console_buffers[i][j] != NULL) {
- kfree(cfs_trace_console_buffers[i][j]);
- cfs_trace_console_buffers[i][j] = NULL;
- }
+ for (j = 0; j < 3; j++) {
+ kfree(cfs_trace_console_buffers[i][j]);
+ cfs_trace_console_buffers[i][j] = NULL;
+ }
for (i = 0; cfs_trace_data[i] != NULL; i++) {
kfree(cfs_trace_data[i]);
@@ -194,16 +191,18 @@ cfs_set_ptldebug_header(struct ptldebug_header *header,
struct libcfs_debug_msg_data *msgdata,
unsigned long stack)
{
- struct timeval tv;
+ struct timespec64 ts;
- do_gettimeofday(&tv);
+ ktime_get_real_ts64(&ts);
header->ph_subsys = msgdata->msg_subsys;
header->ph_mask = msgdata->msg_mask;
header->ph_cpu_id = smp_processor_id();
header->ph_type = cfs_trace_buf_idx_get();
- header->ph_sec = (__u32)tv.tv_sec;
- header->ph_usec = tv.tv_usec;
+ /* y2038 safe since all user space treats this as unsigned, but
+ * will overflow in 2106 */
+ header->ph_sec = (u32)ts.tv_sec;
+ header->ph_usec = ts.tv_nsec / NSEC_PER_USEC;
header->ph_stack = stack;
header->ph_pid = current->pid;
header->ph_line_num = msgdata->msg_line;
@@ -215,12 +214,11 @@ static char *
dbghdr_to_err_string(struct ptldebug_header *hdr)
{
switch (hdr->ph_subsys) {
-
- case S_LND:
- case S_LNET:
- return "LNetError";
- default:
- return "LustreError";
+ case S_LND:
+ case S_LNET:
+ return "LNetError";
+ default:
+ return "LustreError";
}
}
@@ -228,12 +226,11 @@ static char *
dbghdr_to_info_string(struct ptldebug_header *hdr)
{
switch (hdr->ph_subsys) {
-
- case S_LND:
- case S_LNET:
- return "LNet";
- default:
- return "Lustre";
+ case S_LND:
+ case S_LNET:
+ return "LNet";
+ default:
+ return "Lustre";
}
}
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/module.c b/kernel/drivers/staging/lustre/lustre/libcfs/module.c
index f0ee76abf..e7c2b2615 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/module.c
@@ -49,8 +49,8 @@
#include <linux/file.h>
#include <linux/list.h>
-#include <linux/proc_fs.h>
#include <linux/sysctl.h>
+#include <linux/debugfs.h>
# define DEBUG_SUBSYSTEM S_LNET
@@ -66,50 +66,9 @@ MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
MODULE_DESCRIPTION("Portals v3.1");
MODULE_LICENSE("GPL");
-extern struct miscdevice libcfs_dev;
-extern struct rw_semaphore cfs_tracefile_sem;
-extern struct mutex cfs_trace_thread_mutex;
-extern struct cfs_wi_sched *cfs_sched_rehash;
-extern void libcfs_init_nidstrings(void);
+static struct dentry *lnet_debugfs_root;
-static int insert_proc(void);
-static void remove_proc(void);
-
-static struct ctl_table_header *lnet_table_header;
-extern char lnet_upcall[1024];
-/**
- * The path of debug log dump upcall script.
- */
-extern char lnet_debug_log_upcall[1024];
-
-#define CTL_LNET (0x100)
-
-enum {
- PSDEV_DEBUG = 1, /* control debugging */
- PSDEV_SUBSYSTEM_DEBUG, /* control debugging */
- PSDEV_PRINTK, /* force all messages to console */
- PSDEV_CONSOLE_RATELIMIT, /* ratelimit console messages */
- PSDEV_CONSOLE_MAX_DELAY_CS, /* maximum delay over which we skip messages */
- PSDEV_CONSOLE_MIN_DELAY_CS, /* initial delay over which we skip messages */
- PSDEV_CONSOLE_BACKOFF, /* delay increase factor */
- PSDEV_DEBUG_PATH, /* crashdump log location */
- PSDEV_DEBUG_DUMP_PATH, /* crashdump tracelog location */
- PSDEV_CPT_TABLE, /* information about cpu partitions */
- PSDEV_LNET_UPCALL, /* User mode upcall script */
- PSDEV_LNET_MEMUSED, /* bytes currently PORTAL_ALLOCated */
- PSDEV_LNET_CATASTROPHE, /* if we have LBUGged or panic'd */
- PSDEV_LNET_PANIC_ON_LBUG, /* flag to panic on LBUG */
- PSDEV_LNET_DUMP_KERNEL, /* snapshot kernel debug buffer to file */
- PSDEV_LNET_DAEMON_FILE, /* spool kernel debug buffer to file */
- PSDEV_LNET_DEBUG_MB, /* size of debug buffer */
- PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */
- PSDEV_LNET_WATCHDOG_RATELIMIT, /* ratelimit watchdog messages */
- PSDEV_LNET_FORCE_LBUG, /* hook to force an LBUG */
- PSDEV_LNET_FAIL_LOC, /* control test failures instrumentation */
- PSDEV_LNET_FAIL_VAL, /* userdata for fail loc */
-};
-
-static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
{
struct page **level0p = &ldu->ldu_memhog_root_page;
struct page **level1p;
@@ -149,7 +108,7 @@ static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
*level0p = NULL;
}
- LASSERT (ldu->ldu_memhog_pages == 0);
+ LASSERT(ldu->ldu_memhog_pages == 0);
}
static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
@@ -161,8 +120,8 @@ static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
int count1;
int count2;
- LASSERT (ldu->ldu_memhog_pages == 0);
- LASSERT (ldu->ldu_memhog_root_page == NULL);
+ LASSERT(ldu->ldu_memhog_pages == 0);
+ LASSERT(ldu->ldu_memhog_root_page == NULL);
if (npages < 0)
return -EINVAL;
@@ -249,8 +208,8 @@ static int libcfs_psdev_release(unsigned long flags, void *args)
return 0;
}
-static struct rw_semaphore ioctl_list_sem;
-static struct list_head ioctl_list;
+static DECLARE_RWSEM(ioctl_list_sem);
+static LIST_HEAD(ioctl_list);
int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand)
{
@@ -315,25 +274,9 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd,
}
break;
- case IOC_LIBCFS_PING_TEST: {
- extern void (kping_client)(struct libcfs_ioctl_data *);
- void (*ping)(struct libcfs_ioctl_data *);
-
- CDEBUG(D_IOCTL, "doing %d pings to nid %s (%s)\n",
- data->ioc_count, libcfs_nid2str(data->ioc_nid),
- libcfs_nid2str(data->ioc_nid));
- ping = symbol_get(kping_client);
- if (!ping)
- CERROR("symbol_get failed\n");
- else {
- ping(data);
- symbol_put(kping_client);
- }
- return 0;
- }
-
default: {
struct libcfs_ioctl_handler *hand;
+
err = -EINVAL;
down_read(&ioctl_list_sem);
list_for_each_entry(hand, &ioctl_list, item) {
@@ -341,7 +284,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd,
if (err != -EINVAL) {
if (err == 0)
err = libcfs_ioctl_popdata(arg,
- data, sizeof (*data));
+ data, sizeof(*data));
break;
}
}
@@ -359,12 +302,12 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a
struct libcfs_ioctl_data *data;
int err = 0;
- LIBCFS_ALLOC_GFP(buf, 1024, GFP_IOFS);
+ LIBCFS_ALLOC_GFP(buf, 1024, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
/* 'cmd' and permissions get checked in our arch-specific caller */
- if (libcfs_ioctl_getdata(buf, buf + 800, (void *)arg)) {
+ if (libcfs_ioctl_getdata(buf, buf + 800, arg)) {
CERROR("PORTALS ioctl: data error\n");
err = -EINVAL;
goto out;
@@ -378,7 +321,6 @@ out:
return err;
}
-
struct cfs_psdev_ops libcfs_psdev_ops = {
libcfs_psdev_open,
libcfs_psdev_release,
@@ -387,111 +329,6 @@ struct cfs_psdev_ops libcfs_psdev_ops = {
libcfs_ioctl
};
-static int init_libcfs_module(void)
-{
- int rc;
-
- libcfs_arch_init();
- libcfs_init_nidstrings();
- init_rwsem(&cfs_tracefile_sem);
- mutex_init(&cfs_trace_thread_mutex);
- init_rwsem(&ioctl_list_sem);
- INIT_LIST_HEAD(&ioctl_list);
- init_waitqueue_head(&cfs_race_waitq);
-
- rc = libcfs_debug_init(5 * 1024 * 1024);
- if (rc < 0) {
- pr_err("LustreError: libcfs_debug_init: %d\n", rc);
- return rc;
- }
-
- rc = cfs_cpu_init();
- if (rc != 0)
- goto cleanup_debug;
-
- rc = misc_register(&libcfs_dev);
- if (rc) {
- CERROR("misc_register: error %d\n", rc);
- goto cleanup_cpu;
- }
-
- rc = cfs_wi_startup();
- if (rc) {
- CERROR("initialize workitem: error %d\n", rc);
- goto cleanup_deregister;
- }
-
- /* max to 4 threads, should be enough for rehash */
- rc = min(cfs_cpt_weight(cfs_cpt_table, CFS_CPT_ANY), 4);
- rc = cfs_wi_sched_create("cfs_rh", cfs_cpt_table, CFS_CPT_ANY,
- rc, &cfs_sched_rehash);
- if (rc != 0) {
- CERROR("Startup workitem scheduler: error: %d\n", rc);
- goto cleanup_deregister;
- }
-
- rc = cfs_crypto_register();
- if (rc) {
- CERROR("cfs_crypto_register: error %d\n", rc);
- goto cleanup_wi;
- }
-
-
- rc = insert_proc();
- if (rc) {
- CERROR("insert_proc: error %d\n", rc);
- goto cleanup_crypto;
- }
-
- CDEBUG (D_OTHER, "portals setup OK\n");
- return 0;
- cleanup_crypto:
- cfs_crypto_unregister();
- cleanup_wi:
- cfs_wi_shutdown();
- cleanup_deregister:
- misc_deregister(&libcfs_dev);
-cleanup_cpu:
- cfs_cpu_fini();
- cleanup_debug:
- libcfs_debug_cleanup();
- return rc;
-}
-
-static void exit_libcfs_module(void)
-{
- int rc;
-
- remove_proc();
-
- CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
- if (cfs_sched_rehash != NULL) {
- cfs_wi_sched_destroy(cfs_sched_rehash);
- cfs_sched_rehash = NULL;
- }
-
- cfs_crypto_unregister();
- cfs_wi_shutdown();
-
- rc = misc_deregister(&libcfs_dev);
- if (rc)
- CERROR("misc_deregister error %d\n", rc);
-
- cfs_cpu_fini();
-
- if (atomic_read(&libcfs_kmemory) != 0)
- CERROR("Portals memory leaked: %d bytes\n",
- atomic_read(&libcfs_kmemory));
-
- rc = libcfs_debug_cleanup();
- if (rc)
- pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
-
- libcfs_arch_cleanup();
-}
-
static int proc_call_handler(void *data, int write, loff_t *ppos,
void __user *buffer, size_t *lenp,
int (*handler)(void *data, int write,
@@ -559,9 +396,6 @@ static int proc_dobitmasks(struct ctl_table *table, int write,
__proc_dobitmasks);
}
-static int min_watchdog_ratelimit; /* disable ratelimiting */
-static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */
-
static int __proc_dump_kernel(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
@@ -601,125 +435,6 @@ static int proc_daemon_file(struct ctl_table *table, int write,
__proc_daemon_file);
}
-static int __proc_debug_mb(void *data, int write,
- loff_t pos, void __user *buffer, int nob)
-{
- if (!write) {
- char tmpstr[32];
- int len = snprintf(tmpstr, sizeof(tmpstr), "%d",
- cfs_trace_get_debug_mb());
-
- if (pos >= len)
- return 0;
-
- return cfs_trace_copyout_string(buffer, nob, tmpstr + pos,
- "\n");
- }
-
- return cfs_trace_set_debug_mb_usrstr(buffer, nob);
-}
-
-static int proc_debug_mb(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- return proc_call_handler(table->data, write, ppos, buffer, lenp,
- __proc_debug_mb);
-}
-
-static int proc_console_max_delay_cs(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp,
- loff_t *ppos)
-{
- int rc, max_delay_cs;
- struct ctl_table dummy = *table;
- long d;
-
- dummy.data = &max_delay_cs;
- dummy.proc_handler = &proc_dointvec;
-
- if (!write) { /* read */
- max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100);
- rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
- return rc;
- }
-
- /* write */
- max_delay_cs = 0;
- rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
- if (rc < 0)
- return rc;
- if (max_delay_cs <= 0)
- return -EINVAL;
-
- d = cfs_time_seconds(max_delay_cs) / 100;
- if (d == 0 || d < libcfs_console_min_delay)
- return -EINVAL;
- libcfs_console_max_delay = d;
-
- return rc;
-}
-
-static int proc_console_min_delay_cs(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp,
- loff_t *ppos)
-{
- int rc, min_delay_cs;
- struct ctl_table dummy = *table;
- long d;
-
- dummy.data = &min_delay_cs;
- dummy.proc_handler = &proc_dointvec;
-
- if (!write) { /* read */
- min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100);
- rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
- return rc;
- }
-
- /* write */
- min_delay_cs = 0;
- rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
- if (rc < 0)
- return rc;
- if (min_delay_cs <= 0)
- return -EINVAL;
-
- d = cfs_time_seconds(min_delay_cs) / 100;
- if (d == 0 || d > libcfs_console_max_delay)
- return -EINVAL;
- libcfs_console_min_delay = d;
-
- return rc;
-}
-
-static int proc_console_backoff(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- int rc, backoff;
- struct ctl_table dummy = *table;
-
- dummy.data = &backoff;
- dummy.proc_handler = &proc_dointvec;
-
- if (!write) { /* read */
- backoff = libcfs_console_backoff;
- rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
- return rc;
- }
-
- /* write */
- backoff = 0;
- rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
- if (rc < 0)
- return rc;
- if (backoff <= 0)
- return -EINVAL;
-
- libcfs_console_backoff = backoff;
-
- return rc;
-}
-
static int libcfs_force_lbug(struct ctl_table *table, int write,
void __user *buffer,
size_t *lenp, loff_t *ppos)
@@ -817,40 +532,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_dobitmasks,
},
{
- .procname = "console_ratelimit",
- .data = &libcfs_console_ratelimit,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
- .procname = "console_max_delay_centisecs",
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_console_max_delay_cs
- },
- {
- .procname = "console_min_delay_centisecs",
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_console_min_delay_cs
- },
- {
- .procname = "console_backoff",
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_console_backoff
- },
-
- {
- .procname = "debug_path",
- .data = libcfs_debug_file_path_arr,
- .maxlen = sizeof(libcfs_debug_file_path_arr),
- .mode = 0644,
- .proc_handler = &proc_dostring,
- },
-
- {
.procname = "cpu_partition_table",
.maxlen = 128,
.mode = 0444,
@@ -872,13 +553,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_dostring,
},
{
- .procname = "lnet_memused",
- .data = (int *)&libcfs_kmemory.counter,
- .maxlen = sizeof(int),
- .mode = 0444,
- .proc_handler = &proc_dointvec,
- },
- {
.procname = "catastrophe",
.data = &libcfs_catastrophe,
.maxlen = sizeof(int),
@@ -886,13 +560,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_dointvec,
},
{
- .procname = "panic_on_lbug",
- .data = &libcfs_panic_on_lbug,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
.procname = "dump_kernel",
.maxlen = 256,
.mode = 0200,
@@ -905,20 +572,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_daemon_file,
},
{
- .procname = "debug_mb",
- .mode = 0644,
- .proc_handler = &proc_debug_mb,
- },
- {
- .procname = "watchdog_ratelimit",
- .data = &libcfs_watchdog_ratelimit,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec_minmax,
- .extra1 = &min_watchdog_ratelimit,
- .extra2 = &max_watchdog_ratelimit,
- },
- {
.procname = "force_lbug",
.data = NULL,
.maxlen = 0,
@@ -943,31 +596,167 @@ static struct ctl_table lnet_table[] = {
}
};
-static struct ctl_table top_table[] = {
- {
- .procname = "lnet",
- .mode = 0555,
- .data = NULL,
- .maxlen = 0,
- .child = lnet_table,
- },
- {
- }
+static const struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
+ { "console_ratelimit",
+ "/sys/module/libcfs/parameters/libcfs_console_ratelimit"},
+ { "debug_path",
+ "/sys/module/libcfs/parameters/libcfs_debug_file_path"},
+ { "panic_on_lbug",
+ "/sys/module/libcfs/parameters/libcfs_panic_on_lbug"},
+ { "libcfs_console_backoff",
+ "/sys/module/libcfs/parameters/libcfs_console_backoff"},
+ { "debug_mb",
+ "/sys/module/libcfs/parameters/libcfs_debug_mb"},
+ { "console_min_delay_centisecs",
+ "/sys/module/libcfs/parameters/libcfs_console_min_delay"},
+ { "console_max_delay_centisecs",
+ "/sys/module/libcfs/parameters/libcfs_console_max_delay"},
+ {},
+};
+
+static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ctl_table *table = filp->private_data;
+ int error;
+
+ error = table->proc_handler(table, 0, (void __user *)buf, &count, ppos);
+ if (!error)
+ error = count;
+
+ return error;
+}
+
+static ssize_t lnet_debugfs_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ctl_table *table = filp->private_data;
+ int error;
+
+ error = table->proc_handler(table, 1, (void __user *)buf, &count, ppos);
+ if (!error)
+ error = count;
+
+ return error;
+}
+
+static const struct file_operations lnet_debugfs_file_operations = {
+ .open = simple_open,
+ .read = lnet_debugfs_read,
+ .write = lnet_debugfs_write,
+ .llseek = default_llseek,
};
-static int insert_proc(void)
+void lustre_insert_debugfs(struct ctl_table *table,
+ const struct lnet_debugfs_symlink_def *symlinks)
+{
+ struct dentry *entry;
+
+ if (lnet_debugfs_root == NULL)
+ lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
+
+ /* Even if we cannot create, just ignore it altogether) */
+ if (IS_ERR_OR_NULL(lnet_debugfs_root))
+ return;
+
+ for (; table->procname; table++)
+ entry = debugfs_create_file(table->procname, table->mode,
+ lnet_debugfs_root, table,
+ &lnet_debugfs_file_operations);
+
+ for (; symlinks && symlinks->name; symlinks++)
+ entry = debugfs_create_symlink(symlinks->name,
+ lnet_debugfs_root,
+ symlinks->target);
+
+}
+EXPORT_SYMBOL_GPL(lustre_insert_debugfs);
+
+static void lustre_remove_debugfs(void)
{
- if (lnet_table_header == NULL)
- lnet_table_header = register_sysctl_table(top_table);
+ if (lnet_debugfs_root != NULL)
+ debugfs_remove_recursive(lnet_debugfs_root);
+
+ lnet_debugfs_root = NULL;
+}
+
+static int init_libcfs_module(void)
+{
+ int rc;
+
+ rc = libcfs_debug_init(5 * 1024 * 1024);
+ if (rc < 0) {
+ pr_err("LustreError: libcfs_debug_init: %d\n", rc);
+ return rc;
+ }
+
+ rc = cfs_cpu_init();
+ if (rc != 0)
+ goto cleanup_debug;
+
+ rc = misc_register(&libcfs_dev);
+ if (rc) {
+ CERROR("misc_register: error %d\n", rc);
+ goto cleanup_cpu;
+ }
+
+ rc = cfs_wi_startup();
+ if (rc) {
+ CERROR("initialize workitem: error %d\n", rc);
+ goto cleanup_deregister;
+ }
+
+ /* max to 4 threads, should be enough for rehash */
+ rc = min(cfs_cpt_weight(cfs_cpt_table, CFS_CPT_ANY), 4);
+ rc = cfs_wi_sched_create("cfs_rh", cfs_cpt_table, CFS_CPT_ANY,
+ rc, &cfs_sched_rehash);
+ if (rc != 0) {
+ CERROR("Startup workitem scheduler: error: %d\n", rc);
+ goto cleanup_deregister;
+ }
+
+ rc = cfs_crypto_register();
+ if (rc) {
+ CERROR("cfs_crypto_register: error %d\n", rc);
+ goto cleanup_wi;
+ }
+
+ lustre_insert_debugfs(lnet_table, lnet_debugfs_symlinks);
+
+ CDEBUG(D_OTHER, "portals setup OK\n");
return 0;
+ cleanup_wi:
+ cfs_wi_shutdown();
+ cleanup_deregister:
+ misc_deregister(&libcfs_dev);
+cleanup_cpu:
+ cfs_cpu_fini();
+ cleanup_debug:
+ libcfs_debug_cleanup();
+ return rc;
}
-static void remove_proc(void)
+static void exit_libcfs_module(void)
{
- if (lnet_table_header != NULL)
- unregister_sysctl_table(lnet_table_header);
+ int rc;
+
+ lustre_remove_debugfs();
+
+ if (cfs_sched_rehash) {
+ cfs_wi_sched_destroy(cfs_sched_rehash);
+ cfs_sched_rehash = NULL;
+ }
+
+ cfs_crypto_unregister();
+ cfs_wi_shutdown();
- lnet_table_header = NULL;
+ misc_deregister(&libcfs_dev);
+
+ cfs_cpu_fini();
+
+ rc = libcfs_debug_cleanup();
+ if (rc)
+ pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
}
MODULE_VERSION("1.0.0");
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/kernel/drivers/staging/lustre/lustre/libcfs/nidstrings.c
deleted file mode 100644
index 087449f4e..000000000
--- a/kernel/drivers/staging/lustre/lustre/libcfs/nidstrings.c
+++ /dev/null
@@ -1,842 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/nidstrings.c
- *
- * Author: Phil Schwan <phil@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include "../../include/linux/libcfs/libcfs.h"
-#include "../../include/linux/lnet/lnet.h"
-
-/* CAVEAT VENDITOR! Keep the canonical string representation of nets/nids
- * consistent in all conversion functions. Some code fragments are copied
- * around for the sake of clarity...
- */
-
-/* CAVEAT EMPTOR! Racey temporary buffer allocation!
- * Choose the number of nidstrings to support the MAXIMUM expected number of
- * concurrent users. If there are more, the returned string will be volatile.
- * NB this number must allow for a process to be descheduled for a timeslice
- * between getting its string and using it.
- */
-
-static char libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE];
-static int libcfs_nidstring_idx;
-
-static spinlock_t libcfs_nidstring_lock;
-
-void libcfs_init_nidstrings(void)
-{
- spin_lock_init(&libcfs_nidstring_lock);
-}
-
-static char *
-libcfs_next_nidstring(void)
-{
- char *str;
- unsigned long flags;
-
- spin_lock_irqsave(&libcfs_nidstring_lock, flags);
-
- str = libcfs_nidstrings[libcfs_nidstring_idx++];
- if (libcfs_nidstring_idx == ARRAY_SIZE(libcfs_nidstrings))
- libcfs_nidstring_idx = 0;
-
- spin_unlock_irqrestore(&libcfs_nidstring_lock, flags);
- return str;
-}
-
-static int libcfs_lo_str2addr(const char *str, int nob, __u32 *addr)
-{
- *addr = 0;
- return 1;
-}
-
-static void libcfs_ip_addr2str(__u32 addr, char *str)
-{
- snprintf(str, LNET_NIDSTR_SIZE, "%u.%u.%u.%u",
- (addr >> 24) & 0xff, (addr >> 16) & 0xff,
- (addr >> 8) & 0xff, addr & 0xff);
-}
-
-static int libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
-{
- unsigned int a;
- unsigned int b;
- unsigned int c;
- unsigned int d;
- int n = nob; /* XscanfX */
-
- /* numeric IP? */
- if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
- n == nob &&
- (a & ~0xff) == 0 && (b & ~0xff) == 0 &&
- (c & ~0xff) == 0 && (d & ~0xff) == 0) {
- *addr = ((a<<24)|(b<<16)|(c<<8)|d);
- return 1;
- }
-
- return 0;
-}
-
-static void libcfs_decnum_addr2str(__u32 addr, char *str)
-{
- snprintf(str, LNET_NIDSTR_SIZE, "%u", addr);
-}
-
-static void libcfs_hexnum_addr2str(__u32 addr, char *str)
-{
- snprintf(str, LNET_NIDSTR_SIZE, "0x%x", addr);
-}
-
-static int libcfs_num_str2addr(const char *str, int nob, __u32 *addr)
-{
- int n;
-
- n = nob;
- if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob)
- return 1;
-
- n = nob;
- if (sscanf(str, "0X%x%n", addr, &n) >= 1 && n == nob)
- return 1;
-
- n = nob;
- if (sscanf(str, "%u%n", addr, &n) >= 1 && n == nob)
- return 1;
-
- return 0;
-}
-
-/**
- * Nf_parse_addrlist method for networks using numeric addresses.
- *
- * Examples of such networks are gm and elan.
- *
- * \retval 0 if \a str parsed to numeric address
- * \retval errno otherwise
- */
-static int
-libcfs_num_parse(char *str, int len, struct list_head *list)
-{
- struct cfs_expr_list *el;
- int rc;
-
- rc = cfs_expr_list_parse(str, len, 0, MAX_NUMERIC_VALUE, &el);
- if (rc == 0)
- list_add_tail(&el->el_link, list);
-
- return rc;
-}
-
-/*
- * Nf_match_addr method for networks using numeric addresses
- *
- * \retval 1 on match
- * \retval 0 otherwise
- */
-static int
-libcfs_num_match(__u32 addr, struct list_head *numaddr)
-{
- struct cfs_expr_list *el;
-
- LASSERT(!list_empty(numaddr));
- el = list_entry(numaddr->next, struct cfs_expr_list, el_link);
-
- return cfs_expr_list_match(addr, el);
-}
-
-struct netstrfns {
- int nf_type;
- char *nf_name;
- char *nf_modname;
- void (*nf_addr2str)(__u32 addr, char *str);
- int (*nf_str2addr)(const char *str, int nob, __u32 *addr);
- int (*nf_parse_addrlist)(char *str, int len,
- struct list_head *list);
- int (*nf_match_addr)(__u32 addr, struct list_head *list);
-};
-
-static struct netstrfns libcfs_netstrfns[] = {
- {/* .nf_type */ LOLND,
- /* .nf_name */ "lo",
- /* .nf_modname */ "klolnd",
- /* .nf_addr2str */ libcfs_decnum_addr2str,
- /* .nf_str2addr */ libcfs_lo_str2addr,
- /* .nf_parse_addr*/ libcfs_num_parse,
- /* .nf_match_addr*/ libcfs_num_match},
- {/* .nf_type */ SOCKLND,
- /* .nf_name */ "tcp",
- /* .nf_modname */ "ksocklnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ O2IBLND,
- /* .nf_name */ "o2ib",
- /* .nf_modname */ "ko2iblnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ CIBLND,
- /* .nf_name */ "cib",
- /* .nf_modname */ "kciblnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ OPENIBLND,
- /* .nf_name */ "openib",
- /* .nf_modname */ "kopeniblnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ IIBLND,
- /* .nf_name */ "iib",
- /* .nf_modname */ "kiiblnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ VIBLND,
- /* .nf_name */ "vib",
- /* .nf_modname */ "kviblnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ RALND,
- /* .nf_name */ "ra",
- /* .nf_modname */ "kralnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ QSWLND,
- /* .nf_name */ "elan",
- /* .nf_modname */ "kqswlnd",
- /* .nf_addr2str */ libcfs_decnum_addr2str,
- /* .nf_str2addr */ libcfs_num_str2addr,
- /* .nf_parse_addrlist*/ libcfs_num_parse,
- /* .nf_match_addr*/ libcfs_num_match},
- {/* .nf_type */ GMLND,
- /* .nf_name */ "gm",
- /* .nf_modname */ "kgmlnd",
- /* .nf_addr2str */ libcfs_hexnum_addr2str,
- /* .nf_str2addr */ libcfs_num_str2addr,
- /* .nf_parse_addrlist*/ libcfs_num_parse,
- /* .nf_match_addr*/ libcfs_num_match},
- {/* .nf_type */ MXLND,
- /* .nf_name */ "mx",
- /* .nf_modname */ "kmxlnd",
- /* .nf_addr2str */ libcfs_ip_addr2str,
- /* .nf_str2addr */ libcfs_ip_str2addr,
- /* .nf_parse_addrlist*/ cfs_ip_addr_parse,
- /* .nf_match_addr*/ cfs_ip_addr_match},
- {/* .nf_type */ PTLLND,
- /* .nf_name */ "ptl",
- /* .nf_modname */ "kptllnd",
- /* .nf_addr2str */ libcfs_decnum_addr2str,
- /* .nf_str2addr */ libcfs_num_str2addr,
- /* .nf_parse_addrlist*/ libcfs_num_parse,
- /* .nf_match_addr*/ libcfs_num_match},
- {/* .nf_type */ GNILND,
- /* .nf_name */ "gni",
- /* .nf_modname */ "kgnilnd",
- /* .nf_addr2str */ libcfs_decnum_addr2str,
- /* .nf_str2addr */ libcfs_num_str2addr,
- /* .nf_parse_addrlist*/ libcfs_num_parse,
- /* .nf_match_addr*/ libcfs_num_match},
- /* placeholder for net0 alias. It MUST BE THE LAST ENTRY */
- {/* .nf_type */ -1},
-};
-
-static const int libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns);
-
-/* CAVEAT EMPTOR XscanfX
- * I use "%n" at the end of a sscanf format to detect trailing junk. However
- * sscanf may return immediately if it sees the terminating '0' in a string, so
- * I initialise the %n variable to the expected length. If sscanf sets it;
- * fine, if it doesn't, then the scan ended at the end of the string, which is
- * fine too :) */
-
-static struct netstrfns *
-libcfs_lnd2netstrfns(int lnd)
-{
- int i;
-
- if (lnd >= 0)
- for (i = 0; i < libcfs_nnetstrfns; i++)
- if (lnd == libcfs_netstrfns[i].nf_type)
- return &libcfs_netstrfns[i];
-
- return NULL;
-}
-
-static struct netstrfns *
-libcfs_namenum2netstrfns(const char *name)
-{
- struct netstrfns *nf;
- int i;
-
- for (i = 0; i < libcfs_nnetstrfns; i++) {
- nf = &libcfs_netstrfns[i];
- if (nf->nf_type >= 0 &&
- !strncmp(name, nf->nf_name, strlen(nf->nf_name)))
- return nf;
- }
- return NULL;
-}
-
-static struct netstrfns *
-libcfs_name2netstrfns(const char *name)
-{
- int i;
-
- for (i = 0; i < libcfs_nnetstrfns; i++)
- if (libcfs_netstrfns[i].nf_type >= 0 &&
- !strcmp(libcfs_netstrfns[i].nf_name, name))
- return &libcfs_netstrfns[i];
-
- return NULL;
-}
-
-int
-libcfs_isknown_lnd(int type)
-{
- return libcfs_lnd2netstrfns(type) != NULL;
-}
-EXPORT_SYMBOL(libcfs_isknown_lnd);
-
-char *
-libcfs_lnd2modname(int lnd)
-{
- struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
-
- return (nf == NULL) ? NULL : nf->nf_modname;
-}
-EXPORT_SYMBOL(libcfs_lnd2modname);
-
-char *
-libcfs_lnd2str(int lnd)
-{
- char *str;
- struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
-
- if (nf != NULL)
- return nf->nf_name;
-
- str = libcfs_next_nidstring();
- snprintf(str, LNET_NIDSTR_SIZE, "?%d?", lnd);
- return str;
-}
-EXPORT_SYMBOL(libcfs_lnd2str);
-
-int
-libcfs_str2lnd(const char *str)
-{
- struct netstrfns *nf = libcfs_name2netstrfns(str);
-
- if (nf != NULL)
- return nf->nf_type;
-
- return -1;
-}
-EXPORT_SYMBOL(libcfs_str2lnd);
-
-char *
-libcfs_net2str(__u32 net)
-{
- int lnd = LNET_NETTYP(net);
- int num = LNET_NETNUM(net);
- struct netstrfns *nf = libcfs_lnd2netstrfns(lnd);
- char *str = libcfs_next_nidstring();
-
- if (nf == NULL)
- snprintf(str, LNET_NIDSTR_SIZE, "<%d:%d>", lnd, num);
- else if (num == 0)
- snprintf(str, LNET_NIDSTR_SIZE, "%s", nf->nf_name);
- else
- snprintf(str, LNET_NIDSTR_SIZE, "%s%d", nf->nf_name, num);
-
- return str;
-}
-EXPORT_SYMBOL(libcfs_net2str);
-
-char *
-libcfs_nid2str(lnet_nid_t nid)
-{
- __u32 addr = LNET_NIDADDR(nid);
- __u32 net = LNET_NIDNET(nid);
- int lnd = LNET_NETTYP(net);
- int nnum = LNET_NETNUM(net);
- struct netstrfns *nf;
- char *str;
- int nob;
-
- if (nid == LNET_NID_ANY)
- return "<?>";
-
- nf = libcfs_lnd2netstrfns(lnd);
- str = libcfs_next_nidstring();
-
- if (nf == NULL)
- snprintf(str, LNET_NIDSTR_SIZE, "%x@<%d:%d>", addr, lnd, nnum);
- else {
- nf->nf_addr2str(addr, str);
- nob = strlen(str);
- if (nnum == 0)
- snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s",
- nf->nf_name);
- else
- snprintf(str + nob, LNET_NIDSTR_SIZE - nob, "@%s%d",
- nf->nf_name, nnum);
- }
-
- return str;
-}
-EXPORT_SYMBOL(libcfs_nid2str);
-
-static struct netstrfns *
-libcfs_str2net_internal(const char *str, __u32 *net)
-{
- struct netstrfns *uninitialized_var(nf);
- int nob;
- unsigned int netnum;
- int i;
-
- for (i = 0; i < libcfs_nnetstrfns; i++) {
- nf = &libcfs_netstrfns[i];
- if (nf->nf_type >= 0 &&
- !strncmp(str, nf->nf_name, strlen(nf->nf_name)))
- break;
- }
-
- if (i == libcfs_nnetstrfns)
- return NULL;
-
- nob = strlen(nf->nf_name);
-
- if (strlen(str) == (unsigned int)nob) {
- netnum = 0;
- } else {
- if (nf->nf_type == LOLND) /* net number not allowed */
- return NULL;
-
- str += nob;
- i = strlen(str);
- if (sscanf(str, "%u%n", &netnum, &i) < 1 ||
- i != (int)strlen(str))
- return NULL;
- }
-
- *net = LNET_MKNET(nf->nf_type, netnum);
- return nf;
-}
-
-__u32
-libcfs_str2net(const char *str)
-{
- __u32 net;
-
- if (libcfs_str2net_internal(str, &net) != NULL)
- return net;
-
- return LNET_NIDNET(LNET_NID_ANY);
-}
-EXPORT_SYMBOL(libcfs_str2net);
-
-lnet_nid_t
-libcfs_str2nid(const char *str)
-{
- const char *sep = strchr(str, '@');
- struct netstrfns *nf;
- __u32 net;
- __u32 addr;
-
- if (sep != NULL) {
- nf = libcfs_str2net_internal(sep + 1, &net);
- if (nf == NULL)
- return LNET_NID_ANY;
- } else {
- sep = str + strlen(str);
- net = LNET_MKNET(SOCKLND, 0);
- nf = libcfs_lnd2netstrfns(SOCKLND);
- LASSERT(nf != NULL);
- }
-
- if (!nf->nf_str2addr(str, (int)(sep - str), &addr))
- return LNET_NID_ANY;
-
- return LNET_MKNID(net, addr);
-}
-EXPORT_SYMBOL(libcfs_str2nid);
-
-char *
-libcfs_id2str(lnet_process_id_t id)
-{
- char *str = libcfs_next_nidstring();
-
- if (id.pid == LNET_PID_ANY) {
- snprintf(str, LNET_NIDSTR_SIZE,
- "LNET_PID_ANY-%s", libcfs_nid2str(id.nid));
- return str;
- }
-
- snprintf(str, LNET_NIDSTR_SIZE, "%s%u-%s",
- ((id.pid & LNET_PID_USERFLAG) != 0) ? "U" : "",
- (id.pid & ~LNET_PID_USERFLAG), libcfs_nid2str(id.nid));
- return str;
-}
-EXPORT_SYMBOL(libcfs_id2str);
-
-int
-libcfs_str2anynid(lnet_nid_t *nidp, const char *str)
-{
- if (!strcmp(str, "*")) {
- *nidp = LNET_NID_ANY;
- return 1;
- }
-
- *nidp = libcfs_str2nid(str);
- return *nidp != LNET_NID_ANY;
-}
-EXPORT_SYMBOL(libcfs_str2anynid);
-
-/**
- * Nid range list syntax.
- * \verbatim
- *
- * <nidlist> :== <nidrange> [ ' ' <nidrange> ]
- * <nidrange> :== <addrrange> '@' <net>
- * <addrrange> :== '*' |
- * <ipaddr_range> |
- * <cfs_expr_list>
- * <ipaddr_range> :== <cfs_expr_list>.<cfs_expr_list>.<cfs_expr_list>.
- * <cfs_expr_list>
- * <cfs_expr_list> :== <number> |
- * <expr_list>
- * <expr_list> :== '[' <range_expr> [ ',' <range_expr>] ']'
- * <range_expr> :== <number> |
- * <number> '-' <number> |
- * <number> '-' <number> '/' <number>
- * <net> :== <netname> | <netname><number>
- * <netname> :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" |
- * "vib" | "ra" | "elan" | "mx" | "ptl"
- * \endverbatim
- */
-
-/**
- * Structure to represent \<nidrange\> token of the syntax.
- *
- * One of this is created for each \<net\> parsed.
- */
-struct nidrange {
- /**
- * Link to list of this structures which is built on nid range
- * list parsing.
- */
- struct list_head nr_link;
- /**
- * List head for addrrange::ar_link.
- */
- struct list_head nr_addrranges;
- /**
- * Flag indicating that *@<net> is found.
- */
- int nr_all;
- /**
- * Pointer to corresponding element of libcfs_netstrfns.
- */
- struct netstrfns *nr_netstrfns;
- /**
- * Number of network. E.g. 5 if \<net\> is "elan5".
- */
- int nr_netnum;
-};
-
-/**
- * Structure to represent \<addrrange\> token of the syntax.
- */
-struct addrrange {
- /**
- * Link to nidrange::nr_addrranges.
- */
- struct list_head ar_link;
- /**
- * List head for cfs_expr_list::el_list.
- */
- struct list_head ar_numaddr_ranges;
-};
-
-/**
- * Parses \<addrrange\> token on the syntax.
- *
- * Allocates struct addrrange and links to \a nidrange via
- * (nidrange::nr_addrranges)
- *
- * \retval 1 if \a src parses to '*' | \<ipaddr_range\> | \<cfs_expr_list\>
- * \retval 0 otherwise
- */
-static int
-parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange)
-{
- struct addrrange *addrrange;
-
- if (src->ls_len == 1 && src->ls_str[0] == '*') {
- nidrange->nr_all = 1;
- return 1;
- }
-
- LIBCFS_ALLOC(addrrange, sizeof(struct addrrange));
- if (addrrange == NULL)
- return 0;
- list_add_tail(&addrrange->ar_link, &nidrange->nr_addrranges);
- INIT_LIST_HEAD(&addrrange->ar_numaddr_ranges);
-
- return nidrange->nr_netstrfns->nf_parse_addrlist(src->ls_str,
- src->ls_len,
- &addrrange->ar_numaddr_ranges);
-}
-
-/**
- * Finds or creates struct nidrange.
- *
- * Checks if \a src is a valid network name, looks for corresponding
- * nidrange on the ist of nidranges (\a nidlist), creates new struct
- * nidrange if it is not found.
- *
- * \retval pointer to struct nidrange matching network specified via \a src
- * \retval NULL if \a src does not match any network
- */
-static struct nidrange *
-add_nidrange(const struct cfs_lstr *src,
- struct list_head *nidlist)
-{
- struct netstrfns *nf;
- struct nidrange *nr;
- int endlen;
- unsigned netnum;
-
- if (src->ls_len >= LNET_NIDSTR_SIZE)
- return NULL;
-
- nf = libcfs_namenum2netstrfns(src->ls_str);
- if (nf == NULL)
- return NULL;
- endlen = src->ls_len - strlen(nf->nf_name);
- if (endlen == 0)
- /* network name only, e.g. "elan" or "tcp" */
- netnum = 0;
- else {
- /* e.g. "elan25" or "tcp23", refuse to parse if
- * network name is not appended with decimal or
- * hexadecimal number */
- if (!cfs_str2num_check(src->ls_str + strlen(nf->nf_name),
- endlen, &netnum, 0, MAX_NUMERIC_VALUE))
- return NULL;
- }
-
- list_for_each_entry(nr, nidlist, nr_link) {
- if (nr->nr_netstrfns != nf)
- continue;
- if (nr->nr_netnum != netnum)
- continue;
- return nr;
- }
-
- LIBCFS_ALLOC(nr, sizeof(struct nidrange));
- if (nr == NULL)
- return NULL;
- list_add_tail(&nr->nr_link, nidlist);
- INIT_LIST_HEAD(&nr->nr_addrranges);
- nr->nr_netstrfns = nf;
- nr->nr_all = 0;
- nr->nr_netnum = netnum;
-
- return nr;
-}
-
-/**
- * Parses \<nidrange\> token of the syntax.
- *
- * \retval 1 if \a src parses to \<addrrange\> '@' \<net\>
- * \retval 0 otherwise
- */
-static int
-parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist)
-{
- struct cfs_lstr addrrange;
- struct cfs_lstr net;
- struct cfs_lstr tmp;
- struct nidrange *nr;
-
- tmp = *src;
- if (cfs_gettok(src, '@', &addrrange) == 0)
- goto failed;
-
- if (cfs_gettok(src, '@', &net) == 0 || src->ls_str != NULL)
- goto failed;
-
- nr = add_nidrange(&net, nidlist);
- if (nr == NULL)
- goto failed;
-
- if (parse_addrange(&addrrange, nr) != 0)
- goto failed;
-
- return 1;
- failed:
- CWARN("can't parse nidrange: \"%.*s\"\n", tmp.ls_len, tmp.ls_str);
- return 0;
-}
-
-/**
- * Frees addrrange structures of \a list.
- *
- * For each struct addrrange structure found on \a list it frees
- * cfs_expr_list list attached to it and frees the addrrange itself.
- *
- * \retval none
- */
-static void
-free_addrranges(struct list_head *list)
-{
- while (!list_empty(list)) {
- struct addrrange *ar;
-
- ar = list_entry(list->next, struct addrrange, ar_link);
-
- cfs_expr_list_free_list(&ar->ar_numaddr_ranges);
- list_del(&ar->ar_link);
- LIBCFS_FREE(ar, sizeof(struct addrrange));
- }
-}
-
-/**
- * Frees nidrange strutures of \a list.
- *
- * For each struct nidrange structure found on \a list it frees
- * addrrange list attached to it and frees the nidrange itself.
- *
- * \retval none
- */
-void
-cfs_free_nidlist(struct list_head *list)
-{
- struct list_head *pos, *next;
- struct nidrange *nr;
-
- list_for_each_safe(pos, next, list) {
- nr = list_entry(pos, struct nidrange, nr_link);
- free_addrranges(&nr->nr_addrranges);
- list_del(pos);
- LIBCFS_FREE(nr, sizeof(struct nidrange));
- }
-}
-EXPORT_SYMBOL(cfs_free_nidlist);
-
-/**
- * Parses nid range list.
- *
- * Parses with rigorous syntax and overflow checking \a str into
- * \<nidrange\> [ ' ' \<nidrange\> ], compiles \a str into set of
- * structures and links that structure to \a nidlist. The resulting
- * list can be used to match a NID againts set of NIDS defined by \a
- * str.
- * \see cfs_match_nid
- *
- * \retval 1 on success
- * \retval 0 otherwise
- */
-int
-cfs_parse_nidlist(char *str, int len, struct list_head *nidlist)
-{
- struct cfs_lstr src;
- struct cfs_lstr res;
- int rc;
-
- src.ls_str = str;
- src.ls_len = len;
- INIT_LIST_HEAD(nidlist);
- while (src.ls_str) {
- rc = cfs_gettok(&src, ' ', &res);
- if (rc == 0) {
- cfs_free_nidlist(nidlist);
- return 0;
- }
- rc = parse_nidrange(&res, nidlist);
- if (rc == 0) {
- cfs_free_nidlist(nidlist);
- return 0;
- }
- }
- return 1;
-}
-EXPORT_SYMBOL(cfs_parse_nidlist);
-
-/**
- * Matches a nid (\a nid) against the compiled list of nidranges (\a nidlist).
- *
- * \see cfs_parse_nidlist()
- *
- * \retval 1 on match
- * \retval 0 otherwises
- */
-int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist)
-{
- struct nidrange *nr;
- struct addrrange *ar;
-
- list_for_each_entry(nr, nidlist, nr_link) {
- if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid)))
- continue;
- if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid)))
- continue;
- if (nr->nr_all)
- return 1;
- list_for_each_entry(ar, &nr->nr_addrranges, ar_link)
- if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid),
- &ar->ar_numaddr_ranges))
- return 1;
- }
- return 0;
-}
-EXPORT_SYMBOL(cfs_match_nid);
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.c b/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.c
index c86394f7f..f2d018d78 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.c
@@ -39,7 +39,6 @@
* Author: Phil Schwan <phil@clusterfs.com>
*/
-
#define DEBUG_SUBSYSTEM S_LNET
#define LUSTRE_TRACEFILE_PRIVATE
#include "tracefile.h"
@@ -52,7 +51,7 @@ union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline
char cfs_tracefile[TRACEFILE_NAME_SIZE];
long long cfs_tracefile_size = CFS_TRACEFILE_SIZE;
static struct tracefiled_ctl trace_tctl;
-struct mutex cfs_trace_thread_mutex;
+static DEFINE_MUTEX(cfs_trace_thread_mutex);
static int thread_running;
static atomic_t cfs_tage_allocated = ATOMIC_INIT(0);
@@ -124,7 +123,7 @@ int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp,
* from here: this will lead to infinite recursion.
*/
- for (i = 0; i + tcd->tcd_cur_stock_pages < TCD_STOCK_PAGES ; ++ i) {
+ for (i = 0; i + tcd->tcd_cur_stock_pages < TCD_STOCK_PAGES ; ++i) {
struct cfs_trace_page *tage;
tage = cfs_tage_alloc(gfp);
@@ -370,7 +369,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
/* indent message according to the nesting level */
while (depth-- > 0) {
*(debug_buf++) = '.';
- ++ tage->used;
+ ++tage->used;
}
strcpy(debug_buf, file);
@@ -652,6 +651,7 @@ void cfs_trace_debug_print(void)
while (p < ((char *)page_address(page) + tage->used)) {
struct ptldebug_header *hdr;
int len;
+
hdr = (void *)p;
p += sizeof(*hdr);
file = p;
@@ -810,7 +810,7 @@ int cfs_trace_allocate_string_buffer(char **str, int nob)
if (nob > 2 * PAGE_CACHE_SIZE) /* string must be "sensible" */
return -EINVAL;
- *str = kmalloc(nob, GFP_IOFS | __GFP_ZERO);
+ *str = kmalloc(nob, GFP_KERNEL | __GFP_ZERO);
if (*str == NULL)
return -ENOMEM;
@@ -937,18 +937,6 @@ int cfs_trace_set_debug_mb(int mb)
return 0;
}
-int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob)
-{
- char str[32];
- int rc;
-
- rc = cfs_trace_copyin_string(str, sizeof(str), usr_str, usr_str_nob);
- if (rc < 0)
- return rc;
-
- return cfs_trace_set_debug_mb(simple_strtoul(str, NULL, 0));
-}
-
int cfs_trace_get_debug_mb(void)
{
int i;
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.h b/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.h
index 0601476e1..cb7a39635 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.h
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/tracefile.h
@@ -47,7 +47,7 @@
extern char cfs_tracefile[TRACEFILE_NAME_SIZE];
extern long long cfs_tracefile_size;
-extern void libcfs_run_debug_log_upcall(char *file);
+void libcfs_run_debug_log_upcall(char *file);
int cfs_tracefile_init_arch(void);
void cfs_tracefile_fini_arch(void);
@@ -65,8 +65,6 @@ void cfs_trace_stop_thread(void);
int cfs_tracefile_init(int max_pages);
void cfs_tracefile_exit(void);
-
-
int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
const char __user *usr_buffer, int usr_buffer_nob);
int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,
@@ -77,14 +75,13 @@ int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob);
int cfs_trace_daemon_command(char *str);
int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob);
int cfs_trace_set_debug_mb(int mb);
-int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob);
int cfs_trace_get_debug_mb(void);
-extern void libcfs_debug_dumplog_internal(void *arg);
-extern void libcfs_register_panic_notifier(void);
-extern void libcfs_unregister_panic_notifier(void);
+void libcfs_debug_dumplog_internal(void *arg);
+void libcfs_register_panic_notifier(void);
+void libcfs_unregister_panic_notifier(void);
extern int libcfs_panic_in_progress;
-extern int cfs_trace_max_debug_mb(void);
+int cfs_trace_max_debug_mb(void);
#define TCD_MAX_PAGES (5 << (20 - PAGE_CACHE_SHIFT))
#define TCD_STOCK_PAGES (TCD_MAX_PAGES)
@@ -253,15 +250,15 @@ struct cfs_trace_page {
unsigned short type;
};
-extern void cfs_set_ptldebug_header(struct ptldebug_header *header,
- struct libcfs_debug_msg_data *m,
- unsigned long stack);
-extern void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
- const char *buf, int len, const char *file,
- const char *fn);
+void cfs_set_ptldebug_header(struct ptldebug_header *header,
+ struct libcfs_debug_msg_data *m,
+ unsigned long stack);
+void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
+ const char *buf, int len, const char *file,
+ const char *fn);
-extern int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
-extern void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
+int cfs_trace_lock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
+void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
/**
* trace_buf_type_t, trace_buf_idx_get() and trace_console_buffers[][]
@@ -271,7 +268,7 @@ extern void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking);
*/
extern char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
-extern cfs_trace_buf_type_t cfs_trace_buf_idx_get(void);
+cfs_trace_buf_type_t cfs_trace_buf_idx_get(void);
static inline char *
cfs_trace_get_console_buffer(void)
@@ -310,12 +307,11 @@ cfs_trace_put_tcd (struct cfs_trace_cpu_data *tcd)
int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp,
struct list_head *stock);
-
int cfs_tcd_owns_tage(struct cfs_trace_cpu_data *tcd,
struct cfs_trace_page *tage);
-extern void cfs_trace_assertion_failed(const char *str,
- struct libcfs_debug_msg_data *m);
+void cfs_trace_assertion_failed(const char *str,
+ struct libcfs_debug_msg_data *m);
/* ASSERTION that is safe to use within the debug system */
#define __LASSERT(cond) \
diff --git a/kernel/drivers/staging/lustre/lustre/libcfs/workitem.c b/kernel/drivers/staging/lustre/lustre/libcfs/workitem.c
index 48009b775..e1143a566 100644
--- a/kernel/drivers/staging/lustre/lustre/libcfs/workitem.c
+++ b/kernel/drivers/staging/lustre/lustre/libcfs/workitem.c
@@ -45,7 +45,7 @@
#define CFS_WS_NAME_LEN 16
-typedef struct cfs_wi_sched {
+struct cfs_wi_sched {
struct list_head ws_list; /* chain on global list */
/** serialised workitems */
spinlock_t ws_lock;
@@ -73,7 +73,7 @@ typedef struct cfs_wi_sched {
unsigned int ws_starting:1;
/** scheduler name */
char ws_name[CFS_WS_NAME_LEN];
-} cfs_wi_sched_t;
+};
static struct cfs_workitem_data {
/** serialize */
@@ -87,19 +87,19 @@ static struct cfs_workitem_data {
} cfs_wi_data;
static inline void
-cfs_wi_sched_lock(cfs_wi_sched_t *sched)
+cfs_wi_sched_lock(struct cfs_wi_sched *sched)
{
spin_lock(&sched->ws_lock);
}
static inline void
-cfs_wi_sched_unlock(cfs_wi_sched_t *sched)
+cfs_wi_sched_unlock(struct cfs_wi_sched *sched)
{
spin_unlock(&sched->ws_lock);
}
static inline int
-cfs_wi_sched_cansleep(cfs_wi_sched_t *sched)
+cfs_wi_sched_cansleep(struct cfs_wi_sched *sched)
{
cfs_wi_sched_lock(sched);
if (sched->ws_stopping) {
@@ -115,7 +115,6 @@ cfs_wi_sched_cansleep(cfs_wi_sched_t *sched)
return 1;
}
-
/* XXX:
* 0. it only works when called from wi->wi_action.
* 1. when it returns no one shall try to schedule the workitem.
@@ -217,11 +216,10 @@ cfs_wi_schedule(struct cfs_wi_sched *sched, cfs_workitem_t *wi)
}
EXPORT_SYMBOL(cfs_wi_schedule);
-
static int
cfs_wi_scheduler (void *arg)
{
- struct cfs_wi_sched *sched = (cfs_wi_sched_t *)arg;
+ struct cfs_wi_sched *sched = (struct cfs_wi_sched *)arg;
cfs_block_allsigs();
@@ -258,7 +256,6 @@ cfs_wi_scheduler (void *arg)
wi->wi_running = 1;
wi->wi_scheduled = 0;
-
cfs_wi_sched_unlock(sched);
nloops++;
@@ -302,7 +299,6 @@ cfs_wi_scheduler (void *arg)
return 0;
}
-
void
cfs_wi_sched_destroy(struct cfs_wi_sched *sched)
{
diff --git a/kernel/drivers/staging/lustre/lustre/llite/Makefile b/kernel/drivers/staging/lustre/lustre/llite/Makefile
index 7d70115d5..9ac29e718 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/llite/Makefile
@@ -2,10 +2,9 @@ obj-$(CONFIG_LUSTRE_FS) += lustre.o
obj-$(CONFIG_LUSTRE_LLITE_LLOOP) += llite_lloop.o
lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \
rw.o namei.o symlink.o llite_mmap.o \
- xattr.o xattr_cache.o remote_perm.o llite_rmtacl.o llite_capa.o \
+ xattr.o xattr_cache.o remote_perm.o llite_rmtacl.o \
rw26.o super25.o statahead.o \
../lclient/glimpse.o ../lclient/lcommon_cl.o ../lclient/lcommon_misc.o \
- vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o
+ vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o lproc_llite.o
-lustre-$(CONFIG_PROC_FS) += lproc_llite.o
llite_lloop-y := lloop.o
diff --git a/kernel/drivers/staging/lustre/lustre/llite/dcache.c b/kernel/drivers/staging/lustre/lustre/llite/dcache.c
index 5af013513..80cba0448 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/dcache.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/dcache.c
@@ -52,7 +52,7 @@ static void free_dentry_data(struct rcu_head *head)
struct ll_dentry_data *lld;
lld = container_of(head, struct ll_dentry_data, lld_rcu_head);
- OBD_FREE_PTR(lld);
+ kfree(lld);
}
/* should NOT be called with the dcache lock, see fs/dcache.c */
@@ -67,7 +67,7 @@ static void ll_release(struct dentry *de)
if (lld->lld_it) {
ll_intent_release(lld->lld_it);
- OBD_FREE(lld->lld_it, sizeof(*lld->lld_it));
+ kfree(lld->lld_it);
}
de->d_fsdata = NULL;
@@ -194,7 +194,7 @@ int ll_d_init(struct dentry *de)
de->d_fsdata = lld;
__d_lustre_invalidate(de);
} else {
- OBD_FREE_PTR(lld);
+ kfree(lld);
}
spin_unlock(&de->d_lock);
} else {
@@ -250,7 +250,6 @@ void ll_intent_release(struct lookup_intent *it)
void ll_invalidate_aliases(struct inode *inode)
{
struct dentry *dentry;
- struct ll_d_hlist_node *p;
LASSERT(inode != NULL);
@@ -258,7 +257,7 @@ void ll_invalidate_aliases(struct inode *inode)
inode->i_ino, inode->i_generation, inode);
ll_lock_dcache(inode);
- ll_d_hlist_for_each_entry(dentry, p, &inode->i_dentry, d_u.d_alias) {
+ hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
CDEBUG(D_DENTRY, "dentry in drop %pd (%p) parent %p inode %p flags %d\n",
dentry, dentry, dentry->d_parent,
d_inode(dentry), dentry->d_flags);
@@ -345,7 +344,6 @@ static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
return ll_revalidate_dentry(dentry, flags);
}
-
static void ll_d_iput(struct dentry *de, struct inode *inode)
{
LASSERT(inode);
diff --git a/kernel/drivers/staging/lustre/lustre/llite/dir.c b/kernel/drivers/staging/lustre/lustre/llite/dir.c
index a5bc694dc..5c9502b5b 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/dir.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/dir.c
@@ -203,7 +203,6 @@ static int ll_dir_filler(void *_hash, struct page *page0)
CDEBUG(D_VFSTRACE, "read %d/%d pages\n", nrdpgs, npages);
- ll_pagevec_init(&lru_pvec, 0);
for (i = 1; i < npages; i++) {
unsigned long offset;
int ret;
@@ -225,21 +224,18 @@ static int ll_dir_filler(void *_hash, struct page *page0)
prefetchw(&page->flags);
ret = add_to_page_cache_lru(page, inode->i_mapping, offset,
- GFP_KERNEL);
+ GFP_NOFS);
if (ret == 0) {
unlock_page(page);
- if (ll_pagevec_add(&lru_pvec, page) == 0)
- ll_pagevec_lru_add_file(&lru_pvec);
} else {
CDEBUG(D_VFSTRACE, "page %lu add to page cache failed: %d\n",
offset, ret);
}
page_cache_release(page);
}
- ll_pagevec_lru_add_file(&lru_pvec);
if (page_pool != &page0)
- OBD_FREE(page_pool, sizeof(struct page *) * max_pages);
+ kfree(page_pool);
return rc;
}
@@ -650,7 +646,7 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string)
sizeof(struct mgs_send_param), msp, NULL);
if (rc)
CERROR("Failed to set parameter: %d\n", rc);
- OBD_FREE_PTR(msp);
+ kfree(msp);
return rc;
}
@@ -664,7 +660,7 @@ static int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump,
int mode;
int err;
- mode = (0755 & ~current_umask()) | S_IFDIR;
+ mode = (~current_umask() & 0755) | S_IFDIR;
op_data = ll_prep_md_op_data(NULL, dir, NULL, filename,
strlen(filename), mode, LUSTRE_OPC_MKDIR,
lump);
@@ -754,10 +750,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
char *buf;
param = kzalloc(MGS_PARAM_MAXLEN, GFP_NOFS);
- if (!param) {
- rc = -ENOMEM;
- goto end;
- }
+ if (!param)
+ return -ENOMEM;
buf = param;
/* Get fsname and assume devname to be -MDT0000. */
@@ -786,8 +780,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
end:
- if (param != NULL)
- OBD_FREE(param, MGS_PARAM_MAXLEN);
+ kfree(param);
}
return rc;
}
@@ -845,11 +838,11 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
/* We don't swab objects for directories */
switch (le32_to_cpu(lmm->lmm_magic)) {
case LOV_MAGIC_V1:
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))
+ if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC)
lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm);
break;
case LOV_MAGIC_V3:
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))
+ if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC)
lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm);
break;
default:
@@ -914,7 +907,6 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy)
hpk.hpk_errval = 0;
hpk.hpk_data_version = 0;
-
/* For archive request, we need to read the current file version. */
if (copy->hc_hai.hai_action == HSMA_ARCHIVE) {
struct inode *inode;
@@ -1054,7 +1046,6 @@ progress:
return rc;
}
-
static int copy_and_ioctl(int cmd, struct obd_export *exp,
const void __user *data, size_t size)
{
@@ -1072,7 +1063,7 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp,
rc = obd_iocontrol(cmd, exp, size, copy, NULL);
out:
- OBD_FREE(copy, size);
+ kfree(copy);
return rc;
}
@@ -1163,7 +1154,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
oqctl->qc_cmd = Q_QUOTAOFF;
obd_quotactl(sbi->ll_md_exp, oqctl);
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
return rc;
}
/* If QIF_SPACE is not set, client should collect the
@@ -1206,39 +1197,44 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
oqctl->qc_dqblk.dqb_valid &= ~QIF_SPACE;
}
- OBD_FREE_PTR(oqctl_tmp);
+ kfree(oqctl_tmp);
}
out:
QCTL_COPY(qctl, oqctl);
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
}
return rc;
}
-static char *
-ll_getname(const char __user *filename)
+/* This function tries to get a single name component,
+ * to send to the server. No actual path traversal involved,
+ * so we limit to NAME_MAX */
+static char *ll_getname(const char __user *filename)
{
int ret = 0, len;
- char *tmp = __getname();
+ char *tmp;
+ tmp = kzalloc(NAME_MAX + 1, GFP_KERNEL);
if (!tmp)
return ERR_PTR(-ENOMEM);
- len = strncpy_from_user(tmp, filename, PATH_MAX);
- if (len == 0)
+ len = strncpy_from_user(tmp, filename, NAME_MAX + 1);
+ if (len < 0)
+ ret = len;
+ else if (len == 0)
ret = -ENOENT;
- else if (len > PATH_MAX)
+ else if (len > NAME_MAX && tmp[NAME_MAX] != 0)
ret = -ENAMETOOLONG;
if (ret) {
- __putname(tmp);
+ kfree(tmp);
tmp = ERR_PTR(ret);
}
return tmp;
}
-#define ll_putname(filename) __putname(filename)
+#define ll_putname(filename) kfree(filename)
static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
@@ -1436,37 +1432,7 @@ lmv_out_free:
goto free_lmv;
}
free_lmv:
- if (tmp)
- OBD_FREE(tmp, lum_size);
- return rc;
- }
- case LL_IOC_REMOVE_ENTRY: {
- char *filename = NULL;
- int namelen = 0;
- int rc;
-
- /* Here is a little hack to avoid sending REINT_RMENTRY to
- * unsupported server, which might crash the server(LU-2730),
- * Because both LVB_TYPE and REINT_RMENTRY will be supported
- * on 2.4, we use OBD_CONNECT_LVB_TYPE to detect whether the
- * server will support REINT_RMENTRY XXX*/
- if (!(exp_connect_flags(sbi->ll_md_exp) & OBD_CONNECT_LVB_TYPE))
- return -ENOTSUPP;
-
- filename = ll_getname((const char *)arg);
- if (IS_ERR(filename))
- return PTR_ERR(filename);
-
- namelen = strlen(filename);
- if (namelen < 1) {
- rc = -EINVAL;
- goto out_rmdir;
- }
-
- rc = ll_rmdir_entry(inode, filename, namelen);
-out_rmdir:
- if (filename)
- ll_putname(filename);
+ kfree(tmp);
return rc;
}
case LL_IOC_LOV_SWAP_LAYOUTS:
@@ -1576,7 +1542,7 @@ out_req:
if (rc)
return rc;
- OBD_ALLOC_LARGE(lmm, lmmsize);
+ lmm = libcfs_kvzalloc(lmmsize, GFP_NOFS);
if (lmm == NULL)
return -ENOMEM;
if (copy_from_user(lmm, lum, lmmsize)) {
@@ -1586,7 +1552,7 @@ out_req:
switch (lmm->lmm_magic) {
case LOV_USER_MAGIC_V1:
- if (LOV_USER_MAGIC_V1 == cpu_to_le32(LOV_USER_MAGIC_V1))
+ if (cpu_to_le32(LOV_USER_MAGIC_V1) == LOV_USER_MAGIC_V1)
break;
/* swab objects first so that stripes num will be sane */
lustre_swab_lov_user_md_objects(
@@ -1595,7 +1561,7 @@ out_req:
lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm);
break;
case LOV_USER_MAGIC_V3:
- if (LOV_USER_MAGIC_V3 == cpu_to_le32(LOV_USER_MAGIC_V3))
+ if (cpu_to_le32(LOV_USER_MAGIC_V3) == LOV_USER_MAGIC_V3)
break;
/* swab objects first so that stripes num will be sane */
lustre_swab_lov_user_md_objects(
@@ -1629,7 +1595,7 @@ out_req:
free_lsm:
obd_free_memmd(sbi->ll_dt_exp, &lsm);
free_lmm:
- OBD_FREE_LARGE(lmm, lmmsize);
+ kvfree(lmm);
return rc;
}
case OBD_IOC_LLOG_CATINFO: {
@@ -1657,7 +1623,7 @@ free_lmm:
if (rc < 0)
CDEBUG(D_INFO, "obd_quotacheck failed: rc %d\n", rc);
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
return error ?: rc;
}
case OBD_IOC_POLL_QUOTACHECK: {
@@ -1691,7 +1657,7 @@ free_lmm:
goto out_poll;
}
out_poll:
- OBD_FREE_PTR(check);
+ kfree(check);
return rc;
}
case LL_IOC_QUOTACTL: {
@@ -1712,7 +1678,7 @@ out_poll:
rc = -EFAULT;
out_quotactl:
- OBD_FREE_PTR(qctl);
+ kfree(qctl);
return rc;
}
case OBD_IOC_GETDTNAME:
@@ -1766,6 +1732,9 @@ out_quotactl:
}
case OBD_IOC_CHANGELOG_SEND:
case OBD_IOC_CHANGELOG_CLEAR:
+ if (!capable(CFS_CAP_SYS_ADMIN))
+ return -EPERM;
+
rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg,
sizeof(struct ioc_changelog));
return rc;
@@ -1775,19 +1744,13 @@ out_quotactl:
struct hsm_user_request *hur;
ssize_t totalsize;
- hur = kzalloc(sizeof(*hur), GFP_NOFS);
- if (!hur)
- return -ENOMEM;
-
- /* We don't know the true size yet; copy the fixed-size part */
- if (copy_from_user(hur, (void *)arg, sizeof(*hur))) {
- OBD_FREE_PTR(hur);
- return -EFAULT;
- }
+ hur = memdup_user((void *)arg, sizeof(*hur));
+ if (IS_ERR(hur))
+ return PTR_ERR(hur);
/* Compute the whole struct size */
totalsize = hur_len(hur);
- OBD_FREE_PTR(hur);
+ kfree(hur);
if (totalsize < 0)
return -E2BIG;
@@ -1795,13 +1758,13 @@ out_quotactl:
if (totalsize >= MDS_MAXREQSIZE / 3)
return -E2BIG;
- OBD_ALLOC_LARGE(hur, totalsize);
+ hur = libcfs_kvzalloc(totalsize, GFP_NOFS);
if (hur == NULL)
return -ENOMEM;
/* Copy the whole struct */
if (copy_from_user(hur, (void *)arg, totalsize)) {
- OBD_FREE_LARGE(hur, totalsize);
+ kvfree(hur);
return -EFAULT;
}
@@ -1828,7 +1791,7 @@ out_quotactl:
hur, NULL);
}
- OBD_FREE_LARGE(hur, totalsize);
+ kvfree(hur);
return rc;
}
@@ -1861,38 +1824,30 @@ out_quotactl:
struct hsm_copy *copy;
int rc;
- copy = kzalloc(sizeof(*copy), GFP_NOFS);
- if (!copy)
- return -ENOMEM;
- if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
- OBD_FREE_PTR(copy);
- return -EFAULT;
- }
+ copy = memdup_user((char *)arg, sizeof(*copy));
+ if (IS_ERR(copy))
+ return PTR_ERR(copy);
rc = ll_ioc_copy_start(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy)))
rc = -EFAULT;
- OBD_FREE_PTR(copy);
+ kfree(copy);
return rc;
}
case LL_IOC_HSM_COPY_END: {
struct hsm_copy *copy;
int rc;
- copy = kzalloc(sizeof(*copy), GFP_NOFS);
- if (!copy)
- return -ENOMEM;
- if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
- OBD_FREE_PTR(copy);
- return -EFAULT;
- }
+ copy = memdup_user((char *)arg, sizeof(*copy));
+ if (IS_ERR(copy))
+ return PTR_ERR(copy);
rc = ll_ioc_copy_end(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy)))
rc = -EFAULT;
- OBD_FREE_PTR(copy);
+ kfree(copy);
return rc;
}
default:
diff --git a/kernel/drivers/staging/lustre/lustre/llite/file.c b/kernel/drivers/staging/lustre/lustre/llite/file.c
index 4b44c634f..02f275930 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/file.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/file.c
@@ -64,7 +64,7 @@ static struct ll_file_data *ll_file_data_get(void)
{
struct ll_file_data *fd;
- OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, GFP_NOFS);
+ fd = kmem_cache_alloc(ll_file_data_slab, GFP_NOFS | __GFP_ZERO);
if (fd == NULL)
return NULL;
fd->fd_write_failed = false;
@@ -74,7 +74,7 @@ static struct ll_file_data *ll_file_data_get(void)
static void ll_file_data_put(struct ll_file_data *fd)
{
if (fd != NULL)
- OBD_SLAB_FREE_PTR(fd, ll_file_data_slab);
+ kmem_cache_free(ll_file_data_slab, fd);
}
void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data,
@@ -92,9 +92,8 @@ void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data,
op_data->op_ioepoch = ll_i2info(inode)->lli_ioepoch;
if (fh)
op_data->op_handle = *fh;
- op_data->op_capa1 = ll_mdscapa_get(inode);
- if (LLIF_DATA_MODIFIED & ll_i2info(inode)->lli_flags)
+ if (ll_i2info(inode)->lli_flags & LLIF_DATA_MODIFIED)
op_data->op_bias |= MDS_DATA_MODIFIED;
}
@@ -213,7 +212,7 @@ out:
md_clear_open_replay_data(md_exp, och);
/* Free @och if it is not waiting for DONE_WRITING. */
och->och_fh.cookie = DEAD_HANDLE_MAGIC;
- OBD_FREE_PTR(och);
+ kfree(och);
}
if (req) /* This is close request */
ptlrpc_req_finished(req);
@@ -270,7 +269,7 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
int lockmode;
__u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
struct lustre_handle lockh;
- ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_OPEN}};
+ ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_OPEN} };
int rc = 0;
/* clear group lock, if present */
@@ -321,7 +320,6 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
out:
LUSTRE_FPRIVATE(file) = NULL;
ll_file_data_put(fd);
- ll_capa_close(inode);
return rc;
}
@@ -679,8 +677,6 @@ restart:
if (!S_ISREG(inode->i_mode))
goto out_och_free;
- ll_capa_open(inode);
-
if (!lli->lli_has_smd &&
(cl_is_lov_delay_create(file->f_flags) ||
(file->f_mode & FMODE_WRITE) == 0)) {
@@ -693,8 +689,8 @@ restart:
out_och_free:
if (rc) {
if (och_p && *och_p) {
- OBD_FREE(*och_p, sizeof(struct obd_client_handle));
- *och_p = NULL; /* OBD_FREE writes some magic there */
+ kfree(*och_p);
+ *och_p = NULL;
(*och_usecount)--;
}
mutex_unlock(&lli->lli_och_mutex);
@@ -702,8 +698,7 @@ out_och_free:
out_openerr:
if (opendir_set != 0)
ll_stop_statahead(inode, lli->lli_opendir_key);
- if (fd != NULL)
- ll_file_data_put(fd);
+ ll_file_data_put(fd);
} else {
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1);
}
@@ -875,7 +870,7 @@ out_close:
out_release_it:
ll_intent_release(&it);
out:
- OBD_FREE_PTR(och);
+ kfree(och);
return ERR_PTR(rc);
}
@@ -913,11 +908,10 @@ static int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
/* Fills the obdo with the attributes for the lsm */
static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp,
- struct obd_capa *capa, struct obdo *obdo,
- __u64 ioepoch, int sync)
+ struct obdo *obdo, __u64 ioepoch, int sync)
{
struct ptlrpc_request_set *set;
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info oinfo = { };
int rc;
LASSERT(lsm != NULL);
@@ -933,7 +927,6 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp,
OBD_MD_FLMTIME | OBD_MD_FLCTIME |
OBD_MD_FLGROUP | OBD_MD_FLEPOCH |
OBD_MD_FLDATAVERSION;
- oinfo.oi_capa = capa;
if (sync) {
oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS;
oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK;
@@ -964,14 +957,12 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp,
int ll_inode_getattr(struct inode *inode, struct obdo *obdo,
__u64 ioepoch, int sync)
{
- struct obd_capa *capa = ll_mdscapa_get(inode);
struct lov_stripe_md *lsm;
int rc;
lsm = ccc_inode_lsm_get(inode);
rc = ll_lsm_getattr(lsm, ll_i2dtexp(inode),
- capa, obdo, ioepoch, sync);
- capa_put(capa);
+ obdo, ioepoch, sync);
if (rc == 0) {
struct ost_id *oi = lsm ? &lsm->lsm_oi : &obdo->o_oi;
@@ -1039,7 +1030,7 @@ int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm,
struct obdo obdo = { 0 };
int rc;
- rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, &obdo, 0, 0);
+ rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, &obdo, 0, 0);
if (rc == 0) {
st->st_size = obdo.o_size;
st->st_blocks = obdo.o_blocks;
@@ -1269,7 +1260,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx)
int rc = 0;
struct lov_stripe_md *lsm = NULL, *lsm2;
- OBDO_ALLOC(oa);
+ oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
if (oa == NULL)
return -ENOMEM;
@@ -1282,7 +1273,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx)
lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) *
(lsm->lsm_stripe_count));
- OBD_ALLOC_LARGE(lsm2, lsm_size);
+ lsm2 = libcfs_kvzalloc(lsm_size, GFP_NOFS);
if (lsm2 == NULL) {
rc = -ENOMEM;
goto out;
@@ -1300,11 +1291,11 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx)
rc = obd_create(NULL, exp, oa, &lsm2, &oti);
ll_inode_size_unlock(inode);
- OBD_FREE_LARGE(lsm2, lsm_size);
+ kvfree(lsm2);
goto out;
out:
ccc_inode_lsm_put(inode, lsm);
- OBDO_FREE(oa);
+ kmem_cache_free(obdo_cachep, oa);
return rc;
}
@@ -1434,7 +1425,7 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
* little endian. We convert it to host endian before
* passing it to userspace.
*/
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) {
+ if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) {
int stripe_count;
stripe_count = le16_to_cpu(lmm->lmm_stripe_count);
@@ -1477,12 +1468,12 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
if (!capable(CFS_CAP_SYS_ADMIN))
return -EPERM;
- OBD_ALLOC_LARGE(lump, lum_size);
+ lump = libcfs_kvzalloc(lum_size, GFP_NOFS);
if (lump == NULL)
return -ENOMEM;
if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) {
- OBD_FREE_LARGE(lump, lum_size);
+ kvfree(lump);
return -EFAULT;
}
@@ -1490,7 +1481,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
lum_size);
cl_lov_delay_create_clear(&file->f_flags);
- OBD_FREE_LARGE(lump, lum_size);
+ kvfree(lump);
return rc;
}
@@ -1779,7 +1770,7 @@ int ll_fid2path(struct inode *inode, void __user *arg)
rc = -EFAULT;
gf_free:
- OBD_FREE(gfout, outsize);
+ kfree(gfout);
return rc;
}
@@ -1802,7 +1793,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg)
num_bytes = sizeof(*fiemap_s) + (extent_count *
sizeof(struct ll_fiemap_extent));
- OBD_ALLOC_LARGE(fiemap_s, num_bytes);
+ fiemap_s = libcfs_kvzalloc(num_bytes, GFP_NOFS);
if (fiemap_s == NULL)
return -ENOMEM;
@@ -1839,7 +1830,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg)
rc = -EFAULT;
error:
- OBD_FREE_LARGE(fiemap_s, num_bytes);
+ kvfree(fiemap_s);
return rc;
}
@@ -1875,7 +1866,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version,
goto out;
}
- rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, obdo, 0, extent_lock);
+ rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, obdo, 0, extent_lock);
if (rc == 0) {
if (!(obdo->o_valid & OBD_MD_FLDATAVERSION))
rc = -EOPNOTSUPP;
@@ -1883,7 +1874,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version,
*data_version = obdo->o_data_version;
}
- OBD_FREE_PTR(obdo);
+ kfree(obdo);
out:
ccc_inode_lsm_put(inode, lsm);
return rc;
@@ -1900,7 +1891,6 @@ int ll_hsm_release(struct inode *inode)
__u64 data_version = 0;
int rc;
-
CDEBUG(D_INODE, "%s: Releasing file "DFID".\n",
ll_get_fsname(inode->i_sb, NULL, 0),
PFID(&ll_i2info(inode)->lli_fid));
@@ -1932,7 +1922,6 @@ int ll_hsm_release(struct inode *inode)
&data_version);
och = NULL;
-
out:
if (och != NULL && !IS_ERR(och)) /* close the file */
ll_lease_close(och, inode, NULL);
@@ -2109,8 +2098,7 @@ putgl:
}
free:
- if (llss != NULL)
- OBD_FREE_PTR(llss);
+ kfree(llss);
return rc;
}
@@ -2120,12 +2108,21 @@ static int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss)
struct md_op_data *op_data;
int rc;
+ /* Detect out-of range masks */
+ if ((hss->hss_setmask | hss->hss_clearmask) & ~HSM_FLAGS_MASK)
+ return -EINVAL;
+
/* Non-root users are forbidden to set or clear flags which are
* NOT defined in HSM_USER_MASK. */
if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) &&
!capable(CFS_CAP_SYS_ADMIN))
return -EPERM;
+ /* Detect out-of range archive id */
+ if ((hss->hss_valid & HSS_ARCHIVE_ID) &&
+ (hss->hss_archive_id > LL_HSM_MAX_ARCHIVE))
+ return -EINVAL;
+
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hss);
if (IS_ERR(op_data))
@@ -2146,28 +2143,25 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
struct iattr *attr = NULL;
int rc;
-
if (!S_ISREG(inode->i_mode))
return -EINVAL;
/* set HSM flags */
hss = kzalloc(sizeof(*hss), GFP_NOFS);
- if (!hss) {
- rc = -ENOMEM;
- goto out;
- }
+ if (!hss)
+ return -ENOMEM;
hss->hss_valid = HSS_SETMASK | HSS_ARCHIVE_ID;
hss->hss_archive_id = hui->hui_archive_id;
hss->hss_setmask = HS_ARCHIVED | HS_EXISTS | HS_RELEASED;
rc = ll_hsm_state_set(inode, hss);
if (rc != 0)
- goto out;
+ goto free_hss;
attr = kzalloc(sizeof(*attr), GFP_NOFS);
if (!attr) {
rc = -ENOMEM;
- goto out;
+ goto free_hss;
}
attr->ia_mode = hui->hui_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
@@ -2193,13 +2187,9 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
mutex_unlock(&inode->i_mutex);
-out:
- if (hss != NULL)
- OBD_FREE_PTR(hss);
-
- if (attr != NULL)
- OBD_FREE_PTR(attr);
-
+ kfree(attr);
+free_hss:
+ kfree(hss);
return rc;
}
@@ -2350,7 +2340,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hus);
if (IS_ERR(op_data)) {
- OBD_FREE_PTR(hus);
+ kfree(hus);
return PTR_ERR(op_data);
}
@@ -2361,25 +2351,20 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
rc = -EFAULT;
ll_finish_md_op_data(op_data);
- OBD_FREE_PTR(hus);
+ kfree(hus);
return rc;
}
case LL_IOC_HSM_STATE_SET: {
struct hsm_state_set *hss;
int rc;
- hss = kzalloc(sizeof(*hss), GFP_NOFS);
- if (!hss)
- return -ENOMEM;
-
- if (copy_from_user(hss, (char *)arg, sizeof(*hss))) {
- OBD_FREE_PTR(hss);
- return -EFAULT;
- }
+ hss = memdup_user((char *)arg, sizeof(*hss));
+ if (IS_ERR(hss))
+ return PTR_ERR(hss);
rc = ll_hsm_state_set(inode, hss);
- OBD_FREE_PTR(hss);
+ kfree(hss);
return rc;
}
case LL_IOC_HSM_ACTION: {
@@ -2394,7 +2379,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hca);
if (IS_ERR(op_data)) {
- OBD_FREE_PTR(hca);
+ kfree(hca);
return PTR_ERR(op_data);
}
@@ -2405,7 +2390,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
rc = -EFAULT;
ll_finish_md_op_data(op_data);
- OBD_FREE_PTR(hca);
+ kfree(hca);
return rc;
}
case LL_IOC_SET_LEASE: {
@@ -2495,25 +2480,20 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case LL_IOC_HSM_IMPORT: {
struct hsm_user_import *hui;
- hui = kzalloc(sizeof(*hui), GFP_NOFS);
- if (!hui)
- return -ENOMEM;
-
- if (copy_from_user(hui, (void *)arg, sizeof(*hui))) {
- OBD_FREE_PTR(hui);
- return -EFAULT;
- }
+ hui = memdup_user((void *)arg, sizeof(*hui));
+ if (IS_ERR(hui))
+ return PTR_ERR(hui);
rc = ll_hsm_import(inode, file, hui);
- OBD_FREE_PTR(hui);
+ kfree(hui);
return rc;
}
default: {
int err;
- if (LLIOC_STOP ==
- ll_iocontrol_call(inode, file, cmd, arg, &err))
+ if (ll_iocontrol_call(inode, file, cmd, arg, &err) ==
+ LLIOC_STOP)
return err;
return obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL,
@@ -2522,7 +2502,6 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
}
}
-
static loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
{
struct inode *inode = file_inode(file);
@@ -2583,7 +2562,6 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
struct cl_env_nest nest;
struct lu_env *env;
struct cl_io *io;
- struct obd_capa *capa = NULL;
struct cl_fsync_io *fio;
int result;
@@ -2595,15 +2573,12 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
if (IS_ERR(env))
return PTR_ERR(env);
- capa = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE);
-
io = ccc_env_thread_io(env);
io->ci_obj = cl_i2info(inode)->lli_clob;
io->ci_ignore_layout = ignore_layout;
/* initialize parameters for sync */
fio = &io->u.ci_fsync;
- fio->fi_capa = capa;
fio->fi_start = start;
fio->fi_end = end;
fio->fi_fid = ll_inode2fid(inode);
@@ -2619,8 +2594,6 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
cl_io_fini(env, io);
cl_env_nested_put(&nest, env);
- capa_put(capa);
-
return result;
}
@@ -2629,7 +2602,6 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
struct inode *inode = file_inode(file);
struct ll_inode_info *lli = ll_i2info(inode);
struct ptlrpc_request *req;
- struct obd_capa *oc;
int rc, err;
CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
@@ -2651,10 +2623,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
rc = err;
}
- oc = ll_mdscapa_get(inode);
- err = md_sync(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), oc,
- &req);
- capa_put(oc);
+ err = md_sync(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), &req);
if (!rc)
rc = err;
if (!err)
@@ -2688,7 +2657,7 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
};
struct md_op_data *op_data;
struct lustre_handle lockh = {0};
- ldlm_policy_data_t flock = {{0}};
+ ldlm_policy_data_t flock = { {0} };
__u64 flags = 0;
int rc;
int rc2 = 0;
@@ -2781,13 +2750,9 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL,
op_data, &lockh, &flock, 0, NULL /* req */, flags);
- if ((file_lock->fl_flags & FL_FLOCK) &&
- (rc == 0 || file_lock->fl_type == F_UNLCK))
- rc2 = flock_lock_file_wait(file, file_lock);
- if ((file_lock->fl_flags & FL_POSIX) &&
- (rc == 0 || file_lock->fl_type == F_UNLCK) &&
+ if ((rc == 0 || file_lock->fl_type == F_UNLCK) &&
!(flags & LDLM_FL_TEST_LOCK))
- rc2 = posix_lock_file_wait(file, file_lock);
+ rc2 = locks_lock_file_wait(file, file_lock);
if (rc2 && file_lock->fl_type != F_UNLCK) {
einfo.ei_mode = LCK_NL;
@@ -2868,7 +2833,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
fid = &ll_i2info(inode)->lli_fid;
CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid));
- rc = md_lock_match(ll_i2mdexp(inode), LDLM_FL_BLOCK_GRANTED|flags,
+ rc = md_lock_match(ll_i2mdexp(inode), flags | LDLM_FL_BLOCK_GRANTED,
fid, LDLM_IBITS, &policy, mode, lockh);
return rc;
@@ -2972,9 +2937,6 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
return PTR_ERR(op_data);
op_data->op_valid = valid;
- /* Once OBD_CONNECT_ATTRFID is not supported, we can't find one
- * capa for this inode. Because we only keep capas of dirs
- * fresh. */
rc = md_getattr(sbi->ll_md_exp, op_data, &req);
ll_finish_md_op_data(op_data);
if (rc) {
@@ -3022,7 +2984,7 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
struct inode *inode = d_inode(de);
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ll_inode_info *lli = ll_i2info(inode);
- int res = 0;
+ int res;
res = ll_inode_revalidate(de, MDS_INODELOCK_UPDATE |
MDS_INODELOCK_LOOKUP);
@@ -3062,7 +3024,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
num_bytes = sizeof(*fiemap) + (extent_count *
sizeof(struct ll_fiemap_extent));
- OBD_ALLOC_LARGE(fiemap, num_bytes);
+ fiemap = libcfs_kvzalloc(num_bytes, GFP_NOFS);
if (fiemap == NULL)
return -ENOMEM;
@@ -3084,7 +3046,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
fiemap->fm_mapped_extents *
sizeof(struct ll_fiemap_extent));
- OBD_FREE_LARGE(fiemap, num_bytes);
+ kvfree(fiemap);
return rc;
}
@@ -3101,7 +3063,6 @@ struct posix_acl *ll_get_acl(struct inode *inode, int type)
return acl;
}
-
int ll_inode_permission(struct inode *inode, int mask)
{
int rc = 0;
@@ -3199,7 +3160,6 @@ static struct llioc_ctl_data {
LIST_HEAD_INIT(llioc.ioc_head)
};
-
struct llioc_data {
struct list_head iocd_list;
unsigned int iocd_size;
@@ -3246,12 +3206,10 @@ void ll_iocontrol_unregister(void *magic)
down_write(&llioc.ioc_sem);
list_for_each_entry(tmp, &llioc.ioc_head, iocd_list) {
if (tmp == magic) {
- unsigned int size = tmp->iocd_size;
-
list_del(&tmp->iocd_list);
up_write(&llioc.ioc_sem);
- OBD_FREE(tmp, size);
+ kfree(tmp);
return;
}
}
@@ -3327,7 +3285,6 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
{
struct ll_sb_info *sbi = ll_i2sbi(inode);
- struct obd_capa *oc;
struct ptlrpc_request *req;
struct mdt_body *body;
void *lvbdata;
@@ -3347,13 +3304,11 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
* blocked and then granted via completion ast, we have to fetch
* layout here. Please note that we can't use the LVB buffer in
* completion AST because it doesn't have a large enough buffer */
- oc = ll_mdscapa_get(inode);
rc = ll_get_default_mdsize(sbi, &lmmsize);
if (rc == 0)
- rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
- OBD_MD_FLXATTR, XATTR_NAME_LOV, NULL, 0,
- lmmsize, 0, &req);
- capa_put(oc);
+ rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode),
+ OBD_MD_FLXATTR, XATTR_NAME_LOV, NULL, 0,
+ lmmsize, 0, &req);
if (rc < 0)
return rc;
@@ -3375,7 +3330,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
goto out;
}
- OBD_ALLOC_LARGE(lvbdata, lmmsize);
+ lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS);
if (lvbdata == NULL) {
rc = -ENOMEM;
goto out;
@@ -3384,7 +3339,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
memcpy(lvbdata, lmm, lmmsize);
lock_res_and_lock(lock);
if (lock->l_lvb_data != NULL)
- OBD_FREE_LARGE(lock->l_lvb_data, lock->l_lvb_len);
+ kvfree(lock->l_lvb_data);
lock->l_lvb_data = lvbdata;
lock->l_lvb_len = lmmsize;
@@ -3619,6 +3574,6 @@ int ll_layout_restore(struct inode *inode)
hur->hur_request.hr_itemcount = 1;
rc = obd_iocontrol(LL_IOC_HSM_REQUEST, cl_i2sbi(inode)->ll_md_exp,
len, hur, NULL);
- OBD_FREE(hur, len);
+ kfree(hur);
return rc;
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/llite_capa.c b/kernel/drivers/staging/lustre/lustre/llite/llite_capa.c
deleted file mode 100644
index aec9a4412..000000000
--- a/kernel/drivers/staging/lustre/lustre/llite/llite_capa.c
+++ /dev/null
@@ -1,654 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/llite/llite_capa.c
- *
- * Author: Lai Siyao <lsy@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_LLITE
-
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-#include <linux/file.h>
-#include <linux/kmod.h>
-
-#include "../include/lustre_lite.h"
-#include "llite_internal.h"
-
-/* for obd_capa.c_list, client capa might stay in three places:
- * 1. ll_capa_list.
- * 2. ll_idle_capas.
- * 3. stand alone: just allocated.
- */
-
-/* capas for oss writeback and those failed to renew */
-static LIST_HEAD(ll_idle_capas);
-static struct ptlrpc_thread ll_capa_thread;
-static struct list_head *ll_capa_list = &capa_list[CAPA_SITE_CLIENT];
-
-/* llite capa renewal timer */
-struct timer_list ll_capa_timer;
-/* for debug: indicate whether capa on llite is enabled or not */
-static atomic_t ll_capa_debug = ATOMIC_INIT(0);
-static unsigned long long ll_capa_renewed;
-static unsigned long long ll_capa_renewal_noent;
-static unsigned long long ll_capa_renewal_failed;
-static unsigned long long ll_capa_renewal_retries;
-
-static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa);
-
-static inline void update_capa_timer(struct obd_capa *ocapa, unsigned long expiry)
-{
- if (time_before(expiry, ll_capa_timer.expires) ||
- !timer_pending(&ll_capa_timer)) {
- mod_timer(&ll_capa_timer, expiry);
- DEBUG_CAPA(D_SEC, &ocapa->c_capa,
- "ll_capa_timer update: %lu/%lu by", expiry, jiffies);
- }
-}
-
-static inline unsigned long capa_renewal_time(struct obd_capa *ocapa)
-{
- return cfs_time_sub(ocapa->c_expiry,
- cfs_time_seconds(ocapa->c_capa.lc_timeout) / 2);
-}
-
-static inline int capa_is_to_expire(struct obd_capa *ocapa)
-{
- return time_before_eq(capa_renewal_time(ocapa), cfs_time_current());
-}
-
-static inline int have_expired_capa(void)
-{
- struct obd_capa *ocapa = NULL;
- int expired = 0;
-
- /* if ll_capa_list has client capa to expire or ll_idle_capas has
- * expired capa, return 1.
- */
- spin_lock(&capa_lock);
- if (!list_empty(ll_capa_list)) {
- ocapa = list_entry(ll_capa_list->next, struct obd_capa,
- c_list);
- expired = capa_is_to_expire(ocapa);
- if (!expired)
- update_capa_timer(ocapa, capa_renewal_time(ocapa));
- } else if (!list_empty(&ll_idle_capas)) {
- ocapa = list_entry(ll_idle_capas.next, struct obd_capa,
- c_list);
- expired = capa_is_expired(ocapa);
- if (!expired)
- update_capa_timer(ocapa, ocapa->c_expiry);
- }
- spin_unlock(&capa_lock);
-
- if (expired)
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "expired");
- return expired;
-}
-
-static void sort_add_capa(struct obd_capa *ocapa, struct list_head *head)
-{
- struct obd_capa *tmp;
- struct list_head *before = NULL;
-
- /* TODO: client capa is sorted by expiry, this could be optimized */
- list_for_each_entry_reverse(tmp, head, c_list) {
- if (cfs_time_aftereq(ocapa->c_expiry, tmp->c_expiry)) {
- before = &tmp->c_list;
- break;
- }
- }
-
- LASSERT(&ocapa->c_list != before);
- list_add(&ocapa->c_list, before ?: head);
-}
-
-static inline int obd_capa_open_count(struct obd_capa *oc)
-{
- struct ll_inode_info *lli = ll_i2info(oc->u.cli.inode);
- return atomic_read(&lli->lli_open_count);
-}
-
-static void ll_delete_capa(struct obd_capa *ocapa)
-{
- struct ll_inode_info *lli = ll_i2info(ocapa->u.cli.inode);
-
- if (capa_for_mds(&ocapa->c_capa)) {
- LASSERT(lli->lli_mds_capa == ocapa);
- lli->lli_mds_capa = NULL;
- } else if (capa_for_oss(&ocapa->c_capa)) {
- list_del_init(&ocapa->u.cli.lli_list);
- }
-
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free client");
- list_del_init(&ocapa->c_list);
- capa_count[CAPA_SITE_CLIENT]--;
- /* release the ref when alloc */
- capa_put(ocapa);
-}
-
-/* three places where client capa is deleted:
- * 1. capa_thread_main(), main place to delete expired capa.
- * 2. ll_clear_inode_capas() in ll_clear_inode().
- * 3. ll_truncate_free_capa() delete truncate capa explicitly in ll_setattr_ost().
- */
-static int capa_thread_main(void *unused)
-{
- struct obd_capa *ocapa, *tmp, *next;
- struct inode *inode = NULL;
- struct l_wait_info lwi = { 0 };
- int rc;
-
- thread_set_flags(&ll_capa_thread, SVC_RUNNING);
- wake_up(&ll_capa_thread.t_ctl_waitq);
-
- while (1) {
- l_wait_event(ll_capa_thread.t_ctl_waitq,
- !thread_is_running(&ll_capa_thread) ||
- have_expired_capa(),
- &lwi);
-
- if (!thread_is_running(&ll_capa_thread))
- break;
-
- next = NULL;
-
- spin_lock(&capa_lock);
- list_for_each_entry_safe(ocapa, tmp, ll_capa_list, c_list) {
- __u64 ibits;
-
- LASSERT(ocapa->c_capa.lc_opc != CAPA_OPC_OSS_TRUNC);
-
- if (!capa_is_to_expire(ocapa)) {
- next = ocapa;
- break;
- }
-
- list_del_init(&ocapa->c_list);
-
- /* for MDS capability, only renew those which belong to
- * dir, or its inode is opened, or client holds LOOKUP
- * lock.
- */
- /* ibits may be changed by ll_have_md_lock() so we have
- * to set it each time */
- ibits = MDS_INODELOCK_LOOKUP;
- if (capa_for_mds(&ocapa->c_capa) &&
- !S_ISDIR(ocapa->u.cli.inode->i_mode) &&
- obd_capa_open_count(ocapa) == 0 &&
- !ll_have_md_lock(ocapa->u.cli.inode,
- &ibits, LCK_MINMODE)) {
- DEBUG_CAPA(D_SEC, &ocapa->c_capa,
- "skip renewal for");
- sort_add_capa(ocapa, &ll_idle_capas);
- continue;
- }
-
- /* for OSS capability, only renew those whose inode is
- * opened.
- */
- if (capa_for_oss(&ocapa->c_capa) &&
- obd_capa_open_count(ocapa) == 0) {
- /* oss capa with open count == 0 won't renew,
- * move to idle list */
- sort_add_capa(ocapa, &ll_idle_capas);
- continue;
- }
-
- /* NB iput() is in ll_update_capa() */
- inode = igrab(ocapa->u.cli.inode);
- if (inode == NULL) {
- DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
- "igrab failed for");
- continue;
- }
-
- capa_get(ocapa);
- ll_capa_renewed++;
- spin_unlock(&capa_lock);
- rc = md_renew_capa(ll_i2mdexp(inode), ocapa,
- ll_update_capa);
- spin_lock(&capa_lock);
- if (rc) {
- DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
- "renew failed: %d", rc);
- ll_capa_renewal_failed++;
- }
- }
-
- if (next)
- update_capa_timer(next, capa_renewal_time(next));
-
- list_for_each_entry_safe(ocapa, tmp, &ll_idle_capas,
- c_list) {
- if (!capa_is_expired(ocapa)) {
- if (!next)
- update_capa_timer(ocapa,
- ocapa->c_expiry);
- break;
- }
-
- if (atomic_read(&ocapa->c_refc) > 1) {
- DEBUG_CAPA(D_SEC, &ocapa->c_capa,
- "expired(c_refc %d), don't release",
- atomic_read(&ocapa->c_refc));
- /* don't try to renew any more */
- list_del_init(&ocapa->c_list);
- continue;
- }
-
- /* expired capa is released. */
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "release expired");
- ll_delete_capa(ocapa);
- }
-
- spin_unlock(&capa_lock);
- }
-
- thread_set_flags(&ll_capa_thread, SVC_STOPPED);
- wake_up(&ll_capa_thread.t_ctl_waitq);
- return 0;
-}
-
-void ll_capa_timer_callback(unsigned long unused)
-{
- wake_up(&ll_capa_thread.t_ctl_waitq);
-}
-
-int ll_capa_thread_start(void)
-{
- struct task_struct *task;
-
- init_waitqueue_head(&ll_capa_thread.t_ctl_waitq);
-
- task = kthread_run(capa_thread_main, NULL, "ll_capa");
- if (IS_ERR(task)) {
- CERROR("cannot start expired capa thread: rc %ld\n",
- PTR_ERR(task));
- return PTR_ERR(task);
- }
- wait_event(ll_capa_thread.t_ctl_waitq,
- thread_is_running(&ll_capa_thread));
-
- return 0;
-}
-
-void ll_capa_thread_stop(void)
-{
- thread_set_flags(&ll_capa_thread, SVC_STOPPING);
- wake_up(&ll_capa_thread.t_ctl_waitq);
- wait_event(ll_capa_thread.t_ctl_waitq,
- thread_is_stopped(&ll_capa_thread));
-}
-
-struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_capa *ocapa;
- int found = 0;
-
- if ((ll_i2sbi(inode)->ll_flags & LL_SBI_OSS_CAPA) == 0)
- return NULL;
-
- LASSERT(opc == CAPA_OPC_OSS_WRITE || opc == CAPA_OPC_OSS_RW ||
- opc == CAPA_OPC_OSS_TRUNC);
-
- spin_lock(&capa_lock);
- list_for_each_entry(ocapa, &lli->lli_oss_capas, u.cli.lli_list) {
- if (capa_is_expired(ocapa))
- continue;
- if ((opc & CAPA_OPC_OSS_WRITE) &&
- capa_opc_supported(&ocapa->c_capa, CAPA_OPC_OSS_WRITE)) {
- found = 1;
- break;
- } else if ((opc & CAPA_OPC_OSS_READ) &&
- capa_opc_supported(&ocapa->c_capa,
- CAPA_OPC_OSS_READ)) {
- found = 1;
- break;
- } else if ((opc & CAPA_OPC_OSS_TRUNC) &&
- capa_opc_supported(&ocapa->c_capa, opc)) {
- found = 1;
- break;
- }
- }
-
- if (found) {
- LASSERT(lu_fid_eq(capa_fid(&ocapa->c_capa),
- ll_inode2fid(inode)));
- LASSERT(ocapa->c_site == CAPA_SITE_CLIENT);
-
- capa_get(ocapa);
-
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "found client");
- } else {
- ocapa = NULL;
-
- if (atomic_read(&ll_capa_debug)) {
- CERROR("no capability for "DFID" opc %#llx\n",
- PFID(&lli->lli_fid), opc);
- atomic_set(&ll_capa_debug, 0);
- }
- }
- spin_unlock(&capa_lock);
-
- return ocapa;
-}
-EXPORT_SYMBOL(ll_osscapa_get);
-
-struct obd_capa *ll_mdscapa_get(struct inode *inode)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_capa *ocapa;
-
- LASSERT(inode != NULL);
-
- if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0)
- return NULL;
-
- spin_lock(&capa_lock);
- ocapa = capa_get(lli->lli_mds_capa);
- spin_unlock(&capa_lock);
- if (!ocapa && atomic_read(&ll_capa_debug)) {
- CERROR("no mds capability for "DFID"\n", PFID(&lli->lli_fid));
- atomic_set(&ll_capa_debug, 0);
- }
-
- return ocapa;
-}
-
-static struct obd_capa *do_add_mds_capa(struct inode *inode,
- struct obd_capa *ocapa)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_capa *old = lli->lli_mds_capa;
- struct lustre_capa *capa = &ocapa->c_capa;
-
- if (!old) {
- ocapa->u.cli.inode = inode;
- lli->lli_mds_capa = ocapa;
- capa_count[CAPA_SITE_CLIENT]++;
-
- DEBUG_CAPA(D_SEC, capa, "add MDS");
- } else {
- spin_lock(&old->c_lock);
- old->c_capa = *capa;
- spin_unlock(&old->c_lock);
-
- DEBUG_CAPA(D_SEC, capa, "update MDS");
-
- capa_put(ocapa);
- ocapa = old;
- }
- return ocapa;
-}
-
-static struct obd_capa *do_lookup_oss_capa(struct inode *inode, int opc)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_capa *ocapa;
-
- /* inside capa_lock */
- list_for_each_entry(ocapa, &lli->lli_oss_capas, u.cli.lli_list) {
- if ((capa_opc(&ocapa->c_capa) & opc) != opc)
- continue;
-
- LASSERT(lu_fid_eq(capa_fid(&ocapa->c_capa),
- ll_inode2fid(inode)));
- LASSERT(ocapa->c_site == CAPA_SITE_CLIENT);
-
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "found client");
- return ocapa;
- }
-
- return NULL;
-}
-
-static inline void inode_add_oss_capa(struct inode *inode,
- struct obd_capa *ocapa)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_capa *tmp;
- struct list_head *next = NULL;
-
- /* capa is sorted in lli_oss_capas so lookup can always find the
- * latest one */
- list_for_each_entry(tmp, &lli->lli_oss_capas, u.cli.lli_list) {
- if (cfs_time_after(ocapa->c_expiry, tmp->c_expiry)) {
- next = &tmp->u.cli.lli_list;
- break;
- }
- }
- LASSERT(&ocapa->u.cli.lli_list != next);
- list_move_tail(&ocapa->u.cli.lli_list, next ?: &lli->lli_oss_capas);
-}
-
-static struct obd_capa *do_add_oss_capa(struct inode *inode,
- struct obd_capa *ocapa)
-{
- struct obd_capa *old;
- struct lustre_capa *capa = &ocapa->c_capa;
-
- LASSERTF(S_ISREG(inode->i_mode),
- "inode has oss capa, but not regular file, mode: %d\n",
- inode->i_mode);
-
- /* FIXME: can't replace it so easily with fine-grained opc */
- old = do_lookup_oss_capa(inode, capa_opc(capa) & CAPA_OPC_OSS_ONLY);
- if (!old) {
- ocapa->u.cli.inode = inode;
- INIT_LIST_HEAD(&ocapa->u.cli.lli_list);
- capa_count[CAPA_SITE_CLIENT]++;
-
- DEBUG_CAPA(D_SEC, capa, "add OSS");
- } else {
- spin_lock(&old->c_lock);
- old->c_capa = *capa;
- spin_unlock(&old->c_lock);
-
- DEBUG_CAPA(D_SEC, capa, "update OSS");
-
- capa_put(ocapa);
- ocapa = old;
- }
-
- inode_add_oss_capa(inode, ocapa);
- return ocapa;
-}
-
-struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa)
-{
- spin_lock(&capa_lock);
- ocapa = capa_for_mds(&ocapa->c_capa) ? do_add_mds_capa(inode, ocapa) :
- do_add_oss_capa(inode, ocapa);
-
- /* truncate capa won't renew */
- if (ocapa->c_capa.lc_opc != CAPA_OPC_OSS_TRUNC) {
- set_capa_expiry(ocapa);
- list_del_init(&ocapa->c_list);
- sort_add_capa(ocapa, ll_capa_list);
-
- update_capa_timer(ocapa, capa_renewal_time(ocapa));
- }
-
- spin_unlock(&capa_lock);
-
- atomic_set(&ll_capa_debug, 1);
- return ocapa;
-}
-
-static inline void delay_capa_renew(struct obd_capa *oc, unsigned long delay)
-{
- /* NB: set a fake expiry for this capa to prevent it renew too soon */
- oc->c_expiry = cfs_time_add(oc->c_expiry, cfs_time_seconds(delay));
-}
-
-static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
-{
- struct inode *inode = ocapa->u.cli.inode;
- int rc = 0;
-
- LASSERT(ocapa);
-
- if (IS_ERR(capa)) {
- /* set error code */
- rc = PTR_ERR(capa);
- spin_lock(&capa_lock);
- if (rc == -ENOENT) {
- DEBUG_CAPA(D_SEC, &ocapa->c_capa,
- "renewal canceled because object removed");
- ll_capa_renewal_noent++;
- } else {
- ll_capa_renewal_failed++;
-
- /* failed capa won't be renewed any longer, but if -EIO,
- * client might be doing recovery, retry in 2 min. */
- if (rc == -EIO && !capa_is_expired(ocapa)) {
- delay_capa_renew(ocapa, 120);
- DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
- "renewal failed: -EIO, retry in 2 mins");
- ll_capa_renewal_retries++;
- goto retry;
- } else {
- DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
- "renewal failed(rc: %d) for", rc);
- }
- }
-
- list_del_init(&ocapa->c_list);
- sort_add_capa(ocapa, &ll_idle_capas);
- spin_unlock(&capa_lock);
-
- capa_put(ocapa);
- iput(inode);
- return rc;
- }
-
- spin_lock(&ocapa->c_lock);
- LASSERT(!memcmp(&ocapa->c_capa, capa,
- offsetof(struct lustre_capa, lc_opc)));
- ocapa->c_capa = *capa;
- set_capa_expiry(ocapa);
- spin_unlock(&ocapa->c_lock);
-
- spin_lock(&capa_lock);
- if (capa_for_oss(capa))
- inode_add_oss_capa(inode, ocapa);
- DEBUG_CAPA(D_SEC, capa, "renew");
-retry:
- list_del_init(&ocapa->c_list);
- sort_add_capa(ocapa, ll_capa_list);
- update_capa_timer(ocapa, capa_renewal_time(ocapa));
- spin_unlock(&capa_lock);
-
- capa_put(ocapa);
- iput(inode);
- return rc;
-}
-
-void ll_capa_open(struct inode *inode)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
-
- if ((ll_i2sbi(inode)->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
- == 0)
- return;
-
- if (!S_ISREG(inode->i_mode))
- return;
-
- atomic_inc(&lli->lli_open_count);
-}
-
-void ll_capa_close(struct inode *inode)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
-
- if ((ll_i2sbi(inode)->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
- == 0)
- return;
-
- if (!S_ISREG(inode->i_mode))
- return;
-
- atomic_dec(&lli->lli_open_count);
-}
-
-/* delete CAPA_OPC_OSS_TRUNC only */
-void ll_truncate_free_capa(struct obd_capa *ocapa)
-{
- if (!ocapa)
- return;
-
- LASSERT(ocapa->c_capa.lc_opc & CAPA_OPC_OSS_TRUNC);
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free truncate");
-
- /* release ref when find */
- capa_put(ocapa);
- if (likely(ocapa->c_capa.lc_opc == CAPA_OPC_OSS_TRUNC)) {
- spin_lock(&capa_lock);
- ll_delete_capa(ocapa);
- spin_unlock(&capa_lock);
- }
-}
-
-void ll_clear_inode_capas(struct inode *inode)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct obd_capa *ocapa, *tmp;
-
- spin_lock(&capa_lock);
- ocapa = lli->lli_mds_capa;
- if (ocapa)
- ll_delete_capa(ocapa);
-
- list_for_each_entry_safe(ocapa, tmp, &lli->lli_oss_capas,
- u.cli.lli_list)
- ll_delete_capa(ocapa);
- spin_unlock(&capa_lock);
-}
-
-void ll_print_capa_stat(struct ll_sb_info *sbi)
-{
- if (sbi->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
- LCONSOLE_INFO("Fid capabilities renewed: %llu\n"
- "Fid capabilities renewal ENOENT: %llu\n"
- "Fid capabilities failed to renew: %llu\n"
- "Fid capabilities renewal retries: %llu\n",
- ll_capa_renewed, ll_capa_renewal_noent,
- ll_capa_renewal_failed, ll_capa_renewal_retries);
-}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/llite_close.c b/kernel/drivers/staging/lustre/lustre/llite/llite_close.c
index a94ba02cc..3f348a3aa 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/llite_close.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/llite_close.c
@@ -221,7 +221,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data)
inode->i_ino, inode->i_generation,
lli->lli_flags);
- OBDO_ALLOC(oa);
+ oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
if (!oa) {
CERROR("can't allocate memory for Size-on-MDS update.\n");
return -ENOMEM;
@@ -252,7 +252,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data)
NULL, 0, NULL, 0, &request, NULL);
ptlrpc_req_finished(request);
- OBDO_FREE(oa);
+ kmem_cache_free(obdo_cachep, oa);
return rc;
}
@@ -293,19 +293,18 @@ static void ll_done_writing(struct inode *inode)
goto out;
rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, NULL);
- if (rc == -EAGAIN) {
+ if (rc == -EAGAIN)
/* MDS has instructed us to obtain Size-on-MDS attribute from
* OSTs and send setattr to back to MDS. */
rc = ll_som_update(inode, op_data);
- } else if (rc) {
+ else if (rc)
CERROR("inode %lu mdc done_writing failed: rc = %d\n",
inode->i_ino, rc);
- }
out:
ll_finish_md_op_data(op_data);
if (och) {
md_clear_open_replay_data(ll_i2sbi(inode)->ll_md_exp, och);
- OBD_FREE_PTR(och);
+ kfree(och);
}
}
@@ -374,7 +373,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
task = kthread_run(ll_close_thread, lcq, "ll_close");
if (IS_ERR(task)) {
- OBD_FREE(lcq, sizeof(*lcq));
+ kfree(lcq);
return PTR_ERR(task);
}
@@ -389,5 +388,5 @@ void ll_close_thread_shutdown(struct ll_close_queue *lcq)
atomic_inc(&lcq->lcq_stop);
wake_up(&lcq->lcq_waitq);
wait_for_completion(&lcq->lcq_comp);
- OBD_FREE(lcq, sizeof(*lcq));
+ kfree(lcq);
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/llite_internal.h b/kernel/drivers/staging/lustre/lustre/llite/llite_internal.h
index 5f918e3c4..9096d311e 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -57,12 +57,6 @@
#define VM_FAULT_RETRY 0
#endif
-/* Kernel 3.1 kills LOOKUP_CONTINUE, LOOKUP_PARENT is equivalent to it.
- * seem kernel commit 49084c3bb2055c401f3493c13edae14d49128ca0 */
-#ifndef LOOKUP_CONTINUE
-#define LOOKUP_CONTINUE LOOKUP_PARENT
-#endif
-
/** Only used on client-side for indicating the tail of dir hash/offset. */
#define LL_DIR_END_OFF 0x7fffffffffffffffULL
#define LL_DIR_END_OFF_32BIT 0x7fffffffUL
@@ -77,7 +71,7 @@ struct ll_dentry_data {
struct rcu_head lld_rcu_head;
};
-#define ll_d2d(de) ((struct ll_dentry_data*)((de)->d_fsdata))
+#define ll_d2d(de) ((struct ll_dentry_data *)((de)->d_fsdata))
#define LLI_INODE_MAGIC 0x111d0de5
#define LLI_INODE_DEAD 0xdeadd00d
@@ -140,11 +134,9 @@ struct ll_inode_info {
struct lu_fid lli_pfid;
struct list_head lli_close_list;
- struct list_head lli_oss_capas;
/* open count currently used by capability only, indicate whether
* capability needs renewal */
atomic_t lli_open_count;
- struct obd_capa *lli_mds_capa;
unsigned long lli_rmtperm_time;
/* handle is to be sent to MDS later on done_writing and setattr.
@@ -404,8 +396,8 @@ enum stats_track_type {
#define LL_SBI_USER_XATTR 0x08 /* support user xattr */
#define LL_SBI_ACL 0x10 /* support ACL */
#define LL_SBI_RMT_CLIENT 0x40 /* remote client */
-#define LL_SBI_MDS_CAPA 0x80 /* support mds capa */
-#define LL_SBI_OSS_CAPA 0x100 /* support oss capa */
+#define LL_SBI_MDS_CAPA 0x80 /* support mds capa, obsolete */
+#define LL_SBI_OSS_CAPA 0x100 /* support oss capa, obsolete */
#define LL_SBI_LOCALFLOCK 0x200 /* Local flocks support by kernel */
#define LL_SBI_LRU_RESIZE 0x400 /* lru resize support */
#define LL_SBI_LAZYSTATFS 0x800 /* lazystatfs mount option */
@@ -462,7 +454,6 @@ struct eacl_table {
};
struct ll_sb_info {
- struct list_head ll_list;
/* this protects pglist and ra_info. It isn't safe to
* grab from interrupt contexts */
spinlock_t ll_lock;
@@ -471,7 +462,7 @@ struct ll_sb_info {
struct obd_uuid ll_sb_uuid;
struct obd_export *ll_md_exp;
struct obd_export *ll_dt_exp;
- struct proc_dir_entry* ll_proc_root;
+ struct dentry *ll_debugfs_entry;
struct lu_fid ll_root_fid; /* root object fid */
int ll_flags;
@@ -493,9 +484,6 @@ struct ll_sb_info {
unsigned int ll_namelen;
struct file_operations *ll_fop;
- /* =0 - hold lock over whole read/write
- * >0 - max. chunk to be read/written w/o lock re-acquiring */
- unsigned long ll_max_rw_chunk;
unsigned int ll_md_brw_size; /* used by readdir */
struct lu_site *ll_site;
@@ -524,10 +512,11 @@ struct ll_sb_info {
struct rmtacl_ctl_table ll_rct;
struct eacl_table ll_et;
__kernel_fsid_t ll_fsid;
+ struct kobject ll_kobj; /* sysfs object */
+ struct super_block *ll_sb; /* struct super_block (for sysfs code)*/
+ struct completion ll_kobj_unregister;
};
-#define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024)
-
struct ll_ra_read {
pgoff_t lrr_start;
pgoff_t lrr_count;
@@ -644,7 +633,8 @@ struct lov_stripe_md;
extern spinlock_t inode_lock;
-extern struct proc_dir_entry *proc_lustre_fs_root;
+extern struct dentry *llite_root;
+extern struct kset *llite_kset;
static inline struct inode *ll_info2i(struct ll_inode_info *lli)
{
@@ -667,33 +657,16 @@ static inline int ll_need_32bit_api(struct ll_sb_info *sbi)
void ll_ra_read_in(struct file *f, struct ll_ra_read *rar);
void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
-struct ll_ra_read *ll_ra_read_get(struct file *f);
/* llite/lproc_llite.c */
-#if defined (CONFIG_PROC_FS)
-int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
- struct super_block *sb, char *osc, char *mdc);
-void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
+int ldebugfs_register_mountpoint(struct dentry *parent,
+ struct super_block *sb, char *osc, char *mdc);
+void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi);
void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars);
void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
struct ll_file_data *file, loff_t pos,
size_t count, int rw);
-#else
-static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
- struct super_block *sb, char *osc, char *mdc){return 0;}
-static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
-static inline
-void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
-static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
- struct ll_file_data *file, loff_t pos,
- size_t count, int rw) {}
-#endif
-
/* llite/dir.c */
void ll_release_page(struct page *page, int remove);
@@ -714,7 +687,6 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash,
int ll_md_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
void *data, int flag);
struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de);
-int ll_rmdir_entry(struct inode *dir, char *name, int namelen);
/* llite/rw.c */
int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
@@ -727,22 +699,18 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io,
struct ll_readahead_state *ras, struct address_space *mapping,
struct cl_page_list *queue, int flags);
-#ifndef MS_HAS_NEW_AOPS
extern const struct address_space_operations ll_aops;
-#else
-extern const struct address_space_operations_ext ll_aops;
-#endif
/* llite/file.c */
extern struct file_operations ll_file_operations;
extern struct file_operations ll_file_operations_flock;
extern struct file_operations ll_file_operations_noflock;
extern struct inode_operations ll_file_inode_operations;
-extern int ll_have_md_lock(struct inode *inode, __u64 *bits,
- ldlm_mode_t l_req_mode);
-extern ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
- struct lustre_handle *lockh, __u64 flags,
- ldlm_mode_t mode);
+int ll_have_md_lock(struct inode *inode, __u64 *bits,
+ ldlm_mode_t l_req_mode);
+ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
+ struct lustre_handle *lockh, __u64 flags,
+ ldlm_mode_t mode);
int ll_file_open(struct inode *inode, struct file *file);
int ll_file_release(struct inode *inode, struct file *file);
int ll_glimpse_ioctl(struct ll_sb_info *sbi,
@@ -819,8 +787,6 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
int ll_obd_statfs(struct inode *inode, void *arg);
int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
-int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *max_cookiesize);
-int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *default_cookiesize);
int ll_process_config(struct lustre_cfg *lcfg);
struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
struct inode *i1, struct inode *i2,
@@ -829,6 +795,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
void ll_finish_md_op_data(struct md_op_data *op_data);
int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg);
char *ll_get_fsname(struct super_block *sb, char *buf, int buflen);
+void ll_open_cleanup(struct super_block *sb, struct ptlrpc_request *open_req);
/* llite/llite_nfs.c */
extern struct export_operations lustre_export_operations;
@@ -851,7 +818,6 @@ struct ll_close_queue {
struct ccc_object *cl_inode2ccc(struct inode *inode);
-
void vvp_write_pending (struct ccc_object *club, struct ccc_page *page);
void vvp_write_complete(struct ccc_object *club, struct ccc_page *page);
@@ -878,7 +844,7 @@ struct vvp_io {
* Inode modification time that is checked across DLM
* lock request.
*/
- time_t ft_mtime;
+ time64_t ft_mtime;
struct vm_area_struct *ft_vma;
/**
* locked page returned from vvp_io
@@ -1028,6 +994,7 @@ static inline struct obd_export *ll_s2mdexp(struct super_block *sb)
static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
{
struct obd_device *obd = sbi->ll_md_exp->exp_obd;
+
if (obd == NULL)
LBUG();
return &obd->u.cli;
@@ -1080,25 +1047,6 @@ void free_rmtperm_hash(struct hlist_head *hash);
int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm);
int lustre_check_remote_perm(struct inode *inode, int mask);
-/* llite/llite_capa.c */
-extern struct timer_list ll_capa_timer;
-
-int ll_capa_thread_start(void);
-void ll_capa_thread_stop(void);
-void ll_capa_timer_callback(unsigned long unused);
-
-struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa);
-
-void ll_capa_open(struct inode *inode);
-void ll_capa_close(struct inode *inode);
-
-struct obd_capa *ll_mdscapa_get(struct inode *inode);
-struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc);
-
-void ll_truncate_free_capa(struct obd_capa *ocapa);
-void ll_clear_inode_capas(struct inode *inode);
-void ll_print_capa_stat(struct ll_sb_info *sbi);
-
/* llite/llite_cl.c */
extern struct lu_device_type vvp_device_type;
@@ -1324,7 +1272,6 @@ typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd);
void ll_iocontrol_unregister(void *magic);
-
/* lclient compat stuff */
#define cl_inode_info ll_inode_info
#define cl_i2info(info) ll_i2info(info)
@@ -1372,8 +1319,6 @@ static inline int cl_merge_lvb(const struct lu_env *env, struct inode *inode)
#define cl_inode_ctime(inode) LTIME_S((inode)->i_ctime)
#define cl_inode_mtime(inode) LTIME_S((inode)->i_mtime)
-struct obd_capa *cl_capa_lookup(struct inode *inode, enum cl_req_type crt);
-
int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
enum cl_fsync_mode mode, int ignore_layout);
@@ -1403,9 +1348,9 @@ static inline void cl_stats_tally(struct cl_device *dev, enum cl_req_type crt,
ll_stats_ops_tally(ll_s2sbi(cl2ccc_dev(dev)->cdv_sb), opc, rc);
}
-extern ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
- int rw, struct inode *inode,
- struct ll_dio_pages *pv);
+ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
+ int rw, struct inode *inode,
+ struct ll_dio_pages *pv);
static inline int ll_file_nolock(const struct file *file)
{
@@ -1493,7 +1438,15 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
spin_lock_nested(&dentry->d_lock,
nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
__d_lustre_invalidate(dentry);
- if (d_count(dentry) == 0)
+ /*
+ * We should be careful about dentries created by d_obtain_alias().
+ * These dentries are not put in the dentry tree, instead they are
+ * linked to sb->s_anon through dentry->d_hash.
+ * shrink_dcache_for_umount() shrinks the tree and sb->s_anon list.
+ * If we unhashed such a dentry, unmount would not be able to find
+ * it and busy inodes would be reported.
+ */
+ if (d_count(dentry) == 0 && !(dentry->d_flags & DCACHE_DISCONNECTED))
__d_drop(dentry);
spin_unlock(&dentry->d_lock);
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/llite_lib.c b/kernel/drivers/staging/lustre/lustre/llite/llite_lib.c
index a27af7882..4a8c759fe 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -57,16 +57,14 @@
#include "llite_internal.h"
struct kmem_cache *ll_file_data_slab;
-struct proc_dir_entry *proc_lustre_fs_root;
-
-static LIST_HEAD(ll_super_blocks);
-static DEFINE_SPINLOCK(ll_sb_lock);
+struct dentry *llite_root;
+struct kset *llite_kset;
#ifndef log2
#define log2(n) ffz(~(n))
#endif
-static struct ll_sb_info *ll_init_sbi(void)
+static struct ll_sb_info *ll_init_sbi(struct super_block *sb)
{
struct ll_sb_info *sbi = NULL;
unsigned long pages;
@@ -111,10 +109,6 @@ static struct ll_sb_info *ll_init_sbi(void)
class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
CDEBUG(D_CONFIG, "generated uuid: %s\n", sbi->ll_sb_uuid.uuid);
- spin_lock(&ll_sb_lock);
- list_add_tail(&sbi->ll_list, &ll_super_blocks);
- spin_unlock(&ll_sb_lock);
-
sbi->ll_flags |= LL_SBI_VERBOSE;
sbi->ll_flags |= LL_SBI_CHECKSUM;
@@ -134,6 +128,8 @@ static struct ll_sb_info *ll_init_sbi(void)
atomic_set(&sbi->ll_agl_total, 0);
sbi->ll_flags |= LL_SBI_AGL_ENABLED;
+ sbi->ll_sb = sb;
+
return sbi;
}
@@ -141,12 +137,7 @@ static void ll_free_sbi(struct super_block *sb)
{
struct ll_sb_info *sbi = ll_s2sbi(sb);
- if (sbi != NULL) {
- spin_lock(&ll_sb_lock);
- list_del(&sbi->ll_list);
- spin_unlock(&ll_sb_lock);
- OBD_FREE(sbi, sizeof(*sbi));
- }
+ kfree(sbi);
}
static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
@@ -155,7 +146,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
struct inode *root = NULL;
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct obd_device *obd;
- struct obd_capa *oc = NULL;
struct obd_statfs *osfs = NULL;
struct ptlrpc_request *request = NULL;
struct obd_connect_data *data = NULL;
@@ -177,22 +167,20 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
osfs = kzalloc(sizeof(*osfs), GFP_NOFS);
if (!osfs) {
- OBD_FREE_PTR(data);
+ kfree(data);
return -ENOMEM;
}
- if (proc_lustre_fs_root) {
- err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
- dt, md);
+ if (llite_root != NULL) {
+ err = ldebugfs_register_mountpoint(llite_root, sb, dt, md);
if (err < 0)
- CERROR("could not register mount in /proc/fs/lustre\n");
+ CERROR("could not register mount in <debugfs>/lustre/llite\n");
}
/* indicate the features supported by this client */
data->ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_NODEVOH |
OBD_CONNECT_ATTRFID |
OBD_CONNECT_VERSION | OBD_CONNECT_BRW_SIZE |
- OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA |
OBD_CONNECT_CANCELSET | OBD_CONNECT_FID |
OBD_CONNECT_AT | OBD_CONNECT_LOV_V3 |
OBD_CONNECT_RMT_CLIENT | OBD_CONNECT_VBR |
@@ -227,14 +215,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (sbi->ll_flags & LL_SBI_USER_XATTR)
data->ocd_connect_flags |= OBD_CONNECT_XATTR;
-#ifdef HAVE_MS_FLOCK_LOCK
- /* force vfs to use lustre handler for flock() calls - bug 10743 */
- sb->s_flags |= MS_FLOCK_LOCK;
-#endif
-#ifdef MS_HAS_NEW_AOPS
- sb->s_flags |= MS_HAS_NEW_AOPS;
-#endif
-
if (sbi->ll_flags & LL_SBI_FLOCK)
sbi->ll_fop = &ll_file_operations_flock;
else if (sbi->ll_flags & LL_SBI_LOCALFLOCK)
@@ -292,11 +272,15 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
char *buf;
buf = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
+ if (!buf) {
+ err = -ENOMEM;
+ goto out_md_fid;
+ }
obd_connect_flags2str(buf, PAGE_CACHE_SIZE,
valid ^ CLIENT_CONNECT_MDT_REQD, ",");
LCONSOLE_ERROR_MSG(0x170, "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n",
sbi->ll_md_exp->exp_obd->obd_name, buf);
- OBD_FREE(buf, PAGE_CACHE_SIZE);
+ kfree(buf);
err = -EPROTO;
goto out_md_fid;
}
@@ -316,7 +300,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
sb->s_magic = LL_SUPER_MAGIC;
sb->s_maxbytes = MAX_LFS_FILESIZE;
sbi->ll_namelen = osfs->os_namelen;
- sbi->ll_max_rw_chunk = LL_DEFAULT_MAX_RW_CHUNK;
if ((sbi->ll_flags & LL_SBI_USER_XATTR) &&
!(data->ocd_connect_flags & OBD_CONNECT_XATTR)) {
@@ -349,16 +332,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
}
}
- if (data->ocd_connect_flags & OBD_CONNECT_MDS_CAPA) {
- LCONSOLE_INFO("client enabled MDS capability!\n");
- sbi->ll_flags |= LL_SBI_MDS_CAPA;
- }
-
- if (data->ocd_connect_flags & OBD_CONNECT_OSS_CAPA) {
- LCONSOLE_INFO("client enabled OSS capability!\n");
- sbi->ll_flags |= LL_SBI_OSS_CAPA;
- }
-
if (data->ocd_connect_flags & OBD_CONNECT_64BITHASH)
sbi->ll_flags |= LL_SBI_64BIT_HASH;
@@ -408,7 +381,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_CKSUM)) {
/* OBD_CONNECT_CKSUM should always be set, even if checksums are
* disabled by default, because it can still be enabled on the
- * fly via /proc. As a consequence, we still need to come to an
+ * fly via /sys. As a consequence, we still need to come to an
* agreement on the supported algorithms at connect time */
data->ocd_connect_flags |= OBD_CONNECT_CKSUM;
@@ -460,7 +433,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
mutex_unlock(&sbi->ll_lco.lco_lock);
fid_zero(&sbi->ll_root_fid);
- err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid, &oc);
+ err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid);
if (err) {
CERROR("cannot mds_connect: rc = %d\n", err);
goto out_lock_cn_cb;
@@ -481,7 +454,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
/* make root inode
* XXX: move this to after cbd setup? */
- valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | OBD_MD_FLMDSCAPA;
+ valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS;
if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
valid |= OBD_MD_FLRMTPERM;
else if (sbi->ll_flags & LL_SBI_ACL)
@@ -495,13 +468,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
op_data->op_fid1 = sbi->ll_root_fid;
op_data->op_mode = 0;
- op_data->op_capa1 = oc;
op_data->op_valid = valid;
err = md_getattr(sbi->ll_md_exp, op_data, &request);
- if (oc)
- capa_put(oc);
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
if (err) {
CERROR("%s: md_getattr failed for root: rc = %d\n",
sbi->ll_md_exp->exp_obd->obd_name, err);
@@ -582,10 +552,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid);
}
- if (data != NULL)
- OBD_FREE_PTR(data);
- if (osfs != NULL)
- OBD_FREE_PTR(osfs);
+ kfree(data);
+ kfree(osfs);
return err;
out_root:
@@ -603,11 +571,9 @@ out_md:
obd_disconnect(sbi->ll_md_exp);
sbi->ll_md_exp = NULL;
out:
- if (data != NULL)
- OBD_FREE_PTR(data);
- if (osfs != NULL)
- OBD_FREE_PTR(osfs);
- lprocfs_unregister_mountpoint(sbi);
+ kfree(data);
+ kfree(osfs);
+ ldebugfs_unregister_mountpoint(sbi);
return err;
}
@@ -638,32 +604,6 @@ int ll_get_default_mdsize(struct ll_sb_info *sbi, int *lmmsize)
return rc;
}
-int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *lmmsize)
-{
- int size, rc;
-
- size = sizeof(int);
- rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_MAX_COOKIESIZE),
- KEY_MAX_COOKIESIZE, &size, lmmsize, NULL);
- if (rc)
- CERROR("Get max cookiesize error rc %d\n", rc);
-
- return rc;
-}
-
-int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *lmmsize)
-{
- int size, rc;
-
- size = sizeof(int);
- rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_DEFAULT_COOKIESIZE),
- KEY_DEFAULT_COOKIESIZE, &size, lmmsize, NULL);
- if (rc)
- CERROR("Get default cookiesize error rc %d\n", rc);
-
- return rc;
-}
-
static void client_common_put_super(struct super_block *sb)
{
struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -688,7 +628,7 @@ static void client_common_put_super(struct super_block *sb)
* see LU-2543. */
obd_zombie_barrier();
- lprocfs_unregister_mountpoint(sbi);
+ ldebugfs_unregister_mountpoint(sbi);
obd_fid_fini(sbi->ll_md_exp->exp_obd);
obd_disconnect(sbi->ll_md_exp);
@@ -857,9 +797,7 @@ void ll_lli_init(struct ll_inode_info *lli)
/* Do not set lli_fid, it has been initialized already. */
fid_zero(&lli->lli_pfid);
INIT_LIST_HEAD(&lli->lli_close_list);
- INIT_LIST_HEAD(&lli->lli_oss_capas);
atomic_set(&lli->lli_open_count, 0);
- lli->lli_mds_capa = NULL;
lli->lli_rmtperm_time = 0;
lli->lli_pending_och = NULL;
lli->lli_mds_read_och = NULL;
@@ -916,8 +854,6 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
char *dt = NULL, *md = NULL;
char *profilenm = get_profile_name(sb);
struct config_llog_instance *cfg;
- /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */
- const int instlen = sizeof(cfg->cfg_instance) * 2 + 2;
int err;
CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
@@ -929,10 +865,10 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
try_module_get(THIS_MODULE);
/* client additional sb info */
- lsi->lsi_llsbi = sbi = ll_init_sbi();
+ lsi->lsi_llsbi = sbi = ll_init_sbi(sb);
if (!sbi) {
module_put(THIS_MODULE);
- OBD_FREE_PTR(cfg);
+ kfree(cfg);
return -ENOMEM;
}
@@ -993,16 +929,14 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
err = client_common_fill_super(sb, md, dt, mnt);
out_free:
- if (md)
- OBD_FREE(md, strlen(lprof->lp_md) + instlen + 2);
- if (dt)
- OBD_FREE(dt, strlen(lprof->lp_dt) + instlen + 2);
+ kfree(md);
+ kfree(dt);
if (err)
ll_put_super(sb);
else if (sbi->ll_flags & LL_SBI_VERBOSE)
LCONSOLE_WARN("Mounted %s\n", profilenm);
- OBD_FREE_PTR(cfg);
+ kfree(cfg);
return err;
} /* ll_fill_super */
@@ -1017,8 +951,6 @@ void ll_put_super(struct super_block *sb)
CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm);
- ll_print_capa_stat(sbi);
-
cfg.cfg_instance = sb;
lustre_end_log(sb, profilenm, &cfg);
@@ -1125,9 +1057,8 @@ void ll_clear_inode(struct inode *inode)
if (lli->lli_mds_read_och)
ll_md_real_close(inode, FMODE_READ);
- if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) {
- OBD_FREE(lli->lli_symlink_name,
- strlen(lli->lli_symlink_name) + 1);
+ if (S_ISLNK(inode->i_mode)) {
+ kfree(lli->lli_symlink_name);
lli->lli_symlink_name = NULL;
}
@@ -1150,7 +1081,6 @@ void ll_clear_inode(struct inode *inode)
#endif
lli->lli_inode_magic = LLI_INODE_DEAD;
- ll_clear_inode_capas(inode);
if (!S_ISDIR(inode->i_mode))
LASSERT(list_empty(&lli->lli_agl_list));
@@ -1162,6 +1092,8 @@ void ll_clear_inode(struct inode *inode)
lli->lli_has_smd = false;
}
+#define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)
+
static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data,
struct md_open_data **mod)
{
@@ -1205,7 +1137,7 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data,
}
ia_valid = op_data->op_attr.ia_valid;
- /* inode size will be in ll_setattr_ost, can't do it now since dirty
+ /* inode size will be in cl_setattr_ost, can't do it now since dirty
* cache is not cleared yet. */
op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE);
rc = simple_setattr(dentry, &op_data->op_attr);
@@ -1241,38 +1173,16 @@ static int ll_setattr_done_writing(struct inode *inode,
ll_pack_inode2opdata(inode, op_data, NULL);
rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, mod);
- if (rc == -EAGAIN) {
+ if (rc == -EAGAIN)
/* MDS has instructed us to obtain Size-on-MDS attribute
* from OSTs and send setattr to back to MDS. */
rc = ll_som_update(inode, op_data);
- } else if (rc) {
+ else if (rc)
CERROR("inode %lu mdc truncate failed: rc = %d\n",
inode->i_ino, rc);
- }
return rc;
}
-static int ll_setattr_ost(struct inode *inode, struct iattr *attr)
-{
- struct obd_capa *capa;
- int rc;
-
- if (attr->ia_valid & ATTR_SIZE)
- capa = ll_osscapa_get(inode, CAPA_OPC_OSS_TRUNC);
- else
- capa = ll_mdscapa_get(inode);
-
- rc = cl_setattr_ost(inode, attr, capa);
-
- if (attr->ia_valid & ATTR_SIZE)
- ll_truncate_free_capa(capa);
- else
- capa_put(capa);
-
- return rc;
-}
-
-
/* If this inode has objects allocated to it (lsm != NULL), then the OST
* object(s) determine the file size and mtime. Otherwise, the MDS will
* keep these values until such a time that objects are allocated for it.
@@ -1347,9 +1257,9 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
}
if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
- CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
+ CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %llu\n",
LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
- get_seconds());
+ (s64)ktime_get_real_seconds());
/* If we are changing file size, file content is modified, flag it. */
if (attr->ia_valid & ATTR_SIZE) {
@@ -1366,11 +1276,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
if (!op_data)
return -ENOMEM;
- if (!S_ISDIR(inode->i_mode)) {
- if (attr->ia_valid & ATTR_SIZE)
- inode_dio_write_done(inode);
+ if (!S_ISDIR(inode->i_mode))
mutex_unlock(&inode->i_mutex);
- }
memcpy(&op_data->op_attr, attr, sizeof(*attr));
@@ -1438,19 +1345,18 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
* time de-synchronization between MDT inode and OST objects */
if (attr->ia_valid & ATTR_SIZE)
down_write(&lli->lli_trunc_sem);
- rc = ll_setattr_ost(inode, attr);
+ rc = cl_setattr_ost(inode, attr);
if (attr->ia_valid & ATTR_SIZE)
up_write(&lli->lli_trunc_sem);
}
out:
- if (op_data) {
- if (op_data->op_ioepoch) {
- rc1 = ll_setattr_done_writing(inode, op_data, mod);
- if (!rc)
- rc = rc1;
- }
- ll_finish_md_op_data(op_data);
+ if (op_data->op_ioepoch) {
+ rc1 = ll_setattr_done_writing(inode, op_data, mod);
+ if (!rc)
+ rc = rc1;
}
+ ll_finish_md_op_data(op_data);
+
if (!S_ISDIR(inode->i_mode)) {
mutex_lock(&inode->i_mutex);
if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
@@ -1542,6 +1448,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
return rc;
}
+
int ll_statfs(struct dentry *de, struct kstatfs *sfs)
{
struct super_block *sb = de->d_sb;
@@ -1731,15 +1638,6 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
inode->i_blocks = body->blocks;
}
- if (body->valid & OBD_MD_FLMDSCAPA) {
- LASSERT(md->mds_capa);
- ll_add_capa(inode, md->mds_capa);
- }
- if (body->valid & OBD_MD_FLOSSCAPA) {
- LASSERT(md->oss_capa);
- ll_add_capa(inode, md->oss_capa);
- }
-
if (body->valid & OBD_MD_TSTATE) {
if (body->t_state & MS_RESTORE)
lli->lli_flags |= LLIF_FILE_RESTORING;
@@ -1850,7 +1748,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
}
case FSFILT_IOC_SETFLAGS: {
struct lov_stripe_md *lsm;
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info oinfo = { };
struct md_op_data *op_data;
if (get_user(flags, (int *)arg))
@@ -1878,7 +1776,8 @@ int ll_iocontrol(struct inode *inode, struct file *file,
return 0;
}
- OBDO_ALLOC(oinfo.oi_oa);
+ oinfo.oi_oa = kmem_cache_alloc(obdo_cachep,
+ GFP_NOFS | __GFP_ZERO);
if (!oinfo.oi_oa) {
ccc_inode_lsm_put(inode, lsm);
return -ENOMEM;
@@ -1888,11 +1787,9 @@ int ll_iocontrol(struct inode *inode, struct file *file,
oinfo.oi_oa->o_flags = flags;
oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS |
OBD_MD_FLGROUP;
- oinfo.oi_capa = ll_mdscapa_get(inode);
obdo_set_parent_fid(oinfo.oi_oa, &ll_i2info(inode)->lli_fid);
rc = obd_setattr_rqset(sbi->ll_dt_exp, &oinfo, NULL);
- capa_put(oinfo.oi_capa);
- OBDO_FREE(oinfo.oi_oa);
+ kmem_cache_free(obdo_cachep, oinfo.oi_oa);
ccc_inode_lsm_put(inode, lsm);
if (rc && rc != -EPERM && rc != -EACCES)
@@ -1957,7 +1854,7 @@ void ll_umount_begin(struct super_block *sb)
obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
sizeof(*ioc_data), ioc_data, NULL);
- OBD_FREE_PTR(ioc_data);
+ kfree(ioc_data);
}
/* Really, we'd like to wait until there are no requests outstanding,
@@ -1999,6 +1896,47 @@ int ll_remount_fs(struct super_block *sb, int *flags, char *data)
return 0;
}
+/**
+ * Cleanup the open handle that is cached on MDT-side.
+ *
+ * For open case, the client side open handling thread may hit error
+ * after the MDT grant the open. Under such case, the client should
+ * send close RPC to the MDT as cleanup; otherwise, the open handle
+ * on the MDT will be leaked there until the client umount or evicted.
+ *
+ * In further, if someone unlinked the file, because the open handle
+ * holds the reference on such file/object, then it will block the
+ * subsequent threads that want to locate such object via FID.
+ *
+ * \param[in] sb super block for this file-system
+ * \param[in] open_req pointer to the original open request
+ */
+void ll_open_cleanup(struct super_block *sb, struct ptlrpc_request *open_req)
+{
+ struct mdt_body *body;
+ struct md_op_data *op_data;
+ struct ptlrpc_request *close_req = NULL;
+ struct obd_export *exp = ll_s2sbi(sb)->ll_md_exp;
+
+ body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY);
+ op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
+ if (!op_data) {
+ CWARN("%s: cannot allocate op_data to release open handle for "
+ DFID "\n",
+ ll_get_fsname(sb, NULL, 0), PFID(&body->fid1));
+
+ return;
+ }
+
+ op_data->op_fid1 = body->fid1;
+ op_data->op_ioepoch = body->ioepoch;
+ op_data->op_handle = body->handle;
+ op_data->op_mod_time = get_seconds();
+ md_close(exp, op_data, NULL, &close_req);
+ ptlrpc_req_finished(close_req);
+ ll_finish_md_op_data(op_data);
+}
+
int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
struct super_block *sb, struct lookup_intent *it)
{
@@ -2011,7 +1949,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
rc = md_get_lustre_md(sbi->ll_md_exp, req, sbi->ll_dt_exp,
sbi->ll_md_exp, &md);
if (rc)
- return rc;
+ goto cleanup;
if (*inode) {
ll_update_inode(*inode, &md);
@@ -2073,6 +2011,11 @@ out:
if (md.lsm != NULL)
obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
md_free_lustre_md(sbi->ll_md_exp, &md);
+
+cleanup:
+ if (rc != 0 && it && it->it_op & IT_OPEN)
+ ll_open_cleanup(sb ? sb : (*inode)->i_sb, req);
+
return rc;
}
@@ -2185,20 +2128,16 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
ll_i2gids(op_data->op_suppgids, i1, i2);
op_data->op_fid1 = *ll_inode2fid(i1);
- op_data->op_capa1 = ll_mdscapa_get(i1);
- if (i2) {
+ if (i2)
op_data->op_fid2 = *ll_inode2fid(i2);
- op_data->op_capa2 = ll_mdscapa_get(i2);
- } else {
+ else
fid_zero(&op_data->op_fid2);
- op_data->op_capa2 = NULL;
- }
op_data->op_name = name;
op_data->op_namelen = namelen;
op_data->op_mode = mode;
- op_data->op_mod_time = get_seconds();
+ op_data->op_mod_time = ktime_get_real_seconds();
op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
op_data->op_cap = cfs_curproc_cap_pack();
@@ -2222,11 +2161,10 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
if (likely(!lli->lli_has_smd && !fid_is_zero(&lli->lli_pfid)))
op_data->op_fid1 = lli->lli_pfid;
spin_unlock(&lli->lli_lock);
- /** We ignore parent's capability temporary. */
}
/* When called by ll_setattr_raw, file is i1. */
- if (LLIF_DATA_MODIFIED & ll_i2info(i1)->lli_flags)
+ if (ll_i2info(i1)->lli_flags & LLIF_DATA_MODIFIED)
op_data->op_bias |= MDS_DATA_MODIFIED;
return op_data;
@@ -2234,9 +2172,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
void ll_finish_md_op_data(struct md_op_data *op_data)
{
- capa_put(op_data->op_capa1);
- capa_put(op_data->op_capa2);
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
}
int ll_show_options(struct seq_file *seq, struct dentry *dentry)
diff --git a/kernel/drivers/staging/lustre/lustre/llite/llite_mmap.c b/kernel/drivers/staging/lustre/lustre/llite/llite_mmap.c
index a90214bb8..7df978371 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -258,8 +258,6 @@ out:
return result;
}
-
-
static inline int to_fault_error(int result)
{
switch (result) {
diff --git a/kernel/drivers/staging/lustre/lustre/llite/llite_nfs.c b/kernel/drivers/staging/lustre/lustre/llite/llite_nfs.c
index db43b8138..e578a1130 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -49,6 +49,7 @@
__u32 get_uuid2int(const char *name, int len)
{
__u32 key0 = 0x12a3fe2d, key1 = 0x37abe8f9;
+
while (len--) {
__u32 key = key1 + (key0 ^ (*name++ * 7152373));
@@ -78,8 +79,7 @@ void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid)
static int ll_nfs_test_inode(struct inode *inode, void *opaque)
{
- return lu_fid_eq(&ll_i2info(inode)->lli_fid,
- (struct lu_fid *)opaque);
+ return lu_fid_eq(&ll_i2info(inode)->lli_fid, opaque);
}
struct inode *search_inode_for_lustre(struct super_block *sb,
@@ -116,7 +116,7 @@ struct inode *search_inode_for_lustre(struct super_block *sb,
/* mds_fid2dentry ignores f_type */
rc = md_getattr(sbi->ll_md_exp, op_data, &req);
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
if (rc) {
CERROR("can't get object attrs, fid "DFID", rc %d\n",
PFID(fid), rc);
@@ -168,11 +168,8 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren
spin_unlock(&lli->lli_lock);
}
+ /* N.B. d_obtain_alias() drops inode ref on error */
result = d_obtain_alias(inode);
- if (IS_ERR(result)) {
- iput(inode);
- return result;
- }
return result;
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/kernel/drivers/staging/lustre/lustre/llite/llite_rmtacl.c
index f4da156f3..b27c3f2fc 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/llite_rmtacl.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/llite_rmtacl.c
@@ -94,7 +94,7 @@ static void rce_free(struct rmtacl_ctl_entry *rce)
if (!list_empty(&rce->rce_list))
list_del(&rce->rce_list);
- OBD_FREE_PTR(rce);
+ kfree(rce);
}
static struct rmtacl_ctl_entry *__rct_search(struct rmtacl_ctl_table *rct,
@@ -178,7 +178,6 @@ void rct_fini(struct rmtacl_ctl_table *rct)
spin_unlock(&rct->rct_lock);
}
-
static struct eacl_entry *ee_alloc(pid_t key, struct lu_fid *fid, int type,
ext_acl_xattr_header *header)
{
@@ -205,7 +204,7 @@ void ee_free(struct eacl_entry *ee)
if (ee->ee_acl)
lustre_ext_acl_xattr_free(ee->ee_acl);
- OBD_FREE_PTR(ee);
+ kfree(ee);
}
static struct eacl_entry *__et_search_del(struct eacl_table *et, pid_t key,
diff --git a/kernel/drivers/staging/lustre/lustre/llite/lloop.c b/kernel/drivers/staging/lustre/lustre/llite/lloop.c
index 413a8408e..fed50d538 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/lloop.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/lloop.c
@@ -162,7 +162,7 @@ static int max_loop = MAX_LOOP_DEFAULT;
static struct lloop_device *loop_dev;
static struct gendisk **disks;
static struct mutex lloop_mutex;
-static void *ll_iocontrol_magic = NULL;
+static void *ll_iocontrol_magic;
static loff_t get_loop_size(struct lloop_device *lo, struct file *file)
{
@@ -315,7 +315,6 @@ static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req)
if (page_count + (*bio)->bi_vcnt > LLOOP_MAX_SEGMENTS)
break;
-
page_count += (*bio)->bi_vcnt;
count++;
bio = &(*bio)->bi_next;
@@ -334,12 +333,14 @@ static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req)
return count;
}
-static void loop_make_request(struct request_queue *q, struct bio *old_bio)
+static blk_qc_t loop_make_request(struct request_queue *q, struct bio *old_bio)
{
struct lloop_device *lo = q->queuedata;
int rw = bio_rw(old_bio);
int inactive;
+ blk_queue_split(q, &old_bio, q->bio_split);
+
if (!lo)
goto err;
@@ -363,20 +364,23 @@ static void loop_make_request(struct request_queue *q, struct bio *old_bio)
goto err;
}
loop_add_bio(lo, old_bio);
- return;
+ return BLK_QC_T_NONE;
err:
- cfs_bio_io_error(old_bio, old_bio->bi_iter.bi_size);
+ bio_io_error(old_bio);
+ return BLK_QC_T_NONE;
}
-
static inline void loop_handle_bio(struct lloop_device *lo, struct bio *bio)
{
int ret;
+
ret = do_bio_lustrebacked(lo, bio);
while (bio) {
struct bio *tmp = bio->bi_next;
+
bio->bi_next = NULL;
- cfs_bio_endio(bio, bio->bi_iter.bi_size, ret);
+ bio->bi_error = ret;
+ bio_endio(bio);
bio = tmp;
}
}
@@ -427,6 +431,7 @@ static int loop_thread(void *data)
wait_event(lo->lo_bh_wait, loop_active(lo));
if (!atomic_read(&lo->lo_pending)) {
int exiting = 0;
+
spin_lock_irq(&lo->lo_lock);
exiting = (lo->lo_state == LLOOP_RUNDOWN);
spin_unlock_irq(&lo->lo_lock);
@@ -840,9 +845,9 @@ out_mem4:
out_mem3:
while (i--)
put_disk(disks[i]);
- OBD_FREE(disks, max_loop * sizeof(*disks));
+ kfree(disks);
out_mem2:
- OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
+ kfree(loop_dev);
out_mem1:
unregister_blkdev(lloop_major, "lloop");
ll_iocontrol_unregister(ll_iocontrol_magic);
@@ -863,8 +868,8 @@ static void lloop_exit(void)
unregister_blkdev(lloop_major, "lloop");
- OBD_FREE(disks, max_loop * sizeof(*disks));
- OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
+ kfree(disks);
+ kfree(loop_dev);
}
module_init(lloop_init);
diff --git a/kernel/drivers/staging/lustre/lustre/llite/lproc_llite.c b/kernel/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 83a9b8547..190fc4411 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -48,31 +48,33 @@ static struct file_operations ll_rw_extents_stats_fops;
static struct file_operations ll_rw_extents_stats_pp_fops;
static struct file_operations ll_rw_offset_stats_fops;
-static int ll_blksize_seq_show(struct seq_file *m, void *v)
+static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%u\n", osfs.os_bsize);
+ return sprintf(buf, "%u\n", osfs.os_bsize);
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_blksize);
+LUSTRE_RO_ATTR(blocksize);
-static int ll_kbytestotal_seq_show(struct seq_file *m, void *v)
+static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
@@ -82,21 +84,22 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ rc = sprintf(buf, "%llu\n", result);
}
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_kbytestotal);
+LUSTRE_RO_ATTR(kbytestotal);
-static int ll_kbytesfree_seq_show(struct seq_file *m, void *v)
+static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
@@ -106,21 +109,22 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ rc = sprintf(buf, "%llu\n", result);
}
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_kbytesfree);
+LUSTRE_RO_ATTR(kbytesfree);
-static int ll_kbytesavail_seq_show(struct seq_file *m, void *v)
+static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
@@ -130,81 +134,79 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ rc = sprintf(buf, "%llu\n", result);
}
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_kbytesavail);
+LUSTRE_RO_ATTR(kbytesavail);
-static int ll_filestotal_seq_show(struct seq_file *m, void *v)
+static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_files);
+ return sprintf(buf, "%llu\n", osfs.os_files);
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_filestotal);
+LUSTRE_RO_ATTR(filestotal);
-static int ll_filesfree_seq_show(struct seq_file *m, void *v)
+static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_ffree);
+ return sprintf(buf, "%llu\n", osfs.os_ffree);
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_filesfree);
+LUSTRE_RO_ATTR(filesfree);
-static int ll_client_type_seq_show(struct seq_file *m, void *v)
+static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- LASSERT(sbi != NULL);
-
- if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
- seq_puts(m, "remote client\n");
- else
- seq_puts(m, "local client\n");
-
- return 0;
+ return sprintf(buf, "%s client\n",
+ sbi->ll_flags & LL_SBI_RMT_CLIENT ? "remote" : "local");
}
-LPROC_SEQ_FOPS_RO(ll_client_type);
+LUSTRE_RO_ATTR(client_type);
-static int ll_fstype_seq_show(struct seq_file *m, void *v)
+static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- LASSERT(sb != NULL);
- seq_printf(m, "%s\n", sb->s_type->name);
- return 0;
+ return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name);
}
-LPROC_SEQ_FOPS_RO(ll_fstype);
+LUSTRE_RO_ATTR(fstype);
-static int ll_sb_uuid_seq_show(struct seq_file *m, void *v)
+static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- LASSERT(sb != NULL);
- seq_printf(m, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
- return 0;
+ return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid);
}
-LPROC_SEQ_FOPS_RO(ll_sb_uuid);
+LUSTRE_RO_ATTR(uuid);
static int ll_site_stats_seq_show(struct seq_file *m, void *v)
{
@@ -216,12 +218,14 @@ static int ll_site_stats_seq_show(struct seq_file *m, void *v)
*/
return cl_site_stats_print(lu2cl_site(ll_s2sbi(sb)->ll_site), m);
}
+
LPROC_SEQ_FOPS_RO(ll_site_stats);
-static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v)
+static ssize_t max_read_ahead_mb_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
long pages_number;
int mult;
@@ -230,23 +234,27 @@ static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v)
spin_unlock(&sbi->ll_lock);
mult = 1 << (20 - PAGE_CACHE_SHIFT);
- return lprocfs_seq_read_frac_helper(m, pages_number, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult);
}
-static ssize_t ll_max_readahead_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_read_ahead_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int mult, rc, pages_number;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
- if (pages_number < 0 || pages_number > totalram_pages / 2) {
+ pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */
+
+ if (pages_number > totalram_pages / 2) {
+
CERROR("can't set file readahead more than %lu MB\n",
totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/
return -ERANGE;
@@ -258,12 +266,14 @@ static ssize_t ll_max_readahead_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_max_readahead_mb);
+LUSTRE_RW_ATTR(max_read_ahead_mb);
-static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v)
+static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
long pages_number;
int mult;
@@ -272,24 +282,24 @@ static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v)
spin_unlock(&sbi->ll_lock);
mult = 1 << (20 - PAGE_CACHE_SHIFT);
- return lprocfs_seq_read_frac_helper(m, pages_number, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult);
}
-static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int mult, rc, pages_number;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
- if (pages_number < 0 ||
- pages_number > sbi->ll_ra_info.ra_max_pages) {
+ if (pages_number > sbi->ll_ra_info.ra_max_pages) {
CERROR("can't set file readahead more than max_read_ahead_mb %lu MB\n",
sbi->ll_ra_info.ra_max_pages);
return -ERANGE;
@@ -301,12 +311,14 @@ static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_max_readahead_per_file_mb);
+LUSTRE_RW_ATTR(max_read_ahead_per_file_mb);
-static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused)
+static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
long pages_number;
int mult;
@@ -315,26 +327,26 @@ static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused)
spin_unlock(&sbi->ll_lock);
mult = 1 << (20 - PAGE_CACHE_SHIFT);
- return lprocfs_seq_read_frac_helper(m, pages_number, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult);
}
-static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int mult, rc, pages_number;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
/* Cap this at the current max readahead window size, the readahead
* algorithm does this anyway so it's pointless to set it larger. */
- if (pages_number < 0 ||
- pages_number > sbi->ll_ra_info.ra_max_pages_per_file) {
+ if (pages_number > sbi->ll_ra_info.ra_max_pages_per_file) {
CERROR("can't set max_read_ahead_whole_mb more than max_read_ahead_per_file_mb: %lu\n",
sbi->ll_ra_info.ra_max_pages_per_file >> (20 - PAGE_CACHE_SHIFT));
return -ERANGE;
@@ -346,7 +358,7 @@ static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_max_read_ahead_whole_mb);
+LUSTRE_RW_ATTR(max_read_ahead_whole_mb);
static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v)
{
@@ -467,30 +479,33 @@ out:
}
return rc;
}
+
LPROC_SEQ_FOPS(ll_max_cached_mb);
-static int ll_checksum_seq_show(struct seq_file *m, void *v)
+static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
- return 0;
+ return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
}
-static ssize_t ll_checksum_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t checksum_pages_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
if (!sbi->ll_dt_exp)
/* Not set up yet */
return -EAGAIN;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
if (val)
@@ -505,154 +520,146 @@ static ssize_t ll_checksum_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_checksum);
-
-static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v)
-{
- struct super_block *sb = m->private;
-
- seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk);
- return 0;
-}
+LUSTRE_RW_ATTR(checksum_pages);
-static ssize_t ll_max_rw_chunk_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t ll_rd_track_id(struct kobject *kobj, char *buf,
+ enum stats_track_type type)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- int rc, val;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
- ll_s2sbi(sb)->ll_max_rw_chunk = val;
- return count;
-}
-LPROC_SEQ_FOPS(ll_max_rw_chunk);
-
-static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type)
-{
- struct super_block *sb = m->private;
-
- if (ll_s2sbi(sb)->ll_stats_track_type == type)
- seq_printf(m, "%d\n", ll_s2sbi(sb)->ll_stats_track_id);
- else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL)
- seq_puts(m, "0 (all)\n");
+ if (sbi->ll_stats_track_type == type)
+ return sprintf(buf, "%d\n", sbi->ll_stats_track_id);
+ else if (sbi->ll_stats_track_type == STATS_TRACK_ALL)
+ return sprintf(buf, "0 (all)\n");
else
- seq_puts(m, "untracked\n");
-
- return 0;
+ return sprintf(buf, "untracked\n");
}
-static int ll_wr_track_id(const char __user *buffer, unsigned long count,
- void *data, enum stats_track_type type)
+static ssize_t ll_wr_track_id(struct kobject *kobj, const char *buffer,
+ size_t count,
+ enum stats_track_type type)
{
- struct super_block *sb = data;
- int rc, pid;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pid;
- rc = lprocfs_write_helper(buffer, count, &pid);
+ rc = kstrtoul(buffer, 10, &pid);
if (rc)
return rc;
- ll_s2sbi(sb)->ll_stats_track_id = pid;
+ sbi->ll_stats_track_id = pid;
if (pid == 0)
- ll_s2sbi(sb)->ll_stats_track_type = STATS_TRACK_ALL;
+ sbi->ll_stats_track_type = STATS_TRACK_ALL;
else
- ll_s2sbi(sb)->ll_stats_track_type = type;
- lprocfs_clear_stats(ll_s2sbi(sb)->ll_stats);
+ sbi->ll_stats_track_type = type;
+ lprocfs_clear_stats(sbi->ll_stats);
return count;
}
-static int ll_track_pid_seq_show(struct seq_file *m, void *v)
+static ssize_t stats_track_pid_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return ll_rd_track_id(m, STATS_TRACK_PID);
+ return ll_rd_track_id(kobj, buf, STATS_TRACK_PID);
}
-static ssize_t ll_track_pid_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t stats_track_pid_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PID);
+ return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PID);
}
-LPROC_SEQ_FOPS(ll_track_pid);
+LUSTRE_RW_ATTR(stats_track_pid);
-static int ll_track_ppid_seq_show(struct seq_file *m, void *v)
+static ssize_t stats_track_ppid_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return ll_rd_track_id(m, STATS_TRACK_PPID);
+ return ll_rd_track_id(kobj, buf, STATS_TRACK_PPID);
}
-static ssize_t ll_track_ppid_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t stats_track_ppid_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PPID);
+ return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PPID);
}
-LPROC_SEQ_FOPS(ll_track_ppid);
+LUSTRE_RW_ATTR(stats_track_ppid);
-static int ll_track_gid_seq_show(struct seq_file *m, void *v)
+static ssize_t stats_track_gid_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return ll_rd_track_id(m, STATS_TRACK_GID);
+ return ll_rd_track_id(kobj, buf, STATS_TRACK_GID);
}
-static ssize_t ll_track_gid_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t stats_track_gid_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_GID);
+ return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_GID);
}
-LPROC_SEQ_FOPS(ll_track_gid);
+LUSTRE_RW_ATTR(stats_track_gid);
-static int ll_statahead_max_seq_show(struct seq_file *m, void *v)
+static ssize_t statahead_max_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", sbi->ll_sa_max);
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_sa_max);
}
-static ssize_t ll_statahead_max_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t statahead_max_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
- if (val >= 0 && val <= LL_SA_RPC_MAX)
+ if (val <= LL_SA_RPC_MAX)
sbi->ll_sa_max = val;
else
- CERROR("Bad statahead_max value %d. Valid values are in the range [0, %d]\n",
+ CERROR("Bad statahead_max value %lu. Valid values are in the range [0, %d]\n",
val, LL_SA_RPC_MAX);
return count;
}
-LPROC_SEQ_FOPS(ll_statahead_max);
+LUSTRE_RW_ATTR(statahead_max);
-static int ll_statahead_agl_seq_show(struct seq_file *m, void *v)
+static ssize_t statahead_agl_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0);
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0);
}
-static ssize_t ll_statahead_agl_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t statahead_agl_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -663,7 +670,7 @@ static ssize_t ll_statahead_agl_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_statahead_agl);
+LUSTRE_RW_ATTR(statahead_agl);
static int ll_statahead_stats_seq_show(struct seq_file *m, void *v)
{
@@ -679,26 +686,30 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v)
atomic_read(&sbi->ll_agl_total));
return 0;
}
+
LPROC_SEQ_FOPS_RO(ll_statahead_stats);
-static int ll_lazystatfs_seq_show(struct seq_file *m, void *v)
+static ssize_t lazystatfs_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0);
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0);
}
-static ssize_t ll_lazystatfs_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t lazystatfs_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -709,12 +720,14 @@ static ssize_t ll_lazystatfs_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_lazystatfs);
+LUSTRE_RW_ATTR(lazystatfs);
-static int ll_max_easize_seq_show(struct seq_file *m, void *v)
+static ssize_t max_easize_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
unsigned int ealen;
int rc;
@@ -722,15 +735,16 @@ static int ll_max_easize_seq_show(struct seq_file *m, void *v)
if (rc)
return rc;
- seq_printf(m, "%u\n", ealen);
- return 0;
+ return sprintf(buf, "%u\n", ealen);
}
-LPROC_SEQ_FOPS_RO(ll_max_easize);
+LUSTRE_RO_ATTR(max_easize);
-static int ll_default_easize_seq_show(struct seq_file *m, void *v)
+static ssize_t default_easize_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
unsigned int ealen;
int rc;
@@ -738,42 +752,9 @@ static int ll_default_easize_seq_show(struct seq_file *m, void *v)
if (rc)
return rc;
- seq_printf(m, "%u\n", ealen);
- return 0;
-}
-LPROC_SEQ_FOPS_RO(ll_default_easize);
-
-static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v)
-{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- unsigned int cookielen;
- int rc;
-
- rc = ll_get_max_cookiesize(sbi, &cookielen);
- if (rc)
- return rc;
-
- seq_printf(m, "%u\n", cookielen);
- return 0;
+ return sprintf(buf, "%u\n", ealen);
}
-LPROC_SEQ_FOPS_RO(ll_max_cookiesize);
-
-static int ll_default_cookiesize_seq_show(struct seq_file *m, void *v)
-{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- unsigned int cookielen;
- int rc;
-
- rc = ll_get_default_cookiesize(sbi, &cookielen);
- if (rc)
- return rc;
-
- seq_printf(m, "%u\n", cookielen);
- return 0;
-}
-LPROC_SEQ_FOPS_RO(ll_default_cookiesize);
+LUSTRE_RO_ATTR(default_easize);
static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
{
@@ -797,28 +778,30 @@ static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
seq_printf(m, "\b\n");
return 0;
}
+
LPROC_SEQ_FOPS_RO(ll_sbi_flags);
-static int ll_xattr_cache_seq_show(struct seq_file *m, void *v)
+static ssize_t xattr_cache_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
-
- seq_printf(m, "%u\n", sbi->ll_xattr_cache_enabled);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_xattr_cache_enabled);
}
-static ssize_t ll_xattr_cache_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t xattr_cache_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- struct super_block *sb = seq->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -832,46 +815,59 @@ static ssize_t ll_xattr_cache_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_xattr_cache);
+LUSTRE_RW_ATTR(xattr_cache);
static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
- { "uuid", &ll_sb_uuid_fops, NULL, 0 },
/* { "mntpt_path", ll_rd_path, 0, 0 }, */
- { "fstype", &ll_fstype_fops, NULL, 0 },
{ "site", &ll_site_stats_fops, NULL, 0 },
- { "blocksize", &ll_blksize_fops, NULL, 0 },
- { "kbytestotal", &ll_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &ll_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &ll_kbytesavail_fops, NULL, 0 },
- { "filestotal", &ll_filestotal_fops, NULL, 0 },
- { "filesfree", &ll_filesfree_fops, NULL, 0 },
- { "client_type", &ll_client_type_fops, NULL, 0 },
/* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */
- { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL },
- { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops,
- NULL },
- { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, NULL },
{ "max_cached_mb", &ll_max_cached_mb_fops, NULL },
- { "checksum_pages", &ll_checksum_fops, NULL },
- { "max_rw_chunk", &ll_max_rw_chunk_fops, NULL },
- { "stats_track_pid", &ll_track_pid_fops, NULL },
- { "stats_track_ppid", &ll_track_ppid_fops, NULL },
- { "stats_track_gid", &ll_track_gid_fops, NULL },
- { "statahead_max", &ll_statahead_max_fops, NULL },
- { "statahead_agl", &ll_statahead_agl_fops, NULL },
{ "statahead_stats", &ll_statahead_stats_fops, NULL, 0 },
- { "lazystatfs", &ll_lazystatfs_fops, NULL },
- { "max_easize", &ll_max_easize_fops, NULL, 0 },
- { "default_easize", &ll_default_easize_fops, NULL, 0 },
- { "max_cookiesize", &ll_max_cookiesize_fops, NULL, 0 },
- { "default_cookiesize", &ll_default_cookiesize_fops, NULL, 0 },
{ "sbi_flags", &ll_sbi_flags_fops, NULL, 0 },
- { "xattr_cache", &ll_xattr_cache_fops, NULL, 0 },
{ NULL }
};
#define MAX_STRING_SIZE 128
+static struct attribute *llite_attrs[] = {
+ &lustre_attr_blocksize.attr,
+ &lustre_attr_kbytestotal.attr,
+ &lustre_attr_kbytesfree.attr,
+ &lustre_attr_kbytesavail.attr,
+ &lustre_attr_filestotal.attr,
+ &lustre_attr_filesfree.attr,
+ &lustre_attr_client_type.attr,
+ &lustre_attr_fstype.attr,
+ &lustre_attr_uuid.attr,
+ &lustre_attr_max_read_ahead_mb.attr,
+ &lustre_attr_max_read_ahead_per_file_mb.attr,
+ &lustre_attr_max_read_ahead_whole_mb.attr,
+ &lustre_attr_checksum_pages.attr,
+ &lustre_attr_stats_track_pid.attr,
+ &lustre_attr_stats_track_ppid.attr,
+ &lustre_attr_stats_track_gid.attr,
+ &lustre_attr_statahead_max.attr,
+ &lustre_attr_statahead_agl.attr,
+ &lustre_attr_lazystatfs.attr,
+ &lustre_attr_max_easize.attr,
+ &lustre_attr_default_easize.attr,
+ &lustre_attr_xattr_cache.attr,
+ NULL,
+};
+
+static void llite_sb_release(struct kobject *kobj)
+{
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ complete(&sbi->ll_kobj_unregister);
+}
+
+static struct kobj_type llite_ktype = {
+ .default_attrs = llite_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = llite_sb_release,
+};
+
static const struct llite_file_opcode {
__u32 opcode;
__u32 type;
@@ -958,24 +954,17 @@ static const char *ra_stat_string[] = {
[RA_STAT_WRONG_GRAB_PAGE] = "wrong page from grab_cache_page",
};
-LPROC_SEQ_FOPS_RO_TYPE(llite, name);
-LPROC_SEQ_FOPS_RO_TYPE(llite, uuid);
-
-int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
- struct super_block *sb, char *osc, char *mdc)
+int ldebugfs_register_mountpoint(struct dentry *parent,
+ struct super_block *sb, char *osc, char *mdc)
{
- struct lprocfs_vars lvars[2];
struct lustre_sb_info *lsi = s2lsi(sb);
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct obd_device *obd;
- struct proc_dir_entry *dir;
+ struct dentry *dir;
char name[MAX_STRING_SIZE + 1], *ptr;
int err, id, len, rc;
- memset(lvars, 0, sizeof(lvars));
-
name[MAX_STRING_SIZE] = '\0';
- lvars[0].name = name;
LASSERT(sbi != NULL);
LASSERT(mdc != NULL);
@@ -991,30 +980,32 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len,
lsi->lsi_lmd->lmd_profile, sb);
- sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
- if (IS_ERR(sbi->ll_proc_root)) {
- err = PTR_ERR(sbi->ll_proc_root);
- sbi->ll_proc_root = NULL;
+ dir = ldebugfs_register(name, parent, NULL, NULL);
+ if (IS_ERR_OR_NULL(dir)) {
+ err = dir ? PTR_ERR(dir) : -ENOMEM;
+ sbi->ll_debugfs_entry = NULL;
return err;
}
+ sbi->ll_debugfs_entry = dir;
- rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444,
- &vvp_dump_pgcache_file_ops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "dump_page_cache", 0444,
+ &vvp_dump_pgcache_file_ops, sbi);
if (rc)
CWARN("Error adding the dump_page_cache file\n");
- rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats", 0644,
- &ll_rw_extents_stats_fops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "extents_stats", 0644,
+ &ll_rw_extents_stats_fops, sbi);
if (rc)
CWARN("Error adding the extent_stats file\n");
- rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats_per_process",
- 0644, &ll_rw_extents_stats_pp_fops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry,
+ "extents_stats_per_process",
+ 0644, &ll_rw_extents_stats_pp_fops, sbi);
if (rc)
CWARN("Error adding the extents_stats_per_process file\n");
- rc = lprocfs_seq_create(sbi->ll_proc_root, "offset_stats", 0644,
- &ll_rw_offset_stats_fops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "offset_stats", 0644,
+ &ll_rw_offset_stats_fops, sbi);
if (rc)
CWARN("Error adding the offset_stats file\n");
@@ -1029,6 +1020,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) {
__u32 type = llite_opcode_table[id].type;
void *ptr = NULL;
+
if (type & LPROCFS_TYPE_REGS)
ptr = "regs";
else if (type & LPROCFS_TYPE_BYTES)
@@ -1040,7 +1032,8 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
(type & LPROCFS_CNTR_AVGMINMAX),
llite_opcode_table[id].opname, ptr);
}
- err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats);
+ err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats",
+ sbi->ll_stats);
if (err)
goto out;
@@ -1054,80 +1047,57 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++)
lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
ra_stat_string[id], "pages");
- err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats",
+
+ err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats",
sbi->ll_ra_stats);
if (err)
goto out;
+ err = ldebugfs_add_vars(sbi->ll_debugfs_entry,
+ lprocfs_llite_obd_vars, sb);
+ if (err)
+ goto out;
- err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb);
+ sbi->ll_kobj.kset = llite_kset;
+ init_completion(&sbi->ll_kobj_unregister);
+ err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL,
+ "%s", name);
if (err)
goto out;
/* MDC info */
obd = class_name2obd(mdc);
- LASSERT(obd != NULL);
- LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(obd->obd_type->typ_name != NULL);
-
- dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
- if (dir == NULL) {
- err = -ENOMEM;
- goto out;
- }
-
- snprintf(name, MAX_STRING_SIZE, "common_name");
- lvars[0].fops = &llite_name_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
- if (err)
- goto out;
-
- snprintf(name, MAX_STRING_SIZE, "uuid");
- lvars[0].fops = &llite_uuid_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
+ err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj,
+ obd->obd_type->typ_name);
if (err)
goto out;
/* OSC */
obd = class_name2obd(osc);
- LASSERT(obd != NULL);
- LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(obd->obd_type->typ_name != NULL);
-
- dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
- if (dir == NULL) {
- err = -ENOMEM;
- goto out;
- }
-
- snprintf(name, MAX_STRING_SIZE, "common_name");
- lvars[0].fops = &llite_name_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
- if (err)
- goto out;
-
- snprintf(name, MAX_STRING_SIZE, "uuid");
- lvars[0].fops = &llite_uuid_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
+ err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj,
+ obd->obd_type->typ_name);
out:
if (err) {
- lprocfs_remove(&sbi->ll_proc_root);
+ ldebugfs_remove(&sbi->ll_debugfs_entry);
lprocfs_free_stats(&sbi->ll_ra_stats);
lprocfs_free_stats(&sbi->ll_stats);
}
return err;
}
-void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi)
+void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi)
{
- if (sbi->ll_proc_root) {
- lprocfs_remove(&sbi->ll_proc_root);
+ if (sbi->ll_debugfs_entry) {
+ ldebugfs_remove(&sbi->ll_debugfs_entry);
+ kobject_put(&sbi->ll_kobj);
+ wait_for_completion(&sbi->ll_kobj_unregister);
lprocfs_free_stats(&sbi->ll_ra_stats);
lprocfs_free_stats(&sbi->ll_stats);
}
}
+
#undef MAX_STRING_SIZE
#define pct(a, b) (b ? a * 100 / b : 0)
@@ -1174,20 +1144,20 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v)
{
- struct timeval now;
+ struct timespec64 now;
struct ll_sb_info *sbi = seq->private;
struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
int k;
- do_gettimeofday(&now);
+ ktime_get_real_ts64(&now);
if (!sbi->ll_rw_stats_on) {
seq_printf(seq, "disabled\n"
"write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n");
return 0;
}
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
- now.tv_sec, (unsigned long)now.tv_usec);
+ seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n",
+ (s64)now.tv_sec, (unsigned long)now.tv_nsec);
seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write");
seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n",
"extents", "calls", "%", "cum%",
@@ -1253,19 +1223,19 @@ LPROC_SEQ_FOPS(ll_rw_extents_stats_pp);
static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v)
{
- struct timeval now;
+ struct timespec64 now;
struct ll_sb_info *sbi = seq->private;
struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
- do_gettimeofday(&now);
+ ktime_get_real_ts64(&now);
if (!sbi->ll_rw_stats_on) {
seq_printf(seq, "disabled\n"
"write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n");
return 0;
}
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
- now.tv_sec, (unsigned long)now.tv_usec);
+ seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n",
+ (u64)now.tv_sec, (unsigned long)now.tv_nsec);
seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write");
seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n",
@@ -1322,6 +1292,7 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file,
return len;
}
+
LPROC_SEQ_FOPS(ll_rw_extents_stats);
void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
@@ -1359,8 +1330,9 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
lprocfs_oh_clear(&io_extents->pp_extents[cur].pp_w_hist);
}
- for(i = 0; (count >= (1 << LL_HIST_START << i)) &&
- (i < (LL_HIST_MAX - 1)); i++);
+ for (i = 0; (count >= (1 << LL_HIST_START << i)) &&
+ (i < (LL_HIST_MAX - 1)); i++)
+ ;
if (rw == 0) {
io_extents->pp_extents[cur].pp_r_hist.oh_buckets[i]++;
io_extents->pp_extents[LL_PROCESS_HIST_MAX].pp_r_hist.oh_buckets[i]++;
@@ -1429,13 +1401,13 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v)
{
- struct timeval now;
+ struct timespec64 now;
struct ll_sb_info *sbi = seq->private;
struct ll_rw_process_info *offset = sbi->ll_rw_offset_info;
struct ll_rw_process_info *process = sbi->ll_rw_process_info;
int i;
- do_gettimeofday(&now);
+ ktime_get_real_ts64(&now);
if (!sbi->ll_rw_stats_on) {
seq_printf(seq, "disabled\n"
@@ -1444,8 +1416,8 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v)
}
spin_lock(&sbi->ll_process_lock);
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
- now.tv_sec, (unsigned long)now.tv_usec);
+ seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n",
+ (s64)now.tv_sec, (unsigned long)now.tv_nsec);
seq_printf(seq, "%3s %10s %14s %14s %17s %17s %14s\n",
"R/W", "PID", "RANGE START", "RANGE END",
"SMALLEST EXTENT", "LARGEST EXTENT", "OFFSET");
@@ -1531,6 +1503,5 @@ LPROC_SEQ_FOPS(ll_rw_offset_stats);
void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = NULL;
lvars->obd_vars = lprocfs_llite_obd_vars;
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/namei.c b/kernel/drivers/staging/lustre/lustre/llite/namei.c
index 5a25dcd10..2ca22001a 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/namei.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/namei.c
@@ -100,7 +100,6 @@ static int ll_set_inode(struct inode *inode, void *opaque)
return 0;
}
-
/*
* Get an inode by inode number (already instantiated by the intent lookup).
* Returns inode or NULL
@@ -144,10 +143,9 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash,
static void ll_invalidate_negative_children(struct inode *dir)
{
struct dentry *dentry, *tmp_subdir;
- struct ll_d_hlist_node *p;
ll_lock_dcache(dir);
- ll_d_hlist_for_each_entry(dentry, p, &dir->i_dentry, d_u.d_alias) {
+ hlist_for_each_entry(dentry, &dir->i_dentry, d_u.d_alias) {
spin_lock(&dentry->d_lock);
if (!list_empty(&dentry->d_subdirs)) {
struct dentry *child;
@@ -334,15 +332,14 @@ void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2)
static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry)
{
struct dentry *alias, *discon_alias, *invalid_alias;
- struct ll_d_hlist_node *p;
- if (ll_d_hlist_empty(&inode->i_dentry))
+ if (hlist_empty(&inode->i_dentry))
return NULL;
discon_alias = invalid_alias = NULL;
ll_lock_dcache(inode);
- ll_d_hlist_for_each_entry(alias, p, &inode->i_dentry, d_u.d_alias) {
+ hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
LASSERT(alias != dentry);
spin_lock(&alias->d_lock);
@@ -411,7 +408,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
{
struct inode *inode = NULL;
__u64 bits = 0;
- int rc;
+ int rc = 0;
/* NB 1 request reference will be taken away by ll_intent_lock()
* when I return */
@@ -441,8 +438,10 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
struct dentry *alias;
alias = ll_splice_alias(inode, *de);
- if (IS_ERR(alias))
- return PTR_ERR(alias);
+ if (IS_ERR(alias)) {
+ rc = PTR_ERR(alias);
+ goto out;
+ }
*de = alias;
} else if (!it_disposition(it, DISP_LOOKUP_NEG) &&
!it_disposition(it, DISP_OPEN_CREATE)) {
@@ -473,7 +472,11 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
}
}
- return 0;
+out:
+ if (rc != 0 && it->it_op & IT_OPEN)
+ ll_open_cleanup((*de)->d_sb, request);
+
+ return rc;
}
static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
@@ -665,12 +668,11 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
out_release:
ll_intent_release(it);
- OBD_FREE(it, sizeof(*it));
+ kfree(it);
return rc;
}
-
/* We depend on "mode" being set with the proper file type/umask by now */
static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
{
@@ -690,7 +692,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
goto out;
}
- LASSERT(ll_d_hlist_empty(&inode->i_dentry));
+ LASSERT(hlist_empty(&inode->i_dentry));
/* We asked for a lock on the directory, but were granted a
* lock on the inode. Since we finally have an inode pointer,
@@ -866,34 +868,6 @@ static inline void ll_get_child_fid(struct dentry *child, struct lu_fid *fid)
*fid = *ll_inode2fid(d_inode(child));
}
-/**
- * Remove dir entry
- **/
-int ll_rmdir_entry(struct inode *dir, char *name, int namelen)
-{
- struct ptlrpc_request *request = NULL;
- struct md_op_data *op_data;
- int rc;
-
- CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
- namelen, name, dir->i_ino, dir->i_generation, dir);
-
- op_data = ll_prep_md_op_data(NULL, dir, NULL, name, strlen(name),
- S_IFDIR, LUSTRE_OPC_ANY, NULL);
- if (IS_ERR(op_data))
- return PTR_ERR(op_data);
- op_data->op_cli_flags |= CLI_RM_ENTRY;
- rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request);
- ll_finish_md_op_data(op_data);
- if (rc == 0) {
- ll_update_times(request, dir);
- ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_RMDIR, 1);
- }
-
- ptlrpc_req_finished(request);
- return rc;
-}
-
int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
{
struct mdt_body *body;
@@ -901,7 +875,6 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
struct lov_stripe_md *lsm = NULL;
struct obd_trans_info oti = { 0 };
struct obdo *oa;
- struct obd_capa *oc = NULL;
int rc;
/* req is swabbed so this is safe */
@@ -930,7 +903,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
}
LASSERT(rc >= sizeof(*lsm));
- OBDO_ALLOC(oa);
+ oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
if (oa == NULL) {
rc = -ENOMEM;
goto out_free_memmd;
@@ -953,21 +926,14 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
}
}
- if (body->valid & OBD_MD_FLOSSCAPA) {
- rc = md_unpack_capa(ll_i2mdexp(dir), request, &RMF_CAPA2, &oc);
- if (rc)
- goto out_free_memmd;
- }
-
rc = obd_destroy(NULL, ll_i2dtexp(dir), oa, lsm, &oti,
- ll_i2mdexp(dir), oc);
- capa_put(oc);
+ ll_i2mdexp(dir));
if (rc)
CERROR("obd destroy objid "DOSTID" error %d\n",
POSTID(&lsm->lsm_oi), rc);
out_free_memmd:
obd_free_memmd(ll_i2dtexp(dir), &lsm);
- OBDO_FREE(oa);
+ kmem_cache_free(obdo_cachep, oa);
out:
return rc;
}
@@ -1008,7 +974,7 @@ static int ll_unlink(struct inode *dir, struct dentry *dentry)
return rc;
}
-static int ll_mkdir(struct inode *dir, struct dentry *dentry, ll_umode_t mode)
+static int ll_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
int err;
diff --git a/kernel/drivers/staging/lustre/lustre/llite/remote_perm.c b/kernel/drivers/staging/lustre/lustre/llite/remote_perm.c
index a58182600..fe4a72268 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/remote_perm.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/remote_perm.c
@@ -54,14 +54,14 @@
#include "../include/lustre_param.h"
#include "llite_internal.h"
-struct kmem_cache *ll_remote_perm_cachep = NULL;
-struct kmem_cache *ll_rmtperm_hash_cachep = NULL;
+struct kmem_cache *ll_remote_perm_cachep;
+struct kmem_cache *ll_rmtperm_hash_cachep;
static inline struct ll_remote_perm *alloc_ll_remote_perm(void)
{
struct ll_remote_perm *lrp;
- OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, GFP_KERNEL);
+ lrp = kmem_cache_alloc(ll_remote_perm_cachep, GFP_KERNEL | __GFP_ZERO);
if (lrp)
INIT_HLIST_NODE(&lrp->lrp_list);
return lrp;
@@ -74,7 +74,7 @@ static inline void free_ll_remote_perm(struct ll_remote_perm *lrp)
if (!hlist_unhashed(&lrp->lrp_list))
hlist_del(&lrp->lrp_list);
- OBD_SLAB_FREE(lrp, ll_remote_perm_cachep, sizeof(*lrp));
+ kmem_cache_free(ll_remote_perm_cachep, lrp);
}
static struct hlist_head *alloc_rmtperm_hash(void)
@@ -82,9 +82,7 @@ static struct hlist_head *alloc_rmtperm_hash(void)
struct hlist_head *hash;
int i;
- OBD_SLAB_ALLOC_GFP(hash, ll_rmtperm_hash_cachep,
- REMOTE_PERM_HASHSIZE * sizeof(*hash),
- GFP_IOFS);
+ hash = kmem_cache_alloc(ll_rmtperm_hash_cachep, GFP_NOFS | __GFP_ZERO);
if (!hash)
return NULL;
@@ -104,11 +102,9 @@ void free_rmtperm_hash(struct hlist_head *hash)
return;
for (i = 0; i < REMOTE_PERM_HASHSIZE; i++)
- hlist_for_each_entry_safe(lrp, next, hash + i,
- lrp_list)
+ hlist_for_each_entry_safe(lrp, next, hash + i, lrp_list)
free_ll_remote_perm(lrp);
- OBD_SLAB_FREE(hash, ll_rmtperm_hash_cachep,
- REMOTE_PERM_HASHSIZE * sizeof(*hash));
+ kmem_cache_free(ll_rmtperm_hash_cachep, hash);
}
static inline int remote_perm_hashfunc(uid_t uid)
@@ -117,7 +113,8 @@ static inline int remote_perm_hashfunc(uid_t uid)
}
/* NB: setxid permission is not checked here, instead it's done on
- * MDT when client get remote permission. */
+ * MDT when client get remote permission.
+ */
static int do_check_remote_perm(struct ll_inode_info *lli, int mask)
{
struct hlist_head *head;
@@ -184,7 +181,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm)
if (!lli->lli_remote_perms) {
perm_hash = alloc_rmtperm_hash();
- if (perm_hash == NULL) {
+ if (!perm_hash) {
CERROR("alloc lli_remote_perms failed!\n");
return -ENOMEM;
}
@@ -249,7 +246,6 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ptlrpc_request *req = NULL;
struct mdt_remote_perm *perm;
- struct obd_capa *oc;
unsigned long save;
int i = 0, rc;
@@ -276,10 +272,8 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
LBUG();
}
- oc = ll_mdscapa_get(inode);
- rc = md_get_remote_perm(sbi->ll_md_exp, ll_inode2fid(inode), oc,
+ rc = md_get_remote_perm(sbi->ll_md_exp, ll_inode2fid(inode),
ll_i2suppgid(inode), &req);
- capa_put(oc);
if (rc) {
mutex_unlock(&lli->lli_rmtperm_mutex);
break;
@@ -287,7 +281,7 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
perm = req_capsule_server_swab_get(&req->rq_pill, &RMF_ACL,
lustre_swab_mdt_remote_perm);
- if (unlikely(perm == NULL)) {
+ if (unlikely(!perm)) {
mutex_unlock(&lli->lli_rmtperm_mutex);
rc = -EPROTO;
break;
@@ -321,8 +315,7 @@ void ll_free_remote_perms(struct inode *inode)
spin_lock(&lli->lli_lock);
for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) {
- hlist_for_each_entry_safe(lrp, node, next, hash + i,
- lrp_list)
+ hlist_for_each_entry_safe(lrp, node, next, hash + i, lrp_list)
free_ll_remote_perm(lrp);
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/rw.c b/kernel/drivers/staging/lustre/lustre/llite/rw.c
index 991d20c50..f79193fa2 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/rw.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/rw.c
@@ -277,14 +277,6 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from,
return result;
}
-struct obd_capa *cl_capa_lookup(struct inode *inode, enum cl_req_type crt)
-{
- __u64 opc;
-
- opc = crt == CRT_WRITE ? CAPA_OPC_OSS_WRITE : CAPA_OPC_OSS_RW;
- return ll_osscapa_get(inode, opc);
-}
-
static void ll_ra_stats_inc_sbi(struct ll_sb_info *sbi, enum ra_stat which);
/**
@@ -335,6 +327,7 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi,
* the RPC boundary from needing an extra read RPC. */
if (ria->ria_pages == 0) {
long beyond_rpc = (ria->ria_start + ret) % PTLRPC_MAX_BRW_PAGES;
+
if (/* beyond_rpc != 0 && */ beyond_rpc < ret)
ret -= beyond_rpc;
}
@@ -351,6 +344,7 @@ out:
void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len)
{
struct ll_ra_info *ra = &sbi->ll_ra_info;
+
atomic_sub(len, &ra->ra_cur_pages);
}
@@ -363,6 +357,7 @@ static void ll_ra_stats_inc_sbi(struct ll_sb_info *sbi, enum ra_stat which)
void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which)
{
struct ll_sb_info *sbi = ll_i2sbi(mapping->host);
+
ll_ra_stats_inc_sbi(sbi, which);
}
@@ -425,30 +420,6 @@ void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar)
spin_unlock(&ras->ras_lock);
}
-static struct ll_ra_read *ll_ra_read_get_locked(struct ll_readahead_state *ras)
-{
- struct ll_ra_read *scan;
-
- list_for_each_entry(scan, &ras->ras_read_beads, lrr_linkage) {
- if (scan->lrr_reader == current)
- return scan;
- }
- return NULL;
-}
-
-struct ll_ra_read *ll_ra_read_get(struct file *f)
-{
- struct ll_readahead_state *ras;
- struct ll_ra_read *bead;
-
- ras = ll_ras_get(f);
-
- spin_lock(&ras->ras_lock);
- bead = ll_ra_read_get_locked(ras);
- spin_unlock(&ras->ras_lock);
- return bead;
-}
-
static int cl_read_ahead_page(const struct lu_env *env, struct cl_io *io,
struct cl_page_list *queue, struct cl_page *page,
struct page *vmpage)
@@ -557,6 +528,7 @@ static inline int stride_io_mode(struct ll_readahead_state *ras)
{
return ras->ras_consecutive_stride_requests > 1;
}
+
/* The function calculates how much pages will be read in
* [off, off + length], in such stride IO area,
* stride_offset = st_off, stride_length = st_len,
@@ -656,7 +628,7 @@ static int ll_read_ahead_pages(const struct lu_env *env,
page_idx, mapping);
if (rc == 1) {
(*reserved_pages)--;
- count ++;
+ count++;
} else if (rc == -ENOLCK)
break;
} else if (stride_ria) {
@@ -890,7 +862,7 @@ static void ras_update_stride_detector(struct ll_readahead_state *ras,
if (!stride_io_mode(ras) && (stride_gap != 0 ||
ras->ras_consecutive_stride_requests == 0)) {
ras->ras_stride_pages = ras->ras_consecutive_pages;
- ras->ras_stride_length = stride_gap +ras->ras_consecutive_pages;
+ ras->ras_stride_length = stride_gap+ras->ras_consecutive_pages;
}
LASSERT(ras->ras_request_index == 0);
LASSERT(ras->ras_consecutive_stride_requests == 0);
@@ -902,7 +874,7 @@ static void ras_update_stride_detector(struct ll_readahead_state *ras,
}
ras->ras_stride_pages = ras->ras_consecutive_pages;
- ras->ras_stride_length = stride_gap +ras->ras_consecutive_pages;
+ ras->ras_stride_length = stride_gap+ras->ras_consecutive_pages;
RAS_CDEBUG(ras);
return;
diff --git a/kernel/drivers/staging/lustre/lustre/llite/rw26.c b/kernel/drivers/staging/lustre/lustre/llite/rw26.c
index c6c824356..3da4c01e2 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/rw26.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/rw26.c
@@ -200,12 +200,12 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr,
*max_pages = (user_addr + size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
*max_pages -= user_addr >> PAGE_CACHE_SHIFT;
- OBD_ALLOC_LARGE(*pages, *max_pages * sizeof(**pages));
+ *pages = libcfs_kvzalloc(*max_pages * sizeof(**pages), GFP_NOFS);
if (*pages) {
result = get_user_pages_fast(user_addr, *max_pages,
(rw == READ), *pages);
if (unlikely(result <= 0))
- OBD_FREE_LARGE(*pages, *max_pages * sizeof(**pages));
+ kvfree(*pages);
}
return result;
@@ -418,6 +418,7 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter,
result = iov_iter_get_pages_alloc(iter, &pages, count, &offs);
if (likely(result > 0)) {
int n = DIV_ROUND_UP(result + offs, PAGE_SIZE);
+
result = ll_direct_IO_26_seg(env, io, iov_iter_rw(iter),
inode, file->f_mapping,
result, file_offset, pages,
@@ -517,7 +518,6 @@ static int ll_migratepage(struct address_space *mapping,
}
#endif
-#ifndef MS_HAS_NEW_AOPS
const struct address_space_operations ll_aops = {
.readpage = ll_readpage,
.direct_IO = ll_direct_IO_26,
@@ -532,22 +532,3 @@ const struct address_space_operations ll_aops = {
.migratepage = ll_migratepage,
#endif
};
-#else
-const struct address_space_operations_ext ll_aops = {
- .orig_aops.readpage = ll_readpage,
-/* .orig_aops.readpages = ll_readpages, */
- .orig_aops.direct_IO = ll_direct_IO_26,
- .orig_aops.writepage = ll_writepage,
- .orig_aops.writepages = ll_writepages,
- .orig_aops.set_page_dirty = ll_set_page_dirty,
- .orig_aops.prepare_write = ll_prepare_write,
- .orig_aops.commit_write = ll_commit_write,
- .orig_aops.invalidatepage = ll_invalidatepage,
- .orig_aops.releasepage = ll_releasepage,
-#ifdef CONFIG_MIGRATION
- .orig_aops.migratepage = ll_migratepage,
-#endif
- .write_begin = ll_write_begin,
- .write_end = ll_write_end
-};
-#endif
diff --git a/kernel/drivers/staging/lustre/lustre/llite/statahead.c b/kernel/drivers/staging/lustre/lustre/llite/statahead.c
index 7f8071242..18f5f2b7e 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/statahead.c
@@ -312,7 +312,7 @@ static void ll_sa_entry_cleanup(struct ll_statahead_info *sai,
entry->se_minfo = NULL;
ll_intent_release(&minfo->mi_it);
iput(minfo->mi_dir);
- OBD_FREE_PTR(minfo);
+ kfree(minfo);
}
if (req) {
@@ -336,7 +336,7 @@ static void ll_sa_entry_put(struct ll_statahead_info *sai,
ll_sa_entry_cleanup(sai, entry);
iput(entry->se_inode);
- OBD_FREE(entry, entry->se_size);
+ kfree(entry);
atomic_dec(&sai->sai_cache_count);
}
}
@@ -544,7 +544,7 @@ static void ll_sai_put(struct ll_statahead_info *sai)
LASSERT(agl_list_empty(sai));
iput(inode);
- OBD_FREE_PTR(sai);
+ kfree(sai);
}
}
@@ -659,7 +659,7 @@ static void ll_post_statahead(struct ll_statahead_info *sai)
* revalidate.
*/
/* unlinked and re-created with the same name */
- if (unlikely(!lu_fid_eq(&minfo->mi_data.op_fid2, &body->fid1))){
+ if (unlikely(!lu_fid_eq(&minfo->mi_data.op_fid2, &body->fid1))) {
entry->se_inode = NULL;
iput(child);
child = NULL;
@@ -772,7 +772,7 @@ out:
if (rc != 0) {
ll_intent_release(it);
iput(dir);
- OBD_FREE_PTR(minfo);
+ kfree(minfo);
}
if (sai != NULL)
ll_sai_put(sai);
@@ -784,25 +784,16 @@ static void sa_args_fini(struct md_enqueue_info *minfo,
{
LASSERT(minfo && einfo);
iput(minfo->mi_dir);
- capa_put(minfo->mi_data.op_capa1);
- capa_put(minfo->mi_data.op_capa2);
- OBD_FREE_PTR(minfo);
- OBD_FREE_PTR(einfo);
+ kfree(minfo);
+ kfree(einfo);
}
/**
- * There is race condition between "capa_put" and "ll_statahead_interpret" for
- * accessing "op_data.op_capa[1,2]" as following:
- * "capa_put" releases "op_data.op_capa[1,2]"'s reference count after calling
- * "md_intent_getattr_async". But "ll_statahead_interpret" maybe run first, and
- * fill "op_data.op_capa[1,2]" as POISON, then cause "capa_put" access invalid
- * "ocapa". So here reserve "op_data.op_capa[1,2]" in "pcapa" before calling
- * "md_intent_getattr_async".
+ * prepare arguments for async stat RPC.
*/
static int sa_args_init(struct inode *dir, struct inode *child,
struct ll_sa_entry *entry, struct md_enqueue_info **pmi,
- struct ldlm_enqueue_info **pei,
- struct obd_capa **pcapa)
+ struct ldlm_enqueue_info **pei)
{
struct qstr *qstr = &entry->se_qstr;
struct ll_inode_info *lli = ll_i2info(dir);
@@ -816,15 +807,15 @@ static int sa_args_init(struct inode *dir, struct inode *child,
minfo = kzalloc(sizeof(*minfo), GFP_NOFS);
if (!minfo) {
- OBD_FREE_PTR(einfo);
+ kfree(einfo);
return -ENOMEM;
}
op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child, qstr->name,
qstr->len, 0, LUSTRE_OPC_ANY, NULL);
if (IS_ERR(op_data)) {
- OBD_FREE_PTR(einfo);
- OBD_FREE_PTR(minfo);
+ kfree(einfo);
+ kfree(minfo);
return PTR_ERR(op_data);
}
@@ -843,8 +834,6 @@ static int sa_args_init(struct inode *dir, struct inode *child,
*pmi = minfo;
*pei = einfo;
- pcapa[0] = op_data->op_capa1;
- pcapa[1] = op_data->op_capa2;
return 0;
}
@@ -853,20 +842,15 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry)
{
struct md_enqueue_info *minfo;
struct ldlm_enqueue_info *einfo;
- struct obd_capa *capas[2];
int rc;
- rc = sa_args_init(dir, NULL, entry, &minfo, &einfo, capas);
+ rc = sa_args_init(dir, NULL, entry, &minfo, &einfo);
if (rc)
return rc;
rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo);
- if (!rc) {
- capa_put(capas[0]);
- capa_put(capas[1]);
- } else {
+ if (rc < 0)
sa_args_fini(minfo, einfo);
- }
return rc;
}
@@ -885,7 +869,6 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry,
.d.lustre.it_lock_handle = 0 };
struct md_enqueue_info *minfo;
struct ldlm_enqueue_info *einfo;
- struct obd_capa *capas[2];
int rc;
if (unlikely(inode == NULL))
@@ -903,7 +886,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry,
return 1;
}
- rc = sa_args_init(dir, inode, entry, &minfo, &einfo, capas);
+ rc = sa_args_init(dir, inode, entry, &minfo, &einfo);
if (rc) {
entry->se_inode = NULL;
iput(inode);
@@ -911,10 +894,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry,
}
rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo);
- if (!rc) {
- capa_put(capas[0]);
- capa_put(capas[1]);
- } else {
+ if (rc < 0) {
entry->se_inode = NULL;
iput(inode);
sa_args_fini(minfo, einfo);
@@ -967,7 +947,7 @@ static void ll_statahead_one(struct dentry *parent, const char *entry_name,
static int ll_agl_thread(void *arg)
{
- struct dentry *parent = (struct dentry *)arg;
+ struct dentry *parent = arg;
struct inode *dir = d_inode(parent);
struct ll_inode_info *plli = ll_i2info(dir);
struct ll_inode_info *clli;
@@ -1058,7 +1038,7 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
static int ll_statahead_thread(void *arg)
{
- struct dentry *parent = (struct dentry *)arg;
+ struct dentry *parent = arg;
struct inode *dir = d_inode(parent);
struct ll_inode_info *plli = ll_i2info(dir);
struct ll_inode_info *clli;
@@ -1215,7 +1195,7 @@ do_it:
while (1) {
l_wait_event(thread->t_ctl_waitq,
!sa_received_empty(sai) ||
- sai->sai_sent == sai->sai_replied||
+ sai->sai_sent == sai->sai_replied ||
!thread_is_running(thread),
&lwi);
@@ -1719,8 +1699,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
return -EAGAIN;
out:
- if (sai != NULL)
- OBD_FREE_PTR(sai);
+ kfree(sai);
spin_lock(&lli->lli_sa_lock);
lli->lli_opendir_key = NULL;
lli->lli_opendir_pid = 0;
diff --git a/kernel/drivers/staging/lustre/lustre/llite/super25.c b/kernel/drivers/staging/lustre/lustre/llite/super25.c
index a494f6271..013136860 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/super25.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/super25.c
@@ -51,8 +51,9 @@ static struct kmem_cache *ll_inode_cachep;
static struct inode *ll_alloc_inode(struct super_block *sb)
{
struct ll_inode_info *lli;
+
ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1);
- OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, GFP_NOFS);
+ lli = kmem_cache_alloc(ll_inode_cachep, GFP_NOFS | __GFP_ZERO);
if (lli == NULL)
return NULL;
@@ -64,7 +65,8 @@ static void ll_inode_destroy_callback(struct rcu_head *head)
{
struct inode *inode = container_of(head, struct inode, i_rcu);
struct ll_inode_info *ptr = ll_i2info(inode);
- OBD_SLAB_FREE_PTR(ptr, ll_inode_cachep);
+
+ kmem_cache_free(ll_inode_cachep, ptr);
}
static void ll_destroy_inode(struct inode *inode)
@@ -89,9 +91,8 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
static int __init init_lustre_lite(void)
{
- struct proc_dir_entry *entry;
lnet_process_id_t lnet_id;
- struct timeval tv;
+ struct timespec64 ts;
int i, rc, seed[2];
CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1);
@@ -128,15 +129,18 @@ static int __init init_lustre_lite(void)
if (ll_rmtperm_hash_cachep == NULL)
goto out_cache;
- entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL);
- if (IS_ERR(entry)) {
- rc = PTR_ERR(entry);
- CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n",
- rc);
+ llite_root = debugfs_create_dir("llite", debugfs_lustre_root);
+ if (IS_ERR_OR_NULL(llite_root)) {
+ rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM;
+ llite_root = NULL;
goto out_cache;
}
- proc_lustre_fs_root = entry;
+ llite_kset = kset_create_and_add("llite", NULL, lustre_kobj);
+ if (!llite_kset) {
+ rc = -ENOMEM;
+ goto out_debugfs;
+ }
cfs_get_random_bytes(seed, sizeof(seed));
@@ -150,16 +154,12 @@ static int __init init_lustre_lite(void)
seed[0] ^= LNET_NIDADDR(lnet_id.nid);
}
- do_gettimeofday(&tv);
- cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
- setup_timer(&ll_capa_timer, ll_capa_timer_callback, 0);
- rc = ll_capa_thread_start();
- if (rc != 0)
- goto out_proc;
+ ktime_get_ts64(&ts);
+ cfs_srand(ts.tv_sec ^ seed[0], ts.tv_nsec ^ seed[1]);
rc = vvp_global_init();
if (rc != 0)
- goto out_capa;
+ goto out_sysfs;
rc = ll_xattr_init();
if (rc != 0)
@@ -173,24 +173,15 @@ static int __init init_lustre_lite(void)
out_vvp:
vvp_global_fini();
-out_capa:
- del_timer(&ll_capa_timer);
- ll_capa_thread_stop();
-out_proc:
- lprocfs_remove(&proc_lustre_fs_root);
+out_sysfs:
+ kset_unregister(llite_kset);
+out_debugfs:
+ debugfs_remove(llite_root);
out_cache:
- if (ll_inode_cachep != NULL)
- kmem_cache_destroy(ll_inode_cachep);
-
- if (ll_file_data_slab != NULL)
- kmem_cache_destroy(ll_file_data_slab);
-
- if (ll_remote_perm_cachep != NULL)
- kmem_cache_destroy(ll_remote_perm_cachep);
-
- if (ll_rmtperm_hash_cachep != NULL)
- kmem_cache_destroy(ll_rmtperm_hash_cachep);
-
+ kmem_cache_destroy(ll_inode_cachep);
+ kmem_cache_destroy(ll_file_data_slab);
+ kmem_cache_destroy(ll_remote_perm_cachep);
+ kmem_cache_destroy(ll_rmtperm_hash_cachep);
return rc;
}
@@ -200,15 +191,11 @@ static void __exit exit_lustre_lite(void)
lustre_register_kill_super_cb(NULL);
lustre_register_client_process_config(NULL);
- lprocfs_remove(&proc_lustre_fs_root);
+ debugfs_remove(llite_root);
+ kset_unregister(llite_kset);
ll_xattr_fini();
vvp_global_fini();
- del_timer(&ll_capa_timer);
- ll_capa_thread_stop();
- LASSERTF(capa_count[CAPA_SITE_CLIENT] == 0,
- "client remaining capa count %d\n",
- capa_count[CAPA_SITE_CLIENT]);
kmem_cache_destroy(ll_inode_cachep);
kmem_cache_destroy(ll_rmtperm_hash_cachep);
diff --git a/kernel/drivers/staging/lustre/lustre/llite/symlink.c b/kernel/drivers/staging/lustre/lustre/llite/symlink.c
index 3711e671a..69b203651 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/symlink.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/symlink.c
@@ -118,7 +118,7 @@ failed:
return rc;
}
-static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
+static const char *ll_follow_link(struct dentry *dentry, void **cookie)
{
struct inode *inode = d_inode(dentry);
struct ptlrpc_request *request = NULL;
@@ -126,32 +126,22 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
char *symname = NULL;
CDEBUG(D_VFSTRACE, "VFS Op\n");
- /* Limit the recursive symlink depth to 5 instead of default
- * 8 links when kernel has 4k stack to prevent stack overflow.
- * For 8k stacks we need to limit it to 7 for local servers. */
- if (THREAD_SIZE < 8192 && current->link_count >= 6) {
- rc = -ELOOP;
- } else if (THREAD_SIZE == 8192 && current->link_count >= 8) {
- rc = -ELOOP;
- } else {
- ll_inode_size_lock(inode);
- rc = ll_readlink_internal(inode, &request, &symname);
- ll_inode_size_unlock(inode);
- }
+ ll_inode_size_lock(inode);
+ rc = ll_readlink_internal(inode, &request, &symname);
+ ll_inode_size_unlock(inode);
if (rc) {
ptlrpc_req_finished(request);
- request = NULL;
- symname = ERR_PTR(rc);
+ return ERR_PTR(rc);
}
- nd_set_link(nd, symname);
/* symname may contain a pointer to the request message buffer,
* we delay request releasing until ll_put_link then.
*/
- return request;
+ *cookie = request;
+ return symname;
}
-static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
+static void ll_put_link(struct inode *unused, void *cookie)
{
ptlrpc_req_finished(cookie);
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/vvp_dev.c b/kernel/drivers/staging/lustre/lustre/llite/vvp_dev.c
index fde41d7c5..d16d6cfce 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -40,7 +40,6 @@
#define DEBUG_SUBSYSTEM S_LLITE
-
#include "../include/obd.h"
#include "../include/lustre_lite.h"
#include "llite_internal.h"
@@ -80,7 +79,7 @@ static void *vvp_key_init(const struct lu_context *ctx,
{
struct vvp_thread_info *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, vvp_thread_kmem, GFP_NOFS);
+ info = kmem_cache_alloc(vvp_thread_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
@@ -91,7 +90,7 @@ static void vvp_key_fini(const struct lu_context *ctx,
{
struct vvp_thread_info *info = data;
- OBD_SLAB_FREE_PTR(info, vvp_thread_kmem);
+ kmem_cache_free(vvp_thread_kmem, info);
}
static void *vvp_session_key_init(const struct lu_context *ctx,
@@ -99,7 +98,7 @@ static void *vvp_session_key_init(const struct lu_context *ctx,
{
struct vvp_session *session;
- OBD_SLAB_ALLOC_PTR_GFP(session, vvp_session_kmem, GFP_NOFS);
+ session = kmem_cache_alloc(vvp_session_kmem, GFP_NOFS | __GFP_ZERO);
if (session == NULL)
session = ERR_PTR(-ENOMEM);
return session;
@@ -110,10 +109,9 @@ static void vvp_session_key_fini(const struct lu_context *ctx,
{
struct vvp_session *session = data;
- OBD_SLAB_FREE_PTR(session, vvp_session_kmem);
+ kmem_cache_free(vvp_session_kmem, session);
}
-
struct lu_context_key vvp_key = {
.lct_tags = LCT_CL_THREAD,
.lct_init = vvp_key_init,
@@ -187,7 +185,6 @@ void vvp_global_fini(void)
lu_kmem_fini(vvp_caches);
}
-
/*****************************************************************************
*
* mirror obd-devices into cl devices.
@@ -253,7 +250,7 @@ int cl_sb_fini(struct super_block *sb)
/****************************************************************************
*
- * /proc/fs/lustre/llite/$MNT/dump_page_cache
+ * debugfs/lustre/llite/$MNT/dump_page_cache
*
****************************************************************************/
@@ -517,7 +514,7 @@ static void vvp_pgcache_stop(struct seq_file *f, void *v)
/* Nothing to do */
}
-static struct seq_operations vvp_pgcache_ops = {
+static const struct seq_operations vvp_pgcache_ops = {
.start = vvp_pgcache_start,
.next = vvp_pgcache_next,
.stop = vvp_pgcache_stop,
@@ -526,16 +523,17 @@ static struct seq_operations vvp_pgcache_ops = {
static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp)
{
- struct ll_sb_info *sbi = PDE_DATA(inode);
- struct seq_file *seq;
- int result;
+ struct seq_file *seq;
+ int rc;
- result = seq_open(filp, &vvp_pgcache_ops);
- if (result == 0) {
- seq = filp->private_data;
- seq->private = sbi;
- }
- return result;
+ rc = seq_open(filp, &vvp_pgcache_ops);
+ if (rc)
+ return rc;
+
+ seq = filp->private_data;
+ seq->private = inode->i_private;
+
+ return 0;
}
const struct file_operations vvp_dump_pgcache_file_ops = {
diff --git a/kernel/drivers/staging/lustre/lustre/llite/vvp_internal.h b/kernel/drivers/staging/lustre/lustre/llite/vvp_internal.h
index 2162bf6c0..b5a6661d4 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/vvp_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/llite/vvp_internal.h
@@ -39,7 +39,6 @@
#ifndef VVP_INTERNAL_H
#define VVP_INTERNAL_H
-
#include "../include/cl_object.h"
#include "llite_internal.h"
diff --git a/kernel/drivers/staging/lustre/lustre/llite/vvp_io.c b/kernel/drivers/staging/lustre/lustre/llite/vvp_io.c
index 91bba7967..37773c181 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/vvp_io.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/vvp_io.c
@@ -41,7 +41,6 @@
#define DEBUG_SUBSYSTEM S_LLITE
-
#include "../include/obd.h"
#include "../include/lustre_lite.h"
@@ -109,7 +108,7 @@ static int vvp_io_fault_iter_init(const struct lu_env *env,
LASSERT(inode ==
file_inode(cl2ccc_io(env, ios)->cui_fd->fd_file));
- vio->u.fault.ft_mtime = LTIME_S(inode->i_mtime);
+ vio->u.fault.ft_mtime = inode->i_mtime.tv_sec;
return 0;
}
@@ -455,12 +454,11 @@ static void vvp_io_setattr_end(const struct lu_env *env,
struct cl_io *io = ios->cis_io;
struct inode *inode = ccc_object_inode(io->ci_obj);
- if (cl_io_is_trunc(io)) {
+ if (cl_io_is_trunc(io))
/* Truncate in memory pages - they must be clean pages
* because osc has already notified to destroy osc_extents. */
vvp_do_vmtruncate(inode, io->u.ci_setattr.sa_attr.lvb_size);
- inode_dio_write_done(inode);
- }
+
mutex_unlock(&inode->i_mutex);
}
@@ -644,7 +642,6 @@ static int vvp_io_kernel_fault(struct vvp_fault_io *cfio)
return -EINVAL;
}
-
static int vvp_io_fault_start(const struct lu_env *env,
const struct cl_io_slice *ios)
{
@@ -662,7 +659,7 @@ static int vvp_io_fault_start(const struct lu_env *env,
pgoff_t last; /* last page in a file data region */
if (fio->ft_executable &&
- LTIME_S(inode->i_mtime) != vio->u.fault.ft_mtime)
+ inode->i_mtime.tv_sec != vio->u.fault.ft_mtime)
CWARN("binary "DFID
" changed while waiting for the page fault lock\n",
PFID(lu_object_fid(&obj->co_lu)));
@@ -699,11 +696,10 @@ static int vvp_io_fault_start(const struct lu_env *env,
/* return +1 to stop cl_io_loop() and ll_fault() will catch
* and retry. */
- result = +1;
+ result = 1;
goto out;
}
-
if (fio->ft_mkwrite) {
pgoff_t last_index;
/*
@@ -1040,6 +1036,7 @@ static int vvp_io_commit_write(const struct lu_env *env,
need_clip = false;
} else if (last_index == pg->cp_index) {
int size_to = i_size_read(inode) & ~CFS_PAGE_MASK;
+
if (to < size_to)
to = size_to;
}
diff --git a/kernel/drivers/staging/lustre/lustre/llite/vvp_lock.c b/kernel/drivers/staging/lustre/lustre/llite/vvp_lock.c
index f354e82d4..f7b1144aa 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/vvp_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/vvp_lock.c
@@ -38,7 +38,6 @@
#define DEBUG_SUBSYSTEM S_LLITE
-
#include "../include/obd.h"
#include "../include/lustre_lite.h"
diff --git a/kernel/drivers/staging/lustre/lustre/llite/vvp_object.c b/kernel/drivers/staging/lustre/lustre/llite/vvp_object.c
index b6f6d4cb6..e13afb7e8 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/vvp_object.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/vvp_object.c
@@ -40,7 +40,6 @@
#define DEBUG_SUBSYSTEM S_LLITE
-
#include "../../include/linux/libcfs/libcfs.h"
#include "../include/obd.h"
@@ -87,9 +86,9 @@ static int vvp_attr_get(const struct lu_env *env, struct cl_object *obj,
*/
attr->cat_size = i_size_read(inode);
- attr->cat_mtime = LTIME_S(inode->i_mtime);
- attr->cat_atime = LTIME_S(inode->i_atime);
- attr->cat_ctime = LTIME_S(inode->i_ctime);
+ attr->cat_mtime = inode->i_mtime.tv_sec;
+ attr->cat_atime = inode->i_atime.tv_sec;
+ attr->cat_ctime = inode->i_ctime.tv_sec;
attr->cat_blocks = inode->i_blocks;
attr->cat_uid = from_kuid(&init_user_ns, inode->i_uid);
attr->cat_gid = from_kgid(&init_user_ns, inode->i_gid);
@@ -107,11 +106,11 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj,
if (valid & CAT_GID)
inode->i_gid = make_kgid(&init_user_ns, attr->cat_gid);
if (valid & CAT_ATIME)
- LTIME_S(inode->i_atime) = attr->cat_atime;
+ inode->i_atime.tv_sec = attr->cat_atime;
if (valid & CAT_MTIME)
- LTIME_S(inode->i_mtime) = attr->cat_mtime;
+ inode->i_mtime.tv_sec = attr->cat_mtime;
if (valid & CAT_CTIME)
- LTIME_S(inode->i_ctime) = attr->cat_ctime;
+ inode->i_ctime.tv_sec = attr->cat_ctime;
if (0 && valid & CAT_SIZE)
cl_isize_write_nolock(inode, attr->cat_size);
/* not currently necessary */
diff --git a/kernel/drivers/staging/lustre/lustre/llite/vvp_page.c b/kernel/drivers/staging/lustre/lustre/llite/vvp_page.c
index 954ed08c6..92f60c350 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/vvp_page.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/vvp_page.c
@@ -41,7 +41,6 @@
#define DEBUG_SUBSYSTEM S_LLITE
-
#include "../include/obd.h"
#include "../include/lustre_lite.h"
@@ -227,11 +226,16 @@ static int vvp_page_prep_write(const struct lu_env *env,
struct cl_io *unused)
{
struct page *vmpage = cl2vm_page(slice);
+ struct cl_page *pg = slice->cpl_page;
LASSERT(PageLocked(vmpage));
LASSERT(!PageDirty(vmpage));
- set_page_writeback(vmpage);
+ /* ll_writepage path is not a sync write, so need to set page writeback
+ * flag */
+ if (!pg->cp_sync_io)
+ set_page_writeback(vmpage);
+
vvp_write_pending(cl2ccc(slice->cpl_obj), cl2ccc_page(slice));
return 0;
@@ -298,9 +302,6 @@ static void vvp_page_completion_write(const struct lu_env *env,
struct cl_page *pg = slice->cpl_page;
struct page *vmpage = cp->cpg_page;
- LASSERT(ergo(pg->cp_sync_io != NULL, PageLocked(vmpage)));
- LASSERT(PageWriteback(vmpage));
-
CL_PAGE_HEADER(D_PAGE, env, pg, "completing WRITE with %d\n", ioret);
/*
@@ -316,14 +317,19 @@ static void vvp_page_completion_write(const struct lu_env *env,
cp->cpg_write_queued = 0;
vvp_write_complete(cl2ccc(slice->cpl_obj), cp);
- /*
- * Only mark the page error only when it's an async write because
- * applications won't wait for IO to finish.
- */
- if (pg->cp_sync_io == NULL)
+ if (pg->cp_sync_io != NULL) {
+ LASSERT(PageLocked(vmpage));
+ LASSERT(!PageWriteback(vmpage));
+ } else {
+ LASSERT(PageWriteback(vmpage));
+ /*
+ * Only mark the page error only when it's an async write
+ * because applications won't wait for IO to finish.
+ */
vvp_vmpage_error(ccc_object_inode(pg->cp_obj), vmpage, ioret);
- end_page_writeback(vmpage);
+ end_page_writeback(vmpage);
+ }
}
/**
diff --git a/kernel/drivers/staging/lustre/lustre/llite/xattr.c b/kernel/drivers/staging/lustre/lustre/llite/xattr.c
index e0fcbe139..4b7eb33f7 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/xattr.c
@@ -111,7 +111,6 @@ int ll_setxattr_common(struct inode *inode, const char *name,
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ptlrpc_request *req = NULL;
int xattr_type, rc;
- struct obd_capa *oc;
#ifdef CONFIG_FS_POSIX_ACL
struct rmtacl_ctl_entry *rce = NULL;
posix_acl_xattr_header *new_value = NULL;
@@ -175,11 +174,12 @@ int ll_setxattr_common(struct inode *inode, const char *name,
}
ee_free(ee);
} else if (rce->rce_ops == RMT_RSETFACL) {
- size = lustre_posix_acl_xattr_filter(
+ rc = lustre_posix_acl_xattr_filter(
(posix_acl_xattr_header *)value,
size, &new_value);
- if (unlikely(size < 0))
- return size;
+ if (unlikely(rc < 0))
+ return rc;
+ size = rc;
pv = (const char *)new_value;
} else
@@ -188,11 +188,9 @@ int ll_setxattr_common(struct inode *inode, const char *name,
valid |= rce_ops2valid(rce->rce_ops);
}
#endif
- oc = ll_mdscapa_get(inode);
- rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
- valid, name, pv, size, 0, flags,
- ll_i2suppgid(inode), &req);
- capa_put(oc);
+ rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
+ valid, name, pv, size, 0, flags,
+ ll_i2suppgid(inode), &req);
#ifdef CONFIG_FS_POSIX_ACL
if (new_value != NULL)
lustre_posix_acl_xattr_free(new_value, size);
@@ -289,7 +287,6 @@ int ll_getxattr_common(struct inode *inode, const char *name,
struct mdt_body *body;
int xattr_type, rc;
void *xdata;
- struct obd_capa *oc;
struct rmtacl_ctl_entry *rce = NULL;
struct ll_inode_info *lli = ll_i2info(inode);
@@ -380,11 +377,9 @@ do_getxattr:
}
} else {
getxattr_nocache:
- oc = ll_mdscapa_get(inode);
- rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
+ rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode),
valid | (rce ? rce_ops2valid(rce->rce_ops) : 0),
name, NULL, 0, size, 0, &req);
- capa_put(oc);
if (rc < 0)
goto out_xattr;
@@ -524,7 +519,7 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name,
goto out;
}
- lump = (struct lov_user_md *)buffer;
+ lump = buffer;
memcpy(lump, lmm, lmmsize);
/* do not return layout gen for getxattr otherwise it would
* confuse tar --xattr by recognizing layout gen as stripe
diff --git a/kernel/drivers/staging/lustre/lustre/llite/xattr_cache.c b/kernel/drivers/staging/lustre/lustre/llite/xattr_cache.c
index 69ea92adf..e1e599ceb 100644
--- a/kernel/drivers/staging/lustre/lustre/llite/xattr_cache.c
+++ b/kernel/drivers/staging/lustre/lustre/llite/xattr_cache.c
@@ -58,7 +58,6 @@ void ll_xattr_fini(void)
static void ll_xattr_cache_init(struct ll_inode_info *lli)
{
-
LASSERT(lli != NULL);
INIT_LIST_HEAD(&lli->lli_xattrs);
@@ -80,8 +79,6 @@ static int ll_xattr_cache_find(struct list_head *cache,
{
struct ll_xattr_entry *entry;
-
-
list_for_each_entry(entry, cache, xe_list) {
/* xattr_name == NULL means look for any entry */
if (xattr_name == NULL ||
@@ -113,14 +110,12 @@ static int ll_xattr_cache_add(struct list_head *cache,
{
struct ll_xattr_entry *xattr;
-
-
if (ll_xattr_cache_find(cache, xattr_name, &xattr) == 0) {
CDEBUG(D_CACHE, "duplicate xattr: [%s]\n", xattr_name);
return -EPROTO;
}
- OBD_SLAB_ALLOC_PTR_GFP(xattr, xattr_kmem, GFP_NOFS);
+ xattr = kmem_cache_alloc(xattr_kmem, GFP_NOFS | __GFP_ZERO);
if (xattr == NULL) {
CDEBUG(D_CACHE, "failed to allocate xattr\n");
return -ENOMEM;
@@ -144,9 +139,9 @@ static int ll_xattr_cache_add(struct list_head *cache,
return 0;
err_value:
- OBD_FREE(xattr->xe_name, xattr->xe_namelen);
+ kfree(xattr->xe_name);
err_name:
- OBD_SLAB_FREE_PTR(xattr, xattr_kmem);
+ kmem_cache_free(xattr_kmem, xattr);
return -ENOMEM;
}
@@ -164,15 +159,13 @@ static int ll_xattr_cache_del(struct list_head *cache,
{
struct ll_xattr_entry *xattr;
-
-
CDEBUG(D_CACHE, "del xattr: %s\n", xattr_name);
if (ll_xattr_cache_find(cache, xattr_name, &xattr) == 0) {
list_del(&xattr->xe_list);
- OBD_FREE(xattr->xe_name, xattr->xe_namelen);
- OBD_FREE(xattr->xe_value, xattr->xe_vallen);
- OBD_SLAB_FREE_PTR(xattr, xattr_kmem);
+ kfree(xattr->xe_name);
+ kfree(xattr->xe_value);
+ kmem_cache_free(xattr_kmem, xattr);
return 0;
}
@@ -197,8 +190,6 @@ static int ll_xattr_cache_list(struct list_head *cache,
struct ll_xattr_entry *xattr, *tmp;
int xld_tail = 0;
-
-
list_for_each_entry_safe(xattr, tmp, cache, xe_list) {
CDEBUG(D_CACHE, "list: buffer=%p[%d] name=%s\n",
xld_buffer, xld_tail, xattr->xe_name);
@@ -240,7 +231,6 @@ static int ll_xattr_cache_valid(struct ll_inode_info *lli)
static int ll_xattr_cache_destroy_locked(struct ll_inode_info *lli)
{
-
if (!ll_xattr_cache_valid(lli))
return 0;
@@ -256,8 +246,6 @@ int ll_xattr_cache_destroy(struct inode *inode)
struct ll_inode_info *lli = ll_i2info(inode);
int rc;
-
-
down_write(&lli->lli_xattrs_list_rwsem);
rc = ll_xattr_cache_destroy_locked(lli);
up_write(&lli->lli_xattrs_list_rwsem);
@@ -292,8 +280,6 @@ static int ll_xattr_find_get_lock(struct inode *inode,
struct obd_export *exp = sbi->ll_md_exp;
int rc;
-
-
mutex_lock(&lli->lli_xattrs_enq_lock);
/* inode may have been shrunk and recreated, so data is gone, match lock
* only when data exists. */
@@ -357,9 +343,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
struct ll_inode_info *lli = ll_i2info(inode);
struct mdt_body *body;
__u32 *xsizes;
- int rc = 0, i;
-
-
+ int rc, i;
rc = ll_xattr_find_get_lock(inode, oit, &req);
if (rc)
@@ -495,8 +479,6 @@ int ll_xattr_cache_get(struct inode *inode,
struct ll_inode_info *lli = ll_i2info(inode);
int rc = 0;
-
-
LASSERT(!!(valid & OBD_MD_FLXATTR) ^ !!(valid & OBD_MD_FLXATTRLS));
down_read(&lli->lli_xattrs_list_rwsem);
diff --git a/kernel/drivers/staging/lustre/lustre/lmv/Makefile b/kernel/drivers/staging/lustre/lustre/lmv/Makefile
index a7a15369a..1a2429979 100644
--- a/kernel/drivers/staging/lustre/lustre/lmv/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/lmv/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += lmv.o
-lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o
-lmv-$(CONFIG_PROC_FS) += lproc_lmv.o
+lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o lproc_lmv.o
diff --git a/kernel/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/kernel/drivers/staging/lustre/lustre/lmv/lmv_intent.c
index d22d57b4f..eebe45bdc 100644
--- a/kernel/drivers/staging/lustre/lustre/lmv/lmv_intent.c
+++ b/kernel/drivers/staging/lustre/lustre/lmv/lmv_intent.c
@@ -99,8 +99,8 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
goto out;
}
- OBD_ALLOC_PTR(op_data);
- if (op_data == NULL) {
+ op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
+ if (!op_data) {
rc = -ENOMEM;
goto out;
}
@@ -142,7 +142,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
it->d.lustre.it_lock_mode = pmode;
out_free_op_data:
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
out:
if (rc && pmode)
ldlm_lock_decref(&plock, pmode);
diff --git a/kernel/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/kernel/drivers/staging/lustre/lustre/lmv/lmv_internal.h
index 852d78721..b808728da 100644
--- a/kernel/drivers/staging/lustre/lustre/lmv/lmv_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/lmv/lmv_internal.h
@@ -144,14 +144,8 @@ struct lmv_tgt_desc
*lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
struct lu_fid *fid);
/* lproc_lmv.c */
-#if defined(CONFIG_PROC_FS)
void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
+
extern struct file_operations lmv_proc_target_fops;
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/kernel/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index b9459faf8..635a93cc9 100644
--- a/kernel/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/kernel/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -199,7 +199,6 @@ static int lmv_connect(const struct lu_env *env,
struct obd_uuid *cluuid, struct obd_connect_data *data,
void *localdata)
{
- struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv;
struct lustre_handle conn = { 0 };
int rc = 0;
@@ -230,19 +229,8 @@ static int lmv_connect(const struct lu_env *env,
if (data)
lmv->conn_data = *data;
- if (obd->obd_proc_private != NULL) {
- lmv_proc_dir = obd->obd_proc_private;
- } else {
- lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
- NULL, NULL);
- if (IS_ERR(lmv_proc_dir)) {
- CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.",
- obd->obd_type->typ_name, obd->obd_name);
- lmv_proc_dir = NULL;
- }
- obd->obd_proc_private = lmv_proc_dir;
- }
-
+ lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds",
+ &obd->obd_kobj);
/*
* All real clients should perform actual connection right away, because
* it is possible, that LMV will not have opportunity to connect targets
@@ -252,10 +240,8 @@ static int lmv_connect(const struct lu_env *env,
if (data->ocd_connect_flags & OBD_CONNECT_REAL)
rc = lmv_check_connect(obd);
- if (rc && lmv_proc_dir) {
- lprocfs_remove(&lmv_proc_dir);
- obd->obd_proc_private = NULL;
- }
+ if (rc && lmv->lmv_tgts_kobj)
+ kobject_put(lmv->lmv_tgts_kobj);
return rc;
}
@@ -337,7 +323,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize,
static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
{
- struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv;
struct obd_uuid *cluuid = &lmv->cluuid;
struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" };
@@ -415,25 +400,10 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
atomic_read(&obd->obd_refcount));
- lmv_proc_dir = obd->obd_proc_private;
- if (lmv_proc_dir) {
- struct proc_dir_entry *mdc_symlink;
-
- LASSERT(mdc_obd->obd_type != NULL);
- LASSERT(mdc_obd->obd_type->typ_name != NULL);
- mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name,
- lmv_proc_dir,
- "../../../%s/%s",
- mdc_obd->obd_type->typ_name,
- mdc_obd->obd_name);
- if (mdc_symlink == NULL) {
- CERROR("Could not register LMV target /proc/fs/lustre/%s/%s/target_obds/%s.",
- obd->obd_type->typ_name, obd->obd_name,
- mdc_obd->obd_name);
- lprocfs_remove(&lmv_proc_dir);
- obd->obd_proc_private = NULL;
- }
- }
+ if (lmv->lmv_tgts_kobj)
+ /* Even if we failed to create the link, that's fine */
+ rc = sysfs_create_link(lmv->lmv_tgts_kobj, &mdc_obd->obd_kobj,
+ mdc_obd->obd_name);
return 0;
}
@@ -442,7 +412,7 @@ static void lmv_del_target(struct lmv_obd *lmv, int index)
if (lmv->tgts[index] == NULL)
return;
- OBD_FREE_PTR(lmv->tgts[index]);
+ kfree(lmv->tgts[index]);
lmv->tgts[index] = NULL;
return;
}
@@ -488,7 +458,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
while (newsize < index + 1)
newsize <<= 1;
- OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
+ newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS);
if (newtgts == NULL) {
lmv_init_unlock(lmv);
return -ENOMEM;
@@ -504,14 +474,13 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
lmv->tgts = newtgts;
lmv->tgts_size = newsize;
smp_rmb();
- if (old)
- OBD_FREE(old, sizeof(*old) * oldsize);
+ kfree(old);
CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts,
lmv->tgts_size);
}
- OBD_ALLOC_PTR(tgt);
+ tgt = kzalloc(sizeof(*tgt), GFP_NOFS);
if (!tgt) {
lmv_init_unlock(lmv);
return -ENOMEM;
@@ -591,6 +560,7 @@ int lmv_check_connect(struct obd_device *obd)
out_disc:
while (i-- > 0) {
int rc2;
+
tgt = lmv->tgts[i];
if (tgt == NULL)
continue;
@@ -611,7 +581,6 @@ int lmv_check_connect(struct obd_device *obd)
static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
{
- struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv;
struct obd_device *mdc_obd;
int rc;
@@ -625,11 +594,11 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_force = obd->obd_force;
mdc_obd->obd_fail = obd->obd_fail;
mdc_obd->obd_no_recov = obd->obd_no_recov;
- }
- lmv_proc_dir = obd->obd_proc_private;
- if (lmv_proc_dir)
- lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir);
+ if (lmv->lmv_tgts_kobj)
+ sysfs_remove_link(lmv->lmv_tgts_kobj,
+ mdc_obd->obd_name);
+ }
rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
if (rc)
@@ -677,11 +646,8 @@ static int lmv_disconnect(struct obd_export *exp)
lmv_disconnect_mdc(obd, lmv->tgts[i]);
}
- if (obd->obd_proc_private)
- lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private);
- else
- CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n",
- obd->obd_type->typ_name, obd->obd_name);
+ if (lmv->lmv_tgts_kobj)
+ kobject_put(lmv->lmv_tgts_kobj);
out_local:
/*
@@ -750,8 +716,8 @@ repeat_fid2path:
/* sigh, has to go to another MDT to do path building further */
if (remote_gf == NULL) {
remote_gf_size = sizeof(*remote_gf) + PATH_MAX;
- OBD_ALLOC(remote_gf, remote_gf_size);
- if (remote_gf == NULL) {
+ remote_gf = kzalloc(remote_gf_size, GFP_NOFS);
+ if (!remote_gf) {
rc = -ENOMEM;
goto out_fid2path;
}
@@ -780,8 +746,7 @@ repeat_fid2path:
goto repeat_fid2path;
out_fid2path:
- if (remote_gf != NULL)
- OBD_FREE(remote_gf, remote_gf_size);
+ kfree(remote_gf);
return rc;
}
@@ -898,9 +863,6 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
return rc;
}
-
-
-
static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
int len, void *karg, void *uarg)
{
@@ -984,7 +946,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
return -EAGAIN;
LASSERT(tgt && tgt->ltd_exp);
- OBD_ALLOC_PTR(oqctl);
+ oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl)
return -ENOMEM;
@@ -995,7 +957,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
qctl->qc_valid = QC_MDTIDX;
qctl->obd_uuid = tgt->ltd_uuid;
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
break;
}
case OBD_IOC_CHANGELOG_SEND:
@@ -1081,7 +1043,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
reqlen = offsetof(typeof(*hur),
hur_user_item[nr])
+ hur->hur_request.hr_data_len;
- OBD_ALLOC_LARGE(req, reqlen);
+ req = libcfs_kvzalloc(reqlen, GFP_NOFS);
if (req == NULL)
return -ENOMEM;
@@ -1091,7 +1053,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
reqlen, req, uarg);
if (rc1 != 0 && rc == 0)
rc = rc1;
- OBD_FREE_LARGE(req, reqlen);
+ kvfree(req);
}
}
break;
@@ -1120,6 +1082,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
}
case LL_IOC_HSM_CT_START: {
struct lustre_kernelcomm *lk = karg;
+
if (lk->lk_flags & LK_FLG_STOP)
rc = lmv_hsm_ct_unregister(lmv, cmd, len, lk, uarg);
else
@@ -1311,7 +1274,7 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
struct lmv_obd *lmv = &obd->u.lmv;
- struct lprocfs_static_vars lvars;
+ struct lprocfs_static_vars lvars = { NULL };
struct lmv_desc *desc;
int rc;
@@ -1327,7 +1290,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
return -EINVAL;
}
- OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32);
+ lmv->tgts = kcalloc(32, sizeof(*lmv->tgts), GFP_NOFS);
if (lmv->tgts == NULL)
return -ENOMEM;
lmv->tgts_size = 32;
@@ -1345,16 +1308,12 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
lprocfs_lmv_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
-#if defined (CONFIG_PROC_FS)
- {
- rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
- 0444, &lmv_proc_target_fops, obd);
- if (rc)
- CWARN("%s: error adding LMV target_obd file: rc = %d\n",
- obd->obd_name, rc);
- }
-#endif
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
+ rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd",
+ 0444, &lmv_proc_target_fops, obd);
+ if (rc)
+ CWARN("%s: error adding LMV target_obd file: rc = %d\n",
+ obd->obd_name, rc);
rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
LUSTRE_CLI_FLD_HASH_DHT);
if (rc) {
@@ -1375,12 +1334,13 @@ static int lmv_cleanup(struct obd_device *obd)
fld_client_fini(&lmv->lmv_fld);
if (lmv->tgts != NULL) {
int i;
+
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
if (lmv->tgts[i] == NULL)
continue;
lmv_del_target(lmv, i);
}
- OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size);
+ kfree(lmv->tgts);
lmv->tgts_size = 0;
}
return 0;
@@ -1437,8 +1397,8 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
if (rc)
return rc;
- OBD_ALLOC(temp, sizeof(*temp));
- if (temp == NULL)
+ temp = kzalloc(sizeof(*temp), GFP_NOFS);
+ if (!temp)
return -ENOMEM;
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
@@ -1473,13 +1433,12 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
}
out_free_temp:
- OBD_FREE(temp, sizeof(*temp));
+ kfree(temp);
return rc;
}
static int lmv_getstatus(struct obd_export *exp,
- struct lu_fid *fid,
- struct obd_capa **pc)
+ struct lu_fid *fid)
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
@@ -1489,12 +1448,12 @@ static int lmv_getstatus(struct obd_export *exp,
if (rc)
return rc;
- rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid, pc);
+ rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid);
return rc;
}
static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, u64 valid, const char *name,
+ u64 valid, const char *name,
const char *input, int input_size, int output_size,
int flags, struct ptlrpc_request **request)
{
@@ -1511,14 +1470,14 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
if (IS_ERR(tgt))
return PTR_ERR(tgt);
- rc = md_getxattr(tgt->ltd_exp, fid, oc, valid, name, input,
+ rc = md_getxattr(tgt->ltd_exp, fid, valid, name, input,
input_size, output_size, flags, request);
return rc;
}
static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, u64 valid, const char *name,
+ u64 valid, const char *name,
const char *input, int input_size, int output_size,
int flags, __u32 suppgid,
struct ptlrpc_request **request)
@@ -1536,7 +1495,7 @@ static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
if (IS_ERR(tgt))
return PTR_ERR(tgt);
- rc = md_setxattr(tgt->ltd_exp, fid, oc, valid, name, input,
+ rc = md_setxattr(tgt->ltd_exp, fid, valid, name, input,
input_size, output_size, flags, suppgid,
request);
@@ -1626,7 +1585,6 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid,
return rc;
}
-
static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
struct md_open_data *mod, struct ptlrpc_request **request)
{
@@ -1769,8 +1727,8 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
goto out;
}
- OBD_ALLOC_PTR(rdata);
- if (rdata == NULL) {
+ rdata = kzalloc(sizeof(*rdata), GFP_NOFS);
+ if (!rdata) {
rc = -ENOMEM;
goto out;
}
@@ -1780,7 +1738,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
lmm, lmmsize, NULL, extra_lock_flags);
- OBD_FREE_PTR(rdata);
+ kfree(rdata);
out:
ldlm_lock_decref(&plock, pmode);
return rc;
@@ -1854,6 +1812,7 @@ lmv_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
if (body->valid & OBD_MD_MDS) {
struct lu_fid rid = body->fid1;
+
CDEBUG(D_INODE, "Request attrs for "DFID"\n",
PFID(&rid));
@@ -1889,7 +1848,7 @@ static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data,
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
struct lmv_tgt_desc *tgt;
- ldlm_policy_data_t policy = {{0}};
+ ldlm_policy_data_t policy = { {0} };
int rc = 0;
if (!fid_is_sane(fid))
@@ -2033,7 +1992,7 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
struct lmv_tgt_desc *tgt;
- int rc = 0;
+ int rc;
rc = lmv_check_connect(obd);
if (rc)
@@ -2054,7 +2013,7 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
}
static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, struct ptlrpc_request **request)
+ struct ptlrpc_request **request)
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
@@ -2069,7 +2028,7 @@ static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,
if (IS_ERR(tgt))
return PTR_ERR(tgt);
- rc = md_sync(tgt->ltd_exp, fid, oc, request);
+ rc = md_sync(tgt->ltd_exp, fid, request);
return rc;
}
@@ -2139,7 +2098,8 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs)
while (--nlupgs > 0) {
ent = lu_dirent_start(dp);
for (end_dirent = ent; ent != NULL;
- end_dirent = ent, ent = lu_dirent_next(ent));
+ end_dirent = ent, ent = lu_dirent_next(ent))
+ ;
/* Advance dp to next lu_dirpage. */
dp = (struct lu_dirpage *)((char *)dp + LU_PAGE_SIZE);
@@ -2313,7 +2273,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
* stack. */
break;
case OBD_CLEANUP_EXPORTS:
- fld_client_proc_fini(&lmv->lmv_fld);
+ fld_client_debugfs_fini(&lmv->lmv_fld);
lprocfs_obd_cleanup(obd);
break;
default:
@@ -2362,8 +2322,6 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
return -EINVAL;
} else if (KEY_IS(KEY_MAX_EASIZE) ||
KEY_IS(KEY_DEFAULT_EASIZE) ||
- KEY_IS(KEY_MAX_COOKIESIZE) ||
- KEY_IS(KEY_DEFAULT_COOKIESIZE) ||
KEY_IS(KEY_CONN_DATA)) {
rc = lmv_check_connect(obd);
if (rc)
@@ -2440,13 +2398,13 @@ static int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
return mea_size;
if (*lmmp && !lsm) {
- OBD_FREE_LARGE(*lmmp, mea_size);
+ kvfree(*lmmp);
*lmmp = NULL;
return 0;
}
if (*lmmp == NULL) {
- OBD_ALLOC_LARGE(*lmmp, mea_size);
+ *lmmp = libcfs_kvzalloc(mea_size, GFP_NOFS);
if (*lmmp == NULL)
return -ENOMEM;
}
@@ -2489,14 +2447,14 @@ static int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return mea_size;
if (*lsmp != NULL && lmm == NULL) {
- OBD_FREE_LARGE(*tmea, mea_size);
+ kvfree(*tmea);
*lsmp = NULL;
return 0;
}
LASSERT(mea_size == lmm_size);
- OBD_ALLOC_LARGE(*tmea, mea_size);
+ *tmea = libcfs_kvzalloc(mea_size, GFP_NOFS);
if (*tmea == NULL)
return -ENOMEM;
@@ -2646,8 +2604,7 @@ static int lmv_clear_open_replay_data(struct obd_export *exp,
static int lmv_get_remote_perm(struct obd_export *exp,
const struct lu_fid *fid,
- struct obd_capa *oc, __u32 suppgid,
- struct ptlrpc_request **request)
+ __u32 suppgid, struct ptlrpc_request **request)
{
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
@@ -2662,39 +2619,10 @@ static int lmv_get_remote_perm(struct obd_export *exp,
if (IS_ERR(tgt))
return PTR_ERR(tgt);
- rc = md_get_remote_perm(tgt->ltd_exp, fid, oc, suppgid, request);
+ rc = md_get_remote_perm(tgt->ltd_exp, fid, suppgid, request);
return rc;
}
-static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc,
- renew_capa_cb_t cb)
-{
- struct obd_device *obd = exp->exp_obd;
- struct lmv_obd *lmv = &obd->u.lmv;
- struct lmv_tgt_desc *tgt;
- int rc;
-
- rc = lmv_check_connect(obd);
- if (rc)
- return rc;
-
- tgt = lmv_find_target(lmv, &oc->c_capa.lc_fid);
- if (IS_ERR(tgt))
- return PTR_ERR(tgt);
-
- rc = md_renew_capa(tgt->ltd_exp, oc, cb);
- return rc;
-}
-
-static int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
- const struct req_msg_field *field,
- struct obd_capa **oc)
-{
- struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
-
- return md_unpack_capa(lmv->tgts[0]->ltd_exp, req, field, oc);
-}
-
static int lmv_intent_getattr_async(struct obd_export *exp,
struct md_enqueue_info *minfo,
struct ldlm_enqueue_info *einfo)
@@ -2764,6 +2692,7 @@ static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp,
curspace = curinodes = 0;
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
int err;
+
tgt = lmv->tgts[i];
if (tgt == NULL || tgt->ltd_exp == NULL || tgt->ltd_active == 0)
@@ -2799,6 +2728,7 @@ static int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp,
for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
int err;
+
tgt = lmv->tgts[i];
if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) {
CERROR("lmv idx %d inactive\n", i);
@@ -2860,8 +2790,6 @@ static struct md_ops lmv_md_ops = {
.m_free_lustre_md = lmv_free_lustre_md,
.m_set_open_replay_data = lmv_set_open_replay_data,
.m_clear_open_replay_data = lmv_clear_open_replay_data,
- .m_renew_capa = lmv_renew_capa,
- .m_unpack_capa = lmv_unpack_capa,
.m_get_remote_perm = lmv_get_remote_perm,
.m_intent_getattr_async = lmv_intent_getattr_async,
.m_revalidate_lock = lmv_revalidate_lock
@@ -2875,7 +2803,7 @@ static int __init lmv_init(void)
lprocfs_lmv_init_vars(&lvars);
rc = class_register_type(&lmv_obd_ops, &lmv_md_ops,
- lvars.module_vars, LUSTRE_LMV_NAME, NULL);
+ LUSTRE_LMV_NAME, NULL);
return rc;
}
diff --git a/kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
index 22e5c315f..40cf4d9f0 100644
--- a/kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
+++ b/kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
@@ -42,17 +42,17 @@
#include "../include/obd_class.h"
#include "lmv_internal.h"
-static int lmv_numobd_seq_show(struct seq_file *m, void *v)
+static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
- struct lmv_desc *desc;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct lmv_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lmv.desc;
- seq_printf(m, "%u\n", desc->ld_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lmv_numobd);
+LUSTRE_RO_ATTR(numobd);
static const char *placement_name[] = {
[PLACEMENT_CHAR_POLICY] = "CHAR",
@@ -77,66 +77,61 @@ static const char *placement_policy2name(enum placement_policy placement)
return placement_name[placement];
}
-static int lmv_placement_seq_show(struct seq_file *m, void *v)
+static ssize_t placement_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
- struct lmv_obd *lmv;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct lmv_obd *lmv;
- LASSERT(dev != NULL);
lmv = &dev->u.lmv;
- seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement));
- return 0;
+ return sprintf(buf, "%s\n", placement_policy2name(lmv->lmv_placement));
}
#define MAX_POLICY_STRING_SIZE 64
-static ssize_t lmv_placement_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t placement_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
- char dummy[MAX_POLICY_STRING_SIZE + 1];
- int len = count;
- enum placement_policy policy;
- struct lmv_obd *lmv;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ char dummy[MAX_POLICY_STRING_SIZE + 1];
+ enum placement_policy policy;
+ struct lmv_obd *lmv = &dev->u.lmv;
- if (copy_from_user(dummy, buffer, MAX_POLICY_STRING_SIZE))
- return -EFAULT;
+ memcpy(dummy, buffer, MAX_POLICY_STRING_SIZE);
- LASSERT(dev != NULL);
- lmv = &dev->u.lmv;
-
- if (len > MAX_POLICY_STRING_SIZE)
- len = MAX_POLICY_STRING_SIZE;
+ if (count > MAX_POLICY_STRING_SIZE)
+ count = MAX_POLICY_STRING_SIZE;
- if (dummy[len - 1] == '\n')
- len--;
- dummy[len] = '\0';
+ if (dummy[count - 1] == '\n')
+ count--;
+ dummy[count] = '\0';
- policy = placement_name2policy(dummy, len);
+ policy = placement_name2policy(dummy, count);
if (policy != PLACEMENT_INVAL_POLICY) {
spin_lock(&lmv->lmv_lock);
lmv->lmv_placement = policy;
spin_unlock(&lmv->lmv_lock);
} else {
- CERROR("Invalid placement policy \"%s\"!\n", dummy);
return -EINVAL;
}
return count;
}
-LPROC_SEQ_FOPS(lmv_placement);
+LUSTRE_RW_ATTR(placement);
-static int lmv_activeobd_seq_show(struct seq_file *m, void *v)
+static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
- struct lmv_desc *desc;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct lmv_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lmv.desc;
- seq_printf(m, "%u\n", desc->ld_active_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_active_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lmv_activeobd);
+LUSTRE_RO_ATTR(activeobd);
static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
{
@@ -148,12 +143,14 @@ static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid);
return 0;
}
+
LPROC_SEQ_FOPS_RO(lmv_desc_uuid);
static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos)
{
struct obd_device *dev = p->private;
struct lmv_obd *lmv = &dev->u.lmv;
+
return (*pos >= lmv->desc.ld_tgt_count) ? NULL : lmv->tgts[*pos];
}
@@ -182,7 +179,7 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v)
return 0;
}
-static struct seq_operations lmv_tgt_sops = {
+static const struct seq_operations lmv_tgt_sops = {
.start = lmv_tgt_seq_start,
.stop = lmv_tgt_seq_stop,
.next = lmv_tgt_seq_next,
@@ -199,29 +196,16 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
return 0;
}
-LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
-
static struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
- { "numobd", &lmv_numobd_fops, NULL, 0 },
- { "placement", &lmv_placement_fops, NULL, 0 },
- { "activeobd", &lmv_activeobd_fops, NULL, 0 },
- { "uuid", &lmv_uuid_fops, NULL, 0 },
{ "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 },
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs);
-
-static struct lprocfs_vars lprocfs_lmv_module_vars[] = {
- { "num_refs", &lmv_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
struct file_operations lmv_proc_target_fops = {
.owner = THIS_MODULE,
.open = lmv_target_seq_open,
@@ -230,8 +214,19 @@ struct file_operations lmv_proc_target_fops = {
.release = seq_release,
};
+static struct attribute *lmv_attrs[] = {
+ &lustre_attr_activeobd.attr,
+ &lustre_attr_numobd.attr,
+ &lustre_attr_placement.attr,
+ NULL,
+};
+
+static struct attribute_group lmv_attr_group = {
+ .attrs = lmv_attrs,
+};
+
void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_lmv_module_vars;
+ lvars->sysfs_vars = &lmv_attr_group;
lvars->obd_vars = lprocfs_lmv_obd_vars;
}
diff --git a/kernel/drivers/staging/lustre/lustre/lov/Makefile b/kernel/drivers/staging/lustre/lustre/lov/Makefile
index 6fe56a24b..e4cc0db21 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/lov/Makefile
@@ -2,5 +2,4 @@ obj-$(CONFIG_LUSTRE_FS) += lov.o
lov-y := lov_obd.o lov_pack.o lov_offset.o lov_merge.o \
lov_request.o lov_ea.o lov_dev.o lov_object.o lov_page.o \
lov_lock.o lov_io.o lovsub_dev.o lovsub_object.o lovsub_page.o \
- lovsub_lock.o lovsub_io.o lov_pool.o
-lov-$(CONFIG_PROC_FS) += lproc_lov.o
+ lovsub_lock.o lovsub_io.o lov_pool.o lproc_lov.o
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/kernel/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
index 314ce8525..1c0fe6524 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
@@ -438,7 +438,6 @@ struct lovsub_page {
struct cl_page_slice lsb_cl;
};
-
struct lov_thread_info {
struct cl_object_conf lti_stripe_conf;
struct lu_fid lti_fid;
@@ -611,7 +610,6 @@ int lov_sublock_modify(const struct lu_env *env, struct lov_lock *lov,
struct lovsub_lock *sublock,
const struct cl_lock_descr *d, int idx);
-
int lov_page_init(const struct lu_env *env, struct cl_object *ob,
struct cl_page *page, struct page *vmpage);
int lovsub_page_init(const struct lu_env *env, struct cl_object *ob,
@@ -637,9 +635,6 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env,
struct lov_io *lio,
const struct cl_page_slice *slice);
-void lov_lsm_decref(struct lov_object *lov, struct lov_stripe_md *lsm);
-struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov);
-
#define lov_foreach_target(lov, var) \
for (var = 0; var < lov_targets_nr(lov); ++var)
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_dev.c b/kernel/drivers/staging/lustre/lustre/lov/lov_dev.c
index 711b837dd..2e8b56645 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_dev.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_dev.c
@@ -46,7 +46,6 @@
#include "lov_cl_internal.h"
#include "lov_internal.h"
-
struct kmem_cache *lov_lock_kmem;
struct kmem_cache *lov_object_kmem;
struct kmem_cache *lov_thread_kmem;
@@ -125,7 +124,7 @@ static void lov_req_completion(const struct lu_env *env,
struct lov_req *lr;
lr = cl2lov_req(slice);
- OBD_SLAB_FREE_PTR(lr, lov_req_kmem);
+ kmem_cache_free(lov_req_kmem, lr);
}
static const struct cl_req_operations lov_req_ops = {
@@ -143,7 +142,7 @@ static void *lov_key_init(const struct lu_context *ctx,
{
struct lov_thread_info *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, GFP_NOFS);
+ info = kmem_cache_alloc(lov_thread_kmem, GFP_NOFS | __GFP_ZERO);
if (info != NULL)
INIT_LIST_HEAD(&info->lti_closure.clc_list);
else
@@ -155,8 +154,9 @@ static void lov_key_fini(const struct lu_context *ctx,
struct lu_context_key *key, void *data)
{
struct lov_thread_info *info = data;
+
LINVRNT(list_empty(&info->lti_closure.clc_list));
- OBD_SLAB_FREE_PTR(info, lov_thread_kmem);
+ kmem_cache_free(lov_thread_kmem, info);
}
struct lu_context_key lov_key = {
@@ -170,7 +170,7 @@ static void *lov_session_key_init(const struct lu_context *ctx,
{
struct lov_session *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, GFP_NOFS);
+ info = kmem_cache_alloc(lov_session_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
@@ -180,7 +180,8 @@ static void lov_session_key_fini(const struct lu_context *ctx,
struct lu_context_key *key, void *data)
{
struct lov_session *info = data;
- OBD_SLAB_FREE_PTR(info, lov_session_kmem);
+
+ kmem_cache_free(lov_session_kmem, info);
}
struct lu_context_key lov_session_key = {
@@ -260,7 +261,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev,
struct lov_req *lr;
int result;
- OBD_SLAB_ALLOC_PTR_GFP(lr, lov_req_kmem, GFP_NOFS);
+ lr = kmem_cache_alloc(lov_req_kmem, GFP_NOFS | __GFP_ZERO);
if (lr != NULL) {
cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops);
result = 0;
@@ -285,10 +286,10 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr)
LASSERT(em->emrg_page_list.pl_nr == 0);
if (em->emrg_env != NULL)
cl_env_put(em->emrg_env, &em->emrg_refcheck);
- OBD_FREE_PTR(em);
+ kfree(em);
}
}
- OBD_FREE(emrg, nr * sizeof(emrg[0]));
+ kfree(emrg);
}
static struct lu_device *lov_device_free(const struct lu_env *env,
@@ -298,11 +299,10 @@ static struct lu_device *lov_device_free(const struct lu_env *env,
const int nr = ld->ld_target_nr;
cl_device_fini(lu2cl_dev(d));
- if (ld->ld_target != NULL)
- OBD_FREE(ld->ld_target, nr * sizeof(ld->ld_target[0]));
+ kfree(ld->ld_target);
if (ld->ld_emrg != NULL)
lov_emerg_free(ld->ld_emrg, nr);
- OBD_FREE_PTR(ld);
+ kfree(ld);
return NULL;
}
@@ -323,13 +323,13 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr)
int i;
int result;
- OBD_ALLOC(emerg, nr * sizeof(emerg[0]));
+ emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS);
if (emerg == NULL)
return ERR_PTR(-ENOMEM);
for (result = i = 0; i < nr && result == 0; i++) {
struct lov_device_emerg *em;
- OBD_ALLOC_PTR(em);
+ em = kzalloc(sizeof(*em), GFP_NOFS);
if (em != NULL) {
emerg[i] = em;
cl_page_list_init(&em->emrg_page_list);
@@ -369,12 +369,12 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
if (IS_ERR(emerg))
return PTR_ERR(emerg);
- OBD_ALLOC(newd, tgt_size * sz);
+ newd = kcalloc(tgt_size, sz, GFP_NOFS);
if (newd != NULL) {
mutex_lock(&dev->ld_mutex);
if (sub_size > 0) {
memcpy(newd, dev->ld_target, sub_size * sz);
- OBD_FREE(dev->ld_target, sub_size * sz);
+ kfree(dev->ld_target);
}
dev->ld_target = newd;
dev->ld_target_nr = tgt_size;
@@ -478,8 +478,8 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env,
struct obd_device *obd;
int rc;
- OBD_ALLOC_PTR(ld);
- if (ld == NULL)
+ ld = kzalloc(sizeof(*ld), GFP_NOFS);
+ if (!ld)
return ERR_PTR(-ENOMEM);
cl_device_init(&ld->ld_cl, t);
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_ea.c b/kernel/drivers/staging/lustre/lustre/lov/lov_ea.c
index 2bcfaeaff..34c1346f0 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -95,12 +95,12 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size)
oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count;
*size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size;
- OBD_ALLOC_LARGE(lsm, *size);
+ lsm = libcfs_kvzalloc(*size, GFP_NOFS);
if (!lsm)
return NULL;
for (i = 0; i < stripe_count; i++) {
- OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, GFP_NOFS);
+ loi = kmem_cache_alloc(lov_oinfo_slab, GFP_NOFS | __GFP_ZERO);
if (loi == NULL)
goto err;
lsm->lsm_oinfo[i] = loi;
@@ -110,8 +110,8 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size)
err:
while (--i >= 0)
- OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi));
- OBD_FREE_LARGE(lsm, *size);
+ kmem_cache_free(lov_oinfo_slab, lsm->lsm_oinfo[i]);
+ kvfree(lsm);
return NULL;
}
@@ -121,10 +121,8 @@ void lsm_free_plain(struct lov_stripe_md *lsm)
int i;
for (i = 0; i < stripe_count; i++)
- OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab,
- sizeof(struct lov_oinfo));
- OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
- stripe_count * sizeof(struct lov_oinfo *));
+ kmem_cache_free(lov_oinfo_slab, lsm->lsm_oinfo[i]);
+ kvfree(lsm);
}
static void lsm_unpackmd_common(struct lov_stripe_md *lsm,
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_internal.h b/kernel/drivers/staging/lustre/lustre/lov/lov_internal.h
index b644acc9b..515a5c147 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -71,13 +71,6 @@
})
#endif
-struct lov_lock_handles {
- struct portals_handle llh_handle;
- atomic_t llh_refcount;
- int llh_stripe_count;
- struct lustre_handle llh_handles[0];
-};
-
struct lov_request {
struct obd_info rq_oi;
struct lov_request_set *rq_rqset;
@@ -88,7 +81,6 @@ struct lov_request {
int rq_stripe; /* stripe number */
int rq_complete;
int rq_rc;
- int rq_buflen; /* length of sub_md */
u32 rq_oabufs;
u32 rq_pgaidx;
@@ -109,9 +101,6 @@ struct lov_request_set {
struct llog_cookie *set_cookies;
int set_cookie_sent;
struct obd_trans_info *set_oti;
- u32 set_oabufs;
- struct brw_page *set_pga;
- struct lov_lock_handles *set_lockh;
struct list_head set_list;
wait_queue_head_t set_waitq;
spinlock_t set_lock;
@@ -136,32 +125,6 @@ static inline void lov_put_reqset(struct lov_request_set *set)
lov_finish_set(set);
}
-static inline struct lov_lock_handles *
-lov_handle2llh(struct lustre_handle *handle)
-{
- LASSERT(handle != NULL);
- return class_handle2object(handle->cookie);
-}
-
-static inline void lov_llh_put(struct lov_lock_handles *llh)
-{
- CDEBUG(D_INFO, "PUTting llh %p : new refcount %d\n", llh,
- atomic_read(&llh->llh_refcount) - 1);
- LASSERT(atomic_read(&llh->llh_refcount) > 0 &&
- atomic_read(&llh->llh_refcount) < 0x5a5a);
- if (atomic_dec_and_test(&llh->llh_refcount)) {
- class_handle_unhash(&llh->llh_handle);
- /* The structure may be held by other threads because RCU.
- * -jxiong */
- if (atomic_read(&llh->llh_refcount))
- return;
-
- OBD_FREE_RCU(llh, sizeof(*llh) +
- sizeof(*llh->llh_handles) * llh->llh_stripe_count,
- &llh->llh_handle);
- }
-}
-
#define lov_uuid2str(lv, index) \
(char *)((lv)->lov_tgts[index]->ltd_uuid.uuid)
@@ -257,7 +220,6 @@ int lov_free_memmd(struct lov_stripe_md **lsmp);
void lov_dump_lmm_v1(int level, struct lov_mds_md_v1 *lmm);
void lov_dump_lmm_v3(int level, struct lov_mds_md_v3 *lmm);
void lov_dump_lmm_common(int level, void *lmmp);
-void lov_dump_lmm(int level, void *lmm);
/* lov_ea.c */
struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size);
@@ -265,21 +227,14 @@ void lsm_free_plain(struct lov_stripe_md *lsm);
void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm);
/* lproc_lov.c */
-#if defined (CONFIG_PROC_FS)
extern const struct file_operations lov_proc_target_fops;
void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
/* lov_cl.c */
extern struct lu_device_type lov_device_type;
/* pools */
-extern cfs_hash_ops_t pool_hash_operations;
+extern struct cfs_hash_ops pool_hash_operations;
/* ost_pool methods */
int lov_ost_pool_init(struct ost_pool *op, unsigned int count);
int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count);
@@ -292,7 +247,6 @@ int lov_pool_new(struct obd_device *obd, char *poolname);
int lov_pool_del(struct obd_device *obd, char *poolname);
int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname);
int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname);
-void lov_dump_pool(int level, struct pool_desc *pool);
struct pool_desc *lov_find_pool(struct lov_obd *lov, char *poolname);
int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool);
void lov_pool_putref(struct pool_desc *pool);
@@ -315,5 +269,4 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi)
return false;
}
-
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_io.c b/kernel/drivers/staging/lustre/lustre/lov/lov_io.c
index cf96e0d01..5e6228b9c 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_io.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_io.c
@@ -51,6 +51,7 @@ static inline void lov_sub_enter(struct lov_io_sub *sub)
{
sub->sub_reenter++;
}
+
static inline void lov_sub_exit(struct lov_io_sub *sub)
{
sub->sub_reenter--;
@@ -70,7 +71,7 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio,
if (sub->sub_stripe == lio->lis_single_subio_index)
lio->lis_single_subio_index = -1;
else if (!sub->sub_borrowed)
- OBD_FREE_PTR(sub->sub_io);
+ kfree(sub->sub_io);
sub->sub_io = NULL;
}
if (sub->sub_env != NULL && !IS_ERR(sub->sub_env)) {
@@ -90,7 +91,6 @@ static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio,
case CIT_SETATTR: {
io->u.ci_setattr.sa_attr = parent->u.ci_setattr.sa_attr;
io->u.ci_setattr.sa_valid = parent->u.ci_setattr.sa_valid;
- io->u.ci_setattr.sa_capa = parent->u.ci_setattr.sa_capa;
if (cl_io_is_trunc(io)) {
loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size;
@@ -111,7 +111,6 @@ static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio,
case CIT_FSYNC: {
io->u.ci_fsync.fi_start = start;
io->u.ci_fsync.fi_end = end;
- io->u.ci_fsync.fi_capa = parent->u.ci_fsync.fi_capa;
io->u.ci_fsync.fi_fid = parent->u.ci_fsync.fi_fid;
io->u.ci_fsync.fi_mode = parent->u.ci_fsync.fi_mode;
break;
@@ -179,8 +178,9 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
sub->sub_io = &lio->lis_single_subio;
lio->lis_single_subio_index = stripe;
} else {
- OBD_ALLOC_PTR(sub->sub_io);
- if (sub->sub_io == NULL)
+ sub->sub_io = kzalloc(sizeof(*sub->sub_io),
+ GFP_NOFS);
+ if (!sub->sub_io)
result = -ENOMEM;
}
}
@@ -272,7 +272,6 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio,
return lov_sub_get(env, lio, stripe);
}
-
static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
struct cl_io *io)
{
@@ -285,8 +284,10 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
* Need to be optimized, we can't afford to allocate a piece of memory
* when writing a page. -jay
*/
- OBD_ALLOC_LARGE(lio->lis_subs,
- lsm->lsm_stripe_count * sizeof(lio->lis_subs[0]));
+ lio->lis_subs =
+ libcfs_kvzalloc(lsm->lsm_stripe_count *
+ sizeof(lio->lis_subs[0]),
+ GFP_NOFS);
if (lio->lis_subs != NULL) {
lio->lis_nr_subios = lio->lis_stripe_count;
lio->lis_single_subio_index = -1;
@@ -329,6 +330,7 @@ static void lov_io_slice_init(struct lov_io *lio,
case CIT_FAULT: {
pgoff_t index = io->u.ci_fault.ft_index;
+
lio->lis_pos = cl_offset(io->ci_obj, index);
lio->lis_endpos = cl_offset(io->ci_obj, index + 1);
break;
@@ -359,8 +361,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
if (lio->lis_subs != NULL) {
for (i = 0; i < lio->lis_nr_subios; i++)
lov_io_sub_fini(env, lio, &lio->lis_subs[i]);
- OBD_FREE_LARGE(lio->lis_subs,
- lio->lis_nr_subios * sizeof(lio->lis_subs[0]));
+ kvfree(lio->lis_subs);
lio->lis_nr_subios = 0;
}
@@ -544,7 +545,6 @@ static void lov_io_unlock(const struct lu_env *env,
LASSERT(rc == 0);
}
-
static struct cl_page_list *lov_io_submit_qin(struct lov_device *ld,
struct cl_page_list *qin,
int idx, int alloc)
@@ -603,8 +603,10 @@ static int lov_io_submit(const struct lu_env *env,
LASSERT(lio->lis_subs != NULL);
if (alloc) {
- OBD_ALLOC_LARGE(stripes_qin,
- sizeof(*stripes_qin) * lio->lis_nr_subios);
+ stripes_qin =
+ libcfs_kvzalloc(sizeof(*stripes_qin) *
+ lio->lis_nr_subios,
+ GFP_NOFS);
if (stripes_qin == NULL)
return -ENOMEM;
@@ -657,8 +659,7 @@ static int lov_io_submit(const struct lu_env *env,
}
if (alloc) {
- OBD_FREE_LARGE(stripes_qin,
- sizeof(*stripes_qin) * lio->lis_nr_subios);
+ kvfree(stripes_qin);
} else {
int i;
@@ -726,6 +727,8 @@ static int lov_io_fault_start(const struct lu_env *env,
fio = &ios->cis_io->u.ci_fault;
lio = cl2lov_io(env, ios);
sub = lov_sub_get(env, lio, lov_page_stripe(fio->ft_page));
+ if (IS_ERR(sub))
+ return PTR_ERR(sub);
sub->sub_io->u.ci_fault.ft_nob = fio->ft_nob;
lov_sub_put(sub);
return lov_io_start(env, ios);
@@ -987,4 +990,5 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
io->ci_result = result < 0 ? result : 0;
return result != 0;
}
+
/** @} lov */
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_lock.c b/kernel/drivers/staging/lustre/lustre/lov/lov_lock.c
index f2eca565b..d866791d7 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_lock.c
@@ -144,7 +144,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env,
LASSERT(idx < lck->lls_nr);
- OBD_SLAB_ALLOC_PTR_GFP(link, lov_lock_link_kmem, GFP_NOFS);
+ link = kmem_cache_alloc(lov_lock_link_kmem, GFP_NOFS | __GFP_ZERO);
if (link != NULL) {
struct lov_sublock_env *subenv;
struct lov_lock_sub *lls;
@@ -173,7 +173,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env,
if (!IS_ERR(sublock))
*out = link;
else
- OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem);
+ kmem_cache_free(lov_lock_link_kmem, link);
} else
sublock = ERR_PTR(-ENOMEM);
return sublock;
@@ -227,6 +227,7 @@ static int lov_sublock_lock(const struct lu_env *env,
result = CLO_REPEAT;
} else if (lsep) {
struct lov_sublock_env *subenv;
+
subenv = lov_sublock_env_get(env, parent, lls);
if (IS_ERR(subenv)) {
lov_sublock_unlock(env, sublock,
@@ -314,7 +315,7 @@ static int lov_lock_sub_init(const struct lu_env *env,
nr++;
}
LASSERT(nr > 0);
- OBD_ALLOC_LARGE(lck->lls_sub, nr * sizeof(lck->lls_sub[0]));
+ lck->lls_sub = libcfs_kvzalloc(nr * sizeof(lck->lls_sub[0]), GFP_NOFS);
if (lck->lls_sub == NULL)
return -ENOMEM;
@@ -441,10 +442,9 @@ static void lov_lock_fini(const struct lu_env *env,
* a reference on its parent.
*/
LASSERT(lck->lls_sub[i].sub_lock == NULL);
- OBD_FREE_LARGE(lck->lls_sub,
- lck->lls_nr * sizeof(lck->lls_sub[0]));
+ kvfree(lck->lls_sub);
}
- OBD_SLAB_FREE_PTR(lck, lov_lock_kmem);
+ kmem_cache_free(lov_lock_kmem, lck);
}
static int lov_lock_enqueue_wait(const struct lu_env *env,
@@ -518,7 +518,7 @@ static int lov_sublock_fill(const struct lu_env *env, struct cl_lock *parent,
lck->lls_sub[idx].sub_lock == NULL) {
lov_sublock_adopt(env, lck, sublock, idx, link);
} else {
- OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem);
+ kmem_cache_free(lov_lock_link_kmem, link);
/* other thread allocated sub-lock, or enqueue is no
* longer going on */
cl_lock_mutex_put(env, parent);
@@ -678,7 +678,6 @@ static int lov_lock_unuse(const struct lu_env *env,
return result;
}
-
static void lov_lock_cancel(const struct lu_env *env,
const struct cl_lock_slice *slice)
{
@@ -982,6 +981,7 @@ static int lov_lock_fits_into(const struct lu_env *env,
result = cl_lock_ext_match(&lov->lls_orig, need);
else if (lov->lls_nr == 1) {
struct cl_lock_descr *got = &lov->lls_sub[0].sub_got;
+
result = lov_lock_stripe_is_matching(env,
cl2lov(slice->cls_obj),
lov->lls_sub[0].sub_stripe,
@@ -1027,7 +1027,7 @@ void lov_lock_unlink(const struct lu_env *env,
lck->lls_nr_filled--;
lu_ref_del(&parent->cll_reference, "lov-child", sub->lss_cl.cls_lock);
cl_lock_put(env, parent);
- OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem);
+ kmem_cache_free(lov_lock_link_kmem, link);
}
struct lov_lock_link *lov_lock_link_find(const struct lu_env *env,
@@ -1139,7 +1139,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj,
struct lov_lock *lck;
int result;
- OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, GFP_NOFS);
+ lck = kmem_cache_alloc(lov_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (lck != NULL) {
cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops);
result = lov_lock_sub_init(env, lck, io);
@@ -1152,7 +1152,8 @@ static void lov_empty_lock_fini(const struct lu_env *env,
struct cl_lock_slice *slice)
{
struct lov_lock *lck = cl2lov_lock(slice);
- OBD_SLAB_FREE_PTR(lck, lov_lock_kmem);
+
+ kmem_cache_free(lov_lock_kmem, lck);
}
static int lov_empty_lock_print(const struct lu_env *env, void *cookie,
@@ -1174,7 +1175,7 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj,
struct lov_lock *lck;
int result = -ENOMEM;
- OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, GFP_NOFS);
+ lck = kmem_cache_alloc(lov_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (lck != NULL) {
cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops);
lck->lls_orig = lock->cll_descr;
@@ -1194,5 +1195,4 @@ static struct cl_lock_closure *lov_closure_get(const struct lu_env *env,
return closure;
}
-
/** @} lov */
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_merge.c b/kernel/drivers/staging/lustre/lustre/lov/lov_merge.c
index b7e7bfabe..dd1cf3d2d 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_merge.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_merge.c
@@ -123,6 +123,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
if (shrink) {
for (; stripe < lsm->lsm_stripe_count; stripe++) {
struct lov_oinfo *loi = lsm->lsm_oinfo[stripe];
+
kms = lov_size_to_stripe(lsm, size, stripe);
CDEBUG(D_INODE,
"stripe %d KMS %sing %llu->%llu\n",
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_obd.c b/kernel/drivers/staging/lustre/lustre/lov/lov_obd.c
index 027815766..7abe484c0 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -85,6 +85,7 @@ static void lov_putref(struct obd_device *obd)
LIST_HEAD(kill);
int i;
struct lov_tgt_desc *tgt, *n;
+
CDEBUG(D_CONFIG, "destroying %d lov targets\n",
lov->lov_death_row);
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
@@ -107,6 +108,10 @@ static void lov_putref(struct obd_device *obd)
/* Disconnect */
__lov_del_obd(obd, tgt);
}
+
+ if (lov->lov_tgts_kobj)
+ kobject_put(lov->lov_tgts_kobj);
+
} else {
mutex_unlock(&lov->lov_lock);
}
@@ -117,7 +122,6 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
static int lov_notify(struct obd_device *obd, struct obd_device *watched,
enum obd_notify_event ev, void *data);
-
#define MAX_STRING_SIZE 128
int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
struct obd_connect_data *data)
@@ -127,7 +131,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
struct obd_device *tgt_obd;
static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
struct obd_import *imp;
- struct proc_dir_entry *lov_proc_dir;
int rc;
if (!lov->lov_tgts[index])
@@ -166,7 +169,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
return rc;
}
-
if (imp->imp_invalid) {
CDEBUG(D_CONFIG, "not connecting OSC %s; administratively disabled\n",
obd_uuid2str(tgt_uuid));
@@ -186,28 +188,10 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
- lov_proc_dir = obd->obd_proc_private;
- if (lov_proc_dir) {
- struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
- struct proc_dir_entry *osc_symlink;
-
- LASSERT(osc_obd != NULL);
- LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(osc_obd->obd_type->typ_name != NULL);
-
- osc_symlink = lprocfs_add_symlink(osc_obd->obd_name,
- lov_proc_dir,
- "../../../%s/%s",
- osc_obd->obd_type->typ_name,
- osc_obd->obd_name);
- if (osc_symlink == NULL) {
- CERROR("could not register LOV target /proc/fs/lustre/%s/%s/target_obds/%s.",
- obd->obd_type->typ_name, obd->obd_name,
- osc_obd->obd_name);
- lprocfs_remove(&lov_proc_dir);
- obd->obd_proc_private = NULL;
- }
- }
+ if (lov->lov_tgts_kobj)
+ /* Even if we failed, that's ok */
+ rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kobj,
+ tgt_obd->obd_name);
return 0;
}
@@ -239,6 +223,10 @@ static int lov_connect(const struct lu_env *env,
lov->lov_ocd = *data;
obd_getref(obd);
+
+ lov->lov_tgts_kobj = kobject_create_and_add("target_obds",
+ &obd->obd_kobj);
+
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
tgt = lov->lov_tgts[i];
if (!tgt || obd_uuid_empty(&tgt->ltd_uuid))
@@ -268,7 +256,6 @@ static int lov_connect(const struct lu_env *env,
static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
{
- struct proc_dir_entry *lov_proc_dir;
struct lov_obd *lov = &obd->u.lov;
struct obd_device *osc_obd;
int rc;
@@ -284,10 +271,10 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
}
if (osc_obd) {
- lov_proc_dir = obd->obd_proc_private;
- if (lov_proc_dir) {
- lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir);
- }
+ if (lov->lov_tgts_kobj)
+ sysfs_remove_link(lov->lov_tgts_kobj,
+ osc_obd->obd_name);
+
/* Pass it on to our clients.
* XXX This should be an argument to disconnect,
* XXX not a back-door flag on the OBD. Ah well.
@@ -337,6 +324,7 @@ static int lov_disconnect(struct obd_export *exp)
lov_del_target(obd, i, NULL, lov->lov_tgts[i]->ltd_gen);
}
}
+
obd_putref(obd);
out:
@@ -554,7 +542,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
newsize = max_t(__u32, lov->lov_tgt_size, 2);
while (newsize < index + 1)
newsize <<= 1;
- OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
+ newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS);
if (newtgts == NULL) {
mutex_unlock(&lov->lov_lock);
return -ENOMEM;
@@ -570,14 +558,13 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
lov->lov_tgts = newtgts;
lov->lov_tgt_size = newsize;
smp_rmb();
- if (old)
- OBD_FREE(old, sizeof(*old) * oldsize);
+ kfree(old);
CDEBUG(D_CONFIG, "tgts: %p size: %d\n",
lov->lov_tgts, lov->lov_tgt_size);
}
- OBD_ALLOC_PTR(tgt);
+ tgt = kzalloc(sizeof(*tgt), GFP_NOFS);
if (!tgt) {
mutex_unlock(&lov->lov_lock);
return -ENOMEM;
@@ -586,7 +573,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
if (rc) {
mutex_unlock(&lov->lov_lock);
- OBD_FREE_PTR(tgt);
+ kfree(tgt);
return rc;
}
@@ -712,7 +699,7 @@ static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
if (tgt->ltd_exp)
lov_disconnect_obd(obd, tgt);
- OBD_FREE_PTR(tgt);
+ kfree(tgt);
/* Manual cleanup - no cleanup logs to clean up the osc's. We must
do it ourselves. And we can't do it from lov_cleanup,
@@ -822,21 +809,16 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
goto out;
lprocfs_lov_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
-#if defined (CONFIG_PROC_FS)
- {
- int rc1;
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
- rc1 = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
- 0444, &lov_proc_target_fops, obd);
- if (rc1)
- CWARN("Error adding the target_obd file\n");
- }
-#endif
- lov->lov_pool_proc_entry = lprocfs_register("pools",
- obd->obd_proc_entry,
- NULL, NULL);
+ rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd",
+ 0444, &lov_proc_target_fops, obd);
+ if (rc)
+ CWARN("Error adding the target_obd file\n");
+ lov->lov_pool_debugfs_entry = ldebugfs_register("pools",
+ obd->obd_debugfs_entry,
+ NULL, NULL);
return 0;
out:
@@ -850,6 +832,7 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
switch (stage) {
case OBD_CLEANUP_EARLY: {
int i;
+
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active)
continue;
@@ -886,6 +869,7 @@ static int lov_cleanup(struct obd_device *obd)
lprocfs_obd_cleanup(obd);
if (lov->lov_tgts) {
int i;
+
obd_getref(obd);
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
if (!lov->lov_tgts[i])
@@ -903,8 +887,7 @@ static int lov_cleanup(struct obd_device *obd)
lov_del_target(obd, i, NULL, 0);
}
obd_putref(obd);
- OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) *
- lov->lov_tgt_size);
+ kfree(lov->lov_tgts);
lov->lov_tgt_size = 0;
}
return 0;
@@ -931,14 +914,12 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg,
obd_str2uuid(&obd_uuid, lustre_cfg_buf(lcfg, 1));
- if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", indexp) != 1) {
- rc = -EINVAL;
+ rc = kstrtoint(lustre_cfg_buf(lcfg, 2), 10, indexp);
+ if (rc < 0)
goto out;
- }
- if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", genp) != 1) {
- rc = -EINVAL;
+ rc = kstrtoint(lustre_cfg_buf(lcfg, 3), 10, genp);
+ if (rc < 0)
goto out;
- }
index = *indexp;
gen = *genp;
if (cmd == LCFG_LOV_ADD_OBD)
@@ -994,8 +975,8 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS &&
src_oa->o_flags & OBD_FL_RECREATE_OBJS);
- OBD_ALLOC(obj_mdp, sizeof(*obj_mdp));
- if (obj_mdp == NULL)
+ obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS);
+ if (!obj_mdp)
return -ENOMEM;
ost_idx = src_oa->o_nlink;
@@ -1032,7 +1013,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
rc = obd_create(NULL, lov->lov_tgts[ost_idx]->ltd_exp,
src_oa, &obj_mdp, oti);
out:
- OBD_FREE(obj_mdp, sizeof(*obj_mdp));
+ kfree(obj_mdp);
return rc;
}
@@ -1079,8 +1060,7 @@ do { \
static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
struct obdo *oa, struct lov_stripe_md *lsm,
- struct obd_trans_info *oti, struct obd_export *md_exp,
- void *capa)
+ struct obd_trans_info *oti, struct obd_export *md_exp)
{
struct lov_request_set *set;
struct obd_info oinfo;
@@ -1112,7 +1092,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
oti->oti_logcookies = set->set_cookies + req->rq_stripe;
err = obd_destroy(env, lov->lov_tgts[req->rq_idx]->ltd_exp,
- req->rq_oi.oi_oa, NULL, oti, NULL, capa);
+ req->rq_oi.oi_oa, NULL, oti, NULL);
err = lov_update_common_set(set, req, err);
if (err) {
CERROR("%s: destroying objid "DOSTID" subobj "
@@ -1275,6 +1255,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
/* If we are not waiting for responses on async requests, return. */
if (rc || !rqset || list_empty(&rqset->set_requests)) {
int err;
+
if (rc)
atomic_set(&set->set_completes, 0);
err = lov_fini_setattr_set(set);
@@ -1367,6 +1348,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
if (rc || list_empty(&rqset->set_requests)) {
int err;
+
if (rc)
atomic_set(&set->set_completes, 0);
err = lov_fini_statfs_set(set);
@@ -1383,7 +1365,7 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp,
struct obd_statfs *osfs, __u64 max_age, __u32 flags)
{
struct ptlrpc_request_set *set = NULL;
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info oinfo = { };
int rc = 0;
/* for obdclass we forbid using obd_statfs_rqset, but prefer using async
@@ -1419,7 +1401,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
__u32 flags;
memcpy(&index, data->ioc_inlbuf2, sizeof(__u32));
- if ((index >= count))
+ if (index >= count)
return -ENODEV;
if (!lov->lov_tgts[index])
@@ -1458,7 +1440,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
__u32 *genp;
len = 0;
- if (obd_ioctl_getdata(&buf, &len, (void *)uarg))
+ if (obd_ioctl_getdata(&buf, &len, uarg))
return -EINVAL;
data = (struct obd_ioctl_data *)buf;
@@ -1491,7 +1473,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
*genp = lov->lov_tgts[i]->ltd_gen;
}
- if (copy_to_user((void *)uarg, buf, len))
+ if (copy_to_user(uarg, buf, len))
rc = -EFAULT;
obd_ioctl_freedata(buf, len);
break;
@@ -1505,7 +1487,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
struct obd_quotactl *oqctl;
if (qctl->qc_valid == QC_OSTIDX) {
- if (qctl->qc_idx < 0 || count <= qctl->qc_idx)
+ if (count <= qctl->qc_idx)
return -EINVAL;
tgt = lov->lov_tgts[qctl->qc_idx];
@@ -1532,7 +1514,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
return -EAGAIN;
LASSERT(tgt && tgt->ltd_exp);
- OBD_ALLOC_PTR(oqctl);
+ oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl)
return -ENOMEM;
@@ -1543,7 +1525,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
qctl->qc_valid = QC_OSTIDX;
qctl->obd_uuid = tgt->ltd_uuid;
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
break;
}
default: {
@@ -1690,7 +1672,7 @@ static int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, u64 fm_start,
break;
}
*stripe_count = j;
- last_stripe = (start_stripe + j - 1) %lsm->lsm_stripe_count;
+ last_stripe = (start_stripe + j - 1) % lsm->lsm_stripe_count;
}
return last_stripe;
@@ -1756,7 +1738,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
if (fiemap_count_to_size(fm_key->fiemap.fm_extent_count) < buffer_size)
buffer_size = fiemap_count_to_size(fm_key->fiemap.fm_extent_count);
- OBD_ALLOC_LARGE(fm_local, buffer_size);
+ fm_local = libcfs_kvzalloc(buffer_size, GFP_NOFS);
if (fm_local == NULL) {
rc = -ENOMEM;
goto out;
@@ -1880,7 +1862,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
fm_local->fm_start = lun_start;
fm_local->fm_flags &= ~FIEMAP_FLAG_DEVICE_ORDER;
memcpy(&fm_key->fiemap, fm_local, sizeof(*fm_local));
- *vallen=fiemap_count_to_size(fm_local->fm_extent_count);
+ *vallen = fiemap_count_to_size(fm_local->fm_extent_count);
rc = obd_get_info(NULL,
lov->lov_tgts[ost_index]->ltd_exp,
keylen, key, vallen, fm_local, lsm);
@@ -1962,7 +1944,7 @@ skip_last_device_calc:
fiemap->fm_mapped_extents = current_extent;
out:
- OBD_FREE_LARGE(fm_local, buffer_size);
+ kvfree(fm_local);
return rc;
}
@@ -2085,7 +2067,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp,
struct lov_tgt_desc *tgt;
unsigned incr, check_uuid,
do_inactive, no_set;
- unsigned next_id = 0, mds_con = 0, capa = 0;
+ unsigned next_id = 0, mds_con = 0;
incr = check_uuid = do_inactive = no_set = 0;
if (set == NULL) {
@@ -2110,8 +2092,6 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp,
/* use defaults: do_inactive = incr = 0; */
} else if (KEY_IS(KEY_MDS_CONN)) {
mds_con = 1;
- } else if (KEY_IS(KEY_CAPA_KEY)) {
- capa = 1;
} else if (KEY_IS(KEY_CACHE_SET)) {
LASSERT(lov->lov_cache == NULL);
lov->lov_cache = val;
@@ -2119,11 +2099,10 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp,
}
for (i = 0; i < count; i++, val = (char *)val + incr) {
- if (next_id) {
+ if (next_id)
tgt = lov->lov_tgts[((struct obd_id_info *)val)->idx];
- } else {
+ else
tgt = lov->lov_tgts[i];
- }
/* OST was disconnected */
if (!tgt || !tgt->ltd_exp)
continue;
@@ -2150,19 +2129,6 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp,
err = obd_set_info_async(env, tgt->ltd_exp,
keylen, key, vallen,
((struct obd_id_info *)val)->data, set);
- } else if (capa) {
- struct mds_capa_info *info = (struct mds_capa_info *)val;
-
- LASSERT(vallen == sizeof(*info));
-
- /* Only want a specific OSC */
- if (info->uuid &&
- !obd_uuid_equals(info->uuid, &tgt->ltd_uuid))
- continue;
-
- err = obd_set_info_async(env, tgt->ltd_exp, keylen,
- key, sizeof(*info->capa),
- info->capa, set);
} else {
/* Only want a specific OSC */
if (check_uuid &&
@@ -2367,7 +2333,7 @@ static int __init lov_init(void)
}
lprocfs_lov_init_vars(&lvars);
- rc = class_register_type(&lov_obd_ops, NULL, lvars.module_vars,
+ rc = class_register_type(&lov_obd_ops, NULL,
LUSTRE_LOV_NAME, &lov_device_type);
if (rc) {
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_object.c b/kernel/drivers/staging/lustre/lustre/lov/lov_object.c
index a22342fa7..c7ff817bb 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_object.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_object.c
@@ -42,7 +42,6 @@
#define DEBUG_SUBSYSTEM S_LOV
#include "lov_cl_internal.h"
-#include "../include/lclient.h"
/** \addtogroup lov
* @{
@@ -218,7 +217,8 @@ static int lov_init_raid0(const struct lu_env *env,
r0->lo_nr = lsm->lsm_stripe_count;
LASSERT(r0->lo_nr <= lov_targets_nr(dev));
- OBD_ALLOC_LARGE(r0->lo_sub, r0->lo_nr * sizeof(r0->lo_sub[0]));
+ r0->lo_sub = libcfs_kvzalloc(r0->lo_nr * sizeof(r0->lo_sub[0]),
+ GFP_NOFS);
if (r0->lo_sub != NULL) {
result = 0;
subconf->coc_inode = conf->coc_inode;
@@ -375,7 +375,7 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov,
struct lov_layout_raid0 *r0 = &state->raid0;
if (r0->lo_sub != NULL) {
- OBD_FREE_LARGE(r0->lo_sub, r0->lo_nr * sizeof(r0->lo_sub[0]));
+ kvfree(r0->lo_sub);
r0->lo_sub = NULL;
}
@@ -808,7 +808,7 @@ static void lov_object_free(const struct lu_env *env, struct lu_object *obj)
LOV_2DISPATCH_VOID(lov, llo_fini, env, lov, &lov->u);
lu_object_fini(obj);
- OBD_SLAB_FREE_PTR(lov, lov_object_kmem);
+ kmem_cache_free(lov_object_kmem, lov);
}
static int lov_object_print(const struct lu_env *env, void *cookie,
@@ -891,7 +891,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env,
struct lov_object *lov;
struct lu_object *obj;
- OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, GFP_NOFS);
+ lov = kmem_cache_alloc(lov_object_kmem, GFP_NOFS | __GFP_ZERO);
if (lov != NULL) {
obj = lov2lu(lov);
lu_object_init(obj, NULL, dev);
@@ -908,7 +908,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env,
return obj;
}
-struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov)
+static struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov)
{
struct lov_stripe_md *lsm = NULL;
@@ -923,17 +923,6 @@ struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov)
return lsm;
}
-void lov_lsm_decref(struct lov_object *lov, struct lov_stripe_md *lsm)
-{
- if (lsm == NULL)
- return;
-
- CDEBUG(D_INODE, "lsm %p decref %d by %p.\n",
- lsm, atomic_read(&lsm->lsm_refc), current);
-
- lov_free_memmd(&lsm);
-}
-
struct lov_stripe_md *lov_lsm_get(struct cl_object *clobj)
{
struct lu_object *luobj;
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_pack.c b/kernel/drivers/staging/lustre/lustre/lov/lov_pack.c
index 5356d5324..2fb1e974c 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_pack.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_pack.c
@@ -100,26 +100,6 @@ void lov_dump_lmm_v3(int level, struct lov_mds_md_v3 *lmm)
le16_to_cpu(lmm->lmm_stripe_count));
}
-void lov_dump_lmm(int level, void *lmm)
-{
- int magic;
-
- magic = le32_to_cpu(((struct lov_mds_md *)lmm)->lmm_magic);
- switch (magic) {
- case LOV_MAGIC_V1:
- lov_dump_lmm_v1(level, (struct lov_mds_md_v1 *)lmm);
- break;
- case LOV_MAGIC_V3:
- lov_dump_lmm_v3(level, (struct lov_mds_md_v3 *)lmm);
- break;
- default:
- CDEBUG(level, "unrecognized lmm_magic %x, assuming %x\n",
- magic, LOV_MAGIC_V1);
- lov_dump_lmm_common(level, lmm);
- break;
- }
-}
-
/* Pack LOV object metadata for disk storage. It is packed in LE byte
* order and is opaque to the networking layer.
*
@@ -192,13 +172,13 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
if (*lmmp && !lsm) {
stripe_count = le16_to_cpu((*lmmp)->lmm_stripe_count);
lmm_size = lov_mds_md_size(stripe_count, lmm_magic);
- OBD_FREE_LARGE(*lmmp, lmm_size);
+ kvfree(*lmmp);
*lmmp = NULL;
return 0;
}
if (!*lmmp) {
- OBD_ALLOC_LARGE(*lmmp, lmm_size);
+ *lmmp = libcfs_kvzalloc(lmm_size, GFP_NOFS);
if (!*lmmp)
return -ENOMEM;
}
@@ -273,7 +253,6 @@ __u16 lov_get_stripecnt(struct lov_obd *lov, __u32 magic, __u16 stripe_count)
return stripe_count;
}
-
static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count)
{
int rc;
@@ -285,7 +264,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count)
CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n",
le32_to_cpu(*(__u32 *)lmm), lmm_bytes);
sz = lmm_bytes * 2 + 1;
- OBD_ALLOC_LARGE(buffer, sz);
+ buffer = libcfs_kvzalloc(sz, GFP_NOFS);
if (buffer != NULL) {
int i;
@@ -293,7 +272,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count)
sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]);
buffer[sz - 1] = '\0';
CERROR("%s\n", buffer);
- OBD_FREE_LARGE(buffer, sz);
+ kvfree(buffer);
}
return -EINVAL;
}
@@ -347,7 +326,6 @@ int lov_free_memmd(struct lov_stripe_md **lsmp)
return refc;
}
-
/* Unpack LOV object metadata from disk storage. It is packed in LE byte
* order and is opaque to the networking layer.
*/
@@ -367,9 +345,11 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
if (rc)
return rc;
magic = le32_to_cpu(lmm->lmm_magic);
+ pattern = le32_to_cpu(lmm->lmm_pattern);
} else {
magic = LOV_MAGIC;
stripe_count = lov_get_stripecnt(lov, magic, 0);
+ pattern = LOV_PATTERN_RAID0;
}
/* If we aren't passed an lsmp struct, we just want the size */
@@ -384,7 +364,6 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return 0;
}
- pattern = le32_to_cpu(lmm->lmm_pattern);
lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic);
if (lsm_size < 0)
return lsm_size;
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_page.c b/kernel/drivers/staging/lustre/lustre/lov/lov_page.c
index c4596e8e5..463cadbd9 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_page.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_page.c
@@ -208,7 +208,6 @@ out:
return rc;
}
-
static const struct cl_page_operations lov_empty_page_ops = {
.cpo_fini = lov_empty_page_fini,
.cpo_print = lov_page_print
@@ -228,5 +227,4 @@ int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj,
return 0;
}
-
/** @} lov */
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_pool.c b/kernel/drivers/staging/lustre/lustre/lov/lov_pool.c
index d96163de7..b03827ef6 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_pool.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_pool.c
@@ -64,10 +64,10 @@ void lov_pool_putref(struct pool_desc *pool)
if (atomic_dec_and_test(&pool->pool_refcount)) {
LASSERT(hlist_unhashed(&pool->pool_hash));
LASSERT(list_empty(&pool->pool_list));
- LASSERT(pool->pool_proc_entry == NULL);
+ LASSERT(pool->pool_debugfs_entry == NULL);
lov_ost_pool_free(&(pool->pool_rr.lqr_pool));
lov_ost_pool_free(&(pool->pool_obds));
- OBD_FREE_PTR(pool);
+ kfree(pool);
}
}
@@ -142,17 +142,16 @@ static void pool_hashrefcount_put_locked(struct cfs_hash *hs,
lov_pool_putref_locked(pool);
}
-cfs_hash_ops_t pool_hash_operations = {
+struct cfs_hash_ops pool_hash_operations = {
.hs_hash = pool_hashfn,
- .hs_key = pool_key,
+ .hs_key = pool_key,
.hs_keycmp = pool_hashkey_keycmp,
.hs_object = pool_hashobject,
- .hs_get = pool_hashrefcount_get,
+ .hs_get = pool_hashrefcount_get,
.hs_put_locked = pool_hashrefcount_put_locked,
};
-#if defined (CONFIG_PROC_FS)
/* ifdef needed for liblustre support */
/*
* pool /proc seq_file methods
@@ -210,7 +209,7 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos)
return NULL;
}
- OBD_ALLOC_PTR(iter);
+ iter = kzalloc(sizeof(*iter), GFP_NOFS);
if (!iter)
return ERR_PTR(-ENOMEM);
iter->magic = POOL_IT_MAGIC;
@@ -246,7 +245,7 @@ static void pool_proc_stop(struct seq_file *s, void *v)
* will work */
s->private = iter->pool;
lov_pool_putref(iter->pool);
- OBD_FREE_PTR(iter);
+ kfree(iter);
}
return;
}
@@ -269,7 +268,7 @@ static int pool_proc_show(struct seq_file *s, void *v)
return 0;
}
-static struct seq_operations pool_proc_ops = {
+static const struct seq_operations pool_proc_ops = {
.start = pool_proc_start,
.next = pool_proc_next,
.stop = pool_proc_stop,
@@ -283,7 +282,8 @@ static int pool_proc_open(struct inode *inode, struct file *file)
rc = seq_open(file, &pool_proc_ops);
if (!rc) {
struct seq_file *s = file->private_data;
- s->private = PDE_DATA(inode);
+
+ s->private = inode->i_private;
}
return rc;
}
@@ -294,29 +294,6 @@ static struct file_operations pool_proc_operations = {
.llseek = seq_lseek,
.release = seq_release,
};
-#endif /* CONFIG_PROC_FS */
-
-void lov_dump_pool(int level, struct pool_desc *pool)
-{
- int i;
-
- lov_pool_getref(pool);
-
- CDEBUG(level, "pool "LOV_POOLNAMEF" has %d members\n",
- pool->pool_name, pool->pool_obds.op_count);
- down_read(&pool_tgt_rw_sem(pool));
-
- for (i = 0; i < pool_tgt_count(pool) ; i++) {
- if (!pool_tgt(pool, i) || !(pool_tgt(pool, i))->ltd_exp)
- continue;
- CDEBUG(level, "pool "LOV_POOLNAMEF"[%d] = %s\n",
- pool->pool_name, i,
- obd_uuid2str(&((pool_tgt(pool, i))->ltd_uuid)));
- }
-
- up_read(&pool_tgt_rw_sem(pool));
- lov_pool_putref(pool);
-}
#define LOV_POOL_INIT_COUNT 2
int lov_ost_pool_init(struct ost_pool *op, unsigned int count)
@@ -327,7 +304,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count)
op->op_count = 0;
init_rwsem(&op->op_rw_sem);
op->op_size = count;
- OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0]));
+ op->op_array = kcalloc(op->op_size, sizeof(op->op_array[0]), GFP_NOFS);
if (op->op_array == NULL) {
op->op_size = 0;
return -ENOMEM;
@@ -347,13 +324,13 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count)
return 0;
new_size = max(min_count, 2 * op->op_size);
- OBD_ALLOC(new, new_size * sizeof(op->op_array[0]));
+ new = kcalloc(new_size, sizeof(op->op_array[0]), GFP_NOFS);
if (new == NULL)
return -ENOMEM;
/* copy old array to new one */
memcpy(new, op->op_array, op->op_size * sizeof(op->op_array[0]));
- OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+ kfree(op->op_array);
op->op_array = new;
op->op_size = new_size;
return 0;
@@ -411,7 +388,7 @@ int lov_ost_pool_free(struct ost_pool *op)
down_write(&op->op_rw_sem);
- OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+ kfree(op->op_array);
op->op_array = NULL;
op->op_count = 0;
op->op_size = 0;
@@ -420,7 +397,6 @@ int lov_ost_pool_free(struct ost_pool *op)
return 0;
}
-
int lov_pool_new(struct obd_device *obd, char *poolname)
{
struct lov_obd *lov;
@@ -432,8 +408,8 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
if (strlen(poolname) > LOV_MAXPOOLNAME)
return -ENAMETOOLONG;
- OBD_ALLOC_PTR(new_pool);
- if (new_pool == NULL)
+ new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS);
+ if (!new_pool)
return -ENOMEM;
strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
@@ -454,20 +430,21 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
INIT_HLIST_NODE(&new_pool->pool_hash);
-#if defined (CONFIG_PROC_FS)
/* we need this assert seq_file is not implemented for liblustre */
/* get ref for /proc file */
lov_pool_getref(new_pool);
- new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry,
- poolname, new_pool,
- &pool_proc_operations);
- if (IS_ERR(new_pool->pool_proc_entry)) {
- CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname);
- new_pool->pool_proc_entry = NULL;
+ new_pool->pool_debugfs_entry = ldebugfs_add_simple(
+ lov->lov_pool_debugfs_entry,
+ poolname, new_pool,
+ &pool_proc_operations);
+ if (IS_ERR_OR_NULL(new_pool->pool_debugfs_entry)) {
+ CWARN("Cannot add debugfs pool entry "LOV_POOLNAMEF"\n",
+ poolname);
+ new_pool->pool_debugfs_entry = NULL;
lov_pool_putref(new_pool);
}
- CDEBUG(D_INFO, "pool %p - proc %p\n", new_pool, new_pool->pool_proc_entry);
-#endif
+ CDEBUG(D_INFO, "pool %p - proc %p\n",
+ new_pool, new_pool->pool_debugfs_entry);
spin_lock(&obd->obd_dev_lock);
list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
@@ -493,12 +470,12 @@ out_err:
lov->lov_pool_count--;
spin_unlock(&obd->obd_dev_lock);
- lprocfs_remove(&new_pool->pool_proc_entry);
+ ldebugfs_remove(&new_pool->pool_debugfs_entry);
lov_ost_pool_free(&new_pool->pool_rr.lqr_pool);
out_free_pool_obds:
lov_ost_pool_free(&new_pool->pool_obds);
- OBD_FREE_PTR(new_pool);
+ kfree(new_pool);
return rc;
}
@@ -514,9 +491,9 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
if (pool == NULL)
return -ENOENT;
- if (pool->pool_proc_entry != NULL) {
- CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry);
- lprocfs_remove(&pool->pool_proc_entry);
+ if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) {
+ CDEBUG(D_INFO, "proc entry %p\n", pool->pool_debugfs_entry);
+ ldebugfs_remove(&pool->pool_debugfs_entry);
lov_pool_putref(pool);
}
@@ -531,7 +508,6 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
return 0;
}
-
int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
{
struct obd_uuid ost_uuid;
@@ -548,7 +524,6 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
obd_str2uuid(&ost_uuid, ostname);
-
/* search ost in lov array */
obd_getref(obd);
for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lov_request.c b/kernel/drivers/staging/lustre/lustre/lov/lov_request.c
index 933e2d1f8..1a150c267 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -67,23 +67,11 @@ void lov_finish_set(struct lov_request_set *set)
list_del_init(&req->rq_link);
if (req->rq_oi.oi_oa)
- OBDO_FREE(req->rq_oi.oi_oa);
- if (req->rq_oi.oi_md)
- OBD_FREE_LARGE(req->rq_oi.oi_md, req->rq_buflen);
- if (req->rq_oi.oi_osfs)
- OBD_FREE(req->rq_oi.oi_osfs,
- sizeof(*req->rq_oi.oi_osfs));
- OBD_FREE(req, sizeof(*req));
+ kmem_cache_free(obdo_cachep, req->rq_oi.oi_oa);
+ kfree(req->rq_oi.oi_osfs);
+ kfree(req);
}
-
- if (set->set_pga) {
- int len = set->set_oabufs * sizeof(*set->set_pga);
- OBD_FREE_LARGE(set->set_pga, len);
- }
- if (set->set_lockh)
- lov_llh_put(set->set_lockh);
-
- OBD_FREE(set, sizeof(*set));
+ kfree(set);
}
int lov_set_finished(struct lov_request_set *set, int idempotent)
@@ -214,7 +202,7 @@ static int common_attr_done(struct lov_request_set *set)
if (!atomic_read(&set->set_success))
return -EIO;
- OBDO_ALLOC(tmp_oa);
+ tmp_oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
if (tmp_oa == NULL) {
rc = -ENOMEM;
goto out;
@@ -248,7 +236,7 @@ static int common_attr_done(struct lov_request_set *set)
memcpy(set->set_oi->oi_oa, tmp_oa, sizeof(*set->set_oi->oi_oa));
out:
if (tmp_oa)
- OBDO_FREE(tmp_oa);
+ kmem_cache_free(obdo_cachep, tmp_oa);
return rc;
}
@@ -286,8 +274,8 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
struct lov_obd *lov = &exp->exp_obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
- if (set == NULL)
+ set = kzalloc(sizeof(*set), GFP_NOFS);
+ if (!set)
return -ENOMEM;
lov_init_set(set);
@@ -312,8 +300,8 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
- if (req == NULL) {
+ req = kzalloc(sizeof(*req), GFP_NOFS);
+ if (!req) {
rc = -ENOMEM;
goto out_set;
}
@@ -321,9 +309,10 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- OBDO_ALLOC(req->rq_oi.oi_oa);
+ req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep,
+ GFP_NOFS | __GFP_ZERO);
if (req->rq_oi.oi_oa == NULL) {
- OBD_FREE(req, sizeof(*req));
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
@@ -331,7 +320,6 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
sizeof(*req->rq_oi.oi_oa));
req->rq_oi.oi_oa->o_oi = loi->loi_oi;
req->rq_oi.oi_cb_up = cb_getattr_update;
- req->rq_oi.oi_capa = oinfo->oi_capa;
lov_set_add_req(req, set);
}
@@ -369,8 +357,8 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
struct lov_obd *lov = &exp->exp_obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
- if (set == NULL)
+ set = kzalloc(sizeof(*set), GFP_NOFS);
+ if (!set)
return -ENOMEM;
lov_init_set(set);
@@ -395,8 +383,8 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
- if (req == NULL) {
+ req = kzalloc(sizeof(*req), GFP_NOFS);
+ if (!req) {
rc = -ENOMEM;
goto out_set;
}
@@ -404,9 +392,10 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- OBDO_ALLOC(req->rq_oi.oi_oa);
+ req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep,
+ GFP_NOFS | __GFP_ZERO);
if (req->rq_oi.oi_oa == NULL) {
- OBD_FREE(req, sizeof(*req));
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
@@ -488,8 +477,8 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
struct lov_obd *lov = &exp->exp_obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
- if (set == NULL)
+ set = kzalloc(sizeof(*set), GFP_NOFS);
+ if (!set)
return -ENOMEM;
lov_init_set(set);
@@ -511,17 +500,18 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
- if (req == NULL) {
+ req = kzalloc(sizeof(*req), GFP_NOFS);
+ if (!req) {
rc = -ENOMEM;
goto out_set;
}
req->rq_stripe = i;
req->rq_idx = loi->loi_ost_idx;
- OBDO_ALLOC(req->rq_oi.oi_oa);
+ req->rq_oi.oi_oa = kmem_cache_alloc(obdo_cachep,
+ GFP_NOFS | __GFP_ZERO);
if (req->rq_oi.oi_oa == NULL) {
- OBD_FREE(req, sizeof(*req));
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
@@ -530,7 +520,6 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
req->rq_oi.oi_oa->o_oi = loi->loi_oi;
req->rq_oi.oi_oa->o_stripe_idx = i;
req->rq_oi.oi_cb_up = cb_setattr_update;
- req->rq_oi.oi_capa = oinfo->oi_capa;
if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE) {
int off = lov_stripe_offset(oinfo->oi_md,
@@ -619,8 +608,7 @@ void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs,
if (tmp & 1) {
if (quit)
break;
- else
- quit = 1;
+ quit = 1;
shift = 0;
}
tmp >>= 1;
@@ -716,8 +704,8 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
struct lov_obd *lov = &obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
- if (set == NULL)
+ set = kzalloc(sizeof(*set), GFP_NOFS);
+ if (!set)
return -ENOMEM;
lov_init_set(set);
@@ -742,15 +730,16 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
- if (req == NULL) {
+ req = kzalloc(sizeof(*req), GFP_NOFS);
+ if (!req) {
rc = -ENOMEM;
goto out_set;
}
- OBD_ALLOC(req->rq_oi.oi_osfs, sizeof(*req->rq_oi.oi_osfs));
- if (req->rq_oi.oi_osfs == NULL) {
- OBD_FREE(req, sizeof(*req));
+ req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs),
+ GFP_NOFS);
+ if (!req->rq_oi.oi_osfs) {
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/kernel/drivers/staging/lustre/lustre/lov/lovsub_dev.c
index 42336f13a..8bc04c8d3 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lovsub_dev.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lovsub_dev.c
@@ -56,7 +56,7 @@ static void lovsub_req_completion(const struct lu_env *env,
struct lovsub_req *lsr;
lsr = cl2lovsub_req(slice);
- OBD_SLAB_FREE_PTR(lsr, lovsub_req_kmem);
+ kmem_cache_free(lovsub_req_kmem, lsr);
}
/**
@@ -136,7 +136,7 @@ static struct lu_device *lovsub_device_free(const struct lu_env *env,
lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer);
}
cl_device_fini(lu2cl_dev(d));
- OBD_FREE_PTR(lsd);
+ kfree(lsd);
return next;
}
@@ -146,7 +146,7 @@ static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev,
struct lovsub_req *lsr;
int result;
- OBD_SLAB_ALLOC_PTR_GFP(lsr, lovsub_req_kmem, GFP_NOFS);
+ lsr = kmem_cache_alloc(lovsub_req_kmem, GFP_NOFS | __GFP_ZERO);
if (lsr != NULL) {
cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops);
result = 0;
@@ -172,7 +172,7 @@ static struct lu_device *lovsub_device_alloc(const struct lu_env *env,
struct lu_device *d;
struct lovsub_device *lsd;
- OBD_ALLOC_PTR(lsd);
+ lsd = kzalloc(sizeof(*lsd), GFP_NOFS);
if (lsd != NULL) {
int result;
@@ -205,5 +205,4 @@ struct lu_device_type lovsub_device_type = {
.ldt_ctx_tags = LCT_CL_THREAD
};
-
/** @} lov */
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/kernel/drivers/staging/lustre/lustre/lov/lovsub_lock.c
index 62b696d25..1a3e30a14 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lovsub_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lovsub_lock.c
@@ -59,7 +59,7 @@ static void lovsub_lock_fini(const struct lu_env *env,
lsl = cl2lovsub_lock(slice);
LASSERT(list_empty(&lsl->lss_parents));
- OBD_SLAB_FREE_PTR(lsl, lovsub_lock_kmem);
+ kmem_cache_free(lovsub_lock_kmem, lsl);
}
static void lovsub_parent_lock(const struct lu_env *env, struct lov_lock *lov)
@@ -453,7 +453,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj,
struct lovsub_lock *lsk;
int result;
- OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, GFP_NOFS);
+ lsk = kmem_cache_alloc(lovsub_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (lsk != NULL) {
INIT_LIST_HEAD(&lsk->lss_parents);
cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops);
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lovsub_object.c b/kernel/drivers/staging/lustre/lustre/lov/lovsub_object.c
index 57e3629fc..d775e28d4 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lovsub_object.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lovsub_object.c
@@ -91,7 +91,7 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj)
lu_object_fini(obj);
lu_object_header_fini(&los->lso_header.coh_lu);
- OBD_SLAB_FREE_PTR(los, lovsub_object_kmem);
+ kmem_cache_free(lovsub_object_kmem, los);
}
static int lovsub_object_print(const struct lu_env *env, void *cookie,
@@ -120,8 +120,6 @@ static int lovsub_object_glimpse(const struct lu_env *env,
return cl_object_glimpse(env, &los->lso_super->lo_cl, lvb);
}
-
-
static const struct cl_object_operations lovsub_ops = {
.coo_page_init = lovsub_page_init,
.coo_lock_init = lovsub_lock_init,
@@ -145,7 +143,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env,
struct lovsub_object *los;
struct lu_object *obj;
- OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, GFP_NOFS);
+ los = kmem_cache_alloc(lovsub_object_kmem, GFP_NOFS | __GFP_ZERO);
if (los != NULL) {
struct cl_object_header *hdr;
diff --git a/kernel/drivers/staging/lustre/lustre/lov/lproc_lov.c b/kernel/drivers/staging/lustre/lustre/lov/lproc_lov.c
index 174cbf5c1..a0be15c6b 100644
--- a/kernel/drivers/staging/lustre/lustre/lov/lproc_lov.c
+++ b/kernel/drivers/staging/lustre/lustre/lov/lproc_lov.c
@@ -71,6 +71,7 @@ static ssize_t lov_stripesize_seq_write(struct file *file,
desc->ld_default_stripe_size = val;
return count;
}
+
LPROC_SEQ_FOPS(lov_stripesize);
static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
@@ -102,6 +103,7 @@ static ssize_t lov_stripeoffset_seq_write(struct file *file,
desc->ld_default_stripe_offset = val;
return count;
}
+
LPROC_SEQ_FOPS(lov_stripeoffset);
static int lov_stripetype_seq_show(struct seq_file *m, void *v)
@@ -133,6 +135,7 @@ static ssize_t lov_stripetype_seq_write(struct file *file,
desc->ld_pattern = val;
return count;
}
+
LPROC_SEQ_FOPS(lov_stripetype);
static int lov_stripecount_seq_show(struct seq_file *m, void *v)
@@ -164,31 +167,32 @@ static ssize_t lov_stripecount_seq_write(struct file *file,
desc->ld_default_stripe_count = val;
return count;
}
+
LPROC_SEQ_FOPS(lov_stripecount);
-static int lov_numobd_seq_show(struct seq_file *m, void *v)
+static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct lov_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
- seq_printf(m, "%u\n", desc->ld_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lov_numobd);
+LUSTRE_RO_ATTR(numobd);
-static int lov_activeobd_seq_show(struct seq_file *m, void *v)
+static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct lov_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
- seq_printf(m, "%u\n", desc->ld_active_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_active_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lov_activeobd);
+LUSTRE_RO_ATTR(activeobd);
static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
{
@@ -200,6 +204,7 @@ static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid);
return 0;
}
+
LPROC_SEQ_FOPS_RO(lov_desc_uuid);
static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
@@ -258,48 +263,34 @@ static int lov_target_seq_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
return 0;
}
-LPROC_SEQ_FOPS_RO_TYPE(lov, uuid);
-LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree);
-LPROC_SEQ_FOPS_RO_TYPE(lov, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
-
static struct lprocfs_vars lprocfs_lov_obd_vars[] = {
- { "uuid", &lov_uuid_fops, NULL, 0 },
{ "stripesize", &lov_stripesize_fops, NULL },
{ "stripeoffset", &lov_stripeoffset_fops, NULL },
{ "stripecount", &lov_stripecount_fops, NULL },
{ "stripetype", &lov_stripetype_fops, NULL },
- { "numobd", &lov_numobd_fops, NULL, 0 },
- { "activeobd", &lov_activeobd_fops, NULL, 0 },
- { "filestotal", &lov_filestotal_fops, NULL, 0 },
- { "filesfree", &lov_filesfree_fops, NULL, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
- { "blocksize", &lov_blksize_fops, NULL, 0 },
- { "kbytestotal", &lov_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &lov_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &lov_kbytesavail_fops, NULL, 0 },
{ "desc_uuid", &lov_desc_uuid_fops, NULL, 0 },
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(lov, numrefs);
+static struct attribute *lov_attrs[] = {
+ &lustre_attr_activeobd.attr,
+ &lustre_attr_numobd.attr,
+ NULL,
+};
-static struct lprocfs_vars lprocfs_lov_module_vars[] = {
- { "num_refs", &lov_numrefs_fops, NULL, 0 },
- { NULL }
+static struct attribute_group lov_attr_group = {
+ .attrs = lov_attrs,
};
void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_lov_module_vars;
- lvars->obd_vars = lprocfs_lov_obd_vars;
+ lvars->sysfs_vars = &lov_attr_group;
+ lvars->obd_vars = lprocfs_lov_obd_vars;
}
const struct file_operations lov_proc_target_fops = {
diff --git a/kernel/drivers/staging/lustre/lustre/mdc/Makefile b/kernel/drivers/staging/lustre/lustre/mdc/Makefile
index 2516551a6..99ba9ff0d 100644
--- a/kernel/drivers/staging/lustre/lustre/mdc/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/mdc/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += mdc.o
-mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o
-mdc-$(CONFIG_PROC_FS) += lproc_mdc.o
+mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.o
diff --git a/kernel/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/kernel/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
index acfe08e45..1c95f87a0 100644
--- a/kernel/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
+++ b/kernel/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
@@ -40,29 +40,34 @@
#include "../include/lprocfs_status.h"
#include "mdc_internal.h"
-static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
+static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ int len;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
+ len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
- const char __user *buffer,
- size_t count,
- loff_t *off)
+static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev =
- ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
- int val, rc;
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -75,11 +80,11 @@ static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
+LUSTRE_RW_ATTR(max_rpcs_in_flight);
static int mdc_kuc_open(struct inode *inode, struct file *file)
{
- return single_open(file, NULL, PDE_DATA(inode));
+ return single_open(file, NULL, inode->i_private);
}
/* temporary for testing */
@@ -106,7 +111,7 @@ static ssize_t mdc_kuc_write(struct file *file,
len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN +
/* for mockup below */ 2 * cfs_size_round(sizeof(*hai));
- OBD_ALLOC(lh, len);
+ lh = kzalloc(len, GFP_NOFS);
if (!lh)
return -ENOMEM;
@@ -141,13 +146,13 @@ static ssize_t mdc_kuc_write(struct file *file,
rc = libcfs_kkuc_msg_put(fp, lh);
fput(fp);
}
- OBD_FREE(lh, len);
+ kfree(lh);
if (rc < 0)
return rc;
return count;
}
-struct file_operations mdc_kuc_fops = {
+static struct file_operations mdc_kuc_fops = {
.open = mdc_kuc_open,
.write = mdc_kuc_write,
.release = single_release,
@@ -155,49 +160,39 @@ struct file_operations mdc_kuc_fops = {
LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
-static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
+/*
+ * Note: below sysfs entry is provided, but not currently in use, instead
+ * sbi->sb_md_brw_size is used, the per obd variable should be used
+ * when DNE is enabled, and dir pages are managed in MDC layer.
+ * Don't forget to enable sysfs store function then.
+ */
+static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return lprocfs_obd_rd_max_pages_per_rpc(m, m->private);
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct client_obd *cli = &dev->u.cli;
+
+ return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
}
-LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
+LUSTRE_RO_ATTR(max_pages_per_rpc);
LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
- { "uuid", &mdc_uuid_fops, NULL, 0 },
{ "ping", &mdc_ping_fops, NULL, 0222 },
{ "connect_flags", &mdc_connect_flags_fops, NULL, 0 },
- { "blocksize", &mdc_blksize_fops, NULL, 0 },
- { "kbytestotal", &mdc_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &mdc_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &mdc_kbytesavail_fops, NULL, 0 },
- { "filestotal", &mdc_filestotal_fops, NULL, 0 },
- { "filesfree", &mdc_filesfree_fops, NULL, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
{ "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 },
{ "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 },
- /*
- * FIXME: below proc entry is provided, but not in used, instead
- * sbi->sb_md_brw_size is used, the per obd variable should be used
- * when CMD is enabled, and dir pages are managed in MDC layer.
- * Remember to enable proc write function.
- */
- { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, NULL, 0 },
- { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, NULL, 0 },
{ "timeouts", &mdc_timeouts_fops, NULL, 0 },
{ "import", &mdc_import_fops, NULL, 0 },
{ "state", &mdc_state_fops, NULL, 0 },
@@ -206,15 +201,18 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(mdc, numrefs);
+static struct attribute *mdc_attrs[] = {
+ &lustre_attr_max_rpcs_in_flight.attr,
+ &lustre_attr_max_pages_per_rpc.attr,
+ NULL,
+};
-static struct lprocfs_vars lprocfs_mdc_module_vars[] = {
- { "num_refs", &mdc_numrefs_fops, NULL, 0 },
- { NULL }
+static struct attribute_group mdc_attr_group = {
+ .attrs = mdc_attrs,
};
void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_mdc_module_vars;
+ lvars->sysfs_vars = &mdc_attr_group;
lvars->obd_vars = lprocfs_mdc_obd_vars;
}
diff --git a/kernel/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/kernel/drivers/staging/lustre/lustre/mdc/mdc_internal.h
index 81780c943..29b46f754 100644
--- a/kernel/drivers/staging/lustre/lustre/mdc/mdc_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/mdc/mdc_internal.h
@@ -40,27 +40,17 @@
#include "../include/lustre_mdc.h"
#include "../include/lustre_mds.h"
-#if defined CONFIG_PROC_FS
void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid,
- struct obd_capa *oc, __u64 valid, int ea_size,
- __u32 suppgid, int flags);
-void mdc_pack_capa(struct ptlrpc_request *req,
- const struct req_msg_field *field, struct obd_capa *oc);
+ __u64 valid, int ea_size, __u32 suppgid, int flags);
int mdc_pack_req(struct ptlrpc_request *req, int version, int opc);
void mdc_is_subdir_pack(struct ptlrpc_request *req, const struct lu_fid *pfid,
const struct lu_fid *cfid, int flags);
void mdc_swap_layouts_pack(struct ptlrpc_request *req,
struct md_op_data *op_data);
void mdc_readdir_pack(struct ptlrpc_request *req, __u64 pgoff, __u32 size,
- const struct lu_fid *fid, struct obd_capa *oc);
+ const struct lu_fid *fid);
void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, int flags,
struct md_op_data *data, int ea_size);
void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
@@ -147,17 +137,6 @@ int mdc_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
ldlm_policy_data_t *policy, ldlm_mode_t mode,
ldlm_cancel_flags_t flags, void *opaque);
-static inline void mdc_set_capa_size(struct ptlrpc_request *req,
- const struct req_msg_field *field,
- struct obd_capa *oc)
-{
- if (oc == NULL)
- req_capsule_set_size(&req->rq_pill, field, RCL_CLIENT, 0);
- else
- /* it is already calculated as sizeof struct obd_capa */
- ;
-}
-
int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
struct lu_fid *fid, __u64 *bits);
diff --git a/kernel/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/kernel/drivers/staging/lustre/lustre/mdc/mdc_lib.c
index d3234cb1e..227fc9ee0 100644
--- a/kernel/drivers/staging/lustre/lustre/mdc/mdc_lib.c
+++ b/kernel/drivers/staging/lustre/lustre/mdc/mdc_lib.c
@@ -39,7 +39,6 @@
#include "../include/lustre/lustre_idl.h"
#include "mdc_internal.h"
-
static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
{
LASSERT(b != NULL);
@@ -52,24 +51,6 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
b->capability = cfs_curproc_cap_pack();
}
-void mdc_pack_capa(struct ptlrpc_request *req,
- const struct req_msg_field *field,
- struct obd_capa *oc)
-{
- struct req_capsule *pill = &req->rq_pill;
- struct lustre_capa *c;
-
- if (oc == NULL) {
- LASSERT(req_capsule_get_size(pill, field, RCL_CLIENT) == 0);
- return;
- }
-
- c = req_capsule_client_get(pill, field);
- LASSERT(c != NULL);
- capa_cpy(c, oc);
- DEBUG_CAPA(D_SEC, c, "pack");
-}
-
void mdc_is_subdir_pack(struct ptlrpc_request *req, const struct lu_fid *pfid,
const struct lu_fid *cfid, int flags)
{
@@ -95,13 +76,9 @@ void mdc_swap_layouts_pack(struct ptlrpc_request *req,
b->fid1 = op_data->op_fid1;
b->fid2 = op_data->op_fid2;
b->valid |= OBD_MD_FLID;
-
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
- mdc_pack_capa(req, &RMF_CAPA2, op_data->op_capa2);
}
-void mdc_pack_body(struct ptlrpc_request *req,
- const struct lu_fid *fid, struct obd_capa *oc,
+void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid,
__u64 valid, int ea_size, __u32 suppgid, int flags)
{
struct mdt_body *b = req_capsule_client_get(&req->rq_pill,
@@ -114,12 +91,11 @@ void mdc_pack_body(struct ptlrpc_request *req,
if (fid) {
b->fid1 = *fid;
b->valid |= OBD_MD_FLID;
- mdc_pack_capa(req, &RMF_CAPA1, oc);
}
}
void mdc_readdir_pack(struct ptlrpc_request *req, __u64 pgoff,
- __u32 size, const struct lu_fid *fid, struct obd_capa *oc)
+ __u32 size, const struct lu_fid *fid)
{
struct mdt_body *b = req_capsule_client_get(&req->rq_pill,
&RMF_MDT_BODY);
@@ -129,8 +105,6 @@ void mdc_readdir_pack(struct ptlrpc_request *req, __u64 pgoff,
b->nlink = size; /* !! */
__mdc_pack_body(b, -1);
b->mode = LUDA_FID | LUDA_TYPE;
-
- mdc_pack_capa(req, &RMF_CAPA1, oc);
}
/* packing of MDS records */
@@ -145,7 +119,6 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create));
rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
-
rec->cr_opcode = REINT_CREATE;
rec->cr_fsuid = uid;
rec->cr_fsgid = gid;
@@ -164,8 +137,6 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
rec->cr_bias = op_data->op_bias;
rec->cr_umask = current_umask();
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
-
tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
LOGL0(op_data->op_name, op_data->op_namelen, tmp);
@@ -235,10 +206,6 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
rec->cr_umask = current_umask();
rec->cr_old_handle = op_data->op_handle;
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
- /* the next buffer is child capa, which is used for replay,
- * will be packed from the data in reply message. */
-
if (op_data->op_name) {
tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
LOGL0(op_data->op_name, op_data->op_namelen, tmp);
@@ -286,7 +253,7 @@ static inline __u64 attr_pack(unsigned int ia_valid)
sa_valid |= MDS_ATTR_KILL_SGID;
if (ia_valid & ATTR_CTIME_SET)
sa_valid |= MDS_ATTR_CTIME_SET;
- if (ia_valid & ATTR_FROM_OPEN)
+ if (ia_valid & ATTR_OPEN)
sa_valid |= MDS_ATTR_FROM_OPEN;
if (ia_valid & ATTR_BLOCKS)
sa_valid |= MDS_ATTR_BLOCKS;
@@ -347,8 +314,6 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
mdc_setattr_pack_rec(rec, op_data);
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
-
if (op_data->op_flags & (MF_SOM_CHANGE | MF_EPOCH_OPEN)) {
epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH);
mdc_ioepoch_pack(epoch, op_data);
@@ -396,8 +361,6 @@ void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data)
rec->ul_time = op_data->op_mod_time;
rec->ul_bias = op_data->op_bias;
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
-
tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
LASSERT(tmp != NULL);
LOGL0(op_data->op_name, op_data->op_namelen, tmp);
@@ -423,9 +386,6 @@ void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data)
rec->lk_time = op_data->op_mod_time;
rec->lk_bias = op_data->op_bias;
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
- mdc_pack_capa(req, &RMF_CAPA2, op_data->op_capa2);
-
tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
LOGL0(op_data->op_name, op_data->op_namelen, tmp);
}
@@ -452,9 +412,6 @@ void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
rec->rn_mode = op_data->op_mode;
rec->rn_bias = op_data->op_bias;
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
- mdc_pack_capa(req, &RMF_CAPA2, op_data->op_capa2);
-
tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
LOGL0(old, oldlen, tmp);
@@ -483,8 +440,6 @@ void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, int flags,
b->fid2 = op_data->op_fid2;
b->valid |= OBD_MD_FLID;
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
-
if (op_data->op_name) {
char *tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
@@ -524,7 +479,6 @@ void mdc_close_pack(struct ptlrpc_request *req, struct md_op_data *op_data)
rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
mdc_setattr_pack_rec(rec, op_data);
- mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
mdc_ioepoch_pack(epoch, op_data);
mdc_hsm_release_pack(req, op_data);
}
diff --git a/kernel/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/kernel/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index d1c224ecd..d4bf34b61 100644
--- a/kernel/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/kernel/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -322,12 +322,6 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp,
return ERR_PTR(-ENOMEM);
}
- /* parent capability */
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
- /* child capability, reserve the size according to parent capa, it will
- * be filled after we get the reply */
- mdc_set_capa_size(req, &RMF_CAPA2, op_data->op_capa1);
-
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
op_data->op_namelen + 1);
req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
@@ -369,15 +363,11 @@ mdc_intent_getxattr_pack(struct obd_export *exp,
int rc, count = 0, maxdata;
LIST_HEAD(cancels);
-
-
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
&RQF_LDLM_INTENT_GETXATTR);
if (req == NULL)
return ERR_PTR(-ENOMEM);
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
-
rc = ldlm_prep_enqueue_req(exp, req, &cancels, count);
if (rc) {
ptlrpc_request_free(req);
@@ -391,8 +381,8 @@ mdc_intent_getxattr_pack(struct obd_export *exp,
maxdata = class_exp2cliimp(exp)->imp_connect_data.ocd_max_easize;
/* pack the intended request */
- mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
- op_data->op_valid, maxdata, -1, 0);
+ mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid, maxdata, -1,
+ 0);
req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
RCL_SERVER, maxdata);
@@ -422,7 +412,6 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp,
if (req == NULL)
return ERR_PTR(-ENOMEM);
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
op_data->op_namelen + 1);
@@ -455,7 +444,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp,
struct obd_device *obddev = class_exp2obd(exp);
u64 valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE |
OBD_MD_FLMODEASIZE | OBD_MD_FLDIREA |
- OBD_MD_FLMDSCAPA | OBD_MD_MEA |
+ OBD_MD_MEA |
(client_is_remote(exp) ?
OBD_MD_FLRMTPERM : OBD_MD_FLACL);
struct ldlm_intent *lit;
@@ -467,7 +456,6 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp,
if (req == NULL)
return ERR_PTR(-ENOMEM);
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
op_data->op_namelen + 1);
@@ -705,27 +693,6 @@ static int mdc_finish_enqueue(struct obd_export *exp,
if (perm == NULL)
return -EPROTO;
}
- if (body->valid & OBD_MD_FLMDSCAPA) {
- struct lustre_capa *capa, *p;
-
- capa = req_capsule_server_get(pill, &RMF_CAPA1);
- if (capa == NULL)
- return -EPROTO;
-
- if (it->it_op & IT_OPEN) {
- /* client fid capa will be checked in replay */
- p = req_capsule_client_get(pill, &RMF_CAPA2);
- LASSERT(p);
- *p = *capa;
- }
- }
- if (body->valid & OBD_MD_FLOSSCAPA) {
- struct lustre_capa *capa;
-
- capa = req_capsule_server_get(pill, &RMF_CAPA2);
- if (capa == NULL)
- return -EPROTO;
- }
} else if (it->it_op & IT_LAYOUT) {
/* maybe the lock was granted right away and layout
* is packed into RMF_DLM_LVB of req */
@@ -746,7 +713,7 @@ static int mdc_finish_enqueue(struct obd_export *exp,
LDLM_DEBUG(lock, "layout lock returned by: %s, lvb_len: %d\n",
ldlm_it2str(it->it_op), lvb_len);
- OBD_ALLOC_LARGE(lmm, lvb_len);
+ lmm = libcfs_kvzalloc(lvb_len, GFP_NOFS);
if (lmm == NULL) {
LDLM_LOCK_PUT(lock);
return -ENOMEM;
@@ -763,7 +730,7 @@ static int mdc_finish_enqueue(struct obd_export *exp,
}
unlock_res_and_lock(lock);
if (lmm != NULL)
- OBD_FREE_LARGE(lmm, lvb_len);
+ kvfree(lmm);
}
if (lock != NULL)
LDLM_LOCK_PUT(lock);
@@ -826,7 +793,7 @@ resend:
LASSERT(lmm && lmmsize == 0);
LASSERTF(einfo->ei_type == LDLM_FLOCK, "lock type %d\n",
einfo->ei_type);
- policy = (ldlm_policy_data_t *)lmm;
+ policy = lmm;
res_id.name[3] = LDLM_FLOCK;
req = NULL;
} else if (it->it_op & IT_OPEN) {
@@ -864,7 +831,7 @@ resend:
if (resends) {
req->rq_generation_set = 1;
req->rq_import_generation = generation;
- req->rq_sent = get_seconds() + resends;
+ req->rq_sent = ktime_get_real_seconds() + resends;
}
/* It is important to obtain rpc_lock first (if applicable), so that
@@ -918,7 +885,7 @@ resend:
/* Retry the create infinitely when we get -EINPROGRESS from
* server. This is required by the new quota design. */
- if (it && it->it_op & IT_CREAT &&
+ if (it->it_op & IT_CREAT &&
(int)lockrep->lock_policy_res2 == -EINPROGRESS) {
mdc_clear_replay_flag(req, rc);
ptlrpc_req_finished(req);
@@ -1251,7 +1218,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh);
out:
- OBD_FREE_PTR(einfo);
+ kfree(einfo);
minfo->mi_cb(req, minfo, rc);
return 0;
}
@@ -1307,7 +1274,7 @@ int mdc_intent_getattr_async(struct obd_export *exp,
ga->ga_einfo = einfo;
req->rq_interpret_reply = mdc_intent_getattr_async_interpret;
- ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+ ptlrpcd_add_req(req);
return 0;
}
diff --git a/kernel/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/kernel/drivers/staging/lustre/lustre/mdc/mdc_reint.c
index 5e9c6296c..c87c7d8ef 100644
--- a/kernel/drivers/staging/lustre/lustre/mdc/mdc_reint.c
+++ b/kernel/drivers/staging/lustre/lustre/mdc/mdc_reint.c
@@ -127,7 +127,6 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
ldlm_lock_list_put(&cancels, l_bl_ast, count);
return -ENOMEM;
}
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
if ((op_data->op_flags & (MF_SOM_CHANGE | MF_EPOCH_OPEN)) == 0)
req_capsule_set_size(&req->rq_pill, &RMF_MDT_EPOCH, RCL_CLIENT,
0);
@@ -144,8 +143,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
rpc_lock = obd->u.cli.cl_rpc_lock;
if (op_data->op_attr.ia_valid & (ATTR_MTIME | ATTR_CTIME))
- CDEBUG(D_INODE, "setting mtime "CFS_TIME_T
- ", ctime "CFS_TIME_T"\n",
+ CDEBUG(D_INODE, "setting mtime %ld, ctime %ld\n",
LTIME_S(op_data->op_attr.ia_mtime),
LTIME_S(op_data->op_attr.ia_ctime));
mdc_setattr_pack(req, op_data, ea, ealen, ea2, ea2len);
@@ -243,7 +241,6 @@ rebuild:
ldlm_lock_list_put(&cancels, l_bl_ast, count);
return -ENOMEM;
}
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
op_data->op_namelen + 1);
req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
@@ -271,7 +268,7 @@ rebuild:
if (resends) {
req->rq_generation_set = 1;
req->rq_import_generation = generation;
- req->rq_sent = get_seconds() + resends;
+ req->rq_sent = ktime_get_real_seconds() + resends;
}
level = LUSTRE_IMP_FULL;
resend:
@@ -297,18 +294,6 @@ rebuild:
CDEBUG(D_HA, "resend cross eviction\n");
return -EIO;
}
- } else if (rc == 0) {
- struct mdt_body *body;
- struct lustre_capa *capa;
-
- body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
- LASSERT(body);
- if (body->valid & OBD_MD_FLMDSCAPA) {
- capa = req_capsule_server_get(&req->rq_pill,
- &RMF_CAPA1);
- if (capa == NULL)
- rc = -EPROTO;
- }
}
*request = req;
@@ -343,7 +328,6 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data,
ldlm_lock_list_put(&cancels, l_bl_ast, count);
return -ENOMEM;
}
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
op_data->op_namelen + 1);
@@ -393,8 +377,6 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data,
ldlm_lock_list_put(&cancels, l_bl_ast, count);
return -ENOMEM;
}
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
- mdc_set_capa_size(req, &RMF_CAPA2, op_data->op_capa2);
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
op_data->op_namelen + 1);
@@ -452,8 +434,6 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data,
return -ENOMEM;
}
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
- mdc_set_capa_size(req, &RMF_CAPA2, op_data->op_capa2);
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, oldlen + 1);
req_capsule_set_size(&req->rq_pill, &RMF_SYMTGT, RCL_CLIENT, newlen+1);
diff --git a/kernel/drivers/staging/lustre/lustre/mdc/mdc_request.c b/kernel/drivers/staging/lustre/lustre/mdc/mdc_request.c
index f8ef5fe5e..16a5a10d3 100644
--- a/kernel/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/kernel/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -53,35 +53,8 @@
#define REQUEST_MINOR 244
-struct mdc_renew_capa_args {
- struct obd_capa *ra_oc;
- renew_capa_cb_t ra_cb;
-};
-
static int mdc_cleanup(struct obd_device *obd);
-static int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
- const struct req_msg_field *field, struct obd_capa **oc)
-{
- struct lustre_capa *capa;
- struct obd_capa *c;
-
- /* swabbed already in mdc_enqueue */
- capa = req_capsule_server_get(&req->rq_pill, field);
- if (capa == NULL)
- return -EPROTO;
-
- c = alloc_capa(CAPA_SITE_CLIENT);
- if (IS_ERR(c)) {
- CDEBUG(D_INFO, "alloc capa failed!\n");
- return PTR_ERR(c);
- } else {
- c->c_capa = *capa;
- *oc = c;
- return 0;
- }
-}
-
static inline int mdc_queue_wait(struct ptlrpc_request *req)
{
struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
@@ -100,23 +73,20 @@ static inline int mdc_queue_wait(struct ptlrpc_request *req)
return rc;
}
-/* Helper that implements most of mdc_getstatus and signal_completed_replay. */
-/* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
-static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid,
- struct obd_capa **pc, int level, int msg_flags)
+static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid)
{
struct ptlrpc_request *req;
struct mdt_body *body;
int rc;
- req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_GETSTATUS,
+ req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
+ &RQF_MDS_GETSTATUS,
LUSTRE_MDS_VERSION, MDS_GETSTATUS);
if (req == NULL)
return -ENOMEM;
- mdc_pack_body(req, NULL, NULL, 0, 0, -1, 0);
- lustre_msg_add_flags(req->rq_reqmsg, msg_flags);
- req->rq_send_state = level;
+ mdc_pack_body(req, NULL, 0, 0, -1, 0);
+ req->rq_send_state = LUSTRE_IMP_FULL;
ptlrpc_request_set_replen(req);
@@ -130,12 +100,6 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid,
goto out;
}
- if (body->valid & OBD_MD_FLMDSCAPA) {
- rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, pc);
- if (rc)
- goto out;
- }
-
*rootfid = body->fid1;
CDEBUG(D_NET,
"root fid="DFID", last_committed=%llu\n",
@@ -146,14 +110,6 @@ out:
return rc;
}
-/* This should be mdc_get_info("rootfid") */
-static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid,
- struct obd_capa **pc)
-{
- return send_getstatus(class_exp2cliimp(exp), rootfid, pc,
- LUSTRE_IMP_FULL, 0);
-}
-
/*
* This function now is known to always saying that it will receive 4 buffers
* from server. Even for cases when acl_size and md_size is zero, RPC header
@@ -203,14 +159,6 @@ static int mdc_getattr_common(struct obd_export *exp,
return -EPROTO;
}
- if (body->valid & OBD_MD_FLMDSCAPA) {
- struct lustre_capa *capa;
-
- capa = req_capsule_server_get(pill, &RMF_CAPA1);
- if (capa == NULL)
- return -EPROTO;
- }
-
return 0;
}
@@ -230,16 +178,14 @@ static int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
if (rc) {
ptlrpc_request_free(req);
return rc;
}
- mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
- op_data->op_valid, op_data->op_mode, -1, 0);
+ mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid,
+ op_data->op_mode, -1, 0);
req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
op_data->op_mode);
@@ -270,7 +216,6 @@ static int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
op_data->op_namelen + 1);
@@ -280,9 +225,8 @@ static int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
return rc;
}
- mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
- op_data->op_valid, op_data->op_mode,
- op_data->op_suppgids[0], 0);
+ mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid,
+ op_data->op_mode, op_data->op_suppgids[0], 0);
if (op_data->op_name) {
char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
@@ -333,7 +277,7 @@ static int mdc_is_subdir(struct obd_export *exp,
static int mdc_xattr_common(struct obd_export *exp,
const struct req_format *fmt,
const struct lu_fid *fid,
- struct obd_capa *oc, int opcode, u64 valid,
+ int opcode, u64 valid,
const char *xattr_name, const char *input,
int input_size, int output_size, int flags,
__u32 suppgid, struct ptlrpc_request **request)
@@ -348,7 +292,6 @@ static int mdc_xattr_common(struct obd_export *exp,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, oc);
if (xattr_name) {
xattr_namelen = strlen(xattr_name) + 1;
req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
@@ -402,13 +345,12 @@ static int mdc_xattr_common(struct obd_export *exp,
rec->sx_suppgid2 = -1;
rec->sx_fid = *fid;
rec->sx_valid = valid | OBD_MD_FLCTIME;
- rec->sx_time = get_seconds();
+ rec->sx_time = ktime_get_real_seconds();
rec->sx_size = output_size;
rec->sx_flags = flags;
- mdc_pack_capa(req, &RMF_CAPA1, oc);
} else {
- mdc_pack_body(req, fid, oc, valid, output_size, suppgid, flags);
+ mdc_pack_body(req, fid, valid, output_size, suppgid, flags);
}
if (xattr_name) {
@@ -442,23 +384,24 @@ static int mdc_xattr_common(struct obd_export *exp,
}
static int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, u64 valid, const char *xattr_name,
- const char *input, int input_size, int output_size,
- int flags, __u32 suppgid, struct ptlrpc_request **request)
+ u64 valid, const char *xattr_name,
+ const char *input, int input_size, int output_size,
+ int flags, __u32 suppgid,
+ struct ptlrpc_request **request)
{
return mdc_xattr_common(exp, &RQF_MDS_REINT_SETXATTR,
- fid, oc, MDS_REINT, valid, xattr_name,
+ fid, MDS_REINT, valid, xattr_name,
input, input_size, output_size, flags,
suppgid, request);
}
static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, u64 valid, const char *xattr_name,
- const char *input, int input_size, int output_size,
- int flags, struct ptlrpc_request **request)
+ u64 valid, const char *xattr_name,
+ const char *input, int input_size, int output_size,
+ int flags, struct ptlrpc_request **request)
{
return mdc_xattr_common(exp, &RQF_MDS_GETXATTR,
- fid, oc, MDS_GETXATTR, valid, xattr_name,
+ fid, MDS_GETXATTR, valid, xattr_name,
input, input_size, output_size, flags,
-1, request);
}
@@ -618,34 +561,9 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
#endif
}
}
- if (md->body->valid & OBD_MD_FLMDSCAPA) {
- struct obd_capa *oc = NULL;
-
- rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, &oc);
- if (rc)
- goto out;
- md->mds_capa = oc;
- }
-
- if (md->body->valid & OBD_MD_FLOSSCAPA) {
- struct obd_capa *oc = NULL;
-
- rc = mdc_unpack_capa(NULL, req, &RMF_CAPA2, &oc);
- if (rc)
- goto out;
- md->oss_capa = oc;
- }
out:
if (rc) {
- if (md->oss_capa) {
- capa_put(md->oss_capa);
- md->oss_capa = NULL;
- }
- if (md->mds_capa) {
- capa_put(md->mds_capa);
- md->mds_capa = NULL;
- }
#ifdef CONFIG_FS_POSIX_ACL
posix_acl_release(md->posix_acl);
#endif
@@ -867,7 +785,6 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
int rc;
int saved_rc = 0;
-
req_fmt = &RQF_MDS_CLOSE;
if (op_data->op_bias & MDS_HSM_RELEASE) {
req_fmt = &RQF_MDS_RELEASE_CLOSE;
@@ -887,8 +804,6 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE);
if (rc) {
ptlrpc_request_free(req);
@@ -989,7 +904,6 @@ static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING);
if (rc) {
ptlrpc_request_free(req);
@@ -1046,7 +960,6 @@ static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data,
return rc;
}
-
static int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data,
struct page **pages, struct ptlrpc_request **request)
{
@@ -1066,8 +979,6 @@ restart_bulk:
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE);
if (rc) {
ptlrpc_request_free(req);
@@ -1090,7 +1001,7 @@ restart_bulk:
mdc_readdir_pack(req, op_data->op_offset,
PAGE_CACHE_SIZE * op_data->op_npages,
- &op_data->op_fid1, op_data->op_capa1);
+ &op_data->op_fid1);
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
@@ -1201,8 +1112,8 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
/* Key is KEY_FID2PATH + getinfo_fid2path description */
keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
- OBD_ALLOC(key, keylen);
- if (key == NULL)
+ key = kzalloc(keylen, GFP_NOFS);
+ if (!key)
return -ENOMEM;
memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf));
@@ -1234,7 +1145,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
out:
- OBD_FREE(key, keylen);
+ kfree(key);
return rc;
}
@@ -1253,7 +1164,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
goto out;
}
- mdc_pack_body(req, NULL, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
+ mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
/* Copy hsm_progress struct */
req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS);
@@ -1288,7 +1199,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
goto out;
}
- mdc_pack_body(req, NULL, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
+ mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
/* Copy hsm_progress struct */
archive_mask = req_capsule_client_get(&req->rq_pill,
@@ -1322,16 +1233,14 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_ACTION);
if (rc) {
ptlrpc_request_free(req);
return rc;
}
- mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
- OBD_MD_FLRMTPERM, 0, op_data->op_suppgids[0], 0);
+ mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0,
+ op_data->op_suppgids[0], 0);
ptlrpc_request_set_replen(req);
@@ -1366,7 +1275,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
goto out;
}
- mdc_pack_body(req, NULL, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
+ mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
ptlrpc_request_set_replen(req);
@@ -1390,16 +1299,14 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_GET);
if (rc != 0) {
ptlrpc_request_free(req);
return rc;
}
- mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
- OBD_MD_FLRMTPERM, 0, op_data->op_suppgids[0], 0);
+ mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0,
+ op_data->op_suppgids[0], 0);
ptlrpc_request_set_replen(req);
@@ -1433,16 +1340,14 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_SET);
if (rc) {
ptlrpc_request_free(req);
return rc;
}
- mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
- OBD_MD_FLRMTPERM, 0, op_data->op_suppgids[0], 0);
+ mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0,
+ op_data->op_suppgids[0], 0);
/* Copy states */
req_hss = req_capsule_client_get(&req->rq_pill, &RMF_HSM_STATE_SET);
@@ -1490,7 +1395,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
return rc;
}
- mdc_pack_body(req, NULL, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
+ mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
/* Copy hsm_request struct */
req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST);
@@ -1604,8 +1509,8 @@ static int mdc_changelog_send_thread(void *csdata)
CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n",
cs->cs_fp, cs->cs_startrec);
- OBD_ALLOC(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE);
- if (cs->cs_buf == NULL) {
+ cs->cs_buf = kzalloc(KUC_CHANGELOG_MSG_MAXSIZE, GFP_NOFS);
+ if (!cs->cs_buf) {
rc = -ENOMEM;
goto out;
}
@@ -1644,9 +1549,8 @@ out:
llog_cat_close(NULL, llh);
if (ctxt)
llog_ctxt_put(ctxt);
- if (cs->cs_buf)
- OBD_FREE(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE);
- OBD_FREE_PTR(cs);
+ kfree(cs->cs_buf);
+ kfree(cs);
return rc;
}
@@ -1657,7 +1561,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
int rc;
/* Freed in mdc_changelog_send_thread */
- OBD_ALLOC_PTR(cs);
+ cs = kzalloc(sizeof(*cs), GFP_NOFS);
if (!cs)
return -ENOMEM;
@@ -1679,7 +1583,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
}
CERROR("Failed to start changelog thread: %d\n", rc);
- OBD_FREE_PTR(cs);
+ kfree(cs);
return rc;
}
@@ -1800,9 +1704,6 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp,
return -ENOMEM;
}
- mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
- mdc_set_capa_size(req, &RMF_CAPA2, op_data->op_capa2);
-
rc = mdc_prep_elc_req(exp, req, MDS_SWAP_LAYOUTS, &cancels, count);
if (rc) {
ptlrpc_request_free(req);
@@ -1819,10 +1720,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp,
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
- if (rc)
- goto out;
-out:
ptlrpc_req_finished(req);
return rc;
}
@@ -1937,8 +1835,8 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
struct if_quotactl *qctl = karg;
struct obd_quotactl *oqctl;
- OBD_ALLOC_PTR(oqctl);
- if (oqctl == NULL) {
+ oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
+ if (!oqctl) {
rc = -ENOMEM;
goto out;
}
@@ -1951,7 +1849,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
qctl->obd_uuid = obd->u.cli.cl_target_uuid;
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
goto out;
}
case LL_IOC_GET_CONNECT_FLAGS:
@@ -2094,7 +1992,6 @@ static int mdc_hsm_copytool_send(int len, void *val)
{
struct kuc_hdr *lh = (struct kuc_hdr *)val;
struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1);
- int rc;
if (len < sizeof(*lh) + sizeof(*hal)) {
CERROR("Short HSM message %d < %d\n", len,
@@ -2115,9 +2012,7 @@ static int mdc_hsm_copytool_send(int len, void *val)
lh->kuc_msglen, hal->hal_count, hal->hal_fsname);
/* Broadcast to HSM listeners */
- rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh);
-
- return rc;
+ return libcfs_kkuc_group_put(KUC_GRP_HSM, lh);
}
/**
@@ -2227,26 +2122,6 @@ static int mdc_get_info(const struct lu_env *env, struct obd_export *exp,
default_easize = val;
*default_easize = exp->exp_obd->u.cli.cl_default_mds_easize;
return 0;
- } else if (KEY_IS(KEY_MAX_COOKIESIZE)) {
- int mdsize, *max_cookiesize;
-
- if (*vallen != sizeof(int))
- return -EINVAL;
- mdsize = *(int *)val;
- if (mdsize > exp->exp_obd->u.cli.cl_max_mds_cookiesize)
- exp->exp_obd->u.cli.cl_max_mds_cookiesize = mdsize;
- max_cookiesize = val;
- *max_cookiesize = exp->exp_obd->u.cli.cl_max_mds_cookiesize;
- return 0;
- } else if (KEY_IS(KEY_DEFAULT_COOKIESIZE)) {
- int *default_cookiesize;
-
- if (*vallen != sizeof(int))
- return -EINVAL;
- default_cookiesize = val;
- *default_cookiesize =
- exp->exp_obd->u.cli.cl_default_mds_cookiesize;
- return 0;
} else if (KEY_IS(KEY_CONN_DATA)) {
struct obd_import *imp = class_exp2cliimp(exp);
struct obd_connect_data *data = val;
@@ -2267,7 +2142,7 @@ static int mdc_get_info(const struct lu_env *env, struct obd_export *exp,
}
static int mdc_sync(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, struct ptlrpc_request **request)
+ struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
int rc;
@@ -2277,15 +2152,13 @@ static int mdc_sync(struct obd_export *exp, const struct lu_fid *fid,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, oc);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC);
if (rc) {
ptlrpc_request_free(req);
return rc;
}
- mdc_pack_body(req, fid, oc, 0, 0, -1, 0);
+ mdc_pack_body(req, fid, 0, 0, -1, 0);
ptlrpc_request_set_replen(req);
@@ -2430,14 +2303,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
struct lprocfs_static_vars lvars = { NULL };
int rc;
- OBD_ALLOC(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock));
+ cli->cl_rpc_lock = kzalloc(sizeof(*cli->cl_rpc_lock), GFP_NOFS);
if (!cli->cl_rpc_lock)
return -ENOMEM;
mdc_init_rpc_lock(cli->cl_rpc_lock);
ptlrpcd_addref();
- OBD_ALLOC(cli->cl_close_lock, sizeof(*cli->cl_close_lock));
+ cli->cl_close_lock = kzalloc(sizeof(*cli->cl_close_lock), GFP_NOFS);
if (!cli->cl_close_lock) {
rc = -ENOMEM;
goto err_rpc_lock;
@@ -2448,7 +2321,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
if (rc)
goto err_close_lock;
lprocfs_mdc_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
sptlrpc_lprocfs_cliobd_attach(obd);
ptlrpc_lprocfs_register_obd(obd);
@@ -2465,9 +2338,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
return rc;
err_close_lock:
- OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock));
+ kfree(cli->cl_close_lock);
err_rpc_lock:
- OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock));
+ kfree(cli->cl_rpc_lock);
ptlrpcd_decref();
return rc;
}
@@ -2525,8 +2398,8 @@ static int mdc_cleanup(struct obd_device *obd)
{
struct client_obd *cli = &obd->u.cli;
- OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock));
- OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock));
+ kfree(cli->cl_rpc_lock);
+ kfree(cli->cl_close_lock);
ptlrpcd_decref();
@@ -2551,11 +2424,9 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf)
return rc;
}
-
/* get remote permission for current user on fid */
static int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
- struct obd_capa *oc, __u32 suppgid,
- struct ptlrpc_request **request)
+ __u32 suppgid, struct ptlrpc_request **request)
{
struct ptlrpc_request *req;
int rc;
@@ -2567,15 +2438,13 @@ static int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
if (req == NULL)
return -ENOMEM;
- mdc_set_capa_size(req, &RMF_CAPA1, oc);
-
rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
if (rc) {
ptlrpc_request_free(req);
return rc;
}
- mdc_pack_body(req, fid, oc, OBD_MD_FLRMTPERM, 0, suppgid, 0);
+ mdc_pack_body(req, fid, OBD_MD_FLRMTPERM, 0, suppgid, 0);
req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
sizeof(struct mdt_remote_perm));
@@ -2590,66 +2459,6 @@ static int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
return rc;
}
-static int mdc_interpret_renew_capa(const struct lu_env *env,
- struct ptlrpc_request *req, void *args,
- int status)
-{
- struct mdc_renew_capa_args *ra = args;
- struct mdt_body *body = NULL;
- struct lustre_capa *capa;
-
- if (status) {
- capa = ERR_PTR(status);
- goto out;
- }
-
- body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
- if (body == NULL) {
- capa = ERR_PTR(-EFAULT);
- goto out;
- }
-
- if ((body->valid & OBD_MD_FLOSSCAPA) == 0) {
- capa = ERR_PTR(-ENOENT);
- goto out;
- }
-
- capa = req_capsule_server_get(&req->rq_pill, &RMF_CAPA2);
- if (!capa) {
- capa = ERR_PTR(-EFAULT);
- goto out;
- }
-out:
- ra->ra_cb(ra->ra_oc, capa);
- return 0;
-}
-
-static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc,
- renew_capa_cb_t cb)
-{
- struct ptlrpc_request *req;
- struct mdc_renew_capa_args *ra;
-
- req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETATTR,
- LUSTRE_MDS_VERSION, MDS_GETATTR);
- if (req == NULL)
- return -ENOMEM;
-
- /* NB, OBD_MD_FLOSSCAPA is set here, but it doesn't necessarily mean the
- * capa to renew is oss capa.
- */
- mdc_pack_body(req, &oc->c_capa.lc_fid, oc, OBD_MD_FLOSSCAPA, 0, -1, 0);
- ptlrpc_request_set_replen(req);
-
- CLASSERT(sizeof(*ra) <= sizeof(req->rq_async_args));
- ra = ptlrpc_req_async_args(req);
- ra->ra_oc = oc;
- ra->ra_cb = cb;
- req->rq_interpret_reply = mdc_interpret_renew_capa;
- ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
- return 0;
-}
-
static struct obd_ops mdc_obd_ops = {
.o_owner = THIS_MODULE,
.o_setup = mdc_setup,
@@ -2701,8 +2510,6 @@ static struct md_ops mdc_md_ops = {
.m_free_lustre_md = mdc_free_lustre_md,
.m_set_open_replay_data = mdc_set_open_replay_data,
.m_clear_open_replay_data = mdc_clear_open_replay_data,
- .m_renew_capa = mdc_renew_capa,
- .m_unpack_capa = mdc_unpack_capa,
.m_get_remote_perm = mdc_get_remote_perm,
.m_intent_getattr_async = mdc_intent_getattr_async,
.m_revalidate_lock = mdc_revalidate_lock
@@ -2714,7 +2521,7 @@ static int __init mdc_init(void)
lprocfs_mdc_init_vars(&lvars);
- return class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
+ return class_register_type(&mdc_obd_ops, &mdc_md_ops,
LUSTRE_MDC_NAME, NULL);
}
diff --git a/kernel/drivers/staging/lustre/lustre/mgc/Makefile b/kernel/drivers/staging/lustre/lustre/mgc/Makefile
index cc6e9f51a..8ea29a89c 100644
--- a/kernel/drivers/staging/lustre/lustre/mgc/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/mgc/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += mgc.o
-mgc-y := mgc_request.o
-mgc-$(CONFIG_PROC_FS) += lproc_mgc.o
+mgc-y := mgc_request.o lproc_mgc.o
diff --git a/kernel/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/kernel/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
index c4ea38e5f..8d5bc5a75 100644
--- a/kernel/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
+++ b/kernel/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
@@ -40,7 +40,6 @@
#include "../include/lprocfs_status.h"
#include "mgc_internal.h"
-LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags);
LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid);
@@ -53,10 +52,10 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v)
{
return lprocfs_mgc_rd_ir_state(m, m->private);
}
+
LPROC_SEQ_FOPS_RO(mgc_ir_state);
static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
- { "uuid", &mgc_uuid_fops, NULL, 0 },
{ "ping", &mgc_ping_fops, NULL, 0222 },
{ "connect_flags", &mgc_connect_flags_fops, NULL, 0 },
{ "mgs_server_uuid", &mgc_server_uuid_fops, NULL, 0 },
@@ -67,14 +66,7 @@ static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(mgc, numrefs);
-static struct lprocfs_vars lprocfs_mgc_module_vars[] = {
- { "num_refs", &mgc_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_mgc_module_vars;
lvars->obd_vars = lprocfs_mgc_obd_vars;
}
diff --git a/kernel/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/kernel/drivers/staging/lustre/lustre/mgc/mgc_internal.h
index a6f8b3ced..82fb8f46e 100644
--- a/kernel/drivers/staging/lustre/lustre/mgc/mgc_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/mgc/mgc_internal.h
@@ -44,19 +44,8 @@
#include "../include/lustre_log.h"
#include "../include/lustre_export.h"
-#if defined (CONFIG_PROC_FS)
void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars);
int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data);
-#else
-static inline void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-static inline int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
-{
- return 0;
-}
-#endif /* CONFIG_PROC_FS */
int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld);
diff --git a/kernel/drivers/staging/lustre/lustre/mgc/mgc_request.c b/kernel/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 7947aec5c..5f53f3b7c 100644
--- a/kernel/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/kernel/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -149,7 +149,7 @@ static void config_log_put(struct config_llog_data *cld)
sptlrpc_conf_log_stop(cld->cld_logname);
class_export_put(cld->cld_mgcexp);
- OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1);
+ kfree(cld);
}
}
@@ -198,7 +198,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd,
CDEBUG(D_MGC, "do adding config log %s:%p\n", logname,
cfg ? cfg->cfg_instance : NULL);
- OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1);
+ cld = kzalloc(sizeof(*cld) + strlen(logname) + 1, GFP_NOFS);
if (!cld)
return ERR_PTR(-ENOMEM);
@@ -248,29 +248,15 @@ static struct config_llog_data *config_recover_log_add(struct obd_device *obd,
struct super_block *sb)
{
struct config_llog_instance lcfg = *cfg;
- struct lustre_sb_info *lsi = s2lsi(sb);
struct config_llog_data *cld;
char logname[32];
- if (IS_OST(lsi))
- return NULL;
-
- /* for osp-on-ost, see lustre_start_osp() */
- if (IS_MDT(lsi) && lcfg.cfg_instance)
- return NULL;
-
/* we have to use different llog for clients and mdts for cmd
* where only clients are notified if one of cmd server restarts */
LASSERT(strlen(fsname) < sizeof(logname) / 2);
strcpy(logname, fsname);
- if (IS_SERVER(lsi)) { /* mdt */
- LASSERT(lcfg.cfg_instance == NULL);
- lcfg.cfg_instance = sb;
- strcat(logname, "-mdtir");
- } else {
- LASSERT(lcfg.cfg_instance != NULL);
- strcat(logname, "-cliir");
- }
+ LASSERT(lcfg.cfg_instance);
+ strcat(logname, "-cliir");
cld = do_config_log_add(obd, logname, CONFIG_T_RECOVER, &lcfg, sb);
return cld;
@@ -448,15 +434,18 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg)
return rc;
}
-#if defined (CONFIG_PROC_FS)
int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
{
struct obd_device *obd = data;
struct obd_import *imp;
struct obd_connect_data *ocd;
struct config_llog_data *cld;
+ int rc;
+
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
- LPROCFS_CLIMP_CHECK(obd);
imp = obd->u.cli.cl_import;
ocd = &imp->imp_connect_data;
@@ -477,7 +466,6 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
LPROCFS_CLIMP_EXIT(obd);
return 0;
}
-#endif
/* reenqueue any lost locks */
#define RQ_RUNNING 0x1
@@ -722,7 +710,7 @@ static int mgc_cleanup(struct obd_device *obd)
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
- struct lprocfs_static_vars lvars;
+ struct lprocfs_static_vars lvars = { NULL };
int rc;
ptlrpcd_addref();
@@ -738,7 +726,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
}
lprocfs_mgc_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
sptlrpc_lprocfs_cliobd_attach(obd);
if (atomic_inc_return(&mgc_count) == 1) {
@@ -772,7 +760,7 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
void *data, int flag)
{
struct lustre_handle lockh;
- struct config_llog_data *cld = (struct config_llog_data *)data;
+ struct config_llog_data *cld = data;
int rc = 0;
switch (flag) {
@@ -876,7 +864,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
void *data, __u32 lvb_len, void *lvb_swabber,
struct lustre_handle *lockh)
{
- struct config_llog_data *cld = (struct config_llog_data *)data;
+ struct config_llog_data *cld = data;
struct ldlm_enqueue_info einfo = {
.ei_type = type,
.ei_mode = mode,
@@ -901,12 +889,6 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, 0);
ptlrpc_request_set_replen(req);
- /* check if this is server or client */
- if (cld->cld_cfg.cfg_sb) {
- struct lustre_sb_info *lsi = s2lsi(cld->cld_cfg.cfg_sb);
- if (lsi && IS_SERVER(lsi))
- short_limit = 1;
- }
/* Limit how long we will wait for the enqueue to complete */
req->rq_delay_limit = short_limit ? 5 : MGC_ENQUEUE_LIMIT;
rc = ldlm_cli_enqueue(exp, &req, &einfo, &cld->cld_resid, NULL, flags,
@@ -977,6 +959,7 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
if (KEY_IS(KEY_INIT_RECOV_BACKUP)) {
struct obd_import *imp = class_exp2cliimp(exp);
int value;
+
if (vallen != sizeof(int))
return -EINVAL;
value = *(int *)val;
@@ -994,7 +977,7 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
if (KEY_IS(KEY_SET_INFO)) {
struct mgs_send_param *msp;
- msp = (struct mgs_send_param *)val;
+ msp = val;
rc = mgc_set_mgs_param(exp, msp);
return rc;
}
@@ -1080,6 +1063,7 @@ static int mgc_import_event(struct obd_device *obd,
break;
case IMP_EVENT_INVALIDATE: {
struct ldlm_namespace *ns = obd->obd_namespace;
+
ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
break;
}
@@ -1114,7 +1098,6 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
void *data, int datalen, bool mne_swab)
{
struct config_llog_instance *cfg = &cld->cld_cfg;
- struct lustre_sb_info *lsi = s2lsi(cfg->cfg_sb);
struct mgs_nidtbl_entry *entry;
struct lustre_cfg *lcfg;
struct lustre_cfg_bufs bufs;
@@ -1129,25 +1112,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
LASSERT(cfg->cfg_instance != NULL);
LASSERT(cfg->cfg_sb == cfg->cfg_instance);
- OBD_ALLOC(inst, PAGE_CACHE_SIZE);
- if (inst == NULL)
+ inst = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
+ if (!inst)
return -ENOMEM;
- if (!IS_SERVER(lsi)) {
- pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance);
- if (pos >= PAGE_CACHE_SIZE) {
- OBD_FREE(inst, PAGE_CACHE_SIZE);
- return -E2BIG;
- }
- } else {
- LASSERT(IS_MDT(lsi));
- rc = server_name2svname(lsi->lsi_svname, inst, NULL,
- PAGE_CACHE_SIZE);
- if (rc) {
- OBD_FREE(inst, PAGE_CACHE_SIZE);
- return -EINVAL;
- }
- pos = strlen(inst);
+ pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance);
+ if (pos >= PAGE_CACHE_SIZE) {
+ kfree(inst);
+ return -E2BIG;
}
++pos;
@@ -1234,7 +1206,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
pos += sprintf(obdname + pos, "-%s%04x",
is_ost ? "OST" : "MDT", entry->mne_index);
- cname = is_ost ? "osc" : "mdc",
+ cname = is_ost ? "osc" : "mdc";
pos += sprintf(obdname + pos, "-%s-%s", cname, inst);
lustre_cfg_bufs_reset(&bufs, obdname);
@@ -1302,7 +1274,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
/* continue, even one with error */
}
- OBD_FREE(inst, PAGE_CACHE_SIZE);
+ kfree(inst);
return rc;
}
@@ -1336,14 +1308,14 @@ static int mgc_process_recover_log(struct obd_device *obd,
if (cfg->cfg_last_idx == 0) /* the first time */
nrpages = CONFIG_READ_NRPAGES_INIT;
- OBD_ALLOC(pages, sizeof(*pages) * nrpages);
+ pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL);
if (pages == NULL) {
rc = -ENOMEM;
goto out;
}
for (i = 0; i < nrpages; i++) {
- pages[i] = alloc_page(GFP_IOFS);
+ pages[i] = alloc_page(GFP_KERNEL);
if (pages[i] == NULL) {
rc = -ENOMEM;
goto out;
@@ -1466,7 +1438,7 @@ out:
break;
__free_page(pages[i]);
}
- OBD_FREE(pages, sizeof(*pages) * nrpages);
+ kfree(pages);
}
return rc;
}
@@ -1494,8 +1466,8 @@ static int mgc_process_cfg_log(struct obd_device *mgc,
if (cld->cld_cfg.cfg_sb)
lsi = s2lsi(cld->cld_cfg.cfg_sb);
- OBD_ALLOC_PTR(env);
- if (env == NULL)
+ env = kzalloc(sizeof(*env), GFP_KERNEL);
+ if (!env)
return -ENOMEM;
rc = lu_env_init(env, LCT_MG_THREAD);
@@ -1540,7 +1512,7 @@ out_pop:
lu_env_fini(env);
out_free:
- OBD_FREE_PTR(env);
+ kfree(env);
return rc;
}
@@ -1590,7 +1562,6 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld)
config_log_get(cld);
}
-
if (cld_is_recover(cld)) {
rc = 0; /* this is not a fatal error for recover log */
if (rcl == 0)
@@ -1611,7 +1582,6 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld)
return rc;
}
-
/** Called from lustre_process_log.
* LCFG_LOG_START gets the config log from the MGS, processes it to start
* any services, and adds it to the list logs to watch (follow).
@@ -1682,6 +1652,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
rc = mgc_process_log(obd, cld->cld_recover);
} else {
struct config_llog_data *cir = cld->cld_recover;
+
cld->cld_recover = NULL;
config_log_put(cir);
}
@@ -1726,7 +1697,7 @@ out:
return rc;
}
-struct obd_ops mgc_obd_ops = {
+static struct obd_ops mgc_obd_ops = {
.o_owner = THIS_MODULE,
.o_setup = mgc_setup,
.o_precleanup = mgc_precleanup,
@@ -1745,7 +1716,7 @@ struct obd_ops mgc_obd_ops = {
static int __init mgc_init(void)
{
- return class_register_type(&mgc_obd_ops, NULL, NULL,
+ return class_register_type(&mgc_obd_ops, NULL,
LUSTRE_MGC_NAME, NULL);
}
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/Makefile b/kernel/drivers/staging/lustre/lustre/obdclass/Makefile
index e89468179..acc685712 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -5,7 +5,5 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
genops.o uuid.o lprocfs_status.o \
lustre_handles.o lustre_peer.o \
statfs_pack.o obdo.o obd_config.o obd_mount.o \
- lu_object.o dt_object.o capa.o cl_object.o \
- cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o
-
-obdclass-$(CONFIG_PROC_FS) += lprocfs_counters.o
+ lu_object.o cl_object.o \
+ cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o lprocfs_counters.o
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/acl.c b/kernel/drivers/staging/lustre/lustre/obdclass/acl.c
index 9a69f6b35..2e20cf635 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/acl.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/acl.c
@@ -92,7 +92,6 @@ static inline void lustre_posix_acl_cpu_to_le(posix_acl_xattr_entry *d,
d->e_id = cpu_to_le32(s->e_id);
}
-
/* if "new_count == 0", then "new = {a_version, NULL}", NOT NULL. */
static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header,
int old_count, int new_count)
@@ -104,12 +103,11 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header,
if (unlikely(old_count <= new_count))
return old_size;
- OBD_ALLOC(new, new_size);
+ new = kmemdup(*header, new_size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
- memcpy(new, *header, new_size);
- OBD_FREE(*header, old_size);
+ kfree(*header);
*header = new;
return new_size;
}
@@ -120,18 +118,16 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header,
{
int ext_count = le32_to_cpu((*header)->a_count);
int ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr);
- int old_size = CFS_ACL_XATTR_SIZE(old_count, ext_acl_xattr);
ext_acl_xattr_header *new;
if (unlikely(old_count <= ext_count))
return 0;
- OBD_ALLOC(new, ext_size);
+ new = kmemdup(*header, ext_size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
- memcpy(new, *header, ext_size);
- OBD_FREE(*header, old_size);
+ kfree(*header);
*header = new;
return 0;
}
@@ -152,7 +148,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size)
else
count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr);
esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr);
- OBD_ALLOC(new, esize);
+ new = kzalloc(esize, GFP_NOFS);
if (unlikely(new == NULL))
return ERR_PTR(-ENOMEM);
@@ -183,7 +179,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
if (size < sizeof(*new))
return -EINVAL;
- OBD_ALLOC(new, size);
+ new = kzalloc(size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
@@ -232,7 +228,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
_out:
if (rc) {
- OBD_FREE(new, size);
+ kfree(new);
size = rc;
}
return size;
@@ -244,7 +240,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_filter);
*/
void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size)
{
- OBD_FREE(header, size);
+ kfree(header);
}
EXPORT_SYMBOL(lustre_posix_acl_xattr_free);
@@ -253,8 +249,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_free);
*/
void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header)
{
- OBD_FREE(header, CFS_ACL_XATTR_SIZE(le32_to_cpu(header->a_count), \
- ext_acl_xattr));
+ kfree(header);
}
EXPORT_SYMBOL(lustre_ext_acl_xattr_free);
@@ -291,125 +286,6 @@ again:
}
/*
- * Merge the posix ACL and the extended ACL into new posix ACL.
- */
-int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
- ext_acl_xattr_header *ext_header,
- posix_acl_xattr_header **out)
-{
- int posix_count, posix_size, i, j;
- int ext_count = le32_to_cpu(ext_header->a_count), pos = 0, rc = 0;
- posix_acl_xattr_entry pe = {ACL_MASK, 0, ACL_UNDEFINED_ID};
- posix_acl_xattr_header *new;
- ext_acl_xattr_entry *ee, ae;
-
- lustre_posix_acl_cpu_to_le(&pe, &pe);
- ee = lustre_ext_acl_xattr_search(ext_header, &pe, &pos);
- if (ee == NULL || le32_to_cpu(ee->e_stat) == ES_DEL) {
- /* there are only base ACL entries at most. */
- posix_count = 3;
- posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr);
- OBD_ALLOC(new, posix_size);
- if (unlikely(new == NULL))
- return -ENOMEM;
-
- new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION);
- for (i = 0, j = 0; i < ext_count; i++) {
- lustre_ext_acl_le_to_cpu(&ae,
- &ext_header->a_entries[i]);
- switch (ae.e_tag) {
- case ACL_USER_OBJ:
- case ACL_GROUP_OBJ:
- case ACL_OTHER:
- if (ae.e_id != ACL_UNDEFINED_ID) {
- rc = -EIO;
- goto _out;
- }
-
- if (ae.e_stat != ES_DEL) {
- new->a_entries[j].e_tag =
- ext_header->a_entries[i].e_tag;
- new->a_entries[j].e_perm =
- ext_header->a_entries[i].e_perm;
- new->a_entries[j++].e_id =
- ext_header->a_entries[i].e_id;
- }
- break;
- case ACL_MASK:
- case ACL_USER:
- case ACL_GROUP:
- if (ae.e_stat == ES_DEL)
- break;
- default:
- rc = -EIO;
- goto _out;
- }
- }
- } else {
- /* maybe there are valid ACL_USER or ACL_GROUP entries in the
- * original server-side ACL, they are regarded as ES_UNC stat.*/
- int ori_posix_count;
-
- if (unlikely(size < 0))
- return -EINVAL;
- else if (!size)
- ori_posix_count = 0;
- else
- ori_posix_count =
- CFS_ACL_XATTR_COUNT(size, posix_acl_xattr);
- posix_count = ori_posix_count + ext_count;
- posix_size =
- CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr);
- OBD_ALLOC(new, posix_size);
- if (unlikely(new == NULL))
- return -ENOMEM;
-
- new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION);
- /* 1. process the unchanged ACL entries
- * in the original server-side ACL. */
- pos = 0;
- for (i = 0, j = 0; i < ori_posix_count; i++) {
- ee = lustre_ext_acl_xattr_search(ext_header,
- &posix_header->a_entries[i], &pos);
- if (ee == NULL)
- memcpy(&new->a_entries[j++],
- &posix_header->a_entries[i],
- sizeof(posix_acl_xattr_entry));
- }
-
- /* 2. process the non-deleted entries
- * from client-side extended ACL. */
- for (i = 0; i < ext_count; i++) {
- if (le16_to_cpu(ext_header->a_entries[i].e_stat) !=
- ES_DEL) {
- new->a_entries[j].e_tag =
- ext_header->a_entries[i].e_tag;
- new->a_entries[j].e_perm =
- ext_header->a_entries[i].e_perm;
- new->a_entries[j++].e_id =
- ext_header->a_entries[i].e_id;
- }
- }
- }
-
- /* free unused space. */
- rc = lustre_posix_acl_xattr_reduce_space(&new, posix_count, j);
- if (rc >= 0) {
- posix_size = rc;
- *out = new;
- rc = 0;
- }
-
-_out:
- if (rc) {
- OBD_FREE(new, posix_size);
- posix_size = rc;
- }
- return posix_size;
-}
-EXPORT_SYMBOL(lustre_acl_xattr_merge2posix);
-
-/*
* Merge the posix ACL and the extended ACL into new extended ACL.
*/
ext_acl_xattr_header *
@@ -432,7 +308,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
ext_count = posix_count + ori_ext_count;
ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr);
- OBD_ALLOC(new, ext_size);
+ new = kzalloc(ext_size, GFP_NOFS);
if (unlikely(new == NULL))
return ERR_PTR(-ENOMEM);
@@ -538,7 +414,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
out:
if (rc) {
- OBD_FREE(new, ext_size);
+ kfree(new);
new = ERR_PTR(rc);
}
return new;
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/capa.c b/kernel/drivers/staging/lustre/lustre/obdclass/capa.c
deleted file mode 100644
index d206b1046..000000000
--- a/kernel/drivers/staging/lustre/lustre/obdclass/capa.c
+++ /dev/null
@@ -1,421 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2005, 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/capa.c
- *
- * Lustre Capability Hash Management
- *
- * Author: Lai Siyao<lsy@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_SEC
-
-#include <linux/fs.h>
-#include <asm/unistd.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/crypto.h>
-
-#include "../include/obd_class.h"
-#include "../include/lustre_debug.h"
-#include "../include/lustre/lustre_idl.h"
-
-#include <linux/list.h>
-#include "../include/lustre_capa.h"
-
-#define NR_CAPAHASH 32
-#define CAPA_HASH_SIZE 3000 /* for MDS & OSS */
-
-struct kmem_cache *capa_cachep = NULL;
-
-/* lock for capa hash/capa_list/fo_capa_keys */
-DEFINE_SPINLOCK(capa_lock);
-
-struct list_head capa_list[CAPA_SITE_MAX];
-
-static struct capa_hmac_alg capa_hmac_algs[] = {
- DEF_CAPA_HMAC_ALG("sha1", SHA1, 20, 20),
-};
-/* capa count */
-int capa_count[CAPA_SITE_MAX] = { 0, };
-
-EXPORT_SYMBOL(capa_cachep);
-EXPORT_SYMBOL(capa_list);
-EXPORT_SYMBOL(capa_lock);
-EXPORT_SYMBOL(capa_count);
-
-static inline
-unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
-{
- return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize;
-}
-
-struct hlist_head *init_capa_hash(void)
-{
- struct hlist_head *hash;
- int nr_hash, i;
-
- OBD_ALLOC(hash, PAGE_CACHE_SIZE);
- if (!hash)
- return NULL;
-
- nr_hash = PAGE_CACHE_SIZE / sizeof(struct hlist_head);
- LASSERT(nr_hash > NR_CAPAHASH);
-
- for (i = 0; i < NR_CAPAHASH; i++)
- INIT_HLIST_HEAD(hash + i);
- return hash;
-}
-EXPORT_SYMBOL(init_capa_hash);
-
-static inline int capa_on_server(struct obd_capa *ocapa)
-{
- return ocapa->c_site == CAPA_SITE_SERVER;
-}
-
-static inline void capa_delete(struct obd_capa *ocapa)
-{
- LASSERT(capa_on_server(ocapa));
- hlist_del_init(&ocapa->u.tgt.c_hash);
- list_del_init(&ocapa->c_list);
- capa_count[ocapa->c_site]--;
- /* release the ref when alloc */
- capa_put(ocapa);
-}
-
-void cleanup_capa_hash(struct hlist_head *hash)
-{
- int i;
- struct hlist_node *next;
- struct obd_capa *oc;
-
- spin_lock(&capa_lock);
- for (i = 0; i < NR_CAPAHASH; i++) {
- hlist_for_each_entry_safe(oc, next, hash + i,
- u.tgt.c_hash)
- capa_delete(oc);
- }
- spin_unlock(&capa_lock);
-
- OBD_FREE(hash, PAGE_CACHE_SIZE);
-}
-EXPORT_SYMBOL(cleanup_capa_hash);
-
-static inline int capa_hashfn(struct lu_fid *fid)
-{
- return (fid_oid(fid) ^ fid_ver(fid)) *
- (unsigned long)(fid_seq(fid) + 1) % NR_CAPAHASH;
-}
-
-/* capa renewal time check is earlier than that on client, which is to prevent
- * client renew right after obtaining it. */
-static inline int capa_is_to_expire(struct obd_capa *oc)
-{
- return time_before(cfs_time_sub(oc->c_expiry,
- cfs_time_seconds(oc->c_capa.lc_timeout)*2/3),
- cfs_time_current());
-}
-
-static struct obd_capa *find_capa(struct lustre_capa *capa,
- struct hlist_head *head, int alive)
-{
- struct obd_capa *ocapa;
- int len = alive ? offsetof(struct lustre_capa, lc_keyid):sizeof(*capa);
-
- hlist_for_each_entry(ocapa, head, u.tgt.c_hash) {
- if (memcmp(&ocapa->c_capa, capa, len))
- continue;
- /* don't return one that will expire soon in this case */
- if (alive && capa_is_to_expire(ocapa))
- continue;
-
- LASSERT(capa_on_server(ocapa));
-
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "found");
- return ocapa;
- }
-
- return NULL;
-}
-
-#define LRU_CAPA_DELETE_COUNT 12
-static inline void capa_delete_lru(struct list_head *head)
-{
- struct obd_capa *ocapa;
- struct list_head *node = head->next;
- int count = 0;
-
- /* free LRU_CAPA_DELETE_COUNT unused capa from head */
- while (count++ < LRU_CAPA_DELETE_COUNT) {
- ocapa = list_entry(node, struct obd_capa, c_list);
- node = node->next;
- if (atomic_read(&ocapa->c_refc))
- continue;
-
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free lru");
- capa_delete(ocapa);
- }
-}
-
-/* add or update */
-struct obd_capa *capa_add(struct hlist_head *hash, struct lustre_capa *capa)
-{
- struct hlist_head *head = hash + capa_hashfn(&capa->lc_fid);
- struct obd_capa *ocapa, *old = NULL;
- struct list_head *list = &capa_list[CAPA_SITE_SERVER];
-
- ocapa = alloc_capa(CAPA_SITE_SERVER);
- if (IS_ERR(ocapa))
- return NULL;
-
- spin_lock(&capa_lock);
- old = find_capa(capa, head, 0);
- if (!old) {
- ocapa->c_capa = *capa;
- set_capa_expiry(ocapa);
- hlist_add_head(&ocapa->u.tgt.c_hash, head);
- list_add_tail(&ocapa->c_list, list);
- capa_get(ocapa);
- capa_count[CAPA_SITE_SERVER]++;
- if (capa_count[CAPA_SITE_SERVER] > CAPA_HASH_SIZE)
- capa_delete_lru(list);
- spin_unlock(&capa_lock);
- return ocapa;
- }
- capa_get(old);
- spin_unlock(&capa_lock);
- capa_put(ocapa);
- return old;
-}
-EXPORT_SYMBOL(capa_add);
-
-struct obd_capa *capa_lookup(struct hlist_head *hash, struct lustre_capa *capa,
- int alive)
-{
- struct obd_capa *ocapa;
-
- spin_lock(&capa_lock);
- ocapa = find_capa(capa, hash + capa_hashfn(&capa->lc_fid), alive);
- if (ocapa) {
- list_move_tail(&ocapa->c_list,
- &capa_list[CAPA_SITE_SERVER]);
- capa_get(ocapa);
- }
- spin_unlock(&capa_lock);
-
- return ocapa;
-}
-EXPORT_SYMBOL(capa_lookup);
-
-static inline int ll_crypto_hmac(struct crypto_hash *tfm,
- u8 *key, unsigned int *keylen,
- struct scatterlist *sg,
- unsigned int size, u8 *result)
-{
- struct hash_desc desc;
- int rv;
- desc.tfm = tfm;
- desc.flags = 0;
- rv = crypto_hash_setkey(desc.tfm, key, *keylen);
- if (rv) {
- CERROR("failed to hash setkey: %d\n", rv);
- return rv;
- }
- return crypto_hash_digest(&desc, sg, size, result);
-}
-
-int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key)
-{
- struct crypto_hash *tfm;
- struct capa_hmac_alg *alg;
- int keylen;
- struct scatterlist sl;
-
- if (capa_alg(capa) != CAPA_HMAC_ALG_SHA1) {
- CERROR("unknown capability hmac algorithm!\n");
- return -EFAULT;
- }
-
- alg = &capa_hmac_algs[capa_alg(capa)];
-
- tfm = crypto_alloc_hash(alg->ha_name, 0, 0);
- if (IS_ERR(tfm)) {
- CERROR("crypto_alloc_tfm failed, check whether your kernel has crypto support!\n");
- return PTR_ERR(tfm);
- }
- keylen = alg->ha_keylen;
-
- sg_init_table(&sl, 1);
- sg_set_page(&sl, virt_to_page(capa),
- offsetof(struct lustre_capa, lc_hmac),
- (unsigned long)(capa) % PAGE_CACHE_SIZE);
-
- ll_crypto_hmac(tfm, key, &keylen, &sl, sl.length, hmac);
- crypto_free_hash(tfm);
-
- return 0;
-}
-EXPORT_SYMBOL(capa_hmac);
-
-int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
-{
- struct crypto_blkcipher *tfm;
- struct scatterlist sd;
- struct scatterlist ss;
- struct blkcipher_desc desc;
- unsigned int min;
- int rc;
- char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
-
- /* passing "aes" in a variable instead of a constant string keeps gcc
- * 4.3.2 happy */
- tfm = crypto_alloc_blkcipher(alg, 0, 0);
- if (IS_ERR(tfm)) {
- CERROR("failed to load transform for aes\n");
- return PTR_ERR(tfm);
- }
-
- min = ll_crypto_tfm_alg_min_keysize(tfm);
- if (keylen < min) {
- CERROR("keylen at least %d bits for aes\n", min * 8);
- rc = -EINVAL;
- goto out;
- }
-
- rc = crypto_blkcipher_setkey(tfm, key, min);
- if (rc) {
- CERROR("failed to setting key for aes\n");
- goto out;
- }
-
- sg_init_table(&sd, 1);
- sg_set_page(&sd, virt_to_page(d), 16,
- (unsigned long)(d) % PAGE_CACHE_SIZE);
-
- sg_init_table(&ss, 1);
- sg_set_page(&ss, virt_to_page(s), 16,
- (unsigned long)(s) % PAGE_CACHE_SIZE);
- desc.tfm = tfm;
- desc.info = NULL;
- desc.flags = 0;
- rc = crypto_blkcipher_encrypt(&desc, &sd, &ss, 16);
- if (rc) {
- CERROR("failed to encrypt for aes\n");
- goto out;
- }
-
-out:
- crypto_free_blkcipher(tfm);
- return rc;
-}
-EXPORT_SYMBOL(capa_encrypt_id);
-
-int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
-{
- struct crypto_blkcipher *tfm;
- struct scatterlist sd;
- struct scatterlist ss;
- struct blkcipher_desc desc;
- unsigned int min;
- int rc;
- char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
-
- /* passing "aes" in a variable instead of a constant string keeps gcc
- * 4.3.2 happy */
- tfm = crypto_alloc_blkcipher(alg, 0, 0);
- if (IS_ERR(tfm)) {
- CERROR("failed to load transform for aes\n");
- return PTR_ERR(tfm);
- }
-
- min = ll_crypto_tfm_alg_min_keysize(tfm);
- if (keylen < min) {
- CERROR("keylen at least %d bits for aes\n", min * 8);
- rc = -EINVAL;
- goto out;
- }
-
- rc = crypto_blkcipher_setkey(tfm, key, min);
- if (rc) {
- CERROR("failed to setting key for aes\n");
- goto out;
- }
-
- sg_init_table(&sd, 1);
- sg_set_page(&sd, virt_to_page(d), 16,
- (unsigned long)(d) % PAGE_CACHE_SIZE);
-
- sg_init_table(&ss, 1);
- sg_set_page(&ss, virt_to_page(s), 16,
- (unsigned long)(s) % PAGE_CACHE_SIZE);
-
- desc.tfm = tfm;
- desc.info = NULL;
- desc.flags = 0;
- rc = crypto_blkcipher_decrypt(&desc, &sd, &ss, 16);
- if (rc) {
- CERROR("failed to decrypt for aes\n");
- goto out;
- }
-
-out:
- crypto_free_blkcipher(tfm);
- return rc;
-}
-EXPORT_SYMBOL(capa_decrypt_id);
-
-void capa_cpy(void *capa, struct obd_capa *ocapa)
-{
- spin_lock(&ocapa->c_lock);
- *(struct lustre_capa *)capa = ocapa->c_capa;
- spin_unlock(&ocapa->c_lock);
-}
-EXPORT_SYMBOL(capa_cpy);
-
-void _debug_capa(struct lustre_capa *c,
- struct libcfs_debug_msg_data *msgdata,
- const char *fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- libcfs_debug_vmsg2(msgdata, fmt, args,
- " capability@%p fid " DFID " opc %#llx uid %llu gid %llu flags %u alg %d keyid %u timeout %u expiry %u\n",
- c, PFID(capa_fid(c)), capa_opc(c),
- capa_uid(c), capa_gid(c), capa_flags(c),
- capa_alg(c), capa_keyid(c), capa_timeout(c),
- capa_expiry(c));
- va_end(args);
-}
-EXPORT_SYMBOL(_debug_capa);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/cl_io.c b/kernel/drivers/staging/lustre/lustre/obdclass/cl_io.c
index 3141b6043..e67cea758 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -307,7 +307,7 @@ static void cl_io_locks_sort(struct cl_io *io)
*/
default:
LBUG();
- case +1:
+ case 1:
list_move_tail(&curr->cill_linkage,
&prev->cill_linkage);
done = 0;
@@ -335,7 +335,7 @@ int cl_queue_match(const struct list_head *queue,
list_for_each_entry(scan, queue, cill_linkage) {
if (cl_lock_descr_match(&scan->cill_descr, need))
- return +1;
+ return 1;
}
return 0;
}
@@ -353,7 +353,7 @@ static int cl_queue_merge(const struct list_head *queue,
CDEBUG(D_VFSTRACE, "lock: %d: [%lu, %lu]\n",
scan->cill_descr.cld_mode, scan->cill_descr.cld_start,
scan->cill_descr.cld_end);
- return +1;
+ return 1;
}
return 0;
@@ -570,7 +570,8 @@ EXPORT_SYMBOL(cl_io_iter_fini);
/**
* Records that read or write io progressed \a nob bytes forward.
*/
-void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, size_t nob)
+static void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io,
+ size_t nob)
{
const struct cl_io_slice *scan;
@@ -589,7 +590,6 @@ void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, size_t nob)
nob);
}
}
-EXPORT_SYMBOL(cl_io_rw_advance);
/**
* Adds a lock to a lockset.
@@ -600,7 +600,7 @@ int cl_io_lock_add(const struct lu_env *env, struct cl_io *io,
int result;
if (cl_lockset_merge(&io->ci_lockset, &link->cill_descr))
- result = +1;
+ result = 1;
else {
list_add(&link->cill_linkage, &io->ci_lockset.cls_todo);
result = 0;
@@ -612,7 +612,7 @@ EXPORT_SYMBOL(cl_io_lock_add);
static void cl_free_io_lock_link(const struct lu_env *env,
struct cl_io_lock_link *link)
{
- OBD_FREE_PTR(link);
+ kfree(link);
}
/**
@@ -624,7 +624,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io,
struct cl_io_lock_link *link;
int result;
- OBD_ALLOC_PTR(link);
+ link = kzalloc(sizeof(*link), GFP_NOFS);
if (link != NULL) {
link->cill_descr = *descr;
link->cill_fini = cl_free_io_lock_link;
@@ -715,6 +715,7 @@ static int cl_page_in_io(const struct cl_page *page, const struct cl_io *io)
*/
if (!cl_io_is_append(io)) {
const struct cl_io_rw_common *crw = &(io->u.ci_rw);
+
start = cl_offset(page->cp_obj, idx);
end = cl_offset(page->cp_obj, idx + 1);
result = crw->crw_pos < end &&
@@ -918,7 +919,7 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io,
*/
cl_page_list_for_each(pg, &queue->c2_qin) {
pg->cp_sync_io = NULL;
- cl_sync_io_note(anchor, +1);
+ cl_sync_io_note(anchor, 1);
}
/* wait for the IO to be finished. */
@@ -936,8 +937,8 @@ EXPORT_SYMBOL(cl_io_submit_sync);
/**
* Cancel an IO which has been submitted by cl_io_submit_rw.
*/
-int cl_io_cancel(const struct lu_env *env, struct cl_io *io,
- struct cl_page_list *queue)
+static int cl_io_cancel(const struct lu_env *env, struct cl_io *io,
+ struct cl_page_list *queue)
{
struct cl_page *page;
int result = 0;
@@ -952,7 +953,6 @@ int cl_io_cancel(const struct lu_env *env, struct cl_io *io,
}
return result;
}
-EXPORT_SYMBOL(cl_io_cancel);
/**
* Main io loop.
@@ -1040,7 +1040,6 @@ void cl_io_slice_add(struct cl_io *io, struct cl_io_slice *slice,
}
EXPORT_SYMBOL(cl_io_slice_add);
-
/**
* Initializes page list.
*/
@@ -1076,8 +1075,8 @@ EXPORT_SYMBOL(cl_page_list_add);
/**
* Removes a page from a page list.
*/
-void cl_page_list_del(const struct lu_env *env,
- struct cl_page_list *plist, struct cl_page *page)
+static void cl_page_list_del(const struct lu_env *env,
+ struct cl_page_list *plist, struct cl_page *page)
{
LASSERT(plist->pl_nr > 0);
LINVRNT(plist->pl_owner == current);
@@ -1090,7 +1089,6 @@ void cl_page_list_del(const struct lu_env *env,
lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist);
cl_page_put(env, page);
}
-EXPORT_SYMBOL(cl_page_list_del);
/**
* Moves a page from one page list to another.
@@ -1167,7 +1165,8 @@ EXPORT_SYMBOL(cl_page_list_disown);
/**
* Releases pages from queue.
*/
-void cl_page_list_fini(const struct lu_env *env, struct cl_page_list *plist)
+static void cl_page_list_fini(const struct lu_env *env,
+ struct cl_page_list *plist)
{
struct cl_page *page;
struct cl_page *temp;
@@ -1178,39 +1177,12 @@ void cl_page_list_fini(const struct lu_env *env, struct cl_page_list *plist)
cl_page_list_del(env, plist, page);
LASSERT(plist->pl_nr == 0);
}
-EXPORT_SYMBOL(cl_page_list_fini);
-
-/**
- * Owns all pages in a queue.
- */
-int cl_page_list_own(const struct lu_env *env,
- struct cl_io *io, struct cl_page_list *plist)
-{
- struct cl_page *page;
- struct cl_page *temp;
- pgoff_t index = 0;
- int result;
-
- LINVRNT(plist->pl_owner == current);
-
- result = 0;
- cl_page_list_for_each_safe(page, temp, plist) {
- LASSERT(index <= page->cp_index);
- index = page->cp_index;
- if (cl_page_own(env, io, page) == 0)
- result = result ?: page->cp_error;
- else
- cl_page_list_del(env, plist, page);
- }
- return result;
-}
-EXPORT_SYMBOL(cl_page_list_own);
/**
* Assumes all pages in a queue.
*/
-void cl_page_list_assume(const struct lu_env *env,
- struct cl_io *io, struct cl_page_list *plist)
+static void cl_page_list_assume(const struct lu_env *env,
+ struct cl_io *io, struct cl_page_list *plist)
{
struct cl_page *page;
@@ -1219,13 +1191,12 @@ void cl_page_list_assume(const struct lu_env *env,
cl_page_list_for_each(page, plist)
cl_page_assume(env, io, page);
}
-EXPORT_SYMBOL(cl_page_list_assume);
/**
* Discards all pages in a queue.
*/
-void cl_page_list_discard(const struct lu_env *env, struct cl_io *io,
- struct cl_page_list *plist)
+static void cl_page_list_discard(const struct lu_env *env, struct cl_io *io,
+ struct cl_page_list *plist)
{
struct cl_page *page;
@@ -1233,27 +1204,6 @@ void cl_page_list_discard(const struct lu_env *env, struct cl_io *io,
cl_page_list_for_each(page, plist)
cl_page_discard(env, io, page);
}
-EXPORT_SYMBOL(cl_page_list_discard);
-
-/**
- * Unmaps all pages in a queue from user virtual memory.
- */
-int cl_page_list_unmap(const struct lu_env *env, struct cl_io *io,
- struct cl_page_list *plist)
-{
- struct cl_page *page;
- int result;
-
- LINVRNT(plist->pl_owner == current);
- result = 0;
- cl_page_list_for_each(page, plist) {
- result = cl_page_unmap(env, io, page);
- if (result != 0)
- break;
- }
- return result;
-}
-EXPORT_SYMBOL(cl_page_list_unmap);
/**
* Initialize dual page queue.
@@ -1297,17 +1247,6 @@ void cl_2queue_discard(const struct lu_env *env,
EXPORT_SYMBOL(cl_2queue_discard);
/**
- * Assume to own the pages in cl_2queue
- */
-void cl_2queue_assume(const struct lu_env *env,
- struct cl_io *io, struct cl_2queue *queue)
-{
- cl_page_list_assume(env, io, &queue->c2_qin);
- cl_page_list_assume(env, io, &queue->c2_qout);
-}
-EXPORT_SYMBOL(cl_2queue_assume);
-
-/**
* Finalize both page lists of a 2-queue.
*/
void cl_2queue_fini(const struct lu_env *env, struct cl_2queue *queue)
@@ -1341,14 +1280,6 @@ struct cl_io *cl_io_top(struct cl_io *io)
EXPORT_SYMBOL(cl_io_top);
/**
- * Prints human readable representation of \a io to the \a f.
- */
-void cl_io_print(const struct lu_env *env, void *cookie,
- lu_printer_t printer, const struct cl_io *io)
-{
-}
-
-/**
* Adds request slice to the compound request.
*
* This is called by cl_device_operations::cdo_req_init() methods to add a
@@ -1380,6 +1311,7 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req)
if (req->crq_o != NULL) {
for (i = 0; i < req->crq_nrobjs; ++i) {
struct cl_object *obj = req->crq_o[i].ro_obj;
+
if (obj != NULL) {
lu_object_ref_del_at(&obj->co_lu,
&req->crq_o[i].ro_obj_ref,
@@ -1387,9 +1319,9 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req)
cl_object_put(env, obj);
}
}
- OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof(req->crq_o[0]));
+ kfree(req->crq_o);
}
- OBD_FREE_PTR(req);
+ kfree(req);
}
static int cl_req_init(const struct lu_env *env, struct cl_req *req,
@@ -1448,7 +1380,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page,
LINVRNT(nr_objects > 0);
- OBD_ALLOC_PTR(req);
+ req = kzalloc(sizeof(*req), GFP_NOFS);
if (req != NULL) {
int result;
@@ -1456,7 +1388,8 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page,
INIT_LIST_HEAD(&req->crq_pages);
INIT_LIST_HEAD(&req->crq_layers);
- OBD_ALLOC(req->crq_o, nr_objects * sizeof(req->crq_o[0]));
+ req->crq_o = kcalloc(nr_objects, sizeof(req->crq_o[0]),
+ GFP_NOFS);
if (req->crq_o != NULL) {
req->crq_nrobjs = nr_objects;
result = cl_req_init(env, req, page);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/kernel/drivers/staging/lustre/lustre/obdclass/cl_lock.c
index b081167f9..5621bebf3 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/cl_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/cl_lock.c
@@ -129,6 +129,7 @@ static void cl_lock_trace0(int level, const struct lu_env *env,
const char *func, const int line)
{
struct cl_object_header *h = cl_object_header(lock->cll_descr.cld_obj);
+
CDEBUG(level, "%s: %p@(%d %p %d %d %d %d %d %lx)(%p/%d/%d) at %s():%d\n",
prefix, lock, atomic_read(&lock->cll_ref),
lock->cll_guarder, lock->cll_depth,
@@ -137,6 +138,7 @@ static void cl_lock_trace0(int level, const struct lu_env *env,
env, h->coh_nesting, cl_lock_nr_mutexed(env),
func, line);
}
+
#define cl_lock_trace(level, env, prefix, lock) \
cl_lock_trace0(level, env, prefix, lock, __func__, __LINE__)
@@ -268,7 +270,7 @@ static void cl_lock_free(const struct lu_env *env, struct cl_lock *lock)
lu_ref_fini(&lock->cll_reference);
lu_ref_fini(&lock->cll_holders);
mutex_destroy(&lock->cll_guard);
- OBD_SLAB_FREE_PTR(lock, cl_lock_kmem);
+ kmem_cache_free(cl_lock_kmem, lock);
}
/**
@@ -359,7 +361,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env,
struct cl_lock *lock;
struct lu_object_header *head;
- OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, GFP_NOFS);
+ lock = kmem_cache_alloc(cl_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (lock != NULL) {
atomic_set(&lock->cll_ref, 1);
lock->cll_descr = *descr;
@@ -403,8 +405,8 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env,
* \post state: CLS_INTRANSIT
* \see CLS_INTRANSIT
*/
-enum cl_lock_state cl_lock_intransit(const struct lu_env *env,
- struct cl_lock *lock)
+static enum cl_lock_state cl_lock_intransit(const struct lu_env *env,
+ struct cl_lock *lock)
{
enum cl_lock_state state = lock->cll_state;
@@ -418,13 +420,12 @@ enum cl_lock_state cl_lock_intransit(const struct lu_env *env,
cl_lock_hold_add(env, lock, "intransit", current);
return state;
}
-EXPORT_SYMBOL(cl_lock_intransit);
/**
* Exit the intransit state and restore the lock state to the original state
*/
-void cl_lock_extransit(const struct lu_env *env, struct cl_lock *lock,
- enum cl_lock_state state)
+static void cl_lock_extransit(const struct lu_env *env, struct cl_lock *lock,
+ enum cl_lock_state state)
{
LASSERT(cl_lock_is_mutexed(lock));
LASSERT(lock->cll_state == CLS_INTRANSIT);
@@ -435,7 +436,6 @@ void cl_lock_extransit(const struct lu_env *env, struct cl_lock *lock,
cl_lock_state_set(env, lock, state);
cl_lock_unhold(env, lock, "intransit", current);
}
-EXPORT_SYMBOL(cl_lock_extransit);
/**
* Checking whether the lock is intransit state
@@ -1100,6 +1100,7 @@ int cl_use_try(const struct lu_env *env, struct cl_lock *lock, int atomic)
/* @atomic means back-off-on-failure. */
if (atomic) {
int rc;
+
rc = cl_unuse_try_internal(env, lock);
/* Vet the results. */
if (rc < 0 && result > 0)
@@ -1276,32 +1277,6 @@ static int cl_enqueue_locked(const struct lu_env *env, struct cl_lock *lock,
}
/**
- * Enqueues a lock.
- *
- * \pre current thread or io owns a hold on lock.
- *
- * \post ergo(result == 0, lock->users increased)
- * \post ergo(result == 0, lock->cll_state == CLS_ENQUEUED ||
- * lock->cll_state == CLS_HELD)
- */
-int cl_enqueue(const struct lu_env *env, struct cl_lock *lock,
- struct cl_io *io, __u32 enqflags)
-{
- int result;
-
- cl_lock_lockdep_acquire(env, lock, enqflags);
- cl_lock_mutex_get(env, lock);
- result = cl_enqueue_locked(env, lock, io, enqflags);
- cl_lock_mutex_put(env, lock);
- if (result != 0)
- cl_lock_lockdep_release(env, lock);
- LASSERT(ergo(result == 0, lock->cll_state == CLS_ENQUEUED ||
- lock->cll_state == CLS_HELD));
- return result;
-}
-EXPORT_SYMBOL(cl_enqueue);
-
-/**
* Tries to unlock a lock.
*
* This function is called to release underlying resource:
@@ -2027,7 +2002,7 @@ static struct cl_lock *cl_lock_hold_mutex(const struct lu_env *env,
cl_lock_mutex_get(env, lock);
if (lock->cll_state < CLS_FREEING &&
!(lock->cll_flags & CLF_CANCELLED)) {
- cl_lock_hold_mod(env, lock, +1);
+ cl_lock_hold_mod(env, lock, 1);
lu_ref_add(&lock->cll_holders, scope, source);
lu_ref_add(&lock->cll_reference, scope, source);
break;
@@ -2115,7 +2090,7 @@ void cl_lock_hold_add(const struct lu_env *env, struct cl_lock *lock,
LINVRNT(cl_lock_invariant(env, lock));
LASSERT(lock->cll_state != CLS_FREEING);
- cl_lock_hold_mod(env, lock, +1);
+ cl_lock_hold_mod(env, lock, 1);
cl_lock_get(lock);
lu_ref_add(&lock->cll_holders, scope, source);
lu_ref_add(&lock->cll_reference, scope, source);
@@ -2157,7 +2132,7 @@ void cl_lock_user_add(const struct lu_env *env, struct cl_lock *lock)
LINVRNT(cl_lock_is_mutexed(lock));
LINVRNT(cl_lock_invariant(env, lock));
- cl_lock_used_mod(env, lock, +1);
+ cl_lock_used_mod(env, lock, 1);
}
EXPORT_SYMBOL(cl_lock_user_add);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/cl_object.c b/kernel/drivers/staging/lustre/lustre/obdclass/cl_object.c
index f13d1fbff..a1a602422 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -98,16 +98,6 @@ int cl_object_header_init(struct cl_object_header *h)
EXPORT_SYMBOL(cl_object_header_init);
/**
- * Finalize cl_object_header.
- */
-void cl_object_header_fini(struct cl_object_header *h)
-{
- LASSERT(list_empty(&h->coh_locks));
- lu_object_header_fini(&h->coh_lu);
-}
-EXPORT_SYMBOL(cl_object_header_fini);
-
-/**
* Returns a cl_object with a given \a fid.
*
* Returns either cached or newly created object. Additional reference on the
@@ -363,22 +353,6 @@ void cl_object_prune(const struct lu_env *env, struct cl_object *obj)
}
EXPORT_SYMBOL(cl_object_prune);
-/**
- * Check if the object has locks.
- */
-int cl_object_has_locks(struct cl_object *obj)
-{
- struct cl_object_header *head = cl_object_header(obj);
- int has;
-
- spin_lock(&head->coh_lock_guard);
- has = list_empty(&head->coh_locks);
- spin_unlock(&head->coh_lock_guard);
-
- return (has == 0);
-}
-EXPORT_SYMBOL(cl_object_has_locks);
-
void cache_stats_init(struct cache_stats *cs, const char *name)
{
int i;
@@ -573,7 +547,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug)
CL_ENV_INC(busy);
}
-
/*
* The implementation of using hash table to connect cl_env and thread
*/
@@ -593,6 +566,7 @@ static unsigned cl_env_hops_hash(struct cfs_hash *lh,
static void *cl_env_hops_obj(struct hlist_node *hn)
{
struct cl_env *cle = hlist_entry(hn, struct cl_env, ce_node);
+
LASSERT(cle->ce_magic == &cl_env_init0);
return (void *)cle;
}
@@ -608,15 +582,16 @@ static int cl_env_hops_keycmp(const void *key, struct hlist_node *hn)
static void cl_env_hops_noop(struct cfs_hash *hs, struct hlist_node *hn)
{
struct cl_env *cle = hlist_entry(hn, struct cl_env, ce_node);
+
LASSERT(cle->ce_magic == &cl_env_init0);
}
-static cfs_hash_ops_t cl_env_hops = {
+static struct cfs_hash_ops cl_env_hops = {
.hs_hash = cl_env_hops_hash,
- .hs_key = cl_env_hops_obj,
+ .hs_key = cl_env_hops_obj,
.hs_keycmp = cl_env_hops_keycmp,
.hs_object = cl_env_hops_obj,
- .hs_get = cl_env_hops_noop,
+ .hs_get = cl_env_hops_noop,
.hs_put_locked = cl_env_hops_noop,
};
@@ -653,7 +628,8 @@ static inline void cl_env_do_detach(struct cl_env *cle)
cle->ce_owner = NULL;
}
-static int cl_env_store_init(void) {
+static int cl_env_store_init(void)
+{
cl_env_hash = cfs_hash_create("cl_env",
HASH_CL_ENV_BITS, HASH_CL_ENV_BITS,
HASH_CL_ENV_BKT_BITS, 0,
@@ -661,7 +637,7 @@ static int cl_env_store_init(void) {
CFS_HASH_MAX_THETA,
&cl_env_hops,
CFS_HASH_RW_BKTLOCK);
- return cl_env_hash != NULL ? 0 :-ENOMEM;
+ return cl_env_hash != NULL ? 0 : -ENOMEM;
}
static void cl_env_store_fini(void)
@@ -669,7 +645,6 @@ static void cl_env_store_fini(void)
cfs_hash_putref(cl_env_hash);
}
-
static inline struct cl_env *cl_env_detach(struct cl_env *cle)
{
if (cle == NULL)
@@ -686,17 +661,17 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)
struct lu_env *env;
struct cl_env *cle;
- OBD_SLAB_ALLOC_PTR_GFP(cle, cl_env_kmem, GFP_NOFS);
+ cle = kmem_cache_alloc(cl_env_kmem, GFP_NOFS | __GFP_ZERO);
if (cle != NULL) {
int rc;
INIT_LIST_HEAD(&cle->ce_linkage);
cle->ce_magic = &cl_env_init0;
env = &cle->ce_lu;
- rc = lu_env_init(env, LCT_CL_THREAD|ctx_tags);
+ rc = lu_env_init(env, ctx_tags | LCT_CL_THREAD);
if (rc == 0) {
rc = lu_context_init(&cle->ce_ses,
- LCT_SESSION | ses_tags);
+ ses_tags | LCT_SESSION);
if (rc == 0) {
lu_context_enter(&cle->ce_ses);
env->le_ses = &cle->ce_ses;
@@ -705,7 +680,7 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)
lu_env_fini(env);
}
if (rc != 0) {
- OBD_SLAB_FREE_PTR(cle, cl_env_kmem);
+ kmem_cache_free(cl_env_kmem, cle);
env = ERR_PTR(rc);
} else {
CL_ENV_INC(create);
@@ -721,7 +696,7 @@ static void cl_env_fini(struct cl_env *cle)
CL_ENV_DEC(total);
lu_context_fini(&cle->ce_lu.le_ctx);
lu_context_fini(&cle->ce_ses);
- OBD_SLAB_FREE_PTR(cle, cl_env_kmem);
+ kmem_cache_free(cl_env_kmem, cle);
}
static inline struct cl_env *cl_env_container(struct lu_env *env)
@@ -906,10 +881,8 @@ struct lu_env *cl_env_nested_get(struct cl_env_nest *nest)
if (env != NULL) {
if (!cl_io_is_going(env))
return env;
- else {
- cl_env_put(env, &nest->cen_refcheck);
- nest->cen_cookie = cl_env_reenter();
- }
+ cl_env_put(env, &nest->cen_refcheck);
+ nest->cen_cookie = cl_env_reenter();
}
env = cl_env_get(&nest->cen_refcheck);
if (IS_ERR(env)) {
@@ -930,21 +903,6 @@ void cl_env_nested_put(struct cl_env_nest *nest, struct lu_env *env)
EXPORT_SYMBOL(cl_env_nested_put);
/**
- * Converts struct cl_attr to struct ost_lvb.
- *
- * \see cl_lvb2attr
- */
-void cl_attr2lvb(struct ost_lvb *lvb, const struct cl_attr *attr)
-{
- lvb->lvb_size = attr->cat_size;
- lvb->lvb_mtime = attr->cat_mtime;
- lvb->lvb_atime = attr->cat_atime;
- lvb->lvb_ctime = attr->cat_ctime;
- lvb->lvb_blocks = attr->cat_blocks;
-}
-EXPORT_SYMBOL(cl_attr2lvb);
-
-/**
* Converts struct ost_lvb to struct cl_attr.
*
* \see cl_attr2lvb
@@ -1076,7 +1034,7 @@ static struct lu_kmem_descr cl_object_caches[] = {
{
.ckd_cache = &cl_env_kmem,
.ckd_name = "cl_env_kmem",
- .ckd_size = sizeof (struct cl_env)
+ .ckd_size = sizeof(struct cl_env)
},
{
.ckd_cache = NULL
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/cl_page.c b/kernel/drivers/staging/lustre/lustre/obdclass/cl_page.c
index b7dd04808..2f569edd0 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -51,23 +51,17 @@
static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
int radix);
-# define PASSERT(env, page, expr) \
- do { \
- if (unlikely(!(expr))) { \
- CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
- LASSERT(0); \
- } \
- } while (0)
+# define PASSERT(env, page, expr) \
+ do { \
+ if (unlikely(!(expr))) { \
+ CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
+ LASSERT(0); \
+ } \
+ } while (0)
# define PINVRNT(env, page, exp) \
((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
-/* Disable page statistic by default due to huge performance penalty. */
-#define CS_PAGE_INC(o, item)
-#define CS_PAGE_DEC(o, item)
-#define CS_PAGESTATE_INC(o, state)
-#define CS_PAGESTATE_DEC(o, state)
-
/**
* Internal version of cl_page_top, it should be called if the page is
* known to be not freed, says with page referenced, or radix tree lock held,
@@ -175,6 +169,7 @@ int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj,
while ((nr = radix_tree_gang_lookup(&hdr->coh_tree, (void **)pvec,
idx, CLT_PVEC_SIZE)) > 0) {
int end_of_region = 0;
+
idx = pvec[nr - 1]->cp_index + 1;
for (i = 0, j = 0; i < nr; ++i) {
page = pvec[i];
@@ -248,7 +243,6 @@ EXPORT_SYMBOL(cl_page_gang_lookup);
static void cl_page_free(const struct lu_env *env, struct cl_page *page)
{
struct cl_object *obj = page->cp_obj;
- int pagesize = cl_object_header(obj)->coh_page_bufsize;
PASSERT(env, page, list_empty(&page->cp_batch));
PASSERT(env, page, page->cp_owner == NULL);
@@ -265,12 +259,10 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page)
list_del_init(page->cp_layers.next);
slice->cpl_ops->cpo_fini(env, slice);
}
- CS_PAGE_DEC(obj, total);
- CS_PAGESTATE_DEC(obj, page->cp_state);
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);
- OBD_FREE(page, pagesize);
+ kfree(page);
}
/**
@@ -291,10 +283,10 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env,
struct cl_page *page;
struct lu_object_header *head;
- OBD_ALLOC_GFP(page, cl_object_header(o)->coh_page_bufsize,
- GFP_NOFS);
+ page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS);
if (page != NULL) {
int result = 0;
+
atomic_set(&page->cp_ref, 1);
if (type == CPT_CACHEABLE) /* for radix tree */
atomic_inc(&page->cp_ref);
@@ -324,11 +316,6 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env,
}
}
}
- if (result == 0) {
- CS_PAGE_INC(o, total);
- CS_PAGE_INC(o, create);
- CS_PAGESTATE_DEC(o, CPS_CACHED);
- }
} else {
page = ERR_PTR(-ENOMEM);
}
@@ -361,14 +348,15 @@ static struct cl_page *cl_page_find0(const struct lu_env *env,
might_sleep();
hdr = cl_object_header(o);
- CS_PAGE_INC(o, lookup);
CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n",
idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type);
/* fast path. */
if (type == CPT_CACHEABLE) {
- /* vmpage lock is used to protect the child/parent
- * relationship */
+ /*
+ * vmpage lock is used to protect the child/parent
+ * relationship
+ */
KLASSERT(PageLocked(vmpage));
/*
* cl_vmpage_page() can be called here without any locks as
@@ -387,10 +375,8 @@ static struct cl_page *cl_page_find0(const struct lu_env *env,
idx) == page));
}
- if (page != NULL) {
- CS_PAGE_INC(o, hit);
+ if (page != NULL)
return page;
- }
/* allocate and initialize cl_page */
page = cl_page_alloc(env, o, idx, vmpage, type);
@@ -455,7 +441,6 @@ struct cl_page *cl_page_find(const struct lu_env *env, struct cl_object *o,
}
EXPORT_SYMBOL(cl_page_find);
-
struct cl_page *cl_page_find_sub(const struct lu_env *env, struct cl_object *o,
pgoff_t idx, struct page *vmpage,
struct cl_page *parent)
@@ -555,8 +540,6 @@ static void cl_page_state_set0(const struct lu_env *env,
PASSERT(env, page,
equi(state == CPS_OWNED, page->cp_owner != NULL));
- CS_PAGESTATE_DEC(page->cp_obj, page->cp_state);
- CS_PAGESTATE_INC(page->cp_obj, state);
cl_page_state_set_trust(page, state);
}
}
@@ -919,7 +902,6 @@ int cl_page_own_try(const struct lu_env *env, struct cl_io *io,
}
EXPORT_SYMBOL(cl_page_own_try);
-
/**
* Assume page ownership.
*
@@ -1207,9 +1189,6 @@ int cl_page_prep(const struct lu_env *env, struct cl_io *io,
if (result == 0)
cl_page_io_start(env, pg, crt);
- KLASSERT(ergo(crt == CRT_WRITE && pg->cp_type == CPT_CACHEABLE,
- equi(result == 0,
- PageWriteback(cl_page_vmpage(env, pg)))));
CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
return result;
}
@@ -1443,7 +1422,7 @@ void cl_page_clip(const struct lu_env *env, struct cl_page *pg,
CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", from, to);
CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_clip),
(const struct lu_env *,
- const struct cl_page_slice *,int, int),
+ const struct cl_page_slice *, int, int),
from, to);
}
EXPORT_SYMBOL(cl_page_clip);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/class_obd.c b/kernel/drivers/staging/lustre/lustre/obdclass/class_obd.c
index d4b74b670..3e9c24684 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -47,25 +47,12 @@
#include "../include/cl_object.h"
#include "llog_internal.h"
-
struct obd_device *obd_devs[MAX_OBD_DEVICES];
EXPORT_SYMBOL(obd_devs);
struct list_head obd_types;
DEFINE_RWLOCK(obd_dev_lock);
-__u64 obd_max_pages = 0;
-EXPORT_SYMBOL(obd_max_pages);
-__u64 obd_max_alloc = 0;
-EXPORT_SYMBOL(obd_max_alloc);
-__u64 obd_alloc;
-EXPORT_SYMBOL(obd_alloc);
-__u64 obd_pages;
-EXPORT_SYMBOL(obd_pages);
-static DEFINE_SPINLOCK(obd_updatemax_lock);
-
/* The following are visible and mutable through /proc/sys/lustre/. */
-unsigned int obd_alloc_fail_rate = 0;
-EXPORT_SYMBOL(obd_alloc_fail_rate);
unsigned int obd_debug_peer_on_timeout;
EXPORT_SYMBOL(obd_debug_peer_on_timeout);
unsigned int obd_dump_on_timeout;
@@ -78,14 +65,10 @@ atomic_t obd_dirty_pages;
EXPORT_SYMBOL(obd_dirty_pages);
unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT; /* seconds */
EXPORT_SYMBOL(obd_timeout);
-unsigned int ldlm_timeout = LDLM_TIMEOUT_DEFAULT; /* seconds */
-EXPORT_SYMBOL(ldlm_timeout);
unsigned int obd_timeout_set;
EXPORT_SYMBOL(obd_timeout_set);
-unsigned int ldlm_timeout_set;
-EXPORT_SYMBOL(ldlm_timeout_set);
/* Adaptive timeout defs here instead of ptlrpc module for /proc/sys/ access */
-unsigned int at_min = 0;
+unsigned int at_min;
EXPORT_SYMBOL(at_min);
unsigned int at_max = 600;
EXPORT_SYMBOL(at_max);
@@ -136,25 +119,6 @@ int lustre_get_jobid(char *jobid)
}
EXPORT_SYMBOL(lustre_get_jobid);
-int obd_alloc_fail(const void *ptr, const char *name, const char *type,
- size_t size, const char *file, int line)
-{
- if (ptr == NULL ||
- (cfs_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) {
- CERROR("%s%salloc of %s (%llu bytes) failed at %s:%d\n",
- ptr ? "force " :"", type, name, (__u64)size, file,
- line);
- CERROR("%llu total bytes and %llu total pages (%llu bytes) allocated by Lustre, %d total bytes by LNET\n",
- obd_memory_sum(),
- obd_pages_sum() << PAGE_CACHE_SHIFT,
- obd_pages_sum(),
- atomic_read(&libcfs_kmemory));
- return 1;
- }
- return 0;
-}
-EXPORT_SYMBOL(obd_alloc_fail);
-
static inline void obd_data2conn(struct lustre_handle *conn,
struct obd_ioctl_data *data)
{
@@ -168,7 +132,7 @@ static inline void obd_conn2data(struct obd_ioctl_data *data,
data->ioc_cookie = conn->cookie;
}
-int class_resolve_dev_name(__u32 len, const char *name)
+static int class_resolve_dev_name(__u32 len, const char *name)
{
int rc;
int dev;
@@ -231,8 +195,8 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
err = -EINVAL;
goto out;
}
- OBD_ALLOC(lcfg, data->ioc_plen1);
- if (lcfg == NULL) {
+ lcfg = kzalloc(data->ioc_plen1, GFP_NOFS);
+ if (!lcfg) {
err = -ENOMEM;
goto out;
}
@@ -243,7 +207,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
if (!err)
err = class_process_config(lcfg);
- OBD_FREE(lcfg, data->ioc_plen1);
+ kfree(lcfg);
goto out;
}
@@ -438,7 +402,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
} /* class_handle_ioctl */
#define OBD_INIT_CHECK
-int obd_init_checks(void)
+static int obd_init_checks(void)
{
__u64 u64val, div64val;
char buf[64];
@@ -474,7 +438,7 @@ int obd_init_checks(void)
return -EOVERFLOW;
}
if (do_div(div64val, 256) != (u64val & 255)) {
- CERROR("do_div(%#llx,256) != %llu\n", u64val, u64val &255);
+ CERROR("do_div(%#llx,256) != %llu\n", u64val, u64val & 255);
return -EOVERFLOW;
}
if (u64val >> 8 != div64val) {
@@ -506,47 +470,20 @@ int obd_init_checks(void)
return ret;
}
-#if defined (CONFIG_PROC_FS)
extern int class_procfs_init(void);
extern int class_procfs_clean(void);
-#else
-static inline int class_procfs_init(void)
-{ return 0; }
-static inline int class_procfs_clean(void)
-{ return 0; }
-#endif
static int __init init_obdclass(void)
{
int i, err;
- int lustre_register_fs(void);
- for (i = CAPA_SITE_CLIENT; i < CAPA_SITE_MAX; i++)
- INIT_LIST_HEAD(&capa_list[i]);
+ int lustre_register_fs(void);
LCONSOLE_INFO("Lustre: Build Version: "BUILD_VERSION"\n");
spin_lock_init(&obd_types_lock);
obd_zombie_impexp_init();
- if (IS_ENABLED(CONFIG_PROC_FS)) {
- obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
- LPROCFS_STATS_FLAG_NONE |
- LPROCFS_STATS_FLAG_IRQ_SAFE);
-
- if (obd_memory == NULL) {
- CERROR("kmalloc of 'obd_memory' failed\n");
- return -ENOMEM;
- }
-
- lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
- LPROCFS_CNTR_AVGMINMAX,
- "memused", "bytes");
- lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
- LPROCFS_CNTR_AVGMINMAX,
- "pagesused", "pages");
- }
-
err = obd_init_checks();
if (err == -EOVERFLOW)
return err;
@@ -580,12 +517,14 @@ static int __init init_obdclass(void)
if (err)
return err;
- obd_sysctl_init();
-
err = class_procfs_init();
if (err)
return err;
+ err = obd_sysctl_init();
+ if (err)
+ return err;
+
err = lu_global_init();
if (err)
return err;
@@ -594,7 +533,6 @@ static int __init init_obdclass(void)
if (err != 0)
return err;
-
err = llog_info_init();
if (err)
return err;
@@ -604,62 +542,20 @@ static int __init init_obdclass(void)
return err;
}
-void obd_update_maxusage(void)
-{
- __u64 max1, max2;
-
- max1 = obd_pages_sum();
- max2 = obd_memory_sum();
-
- spin_lock(&obd_updatemax_lock);
- if (max1 > obd_max_pages)
- obd_max_pages = max1;
- if (max2 > obd_max_alloc)
- obd_max_alloc = max2;
- spin_unlock(&obd_updatemax_lock);
-}
-EXPORT_SYMBOL(obd_update_maxusage);
-
-#if defined (CONFIG_PROC_FS)
-__u64 obd_memory_max(void)
-{
- __u64 ret;
-
- spin_lock(&obd_updatemax_lock);
- ret = obd_max_alloc;
- spin_unlock(&obd_updatemax_lock);
-
- return ret;
-}
-EXPORT_SYMBOL(obd_memory_max);
-
-__u64 obd_pages_max(void)
-{
- __u64 ret;
-
- spin_lock(&obd_updatemax_lock);
- ret = obd_max_pages;
- spin_unlock(&obd_updatemax_lock);
-
- return ret;
-}
-EXPORT_SYMBOL(obd_pages_max);
-#endif
-
/* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this
* ifdef to the end of the file to cover module and versioning goo.*/
static void cleanup_obdclass(void)
{
int i;
+
int lustre_unregister_fs(void);
- __u64 memory_leaked, pages_leaked;
- __u64 memory_max, pages_max;
lustre_unregister_fs();
misc_deregister(&obd_psdev);
for (i = 0; i < class_devno_max(); i++) {
struct obd_device *obd = class_num2obd(i);
+
if (obd && obd->obd_set_up &&
OBT(obd) && OBP(obd, detach)) {
/* XXX should this call generic detach otherwise? */
@@ -672,27 +568,12 @@ static void cleanup_obdclass(void)
lu_global_fini();
obd_cleanup_caches();
- obd_sysctl_clean();
class_procfs_clean();
class_handle_cleanup();
class_exit_uuidlist();
obd_zombie_impexp_stop();
-
- memory_leaked = obd_memory_sum();
- pages_leaked = obd_pages_sum();
-
- memory_max = obd_memory_max();
- pages_max = obd_pages_max();
-
- lprocfs_free_stats(&obd_memory);
- CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
- "obd_memory max: %llu, leaked: %llu\n",
- memory_max, memory_leaked);
- CDEBUG((pages_leaked) ? D_ERROR : D_INFO,
- "obd_memory_pages max: %llu, leaked: %llu\n",
- pages_max, pages_leaked);
}
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/debug.c b/kernel/drivers/staging/lustre/lustre/obdclass/debug.c
index c61add46b..43a7f7a79 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/debug.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/debug.c
@@ -46,16 +46,6 @@
#include "../include/lustre_debug.h"
#include "../include/lustre_net.h"
-void dump_lniobuf(struct niobuf_local *nb)
-{
- CDEBUG(D_RPCTRACE,
- "niobuf_local: file_offset=%lld, len=%d, page=%p, rc=%d\n",
- nb->lnb_file_offset, nb->len, nb->page, nb->rc);
- CDEBUG(D_RPCTRACE, "nb->page: index = %ld\n",
- nb->page ? page_index(nb->page) : -1);
-}
-EXPORT_SYMBOL(dump_lniobuf);
-
#define LPDS sizeof(__u64)
int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
{
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/dt_object.c b/kernel/drivers/staging/lustre/lustre/obdclass/dt_object.c
deleted file mode 100644
index b1eee0a6d..000000000
--- a/kernel/drivers/staging/lustre/lustre/obdclass/dt_object.c
+++ /dev/null
@@ -1,1059 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/obdclass/dt_object.c
- *
- * Dt Object.
- * Generic functions from dt_object.h
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_CLASS
-
-#include "../include/obd.h"
-#include "../include/dt_object.h"
-#include <linux/list.h>
-/* fid_be_to_cpu() */
-#include "../include/lustre_fid.h"
-
-#include "../include/lustre_quota.h"
-
-/* context key constructor/destructor: dt_global_key_init, dt_global_key_fini */
-LU_KEY_INIT(dt_global, struct dt_thread_info);
-LU_KEY_FINI(dt_global, struct dt_thread_info);
-
-struct lu_context_key dt_key = {
- .lct_tags = LCT_MD_THREAD | LCT_DT_THREAD | LCT_MG_THREAD | LCT_LOCAL,
- .lct_init = dt_global_key_init,
- .lct_fini = dt_global_key_fini
-};
-EXPORT_SYMBOL(dt_key);
-
-/* no lock is necessary to protect the list, because call-backs
- * are added during system startup. Please refer to "struct dt_device".
- */
-void dt_txn_callback_add(struct dt_device *dev, struct dt_txn_callback *cb)
-{
- list_add(&cb->dtc_linkage, &dev->dd_txn_callbacks);
-}
-EXPORT_SYMBOL(dt_txn_callback_add);
-
-void dt_txn_callback_del(struct dt_device *dev, struct dt_txn_callback *cb)
-{
- list_del_init(&cb->dtc_linkage);
-}
-EXPORT_SYMBOL(dt_txn_callback_del);
-
-int dt_txn_hook_start(const struct lu_env *env,
- struct dt_device *dev, struct thandle *th)
-{
- int rc = 0;
- struct dt_txn_callback *cb;
-
- if (th->th_local)
- return 0;
-
- list_for_each_entry(cb, &dev->dd_txn_callbacks, dtc_linkage) {
- if (cb->dtc_txn_start == NULL ||
- !(cb->dtc_tag & env->le_ctx.lc_tags))
- continue;
- rc = cb->dtc_txn_start(env, th, cb->dtc_cookie);
- if (rc < 0)
- break;
- }
- return rc;
-}
-EXPORT_SYMBOL(dt_txn_hook_start);
-
-int dt_txn_hook_stop(const struct lu_env *env, struct thandle *txn)
-{
- struct dt_device *dev = txn->th_dev;
- struct dt_txn_callback *cb;
- int rc = 0;
-
- if (txn->th_local)
- return 0;
-
- list_for_each_entry(cb, &dev->dd_txn_callbacks, dtc_linkage) {
- if (cb->dtc_txn_stop == NULL ||
- !(cb->dtc_tag & env->le_ctx.lc_tags))
- continue;
- rc = cb->dtc_txn_stop(env, txn, cb->dtc_cookie);
- if (rc < 0)
- break;
- }
- return rc;
-}
-EXPORT_SYMBOL(dt_txn_hook_stop);
-
-void dt_txn_hook_commit(struct thandle *txn)
-{
- struct dt_txn_callback *cb;
-
- if (txn->th_local)
- return;
-
- list_for_each_entry(cb, &txn->th_dev->dd_txn_callbacks,
- dtc_linkage) {
- if (cb->dtc_txn_commit)
- cb->dtc_txn_commit(txn, cb->dtc_cookie);
- }
-}
-EXPORT_SYMBOL(dt_txn_hook_commit);
-
-int dt_device_init(struct dt_device *dev, struct lu_device_type *t)
-{
-
- INIT_LIST_HEAD(&dev->dd_txn_callbacks);
- return lu_device_init(&dev->dd_lu_dev, t);
-}
-EXPORT_SYMBOL(dt_device_init);
-
-void dt_device_fini(struct dt_device *dev)
-{
- lu_device_fini(&dev->dd_lu_dev);
-}
-EXPORT_SYMBOL(dt_device_fini);
-
-int dt_object_init(struct dt_object *obj,
- struct lu_object_header *h, struct lu_device *d)
-
-{
- return lu_object_init(&obj->do_lu, h, d);
-}
-EXPORT_SYMBOL(dt_object_init);
-
-void dt_object_fini(struct dt_object *obj)
-{
- lu_object_fini(&obj->do_lu);
-}
-EXPORT_SYMBOL(dt_object_fini);
-
-int dt_try_as_dir(const struct lu_env *env, struct dt_object *obj)
-{
- if (obj->do_index_ops == NULL)
- obj->do_ops->do_index_try(env, obj, &dt_directory_features);
- return obj->do_index_ops != NULL;
-}
-EXPORT_SYMBOL(dt_try_as_dir);
-
-enum dt_format_type dt_mode_to_dft(__u32 mode)
-{
- enum dt_format_type result;
-
- switch (mode & S_IFMT) {
- case S_IFDIR:
- result = DFT_DIR;
- break;
- case S_IFREG:
- result = DFT_REGULAR;
- break;
- case S_IFLNK:
- result = DFT_SYM;
- break;
- case S_IFCHR:
- case S_IFBLK:
- case S_IFIFO:
- case S_IFSOCK:
- result = DFT_NODE;
- break;
- default:
- LBUG();
- break;
- }
- return result;
-}
-EXPORT_SYMBOL(dt_mode_to_dft);
-
-/**
- * lookup fid for object named \a name in directory \a dir.
- */
-
-int dt_lookup_dir(const struct lu_env *env, struct dt_object *dir,
- const char *name, struct lu_fid *fid)
-{
- if (dt_try_as_dir(env, dir))
- return dt_lookup(env, dir, (struct dt_rec *)fid,
- (const struct dt_key *)name, BYPASS_CAPA);
- return -ENOTDIR;
-}
-EXPORT_SYMBOL(dt_lookup_dir);
-
-/* this differs from dt_locate by top_dev as parameter
- * but not one from lu_site */
-struct dt_object *dt_locate_at(const struct lu_env *env,
- struct dt_device *dev, const struct lu_fid *fid,
- struct lu_device *top_dev)
-{
- struct lu_object *lo, *n;
-
- lo = lu_object_find_at(env, top_dev, fid, NULL);
- if (IS_ERR(lo))
- return (void *)lo;
-
- LASSERT(lo != NULL);
-
- list_for_each_entry(n, &lo->lo_header->loh_layers, lo_linkage) {
- if (n->lo_dev == &dev->dd_lu_dev)
- return container_of0(n, struct dt_object, do_lu);
- }
- return ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(dt_locate_at);
-
-/**
- * find a object named \a entry in given \a dfh->dfh_o directory.
- */
-static int dt_find_entry(const struct lu_env *env, const char *entry, void *data)
-{
- struct dt_find_hint *dfh = data;
- struct dt_device *dt = dfh->dfh_dt;
- struct lu_fid *fid = dfh->dfh_fid;
- struct dt_object *obj = dfh->dfh_o;
- int result;
-
- result = dt_lookup_dir(env, obj, entry, fid);
- lu_object_put(env, &obj->do_lu);
- if (result == 0) {
- obj = dt_locate(env, dt, fid);
- if (IS_ERR(obj))
- result = PTR_ERR(obj);
- }
- dfh->dfh_o = obj;
- return result;
-}
-
-/**
- * Abstract function which parses path name. This function feeds
- * path component to \a entry_func.
- */
-int dt_path_parser(const struct lu_env *env,
- char *path, dt_entry_func_t entry_func,
- void *data)
-{
- char *e;
- int rc = 0;
-
- while (1) {
- e = strsep(&path, "/");
- if (e == NULL)
- break;
-
- if (e[0] == 0) {
- if (!path || path[0] == '\0')
- break;
- continue;
- }
- rc = entry_func(env, e, data);
- if (rc)
- break;
- }
-
- return rc;
-}
-
-struct dt_object *
-dt_store_resolve(const struct lu_env *env, struct dt_device *dt,
- const char *path, struct lu_fid *fid)
-{
- struct dt_thread_info *info = dt_info(env);
- struct dt_find_hint *dfh = &info->dti_dfh;
- struct dt_object *obj;
- char *local = info->dti_buf;
- int result;
-
-
- dfh->dfh_dt = dt;
- dfh->dfh_fid = fid;
-
- strncpy(local, path, DT_MAX_PATH);
- local[DT_MAX_PATH - 1] = '\0';
-
- result = dt->dd_ops->dt_root_get(env, dt, fid);
- if (result == 0) {
- obj = dt_locate(env, dt, fid);
- if (!IS_ERR(obj)) {
- dfh->dfh_o = obj;
- result = dt_path_parser(env, local, dt_find_entry, dfh);
- if (result != 0)
- obj = ERR_PTR(result);
- else
- obj = dfh->dfh_o;
- }
- } else {
- obj = ERR_PTR(result);
- }
- return obj;
-}
-EXPORT_SYMBOL(dt_store_resolve);
-
-static struct dt_object *dt_reg_open(const struct lu_env *env,
- struct dt_device *dt,
- struct dt_object *p,
- const char *name,
- struct lu_fid *fid)
-{
- struct dt_object *o;
- int result;
-
- result = dt_lookup_dir(env, p, name, fid);
- if (result == 0){
- o = dt_locate(env, dt, fid);
- } else
- o = ERR_PTR(result);
-
- return o;
-}
-
-/**
- * Open dt object named \a filename from \a dirname directory.
- * \param dt dt device
- * \param fid on success, object fid is stored in *fid
- */
-struct dt_object *dt_store_open(const struct lu_env *env,
- struct dt_device *dt,
- const char *dirname,
- const char *filename,
- struct lu_fid *fid)
-{
- struct dt_object *file;
- struct dt_object *dir;
-
- dir = dt_store_resolve(env, dt, dirname, fid);
- if (!IS_ERR(dir)) {
- file = dt_reg_open(env, dt, dir,
- filename, fid);
- lu_object_put(env, &dir->do_lu);
- } else {
- file = dir;
- }
- return file;
-}
-EXPORT_SYMBOL(dt_store_open);
-
-struct dt_object *dt_find_or_create(const struct lu_env *env,
- struct dt_device *dt,
- const struct lu_fid *fid,
- struct dt_object_format *dof,
- struct lu_attr *at)
-{
- struct dt_object *dto;
- struct thandle *th;
- int rc;
-
- dto = dt_locate(env, dt, fid);
- if (IS_ERR(dto))
- return dto;
-
- LASSERT(dto != NULL);
- if (dt_object_exists(dto))
- return dto;
-
- th = dt_trans_create(env, dt);
- if (IS_ERR(th)) {
- rc = PTR_ERR(th);
- goto out;
- }
-
- rc = dt_declare_create(env, dto, at, NULL, dof, th);
- if (rc)
- goto trans_stop;
-
- rc = dt_trans_start_local(env, dt, th);
- if (rc)
- goto trans_stop;
-
- dt_write_lock(env, dto, 0);
- if (dt_object_exists(dto)) {
- rc = 0;
- goto unlock;
- }
-
- CDEBUG(D_OTHER, "create new object "DFID"\n", PFID(fid));
-
- rc = dt_create(env, dto, at, NULL, dof, th);
- if (rc)
- goto unlock;
- LASSERT(dt_object_exists(dto));
-unlock:
- dt_write_unlock(env, dto);
-trans_stop:
- dt_trans_stop(env, dt, th);
-out:
- if (rc) {
- lu_object_put(env, &dto->do_lu);
- return ERR_PTR(rc);
- }
- return dto;
-}
-EXPORT_SYMBOL(dt_find_or_create);
-
-/* dt class init function. */
-int dt_global_init(void)
-{
- LU_CONTEXT_KEY_INIT(&dt_key);
- return lu_context_key_register(&dt_key);
-}
-
-void dt_global_fini(void)
-{
- lu_context_key_degister(&dt_key);
-}
-
-/**
- * Generic read helper. May return an error for partial reads.
- *
- * \param env lustre environment
- * \param dt object to be read
- * \param buf lu_buf to be filled, with buffer pointer and length
- * \param pos position to start reading, updated as data is read
- *
- * \retval real size of data read
- * \retval -ve errno on failure
- */
-int dt_read(const struct lu_env *env, struct dt_object *dt,
- struct lu_buf *buf, loff_t *pos)
-{
- LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
- return dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
-}
-EXPORT_SYMBOL(dt_read);
-
-/**
- * Read structures of fixed size from storage. Unlike dt_read(), using
- * dt_record_read() will return an error for partial reads.
- *
- * \param env lustre environment
- * \param dt object to be read
- * \param buf lu_buf to be filled, with buffer pointer and length
- * \param pos position to start reading, updated as data is read
- *
- * \retval 0 on successfully reading full buffer
- * \retval -EFAULT on short read
- * \retval -ve errno on failure
- */
-int dt_record_read(const struct lu_env *env, struct dt_object *dt,
- struct lu_buf *buf, loff_t *pos)
-{
- int rc;
-
- LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
-
- rc = dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
-
- if (rc == buf->lb_len)
- rc = 0;
- else if (rc >= 0)
- rc = -EFAULT;
- return rc;
-}
-EXPORT_SYMBOL(dt_record_read);
-
-int dt_record_write(const struct lu_env *env, struct dt_object *dt,
- const struct lu_buf *buf, loff_t *pos, struct thandle *th)
-{
- int rc;
-
- LASSERTF(dt != NULL, "dt is NULL when we want to write record\n");
- LASSERT(th != NULL);
- LASSERT(dt->do_body_ops);
- LASSERT(dt->do_body_ops->dbo_write);
- rc = dt->do_body_ops->dbo_write(env, dt, buf, pos, th, BYPASS_CAPA, 1);
- if (rc == buf->lb_len)
- rc = 0;
- else if (rc >= 0)
- rc = -EFAULT;
- return rc;
-}
-EXPORT_SYMBOL(dt_record_write);
-
-int dt_declare_version_set(const struct lu_env *env, struct dt_object *o,
- struct thandle *th)
-{
- struct lu_buf vbuf;
- char *xname = XATTR_NAME_VERSION;
-
- LASSERT(o);
- vbuf.lb_buf = NULL;
- vbuf.lb_len = sizeof(dt_obj_version_t);
- return dt_declare_xattr_set(env, o, &vbuf, xname, 0, th);
-
-}
-EXPORT_SYMBOL(dt_declare_version_set);
-
-void dt_version_set(const struct lu_env *env, struct dt_object *o,
- dt_obj_version_t version, struct thandle *th)
-{
- struct lu_buf vbuf;
- char *xname = XATTR_NAME_VERSION;
- int rc;
-
- LASSERT(o);
- vbuf.lb_buf = &version;
- vbuf.lb_len = sizeof(version);
-
- rc = dt_xattr_set(env, o, &vbuf, xname, 0, th, BYPASS_CAPA);
- if (rc < 0)
- CDEBUG(D_INODE, "Can't set version, rc %d\n", rc);
- return;
-}
-EXPORT_SYMBOL(dt_version_set);
-
-dt_obj_version_t dt_version_get(const struct lu_env *env, struct dt_object *o)
-{
- struct lu_buf vbuf;
- char *xname = XATTR_NAME_VERSION;
- dt_obj_version_t version;
- int rc;
-
- LASSERT(o);
- vbuf.lb_buf = &version;
- vbuf.lb_len = sizeof(version);
- rc = dt_xattr_get(env, o, &vbuf, xname, BYPASS_CAPA);
- if (rc != sizeof(version)) {
- CDEBUG(D_INODE, "Can't get version, rc %d\n", rc);
- version = 0;
- }
- return version;
-}
-EXPORT_SYMBOL(dt_version_get);
-
-/* list of all supported index types */
-
-/* directories */
-const struct dt_index_features dt_directory_features;
-EXPORT_SYMBOL(dt_directory_features);
-
-/* scrub iterator */
-const struct dt_index_features dt_otable_features;
-EXPORT_SYMBOL(dt_otable_features);
-
-/* lfsck */
-const struct dt_index_features dt_lfsck_features = {
- .dif_flags = DT_IND_UPDATE,
- .dif_keysize_min = sizeof(struct lu_fid),
- .dif_keysize_max = sizeof(struct lu_fid),
- .dif_recsize_min = sizeof(__u8),
- .dif_recsize_max = sizeof(__u8),
- .dif_ptrsize = 4
-};
-EXPORT_SYMBOL(dt_lfsck_features);
-
-/* accounting indexes */
-const struct dt_index_features dt_acct_features = {
- .dif_flags = DT_IND_UPDATE,
- .dif_keysize_min = sizeof(__u64), /* 64-bit uid/gid */
- .dif_keysize_max = sizeof(__u64), /* 64-bit uid/gid */
- .dif_recsize_min = sizeof(struct lquota_acct_rec), /* 16 bytes */
- .dif_recsize_max = sizeof(struct lquota_acct_rec), /* 16 bytes */
- .dif_ptrsize = 4
-};
-EXPORT_SYMBOL(dt_acct_features);
-
-/* global quota files */
-const struct dt_index_features dt_quota_glb_features = {
- .dif_flags = DT_IND_UPDATE,
- /* a different key would have to be used for per-directory quota */
- .dif_keysize_min = sizeof(__u64), /* 64-bit uid/gid */
- .dif_keysize_max = sizeof(__u64), /* 64-bit uid/gid */
- .dif_recsize_min = sizeof(struct lquota_glb_rec), /* 32 bytes */
- .dif_recsize_max = sizeof(struct lquota_glb_rec), /* 32 bytes */
- .dif_ptrsize = 4
-};
-EXPORT_SYMBOL(dt_quota_glb_features);
-
-/* slave quota files */
-const struct dt_index_features dt_quota_slv_features = {
- .dif_flags = DT_IND_UPDATE,
- /* a different key would have to be used for per-directory quota */
- .dif_keysize_min = sizeof(__u64), /* 64-bit uid/gid */
- .dif_keysize_max = sizeof(__u64), /* 64-bit uid/gid */
- .dif_recsize_min = sizeof(struct lquota_slv_rec), /* 8 bytes */
- .dif_recsize_max = sizeof(struct lquota_slv_rec), /* 8 bytes */
- .dif_ptrsize = 4
-};
-EXPORT_SYMBOL(dt_quota_slv_features);
-
-/* helper function returning what dt_index_features structure should be used
- * based on the FID sequence. This is used by OBD_IDX_READ RPC */
-static inline const struct dt_index_features *dt_index_feat_select(__u64 seq,
- __u32 mode)
-{
- if (seq == FID_SEQ_QUOTA_GLB) {
- /* global quota index */
- if (!S_ISREG(mode))
- /* global quota index should be a regular file */
- return ERR_PTR(-ENOENT);
- return &dt_quota_glb_features;
- } else if (seq == FID_SEQ_QUOTA) {
- /* quota slave index */
- if (!S_ISREG(mode))
- /* slave index should be a regular file */
- return ERR_PTR(-ENOENT);
- return &dt_quota_slv_features;
- } else if (seq >= FID_SEQ_NORMAL) {
- /* object is part of the namespace, verify that it is a
- * directory */
- if (!S_ISDIR(mode))
- /* sorry, we can only deal with directory */
- return ERR_PTR(-ENOTDIR);
- return &dt_directory_features;
- }
-
- return ERR_PTR(-EOPNOTSUPP);
-}
-
-/*
- * Fill a lu_idxpage with key/record pairs read for transfer via OBD_IDX_READ
- * RPC
- *
- * \param env - is the environment passed by the caller
- * \param lp - is a pointer to the lu_page to fill
- * \param nob - is the maximum number of bytes that should be copied
- * \param iops - is the index operation vector associated with the index object
- * \param it - is a pointer to the current iterator
- * \param attr - is the index attribute to pass to iops->rec()
- * \param arg - is a pointer to the idx_info structure
- */
-static int dt_index_page_build(const struct lu_env *env, union lu_page *lp,
- int nob, const struct dt_it_ops *iops,
- struct dt_it *it, __u32 attr, void *arg)
-{
- struct idx_info *ii = (struct idx_info *)arg;
- struct lu_idxpage *lip = &lp->lp_idx;
- char *entry;
- int rc, size;
-
- /* no support for variable key & record size for now */
- LASSERT((ii->ii_flags & II_FL_VARKEY) == 0);
- LASSERT((ii->ii_flags & II_FL_VARREC) == 0);
-
- /* initialize the header of the new container */
- memset(lip, 0, LIP_HDR_SIZE);
- lip->lip_magic = LIP_MAGIC;
- nob -= LIP_HDR_SIZE;
-
- /* compute size needed to store a key/record pair */
- size = ii->ii_recsize + ii->ii_keysize;
- if ((ii->ii_flags & II_FL_NOHASH) == 0)
- /* add hash if the client wants it */
- size += sizeof(__u64);
-
- entry = lip->lip_entries;
- do {
- char *tmp_entry = entry;
- struct dt_key *key;
- __u64 hash;
-
- /* fetch 64-bit hash value */
- hash = iops->store(env, it);
- ii->ii_hash_end = hash;
-
- if (OBD_FAIL_CHECK(OBD_FAIL_OBD_IDX_READ_BREAK)) {
- if (lip->lip_nr != 0) {
- rc = 0;
- goto out;
- }
- }
-
- if (nob < size) {
- if (lip->lip_nr == 0)
- rc = -EINVAL;
- else
- rc = 0;
- goto out;
- }
-
- if ((ii->ii_flags & II_FL_NOHASH) == 0) {
- /* client wants to the 64-bit hash value associated with
- * each record */
- memcpy(tmp_entry, &hash, sizeof(hash));
- tmp_entry += sizeof(hash);
- }
-
- /* then the key value */
- LASSERT(iops->key_size(env, it) == ii->ii_keysize);
- key = iops->key(env, it);
- memcpy(tmp_entry, key, ii->ii_keysize);
- tmp_entry += ii->ii_keysize;
-
- /* and finally the record */
- rc = iops->rec(env, it, (struct dt_rec *)tmp_entry, attr);
- if (rc != -ESTALE) {
- if (rc != 0)
- goto out;
-
- /* hash/key/record successfully copied! */
- lip->lip_nr++;
- if (unlikely(lip->lip_nr == 1 && ii->ii_count == 0))
- ii->ii_hash_start = hash;
- entry = tmp_entry + ii->ii_recsize;
- nob -= size;
- }
-
- /* move on to the next record */
- do {
- rc = iops->next(env, it);
- } while (rc == -ESTALE);
-
- } while (rc == 0);
-
- goto out;
-out:
- if (rc >= 0 && lip->lip_nr > 0)
- /* one more container */
- ii->ii_count++;
- if (rc > 0)
- /* no more entries */
- ii->ii_hash_end = II_END_OFF;
- return rc;
-}
-
-/*
- * Walk index and fill lu_page containers with key/record pairs
- *
- * \param env - is the environment passed by the caller
- * \param obj - is the index object to parse
- * \param rdpg - is the lu_rdpg descriptor associated with the transfer
- * \param filler - is the callback function responsible for filling a lu_page
- * with key/record pairs in the format wanted by the caller
- * \param arg - is an opaq argument passed to the filler function
- *
- * \retval sum (in bytes) of all filled lu_pages
- * \retval -ve errno on failure
- */
-int dt_index_walk(const struct lu_env *env, struct dt_object *obj,
- const struct lu_rdpg *rdpg, dt_index_page_build_t filler,
- void *arg)
-{
- struct dt_it *it;
- const struct dt_it_ops *iops;
- unsigned int pageidx, nob, nlupgs = 0;
- int rc;
-
- LASSERT(rdpg->rp_pages != NULL);
- LASSERT(obj->do_index_ops != NULL);
-
- nob = rdpg->rp_count;
- if (nob <= 0)
- return -EFAULT;
-
- /* Iterate through index and fill containers from @rdpg */
- iops = &obj->do_index_ops->dio_it;
- LASSERT(iops != NULL);
- it = iops->init(env, obj, rdpg->rp_attrs, BYPASS_CAPA);
- if (IS_ERR(it))
- return PTR_ERR(it);
-
- rc = iops->load(env, it, rdpg->rp_hash);
- if (rc == 0) {
- /*
- * Iterator didn't find record with exactly the key requested.
- *
- * It is currently either
- *
- * - positioned above record with key less than
- * requested---skip it.
- * - or not positioned at all (is in IAM_IT_SKEWED
- * state)---position it on the next item.
- */
- rc = iops->next(env, it);
- } else if (rc > 0) {
- rc = 0;
- }
-
- /* Fill containers one after the other. There might be multiple
- * containers per physical page.
- *
- * At this point and across for-loop:
- * rc == 0 -> ok, proceed.
- * rc > 0 -> end of index.
- * rc < 0 -> error. */
- for (pageidx = 0; rc == 0 && nob > 0; pageidx++) {
- union lu_page *lp;
- int i;
-
- LASSERT(pageidx < rdpg->rp_npages);
- lp = kmap(rdpg->rp_pages[pageidx]);
-
- /* fill lu pages */
- for (i = 0; i < LU_PAGE_COUNT; i++, lp++, nob -= LU_PAGE_SIZE) {
- rc = filler(env, lp, min_t(int, nob, LU_PAGE_SIZE),
- iops, it, rdpg->rp_attrs, arg);
- if (rc < 0)
- break;
- /* one more lu_page */
- nlupgs++;
- if (rc > 0)
- /* end of index */
- break;
- }
- kunmap(rdpg->rp_pages[i]);
- }
-
- iops->put(env, it);
- iops->fini(env, it);
-
- if (rc >= 0)
- rc = min_t(unsigned int, nlupgs * LU_PAGE_SIZE, rdpg->rp_count);
-
- return rc;
-}
-EXPORT_SYMBOL(dt_index_walk);
-
-/**
- * Walk key/record pairs of an index and copy them into 4KB containers to be
- * transferred over the network. This is the common handler for OBD_IDX_READ
- * RPC processing.
- *
- * \param env - is the environment passed by the caller
- * \param dev - is the dt_device storing the index
- * \param ii - is the idx_info structure packed by the client in the
- * OBD_IDX_READ request
- * \param rdpg - is the lu_rdpg descriptor
- *
- * \retval on success, return sum (in bytes) of all filled containers
- * \retval appropriate error otherwise.
- */
-int dt_index_read(const struct lu_env *env, struct dt_device *dev,
- struct idx_info *ii, const struct lu_rdpg *rdpg)
-{
- const struct dt_index_features *feat;
- struct dt_object *obj;
- int rc;
-
- /* rp_count shouldn't be null and should be a multiple of the container
- * size */
- if (rdpg->rp_count <= 0 && (rdpg->rp_count & (LU_PAGE_SIZE - 1)) != 0)
- return -EFAULT;
-
- if (fid_seq(&ii->ii_fid) >= FID_SEQ_NORMAL)
- /* we don't support directory transfer via OBD_IDX_READ for the
- * time being */
- return -EOPNOTSUPP;
-
- if (!fid_is_quota(&ii->ii_fid))
- /* block access to all local files except quota files */
- return -EPERM;
-
- /* lookup index object subject to the transfer */
- obj = dt_locate(env, dev, &ii->ii_fid);
- if (IS_ERR(obj))
- return PTR_ERR(obj);
- if (dt_object_exists(obj) == 0) {
- rc = -ENOENT;
- goto out;
- }
-
- /* fetch index features associated with index object */
- feat = dt_index_feat_select(fid_seq(&ii->ii_fid),
- lu_object_attr(&obj->do_lu));
- if (IS_ERR(feat)) {
- rc = PTR_ERR(feat);
- goto out;
- }
-
- /* load index feature if not done already */
- if (obj->do_index_ops == NULL) {
- rc = obj->do_ops->do_index_try(env, obj, feat);
- if (rc)
- goto out;
- }
-
- /* fill ii_flags with supported index features */
- ii->ii_flags &= II_FL_NOHASH;
-
- ii->ii_keysize = feat->dif_keysize_max;
- if ((feat->dif_flags & DT_IND_VARKEY) != 0) {
- /* key size is variable */
- ii->ii_flags |= II_FL_VARKEY;
- /* we don't support variable key size for the time being */
- rc = -EOPNOTSUPP;
- goto out;
- }
-
- ii->ii_recsize = feat->dif_recsize_max;
- if ((feat->dif_flags & DT_IND_VARREC) != 0) {
- /* record size is variable */
- ii->ii_flags |= II_FL_VARREC;
- /* we don't support variable record size for the time being */
- rc = -EOPNOTSUPP;
- goto out;
- }
-
- if ((feat->dif_flags & DT_IND_NONUNQ) != 0)
- /* key isn't necessarily unique */
- ii->ii_flags |= II_FL_NONUNQ;
-
- dt_read_lock(env, obj, 0);
- /* fetch object version before walking the index */
- ii->ii_version = dt_version_get(env, obj);
-
- /* walk the index and fill lu_idxpages with key/record pairs */
- rc = dt_index_walk(env, obj, rdpg, dt_index_page_build ,ii);
- dt_read_unlock(env, obj);
-
- if (rc == 0) {
- /* index is empty */
- LASSERT(ii->ii_count == 0);
- ii->ii_hash_end = II_END_OFF;
- }
-
- goto out;
-out:
- lu_object_put(env, &obj->do_lu);
- return rc;
-}
-EXPORT_SYMBOL(dt_index_read);
-
-#if defined (CONFIG_PROC_FS)
-
-int lprocfs_dt_rd_blksize(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct dt_device *dt = data;
- struct obd_statfs osfs;
- int rc = dt_statfs(NULL, dt, &osfs);
-
- if (rc == 0) {
- *eof = 1;
- rc = snprintf(page, count, "%u\n",
- (unsigned) osfs.os_bsize);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_dt_rd_blksize);
-
-int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct dt_device *dt = data;
- struct obd_statfs osfs;
- int rc = dt_statfs(NULL, dt, &osfs);
-
- if (rc == 0) {
- __u32 blk_size = osfs.os_bsize >> 10;
- __u64 result = osfs.os_blocks;
-
- while (blk_size >>= 1)
- result <<= 1;
-
- *eof = 1;
- rc = snprintf(page, count, "%llu\n", result);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_dt_rd_kbytestotal);
-
-int lprocfs_dt_rd_kbytesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct dt_device *dt = data;
- struct obd_statfs osfs;
- int rc = dt_statfs(NULL, dt, &osfs);
-
- if (rc == 0) {
- __u32 blk_size = osfs.os_bsize >> 10;
- __u64 result = osfs.os_bfree;
-
- while (blk_size >>= 1)
- result <<= 1;
-
- *eof = 1;
- rc = snprintf(page, count, "%llu\n", result);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_dt_rd_kbytesfree);
-
-int lprocfs_dt_rd_kbytesavail(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct dt_device *dt = data;
- struct obd_statfs osfs;
- int rc = dt_statfs(NULL, dt, &osfs);
-
- if (rc == 0) {
- __u32 blk_size = osfs.os_bsize >> 10;
- __u64 result = osfs.os_bavail;
-
- while (blk_size >>= 1)
- result <<= 1;
-
- *eof = 1;
- rc = snprintf(page, count, "%llu\n", result);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_dt_rd_kbytesavail);
-
-int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct dt_device *dt = data;
- struct obd_statfs osfs;
- int rc = dt_statfs(NULL, dt, &osfs);
-
- if (rc == 0) {
- *eof = 1;
- rc = snprintf(page, count, "%llu\n", osfs.os_files);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_dt_rd_filestotal);
-
-int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct dt_device *dt = data;
- struct obd_statfs osfs;
- int rc = dt_statfs(NULL, dt, &osfs);
-
- if (rc == 0) {
- *eof = 1;
- rc = snprintf(page, count, "%llu\n", osfs.os_ffree);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_dt_rd_filesfree);
-
-#endif /* CONFIG_PROC_FS */
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/genops.c b/kernel/drivers/staging/lustre/lustre/obdclass/genops.c
index 66b56784f..6477aeb88 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -45,7 +45,7 @@
spinlock_t obd_types_lock;
-struct kmem_cache *obd_device_cachep;
+static struct kmem_cache *obd_device_cachep;
struct kmem_cache *obdo_cachep;
EXPORT_SYMBOL(obdo_cachep);
static struct kmem_cache *import_cachep;
@@ -56,8 +56,6 @@ static spinlock_t obd_zombie_impexp_lock;
static void obd_zombie_impexp_notify(void);
static void obd_zombie_export_add(struct obd_export *exp);
static void obd_zombie_import_add(struct obd_import *imp);
-static void print_export_data(struct obd_export *exp,
- const char *status, int locks);
int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
@@ -70,10 +68,9 @@ static struct obd_device *obd_device_alloc(void)
{
struct obd_device *obd;
- OBD_SLAB_ALLOC_PTR_GFP(obd, obd_device_cachep, GFP_NOFS);
- if (obd != NULL) {
+ obd = kmem_cache_alloc(obd_device_cachep, GFP_NOFS | __GFP_ZERO);
+ if (obd != NULL)
obd->obd_magic = OBD_DEVICE_MAGIC;
- }
return obd;
}
@@ -88,10 +85,10 @@ static void obd_device_free(struct obd_device *obd)
LBUG();
}
lu_ref_fini(&obd->obd_reference);
- OBD_SLAB_FREE_PTR(obd, obd_device_cachep);
+ kmem_cache_free(obd_device_cachep, obd);
}
-struct obd_type *class_search_type(const char *name)
+static struct obd_type *class_search_type(const char *name)
{
struct list_head *tmp;
struct obd_type *type;
@@ -107,9 +104,8 @@ struct obd_type *class_search_type(const char *name)
spin_unlock(&obd_types_lock);
return NULL;
}
-EXPORT_SYMBOL(class_search_type);
-struct obd_type *class_get_type(const char *name)
+static struct obd_type *class_get_type(const char *name)
{
struct obd_type *type = class_search_type(name);
@@ -141,7 +137,6 @@ struct obd_type *class_get_type(const char *name)
}
return type;
}
-EXPORT_SYMBOL(class_get_type);
void class_put_type(struct obd_type *type)
{
@@ -156,7 +151,7 @@ EXPORT_SYMBOL(class_put_type);
#define CLASS_MAX_NAME 1024
int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
- struct lprocfs_vars *vars, const char *name,
+ const char *name,
struct lu_device_type *ldt)
{
struct obd_type *type;
@@ -171,17 +166,17 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
}
rc = -ENOMEM;
- OBD_ALLOC(type, sizeof(*type));
- if (type == NULL)
+ type = kzalloc(sizeof(*type), GFP_NOFS);
+ if (!type)
return rc;
- OBD_ALLOC_PTR(type->typ_dt_ops);
- OBD_ALLOC_PTR(type->typ_md_ops);
- OBD_ALLOC(type->typ_name, strlen(name) + 1);
+ 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 == NULL ||
- type->typ_md_ops == NULL ||
- type->typ_name == NULL)
+ if (!type->typ_dt_ops ||
+ !type->typ_md_ops ||
+ !type->typ_name)
goto failed;
*(type->typ_dt_ops) = *dt_ops;
@@ -191,11 +186,19 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
strcpy(type->typ_name, name);
spin_lock_init(&type->obd_type_lock);
- type->typ_procroot = lprocfs_register(type->typ_name, proc_lustre_root,
- vars, type);
- if (IS_ERR(type->typ_procroot)) {
- rc = PTR_ERR(type->typ_procroot);
- type->typ_procroot = NULL;
+ type->typ_debugfs_entry = ldebugfs_register(type->typ_name,
+ debugfs_lustre_root,
+ NULL, type);
+ if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) {
+ rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
+ : -ENOMEM;
+ type->typ_debugfs_entry = NULL;
+ goto failed;
+ }
+
+ type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj);
+ if (!type->typ_kobj) {
+ rc = -ENOMEM;
goto failed;
}
@@ -213,13 +216,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
return 0;
failed:
- if (type->typ_name != NULL)
- OBD_FREE(type->typ_name, strlen(name) + 1);
- if (type->typ_md_ops != NULL)
- OBD_FREE_PTR(type->typ_md_ops);
- if (type->typ_dt_ops != NULL)
- OBD_FREE_PTR(type->typ_dt_ops);
- OBD_FREE(type, sizeof(*type));
+ if (type->typ_kobj)
+ kobject_put(type->typ_kobj);
+ kfree(type->typ_name);
+ kfree(type->typ_md_ops);
+ kfree(type->typ_dt_ops);
+ kfree(type);
return rc;
}
EXPORT_SYMBOL(class_register_type);
@@ -237,14 +239,16 @@ int class_unregister_type(const char *name)
CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt);
/* This is a bad situation, let's make the best of it */
/* Remove ops, but leave the name for debugging */
- OBD_FREE_PTR(type->typ_dt_ops);
- OBD_FREE_PTR(type->typ_md_ops);
+ kfree(type->typ_dt_ops);
+ kfree(type->typ_md_ops);
return -EBUSY;
}
- if (type->typ_procroot) {
- lprocfs_remove(&type->typ_procroot);
- }
+ if (type->typ_kobj)
+ kobject_put(type->typ_kobj);
+
+ if (!IS_ERR_OR_NULL(type->typ_debugfs_entry))
+ ldebugfs_remove(&type->typ_debugfs_entry);
if (type->typ_lu)
lu_device_type_fini(type->typ_lu);
@@ -252,12 +256,10 @@ int class_unregister_type(const char *name)
spin_lock(&obd_types_lock);
list_del(&type->typ_chain);
spin_unlock(&obd_types_lock);
- OBD_FREE(type->typ_name, strlen(name) + 1);
- if (type->typ_dt_ops != NULL)
- OBD_FREE_PTR(type->typ_dt_ops);
- if (type->typ_md_ops != NULL)
- OBD_FREE_PTR(type->typ_md_ops);
- OBD_FREE(type, sizeof(*type));
+ kfree(type->typ_name);
+ kfree(type->typ_dt_ops);
+ kfree(type->typ_md_ops);
+ kfree(type);
return 0;
} /* class_unregister_type */
EXPORT_SYMBOL(class_unregister_type);
@@ -287,13 +289,13 @@ struct obd_device *class_newdev(const char *type_name, const char *name)
}
type = class_get_type(type_name);
- if (type == NULL){
+ if (!type) {
CERROR("OBD: unknown type: %s\n", type_name);
return ERR_PTR(-ENODEV);
}
newdev = obd_device_alloc();
- if (newdev == NULL) {
+ if (!newdev) {
result = ERR_PTR(-ENOMEM);
goto out_type;
}
@@ -333,7 +335,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name)
}
write_unlock(&obd_dev_lock);
- if (result == NULL && i >= class_devno_max()) {
+ if (!result && i >= class_devno_max()) {
CERROR("all %u OBD devices used, increase MAX_OBD_DEVICES\n",
class_devno_max());
result = ERR_PTR(-EOVERFLOW);
@@ -433,15 +435,6 @@ int class_uuid2dev(struct obd_uuid *uuid)
}
EXPORT_SYMBOL(class_uuid2dev);
-struct obd_device *class_uuid2obd(struct obd_uuid *uuid)
-{
- int dev = class_uuid2dev(uuid);
- if (dev < 0)
- return NULL;
- return class_num2obd(dev);
-}
-EXPORT_SYMBOL(class_uuid2obd);
-
/**
* Get obd device from ::obd_devs[]
*
@@ -456,7 +449,7 @@ struct obd_device *class_num2obd(int num)
if (num < class_devno_max()) {
obd = obd_devs[num];
- if (obd == NULL)
+ if (!obd)
return NULL;
LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC,
@@ -471,55 +464,6 @@ struct obd_device *class_num2obd(int num)
}
EXPORT_SYMBOL(class_num2obd);
-/**
- * Get obd devices count. Device in any
- * state are counted
- * \retval obd device count
- */
-int get_devices_count(void)
-{
- int index, max_index = class_devno_max(), dev_count = 0;
-
- read_lock(&obd_dev_lock);
- for (index = 0; index <= max_index; index++) {
- struct obd_device *obd = class_num2obd(index);
- if (obd != NULL)
- dev_count++;
- }
- read_unlock(&obd_dev_lock);
-
- return dev_count;
-}
-EXPORT_SYMBOL(get_devices_count);
-
-void class_obd_list(void)
-{
- char *status;
- int i;
-
- read_lock(&obd_dev_lock);
- for (i = 0; i < class_devno_max(); i++) {
- struct obd_device *obd = class_num2obd(i);
-
- if (obd == NULL)
- continue;
- if (obd->obd_stopping)
- status = "ST";
- else if (obd->obd_set_up)
- status = "UP";
- else if (obd->obd_attached)
- status = "AT";
- else
- status = "--";
- LCONSOLE(D_CONFIG, "%3d %s %s %s %s %d\n",
- i, status, obd->obd_type->typ_name,
- obd->obd_name, obd->obd_uuid.uuid,
- atomic_read(&obd->obd_refcount));
- }
- read_unlock(&obd_dev_lock);
- return;
-}
-
/* Search for a client OBD connected to tgt_uuid. If grp_uuid is
specified, then only the client with that uuid is returned,
otherwise any client connected to the tgt is returned. */
@@ -533,13 +477,13 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid,
for (i = 0; i < class_devno_max(); i++) {
struct obd_device *obd = class_num2obd(i);
- if (obd == NULL)
+ if (!obd)
continue;
if ((strncmp(obd->obd_type->typ_name, typ_name,
strlen(typ_name)) == 0)) {
if (obd_uuid_equals(tgt_uuid,
&obd->u.cli.cl_target_uuid) &&
- ((grp_uuid)? obd_uuid_equals(grp_uuid,
+ ((grp_uuid) ? obd_uuid_equals(grp_uuid,
&obd->obd_uuid) : 1)) {
read_unlock(&obd_dev_lock);
return obd;
@@ -560,7 +504,7 @@ struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next)
{
int i;
- if (next == NULL)
+ if (!next)
i = 0;
else if (*next >= 0 && *next < class_devno_max())
i = *next;
@@ -571,10 +515,10 @@ struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next)
for (; i < class_devno_max(); i++) {
struct obd_device *obd = class_num2obd(i);
- if (obd == NULL)
+ if (!obd)
continue;
if (obd_uuid_equals(grp_uuid, &obd->obd_uuid)) {
- if (next != NULL)
+ if (next)
*next = i+1;
read_unlock(&obd_dev_lock);
return obd;
@@ -602,7 +546,7 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen)
for (i = 0; i < class_devno_max(); i++) {
obd = class_num2obd(i);
- if (obd == NULL || obd->obd_set_up == 0 || obd->obd_stopping)
+ if (!obd || obd->obd_set_up == 0 || obd->obd_stopping)
continue;
/* only notify mdc, osc, mdt, ost */
@@ -632,52 +576,36 @@ EXPORT_SYMBOL(class_notify_sptlrpc_conf);
void obd_cleanup_caches(void)
{
- if (obd_device_cachep) {
- kmem_cache_destroy(obd_device_cachep);
- obd_device_cachep = NULL;
- }
- if (obdo_cachep) {
- kmem_cache_destroy(obdo_cachep);
- obdo_cachep = NULL;
- }
- if (import_cachep) {
- kmem_cache_destroy(import_cachep);
- import_cachep = NULL;
- }
- if (capa_cachep) {
- kmem_cache_destroy(capa_cachep);
- capa_cachep = NULL;
- }
+ kmem_cache_destroy(obd_device_cachep);
+ obd_device_cachep = NULL;
+ kmem_cache_destroy(obdo_cachep);
+ obdo_cachep = NULL;
+ kmem_cache_destroy(import_cachep);
+ import_cachep = NULL;
}
int obd_init_caches(void)
{
- LASSERT(obd_device_cachep == NULL);
+ LASSERT(!obd_device_cachep);
obd_device_cachep = kmem_cache_create("ll_obd_dev_cache",
sizeof(struct obd_device),
0, 0, NULL);
if (!obd_device_cachep)
goto out;
- LASSERT(obdo_cachep == NULL);
+ LASSERT(!obdo_cachep);
obdo_cachep = kmem_cache_create("ll_obdo_cache", sizeof(struct obdo),
0, 0, NULL);
if (!obdo_cachep)
goto out;
- LASSERT(import_cachep == NULL);
+ LASSERT(!import_cachep);
import_cachep = kmem_cache_create("ll_import_cache",
sizeof(struct obd_import),
0, 0, NULL);
if (!import_cachep)
goto out;
- LASSERT(capa_cachep == NULL);
- capa_cachep = kmem_cache_create("capa_cache",
- sizeof(struct obd_capa), 0, 0, NULL);
- if (!capa_cachep)
- goto out;
-
return 0;
out:
obd_cleanup_caches();
@@ -714,36 +642,15 @@ struct obd_device *class_exp2obd(struct obd_export *exp)
}
EXPORT_SYMBOL(class_exp2obd);
-struct obd_device *class_conn2obd(struct lustre_handle *conn)
-{
- struct obd_export *export;
- export = class_conn2export(conn);
- if (export) {
- struct obd_device *obd = export->exp_obd;
- class_export_put(export);
- return obd;
- }
- return NULL;
-}
-EXPORT_SYMBOL(class_conn2obd);
-
struct obd_import *class_exp2cliimp(struct obd_export *exp)
{
struct obd_device *obd = exp->exp_obd;
- if (obd == NULL)
- return NULL;
- return obd->u.cli.cl_import;
-}
-EXPORT_SYMBOL(class_exp2cliimp);
-struct obd_import *class_conn2cliimp(struct lustre_handle *conn)
-{
- struct obd_device *obd = class_conn2obd(conn);
- if (obd == NULL)
+ if (!obd)
return NULL;
return obd->u.cli.cl_import;
}
-EXPORT_SYMBOL(class_conn2cliimp);
+EXPORT_SYMBOL(class_exp2cliimp);
/* Export management functions */
static void class_export_destroy(struct obd_export *exp)
@@ -819,7 +726,7 @@ struct obd_export *class_new_export(struct obd_device *obd,
struct cfs_hash *hash = NULL;
int rc = 0;
- OBD_ALLOC_PTR(export);
+ export = kzalloc(sizeof(*export), GFP_NOFS);
if (!export)
return ERR_PTR(-ENOMEM);
@@ -843,11 +750,9 @@ struct obd_export *class_new_export(struct obd_device *obd,
INIT_LIST_HEAD(&export->exp_handle.h_link);
INIT_LIST_HEAD(&export->exp_hp_rpcs);
class_handle_hash(&export->exp_handle, &export_handle_ops);
- export->exp_last_request_time = get_seconds();
spin_lock_init(&export->exp_lock);
spin_lock_init(&export->exp_rpc_lock);
INIT_HLIST_NODE(&export->exp_uuid_hash);
- INIT_HLIST_NODE(&export->exp_nid_hash);
spin_lock_init(&export->exp_bl_list_lock);
INIT_LIST_HEAD(&export->exp_bl_list);
@@ -864,7 +769,7 @@ struct obd_export *class_new_export(struct obd_device *obd,
}
hash = cfs_hash_getref(obd->obd_uuid_hash);
- if (hash == NULL) {
+ if (!hash) {
rc = -ENODEV;
goto exit_unlock;
}
@@ -889,8 +794,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
class_incref(obd, "export", export);
list_add(&export->exp_obd_chain, &export->exp_obd->obd_exports);
- list_add_tail(&export->exp_obd_chain_timed,
- &export->exp_obd->obd_exports_timed);
export->exp_obd->obd_num_exports++;
spin_unlock(&obd->obd_dev_lock);
cfs_hash_putref(hash);
@@ -904,7 +807,7 @@ exit_err:
class_handle_unhash(&export->exp_handle);
LASSERT(hlist_unhashed(&export->exp_uuid_hash));
obd_destroy_export(export);
- OBD_FREE_PTR(export);
+ kfree(export);
return ERR_PTR(rc);
}
EXPORT_SYMBOL(class_new_export);
@@ -921,7 +824,6 @@ void class_unlink_export(struct obd_export *exp)
&exp->exp_uuid_hash);
list_move(&exp->exp_obd_chain, &exp->exp_obd->obd_unlinked_exports);
- list_del_init(&exp->exp_obd_chain_timed);
exp->exp_obd->obd_num_exports--;
spin_unlock(&exp->exp_obd->obd_dev_lock);
class_export_put(exp);
@@ -945,10 +847,10 @@ static void class_import_destroy(struct obd_import *imp)
struct obd_import_conn, oic_item);
list_del_init(&imp_conn->oic_item);
ptlrpc_put_connection_superhack(imp_conn->oic_conn);
- OBD_FREE(imp_conn, sizeof(*imp_conn));
+ kfree(imp_conn);
}
- LASSERT(imp->imp_sec == NULL);
+ LASSERT(!imp->imp_sec);
class_decref(imp->imp_obd, "import", imp);
OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle);
}
@@ -992,8 +894,10 @@ void class_import_put(struct obd_import *imp)
}
EXPORT_SYMBOL(class_import_put);
-static void init_imp_at(struct imp_at *at) {
+static void init_imp_at(struct imp_at *at)
+{
int i;
+
at_init(&at->iat_net_latency, 0, 0);
for (i = 0; i < IMP_AT_MAX_PORTALS; i++) {
/* max service estimates are tracked on the server side, so
@@ -1008,8 +912,8 @@ struct obd_import *class_new_import(struct obd_device *obd)
{
struct obd_import *imp;
- OBD_ALLOC(imp, sizeof(*imp));
- if (imp == NULL)
+ imp = kzalloc(sizeof(*imp), GFP_NOFS);
+ if (!imp)
return NULL;
INIT_LIST_HEAD(&imp->imp_pinger_chain);
@@ -1071,7 +975,7 @@ void __class_export_add_lock_ref(struct obd_export *exp, struct ldlm_lock *lock)
LCONSOLE_WARN("setting export %p for lock %p which already has export %p\n",
exp, lock, lock->l_exp_refs_target);
}
- if ((lock->l_exp_refs_nr ++) == 0) {
+ if ((lock->l_exp_refs_nr++) == 0) {
list_add(&lock->l_exp_refs_link, &exp->exp_locks_list);
lock->l_exp_refs_target = exp;
}
@@ -1108,6 +1012,7 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd,
struct obd_uuid *cluuid)
{
struct obd_export *export;
+
LASSERT(conn != NULL);
LASSERT(obd != NULL);
LASSERT(cluuid != NULL);
@@ -1125,51 +1030,6 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd,
}
EXPORT_SYMBOL(class_connect);
-/* if export is involved in recovery then clean up related things */
-static void class_export_recovery_cleanup(struct obd_export *exp)
-{
- struct obd_device *obd = exp->exp_obd;
-
- spin_lock(&obd->obd_recovery_task_lock);
- if (exp->exp_delayed)
- obd->obd_delayed_clients--;
- if (obd->obd_recovering) {
- if (exp->exp_in_recovery) {
- spin_lock(&exp->exp_lock);
- exp->exp_in_recovery = 0;
- spin_unlock(&exp->exp_lock);
- LASSERT_ATOMIC_POS(&obd->obd_connected_clients);
- atomic_dec(&obd->obd_connected_clients);
- }
-
- /* if called during recovery then should update
- * obd_stale_clients counter,
- * lightweight exports are not counted */
- if (exp->exp_failed &&
- (exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) == 0)
- exp->exp_obd->obd_stale_clients++;
- }
- spin_unlock(&obd->obd_recovery_task_lock);
-
- spin_lock(&exp->exp_lock);
- /** Cleanup req replay fields */
- if (exp->exp_req_replay_needed) {
- exp->exp_req_replay_needed = 0;
-
- LASSERT(atomic_read(&obd->obd_req_replay_clients));
- atomic_dec(&obd->obd_req_replay_clients);
- }
-
- /** Cleanup lock replay data */
- if (exp->exp_lock_replay_needed) {
- exp->exp_lock_replay_needed = 0;
-
- LASSERT(atomic_read(&obd->obd_lock_replay_clients));
- atomic_dec(&obd->obd_lock_replay_clients);
- }
- spin_unlock(&exp->exp_lock);
-}
-
/* This function removes 1-3 references from the export:
* 1 - for export pointer passed
* and if disconnect really need
@@ -1180,7 +1040,7 @@ int class_disconnect(struct obd_export *export)
{
int already_disconnected;
- if (export == NULL) {
+ if (!export) {
CWARN("attempting to free NULL export %p\n", export);
return -EINVAL;
}
@@ -1193,20 +1053,12 @@ int class_disconnect(struct obd_export *export)
/* class_cleanup(), abort_recovery(), and class_fail_export()
* all end up in here, and if any of them race we shouldn't
* call extra class_export_puts(). */
- if (already_disconnected) {
- LASSERT(hlist_unhashed(&export->exp_nid_hash));
+ if (already_disconnected)
goto no_disconn;
- }
CDEBUG(D_IOCTL, "disconnect: cookie %#llx\n",
export->exp_handle.h_cookie);
- if (!hlist_unhashed(&export->exp_nid_hash))
- cfs_hash_del(export->exp_obd->obd_nid_hash,
- &export->exp_connection->c_peer.nid,
- &export->exp_nid_hash);
-
- class_export_recovery_cleanup(export);
class_unlink_export(export);
no_disconn:
class_export_put(export);
@@ -1214,135 +1066,6 @@ no_disconn:
}
EXPORT_SYMBOL(class_disconnect);
-/* Return non-zero for a fully connected export */
-int class_connected_export(struct obd_export *exp)
-{
- if (exp) {
- int connected;
- spin_lock(&exp->exp_lock);
- connected = exp->exp_conn_cnt > 0;
- spin_unlock(&exp->exp_lock);
- return connected;
- }
- return 0;
-}
-EXPORT_SYMBOL(class_connected_export);
-
-static void class_disconnect_export_list(struct list_head *list,
- enum obd_option flags)
-{
- int rc;
- struct obd_export *exp;
-
- /* It's possible that an export may disconnect itself, but
- * nothing else will be added to this list. */
- while (!list_empty(list)) {
- exp = list_entry(list->next, struct obd_export,
- exp_obd_chain);
- /* need for safe call CDEBUG after obd_disconnect */
- class_export_get(exp);
-
- spin_lock(&exp->exp_lock);
- exp->exp_flags = flags;
- spin_unlock(&exp->exp_lock);
-
- if (obd_uuid_equals(&exp->exp_client_uuid,
- &exp->exp_obd->obd_uuid)) {
- CDEBUG(D_HA,
- "exp %p export uuid == obd uuid, don't discon\n",
- exp);
- /* Need to delete this now so we don't end up pointing
- * to work_list later when this export is cleaned up. */
- list_del_init(&exp->exp_obd_chain);
- class_export_put(exp);
- continue;
- }
-
- class_export_get(exp);
- CDEBUG(D_HA, "%s: disconnecting export at %s (%p), last request at " CFS_TIME_T "\n",
- exp->exp_obd->obd_name, obd_export_nid2str(exp),
- exp, exp->exp_last_request_time);
- /* release one export reference anyway */
- rc = obd_disconnect(exp);
-
- CDEBUG(D_HA, "disconnected export at %s (%p): rc %d\n",
- obd_export_nid2str(exp), exp, rc);
- class_export_put(exp);
- }
-}
-
-void class_disconnect_exports(struct obd_device *obd)
-{
- struct list_head work_list;
-
- /* Move all of the exports from obd_exports to a work list, en masse. */
- INIT_LIST_HEAD(&work_list);
- spin_lock(&obd->obd_dev_lock);
- list_splice_init(&obd->obd_exports, &work_list);
- list_splice_init(&obd->obd_delayed_exports, &work_list);
- spin_unlock(&obd->obd_dev_lock);
-
- if (!list_empty(&work_list)) {
- CDEBUG(D_HA, "OBD device %d (%p) has exports, disconnecting them\n",
- obd->obd_minor, obd);
- class_disconnect_export_list(&work_list,
- exp_flags_from_obd(obd));
- } else
- CDEBUG(D_HA, "OBD device %d (%p) has no exports\n",
- obd->obd_minor, obd);
-}
-EXPORT_SYMBOL(class_disconnect_exports);
-
-/* Remove exports that have not completed recovery.
- */
-void class_disconnect_stale_exports(struct obd_device *obd,
- int (*test_export)(struct obd_export *))
-{
- struct list_head work_list;
- struct obd_export *exp, *n;
- int evicted = 0;
-
- INIT_LIST_HEAD(&work_list);
- spin_lock(&obd->obd_dev_lock);
- list_for_each_entry_safe(exp, n, &obd->obd_exports,
- exp_obd_chain) {
- /* don't count self-export as client */
- if (obd_uuid_equals(&exp->exp_client_uuid,
- &exp->exp_obd->obd_uuid))
- continue;
-
- /* don't evict clients which have no slot in last_rcvd
- * (e.g. lightweight connection) */
- if (exp->exp_target_data.ted_lr_idx == -1)
- continue;
-
- spin_lock(&exp->exp_lock);
- if (exp->exp_failed || test_export(exp)) {
- spin_unlock(&exp->exp_lock);
- continue;
- }
- exp->exp_failed = 1;
- spin_unlock(&exp->exp_lock);
-
- list_move(&exp->exp_obd_chain, &work_list);
- evicted++;
- CDEBUG(D_HA, "%s: disconnect stale client %s@%s\n",
- obd->obd_name, exp->exp_client_uuid.uuid,
- exp->exp_connection == NULL ? "<unknown>" :
- libcfs_nid2str(exp->exp_connection->c_peer.nid));
- print_export_data(exp, "EVICTING", 0);
- }
- spin_unlock(&obd->obd_dev_lock);
-
- if (evicted)
- LCONSOLE_WARN("%s: disconnecting %d stale clients\n",
- obd->obd_name, evicted);
-
- class_disconnect_export_list(&work_list, exp_flags_from_obd(obd) |
- OBD_OPT_ABORT_RECOV);
-}
-EXPORT_SYMBOL(class_disconnect_stale_exports);
-
void class_fail_export(struct obd_export *exp)
{
int rc, already_failed;
@@ -1381,189 +1104,18 @@ void class_fail_export(struct obd_export *exp)
}
EXPORT_SYMBOL(class_fail_export);
-char *obd_export_nid2str(struct obd_export *exp)
-{
- if (exp->exp_connection != NULL)
- return libcfs_nid2str(exp->exp_connection->c_peer.nid);
-
- return "(no nid)";
-}
-EXPORT_SYMBOL(obd_export_nid2str);
-
-int obd_export_evict_by_nid(struct obd_device *obd, const char *nid)
-{
- struct cfs_hash *nid_hash;
- struct obd_export *doomed_exp = NULL;
- int exports_evicted = 0;
-
- lnet_nid_t nid_key = libcfs_str2nid((char *)nid);
-
- spin_lock(&obd->obd_dev_lock);
- /* umount has run already, so evict thread should leave
- * its task to umount thread now */
- if (obd->obd_stopping) {
- spin_unlock(&obd->obd_dev_lock);
- return exports_evicted;
- }
- nid_hash = obd->obd_nid_hash;
- cfs_hash_getref(nid_hash);
- spin_unlock(&obd->obd_dev_lock);
-
- do {
- doomed_exp = cfs_hash_lookup(nid_hash, &nid_key);
- if (doomed_exp == NULL)
- break;
-
- LASSERTF(doomed_exp->exp_connection->c_peer.nid == nid_key,
- "nid %s found, wanted nid %s, requested nid %s\n",
- obd_export_nid2str(doomed_exp),
- libcfs_nid2str(nid_key), nid);
- LASSERTF(doomed_exp != obd->obd_self_export,
- "self-export is hashed by NID?\n");
- exports_evicted++;
- LCONSOLE_WARN("%s: evicting %s (at %s) by administrative request\n",
- obd->obd_name,
- obd_uuid2str(&doomed_exp->exp_client_uuid),
- obd_export_nid2str(doomed_exp));
- class_fail_export(doomed_exp);
- class_export_put(doomed_exp);
- } while (1);
-
- cfs_hash_putref(nid_hash);
-
- if (!exports_evicted)
- CDEBUG(D_HA,
- "%s: can't disconnect NID '%s': no exports found\n",
- obd->obd_name, nid);
- return exports_evicted;
-}
-EXPORT_SYMBOL(obd_export_evict_by_nid);
-
-int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid)
-{
- struct cfs_hash *uuid_hash;
- struct obd_export *doomed_exp = NULL;
- struct obd_uuid doomed_uuid;
- int exports_evicted = 0;
-
- spin_lock(&obd->obd_dev_lock);
- if (obd->obd_stopping) {
- spin_unlock(&obd->obd_dev_lock);
- return exports_evicted;
- }
- uuid_hash = obd->obd_uuid_hash;
- cfs_hash_getref(uuid_hash);
- spin_unlock(&obd->obd_dev_lock);
-
- obd_str2uuid(&doomed_uuid, uuid);
- if (obd_uuid_equals(&doomed_uuid, &obd->obd_uuid)) {
- CERROR("%s: can't evict myself\n", obd->obd_name);
- cfs_hash_putref(uuid_hash);
- return exports_evicted;
- }
-
- doomed_exp = cfs_hash_lookup(uuid_hash, &doomed_uuid);
-
- if (doomed_exp == NULL) {
- CERROR("%s: can't disconnect %s: no exports found\n",
- obd->obd_name, uuid);
- } else {
- CWARN("%s: evicting %s at administrative request\n",
- obd->obd_name, doomed_exp->exp_client_uuid.uuid);
- class_fail_export(doomed_exp);
- class_export_put(doomed_exp);
- exports_evicted++;
- }
- cfs_hash_putref(uuid_hash);
-
- return exports_evicted;
-}
-EXPORT_SYMBOL(obd_export_evict_by_uuid);
-
#if LUSTRE_TRACKS_LOCK_EXP_REFS
-void (*class_export_dump_hook)(struct obd_export*) = NULL;
+void (*class_export_dump_hook)(struct obd_export *) = NULL;
EXPORT_SYMBOL(class_export_dump_hook);
#endif
-static void print_export_data(struct obd_export *exp, const char *status,
- int locks)
-{
- struct ptlrpc_reply_state *rs;
- struct ptlrpc_reply_state *first_reply = NULL;
- int nreplies = 0;
-
- spin_lock(&exp->exp_lock);
- list_for_each_entry(rs, &exp->exp_outstanding_replies,
- rs_exp_list) {
- if (nreplies == 0)
- first_reply = rs;
- nreplies++;
- }
- spin_unlock(&exp->exp_lock);
-
- CDEBUG(D_HA, "%s: %s %p %s %s %d (%d %d %d) %d %d %d %d: %p %s %llu\n",
- exp->exp_obd->obd_name, status, exp, exp->exp_client_uuid.uuid,
- obd_export_nid2str(exp), atomic_read(&exp->exp_refcount),
- atomic_read(&exp->exp_rpc_count),
- atomic_read(&exp->exp_cb_count),
- atomic_read(&exp->exp_locks_count),
- exp->exp_disconnected, exp->exp_delayed, exp->exp_failed,
- nreplies, first_reply, nreplies > 3 ? "..." : "",
- exp->exp_last_committed);
-#if LUSTRE_TRACKS_LOCK_EXP_REFS
- if (locks && class_export_dump_hook != NULL)
- class_export_dump_hook(exp);
-#endif
-}
-
-void dump_exports(struct obd_device *obd, int locks)
-{
- struct obd_export *exp;
-
- spin_lock(&obd->obd_dev_lock);
- list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain)
- print_export_data(exp, "ACTIVE", locks);
- list_for_each_entry(exp, &obd->obd_unlinked_exports, exp_obd_chain)
- print_export_data(exp, "UNLINKED", locks);
- list_for_each_entry(exp, &obd->obd_delayed_exports, exp_obd_chain)
- print_export_data(exp, "DELAYED", locks);
- spin_unlock(&obd->obd_dev_lock);
- spin_lock(&obd_zombie_impexp_lock);
- list_for_each_entry(exp, &obd_zombie_exports, exp_obd_chain)
- print_export_data(exp, "ZOMBIE", locks);
- spin_unlock(&obd_zombie_impexp_lock);
-}
-EXPORT_SYMBOL(dump_exports);
-
-void obd_exports_barrier(struct obd_device *obd)
-{
- int waited = 2;
- LASSERT(list_empty(&obd->obd_exports));
- spin_lock(&obd->obd_dev_lock);
- while (!list_empty(&obd->obd_unlinked_exports)) {
- spin_unlock(&obd->obd_dev_lock);
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(cfs_time_seconds(waited));
- if (waited > 5 && IS_PO2(waited)) {
- LCONSOLE_WARN("%s is waiting for obd_unlinked_exports more than %d seconds. The obd refcount = %d. Is it stuck?\n",
- obd->obd_name, waited,
- atomic_read(&obd->obd_refcount));
- dump_exports(obd, 1);
- }
- waited *= 2;
- spin_lock(&obd->obd_dev_lock);
- }
- spin_unlock(&obd->obd_dev_lock);
-}
-EXPORT_SYMBOL(obd_exports_barrier);
-
/* Total amount of zombies to be destroyed */
static int zombies_count;
/**
* kill zombie imports and exports
*/
-void obd_zombie_impexp_cull(void)
+static void obd_zombie_impexp_cull(void)
{
struct obd_import *import;
struct obd_export *export;
@@ -1635,7 +1187,8 @@ static int obd_zombie_impexp_check(void *arg)
/**
* Add export to the obd_zombie thread and notify it.
*/
-static void obd_zombie_export_add(struct obd_export *exp) {
+static void obd_zombie_export_add(struct obd_export *exp)
+{
spin_lock(&exp->exp_obd->obd_dev_lock);
LASSERT(!list_empty(&exp->exp_obd_chain));
list_del_init(&exp->exp_obd_chain);
@@ -1651,9 +1204,9 @@ static void obd_zombie_export_add(struct obd_export *exp) {
/**
* Add import to the obd_zombie thread and notify it.
*/
-static void obd_zombie_import_add(struct obd_import *imp) {
- LASSERT(imp->imp_sec == NULL);
- LASSERT(imp->imp_rq_pool == NULL);
+static void obd_zombie_import_add(struct obd_import *imp)
+{
+ LASSERT(!imp->imp_sec);
spin_lock(&obd_zombie_impexp_lock);
LASSERT(list_empty(&imp->imp_zombie_chain));
zombies_count++;
@@ -1704,7 +1257,6 @@ void obd_zombie_barrier(void)
}
EXPORT_SYMBOL(obd_zombie_barrier);
-
/**
* destroy zombie export/import thread.
*/
@@ -1734,7 +1286,6 @@ static int obd_zombie_impexp_thread(void *unused)
return 0;
}
-
/**
* start destroy zombie import/export thread
*/
@@ -1757,6 +1308,7 @@ int obd_zombie_impexp_init(void)
wait_for_completion(&obd_zombie_start);
return 0;
}
+
/**
* stop destroy zombie import/export thread
*/
@@ -1766,68 +1318,3 @@ void obd_zombie_impexp_stop(void)
obd_zombie_impexp_notify();
wait_for_completion(&obd_zombie_stop);
}
-
-/***** Kernel-userspace comm helpers *******/
-
-/* Get length of entire message, including header */
-int kuc_len(int payload_len)
-{
- return sizeof(struct kuc_hdr) + payload_len;
-}
-EXPORT_SYMBOL(kuc_len);
-
-/* Get a pointer to kuc header, given a ptr to the payload
- * @param p Pointer to payload area
- * @returns Pointer to kuc header
- */
-struct kuc_hdr *kuc_ptr(void *p)
-{
- struct kuc_hdr *lh = ((struct kuc_hdr *)p) - 1;
- LASSERT(lh->kuc_magic == KUC_MAGIC);
- return lh;
-}
-EXPORT_SYMBOL(kuc_ptr);
-
-/* Test if payload is part of kuc message
- * @param p Pointer to payload area
- * @returns boolean
- */
-int kuc_ispayload(void *p)
-{
- struct kuc_hdr *kh = ((struct kuc_hdr *)p) - 1;
-
- if (kh->kuc_magic == KUC_MAGIC)
- return 1;
- else
- return 0;
-}
-EXPORT_SYMBOL(kuc_ispayload);
-
-/* Alloc space for a message, and fill in header
- * @return Pointer to payload area
- */
-void *kuc_alloc(int payload_len, int transport, int type)
-{
- struct kuc_hdr *lh;
- int len = kuc_len(payload_len);
-
- OBD_ALLOC(lh, len);
- if (lh == NULL)
- return ERR_PTR(-ENOMEM);
-
- lh->kuc_magic = KUC_MAGIC;
- lh->kuc_transport = transport;
- lh->kuc_msgtype = type;
- lh->kuc_msglen = len;
-
- return (void *)(lh + 1);
-}
-EXPORT_SYMBOL(kuc_alloc);
-
-/* Takes pointer to payload area */
-inline void kuc_free(void *p, int payload_len)
-{
- struct kuc_hdr *lh = kuc_ptr(p);
- OBD_FREE(lh, kuc_len(payload_len));
-}
-EXPORT_SYMBOL(kuc_free);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 06944b863..a055cbb4f 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -53,7 +53,6 @@
#include <linux/fcntl.h>
#include <linux/delay.h>
#include <linux/skbuff.h>
-#include <linux/proc_fs.h>
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/list.h>
@@ -64,6 +63,7 @@
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/seq_file.h>
+#include <linux/kobject.h>
#include "../../../include/linux/libcfs/libcfs.h"
#include "../../../include/linux/lnet/lnetctl.h"
@@ -73,8 +73,6 @@
#include "../../include/lustre_ver.h"
#include "../../include/lustre/lustre_build_version.h"
-int proc_version;
-
/* buffer MUST be at least the size of obd_ioctl_hdr */
int obd_ioctl_getdata(char **buf, int *len, void *arg)
{
@@ -107,7 +105,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg)
* system, the high lock contention will hurt performance badly,
* obdfilter-survey is an example, which relies on ioctl. So we'd
* better avoid vmalloc on ioctl path. LU-66 */
- OBD_ALLOC_LARGE(*buf, hdr.ioc_len);
+ *buf = libcfs_kvzalloc(hdr.ioc_len, GFP_NOFS);
if (*buf == NULL) {
CERROR("Cannot allocate control buffer of len %d\n",
hdr.ioc_len);
@@ -153,7 +151,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg)
return 0;
free_buf:
- OBD_FREE_LARGE(*buf, hdr.ioc_len);
+ kvfree(*buf);
return err;
}
EXPORT_SYMBOL(obd_ioctl_getdata);
@@ -215,30 +213,27 @@ struct miscdevice obd_psdev = {
.fops = &obd_psdev_fops,
};
-
-#if defined (CONFIG_PROC_FS)
-static int obd_proc_version_seq_show(struct seq_file *m, void *v)
+static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n",
- LUSTRE_VERSION_STRING, "patchless_client", BUILD_VERSION);
- return 0;
+ return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING);
}
-LPROC_SEQ_FOPS_RO(obd_proc_version);
-int obd_proc_pinger_seq_show(struct seq_file *m, void *v)
+static ssize_t pinger_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "%s\n", "on");
- return 0;
+ return sprintf(buf, "%s\n", "on");
}
-LPROC_SEQ_FOPS_RO(obd_proc_pinger);
-static int obd_proc_health_seq_show(struct seq_file *m, void *v)
+static ssize_t health_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
bool healthy = true;
int i;
+ size_t len = 0;
if (libcfs_catastrophe)
- seq_printf(m, "LBUG\n");
+ return sprintf(buf, "LBUG\n");
read_lock(&obd_dev_lock);
for (i = 0; i < class_devno_max(); i++) {
@@ -256,8 +251,6 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
read_unlock(&obd_dev_lock);
if (obd_health_check(NULL, obd)) {
- seq_printf(m, "device %s reported unhealthy\n",
- obd->obd_name);
healthy = false;
}
class_decref(obd, __func__, current);
@@ -266,32 +259,29 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
read_unlock(&obd_dev_lock);
if (healthy)
- seq_puts(m, "healthy\n");
+ len = sprintf(buf, "healthy\n");
else
- seq_puts(m, "NOT HEALTHY\n");
+ len = sprintf(buf, "NOT HEALTHY\n");
- return 0;
+ return len;
}
-LPROC_SEQ_FOPS_RO(obd_proc_health);
-static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
+static ssize_t jobid_var_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "%s\n", obd_jobid_var);
- return 0;
+ return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_var);
}
-static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
return -EINVAL;
memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1);
- /* This might leave the var invalid on error, which is probably fine.*/
- if (copy_from_user(obd_jobid_var, buffer, count))
- return -EFAULT;
+ memcpy(obd_jobid_var, buffer, count);
/* Trim the trailing '\n' if any */
if (obd_jobid_var[count - 1] == '\n')
@@ -299,23 +289,21 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(obd_proc_jobid_var);
-static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v)
+static ssize_t jobid_name_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "%s\n", obd_jobid_var);
- return 0;
+ return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_node);
}
-static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
if (!count || count > JOBSTATS_JOBID_SIZE)
return -EINVAL;
- if (copy_from_user(obd_jobid_node, buffer, count))
- return -EFAULT;
+ memcpy(obd_jobid_node, buffer, count);
obd_jobid_node[count] = 0;
@@ -325,20 +313,24 @@ static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(obd_proc_jobid_name);
-
-/* Root for /proc/fs/lustre */
-struct proc_dir_entry *proc_lustre_root = NULL;
-EXPORT_SYMBOL(proc_lustre_root);
-
-struct lprocfs_vars lprocfs_base[] = {
- { "version", &obd_proc_version_fops },
- { "pinger", &obd_proc_pinger_fops },
- { "health_check", &obd_proc_health_fops },
- { "jobid_var", &obd_proc_jobid_var_fops },
- { .name = "jobid_name",
- .fops = &obd_proc_jobid_name_fops},
- { NULL }
+
+/* Root for /sys/kernel/debug/lustre */
+struct dentry *debugfs_lustre_root;
+EXPORT_SYMBOL_GPL(debugfs_lustre_root);
+
+LUSTRE_RO_ATTR(version);
+LUSTRE_RO_ATTR(pinger);
+LUSTRE_RO_ATTR(health);
+LUSTRE_RW_ATTR(jobid_var);
+LUSTRE_RW_ATTR(jobid_name);
+
+static struct attribute *lustre_attrs[] = {
+ &lustre_attr_version.attr,
+ &lustre_attr_pinger.attr,
+ &lustre_attr_health.attr,
+ &lustre_attr_jobid_name.attr,
+ &lustre_attr_jobid_var.attr,
+ NULL,
};
static void *obd_device_list_seq_start(struct seq_file *p, loff_t *pos)
@@ -390,7 +382,7 @@ static int obd_device_list_seq_show(struct seq_file *p, void *v)
return 0;
}
-struct seq_operations obd_device_list_sops = {
+static const struct seq_operations obd_device_list_sops = {
.start = obd_device_list_seq_start,
.stop = obd_device_list_seq_stop,
.next = obd_device_list_seq_next,
@@ -406,12 +398,12 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
return 0;
}
-struct file_operations obd_device_list_fops = {
+static const struct file_operations obd_device_list_fops = {
.owner = THIS_MODULE,
.open = obd_device_list_open,
.read = seq_read,
@@ -419,31 +411,57 @@ struct file_operations obd_device_list_fops = {
.release = seq_release,
};
+struct kobject *lustre_kobj;
+EXPORT_SYMBOL_GPL(lustre_kobj);
+
+static struct attribute_group lustre_attr_group = {
+ .attrs = lustre_attrs,
+};
+
int class_procfs_init(void)
{
- int rc = 0;
+ int rc = -ENOMEM;
+ struct dentry *file;
- proc_lustre_root = lprocfs_register("fs/lustre", NULL,
- lprocfs_base, NULL);
- if (IS_ERR(proc_lustre_root)) {
- rc = PTR_ERR(proc_lustre_root);
- proc_lustre_root = NULL;
+ lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
+ if (lustre_kobj == NULL)
+ goto out;
+
+ /* Create the files associated with this kobject */
+ rc = sysfs_create_group(lustre_kobj, &lustre_attr_group);
+ if (rc) {
+ kobject_put(lustre_kobj);
goto out;
}
- rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444,
- &obd_device_list_fops, NULL);
+ debugfs_lustre_root = debugfs_create_dir("lustre", NULL);
+ if (IS_ERR_OR_NULL(debugfs_lustre_root)) {
+ rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root)
+ : -ENOMEM;
+ debugfs_lustre_root = NULL;
+ kobject_put(lustre_kobj);
+ goto out;
+ }
+
+ file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
+ &obd_device_list_fops);
+ if (IS_ERR_OR_NULL(file)) {
+ rc = file ? PTR_ERR(file) : -ENOMEM;
+ kobject_put(lustre_kobj);
+ goto out;
+ }
out:
- if (rc)
- CERROR("error adding /proc/fs/lustre/devices file\n");
- return 0;
+ return rc;
}
int class_procfs_clean(void)
{
- if (proc_lustre_root) {
- lprocfs_remove(&proc_lustre_root);
- }
+ if (debugfs_lustre_root != NULL)
+ debugfs_remove_recursive(debugfs_lustre_root);
+
+ debugfs_lustre_root = NULL;
+
+ kobject_put(lustre_kobj);
+
return 0;
}
-#endif /* CONFIG_PROC_FS */
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c b/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c
index 62ed706b1..9496c09b2 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c
@@ -49,102 +49,6 @@
#include <linux/fs.h>
#include <linux/pagemap.h> /* for PAGE_CACHE_SIZE */
-/*FIXME: Just copy from obdo_from_inode*/
-void obdo_from_la(struct obdo *dst, struct lu_attr *la, __u64 valid)
-{
- u32 newvalid = 0;
-
- if (valid & LA_ATIME) {
- dst->o_atime = la->la_atime;
- newvalid |= OBD_MD_FLATIME;
- }
- if (valid & LA_MTIME) {
- dst->o_mtime = la->la_mtime;
- newvalid |= OBD_MD_FLMTIME;
- }
- if (valid & LA_CTIME) {
- dst->o_ctime = la->la_ctime;
- newvalid |= OBD_MD_FLCTIME;
- }
- if (valid & LA_SIZE) {
- dst->o_size = la->la_size;
- newvalid |= OBD_MD_FLSIZE;
- }
- if (valid & LA_BLOCKS) { /* allocation of space (x512 bytes) */
- dst->o_blocks = la->la_blocks;
- newvalid |= OBD_MD_FLBLOCKS;
- }
- if (valid & LA_TYPE) {
- dst->o_mode = (dst->o_mode & S_IALLUGO) |
- (la->la_mode & S_IFMT);
- newvalid |= OBD_MD_FLTYPE;
- }
- if (valid & LA_MODE) {
- dst->o_mode = (dst->o_mode & S_IFMT) |
- (la->la_mode & S_IALLUGO);
- newvalid |= OBD_MD_FLMODE;
- }
- if (valid & LA_UID) {
- dst->o_uid = la->la_uid;
- newvalid |= OBD_MD_FLUID;
- }
- if (valid & LA_GID) {
- dst->o_gid = la->la_gid;
- newvalid |= OBD_MD_FLGID;
- }
- dst->o_valid |= newvalid;
-}
-EXPORT_SYMBOL(obdo_from_la);
-
-/*FIXME: Just copy from obdo_from_inode*/
-void la_from_obdo(struct lu_attr *dst, struct obdo *obdo, u32 valid)
-{
- __u64 newvalid = 0;
-
- valid &= obdo->o_valid;
-
- if (valid & OBD_MD_FLATIME) {
- dst->la_atime = obdo->o_atime;
- newvalid |= LA_ATIME;
- }
- if (valid & OBD_MD_FLMTIME) {
- dst->la_mtime = obdo->o_mtime;
- newvalid |= LA_MTIME;
- }
- if (valid & OBD_MD_FLCTIME) {
- dst->la_ctime = obdo->o_ctime;
- newvalid |= LA_CTIME;
- }
- if (valid & OBD_MD_FLSIZE) {
- dst->la_size = obdo->o_size;
- newvalid |= LA_SIZE;
- }
- if (valid & OBD_MD_FLBLOCKS) {
- dst->la_blocks = obdo->o_blocks;
- newvalid |= LA_BLOCKS;
- }
- if (valid & OBD_MD_FLTYPE) {
- dst->la_mode = (dst->la_mode & S_IALLUGO) |
- (obdo->o_mode & S_IFMT);
- newvalid |= LA_TYPE;
- }
- if (valid & OBD_MD_FLMODE) {
- dst->la_mode = (dst->la_mode & S_IFMT) |
- (obdo->o_mode & S_IALLUGO);
- newvalid |= LA_MODE;
- }
- if (valid & OBD_MD_FLUID) {
- dst->la_uid = obdo->o_uid;
- newvalid |= LA_UID;
- }
- if (valid & OBD_MD_FLGID) {
- dst->la_gid = obdo->o_gid;
- newvalid |= LA_GID;
- }
- dst->la_valid = newvalid;
-}
-EXPORT_SYMBOL(la_from_obdo);
-
void obdo_refresh_inode(struct inode *dst, struct obdo *src, u32 valid)
{
valid &= src->o_valid;
@@ -179,44 +83,3 @@ void obdo_refresh_inode(struct inode *dst, struct obdo *src, u32 valid)
dst->i_blocks = src->o_blocks;
}
EXPORT_SYMBOL(obdo_refresh_inode);
-
-void obdo_to_inode(struct inode *dst, struct obdo *src, u32 valid)
-{
- valid &= src->o_valid;
-
- LASSERTF(!(valid & (OBD_MD_FLTYPE | OBD_MD_FLGENER | OBD_MD_FLFID |
- OBD_MD_FLID | OBD_MD_FLGROUP)),
- "object "DOSTID", valid %x\n", POSTID(&src->o_oi), valid);
-
- if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
- CDEBUG(D_INODE,
- "valid %#llx, cur time %lu/%lu, new %llu/%llu\n",
- src->o_valid, LTIME_S(dst->i_mtime),
- LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime);
-
- if (valid & OBD_MD_FLATIME)
- LTIME_S(dst->i_atime) = src->o_atime;
- if (valid & OBD_MD_FLMTIME)
- LTIME_S(dst->i_mtime) = src->o_mtime;
- if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime))
- LTIME_S(dst->i_ctime) = src->o_ctime;
- if (valid & OBD_MD_FLSIZE)
- i_size_write(dst, src->o_size);
- if (valid & OBD_MD_FLBLOCKS) { /* allocation of space */
- dst->i_blocks = src->o_blocks;
- if (dst->i_blocks < src->o_blocks) /* overflow */
- dst->i_blocks = -1;
-
- }
- if (valid & OBD_MD_FLBLKSZ)
- dst->i_blkbits = ffs(src->o_blksize)-1;
- if (valid & OBD_MD_FLMODE)
- dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
- if (valid & OBD_MD_FLUID)
- dst->i_uid = make_kuid(&init_user_ns, src->o_uid);
- if (valid & OBD_MD_FLGID)
- dst->i_gid = make_kgid(&init_user_ns, src->o_gid);
- if (valid & OBD_MD_FLFLAGS)
- dst->i_flags = src->o_flags;
-}
-EXPORT_SYMBOL(obdo_to_inode);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index 4b62d2576..518288df4 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -38,7 +38,6 @@
#include <linux/sysctl.h>
#include <linux/sched.h>
#include <linux/mm.h>
-#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/ctype.h>
@@ -51,355 +50,115 @@
#include "../../include/obd_support.h"
#include "../../include/lprocfs_status.h"
-#ifdef CONFIG_SYSCTL
-static struct ctl_table_header *obd_table_header;
-#endif
-
-
-#define OBD_SYSCTL 300
-
-enum {
- OBD_TIMEOUT = 3, /* RPC timeout before recovery/intr */
- OBD_DUMP_ON_TIMEOUT, /* dump kernel debug log upon eviction */
- OBD_MEMUSED, /* bytes currently OBD_ALLOCated */
- OBD_PAGESUSED, /* pages currently OBD_PAGE_ALLOCated */
- OBD_MAXMEMUSED, /* maximum bytes OBD_ALLOCated concurrently */
- OBD_MAXPAGESUSED, /* maximum pages OBD_PAGE_ALLOCated concurrently */
- OBD_SYNCFILTER, /* XXX temporary, as we play with sync osts.. */
- OBD_LDLM_TIMEOUT, /* LDLM timeout for ASTs before client eviction */
- OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */
- OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */
- OBD_ALLOC_FAIL_RATE, /* memory allocation random failure rate */
- OBD_MAX_DIRTY_PAGES, /* maximum dirty pages */
- OBD_AT_MIN, /* Adaptive timeouts params */
- OBD_AT_MAX,
- OBD_AT_EXTRA,
- OBD_AT_EARLY_MARGIN,
- OBD_AT_HISTORY,
+struct static_lustre_uintvalue_attr {
+ struct {
+ struct attribute attr;
+ ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len);
+ } u;
+ int *value;
};
-
-#ifdef CONFIG_SYSCTL
-static int proc_set_timeout(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
+static ssize_t static_uintvalue_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- int rc;
+ struct static_lustre_uintvalue_attr *lattr = (void *)attr;
- rc = proc_dointvec(table, write, buffer, lenp, ppos);
- if (ldlm_timeout >= obd_timeout)
- ldlm_timeout = max(obd_timeout / 3, 1U);
- return rc;
+ return sprintf(buf, "%d\n", *lattr->value);
}
-static int proc_memory_alloc(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
+static ssize_t static_uintvalue_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- char buf[22];
- int len;
-
- if (!*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
- }
- if (write)
- return -EINVAL;
-
- len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_sum());
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
- *ppos += *lenp;
- return 0;
-}
+ struct static_lustre_uintvalue_attr *lattr = (void *)attr;
+ int rc;
+ unsigned int val;
-static int proc_pages_alloc(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- char buf[22];
- int len;
+ rc = kstrtouint(buffer, 10, &val);
+ if (rc)
+ return rc;
- if (!*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
- }
- if (write)
- return -EINVAL;
+ *lattr->value = val;
- len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_sum());
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
- *ppos += *lenp;
- return 0;
+ return count;
}
-static int proc_mem_max(struct ctl_table *table, int write, void __user *buffer,
- size_t *lenp, loff_t *ppos)
-{
- char buf[22];
- int len;
+#define LUSTRE_STATIC_UINT_ATTR(name, value) \
+static struct static_lustre_uintvalue_attr lustre_sattr_##name = \
+ {__ATTR(name, 0644, \
+ static_uintvalue_show, \
+ static_uintvalue_store),\
+ value }
- if (!*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
- }
- if (write)
- return -EINVAL;
+LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout);
- len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_max());
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
- *ppos += *lenp;
- return 0;
+static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%ul\n",
+ obd_max_dirty_pages / (1 << (20 - PAGE_CACHE_SHIFT)));
}
-static int proc_pages_max(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
+static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- char buf[22];
- int len;
+ int rc;
+ unsigned long val;
- if (!*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
- }
- if (write)
- return -EINVAL;
+ rc = kstrtoul(buffer, 10, &val);
+ if (rc)
+ return rc;
- len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_max());
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
- *ppos += *lenp;
- return 0;
-}
+ val *= 1 << (20 - PAGE_CACHE_SHIFT); /* convert to pages */
-static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- int rc = 0;
-
- if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
+ if (val > ((totalram_pages / 10) * 9)) {
+ /* Somebody wants to assign too much memory to dirty pages */
+ return -EINVAL;
}
- if (write) {
- rc = lprocfs_write_frac_helper(buffer, *lenp,
- (unsigned int *)table->data,
- 1 << (20 - PAGE_CACHE_SHIFT));
- /* Don't allow them to let dirty pages exceed 90% of system
- * memory and set a hard minimum of 4MB. */
- if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) {
- CERROR("Refusing to set max dirty pages to %u, which is more than 90%% of available RAM; setting to %lu\n",
- obd_max_dirty_pages,
- ((totalram_pages / 10) * 9));
- obd_max_dirty_pages = (totalram_pages / 10) * 9;
- } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) {
- obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
- }
- } else {
- char buf[21];
- int len;
- len = lprocfs_read_frac_helper(buf, sizeof(buf),
- *(unsigned int *)table->data,
- 1 << (20 - PAGE_CACHE_SHIFT));
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
+ if (val < 4 << (20 - PAGE_CACHE_SHIFT)) {
+ /* Less than 4 Mb for dirty cache is also bad */
+ return -EINVAL;
}
- *ppos += *lenp;
- return rc;
-}
-static int proc_alloc_fail_rate(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- int rc = 0;
-
- if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
- }
- if (write) {
- rc = lprocfs_write_frac_helper(buffer, *lenp,
- (unsigned int *)table->data,
- OBD_ALLOC_FAIL_MULT);
- } else {
- char buf[21];
- int len;
+ obd_max_dirty_pages = val;
- len = lprocfs_read_frac_helper(buf, 21,
- *(unsigned int *)table->data,
- OBD_ALLOC_FAIL_MULT);
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
- }
- *ppos += *lenp;
- return rc;
+ return count;
}
-
-static struct ctl_table obd_table[] = {
- {
- .procname = "timeout",
- .data = &obd_timeout,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_set_timeout
- },
- {
- .procname = "debug_peer_on_timeout",
- .data = &obd_debug_peer_on_timeout,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
- .procname = "dump_on_timeout",
- .data = &obd_dump_on_timeout,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
- .procname = "dump_on_eviction",
- .data = &obd_dump_on_eviction,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
- .procname = "memused",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_memory_alloc
- },
- {
- .procname = "pagesused",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_pages_alloc
- },
- {
- .procname = "memused_max",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_mem_max
- },
- {
- .procname = "pagesused_max",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_pages_max
- },
- {
- .procname = "ldlm_timeout",
- .data = &ldlm_timeout,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_set_timeout
- },
- {
- .procname = "alloc_fail_rate",
- .data = &obd_alloc_fail_rate,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_alloc_fail_rate
- },
- {
- .procname = "max_dirty_mb",
- .data = &obd_max_dirty_pages,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_max_dirty_pages_in_mb
- },
- {
- .procname = "at_min",
- .data = &at_min,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_max",
- .data = &at_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_extra",
- .data = &at_extra,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_early_margin",
- .data = &at_early_margin,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_history",
- .data = &at_history,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {}
+LUSTRE_RW_ATTR(max_dirty_mb);
+
+LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout);
+LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout);
+LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction);
+LUSTRE_STATIC_UINT_ATTR(at_min, &at_min);
+LUSTRE_STATIC_UINT_ATTR(at_max, &at_max);
+LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra);
+LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin);
+LUSTRE_STATIC_UINT_ATTR(at_history, &at_history);
+
+static struct attribute *lustre_attrs[] = {
+ &lustre_sattr_timeout.u.attr,
+ &lustre_attr_max_dirty_mb.attr,
+ &lustre_sattr_debug_peer_on_timeout.u.attr,
+ &lustre_sattr_dump_on_timeout.u.attr,
+ &lustre_sattr_dump_on_eviction.u.attr,
+ &lustre_sattr_at_min.u.attr,
+ &lustre_sattr_at_max.u.attr,
+ &lustre_sattr_at_extra.u.attr,
+ &lustre_sattr_at_early_margin.u.attr,
+ &lustre_sattr_at_history.u.attr,
+ NULL,
};
-static struct ctl_table parent_table[] = {
- {
- .procname = "lustre",
- .data = NULL,
- .maxlen = 0,
- .mode = 0555,
- .child = obd_table
- },
- {}
+static struct attribute_group lustre_attr_group = {
+ .attrs = lustre_attrs,
};
-#endif
-
-void obd_sysctl_init(void)
-{
-#ifdef CONFIG_SYSCTL
- if (!obd_table_header)
- obd_table_header = register_sysctl_table(parent_table);
-#endif
-}
-void obd_sysctl_clean(void)
+int obd_sysctl_init(void)
{
-#ifdef CONFIG_SYSCTL
- if (obd_table_header)
- unregister_sysctl_table(obd_table_header);
- obd_table_header = NULL;
-#endif
+ return sysfs_create_group(lustre_kobj, &lustre_attr_group);
}
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/llog.c b/kernel/drivers/staging/lustre/lustre/obdclass/llog.c
index 114be4a78..7cb55ef79 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -47,7 +47,6 @@
#define DEBUG_SUBSYSTEM S_LOG
-
#include "../include/obd_class.h"
#include "../include/lustre_log.h"
#include "llog_internal.h"
@@ -60,8 +59,8 @@ static struct llog_handle *llog_alloc_handle(void)
{
struct llog_handle *loghandle;
- OBD_ALLOC_PTR(loghandle);
- if (loghandle == NULL)
+ loghandle = kzalloc(sizeof(*loghandle), GFP_NOFS);
+ if (!loghandle)
return NULL;
init_rwsem(&loghandle->lgh_lock);
@@ -88,9 +87,9 @@ static void llog_free_handle(struct llog_handle *loghandle)
else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)
LASSERT(list_empty(&loghandle->u.chd.chd_head));
LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE);
- OBD_FREE(loghandle->lgh_hdr, LLOG_CHUNK_SIZE);
+ kfree(loghandle->lgh_hdr);
out:
- OBD_FREE_PTR(loghandle);
+ kfree(loghandle);
}
void llog_handle_get(struct llog_handle *loghandle)
@@ -105,66 +104,6 @@ void llog_handle_put(struct llog_handle *loghandle)
llog_free_handle(loghandle);
}
-/* returns negative on error; 0 if success; 1 if success & log destroyed */
-int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle,
- int index)
-{
- struct llog_log_hdr *llh = loghandle->lgh_hdr;
- int rc = 0;
-
- CDEBUG(D_RPCTRACE, "Canceling %d in log "DOSTID"\n",
- index, POSTID(&loghandle->lgh_id.lgl_oi));
-
- if (index == 0) {
- CERROR("Can't cancel index 0 which is header\n");
- return -EINVAL;
- }
-
- spin_lock(&loghandle->lgh_hdr_lock);
- if (!ext2_clear_bit(index, llh->llh_bitmap)) {
- spin_unlock(&loghandle->lgh_hdr_lock);
- CDEBUG(D_RPCTRACE, "Catalog index %u already clear?\n", index);
- return -ENOENT;
- }
-
- llh->llh_count--;
-
- if ((llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
- (llh->llh_count == 1) &&
- (loghandle->lgh_last_idx == (LLOG_BITMAP_BYTES * 8) - 1)) {
- spin_unlock(&loghandle->lgh_hdr_lock);
- rc = llog_destroy(env, loghandle);
- if (rc < 0) {
- CERROR("%s: can't destroy empty llog #"DOSTID
- "#%08x: rc = %d\n",
- loghandle->lgh_ctxt->loc_obd->obd_name,
- POSTID(&loghandle->lgh_id.lgl_oi),
- loghandle->lgh_id.lgl_ogen, rc);
- goto out_err;
- }
- return 1;
- }
- spin_unlock(&loghandle->lgh_hdr_lock);
-
- rc = llog_write(env, loghandle, &llh->llh_hdr, NULL, 0, NULL, 0);
- if (rc < 0) {
- CERROR("%s: fail to write header for llog #"DOSTID
- "#%08x: rc = %d\n",
- loghandle->lgh_ctxt->loc_obd->obd_name,
- POSTID(&loghandle->lgh_id.lgl_oi),
- loghandle->lgh_id.lgl_ogen, rc);
- goto out_err;
- }
- return 0;
-out_err:
- spin_lock(&loghandle->lgh_hdr_lock);
- ext2_set_bit(index, llh->llh_bitmap);
- llh->llh_count++;
- spin_unlock(&loghandle->lgh_hdr_lock);
- return rc;
-}
-EXPORT_SYMBOL(llog_cancel_rec);
-
static int llog_read_header(const struct lu_env *env,
struct llog_handle *handle,
struct obd_uuid *uuid)
@@ -188,7 +127,7 @@ static int llog_read_header(const struct lu_env *env,
llh->llh_hdr.lrh_type = LLOG_HDR_MAGIC;
llh->llh_hdr.lrh_len = llh->llh_tail.lrt_len = LLOG_CHUNK_SIZE;
llh->llh_hdr.lrh_index = llh->llh_tail.lrt_index = 0;
- llh->llh_timestamp = get_seconds();
+ llh->llh_timestamp = ktime_get_real_seconds();
if (uuid)
memcpy(&llh->llh_tgtuuid, uuid,
sizeof(llh->llh_tgtuuid));
@@ -207,8 +146,8 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
LASSERT(handle->lgh_hdr == NULL);
- OBD_ALLOC_PTR(llh);
- if (llh == NULL)
+ llh = kzalloc(sizeof(*llh), GFP_NOFS);
+ if (!llh)
return -ENOMEM;
handle->lgh_hdr = llh;
/* first assign flags to use llog_client_ops */
@@ -261,7 +200,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
}
out:
if (rc) {
- OBD_FREE_PTR(llh);
+ kfree(llh);
handle->lgh_hdr = NULL;
}
return rc;
@@ -283,7 +222,7 @@ static int llog_process_thread(void *arg)
LASSERT(llh);
- OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
+ buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS);
if (!buf) {
lpi->lpi_rc = -ENOMEM;
return 0;
@@ -326,7 +265,7 @@ repeat:
* swabbing is done at the beginning of the loop. */
for (rec = (struct llog_rec_hdr *)buf;
(char *)rec < buf + LLOG_CHUNK_SIZE;
- rec = (struct llog_rec_hdr *)((char *)rec + rec->lrh_len)){
+ rec = (struct llog_rec_hdr *)((char *)rec + rec->lrh_len)) {
CDEBUG(D_OTHER, "processing rec 0x%p type %#x\n",
rec, rec->lrh_type);
@@ -373,14 +312,6 @@ repeat:
rc = lpi->lpi_cb(lpi->lpi_env, loghandle, rec,
lpi->lpi_cbdata);
last_called_index = index;
- if (rc == LLOG_PROC_BREAK) {
- goto out;
- } else if (rc == LLOG_DEL_RECORD) {
- llog_cancel_rec(lpi->lpi_env,
- loghandle,
- rec->lrh_index);
- rc = 0;
- }
if (rc)
goto out;
} else {
@@ -400,7 +331,7 @@ out:
if (cd != NULL)
cd->lpcd_last_idx = last_called_index;
- OBD_FREE(buf, LLOG_CHUNK_SIZE);
+ kfree(buf);
lpi->lpi_rc = rc;
return 0;
}
@@ -434,8 +365,8 @@ int llog_process_or_fork(const struct lu_env *env,
struct llog_process_info *lpi;
int rc;
- OBD_ALLOC_PTR(lpi);
- if (lpi == NULL) {
+ lpi = kzalloc(sizeof(*lpi), GFP_NOFS);
+ if (!lpi) {
CERROR("cannot alloc pointer\n");
return -ENOMEM;
}
@@ -454,7 +385,7 @@ int llog_process_or_fork(const struct lu_env *env,
if (IS_ERR_VALUE(rc)) {
CERROR("%s: cannot start thread: rc = %d\n",
loghandle->lgh_ctxt->loc_obd->obd_name, rc);
- OBD_FREE_PTR(lpi);
+ kfree(lpi);
return rc;
}
wait_for_completion(&lpi->lpi_completion);
@@ -463,7 +394,7 @@ int llog_process_or_fork(const struct lu_env *env,
llog_process_thread(lpi);
}
rc = lpi->lpi_rc;
- OBD_FREE_PTR(lpi);
+ kfree(lpi);
return rc;
}
EXPORT_SYMBOL(llog_process_or_fork);
@@ -475,381 +406,6 @@ int llog_process(const struct lu_env *env, struct llog_handle *loghandle,
}
EXPORT_SYMBOL(llog_process);
-int llog_reverse_process(const struct lu_env *env,
- struct llog_handle *loghandle, llog_cb_t cb,
- void *data, void *catdata)
-{
- struct llog_log_hdr *llh = loghandle->lgh_hdr;
- struct llog_process_cat_data *cd = catdata;
- void *buf;
- int rc = 0, first_index = 1, index, idx;
-
- OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
- if (!buf)
- return -ENOMEM;
-
- if (cd != NULL)
- first_index = cd->lpcd_first_idx + 1;
- if (cd != NULL && cd->lpcd_last_idx)
- index = cd->lpcd_last_idx;
- else
- index = LLOG_BITMAP_BYTES * 8 - 1;
-
- while (rc == 0) {
- struct llog_rec_hdr *rec;
- struct llog_rec_tail *tail;
-
- /* skip records not set in bitmap */
- while (index >= first_index &&
- !ext2_test_bit(index, llh->llh_bitmap))
- --index;
-
- LASSERT(index >= first_index - 1);
- if (index == first_index - 1)
- break;
-
- /* get the buf with our target record; avoid old garbage */
- memset(buf, 0, LLOG_CHUNK_SIZE);
- rc = llog_prev_block(env, loghandle, index, buf,
- LLOG_CHUNK_SIZE);
- if (rc)
- goto out;
-
- rec = buf;
- idx = rec->lrh_index;
- CDEBUG(D_RPCTRACE, "index %u : idx %u\n", index, idx);
- while (idx < index) {
- rec = (void *)rec + rec->lrh_len;
- if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
- lustre_swab_llog_rec(rec);
- idx ++;
- }
- LASSERT(idx == index);
- tail = (void *)rec + rec->lrh_len - sizeof(*tail);
-
- /* process records in buffer, starting where we found one */
- while ((void *)tail > buf) {
- if (tail->lrt_index == 0) {
- /* no more records */
- rc = 0;
- goto out;
- }
-
- /* if set, process the callback on this record */
- if (ext2_test_bit(index, llh->llh_bitmap)) {
- rec = (void *)tail - tail->lrt_len +
- sizeof(*tail);
-
- rc = cb(env, loghandle, rec, data);
- if (rc == LLOG_PROC_BREAK) {
- goto out;
- } else if (rc == LLOG_DEL_RECORD) {
- llog_cancel_rec(env, loghandle,
- tail->lrt_index);
- rc = 0;
- }
- if (rc)
- goto out;
- }
-
- /* previous record, still in buffer? */
- --index;
- if (index < first_index) {
- rc = 0;
- goto out;
- }
- tail = (void *)tail - tail->lrt_len;
- }
- }
-
-out:
- if (buf)
- OBD_FREE(buf, LLOG_CHUNK_SIZE);
- return rc;
-}
-EXPORT_SYMBOL(llog_reverse_process);
-
-/**
- * new llog API
- *
- * API functions:
- * llog_open - open llog, may not exist
- * llog_exist - check if llog exists
- * llog_close - close opened llog, pair for open, frees llog_handle
- * llog_declare_create - declare llog creation
- * llog_create - create new llog on disk, need transaction handle
- * llog_declare_write_rec - declaration of llog write
- * llog_write_rec - write llog record on disk, need transaction handle
- * llog_declare_add - declare llog catalog record addition
- * llog_add - add llog record in catalog, need transaction handle
- */
-int llog_exist(struct llog_handle *loghandle)
-{
- struct llog_operations *lop;
- int rc;
-
- rc = llog_handle2ops(loghandle, &lop);
- if (rc)
- return rc;
- if (lop->lop_exist == NULL)
- return -EOPNOTSUPP;
-
- rc = lop->lop_exist(loghandle);
- return rc;
-}
-EXPORT_SYMBOL(llog_exist);
-
-int llog_declare_create(const struct lu_env *env,
- struct llog_handle *loghandle, struct thandle *th)
-{
- struct llog_operations *lop;
- int raised, rc;
-
- rc = llog_handle2ops(loghandle, &lop);
- if (rc)
- return rc;
- if (lop->lop_declare_create == NULL)
- return -EOPNOTSUPP;
-
- raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE);
- if (!raised)
- cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
- rc = lop->lop_declare_create(env, loghandle, th);
- if (!raised)
- cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
- return rc;
-}
-EXPORT_SYMBOL(llog_declare_create);
-
-int llog_create(const struct lu_env *env, struct llog_handle *handle,
- struct thandle *th)
-{
- struct llog_operations *lop;
- int raised, rc;
-
- rc = llog_handle2ops(handle, &lop);
- if (rc)
- return rc;
- if (lop->lop_create == NULL)
- return -EOPNOTSUPP;
-
- raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE);
- if (!raised)
- cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
- rc = lop->lop_create(env, handle, th);
- if (!raised)
- cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
- return rc;
-}
-EXPORT_SYMBOL(llog_create);
-
-int llog_declare_write_rec(const struct lu_env *env,
- struct llog_handle *handle,
- struct llog_rec_hdr *rec, int idx,
- struct thandle *th)
-{
- struct llog_operations *lop;
- int raised, rc;
-
- rc = llog_handle2ops(handle, &lop);
- if (rc)
- return rc;
- LASSERT(lop);
- if (lop->lop_declare_write_rec == NULL)
- return -EOPNOTSUPP;
-
- raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE);
- if (!raised)
- cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
- rc = lop->lop_declare_write_rec(env, handle, rec, idx, th);
- if (!raised)
- cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
- return rc;
-}
-EXPORT_SYMBOL(llog_declare_write_rec);
-
-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)
-{
- struct llog_operations *lop;
- int raised, rc, buflen;
-
- rc = llog_handle2ops(handle, &lop);
- if (rc)
- return rc;
-
- LASSERT(lop);
- if (lop->lop_write_rec == NULL)
- return -EOPNOTSUPP;
-
- if (buf)
- buflen = rec->lrh_len + sizeof(struct llog_rec_hdr) +
- sizeof(struct llog_rec_tail);
- else
- buflen = rec->lrh_len;
- LASSERT(cfs_size_round(buflen) == buflen);
-
- raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE);
- if (!raised)
- cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
- rc = lop->lop_write_rec(env, handle, rec, logcookies, numcookies,
- buf, idx, th);
- if (!raised)
- cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
- return rc;
-}
-EXPORT_SYMBOL(llog_write_rec);
-
-int llog_add(const struct lu_env *env, struct llog_handle *lgh,
- struct llog_rec_hdr *rec, struct llog_cookie *logcookies,
- void *buf, struct thandle *th)
-{
- int raised, rc;
-
- if (lgh->lgh_logops->lop_add == NULL)
- return -EOPNOTSUPP;
-
- raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE);
- if (!raised)
- cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
- rc = lgh->lgh_logops->lop_add(env, lgh, rec, logcookies, buf, th);
- if (!raised)
- cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
- return rc;
-}
-EXPORT_SYMBOL(llog_add);
-
-int llog_declare_add(const struct lu_env *env, struct llog_handle *lgh,
- struct llog_rec_hdr *rec, struct thandle *th)
-{
- int raised, rc;
-
- if (lgh->lgh_logops->lop_declare_add == NULL)
- return -EOPNOTSUPP;
-
- raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE);
- if (!raised)
- cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
- rc = lgh->lgh_logops->lop_declare_add(env, lgh, rec, th);
- if (!raised)
- cfs_cap_lower(CFS_CAP_SYS_RESOURCE);
- return rc;
-}
-EXPORT_SYMBOL(llog_declare_add);
-
-/**
- * Helper function to open llog or create it if doesn't exist.
- * It hides all transaction handling from caller.
- */
-int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt,
- struct llog_handle **res, struct llog_logid *logid,
- char *name)
-{
- struct dt_device *d;
- struct thandle *th;
- int rc;
-
- rc = llog_open(env, ctxt, res, logid, name, LLOG_OPEN_NEW);
- if (rc)
- return rc;
-
- if (llog_exist(*res))
- return 0;
-
- LASSERT((*res)->lgh_obj != NULL);
-
- d = lu2dt_dev((*res)->lgh_obj->do_lu.lo_dev);
-
- th = dt_trans_create(env, d);
- if (IS_ERR(th)) {
- rc = PTR_ERR(th);
- goto out;
- }
-
- rc = llog_declare_create(env, *res, th);
- if (rc == 0) {
- rc = dt_trans_start_local(env, d, th);
- if (rc == 0)
- rc = llog_create(env, *res, th);
- }
- dt_trans_stop(env, d, th);
-out:
- if (rc)
- llog_close(env, *res);
- return rc;
-}
-EXPORT_SYMBOL(llog_open_create);
-
-/**
- * Helper function to delete existent llog.
- */
-int llog_erase(const struct lu_env *env, struct llog_ctxt *ctxt,
- struct llog_logid *logid, char *name)
-{
- struct llog_handle *handle;
- int rc = 0, rc2;
-
- /* nothing to erase */
- if (name == NULL && logid == NULL)
- return 0;
-
- rc = llog_open(env, ctxt, &handle, logid, name, LLOG_OPEN_EXISTS);
- if (rc < 0)
- return rc;
-
- rc = llog_init_handle(env, handle, LLOG_F_IS_PLAIN, NULL);
- if (rc == 0)
- rc = llog_destroy(env, handle);
-
- rc2 = llog_close(env, handle);
- if (rc == 0)
- rc = rc2;
- return rc;
-}
-EXPORT_SYMBOL(llog_erase);
-
-/*
- * Helper function for write record in llog.
- * It hides all transaction handling from caller.
- * Valid only with local llog.
- */
-int llog_write(const struct lu_env *env, struct llog_handle *loghandle,
- struct llog_rec_hdr *rec, struct llog_cookie *reccookie,
- int cookiecount, void *buf, int idx)
-{
- struct dt_device *dt;
- struct thandle *th;
- int rc;
-
- LASSERT(loghandle);
- LASSERT(loghandle->lgh_ctxt);
- LASSERT(loghandle->lgh_obj != NULL);
-
- dt = lu2dt_dev(loghandle->lgh_obj->do_lu.lo_dev);
-
- th = dt_trans_create(env, dt);
- if (IS_ERR(th))
- return PTR_ERR(th);
-
- rc = llog_declare_write_rec(env, loghandle, rec, idx, th);
- if (rc)
- goto out_trans;
-
- rc = dt_trans_start_local(env, dt, th);
- if (rc)
- goto out_trans;
-
- down_write(&loghandle->lgh_lock);
- rc = llog_write_rec(env, loghandle, rec, reccookie,
- cookiecount, buf, idx, th);
- up_write(&loghandle->lgh_lock);
-out_trans:
- dt_trans_stop(env, dt, th);
- return rc;
-}
-EXPORT_SYMBOL(llog_write);
-
int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt,
struct llog_handle **lgh, struct llog_logid *logid,
char *name, enum llog_open_param open_param)
@@ -903,105 +459,3 @@ out:
return rc;
}
EXPORT_SYMBOL(llog_close);
-
-int llog_is_empty(const struct lu_env *env, struct llog_ctxt *ctxt,
- char *name)
-{
- struct llog_handle *llh;
- int rc = 0;
-
- rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
- if (rc < 0) {
- if (likely(rc == -ENOENT))
- rc = 0;
- goto out;
- }
-
- rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
- if (rc)
- goto out_close;
- rc = llog_get_size(llh);
-
-out_close:
- llog_close(env, llh);
-out:
- /* header is record 1 */
- return rc <= 1;
-}
-EXPORT_SYMBOL(llog_is_empty);
-
-int llog_copy_handler(const struct lu_env *env, struct llog_handle *llh,
- struct llog_rec_hdr *rec, void *data)
-{
- struct llog_handle *copy_llh = data;
-
- /* Append all records */
- return llog_write(env, copy_llh, rec, NULL, 0, NULL, -1);
-}
-EXPORT_SYMBOL(llog_copy_handler);
-
-/* backup plain llog */
-int llog_backup(const struct lu_env *env, struct obd_device *obd,
- struct llog_ctxt *ctxt, struct llog_ctxt *bctxt,
- char *name, char *backup)
-{
- struct llog_handle *llh, *bllh;
- int rc;
-
-
-
- /* open original log */
- rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
- if (rc < 0) {
- /* the -ENOENT case is also reported to the caller
- * but silently so it should handle that if needed.
- */
- if (rc != -ENOENT)
- CERROR("%s: failed to open log %s: rc = %d\n",
- obd->obd_name, name, rc);
- return rc;
- }
-
- rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
- if (rc)
- goto out_close;
-
- /* Make sure there's no old backup log */
- rc = llog_erase(env, bctxt, NULL, backup);
- if (rc < 0 && rc != -ENOENT)
- goto out_close;
-
- /* open backup log */
- rc = llog_open_create(env, bctxt, &bllh, NULL, backup);
- if (rc) {
- CERROR("%s: failed to open backup logfile %s: rc = %d\n",
- obd->obd_name, backup, rc);
- goto out_close;
- }
-
- /* check that backup llog is not the same object as original one */
- if (llh->lgh_obj == bllh->lgh_obj) {
- CERROR("%s: backup llog %s to itself (%s), objects %p/%p\n",
- obd->obd_name, name, backup, llh->lgh_obj,
- bllh->lgh_obj);
- rc = -EEXIST;
- goto out_backup;
- }
-
- rc = llog_init_handle(env, bllh, LLOG_F_IS_PLAIN, NULL);
- if (rc)
- goto out_backup;
-
- /* Copy log record by record */
- rc = llog_process_or_fork(env, llh, llog_copy_handler, (void *)bllh,
- NULL, false);
- if (rc)
- CERROR("%s: failed to backup log %s: rc = %d\n",
- obd->obd_name, name, rc);
-out_backup:
- llog_close(env, bllh);
-out_close:
- llog_close(env, llh);
- return rc;
-}
-EXPORT_SYMBOL(llog_backup);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/kernel/drivers/staging/lustre/lustre/obdclass/llog_cat.c
index c8f6ab006..c442cae5f 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/llog_cat.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/llog_cat.c
@@ -48,98 +48,10 @@
#define DEBUG_SUBSYSTEM S_LOG
-
#include "../include/obd_class.h"
#include "llog_internal.h"
-/* Create a new log handle and add it to the open list.
- * This log handle will be closed when all of the records in it are removed.
- *
- * Assumes caller has already pushed us into the kernel context and is locking.
- */
-static int llog_cat_new_log(const struct lu_env *env,
- struct llog_handle *cathandle,
- struct llog_handle *loghandle,
- struct thandle *th)
-{
-
- struct llog_log_hdr *llh;
- struct llog_logid_rec rec = { { 0 }, };
- int rc, index, bitmap_size;
-
- llh = cathandle->lgh_hdr;
- bitmap_size = LLOG_BITMAP_SIZE(llh);
-
- index = (cathandle->lgh_last_idx + 1) % bitmap_size;
-
- /* maximum number of available slots in catlog is bitmap_size - 2 */
- if (llh->llh_cat_idx == index) {
- CERROR("no free catalog slots for log...\n");
- return -ENOSPC;
- }
-
- if (OBD_FAIL_CHECK(OBD_FAIL_MDS_LLOG_CREATE_FAILED))
- return -ENOSPC;
-
- rc = llog_create(env, loghandle, th);
- /* if llog is already created, no need to initialize it */
- if (rc == -EEXIST) {
- return 0;
- } else if (rc != 0) {
- CERROR("%s: can't create new plain llog in catalog: rc = %d\n",
- loghandle->lgh_ctxt->loc_obd->obd_name, rc);
- return rc;
- }
-
- rc = llog_init_handle(env, loghandle,
- LLOG_F_IS_PLAIN | LLOG_F_ZAP_WHEN_EMPTY,
- &cathandle->lgh_hdr->llh_tgtuuid);
- if (rc)
- goto out_destroy;
-
- if (index == 0)
- index = 1;
-
- spin_lock(&loghandle->lgh_hdr_lock);
- llh->llh_count++;
- if (ext2_set_bit(index, llh->llh_bitmap)) {
- CERROR("argh, index %u already set in log bitmap?\n",
- index);
- spin_unlock(&loghandle->lgh_hdr_lock);
- LBUG(); /* should never happen */
- }
- spin_unlock(&loghandle->lgh_hdr_lock);
-
- cathandle->lgh_last_idx = index;
- llh->llh_tail.lrt_index = index;
-
- CDEBUG(D_RPCTRACE,
- "new recovery log "DOSTID":%x for index %u of catalog"
- DOSTID"\n", POSTID(&loghandle->lgh_id.lgl_oi),
- loghandle->lgh_id.lgl_ogen, index,
- POSTID(&cathandle->lgh_id.lgl_oi));
- /* build the record for this log in the catalog */
- rec.lid_hdr.lrh_len = sizeof(rec);
- rec.lid_hdr.lrh_index = index;
- rec.lid_hdr.lrh_type = LLOG_LOGID_MAGIC;
- rec.lid_id = loghandle->lgh_id;
- rec.lid_tail.lrt_len = sizeof(rec);
- rec.lid_tail.lrt_index = index;
-
- /* update the catalog: header and record */
- rc = llog_write_rec(env, cathandle, &rec.lid_hdr,
- &loghandle->u.phd.phd_cookie, 1, NULL, index, th);
- if (rc < 0)
- goto out_destroy;
-
- loghandle->lgh_hdr->llh_cat_idx = index;
- return 0;
-out_destroy:
- llog_destroy(env, loghandle);
- return rc;
-}
-
/* Open an existent log handle and add it to the open list.
* This log handle will be closed when all of the records in it are removed.
*
@@ -149,8 +61,10 @@ out_destroy:
* This takes extra reference on llog_handle via llog_handle_get() and require
* this reference to be put by caller using llog_handle_put()
*/
-int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_handle **res, struct llog_logid *logid)
+static int llog_cat_id2handle(const struct lu_env *env,
+ struct llog_handle *cathandle,
+ struct llog_handle **res,
+ struct llog_logid *logid)
{
struct llog_handle *loghandle;
int rc = 0;
@@ -217,24 +131,8 @@ int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle)
list_for_each_entry_safe(loghandle, n, &cathandle->u.chd.chd_head,
u.phd.phd_entry) {
- struct llog_log_hdr *llh = loghandle->lgh_hdr;
- int index;
-
/* unlink open-not-created llogs */
list_del_init(&loghandle->u.phd.phd_entry);
- llh = loghandle->lgh_hdr;
- if (loghandle->lgh_obj != NULL && llh != NULL &&
- (llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
- (llh->llh_count == 1)) {
- rc = llog_destroy(env, loghandle);
- if (rc)
- CERROR("%s: failure destroying log during cleanup: rc = %d\n",
- loghandle->lgh_ctxt->loc_obd->obd_name,
- rc);
-
- index = loghandle->u.phd.phd_cookie.lgc_index;
- llog_cat_cleanup(env, cathandle, NULL, index);
- }
llog_close(env, loghandle);
}
/* if handle was stored in ctxt, remove it too */
@@ -245,287 +143,6 @@ int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle)
}
EXPORT_SYMBOL(llog_cat_close);
-/**
- * lockdep markers for nested struct llog_handle::lgh_lock locking.
- */
-enum {
- LLOGH_CAT,
- LLOGH_LOG
-};
-
-/** Return the currently active log handle. If the current log handle doesn't
- * have enough space left for the current record, start a new one.
- *
- * If reclen is 0, we only want to know what the currently active log is,
- * otherwise we get a lock on this log so nobody can steal our space.
- *
- * Assumes caller has already pushed us into the kernel context and is locking.
- *
- * NOTE: loghandle is write-locked upon successful return
- */
-static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle,
- struct thandle *th)
-{
- struct llog_handle *loghandle = NULL;
-
- down_read_nested(&cathandle->lgh_lock, LLOGH_CAT);
- loghandle = cathandle->u.chd.chd_current_log;
- if (loghandle) {
- struct llog_log_hdr *llh;
-
- down_write_nested(&loghandle->lgh_lock, LLOGH_LOG);
- llh = loghandle->lgh_hdr;
- if (llh == NULL ||
- loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) {
- up_read(&cathandle->lgh_lock);
- return loghandle;
- } else {
- up_write(&loghandle->lgh_lock);
- }
- }
- up_read(&cathandle->lgh_lock);
-
- /* time to use next log */
-
- /* first, we have to make sure the state hasn't changed */
- down_write_nested(&cathandle->lgh_lock, LLOGH_CAT);
- loghandle = cathandle->u.chd.chd_current_log;
- if (loghandle) {
- struct llog_log_hdr *llh;
-
- down_write_nested(&loghandle->lgh_lock, LLOGH_LOG);
- llh = loghandle->lgh_hdr;
- LASSERT(llh);
- if (loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) {
- up_write(&cathandle->lgh_lock);
- return loghandle;
- } else {
- up_write(&loghandle->lgh_lock);
- }
- }
-
- CDEBUG(D_INODE, "use next log\n");
-
- loghandle = cathandle->u.chd.chd_next_log;
- cathandle->u.chd.chd_current_log = loghandle;
- cathandle->u.chd.chd_next_log = NULL;
- down_write_nested(&loghandle->lgh_lock, LLOGH_LOG);
- up_write(&cathandle->lgh_lock);
- LASSERT(loghandle);
- return loghandle;
-}
-
-/* Add a single record to the recovery log(s) using a catalog
- * Returns as llog_write_record
- *
- * Assumes caller has already pushed us into the kernel context.
- */
-int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, struct llog_cookie *reccookie,
- void *buf, struct thandle *th)
-{
- struct llog_handle *loghandle;
- int rc;
-
- LASSERT(rec->lrh_len <= LLOG_CHUNK_SIZE);
- loghandle = llog_cat_current_log(cathandle, th);
- LASSERT(!IS_ERR(loghandle));
-
- /* loghandle is already locked by llog_cat_current_log() for us */
- if (!llog_exist(loghandle)) {
- rc = llog_cat_new_log(env, cathandle, loghandle, th);
- if (rc < 0) {
- up_write(&loghandle->lgh_lock);
- return rc;
- }
- }
- /* now let's try to add the record */
- rc = llog_write_rec(env, loghandle, rec, reccookie, 1, buf, -1, th);
- if (rc < 0)
- CDEBUG_LIMIT(rc == -ENOSPC ? D_HA : D_ERROR,
- "llog_write_rec %d: lh=%p\n", rc, loghandle);
- up_write(&loghandle->lgh_lock);
- if (rc == -ENOSPC) {
- /* try to use next log */
- loghandle = llog_cat_current_log(cathandle, th);
- LASSERT(!IS_ERR(loghandle));
- /* new llog can be created concurrently */
- if (!llog_exist(loghandle)) {
- rc = llog_cat_new_log(env, cathandle, loghandle, th);
- if (rc < 0) {
- up_write(&loghandle->lgh_lock);
- return rc;
- }
- }
- /* now let's try to add the record */
- rc = llog_write_rec(env, loghandle, rec, reccookie, 1, buf,
- -1, th);
- if (rc < 0)
- CERROR("llog_write_rec %d: lh=%p\n", rc, loghandle);
- up_write(&loghandle->lgh_lock);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(llog_cat_add_rec);
-
-int llog_cat_declare_add_rec(const struct lu_env *env,
- struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, struct thandle *th)
-{
- struct llog_handle *loghandle, *next;
- int rc = 0;
-
- if (cathandle->u.chd.chd_current_log == NULL) {
- /* declare new plain llog */
- down_write(&cathandle->lgh_lock);
- if (cathandle->u.chd.chd_current_log == NULL) {
- rc = llog_open(env, cathandle->lgh_ctxt, &loghandle,
- NULL, NULL, LLOG_OPEN_NEW);
- if (rc == 0) {
- cathandle->u.chd.chd_current_log = loghandle;
- list_add_tail(&loghandle->u.phd.phd_entry,
- &cathandle->u.chd.chd_head);
- }
- }
- up_write(&cathandle->lgh_lock);
- } else if (cathandle->u.chd.chd_next_log == NULL) {
- /* declare next plain llog */
- down_write(&cathandle->lgh_lock);
- if (cathandle->u.chd.chd_next_log == NULL) {
- rc = llog_open(env, cathandle->lgh_ctxt, &loghandle,
- NULL, NULL, LLOG_OPEN_NEW);
- if (rc == 0) {
- cathandle->u.chd.chd_next_log = loghandle;
- list_add_tail(&loghandle->u.phd.phd_entry,
- &cathandle->u.chd.chd_head);
- }
- }
- up_write(&cathandle->lgh_lock);
- }
- if (rc)
- goto out;
-
- if (!llog_exist(cathandle->u.chd.chd_current_log)) {
- rc = llog_declare_create(env, cathandle->u.chd.chd_current_log,
- th);
- if (rc)
- goto out;
- llog_declare_write_rec(env, cathandle, NULL, -1, th);
- }
- /* declare records in the llogs */
- rc = llog_declare_write_rec(env, cathandle->u.chd.chd_current_log,
- rec, -1, th);
- if (rc)
- goto out;
-
- next = cathandle->u.chd.chd_next_log;
- if (next) {
- if (!llog_exist(next)) {
- rc = llog_declare_create(env, next, th);
- llog_declare_write_rec(env, cathandle, NULL, -1, th);
- }
- llog_declare_write_rec(env, next, rec, -1, th);
- }
-out:
- return rc;
-}
-EXPORT_SYMBOL(llog_cat_declare_add_rec);
-
-int llog_cat_add(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, struct llog_cookie *reccookie,
- void *buf)
-{
- struct llog_ctxt *ctxt;
- struct dt_device *dt;
- struct thandle *th = NULL;
- int rc;
-
- ctxt = cathandle->lgh_ctxt;
- LASSERT(ctxt);
- LASSERT(ctxt->loc_exp);
-
- if (cathandle->lgh_obj != NULL) {
- dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt;
- LASSERT(dt);
-
- th = dt_trans_create(env, dt);
- if (IS_ERR(th))
- return PTR_ERR(th);
-
- rc = llog_cat_declare_add_rec(env, cathandle, rec, th);
- if (rc)
- goto out_trans;
-
- rc = dt_trans_start_local(env, dt, th);
- if (rc)
- goto out_trans;
- rc = llog_cat_add_rec(env, cathandle, rec, reccookie, buf, th);
-out_trans:
- dt_trans_stop(env, dt, th);
- } else { /* lvfs compat code */
- LASSERT(cathandle->lgh_file != NULL);
- rc = llog_cat_declare_add_rec(env, cathandle, rec, th);
- if (rc == 0)
- rc = llog_cat_add_rec(env, cathandle, rec, reccookie,
- buf, th);
- }
- return rc;
-}
-EXPORT_SYMBOL(llog_cat_add);
-
-/* For each cookie in the cookie array, we clear the log in-use bit and either:
- * - the log is empty, so mark it free in the catalog header and delete it
- * - the log is not empty, just write out the log header
- *
- * The cookies may be in different log files, so we need to get new logs
- * each time.
- *
- * Assumes caller has already pushed us into the kernel context.
- */
-int llog_cat_cancel_records(const struct lu_env *env,
- struct llog_handle *cathandle, int count,
- struct llog_cookie *cookies)
-{
- int i, index, rc = 0, failed = 0;
-
- for (i = 0; i < count; i++, cookies++) {
- struct llog_handle *loghandle;
- struct llog_logid *lgl = &cookies->lgc_lgl;
- int lrc;
-
- rc = llog_cat_id2handle(env, cathandle, &loghandle, lgl);
- if (rc) {
- CERROR("%s: cannot find handle for llog "DOSTID": %d\n",
- cathandle->lgh_ctxt->loc_obd->obd_name,
- POSTID(&lgl->lgl_oi), rc);
- failed++;
- continue;
- }
-
- lrc = llog_cancel_rec(env, loghandle, cookies->lgc_index);
- if (lrc == 1) { /* log has been destroyed */
- index = loghandle->u.phd.phd_cookie.lgc_index;
- rc = llog_cat_cleanup(env, cathandle, loghandle,
- index);
- } else if (lrc == -ENOENT) {
- if (rc == 0) /* ENOENT shouldn't rewrite any error */
- rc = lrc;
- } else if (lrc < 0) {
- failed++;
- rc = lrc;
- }
- llog_handle_put(loghandle);
- }
- if (rc)
- CERROR("%s: fail to cancel %d of %d llog-records: rc = %d\n",
- cathandle->lgh_ctxt->loc_obd->obd_name, failed, count,
- rc);
-
- return rc;
-}
-EXPORT_SYMBOL(llog_cat_cancel_records);
-
static int llog_cat_process_cb(const struct lu_env *env,
struct llog_handle *cat_llh,
struct llog_rec_hdr *rec, void *data)
@@ -573,10 +190,10 @@ static int llog_cat_process_cb(const struct lu_env *env,
return rc;
}
-int llog_cat_process_or_fork(const struct lu_env *env,
- struct llog_handle *cat_llh,
- llog_cb_t cb, void *data, int startcat,
- int startidx, bool fork)
+static int llog_cat_process_or_fork(const struct lu_env *env,
+ struct llog_handle *cat_llh,
+ llog_cb_t cb, void *data, int startcat,
+ int startidx, bool fork)
{
struct llog_process_data d;
struct llog_log_hdr *llh = cat_llh->lgh_hdr;
@@ -612,7 +229,6 @@ int llog_cat_process_or_fork(const struct lu_env *env,
return rc;
}
-EXPORT_SYMBOL(llog_cat_process_or_fork);
int llog_cat_process(const struct lu_env *env, struct llog_handle *cat_llh,
llog_cb_t cb, void *data, int startcat, int startidx)
@@ -621,195 +237,3 @@ int llog_cat_process(const struct lu_env *env, struct llog_handle *cat_llh,
startidx, false);
}
EXPORT_SYMBOL(llog_cat_process);
-
-static int llog_cat_reverse_process_cb(const struct lu_env *env,
- struct llog_handle *cat_llh,
- struct llog_rec_hdr *rec, void *data)
-{
- struct llog_process_data *d = data;
- struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
- struct llog_handle *llh;
- int rc;
-
- if (le32_to_cpu(rec->lrh_type) != LLOG_LOGID_MAGIC) {
- CERROR("invalid record in catalog\n");
- return -EINVAL;
- }
- CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog "
- DOSTID"\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen,
- le32_to_cpu(rec->lrh_index), POSTID(&cat_llh->lgh_id.lgl_oi));
-
- rc = llog_cat_id2handle(env, cat_llh, &llh, &lir->lid_id);
- if (rc) {
- CERROR("%s: cannot find handle for llog "DOSTID": %d\n",
- cat_llh->lgh_ctxt->loc_obd->obd_name,
- POSTID(&lir->lid_id.lgl_oi), rc);
- return rc;
- }
-
- rc = llog_reverse_process(env, llh, d->lpd_cb, d->lpd_data, NULL);
- llog_handle_put(llh);
- return rc;
-}
-
-int llog_cat_reverse_process(const struct lu_env *env,
- struct llog_handle *cat_llh,
- llog_cb_t cb, void *data)
-{
- struct llog_process_data d;
- struct llog_process_cat_data cd;
- struct llog_log_hdr *llh = cat_llh->lgh_hdr;
- int rc;
-
- LASSERT(llh->llh_flags & LLOG_F_IS_CAT);
- d.lpd_data = data;
- d.lpd_cb = cb;
-
- if (llh->llh_cat_idx > cat_llh->lgh_last_idx) {
- CWARN("catalog "DOSTID" crosses index zero\n",
- POSTID(&cat_llh->lgh_id.lgl_oi));
-
- cd.lpcd_first_idx = 0;
- cd.lpcd_last_idx = cat_llh->lgh_last_idx;
- rc = llog_reverse_process(env, cat_llh,
- llog_cat_reverse_process_cb,
- &d, &cd);
- if (rc != 0)
- return rc;
-
- cd.lpcd_first_idx = le32_to_cpu(llh->llh_cat_idx);
- cd.lpcd_last_idx = 0;
- rc = llog_reverse_process(env, cat_llh,
- llog_cat_reverse_process_cb,
- &d, &cd);
- } else {
- rc = llog_reverse_process(env, cat_llh,
- llog_cat_reverse_process_cb,
- &d, NULL);
- }
-
- return rc;
-}
-EXPORT_SYMBOL(llog_cat_reverse_process);
-
-static int llog_cat_set_first_idx(struct llog_handle *cathandle, int index)
-{
- struct llog_log_hdr *llh = cathandle->lgh_hdr;
- int i, bitmap_size, idx;
-
- bitmap_size = LLOG_BITMAP_SIZE(llh);
- if (llh->llh_cat_idx == (index - 1)) {
- idx = llh->llh_cat_idx + 1;
- llh->llh_cat_idx = idx;
- if (idx == cathandle->lgh_last_idx)
- goto out;
- for (i = (index + 1) % bitmap_size;
- i != cathandle->lgh_last_idx;
- i = (i + 1) % bitmap_size) {
- if (!ext2_test_bit(i, llh->llh_bitmap)) {
- idx = llh->llh_cat_idx + 1;
- llh->llh_cat_idx = idx;
- } else if (i == 0) {
- llh->llh_cat_idx = 0;
- } else {
- break;
- }
- }
-out:
- CDEBUG(D_RPCTRACE, "set catlog "DOSTID" first idx %u\n",
- POSTID(&cathandle->lgh_id.lgl_oi), llh->llh_cat_idx);
- }
-
- return 0;
-}
-
-/* Cleanup deleted plain llog traces from catalog */
-int llog_cat_cleanup(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_handle *loghandle, int index)
-{
- int rc;
-
- LASSERT(index);
- if (loghandle != NULL) {
- /* remove destroyed llog from catalog list and
- * chd_current_log variable */
- down_write(&cathandle->lgh_lock);
- if (cathandle->u.chd.chd_current_log == loghandle)
- cathandle->u.chd.chd_current_log = NULL;
- list_del_init(&loghandle->u.phd.phd_entry);
- up_write(&cathandle->lgh_lock);
- LASSERT(index == loghandle->u.phd.phd_cookie.lgc_index);
- /* llog was opened and keep in a list, close it now */
- llog_close(env, loghandle);
- }
- /* remove plain llog entry from catalog by index */
- llog_cat_set_first_idx(cathandle, index);
- rc = llog_cancel_rec(env, cathandle, index);
- if (rc == 0)
- CDEBUG(D_HA, "cancel plain log at index %u of catalog " DOSTID "\n",
- index, POSTID(&cathandle->lgh_id.lgl_oi));
- return rc;
-}
-
-static int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_rec_hdr *rec, void *data)
-{
- struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
- struct llog_handle *loghandle;
- struct llog_log_hdr *llh;
- int rc;
-
- if (rec->lrh_type != LLOG_LOGID_MAGIC) {
- CERROR("invalid record in catalog\n");
- return -EINVAL;
- }
-
- CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog "
- DOSTID"\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen,
- rec->lrh_index, POSTID(&cathandle->lgh_id.lgl_oi));
-
- rc = llog_cat_id2handle(env, cathandle, &loghandle, &lir->lid_id);
- if (rc) {
- CERROR("%s: cannot find handle for llog "DOSTID": %d\n",
- cathandle->lgh_ctxt->loc_obd->obd_name,
- POSTID(&lir->lid_id.lgl_oi), rc);
- if (rc == -ENOENT || rc == -ESTALE) {
- /* remove index from catalog */
- llog_cat_cleanup(env, cathandle, NULL, rec->lrh_index);
- }
- return rc;
- }
-
- llh = loghandle->lgh_hdr;
- if ((llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
- (llh->llh_count == 1)) {
- rc = llog_destroy(env, loghandle);
- if (rc)
- CERROR("%s: fail to destroy empty log: rc = %d\n",
- loghandle->lgh_ctxt->loc_obd->obd_name, rc);
-
- llog_cat_cleanup(env, cathandle, loghandle,
- loghandle->u.phd.phd_cookie.lgc_index);
- }
- llog_handle_put(loghandle);
-
- return rc;
-}
-
-/* helper to initialize catalog llog and process it to cancel */
-int llog_cat_init_and_process(const struct lu_env *env,
- struct llog_handle *llh)
-{
- int rc;
-
- rc = llog_init_handle(env, llh, LLOG_F_IS_CAT, NULL);
- if (rc)
- return rc;
-
- rc = llog_process_or_fork(env, llh, cat_cancel_cb, NULL, NULL, false);
- if (rc)
- CERROR("%s: llog_process() with cat_cancel_cb failed: rc = %d\n",
- llh->lgh_ctxt->loc_obd->obd_name, rc);
- return 0;
-}
-EXPORT_SYMBOL(llog_cat_init_and_process);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/llog_internal.h b/kernel/drivers/staging/lustre/lustre/obdclass/llog_internal.h
index 5332131a2..b9fe4b01c 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/llog_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/llog_internal.h
@@ -53,7 +53,6 @@ struct llog_process_info {
struct llog_thread_info {
struct lu_attr lgi_attr;
struct lu_fid lgi_fid;
- struct dt_object_format lgi_dof;
struct lu_buf lgi_buf;
loff_t lgi_off;
struct llog_rec_hdr lgi_lrh;
@@ -62,34 +61,14 @@ struct llog_thread_info {
extern struct lu_context_key llog_thread_key;
-static inline struct llog_thread_info *llog_info(const struct lu_env *env)
-{
- struct llog_thread_info *lgi;
-
- lgi = lu_context_key_get(&env->le_ctx, &llog_thread_key);
- LASSERT(lgi);
- return lgi;
-}
-
-static inline void
-lustre_build_llog_lvfs_oid(struct llog_logid *logid, __u64 ino, __u32 gen)
-{
- ostid_set_seq_llog(&logid->lgl_oi);
- ostid_set_id(&logid->lgl_oi, ino);
- logid->lgl_ogen = gen;
-}
-
int llog_info_init(void);
void llog_info_fini(void);
void llog_handle_get(struct llog_handle *loghandle);
void llog_handle_put(struct llog_handle *loghandle);
-int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle,
- struct llog_handle **res, struct llog_logid *logid);
int class_config_dump_handler(const struct lu_env *env,
struct llog_handle *handle,
struct llog_rec_hdr *rec, void *data);
-int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size);
int llog_process_or_fork(const struct lu_env *env,
struct llog_handle *loghandle,
llog_cb_t cb, void *data, void *catdata, bool fork);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/kernel/drivers/staging/lustre/lustre/obdclass/llog_obd.c
index 978d886a1..3900b9d40 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/llog_obd.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/llog_obd.c
@@ -36,7 +36,6 @@
#define DEBUG_SUBSYSTEM S_LOG
-
#include "../include/obd_class.h"
#include "../include/lustre_log.h"
#include "llog_internal.h"
@@ -46,7 +45,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd)
{
struct llog_ctxt *ctxt;
- OBD_ALLOC_PTR(ctxt);
+ ctxt = kzalloc(sizeof(*ctxt), GFP_NOFS);
if (!ctxt)
return NULL;
@@ -66,7 +65,7 @@ static void llog_ctxt_destroy(struct llog_ctxt *ctxt)
class_import_put(ctxt->loc_imp);
ctxt->loc_imp = NULL;
}
- OBD_FREE_PTR(ctxt);
+ kfree(ctxt);
}
int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt)
@@ -212,36 +211,6 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd,
}
EXPORT_SYMBOL(llog_setup);
-int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags)
-{
- int rc = 0;
-
- if (!ctxt)
- return 0;
-
- if (CTXTP(ctxt, sync))
- rc = CTXTP(ctxt, sync)(ctxt, exp, flags);
-
- return rc;
-}
-EXPORT_SYMBOL(llog_sync);
-
-int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt,
- struct llog_cookie *cookies, int flags)
-{
- int rc;
-
- if (!ctxt) {
- CERROR("No ctxt\n");
- return -ENODEV;
- }
-
- CTXT_CHECK_OP(ctxt, cancel, -EOPNOTSUPP);
- rc = CTXTP(ctxt, cancel)(env, ctxt, cookies, flags);
- return rc;
-}
-EXPORT_SYMBOL(llog_cancel);
-
/* context key constructor/destructor: llog_key_init, llog_key_fini */
LU_KEY_INIT_FINI(llog, struct llog_thread_info);
/* context key: llog_thread_key */
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/kernel/drivers/staging/lustre/lustre/obdclass/llog_swab.c
index a2d5aa105..9354f75b5 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/llog_swab.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/llog_swab.c
@@ -42,7 +42,6 @@
#define DEBUG_SUBSYSTEM S_LOG
-
#include "../include/lustre_log.h"
static void print_llogd_body(struct llogd_body *d)
@@ -78,13 +77,12 @@ void lustre_swab_ost_id(struct ost_id *oid)
}
EXPORT_SYMBOL(lustre_swab_ost_id);
-void lustre_swab_llog_id(struct llog_logid *log_id)
+static void lustre_swab_llog_id(struct llog_logid *log_id)
{
__swab64s(&log_id->lgl_oi.oi.oi_id);
__swab64s(&log_id->lgl_oi.oi.oi_seq);
__swab32s(&log_id->lgl_ogen);
}
-EXPORT_SYMBOL(lustre_swab_llog_id);
void lustre_swab_llogd_body(struct llogd_body *d)
{
@@ -109,13 +107,12 @@ void lustre_swab_llogd_conn_body(struct llogd_conn_body *d)
}
EXPORT_SYMBOL(lustre_swab_llogd_conn_body);
-void lustre_swab_ll_fid(struct ll_fid *fid)
+static void lustre_swab_ll_fid(struct ll_fid *fid)
{
__swab64s(&fid->id);
__swab32s(&fid->generation);
__swab32s(&fid->f_type);
}
-EXPORT_SYMBOL(lustre_swab_ll_fid);
void lustre_swab_lu_seq_range(struct lu_seq_range *range)
{
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c b/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
index c49dfe541..6acc4a10f 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c
@@ -41,9 +41,6 @@
#include "../include/lprocfs_status.h"
#include "../include/obd_support.h"
-struct lprocfs_stats *obd_memory = NULL;
-EXPORT_SYMBOL(obd_memory);
-
void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount)
{
struct lprocfs_counter *percpu_cntr;
@@ -74,9 +71,6 @@ void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount)
* ldlm_pool_shrink(), which calls lprocfs_counter_add().
* LU-1727.
*
- * Only obd_memory uses LPROCFS_STATS_FLAG_IRQ_SAFE
- * flag, because it needs accurate counting lest memory leak
- * check reports error.
*/
if (in_interrupt() &&
(stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
@@ -124,9 +118,6 @@ void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx, long amount)
* softirq context here, use separate counter for that.
* bz20650.
*
- * Only obd_memory uses LPROCFS_STATS_FLAG_IRQ_SAFE
- * flag, because it needs accurate counting lest memory leak
- * check reports error.
*/
if (in_interrupt() &&
(stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index c171c6c6c..333ac7d26 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -40,7 +40,6 @@
#define DEBUG_SUBSYSTEM S_CLASS
-
#include "../include/obd_class.h"
#include "../include/lprocfs_status.h"
#include "../include/lustre/lustre_idl.h"
@@ -221,8 +220,6 @@ int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count,
}
EXPORT_SYMBOL(lprocfs_write_frac_helper);
-#if defined (CONFIG_PROC_FS)
-
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");
@@ -243,11 +240,11 @@ EXPORT_SYMBOL(lprocfs_seq_release);
/* lprocfs API calls */
-struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
- char *name, void *data,
- struct file_operations *fops)
+struct dentry *ldebugfs_add_simple(struct dentry *root,
+ char *name, void *data,
+ struct file_operations *fops)
{
- struct proc_dir_entry *proc;
+ struct dentry *entry;
umode_t mode = 0;
if (root == NULL || name == NULL || fops == NULL)
@@ -257,64 +254,26 @@ struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
mode = 0444;
if (fops->write)
mode |= 0200;
- proc = proc_create_data(name, mode, root, fops, data);
- if (!proc) {
- CERROR("LprocFS: No memory to create /proc entry %s", name);
- return ERR_PTR(-ENOMEM);
+ entry = debugfs_create_file(name, mode, root, data, fops);
+ if (IS_ERR_OR_NULL(entry)) {
+ CERROR("LprocFS: No memory to create <debugfs> entry %s", name);
+ return entry ?: ERR_PTR(-ENOMEM);
}
- return proc;
-}
-EXPORT_SYMBOL(lprocfs_add_simple);
-
-struct proc_dir_entry *lprocfs_add_symlink(const char *name,
- struct proc_dir_entry *parent, const char *format, ...)
-{
- struct proc_dir_entry *entry;
- char *dest;
- va_list ap;
-
- if (parent == NULL || format == NULL)
- return NULL;
-
- OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
- if (dest == NULL)
- return NULL;
-
- va_start(ap, format);
- vsnprintf(dest, MAX_STRING_SIZE, format, ap);
- va_end(ap);
-
- entry = proc_symlink(name, parent, dest);
- if (entry == NULL)
- CERROR("LprocFS: Could not create symbolic link from %s to %s",
- name, dest);
-
- OBD_FREE(dest, MAX_STRING_SIZE + 1);
return entry;
}
-EXPORT_SYMBOL(lprocfs_add_symlink);
+EXPORT_SYMBOL(ldebugfs_add_simple);
static struct file_operations lprocfs_generic_fops = { };
-/**
- * Add /proc entries.
- *
- * \param root [in] The parent proc entry on which new entry will be added.
- * \param list [in] Array of proc entries to be added.
- * \param data [in] The argument to be passed when entries read/write routines
- * are called through /proc file.
- *
- * \retval 0 on success
- * < 0 on error
- */
-int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
- void *data)
+int ldebugfs_add_vars(struct dentry *parent,
+ struct lprocfs_vars *list,
+ void *data)
{
- if (root == NULL || list == NULL)
+ if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list))
return -EINVAL;
while (list->name != NULL) {
- struct proc_dir_entry *proc;
+ struct dentry *entry;
umode_t mode = 0;
if (list->proc_mode != 0000) {
@@ -325,54 +284,50 @@ int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
if (list->fops->write)
mode |= 0200;
}
- proc = proc_create_data(list->name, mode, root,
- list->fops ?: &lprocfs_generic_fops,
- list->data ?: data);
- if (proc == NULL)
- return -ENOMEM;
+ entry = debugfs_create_file(list->name, mode, parent,
+ list->data ?: data,
+ list->fops ?: &lprocfs_generic_fops
+ );
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
list++;
}
return 0;
}
-EXPORT_SYMBOL(lprocfs_add_vars);
+EXPORT_SYMBOL(ldebugfs_add_vars);
-void lprocfs_remove(struct proc_dir_entry **rooth)
+void ldebugfs_remove(struct dentry **entryp)
{
- proc_remove(*rooth);
- *rooth = NULL;
+ debugfs_remove_recursive(*entryp);
+ *entryp = NULL;
}
-EXPORT_SYMBOL(lprocfs_remove);
+EXPORT_SYMBOL(ldebugfs_remove);
-void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
+struct dentry *ldebugfs_register(const char *name,
+ struct dentry *parent,
+ struct lprocfs_vars *list, void *data)
{
- LASSERT(parent != NULL);
- remove_proc_entry(name, parent);
-}
-EXPORT_SYMBOL(lprocfs_remove_proc_entry);
+ struct dentry *entry;
-struct proc_dir_entry *lprocfs_register(const char *name,
- struct proc_dir_entry *parent,
- struct lprocfs_vars *list, void *data)
-{
- struct proc_dir_entry *entry;
-
- entry = proc_mkdir(name, parent);
- if (entry == NULL) {
- entry = ERR_PTR(-ENOMEM);
+ entry = debugfs_create_dir(name, parent);
+ if (IS_ERR_OR_NULL(entry)) {
+ entry = entry ?: ERR_PTR(-ENOMEM);
goto out;
}
- if (list != NULL) {
- int rc = lprocfs_add_vars(entry, list, data);
+ if (!IS_ERR_OR_NULL(list)) {
+ int rc;
+
+ rc = ldebugfs_add_vars(entry, list, data);
if (rc != 0) {
- lprocfs_remove(&entry);
+ debugfs_remove(entry);
entry = ERR_PTR(rc);
}
}
out:
return entry;
}
-EXPORT_SYMBOL(lprocfs_register);
+EXPORT_SYMBOL(ldebugfs_register);
/* Generic callbacks */
int lprocfs_rd_uint(struct seq_file *m, void *data)
@@ -402,78 +357,37 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer,
}
EXPORT_SYMBOL(lprocfs_wr_uint);
-int lprocfs_rd_u64(struct seq_file *m, void *data)
-{
- seq_printf(m, "%llu\n", *(__u64 *)data);
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_rd_u64);
-
-int lprocfs_rd_atomic(struct seq_file *m, void *data)
-{
- atomic_t *atom = data;
- LASSERT(atom != NULL);
- seq_printf(m, "%d\n", atomic_read(atom));
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_rd_atomic);
-
-int lprocfs_wr_atomic(struct file *file, const char __user *buffer,
- unsigned long count, void *data)
+static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- atomic_t *atm = data;
- int val = 0;
- int rc;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc < 0)
- return rc;
-
- if (val <= 0)
- return -ERANGE;
-
- atomic_set(atm, val);
- return count;
+ return sprintf(buf, "%s\n", obd->obd_uuid.uuid);
}
-EXPORT_SYMBOL(lprocfs_wr_atomic);
+LUSTRE_RO_ATTR(uuid);
-int lprocfs_rd_uuid(struct seq_file *m, void *data)
+static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
-
- LASSERT(obd != NULL);
- seq_printf(m, "%s\n", obd->obd_uuid.uuid);
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_rd_uuid);
-
-int lprocfs_rd_name(struct seq_file *m, void *data)
-{
- struct obd_device *dev = data;
-
- LASSERT(dev != NULL);
- seq_printf(m, "%s\n", dev->obd_name);
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_rd_name);
-
-int lprocfs_rd_blksize(struct seq_file *m, void *data)
-{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%u\n", osfs.os_bsize);
+ return sprintf(buf, "%u\n", osfs.os_bsize);
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_blksize);
+LUSTRE_RO_ATTR(blocksize);
-int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
+static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -485,16 +399,18 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ return sprintf(buf, "%llu\n", result);
}
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_kbytestotal);
+LUSTRE_RO_ATTR(kbytestotal);
-int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
+static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -506,16 +422,18 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ return sprintf(buf, "%llu\n", result);
}
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_kbytesfree);
+LUSTRE_RO_ATTR(kbytesfree);
-int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
+static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -527,49 +445,57 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ return sprintf(buf, "%llu\n", result);
}
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_kbytesavail);
+LUSTRE_RO_ATTR(kbytesavail);
-int lprocfs_rd_filestotal(struct seq_file *m, void *data)
+static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_files);
+ return sprintf(buf, "%llu\n", osfs.os_files);
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_filestotal);
+LUSTRE_RO_ATTR(filestotal);
-int lprocfs_rd_filesfree(struct seq_file *m, void *data)
+static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_ffree);
+ return sprintf(buf, "%llu\n", osfs.os_ffree);
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_filesfree);
+LUSTRE_RO_ATTR(filesfree);
int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
{
struct obd_device *obd = data;
struct obd_import *imp;
char *imp_state_name = NULL;
+ int rc;
LASSERT(obd != NULL);
- LPROCFS_CLIMP_CHECK(obd);
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
+
imp = obd->u.cli.cl_import;
imp_state_name = ptlrpc_import_state_name(imp->imp_state);
seq_printf(m, "%s\t%s%s\n",
@@ -586,10 +512,14 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
{
struct obd_device *obd = data;
struct ptlrpc_connection *conn;
+ int rc;
LASSERT(obd != NULL);
- LPROCFS_CLIMP_CHECK(obd);
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
+
conn = obd->u.cli.cl_import->imp_connection;
if (conn && obd->u.cli.cl_import)
seq_printf(m, "%s\n", conn->c_remote_uuid.uuid);
@@ -665,6 +595,7 @@ static int obd_import_flags2str(struct obd_import *imp, struct seq_file *m)
flag2str(pingable, first);
return 0;
}
+
#undef flags2str
static void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, char *sep)
@@ -687,17 +618,22 @@ static void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, char *sep
int lprocfs_rd_import(struct seq_file *m, void *data)
{
+ char nidstr[LNET_NIDSTR_SIZE];
struct lprocfs_counter ret;
struct lprocfs_counter_header *header;
- struct obd_device *obd = (struct obd_device *)data;
+ struct obd_device *obd = data;
struct obd_import *imp;
struct obd_import_conn *conn;
int j;
int k;
int rw = 0;
+ int rc;
LASSERT(obd != NULL);
- LPROCFS_CLIMP_CHECK(obd);
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
+
imp = obd->u.cli.cl_import;
seq_printf(m,
@@ -724,18 +660,20 @@ int lprocfs_rd_import(struct seq_file *m, void *data)
spin_lock(&imp->imp_lock);
j = 0;
list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
- seq_printf(m, "%s%s", j ? ", " : "",
- libcfs_nid2str(conn->oic_conn->c_peer.nid));
+ libcfs_nid2str_r(conn->oic_conn->c_peer.nid,
+ nidstr, sizeof(nidstr));
+ seq_printf(m, "%s%s", j ? ", " : "", nidstr);
j++;
}
+ libcfs_nid2str_r(imp->imp_connection->c_peer.nid,
+ nidstr, sizeof(nidstr));
seq_printf(m,
"]\n"
" current_connection: %s\n"
" connection_attempts: %u\n"
" generation: %u\n"
" in-progress_invalidations: %u\n",
- imp->imp_connection == NULL ? "<none>" :
- libcfs_nid2str(imp->imp_connection->c_peer.nid),
+ imp->imp_connection == NULL ? "<none>" : nidstr,
imp->imp_conn_cnt,
imp->imp_generation,
atomic_read(&imp->imp_inval_count));
@@ -749,6 +687,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data)
if (ret.lc_count != 0) {
/* first argument to do_div MUST be __u64 */
__u64 sum = ret.lc_sum;
+
do_div(sum, ret.lc_count);
ret.lc_sum = sum;
} else
@@ -795,6 +734,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data)
if (ret.lc_sum > 0 && ret.lc_count > 0) {
/* first argument to do_div MUST be __u64 */
__u64 sum = ret.lc_sum;
+
do_div(sum, ret.lc_count);
ret.lc_sum = sum;
seq_printf(m,
@@ -810,6 +750,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data)
if (ret.lc_sum > 0 && ret.lc_count != 0) {
/* first argument to do_div MUST be __u64 */
__u64 sum = ret.lc_sum;
+
do_div(sum, ret.lc_count);
ret.lc_sum = sum;
seq_printf(m,
@@ -831,12 +772,15 @@ EXPORT_SYMBOL(lprocfs_rd_import);
int lprocfs_rd_state(struct seq_file *m, void *data)
{
- struct obd_device *obd = (struct obd_device *)data;
+ struct obd_device *obd = data;
struct obd_import *imp;
- int j, k;
+ int j, k, rc;
LASSERT(obd != NULL);
- LPROCFS_CLIMP_CHECK(obd);
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
+
imp = obd->u.cli.cl_import;
seq_printf(m, "current_state: %s\n",
@@ -848,9 +792,8 @@ int lprocfs_rd_state(struct seq_file *m, void *data)
&imp->imp_state_hist[(k + j) % IMP_STATE_HIST_LEN];
if (ish->ish_state == 0)
continue;
- seq_printf(m, " - ["CFS_TIME_T", %s]\n",
- ish->ish_time,
- ptlrpc_import_state_name(ish->ish_state));
+ seq_printf(m, " - [%lld, %s]\n", (s64)ish->ish_time,
+ ptlrpc_import_state_name(ish->ish_state));
}
LPROCFS_CLIMP_EXIT(obd);
@@ -861,6 +804,7 @@ EXPORT_SYMBOL(lprocfs_rd_state);
int lprocfs_at_hist_helper(struct seq_file *m, struct adaptive_timeout *at)
{
int i;
+
for (i = 0; i < AT_BINS; i++)
seq_printf(m, "%3u ", at->at_hist[i]);
seq_printf(m, "\n");
@@ -871,30 +815,33 @@ EXPORT_SYMBOL(lprocfs_at_hist_helper);
/* See also ptlrpc_lprocfs_rd_timeouts */
int lprocfs_rd_timeouts(struct seq_file *m, void *data)
{
- struct obd_device *obd = (struct obd_device *)data;
+ struct obd_device *obd = data;
struct obd_import *imp;
unsigned int cur, worst;
- time_t now, worstt;
+ time64_t now, worstt;
struct dhms ts;
- int i;
+ int i, rc;
LASSERT(obd != NULL);
- LPROCFS_CLIMP_CHECK(obd);
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
+
imp = obd->u.cli.cl_import;
- now = get_seconds();
+ now = ktime_get_real_seconds();
/* Some network health info for kicks */
s2dhms(&ts, now - imp->imp_last_reply_time);
- seq_printf(m, "%-10s : %ld, "DHMS_FMT" ago\n",
- "last reply", imp->imp_last_reply_time, DHMS_VARS(&ts));
+ seq_printf(m, "%-10s : %lld, " DHMS_FMT " ago\n",
+ "last reply", (s64)imp->imp_last_reply_time, DHMS_VARS(&ts));
cur = at_get(&imp->imp_at.iat_net_latency);
worst = imp->imp_at.iat_net_latency.at_worst_ever;
worstt = imp->imp_at.iat_net_latency.at_worst_time;
s2dhms(&ts, now - worstt);
- seq_printf(m, "%-10s : cur %3u worst %3u (at %ld, "DHMS_FMT" ago) ",
- "network", cur, worst, worstt, DHMS_VARS(&ts));
+ seq_printf(m, "%-10s : cur %3u worst %3u (at %lld, " DHMS_FMT " ago) ",
+ "network", cur, worst, (s64)worstt, DHMS_VARS(&ts));
lprocfs_at_hist_helper(m, &imp->imp_at.iat_net_latency);
for (i = 0; i < IMP_AT_MAX_PORTALS; i++) {
@@ -904,9 +851,9 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data)
worst = imp->imp_at.iat_service_estimate[i].at_worst_ever;
worstt = imp->imp_at.iat_service_estimate[i].at_worst_time;
s2dhms(&ts, now - worstt);
- seq_printf(m, "portal %-2d : cur %3u worst %3u (at %ld, "
- DHMS_FMT" ago) ", imp->imp_at.iat_portal[i],
- cur, worst, worstt, DHMS_VARS(&ts));
+ seq_printf(m, "portal %-2d : cur %3u worst %3u (at %lld, "
+ DHMS_FMT " ago) ", imp->imp_at.iat_portal[i],
+ cur, worst, (s64)worstt, DHMS_VARS(&ts));
lprocfs_at_hist_helper(m, &imp->imp_at.iat_service_estimate[i]);
}
@@ -919,8 +866,12 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
{
struct obd_device *obd = data;
__u64 flags;
+ int rc;
+
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
- LPROCFS_CLIMP_CHECK(obd);
flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags;
seq_printf(m, "flags=%#llx\n", flags);
obd_connect_seq_flags2str(m, flags, "\n");
@@ -930,43 +881,62 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
}
EXPORT_SYMBOL(lprocfs_rd_connect_flags);
-int lprocfs_rd_num_exports(struct seq_file *m, void *data)
-{
- struct obd_device *obd = data;
-
- LASSERT(obd != NULL);
- seq_printf(m, "%u\n", obd->obd_num_exports);
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_rd_num_exports);
+static struct attribute *obd_def_attrs[] = {
+ &lustre_attr_blocksize.attr,
+ &lustre_attr_kbytestotal.attr,
+ &lustre_attr_kbytesfree.attr,
+ &lustre_attr_kbytesavail.attr,
+ &lustre_attr_filestotal.attr,
+ &lustre_attr_filesfree.attr,
+ &lustre_attr_uuid.attr,
+ NULL,
+};
-int lprocfs_rd_numrefs(struct seq_file *m, void *data)
+static void obd_sysfs_release(struct kobject *kobj)
{
- struct obd_type *class = (struct obd_type *) data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- LASSERT(class != NULL);
- seq_printf(m, "%d\n", class->typ_refcnt);
- return 0;
+ complete(&obd->obd_kobj_unregister);
}
-EXPORT_SYMBOL(lprocfs_rd_numrefs);
-int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list)
+static struct kobj_type obd_ktype = {
+ .default_attrs = obd_def_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = obd_sysfs_release,
+};
+
+int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
+ struct attribute_group *attrs)
{
int rc = 0;
- LASSERT(obd != NULL);
- LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(obd->obd_type->typ_procroot != NULL);
-
- obd->obd_proc_entry = lprocfs_register(obd->obd_name,
- obd->obd_type->typ_procroot,
- list, obd);
- if (IS_ERR(obd->obd_proc_entry)) {
- rc = PTR_ERR(obd->obd_proc_entry);
+ init_completion(&obd->obd_kobj_unregister);
+ rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype,
+ obd->obd_type->typ_kobj,
+ "%s", obd->obd_name);
+ if (rc)
+ return rc;
+
+ if (attrs) {
+ rc = sysfs_create_group(&obd->obd_kobj, attrs);
+ if (rc) {
+ kobject_put(&obd->obd_kobj);
+ return rc;
+ }
+ }
+
+ obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
+ obd->obd_type->typ_debugfs_entry,
+ list, obd);
+ if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
+ rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
+ : -ENOMEM;
CERROR("error %d setting up lprocfs for %s\n",
rc, obd->obd_name);
- obd->obd_proc_entry = NULL;
+ obd->obd_debugfs_entry = NULL;
}
+
return rc;
}
EXPORT_SYMBOL(lprocfs_obd_setup);
@@ -975,58 +945,16 @@ int lprocfs_obd_cleanup(struct obd_device *obd)
{
if (!obd)
return -EINVAL;
- if (obd->obd_proc_exports_entry) {
- /* Should be no exports left */
- lprocfs_remove(&obd->obd_proc_exports_entry);
- obd->obd_proc_exports_entry = NULL;
- }
- if (obd->obd_proc_entry) {
- lprocfs_remove(&obd->obd_proc_entry);
- obd->obd_proc_entry = NULL;
- }
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_obd_cleanup);
-
-static void lprocfs_free_client_stats(struct nid_stat *client_stat)
-{
- CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
- client_stat->nid_proc, client_stat->nid_stats);
- LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
- "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
- atomic_read(&client_stat->nid_exp_ref_count));
+ if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry))
+ ldebugfs_remove(&obd->obd_debugfs_entry);
- if (client_stat->nid_proc)
- lprocfs_remove(&client_stat->nid_proc);
+ kobject_put(&obd->obd_kobj);
+ wait_for_completion(&obd->obd_kobj_unregister);
- if (client_stat->nid_stats)
- lprocfs_free_stats(&client_stat->nid_stats);
-
- if (client_stat->nid_ldlm_stats)
- lprocfs_free_stats(&client_stat->nid_ldlm_stats);
-
- OBD_FREE_PTR(client_stat);
- return;
-
-}
-
-void lprocfs_free_per_client_stats(struct obd_device *obd)
-{
- struct cfs_hash *hash = obd->obd_nid_stats_hash;
- struct nid_stat *stat;
-
- /* we need extra list - because hash_exit called to early */
- /* not need locking because all clients is died */
- while (!list_empty(&obd->obd_nid_stats)) {
- stat = list_entry(obd->obd_nid_stats.next,
- struct nid_stat, nid_list);
- list_del_init(&stat->nid_list);
- cfs_hash_del(hash, &stat->nid, &stat->nid_hash);
- lprocfs_free_client_stats(stat);
- }
+ return 0;
}
-EXPORT_SYMBOL(lprocfs_free_per_client_stats);
+EXPORT_SYMBOL(lprocfs_obd_cleanup);
int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid)
{
@@ -1107,7 +1035,7 @@ struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num,
goto fail;
stats->ls_biggest_alloc_num = 1;
} else if ((flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0) {
- /* alloc all percpu data, currently only obd_memory use this */
+ /* alloc all percpu data */
for (i = 0; i < num_entry; ++i)
if (lprocfs_stats_alloc_one(stats, i) < 0)
goto fail;
@@ -1215,11 +1143,12 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
int idx = *(loff_t *)v;
if (idx == 0) {
- struct timeval now;
- do_gettimeofday(&now);
- seq_printf(p, "%-25s %lu.%lu secs.usecs\n",
+ struct timespec64 now;
+
+ ktime_get_real_ts64(&now);
+ seq_printf(p, "%-25s %llu.%9lu secs.usecs\n",
"snapshot_time",
- now.tv_sec, (unsigned long)now.tv_usec);
+ (s64)now.tv_sec, (unsigned long)now.tv_nsec);
}
hdr = &stats->ls_cnt_header[idx];
@@ -1257,8 +1186,10 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
rc = seq_open(file, &lprocfs_stats_seq_sops);
if (rc)
return rc;
+
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
+
return 0;
}
@@ -1271,20 +1202,21 @@ struct file_operations lprocfs_stats_seq_fops = {
.release = lprocfs_seq_release,
};
-int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
+int ldebugfs_register_stats(struct dentry *parent, const char *name,
struct lprocfs_stats *stats)
{
- struct proc_dir_entry *entry;
- LASSERT(root != NULL);
+ struct dentry *entry;
- entry = proc_create_data(name, 0644, root,
- &lprocfs_stats_seq_fops, stats);
- if (entry == NULL)
- return -ENOMEM;
+ LASSERT(!IS_ERR_OR_NULL(parent));
+
+ entry = debugfs_create_file(name, 0644, parent, stats,
+ &lprocfs_stats_seq_fops);
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
return 0;
}
-EXPORT_SYMBOL(lprocfs_register_stats);
+EXPORT_SYMBOL(ldebugfs_register_stats);
void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
unsigned conf, const char *name, const char *units)
@@ -1322,462 +1254,8 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
}
EXPORT_SYMBOL(lprocfs_counter_init);
-#define LPROCFS_OBD_OP_INIT(base, stats, op) \
-do { \
- unsigned int coffset = base + OBD_COUNTER_OFFSET(op); \
- LASSERT(coffset < stats->ls_num); \
- lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \
-} while (0)
-
-void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
-{
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, iocontrol);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_info);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, set_info_async);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, attach);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, detach);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, setup);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, precleanup);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, cleanup);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, process_config);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, postrecov);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, add_conn);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, del_conn);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, connect);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, reconnect);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, disconnect);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_init);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_fini);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_alloc);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs_async);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, packmd);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, unpackmd);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, preallocate);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, create);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, setattr);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, setattr_async);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr_async);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, adjust_kms);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, find_cbdata);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, notify);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, health_check);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_uuid);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, quotacheck);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, quotactl);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_new);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_del);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, getref);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, putref);
-}
-EXPORT_SYMBOL(lprocfs_init_ops_stats);
-
-int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
-{
- struct lprocfs_stats *stats;
- unsigned int num_stats;
- int rc, i;
-
- LASSERT(obd->obd_stats == NULL);
- LASSERT(obd->obd_proc_entry != NULL);
- LASSERT(obd->obd_cntr_base == 0);
-
- num_stats = ((int)sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) +
- num_private_stats - 1 /* o_owner */;
- stats = lprocfs_alloc_stats(num_stats, 0);
- if (stats == NULL)
- return -ENOMEM;
-
- lprocfs_init_ops_stats(num_private_stats, stats);
-
- for (i = num_private_stats; i < num_stats; i++) {
- /* If this LBUGs, it is likely that an obd
- * operation was added to struct obd_ops in
- * <obd.h>, and that the corresponding line item
- * LPROCFS_OBD_OP_INIT(.., .., opname)
- * is missing from the list above. */
- LASSERTF(stats->ls_cnt_header[i].lc_name != NULL,
- "Missing obd_stat initializer obd_op operation at offset %d.\n",
- i - num_private_stats);
- }
- rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
- if (rc < 0) {
- lprocfs_free_stats(&stats);
- } else {
- obd->obd_stats = stats;
- obd->obd_cntr_base = num_private_stats;
- }
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
-
-void lprocfs_free_obd_stats(struct obd_device *obd)
-{
- if (obd->obd_stats)
- lprocfs_free_stats(&obd->obd_stats);
-}
-EXPORT_SYMBOL(lprocfs_free_obd_stats);
-
-#define LPROCFS_MD_OP_INIT(base, stats, op) \
-do { \
- unsigned int coffset = base + MD_COUNTER_OFFSET(op); \
- LASSERT(coffset < stats->ls_num); \
- lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \
-} while (0)
-
-void lprocfs_init_mps_stats(int num_private_stats, struct lprocfs_stats *stats)
-{
- LPROCFS_MD_OP_INIT(num_private_stats, stats, getstatus);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, null_inode);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, find_cbdata);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, close);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, create);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, done_writing);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, enqueue);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr_name);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_lock);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, link);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, rename);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, is_subdir);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, setattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, sync);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, readpage);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, unlink);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, setxattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, getxattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, init_ea_size);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, get_lustre_md);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, free_lustre_md);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, set_open_replay_data);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, clear_open_replay_data);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, set_lock_data);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, lock_match);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, cancel_unused);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, renew_capa);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, unpack_capa);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, get_remote_perm);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_getattr_async);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, revalidate_lock);
-}
-EXPORT_SYMBOL(lprocfs_init_mps_stats);
-
-int lprocfs_alloc_md_stats(struct obd_device *obd,
- unsigned num_private_stats)
-{
- struct lprocfs_stats *stats;
- unsigned int num_stats;
- int rc, i;
-
- LASSERT(obd->md_stats == NULL);
- LASSERT(obd->obd_proc_entry != NULL);
- LASSERT(obd->md_cntr_base == 0);
-
- num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) +
- num_private_stats;
- stats = lprocfs_alloc_stats(num_stats, 0);
- if (stats == NULL)
- return -ENOMEM;
-
- lprocfs_init_mps_stats(num_private_stats, stats);
-
- for (i = num_private_stats; i < num_stats; i++) {
- if (stats->ls_cnt_header[i].lc_name == NULL) {
- CERROR("Missing md_stat initializer md_op operation at offset %d. Aborting.\n",
- i - num_private_stats);
- LBUG();
- }
- }
- rc = lprocfs_register_stats(obd->obd_proc_entry, "md_stats", stats);
- if (rc < 0) {
- lprocfs_free_stats(&stats);
- } else {
- obd->md_stats = stats;
- obd->md_cntr_base = num_private_stats;
- }
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_alloc_md_stats);
-
-void lprocfs_free_md_stats(struct obd_device *obd)
-{
- struct lprocfs_stats *stats = obd->md_stats;
-
- if (stats != NULL) {
- obd->md_stats = NULL;
- obd->md_cntr_base = 0;
- lprocfs_free_stats(&stats);
- }
-}
-EXPORT_SYMBOL(lprocfs_free_md_stats);
-
-void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
-{
- lprocfs_counter_init(ldlm_stats,
- LDLM_ENQUEUE - LDLM_FIRST_OPC,
- 0, "ldlm_enqueue", "reqs");
- lprocfs_counter_init(ldlm_stats,
- LDLM_CONVERT - LDLM_FIRST_OPC,
- 0, "ldlm_convert", "reqs");
- lprocfs_counter_init(ldlm_stats,
- LDLM_CANCEL - LDLM_FIRST_OPC,
- 0, "ldlm_cancel", "reqs");
- lprocfs_counter_init(ldlm_stats,
- LDLM_BL_CALLBACK - LDLM_FIRST_OPC,
- 0, "ldlm_bl_callback", "reqs");
- lprocfs_counter_init(ldlm_stats,
- LDLM_CP_CALLBACK - LDLM_FIRST_OPC,
- 0, "ldlm_cp_callback", "reqs");
- lprocfs_counter_init(ldlm_stats,
- LDLM_GL_CALLBACK - LDLM_FIRST_OPC,
- 0, "ldlm_gl_callback", "reqs");
-}
-EXPORT_SYMBOL(lprocfs_init_ldlm_stats);
-
-int lprocfs_exp_print_uuid(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *hnode, void *data)
-
-{
- struct obd_export *exp = cfs_hash_object(hs, hnode);
- struct seq_file *m = (struct seq_file *)data;
-
- if (exp->exp_nid_stats)
- seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid));
-
- return 0;
-}
-
-static int
-lproc_exp_uuid_seq_show(struct seq_file *m, void *unused)
-{
- struct nid_stat *stats = (struct nid_stat *)m->private;
- struct obd_device *obd = stats->nid_obd;
-
- cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
- lprocfs_exp_print_uuid, m);
- return 0;
-}
-
-LPROC_SEQ_FOPS_RO(lproc_exp_uuid);
-
-struct exp_hash_cb_data {
- struct seq_file *m;
- bool first;
-};
-
-int lprocfs_exp_print_hash(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *hnode, void *cb_data)
-
-{
- struct exp_hash_cb_data *data = (struct exp_hash_cb_data *)cb_data;
- struct obd_export *exp = cfs_hash_object(hs, hnode);
-
- if (exp->exp_lock_hash != NULL) {
- if (data->first) {
- cfs_hash_debug_header(data->m);
- data->first = false;
- }
- cfs_hash_debug_str(hs, data->m);
- }
-
- return 0;
-}
-
-static int
-lproc_exp_hash_seq_show(struct seq_file *m, void *unused)
-{
- struct nid_stat *stats = (struct nid_stat *)m->private;
- struct obd_device *obd = stats->nid_obd;
- struct exp_hash_cb_data cb_data = {
- .m = m,
- .first = true
- };
-
- cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
- lprocfs_exp_print_hash, &cb_data);
- return 0;
-}
-
-LPROC_SEQ_FOPS_RO(lproc_exp_hash);
-
-int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
-{
- seq_printf(m, "%s\n",
- "Write into this file to clear all nid stats and stale nid entries");
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_nid_stats_clear_read);
-
-static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
-{
- struct nid_stat *stat = obj;
-
- CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
- if (atomic_read(&stat->nid_exp_ref_count) == 1) {
- /* object has only hash references. */
- spin_lock(&stat->nid_obd->obd_nid_lock);
- list_move(&stat->nid_list, data);
- spin_unlock(&stat->nid_obd->obd_nid_lock);
- return 1;
- }
- /* we has reference to object - only clear data*/
- if (stat->nid_stats)
- lprocfs_clear_stats(stat->nid_stats);
-
- return 0;
-}
-
-int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- struct nid_stat *client_stat;
- LIST_HEAD(free_list);
-
- cfs_hash_cond_del(obd->obd_nid_stats_hash,
- lprocfs_nid_stats_clear_write_cb, &free_list);
-
- while (!list_empty(&free_list)) {
- client_stat = list_entry(free_list.next, struct nid_stat,
- nid_list);
- list_del_init(&client_stat->nid_list);
- lprocfs_free_client_stats(client_stat);
- }
-
- return count;
-}
-EXPORT_SYMBOL(lprocfs_nid_stats_clear_write);
-
-int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
-{
- struct nid_stat *new_stat, *old_stat;
- struct obd_device *obd = NULL;
- struct proc_dir_entry *entry;
- char *buffer = NULL;
- int rc = 0;
-
- *newnid = 0;
-
- if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
- !exp->exp_obd->obd_nid_stats_hash)
- return -EINVAL;
-
- /* not test against zero because eric say:
- * You may only test nid against another nid, or LNET_NID_ANY.
- * Anything else is nonsense.*/
- if (!nid || *nid == LNET_NID_ANY)
- return 0;
-
- obd = exp->exp_obd;
-
- CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
-
- OBD_ALLOC_PTR(new_stat);
- if (new_stat == NULL)
- return -ENOMEM;
-
- new_stat->nid = *nid;
- new_stat->nid_obd = exp->exp_obd;
- /* we need set default refcount to 1 to balance obd_disconnect */
- atomic_set(&new_stat->nid_exp_ref_count, 1);
-
- old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
- nid, &new_stat->nid_hash);
- CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
- old_stat, libcfs_nid2str(*nid),
- atomic_read(&new_stat->nid_exp_ref_count));
-
- /* We need to release old stats because lprocfs_exp_cleanup() hasn't
- * been and will never be called. */
- if (exp->exp_nid_stats) {
- nidstat_putref(exp->exp_nid_stats);
- exp->exp_nid_stats = NULL;
- }
-
- /* Return -EALREADY here so that we know that the /proc
- * entry already has been created */
- if (old_stat != new_stat) {
- exp->exp_nid_stats = old_stat;
- rc = -EALREADY;
- goto destroy_new;
- }
- /* not found - create */
- OBD_ALLOC(buffer, LNET_NIDSTR_SIZE);
- if (buffer == NULL) {
- rc = -ENOMEM;
- goto destroy_new;
- }
-
- memcpy(buffer, libcfs_nid2str(*nid), LNET_NIDSTR_SIZE);
- new_stat->nid_proc = lprocfs_register(buffer,
- obd->obd_proc_exports_entry,
- NULL, NULL);
- OBD_FREE(buffer, LNET_NIDSTR_SIZE);
-
- if (IS_ERR(new_stat->nid_proc)) {
- CERROR("Error making export directory for nid %s\n",
- libcfs_nid2str(*nid));
- rc = PTR_ERR(new_stat->nid_proc);
- new_stat->nid_proc = NULL;
- goto destroy_new_ns;
- }
-
- entry = lprocfs_add_simple(new_stat->nid_proc, "uuid",
- new_stat, &lproc_exp_uuid_fops);
- if (IS_ERR(entry)) {
- CWARN("Error adding the NID stats file\n");
- rc = PTR_ERR(entry);
- goto destroy_new_ns;
- }
-
- entry = lprocfs_add_simple(new_stat->nid_proc, "hash",
- new_stat, &lproc_exp_hash_fops);
- if (IS_ERR(entry)) {
- CWARN("Error adding the hash file\n");
- rc = PTR_ERR(entry);
- goto destroy_new_ns;
- }
-
- exp->exp_nid_stats = new_stat;
- *newnid = 1;
- /* protect competitive add to list, not need locking on destroy */
- spin_lock(&obd->obd_nid_lock);
- list_add(&new_stat->nid_list, &obd->obd_nid_stats);
- spin_unlock(&obd->obd_nid_lock);
-
- return rc;
-
-destroy_new_ns:
- if (new_stat->nid_proc != NULL)
- lprocfs_remove(&new_stat->nid_proc);
- cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
-
-destroy_new:
- nidstat_putref(new_stat);
- OBD_FREE_PTR(new_stat);
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_exp_setup);
-
int lprocfs_exp_cleanup(struct obd_export *exp)
{
- struct nid_stat *stat = exp->exp_nid_stats;
-
- if (!stat || !exp->exp_obd)
- return 0;
-
- nidstat_putref(exp->exp_nid_stats);
- exp->exp_nid_stats = NULL;
-
return 0;
}
EXPORT_SYMBOL(lprocfs_exp_cleanup);
@@ -1831,31 +1309,6 @@ int lprocfs_write_helper(const char __user *buffer, unsigned long count,
}
EXPORT_SYMBOL(lprocfs_write_helper);
-int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult)
-{
- long decimal_val, frac_val;
-
- decimal_val = val / mult;
- seq_printf(m, "%ld", decimal_val);
- frac_val = val % mult;
-
- if (frac_val > 0) {
- frac_val *= 100;
- frac_val /= mult;
- }
- if (frac_val > 0) {
- /* Three cases: x0, xx, 0x */
- if ((frac_val % 10) != 0)
- seq_printf(m, ".%ld", frac_val);
- else
- seq_printf(m, ".%ld", frac_val / 10);
- }
-
- seq_printf(m, "\n");
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_seq_read_frac_helper);
-
int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count,
__u64 *val)
{
@@ -1890,6 +1343,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
if (*end == '.') {
int i;
+
pbuf = end + 1;
/* need to limit frac_d to a __u32 */
@@ -1972,35 +1426,35 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
}
EXPORT_SYMBOL(lprocfs_find_named_value);
-int lprocfs_seq_create(struct proc_dir_entry *parent,
+int ldebugfs_seq_create(struct dentry *parent,
const char *name,
umode_t mode,
const struct file_operations *seq_fops,
void *data)
{
- struct proc_dir_entry *entry;
+ struct dentry *entry;
/* Disallow secretly (un)writable entries. */
LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0));
- entry = proc_create_data(name, mode, parent, seq_fops, data);
- if (entry == NULL)
- return -ENOMEM;
+ entry = debugfs_create_file(name, mode, parent, data, seq_fops);
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
return 0;
}
-EXPORT_SYMBOL(lprocfs_seq_create);
+EXPORT_SYMBOL(ldebugfs_seq_create);
-int lprocfs_obd_seq_create(struct obd_device *dev,
- const char *name,
- umode_t mode,
- const struct file_operations *seq_fops,
- void *data)
+int ldebugfs_obd_seq_create(struct obd_device *dev,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
+ void *data)
{
- return lprocfs_seq_create(dev->obd_proc_entry, name,
- mode, seq_fops, data);
+ return ldebugfs_seq_create(dev->obd_debugfs_entry, name,
+ mode, seq_fops, data);
}
-EXPORT_SYMBOL(lprocfs_obd_seq_create);
+EXPORT_SYMBOL(ldebugfs_obd_seq_create);
void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
{
@@ -2043,17 +1497,24 @@ void lprocfs_oh_clear(struct obd_histogram *oh)
}
EXPORT_SYMBOL(lprocfs_oh_clear);
-int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data)
+static ssize_t lustre_attr_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *dev = data;
- struct client_obd *cli = &dev->u.cli;
+ struct lustre_attr *a = container_of(attr, struct lustre_attr, attr);
+
+ return a->show ? a->show(kobj, attr, buf) : 0;
+}
- client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
- client_obd_list_unlock(&cli->cl_loi_list_lock);
+static ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len)
+{
+ struct lustre_attr *a = container_of(attr, struct lustre_attr, attr);
- return 0;
+ return a->store ? a->store(kobj, attr, buf, len) : len;
}
-EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc);
-#endif
+const struct sysfs_ops lustre_sysfs_ops = {
+ .show = lustre_attr_show,
+ .store = lustre_attr_store,
+};
+EXPORT_SYMBOL_GPL(lustre_sysfs_ops);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/lu_object.c b/kernel/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 20c077995..0193608a9 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -59,6 +59,7 @@
#include <linux/list.h>
static void lu_object_free(const struct lu_env *env, struct lu_object *o);
+static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx);
/**
* Decrease reference counter on object. If last reference is freed, return
@@ -113,8 +114,6 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
return;
}
- LASSERT(bkt->lsb_busy > 0);
- bkt->lsb_busy--;
/*
* When last reference is released, iterate over object
* layers, and notify them that object is no longer busy.
@@ -127,6 +126,10 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
if (!lu_object_is_dying(top)) {
LASSERT(list_empty(&top->loh_lru));
list_add_tail(&top->loh_lru, &bkt->lsb_lru);
+ bkt->lsb_lru_len++;
+ lprocfs_counter_incr(site->ls_stats, LU_SS_LRU_LEN);
+ CDEBUG(D_INODE, "Add %p to site lru. hash: %p, bkt: %p, lru_len: %ld\n",
+ o, site->ls_obj_hash, bkt, bkt->lsb_lru_len);
cfs_hash_bd_unlock(site->ls_obj_hash, &bd, 1);
return;
}
@@ -154,17 +157,6 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o)
EXPORT_SYMBOL(lu_object_put);
/**
- * Put object and don't keep in cache. This is temporary solution for
- * multi-site objects when its layering is not constant.
- */
-void lu_object_put_nocache(const struct lu_env *env, struct lu_object *o)
-{
- set_bit(LU_OBJECT_HEARD_BANSHEE, &o->lo_header->loh_flags);
- return lu_object_put(env, o);
-}
-EXPORT_SYMBOL(lu_object_put_nocache);
-
-/**
* Kill the object and take it out of LRU cache.
* Currently used by client code for layout change.
*/
@@ -175,11 +167,19 @@ void lu_object_unhash(const struct lu_env *env, struct lu_object *o)
top = o->lo_header;
set_bit(LU_OBJECT_HEARD_BANSHEE, &top->loh_flags);
if (!test_and_set_bit(LU_OBJECT_UNHASHED, &top->loh_flags)) {
- struct cfs_hash *obj_hash = o->lo_dev->ld_site->ls_obj_hash;
+ struct lu_site *site = o->lo_dev->ld_site;
+ struct cfs_hash *obj_hash = site->ls_obj_hash;
struct cfs_hash_bd bd;
cfs_hash_bd_get_and_lock(obj_hash, &top->loh_fid, &bd, 1);
- list_del_init(&top->loh_lru);
+ if (!list_empty(&top->loh_lru)) {
+ struct lu_site_bkt_data *bkt;
+
+ list_del_init(&top->loh_lru);
+ bkt = cfs_hash_bd_extra_get(obj_hash, &bd);
+ bkt->lsb_lru_len--;
+ lprocfs_counter_decr(site->ls_stats, LU_SS_LRU_LEN);
+ }
cfs_hash_bd_del_locked(obj_hash, &bd, &top->loh_hash);
cfs_hash_bd_unlock(obj_hash, &bd, 1);
}
@@ -349,6 +349,8 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr)
cfs_hash_bd_del_locked(s->ls_obj_hash,
&bd2, &h->loh_hash);
list_move(&h->loh_lru, &dispose);
+ bkt->lsb_lru_len--;
+ lprocfs_counter_decr(s->ls_stats, LU_SS_LRU_LEN);
if (did_sth == 0)
did_sth = 1;
@@ -427,7 +429,7 @@ LU_KEY_INIT_FINI(lu_global, struct lu_cdebug_data);
* Key, holding temporary buffer. This key is registered very early by
* lu_global_init().
*/
-struct lu_context_key lu_global_key = {
+static struct lu_context_key lu_global_key = {
.lct_tags = LCT_MD_THREAD | LCT_DT_THREAD |
LCT_MG_THREAD | LCT_CL_THREAD | LCT_LOCAL,
.lct_init = lu_global_key_init,
@@ -516,23 +518,6 @@ void lu_object_print(const struct lu_env *env, void *cookie,
}
EXPORT_SYMBOL(lu_object_print);
-/**
- * Check object consistency.
- */
-int lu_object_invariant(const struct lu_object *o)
-{
- struct lu_object_header *top;
-
- top = o->lo_header;
- list_for_each_entry(o, &top->loh_layers, lo_linkage) {
- if (o->lo_ops->loo_object_invariant != NULL &&
- !o->lo_ops->loo_object_invariant(o))
- return 0;
- }
- return 1;
-}
-EXPORT_SYMBOL(lu_object_invariant);
-
static struct lu_object *htable_lookup(struct lu_site *s,
struct cfs_hash_bd *bd,
const struct lu_fid *f,
@@ -561,7 +546,11 @@ static struct lu_object *htable_lookup(struct lu_site *s,
if (likely(!lu_object_is_dying(h))) {
cfs_hash_get(s->ls_obj_hash, hnode);
lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
- list_del_init(&h->loh_lru);
+ if (!list_empty(&h->loh_lru)) {
+ list_del_init(&h->loh_lru);
+ bkt->lsb_lru_len--;
+ lprocfs_counter_decr(s->ls_stats, LU_SS_LRU_LEN);
+ }
return lu_object_top(h);
}
@@ -583,13 +572,13 @@ static struct lu_object *htable_lookup(struct lu_site *s,
* return it. Otherwise, create new object, insert it into cache and return
* it. In any case, additional reference is acquired on the returned object.
*/
-struct lu_object *lu_object_find(const struct lu_env *env,
- struct lu_device *dev, const struct lu_fid *f,
- const struct lu_object_conf *conf)
+static struct lu_object *lu_object_find(const struct lu_env *env,
+ struct lu_device *dev,
+ const struct lu_fid *f,
+ const struct lu_object_conf *conf)
{
return lu_object_find_at(env, dev->ld_site->ls_top_dev, f, conf);
}
-EXPORT_SYMBOL(lu_object_find);
static struct lu_object *lu_object_new(const struct lu_env *env,
struct lu_device *dev,
@@ -599,17 +588,14 @@ static struct lu_object *lu_object_new(const struct lu_env *env,
struct lu_object *o;
struct cfs_hash *hs;
struct cfs_hash_bd bd;
- struct lu_site_bkt_data *bkt;
o = lu_object_alloc(env, dev, f, conf);
- if (unlikely(IS_ERR(o)))
+ if (IS_ERR(o))
return o;
hs = dev->ld_site->ls_obj_hash;
cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1);
- bkt = cfs_hash_bd_extra_get(hs, &bd);
cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
- bkt->lsb_busy++;
cfs_hash_bd_unlock(hs, &bd, 1);
return o;
}
@@ -666,7 +652,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
* operations, including fld queries, inode loading, etc.
*/
o = lu_object_alloc(env, dev, f, conf);
- if (unlikely(IS_ERR(o)))
+ if (IS_ERR(o))
return o;
LASSERT(lu_fid_eq(lu_object_fid(o), f));
@@ -674,12 +660,8 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
cfs_hash_bd_lock(hs, &bd, 1);
shadow = htable_lookup(s, &bd, f, waiter, &version);
- if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
- struct lu_site_bkt_data *bkt;
-
- bkt = cfs_hash_bd_extra_get(hs, &bd);
+ if (likely(PTR_ERR(shadow) == -ENOENT)) {
cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
- bkt->lsb_busy++;
cfs_hash_bd_unlock(hs, &bd, 1);
return o;
}
@@ -926,14 +908,7 @@ static void lu_obj_hop_get(struct cfs_hash *hs, struct hlist_node *hnode)
struct lu_object_header *h;
h = hlist_entry(hnode, struct lu_object_header, loh_hash);
- if (atomic_add_return(1, &h->loh_ref) == 1) {
- struct lu_site_bkt_data *bkt;
- struct cfs_hash_bd bd;
-
- cfs_hash_bd_get(hs, &h->loh_fid, &bd);
- bkt = cfs_hash_bd_extra_get(hs, &bd);
- bkt->lsb_busy++;
- }
+ atomic_inc(&h->loh_ref);
}
static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
@@ -941,31 +916,22 @@ static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
LBUG(); /* we should never called it */
}
-cfs_hash_ops_t lu_site_hash_ops = {
+struct cfs_hash_ops lu_site_hash_ops = {
.hs_hash = lu_obj_hop_hash,
- .hs_key = lu_obj_hop_key,
+ .hs_key = lu_obj_hop_key,
.hs_keycmp = lu_obj_hop_keycmp,
.hs_object = lu_obj_hop_object,
- .hs_get = lu_obj_hop_get,
+ .hs_get = lu_obj_hop_get,
.hs_put_locked = lu_obj_hop_put_locked,
};
-void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d)
+static void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d)
{
spin_lock(&s->ls_ld_lock);
if (list_empty(&d->ld_linkage))
list_add(&d->ld_linkage, &s->ls_ld_linkage);
spin_unlock(&s->ls_ld_lock);
}
-EXPORT_SYMBOL(lu_dev_add_linkage);
-
-void lu_dev_del_linkage(struct lu_site *s, struct lu_device *d)
-{
- spin_lock(&s->ls_ld_lock);
- list_del_init(&d->ld_linkage);
- spin_unlock(&s->ls_ld_lock);
-}
-EXPORT_SYMBOL(lu_dev_del_linkage);
/**
* Initialize site \a s, with \a d as the top level device.
@@ -1034,6 +1000,12 @@ int lu_site_init(struct lu_site *s, struct lu_device *top)
0, "cache_death_race", "cache_death_race");
lprocfs_counter_init(s->ls_stats, LU_SS_LRU_PURGED,
0, "lru_purged", "lru_purged");
+ /*
+ * Unlike other counters, lru_len can be decremented so
+ * need lc_sum instead of just lc_count
+ */
+ lprocfs_counter_init(s->ls_stats, LU_SS_LRU_LEN,
+ LPROCFS_CNTR_AVGMINMAX, "lru_len", "lru_len");
INIT_LIST_HEAD(&s->ls_linkage);
s->ls_top_dev = top;
@@ -1082,6 +1054,7 @@ EXPORT_SYMBOL(lu_site_fini);
int lu_site_init_finish(struct lu_site *s)
{
int result;
+
mutex_lock(&lu_sites_guard);
result = lu_context_refill(&lu_shrink_env.le_ctx);
if (result == 0)
@@ -1252,8 +1225,6 @@ struct lu_object *lu_object_locate(struct lu_object_header *h,
}
EXPORT_SYMBOL(lu_object_locate);
-
-
/**
* Finalize and free devices in the device stack.
*
@@ -1532,7 +1503,7 @@ static void keys_fini(struct lu_context *ctx)
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i)
key_fini(ctx, i);
- OBD_FREE(ctx->lc_value, ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0]));
+ kfree(ctx->lc_value);
ctx->lc_value = NULL;
}
@@ -1558,7 +1529,7 @@ static int keys_fill(struct lu_context *ctx)
LINVRNT(key->lct_index == i);
value = key->lct_init(ctx, key);
- if (unlikely(IS_ERR(value)))
+ if (IS_ERR(value))
return PTR_ERR(value);
if (!(ctx->lc_tags & LCT_NOREF))
@@ -1581,8 +1552,8 @@ static int keys_fill(struct lu_context *ctx)
static int keys_init(struct lu_context *ctx)
{
- OBD_ALLOC(ctx->lc_value,
- ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0]));
+ ctx->lc_value = kcalloc(ARRAY_SIZE(lu_keys), sizeof(ctx->lc_value[0]),
+ GFP_NOFS);
if (likely(ctx->lc_value != NULL))
return keys_fill(ctx);
@@ -1689,44 +1660,8 @@ EXPORT_SYMBOL(lu_context_refill);
* predefined when the lu_device type are registered, during the module probe
* phase.
*/
-__u32 lu_context_tags_default = 0;
-__u32 lu_session_tags_default = 0;
-
-void lu_context_tags_update(__u32 tags)
-{
- spin_lock(&lu_keys_guard);
- lu_context_tags_default |= tags;
- key_set_version++;
- spin_unlock(&lu_keys_guard);
-}
-EXPORT_SYMBOL(lu_context_tags_update);
-
-void lu_context_tags_clear(__u32 tags)
-{
- spin_lock(&lu_keys_guard);
- lu_context_tags_default &= ~tags;
- key_set_version++;
- spin_unlock(&lu_keys_guard);
-}
-EXPORT_SYMBOL(lu_context_tags_clear);
-
-void lu_session_tags_update(__u32 tags)
-{
- spin_lock(&lu_keys_guard);
- lu_session_tags_default |= tags;
- key_set_version++;
- spin_unlock(&lu_keys_guard);
-}
-EXPORT_SYMBOL(lu_session_tags_update);
-
-void lu_session_tags_clear(__u32 tags)
-{
- spin_lock(&lu_keys_guard);
- lu_session_tags_default &= ~tags;
- key_set_version++;
- spin_unlock(&lu_keys_guard);
-}
-EXPORT_SYMBOL(lu_session_tags_clear);
+__u32 lu_context_tags_default;
+__u32 lu_session_tags_default;
int lu_env_init(struct lu_env *env, __u32 tags)
{
@@ -1759,40 +1694,15 @@ int lu_env_refill(struct lu_env *env)
}
EXPORT_SYMBOL(lu_env_refill);
-/**
- * Currently, this API will only be used by echo client.
- * Because echo client and normal lustre client will share
- * same cl_env cache. So echo client needs to refresh
- * the env context after it get one from the cache, especially
- * when normal client and echo client co-exist in the same client.
- */
-int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags,
- __u32 stags)
-{
- if ((env->le_ctx.lc_tags & ctags) != ctags) {
- env->le_ctx.lc_version = 0;
- env->le_ctx.lc_tags |= ctags;
- }
-
- if (env->le_ses && (env->le_ses->lc_tags & stags) != stags) {
- env->le_ses->lc_version = 0;
- env->le_ses->lc_tags |= stags;
- }
-
- return lu_env_refill(env);
-}
-EXPORT_SYMBOL(lu_env_refill_by_tags);
-
-
-typedef struct lu_site_stats{
+struct lu_site_stats {
unsigned lss_populated;
unsigned lss_max_search;
unsigned lss_total;
unsigned lss_busy;
-} lu_site_stats_t;
+};
static void lu_site_stats_get(struct cfs_hash *hs,
- lu_site_stats_t *stats, int populated)
+ struct lu_site_stats *stats, int populated)
{
struct cfs_hash_bd bd;
int i;
@@ -1802,7 +1712,8 @@ static void lu_site_stats_get(struct cfs_hash *hs,
struct hlist_head *hhead;
cfs_hash_bd_lock(hs, &bd, 1);
- stats->lss_busy += bkt->lsb_busy;
+ stats->lss_busy +=
+ cfs_hash_bd_count_get(&bd) - bkt->lsb_lru_len;
stats->lss_total += cfs_hash_bd_count_get(&bd);
stats->lss_max_search = max((int)stats->lss_max_search,
cfs_hash_bd_depmax_get(&bd));
@@ -1819,29 +1730,22 @@ static void lu_site_stats_get(struct cfs_hash *hs,
}
}
-
/*
- * There exists a potential lock inversion deadlock scenario when using
- * Lustre on top of ZFS. This occurs between one of ZFS's
- * buf_hash_table.ht_lock's, and Lustre's lu_sites_guard lock. Essentially,
- * thread A will take the lu_sites_guard lock and sleep on the ht_lock,
- * while thread B will take the ht_lock and sleep on the lu_sites_guard
- * lock. Obviously neither thread will wake and drop their respective hold
- * on their lock.
- *
- * To prevent this from happening we must ensure the lu_sites_guard lock is
- * not taken while down this code path. ZFS reliably does not set the
- * __GFP_FS bit in its code paths, so this can be used to determine if it
- * is safe to take the lu_sites_guard lock.
+ * lu_cache_shrink_count returns the number of cached objects that are
+ * candidates to be freed by shrink_slab(). A counter, which tracks
+ * the number of items in the site's lru, is maintained in the per cpu
+ * stats of each site. The counter is incremented when an object is added
+ * to a site's lru and decremented when one is removed. The number of
+ * free-able objects is the sum of all per cpu counters for all sites.
*
- * Ideally we should accurately return the remaining number of cached
- * objects without taking the lu_sites_guard lock, but this is not
- * possible in the current implementation.
+ * Using a per cpu counter is a compromise solution to concurrent access:
+ * lu_object_put() can update the counter without locking the site and
+ * lu_cache_shrink_count can sum the counters without locking each
+ * ls_obj_hash bucket.
*/
static unsigned long lu_cache_shrink_count(struct shrinker *sk,
struct shrink_control *sc)
{
- lu_site_stats_t stats;
struct lu_site *s;
struct lu_site *tmp;
unsigned long cached = 0;
@@ -1851,14 +1755,14 @@ static unsigned long lu_cache_shrink_count(struct shrinker *sk,
mutex_lock(&lu_sites_guard);
list_for_each_entry_safe(s, tmp, &lu_sites, ls_linkage) {
- memset(&stats, 0, sizeof(stats));
- lu_site_stats_get(s->ls_obj_hash, &stats, 0);
- cached += stats.lss_total - stats.lss_busy;
+ cached += ls_stats_read(s->ls_stats, LU_SS_LRU_LEN);
}
mutex_unlock(&lu_sites_guard);
cached = (cached / 100) * sysctl_vfs_cache_pressure;
- CDEBUG(D_INODE, "%ld objects cached\n", cached);
+ CDEBUG(D_INODE, "%ld objects cached, cache pressure %d\n",
+ cached, sysctl_vfs_cache_pressure);
+
return cached;
}
@@ -1900,29 +1804,9 @@ static unsigned long lu_cache_shrink_scan(struct shrinker *sk,
return sc->nr_to_scan - remain;
}
-/*
- * Debugging stuff.
- */
-
-/**
- * Environment to be used in debugger, contains all tags.
- */
-struct lu_env lu_debugging_env;
-
/**
* Debugging printer function using printk().
*/
-int lu_printk_printer(const struct lu_env *env,
- void *unused, const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- vprintk(format, args);
- va_end(args);
- return 0;
-}
-
static struct shrinker lu_site_shrinker = {
.count_objects = lu_cache_shrink_count,
.scan_objects = lu_cache_shrink_scan,
@@ -1989,14 +1873,17 @@ void lu_global_fini(void)
static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx)
{
-#if defined (CONFIG_PROC_FS)
struct lprocfs_counter ret;
lprocfs_stats_collect(stats, idx, &ret);
+ if (idx == LU_SS_LRU_LEN)
+ /*
+ * protect against counter on cpu A being decremented
+ * before counter is incremented on cpu B; unlikely
+ */
+ return (__u32)((ret.lc_sum > 0) ? ret.lc_sum : 0);
+
return (__u32)ret.lc_count;
-#else
- return 0;
-#endif
}
/**
@@ -2005,12 +1892,12 @@ static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx)
*/
int lu_site_stats_print(const struct lu_site *s, struct seq_file *m)
{
- lu_site_stats_t stats;
+ struct lu_site_stats stats;
memset(&stats, 0, sizeof(stats));
lu_site_stats_get(s->ls_obj_hash, &stats, 1);
- seq_printf(m, "%d/%d %d/%d %d %d %d %d %d %d %d\n",
+ seq_printf(m, "%d/%d %d/%d %d %d %d %d %d %d %d %d\n",
stats.lss_busy,
stats.lss_total,
stats.lss_populated,
@@ -2021,7 +1908,8 @@ int lu_site_stats_print(const struct lu_site *s, struct seq_file *m)
ls_stats_read(s->ls_stats, LU_SS_CACHE_MISS),
ls_stats_read(s->ls_stats, LU_SS_CACHE_RACE),
ls_stats_read(s->ls_stats, LU_SS_CACHE_DEATH_RACE),
- ls_stats_read(s->ls_stats, LU_SS_LRU_PURGED));
+ ls_stats_read(s->ls_stats, LU_SS_LRU_PURGED),
+ ls_stats_read(s->ls_stats, LU_SS_LRU_LEN));
return 0;
}
EXPORT_SYMBOL(lu_site_stats_print);
@@ -2056,137 +1944,8 @@ EXPORT_SYMBOL(lu_kmem_init);
void lu_kmem_fini(struct lu_kmem_descr *caches)
{
for (; caches->ckd_cache != NULL; ++caches) {
- if (*caches->ckd_cache != NULL) {
- kmem_cache_destroy(*caches->ckd_cache);
- *caches->ckd_cache = NULL;
- }
+ kmem_cache_destroy(*caches->ckd_cache);
+ *caches->ckd_cache = NULL;
}
}
EXPORT_SYMBOL(lu_kmem_fini);
-
-/**
- * Temporary solution to be able to assign fid in ->do_create()
- * till we have fully-functional OST fids
- */
-void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
- const struct lu_fid *fid)
-{
- struct lu_site *s = o->lo_dev->ld_site;
- struct lu_fid *old = &o->lo_header->loh_fid;
- struct lu_site_bkt_data *bkt;
- struct lu_object *shadow;
- wait_queue_t waiter;
- struct cfs_hash *hs;
- struct cfs_hash_bd bd;
- __u64 version = 0;
-
- LASSERT(fid_is_zero(old));
-
- hs = s->ls_obj_hash;
- cfs_hash_bd_get_and_lock(hs, (void *)fid, &bd, 1);
- shadow = htable_lookup(s, &bd, fid, &waiter, &version);
- /* supposed to be unique */
- LASSERT(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT);
- *old = *fid;
- bkt = cfs_hash_bd_extra_get(hs, &bd);
- cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
- bkt->lsb_busy++;
- cfs_hash_bd_unlock(hs, &bd, 1);
-}
-EXPORT_SYMBOL(lu_object_assign_fid);
-
-/**
- * allocates object with 0 (non-assigned) fid
- * XXX: temporary solution to be able to assign fid in ->do_create()
- * till we have fully-functional OST fids
- */
-struct lu_object *lu_object_anon(const struct lu_env *env,
- struct lu_device *dev,
- const struct lu_object_conf *conf)
-{
- struct lu_fid fid;
- struct lu_object *o;
-
- fid_zero(&fid);
- o = lu_object_alloc(env, dev, &fid, conf);
-
- return o;
-}
-EXPORT_SYMBOL(lu_object_anon);
-
-struct lu_buf LU_BUF_NULL = {
- .lb_buf = NULL,
- .lb_len = 0
-};
-EXPORT_SYMBOL(LU_BUF_NULL);
-
-void lu_buf_free(struct lu_buf *buf)
-{
- LASSERT(buf);
- if (buf->lb_buf) {
- LASSERT(buf->lb_len > 0);
- OBD_FREE_LARGE(buf->lb_buf, buf->lb_len);
- buf->lb_buf = NULL;
- buf->lb_len = 0;
- }
-}
-EXPORT_SYMBOL(lu_buf_free);
-
-void lu_buf_alloc(struct lu_buf *buf, int size)
-{
- LASSERT(buf);
- LASSERT(buf->lb_buf == NULL);
- LASSERT(buf->lb_len == 0);
- OBD_ALLOC_LARGE(buf->lb_buf, size);
- if (likely(buf->lb_buf))
- buf->lb_len = size;
-}
-EXPORT_SYMBOL(lu_buf_alloc);
-
-void lu_buf_realloc(struct lu_buf *buf, int size)
-{
- lu_buf_free(buf);
- lu_buf_alloc(buf, size);
-}
-EXPORT_SYMBOL(lu_buf_realloc);
-
-struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, int len)
-{
- if (buf->lb_buf == NULL && buf->lb_len == 0)
- lu_buf_alloc(buf, len);
-
- if ((len > buf->lb_len) && (buf->lb_buf != NULL))
- lu_buf_realloc(buf, len);
-
- return buf;
-}
-EXPORT_SYMBOL(lu_buf_check_and_alloc);
-
-/**
- * Increase the size of the \a buf.
- * preserves old data in buffer
- * old buffer remains unchanged on error
- * \retval 0 or -ENOMEM
- */
-int lu_buf_check_and_grow(struct lu_buf *buf, int len)
-{
- char *ptr;
-
- if (len <= buf->lb_len)
- return 0;
-
- OBD_ALLOC_LARGE(ptr, len);
- if (ptr == NULL)
- return -ENOMEM;
-
- /* Free the old buf */
- if (buf->lb_buf != NULL) {
- memcpy(ptr, buf->lb_buf, buf->lb_len);
- OBD_FREE_LARGE(buf->lb_buf, buf->lb_len);
- }
-
- buf->lb_buf = ptr;
- buf->lb_len = len;
- return 0;
-}
-EXPORT_SYMBOL(lu_buf_check_and_grow);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/kernel/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index f720e3183..fb9147cc6 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -44,7 +44,6 @@
#include "../include/lustre_handles.h"
#include "../include/lustre_lib.h"
-
static __u64 handle_base;
#define HANDLE_INCR 7
static spinlock_t handle_base_lock;
@@ -126,6 +125,7 @@ static void class_handle_unhash_nolock(struct portals_handle *h)
void class_handle_unhash(struct portals_handle *h)
{
struct handle_bucket *bucket;
+
bucket = handle_hash + (h->h_cookie & HANDLE_HASH_MASK);
spin_lock(&bucket->lock);
@@ -134,19 +134,6 @@ void class_handle_unhash(struct portals_handle *h)
}
EXPORT_SYMBOL(class_handle_unhash);
-void class_handle_hash_back(struct portals_handle *h)
-{
- struct handle_bucket *bucket;
-
- bucket = handle_hash + (h->h_cookie & HANDLE_HASH_MASK);
-
- spin_lock(&bucket->lock);
- list_add_rcu(&h->h_link, &bucket->head);
- h->h_in = 1;
- spin_unlock(&bucket->lock);
-}
-EXPORT_SYMBOL(class_handle_hash_back);
-
void *class_handle2object(__u64 cookie)
{
struct handle_bucket *bucket;
@@ -186,19 +173,20 @@ void class_handle_free_cb(struct rcu_head *rcu)
if (h->h_ops->hop_free != NULL)
h->h_ops->hop_free(ptr, h->h_size);
else
- OBD_FREE(ptr, h->h_size);
+ kfree(ptr);
}
EXPORT_SYMBOL(class_handle_free_cb);
int class_handle_init(void)
{
struct handle_bucket *bucket;
- struct timeval tv;
+ struct timespec64 ts;
int seed[2];
LASSERT(handle_hash == NULL);
- OBD_ALLOC_LARGE(handle_hash, sizeof(*bucket) * HANDLE_HASH_SIZE);
+ handle_hash = libcfs_kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE,
+ GFP_NOFS);
if (handle_hash == NULL)
return -ENOMEM;
@@ -211,8 +199,8 @@ int class_handle_init(void)
/** bug 21430: add randomness to the initial base */
cfs_get_random_bytes(seed, sizeof(seed));
- do_gettimeofday(&tv);
- cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
+ ktime_get_ts64(&ts);
+ cfs_srand(ts.tv_sec ^ seed[0], ts.tv_nsec ^ seed[1]);
cfs_get_random_bytes(&handle_base, sizeof(handle_base));
LASSERT(handle_base != 0ULL);
@@ -245,11 +233,12 @@ static int cleanup_all_handles(void)
void class_handle_cleanup(void)
{
int count;
+
LASSERT(handle_hash != NULL);
count = cleanup_all_handles();
- OBD_FREE_LARGE(handle_hash, sizeof(*handle_hash) * HANDLE_HASH_SIZE);
+ kvfree(handle_hash);
handle_hash = NULL;
if (count != 0)
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/kernel/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
index 64b2f35e2..d6184f821 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
@@ -104,8 +104,8 @@ int class_add_uuid(const char *uuid, __u64 nid)
if (strlen(uuid) > UUID_MAX - 1)
return -EOVERFLOW;
- OBD_ALLOC_PTR(data);
- if (data == NULL)
+ data = kzalloc(sizeof(*data), GFP_NOFS);
+ if (!data)
return -ENOMEM;
obd_str2uuid(&data->un_uuid, uuid);
@@ -136,7 +136,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
if (found) {
CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid,
libcfs_nid2str(nid), entry->un_nid_count);
- OBD_FREE(data, sizeof(*data));
+ kfree(data);
} else {
CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid));
}
@@ -180,7 +180,7 @@ int class_del_uuid(const char *uuid)
libcfs_nid2str(data->un_nids[0]),
data->un_nid_count);
- OBD_FREE(data, sizeof(*data));
+ kfree(data);
}
return 0;
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/obd_config.c b/kernel/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 6ce9adc2f..c231e0da0 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -47,9 +47,7 @@
#include "llog_internal.h"
-static cfs_hash_ops_t uuid_hash_ops;
-static cfs_hash_ops_t nid_hash_ops;
-static cfs_hash_ops_t nid_stat_hash_ops;
+static struct cfs_hash_ops uuid_hash_ops;
/*********** string parsing utils *********/
@@ -62,7 +60,7 @@ int class_find_param(char *buf, char *key, char **valp)
return 1;
ptr = strstr(buf, key);
- if (ptr == NULL)
+ if (!ptr)
return 1;
if (valp)
@@ -72,117 +70,9 @@ int class_find_param(char *buf, char *key, char **valp)
}
EXPORT_SYMBOL(class_find_param);
-/**
- * Check whether the proc parameter \a param is an old parameter or not from
- * the array \a ptr which contains the mapping from old parameters to new ones.
- * If it's an old one, then return the pointer to the cfg_interop_param struc-
- * ture which contains both the old and new parameters.
- *
- * \param param proc parameter
- * \param ptr an array which contains the mapping from
- * old parameters to new ones
- *
- * \retval valid-pointer pointer to the cfg_interop_param structure
- * which contains the old and new parameters
- * \retval NULL \a param or \a ptr is NULL,
- * or \a param is not an old parameter
- */
-struct cfg_interop_param *class_find_old_param(const char *param,
- struct cfg_interop_param *ptr)
-{
- char *value = NULL;
- int name_len = 0;
-
- if (param == NULL || ptr == NULL)
- return NULL;
-
- value = strchr(param, '=');
- if (value == NULL)
- name_len = strlen(param);
- else
- name_len = value - param;
-
- while (ptr->old_param != NULL) {
- if (strncmp(param, ptr->old_param, name_len) == 0 &&
- name_len == strlen(ptr->old_param))
- return ptr;
- ptr++;
- }
-
- return NULL;
-}
-EXPORT_SYMBOL(class_find_old_param);
-
-/**
- * Finds a parameter in \a params and copies it to \a copy.
- *
- * Leading spaces are skipped. Next space or end of string is the
- * parameter terminator with the exception that spaces inside single or double
- * quotes get included into a parameter. The parameter is copied into \a copy
- * which has to be allocated big enough by a caller, quotes are stripped in
- * the copy and the copy is terminated by 0.
- *
- * On return \a params is set to next parameter or to NULL if last
- * parameter is returned.
- *
- * \retval 0 if parameter is returned in \a copy
- * \retval 1 otherwise
- * \retval -EINVAL if unbalanced quota is found
- */
-int class_get_next_param(char **params, char *copy)
-{
- char *q1, *q2, *str;
- int len;
-
- str = *params;
- while (*str == ' ')
- str++;
-
- if (*str == '\0') {
- *params = NULL;
- return 1;
- }
-
- while (1) {
- q1 = strpbrk(str, " '\"");
- if (q1 == NULL) {
- len = strlen(str);
- memcpy(copy, str, len);
- copy[len] = '\0';
- *params = NULL;
- return 0;
- }
- len = q1 - str;
- if (*q1 == ' ') {
- memcpy(copy, str, len);
- copy[len] = '\0';
- *params = str + len;
- return 0;
- }
-
- memcpy(copy, str, len);
- copy += len;
-
- /* search for the matching closing quote */
- str = q1 + 1;
- q2 = strchr(str, *q1);
- if (q2 == NULL) {
- CERROR("Unbalanced quota in parameters: \"%s\"\n",
- *params);
- return -EINVAL;
- }
- len = q2 - str;
- memcpy(copy, str, len);
- copy += len;
- str = q2 + 1;
- }
- return 1;
-}
-EXPORT_SYMBOL(class_get_next_param);
-
/* returns 0 if this is the first key in the buffer, else 1.
valp points to first char after key. */
-int class_match_param(char *buf, char *key, char **valp)
+static int class_match_param(char *buf, char *key, char **valp)
{
if (!buf)
return 1;
@@ -195,11 +85,10 @@ int class_match_param(char *buf, char *key, char **valp)
return 0;
}
-EXPORT_SYMBOL(class_match_param);
static int parse_nid(char *buf, void *value, int quiet)
{
- lnet_nid_t *nid = (lnet_nid_t *)value;
+ lnet_nid_t *nid = value;
*nid = libcfs_str2nid(buf);
if (*nid != LNET_NID_ANY)
@@ -212,7 +101,7 @@ static int parse_nid(char *buf, void *value, int quiet)
static int parse_net(char *buf, void *value)
{
- __u32 *net = (__u32 *)value;
+ __u32 *net = value;
*net = libcfs_str2net(buf);
CDEBUG(D_INFO, "Net %s\n", libcfs_net2str(*net));
@@ -244,7 +133,7 @@ static int class_parse_value(char *buf, int opc, void *value, char **endh,
/* nid separators or end of nids */
endp = strpbrk(buf, ",: /");
- if (endp == NULL)
+ if (!endp)
endp = buf + strlen(buf);
tmp = *endp;
@@ -279,59 +168,13 @@ int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh)
}
EXPORT_SYMBOL(class_parse_nid_quiet);
-int class_parse_net(char *buf, __u32 *net, char **endh)
-{
- return class_parse_value(buf, CLASS_PARSE_NET, (void *)net, endh, 0);
-}
-EXPORT_SYMBOL(class_parse_net);
-
-/* 1 param contains key and match
- * 0 param contains key and not match
- * -1 param does not contain key
- */
-int class_match_nid(char *buf, char *key, lnet_nid_t nid)
-{
- lnet_nid_t tmp;
- int rc = -1;
-
- while (class_find_param(buf, key, &buf) == 0) {
- /* please restrict to the nids pertaining to
- * the specified nids */
- while (class_parse_nid(buf, &tmp, &buf) == 0) {
- if (tmp == nid)
- return 1;
- }
- rc = 0;
- }
- return rc;
-}
-EXPORT_SYMBOL(class_match_nid);
-
-int class_match_net(char *buf, char *key, __u32 net)
-{
- __u32 tmp;
- int rc = -1;
-
- while (class_find_param(buf, key, &buf) == 0) {
- /* please restrict to the nids pertaining to
- * the specified networks */
- while (class_parse_net(buf, &tmp, &buf) == 0) {
- if (tmp == net)
- return 1;
- }
- rc = 0;
- }
- return rc;
-}
-EXPORT_SYMBOL(class_match_net);
-
/********************** class fns **********************/
/**
* Create a new obd device and set the type, name and uuid. If successful,
* the new device can be accessed by either name or uuid.
*/
-int class_attach(struct lustre_cfg *lcfg)
+static int class_attach(struct lustre_cfg *lcfg)
{
struct obd_device *obd = NULL;
char *typename, *name, *uuid;
@@ -382,8 +225,6 @@ int class_attach(struct lustre_cfg *lcfg)
INIT_LIST_HEAD(&obd->obd_exports);
INIT_LIST_HEAD(&obd->obd_unlinked_exports);
INIT_LIST_HEAD(&obd->obd_delayed_exports);
- INIT_LIST_HEAD(&obd->obd_exports_timed);
- INIT_LIST_HEAD(&obd->obd_nid_stats);
spin_lock_init(&obd->obd_nid_lock);
spin_lock_init(&obd->obd_dev_lock);
mutex_init(&obd->obd_dev_mutex);
@@ -395,14 +236,7 @@ int class_attach(struct lustre_cfg *lcfg)
/* XXX belongs in setup not attach */
init_rwsem(&obd->obd_observer_link_sem);
/* recovery data */
- cfs_init_timer(&obd->obd_recovery_timer);
- spin_lock_init(&obd->obd_recovery_task_lock);
- init_waitqueue_head(&obd->obd_next_transno_waitq);
init_waitqueue_head(&obd->obd_evict_inprogress_waitq);
- INIT_LIST_HEAD(&obd->obd_req_replay_queue);
- INIT_LIST_HEAD(&obd->obd_lock_replay_queue);
- INIT_LIST_HEAD(&obd->obd_final_req_queue);
- INIT_LIST_HEAD(&obd->obd_evict_list);
llog_group_init(&obd->obd_olg, FID_SEQ_LLOG);
@@ -443,12 +277,11 @@ int class_attach(struct lustre_cfg *lcfg)
}
return rc;
}
-EXPORT_SYMBOL(class_attach);
/** Create hashes, self-export, and call type-specific setup.
* Setup is effectively the "start this obd" call.
*/
-int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
+static int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
int err = 0;
struct obd_export *exp;
@@ -485,8 +318,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
other fns check that status, and we're not actually set up yet. */
obd->obd_starting = 1;
obd->obd_uuid_hash = NULL;
- obd->obd_nid_hash = NULL;
- obd->obd_nid_stats_hash = NULL;
spin_unlock(&obd->obd_dev_lock);
/* create an uuid-export lustre hash */
@@ -502,32 +333,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
goto err_hash;
}
- /* create a nid-export lustre hash */
- obd->obd_nid_hash = cfs_hash_create("NID_HASH",
- HASH_NID_CUR_BITS,
- HASH_NID_MAX_BITS,
- HASH_NID_BKT_BITS, 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &nid_hash_ops, CFS_HASH_DEFAULT);
- if (!obd->obd_nid_hash) {
- err = -ENOMEM;
- goto err_hash;
- }
-
- /* create a nid-stats lustre hash */
- obd->obd_nid_stats_hash = cfs_hash_create("NID_STATS",
- HASH_NID_STATS_CUR_BITS,
- HASH_NID_STATS_MAX_BITS,
- HASH_NID_STATS_BKT_BITS, 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &nid_stat_hash_ops, CFS_HASH_DEFAULT);
- if (!obd->obd_nid_stats_hash) {
- err = -ENOMEM;
- goto err_hash;
- }
-
exp = class_new_export(obd, &obd->obd_uuid);
if (IS_ERR(exp)) {
err = PTR_ERR(exp);
@@ -535,7 +340,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
}
obd->obd_self_export = exp;
- list_del_init(&exp->exp_obd_chain_timed);
class_export_put(exp);
err = obd_setup(obd, lcfg);
@@ -563,24 +367,15 @@ err_hash:
cfs_hash_putref(obd->obd_uuid_hash);
obd->obd_uuid_hash = NULL;
}
- if (obd->obd_nid_hash) {
- cfs_hash_putref(obd->obd_nid_hash);
- obd->obd_nid_hash = NULL;
- }
- if (obd->obd_nid_stats_hash) {
- cfs_hash_putref(obd->obd_nid_stats_hash);
- obd->obd_nid_stats_hash = NULL;
- }
obd->obd_starting = 0;
CERROR("setup %s failed (%d)\n", obd->obd_name, err);
return err;
}
-EXPORT_SYMBOL(class_setup);
/** We have finished using this obd and are ready to destroy it.
* There can be no more references to this obd.
*/
-int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)
+static int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)
{
if (obd->obd_set_up) {
CERROR("OBD device %d still set up\n", obd->obd_minor);
@@ -602,13 +397,12 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)
class_decref(obd, "attach", obd);
return 0;
}
-EXPORT_SYMBOL(class_detach);
/** Start shutting down the obd. There may be in-progress ops when
* this is called. We tell them to start shutting down with a call
* to class_disconnect_exports().
*/
-int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
+static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
int err = 0;
char *flag;
@@ -664,18 +458,6 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
LASSERT(obd->obd_self_export);
- /* The three references that should be remaining are the
- * obd_self_export and the attach and setup references. */
- if (atomic_read(&obd->obd_refcount) > 3) {
- /* refcount - 3 might be the number of real exports
- (excluding self export). But class_incref is called
- by other things as well, so don't count on it. */
- CDEBUG(D_IOCTL, "%s: forcing exports to disconnect: %d\n",
- obd->obd_name, atomic_read(&obd->obd_refcount) - 3);
- dump_exports(obd, 0);
- class_disconnect_exports(obd);
- }
-
/* Precleanup, we must make sure all exports get destroyed. */
err = obd_precleanup(obd, OBD_CLEANUP_EXPORTS);
if (err)
@@ -688,24 +470,11 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
obd->obd_uuid_hash = NULL;
}
- /* destroy a nid-export hash body */
- if (obd->obd_nid_hash) {
- cfs_hash_putref(obd->obd_nid_hash);
- obd->obd_nid_hash = NULL;
- }
-
- /* destroy a nid-stats hash body */
- if (obd->obd_nid_stats_hash) {
- cfs_hash_putref(obd->obd_nid_stats_hash);
- obd->obd_nid_stats_hash = NULL;
- }
-
class_decref(obd, "setup", obd);
obd->obd_set_up = 0;
return 0;
}
-EXPORT_SYMBOL(class_cleanup);
struct obd_device *class_incref(struct obd_device *obd,
const char *scope, const void *source)
@@ -769,7 +538,7 @@ EXPORT_SYMBOL(class_decref);
/** Add a failover nid location.
* Client obd types contact server obd types using this nid list.
*/
-int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
+static int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
{
struct obd_import *imp;
struct obd_uuid uuid;
@@ -800,11 +569,10 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
return rc;
}
-EXPORT_SYMBOL(class_add_conn);
/** Remove a failover nid location.
*/
-int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
+static int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
{
struct obd_import *imp;
struct obd_uuid uuid;
@@ -852,56 +620,51 @@ EXPORT_SYMBOL(class_get_profile);
* This defines the mdc and osc names to use for a client.
* This also is used to define the lov to be used by a mdt.
*/
-int class_add_profile(int proflen, char *prof, int osclen, char *osc,
- int mdclen, char *mdc)
+static int class_add_profile(int proflen, char *prof, int osclen, char *osc,
+ int mdclen, char *mdc)
{
struct lustre_profile *lprof;
int err = 0;
CDEBUG(D_CONFIG, "Add profile %s\n", prof);
- OBD_ALLOC(lprof, sizeof(*lprof));
- if (lprof == NULL)
+ lprof = kzalloc(sizeof(*lprof), GFP_NOFS);
+ if (!lprof)
return -ENOMEM;
INIT_LIST_HEAD(&lprof->lp_list);
LASSERT(proflen == (strlen(prof) + 1));
- OBD_ALLOC(lprof->lp_profile, proflen);
- if (lprof->lp_profile == NULL) {
+ lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS);
+ if (!lprof->lp_profile) {
err = -ENOMEM;
- goto out;
+ goto free_lprof;
}
- memcpy(lprof->lp_profile, prof, proflen);
LASSERT(osclen == (strlen(osc) + 1));
- OBD_ALLOC(lprof->lp_dt, osclen);
- if (lprof->lp_dt == NULL) {
+ lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS);
+ if (!lprof->lp_dt) {
err = -ENOMEM;
- goto out;
+ goto free_lp_profile;
}
- memcpy(lprof->lp_dt, osc, osclen);
if (mdclen > 0) {
LASSERT(mdclen == (strlen(mdc) + 1));
- OBD_ALLOC(lprof->lp_md, mdclen);
- if (lprof->lp_md == NULL) {
+ lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS);
+ if (!lprof->lp_md) {
err = -ENOMEM;
- goto out;
+ goto free_lp_dt;
}
- memcpy(lprof->lp_md, mdc, mdclen);
}
list_add(&lprof->lp_list, &lustre_profile_list);
return err;
-out:
- if (lprof->lp_md)
- OBD_FREE(lprof->lp_md, mdclen);
- if (lprof->lp_dt)
- OBD_FREE(lprof->lp_dt, osclen);
- if (lprof->lp_profile)
- OBD_FREE(lprof->lp_profile, proflen);
- OBD_FREE(lprof, sizeof(*lprof));
+free_lp_dt:
+ kfree(lprof->lp_dt);
+free_lp_profile:
+ kfree(lprof->lp_profile);
+free_lprof:
+ kfree(lprof);
return err;
}
@@ -914,11 +677,10 @@ void class_del_profile(const char *prof)
lprof = class_get_profile(prof);
if (lprof) {
list_del(&lprof->lp_list);
- OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1);
- OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1);
- if (lprof->lp_md)
- OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1);
- OBD_FREE(lprof, sizeof(*lprof));
+ kfree(lprof->lp_profile);
+ kfree(lprof->lp_dt);
+ kfree(lprof->lp_md);
+ kfree(lprof);
}
}
EXPORT_SYMBOL(class_del_profile);
@@ -930,11 +692,10 @@ void class_del_profiles(void)
list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) {
list_del(&lprof->lp_list);
- OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1);
- OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1);
- if (lprof->lp_md)
- OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1);
- OBD_FREE(lprof, sizeof(*lprof));
+ kfree(lprof->lp_profile);
+ kfree(lprof->lp_dt);
+ kfree(lprof->lp_md);
+ kfree(lprof);
}
}
EXPORT_SYMBOL(class_del_profiles);
@@ -961,11 +722,10 @@ static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg)
return 0;
}
-
/* We can't call ll_process_config or lquota_process_config directly because
* it lives in a module that must be loaded after this one. */
-static int (*client_process_config)(struct lustre_cfg *lcfg) = NULL;
-static int (*quota_process_config)(struct lustre_cfg *lcfg) = NULL;
+static int (*client_process_config)(struct lustre_cfg *lcfg);
+static int (*quota_process_config)(struct lustre_cfg *lcfg);
void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg))
{
@@ -973,78 +733,6 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg))
}
EXPORT_SYMBOL(lustre_register_client_process_config);
-/**
- * Rename the proc parameter in \a cfg with a new name \a new_name.
- *
- * \param cfg config structure which contains the proc parameter
- * \param new_name new name of the proc parameter
- *
- * \retval valid-pointer pointer to the newly-allocated config structure
- * which contains the renamed proc parameter
- * \retval ERR_PTR(-EINVAL) if \a cfg or \a new_name is NULL, or \a cfg does
- * not contain a proc parameter
- * \retval ERR_PTR(-ENOMEM) if memory allocation failure occurs
- */
-struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
- const char *new_name)
-{
- struct lustre_cfg_bufs *bufs = NULL;
- struct lustre_cfg *new_cfg = NULL;
- char *param = NULL;
- char *new_param = NULL;
- char *value = NULL;
- int name_len = 0;
- int new_len = 0;
-
- if (cfg == NULL || new_name == NULL)
- return ERR_PTR(-EINVAL);
-
- param = lustre_cfg_string(cfg, 1);
- if (param == NULL)
- return ERR_PTR(-EINVAL);
-
- value = strchr(param, '=');
- if (value == NULL)
- name_len = strlen(param);
- else
- name_len = value - param;
-
- new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len;
-
- OBD_ALLOC(new_param, new_len);
- if (new_param == NULL)
- return ERR_PTR(-ENOMEM);
-
- strcpy(new_param, new_name);
- if (value != NULL)
- strcat(new_param, value);
-
- OBD_ALLOC_PTR(bufs);
- if (bufs == NULL) {
- OBD_FREE(new_param, new_len);
- return ERR_PTR(-ENOMEM);
- }
-
- lustre_cfg_bufs_reset(bufs, NULL);
- lustre_cfg_bufs_init(bufs, cfg);
- lustre_cfg_bufs_set_string(bufs, 1, new_param);
-
- new_cfg = lustre_cfg_new(cfg->lcfg_command, bufs);
-
- OBD_FREE(new_param, new_len);
- OBD_FREE_PTR(bufs);
- if (new_cfg == NULL)
- return ERR_PTR(-ENOMEM);
-
- new_cfg->lcfg_num = cfg->lcfg_num;
- new_cfg->lcfg_flags = cfg->lcfg_flags;
- new_cfg->lcfg_nid = cfg->lcfg_nid;
- new_cfg->lcfg_nal = cfg->lcfg_nal;
-
- return new_cfg;
-}
-EXPORT_SYMBOL(lustre_cfg_rename);
-
static int process_param2_config(struct lustre_cfg *lcfg)
{
char *param = lustre_cfg_string(lcfg, 1);
@@ -1055,42 +743,35 @@ static int process_param2_config(struct lustre_cfg *lcfg)
[2] = param,
[3] = NULL
};
- struct timeval start;
- struct timeval end;
+ ktime_t start;
+ ktime_t end;
int rc;
-
/* Add upcall processing here. Now only lctl is supported */
if (strcmp(upcall, LCTL_UPCALL) != 0) {
CERROR("Unsupported upcall %s\n", upcall);
return -EINVAL;
}
- do_gettimeofday(&start);
+ start = ktime_get();
rc = call_usermodehelper(argv[0], argv, NULL, 1);
- do_gettimeofday(&end);
+ end = ktime_get();
if (rc < 0) {
CERROR(
"lctl: error invoking upcall %s %s %s: rc = %d; time %ldus\n",
argv[0], argv[1], argv[2], rc,
- cfs_timeval_sub(&end, &start, NULL));
+ (long)ktime_us_delta(end, start));
} else {
CDEBUG(D_HA, "lctl: invoked upcall %s %s %s, time %ldus\n",
argv[0], argv[1], argv[2],
- cfs_timeval_sub(&end, &start, NULL));
+ (long)ktime_us_delta(end, start));
rc = 0;
}
return rc;
}
-void lustre_register_quota_process_config(int (*qpc)(struct lustre_cfg *lcfg))
-{
- quota_process_config = qpc;
-}
-EXPORT_SYMBOL(lustre_register_quota_process_config);
-
/** Process configuration commands given in lustre_cfg form.
* These may come from direct calls (e.g. class_manual_cleanup)
* or processing the config llog, or ioctl from lctl.
@@ -1156,12 +837,7 @@ int class_process_config(struct lustre_cfg *lcfg)
goto out;
}
case LCFG_SET_LDLM_TIMEOUT: {
- CDEBUG(D_IOCTL, "changing lustre ldlm_timeout from %d to %d\n",
- ldlm_timeout, lcfg->lcfg_num);
- ldlm_timeout = max(lcfg->lcfg_num, 1U);
- if (ldlm_timeout >= obd_timeout)
- ldlm_timeout = max(obd_timeout / 3, 1U);
- ldlm_timeout_set = 1;
+ /* ldlm_timeout is not used on the client */
err = 0;
goto out;
}
@@ -1173,6 +849,7 @@ int class_process_config(struct lustre_cfg *lcfg)
}
case LCFG_MARKER: {
struct cfg_marker *marker;
+
marker = lustre_cfg_buf(lcfg, 1);
CDEBUG(D_IOCTL, "marker %d (%#x) %.16s %s\n", marker->cm_step,
marker->cm_flags, marker->cm_tgtname, marker->cm_comment);
@@ -1216,7 +893,7 @@ int class_process_config(struct lustre_cfg *lcfg)
}
/* Commands that require a device */
obd = class_name2obd(lustre_cfg_string(lcfg, 0));
- if (obd == NULL) {
+ if (!obd) {
if (!LUSTRE_CFG_BUFLEN(lcfg, 0))
CERROR("this lcfg command requires a device name\n");
else
@@ -1337,6 +1014,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
rc = -EROFS;
if (var->fops && var->fops->write) {
mm_segment_t oldfs;
+
oldfs = get_fs();
set_fs(KERNEL_DS);
rc = (var->fops->write)(&fakefile, sval,
@@ -1392,8 +1070,6 @@ int class_config_llog_handler(const struct lu_env *env,
char *cfg_buf = (char *) (rec + 1);
int rc = 0;
- //class_config_dump_handler(handle, rec, data);
-
switch (rec->lrh_type) {
case OBD_CFG_REC: {
struct lustre_cfg *lcfg, *lcfg_new;
@@ -1415,6 +1091,7 @@ int class_config_llog_handler(const struct lu_env *env,
/* Figure out config state info */
if (lcfg->lcfg_command == LCFG_MARKER) {
struct cfg_marker *marker = lustre_cfg_buf(lcfg, 1);
+
lustre_swab_cfg_marker(marker, swab,
LUSTRE_CFG_BUFLEN(lcfg, 1));
CDEBUG(D_CONFIG, "Marker, inst_flg=%#x mark_flg=%#x\n",
@@ -1477,7 +1154,6 @@ int class_config_llog_handler(const struct lu_env *env,
}
}
-
if (clli->cfg_flags & CFG_F_EXCLUDE) {
CDEBUG(D_CONFIG, "cmd: %x marked EXCLUDED\n",
lcfg->lcfg_command);
@@ -1489,18 +1165,17 @@ int class_config_llog_handler(const struct lu_env *env,
lustre_cfg_bufs_init(&bufs, lcfg);
if (clli && clli->cfg_instance &&
- LUSTRE_CFG_BUFLEN(lcfg, 0) > 0){
+ LUSTRE_CFG_BUFLEN(lcfg, 0) > 0) {
inst = 1;
inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
sizeof(clli->cfg_instance) * 2 + 4;
- OBD_ALLOC(inst_name, inst_len);
- if (inst_name == NULL) {
+ inst_name = kasprintf(GFP_NOFS, "%s-%p",
+ lustre_cfg_string(lcfg, 0),
+ clli->cfg_instance);
+ if (!inst_name) {
rc = -ENOMEM;
goto out;
}
- sprintf(inst_name, "%s-%p",
- lustre_cfg_string(lcfg, 0),
- clli->cfg_instance);
lustre_cfg_bufs_set_string(&bufs, 0, inst_name);
CDEBUG(D_CONFIG, "cmd %x, instance name: %s\n",
lcfg->lcfg_command, inst_name);
@@ -1520,7 +1195,7 @@ int class_config_llog_handler(const struct lu_env *env,
* moving them to index [1] and [2], and insert MGC's
* obdname at index [0].
*/
- if (clli && clli->cfg_instance == NULL &&
+ if (clli && !clli->cfg_instance &&
lcfg->lcfg_command == LCFG_SPTLRPC_CONF) {
lustre_cfg_bufs_set(&bufs, 2, bufs.lcfg_buf[1],
bufs.lcfg_buflen[1]);
@@ -1556,7 +1231,7 @@ int class_config_llog_handler(const struct lu_env *env,
lustre_cfg_free(lcfg_new);
if (inst)
- OBD_FREE(inst_name, inst_len);
+ kfree(inst_name);
break;
}
default:
@@ -1620,7 +1295,8 @@ EXPORT_SYMBOL(class_config_parse_llog);
* This is separated from class_config_dump_handler() to use
* for ioctl needs as well
*/
-int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size)
+static int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf,
+ int size)
{
struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1);
char *ptr = buf;
@@ -1640,10 +1316,13 @@ int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size)
if (lcfg->lcfg_num)
ptr += snprintf(ptr, end-ptr, "num=%#08x ", lcfg->lcfg_num);
- if (lcfg->lcfg_nid)
+ if (lcfg->lcfg_nid) {
+ char nidstr[LNET_NIDSTR_SIZE];
+
+ libcfs_nid2str_r(lcfg->lcfg_nid, nidstr, sizeof(nidstr));
ptr += snprintf(ptr, end-ptr, "nid=%s(%#llx)\n ",
- libcfs_nid2str(lcfg->lcfg_nid),
- lcfg->lcfg_nid);
+ nidstr, lcfg->lcfg_nid);
+ }
if (lcfg->lcfg_command == LCFG_MARKER) {
struct cfg_marker *marker = lustre_cfg_buf(lcfg, 1);
@@ -1671,8 +1350,8 @@ int class_config_dump_handler(const struct lu_env *env,
char *outstr;
int rc = 0;
- OBD_ALLOC(outstr, 256);
- if (outstr == NULL)
+ outstr = kzalloc(256, GFP_NOFS);
+ if (!outstr)
return -ENOMEM;
if (rec->lrh_type == OBD_CFG_REC) {
@@ -1683,35 +1362,10 @@ int class_config_dump_handler(const struct lu_env *env,
rc = -EINVAL;
}
- OBD_FREE(outstr, 256);
+ kfree(outstr);
return rc;
}
-int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
- char *name, struct config_llog_instance *cfg)
-{
- struct llog_handle *llh;
- int rc;
-
- LCONSOLE_INFO("Dumping config log %s\n", name);
-
- rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
- if (rc)
- return rc;
-
- rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
- if (rc)
- goto parse_out;
-
- rc = llog_process(env, llh, class_config_dump_handler, cfg, NULL);
-parse_out:
- llog_close(env, llh);
-
- LCONSOLE_INFO("End config log %s\n", name);
- return rc;
-}
-EXPORT_SYMBOL(class_config_dump_llog);
-
/** Call class_cleanup and class_detach.
* "Manual" only in the sense that we're faking lcfg commands.
*/
@@ -1819,135 +1473,11 @@ uuid_export_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
class_export_put(exp);
}
-static cfs_hash_ops_t uuid_hash_ops = {
+static struct cfs_hash_ops uuid_hash_ops = {
.hs_hash = uuid_hash,
- .hs_key = uuid_key,
+ .hs_key = uuid_key,
.hs_keycmp = uuid_keycmp,
.hs_object = uuid_export_object,
- .hs_get = uuid_export_get,
+ .hs_get = uuid_export_get,
.hs_put_locked = uuid_export_put_locked,
};
-
-
-/*
- * nid<->export hash operations
- */
-
-static unsigned
-nid_hash(struct cfs_hash *hs, const void *key, unsigned mask)
-{
- return cfs_hash_djb2_hash(key, sizeof(lnet_nid_t), mask);
-}
-
-static void *
-nid_key(struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- exp = hlist_entry(hnode, struct obd_export, exp_nid_hash);
-
- return &exp->exp_connection->c_peer.nid;
-}
-
-/*
- * NOTE: It is impossible to find an export that is in failed
- * state with this function
- */
-static int
-nid_kepcmp(const void *key, struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- LASSERT(key);
- exp = hlist_entry(hnode, struct obd_export, exp_nid_hash);
-
- return exp->exp_connection->c_peer.nid == *(lnet_nid_t *)key &&
- !exp->exp_failed;
-}
-
-static void *
-nid_export_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct obd_export, exp_nid_hash);
-}
-
-static void
-nid_export_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- exp = hlist_entry(hnode, struct obd_export, exp_nid_hash);
- class_export_get(exp);
-}
-
-static void
-nid_export_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct obd_export *exp;
-
- exp = hlist_entry(hnode, struct obd_export, exp_nid_hash);
- class_export_put(exp);
-}
-
-static cfs_hash_ops_t nid_hash_ops = {
- .hs_hash = nid_hash,
- .hs_key = nid_key,
- .hs_keycmp = nid_kepcmp,
- .hs_object = nid_export_object,
- .hs_get = nid_export_get,
- .hs_put_locked = nid_export_put_locked,
-};
-
-
-/*
- * nid<->nidstats hash operations
- */
-
-static void *
-nidstats_key(struct hlist_node *hnode)
-{
- struct nid_stat *ns;
-
- ns = hlist_entry(hnode, struct nid_stat, nid_hash);
-
- return &ns->nid;
-}
-
-static int
-nidstats_keycmp(const void *key, struct hlist_node *hnode)
-{
- return *(lnet_nid_t *)nidstats_key(hnode) == *(lnet_nid_t *)key;
-}
-
-static void *
-nidstats_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct nid_stat, nid_hash);
-}
-
-static void
-nidstats_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct nid_stat *ns;
-
- ns = hlist_entry(hnode, struct nid_stat, nid_hash);
- nidstat_getref(ns);
-}
-
-static void
-nidstats_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct nid_stat *ns;
-
- ns = hlist_entry(hnode, struct nid_stat, nid_hash);
- nidstat_putref(ns);
-}
-
-static cfs_hash_ops_t nid_stat_hash_ops = {
- .hs_hash = nid_hash,
- .hs_key = nidstats_key,
- .hs_keycmp = nidstats_keycmp,
- .hs_object = nidstats_object,
- .hs_get = nidstats_get,
- .hs_put_locked = nidstats_put_locked,
-};
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/kernel/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index 3437b2ecf..48003d532 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -40,7 +40,6 @@
* Author: Nathan Rutman <nathan@clusterfs.com>
*/
-
#define DEBUG_SUBSYSTEM S_CLASS
#define D_MOUNT (D_SUPER|D_CONFIG/*|D_WARNING */)
#define PRINT_CMD CDEBUG
@@ -84,8 +83,8 @@ int lustre_process_log(struct super_block *sb, char *logname,
LASSERT(mgc);
LASSERT(cfg);
- OBD_ALLOC_PTR(bufs);
- if (bufs == NULL)
+ bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
+ if (!bufs)
return -ENOMEM;
/* mgc_process_config */
@@ -97,7 +96,7 @@ int lustre_process_log(struct super_block *sb, char *logname,
rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
lustre_cfg_free(lcfg);
- OBD_FREE_PTR(bufs);
+ kfree(bufs);
if (rc == -EINVAL)
LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n",
@@ -143,11 +142,11 @@ EXPORT_SYMBOL(lustre_end_log);
/** lustre_cfg_bufs are a holdover from 1.4; we can still set these up from
* lctl (and do for echo cli/srv.
*/
-int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
- char *s1, char *s2, char *s3, char *s4)
+static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
+ char *s1, char *s2, char *s3, char *s4)
{
struct lustre_cfg_bufs bufs;
- struct lustre_cfg * lcfg = NULL;
+ struct lustre_cfg *lcfg = NULL;
int rc;
CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname,
@@ -169,15 +168,15 @@ int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
lustre_cfg_free(lcfg);
return rc;
}
-EXPORT_SYMBOL(do_lcfg);
/** Call class_attach and class_setup. These methods in turn call
* obd type-specific methods.
*/
-int lustre_start_simple(char *obdname, char *type, char *uuid,
- char *s1, char *s2, char *s3, char *s4)
+static int lustre_start_simple(char *obdname, char *type, char *uuid,
+ char *s1, char *s2, char *s3, char *s4)
{
int rc;
+
CDEBUG(D_MOUNT, "Starting obd %s (typ=%s)\n", obdname, type);
rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, NULL, NULL);
@@ -210,35 +209,17 @@ int lustre_start_mgc(struct super_block *sb)
struct obd_uuid *uuid;
class_uuid_t uuidc;
lnet_nid_t nid;
+ char nidstr[LNET_NIDSTR_SIZE];
char *mgcname = NULL, *niduuid = NULL, *mgssec = NULL;
char *ptr;
- int rc = 0, i = 0, j, len;
+ int rc = 0, i = 0, j;
LASSERT(lsi->lsi_lmd);
- /* Find the first non-lo MGS nid for our MGC name */
- if (IS_SERVER(lsi)) {
- /* mount -o mgsnode=nid */
- ptr = lsi->lsi_lmd->lmd_mgs;
- if (lsi->lsi_lmd->lmd_mgs &&
- (class_parse_nid(lsi->lsi_lmd->lmd_mgs, &nid, &ptr) == 0)) {
- i++;
- } else if (IS_MGS(lsi)) {
- lnet_process_id_t id;
- while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
- if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND)
- continue;
- nid = id.nid;
- i++;
- break;
- }
- }
- } else { /* client */
- /* Use nids from mount line: uml1,1@elan:uml2,2@elan:/lustre */
- ptr = lsi->lsi_lmd->lmd_dev;
- if (class_parse_nid(ptr, &nid, &ptr) == 0)
- i++;
- }
+ /* Use nids from mount line: uml1,1@elan:uml2,2@elan:/lustre */
+ ptr = lsi->lsi_lmd->lmd_dev;
+ if (class_parse_nid(ptr, &nid, &ptr) == 0)
+ i++;
if (i == 0) {
CERROR("No valid MGS nids found.\n");
return -EINVAL;
@@ -246,19 +227,19 @@ int lustre_start_mgc(struct super_block *sb)
mutex_lock(&mgc_start_lock);
- len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1;
- OBD_ALLOC(mgcname, len);
- OBD_ALLOC(niduuid, len + 2);
+ libcfs_nid2str_r(nid, nidstr, sizeof(nidstr));
+ mgcname = kasprintf(GFP_NOFS,
+ "%s%s", LUSTRE_MGC_OBDNAME, nidstr);
+ niduuid = kasprintf(GFP_NOFS, "%s_%x", mgcname, i);
if (!mgcname || !niduuid) {
rc = -ENOMEM;
goto out_free;
}
- sprintf(mgcname, "%s%s", LUSTRE_MGC_OBDNAME, libcfs_nid2str(nid));
mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
- OBD_ALLOC_PTR(data);
- if (data == NULL) {
+ data = kzalloc(sizeof(*data), GFP_NOFS);
+ if (!data) {
rc = -ENOMEM;
goto out_free;
}
@@ -300,12 +281,6 @@ int lustre_start_mgc(struct super_block *sb)
}
recov_bk = 0;
- /* If we are restarting the MGS, don't try to keep the MGC's
- old connection, or registration will fail. */
- if (IS_MGS(lsi)) {
- CDEBUG(D_MOUNT, "New MGS with live MGC\n");
- recov_bk = 1;
- }
/* Try all connections, but only once (again).
We don't want to block another target from starting
@@ -326,46 +301,15 @@ int lustre_start_mgc(struct super_block *sb)
/* Add the primary nids for the MGS */
i = 0;
- sprintf(niduuid, "%s_%x", mgcname, i);
- if (IS_SERVER(lsi)) {
- ptr = lsi->lsi_lmd->lmd_mgs;
- if (IS_MGS(lsi)) {
- /* Use local nids (including LO) */
- lnet_process_id_t id;
- while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
- rc = do_lcfg(mgcname, id.nid,
- LCFG_ADD_UUID, niduuid,
- NULL, NULL, NULL);
- }
- } else {
- /* Use mgsnode= nids */
- /* mount -o mgsnode=nid */
- if (lsi->lsi_lmd->lmd_mgs) {
- ptr = lsi->lsi_lmd->lmd_mgs;
- } else if (class_find_param(ptr, PARAM_MGSNODE,
- &ptr) != 0) {
- CERROR("No MGS nids given.\n");
- rc = -EINVAL;
- goto out_free;
- }
- while (class_parse_nid(ptr, &nid, &ptr) == 0) {
- rc = do_lcfg(mgcname, nid,
- LCFG_ADD_UUID, niduuid,
- NULL, NULL, NULL);
- i++;
- }
- }
- } else { /* client */
- /* Use nids from mount line: uml1,1@elan:uml2,2@elan:/lustre */
- ptr = lsi->lsi_lmd->lmd_dev;
- while (class_parse_nid(ptr, &nid, &ptr) == 0) {
- rc = do_lcfg(mgcname, nid,
- LCFG_ADD_UUID, niduuid, NULL, NULL, NULL);
- i++;
- /* Stop at the first failover nid */
- if (*ptr == ':')
- break;
- }
+ /* Use nids from mount line: uml1,1@elan:uml2,2@elan:/lustre */
+ ptr = lsi->lsi_lmd->lmd_dev;
+ while (class_parse_nid(ptr, &nid, &ptr) == 0) {
+ rc = do_lcfg(mgcname, nid,
+ LCFG_ADD_UUID, niduuid, NULL, NULL, NULL);
+ i++;
+ /* Stop at the first failover nid */
+ if (*ptr == ':')
+ break;
}
if (i == 0) {
CERROR("No valid MGS nids found.\n");
@@ -375,7 +319,7 @@ int lustre_start_mgc(struct super_block *sb)
lsi->lsi_lmd->lmd_mgs_failnodes = 1;
/* Random uuid for MGC allows easier reconnects */
- OBD_ALLOC_PTR(uuid);
+ uuid = kzalloc(sizeof(*uuid), GFP_NOFS);
if (!uuid) {
rc = -ENOMEM;
goto out_free;
@@ -388,7 +332,7 @@ int lustre_start_mgc(struct super_block *sb)
rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
(char *)uuid->uuid, LUSTRE_MGS_OBDNAME,
niduuid, NULL, NULL);
- OBD_FREE_PTR(uuid);
+ kfree(uuid);
if (rc)
goto out_free;
@@ -464,12 +408,9 @@ out:
out_free:
mutex_unlock(&mgc_start_lock);
- if (data)
- OBD_FREE_PTR(data);
- if (mgcname)
- OBD_FREE(mgcname, len);
- if (niduuid)
- OBD_FREE(niduuid, len + 2);
+ kfree(data);
+ kfree(mgcname);
+ kfree(niduuid);
return rc;
}
@@ -513,7 +454,7 @@ static int lustre_stop_mgc(struct super_block *sb)
/* Save the obdname for cleaning the nid uuids, which are
obdname_XX */
len = strlen(obd->obd_name) + 6;
- OBD_ALLOC(niduuid, len);
+ niduuid = kzalloc(len, GFP_NOFS);
if (niduuid) {
strcpy(niduuid, obd->obd_name);
ptr = niduuid + strlen(niduuid);
@@ -538,8 +479,7 @@ static int lustre_stop_mgc(struct super_block *sb)
niduuid, rc);
}
out:
- if (niduuid)
- OBD_FREE(niduuid, len);
+ kfree(niduuid);
/* class_import_put will get rid of the additional connections */
mutex_unlock(&mgc_start_lock);
@@ -548,16 +488,16 @@ out:
/***************** lustre superblock **************/
-struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
+static struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
{
struct lustre_sb_info *lsi;
- OBD_ALLOC_PTR(lsi);
+ lsi = kzalloc(sizeof(*lsi), GFP_NOFS);
if (!lsi)
return NULL;
- OBD_ALLOC_PTR(lsi->lsi_lmd);
+ lsi->lsi_lmd = kzalloc(sizeof(*lsi->lsi_lmd), GFP_NOFS);
if (!lsi->lsi_lmd) {
- OBD_FREE_PTR(lsi);
+ kfree(lsi);
return NULL;
}
@@ -585,36 +525,21 @@ static int lustre_free_lsi(struct super_block *sb)
LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
if (lsi->lsi_lmd != NULL) {
- if (lsi->lsi_lmd->lmd_dev != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_dev,
- strlen(lsi->lsi_lmd->lmd_dev) + 1);
- if (lsi->lsi_lmd->lmd_profile != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_profile,
- strlen(lsi->lsi_lmd->lmd_profile) + 1);
- if (lsi->lsi_lmd->lmd_mgssec != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_mgssec,
- strlen(lsi->lsi_lmd->lmd_mgssec) + 1);
- if (lsi->lsi_lmd->lmd_opts != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_opts,
- strlen(lsi->lsi_lmd->lmd_opts) + 1);
+ kfree(lsi->lsi_lmd->lmd_dev);
+ kfree(lsi->lsi_lmd->lmd_profile);
+ kfree(lsi->lsi_lmd->lmd_mgssec);
+ kfree(lsi->lsi_lmd->lmd_opts);
if (lsi->lsi_lmd->lmd_exclude_count)
- OBD_FREE(lsi->lsi_lmd->lmd_exclude,
- sizeof(lsi->lsi_lmd->lmd_exclude[0]) *
- lsi->lsi_lmd->lmd_exclude_count);
- if (lsi->lsi_lmd->lmd_mgs != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_mgs,
- strlen(lsi->lsi_lmd->lmd_mgs) + 1);
- if (lsi->lsi_lmd->lmd_osd_type != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_osd_type,
- strlen(lsi->lsi_lmd->lmd_osd_type) + 1);
- if (lsi->lsi_lmd->lmd_params != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_params, 4096);
-
- OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd));
+ kfree(lsi->lsi_lmd->lmd_exclude);
+ kfree(lsi->lsi_lmd->lmd_mgs);
+ kfree(lsi->lsi_lmd->lmd_osd_type);
+ kfree(lsi->lsi_lmd->lmd_params);
+
+ kfree(lsi->lsi_lmd);
}
LASSERT(lsi->lsi_llsbi == NULL);
- OBD_FREE(lsi, sizeof(*lsi));
+ kfree(lsi);
s2lsi_nocast(sb) = NULL;
return 0;
@@ -622,7 +547,7 @@ static int lustre_free_lsi(struct super_block *sb)
/* The lsi has one reference for every server that is using the disk -
e.g. MDT, MGS, and potentially MGC */
-int lustre_put_lsi(struct super_block *sb)
+static int lustre_put_lsi(struct super_block *sb)
{
struct lustre_sb_info *lsi = s2lsi(sb);
@@ -630,14 +555,6 @@ int lustre_put_lsi(struct super_block *sb)
CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts));
if (atomic_dec_and_test(&lsi->lsi_mounts)) {
- if (IS_SERVER(lsi) && lsi->lsi_osd_exp) {
- lu_device_put(&lsi->lsi_dt_dev->dd_lu_dev);
- lsi->lsi_osd_exp->exp_obd->obd_lvfs_ctxt.dt = NULL;
- lsi->lsi_dt_dev = NULL;
- obd_disconnect(lsi->lsi_osd_exp);
- /* wait till OSD is gone */
- obd_zombie_barrier();
- }
lustre_free_lsi(sb);
return 1;
}
@@ -660,7 +577,8 @@ int lustre_put_lsi(struct super_block *sb)
* @param [out] endptr if endptr isn't NULL it is set to end of fsname
* rc < 0 on error
*/
-int server_name2fsname(const char *svname, char *fsname, const char **endptr)
+static int server_name2fsname(const char *svname, char *fsname,
+ const char **endptr)
{
const char *dash;
@@ -680,40 +598,13 @@ int server_name2fsname(const char *svname, char *fsname, const char **endptr)
return 0;
}
-EXPORT_SYMBOL(server_name2fsname);
-
-/**
- * Get service name (svname) from string
- * rc < 0 on error
- * if endptr isn't NULL it is set to end of fsname *
- */
-int server_name2svname(const char *label, char *svname, const char **endptr,
- size_t svsize)
-{
- int rc;
- const char *dash;
-
- /* We use server_name2fsname() just for parsing */
- rc = server_name2fsname(label, NULL, &dash);
- if (rc != 0)
- return rc;
-
- if (endptr != NULL)
- *endptr = dash;
-
- if (strlcpy(svname, dash + 1, svsize) >= svsize)
- return -E2BIG;
-
- return 0;
-}
-EXPORT_SYMBOL(server_name2svname);
-
/* Get the index from the obd name.
rc = server type, or
rc < 0 on error
if endptr isn't NULL it is set to end of name */
-int server_name2index(const char *svname, __u32 *idx, const char **endptr)
+static int server_name2index(const char *svname, __u32 *idx,
+ const char **endptr)
{
unsigned long index;
int rc;
@@ -752,7 +643,6 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr)
return rc;
}
-EXPORT_SYMBOL(server_name2index);
/*************** mount common between server and client ***************/
@@ -846,7 +736,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
devmax = strlen(ptr) / 8 + 1;
/* temp storage until we figure out how many we have */
- OBD_ALLOC(exclude_list, sizeof(index) * devmax);
+ exclude_list = kcalloc(devmax, sizeof(index), GFP_NOFS);
if (!exclude_list)
return -ENOMEM;
@@ -875,8 +765,8 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
if (lmd->lmd_exclude_count) {
/* permanent, freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_exclude, sizeof(index) *
- lmd->lmd_exclude_count);
+ lmd->lmd_exclude = kcalloc(lmd->lmd_exclude_count,
+ sizeof(index), GFP_NOFS);
if (lmd->lmd_exclude) {
memcpy(lmd->lmd_exclude, exclude_list,
sizeof(index) * lmd->lmd_exclude_count);
@@ -885,7 +775,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
lmd->lmd_exclude_count = 0;
}
}
- OBD_FREE(exclude_list, sizeof(index) * devmax);
+ kfree(exclude_list);
return rc;
}
@@ -894,10 +784,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
char *tail;
int length;
- if (lmd->lmd_mgssec != NULL) {
- OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
- lmd->lmd_mgssec = NULL;
- }
+ kfree(lmd->lmd_mgssec);
+ lmd->lmd_mgssec = NULL;
tail = strchr(ptr, ',');
if (tail == NULL)
@@ -905,8 +793,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
else
length = tail - ptr;
- OBD_ALLOC(lmd->lmd_mgssec, length + 1);
- if (lmd->lmd_mgssec == NULL)
+ lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS);
+ if (!lmd->lmd_mgssec)
return -ENOMEM;
memcpy(lmd->lmd_mgssec, ptr, length);
@@ -922,10 +810,8 @@ static int lmd_parse_string(char **handle, char *ptr)
if ((handle == NULL) || (ptr == NULL))
return -EINVAL;
- if (*handle != NULL) {
- OBD_FREE(*handle, strlen(*handle) + 1);
- *handle = NULL;
- }
+ kfree(*handle);
+ *handle = NULL;
tail = strchr(ptr, ',');
if (tail == NULL)
@@ -933,8 +819,8 @@ static int lmd_parse_string(char **handle, char *ptr)
else
length = tail - ptr;
- OBD_ALLOC(*handle, length + 1);
- if (*handle == NULL)
+ *handle = kzalloc(length + 1, GFP_NOFS);
+ if (!*handle)
return -ENOMEM;
memcpy(*handle, ptr, length);
@@ -953,7 +839,8 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
int oldlen = 0;
/* Find end of nidlist */
- while (class_parse_nid_quiet(tail, &nid, &tail) == 0) {}
+ while (class_parse_nid_quiet(tail, &nid, &tail) == 0)
+ ;
length = tail - *ptr;
if (length == 0) {
LCONSOLE_ERROR_MSG(0x159, "Can't parse NID '%s'\n", *ptr);
@@ -963,15 +850,15 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
if (lmd->lmd_mgs != NULL)
oldlen = strlen(lmd->lmd_mgs) + 1;
- OBD_ALLOC(mgsnid, oldlen + length + 1);
- if (mgsnid == NULL)
+ mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS);
+ if (!mgsnid)
return -ENOMEM;
if (lmd->lmd_mgs != NULL) {
/* Multiple mgsnid= are taken to mean failover locations */
memcpy(mgsnid, lmd->lmd_mgs, oldlen);
mgsnid[oldlen - 1] = ':';
- OBD_FREE(lmd->lmd_mgs, oldlen);
+ kfree(lmd->lmd_mgs);
}
memcpy(mgsnid + oldlen, *ptr, length);
mgsnid[oldlen + length] = '\0';
@@ -1005,8 +892,8 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
}
lmd->lmd_magic = LMD_MAGIC;
- OBD_ALLOC(lmd->lmd_params, 4096);
- if (lmd->lmd_params == NULL)
+ lmd->lmd_params = kzalloc(4096, GFP_NOFS);
+ if (!lmd->lmd_params)
return -ENOMEM;
lmd->lmd_params[0] = '\0';
@@ -1093,6 +980,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
} else if (strncmp(s1, "param=", 6) == 0) {
int length;
char *tail = strchr(s1 + 6, ',');
+
if (tail == NULL)
length = strlen(s1);
else
@@ -1141,16 +1029,16 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
++s1;
lmd->lmd_flags |= LMD_FLG_CLIENT;
/* Remove leading /s from fsname */
- while (*++s1 == '/') ;
+ while (*++s1 == '/')
+ ;
/* Freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_profile, strlen(s1) + 8);
+ lmd->lmd_profile = kasprintf(GFP_NOFS, "%s-client", s1);
if (!lmd->lmd_profile)
return -ENOMEM;
- sprintf(lmd->lmd_profile, "%s-client", s1);
}
/* Freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1);
+ lmd->lmd_dev = kzalloc(strlen(devname) + 1, GFP_NOFS);
if (!lmd->lmd_dev)
return -ENOMEM;
strcpy(lmd->lmd_dev, devname);
@@ -1161,7 +1049,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
*s1-- = 0;
if (*options != 0) {
/* Freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1);
+ lmd->lmd_opts = kzalloc(strlen(options) + 1, GFP_NOFS);
if (!lmd->lmd_opts)
return -ENOMEM;
strcpy(lmd->lmd_opts, options);
@@ -1187,7 +1075,7 @@ struct lustre_mount_data2 {
* and this is where we start setting things up.
* @param data Mount options (e.g. -o flock,abort_recov)
*/
-int lustre_fill_super(struct super_block *sb, void *data, int silent)
+static int lustre_fill_super(struct super_block *sb, void *data, int silent)
{
struct lustre_mount_data *lmd;
struct lustre_mount_data2 *lmd2 = data;
@@ -1213,7 +1101,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
obd_zombie_barrier();
/* Figure out the lmd from the mount options */
- if (lmd_parse((char *)(lmd2->lmd2_data), lmd)) {
+ if (lmd_parse((lmd2->lmd2_data), lmd)) {
lustre_put_lsi(sb);
rc = -EINVAL;
goto out;
@@ -1258,7 +1146,6 @@ out:
return rc;
}
-
/* We can't call ll_fill_super by name because it lives in a module that
must be loaded after this one. */
void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb,
@@ -1290,7 +1177,7 @@ static void lustre_kill_super(struct super_block *sb)
{
struct lustre_sb_info *lsi = s2lsi(sb);
- if (kill_super_cb && lsi && !IS_SERVER(lsi))
+ if (kill_super_cb && lsi)
(*kill_super_cb)(sb);
kill_anon_super(sb);
@@ -1298,13 +1185,13 @@ static void lustre_kill_super(struct super_block *sb)
/** Register the "lustre" fs type
*/
-struct file_system_type lustre_fs_type = {
+static struct file_system_type lustre_fs_type = {
.owner = THIS_MODULE,
.name = "lustre",
.mount = lustre_mount,
.kill_sb = lustre_kill_super,
.fs_flags = FS_BINARY_MOUNTDATA | FS_REQUIRES_DEV |
- FS_HAS_FIEMAP | FS_RENAME_DOES_D_MOVE,
+ FS_RENAME_DOES_D_MOVE,
};
MODULE_ALIAS_FS("lustre");
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/obdo.c b/kernel/drivers/staging/lustre/lustre/obdclass/obdo.c
index 307ffe347..75e1deadd 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/obdo.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/obdo.c
@@ -115,90 +115,6 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, u32 valid)
}
EXPORT_SYMBOL(obdo_from_inode);
-void obdo_cpy_md(struct obdo *dst, struct obdo *src, u32 valid)
-{
- CDEBUG(D_INODE, "src obdo "DOSTID" valid %#llx, dst obdo "DOSTID"\n",
- POSTID(&src->o_oi), src->o_valid, POSTID(&dst->o_oi));
- if (valid & OBD_MD_FLATIME)
- dst->o_atime = src->o_atime;
- if (valid & OBD_MD_FLMTIME)
- dst->o_mtime = src->o_mtime;
- if (valid & OBD_MD_FLCTIME)
- dst->o_ctime = src->o_ctime;
- if (valid & OBD_MD_FLSIZE)
- dst->o_size = src->o_size;
- if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
- dst->o_blocks = src->o_blocks;
- if (valid & OBD_MD_FLBLKSZ)
- dst->o_blksize = src->o_blksize;
- if (valid & OBD_MD_FLTYPE)
- dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
- if (valid & OBD_MD_FLMODE)
- dst->o_mode = (dst->o_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
- if (valid & OBD_MD_FLUID)
- dst->o_uid = src->o_uid;
- if (valid & OBD_MD_FLGID)
- dst->o_gid = src->o_gid;
- if (valid & OBD_MD_FLFLAGS)
- dst->o_flags = src->o_flags;
- if (valid & OBD_MD_FLFID) {
- dst->o_parent_seq = src->o_parent_seq;
- dst->o_parent_ver = src->o_parent_ver;
- }
- if (valid & OBD_MD_FLGENER)
- dst->o_parent_oid = src->o_parent_oid;
- if (valid & OBD_MD_FLHANDLE)
- dst->o_handle = src->o_handle;
- if (valid & OBD_MD_FLCOOKIE)
- dst->o_lcookie = src->o_lcookie;
-
- dst->o_valid |= valid;
-}
-EXPORT_SYMBOL(obdo_cpy_md);
-
-/* returns FALSE if comparison (by flags) is same, TRUE if changed */
-int obdo_cmp_md(struct obdo *dst, struct obdo *src, u32 compare)
-{
- int res = 0;
-
- if (compare & OBD_MD_FLATIME)
- res |= dst->o_atime != src->o_atime;
- if (compare & OBD_MD_FLMTIME)
- res |= dst->o_mtime != src->o_mtime;
- if (compare & OBD_MD_FLCTIME)
- res |= dst->o_ctime != src->o_ctime;
- if (compare & OBD_MD_FLSIZE)
- res |= dst->o_size != src->o_size;
- if (compare & OBD_MD_FLBLOCKS) /* allocation of space */
- res |= dst->o_blocks != src->o_blocks;
- if (compare & OBD_MD_FLBLKSZ)
- res |= dst->o_blksize != src->o_blksize;
- if (compare & OBD_MD_FLTYPE)
- res |= ((dst->o_mode ^ src->o_mode) & S_IFMT) != 0;
- if (compare & OBD_MD_FLMODE)
- res |= ((dst->o_mode ^ src->o_mode) & ~S_IFMT) != 0;
- if (compare & OBD_MD_FLUID)
- res |= dst->o_uid != src->o_uid;
- if (compare & OBD_MD_FLGID)
- res |= dst->o_gid != src->o_gid;
- if (compare & OBD_MD_FLFLAGS)
- res |= dst->o_flags != src->o_flags;
- if (compare & OBD_MD_FLNLINK)
- res |= dst->o_nlink != src->o_nlink;
- if (compare & OBD_MD_FLFID) {
- res |= dst->o_parent_seq != src->o_parent_seq;
- res |= dst->o_parent_ver != src->o_parent_ver;
- }
- if (compare & OBD_MD_FLGENER)
- res |= dst->o_parent_oid != src->o_parent_oid;
- /* XXX Don't know if these should be included here - wasn't previously
- if ( compare & OBD_MD_FLINLINE )
- res |= memcmp(dst->o_inline, src->o_inline);
- */
- return res;
-}
-EXPORT_SYMBOL(obdo_cmp_md);
-
void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj)
{
ioobj->ioo_oid = oa->o_oi;
@@ -211,43 +127,7 @@ void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj)
}
EXPORT_SYMBOL(obdo_to_ioobj);
-void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid)
-{
- if (ia_valid & ATTR_ATIME) {
- oa->o_atime = LTIME_S(attr->ia_atime);
- oa->o_valid |= OBD_MD_FLATIME;
- }
- if (ia_valid & ATTR_MTIME) {
- oa->o_mtime = LTIME_S(attr->ia_mtime);
- oa->o_valid |= OBD_MD_FLMTIME;
- }
- if (ia_valid & ATTR_CTIME) {
- oa->o_ctime = LTIME_S(attr->ia_ctime);
- oa->o_valid |= OBD_MD_FLCTIME;
- }
- if (ia_valid & ATTR_SIZE) {
- oa->o_size = attr->ia_size;
- oa->o_valid |= OBD_MD_FLSIZE;
- }
- if (ia_valid & ATTR_MODE) {
- oa->o_mode = attr->ia_mode;
- oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE;
- if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) &&
- !capable(CFS_CAP_FSETID))
- oa->o_mode &= ~S_ISGID;
- }
- if (ia_valid & ATTR_UID) {
- oa->o_uid = from_kuid(&init_user_ns, attr->ia_uid);
- oa->o_valid |= OBD_MD_FLUID;
- }
- if (ia_valid & ATTR_GID) {
- oa->o_gid = from_kgid(&init_user_ns, attr->ia_gid);
- oa->o_valid |= OBD_MD_FLGID;
- }
-}
-EXPORT_SYMBOL(obdo_from_iattr);
-
-void iattr_from_obdo(struct iattr *attr, struct obdo *oa, u32 valid)
+static void iattr_from_obdo(struct iattr *attr, struct obdo *oa, u32 valid)
{
valid &= oa->o_valid;
@@ -294,7 +174,6 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, u32 valid)
attr->ia_valid |= ATTR_GID;
}
}
-EXPORT_SYMBOL(iattr_from_obdo);
void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, u32 valid)
{
@@ -310,53 +189,3 @@ void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, u32 valid)
}
}
EXPORT_SYMBOL(md_from_obdo);
-
-void obdo_from_md(struct obdo *oa, struct md_op_data *op_data,
- unsigned int valid)
-{
- obdo_from_iattr(oa, &op_data->op_attr, valid);
- if (valid & ATTR_BLOCKS) {
- oa->o_blocks = op_data->op_attr_blocks;
- oa->o_valid |= OBD_MD_FLBLOCKS;
- }
- if (valid & ATTR_ATTR_FLAG) {
- oa->o_flags =
- ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags;
- oa->o_valid |= OBD_MD_FLFLAGS;
- }
-}
-EXPORT_SYMBOL(obdo_from_md);
-
-void obdo_cpu_to_le(struct obdo *dobdo, struct obdo *sobdo)
-{
- dobdo->o_size = cpu_to_le64(sobdo->o_size);
- dobdo->o_mtime = cpu_to_le64(sobdo->o_mtime);
- dobdo->o_atime = cpu_to_le64(sobdo->o_atime);
- dobdo->o_ctime = cpu_to_le64(sobdo->o_ctime);
- dobdo->o_blocks = cpu_to_le64(sobdo->o_blocks);
- dobdo->o_mode = cpu_to_le32(sobdo->o_mode);
- dobdo->o_uid = cpu_to_le32(sobdo->o_uid);
- dobdo->o_gid = cpu_to_le32(sobdo->o_gid);
- dobdo->o_flags = cpu_to_le32(sobdo->o_flags);
- dobdo->o_nlink = cpu_to_le32(sobdo->o_nlink);
- dobdo->o_blksize = cpu_to_le32(sobdo->o_blksize);
- dobdo->o_valid = cpu_to_le64(sobdo->o_valid);
-}
-EXPORT_SYMBOL(obdo_cpu_to_le);
-
-void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo)
-{
- dobdo->o_size = le64_to_cpu(sobdo->o_size);
- dobdo->o_mtime = le64_to_cpu(sobdo->o_mtime);
- dobdo->o_atime = le64_to_cpu(sobdo->o_atime);
- dobdo->o_ctime = le64_to_cpu(sobdo->o_ctime);
- dobdo->o_blocks = le64_to_cpu(sobdo->o_blocks);
- dobdo->o_mode = le32_to_cpu(sobdo->o_mode);
- dobdo->o_uid = le32_to_cpu(sobdo->o_uid);
- dobdo->o_gid = le32_to_cpu(sobdo->o_gid);
- dobdo->o_flags = le32_to_cpu(sobdo->o_flags);
- dobdo->o_nlink = le32_to_cpu(sobdo->o_nlink);
- dobdo->o_blksize = le32_to_cpu(sobdo->o_blksize);
- dobdo->o_valid = le64_to_cpu(sobdo->o_valid);
-}
-EXPORT_SYMBOL(obdo_le_to_cpu);
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/statfs_pack.c b/kernel/drivers/staging/lustre/lustre/obdclass/statfs_pack.c
index cc785ab3f..fb4e3ae84 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/statfs_pack.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/statfs_pack.c
@@ -46,20 +46,6 @@
#include "../include/obd_support.h"
#include "../include/obd_class.h"
-void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs)
-{
- memset(osfs, 0, sizeof(*osfs));
- osfs->os_type = sfs->f_type;
- osfs->os_blocks = sfs->f_blocks;
- osfs->os_bfree = sfs->f_bfree;
- osfs->os_bavail = sfs->f_bavail;
- osfs->os_files = sfs->f_files;
- osfs->os_ffree = sfs->f_ffree;
- osfs->os_bsize = sfs->f_bsize;
- osfs->os_namelen = sfs->f_namelen;
-}
-EXPORT_SYMBOL(statfs_pack);
-
void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs)
{
memset(sfs, 0, sizeof(*sfs));
diff --git a/kernel/drivers/staging/lustre/lustre/obdclass/uuid.c b/kernel/drivers/staging/lustre/lustre/obdclass/uuid.c
index ff0a01bcf..b0b0157a6 100644
--- a/kernel/drivers/staging/lustre/lustre/obdclass/uuid.c
+++ b/kernel/drivers/staging/lustre/lustre/obdclass/uuid.c
@@ -43,40 +43,8 @@
#include "../include/obd_support.h"
#include "../include/obd_class.h"
-
-static inline __u32 consume(int nob, __u8 **ptr)
-{
- __u32 value;
-
- LASSERT(nob <= sizeof(value));
-
- for (value = 0; nob > 0; --nob)
- value = (value << 8) | *((*ptr)++);
- return value;
-}
-
-#define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr))
-
-static void uuid_unpack(class_uuid_t in, __u16 *uu, int nr)
-{
- __u8 *ptr = in;
-
- LASSERT(nr * sizeof(*uu) == sizeof(class_uuid_t));
-
- while (nr-- > 0)
- CONSUME(uu[nr], &ptr);
-}
-
void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
{
- /* uu as an array of __u16's */
- __u16 uuid[sizeof(class_uuid_t) / sizeof(__u16)];
-
- CLASSERT(ARRAY_SIZE(uuid) == 8);
-
- uuid_unpack(uu, uuid, ARRAY_SIZE(uuid));
- sprintf(out->uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7]);
+ sprintf(out->uuid, "%pU", uu);
}
EXPORT_SYMBOL(class_uuid_unparse);
diff --git a/kernel/drivers/staging/lustre/lustre/obdecho/Makefile b/kernel/drivers/staging/lustre/lustre/obdecho/Makefile
index 672028fc7..a659a37a7 100644
--- a/kernel/drivers/staging/lustre/lustre/obdecho/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/obdecho/Makefile
@@ -1,2 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += obdecho.o
-obdecho-y := echo_client.o lproc_echo.o
+obdecho-y := echo_client.o
diff --git a/kernel/drivers/staging/lustre/lustre/obdecho/echo_client.c b/kernel/drivers/staging/lustre/lustre/obdecho/echo_client.c
index d542e06d6..a4a9a763f 100644
--- a/kernel/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/kernel/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -98,7 +98,6 @@ static int echo_client_setup(const struct lu_env *env,
struct lustre_cfg *lcfg);
static int echo_client_cleanup(struct obd_device *obddev);
-
/** \defgroup echo_helpers Helper functions
* @{
*/
@@ -323,6 +322,7 @@ static const struct cl_page_operations echo_page_ops = {
}
}
};
+
/** @} echo_page */
/** \defgroup echo_lock Locking
@@ -337,7 +337,7 @@ static void echo_lock_fini(const struct lu_env *env,
struct echo_lock *ecl = cl2echo_lock(slice);
LASSERT(list_empty(&ecl->el_chain));
- OBD_SLAB_FREE_PTR(ecl, echo_lock_kmem);
+ kmem_cache_free(echo_lock_kmem, ecl);
}
static void echo_lock_delete(const struct lu_env *env,
@@ -396,7 +396,7 @@ static int echo_lock_init(const struct lu_env *env,
{
struct echo_lock *el;
- OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, GFP_NOFS);
+ el = kmem_cache_alloc(echo_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (el != NULL) {
cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops);
el->el_object = cl2echo_obj(obj);
@@ -418,6 +418,7 @@ static const struct cl_object_operations echo_cl_obj_ops = {
.coo_io_init = echo_io_init,
.coo_conf_set = echo_conf_set
};
+
/** @} echo_cl_ops */
/** \defgroup echo_lu_ops lu_object operations
@@ -479,13 +480,13 @@ static int echo_alloc_memmd(struct echo_device *ed,
lsm_size = lov_stripe_md_size(1);
LASSERT(*lsmp == NULL);
- OBD_ALLOC(*lsmp, lsm_size);
- if (*lsmp == NULL)
+ *lsmp = kzalloc(lsm_size, GFP_NOFS);
+ if (!*lsmp)
return -ENOMEM;
- OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
- if ((*lsmp)->lsm_oinfo[0] == NULL) {
- OBD_FREE(*lsmp, lsm_size);
+ (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS);
+ if (!(*lsmp)->lsm_oinfo[0]) {
+ kfree(*lsmp);
return -ENOMEM;
}
@@ -507,8 +508,8 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp)
lsm_size = lov_stripe_md_size(1);
LASSERT(*lsmp != NULL);
- OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
- OBD_FREE(*lsmp, lsm_size);
+ kfree((*lsmp)->lsm_oinfo[0]);
+ kfree(*lsmp);
*lsmp = NULL;
return 0;
}
@@ -529,7 +530,7 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj)
if (eco->eo_lsm)
echo_free_memmd(eco->eo_dev, &eco->eo_lsm);
- OBD_SLAB_FREE_PTR(eco, echo_object_kmem);
+ kmem_cache_free(echo_object_kmem, eco);
}
static int echo_object_print(const struct lu_env *env, void *cookie,
@@ -548,6 +549,7 @@ static const struct lu_object_operations echo_lu_obj_ops = {
.loo_object_print = echo_object_print,
.loo_object_invariant = NULL
};
+
/** @} echo_lu_ops */
/** \defgroup echo_lu_dev_ops lu_device operations
@@ -565,7 +567,7 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env,
/* we're the top dev. */
LASSERT(hdr == NULL);
- OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, GFP_NOFS);
+ eco = kmem_cache_alloc(echo_object_kmem, GFP_NOFS | __GFP_ZERO);
if (eco != NULL) {
struct cl_object_header *hdr = &eco->eo_hdr;
@@ -628,7 +630,7 @@ static void *echo_thread_key_init(const struct lu_context *ctx,
{
struct echo_thread_info *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, GFP_NOFS);
+ info = kmem_cache_alloc(echo_thread_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
@@ -639,7 +641,7 @@ static void echo_thread_key_fini(const struct lu_context *ctx,
{
struct echo_thread_info *info = data;
- OBD_SLAB_FREE_PTR(info, echo_thread_kmem);
+ kmem_cache_free(echo_thread_kmem, info);
}
static void echo_thread_key_exit(const struct lu_context *ctx,
@@ -659,7 +661,7 @@ static void *echo_session_key_init(const struct lu_context *ctx,
{
struct echo_session_info *session;
- OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, GFP_NOFS);
+ session = kmem_cache_alloc(echo_session_kmem, GFP_NOFS | __GFP_ZERO);
if (session == NULL)
session = ERR_PTR(-ENOMEM);
return session;
@@ -670,7 +672,7 @@ static void echo_session_key_fini(const struct lu_context *ctx,
{
struct echo_session_info *session = data;
- OBD_SLAB_FREE_PTR(session, echo_session_kmem);
+ kmem_cache_free(echo_session_kmem, session);
}
static void echo_session_key_exit(const struct lu_context *ctx,
@@ -700,8 +702,8 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
int rc;
int cleanup = 0;
- OBD_ALLOC_PTR(ed);
- if (ed == NULL) {
+ ed = kzalloc(sizeof(*ed), GFP_NOFS);
+ if (!ed) {
rc = -ENOMEM;
goto out;
}
@@ -798,7 +800,7 @@ out:
case 2:
cl_device_fini(&ed->ed_cl);
case 1:
- OBD_FREE_PTR(ed);
+ kfree(ed);
case 0:
default:
break;
@@ -895,7 +897,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
LASSERT(ed->ed_site == lu2cl_site(d->ld_site));
echo_site_fini(env, ed);
cl_device_fini(&ed->ed_cl);
- OBD_FREE_PTR(ed);
+ kfree(ed);
return NULL;
}
@@ -919,6 +921,7 @@ static struct lu_device_type echo_device_type = {
.ldt_ops = &echo_device_type_ops,
.ldt_ctx_tags = LCT_CL_THREAD,
};
+
/** @} echo_init */
/** \defgroup echo_exports Exported operations
@@ -1202,7 +1205,6 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset,
goto out;
LASSERT(rc == 0);
-
rc = cl_echo_enqueue0(env, eco, offset,
offset + npages * PAGE_CACHE_SIZE - 1,
rw == READ ? LCK_PR : LCK_PW, &lh.cookie,
@@ -1259,8 +1261,8 @@ out:
cl_env_put(env, &refcheck);
return rc;
}
-/** @} echo_exports */
+/** @} echo_exports */
static u64 last_object_id;
@@ -1268,6 +1270,7 @@ static int
echo_copyout_lsm(struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
{
struct lov_stripe_md *ulsm = _ulsm;
+ struct lov_oinfo **p;
int nob, i;
nob = offsetof(struct lov_stripe_md, lsm_oinfo[lsm->lsm_stripe_count]);
@@ -1277,9 +1280,10 @@ echo_copyout_lsm(struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
if (copy_to_user(ulsm, lsm, sizeof(*ulsm)))
return -EFAULT;
- for (i = 0; i < lsm->lsm_stripe_count; i++) {
- if (copy_to_user(ulsm->lsm_oinfo[i], lsm->lsm_oinfo[i],
- sizeof(lsm->lsm_oinfo[0])))
+ for (i = 0, p = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++, p++) {
+ struct lov_oinfo __user *up;
+ if (get_user(up, ulsm->lsm_oinfo + i) ||
+ copy_to_user(up, *p, sizeof(struct lov_oinfo)))
return -EFAULT;
}
return 0;
@@ -1287,9 +1291,10 @@ echo_copyout_lsm(struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
static int
echo_copyin_lsm(struct echo_device *ed, struct lov_stripe_md *lsm,
- void *ulsm, int ulsm_nob)
+ struct lov_stripe_md __user *ulsm, int ulsm_nob)
{
struct echo_client_obd *ec = ed->ed_ec;
+ struct lov_oinfo **p;
int i;
if (ulsm_nob < sizeof(*lsm))
@@ -1304,12 +1309,10 @@ echo_copyin_lsm(struct echo_device *ed, struct lov_stripe_md *lsm,
((__u64)lsm->lsm_stripe_size * lsm->lsm_stripe_count > ~0UL))
return -EINVAL;
-
- for (i = 0; i < lsm->lsm_stripe_count; i++) {
- if (copy_from_user(lsm->lsm_oinfo[i],
- ((struct lov_stripe_md *)ulsm)-> \
- lsm_oinfo[i],
- sizeof(lsm->lsm_oinfo[0])))
+ for (i = 0, p = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++, p++) {
+ struct lov_oinfo __user *up;
+ if (get_user(up, ulsm->lsm_oinfo + i) ||
+ copy_from_user(*p, up, sizeof(struct lov_oinfo)))
return -EFAULT;
}
return 0;
@@ -1400,7 +1403,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
failed:
if (created && rc)
- obd_destroy(env, ec->ec_exp, oa, lsm, oti, NULL, NULL);
+ obd_destroy(env, ec->ec_exp, oa, lsm, oti, NULL);
if (lsm)
echo_free_memmd(ed, &lsm);
if (rc)
@@ -1561,7 +1564,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
(oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
(oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
- gfp_mask = ((ostid_id(&oa->o_oi) & 2) == 0) ? GFP_IOFS : GFP_HIGHUSER;
+ gfp_mask = ((ostid_id(&oa->o_oi) & 2) == 0) ? GFP_KERNEL : GFP_HIGHUSER;
LASSERT(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ);
LASSERT(lsm != NULL);
@@ -1577,13 +1580,13 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
if (rw == OBD_BRW_WRITE)
brw_flags = OBD_BRW_ASYNC;
- OBD_ALLOC(pga, npages * sizeof(*pga));
+ pga = kcalloc(npages, sizeof(*pga), GFP_NOFS);
if (pga == NULL)
return -ENOMEM;
- OBD_ALLOC(pages, npages * sizeof(*pages));
+ pages = kcalloc(npages, sizeof(*pages), GFP_NOFS);
if (pages == NULL) {
- OBD_FREE(pga, npages * sizeof(*pga));
+ kfree(pga);
return -ENOMEM;
}
@@ -1594,7 +1597,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
LASSERT(pgp->pg == NULL); /* for cleanup */
rc = -ENOMEM;
- OBD_PAGE_ALLOC(pgp->pg, gfp_mask);
+ pgp->pg = alloc_page(gfp_mask);
if (pgp->pg == NULL)
goto out;
@@ -1630,10 +1633,10 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
if (vrc != 0 && rc == 0)
rc = vrc;
}
- OBD_PAGE_FREE(pgp->pg);
+ __free_page(pgp->pg);
}
- OBD_FREE(pga, npages * sizeof(*pga));
- OBD_FREE(pages, npages * sizeof(*pages));
+ kfree(pga);
+ kfree(pages);
return rc;
}
@@ -1659,8 +1662,8 @@ static int echo_client_prep_commit(const struct lu_env *env,
npages = batch >> PAGE_CACHE_SHIFT;
tot_pages = count >> PAGE_CACHE_SHIFT;
- OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local));
- OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote));
+ lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS);
+ rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS);
if (lnb == NULL || rnb == NULL) {
ret = -ENOMEM;
@@ -1691,7 +1694,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
lpages = npages;
ret = obd_preprw(env, rw, exp, oa, 1, &ioo, rnb, &lpages,
- lnb, oti, NULL);
+ lnb, oti);
if (ret != 0)
goto out;
LASSERT(lpages == npages);
@@ -1737,10 +1740,8 @@ static int echo_client_prep_commit(const struct lu_env *env,
}
out:
- if (lnb)
- OBD_FREE(lnb, npages * sizeof(struct niobuf_local));
- if (rnb)
- OBD_FREE(rnb, npages * sizeof(struct niobuf_remote));
+ kfree(lnb);
+ kfree(rnb);
return ret;
}
@@ -1879,8 +1880,8 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
if (rc < 0)
return rc;
- OBD_ALLOC_PTR(env);
- if (env == NULL)
+ env = kzalloc(sizeof(*env), GFP_NOFS);
+ if (!env)
return -ENOMEM;
rc = lu_env_init(env, LCT_DT_THREAD);
@@ -1909,7 +1910,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
rc = echo_get_object(&eco, ed, oa);
if (rc == 0) {
rc = obd_destroy(env, ec->ec_exp, oa, eco->eo_lsm,
- &dummy_oti, NULL, NULL);
+ &dummy_oti, NULL);
if (rc == 0)
eco->eo_deleted = 1;
echo_put_object(eco);
@@ -1919,7 +1920,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
case OBD_IOC_GETATTR:
rc = echo_get_object(&eco, ed, oa);
if (rc == 0) {
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info oinfo = { };
oinfo.oi_md = eco->eo_lsm;
oinfo.oi_oa = oa;
@@ -1936,7 +1937,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
rc = echo_get_object(&eco, ed, oa);
if (rc == 0) {
- struct obd_info oinfo = { { { 0 } } };
+ struct obd_info oinfo = { };
oinfo.oi_oa = oa;
oinfo.oi_md = eco->eo_lsm;
@@ -2010,7 +2011,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
out:
lu_env_fini(env);
- OBD_FREE_PTR(env);
+ kfree(env);
/* XXX this should be in a helper also called by target_send_reply */
for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i < 4;
@@ -2050,8 +2051,8 @@ static int echo_client_setup(const struct lu_env *env,
ec->ec_unique = 0;
ec->ec_nstripes = 0;
- OBD_ALLOC(ocd, sizeof(*ocd));
- if (ocd == NULL) {
+ ocd = kzalloc(sizeof(*ocd), GFP_NOFS);
+ if (!ocd) {
CERROR("Can't alloc ocd connecting to %s\n",
lustre_cfg_string(lcfg, 1));
return -ENOMEM;
@@ -2067,14 +2068,8 @@ static int echo_client_setup(const struct lu_env *env,
ocd->ocd_group = FID_SEQ_ECHO;
rc = obd_connect(env, &ec->ec_exp, tgt, &echo_uuid, ocd, NULL);
- if (rc == 0) {
- /* Turn off pinger because it connects to tgt obd directly. */
- spin_lock(&tgt->obd_dev_lock);
- list_del_init(&ec->ec_exp->exp_obd_chain_timed);
- spin_unlock(&tgt->obd_dev_lock);
- }
- OBD_FREE(ocd, sizeof(*ocd));
+ kfree(ocd);
if (rc != 0) {
CERROR("fail to connect to device %s\n",
@@ -2141,17 +2136,13 @@ static struct obd_ops echo_client_obd_ops = {
.o_disconnect = echo_client_disconnect
};
-int echo_client_init(void)
+static int echo_client_init(void)
{
- struct lprocfs_static_vars lvars = { NULL };
int rc;
- lprocfs_echo_init_vars(&lvars);
-
rc = lu_kmem_init(echo_caches);
if (rc == 0) {
rc = class_register_type(&echo_client_obd_ops, NULL,
- lvars.module_vars,
LUSTRE_ECHO_CLIENT_NAME,
&echo_device_type);
if (rc)
@@ -2160,7 +2151,7 @@ int echo_client_init(void)
return rc;
}
-void echo_client_exit(void)
+static void echo_client_exit(void)
{
class_unregister_type(LUSTRE_ECHO_CLIENT_NAME);
lu_kmem_fini(echo_caches);
@@ -2168,15 +2159,10 @@ void echo_client_exit(void)
static int __init obdecho_init(void)
{
- struct lprocfs_static_vars lvars;
-
LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n");
LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
- lprocfs_echo_init_vars(&lvars);
-
-
return echo_client_init();
}
diff --git a/kernel/drivers/staging/lustre/lustre/obdecho/echo_internal.h b/kernel/drivers/staging/lustre/lustre/obdecho/echo_internal.h
index 8e9dbc235..69063fa65 100644
--- a/kernel/drivers/staging/lustre/lustre/obdecho/echo_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/obdecho/echo_internal.h
@@ -43,5 +43,4 @@
/* block size to use for data verification */
#define OBD_ECHO_BLOCK_SIZE (4<<10)
-
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/kernel/drivers/staging/lustre/lustre/obdecho/lproc_echo.c
deleted file mode 100644
index 0beb97db7..000000000
--- a/kernel/drivers/staging/lustre/lustre/obdecho/lproc_echo.c
+++ /dev/null
@@ -1,57 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-#define DEBUG_SUBSYSTEM S_ECHO
-
-#include "../include/lprocfs_status.h"
-#include "../include/obd_class.h"
-
-#if defined(CONFIG_PROC_FS)
-LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
-static struct lprocfs_vars lprocfs_echo_obd_vars[] = {
- { "uuid", &echo_uuid_fops, NULL, 0 },
- { NULL }
-};
-
-LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs);
-static struct lprocfs_vars lprocfs_echo_module_vars[] = {
- { "num_refs", &echo_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
-void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
-{
- lvars->module_vars = lprocfs_echo_module_vars;
- lvars->obd_vars = lprocfs_echo_obd_vars;
-}
-#endif /* CONFIG_PROC_FS */
diff --git a/kernel/drivers/staging/lustre/lustre/osc/Makefile b/kernel/drivers/staging/lustre/lustre/osc/Makefile
index 54927fba4..37cdeea9a 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/osc/Makefile
@@ -1,4 +1,3 @@
obj-$(CONFIG_LUSTRE_FS) += osc.o
osc-y := osc_request.o osc_dev.o osc_object.o \
- osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o
-osc-$(CONFIG_PROC_FS) += lproc_osc.o
+ osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o lproc_osc.o
diff --git a/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c b/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c
index 15a662098..c4d44e70f 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -42,84 +42,99 @@
#include <linux/seq_file.h>
#include "osc_internal.h"
-static int osc_active_seq_show(struct seq_file *m, void *v)
+static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
-
- LPROCFS_CLIMP_CHECK(dev);
- seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
- LPROCFS_CLIMP_EXIT(dev);
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
- return 0;
+ return sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive);
}
-static ssize_t osc_active_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
- int val, rc;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
- if (val < 0 || val > 1)
+ if (val > 1)
return -ERANGE;
/* opposite senses */
if (dev->u.cli.cl_import->imp_deactive == val)
rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
else
- CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val);
+ CDEBUG(D_CONFIG, "activate %ld: ignoring repeat request\n",
+ val);
return count;
}
-LPROC_SEQ_FOPS(osc_active);
+LUSTRE_RW_ATTR(active);
-static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
+static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
- client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
- client_obd_list_unlock(&cli->cl_loi_list_lock);
-
- return 0;
+ return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
}
-static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
- struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool;
- int val, rc;
+ int rc;
+ unsigned long val;
+ int adding, added, req_count;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
if (val < 1 || val > OSC_MAX_RIF_MAX)
return -ERANGE;
- LPROCFS_CLIMP_CHECK(dev);
- if (pool && val > cli->cl_max_rpcs_in_flight)
- pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight);
+ adding = val - cli->cl_max_rpcs_in_flight;
+ req_count = atomic_read(&osc_pool_req_count);
+ if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
+ /*
+ * There might be some race which will cause over-limit
+ * allocation, but it is fine.
+ */
+ if (req_count + adding > osc_reqpool_maxreqcount)
+ adding = osc_reqpool_maxreqcount - req_count;
+
+ added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
+ atomic_add(added, &osc_pool_req_count);
+ }
client_obd_list_lock(&cli->cl_loi_list_lock);
cli->cl_max_rpcs_in_flight = val;
client_obd_list_unlock(&cli->cl_loi_list_lock);
- LPROCFS_CLIMP_EXIT(dev);
return count;
}
-LPROC_SEQ_FOPS(osc_max_rpcs_in_flight);
+LUSTRE_RW_ATTR(max_rpcs_in_flight);
-static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
+static ssize_t max_dirty_mb_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
long val;
int mult;
@@ -129,22 +144,26 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
client_obd_list_unlock(&cli->cl_loi_list_lock);
mult = 1 << 20;
- return lprocfs_seq_read_frac_helper(m, val, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult);
}
-static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_dirty_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
- int pages_number, mult, rc;
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
+ pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */
+
if (pages_number <= 0 ||
pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) ||
pages_number > totalram_pages / 4) /* 1/4 of RAM */
@@ -157,7 +176,7 @@ static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(osc_max_dirty_mb);
+LUSTRE_RW_ATTR(max_dirty_mb);
static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
{
@@ -208,46 +227,54 @@ static ssize_t osc_cached_mb_seq_write(struct file *file,
return count;
}
+
LPROC_SEQ_FOPS(osc_cached_mb);
-static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v)
+static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
+ int len;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%lu\n", cli->cl_dirty);
+ len = sprintf(buf, "%lu\n", cli->cl_dirty);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes);
+LUSTRE_RO_ATTR(cur_dirty_bytes);
-static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
+static ssize_t cur_grant_bytes_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
+ int len;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%lu\n", cli->cl_avail_grant);
+ len = sprintf(buf, "%lu\n", cli->cl_avail_grant);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t cur_grant_bytes_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &obd->u.cli;
- int rc;
- __u64 val;
-
- if (obd == NULL)
- return 0;
+ int rc;
+ unsigned long long val;
- rc = lprocfs_write_u64_helper(buffer, count, &val);
+ rc = kstrtoull(buffer, 10, &val);
if (rc)
return rc;
@@ -255,54 +282,56 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
client_obd_list_lock(&cli->cl_loi_list_lock);
if (val >= cli->cl_avail_grant) {
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return -EINVAL;
}
client_obd_list_unlock(&cli->cl_loi_list_lock);
- LPROCFS_CLIMP_CHECK(obd);
if (cli->cl_import->imp_state == LUSTRE_IMP_FULL)
rc = osc_shrink_grant_to_target(cli, val);
- LPROCFS_CLIMP_EXIT(obd);
if (rc)
return rc;
return count;
}
-LPROC_SEQ_FOPS(osc_cur_grant_bytes);
+LUSTRE_RW_ATTR(cur_grant_bytes);
-static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v)
+static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
+ int len;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%lu\n", cli->cl_lost_grant);
+ len = sprintf(buf, "%lu\n", cli->cl_lost_grant);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes);
+LUSTRE_RO_ATTR(cur_lost_grant_bytes);
-static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
+static ssize_t grant_shrink_interval_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- if (obd == NULL)
- return 0;
- seq_printf(m, "%d\n", obd->u.cli.cl_grant_shrink_interval);
- return 0;
+ return sprintf(buf, "%d\n", obd->u.cli.cl_grant_shrink_interval);
}
-static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t grant_shrink_interval_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- int val, rc;
-
- if (obd == NULL)
- return 0;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -313,30 +342,29 @@ static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(osc_grant_shrink_interval);
+LUSTRE_RW_ATTR(grant_shrink_interval);
-static int osc_checksum_seq_show(struct seq_file *m, void *v)
+static ssize_t checksums_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
-
- if (obd == NULL)
- return 0;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
- return 0;
+ return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
}
-static ssize_t osc_checksum_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t checksums_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- int val, rc;
-
- if (obd == NULL)
- return 0;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -344,12 +372,13 @@ static ssize_t osc_checksum_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(osc_checksum);
+LUSTRE_RW_ATTR(checksums);
static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
{
struct obd_device *obd = m->private;
int i;
+
DECLARE_CKSUM_NAME;
if (obd == NULL)
@@ -373,6 +402,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file,
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
int i;
+
DECLARE_CKSUM_NAME;
char kernbuf[10];
@@ -398,103 +428,125 @@ static ssize_t osc_checksum_type_seq_write(struct file *file,
}
return -EINVAL;
}
+
LPROC_SEQ_FOPS(osc_checksum_type);
-static int osc_resend_count_seq_show(struct seq_file *m, void *v)
+static ssize_t resend_count_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
- return 0;
+ return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends));
}
-static ssize_t osc_resend_count_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t resend_count_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- int val, rc;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
- if (val < 0)
- return -EINVAL;
-
atomic_set(&obd->u.cli.cl_resends, val);
return count;
}
-LPROC_SEQ_FOPS(osc_resend_count);
+LUSTRE_RW_ATTR(resend_count);
-static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
+static ssize_t contention_seconds_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
- seq_printf(m, "%u\n", od->od_contention_time);
- return 0;
+ return sprintf(buf, "%u\n", od->od_contention_time);
}
-static ssize_t osc_contention_seconds_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t contention_seconds_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?:
count;
}
-LPROC_SEQ_FOPS(osc_contention_seconds);
+LUSTRE_RW_ATTR(contention_seconds);
-static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
+static ssize_t lockless_truncate_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
- seq_printf(m, "%u\n", od->od_lockless_truncate);
- return 0;
+ return sprintf(buf, "%u\n", od->od_lockless_truncate);
}
-static ssize_t osc_lockless_truncate_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t lockless_truncate_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?:
count;
}
-LPROC_SEQ_FOPS(osc_lockless_truncate);
+LUSTRE_RW_ATTR(lockless_truncate);
-static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
+static ssize_t destroys_in_flight_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight));
- return 0;
+ return sprintf(buf, "%u\n",
+ atomic_read(&obd->u.cli.cl_destroy_in_flight));
}
-LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
+LUSTRE_RO_ATTR(destroys_in_flight);
-static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
+static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return lprocfs_obd_rd_max_pages_per_rpc(m, m->private);
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct client_obd *cli = &dev->u.cli;
+
+ return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
}
-static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_pages_per_rpc_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
int chunk_mask, rc;
- __u64 val;
+ unsigned long long val;
- rc = lprocfs_write_u64_helper(buffer, count, &val);
+ rc = kstrtoull(buffer, 10, &val);
if (rc)
return rc;
@@ -502,32 +554,21 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
if (val >= ONE_MB_BRW_SIZE)
val >>= PAGE_CACHE_SHIFT;
- LPROCFS_CLIMP_CHECK(dev);
-
chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1);
/* max_pages_per_rpc must be chunk aligned */
val = (val + ~chunk_mask) & chunk_mask;
if (val == 0 || val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT) {
- LPROCFS_CLIMP_EXIT(dev);
return -ERANGE;
}
client_obd_list_lock(&cli->cl_loi_list_lock);
cli->cl_max_pages_per_rpc = val;
client_obd_list_unlock(&cli->cl_loi_list_lock);
- LPROCFS_CLIMP_EXIT(dev);
return count;
}
-LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc);
+LUSTRE_RW_ATTR(max_pages_per_rpc);
-LPROC_SEQ_FOPS_RO_TYPE(osc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(osc, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree);
LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid);
LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
@@ -539,62 +580,36 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import);
LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
- { "uuid", &osc_uuid_fops, NULL, 0 },
{ "ping", &osc_ping_fops, NULL, 0222 },
{ "connect_flags", &osc_connect_flags_fops, NULL, 0 },
- { "blocksize", &osc_blksize_fops, NULL, 0 },
- { "kbytestotal", &osc_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &osc_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &osc_kbytesavail_fops, NULL, 0 },
- { "filestotal", &osc_filestotal_fops, NULL, 0 },
- { "filesfree", &osc_filesfree_fops, NULL, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
{ "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 },
{ "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 },
- { "active", &osc_active_fops, NULL },
- { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops, NULL },
- { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops, NULL },
- { "destroys_in_flight", &osc_destroys_in_flight_fops, NULL, 0 },
- { "max_dirty_mb", &osc_max_dirty_mb_fops, NULL },
{ "osc_cached_mb", &osc_cached_mb_fops, NULL },
- { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops, NULL, 0 },
- { "cur_grant_bytes", &osc_cur_grant_bytes_fops, NULL },
- { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops, NULL, 0},
- { "grant_shrink_interval", &osc_grant_shrink_interval_fops, NULL },
- { "checksums", &osc_checksum_fops, NULL },
{ "checksum_type", &osc_checksum_type_fops, NULL },
- { "resend_count", &osc_resend_count_fops, NULL},
{ "timeouts", &osc_timeouts_fops, NULL, 0 },
- { "contention_seconds", &osc_contention_seconds_fops, NULL },
- { "lockless_truncate", &osc_lockless_truncate_fops, NULL },
{ "import", &osc_import_fops, NULL },
{ "state", &osc_state_fops, NULL, 0 },
{ "pinger_recov", &osc_pinger_recov_fops, NULL },
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(osc, numrefs);
-static struct lprocfs_vars lprocfs_osc_module_vars[] = {
- { "num_refs", &osc_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
#define pct(a, b) (b ? a * 100 / b : 0)
static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
{
- struct timeval now;
+ struct timespec64 now;
struct obd_device *dev = seq->private;
struct client_obd *cli = &dev->u.cli;
unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
int i;
- do_gettimeofday(&now);
+ ktime_get_real_ts64(&now);
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
- now.tv_sec, (unsigned long)now.tv_usec);
+ seq_printf(seq, "snapshot_time: %llu.%9lu (secs.usecs)\n",
+ (s64)now.tv_sec, (unsigned long)now.tv_nsec);
seq_printf(seq, "read RPCs in flight: %d\n",
cli->cl_r_in_flight);
seq_printf(seq, "write RPCs in flight: %d\n",
@@ -616,6 +631,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
for (i = 0; i < OBD_HIST_MAX; i++) {
unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
+
read_cum += r;
write_cum += w;
seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
@@ -639,6 +655,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
for (i = 0; i < OBD_HIST_MAX; i++) {
unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
+
read_cum += r;
write_cum += w;
seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
@@ -662,6 +679,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
for (i = 0; i < OBD_HIST_MAX; i++) {
unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
+
read_cum += r;
write_cum += w;
seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
@@ -676,11 +694,12 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
return 0;
}
+
#undef pct
static ssize_t osc_rpc_stats_seq_write(struct file *file,
- const char __user *buf,
- size_t len, loff_t *off)
+ const char __user *buf,
+ size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
struct obd_device *dev = seq->private;
@@ -700,14 +719,14 @@ LPROC_SEQ_FOPS(osc_rpc_stats);
static int osc_stats_seq_show(struct seq_file *seq, void *v)
{
- struct timeval now;
+ struct timespec64 now;
struct obd_device *dev = seq->private;
struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
- do_gettimeofday(&now);
+ ktime_get_real_ts64(&now);
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
- now.tv_sec, (unsigned long)now.tv_usec);
+ seq_printf(seq, "snapshot_time: %llu.%9lu (secs.usecs)\n",
+ (s64)now.tv_sec, (unsigned long)now.tv_nsec);
seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
stats->os_lockless_writes);
seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
@@ -718,8 +737,8 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v)
}
static ssize_t osc_stats_seq_write(struct file *file,
- const char __user *buf,
- size_t len, loff_t *off)
+ const char __user *buf,
+ size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
struct obd_device *dev = seq->private;
@@ -735,17 +754,38 @@ int lproc_osc_attach_seqstat(struct obd_device *dev)
{
int rc;
- rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644,
- &osc_stats_fops, dev);
+ rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "osc_stats", 0644,
+ &osc_stats_fops, dev);
if (rc == 0)
- rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644,
- &osc_rpc_stats_fops, dev);
+ rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644,
+ &osc_rpc_stats_fops, dev);
return rc;
}
+static struct attribute *osc_attrs[] = {
+ &lustre_attr_active.attr,
+ &lustre_attr_checksums.attr,
+ &lustre_attr_contention_seconds.attr,
+ &lustre_attr_cur_dirty_bytes.attr,
+ &lustre_attr_cur_grant_bytes.attr,
+ &lustre_attr_cur_lost_grant_bytes.attr,
+ &lustre_attr_destroys_in_flight.attr,
+ &lustre_attr_grant_shrink_interval.attr,
+ &lustre_attr_lockless_truncate.attr,
+ &lustre_attr_max_dirty_mb.attr,
+ &lustre_attr_max_pages_per_rpc.attr,
+ &lustre_attr_max_rpcs_in_flight.attr,
+ &lustre_attr_resend_count.attr,
+ NULL,
+};
+
+static struct attribute_group osc_attr_group = {
+ .attrs = osc_attrs,
+};
+
void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_osc_module_vars;
+ lvars->sysfs_vars = &osc_attr_group;
lvars->obd_vars = lprocfs_osc_obd_vars;
}
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c b/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c
index d44b3d4ff..b1d1a87f0 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -112,8 +112,8 @@ static const char *oes_strings[] = {
/* ----- extent part 0 ----- */ \
__ext, EXTPARA(__ext), \
/* ----- part 1 ----- */ \
- atomic_read(&__ext->oe_refc), \
- atomic_read(&__ext->oe_users), \
+ atomic_read(&__ext->oe_refc), \
+ atomic_read(&__ext->oe_users), \
list_empty_marker(&__ext->oe_link), \
oes_strings[__ext->oe_state], ext_flags(__ext, __buf), \
__ext->oe_obj, \
@@ -247,6 +247,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
if (ext->oe_osclock) {
struct cl_lock_descr *descr;
+
descr = &ext->oe_osclock->cll_descr;
if (!(descr->cld_start <= ext->oe_start &&
descr->cld_end >= ext->oe_max_end)) {
@@ -297,15 +298,14 @@ out:
#define sanity_check_nolock(ext) \
osc_extent_sanity_check0(ext, __func__, __LINE__)
-#define sanity_check(ext) ({ \
- int __res; \
+#define sanity_check(ext) ({ \
+ int __res; \
osc_object_lock((ext)->oe_obj); \
- __res = sanity_check_nolock(ext); \
- osc_object_unlock((ext)->oe_obj); \
- __res; \
+ __res = sanity_check_nolock(ext); \
+ osc_object_unlock((ext)->oe_obj); \
+ __res; \
})
-
/**
* sanity check - to make sure there is no overlapped extent in the tree.
*/
@@ -346,7 +346,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj)
{
struct osc_extent *ext;
- OBD_SLAB_ALLOC_PTR_GFP(ext, osc_extent_kmem, GFP_IOFS);
+ ext = kmem_cache_alloc(osc_extent_kmem, GFP_NOFS | __GFP_ZERO);
if (ext == NULL)
return NULL;
@@ -365,7 +365,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj)
static void osc_extent_free(struct osc_extent *ext)
{
- OBD_SLAB_FREE_PTR(ext, osc_extent_kmem);
+ kmem_cache_free(osc_extent_kmem, ext);
}
static struct osc_extent *osc_extent_get(struct osc_extent *ext)
@@ -411,7 +411,7 @@ static void osc_extent_put_trust(struct osc_extent *ext)
static struct osc_extent *osc_extent_search(struct osc_object *obj,
pgoff_t index)
{
- struct rb_node *n = obj->oo_root.rb_node;
+ struct rb_node *n = obj->oo_root.rb_node;
struct osc_extent *tmp, *p = NULL;
LASSERT(osc_object_is_locked(obj));
@@ -447,8 +447,8 @@ static struct osc_extent *osc_extent_lookup(struct osc_object *obj,
/* caller must have held object lock. */
static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext)
{
- struct rb_node **n = &obj->oo_root.rb_node;
- struct rb_node *parent = NULL;
+ struct rb_node **n = &obj->oo_root.rb_node;
+ struct rb_node *parent = NULL;
struct osc_extent *tmp;
LASSERT(ext->oe_intree == 0);
@@ -475,6 +475,7 @@ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext)
static void osc_extent_erase(struct osc_extent *ext)
{
struct osc_object *obj = ext->oe_obj;
+
LASSERT(osc_object_is_locked(obj));
if (ext->oe_intree) {
rb_erase(&ext->oe_node, &obj->oo_root);
@@ -544,19 +545,19 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur,
LASSERT(cur->oe_osclock == victim->oe_osclock);
ppc_bits = osc_cli(obj)->cl_chunkbits - PAGE_CACHE_SHIFT;
chunk_start = cur->oe_start >> ppc_bits;
- chunk_end = cur->oe_end >> ppc_bits;
- if (chunk_start != (victim->oe_end >> ppc_bits) + 1 &&
+ chunk_end = cur->oe_end >> ppc_bits;
+ if (chunk_start != (victim->oe_end >> ppc_bits) + 1 &&
chunk_end + 1 != victim->oe_start >> ppc_bits)
return -ERANGE;
OSC_EXTENT_DUMP(D_CACHE, victim, "will be merged by %p.\n", cur);
- cur->oe_start = min(cur->oe_start, victim->oe_start);
- cur->oe_end = max(cur->oe_end, victim->oe_end);
- cur->oe_grants += victim->oe_grants;
+ cur->oe_start = min(cur->oe_start, victim->oe_start);
+ cur->oe_end = max(cur->oe_end, victim->oe_end);
+ cur->oe_grants += victim->oe_grants;
cur->oe_nr_pages += victim->oe_nr_pages;
/* only the following bits are needed to merge */
- cur->oe_urgent |= victim->oe_urgent;
+ cur->oe_urgent |= victim->oe_urgent;
cur->oe_memalloc |= victim->oe_memalloc;
list_splice_init(&victim->oe_pages, &cur->oe_pages);
list_del_init(&victim->oe_link);
@@ -624,18 +625,18 @@ struct osc_extent *osc_extent_find(const struct lu_env *env,
{
struct client_obd *cli = osc_cli(obj);
- struct cl_lock *lock;
+ struct cl_lock *lock;
struct osc_extent *cur;
struct osc_extent *ext;
struct osc_extent *conflict = NULL;
struct osc_extent *found = NULL;
- pgoff_t chunk;
- pgoff_t max_end;
- int max_pages; /* max_pages_per_rpc */
- int chunksize;
- int ppc_bits; /* pages per chunk bits */
- int chunk_mask;
- int rc;
+ pgoff_t chunk;
+ pgoff_t max_end;
+ int max_pages; /* max_pages_per_rpc */
+ int chunksize;
+ int ppc_bits; /* pages per chunk bits */
+ int chunk_mask;
+ int rc;
cur = osc_extent_alloc(obj);
if (cur == NULL)
@@ -646,10 +647,10 @@ struct osc_extent *osc_extent_find(const struct lu_env *env,
LASSERT(lock->cll_descr.cld_mode >= CLM_WRITE);
LASSERT(cli->cl_chunkbits >= PAGE_CACHE_SHIFT);
- ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT;
+ ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT;
chunk_mask = ~((1 << ppc_bits) - 1);
- chunksize = 1 << cli->cl_chunkbits;
- chunk = index >> ppc_bits;
+ chunksize = 1 << cli->cl_chunkbits;
+ chunk = index >> ppc_bits;
/* align end to rpc edge, rpc size may not be a power 2 integer. */
max_pages = cli->cl_max_pages_per_rpc;
@@ -659,15 +660,15 @@ struct osc_extent *osc_extent_find(const struct lu_env *env,
/* initialize new extent by parameters so far */
cur->oe_max_end = max_end;
- cur->oe_start = index & chunk_mask;
- cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1;
+ cur->oe_start = index & chunk_mask;
+ cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1;
if (cur->oe_start < lock->cll_descr.cld_start)
cur->oe_start = lock->cll_descr.cld_start;
if (cur->oe_end > max_end)
cur->oe_end = max_end;
cur->oe_osclock = lock;
- cur->oe_grants = 0;
- cur->oe_mppr = max_pages;
+ cur->oe_grants = 0;
+ cur->oe_mppr = max_pages;
/* grants has been allocated by caller */
LASSERTF(*grants >= chunksize + cli->cl_extent_tax,
@@ -681,7 +682,7 @@ restart:
ext = first_extent(obj);
while (ext != NULL) {
loff_t ext_chk_start = ext->oe_start >> ppc_bits;
- loff_t ext_chk_end = ext->oe_end >> ppc_bits;
+ loff_t ext_chk_end = ext->oe_end >> ppc_bits;
LASSERT(sanity_check_nolock(ext) == 0);
if (chunk > ext_chk_end + 1)
@@ -755,14 +756,14 @@ restart:
EASSERT((ext->oe_start & ~chunk_mask) == 0, ext);
/* pull ext's start back to cover cur */
- ext->oe_start = cur->oe_start;
+ ext->oe_start = cur->oe_start;
ext->oe_grants += chunksize;
*grants -= chunksize;
found = osc_extent_hold(ext);
} else if (chunk == ext_chk_end + 1) {
/* rear merge */
- ext->oe_end = cur->oe_end;
+ ext->oe_end = cur->oe_end;
ext->oe_grants += chunksize;
*grants -= chunksize;
@@ -868,6 +869,7 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext,
int offset = oap->oap_page_off & ~CFS_PAGE_MASK;
int count = oap->oap_count + (offset & (blocksize - 1));
int end = (offset + oap->oap_count) & (blocksize - 1);
+
if (end)
count += blocksize - end;
@@ -943,21 +945,21 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext,
* @size, then partial truncate happens.
*/
static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
- bool partial)
+ bool partial)
{
- struct cl_env_nest nest;
- struct lu_env *env;
- struct cl_io *io;
- struct osc_object *obj = ext->oe_obj;
- struct client_obd *cli = osc_cli(obj);
+ struct cl_env_nest nest;
+ struct lu_env *env;
+ struct cl_io *io;
+ struct osc_object *obj = ext->oe_obj;
+ struct client_obd *cli = osc_cli(obj);
struct osc_async_page *oap;
struct osc_async_page *tmp;
- int pages_in_chunk = 0;
- int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT;
- __u64 trunc_chunk = trunc_index >> ppc_bits;
- int grants = 0;
- int nr_pages = 0;
- int rc = 0;
+ int pages_in_chunk = 0;
+ int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT;
+ __u64 trunc_chunk = trunc_index >> ppc_bits;
+ int grants = 0;
+ int nr_pages = 0;
+ int rc = 0;
LASSERT(sanity_check(ext) == 0);
EASSERT(ext->oe_state == OES_TRUNC, ext);
@@ -976,8 +978,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
/* discard all pages with index greater then trunc_index */
list_for_each_entry_safe(oap, tmp, &ext->oe_pages,
oap_pending_item) {
- struct cl_page *sub = oap2cl_page(oap);
- struct cl_page *page = cl_page_top(sub);
+ struct cl_page *sub = oap2cl_page(oap);
+ struct cl_page *page = cl_page_top(sub);
LASSERT(list_empty(&oap->oap_rpc_item));
@@ -1022,10 +1024,9 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
grants = ext->oe_grants;
ext->oe_grants = 0;
} else { /* calculate how many grants we can free */
- int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk;
+ int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk;
pgoff_t last_index;
-
/* if there is no pages in this chunk, we can also free grants
* for the last chunk */
if (pages_in_chunk == 0) {
@@ -1038,10 +1039,10 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
}
/* this is what we can free from this extent */
- grants = chunks << cli->cl_chunkbits;
+ grants = chunks << cli->cl_chunkbits;
ext->oe_grants -= grants;
- last_index = ((trunc_chunk + 1) << ppc_bits) - 1;
- ext->oe_end = min(last_index, ext->oe_max_end);
+ last_index = ((trunc_chunk + 1) << ppc_bits) - 1;
+ ext->oe_end = min(last_index, ext->oe_max_end);
LASSERT(ext->oe_end >= ext->oe_start);
LASSERT(ext->oe_grants > 0);
}
@@ -1236,8 +1237,8 @@ static inline int osc_is_ready(struct osc_object *osc)
static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
int cmd)
{
- struct osc_page *opg = oap2osc_page(oap);
- struct cl_page *page = cl_page_top(oap2cl_page(oap));
+ struct osc_page *opg = oap2osc_page(oap);
+ struct cl_page *page = cl_page_top(oap2cl_page(oap));
int result;
LASSERT(cmd == OBD_BRW_WRITE); /* no cached reads */
@@ -1251,10 +1252,10 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
static int osc_refresh_count(const struct lu_env *env,
struct osc_async_page *oap, int cmd)
{
- struct osc_page *opg = oap2osc_page(oap);
- struct cl_page *page = oap2cl_page(oap);
+ struct osc_page *opg = oap2osc_page(oap);
+ struct cl_page *page = oap2cl_page(oap);
struct cl_object *obj;
- struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
int result;
loff_t kms;
@@ -1283,10 +1284,10 @@ static int osc_refresh_count(const struct lu_env *env,
static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
int cmd, int rc)
{
- struct osc_page *opg = oap2osc_page(oap);
- struct cl_page *page = cl_page_top(oap2cl_page(oap));
- struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj);
- enum cl_req_type crt;
+ struct osc_page *opg = oap2osc_page(oap);
+ struct cl_page *page = cl_page_top(oap2cl_page(oap));
+ struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj);
+ enum cl_req_type crt;
int srvlock;
cmd &= ~OBD_BRW_NOQUOTA;
@@ -1318,7 +1319,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
/* statistic */
if (rc == 0 && srvlock) {
- struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev;
+ struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev;
struct osc_stats *stats = &lu2osc_dev(ld)->od_stats;
int bytes = oap->oap_count;
@@ -1396,7 +1397,7 @@ static int osc_reserve_grant(struct client_obd *cli, unsigned int bytes)
int rc = -EDQUOT;
if (cli->cl_avail_grant >= bytes) {
- cli->cl_avail_grant -= bytes;
+ cli->cl_avail_grant -= bytes;
cli->cl_reserved_grant += bytes;
rc = 0;
}
@@ -1510,6 +1511,7 @@ static int osc_enter_cache_try(struct client_obd *cli,
static int ocw_granted(struct client_obd *cli, struct osc_cache_waiter *ocw)
{
int rc;
+
client_obd_list_lock(&cli->cl_loi_list_lock);
rc = list_empty(&ocw->ocw_entry);
client_obd_list_unlock(&cli->cl_loi_list_lock);
@@ -1527,7 +1529,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
struct osc_async_page *oap, int bytes)
{
struct osc_object *osc = oap->oap_obj;
- struct lov_oinfo *loi = osc->oo_oinfo;
+ struct lov_oinfo *loi = osc->oo_oinfo;
struct osc_cache_waiter ocw;
struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
int rc = -EDQUOT;
@@ -1632,6 +1634,7 @@ wakeup:
static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc)
{
int hprpc = !!list_empty(&osc->oo_hp_exts);
+
return rpcs_in_flight(cli) >= cli->cl_max_rpcs_in_flight + hprpc;
}
@@ -1693,6 +1696,7 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc,
static void osc_update_pending(struct osc_object *obj, int cmd, int delta)
{
struct client_obd *cli = osc_cli(obj);
+
if (cmd & OBD_BRW_WRITE) {
atomic_add(delta, &obj->oo_nr_writes);
atomic_add(delta, &cli->cl_pending_w_pages);
@@ -1775,14 +1779,13 @@ static void osc_process_ar(struct osc_async_rc *ar, __u64 xid,
ar->ar_force_sync = 0;
}
-
/* this must be called holding the loi list lock to give coverage to exit_cache,
* async_flag maintenance, and oap_request */
static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli,
struct osc_async_page *oap, int sent, int rc)
{
struct osc_object *osc = oap->oap_obj;
- struct lov_oinfo *loi = osc->oo_oinfo;
+ struct lov_oinfo *loi = osc->oo_oinfo;
__u64 xid = 0;
if (oap->oap_request != NULL) {
@@ -1837,12 +1840,6 @@ static int try_to_add_extent_for_io(struct client_obd *cli,
oap2 = list_first_entry(&tmp->oe_pages, struct osc_async_page,
oap_pending_item);
EASSERT(tmp->oe_owner == current, tmp);
-#if 0
- if (overlapped(tmp, ext)) {
- OSC_EXTENT_DUMP(D_ERROR, tmp, "overlapped %p.\n", ext);
- EASSERT(0, ext);
- }
-#endif
if (oap2cl_page(oap)->cp_type != oap2cl_page(oap2)->cp_type) {
CDEBUG(D_CACHE, "Do not permit different type of IO"
" for a same RPC\n");
@@ -1940,7 +1937,7 @@ static int get_write_extents(struct osc_object *obj, struct list_head *rpclist)
static int
osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
- struct osc_object *osc, pdl_policy_t pol)
+ struct osc_object *osc)
{
LIST_HEAD(rpclist);
struct osc_extent *ext;
@@ -1992,7 +1989,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
if (!list_empty(&rpclist)) {
LASSERT(page_count > 0);
- rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_WRITE, pol);
+ rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_WRITE);
LASSERT(list_empty(&rpclist));
}
@@ -2012,7 +2009,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
*/
static int
osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli,
- struct osc_object *osc, pdl_policy_t pol)
+ struct osc_object *osc)
{
struct osc_extent *ext;
struct osc_extent *next;
@@ -2039,7 +2036,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli,
osc_object_unlock(osc);
LASSERT(page_count > 0);
- rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ, pol);
+ rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ);
LASSERT(list_empty(&rpclist));
osc_object_lock(osc);
@@ -2049,7 +2046,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli,
#define list_to_obj(list, item) ({ \
struct list_head *__tmp = (list)->next; \
- list_del_init(__tmp); \
+ list_del_init(__tmp); \
list_entry(__tmp, struct osc_object, oo_##item); \
})
@@ -2085,8 +2082,7 @@ static struct osc_object *osc_next_obj(struct client_obd *cli)
}
/* called with the loi list lock held */
-static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
- pdl_policy_t pol)
+static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
{
struct osc_object *osc;
int rc = 0;
@@ -2115,7 +2111,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
* do io on writes while there are cache waiters */
osc_object_lock(osc);
if (osc_makes_rpc(cli, osc, OBD_BRW_WRITE)) {
- rc = osc_send_write_rpc(env, cli, osc, pol);
+ rc = osc_send_write_rpc(env, cli, osc);
if (rc < 0) {
CERROR("Write request failed with %d\n", rc);
@@ -2139,7 +2135,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
}
}
if (osc_makes_rpc(cli, osc, OBD_BRW_READ)) {
- rc = osc_send_read_rpc(env, cli, osc, pol);
+ rc = osc_send_read_rpc(env, cli, osc);
if (rc < 0)
CERROR("Read request failed with %d\n", rc);
}
@@ -2155,7 +2151,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli,
}
static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli,
- struct osc_object *osc, pdl_policy_t pol, int async)
+ struct osc_object *osc, int async)
{
int rc = 0;
@@ -2167,7 +2163,7 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli,
* potential stack overrun problem. LU-2859 */
atomic_inc(&cli->cl_lru_shrinkers);
client_obd_list_lock(&cli->cl_loi_list_lock);
- osc_check_rpcs(env, cli, pol);
+ osc_check_rpcs(env, cli);
client_obd_list_unlock(&cli->cl_loi_list_lock);
atomic_dec(&cli->cl_lru_shrinkers);
} else {
@@ -2179,22 +2175,21 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli,
}
static int osc_io_unplug_async(const struct lu_env *env,
- struct client_obd *cli, struct osc_object *osc)
+ struct client_obd *cli, struct osc_object *osc)
{
- /* XXX: policy is no use actually. */
- return osc_io_unplug0(env, cli, osc, PDL_POLICY_ROUND, 1);
+ return osc_io_unplug0(env, cli, osc, 1);
}
void osc_io_unplug(const struct lu_env *env, struct client_obd *cli,
- struct osc_object *osc, pdl_policy_t pol)
+ struct osc_object *osc)
{
- (void)osc_io_unplug0(env, cli, osc, pol, 0);
+ (void)osc_io_unplug0(env, cli, osc, 0);
}
int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
struct page *page, loff_t offset)
{
- struct obd_export *exp = osc_export(osc);
+ struct obd_export *exp = osc_export(osc);
struct osc_async_page *oap = &ops->ops_oap;
if (!page)
@@ -2224,16 +2219,16 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
struct osc_page *ops)
{
struct osc_io *oio = osc_env_io(env);
- struct osc_extent *ext = NULL;
+ struct osc_extent *ext = NULL;
struct osc_async_page *oap = &ops->ops_oap;
- struct client_obd *cli = oap->oap_cli;
- struct osc_object *osc = oap->oap_obj;
+ struct client_obd *cli = oap->oap_cli;
+ struct osc_object *osc = oap->oap_obj;
pgoff_t index;
- int grants = 0;
- int brw_flags = OBD_BRW_ASYNC;
- int cmd = OBD_BRW_WRITE;
- int need_release = 0;
- int rc = 0;
+ int grants = 0;
+ int brw_flags = OBD_BRW_ASYNC;
+ int cmd = OBD_BRW_WRITE;
+ int need_release = 0;
+ int rc = 0;
if (oap->oap_magic != OAP_MAGIC)
return -EINVAL;
@@ -2256,7 +2251,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
/* check if the file's owner/group is over quota */
if (!(cmd & OBD_BRW_NOQUOTA)) {
struct cl_object *obj;
- struct cl_attr *attr;
+ struct cl_attr *attr;
unsigned int qid[MAXQUOTAS];
obj = cl_object_top(&osc->oo_cl);
@@ -2386,7 +2381,7 @@ int osc_teardown_async_page(const struct lu_env *env,
struct osc_object *obj, struct osc_page *ops)
{
struct osc_async_page *oap = &ops->ops_oap;
- struct osc_extent *ext = NULL;
+ struct osc_extent *ext = NULL;
int rc = 0;
LASSERT(oap->oap_magic == OAP_MAGIC);
@@ -2425,10 +2420,10 @@ int osc_teardown_async_page(const struct lu_env *env,
int osc_flush_async_page(const struct lu_env *env, struct cl_io *io,
struct osc_page *ops)
{
- struct osc_extent *ext = NULL;
- struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj);
- struct cl_page *cp = ops->ops_cl.cpl_page;
- pgoff_t index = cp->cp_index;
+ struct osc_extent *ext = NULL;
+ struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj);
+ struct cl_page *cp = ops->ops_cl.cpl_page;
+ pgoff_t index = cp->cp_index;
struct osc_async_page *oap = &ops->ops_oap;
bool unplug = false;
int rc = 0;
@@ -2507,14 +2502,14 @@ out:
int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops)
{
struct osc_async_page *oap = &ops->ops_oap;
- struct osc_object *obj = oap->oap_obj;
- struct client_obd *cli = osc_cli(obj);
- struct osc_extent *ext;
- struct osc_extent *found = NULL;
- struct list_head *plist;
+ struct osc_object *obj = oap->oap_obj;
+ struct client_obd *cli = osc_cli(obj);
+ struct osc_extent *ext;
+ struct osc_extent *found = NULL;
+ struct list_head *plist;
pgoff_t index = oap2cl_page(oap)->cp_index;
- int rc = -EBUSY;
- int cmd;
+ int rc = -EBUSY;
+ int cmd;
LASSERT(!oap->oap_interrupted);
oap->oap_interrupted = 1;
@@ -2523,10 +2518,10 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops)
osc_object_lock(obj);
if (oap->oap_cmd & OBD_BRW_WRITE) {
plist = &obj->oo_urgent_exts;
- cmd = OBD_BRW_WRITE;
+ cmd = OBD_BRW_WRITE;
} else {
plist = &obj->oo_reading_exts;
- cmd = OBD_BRW_READ;
+ cmd = OBD_BRW_READ;
}
list_for_each_entry(ext, plist, oe_link) {
if (ext->oe_start <= index && ext->oe_end >= index) {
@@ -2564,16 +2559,17 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops)
int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj,
struct list_head *list, int cmd, int brw_flags)
{
- struct client_obd *cli = osc_cli(obj);
- struct osc_extent *ext;
+ struct client_obd *cli = osc_cli(obj);
+ struct osc_extent *ext;
struct osc_async_page *oap, *tmp;
- int page_count = 0;
- int mppr = cli->cl_max_pages_per_rpc;
- pgoff_t start = CL_PAGE_EOF;
- pgoff_t end = 0;
+ int page_count = 0;
+ int mppr = cli->cl_max_pages_per_rpc;
+ pgoff_t start = CL_PAGE_EOF;
+ pgoff_t end = 0;
list_for_each_entry(oap, list, oap_pending_item) {
struct cl_page *cp = oap2cl_page(oap);
+
if (cp->cp_index > end)
end = cp->cp_index;
if (cp->cp_index < start)
@@ -2785,7 +2781,7 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj,
{
struct osc_extent *ext;
pgoff_t index = start;
- int result = 0;
+ int result = 0;
again:
osc_object_lock(obj);
@@ -2859,6 +2855,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
result += ext->oe_nr_pages;
if (!discard) {
struct list_head *list = NULL;
+
if (hp) {
EASSERT(!ext->oe_hp, ext);
ext->oe_hp = 1;
@@ -2928,10 +2925,11 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
}
if (unplug)
- osc_io_unplug(env, osc_cli(obj), obj, PDL_POLICY_ROUND);
+ osc_io_unplug(env, osc_cli(obj), obj);
if (hp || discard) {
int rc;
+
rc = osc_cache_wait_range(env, obj, start, end);
if (result >= 0 && rc < 0)
result = rc;
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 365b2787b..d2d68452d 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -329,7 +329,6 @@ struct osc_lock {
struct osc_io *ols_owner;
};
-
/**
* Page state private for osc layer.
*/
@@ -454,7 +453,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj,
pgoff_t start, pgoff_t end);
void osc_io_unplug(const struct lu_env *env, struct client_obd *cli,
- struct osc_object *osc, pdl_policy_t pol);
+ struct osc_object *osc);
void osc_object_set_contended (struct osc_object *obj);
void osc_object_clear_contended(struct osc_object *obj);
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c b/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c
index 4935fc7c0..69b523c0f 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c
@@ -118,11 +118,11 @@ static struct lu_device *osc2lu_dev(struct osc_device *osc)
*/
static void *osc_key_init(const struct lu_context *ctx,
- struct lu_context_key *key)
+ struct lu_context_key *key)
{
struct osc_thread_info *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, osc_thread_kmem, GFP_NOFS);
+ info = kmem_cache_alloc(osc_thread_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
@@ -133,7 +133,7 @@ static void osc_key_fini(const struct lu_context *ctx,
{
struct osc_thread_info *info = data;
- OBD_SLAB_FREE_PTR(info, osc_thread_kmem);
+ kmem_cache_free(osc_thread_kmem, info);
}
struct lu_context_key osc_key = {
@@ -147,7 +147,7 @@ static void *osc_session_init(const struct lu_context *ctx,
{
struct osc_session *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, osc_session_kmem, GFP_NOFS);
+ info = kmem_cache_alloc(osc_session_kmem, GFP_NOFS | __GFP_ZERO);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
@@ -158,7 +158,7 @@ static void osc_session_fini(const struct lu_context *ctx,
{
struct osc_session *info = data;
- OBD_SLAB_FREE_PTR(info, osc_session_kmem);
+ kmem_cache_free(osc_session_kmem, info);
}
struct lu_context_key osc_session_key = {
@@ -204,7 +204,7 @@ static struct lu_device *osc_device_free(const struct lu_env *env,
struct osc_device *od = lu2osc_dev(d);
cl_device_fini(lu2cl_dev(d));
- OBD_FREE_PTR(od);
+ kfree(od);
return NULL;
}
@@ -217,8 +217,8 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env,
struct obd_device *obd;
int rc;
- OBD_ALLOC_PTR(od);
- if (od == NULL)
+ od = kzalloc(sizeof(*od), GFP_NOFS);
+ if (!od)
return ERR_PTR(-ENOMEM);
cl_device_init(&od->od_cl, t);
@@ -248,14 +248,14 @@ static const struct lu_device_type_operations osc_device_type_ops = {
.ldto_device_alloc = osc_device_alloc,
.ldto_device_free = osc_device_free,
- .ldto_device_init = osc_device_init,
- .ldto_device_fini = osc_device_fini
+ .ldto_device_init = osc_device_init,
+ .ldto_device_fini = osc_device_fini
};
struct lu_device_type osc_device_type = {
- .ldt_tags = LU_DEVICE_CL,
- .ldt_name = LUSTRE_OSC_NAME,
- .ldt_ops = &osc_device_type_ops,
+ .ldt_tags = LU_DEVICE_CL,
+ .ldt_name = LUSTRE_OSC_NAME,
+ .ldt_ops = &osc_device_type_ops,
.ldt_ctx_tags = LCT_CL_THREAD
};
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h b/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h
index af96c7bc7..5ed30ecc8 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -39,6 +39,10 @@
#define OAP_MAGIC 8675309
+extern atomic_t osc_pool_req_count;
+extern unsigned int osc_reqpool_maxreqcount;
+extern struct ptlrpc_request_pool *osc_rq_pool;
+
struct lu_env;
enum async_flags {
@@ -128,7 +132,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg);
int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
- struct list_head *ext_list, int cmd, pdl_policy_t p);
+ struct list_head *ext_list, int cmd);
int osc_lru_shrink(struct client_obd *cli, int target);
extern spinlock_t osc_ast_guard;
@@ -136,16 +140,8 @@ extern spinlock_t osc_ast_guard;
int osc_cleanup(struct obd_device *obd);
int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
-#if defined (CONFIG_PROC_FS)
int lproc_osc_attach_seqstat(struct obd_device *dev);
void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
-static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
extern struct lu_device_type osc_device_type;
@@ -189,6 +185,7 @@ struct osc_quota_info {
struct hlist_node oqi_hash;
u32 oqi_id;
};
+
int osc_quota_setup(struct obd_device *obd);
int osc_quota_cleanup(struct obd_device *obd);
int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_io.c b/kernel/drivers/staging/lustre/lustre/osc/osc_io.c
index 3c7300b06..d413496c0 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -78,7 +78,6 @@ static struct osc_page *osc_cl_page_osc(struct cl_page *page)
return cl2osc_page(slice);
}
-
/*****************************************************************************
*
* io operations.
@@ -100,16 +99,16 @@ static int osc_io_submit(const struct lu_env *env,
const struct cl_io_slice *ios,
enum cl_req_type crt, struct cl_2queue *queue)
{
- struct cl_page *page;
- struct cl_page *tmp;
- struct client_obd *cli = NULL;
- struct osc_object *osc = NULL; /* to keep gcc happy */
- struct osc_page *opg;
- struct cl_io *io;
+ struct cl_page *page;
+ struct cl_page *tmp;
+ struct client_obd *cli = NULL;
+ struct osc_object *osc = NULL; /* to keep gcc happy */
+ struct osc_page *opg;
+ struct cl_io *io;
LIST_HEAD(list);
- struct cl_page_list *qin = &queue->c2_qin;
- struct cl_page_list *qout = &queue->c2_qout;
+ struct cl_page_list *qin = &queue->c2_qin;
+ struct cl_page_list *qout = &queue->c2_qout;
int queued = 0;
int result = 0;
int cmd;
@@ -189,8 +188,8 @@ static int osc_io_submit(const struct lu_env *env,
static void osc_page_touch_at(const struct lu_env *env,
struct cl_object *obj, pgoff_t idx, unsigned to)
{
- struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
- struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
int valid;
__u64 kms;
@@ -233,8 +232,8 @@ static void osc_page_touch_at(const struct lu_env *env,
static void osc_page_touch(const struct lu_env *env,
struct osc_page *opage, unsigned to)
{
- struct cl_page *page = opage->ops_cl.cpl_page;
- struct cl_object *obj = opage->ops_cl.cpl_obj;
+ struct cl_page *page = opage->ops_cl.cpl_page;
+ struct cl_object *obj = opage->ops_cl.cpl_obj;
osc_page_touch_at(env, obj, page->cp_index, to);
}
@@ -260,7 +259,7 @@ static int osc_io_prepare_write(const struct lu_env *env,
{
struct osc_device *dev = lu2osc_dev(slice->cpl_obj->co_lu.lo_dev);
struct obd_import *imp = class_exp2cliimp(dev->od_exp);
- struct osc_io *oio = cl2osc_io(env, ios);
+ struct osc_io *oio = cl2osc_io(env, ios);
int result = 0;
/*
@@ -284,9 +283,9 @@ static int osc_io_commit_write(const struct lu_env *env,
const struct cl_page_slice *slice,
unsigned from, unsigned to)
{
- struct osc_io *oio = cl2osc_io(env, ios);
- struct osc_page *opg = cl2osc_page(slice);
- struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj);
+ struct osc_io *oio = cl2osc_io(env, ios);
+ struct osc_page *opg = cl2osc_page(slice);
+ struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj);
struct osc_async_page *oap = &opg->ops_oap;
LASSERT(to > 0);
@@ -311,10 +310,10 @@ static int osc_io_commit_write(const struct lu_env *env,
static int osc_io_fault_start(const struct lu_env *env,
const struct cl_io_slice *ios)
{
- struct cl_io *io;
+ struct cl_io *io;
struct cl_fault_io *fio;
- io = ios->cis_io;
+ io = ios->cis_io;
fio = &io->u.ci_fault;
CDEBUG(D_INFO, "%lu %d %d\n",
fio->ft_index, fio->ft_writable, fio->ft_nob);
@@ -375,11 +374,11 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
struct osc_io *oio, __u64 size)
{
struct cl_object *clob;
- int partial;
+ int partial;
pgoff_t start;
- clob = oio->oi_cl.cis_obj;
- start = cl_index(clob, size);
+ clob = oio->oi_cl.cis_obj;
+ start = cl_index(clob, size);
partial = cl_offset(clob, start) < size;
/*
@@ -392,17 +391,17 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
static int osc_io_setattr_start(const struct lu_env *env,
const struct cl_io_slice *slice)
{
- struct cl_io *io = slice->cis_io;
- struct osc_io *oio = cl2osc_io(env, slice);
- struct cl_object *obj = slice->cis_obj;
- struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
- struct cl_attr *attr = &osc_env_info(env)->oti_attr;
- struct obdo *oa = &oio->oi_oa;
+ struct cl_io *io = slice->cis_io;
+ struct osc_io *oio = cl2osc_io(env, slice);
+ struct cl_object *obj = slice->cis_obj;
+ struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ struct obdo *oa = &oio->oi_oa;
struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
- __u64 size = io->u.ci_setattr.sa_attr.lvb_size;
- unsigned int ia_valid = io->u.ci_setattr.sa_valid;
- int result = 0;
- struct obd_info oinfo = { { { 0 } } };
+ __u64 size = io->u.ci_setattr.sa_attr.lvb_size;
+ unsigned int ia_valid = io->u.ci_setattr.sa_valid;
+ int result = 0;
+ struct obd_info oinfo = { };
/* truncate cache dirty pages first */
if (cl_io_is_trunc(io))
@@ -457,7 +456,6 @@ static int osc_io_setattr_start(const struct lu_env *env,
}
oinfo.oi_oa = oa;
- oinfo.oi_capa = io->u.ci_setattr.sa_capa;
init_completion(&cbargs->opc_sync);
if (ia_valid & ATTR_SIZE)
@@ -477,8 +475,8 @@ static int osc_io_setattr_start(const struct lu_env *env,
static void osc_io_setattr_end(const struct lu_env *env,
const struct cl_io_slice *slice)
{
- struct cl_io *io = slice->cis_io;
- struct osc_io *oio = cl2osc_io(env, slice);
+ struct cl_io *io = slice->cis_io;
+ struct osc_io *oio = cl2osc_io(env, slice);
struct cl_object *obj = slice->cis_obj;
struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
int result = 0;
@@ -512,13 +510,13 @@ static void osc_io_setattr_end(const struct lu_env *env,
static int osc_io_read_start(const struct lu_env *env,
const struct cl_io_slice *slice)
{
- struct cl_object *obj = slice->cis_obj;
- struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ struct cl_object *obj = slice->cis_obj;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
int rc = 0;
if (!slice->cis_io->ci_noatime) {
cl_object_attr_lock(obj);
- attr->cat_atime = LTIME_S(CURRENT_TIME);
+ attr->cat_atime = ktime_get_real_seconds();
rc = cl_object_attr_set(env, obj, attr, CAT_ATIME);
cl_object_attr_unlock(obj);
}
@@ -528,13 +526,13 @@ static int osc_io_read_start(const struct lu_env *env,
static int osc_io_write_start(const struct lu_env *env,
const struct cl_io_slice *slice)
{
- struct cl_object *obj = slice->cis_obj;
- struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ struct cl_object *obj = slice->cis_obj;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
int rc = 0;
OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1);
cl_object_attr_lock(obj);
- attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME);
+ attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds();
rc = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME);
cl_object_attr_unlock(obj);
@@ -544,10 +542,10 @@ static int osc_io_write_start(const struct lu_env *env,
static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
struct cl_fsync_io *fio)
{
- struct osc_io *oio = osc_env_io(env);
- struct obdo *oa = &oio->oi_oa;
- struct obd_info *oinfo = &oio->oi_info;
- struct lov_oinfo *loi = obj->oo_oinfo;
+ struct osc_io *oio = osc_env_io(env);
+ struct obdo *oa = &oio->oi_oa;
+ struct obd_info *oinfo = &oio->oi_info;
+ struct lov_oinfo *loi = obj->oo_oinfo;
struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
int rc = 0;
@@ -564,7 +562,6 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
memset(oinfo, 0, sizeof(*oinfo));
oinfo->oi_oa = oa;
- oinfo->oi_capa = fio->fi_capa;
init_completion(&cbargs->opc_sync);
rc = osc_sync_base(osc_export(obj), oinfo, osc_async_upcall, cbargs,
@@ -575,13 +572,13 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
static int osc_io_fsync_start(const struct lu_env *env,
const struct cl_io_slice *slice)
{
- struct cl_io *io = slice->cis_io;
+ struct cl_io *io = slice->cis_io;
struct cl_fsync_io *fio = &io->u.ci_fsync;
- struct cl_object *obj = slice->cis_obj;
- struct osc_object *osc = cl2osc(obj);
- pgoff_t start = cl_index(obj, fio->fi_start);
- pgoff_t end = cl_index(obj, fio->fi_end);
- int result = 0;
+ struct cl_object *obj = slice->cis_obj;
+ struct osc_object *osc = cl2osc(obj);
+ pgoff_t start = cl_index(obj, fio->fi_start);
+ pgoff_t end = cl_index(obj, fio->fi_end);
+ int result = 0;
if (fio->fi_end == OBD_OBJECT_EOF)
end = CL_PAGE_EOF;
@@ -615,15 +612,15 @@ static void osc_io_fsync_end(const struct lu_env *env,
const struct cl_io_slice *slice)
{
struct cl_fsync_io *fio = &slice->cis_io->u.ci_fsync;
- struct cl_object *obj = slice->cis_obj;
+ struct cl_object *obj = slice->cis_obj;
pgoff_t start = cl_index(obj, fio->fi_start);
- pgoff_t end = cl_index(obj, fio->fi_end);
+ pgoff_t end = cl_index(obj, fio->fi_end);
int result = 0;
if (fio->fi_mode == CL_FSYNC_LOCAL) {
result = osc_cache_wait_range(env, cl2osc(obj), start, end);
} else if (fio->fi_mode == CL_FSYNC_ALL) {
- struct osc_io *oio = cl2osc_io(env, slice);
+ struct osc_io *oio = cl2osc_io(env, slice);
struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
wait_for_completion(&cbargs->opc_sync);
@@ -703,7 +700,7 @@ static void osc_req_completion(const struct lu_env *env,
struct osc_req *or;
or = cl2osc_req(slice);
- OBD_SLAB_FREE_PTR(or, osc_req_kmem);
+ kmem_cache_free(osc_req_kmem, or);
}
/**
@@ -717,17 +714,17 @@ static void osc_req_attr_set(const struct lu_env *env,
struct cl_req_attr *attr, u64 flags)
{
struct lov_oinfo *oinfo;
- struct cl_req *clerq;
- struct cl_page *apage; /* _some_ page in @clerq */
- struct cl_lock *lock; /* _some_ lock protecting @apage */
- struct osc_lock *olck;
- struct osc_page *opg;
- struct obdo *oa;
- struct ost_lvb *lvb;
-
- oinfo = cl2osc(obj)->oo_oinfo;
- lvb = &oinfo->loi_lvb;
- oa = attr->cra_oa;
+ struct cl_req *clerq;
+ struct cl_page *apage; /* _some_ page in @clerq */
+ struct cl_lock *lock; /* _some_ lock protecting @apage */
+ struct osc_lock *olck;
+ struct osc_page *opg;
+ struct obdo *oa;
+ struct ost_lvb *lvb;
+
+ oinfo = cl2osc(obj)->oo_oinfo;
+ lvb = &oinfo->loi_lvb;
+ oa = attr->cra_oa;
if ((flags & OBD_MD_FLMTIME) != 0) {
oa->o_mtime = lvb->lvb_mtime;
@@ -759,7 +756,7 @@ static void osc_req_attr_set(const struct lu_env *env,
lock = cl_lock_at_page(env, apage->cp_obj, apage, NULL, 1, 1);
if (lock == NULL) {
struct cl_object_header *head;
- struct cl_lock *scan;
+ struct cl_lock *scan;
head = cl_object_header(apage->cp_obj);
list_for_each_entry(scan, &head->coh_locks,
@@ -790,7 +787,6 @@ static const struct cl_req_operations osc_req_ops = {
.cro_completion = osc_req_completion
};
-
int osc_io_init(const struct lu_env *env,
struct cl_object *obj, struct cl_io *io)
{
@@ -807,7 +803,7 @@ int osc_req_init(const struct lu_env *env, struct cl_device *dev,
struct osc_req *or;
int result;
- OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, GFP_NOFS);
+ or = kmem_cache_alloc(osc_req_kmem, GFP_NOFS | __GFP_ZERO);
if (or != NULL) {
cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops);
result = 0;
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c b/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c
index 350ad4955..194490dca 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c
@@ -89,9 +89,9 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle)
*/
static int osc_lock_invariant(struct osc_lock *ols)
{
- struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle);
- struct ldlm_lock *olock = ols->ols_lock;
- int handle_used = lustre_handle_is_used(&ols->ols_handle);
+ struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle);
+ struct ldlm_lock *olock = ols->ols_lock;
+ int handle_used = lustre_handle_is_used(&ols->ols_handle);
if (ergo(osc_lock_is_lockless(ols),
ols->ols_locklessable && ols->ols_lock == NULL))
@@ -164,7 +164,7 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck)
lock_res_and_lock(dlmlock);
if (dlmlock->l_granted_mode == dlmlock->l_req_mode) {
struct cl_object *obj = olck->ols_cl.cls_obj;
- struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
__u64 old_kms;
cl_object_attr_lock(obj);
@@ -237,7 +237,7 @@ static int osc_lock_unuse(const struct lu_env *env,
static void osc_lock_fini(const struct lu_env *env,
struct cl_lock_slice *slice)
{
- struct osc_lock *ols = cl2osc_lock(slice);
+ struct osc_lock *ols = cl2osc_lock(slice);
LINVRNT(osc_lock_invariant(ols));
/*
@@ -251,7 +251,7 @@ static void osc_lock_fini(const struct lu_env *env,
LASSERT(atomic_read(&ols->ols_pageref) == 0 ||
atomic_read(&ols->ols_pageref) == _PAGEREF_MAGIC);
- OBD_SLAB_FREE_PTR(ols, osc_lock_kmem);
+ kmem_cache_free(osc_lock_kmem, ols);
}
static void osc_lock_build_policy(const struct lu_env *env,
@@ -337,25 +337,25 @@ static void osc_ast_data_put(const struct lu_env *env, struct osc_lock *olck)
static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck,
int rc)
{
- struct ost_lvb *lvb;
- struct cl_object *obj;
- struct lov_oinfo *oinfo;
- struct cl_attr *attr;
- unsigned valid;
+ struct ost_lvb *lvb;
+ struct cl_object *obj;
+ struct lov_oinfo *oinfo;
+ struct cl_attr *attr;
+ unsigned valid;
if (!(olck->ols_flags & LDLM_FL_LVB_READY))
return;
- lvb = &olck->ols_lvb;
- obj = olck->ols_cl.cls_obj;
+ lvb = &olck->ols_lvb;
+ obj = olck->ols_cl.cls_obj;
oinfo = cl2osc(obj)->oo_oinfo;
- attr = &osc_env_info(env)->oti_attr;
+ attr = &osc_env_info(env)->oti_attr;
valid = CAT_BLOCKS | CAT_ATIME | CAT_CTIME | CAT_MTIME | CAT_SIZE;
cl_lvb2attr(attr, lvb);
cl_object_attr_lock(obj);
if (rc == 0) {
- struct ldlm_lock *dlmlock;
+ struct ldlm_lock *dlmlock;
__u64 size;
dlmlock = olck->ols_lock;
@@ -401,23 +401,23 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck,
static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck,
struct ldlm_lock *dlmlock, int rc)
{
- struct ldlm_extent *ext;
- struct cl_lock *lock;
+ struct ldlm_extent *ext;
+ struct cl_lock *lock;
struct cl_lock_descr *descr;
LASSERT(dlmlock->l_granted_mode == dlmlock->l_req_mode);
if (olck->ols_state < OLS_GRANTED) {
- lock = olck->ols_cl.cls_lock;
- ext = &dlmlock->l_policy_data.l_extent;
+ lock = olck->ols_cl.cls_lock;
+ ext = &dlmlock->l_policy_data.l_extent;
descr = &osc_env_info(env)->oti_descr;
descr->cld_obj = lock->cll_descr.cld_obj;
/* XXX check that ->l_granted_mode is valid. */
- descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode);
+ descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode);
descr->cld_start = cl_index(descr->cld_obj, ext->start);
- descr->cld_end = cl_index(descr->cld_obj, ext->end);
- descr->cld_gid = ext->gid;
+ descr->cld_end = cl_index(descr->cld_obj, ext->end);
+ descr->cld_gid = ext->gid;
/*
* tell upper layers the extent of the lock that was actually
* granted
@@ -482,11 +482,11 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck)
*/
static int osc_lock_upcall(void *cookie, int errcode)
{
- struct osc_lock *olck = cookie;
- struct cl_lock_slice *slice = &olck->ols_cl;
- struct cl_lock *lock = slice->cls_lock;
- struct lu_env *env;
- struct cl_env_nest nest;
+ struct osc_lock *olck = cookie;
+ struct cl_lock_slice *slice = &olck->ols_cl;
+ struct cl_lock *lock = slice->cls_lock;
+ struct lu_env *env;
+ struct cl_env_nest nest;
env = cl_env_nested_get(&nest);
if (!IS_ERR(env)) {
@@ -626,7 +626,7 @@ static int osc_dlm_blocking_ast0(const struct lu_env *env,
void *data, int flag)
{
struct osc_lock *olck;
- struct cl_lock *lock;
+ struct cl_lock *lock;
int result;
int cancel;
@@ -733,9 +733,9 @@ static int osc_ldlm_blocking_ast(struct ldlm_lock *dlmlock,
struct ldlm_lock_desc *new, void *data,
int flag)
{
- struct lu_env *env;
+ struct lu_env *env;
struct cl_env_nest nest;
- int result;
+ int result;
/*
* This can be called in the context of outer IO, e.g.,
@@ -774,9 +774,9 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock,
__u64 flags, void *data)
{
struct cl_env_nest nest;
- struct lu_env *env;
- struct osc_lock *olck;
- struct cl_lock *lock;
+ struct lu_env *env;
+ struct osc_lock *olck;
+ struct cl_lock *lock;
int result;
int dlmrc;
@@ -830,15 +830,15 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock,
static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data)
{
- struct ptlrpc_request *req = data;
+ struct ptlrpc_request *req = data;
struct osc_lock *olck;
- struct cl_lock *lock;
- struct cl_object *obj;
- struct cl_env_nest nest;
- struct lu_env *env;
- struct ost_lvb *lvb;
- struct req_capsule *cap;
- int result;
+ struct cl_lock *lock;
+ struct cl_object *obj;
+ struct cl_env_nest nest;
+ struct lu_env *env;
+ struct ost_lvb *lvb;
+ struct req_capsule *cap;
+ int result;
LASSERT(lustre_msg_get_opc(req->rq_reqmsg) == LDLM_GL_CALLBACK);
@@ -916,11 +916,11 @@ static void osc_lock_build_einfo(const struct lu_env *env,
*/
mode = CLM_READ;
- einfo->ei_type = LDLM_EXTENT;
- einfo->ei_mode = osc_cl_lock2ldlm(mode);
- einfo->ei_cb_bl = osc_ldlm_blocking_ast;
- einfo->ei_cb_cp = osc_ldlm_completion_ast;
- einfo->ei_cb_gl = osc_ldlm_glimpse_ast;
+ einfo->ei_type = LDLM_EXTENT;
+ einfo->ei_mode = osc_cl_lock2ldlm(mode);
+ einfo->ei_cb_bl = osc_ldlm_blocking_ast;
+ einfo->ei_cb_cp = osc_ldlm_completion_ast;
+ einfo->ei_cb_gl = osc_ldlm_glimpse_ast;
einfo->ei_cbdata = lock; /* value to be put into ->l_ast_data */
}
@@ -948,9 +948,9 @@ static void osc_lock_to_lockless(const struct lu_env *env,
ols->ols_locklessable = 1;
slice->cls_ops = &osc_lock_lockless_ops;
} else {
- struct osc_io *oio = osc_env_io(env);
- struct cl_io *io = oio->oi_cl.cis_io;
- struct cl_object *obj = slice->cls_obj;
+ struct osc_io *oio = osc_env_io(env);
+ struct cl_io *io = oio->oi_cl.cis_io;
+ struct cl_object *obj = slice->cls_obj;
struct osc_object *oob = cl2osc(obj);
const struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev);
struct obd_connect_data *ocd;
@@ -1006,13 +1006,13 @@ static int osc_lock_compatible(const struct osc_lock *qing,
static int osc_lock_enqueue_wait(const struct lu_env *env,
const struct osc_lock *olck)
{
- struct cl_lock *lock = olck->ols_cl.cls_lock;
- struct cl_lock_descr *descr = &lock->cll_descr;
- struct cl_object_header *hdr = cl_object_header(descr->cld_obj);
- struct cl_lock *scan;
- struct cl_lock *conflict = NULL;
- int lockless = osc_lock_is_lockless(olck);
- int rc = 0;
+ struct cl_lock *lock = olck->ols_cl.cls_lock;
+ struct cl_lock_descr *descr = &lock->cll_descr;
+ struct cl_object_header *hdr = cl_object_header(descr->cld_obj);
+ struct cl_lock *scan;
+ struct cl_lock *conflict = NULL;
+ int lockless = osc_lock_is_lockless(olck);
+ int rc = 0;
LASSERT(cl_lock_is_mutexed(lock));
@@ -1102,8 +1102,8 @@ static int osc_lock_enqueue(const struct lu_env *env,
const struct cl_lock_slice *slice,
struct cl_io *unused, __u32 enqflags)
{
- struct osc_lock *ols = cl2osc_lock(slice);
- struct cl_lock *lock = ols->ols_cl.cls_lock;
+ struct osc_lock *ols = cl2osc_lock(slice);
+ struct cl_lock *lock = ols->ols_cl.cls_lock;
int result;
LASSERT(cl_lock_is_mutexed(lock));
@@ -1116,10 +1116,10 @@ static int osc_lock_enqueue(const struct lu_env *env,
result = osc_lock_enqueue_wait(env, ols);
if (result == 0) {
if (!osc_lock_is_lockless(ols)) {
- struct osc_object *obj = cl2osc(slice->cls_obj);
- struct osc_thread_info *info = osc_env_info(env);
- struct ldlm_res_id *resname = &info->oti_resname;
- ldlm_policy_data_t *policy = &info->oti_policy;
+ struct osc_object *obj = cl2osc(slice->cls_obj);
+ struct osc_thread_info *info = osc_env_info(env);
+ struct ldlm_res_id *resname = &info->oti_resname;
+ ldlm_policy_data_t *policy = &info->oti_policy;
struct ldlm_enqueue_info *einfo = &ols->ols_einfo;
/* lock will be passed as upcall cookie,
@@ -1164,7 +1164,7 @@ static int osc_lock_wait(const struct lu_env *env,
const struct cl_lock_slice *slice)
{
struct osc_lock *olck = cl2osc_lock(slice);
- struct cl_lock *lock = olck->ols_cl.cls_lock;
+ struct cl_lock *lock = olck->ols_cl.cls_lock;
LINVRNT(osc_lock_invariant(olck));
@@ -1176,8 +1176,7 @@ static int osc_lock_wait(const struct lu_env *env,
/* It is from enqueue RPC reply upcall for
* updating state. Do not re-enqueue. */
return -ENAVAIL;
- else
- olck->ols_state = OLS_NEW;
+ olck->ols_state = OLS_NEW;
} else {
LASSERT(lock->cll_error);
return lock->cll_error;
@@ -1245,14 +1244,14 @@ static int osc_lock_use(const struct lu_env *env,
static int osc_lock_flush(struct osc_lock *ols, int discard)
{
- struct cl_lock *lock = ols->ols_cl.cls_lock;
- struct cl_env_nest nest;
- struct lu_env *env;
+ struct cl_lock *lock = ols->ols_cl.cls_lock;
+ struct cl_env_nest nest;
+ struct lu_env *env;
int result = 0;
env = cl_env_nested_get(&nest);
if (!IS_ERR(env)) {
- struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj);
+ struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj);
struct cl_lock_descr *descr = &lock->cll_descr;
int rc = 0;
@@ -1298,11 +1297,11 @@ static int osc_lock_flush(struct osc_lock *ols, int discard)
static void osc_lock_cancel(const struct lu_env *env,
const struct cl_lock_slice *slice)
{
- struct cl_lock *lock = slice->cls_lock;
- struct osc_lock *olck = cl2osc_lock(slice);
+ struct cl_lock *lock = slice->cls_lock;
+ struct osc_lock *olck = cl2osc_lock(slice);
struct ldlm_lock *dlmlock = olck->ols_lock;
- int result = 0;
- int discard;
+ int result = 0;
+ int discard;
LASSERT(cl_lock_is_mutexed(lock));
LINVRNT(osc_lock_invariant(olck));
@@ -1482,7 +1481,7 @@ static int osc_lock_lockless_unuse(const struct lu_env *env,
static void osc_lock_lockless_cancel(const struct lu_env *env,
const struct cl_lock_slice *slice)
{
- struct osc_lock *ols = cl2osc_lock(slice);
+ struct osc_lock *ols = cl2osc_lock(slice);
int result;
result = osc_lock_flush(ols, 0);
@@ -1496,7 +1495,7 @@ static int osc_lock_lockless_wait(const struct lu_env *env,
const struct cl_lock_slice *slice)
{
struct osc_lock *olck = cl2osc_lock(slice);
- struct cl_lock *lock = olck->ols_cl.cls_lock;
+ struct cl_lock *lock = olck->ols_cl.cls_lock;
LINVRNT(osc_lock_invariant(olck));
LASSERT(olck->ols_state >= OLS_UPCALL_RECEIVED);
@@ -1512,7 +1511,7 @@ static void osc_lock_lockless_state(const struct lu_env *env,
LINVRNT(osc_lock_invariant(lock));
if (state == CLS_HELD) {
- struct osc_io *oio = osc_env_io(env);
+ struct osc_io *oio = osc_env_io(env);
LASSERT(ergo(lock->ols_owner, lock->ols_owner == oio));
lock->ols_owner = oio;
@@ -1556,7 +1555,7 @@ int osc_lock_init(const struct lu_env *env,
struct osc_lock *clk;
int result;
- OBD_SLAB_ALLOC_PTR_GFP(clk, osc_lock_kmem, GFP_NOFS);
+ clk = kmem_cache_alloc(osc_lock_kmem, GFP_NOFS | __GFP_ZERO);
if (clk != NULL) {
__u32 enqflags = lock->cll_descr.cld_enq_flags;
@@ -1591,7 +1590,7 @@ int osc_lock_init(const struct lu_env *env,
int osc_dlm_lock_pageref(struct ldlm_lock *dlm)
{
struct osc_lock *olock;
- int rc = 0;
+ int rc = 0;
spin_lock(&osc_ast_guard);
olock = dlm->l_ast_data;
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_object.c b/kernel/drivers/staging/lustre/lustre/osc/osc_object.c
index 92c202f70..ba57f8df5 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -72,7 +72,7 @@ static struct osc_object *lu2osc(const struct lu_object *obj)
static int osc_object_init(const struct lu_env *env, struct lu_object *obj,
const struct lu_object_conf *conf)
{
- struct osc_object *osc = lu2osc(obj);
+ struct osc_object *osc = lu2osc(obj);
const struct cl_object_conf *cconf = lu2cl_conf(conf);
int i;
@@ -122,7 +122,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj)
LASSERT(atomic_read(&osc->oo_nr_writes) == 0);
lu_object_fini(obj);
- OBD_SLAB_FREE_PTR(osc, osc_object_kmem);
+ kmem_cache_free(osc_object_kmem, osc);
}
int osc_lvb_print(const struct lu_env *env, void *cookie,
@@ -136,9 +136,9 @@ int osc_lvb_print(const struct lu_env *env, void *cookie,
static int osc_object_print(const struct lu_env *env, void *cookie,
lu_printer_t p, const struct lu_object *obj)
{
- struct osc_object *osc = lu2osc(obj);
- struct lov_oinfo *oinfo = osc->oo_oinfo;
- struct osc_async_rc *ar = &oinfo->loi_ar;
+ struct osc_object *osc = lu2osc(obj);
+ struct lov_oinfo *oinfo = osc->oo_oinfo;
+ struct osc_async_rc *ar = &oinfo->loi_ar;
(*p)(env, cookie, "id: " DOSTID " idx: %d gen: %d kms_valid: %u kms %llu rc: %d force_sync: %d min_xid: %llu ",
POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx,
@@ -148,7 +148,6 @@ static int osc_object_print(const struct lu_env *env, void *cookie,
return 0;
}
-
static int osc_attr_get(const struct lu_env *env, struct cl_object *obj,
struct cl_attr *attr)
{
@@ -163,7 +162,7 @@ int osc_attr_set(const struct lu_env *env, struct cl_object *obj,
const struct cl_attr *attr, unsigned valid)
{
struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
- struct ost_lvb *lvb = &oinfo->loi_lvb;
+ struct ost_lvb *lvb = &oinfo->loi_lvb;
if (valid & CAT_SIZE)
lvb->lvb_size = attr->cat_size;
@@ -188,12 +187,11 @@ static int osc_object_glimpse(const struct lu_env *env,
{
struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
- lvb->lvb_size = oinfo->loi_kms;
+ lvb->lvb_size = oinfo->loi_kms;
lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks;
return 0;
}
-
void osc_object_set_contended(struct osc_object *obj)
{
obj->oo_contention_time = cfs_time_current();
@@ -208,9 +206,9 @@ void osc_object_clear_contended(struct osc_object *obj)
int osc_object_is_contended(struct osc_object *obj)
{
- struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
+ struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
int osc_contention_time = dev->od_contention_time;
- unsigned long cur_time = cfs_time_current();
+ unsigned long cur_time = cfs_time_current();
unsigned long retry_time;
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
@@ -255,9 +253,9 @@ struct lu_object *osc_object_alloc(const struct lu_env *env,
struct lu_device *dev)
{
struct osc_object *osc;
- struct lu_object *obj;
+ struct lu_object *obj;
- OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, GFP_NOFS);
+ osc = kmem_cache_alloc(osc_object_kmem, GFP_NOFS | __GFP_ZERO);
if (osc != NULL) {
obj = osc2lu(osc);
lu_object_init(obj, NULL, dev);
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_page.c b/kernel/drivers/staging/lustre/lustre/osc/osc_page.c
index 76ba58b09..61eaf7172 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -166,6 +166,7 @@ static void osc_page_fini(const struct lu_env *env,
struct cl_page_slice *slice)
{
struct osc_page *opg = cl2osc_page(slice);
+
CDEBUG(D_TRACE, "%p\n", opg);
LASSERT(opg->ops_lock == NULL);
}
@@ -216,7 +217,7 @@ static int osc_page_cache_add(const struct lu_env *env,
const struct cl_page_slice *slice,
struct cl_io *io)
{
- struct osc_io *oio = osc_env_io(env);
+ struct osc_io *oio = osc_env_io(env);
struct osc_page *opg = cl2osc_page(slice);
int result;
@@ -247,7 +248,7 @@ void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj,
{
memset(policy, 0, sizeof(*policy));
policy->l_extent.start = cl_offset(obj, start);
- policy->l_extent.end = cl_offset(obj, end + 1) - 1;
+ policy->l_extent.end = cl_offset(obj, end + 1) - 1;
}
static int osc_page_addref_lock(const struct lu_env *env,
@@ -255,7 +256,7 @@ static int osc_page_addref_lock(const struct lu_env *env,
struct cl_lock *lock)
{
struct osc_lock *olock;
- int rc;
+ int rc;
LASSERT(opg->ops_lock == NULL);
@@ -274,7 +275,7 @@ static int osc_page_addref_lock(const struct lu_env *env,
static void osc_page_putref_lock(const struct lu_env *env,
struct osc_page *opg)
{
- struct cl_lock *lock = opg->ops_lock;
+ struct cl_lock *lock = opg->ops_lock;
struct osc_lock *olock;
LASSERT(lock != NULL);
@@ -291,7 +292,7 @@ static int osc_page_is_under_lock(const struct lu_env *env,
struct cl_io *unused)
{
struct cl_lock *lock;
- int result = -ENODATA;
+ int result = -ENODATA;
lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page,
NULL, 1, 0);
@@ -317,7 +318,7 @@ static void osc_page_completion_read(const struct lu_env *env,
const struct cl_page_slice *slice,
int ioret)
{
- struct osc_page *opg = cl2osc_page(slice);
+ struct osc_page *opg = cl2osc_page(slice);
struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj);
if (likely(opg->ops_lock))
@@ -329,7 +330,7 @@ static void osc_page_completion_write(const struct lu_env *env,
const struct cl_page_slice *slice,
int ioret)
{
- struct osc_page *opg = cl2osc_page(slice);
+ struct osc_page *opg = cl2osc_page(slice);
struct osc_object *obj = cl2osc(slice->cpl_obj);
osc_lru_add(osc_cli(obj), opg);
@@ -346,7 +347,6 @@ static int osc_page_fail(const struct lu_env *env,
return 0;
}
-
static const char *osc_list(struct list_head *head)
{
return list_empty(head) ? "-" : "+";
@@ -364,10 +364,10 @@ static int osc_page_print(const struct lu_env *env,
const struct cl_page_slice *slice,
void *cookie, lu_printer_t printer)
{
- struct osc_page *opg = cl2osc_page(slice);
+ struct osc_page *opg = cl2osc_page(slice);
struct osc_async_page *oap = &opg->ops_oap;
- struct osc_object *obj = cl2osc(slice->cpl_obj);
- struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli;
+ struct osc_object *obj = cl2osc(slice->cpl_obj);
+ struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli;
return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p: 1< %#x %d %u %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %s %p %d %lu %d > 4< %d %d %d %lu %s | %s %s %s %s > 5< %s %s %s %s | %d %s | %d %s %s>\n",
opg,
@@ -408,7 +408,7 @@ static int osc_page_print(const struct lu_env *env,
static void osc_page_delete(const struct lu_env *env,
const struct cl_page_slice *slice)
{
- struct osc_page *opg = cl2osc_page(slice);
+ struct osc_page *opg = cl2osc_page(slice);
struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj);
int rc;
@@ -437,13 +437,13 @@ static void osc_page_delete(const struct lu_env *env,
void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice,
int from, int to)
{
- struct osc_page *opg = cl2osc_page(slice);
+ struct osc_page *opg = cl2osc_page(slice);
struct osc_async_page *oap = &opg->ops_oap;
LINVRNT(osc_page_protected(env, opg, CLM_READ, 0));
opg->ops_from = from;
- opg->ops_to = to;
+ opg->ops_to = to;
spin_lock(&oap->oap_lock);
oap->oap_async_flags |= ASYNC_COUNT_STABLE;
spin_unlock(&oap->oap_lock);
@@ -471,7 +471,7 @@ static int osc_page_flush(const struct lu_env *env,
struct cl_io *io)
{
struct osc_page *opg = cl2osc_page(slice);
- int rc = 0;
+ int rc;
rc = osc_flush_async_page(env, io, opg);
return rc;
@@ -502,16 +502,17 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj,
struct cl_page *page, struct page *vmpage)
{
struct osc_object *osc = cl2osc(obj);
- struct osc_page *opg = cl_object_page_slice(obj, page);
+ struct osc_page *opg = cl_object_page_slice(obj, page);
int result;
opg->ops_from = 0;
- opg->ops_to = PAGE_CACHE_SIZE;
+ opg->ops_to = PAGE_CACHE_SIZE;
result = osc_prep_async_page(osc, opg, vmpage,
cl_offset(obj, page->cp_index));
if (result == 0) {
struct osc_io *oio = osc_env_io(env);
+
opg->ops_srvlock = osc_io_srvlock(oio);
cl_page_slice_add(page, &opg->ops_cl, obj,
&osc_page_ops);
@@ -540,7 +541,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
enum cl_req_type crt, int brw_flags)
{
struct osc_async_page *oap = &opg->ops_oap;
- struct osc_object *obj = oap->oap_obj;
+ struct osc_object *obj = oap->oap_obj;
LINVRNT(osc_page_protected(env, opg,
crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1));
@@ -550,10 +551,10 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
LASSERT(oap->oap_async_flags & ASYNC_READY);
LASSERT(oap->oap_async_flags & ASYNC_COUNT_STABLE);
- oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ;
- oap->oap_page_off = opg->ops_from;
- oap->oap_count = opg->ops_to - opg->ops_from;
- oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags;
+ oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ;
+ oap->oap_page_off = opg->ops_from;
+ oap->oap_count = opg->ops_to - opg->ops_from;
+ oap->oap_brw_flags = brw_flags | OBD_BRW_SYNC;
if (!client_is_remote(osc_export(obj)) &&
capable(CFS_CAP_SYS_RESOURCE)) {
@@ -624,6 +625,7 @@ static int discard_pagevec(const struct lu_env *env, struct cl_io *io,
for (count = 0, i = 0; i < max_index; i++) {
struct cl_page *page = pvec[i];
+
if (cl_page_own_try(env, io, page) == 0) {
/* free LRU page only if nobody is using it.
* This check is necessary to avoid freeing the pages
@@ -818,7 +820,6 @@ static int osc_lru_reclaim(struct client_obd *cli)
int rc;
LASSERT(cache != NULL);
- LASSERT(!list_empty(&cache->ccc_lru));
rc = osc_lru_shrink(cli, lru_shrink_min);
if (rc != 0) {
@@ -835,6 +836,8 @@ static int osc_lru_reclaim(struct client_obd *cli)
/* Reclaim LRU slots from other client_obd as it can't free enough
* from its own. This should rarely happen. */
spin_lock(&cache->ccc_lru_lock);
+ LASSERT(!list_empty(&cache->ccc_lru));
+
cache->ccc_lru_shrinkers++;
list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru);
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c b/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c
index 6690f149a..199783103 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c
@@ -35,7 +35,7 @@ static inline struct osc_quota_info *osc_oqi_alloc(u32 id)
{
struct osc_quota_info *oqi;
- OBD_SLAB_ALLOC_PTR(oqi, osc_quota_kmem);
+ oqi = kmem_cache_alloc(osc_quota_kmem, GFP_NOFS | __GFP_ZERO);
if (oqi != NULL)
oqi->oqi_id = id;
@@ -104,7 +104,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
/* race with others? */
if (rc == -EALREADY) {
rc = 0;
- OBD_SLAB_FREE_PTR(oqi, osc_quota_kmem);
+ kmem_cache_free(osc_quota_kmem, oqi);
}
CDEBUG(D_QUOTA, "%s: setdq to insert for %s %d (%d)\n",
@@ -120,7 +120,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[],
oqi = cfs_hash_del_key(cli->cl_quota_hash[type],
&qid[type]);
if (oqi)
- OBD_SLAB_FREE_PTR(oqi, osc_quota_kmem);
+ kmem_cache_free(osc_quota_kmem, oqi);
CDEBUG(D_QUOTA, "%s: setdq to remove for %s %d (%p)\n",
cli->cl_import->imp_obd->obd_name,
@@ -158,6 +158,7 @@ static void *
oqi_key(struct hlist_node *hnode)
{
struct osc_quota_info *oqi;
+
oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash);
return &oqi->oqi_id;
}
@@ -185,14 +186,14 @@ oqi_exit(struct cfs_hash *hs, struct hlist_node *hnode)
oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash);
- OBD_SLAB_FREE_PTR(oqi, osc_quota_kmem);
+ kmem_cache_free(osc_quota_kmem, oqi);
}
#define HASH_QUOTA_BKT_BITS 5
#define HASH_QUOTA_CUR_BITS 5
#define HASH_QUOTA_MAX_BITS 15
-static cfs_hash_ops_t quota_hash_ops = {
+static struct cfs_hash_ops quota_hash_ops = {
.hs_hash = oqi_hashfn,
.hs_keycmp = oqi_keycmp,
.hs_key = oqi_key,
@@ -232,7 +233,7 @@ int osc_quota_setup(struct obd_device *obd)
int osc_quota_cleanup(struct obd_device *obd)
{
- struct client_obd *cli = &obd->u.cli;
+ struct client_obd *cli = &obd->u.cli;
int type;
for (type = 0; type < MAXQUOTAS; type++)
@@ -245,8 +246,8 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp,
struct obd_quotactl *oqctl)
{
struct ptlrpc_request *req;
- struct obd_quotactl *oqc;
- int rc;
+ struct obd_quotactl *oqc;
+ int rc;
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_OST_QUOTACTL, LUSTRE_OST_VERSION,
@@ -285,10 +286,10 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp,
int osc_quotacheck(struct obd_device *unused, struct obd_export *exp,
struct obd_quotactl *oqctl)
{
- struct client_obd *cli = &exp->exp_obd->u.cli;
- struct ptlrpc_request *req;
- struct obd_quotactl *body;
- int rc;
+ struct client_obd *cli = &exp->exp_obd->u.cli;
+ struct ptlrpc_request *req;
+ struct obd_quotactl *body;
+ int rc;
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION,
diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_request.c b/kernel/drivers/staging/lustre/lustre/osc/osc_request.c
index d7a9b650d..367f83af1 100644
--- a/kernel/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/kernel/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -38,7 +38,6 @@
#include "../../include/linux/libcfs/libcfs.h"
-
#include "../include/lustre_dlm.h"
#include "../include/lustre_net.h"
#include "../include/lustre/lustre_user.h"
@@ -50,9 +49,18 @@
#include "../include/lustre_param.h"
#include "../include/lustre_fid.h"
#include "../include/obd_class.h"
+#include "../include/obd.h"
#include "osc_internal.h"
#include "osc_cl_internal.h"
+atomic_t osc_pool_req_count;
+unsigned int osc_reqpool_maxreqcount;
+struct ptlrpc_request_pool *osc_rq_pool;
+
+/* max memory used for request pool, unit is MB */
+static unsigned int osc_reqpool_mem_max = 5;
+module_param(osc_reqpool_mem_max, uint, 0444);
+
struct osc_brw_async_args {
struct obdo *aa_oa;
int aa_requested_nob;
@@ -63,7 +71,6 @@ struct osc_brw_async_args {
struct client_obd *aa_cli;
struct list_head aa_oaps;
struct list_head aa_exts;
- struct obd_capa *aa_ocapa;
struct cl_req *aa_clerq;
};
@@ -110,7 +117,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
return lmm_size;
if (*lmmp != NULL && lsm == NULL) {
- OBD_FREE(*lmmp, lmm_size);
+ kfree(*lmmp);
*lmmp = NULL;
return 0;
} else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) {
@@ -118,8 +125,8 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
}
if (*lmmp == NULL) {
- OBD_ALLOC(*lmmp, lmm_size);
- if (*lmmp == NULL)
+ *lmmp = kzalloc(lmm_size, GFP_NOFS);
+ if (!*lmmp)
return -ENOMEM;
}
@@ -157,19 +164,20 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return lsm_size;
if (*lsmp != NULL && lmm == NULL) {
- OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
- OBD_FREE(*lsmp, lsm_size);
+ kfree((*lsmp)->lsm_oinfo[0]);
+ kfree(*lsmp);
*lsmp = NULL;
return 0;
}
if (*lsmp == NULL) {
- OBD_ALLOC(*lsmp, lsm_size);
+ *lsmp = kzalloc(lsm_size, GFP_NOFS);
if (unlikely(*lsmp == NULL))
return -ENOMEM;
- OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
+ (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo),
+ GFP_NOFS);
if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) {
- OBD_FREE(*lsmp, lsm_size);
+ kfree(*lsmp);
return -ENOMEM;
}
loi_init((*lsmp)->lsm_oinfo[0]);
@@ -190,22 +198,6 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return lsm_size;
}
-static inline void osc_pack_capa(struct ptlrpc_request *req,
- struct ost_body *body, void *capa)
-{
- struct obd_capa *oc = (struct obd_capa *)capa;
- struct lustre_capa *c;
-
- if (!capa)
- return;
-
- c = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
- LASSERT(c);
- capa_cpy(c, oc);
- body->oa.o_valid |= OBD_MD_FLOSSCAPA;
- DEBUG_CAPA(D_SEC, c, "pack");
-}
-
static inline void osc_pack_req_body(struct ptlrpc_request *req,
struct obd_info *oinfo)
{
@@ -216,18 +208,6 @@ static inline void osc_pack_req_body(struct ptlrpc_request *req,
lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa,
oinfo->oi_oa);
- osc_pack_capa(req, body, oinfo->oi_capa);
-}
-
-static inline void osc_set_capa_size(struct ptlrpc_request *req,
- const struct req_msg_field *field,
- struct obd_capa *oc)
-{
- if (oc == NULL)
- req_capsule_set_size(&req->rq_pill, field, RCL_CLIENT, 0);
- else
- /* it is already calculated as sizeof struct obd_capa */
- ;
}
static int osc_getattr_interpret(const struct lu_env *env,
@@ -263,13 +243,12 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
{
struct ptlrpc_request *req;
struct osc_async_args *aa;
- int rc;
+ int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR);
if (req == NULL)
return -ENOMEM;
- osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa);
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR);
if (rc) {
ptlrpc_request_free(req);
@@ -293,14 +272,13 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
struct obd_info *oinfo)
{
struct ptlrpc_request *req;
- struct ost_body *body;
- int rc;
+ struct ost_body *body;
+ int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR);
if (req == NULL)
return -ENOMEM;
- osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa);
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR);
if (rc) {
ptlrpc_request_free(req);
@@ -337,8 +315,8 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp,
struct obd_info *oinfo, struct obd_trans_info *oti)
{
struct ptlrpc_request *req;
- struct ost_body *body;
- int rc;
+ struct ost_body *body;
+ int rc;
LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP);
@@ -346,7 +324,6 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp,
if (req == NULL)
return -ENOMEM;
- osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa);
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR);
if (rc) {
ptlrpc_request_free(req);
@@ -402,15 +379,14 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo,
obd_enqueue_update_f upcall, void *cookie,
struct ptlrpc_request_set *rqset)
{
- struct ptlrpc_request *req;
+ struct ptlrpc_request *req;
struct osc_setattr_args *sa;
- int rc;
+ int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR);
if (req == NULL)
return -ENOMEM;
- osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa);
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR);
if (rc) {
ptlrpc_request_free(req);
@@ -427,19 +403,19 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo,
/* do mds to ost setattr asynchronously */
if (!rqset) {
/* Do not wait for response. */
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
} else {
req->rq_interpret_reply =
(ptlrpc_interpterer_t)osc_setattr_interpret;
- CLASSERT (sizeof(*sa) <= sizeof(req->rq_async_args));
+ CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args));
sa = ptlrpc_req_async_args(req);
sa->sa_oa = oinfo->oi_oa;
sa->sa_upcall = upcall;
sa->sa_cookie = cookie;
if (rqset == PTLRPCD_SET)
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
else
ptlrpc_set_add_req(rqset, req);
}
@@ -459,9 +435,9 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md **ea, struct obd_trans_info *oti)
{
struct ptlrpc_request *req;
- struct ost_body *body;
- struct lov_stripe_md *lsm;
- int rc;
+ struct ost_body *body;
+ struct lov_stripe_md *lsm;
+ int rc;
LASSERT(oa);
LASSERT(ea);
@@ -547,16 +523,15 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo,
obd_enqueue_update_f upcall, void *cookie,
struct ptlrpc_request_set *rqset)
{
- struct ptlrpc_request *req;
+ struct ptlrpc_request *req;
struct osc_setattr_args *sa;
- struct ost_body *body;
- int rc;
+ struct ost_body *body;
+ int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH);
if (req == NULL)
return -ENOMEM;
- osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa);
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH);
if (rc) {
ptlrpc_request_free(req);
@@ -569,18 +544,17 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo,
LASSERT(body);
lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa,
oinfo->oi_oa);
- osc_pack_capa(req, body, oinfo->oi_capa);
ptlrpc_request_set_replen(req);
req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret;
- CLASSERT (sizeof(*sa) <= sizeof(req->rq_async_args));
+ CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args));
sa = ptlrpc_req_async_args(req);
- sa->sa_oa = oinfo->oi_oa;
+ sa->sa_oa = oinfo->oi_oa;
sa->sa_upcall = upcall;
sa->sa_cookie = cookie;
if (rqset == PTLRPCD_SET)
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
else
ptlrpc_set_add_req(rqset, req);
@@ -599,7 +573,7 @@ static int osc_sync_interpret(const struct lu_env *env,
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
if (body == NULL) {
- CERROR ("can't unpack ost_body\n");
+ CERROR("can't unpack ost_body\n");
rc = -EPROTO;
goto out;
}
@@ -615,15 +589,14 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
struct ptlrpc_request_set *rqset)
{
struct ptlrpc_request *req;
- struct ost_body *body;
+ struct ost_body *body;
struct osc_fsync_args *fa;
- int rc;
+ int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC);
if (req == NULL)
return -ENOMEM;
- osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa);
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SYNC);
if (rc) {
ptlrpc_request_free(req);
@@ -635,7 +608,6 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
LASSERT(body);
lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa,
oinfo->oi_oa);
- osc_pack_capa(req, body, oinfo->oi_capa);
ptlrpc_request_set_replen(req);
req->rq_interpret_reply = osc_sync_interpret;
@@ -647,7 +619,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
fa->fa_cookie = cookie;
if (rqset == PTLRPCD_SET)
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
else
ptlrpc_set_add_req(rqset, req);
@@ -753,12 +725,11 @@ int osc_create(const struct lu_env *env, struct obd_export *exp,
* cookies to the MDS after committing destroy transactions. */
static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
struct obdo *oa, struct lov_stripe_md *ea,
- struct obd_trans_info *oti, struct obd_export *md_export,
- void *capa)
+ struct obd_trans_info *oti, struct obd_export *md_export)
{
- struct client_obd *cli = &exp->exp_obd->u.cli;
+ struct client_obd *cli = &exp->exp_obd->u.cli;
struct ptlrpc_request *req;
- struct ost_body *body;
+ struct ost_body *body;
LIST_HEAD(cancels);
int rc, count;
@@ -776,7 +747,6 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
return -ENOMEM;
}
- osc_set_capa_size(req, &RMF_CAPA1, (struct obd_capa *)capa);
rc = ldlm_prep_elc_req(exp, req, LUSTRE_OST_VERSION, OST_DESTROY,
0, &cancels, count);
if (rc) {
@@ -793,7 +763,6 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
LASSERT(body);
lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
- osc_pack_capa(req, body, (struct obd_capa *)capa);
ptlrpc_request_set_replen(req);
/* If osc_destroy is for destroying the unlink orphan,
@@ -816,7 +785,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
}
/* Do not wait for response */
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
return 0;
}
@@ -909,7 +878,7 @@ static int osc_shrink_grant_interpret(const struct lu_env *env,
LASSERT(body);
osc_update_grant(cli, body);
out:
- OBDO_FREE(oa);
+ kmem_cache_free(obdo_cachep, oa);
return rc;
}
@@ -946,7 +915,7 @@ static int osc_shrink_grant(struct client_obd *cli)
int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
{
- int rc = 0;
+ int rc = 0;
struct ost_body *body;
client_obd_list_lock(&cli->cl_loi_list_lock);
@@ -962,7 +931,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
}
client_obd_list_unlock(&cli->cl_loi_list_lock);
- OBD_ALLOC_PTR(body);
+ body = kzalloc(sizeof(*body), GFP_NOFS);
if (!body)
return -ENOMEM;
@@ -984,7 +953,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
sizeof(*body), body, NULL);
if (rc != 0)
__osc_update_grant(cli, body->oa.o_grant);
- OBD_FREE_PTR(body);
+ kfree(body);
return rc;
}
@@ -1006,8 +975,8 @@ static int osc_should_shrink_grant(struct client_obd *client)
if (client->cl_import->imp_state == LUSTRE_IMP_FULL &&
client->cl_avail_grant > brw_size)
return 1;
- else
- osc_update_next_shrink(client);
+
+ osc_update_next_shrink(client);
}
return 0;
}
@@ -1099,7 +1068,7 @@ static void handle_short_read(int nob_read, u32 page_count,
/* skip bytes read OK */
while (nob_read > 0) {
- LASSERT (page_count > 0);
+ LASSERT(page_count > 0);
if (pga[i]->count > nob_read) {
/* EOF inside this page */
@@ -1130,8 +1099,8 @@ static int check_write_rcs(struct ptlrpc_request *req,
int requested_nob, int niocount,
u32 page_count, struct brw_page **pga)
{
- int i;
- __u32 *remote_rcs;
+ int i;
+ __u32 *remote_rcs;
remote_rcs = req_capsule_server_sized_get(&req->rq_pill, &RMF_RCS,
sizeof(*remote_rcs) *
@@ -1181,15 +1150,15 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2)
}
static u32 osc_checksum_bulk(int nob, u32 pg_count,
- struct brw_page **pga, int opc,
- cksum_type_t cksum_type)
+ struct brw_page **pga, int opc,
+ cksum_type_t cksum_type)
{
- __u32 cksum;
- int i = 0;
- struct cfs_crypto_hash_desc *hdesc;
- unsigned int bufsize;
- int err;
- unsigned char cfs_alg = cksum_obd2cfs(cksum_type);
+ __u32 cksum;
+ int i = 0;
+ struct cfs_crypto_hash_desc *hdesc;
+ unsigned int bufsize;
+ int err;
+ unsigned char cfs_alg = cksum_obd2cfs(cksum_type);
LASSERT(pg_count > 0);
@@ -1209,6 +1178,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count,
OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_RECEIVE)) {
unsigned char *ptr = kmap(pga[i]->pg);
int off = pga[i]->off & ~CFS_PAGE_MASK;
+
memcpy(ptr + off, "bad1", min(4, nob));
kunmap(pga[i]->pg);
}
@@ -1246,17 +1216,17 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
struct lov_stripe_md *lsm, u32 page_count,
struct brw_page **pga,
struct ptlrpc_request **reqp,
- struct obd_capa *ocapa, int reserve,
+ int reserve,
int resend)
{
- struct ptlrpc_request *req;
+ struct ptlrpc_request *req;
struct ptlrpc_bulk_desc *desc;
- struct ost_body *body;
- struct obd_ioobj *ioobj;
- struct niobuf_remote *niobuf;
+ struct ost_body *body;
+ struct obd_ioobj *ioobj;
+ struct niobuf_remote *niobuf;
int niocount, i, requested_nob, opc, rc;
struct osc_brw_async_args *aa;
- struct req_capsule *pill;
+ struct req_capsule *pill;
struct brw_page *pg_prev;
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ))
@@ -1267,7 +1237,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
if ((cmd & OBD_BRW_WRITE) != 0) {
opc = OST_WRITE;
req = ptlrpc_request_alloc_pool(cli->cl_import,
- cli->cl_import->imp_rq_pool,
+ osc_rq_pool,
&RQF_OST_BRW_WRITE);
} else {
opc = OST_READ;
@@ -1286,7 +1256,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
sizeof(*ioobj));
req_capsule_set_size(pill, &RMF_NIOBUF_REMOTE, RCL_CLIENT,
niocount * sizeof(*niobuf));
- osc_set_capa_size(req, &RMF_CAPA1, ocapa);
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, opc);
if (rc) {
@@ -1325,7 +1294,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
* "max - 1" for old client compatibility sending "0", and also so the
* the actual maximum is a power-of-two number, not one less. LU-1431 */
ioobj_max_brw_set(ioobj, desc->bd_md_max_brw);
- osc_pack_capa(req, body, ocapa);
LASSERT(page_count > 0);
pg_prev = pga[0];
for (requested_nob = i = 0; i < page_count; i++, niobuf++) {
@@ -1358,8 +1326,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
niobuf->len += pg->count;
} else {
niobuf->offset = pg->off;
- niobuf->len = pg->count;
- niobuf->flags = pg->flag;
+ niobuf->len = pg->count;
+ niobuf->flags = pg->flag;
}
pg_prev = pg;
}
@@ -1434,8 +1402,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
aa->aa_ppga = pga;
aa->aa_cli = cli;
INIT_LIST_HEAD(&aa->aa_oaps);
- if (ocapa && reserve)
- aa->aa_ocapa = capa_get(ocapa);
*reqp = req;
return 0;
@@ -1570,7 +1536,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
}
if (rc != req->rq_bulk->bd_nob_transferred) {
- CERROR ("Unexpected rc %d (%d transferred)\n",
+ CERROR("Unexpected rc %d (%d transferred)\n",
rc, req->rq_bulk->bd_nob_transferred);
return -EPROTO;
}
@@ -1580,20 +1546,18 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
if (body->oa.o_valid & OBD_MD_FLCKSUM) {
static int cksum_counter;
- __u32 server_cksum = body->oa.o_cksum;
- char *via;
- char *router;
+ __u32 server_cksum = body->oa.o_cksum;
+ char *via = "";
+ char *router = "";
cksum_type_t cksum_type;
- cksum_type = cksum_type_unpack(body->oa.o_valid &OBD_MD_FLFLAGS?
+ cksum_type = cksum_type_unpack(body->oa.o_valid&OBD_MD_FLFLAGS ?
body->oa.o_flags : 0);
client_cksum = osc_checksum_bulk(rc, aa->aa_page_count,
aa->aa_ppga, OST_READ,
cksum_type);
- if (peer->nid == req->rq_bulk->bd_sender) {
- via = router = "";
- } else {
+ if (peer->nid != req->rq_bulk->bd_sender) {
via = " via ";
router = libcfs_nid2str(req->rq_bulk->bd_sender);
}
@@ -1653,11 +1617,11 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
"redo for recoverable error %d", rc);
rc = osc_brw_prep_request(lustre_msg_get_opc(request->rq_reqmsg) ==
- OST_WRITE ? OBD_BRW_WRITE :OBD_BRW_READ,
+ OST_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ,
aa->aa_cli, aa->aa_oa,
NULL /* lsm unused by osc currently */,
aa->aa_page_count, aa->aa_ppga,
- &new_req, aa->aa_ocapa, 0, 1);
+ &new_req, 0, 1);
if (rc)
return rc;
@@ -1680,9 +1644,9 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
/* cap resend delay to the current request timeout, this is similar to
* what ptlrpc does (see after_reply()) */
if (aa->aa_resends > new_req->rq_timeout)
- new_req->rq_sent = get_seconds() + new_req->rq_timeout;
+ new_req->rq_sent = ktime_get_real_seconds() + new_req->rq_timeout;
else
- new_req->rq_sent = get_seconds() + aa->aa_resends;
+ new_req->rq_sent = ktime_get_real_seconds() + aa->aa_resends;
new_req->rq_generation_set = 1;
new_req->rq_import_generation = request->rq_import_generation;
@@ -1701,14 +1665,11 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
}
}
- new_aa->aa_ocapa = aa->aa_ocapa;
- aa->aa_ocapa = NULL;
-
/* XXX: This code will run into problem if we're going to support
* to add a series of BRW RPCs into a self-defined ptlrpc_request_set
* and wait for all of them to be finished. We should inherit request
* set from old request. */
- ptlrpcd_add_req(new_req, PDL_POLICY_SAME, -1);
+ ptlrpcd_add_req(new_req);
DEBUG_REQ(D_INFO, new_req, "new request");
return 0;
@@ -1748,7 +1709,7 @@ static void sort_brw_pages(struct brw_page **array, int num)
static void osc_release_ppga(struct brw_page **ppga, u32 count)
{
LASSERT(ppga != NULL);
- OBD_FREE(ppga, sizeof(*ppga) * count);
+ kfree(ppga);
}
static int brw_interpret(const struct lu_env *env,
@@ -1757,7 +1718,7 @@ static int brw_interpret(const struct lu_env *env,
struct osc_brw_async_args *aa = data;
struct osc_extent *ext;
struct osc_extent *tmp;
- struct cl_object *obj = NULL;
+ struct cl_object *obj = NULL;
struct client_obd *cli = aa->aa_cli;
rc = osc_brw_fini_request(req, rc);
@@ -1785,11 +1746,6 @@ static int brw_interpret(const struct lu_env *env,
rc = -EIO;
}
- if (aa->aa_ocapa) {
- capa_put(aa->aa_ocapa);
- aa->aa_ocapa = NULL;
- }
-
list_for_each_entry_safe(ext, tmp, &aa->aa_exts, oe_link) {
if (obj == NULL && rc == 0) {
obj = osc2cl(ext->oe_obj);
@@ -1831,7 +1787,7 @@ static int brw_interpret(const struct lu_env *env,
}
cl_object_put(env, obj);
}
- OBDO_FREE(aa->aa_oa);
+ kmem_cache_free(obdo_cachep, aa->aa_oa);
cl_req_completion(env, aa->aa_clerq, rc < 0 ? rc :
req->rq_bulk->bd_nob_transferred);
@@ -1849,7 +1805,7 @@ static int brw_interpret(const struct lu_env *env,
osc_wake_cache_waiters(cli);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME);
+ osc_io_unplug(env, cli, NULL);
return rc;
}
@@ -1859,28 +1815,27 @@ static int brw_interpret(const struct lu_env *env,
* Extents in the list must be in OES_RPC state.
*/
int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
- struct list_head *ext_list, int cmd, pdl_policy_t pol)
-{
- struct ptlrpc_request *req = NULL;
- struct osc_extent *ext;
- struct brw_page **pga = NULL;
- struct osc_brw_async_args *aa = NULL;
- struct obdo *oa = NULL;
- struct osc_async_page *oap;
- struct osc_async_page *tmp;
- struct cl_req *clerq = NULL;
- enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE :
- CRT_READ;
- struct ldlm_lock *lock = NULL;
- struct cl_req_attr *crattr = NULL;
- u64 starting_offset = OBD_OBJECT_EOF;
- u64 ending_offset = 0;
- int mpflag = 0;
- int mem_tight = 0;
- int page_count = 0;
- int i;
- int rc;
- struct ost_body *body;
+ struct list_head *ext_list, int cmd)
+{
+ struct ptlrpc_request *req = NULL;
+ struct osc_extent *ext;
+ struct brw_page **pga = NULL;
+ struct osc_brw_async_args *aa = NULL;
+ struct obdo *oa = NULL;
+ struct osc_async_page *oap;
+ struct osc_async_page *tmp;
+ struct cl_req *clerq = NULL;
+ enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE : CRT_READ;
+ struct ldlm_lock *lock = NULL;
+ struct cl_req_attr *crattr = NULL;
+ u64 starting_offset = OBD_OBJECT_EOF;
+ u64 ending_offset = 0;
+ int mpflag = 0;
+ int mem_tight = 0;
+ int page_count = 0;
+ int i;
+ int rc;
+ struct ost_body *body;
LIST_HEAD(rpc_list);
LASSERT(!list_empty(ext_list));
@@ -1908,19 +1863,19 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
if (mem_tight)
mpflag = cfs_memory_pressure_get_and_set();
- OBD_ALLOC(crattr, sizeof(*crattr));
- if (crattr == NULL) {
+ crattr = kzalloc(sizeof(*crattr), GFP_NOFS);
+ if (!crattr) {
rc = -ENOMEM;
goto out;
}
- OBD_ALLOC(pga, sizeof(*pga) * page_count);
+ pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS);
if (pga == NULL) {
rc = -ENOMEM;
goto out;
}
- OBDO_ALLOC(oa);
+ oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
if (oa == NULL) {
rc = -ENOMEM;
goto out;
@@ -1929,6 +1884,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
i = 0;
list_for_each_entry(oap, &rpc_list, oap_rpc_item) {
struct cl_page *page = oap2cl_page(oap);
+
if (clerq == NULL) {
clerq = cl_req_alloc(env, page, crt,
1 /* only 1-object rpcs for now */);
@@ -1966,7 +1922,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
sort_brw_pages(pga, page_count);
rc = osc_brw_prep_request(cmd, cli, oa, NULL, page_count,
- pga, &req, crattr->cra_capa, 1, 0);
+ pga, &req, 1, 0);
if (rc != 0) {
CERROR("prep_req failed: %d\n", rc);
goto out;
@@ -2034,37 +1990,21 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
page_count, aa, cli->cl_r_in_flight,
cli->cl_w_in_flight);
- /* XXX: Maybe the caller can check the RPC bulk descriptor to
- * see which CPU/NUMA node the majority of pages were allocated
- * on, and try to assign the async RPC to the CPU core
- * (PDL_POLICY_PREFERRED) to reduce cross-CPU memory traffic.
- *
- * But on the other hand, we expect that multiple ptlrpcd
- * threads and the initial write sponsor can run in parallel,
- * especially when data checksum is enabled, which is CPU-bound
- * operation and single ptlrpcd thread cannot process in time.
- * So more ptlrpcd threads sharing BRW load
- * (with PDL_POLICY_ROUND) seems better.
- */
- ptlrpcd_add_req(req, pol, -1);
+ ptlrpcd_add_req(req);
rc = 0;
out:
if (mem_tight != 0)
cfs_memory_pressure_restore(mpflag);
- if (crattr != NULL) {
- capa_put(crattr->cra_capa);
- OBD_FREE(crattr, sizeof(*crattr));
- }
+ kfree(crattr);
if (rc != 0) {
LASSERT(req == NULL);
if (oa)
- OBDO_FREE(oa);
- if (pga)
- OBD_FREE(pga, sizeof(*pga) * page_count);
+ kmem_cache_free(obdo_cachep, oa);
+ kfree(pga);
/* this should happen rarely and is pretty bad, it makes the
* pending list not follow the dirty order */
while (!list_empty(ext_list)) {
@@ -2150,6 +2090,7 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb,
/* The request was created before ldlm_cli_enqueue call. */
if (rc == ELDLM_LOCK_ABORTED) {
struct ldlm_reply *rep;
+
rep = req_capsule_server_get(&req->rq_pill,
&RMF_DLM_REP);
@@ -2300,7 +2241,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
ldlm_lock_decref(lockh, mode);
LDLM_LOCK_PUT(matched);
return -ECANCELED;
- } else if (osc_set_lock_data_with_check(matched, einfo)) {
+ }
+
+ if (osc_set_lock_data_with_check(matched, einfo)) {
*flags |= LDLM_FL_LVB_READY;
/* addref the lock only if not async requests and PW
* lock is matched whereas we asked for PR. */
@@ -2325,15 +2268,16 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
ldlm_lock_decref(lockh, einfo->ei_mode);
LDLM_LOCK_PUT(matched);
return ELDLM_OK;
- } else {
- ldlm_lock_decref(lockh, mode);
- LDLM_LOCK_PUT(matched);
}
+
+ ldlm_lock_decref(lockh, mode);
+ LDLM_LOCK_PUT(matched);
}
no_match:
if (intent) {
LIST_HEAD(cancels);
+
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
&RQF_LDLM_ENQUEUE_LVB);
if (req == NULL)
@@ -2358,6 +2302,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
if (rqset) {
if (!rc) {
struct osc_enqueue_args *aa;
+
CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args));
aa = ptlrpc_req_async_args(req);
aa->oa_ei = einfo;
@@ -2372,7 +2317,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
req->rq_interpret_reply =
(ptlrpc_interpterer_t)osc_enqueue_interpret;
if (rqset == PTLRPCD_SET)
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
else
ptlrpc_set_add_req(rqset, req);
} else if (intent) {
@@ -2480,10 +2425,10 @@ static int osc_statfs_async(struct obd_export *exp,
struct obd_info *oinfo, __u64 max_age,
struct ptlrpc_request_set *rqset)
{
- struct obd_device *obd = class_exp2obd(exp);
+ struct obd_device *obd = class_exp2obd(exp);
struct ptlrpc_request *req;
struct osc_async_args *aa;
- int rc;
+ int rc;
/* We could possibly pass max_age in the request (as an absolute
* timestamp or a "seconds.usec ago") so the target can avoid doing
@@ -2522,10 +2467,10 @@ static int osc_statfs_async(struct obd_export *exp,
static int osc_statfs(const struct lu_env *env, struct obd_export *exp,
struct obd_statfs *osfs, __u64 max_age, __u32 flags)
{
- struct obd_device *obd = class_exp2obd(exp);
- struct obd_statfs *msfs;
+ struct obd_device *obd = class_exp2obd(exp);
+ struct obd_statfs *msfs;
struct ptlrpc_request *req;
- struct obd_import *imp = NULL;
+ struct obd_import *imp = NULL;
int rc;
/*Since the request might also come from lprocfs, so we need
@@ -2617,7 +2562,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
* because lov_user_md_vX and lov_mds_md_vX have the same size */
if (lum.lmm_stripe_count > 0) {
lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic);
- OBD_ALLOC(lumk, lum_size);
+ lumk = kzalloc(lum_size, GFP_NOFS);
if (!lumk)
return -ENOMEM;
@@ -2639,12 +2584,11 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
rc = -EFAULT;
if (lumk != &lum)
- OBD_FREE(lumk, lum_size);
+ kfree(lumk);
return rc;
}
-
static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
void *karg, void *uarg)
{
@@ -2664,7 +2608,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
buf = NULL;
len = 0;
- if (obd_ioctl_getdata(&buf, &len, (void *)uarg)) {
+ if (obd_ioctl_getdata(&buf, &len, uarg)) {
err = -EINVAL;
goto out;
}
@@ -2694,7 +2638,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
memcpy(data->ioc_inlbuf2, &obd->obd_uuid, sizeof(uuid));
- err = copy_to_user((void *)uarg, buf, len);
+ err = copy_to_user(uarg, buf, len);
if (err)
err = -EFAULT;
obd_ioctl_freedata(buf, len);
@@ -2719,7 +2663,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
data->ioc_offset);
goto out;
case OBD_IOC_POLL_QUOTACHECK:
- err = osc_quota_poll_check(exp, (struct if_quotacheck *)karg);
+ err = osc_quota_poll_check(exp, karg);
goto out;
case OBD_IOC_PING_TARGET:
err = ptlrpc_obd_ping(obd);
@@ -2749,9 +2693,9 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp,
return 0;
} else if (KEY_IS(KEY_LAST_ID)) {
struct ptlrpc_request *req;
- u64 *reply;
- char *tmp;
- int rc;
+ u64 *reply;
+ char *tmp;
+ int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
&RQF_OST_GET_INFO_LAST_ID);
@@ -2786,16 +2730,15 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp,
ptlrpc_req_finished(req);
return rc;
} else if (KEY_IS(KEY_FIEMAP)) {
- struct ll_fiemap_info_key *fm_key =
- (struct ll_fiemap_info_key *)key;
- struct ldlm_res_id res_id;
- ldlm_policy_data_t policy;
- struct lustre_handle lockh;
- ldlm_mode_t mode = 0;
- struct ptlrpc_request *req;
- struct ll_user_fiemap *reply;
- char *tmp;
- int rc;
+ struct ll_fiemap_info_key *fm_key = key;
+ struct ldlm_res_id res_id;
+ ldlm_policy_data_t policy;
+ struct lustre_handle lockh;
+ ldlm_mode_t mode = 0;
+ struct ptlrpc_request *req;
+ struct ll_user_fiemap *reply;
+ char *tmp;
+ int rc;
if (!(fm_key->fiemap.fm_flags & FIEMAP_FLAG_SYNC))
goto skip_locking;
@@ -2881,10 +2824,10 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
void *val, struct ptlrpc_request_set *set)
{
struct ptlrpc_request *req;
- struct obd_device *obd = exp->exp_obd;
- struct obd_import *imp = class_exp2cliimp(exp);
- char *tmp;
- int rc;
+ struct obd_device *obd = exp->exp_obd;
+ struct obd_import *imp = class_exp2cliimp(exp);
+ char *tmp;
+ int rc;
OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10);
@@ -2909,7 +2852,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
struct client_obd *cli = &obd->u.cli;
LASSERT(cli->cl_cache == NULL); /* only once */
- cli->cl_cache = (struct cl_client_cache *)val;
+ cli->cl_cache = val;
atomic_inc(&cli->cl_cache->ccc_users);
cli->cl_lru_left = &cli->cl_cache->ccc_lru_left;
@@ -2972,7 +2915,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
aa = ptlrpc_req_async_args(req);
- OBDO_ALLOC(oa);
+ oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
if (!oa) {
ptlrpc_req_finished(req);
return -ENOMEM;
@@ -2987,8 +2930,9 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
LASSERT(set != NULL);
ptlrpc_set_add_req(set, req);
ptlrpc_check_set(NULL, set);
- } else
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ } else {
+ ptlrpcd_add_req(req);
+ }
return 0;
}
@@ -3071,8 +3015,8 @@ static int osc_import_event(struct obd_device *obd,
}
case IMP_EVENT_INVALIDATE: {
struct ldlm_namespace *ns = obd->obd_namespace;
- struct lu_env *env;
- int refcheck;
+ struct lu_env *env;
+ int refcheck;
env = cl_env_get(&refcheck);
if (!IS_ERR(env)) {
@@ -3080,7 +3024,7 @@ static int osc_import_event(struct obd_device *obd,
cli = &obd->u.cli;
/* all pages go to failing rpcs due to the invalid
* import */
- osc_io_unplug(env, cli, NULL, PDL_POLICY_ROUND);
+ osc_io_unplug(env, cli, NULL);
ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
cl_env_put(env, &refcheck);
@@ -3100,7 +3044,7 @@ static int osc_import_event(struct obd_device *obd,
/* See bug 7198 */
if (ocd->ocd_connect_flags & OBD_CONNECT_REQPORTAL)
- imp->imp_client->cli_request_portal =OST_REQUEST_PORTAL;
+ imp->imp_client->cli_request_portal = OST_REQUEST_PORTAL;
rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
break;
@@ -3152,16 +3096,19 @@ static int brw_queue_work(const struct lu_env *env, void *data)
CDEBUG(D_CACHE, "Run writeback work for client obd %p.\n", cli);
- osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME);
+ osc_io_unplug(env, cli, NULL);
return 0;
}
int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
struct lprocfs_static_vars lvars = { NULL };
- struct client_obd *cli = &obd->u.cli;
- void *handler;
- int rc;
+ struct client_obd *cli = &obd->u.cli;
+ void *handler;
+ int rc;
+ int adding;
+ int added;
+ int req_count;
rc = ptlrpcd_addref();
if (rc)
@@ -3184,21 +3131,26 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL;
lprocfs_osc_init_vars(&lvars);
- if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
+ if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) {
lproc_osc_attach_seqstat(obd);
sptlrpc_lprocfs_cliobd_attach(obd);
ptlrpc_lprocfs_register_obd(obd);
}
- /* We need to allocate a few requests more, because
- * brw_interpret tries to create new requests before freeing
- * previous ones, Ideally we want to have 2x max_rpcs_in_flight
- * reserved, but I'm afraid that might be too much wasted RAM
- * in fact, so 2 is just my guess and still should work. */
- cli->cl_import->imp_rq_pool =
- ptlrpc_init_rq_pool(cli->cl_max_rpcs_in_flight + 2,
- OST_MAXREQSIZE,
- ptlrpc_add_rqs_to_pool);
+ /*
+ * We try to control the total number of requests with a upper limit
+ * osc_reqpool_maxreqcount. There might be some race which will cause
+ * over-limit allocation, but it is fine.
+ */
+ req_count = atomic_read(&osc_pool_req_count);
+ if (req_count < osc_reqpool_maxreqcount) {
+ adding = cli->cl_max_rpcs_in_flight + 2;
+ if (req_count + adding > osc_reqpool_maxreqcount)
+ adding = osc_reqpool_maxreqcount - req_count;
+
+ added = ptlrpc_add_rqs_to_pool(osc_rq_pool, adding);
+ atomic_add(added, &osc_pool_req_count);
+ }
INIT_LIST_HEAD(&cli->cl_grant_shrink_list);
ns_register_cancel(obd->obd_namespace, osc_cancel_for_recovery);
@@ -3218,6 +3170,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
switch (stage) {
case OBD_CLEANUP_EARLY: {
struct obd_import *imp;
+
imp = obd->u.cli.cl_import;
CDEBUG(D_HA, "Deactivating import %s\n", obd->obd_name);
/* ptlrpc_abort_inflight to stop an mds_lov_synchronize */
@@ -3338,6 +3291,8 @@ extern struct lock_class_key osc_ast_guard_class;
static int __init osc_init(void)
{
struct lprocfs_static_vars lvars = { NULL };
+ unsigned int reqpool_size;
+ unsigned int reqsize;
int rc;
/* print an address of _any_ initialized kernel symbol from this
@@ -3351,16 +3306,47 @@ static int __init osc_init(void)
lprocfs_osc_init_vars(&lvars);
- rc = class_register_type(&osc_obd_ops, NULL, lvars.module_vars,
+ rc = class_register_type(&osc_obd_ops, NULL,
LUSTRE_OSC_NAME, &osc_device_type);
- if (rc) {
- lu_kmem_fini(osc_caches);
- return rc;
- }
+ if (rc)
+ goto out_kmem;
spin_lock_init(&osc_ast_guard);
lockdep_set_class(&osc_ast_guard, &osc_ast_guard_class);
+ /* This is obviously too much memory, only prevent overflow here */
+ if (osc_reqpool_mem_max >= 1 << 12 || osc_reqpool_mem_max == 0) {
+ rc = -EINVAL;
+ goto out_type;
+ }
+
+ reqpool_size = osc_reqpool_mem_max << 20;
+
+ reqsize = 1;
+ while (reqsize < OST_MAXREQSIZE)
+ reqsize = reqsize << 1;
+
+ /*
+ * We don't enlarge the request count in OSC pool according to
+ * cl_max_rpcs_in_flight. The allocation from the pool will only be
+ * tried after normal allocation failed. So a small OSC pool won't
+ * cause much performance degression in most of cases.
+ */
+ osc_reqpool_maxreqcount = reqpool_size / reqsize;
+
+ atomic_set(&osc_pool_req_count, 0);
+ osc_rq_pool = ptlrpc_init_rq_pool(0, OST_MAXREQSIZE,
+ ptlrpc_add_rqs_to_pool);
+
+ if (osc_rq_pool)
+ return 0;
+
+ rc = -ENOMEM;
+
+out_type:
+ class_unregister_type(LUSTRE_OSC_NAME);
+out_kmem:
+ lu_kmem_fini(osc_caches);
return rc;
}
@@ -3368,6 +3354,7 @@ static void /*__exit*/ osc_exit(void)
{
class_unregister_type(LUSTRE_OSC_NAME);
lu_kmem_fini(osc_caches);
+ ptlrpc_free_rq_pool(osc_rq_pool);
}
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/Makefile b/kernel/drivers/staging/lustre/lustre/ptlrpc/Makefile
index fb50cd4c6..24bbac19d 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/Makefile
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/Makefile
@@ -15,6 +15,5 @@ ptlrpc_objs += pers.o lproc_ptlrpc.o wiretest.o layout.o
ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o
ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o
-ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs)
-ptlrpc-$(CONFIG_PROC_FS) += sec_lproc.o
+ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) sec_lproc.o
ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/client.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/client.c
index 0357f1d45..a9f1bf536 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -57,8 +57,8 @@ void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
struct ptlrpc_client *cl)
{
cl->cli_request_portal = req_portal;
- cl->cli_reply_portal = rep_portal;
- cl->cli_name = name;
+ cl->cli_reply_portal = rep_portal;
+ cl->cli_name = name;
}
EXPORT_SYMBOL(ptlrpc_init_client);
@@ -68,13 +68,15 @@ EXPORT_SYMBOL(ptlrpc_init_client);
struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid)
{
struct ptlrpc_connection *c;
- lnet_nid_t self;
- lnet_process_id_t peer;
- int err;
+ lnet_nid_t self;
+ lnet_process_id_t peer;
+ int err;
- /* ptlrpc_uuid_to_peer() initializes its 2nd parameter
- * before accessing its values. */
- /* coverity[uninit_use_in_call] */
+ /*
+ * ptlrpc_uuid_to_peer() initializes its 2nd parameter
+ * before accessing its values.
+ * coverity[uninit_use_in_call]
+ */
err = ptlrpc_uuid_to_peer(uuid, &peer, &self);
if (err != 0) {
CNETERR("cannot find peer %s!\n", uuid->uuid);
@@ -103,7 +105,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw,
struct ptlrpc_bulk_desc *desc;
int i;
- OBD_ALLOC(desc, offsetof(struct ptlrpc_bulk_desc, bd_iov[npages]));
+ desc = kzalloc(offsetof(struct ptlrpc_bulk_desc, bd_iov[npages]),
+ GFP_NOFS);
if (!desc)
return NULL;
@@ -116,8 +119,10 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw,
desc->bd_md_count = 0;
LASSERT(max_brw > 0);
desc->bd_md_max_brw = min(max_brw, PTLRPC_BULK_OPS_COUNT);
- /* PTLRPC_BULK_OPS_COUNT is the compile-time transfer limit for this
- * node. Negotiated ocd_brw_size will always be <= this number. */
+ /*
+ * PTLRPC_BULK_OPS_COUNT is the compile-time transfer limit for this
+ * node. Negotiated ocd_brw_size will always be <= this number.
+ */
for (i = 0; i < PTLRPC_BULK_OPS_COUNT; i++)
LNetInvalidateHandle(&desc->bd_mds[i]);
@@ -147,7 +152,7 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req,
desc->bd_import = class_import_get(imp);
desc->bd_req = req;
- desc->bd_cbid.cbid_fn = client_bulk_callback;
+ desc->bd_cbid.cbid_fn = client_bulk_callback;
desc->bd_cbid.cbid_arg = desc;
/* This makes req own desc, and free it when she frees herself */
@@ -205,8 +210,7 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin)
page_cache_release(desc->bd_iov[i].kiov_page);
}
- OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc,
- bd_iov[desc->bd_max_iov]));
+ kfree(desc);
}
EXPORT_SYMBOL(__ptlrpc_free_bulk);
@@ -223,8 +227,9 @@ void ptlrpc_at_set_req_timeout(struct ptlrpc_request *req)
LASSERT(req->rq_import);
if (AT_OFF) {
- /* non-AT settings */
- /**
+ /*
+ * non-AT settings
+ *
* \a imp_server_timeout means this is reverse import and
* we send (currently only) ASTs to the client and cannot afford
* to wait too long for the reply, otherwise the other client
@@ -240,11 +245,15 @@ void ptlrpc_at_set_req_timeout(struct ptlrpc_request *req)
serv_est = at_get(&at->iat_service_estimate[idx]);
req->rq_timeout = at_est2timeout(serv_est);
}
- /* We could get even fancier here, using history to predict increased
- loading... */
+ /*
+ * We could get even fancier here, using history to predict increased
+ * loading...
+ */
- /* Let the server know what this RPC timeout is by putting it in the
- reqmsg*/
+ /*
+ * Let the server know what this RPC timeout is by putting it in the
+ * reqmsg
+ */
lustre_msg_set_timeout(req->rq_reqmsg, req->rq_timeout);
}
EXPORT_SYMBOL(ptlrpc_at_set_req_timeout);
@@ -261,8 +270,10 @@ static void ptlrpc_at_adj_service(struct ptlrpc_request *req,
at = &req->rq_import->imp_at;
idx = import_at_get_index(req->rq_import, req->rq_request_portal);
- /* max service estimates are tracked on the server side,
- so just keep minimal history here */
+ /*
+ * max service estimates are tracked on the server side,
+ * so just keep minimal history here
+ */
oldse = at_measured(&at->iat_service_estimate[idx], serv_est);
if (oldse != 0)
CDEBUG(D_ADAPTTO, "The RPC service estimate for %s ptl %d has changed from %d to %d\n",
@@ -282,12 +293,13 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req,
{
unsigned int nl, oldnl;
struct imp_at *at;
- time_t now = get_seconds();
+ time64_t now = ktime_get_real_seconds();
LASSERT(req->rq_import);
if (service_time > now - req->rq_sent + 3) {
- /* bz16408, however, this can also happen if early reply
+ /*
+ * bz16408, however, this can also happen if early reply
* is lost and client RPC is expired and resent, early reply
* or reply of original RPC can still be fit in reply buffer
* of resent RPC, now client is measuring time from the
@@ -298,7 +310,7 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req,
D_ADAPTTO : D_WARNING,
"Reported service time %u > total measured time "
CFS_DURATION_T"\n", service_time,
- cfs_time_sub(now, req->rq_sent));
+ (long)(now - req->rq_sent));
return;
}
@@ -343,8 +355,8 @@ static int unpack_reply(struct ptlrpc_request *req)
static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req)
{
struct ptlrpc_request *early_req;
- time_t olddl;
- int rc;
+ time64_t olddl;
+ int rc;
req->rq_early = 0;
spin_unlock(&req->rq_lock);
@@ -376,21 +388,23 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req)
spin_lock(&req->rq_lock);
olddl = req->rq_deadline;
- /* server assumes it now has rq_timeout from when it sent the
- * early reply, so client should give it at least that long. */
- req->rq_deadline = get_seconds() + req->rq_timeout +
+ /*
+ * server assumes it now has rq_timeout from when it sent the
+ * early reply, so client should give it at least that long.
+ */
+ req->rq_deadline = ktime_get_real_seconds() + req->rq_timeout +
ptlrpc_at_get_net_latency(req);
DEBUG_REQ(D_ADAPTTO, req,
- "Early reply #%d, new deadline in " CFS_DURATION_T "s (" CFS_DURATION_T "s)",
+ "Early reply #%d, new deadline in %lds (%lds)",
req->rq_early_count,
- cfs_time_sub(req->rq_deadline, get_seconds()),
- cfs_time_sub(req->rq_deadline, olddl));
+ (long)(req->rq_deadline - ktime_get_real_seconds()),
+ (long)(req->rq_deadline - olddl));
return rc;
}
-struct kmem_cache *request_cache;
+static struct kmem_cache *request_cache;
int ptlrpc_request_cache_init(void)
{
@@ -409,13 +423,13 @@ struct ptlrpc_request *ptlrpc_request_cache_alloc(gfp_t flags)
{
struct ptlrpc_request *req;
- OBD_SLAB_ALLOC_PTR_GFP(req, request_cache, flags);
+ req = kmem_cache_alloc(request_cache, flags | __GFP_ZERO);
return req;
}
void ptlrpc_request_cache_free(struct ptlrpc_request *req)
{
- OBD_SLAB_FREE_PTR(req, request_cache);
+ kmem_cache_free(request_cache, req);
}
/**
@@ -435,18 +449,18 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
list_del(&req->rq_list);
LASSERT(req->rq_reqbuf);
LASSERT(req->rq_reqbuf_len == pool->prp_rq_size);
- OBD_FREE_LARGE(req->rq_reqbuf, pool->prp_rq_size);
+ kvfree(req->rq_reqbuf);
ptlrpc_request_cache_free(req);
}
spin_unlock(&pool->prp_lock);
- OBD_FREE(pool, sizeof(*pool));
+ kfree(pool);
}
EXPORT_SYMBOL(ptlrpc_free_rq_pool);
/**
* Allocates, initializes and adds \a num_rq requests to the pool \a pool
*/
-void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
+int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
{
int i;
int size = 1;
@@ -468,11 +482,11 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
spin_unlock(&pool->prp_lock);
req = ptlrpc_request_cache_alloc(GFP_NOFS);
if (!req)
- return;
- OBD_ALLOC_LARGE(msg, size);
+ return i;
+ msg = libcfs_kvzalloc(size, GFP_NOFS);
if (!msg) {
ptlrpc_request_cache_free(req);
- return;
+ return i;
}
req->rq_reqbuf = msg;
req->rq_reqbuf_len = size;
@@ -481,6 +495,7 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
list_add_tail(&req->rq_list, &pool->prp_req_list);
}
spin_unlock(&pool->prp_lock);
+ return num_rq;
}
EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
@@ -494,16 +509,18 @@ EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
*/
struct ptlrpc_request_pool *
ptlrpc_init_rq_pool(int num_rq, int msgsize,
- void (*populate_pool)(struct ptlrpc_request_pool *, int))
+ int (*populate_pool)(struct ptlrpc_request_pool *, int))
{
struct ptlrpc_request_pool *pool;
- OBD_ALLOC(pool, sizeof(struct ptlrpc_request_pool));
+ pool = kzalloc(sizeof(struct ptlrpc_request_pool), GFP_NOFS);
if (!pool)
return NULL;
- /* Request next power of two for the allocation, because internally
- kernel would do exactly this */
+ /*
+ * Request next power of two for the allocation, because internally
+ * kernel would do exactly this
+ */
spin_lock_init(&pool->prp_lock);
INIT_LIST_HEAD(&pool->prp_req_list);
@@ -512,11 +529,6 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize,
populate_pool(pool, num_rq);
- if (list_empty(&pool->prp_req_list)) {
- /* have not allocated a single request for the pool */
- OBD_FREE(pool, sizeof(struct ptlrpc_request_pool));
- pool = NULL;
- }
return pool;
}
EXPORT_SYMBOL(ptlrpc_init_rq_pool);
@@ -535,10 +547,12 @@ ptlrpc_prep_req_from_pool(struct ptlrpc_request_pool *pool)
spin_lock(&pool->prp_lock);
- /* See if we have anything in a pool, and bail out if nothing,
+ /*
+ * See if we have anything in a pool, and bail out if nothing,
* in writeout path, where this matters, this is safe to do, because
* nothing is lost in this case, and when some in-flight requests
- * complete, this code will be called again. */
+ * complete, this code will be called again.
+ */
if (unlikely(list_empty(&pool->prp_req_list))) {
spin_unlock(&pool->prp_lock);
return NULL;
@@ -580,8 +594,8 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request,
int count, __u32 *lengths, char **bufs,
struct ptlrpc_cli_ctx *ctx)
{
- struct obd_import *imp = request->rq_import;
- int rc;
+ struct obd_import *imp = request->rq_import;
+ int rc;
if (unlikely(ctx))
request->rq_cli_ctx = sptlrpc_cli_ctx_get(ctx);
@@ -605,10 +619,10 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request,
request->rq_type = PTL_RPC_MSG_REQUEST;
request->rq_export = NULL;
- request->rq_req_cbid.cbid_fn = request_out_callback;
+ request->rq_req_cbid.cbid_fn = request_out_callback;
request->rq_req_cbid.cbid_arg = request;
- request->rq_reply_cbid.cbid_fn = reply_in_callback;
+ request->rq_reply_cbid.cbid_fn = reply_in_callback;
request->rq_reply_cbid.cbid_arg = request;
request->rq_reply_deadline = 0;
@@ -664,11 +678,13 @@ int ptlrpc_request_pack(struct ptlrpc_request *request,
__u32 version, int opcode)
{
int rc;
+
rc = ptlrpc_request_bufs_pack(request, version, opcode, NULL, NULL);
if (rc)
return rc;
- /* For some old 1.8 clients (< 1.8.7), they will LASSERT the size of
+ /*
+ * For some old 1.8 clients (< 1.8.7), they will LASSERT the size of
* ptlrpc_body sent from server equal to local ptlrpc_body size, so we
* have to send old ptlrpc_body to keep interoperability with these
* clients.
@@ -700,13 +716,12 @@ static inline
struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp,
struct ptlrpc_request_pool *pool)
{
- struct ptlrpc_request *request = NULL;
+ struct ptlrpc_request *request;
- if (pool)
- request = ptlrpc_prep_req_from_pool(pool);
+ request = ptlrpc_request_cache_alloc(GFP_NOFS);
- if (!request)
- request = ptlrpc_request_cache_alloc(GFP_NOFS);
+ if (!request && pool)
+ request = ptlrpc_prep_req_from_pool(pool);
if (request) {
LASSERTF((unsigned long)imp > 0x1000, "%p", imp);
@@ -761,8 +776,8 @@ EXPORT_SYMBOL(ptlrpc_request_alloc);
* initialize its buffer structure according to capsule template \a format.
*/
struct ptlrpc_request *ptlrpc_request_alloc_pool(struct obd_import *imp,
- struct ptlrpc_request_pool *pool,
- const struct req_format *format)
+ struct ptlrpc_request_pool *pool,
+ const struct req_format *format)
{
return ptlrpc_request_alloc_internal(imp, pool, format);
}
@@ -789,11 +804,11 @@ EXPORT_SYMBOL(ptlrpc_request_free);
* Returns allocated request or NULL on error.
*/
struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp,
- const struct req_format *format,
- __u32 version, int opcode)
+ const struct req_format *format,
+ __u32 version, int opcode)
{
struct ptlrpc_request *req = ptlrpc_request_alloc(imp, format);
- int rc;
+ int rc;
if (req) {
rc = ptlrpc_request_pack(req, version, opcode);
@@ -807,56 +822,17 @@ struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp,
EXPORT_SYMBOL(ptlrpc_request_alloc_pack);
/**
- * Prepare request (fetched from pool \a pool if not NULL) on import \a imp
- * for operation \a opcode. Request would contain \a count buffers.
- * Sizes of buffers are described in array \a lengths and buffers themselves
- * are provided by a pointer \a bufs.
- * Returns prepared request structure pointer or NULL on error.
- */
-struct ptlrpc_request *
-ptlrpc_prep_req_pool(struct obd_import *imp,
- __u32 version, int opcode,
- int count, __u32 *lengths, char **bufs,
- struct ptlrpc_request_pool *pool)
-{
- struct ptlrpc_request *request;
- int rc;
-
- request = __ptlrpc_request_alloc(imp, pool);
- if (!request)
- return NULL;
-
- rc = __ptlrpc_request_bufs_pack(request, version, opcode, count,
- lengths, bufs, NULL);
- if (rc) {
- ptlrpc_request_free(request);
- request = NULL;
- }
- return request;
-}
-EXPORT_SYMBOL(ptlrpc_prep_req_pool);
-
-/**
- * Same as ptlrpc_prep_req_pool, but without pool
- */
-struct ptlrpc_request *
-ptlrpc_prep_req(struct obd_import *imp, __u32 version, int opcode, int count,
- __u32 *lengths, char **bufs)
-{
- return ptlrpc_prep_req_pool(imp, version, opcode, count, lengths, bufs,
- NULL);
-}
-EXPORT_SYMBOL(ptlrpc_prep_req);
-
-/**
- * Allocate and initialize new request set structure.
+ * Allocate and initialize new request set structure on the current CPT.
* Returns a pointer to the newly allocated set structure or NULL on error.
*/
struct ptlrpc_request_set *ptlrpc_prep_set(void)
{
struct ptlrpc_request_set *set;
+ int cpt;
- OBD_ALLOC(set, sizeof(*set));
+ cpt = cfs_cpt_current(cfs_cpt_table, 0);
+ set = kzalloc_node(sizeof(*set), GFP_NOFS,
+ cfs_cpt_spread_node(cfs_cpt_table, cpt));
if (!set)
return NULL;
atomic_set(&set->set_refcount, 1);
@@ -868,9 +844,9 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void)
INIT_LIST_HEAD(&set->set_new_requests);
INIT_LIST_HEAD(&set->set_cblist);
set->set_max_inflight = UINT_MAX;
- set->set_producer = NULL;
+ set->set_producer = NULL;
set->set_producer_arg = NULL;
- set->set_rc = 0;
+ set->set_rc = 0;
return set;
}
@@ -894,9 +870,9 @@ struct ptlrpc_request_set *ptlrpc_prep_fcset(int max, set_producer_func func,
if (!set)
return NULL;
- set->set_max_inflight = max;
- set->set_producer = func;
- set->set_producer_arg = arg;
+ set->set_max_inflight = max;
+ set->set_producer = func;
+ set->set_producer_arg = arg;
return set;
}
@@ -912,10 +888,10 @@ EXPORT_SYMBOL(ptlrpc_prep_fcset);
*/
void ptlrpc_set_destroy(struct ptlrpc_request_set *set)
{
- struct list_head *tmp;
- struct list_head *next;
- int expected_phase;
- int n = 0;
+ struct list_head *tmp;
+ struct list_head *next;
+ int expected_phase;
+ int n = 0;
/* Requests on the set should either all be completed, or all be new */
expected_phase = (atomic_read(&set->set_remaining) == 0) ?
@@ -961,28 +937,6 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set)
EXPORT_SYMBOL(ptlrpc_set_destroy);
/**
- * Add a callback function \a fn to the set.
- * This function would be called when all requests on this set are completed.
- * The function will be passed \a data argument.
- */
-int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
- set_interpreter_func fn, void *data)
-{
- struct ptlrpc_set_cbdata *cbdata;
-
- OBD_ALLOC_PTR(cbdata);
- if (cbdata == NULL)
- return -ENOMEM;
-
- cbdata->psc_interpret = fn;
- cbdata->psc_data = data;
- list_add_tail(&cbdata->psc_item, &set->set_cblist);
-
- return 0;
-}
-EXPORT_SYMBOL(ptlrpc_set_add_cb);
-
-/**
* Add a new request to the general purpose request set.
* Assumes request reference from the caller.
*/
@@ -1001,8 +955,10 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
lustre_msg_set_jobid(req->rq_reqmsg, NULL);
if (set->set_producer != NULL)
- /* If the request set has a producer callback, the RPC must be
- * sent straight away */
+ /*
+ * If the request set has a producer callback, the RPC must be
+ * sent straight away
+ */
ptlrpc_send_new_req(req);
}
EXPORT_SYMBOL(ptlrpc_set_add_req);
@@ -1013,7 +969,7 @@ EXPORT_SYMBOL(ptlrpc_set_add_req);
* Currently only used for ptlrpcd.
*/
void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
- struct ptlrpc_request *req)
+ struct ptlrpc_request *req)
{
struct ptlrpc_request_set *set = pc->pc_set;
int count, i;
@@ -1022,9 +978,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
LASSERT(test_bit(LIOD_STOP, &pc->pc_flags) == 0);
spin_lock(&set->set_new_req_lock);
- /*
- * The set takes over the caller's request reference.
- */
+ /* The set takes over the caller's request reference. */
req->rq_set = set;
req->rq_queued_time = cfs_time_current();
list_add_tail(&req->rq_set_chain, &set->set_new_requests);
@@ -1035,9 +989,11 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
if (count == 1) {
wake_up(&set->set_waitq);
- /* XXX: It maybe unnecessary to wakeup all the partners. But to
+ /*
+ * XXX: It maybe unnecessary to wakeup all the partners. But to
* guarantee the async RPC can be processed ASAP, we have
- * no other better choice. It maybe fixed in future. */
+ * no other better choice. It maybe fixed in future.
+ */
for (i = 0; i < pc->pc_npartners; i++)
wake_up(&pc->pc_partners[i]->pc_set->set_waitq);
}
@@ -1125,8 +1081,10 @@ static int ptlrpc_console_allow(struct ptlrpc_request *req)
LASSERT(req->rq_reqmsg != NULL);
opc = lustre_msg_get_opc(req->rq_reqmsg);
- /* Suppress particular reconnect errors which are to be expected. No
- * errors are suppressed for the initial connection on an import */
+ /*
+ * Suppress particular reconnect errors which are to be expected. No
+ * errors are suppressed for the initial connection on an import
+ */
if ((lustre_handle_is_used(&req->rq_import->imp_remote_handle)) &&
(opc == OST_CONNECT || opc == MDS_CONNECT || opc == MGS_CONNECT)) {
@@ -1155,6 +1113,7 @@ static int ptlrpc_check_status(struct ptlrpc_request *req)
if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
struct obd_import *imp = req->rq_import;
__u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
+
if (ptlrpc_console_allow(req))
LCONSOLE_ERROR_MSG(0x011, "%s: Communicating with %s, operation %s failed with %d.\n",
imp->imp_obd->obd_name,
@@ -1164,12 +1123,11 @@ static int ptlrpc_check_status(struct ptlrpc_request *req)
return err < 0 ? err : -EINVAL;
}
- if (err < 0) {
+ if (err < 0)
DEBUG_REQ(D_INFO, req, "status is %d", err);
- } else if (err > 0) {
+ else if (err > 0)
/* XXX: translate this error from net to host */
DEBUG_REQ(D_INFO, req, "status is %d", err);
- }
return err;
}
@@ -1206,7 +1164,7 @@ static int after_reply(struct ptlrpc_request *req)
struct obd_import *imp = req->rq_import;
struct obd_device *obd = req->rq_import->imp_obd;
int rc;
- struct timeval work_start;
+ struct timespec64 work_start;
long timediff;
LASSERT(obd != NULL);
@@ -1221,10 +1179,11 @@ static int after_reply(struct ptlrpc_request *req)
}
sptlrpc_cli_free_repbuf(req);
- /* Pass the required reply buffer size (include
- * space for early reply).
- * NB: no need to roundup because alloc_repbuf
- * will roundup it */
+ /*
+ * Pass the required reply buffer size (include space for early
+ * reply). NB: no need to round up because alloc_repbuf will
+ * round it up
+ */
req->rq_replen = req->rq_nob_received;
req->rq_nob_received = 0;
spin_lock(&req->rq_lock);
@@ -1243,9 +1202,7 @@ static int after_reply(struct ptlrpc_request *req)
return rc;
}
- /*
- * Security layer unwrap might ask resend this request.
- */
+ /* Security layer unwrap might ask resend this request. */
if (req->rq_resend)
return 0;
@@ -1256,7 +1213,7 @@ static int after_reply(struct ptlrpc_request *req)
/* retry indefinitely on EINPROGRESS */
if (lustre_msg_get_status(req->rq_repmsg) == -EINPROGRESS &&
ptlrpc_no_resend(req) == 0 && !req->rq_no_retry_einprogress) {
- time_t now = get_seconds();
+ time64_t now = ktime_get_real_seconds();
DEBUG_REQ(D_RPCTRACE, req, "Resending request on EINPROGRESS");
spin_lock(&req->rq_lock);
@@ -1266,18 +1223,19 @@ static int after_reply(struct ptlrpc_request *req)
/* allocate new xid to avoid reply reconstruction */
if (!req->rq_bulk) {
- /* new xid is already allocated for bulk in
- * ptlrpc_check_set() */
+ /* new xid is already allocated for bulk in ptlrpc_check_set() */
req->rq_xid = ptlrpc_next_xid();
DEBUG_REQ(D_RPCTRACE, req, "Allocating new xid for resend on EINPROGRESS");
}
/* Readjust the timeout for current conditions */
ptlrpc_at_set_req_timeout(req);
- /* delay resend to give a chance to the server to get ready.
+ /*
+ * delay resend to give a chance to the server to get ready.
* The delay is increased by 1s on every resend and is capped to
* the current request timeout (i.e. obd_timeout if AT is off,
- * or AT service time x 125% + 5s, see at_est2timeout) */
+ * or AT service time x 125% + 5s, see at_est2timeout)
+ */
if (req->rq_nr_resend > req->rq_timeout)
req->rq_sent = now + req->rq_timeout;
else
@@ -1286,8 +1244,9 @@ static int after_reply(struct ptlrpc_request *req)
return 0;
}
- do_gettimeofday(&work_start);
- timediff = cfs_timeval_sub(&work_start, &req->rq_arrival_time, NULL);
+ ktime_get_real_ts64(&work_start);
+ timediff = (work_start.tv_sec - req->rq_arrival_time.tv_sec) * USEC_PER_SEC +
+ (work_start.tv_nsec - req->rq_arrival_time.tv_nsec) / NSEC_PER_USEC;
if (obd->obd_svc_stats != NULL) {
lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR,
timediff);
@@ -1332,9 +1291,7 @@ static int after_reply(struct ptlrpc_request *req)
ldlm_cli_update_pool(req);
}
- /*
- * Store transno in reqmsg for replay.
- */
+ /* Store transno in reqmsg for replay. */
if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)) {
req->rq_transno = lustre_msg_get_transno(req->rq_repmsg);
lustre_msg_set_transno(req->rq_reqmsg, req->rq_transno);
@@ -1350,22 +1307,22 @@ static int after_reply(struct ptlrpc_request *req)
(req->rq_transno >
lustre_msg_get_last_committed(req->rq_repmsg) ||
req->rq_replay)) {
- /** version recovery */
+ /* version recovery */
ptlrpc_save_versions(req);
ptlrpc_retain_replayable_request(req, imp);
} else if (req->rq_commit_cb != NULL &&
list_empty(&req->rq_replay_list)) {
- /* NB: don't call rq_commit_cb if it's already on
+ /*
+ * NB: don't call rq_commit_cb if it's already on
* rq_replay_list, ptlrpc_free_committed() will call
- * it later, see LU-3618 for details */
+ * it later, see LU-3618 for details
+ */
spin_unlock(&imp->imp_lock);
req->rq_commit_cb(req);
spin_lock(&imp->imp_lock);
}
- /*
- * Replay-enabled imports return commit-status information.
- */
+ /* Replay-enabled imports return commit-status information. */
if (lustre_msg_get_last_committed(req->rq_repmsg)) {
imp->imp_peer_committed_transno =
lustre_msg_get_last_committed(req->rq_repmsg);
@@ -1400,11 +1357,11 @@ static int after_reply(struct ptlrpc_request *req)
*/
static int ptlrpc_send_new_req(struct ptlrpc_request *req)
{
- struct obd_import *imp = req->rq_import;
+ struct obd_import *imp = req->rq_import;
int rc;
LASSERT(req->rq_phase == RQ_PHASE_NEW);
- if (req->rq_sent && (req->rq_sent > get_seconds()) &&
+ if (req->rq_sent && (req->rq_sent > ktime_get_real_seconds()) &&
(!req->rq_generation_set ||
req->rq_import_generation == imp->imp_generation))
return 0;
@@ -1484,8 +1441,10 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set)
remaining = atomic_read(&set->set_remaining);
- /* populate the ->set_requests list with requests until we
- * reach the maximum number of RPCs in flight for this set */
+ /*
+ * populate the ->set_requests list with requests until we
+ * reach the maximum number of RPCs in flight for this set
+ */
while (atomic_read(&set->set_remaining) < set->set_max_inflight) {
rc = set->set_producer(set, set->set_producer_arg);
if (rc == -ENOENT) {
@@ -1525,7 +1484,8 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
int unregistered = 0;
int rc = 0;
- /* This schedule point is mainly for the ptlrpcd caller of this
+ /*
+ * This schedule point is mainly for the ptlrpcd caller of this
* function. Most ptlrpc sets are not long-lived and unbounded
* in length, but at the least the set used by the ptlrpcd is.
* Since the processing time is unbounded, we need to insert an
@@ -1544,7 +1504,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
/* delayed resend - skip */
if (req->rq_phase == RQ_PHASE_RPC && req->rq_resend &&
- req->rq_sent > get_seconds())
+ req->rq_sent > ktime_get_real_seconds())
continue;
if (!(req->rq_phase == RQ_PHASE_RPC ||
@@ -1584,8 +1544,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
OBD_FAIL_ONCE);
}
- /*
- * Move to next phase if reply was successfully
+ /* Move to next phase if reply was successfully
* unlinked.
*/
ptlrpc_rqphase_move(req, req->rq_next_phase);
@@ -1599,15 +1558,11 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
if (req->rq_phase == RQ_PHASE_INTERPRET)
goto interpret;
- /*
- * Note that this also will start async reply unlink.
- */
+ /* Note that this also will start async reply unlink. */
if (req->rq_net_err && !req->rq_timedout) {
ptlrpc_expire_one_request(req, 1);
- /*
- * Check if we still need to wait for unlink.
- */
+ /* Check if we still need to wait for unlink. */
if (ptlrpc_client_recv_or_unlink(req) ||
ptlrpc_client_bulk_active(req))
continue;
@@ -1632,7 +1587,8 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
goto interpret;
}
- /* ptlrpc_set_wait->l_wait_event sets lwi_allow_intr
+ /*
+ * ptlrpc_set_wait->l_wait_event sets lwi_allow_intr
* so it sets rq_intr regardless of individual rpc
* timeouts. The synchronous IO waiting path sets
* rq_intr irrespective of whether ptlrpcd
@@ -1659,8 +1615,10 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
spin_lock(&imp->imp_lock);
if (ptlrpc_import_delay_req(imp, req,
&status)) {
- /* put on delay list - only if we wait
- * recovery finished - before send */
+ /*
+ * put on delay list - only if we wait
+ * recovery finished - before send
+ */
list_del_init(&req->rq_list);
list_add_tail(&req->rq_list,
&imp->
@@ -1669,7 +1627,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
continue;
}
- if (status != 0) {
+ if (status != 0) {
req->rq_status = status;
ptlrpc_rqphase_move(req,
RQ_PHASE_INTERPRET);
@@ -1696,8 +1654,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
spin_unlock(&req->rq_lock);
if (req->rq_timedout || req->rq_resend) {
- /* This is re-sending anyways,
- * let's mark req as resend. */
+ /* This is re-sending anyway, let's mark req as resend. */
spin_lock(&req->rq_lock);
req->rq_resend = 1;
spin_unlock(&req->rq_lock);
@@ -1775,8 +1732,10 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
spin_unlock(&req->rq_lock);
- /* unlink from net because we are going to
- * swab in-place of reply buffer */
+ /*
+ * unlink from net because we are going to
+ * swab in-place of reply buffer
+ */
unregistered = ptlrpc_unregister_reply(req, 1);
if (!unregistered)
continue;
@@ -1785,7 +1744,8 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
if (req->rq_resend)
continue;
- /* If there is no bulk associated with this request,
+ /*
+ * If there is no bulk associated with this request,
* then we're done and should let the interpreter
* process the reply. Similarly if the RPC returned
* an error, and therefore the bulk will never arrive.
@@ -1803,10 +1763,12 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
continue;
if (req->rq_bulk->bd_failure) {
- /* The RPC reply arrived OK, but the bulk screwed
+ /*
+ * The RPC reply arrived OK, but the bulk screwed
* up! Dead weird since the server told us the RPC
* was good after getting the REPLY for her GET or
- * the ACK for her PUT. */
+ * the ACK for her PUT.
+ */
DEBUG_REQ(D_ERROR, req, "bulk transfer failed");
req->rq_status = -EIO;
}
@@ -1816,8 +1778,10 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
interpret:
LASSERT(req->rq_phase == RQ_PHASE_INTERPRET);
- /* This moves to "unregistering" phase we need to wait for
- * reply unlink. */
+ /*
+ * This moves to "unregistering" phase we need to wait for
+ * reply unlink.
+ */
if (!unregistered && !ptlrpc_unregister_reply(req, 1)) {
/* start async bulk unlink too */
ptlrpc_unregister_bulk(req, 1);
@@ -1827,8 +1791,7 @@ interpret:
if (!ptlrpc_unregister_bulk(req, 1))
continue;
- /* When calling interpret receiving already should be
- * finished. */
+ /* When calling interpret receive should already be finished. */
LASSERT(!req->rq_receiving_reply);
ptlrpc_req_interpret(env, req, req->rq_status);
@@ -1847,10 +1810,12 @@ interpret:
lustre_msg_get_opc(req->rq_reqmsg));
spin_lock(&imp->imp_lock);
- /* Request already may be not on sending or delaying list. This
+ /*
+ * Request already may be not on sending or delaying list. This
* may happen in the case of marking it erroneous for the case
* ptlrpc_import_delay_req(req, status) find it impossible to
- * allow sending this rpc and returns *status != 0. */
+ * allow sending this rpc and returns *status != 0.
+ */
if (!list_empty(&req->rq_list)) {
list_del_init(&req->rq_list);
atomic_dec(&imp->imp_inflight);
@@ -1865,8 +1830,10 @@ interpret:
if (ptlrpc_set_producer(set) > 0)
force_timer_recalc = 1;
- /* free the request that has just been completed
- * in order not to pollute set->set_requests */
+ /*
+ * free the request that has just been completed
+ * in order not to pollute set->set_requests
+ */
list_del_init(&req->rq_set_chain);
spin_lock(&req->rq_lock);
req->rq_set = NULL;
@@ -1882,8 +1849,10 @@ interpret:
}
}
- /* move completed request at the head of list so it's easier for
- * caller to find them */
+ /*
+ * move completed request at the head of list so it's easier for
+ * caller to find them
+ */
list_splice(&comp_reqs, &set->set_requests);
/* If we hit an error, we want to recover promptly. */
@@ -1905,14 +1874,13 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
req->rq_timedout = 1;
spin_unlock(&req->rq_lock);
- DEBUG_REQ(D_WARNING, req, "Request sent has %s: [sent "CFS_DURATION_T
- "/real "CFS_DURATION_T"]",
+ DEBUG_REQ(D_WARNING, req, "Request sent has %s: [sent %lld/real %lld]",
req->rq_net_err ? "failed due to network error" :
((req->rq_real_sent == 0 ||
- time_before((unsigned long)req->rq_real_sent, (unsigned long)req->rq_sent) ||
- cfs_time_aftereq(req->rq_real_sent, req->rq_deadline)) ?
+ req->rq_real_sent < req->rq_sent ||
+ req->rq_real_sent >= req->rq_deadline) ?
"timed out for sent delay" : "timed out for slow reply"),
- req->rq_sent, req->rq_real_sent);
+ (s64)req->rq_sent, (s64)req->rq_real_sent);
if (imp != NULL && obd_debug_peer_on_timeout)
LNetCtl(IOC_LIBCFS_DEBUG_PEER, &imp->imp_connection->c_peer);
@@ -1934,8 +1902,10 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
if (imp->imp_dlm_fake)
return 1;
- /* If this request is for recovery or other primordial tasks,
- * then error it out here. */
+ /*
+ * If this request is for recovery or other primordial tasks,
+ * then error it out here.
+ */
if (req->rq_ctx_init || req->rq_ctx_fini ||
req->rq_send_state != LUSTRE_IMP_FULL ||
imp->imp_obd->obd_no_recov) {
@@ -1949,8 +1919,10 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
return 1;
}
- /* if a request can't be resent we can't wait for an answer after
- the timeout */
+ /*
+ * if a request can't be resent we can't wait for an answer after
+ * the timeout
+ */
if (ptlrpc_no_resend(req)) {
DEBUG_REQ(D_RPCTRACE, req, "TIMEOUT-NORESEND:");
rc = 1;
@@ -1969,14 +1941,12 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
int ptlrpc_expired_set(void *data)
{
struct ptlrpc_request_set *set = data;
- struct list_head *tmp;
- time_t now = get_seconds();
+ struct list_head *tmp;
+ time64_t now = ktime_get_real_seconds();
LASSERT(set != NULL);
- /*
- * A timeout expired. See which reqs it applies to...
- */
+ /* A timeout expired. See which reqs it applies to... */
list_for_each(tmp, &set->set_requests) {
struct ptlrpc_request *req =
list_entry(tmp, struct ptlrpc_request,
@@ -1996,8 +1966,10 @@ int ptlrpc_expired_set(void *data)
req->rq_deadline > now) /* not expired */
continue;
- /* Deal with this guy. Do it asynchronously to not block
- * ptlrpcd thread. */
+ /*
+ * Deal with this guy. Do it asynchronously to not block
+ * ptlrpcd thread.
+ */
ptlrpc_expire_one_request(req, 1);
}
@@ -2052,32 +2024,26 @@ EXPORT_SYMBOL(ptlrpc_interrupted_set);
*/
int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set)
{
- struct list_head *tmp;
- time_t now = get_seconds();
- int timeout = 0;
+ struct list_head *tmp;
+ time64_t now = ktime_get_real_seconds();
+ int timeout = 0;
struct ptlrpc_request *req;
- int deadline;
+ time64_t deadline;
list_for_each(tmp, &set->set_requests) {
req = list_entry(tmp, struct ptlrpc_request, rq_set_chain);
- /*
- * Request in-flight?
- */
+ /* Request in-flight? */
if (!(((req->rq_phase == RQ_PHASE_RPC) && !req->rq_waiting) ||
(req->rq_phase == RQ_PHASE_BULK) ||
(req->rq_phase == RQ_PHASE_NEW)))
continue;
- /*
- * Already timed out.
- */
+ /* Already timed out. */
if (req->rq_timedout)
continue;
- /*
- * Waiting for ctx.
- */
+ /* Waiting for ctx. */
if (req->rq_wait_ctx)
continue;
@@ -2105,10 +2071,10 @@ EXPORT_SYMBOL(ptlrpc_set_next_timeout);
*/
int ptlrpc_set_wait(struct ptlrpc_request_set *set)
{
- struct list_head *tmp;
+ struct list_head *tmp;
struct ptlrpc_request *req;
- struct l_wait_info lwi;
- int rc, timeout;
+ struct l_wait_info lwi;
+ int rc, timeout;
if (set->set_producer)
(void)ptlrpc_set_producer(set);
@@ -2126,8 +2092,10 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
do {
timeout = ptlrpc_set_next_timeout(set);
- /* wait until all complete, interrupted, or an in-flight
- * req times out */
+ /*
+ * wait until all complete, interrupted, or an in-flight
+ * req times out
+ */
CDEBUG(D_RPCTRACE, "set %p going to sleep for %d seconds\n",
set, timeout);
@@ -2152,18 +2120,22 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
rc = l_wait_event(set->set_waitq, ptlrpc_check_set(NULL, set), &lwi);
- /* LU-769 - if we ignored the signal because it was already
+ /*
+ * LU-769 - if we ignored the signal because it was already
* pending when we started, we need to handle it now or we risk
- * it being ignored forever */
+ * it being ignored forever
+ */
if (rc == -ETIMEDOUT && !lwi.lwi_allow_intr &&
cfs_signal_pending()) {
sigset_t blocked_sigs =
cfs_block_sigsinv(LUSTRE_FATAL_SIGS);
- /* In fact we only interrupt for the "fatal" signals
+ /*
+ * In fact we only interrupt for the "fatal" signals
* like SIGINT or SIGKILL. We still ignore less
* important signals since ptlrpc set is not easily
- * reentrant from userspace again */
+ * reentrant from userspace again
+ */
if (cfs_signal_pending())
ptlrpc_interrupted_set(set);
cfs_restore_sigs(blocked_sigs);
@@ -2171,13 +2143,15 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
LASSERT(rc == 0 || rc == -EINTR || rc == -ETIMEDOUT);
- /* -EINTR => all requests have been flagged rq_intr so next
+ /*
+ * -EINTR => all requests have been flagged rq_intr so next
* check completes.
* -ETIMEDOUT => someone timed out. When all reqs have
* timed out, signals are enabled allowing completion with
* EINTR.
* I don't really care if we go once more round the loop in
- * the error cases -eeb. */
+ * the error cases -eeb.
+ */
if (rc == 0 && atomic_read(&set->set_remaining) == 0) {
list_for_each(tmp, &set->set_requests) {
req = list_entry(tmp, struct ptlrpc_request,
@@ -2214,7 +2188,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
err = cbdata->psc_interpret(set, cbdata->psc_data, rc);
if (err && !rc)
rc = err;
- OBD_FREE_PTR(cbdata);
+ kfree(cbdata);
}
}
@@ -2243,8 +2217,10 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
req_capsule_fini(&request->rq_pill);
- /* We must take it off the imp_replay_list first. Otherwise, we'll set
- * request->rq_reqmsg to NULL while osc_close is dereferencing it. */
+ /*
+ * We must take it off the imp_replay_list first. Otherwise, we'll set
+ * request->rq_reqmsg to NULL while osc_close is dereferencing it.
+ */
if (request->rq_import != NULL) {
if (!locked)
spin_lock(&request->rq_import->imp_lock);
@@ -2285,18 +2261,6 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
ptlrpc_request_cache_free(request);
}
-static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked);
-/**
- * Drop one request reference. Must be called with import imp_lock held.
- * When reference count drops to zero, request is freed.
- */
-void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request)
-{
- assert_spin_locked(&request->rq_import->imp_lock);
- (void)__ptlrpc_req_finished(request, 1);
-}
-EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
-
/**
* Helper function
* Drops one reference count for request \a request.
@@ -2353,44 +2317,32 @@ EXPORT_SYMBOL(ptlrpc_req_xid);
*/
int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async)
{
- int rc;
- wait_queue_head_t *wq;
+ int rc;
+ wait_queue_head_t *wq;
struct l_wait_info lwi;
- /*
- * Might sleep.
- */
+ /* Might sleep. */
LASSERT(!in_interrupt());
- /*
- * Let's setup deadline for reply unlink.
- */
+ /* Let's setup deadline for reply unlink. */
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) &&
async && request->rq_reply_deadline == 0)
- request->rq_reply_deadline = get_seconds()+LONG_UNLINK;
+ request->rq_reply_deadline = ktime_get_real_seconds()+LONG_UNLINK;
- /*
- * Nothing left to do.
- */
+ /* Nothing left to do. */
if (!ptlrpc_client_recv_or_unlink(request))
return 1;
LNetMDUnlink(request->rq_reply_md_h);
- /*
- * Let's check it once again.
- */
+ /* Let's check it once again. */
if (!ptlrpc_client_recv_or_unlink(request))
return 1;
- /*
- * Move to "Unregistering" phase as reply was not unlinked yet.
- */
+ /* Move to "Unregistering" phase as reply was not unlinked yet. */
ptlrpc_rqphase_move(request, RQ_PHASE_UNREGISTERING);
- /*
- * Do not wait for unlink to finish.
- */
+ /* Do not wait for unlink to finish. */
if (async)
return 0;
@@ -2405,8 +2357,10 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async)
wq = &request->rq_reply_waitq;
for (;;) {
- /* Network access will complete in finite time but the HUGE
- * timeout lets us CWARN for visibility of sluggish NALs */
+ /*
+ * Network access will complete in finite time but the HUGE
+ * timeout lets us CWARN for visibility of sluggish NALs
+ */
lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
cfs_time_seconds(1), NULL, NULL);
rc = l_wait_event(*wq, !ptlrpc_client_recv_or_unlink(request),
@@ -2471,7 +2425,7 @@ void ptlrpc_free_committed(struct obd_import *imp)
{
struct ptlrpc_request *req, *saved;
struct ptlrpc_request *last_req = NULL; /* temporary fire escape */
- bool skip_committed_list = true;
+ bool skip_committed_list = true;
LASSERT(imp != NULL);
assert_spin_locked(&imp->imp_lock);
@@ -2538,11 +2492,6 @@ free_req:
}
}
-void ptlrpc_cleanup_client(struct obd_import *imp)
-{
-}
-EXPORT_SYMBOL(ptlrpc_cleanup_client);
-
/**
* Schedule previously sent request for resend.
* For bulk requests we assign new xid (to avoid problems with
@@ -2554,8 +2503,10 @@ void ptlrpc_resend_req(struct ptlrpc_request *req)
DEBUG_REQ(D_HA, req, "going to resend");
spin_lock(&req->rq_lock);
- /* Request got reply but linked to the import list still.
- Let ptlrpc_check_set() to process it. */
+ /*
+ * Request got reply but linked to the import list still.
+ * Let ptlrpc_check_set() to process it.
+ */
if (ptlrpc_client_replied(req)) {
spin_unlock(&req->rq_lock);
DEBUG_REQ(D_HA, req, "it has reply, so skip it");
@@ -2581,20 +2532,6 @@ void ptlrpc_resend_req(struct ptlrpc_request *req)
}
EXPORT_SYMBOL(ptlrpc_resend_req);
-/* XXX: this function and rq_status are currently unused */
-void ptlrpc_restart_req(struct ptlrpc_request *req)
-{
- DEBUG_REQ(D_HA, req, "restarting (possibly-)completed request");
- req->rq_status = -ERESTARTSYS;
-
- spin_lock(&req->rq_lock);
- req->rq_restart = 1;
- req->rq_timedout = 0;
- ptlrpc_client_wake_req(req);
- spin_unlock(&req->rq_lock);
-}
-EXPORT_SYMBOL(ptlrpc_restart_req);
-
/**
* Grab additional reference on a request \a req
*/
@@ -2621,8 +2558,10 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
LBUG();
}
- /* clear this for new requests that were resent as well
- as resent replayed requests. */
+ /*
+ * clear this for new requests that were resent as well
+ * as resent replayed requests.
+ */
lustre_msg_clear_flags(req->rq_reqmsg, MSG_RESENT);
/* don't re-add requests that have been replayed */
@@ -2639,7 +2578,8 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
list_entry(tmp, struct ptlrpc_request,
rq_replay_list);
- /* We may have duplicate transnos if we create and then
+ /*
+ * We may have duplicate transnos if we create and then
* open a file, or for closes retained if to match creating
* opens, so use req->rq_xid as a secondary key.
* (See bugs 684, 685, and 428.)
@@ -2824,8 +2764,10 @@ int ptlrpc_replay_req(struct ptlrpc_request *req)
/* Readjust the timeout for current conditions */
ptlrpc_at_set_req_timeout(req);
- /* Tell server the net_latency, so the server can calculate how long
- * it should wait for next replay */
+ /*
+ * Tell server the net_latency, so the server can calculate how long
+ * it should wait for next replay
+ */
lustre_msg_set_service_time(req->rq_reqmsg,
ptlrpc_at_get_net_latency(req));
DEBUG_REQ(D_HA, req, "REPLAY");
@@ -2833,7 +2775,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req)
atomic_inc(&req->rq_import->imp_replay_inflight);
ptlrpc_request_addref(req); /* ptlrpcd needs a ref */
- ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
+ ptlrpcd_add_req(req);
return 0;
}
EXPORT_SYMBOL(ptlrpc_replay_req);
@@ -2845,13 +2787,15 @@ void ptlrpc_abort_inflight(struct obd_import *imp)
{
struct list_head *tmp, *n;
- /* Make sure that no new requests get processed for this import.
+ /*
+ * Make sure that no new requests get processed for this import.
* ptlrpc_{queue,set}_wait must (and does) hold imp_lock while testing
* this flag and then putting requests on sending_list or delayed_list.
*/
spin_lock(&imp->imp_lock);
- /* XXX locking? Maybe we should remove each request with the list
+ /*
+ * XXX locking? Maybe we should remove each request with the list
* locked? Also, how do we know if the requests on the list are
* being freed at this time?
*/
@@ -2885,8 +2829,10 @@ void ptlrpc_abort_inflight(struct obd_import *imp)
spin_unlock(&req->rq_lock);
}
- /* Last chance to free reqs left on the replay list, but we
- * will still leak reqs that haven't committed. */
+ /*
+ * Last chance to free reqs left on the replay list, but we
+ * will still leak reqs that haven't committed.
+ */
if (imp->imp_replayable)
ptlrpc_free_committed(imp);
@@ -2942,7 +2888,7 @@ static spinlock_t ptlrpc_last_xid_lock;
#define YEAR_2004 (1ULL << 30)
void ptlrpc_init_xid(void)
{
- time_t now = get_seconds();
+ time64_t now = ktime_get_real_seconds();
spin_lock_init(&ptlrpc_last_xid_lock);
if (now < YEAR_2004) {
@@ -2954,7 +2900,7 @@ void ptlrpc_init_xid(void)
}
/* Always need to be aligned to a power-of-two for multi-bulk BRW */
- CLASSERT((PTLRPC_BULK_OPS_COUNT & (PTLRPC_BULK_OPS_COUNT - 1)) == 0);
+ CLASSERT(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) == 0);
ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK;
}
@@ -3023,15 +2969,15 @@ EXPORT_SYMBOL(ptlrpc_sample_next_xid);
* have delay before it really runs by ptlrpcd thread.
*/
struct ptlrpc_work_async_args {
- int (*cb)(const struct lu_env *, void *);
- void *cbdata;
+ int (*cb)(const struct lu_env *, void *);
+ void *cbdata;
};
static void ptlrpcd_add_work_req(struct ptlrpc_request *req)
{
/* re-initialize the req */
req->rq_timeout = obd_timeout;
- req->rq_sent = get_seconds();
+ req->rq_sent = ktime_get_real_seconds();
req->rq_deadline = req->rq_sent + req->rq_timeout;
req->rq_reply_deadline = req->rq_deadline;
req->rq_phase = RQ_PHASE_INTERPRET;
@@ -3039,7 +2985,7 @@ static void ptlrpcd_add_work_req(struct ptlrpc_request *req)
req->rq_xid = ptlrpc_next_xid();
req->rq_import_generation = req->rq_import->imp_generation;
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
}
static int work_interpreter(const struct lu_env *env,
@@ -3113,7 +3059,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args));
args = ptlrpc_req_async_args(req);
- args->cb = cb;
+ args->cb = cb;
args->cbdata = cbdata;
return req;
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/connection.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/connection.c
index 7e27397ce..da1f0b1ac 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/connection.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/connection.c
@@ -42,7 +42,7 @@
#include "ptlrpc_internal.h"
static struct cfs_hash *conn_hash;
-static cfs_hash_ops_t conn_hash_ops;
+static struct cfs_hash_ops conn_hash_ops;
struct ptlrpc_connection *
ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
@@ -54,7 +54,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
if (conn)
goto out;
- OBD_ALLOC_PTR(conn);
+ conn = kzalloc(sizeof(*conn), GFP_NOFS);
if (!conn)
return NULL;
@@ -76,7 +76,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
/* coverity[overrun-buffer-val] */
conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
if (conn != conn2) {
- OBD_FREE_PTR(conn);
+ kfree(conn);
conn = conn2;
}
out:
@@ -173,7 +173,7 @@ conn_keycmp(const void *key, struct hlist_node *hnode)
const lnet_process_id_t *conn_key;
LASSERT(key != NULL);
- conn_key = (lnet_process_id_t *)key;
+ conn_key = key;
conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
return conn_key->nid == conn->c_peer.nid &&
@@ -227,15 +227,15 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode)
LASSERTF(atomic_read(&conn->c_refcount) == 0,
"Busy connection with %d refs\n",
atomic_read(&conn->c_refcount));
- OBD_FREE_PTR(conn);
+ kfree(conn);
}
-static cfs_hash_ops_t conn_hash_ops = {
+static struct cfs_hash_ops conn_hash_ops = {
.hs_hash = conn_hashfn,
.hs_keycmp = conn_keycmp,
- .hs_key = conn_key,
+ .hs_key = conn_key,
.hs_object = conn_object,
- .hs_get = conn_get,
+ .hs_get = conn_get,
.hs_put_locked = conn_put_locked,
.hs_exit = conn_exit,
};
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/events.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/events.c
index 7f8644e01..9c2fd34e2 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/events.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/events.c
@@ -53,7 +53,7 @@ lnet_handle_eq_t ptlrpc_eq_h;
*/
void request_out_callback(lnet_event_t *ev)
{
- struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+ struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
struct ptlrpc_request *req = cbid->cbid_arg;
LASSERT(ev->type == LNET_EVENT_SEND ||
@@ -64,7 +64,7 @@ void request_out_callback(lnet_event_t *ev)
sptlrpc_request_out_callback(req);
spin_lock(&req->rq_lock);
- req->rq_real_sent = get_seconds();
+ req->rq_real_sent = ktime_get_real_seconds();
if (ev->unlinked)
req->rq_req_unlink = 0;
@@ -86,7 +86,7 @@ void request_out_callback(lnet_event_t *ev)
*/
void reply_in_callback(lnet_event_t *ev)
{
- struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+ struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
struct ptlrpc_request *req = cbid->cbid_arg;
DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status);
@@ -158,7 +158,7 @@ void reply_in_callback(lnet_event_t *ev)
ev->mlength, ev->offset, req->rq_replen);
}
- req->rq_import->imp_last_reply_time = get_seconds();
+ req->rq_import->imp_last_reply_time = ktime_get_real_seconds();
out_wake:
/* NB don't unlock till after wakeup; req can disappear under us
@@ -172,9 +172,9 @@ out_wake:
*/
void client_bulk_callback(lnet_event_t *ev)
{
- struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+ struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
struct ptlrpc_bulk_desc *desc = cbid->cbid_arg;
- struct ptlrpc_request *req;
+ struct ptlrpc_request *req;
LASSERT((desc->bd_type == BULK_PUT_SINK &&
ev->type == LNET_EVENT_PUT) ||
@@ -245,9 +245,9 @@ void client_bulk_callback(lnet_event_t *ev)
static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,
struct ptlrpc_request *req)
{
- __u64 sec = req->rq_arrival_time.tv_sec;
- __u32 usec = req->rq_arrival_time.tv_usec >> 4; /* usec / 16 */
- __u64 new_seq;
+ __u64 sec = req->rq_arrival_time.tv_sec;
+ __u32 usec = req->rq_arrival_time.tv_nsec / NSEC_PER_USEC / 16; /* usec / 16 */
+ __u64 new_seq;
/* set sequence ID for request and add it to history list,
* it must be called with hold svcpt::scp_lock */
@@ -281,11 +281,11 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,
*/
void request_in_callback(lnet_event_t *ev)
{
- struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+ struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
struct ptlrpc_request_buffer_desc *rqbd = cbid->cbid_arg;
- struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt;
- struct ptlrpc_service *service = svcpt->scp_service;
- struct ptlrpc_request *req;
+ struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt;
+ struct ptlrpc_service *service = svcpt->scp_service;
+ struct ptlrpc_request *req;
LASSERT(ev->type == LNET_EVENT_PUT ||
ev->type == LNET_EVENT_UNLINK);
@@ -327,7 +327,7 @@ void request_in_callback(lnet_event_t *ev)
req->rq_reqbuf = ev->md.start + ev->offset;
if (ev->type == LNET_EVENT_PUT && ev->status == 0)
req->rq_reqdata_len = ev->mlength;
- do_gettimeofday(&req->rq_arrival_time);
+ ktime_get_real_ts64(&req->rq_arrival_time);
req->rq_peer = ev->initiator;
req->rq_self = ev->target.nid;
req->rq_rqbd = rqbd;
@@ -380,7 +380,7 @@ void request_in_callback(lnet_event_t *ev)
*/
void reply_out_callback(lnet_event_t *ev)
{
- struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+ struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
struct ptlrpc_reply_state *rs = cbid->cbid_arg;
struct ptlrpc_service_part *svcpt = rs->rs_svcpt;
@@ -415,7 +415,6 @@ void reply_out_callback(lnet_event_t *ev)
}
}
-
static void ptlrpc_master_callback(lnet_event_t *ev)
{
struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
@@ -433,17 +432,17 @@ static void ptlrpc_master_callback(lnet_event_t *ev)
}
int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
- lnet_process_id_t *peer, lnet_nid_t *self)
+ lnet_process_id_t *peer, lnet_nid_t *self)
{
- int best_dist = 0;
- __u32 best_order = 0;
- int count = 0;
- int rc = -ENOENT;
- int portals_compatibility;
- int dist;
- __u32 order;
- lnet_nid_t dst_nid;
- lnet_nid_t src_nid;
+ int best_dist = 0;
+ __u32 best_order = 0;
+ int count = 0;
+ int rc = -ENOENT;
+ int portals_compatibility;
+ int dist;
+ __u32 order;
+ lnet_nid_t dst_nid;
+ lnet_nid_t src_nid;
portals_compatibility = LNetCtl(IOC_LIBCFS_PORTALS_COMPATIBILITY, NULL);
@@ -485,12 +484,12 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
return rc;
}
-void ptlrpc_ni_fini(void)
+static void ptlrpc_ni_fini(void)
{
- wait_queue_head_t waitq;
- struct l_wait_info lwi;
- int rc;
- int retries;
+ wait_queue_head_t waitq;
+ struct l_wait_info lwi;
+ int rc;
+ int retries;
/* Wait for the event queue to become idle since there may still be
* messages in flight with pending events (i.e. the fire-and-forget
@@ -521,18 +520,18 @@ void ptlrpc_ni_fini(void)
/* notreached */
}
-lnet_pid_t ptl_get_pid(void)
+static lnet_pid_t ptl_get_pid(void)
{
- lnet_pid_t pid;
+ lnet_pid_t pid;
pid = LUSTRE_SRV_LNET_PID;
return pid;
}
-int ptlrpc_ni_init(void)
+static int ptlrpc_ni_init(void)
{
- int rc;
- lnet_pid_t pid;
+ int rc;
+ lnet_pid_t pid;
pid = ptl_get_pid();
CDEBUG(D_NET, "My pid is: %x\n", pid);
@@ -560,10 +559,9 @@ int ptlrpc_ni_init(void)
return -ENOMEM;
}
-
int ptlrpc_init_portals(void)
{
- int rc = ptlrpc_ni_init();
+ int rc = ptlrpc_ni_init();
if (rc != 0) {
CERROR("network initialisation failed\n");
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/import.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/import.c
index d5fc689c0..bfa410f7e 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -79,7 +79,7 @@ static void __import_set_state(struct obd_import *imp,
imp->imp_state = state;
imp->imp_state_hist[imp->imp_state_hist_idx].ish_state = state;
imp->imp_state_hist[imp->imp_state_hist_idx].ish_time =
- get_seconds();
+ ktime_get_real_seconds();
imp->imp_state_hist_idx = (imp->imp_state_hist_idx + 1) %
IMP_STATE_HIST_LEN;
}
@@ -103,7 +103,6 @@ do { \
spin_unlock(&imp->imp_lock); \
} while (0)
-
static int ptlrpc_connect_interpret(const struct lu_env *env,
struct ptlrpc_request *request,
void *data, int rc);
@@ -119,7 +118,7 @@ int ptlrpc_init_import(struct obd_import *imp)
spin_lock(&imp->imp_lock);
imp->imp_generation++;
- imp->imp_state = LUSTRE_IMP_NEW;
+ imp->imp_state = LUSTRE_IMP_NEW;
spin_unlock(&imp->imp_lock);
@@ -128,7 +127,8 @@ int ptlrpc_init_import(struct obd_import *imp)
EXPORT_SYMBOL(ptlrpc_init_import);
#define UUID_STR "_UUID"
-void deuuidify(char *uuid, const char *prefix, char **uuid_start, int *uuid_len)
+static void deuuidify(char *uuid, const char *prefix, char **uuid_start,
+ int *uuid_len)
{
*uuid_start = !prefix || strncmp(uuid, prefix, strlen(prefix))
? uuid : uuid + strlen(prefix);
@@ -142,7 +142,6 @@ void deuuidify(char *uuid, const char *prefix, char **uuid_start, int *uuid_len)
UUID_STR, strlen(UUID_STR)))
*uuid_len -= strlen(UUID_STR);
}
-EXPORT_SYMBOL(deuuidify);
/**
* Returns true if import was FULL, false if import was already not
@@ -200,12 +199,15 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt)
return rc;
}
-/* Must be called with imp_lock held! */
-static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp)
+/*
+ * This acts as a barrier; all existing requests are rejected, and
+ * no new requests will be accepted until the import is valid again.
+ */
+void ptlrpc_deactivate_import(struct obd_import *imp)
{
- assert_spin_locked(&imp->imp_lock);
-
CDEBUG(D_HA, "setting import %s INVALID\n", obd2cli_tgt(imp->imp_obd));
+
+ spin_lock(&imp->imp_lock);
imp->imp_invalid = 1;
imp->imp_generation++;
spin_unlock(&imp->imp_lock);
@@ -213,20 +215,10 @@ static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp)
ptlrpc_abort_inflight(imp);
obd_import_event(imp->imp_obd, imp, IMP_EVENT_INACTIVE);
}
-
-/*
- * This acts as a barrier; all existing requests are rejected, and
- * no new requests will be accepted until the import is valid again.
- */
-void ptlrpc_deactivate_import(struct obd_import *imp)
-{
- spin_lock(&imp->imp_lock);
- ptlrpc_deactivate_and_unlock_import(imp);
-}
EXPORT_SYMBOL(ptlrpc_deactivate_import);
static unsigned int
-ptlrpc_inflight_deadline(struct ptlrpc_request *req, time_t now)
+ptlrpc_inflight_deadline(struct ptlrpc_request *req, time64_t now)
{
long dl;
@@ -251,7 +243,7 @@ ptlrpc_inflight_deadline(struct ptlrpc_request *req, time_t now)
static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp)
{
- time_t now = get_seconds();
+ time64_t now = ktime_get_real_seconds();
struct list_head *tmp, *n;
struct ptlrpc_request *req;
unsigned int timeout = 0;
@@ -369,7 +361,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp)
imp_unregistering));
}
spin_unlock(&imp->imp_lock);
- }
+ }
} while (rc != 0);
/*
@@ -461,6 +453,7 @@ int ptlrpc_reconnect_import(struct obd_import *imp)
if (atomic_read(&imp->imp_inval_count) > 0) {
int rc;
struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
+
rc = l_wait_event(imp->imp_recovery_waitq,
(atomic_read(&imp->imp_inval_count) == 0),
&lwi);
@@ -542,6 +535,7 @@ static int import_select_connection(struct obd_import *imp)
trying to reconnect on it.) */
if (tried_all && (imp->imp_conn_list.next == &imp_conn->oic_item)) {
struct adaptive_timeout *at = &imp->imp_at.iat_net_latency;
+
if (at_get(at) < CONNECTION_SWITCH_MAX) {
at_measured(at, at_get(at) + CONNECTION_SWITCH_INC);
if (at_get(at) > CONNECTION_SWITCH_MAX)
@@ -555,14 +549,12 @@ static int import_select_connection(struct obd_import *imp)
imp_conn->oic_last_attempt = cfs_time_current_64();
/* switch connection, don't mind if it's same as the current one */
- if (imp->imp_connection)
- ptlrpc_connection_put(imp->imp_connection);
+ ptlrpc_connection_put(imp->imp_connection);
imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
- dlmexp = class_conn2export(&imp->imp_dlm_handle);
+ dlmexp = class_conn2export(&imp->imp_dlm_handle);
LASSERT(dlmexp != NULL);
- if (dlmexp->exp_connection)
- ptlrpc_connection_put(dlmexp->exp_connection);
+ ptlrpc_connection_put(dlmexp->exp_connection);
dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
class_export_put(dlmexp);
@@ -751,12 +743,11 @@ int ptlrpc_connect_import(struct obd_import *imp)
DEBUG_REQ(D_RPCTRACE, request, "(re)connect request (timeout %d)",
request->rq_timeout);
- ptlrpcd_add_req(request, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(request);
rc = 0;
out:
- if (rc != 0) {
+ if (rc != 0)
IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
- }
return rc;
}
@@ -908,7 +899,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
}
/* Determine what recovery state to move the import to. */
- if (MSG_CONNECT_RECONNECT & msg_flags) {
+ if (msg_flags & MSG_CONNECT_RECONNECT) {
memset(&old_hdl, 0, sizeof(old_hdl));
if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg),
sizeof(old_hdl))) {
@@ -933,7 +924,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
* eviction. If it is in recovery - we are safe to
* participate since we can reestablish all of our state
* with server again */
- if ((MSG_CONNECT_RECOVERING & msg_flags)) {
+ if ((msg_flags & MSG_CONNECT_RECOVERING)) {
CDEBUG(level, "%s@%s changed server handle from %#llx to %#llx but is still in recovery\n",
obd2cli_tgt(imp->imp_obd),
imp->imp_connection->c_remote_uuid.uuid,
@@ -950,11 +941,10 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
request->rq_repmsg)->cookie);
}
-
imp->imp_remote_handle =
*lustre_msg_get_handle(request->rq_repmsg);
- if (!(MSG_CONNECT_RECOVERING & msg_flags)) {
+ if (!(msg_flags & MSG_CONNECT_RECOVERING)) {
IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
rc = 0;
goto finish;
@@ -970,7 +960,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
CDEBUG(D_HA, "%s: reconnected but import is invalid; marking evicted\n",
imp->imp_obd->obd_name);
IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
- } else if (MSG_CONNECT_RECOVERING & msg_flags) {
+ } else if (msg_flags & MSG_CONNECT_RECOVERING) {
CDEBUG(D_HA, "%s: reconnected to %s during replay\n",
imp->imp_obd->obd_name,
obd2cli_tgt(imp->imp_obd));
@@ -983,7 +973,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
} else {
IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
}
- } else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) {
+ } else if ((msg_flags & MSG_CONNECT_RECOVERING) && !imp->imp_invalid) {
LASSERT(imp->imp_replayable);
imp->imp_remote_handle =
*lustre_msg_get_handle(request->rq_repmsg);
@@ -1266,7 +1256,7 @@ static int signal_completed_replay(struct obd_import *imp)
req->rq_timeout *= 3;
req->rq_interpret_reply = completed_replay_interpret;
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
return 0;
}
@@ -1490,7 +1480,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
INITIAL_CONNECT_TIMEOUT);
IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING);
- req->rq_send_state = LUSTRE_IMP_CONNECTING;
+ req->rq_send_state = LUSTRE_IMP_CONNECTING;
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
ptlrpc_req_finished(req);
@@ -1513,16 +1503,6 @@ out:
}
EXPORT_SYMBOL(ptlrpc_disconnect_import);
-void ptlrpc_cleanup_imp(struct obd_import *imp)
-{
- spin_lock(&imp->imp_lock);
- IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED);
- imp->imp_generation++;
- spin_unlock(&imp->imp_lock);
- ptlrpc_abort_inflight(imp);
-}
-EXPORT_SYMBOL(ptlrpc_cleanup_imp);
-
/* Adaptive Timeout utils */
extern unsigned int at_min, at_max, at_history;
@@ -1533,12 +1513,12 @@ extern unsigned int at_min, at_max, at_history;
int at_measured(struct adaptive_timeout *at, unsigned int val)
{
unsigned int old = at->at_current;
- time_t now = get_seconds();
- time_t binlimit = max_t(time_t, at_history / AT_BINS, 1);
+ time64_t now = ktime_get_real_seconds();
+ long binlimit = max_t(long, at_history / AT_BINS, 1);
LASSERT(at);
CDEBUG(D_OTHER, "add %u to %p time=%lu v=%u (%u %u %u %u)\n",
- val, at, now - at->at_binstart, at->at_current,
+ val, at, (long)(now - at->at_binstart), at->at_current,
at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]);
if (val == 0)
@@ -1563,7 +1543,7 @@ int at_measured(struct adaptive_timeout *at, unsigned int val)
int i, shift;
unsigned int maxv = val;
/* move bins over */
- shift = (now - at->at_binstart) / binlimit;
+ shift = (u32)(now - at->at_binstart) / binlimit;
LASSERT(shift > 0);
for (i = AT_BINS - 1; i >= 0; i--) {
if (i >= shift) {
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/layout.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/layout.c
index a42335e26..d7c4f4780 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/layout.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/layout.c
@@ -404,6 +404,7 @@ static const struct req_msg_field *ldlm_intent_layout_client[] = {
&RMF_LAYOUT_INTENT,
&RMF_EADATA /* for new layout to be set up */
};
+
static const struct req_msg_field *ldlm_intent_open_server[] = {
&RMF_PTLRPC_BODY,
&RMF_DLM_REP,
@@ -578,7 +579,6 @@ static const struct req_msg_field *ost_destroy_client[] = {
&RMF_CAPA1
};
-
static const struct req_msg_field *ost_brw_client[] = {
&RMF_PTLRPC_BODY,
&RMF_OST_BODY,
@@ -789,17 +789,17 @@ enum rmf_flags {
/**
* The field is a string, must be NUL-terminated.
*/
- RMF_F_STRING = 1 << 0,
+ RMF_F_STRING = BIT(0),
/**
* The field's buffer size need not match the declared \a rmf_size.
*/
- RMF_F_NO_SIZE_CHECK = 1 << 1,
+ RMF_F_NO_SIZE_CHECK = BIT(1),
/**
* The field's buffer size must be a whole multiple of the declared \a
* rmf_size and the \a rmf_swabber function must work on the declared \a
* rmf_size worth of bytes.
*/
- RMF_F_STRUCT_ARRAY = 1 << 2
+ RMF_F_STRUCT_ARRAY = BIT(2)
};
struct req_capsule;
@@ -807,11 +807,11 @@ struct req_capsule;
/*
* Request fields.
*/
-#define DEFINE_MSGF(name, flags, size, swabber, dumper) { \
- .rmf_name = (name), \
- .rmf_flags = (flags), \
- .rmf_size = (size), \
- .rmf_swabber = (void (*)(void *))(swabber), \
+#define DEFINE_MSGF(name, flags, size, swabber, dumper) { \
+ .rmf_name = (name), \
+ .rmf_flags = (flags), \
+ .rmf_size = (size), \
+ .rmf_swabber = (void (*)(void *))(swabber), \
.rmf_dumper = (void (*)(void *))(dumper) \
}
@@ -1164,25 +1164,25 @@ EXPORT_SYMBOL(RMF_SWAP_LAYOUTS);
struct req_format {
const char *rf_name;
- int rf_idx;
+ int rf_idx;
struct {
- int nr;
+ int nr;
const struct req_msg_field **d;
} rf_fields[RCL_NR];
};
-#define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) { \
- .rf_name = name, \
- .rf_fields = { \
+#define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) { \
+ .rf_name = name, \
+ .rf_fields = { \
[RCL_CLIENT] = { \
.nr = client_nr, \
- .d = client \
- }, \
+ .d = client \
+ }, \
[RCL_SERVER] = { \
.nr = server_nr, \
- .d = server \
- } \
- } \
+ .d = server \
+ } \
+ } \
}
#define DEFINE_REQ_FMT0(name, client, server) \
@@ -1679,7 +1679,7 @@ EXPORT_SYMBOL(req_layout_fini);
* req_capsule_msg_size(). The \a rc_area information is used by.
* ptlrpc_request_set_replen().
*/
-void req_capsule_init_area(struct req_capsule *pill)
+static void req_capsule_init_area(struct req_capsule *pill)
{
int i;
@@ -1688,7 +1688,6 @@ void req_capsule_init_area(struct req_capsule *pill)
pill->rc_area[RCL_SERVER][i] = -1;
}
}
-EXPORT_SYMBOL(req_capsule_init_area);
/**
* Initialize a pill.
@@ -1769,10 +1768,10 @@ EXPORT_SYMBOL(req_capsule_set);
* field of a \a pill's \a rc_fmt's RMF's.
*/
int req_capsule_filled_sizes(struct req_capsule *pill,
- enum req_location loc)
+ enum req_location loc)
{
const struct req_format *fmt = pill->rc_fmt;
- int i;
+ int i;
LASSERT(fmt != NULL);
@@ -1806,8 +1805,8 @@ EXPORT_SYMBOL(req_capsule_filled_sizes);
int req_capsule_server_pack(struct req_capsule *pill)
{
const struct req_format *fmt;
- int count;
- int rc;
+ int count;
+ int rc;
LASSERT(pill->rc_loc == RCL_SERVER);
fmt = pill->rc_fmt;
@@ -1857,11 +1856,11 @@ swabber_dumper_helper(struct req_capsule *pill,
int offset,
void *value, int len, int dump, void (*swabber)(void *))
{
- void *p;
- int i;
- int n;
- int do_swab;
- int inout = loc == RCL_CLIENT;
+ void *p;
+ int i;
+ int n;
+ int do_swab;
+ int inout = loc == RCL_CLIENT;
swabber = swabber ?: field->rmf_swabber;
@@ -1936,10 +1935,10 @@ static void *__req_capsule_get(struct req_capsule *pill,
int dump)
{
const struct req_format *fmt;
- struct lustre_msg *msg;
- void *value;
- int len;
- int offset;
+ struct lustre_msg *msg;
+ void *value;
+ int len;
+ int offset;
void *(*getter)(struct lustre_msg *m, int n, int minlen);
@@ -1996,55 +1995,6 @@ static void *__req_capsule_get(struct req_capsule *pill,
}
/**
- * Dump a request and/or reply
- */
-static void __req_capsule_dump(struct req_capsule *pill, enum req_location loc)
-{
- const struct req_format *fmt;
- const struct req_msg_field *field;
- int len;
- int i;
-
- fmt = pill->rc_fmt;
-
- DEBUG_REQ(D_RPCTRACE, pill->rc_req, "BEGIN REQ CAPSULE DUMP\n");
- for (i = 0; i < fmt->rf_fields[loc].nr; ++i) {
- field = FMT_FIELD(fmt, loc, i);
- if (field->rmf_dumper == NULL) {
- /*
- * FIXME Add a default hex dumper for fields that don't
- * have a specific dumper
- */
- len = req_capsule_get_size(pill, field, loc);
- CDEBUG(D_RPCTRACE, "Field %s has no dumper function; field size is %d\n",
- field->rmf_name, len);
- } else {
- /* It's the dumping side-effect that we're interested in */
- (void) __req_capsule_get(pill, field, loc, NULL, 1);
- }
- }
- CDEBUG(D_RPCTRACE, "END REQ CAPSULE DUMP\n");
-}
-
-/**
- * Dump a request.
- */
-void req_capsule_client_dump(struct req_capsule *pill)
-{
- __req_capsule_dump(pill, RCL_CLIENT);
-}
-EXPORT_SYMBOL(req_capsule_client_dump);
-
-/**
- * Dump a reply
- */
-void req_capsule_server_dump(struct req_capsule *pill)
-{
- __req_capsule_dump(pill, RCL_SERVER);
-}
-EXPORT_SYMBOL(req_capsule_server_dump);
-
-/**
* Trivial wrapper around __req_capsule_get(), that returns the PTLRPC request
* buffer corresponding to the given RMF (\a field) of a \a pill.
*/
@@ -2136,21 +2086,6 @@ void *req_capsule_server_sized_swab_get(struct req_capsule *pill,
EXPORT_SYMBOL(req_capsule_server_sized_swab_get);
/**
- * Returns the buffer of a \a pill corresponding to the given \a field from the
- * request (if the caller is executing on the server-side) or reply (if the
- * caller is executing on the client-side).
- *
- * This function convenient for use is code that could be executed on the
- * client and server alike.
- */
-const void *req_capsule_other_get(struct req_capsule *pill,
- const struct req_msg_field *field)
-{
- return __req_capsule_get(pill, field, pill->rc_loc ^ 1, NULL, 0);
-}
-EXPORT_SYMBOL(req_capsule_other_get);
-
-/**
* Set the size of the PTLRPC request/reply (\a loc) buffer for the given \a
* field of the given \a pill.
*
@@ -2324,9 +2259,9 @@ EXPORT_SYMBOL(req_capsule_has_field);
* Returns a non-zero value if the given \a field is present in the given \a
* pill's PTLRPC request or reply (\a loc), else it returns 0.
*/
-int req_capsule_field_present(const struct req_capsule *pill,
- const struct req_msg_field *field,
- enum req_location loc)
+static int req_capsule_field_present(const struct req_capsule *pill,
+ const struct req_msg_field *field,
+ enum req_location loc)
{
int offset;
@@ -2336,7 +2271,6 @@ int req_capsule_field_present(const struct req_capsule *pill,
offset = __req_capsule_offset(pill, field, loc);
return lustre_msg_bufcount(__req_msg(pill, loc)) > offset;
}
-EXPORT_SYMBOL(req_capsule_field_present);
/**
* This function shrinks the size of the _buffer_ of the \a pill's PTLRPC
@@ -2350,9 +2284,9 @@ void req_capsule_shrink(struct req_capsule *pill,
enum req_location loc)
{
const struct req_format *fmt;
- struct lustre_msg *msg;
- int len;
- int offset;
+ struct lustre_msg *msg;
+ int len;
+ int offset;
fmt = pill->rc_fmt;
LASSERT(fmt != NULL);
@@ -2376,67 +2310,5 @@ void req_capsule_shrink(struct req_capsule *pill,
}
EXPORT_SYMBOL(req_capsule_shrink);
-int req_capsule_server_grow(struct req_capsule *pill,
- const struct req_msg_field *field,
- unsigned int newlen)
-{
- struct ptlrpc_reply_state *rs = pill->rc_req->rq_reply_state, *nrs;
- char *from, *to;
- int offset, len, rc;
-
- LASSERT(pill->rc_fmt != NULL);
- LASSERT(__req_format_is_sane(pill->rc_fmt));
- LASSERT(req_capsule_has_field(pill, field, RCL_SERVER));
- LASSERT(req_capsule_field_present(pill, field, RCL_SERVER));
-
- len = req_capsule_get_size(pill, field, RCL_SERVER);
- offset = __req_capsule_offset(pill, field, RCL_SERVER);
- if (pill->rc_req->rq_repbuf_len >=
- lustre_packed_msg_size(pill->rc_req->rq_repmsg) - len + newlen)
- CERROR("Inplace repack might be done\n");
-
- pill->rc_req->rq_reply_state = NULL;
- req_capsule_set_size(pill, field, RCL_SERVER, newlen);
- rc = req_capsule_server_pack(pill);
- if (rc) {
- /* put old rs back, the caller will decide what to do */
- pill->rc_req->rq_reply_state = rs;
- return rc;
- }
- nrs = pill->rc_req->rq_reply_state;
- /* Now we need only buffers, copy first chunk */
- to = lustre_msg_buf(nrs->rs_msg, 0, 0);
- from = lustre_msg_buf(rs->rs_msg, 0, 0);
- len = (char *)lustre_msg_buf(rs->rs_msg, offset, 0) - from;
- memcpy(to, from, len);
- /* check if we have tail and copy it too */
- if (rs->rs_msg->lm_bufcount > offset + 1) {
- to = lustre_msg_buf(nrs->rs_msg, offset + 1, 0);
- from = lustre_msg_buf(rs->rs_msg, offset + 1, 0);
- offset = rs->rs_msg->lm_bufcount - 1;
- len = (char *)lustre_msg_buf(rs->rs_msg, offset, 0) +
- cfs_size_round(rs->rs_msg->lm_buflens[offset]) - from;
- memcpy(to, from, len);
- }
- /* drop old reply if everything is fine */
- if (rs->rs_difficult) {
- /* copy rs data */
- int i;
-
- nrs->rs_difficult = 1;
- nrs->rs_no_ack = rs->rs_no_ack;
- for (i = 0; i < rs->rs_nlocks; i++) {
- nrs->rs_locks[i] = rs->rs_locks[i];
- nrs->rs_modes[i] = rs->rs_modes[i];
- nrs->rs_nlocks++;
- }
- rs->rs_nlocks = 0;
- rs->rs_difficult = 0;
- rs->rs_no_ack = 0;
- }
- ptlrpc_rs_decref(rs);
- return 0;
-}
-EXPORT_SYMBOL(req_capsule_server_grow);
/* __REQ_LAYOUT_USER__ */
#endif
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
index e9baf5bbe..5122205cb 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
@@ -49,29 +49,29 @@
#include "../include/lustre_net.h"
#include <linux/list.h>
-#define LLOG_CLIENT_ENTRY(ctxt, imp) do { \
- mutex_lock(&ctxt->loc_mutex); \
- if (ctxt->loc_imp) { \
- imp = class_import_get(ctxt->loc_imp); \
- } else { \
- CERROR("ctxt->loc_imp == NULL for context idx %d." \
- "Unable to complete MDS/OSS recovery," \
- "but I'll try again next time. Not fatal.\n", \
- ctxt->loc_idx); \
- imp = NULL; \
- mutex_unlock(&ctxt->loc_mutex); \
- return (-EINVAL); \
- } \
- mutex_unlock(&ctxt->loc_mutex); \
+#define LLOG_CLIENT_ENTRY(ctxt, imp) do { \
+ mutex_lock(&ctxt->loc_mutex); \
+ if (ctxt->loc_imp) { \
+ imp = class_import_get(ctxt->loc_imp); \
+ } else { \
+ CERROR("ctxt->loc_imp == NULL for context idx %d." \
+ "Unable to complete MDS/OSS recovery," \
+ "but I'll try again next time. Not fatal.\n", \
+ ctxt->loc_idx); \
+ imp = NULL; \
+ mutex_unlock(&ctxt->loc_mutex); \
+ return (-EINVAL); \
+ } \
+ mutex_unlock(&ctxt->loc_mutex); \
} while (0)
-#define LLOG_CLIENT_EXIT(ctxt, imp) do { \
- mutex_lock(&ctxt->loc_mutex); \
- if (ctxt->loc_imp != imp) \
- CWARN("loc_imp has changed from %p to %p\n", \
- ctxt->loc_imp, imp); \
- class_import_put(imp); \
- mutex_unlock(&ctxt->loc_mutex); \
+#define LLOG_CLIENT_EXIT(ctxt, imp) do { \
+ mutex_lock(&ctxt->loc_mutex); \
+ if (ctxt->loc_imp != imp) \
+ CWARN("loc_imp has changed from %p to %p\n", \
+ ctxt->loc_imp, imp); \
+ class_import_put(imp); \
+ mutex_unlock(&ctxt->loc_mutex); \
} while (0)
/* This is a callback from the llog_* functions.
@@ -80,11 +80,11 @@ static int llog_client_open(const struct lu_env *env,
struct llog_handle *lgh, struct llog_logid *logid,
char *name, enum llog_open_param open_param)
{
- struct obd_import *imp;
- struct llogd_body *body;
- struct llog_ctxt *ctxt = lgh->lgh_ctxt;
+ struct obd_import *imp;
+ struct llogd_body *body;
+ struct llog_ctxt *ctxt = lgh->lgh_ctxt;
struct ptlrpc_request *req = NULL;
- int rc;
+ int rc;
LLOG_CLIENT_ENTRY(ctxt, imp);
@@ -118,6 +118,7 @@ static int llog_client_open(const struct lu_env *env,
if (name) {
char *tmp;
+
tmp = req_capsule_client_sized_get(&req->rq_pill, &RMF_NAME,
strlen(name) + 1);
LASSERT(tmp);
@@ -142,51 +143,16 @@ out:
return rc;
}
-static int llog_client_destroy(const struct lu_env *env,
- struct llog_handle *loghandle)
-{
- struct obd_import *imp;
- struct ptlrpc_request *req = NULL;
- struct llogd_body *body;
- int rc;
-
- LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp);
- req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_DESTROY,
- LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_HANDLE_DESTROY);
- if (req == NULL) {
- rc = -ENOMEM;
- goto err_exit;
- }
-
- body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
- body->lgd_logid = loghandle->lgh_id;
- body->lgd_llh_flags = loghandle->lgh_hdr->llh_flags;
-
- if (!(body->lgd_llh_flags & LLOG_F_IS_PLAIN))
- CERROR("%s: wrong llog flags %x\n", imp->imp_obd->obd_name,
- body->lgd_llh_flags);
-
- ptlrpc_request_set_replen(req);
- rc = ptlrpc_queue_wait(req);
-
- ptlrpc_req_finished(req);
-err_exit:
- LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp);
- return rc;
-}
-
-
static int llog_client_next_block(const struct lu_env *env,
struct llog_handle *loghandle,
int *cur_idx, int next_idx,
__u64 *cur_offset, void *buf, int len)
{
- struct obd_import *imp;
+ struct obd_import *imp;
struct ptlrpc_request *req = NULL;
- struct llogd_body *body;
- void *ptr;
- int rc;
+ struct llogd_body *body;
+ void *ptr;
+ int rc;
LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp);
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK,
@@ -240,11 +206,11 @@ static int llog_client_prev_block(const struct lu_env *env,
struct llog_handle *loghandle,
int prev_idx, void *buf, int len)
{
- struct obd_import *imp;
+ struct obd_import *imp;
struct ptlrpc_request *req = NULL;
- struct llogd_body *body;
- void *ptr;
- int rc;
+ struct llogd_body *body;
+ void *ptr;
+ int rc;
LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp);
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK,
@@ -292,12 +258,12 @@ err_exit:
static int llog_client_read_header(const struct lu_env *env,
struct llog_handle *handle)
{
- struct obd_import *imp;
+ struct obd_import *imp;
struct ptlrpc_request *req = NULL;
- struct llogd_body *body;
- struct llog_log_hdr *hdr;
- struct llog_rec_hdr *llh_hdr;
- int rc;
+ struct llogd_body *body;
+ struct llog_log_hdr *hdr;
+ struct llog_rec_hdr *llh_hdr;
+ int rc;
LLOG_CLIENT_ENTRY(handle->lgh_ctxt, imp);
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER,
@@ -360,7 +326,6 @@ struct llog_operations llog_client_ops = {
.lop_prev_block = llog_client_prev_block,
.lop_read_header = llog_client_read_header,
.lop_open = llog_client_open,
- .lop_destroy = llog_client_destroy,
.lop_close = llog_client_close,
};
EXPORT_SYMBOL(llog_client_ops);
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 9533ab976..afab0dee7 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -35,7 +35,6 @@
*/
#define DEBUG_SUBSYSTEM S_CLASS
-
#include "../include/obd_support.h"
#include "../include/obd.h"
#include "../include/lprocfs_status.h"
@@ -44,7 +43,6 @@
#include "../include/obd_class.h"
#include "ptlrpc_internal.h"
-
static struct ll_rpc_opcode {
__u32 opcode;
const char *opname;
@@ -54,7 +52,7 @@ static struct ll_rpc_opcode {
{ OST_SETATTR, "ost_setattr" },
{ OST_READ, "ost_read" },
{ OST_WRITE, "ost_write" },
- { OST_CREATE , "ost_create" },
+ { OST_CREATE, "ost_create" },
{ OST_DESTROY, "ost_destroy" },
{ OST_GET_INFO, "ost_get_info" },
{ OST_CONNECT, "ost_connect" },
@@ -166,6 +164,7 @@ const char *ll_opcode2str(__u32 opcode)
* ptlrpc_internal.h needs to be modified.
*/
__u32 offset = opcode_offset(opcode);
+
LASSERTF(offset < LUSTRE_MAX_OPCODES,
"offset %u >= LUSTRE_MAX_OPCODES %u\n",
offset, LUSTRE_MAX_OPCODES);
@@ -181,19 +180,19 @@ static const char *ll_eopcode2str(__u32 opcode)
return ll_eopcode_table[opcode].opname;
}
-#if defined(CONFIG_PROC_FS)
-static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
- char *name,
- struct proc_dir_entry **procroot_ret,
- struct lprocfs_stats **stats_ret)
+static void
+ptlrpc_ldebugfs_register(struct dentry *root, char *dir,
+ char *name,
+ struct dentry **debugfs_root_ret,
+ struct lprocfs_stats **stats_ret)
{
- struct proc_dir_entry *svc_procroot;
+ struct dentry *svc_debugfs_entry;
struct lprocfs_stats *svc_stats;
int i, rc;
unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX |
LPROCFS_CNTR_STDDEV;
- LASSERT(*procroot_ret == NULL);
+ LASSERT(*debugfs_root_ret == NULL);
LASSERT(*stats_ret == NULL);
svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES+LUSTRE_MAX_OPCODES,
@@ -201,14 +200,14 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
if (svc_stats == NULL)
return;
- if (dir) {
- svc_procroot = lprocfs_register(dir, root, NULL, NULL);
- if (IS_ERR(svc_procroot)) {
+ if (dir != NULL) {
+ svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL);
+ if (IS_ERR(svc_debugfs_entry)) {
lprocfs_free_stats(&svc_stats);
return;
}
} else {
- svc_procroot = root;
+ svc_debugfs_entry = root;
}
lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR,
@@ -239,19 +238,20 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
}
for (i = 0; i < LUSTRE_MAX_OPCODES; i++) {
__u32 opcode = ll_rpc_opcode_table[i].opcode;
+
lprocfs_counter_init(svc_stats,
EXTRA_MAX_OPCODES + i, svc_counter_config,
ll_opcode2str(opcode), "usec");
}
- rc = lprocfs_register_stats(svc_procroot, name, svc_stats);
+ rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats);
if (rc < 0) {
- if (dir)
- lprocfs_remove(&svc_procroot);
+ if (dir != NULL)
+ ldebugfs_remove(&svc_debugfs_entry);
lprocfs_free_stats(&svc_stats);
} else {
- if (dir)
- *procroot_ret = svc_procroot;
+ if (dir != NULL)
+ *debugfs_root_ret = svc_debugfs_entry;
*stats_ret = svc_stats;
}
}
@@ -261,8 +261,8 @@ ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v)
{
struct ptlrpc_service *svc = m->private;
struct ptlrpc_service_part *svcpt;
- int total = 0;
- int i;
+ int total = 0;
+ int i;
ptlrpc_service_for_each_part(svcpt, i, svc)
total += svcpt->scp_hist_nrqbds;
@@ -270,6 +270,7 @@ ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v)
seq_printf(m, "%d\n", total);
return 0;
}
+
LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_req_history_len);
static int
@@ -277,8 +278,8 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n)
{
struct ptlrpc_service *svc = m->private;
struct ptlrpc_service_part *svcpt;
- int total = 0;
- int i;
+ int total = 0;
+ int i;
ptlrpc_service_for_each_part(svcpt, i, svc)
total += svc->srv_hist_nrqbds_cpt_max;
@@ -289,13 +290,13 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n)
static ssize_t
ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- int bufpages;
- int val;
- int rc;
+ int bufpages;
+ int val;
+ int rc;
rc = lprocfs_write_helper(buffer, count, &val);
if (rc < 0)
@@ -322,25 +323,25 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
return count;
}
+
LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max);
-static int
-ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n)
+static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
- seq_printf(m, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts);
- return 0;
+ return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts);
}
-static ssize_t
-ptlrpc_lprocfs_threads_min_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t threads_min_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- int val;
- int rc = lprocfs_write_helper(buffer, count, &val);
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ unsigned long val;
+ int rc = kstrtoul(buffer, 10, &val);
if (rc < 0)
return rc;
@@ -360,41 +361,41 @@ ptlrpc_lprocfs_threads_min_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_min);
+LUSTRE_RW_ATTR(threads_min);
-static int
-ptlrpc_lprocfs_threads_started_seq_show(struct seq_file *m, void *n)
+static ssize_t threads_started_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
struct ptlrpc_service_part *svcpt;
- int total = 0;
- int i;
+ int total = 0;
+ int i;
ptlrpc_service_for_each_part(svcpt, i, svc)
total += svcpt->scp_nthrs_running;
- seq_printf(m, "%d\n", total);
- return 0;
+ return sprintf(buf, "%d\n", total);
}
-LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_threads_started);
+LUSTRE_RO_ATTR(threads_started);
-static int
-ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n)
+static ssize_t threads_max_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
- seq_printf(m, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts);
- return 0;
+ return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts);
}
-static ssize_t
-ptlrpc_lprocfs_threads_max_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t threads_max_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- int val;
- int rc = lprocfs_write_helper(buffer, count, &val);
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ unsigned long val;
+ int rc = kstrtoul(buffer, 10, &val);
if (rc < 0)
return rc;
@@ -414,13 +415,12 @@ ptlrpc_lprocfs_threads_max_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_max);
+LUSTRE_RW_ATTR(threads_max);
/**
* \addtogoup nrs
* @{
*/
-extern struct nrs_core nrs_core;
/**
* Translates \e ptlrpc_nrs_pol_state values to human-readable strings.
@@ -453,7 +453,7 @@ static const char *nrs_state2str(enum ptlrpc_nrs_pol_state state)
* \param[in] policy The policy
* \param[out] info Holds returned status information
*/
-void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy,
+static void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy,
struct ptlrpc_nrs_pol_info *info)
{
LASSERT(policy != NULL);
@@ -478,17 +478,17 @@ void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy,
*/
static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n)
{
- struct ptlrpc_service *svc = m->private;
- struct ptlrpc_service_part *svcpt;
- struct ptlrpc_nrs *nrs;
- struct ptlrpc_nrs_policy *policy;
- struct ptlrpc_nrs_pol_info *infos;
- struct ptlrpc_nrs_pol_info tmp;
- unsigned num_pols;
- unsigned pol_idx = 0;
- bool hp = false;
- int i;
- int rc = 0;
+ struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service_part *svcpt;
+ struct ptlrpc_nrs *nrs;
+ struct ptlrpc_nrs_policy *policy;
+ struct ptlrpc_nrs_pol_info *infos;
+ struct ptlrpc_nrs_pol_info tmp;
+ unsigned num_pols;
+ unsigned pol_idx = 0;
+ bool hp = false;
+ int i;
+ int rc = 0;
/**
* Serialize NRS core lprocfs operations with policy registration/
@@ -507,10 +507,10 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n)
num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols;
spin_unlock(&nrs->nrs_lock);
- OBD_ALLOC(infos, num_pols * sizeof(*infos));
+ infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS);
if (infos == NULL) {
rc = -ENOMEM;
- goto out;
+ goto unlock;
}
again:
@@ -617,10 +617,8 @@ again:
goto again;
}
-out:
- if (infos)
- OBD_FREE(infos, num_pols * sizeof(*infos));
-
+ kfree(infos);
+unlock:
mutex_unlock(&nrs_core.nrs_mutex);
return rc;
@@ -640,26 +638,22 @@ out:
* regular and high-priority (if the service has one) NRS head.
*/
static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- enum ptlrpc_nrs_queue_type queue = PTLRPC_NRS_QUEUE_BOTH;
- char *cmd;
- char *cmd_copy = NULL;
- char *token;
- int rc = 0;
+ enum ptlrpc_nrs_queue_type queue = PTLRPC_NRS_QUEUE_BOTH;
+ char *cmd;
+ char *cmd_copy = NULL;
+ char *token;
+ int rc = 0;
- if (count >= LPROCFS_NRS_WR_MAX_CMD) {
- rc = -EINVAL;
- goto out;
- }
+ if (count >= LPROCFS_NRS_WR_MAX_CMD)
+ return -EINVAL;
- OBD_ALLOC(cmd, LPROCFS_NRS_WR_MAX_CMD);
- if (cmd == NULL) {
- rc = -ENOMEM;
- goto out;
- }
+ cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
+ if (!cmd)
+ return -ENOMEM;
/**
* strsep() modifies its argument, so keep a copy
*/
@@ -716,11 +710,11 @@ default_queue:
mutex_unlock(&nrs_core.nrs_mutex);
out:
- if (cmd_copy)
- OBD_FREE(cmd_copy, LPROCFS_NRS_WR_MAX_CMD);
+ kfree(cmd_copy);
return rc < 0 ? rc : count;
}
+
LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs);
/** @} nrs */
@@ -736,8 +730,8 @@ ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt,
struct ptlrpc_srh_iterator *srhi,
__u64 seq)
{
- struct list_head *e;
- struct ptlrpc_request *req;
+ struct list_head *e;
+ struct ptlrpc_request *req;
if (srhi->srhi_req != NULL &&
srhi->srhi_seq > svcpt->scp_hist_seq_culled &&
@@ -825,8 +819,8 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
return NULL;
}
- OBD_ALLOC(srhi, sizeof(*srhi));
- if (srhi == NULL)
+ srhi = kzalloc(sizeof(*srhi), GFP_NOFS);
+ if (!srhi)
return NULL;
srhi->srhi_seq = 0;
@@ -851,7 +845,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
}
}
- OBD_FREE(srhi, sizeof(*srhi));
+ kfree(srhi);
return NULL;
}
@@ -860,20 +854,19 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter)
{
struct ptlrpc_srh_iterator *srhi = iter;
- if (srhi != NULL)
- OBD_FREE(srhi, sizeof(*srhi));
+ kfree(srhi);
}
static void *
ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
void *iter, loff_t *pos)
{
- struct ptlrpc_service *svc = s->private;
- struct ptlrpc_srh_iterator *srhi = iter;
- struct ptlrpc_service_part *svcpt;
- __u64 seq;
- int rc;
- int i;
+ struct ptlrpc_service *svc = s->private;
+ struct ptlrpc_srh_iterator *srhi = iter;
+ struct ptlrpc_service_part *svcpt;
+ __u64 seq;
+ int rc;
+ int i;
for (i = srhi->srhi_idx; i < svc->srv_ncpts; i++) {
svcpt = svc->srv_parts[i];
@@ -895,47 +888,17 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
}
}
- OBD_FREE(srhi, sizeof(*srhi));
+ kfree(srhi);
return NULL;
}
-/* common ost/mdt so_req_printer */
-void target_print_req(void *seq_file, struct ptlrpc_request *req)
-{
- /* Called holding srv_lock with irqs disabled.
- * Print specific req contents and a newline.
- * CAVEAT EMPTOR: check request message length before printing!!!
- * You might have received any old crap so you must be just as
- * careful here as the service's request parser!!! */
- struct seq_file *sf = seq_file;
-
- switch (req->rq_phase) {
- case RQ_PHASE_NEW:
- /* still awaiting a service thread's attention, or rejected
- * because the generic request message didn't unpack */
- seq_printf(sf, "<not swabbed>\n");
- break;
- case RQ_PHASE_INTERPRET:
- /* being handled, so basic msg swabbed, and opc is valid
- * but racing with mds_handle() */
- case RQ_PHASE_COMPLETE:
- /* been handled by mds_handle() reply state possibly still
- * volatile */
- seq_printf(sf, "opc %d\n", lustre_msg_get_opc(req->rq_reqmsg));
- break;
- default:
- DEBUG_REQ(D_ERROR, req, "bad phase %d", req->rq_phase);
- }
-}
-EXPORT_SYMBOL(target_print_req);
-
static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
{
- struct ptlrpc_service *svc = s->private;
- struct ptlrpc_srh_iterator *srhi = iter;
- struct ptlrpc_service_part *svcpt;
- struct ptlrpc_request *req;
- int rc;
+ struct ptlrpc_service *svc = s->private;
+ struct ptlrpc_srh_iterator *srhi = iter;
+ struct ptlrpc_service_part *svcpt;
+ struct ptlrpc_request *req;
+ int rc;
LASSERT(srhi->srhi_idx < svc->srv_ncpts);
@@ -946,23 +909,26 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, srhi->srhi_seq);
if (rc == 0) {
+ char nidstr[LNET_NIDSTR_SIZE];
+
req = srhi->srhi_req;
+ libcfs_nid2str_r(req->rq_self, nidstr, sizeof(nidstr));
/* Print common req fields.
* CAVEAT EMPTOR: we're racing with the service handler
* here. The request could contain any old crap, so you
* must be just as careful as the service's request
* parser. Currently I only print stuff here I know is OK
* to look at coz it was set up in request_in_callback()!!! */
- seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%ld:%lds(%+lds) ",
- req->rq_history_seq, libcfs_nid2str(req->rq_self),
+ seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%lld:%lds(%+lds) ",
+ req->rq_history_seq, nidstr,
libcfs_id2str(req->rq_peer), req->rq_xid,
req->rq_reqlen, ptlrpc_rqphase2str(req),
- req->rq_arrival_time.tv_sec,
- req->rq_sent - req->rq_arrival_time.tv_sec,
- req->rq_sent - req->rq_deadline);
+ (s64)req->rq_arrival_time.tv_sec,
+ (long)(req->rq_sent - req->rq_arrival_time.tv_sec),
+ (long)(req->rq_sent - req->rq_deadline));
if (svc->srv_ops.so_req_printer == NULL)
- seq_printf(s, "\n");
+ seq_putc(s, '\n');
else
svc->srv_ops.so_req_printer(s, srhi->srhi_req);
}
@@ -980,28 +946,28 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file)
.next = ptlrpc_lprocfs_svc_req_history_next,
.show = ptlrpc_lprocfs_svc_req_history_show,
};
- struct seq_file *seqf;
- int rc;
+ struct seq_file *seqf;
+ int rc;
rc = seq_open(file, &sops);
if (rc)
return rc;
seqf = file->private_data;
- seqf->private = PDE_DATA(inode);
+ seqf->private = inode->i_private;
return 0;
}
/* See also lprocfs_rd_timeouts */
static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n)
{
- struct ptlrpc_service *svc = m->private;
- struct ptlrpc_service_part *svcpt;
- struct dhms ts;
- time_t worstt;
- unsigned int cur;
- unsigned int worst;
- int i;
+ struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service_part *svcpt;
+ struct dhms ts;
+ time64_t worstt;
+ unsigned int cur;
+ unsigned int worst;
+ int i;
if (AT_OFF) {
seq_printf(m, "adaptive timeouts off, using obd_timeout %u\n",
@@ -1013,36 +979,40 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n)
cur = at_get(&svcpt->scp_at_estimate);
worst = svcpt->scp_at_estimate.at_worst_ever;
worstt = svcpt->scp_at_estimate.at_worst_time;
- s2dhms(&ts, get_seconds() - worstt);
+ s2dhms(&ts, ktime_get_real_seconds() - worstt);
- seq_printf(m, "%10s : cur %3u worst %3u (at %ld, "
+ seq_printf(m, "%10s : cur %3u worst %3u (at %lld, "
DHMS_FMT" ago) ", "service",
- cur, worst, worstt, DHMS_VARS(&ts));
+ cur, worst, (s64)worstt, DHMS_VARS(&ts));
lprocfs_at_hist_helper(m, &svcpt->scp_at_estimate);
}
return 0;
}
+
LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts);
-static int ptlrpc_lprocfs_hp_ratio_seq_show(struct seq_file *m, void *v)
+static ssize_t high_priority_ratio_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
- seq_printf(m, "%d", svc->srv_hpreq_ratio);
- return 0;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ return sprintf(buf, "%d\n", svc->srv_hpreq_ratio);
}
-static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file,
- const char __user *buffer,
- size_t count,
- loff_t *off)
+static ssize_t high_priority_ratio_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- int rc;
- int val;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ int rc;
+ int val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoint(buffer, 10, &val);
if (rc < 0)
return rc;
@@ -1055,30 +1025,62 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio);
+LUSTRE_RW_ATTR(high_priority_ratio);
+
+static struct attribute *ptlrpc_svc_attrs[] = {
+ &lustre_attr_threads_min.attr,
+ &lustre_attr_threads_started.attr,
+ &lustre_attr_threads_max.attr,
+ &lustre_attr_high_priority_ratio.attr,
+ NULL,
+};
+
+static void ptlrpc_sysfs_svc_release(struct kobject *kobj)
+{
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+
+ complete(&svc->srv_kobj_unregister);
+}
+
+static struct kobj_type ptlrpc_svc_ktype = {
+ .default_attrs = ptlrpc_svc_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = ptlrpc_sysfs_svc_release,
+};
-void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
- struct ptlrpc_service *svc)
+void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc)
+{
+ /* Let's see if we had a chance at initialization first */
+ if (svc->srv_kobj.kset) {
+ kobject_put(&svc->srv_kobj);
+ wait_for_completion(&svc->srv_kobj_unregister);
+ }
+}
+
+int ptlrpc_sysfs_register_service(struct kset *parent,
+ struct ptlrpc_service *svc)
+{
+ int rc;
+
+ svc->srv_kobj.kset = parent;
+ init_completion(&svc->srv_kobj_unregister);
+ rc = kobject_init_and_add(&svc->srv_kobj, &ptlrpc_svc_ktype, NULL,
+ "%s", svc->srv_name);
+
+ return rc;
+}
+
+void ptlrpc_ldebugfs_register_service(struct dentry *entry,
+ struct ptlrpc_service *svc)
{
struct lprocfs_vars lproc_vars[] = {
- {.name = "high_priority_ratio",
- .fops = &ptlrpc_lprocfs_hp_ratio_fops,
- .data = svc},
{.name = "req_buffer_history_len",
.fops = &ptlrpc_lprocfs_req_history_len_fops,
.data = svc},
{.name = "req_buffer_history_max",
.fops = &ptlrpc_lprocfs_req_history_max_fops,
.data = svc},
- {.name = "threads_min",
- .fops = &ptlrpc_lprocfs_threads_min_fops,
- .data = svc},
- {.name = "threads_max",
- .fops = &ptlrpc_lprocfs_threads_max_fops,
- .data = svc},
- {.name = "threads_started",
- .fops = &ptlrpc_lprocfs_threads_started_fops,
- .data = svc},
{.name = "timeouts",
.fops = &ptlrpc_lprocfs_timeouts_fops,
.data = svc},
@@ -1097,26 +1099,26 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
int rc;
- ptlrpc_lprocfs_register(entry, svc->srv_name,
- "stats", &svc->srv_procroot,
- &svc->srv_stats);
+ ptlrpc_ldebugfs_register(entry, svc->srv_name,
+ "stats", &svc->srv_debugfs_entry,
+ &svc->srv_stats);
- if (svc->srv_procroot == NULL)
+ if (svc->srv_debugfs_entry == NULL)
return;
- lprocfs_add_vars(svc->srv_procroot, lproc_vars, NULL);
+ ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL);
- rc = lprocfs_seq_create(svc->srv_procroot, "req_history",
- 0400, &req_history_fops, svc);
+ rc = ldebugfs_seq_create(svc->srv_debugfs_entry, "req_history",
+ 0400, &req_history_fops, svc);
if (rc)
CWARN("Error adding the req_history file\n");
}
void ptlrpc_lprocfs_register_obd(struct obd_device *obddev)
{
- ptlrpc_lprocfs_register(obddev->obd_proc_entry, NULL, "stats",
- &obddev->obd_svc_procroot,
- &obddev->obd_svc_stats);
+ ptlrpc_ldebugfs_register(obddev->obd_debugfs_entry, NULL, "stats",
+ &obddev->obd_svc_debugfs_entry,
+ &obddev->obd_svc_stats);
}
EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd);
@@ -1164,8 +1166,8 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw);
void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
{
- if (svc->srv_procroot != NULL)
- lprocfs_remove(&svc->srv_procroot);
+ if (svc->srv_debugfs_entry != NULL)
+ ldebugfs_remove(&svc->srv_debugfs_entry);
if (svc->srv_stats)
lprocfs_free_stats(&svc->srv_stats);
@@ -1173,63 +1175,14 @@ void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd)
{
- if (obd->obd_svc_procroot)
- lprocfs_remove(&obd->obd_svc_procroot);
+ if (!IS_ERR_OR_NULL(obd->obd_svc_debugfs_entry))
+ ldebugfs_remove(&obd->obd_svc_debugfs_entry);
if (obd->obd_svc_stats)
lprocfs_free_stats(&obd->obd_svc_stats);
}
EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
-
-#define BUFLEN (UUID_MAX + 5)
-
-int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
-{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- char *kbuf;
- char *tmpbuf;
-
- OBD_ALLOC(kbuf, BUFLEN);
- if (kbuf == NULL)
- return -ENOMEM;
-
- /*
- * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
- * bytes into kbuf, to ensure that the string is NUL-terminated.
- * UUID_MAX should include a trailing NUL already.
- */
- if (copy_from_user(kbuf, buffer,
- min_t(unsigned long, BUFLEN - 1, count))) {
- count = -EFAULT;
- goto out;
- }
- tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
- /* Kludge code(deadlock situation): the lprocfs lock has been held
- * since the client is evicted by writing client's
- * uuid/nid to procfs "evict_client" entry. However,
- * obd_export_evict_by_uuid() will call lprocfs_remove() to destroy
- * the proc entries under the being destroyed export{}, so I have
- * to drop the lock at first here.
- * - jay, jxiong@clusterfs.com */
- class_incref(obd, __func__, current);
-
- if (strncmp(tmpbuf, "nid:", 4) == 0)
- obd_export_evict_by_nid(obd, tmpbuf + 4);
- else if (strncmp(tmpbuf, "uuid:", 5) == 0)
- obd_export_evict_by_uuid(obd, tmpbuf + 5);
- else
- obd_export_evict_by_uuid(obd, tmpbuf);
-
- class_decref(obd, __func__, current);
-
-out:
- OBD_FREE(kbuf, BUFLEN);
- return count;
-}
-EXPORT_SYMBOL(lprocfs_wr_evict_client);
-
#undef BUFLEN
int lprocfs_wr_ping(struct file *file, const char __user *buffer,
@@ -1237,9 +1190,12 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer,
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct ptlrpc_request *req;
- int rc;
+ int rc;
+
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
- LPROCFS_CLIMP_CHECK(obd);
req = ptlrpc_prep_ping(obd->u.cli.cl_import);
LPROCFS_CLIMP_EXIT(obd);
if (req == NULL)
@@ -1275,8 +1231,8 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
if (count > PAGE_CACHE_SIZE - 1 || count <= prefix_len)
return -EINVAL;
- OBD_ALLOC(kbuf, count + 1);
- if (kbuf == NULL)
+ kbuf = kzalloc(count + 1, GFP_NOFS);
+ if (!kbuf)
return -ENOMEM;
if (copy_from_user(kbuf, buffer, count)) {
@@ -1301,7 +1257,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
*ptr = 0;
do_reconn = 0;
ptr += strlen("::");
- inst = simple_strtol(ptr, &endptr, 10);
+ inst = simple_strtoul(ptr, &endptr, 10);
if (*endptr) {
CERROR("config: wrong instance # %s\n", ptr);
} else if (inst != imp->imp_connect_data.ocd_instance) {
@@ -1319,7 +1275,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
ptlrpc_recover_import(imp, uuid, 1);
out:
- OBD_FREE(kbuf, count + 1);
+ kfree(kbuf);
return count;
}
EXPORT_SYMBOL(lprocfs_wr_import);
@@ -1328,8 +1284,12 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
{
struct obd_device *obd = m->private;
struct obd_import *imp = obd->u.cli.cl_import;
+ int rc;
+
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
- LPROCFS_CLIMP_CHECK(obd);
seq_printf(m, "%d\n", !imp->imp_no_pinger_recover);
LPROCFS_CLIMP_EXIT(obd);
@@ -1352,7 +1312,10 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
if (val != 0 && val != 1)
return -ERANGE;
- LPROCFS_CLIMP_CHECK(obd);
+ rc = lprocfs_climp_check(obd);
+ if (rc)
+ return rc;
+
spin_lock(&imp->imp_lock);
imp->imp_no_pinger_recover = !val;
spin_unlock(&imp->imp_lock);
@@ -1362,5 +1325,3 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
}
EXPORT_SYMBOL(lprocfs_wr_pinger_recov);
-
-#endif /* CONFIG_PROC_FS */
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
index 2fa258558..09ddeef6b 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
@@ -52,17 +52,17 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len,
struct ptlrpc_connection *conn, int portal, __u64 xid,
unsigned int offset)
{
- int rc;
- lnet_md_t md;
+ int rc;
+ lnet_md_t md;
LASSERT(portal != 0);
LASSERT(conn != NULL);
CDEBUG(D_INFO, "conn=%p id %s\n", conn, libcfs_id2str(conn->c_peer));
- md.start = base;
- md.length = len;
+ md.start = base;
+ md.length = len;
md.threshold = (ack == LNET_ACK_REQ) ? 2 : 1;
- md.options = PTLRPC_MD_OPTIONS;
- md.user_ptr = cbid;
+ md.options = PTLRPC_MD_OPTIONS;
+ md.user_ptr = cbid;
md.eq_handle = ptlrpc_eq_h;
if (unlikely(ack == LNET_ACK_REQ &&
@@ -106,12 +106,11 @@ static void mdunlink_iterate_helper(lnet_handle_md_t *bd_mds, int count)
LNetMDUnlink(bd_mds[i]);
}
-
/**
* Register bulk at the sender for later transfer.
* Returns 0 on success or error code.
*/
-int ptlrpc_register_bulk(struct ptlrpc_request *req)
+static int ptlrpc_register_bulk(struct ptlrpc_request *req)
{
struct ptlrpc_bulk_desc *desc = req->rq_bulk;
lnet_process_id_t peer;
@@ -120,8 +119,8 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req)
int posted_md;
int total_md;
__u64 xid;
- lnet_handle_me_t me_h;
- lnet_md_t md;
+ lnet_handle_me_t me_h;
+ lnet_md_t md;
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET))
return 0;
@@ -232,7 +231,6 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req)
return 0;
}
-EXPORT_SYMBOL(ptlrpc_register_bulk);
/**
* Disconnect a bulk desc from the network. Idempotent. Not
@@ -243,16 +241,16 @@ EXPORT_SYMBOL(ptlrpc_register_bulk);
int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async)
{
struct ptlrpc_bulk_desc *desc = req->rq_bulk;
- wait_queue_head_t *wq;
- struct l_wait_info lwi;
- int rc;
+ wait_queue_head_t *wq;
+ struct l_wait_info lwi;
+ int rc;
LASSERT(!in_interrupt()); /* might sleep */
/* Let's setup deadline for reply unlink. */
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) &&
async && req->rq_bulk_deadline == 0)
- req->rq_bulk_deadline = get_seconds() + LONG_UNLINK;
+ req->rq_bulk_deadline = ktime_get_real_seconds() + LONG_UNLINK;
if (ptlrpc_client_bulk_active(req) == 0) /* completed or */
return 1; /* never registered */
@@ -301,9 +299,9 @@ EXPORT_SYMBOL(ptlrpc_unregister_bulk);
static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags)
{
- struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
- struct ptlrpc_service *svc = svcpt->scp_service;
- int service_time = max_t(int, get_seconds() -
+ struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
+ struct ptlrpc_service *svc = svcpt->scp_service;
+ int service_time = max_t(int, ktime_get_real_seconds() -
req->rq_arrival_time.tv_sec, 1);
if (!(flags & PTLRPC_REPLY_EARLY) &&
@@ -328,8 +326,7 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags)
/* Report service time estimate for future client reqs, but report 0
* (to be ignored by client) if it's a error reply during recovery.
* (bz15815) */
- if (req->rq_type == PTL_RPC_MSG_ERR &&
- (req->rq_export == NULL || req->rq_export->exp_obd->obd_recovering))
+ if (req->rq_type == PTL_RPC_MSG_ERR && !req->rq_export)
lustre_msg_set_timeout(req->rq_repmsg, 0);
else
lustre_msg_set_timeout(req->rq_repmsg,
@@ -337,9 +334,8 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags)
if (req->rq_reqmsg &&
!(lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)) {
- CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x req_flags=%#x magic=%d:%x/%x len=%d\n",
+ CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x req_flags=%#x magic=%x/%x len=%d\n",
flags, lustre_msg_get_flags(req->rq_reqmsg),
- lustre_msg_is_v1(req->rq_reqmsg),
lustre_msg_get_magic(req->rq_reqmsg),
lustre_msg_get_magic(req->rq_repmsg), req->rq_replen);
}
@@ -353,8 +349,8 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags)
int ptlrpc_send_reply(struct ptlrpc_request *req, int flags)
{
struct ptlrpc_reply_state *rs = req->rq_reply_state;
- struct ptlrpc_connection *conn;
- int rc;
+ struct ptlrpc_connection *conn;
+ int rc;
/* We must already have a reply buffer (only ptlrpc_error() may be
* called without one). The reply generated by sptlrpc layer (e.g.
@@ -422,7 +418,7 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags)
if (unlikely(rc))
goto out;
- req->rq_sent = get_seconds();
+ req->rq_sent = ktime_get_real_seconds();
rc = ptl_send_buf(&rs->rs_md_h, rs->rs_repbuf, rs->rs_repdata_len,
(rs->rs_difficult && !rs->rs_no_ack) ?
@@ -491,8 +487,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
int rc2;
int mpflag = 0;
struct ptlrpc_connection *connection;
- lnet_handle_me_t reply_me_h;
- lnet_md_t reply_md;
+ lnet_handle_me_t reply_me_h;
+ lnet_md_t reply_md;
struct obd_device *obd = request->rq_import->imp_obd;
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DROP_RPC))
@@ -594,15 +590,15 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
spin_unlock(&request->rq_lock);
if (!noreply) {
- reply_md.start = request->rq_repbuf;
- reply_md.length = request->rq_repbuf_len;
+ reply_md.start = request->rq_repbuf;
+ reply_md.length = request->rq_repbuf_len;
/* Allow multiple early replies */
reply_md.threshold = LNET_MD_THRESH_INF;
/* Manage remote for early replies */
- reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT |
+ reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT |
LNET_MD_MANAGE_REMOTE |
- LNET_MD_TRUNCATE; /* allow to make EOVERFLOW error */;
- reply_md.user_ptr = &request->rq_reply_cbid;
+ LNET_MD_TRUNCATE; /* allow to make EOVERFLOW error */
+ reply_md.user_ptr = &request->rq_reply_cbid;
reply_md.eq_handle = ptlrpc_eq_h;
/* We must see the unlink callback to unset rq_reply_unlink,
@@ -633,8 +629,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5);
- do_gettimeofday(&request->rq_arrival_time);
- request->rq_sent = get_seconds();
+ ktime_get_real_ts64(&request->rq_arrival_time);
+ request->rq_sent = ktime_get_real_seconds();
/* We give the server rq_timeout secs to process the req, and
add the network latency for our local timeout. */
request->rq_deadline = request->rq_sent + request->rq_timeout +
@@ -682,11 +678,11 @@ EXPORT_SYMBOL(ptl_send_rpc);
*/
int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
{
- struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service;
- static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY};
- int rc;
- lnet_md_t md;
- lnet_handle_me_t me_h;
+ struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service;
+ static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY};
+ int rc;
+ lnet_md_t md;
+ lnet_handle_me_t me_h;
CDEBUG(D_NET, "LNetMEAttach: portal %d\n",
service->srv_req_portal);
@@ -709,12 +705,12 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
LASSERT(rqbd->rqbd_refcount == 0);
rqbd->rqbd_refcount = 1;
- md.start = rqbd->rqbd_buffer;
- md.length = service->srv_buf_size;
- md.max_size = service->srv_max_req_size;
+ md.start = rqbd->rqbd_buffer;
+ md.length = service->srv_buf_size;
+ md.max_size = service->srv_max_req_size;
md.threshold = LNET_MD_THRESH_INF;
- md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE;
- md.user_ptr = &rqbd->rqbd_cbid;
+ md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE;
+ md.user_ptr = &rqbd->rqbd_cbid;
md.eq_handle = ptlrpc_eq_h;
rc = LNetMDAttach(me_h, md, LNET_UNLINK, &rqbd->rqbd_md_h);
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs.c
index 81ad74732..7044e1ff6 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs.c
@@ -49,7 +49,6 @@
/* XXX: This is just for liblustre. Remove the #if defined directive when the
* "cfs_" prefix is dropped from cfs_list_head. */
-extern struct list_head ptlrpc_all_services;
/**
* NRS core object.
@@ -188,8 +187,8 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs)
*/
static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy)
{
- struct ptlrpc_nrs *nrs = policy->pol_nrs;
- int rc = 0;
+ struct ptlrpc_nrs *nrs = policy->pol_nrs;
+ int rc = 0;
/**
* Don't allow multiple starting which is too complex, and has no real
@@ -377,15 +376,15 @@ static void nrs_resource_put(struct ptlrpc_nrs_resource *res)
*/
static
struct ptlrpc_nrs_resource *nrs_resource_get(struct ptlrpc_nrs_policy *policy,
- struct ptlrpc_nrs_request *nrq,
- bool moving_req)
+ struct ptlrpc_nrs_request *nrq,
+ bool moving_req)
{
/**
* Set to NULL to traverse the resource hierarchy from the top.
*/
struct ptlrpc_nrs_resource *res = NULL;
struct ptlrpc_nrs_resource *tmp = NULL;
- int rc;
+ int rc;
while (1) {
rc = policy->pol_desc->pd_ops->op_res_get(policy, nrq, res,
@@ -432,8 +431,8 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs,
struct ptlrpc_nrs_resource **resp,
bool moving_req)
{
- struct ptlrpc_nrs_policy *primary = NULL;
- struct ptlrpc_nrs_policy *fallback = NULL;
+ struct ptlrpc_nrs_policy *primary = NULL;
+ struct ptlrpc_nrs_policy *fallback = NULL;
memset(resp, 0, sizeof(resp[0]) * NRS_RES_MAX);
@@ -478,14 +477,13 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs,
*
* \param resp the resource hierarchy that is being released
*
- * \see ptlrpcnrs_req_hp_move()
* \see ptlrpc_nrs_req_finalize()
*/
static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp)
{
struct ptlrpc_nrs_policy *pols[NRS_RES_MAX];
- struct ptlrpc_nrs *nrs = NULL;
- int i;
+ struct ptlrpc_nrs *nrs = NULL;
+ int i;
for (i = 0; i < NRS_RES_MAX; i++) {
if (resp[i] != NULL) {
@@ -530,7 +528,7 @@ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp)
*/
static inline
struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy,
- bool peek, bool force)
+ bool peek, bool force)
{
struct ptlrpc_nrs_request *nrq;
@@ -556,8 +554,8 @@ struct ptlrpc_nrs_request *nrs_request_get(struct ptlrpc_nrs_policy *policy,
static inline void nrs_request_enqueue(struct ptlrpc_nrs_request *nrq)
{
struct ptlrpc_nrs_policy *policy;
- int rc;
- int i;
+ int rc;
+ int i;
/**
* Try in descending order, because the primary policy (if any) is
@@ -628,8 +626,8 @@ static inline void nrs_request_stop(struct ptlrpc_nrs_request *nrq)
static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name,
enum ptlrpc_nrs_ctl opc, void *arg)
{
- struct ptlrpc_nrs_policy *policy;
- int rc = 0;
+ struct ptlrpc_nrs_policy *policy;
+ int rc = 0;
spin_lock(&nrs->nrs_lock);
@@ -715,7 +713,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name)
nrs_policy_fini(policy);
LASSERT(policy->pol_private == NULL);
- OBD_FREE_PTR(policy);
+ kfree(policy);
return 0;
}
@@ -733,10 +731,10 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name)
static int nrs_policy_register(struct ptlrpc_nrs *nrs,
struct ptlrpc_nrs_pol_desc *desc)
{
- struct ptlrpc_nrs_policy *policy;
- struct ptlrpc_nrs_policy *tmp;
- struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt;
- int rc;
+ struct ptlrpc_nrs_policy *policy;
+ struct ptlrpc_nrs_policy *tmp;
+ struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt;
+ int rc;
LASSERT(svcpt != NULL);
LASSERT(desc->pd_ops != NULL);
@@ -746,22 +744,23 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
LASSERT(desc->pd_ops->op_req_dequeue != NULL);
LASSERT(desc->pd_compat != NULL);
- OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable,
- svcpt->scp_cpt, sizeof(*policy), GFP_NOFS);
+ policy = kzalloc_node(sizeof(*policy), GFP_NOFS,
+ cfs_cpt_spread_node(svcpt->scp_service->srv_cptable,
+ svcpt->scp_cpt));
if (policy == NULL)
return -ENOMEM;
- policy->pol_nrs = nrs;
- policy->pol_desc = desc;
- policy->pol_state = NRS_POL_STATE_STOPPED;
- policy->pol_flags = desc->pd_flags;
+ policy->pol_nrs = nrs;
+ policy->pol_desc = desc;
+ policy->pol_state = NRS_POL_STATE_STOPPED;
+ policy->pol_flags = desc->pd_flags;
INIT_LIST_HEAD(&policy->pol_list);
INIT_LIST_HEAD(&policy->pol_list_queued);
rc = nrs_policy_init(policy);
if (rc != 0) {
- OBD_FREE_PTR(policy);
+ kfree(policy);
return rc;
}
@@ -776,7 +775,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
spin_unlock(&nrs->nrs_lock);
nrs_policy_fini(policy);
- OBD_FREE_PTR(policy);
+ kfree(policy);
return -EEXIST;
}
@@ -803,7 +802,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
*/
static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req)
{
- struct ptlrpc_nrs_policy *policy;
+ struct ptlrpc_nrs_policy *policy;
LASSERT(req->rq_nrq.nr_initialized);
LASSERT(!req->rq_nrq.nr_enqueued);
@@ -828,7 +827,7 @@ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req)
*/
static void ptlrpc_nrs_hpreq_add_nolock(struct ptlrpc_request *req)
{
- int opc = lustre_msg_get_opc(req->rq_reqmsg);
+ int opc = lustre_msg_get_opc(req->rq_reqmsg);
spin_lock(&req->rq_lock);
req->rq_hp = 1;
@@ -871,9 +870,9 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs)
{
struct ptlrpc_nrs_pol_desc *desc;
/* for convenience */
- struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt;
- struct ptlrpc_service *svc = svcpt->scp_service;
- int rc = -EINVAL;
+ struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt;
+ struct ptlrpc_service *svc = svcpt->scp_service;
+ int rc = -EINVAL;
LASSERT(mutex_is_locked(&nrs_core.nrs_mutex));
@@ -911,7 +910,7 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs)
static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs,
struct ptlrpc_service_part *svcpt)
{
- enum ptlrpc_nrs_queue_type queue;
+ enum ptlrpc_nrs_queue_type queue;
LASSERT(mutex_is_locked(&nrs_core.nrs_mutex));
@@ -942,8 +941,8 @@ static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs,
*/
static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt)
{
- struct ptlrpc_nrs *nrs;
- int rc;
+ struct ptlrpc_nrs *nrs;
+ int rc;
LASSERT(mutex_is_locked(&nrs_core.nrs_mutex));
@@ -961,9 +960,10 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt)
if (svcpt->scp_service->srv_ops.so_hpreq_handler == NULL)
goto out;
- OBD_CPT_ALLOC_PTR(svcpt->scp_nrs_hp,
- svcpt->scp_service->srv_cptable,
- svcpt->scp_cpt);
+ svcpt->scp_nrs_hp =
+ kzalloc_node(sizeof(*svcpt->scp_nrs_hp), GFP_NOFS,
+ cfs_cpt_spread_node(svcpt->scp_service->srv_cptable,
+ svcpt->scp_cpt));
if (svcpt->scp_nrs_hp == NULL) {
rc = -ENOMEM;
goto out;
@@ -986,11 +986,11 @@ out:
*/
static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt)
{
- struct ptlrpc_nrs *nrs;
- struct ptlrpc_nrs_policy *policy;
- struct ptlrpc_nrs_policy *tmp;
- int rc;
- bool hp = false;
+ struct ptlrpc_nrs *nrs;
+ struct ptlrpc_nrs_policy *policy;
+ struct ptlrpc_nrs_policy *tmp;
+ int rc;
+ bool hp = false;
LASSERT(mutex_is_locked(&nrs_core.nrs_mutex));
@@ -1013,7 +1013,7 @@ again:
}
if (hp)
- OBD_FREE_PTR(nrs);
+ kfree(nrs);
}
/**
@@ -1026,7 +1026,7 @@ again:
*/
static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name)
{
- struct ptlrpc_nrs_pol_desc *tmp;
+ struct ptlrpc_nrs_pol_desc *tmp;
list_for_each_entry(tmp, &nrs_core.nrs_policies, pd_list) {
if (strncmp(tmp->pd_name, name, NRS_POL_NAME_MAX) == 0)
@@ -1049,11 +1049,11 @@ static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name)
*/
static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc)
{
- struct ptlrpc_nrs *nrs;
- struct ptlrpc_service *svc;
- struct ptlrpc_service_part *svcpt;
- int i;
- int rc = 0;
+ struct ptlrpc_nrs *nrs;
+ struct ptlrpc_service *svc;
+ struct ptlrpc_service_part *svcpt;
+ int i;
+ int rc = 0;
LASSERT(mutex_is_locked(&nrs_core.nrs_mutex));
LASSERT(mutex_is_locked(&ptlrpc_all_services_mutex));
@@ -1111,11 +1111,11 @@ again:
* \retval -ve error
* \retval 0 success
*/
-int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
+static int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
{
- struct ptlrpc_service *svc;
- struct ptlrpc_nrs_pol_desc *desc;
- int rc = 0;
+ struct ptlrpc_service *svc;
+ struct ptlrpc_nrs_pol_desc *desc;
+ int rc = 0;
LASSERT(conf != NULL);
LASSERT(conf->nc_ops != NULL);
@@ -1153,19 +1153,19 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
goto fail;
}
- OBD_ALLOC_PTR(desc);
- if (desc == NULL) {
+ desc = kzalloc(sizeof(*desc), GFP_NOFS);
+ if (!desc) {
rc = -ENOMEM;
goto fail;
}
strncpy(desc->pd_name, conf->nc_name, NRS_POL_NAME_MAX);
- desc->pd_ops = conf->nc_ops;
- desc->pd_compat = conf->nc_compat;
+ desc->pd_ops = conf->nc_ops;
+ desc->pd_compat = conf->nc_compat;
desc->pd_compat_svc_name = conf->nc_compat_svc_name;
if ((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) != 0)
- desc->pd_owner = conf->nc_owner;
- desc->pd_flags = conf->nc_flags;
+ desc->pd_owner = conf->nc_owner;
+ desc->pd_flags = conf->nc_flags;
atomic_set(&desc->pd_refs, 0);
/**
@@ -1185,17 +1185,17 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
mutex_lock(&ptlrpc_all_services_mutex);
list_for_each_entry(svc, &ptlrpc_all_services, srv_list) {
- struct ptlrpc_service_part *svcpt;
- int i;
- int rc2;
+ struct ptlrpc_service_part *svcpt;
+ int i;
+ int rc2;
if (!nrs_policy_compatible(svc, desc) ||
unlikely(svc->srv_is_stopping))
continue;
ptlrpc_service_for_each_part(svcpt, i, svc) {
- struct ptlrpc_nrs *nrs;
- bool hp = false;
+ struct ptlrpc_nrs *nrs;
+ bool hp = false;
again:
nrs = nrs_svcpt2nrs(svcpt, hp);
rc = nrs_policy_register(nrs, desc);
@@ -1210,7 +1210,7 @@ again:
*/
LASSERT(rc2 == 0);
mutex_unlock(&ptlrpc_all_services_mutex);
- OBD_FREE_PTR(desc);
+ kfree(desc);
goto fail;
}
@@ -1233,7 +1233,7 @@ again:
*/
LASSERT(rc2 == 0);
mutex_unlock(&ptlrpc_all_services_mutex);
- OBD_FREE_PTR(desc);
+ kfree(desc);
goto fail;
}
}
@@ -1247,71 +1247,6 @@ fail:
return rc;
}
-EXPORT_SYMBOL(ptlrpc_nrs_policy_register);
-
-/**
- * Unregisters a previously registered policy with NRS core. All instances of
- * the policy on all NRS heads of all supported services are removed.
- *
- * N.B. This function should only be called from a module's exit() function.
- * Although it can be used for policies that ship alongside NRS core, the
- * function is primarily intended for policies that register externally,
- * from other modules.
- *
- * \param[in] conf configuration information for the policy to unregister
- *
- * \retval -ve error
- * \retval 0 success
- */
-int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf)
-{
- struct ptlrpc_nrs_pol_desc *desc;
- int rc;
-
- LASSERT(conf != NULL);
-
- if (conf->nc_flags & PTLRPC_NRS_FL_FALLBACK) {
- CERROR("Unable to unregister a fallback policy, unless the PTLRPC service is stopping.\n");
- return -EPERM;
- }
-
- conf->nc_name[NRS_POL_NAME_MAX - 1] = '\0';
-
- mutex_lock(&nrs_core.nrs_mutex);
-
- desc = nrs_policy_find_desc_locked(conf->nc_name);
- if (desc == NULL) {
- CERROR("Failing to unregister NRS policy %s which has not been registered with NRS core!\n",
- conf->nc_name);
- rc = -ENOENT;
- goto not_exist;
- }
-
- mutex_lock(&ptlrpc_all_services_mutex);
-
- rc = nrs_policy_unregister_locked(desc);
- if (rc < 0) {
- if (rc == -EBUSY)
- CERROR("Please first stop policy %s on all service partitions and then retry to unregister the policy.\n",
- conf->nc_name);
- goto fail;
- }
-
- CDEBUG(D_INFO, "Unregistering policy %s from NRS core.\n",
- conf->nc_name);
-
- list_del(&desc->pd_list);
- OBD_FREE_PTR(desc);
-
-fail:
- mutex_unlock(&ptlrpc_all_services_mutex);
-
-not_exist:
- mutex_unlock(&nrs_core.nrs_mutex);
-
- return rc;
-}
-EXPORT_SYMBOL(ptlrpc_nrs_policy_unregister);
/**
* Setup NRS heads on all service partitions of service \a svc, and register
@@ -1329,10 +1264,10 @@ EXPORT_SYMBOL(ptlrpc_nrs_policy_unregister);
*/
int ptlrpc_service_nrs_setup(struct ptlrpc_service *svc)
{
- struct ptlrpc_service_part *svcpt;
- const struct ptlrpc_nrs_pol_desc *desc;
- int i;
- int rc = 0;
+ struct ptlrpc_service_part *svcpt;
+ const struct ptlrpc_nrs_pol_desc *desc;
+ int i;
+ int rc = 0;
mutex_lock(&nrs_core.nrs_mutex);
@@ -1374,9 +1309,9 @@ failed:
*/
void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc)
{
- struct ptlrpc_service_part *svcpt;
- const struct ptlrpc_nrs_pol_desc *desc;
- int i;
+ struct ptlrpc_service_part *svcpt;
+ const struct ptlrpc_nrs_pol_desc *desc;
+ int i;
mutex_lock(&nrs_core.nrs_mutex);
@@ -1415,7 +1350,7 @@ void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc)
void ptlrpc_nrs_req_initialize(struct ptlrpc_service_part *svcpt,
struct ptlrpc_request *req, bool hp)
{
- struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp);
+ struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp);
memset(&req->rq_nrq, 0, sizeof(req->rq_nrq));
nrs_resource_get_safe(nrs, &req->rq_nrq, req->rq_nrq.nr_res_ptrs,
@@ -1523,8 +1458,8 @@ struct ptlrpc_request *
ptlrpc_nrs_req_get_nolock0(struct ptlrpc_service_part *svcpt, bool hp,
bool peek, bool force)
{
- struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp);
- struct ptlrpc_nrs_policy *policy;
+ struct ptlrpc_nrs *nrs = nrs_svcpt2nrs(svcpt, hp);
+ struct ptlrpc_nrs_policy *policy;
struct ptlrpc_nrs_request *nrq;
/**
@@ -1552,22 +1487,6 @@ ptlrpc_nrs_req_get_nolock0(struct ptlrpc_service_part *svcpt, bool hp,
}
/**
- * Dequeues request \a req from the policy it has been enqueued on.
- *
- * \param[in] req the request
- */
-void ptlrpc_nrs_req_del_nolock(struct ptlrpc_request *req)
-{
- struct ptlrpc_nrs_policy *policy = nrs_request_policy(&req->rq_nrq);
-
- policy->pol_desc->pd_ops->op_req_dequeue(policy, &req->rq_nrq);
-
- req->rq_nrq.nr_enqueued = 0;
-
- nrs_request_removed(policy);
-}
-
-/**
* Returns whether there are any requests currently enqueued on any of the
* policies of service partition's \a svcpt NRS head specified by \a hp. Should
* be called while holding ptlrpc_service_part::scp_req_lock to get a reliable
@@ -1588,48 +1507,6 @@ bool ptlrpc_nrs_req_pending_nolock(struct ptlrpc_service_part *svcpt, bool hp)
};
/**
- * Moves request \a req from the regular to the high-priority NRS head.
- *
- * \param[in] req the request to move
- */
-void ptlrpc_nrs_req_hp_move(struct ptlrpc_request *req)
-{
- struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
- struct ptlrpc_nrs_request *nrq = &req->rq_nrq;
- struct ptlrpc_nrs_resource *res1[NRS_RES_MAX];
- struct ptlrpc_nrs_resource *res2[NRS_RES_MAX];
-
- /**
- * Obtain the high-priority NRS head resources.
- */
- nrs_resource_get_safe(nrs_svcpt2nrs(svcpt, true), nrq, res1, true);
-
- spin_lock(&svcpt->scp_req_lock);
-
- if (!ptlrpc_nrs_req_can_move(req))
- goto out;
-
- ptlrpc_nrs_req_del_nolock(req);
-
- memcpy(res2, nrq->nr_res_ptrs, NRS_RES_MAX * sizeof(res2[0]));
- memcpy(nrq->nr_res_ptrs, res1, NRS_RES_MAX * sizeof(res1[0]));
-
- ptlrpc_nrs_hpreq_add_nolock(req);
-
- memcpy(res1, res2, NRS_RES_MAX * sizeof(res1[0]));
-out:
- spin_unlock(&svcpt->scp_req_lock);
-
- /**
- * Release either the regular NRS head resources if we moved the
- * request, or the high-priority NRS head resources if we took a
- * reference earlier in this function and ptlrpc_nrs_req_can_move()
- * returned false.
- */
- nrs_resource_put_safe(res1);
-}
-
-/**
* Carries out a control operation \a opc on the policy identified by the
* human-readable \a name, on either all partitions, or only on the first
* partition of service \a svc.
@@ -1659,9 +1536,9 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc,
enum ptlrpc_nrs_queue_type queue, char *name,
enum ptlrpc_nrs_ctl opc, bool single, void *arg)
{
- struct ptlrpc_service_part *svcpt;
- int i;
- int rc = 0;
+ struct ptlrpc_service_part *svcpt;
+ int i;
+ int rc = 0;
LASSERT(opc != PTLRPC_NRS_CTL_INVALID);
@@ -1696,7 +1573,6 @@ out:
return rc;
}
-
/* ptlrpc/nrs_fifo.c */
extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo;
@@ -1709,7 +1585,7 @@ extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo;
*/
int ptlrpc_nrs_init(void)
{
- int rc;
+ int rc;
mutex_init(&nrs_core.nrs_mutex);
INIT_LIST_HEAD(&nrs_core.nrs_policies);
@@ -1718,7 +1594,6 @@ int ptlrpc_nrs_init(void)
if (rc != 0)
goto fail;
-
return rc;
fail:
/**
@@ -1747,7 +1622,7 @@ void ptlrpc_nrs_fini(void)
list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies,
pd_list) {
list_del_init(&desc->pd_list);
- OBD_FREE_PTR(desc);
+ kfree(desc);
}
}
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
index eb40c01db..8e21f0cdc 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
@@ -80,7 +80,9 @@ static int nrs_fifo_start(struct ptlrpc_nrs_policy *policy)
{
struct nrs_fifo_head *head;
- OBD_CPT_ALLOC_PTR(head, nrs_pol2cptab(policy), nrs_pol2cptid(policy));
+ head = kzalloc_node(sizeof(*head), GFP_NOFS,
+ cfs_cpt_spread_node(nrs_pol2cptab(policy),
+ nrs_pol2cptid(policy)));
if (head == NULL)
return -ENOMEM;
@@ -105,7 +107,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy)
LASSERT(head != NULL);
LASSERT(list_empty(&head->fh_list));
- OBD_FREE_PTR(head);
+ kfree(head);
}
/**
@@ -158,9 +160,9 @@ static int nrs_fifo_res_get(struct ptlrpc_nrs_policy *policy,
*/
static
struct ptlrpc_nrs_request *nrs_fifo_req_get(struct ptlrpc_nrs_policy *policy,
- bool peek, bool force)
+ bool peek, bool force)
{
- struct nrs_fifo_head *head = policy->pol_private;
+ struct nrs_fifo_head *head = policy->pol_private;
struct ptlrpc_nrs_request *nrq;
nrq = unlikely(list_empty(&head->fh_list)) ? NULL :
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index b51af9bf3..f3cb5184f 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -52,6 +52,8 @@
#include "../include/obd_cksum.h"
#include "../include/lustre/ll_fiemap.h"
+#include "ptlrpc_internal.h"
+
static inline int lustre_msg_hdr_size_v2(int count)
{
return cfs_size_round(offsetof(struct lustre_msg_v2,
@@ -92,32 +94,11 @@ int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout,
}
EXPORT_SYMBOL(ptlrpc_buf_need_swab);
-static inline int lustre_msg_check_version_v2(struct lustre_msg_v2 *msg,
- __u32 version)
-{
- __u32 ver = lustre_msg_get_version(msg);
- return (ver & LUSTRE_VERSION_MASK) != version;
-}
-
-int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- CERROR("msg v1 not supported - please upgrade you system\n");
- return -EINVAL;
- case LUSTRE_MSG_MAGIC_V2:
- return lustre_msg_check_version_v2(msg, version);
- default:
- CERROR("incorrect message magic: %08x\n", msg->lm_magic);
- return 0;
- }
-}
-EXPORT_SYMBOL(lustre_msg_check_version);
-
/* early reply size */
int lustre_msg_early_size(void)
{
static int size;
+
if (!size) {
/* Always reply old ptlrpc_body_v2 to keep interoperability
* with the old client (< 2.3) which doesn't have pb_jobid
@@ -127,6 +108,7 @@ int lustre_msg_early_size(void)
* client.
*/
__u32 pblen = sizeof(struct ptlrpc_body_v2);
+
size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pblen);
}
return size;
@@ -207,6 +189,7 @@ void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens,
ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
for (i = 0; i < count; i++) {
char *tmp = bufs[i];
+
LOGL(tmp, lens[i], ptr);
}
}
@@ -279,8 +262,8 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt)
/* See if we have anything in a pool, and wait if nothing */
while (list_empty(&svcpt->scp_rep_idle)) {
- struct l_wait_info lwi;
- int rc;
+ struct l_wait_info lwi;
+ int rc;
spin_unlock(&svcpt->scp_rep_lock);
/* If we cannot get anything for some long time, we better
@@ -321,7 +304,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
__u32 *lens, char **bufs, int flags)
{
struct ptlrpc_reply_state *rs;
- int msg_len, rc;
+ int msg_len, rc;
LASSERT(req->rq_reply_state == NULL);
@@ -431,17 +414,18 @@ void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
case LUSTRE_MSG_MAGIC_V2:
return lustre_msg_buf_v2(m, n, min_size);
default:
- LASSERTF(0, "incorrect message magic: %08x(msg:%p)\n", m->lm_magic, m);
+ LASSERTF(0, "incorrect message magic: %08x (msg:%p)\n",
+ m->lm_magic, m);
return NULL;
}
}
EXPORT_SYMBOL(lustre_msg_buf);
-int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
- unsigned int newlen, int move_data)
+static int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
+ unsigned int newlen, int move_data)
{
- char *tail = NULL, *newpos;
- int tail_len = 0, n;
+ char *tail = NULL, *newpos;
+ int tail_len = 0, n;
LASSERT(msg);
LASSERT(msg->lm_bufcount > segment);
@@ -591,6 +575,7 @@ EXPORT_SYMBOL(__lustre_unpack_msg);
int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len)
{
int rc;
+
rc = __lustre_unpack_msg(req->rq_reqmsg, len);
if (rc == 1) {
lustre_set_req_swabbed(req, MSG_PTLRPC_HEADER_OFF);
@@ -603,6 +588,7 @@ EXPORT_SYMBOL(ptlrpc_unpack_req_msg);
int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len)
{
int rc;
+
rc = __lustre_unpack_msg(req->rq_repmsg, len);
if (rc == 1) {
lustre_set_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF);
@@ -690,28 +676,6 @@ int lustre_msg_buflen(struct lustre_msg *m, int n)
}
EXPORT_SYMBOL(lustre_msg_buflen);
-static inline void
-lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, int n, int len)
-{
- if (n >= m->lm_bufcount)
- LBUG();
-
- m->lm_buflens[n] = len;
-}
-
-void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len)
-{
- switch (m->lm_magic) {
- case LUSTRE_MSG_MAGIC_V2:
- lustre_msg_set_buflen_v2(m, n, len);
- return;
- default:
- LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
- }
-}
-
-EXPORT_SYMBOL(lustre_msg_set_buflen);
-
/* NB return the bufcount for lustre_msg_v2 format, so if message is packed
* in V1 format, the result is one bigger. (add struct ptlrpc_body). */
int lustre_msg_bufcount(struct lustre_msg *m)
@@ -800,14 +764,11 @@ static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg)
__u32 lustre_msghdr_get_flags(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- case LUSTRE_MSG_MAGIC_V1_SWABBED:
- return 0;
case LUSTRE_MSG_MAGIC_V2:
/* already in host endian */
return msg->lm_flags;
default:
- LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+ CERROR("incorrect message magic: %08x\n", msg->lm_magic);
return 0;
}
}
@@ -816,8 +777,6 @@ EXPORT_SYMBOL(lustre_msghdr_get_flags);
void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- return;
case LUSTRE_MSG_MAGIC_V2:
msg->lm_flags = flags;
return;
@@ -831,12 +790,13 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- if (!pb) {
- CERROR("invalid msg %p: no ptlrpc body!\n", msg);
- return 0;
- }
- return pb->pb_flags;
+
+ if (pb)
+ return pb->pb_flags;
+
+ CERROR("invalid msg %p: no ptlrpc body!\n", msg);
}
+ /* no break */
default:
/* flags might be printed in debug code while message
* uninitialized */
@@ -850,6 +810,7 @@ void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_flags |= flags;
return;
@@ -865,6 +826,7 @@ void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_flags = flags;
return;
@@ -880,8 +842,9 @@ void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
- pb->pb_flags &= ~(MSG_GEN_FLAG_MASK & flags);
+ pb->pb_flags &= ~(flags & MSG_GEN_FLAG_MASK);
return;
}
default:
@@ -895,12 +858,13 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- if (!pb) {
- CERROR("invalid msg %p: no ptlrpc body!\n", msg);
- return 0;
- }
- return pb->pb_op_flags;
+
+ if (pb)
+ return pb->pb_op_flags;
+
+ CERROR("invalid msg %p: no ptlrpc body!\n", msg);
}
+ /* no break */
default:
return 0;
}
@@ -912,21 +876,7 @@ void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
- pb->pb_op_flags |= flags;
- return;
- }
- default:
- LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
- }
-}
-EXPORT_SYMBOL(lustre_msg_add_op_flags);
-void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V2: {
- struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_op_flags |= flags;
return;
@@ -935,13 +885,14 @@ void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
}
}
-EXPORT_SYMBOL(lustre_msg_set_op_flags);
+EXPORT_SYMBOL(lustre_msg_add_op_flags);
struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return NULL;
@@ -960,6 +911,7 @@ __u32 lustre_msg_get_type(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return PTL_RPC_MSG_ERR;
@@ -973,29 +925,12 @@ __u32 lustre_msg_get_type(struct lustre_msg *msg)
}
EXPORT_SYMBOL(lustre_msg_get_type);
-__u32 lustre_msg_get_version(struct lustre_msg *msg)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V2: {
- struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- if (!pb) {
- CERROR("invalid msg %p: no ptlrpc body!\n", msg);
- return 0;
- }
- return pb->pb_version;
- }
- default:
- CERROR("incorrect message magic: %08x\n", msg->lm_magic);
- return 0;
- }
-}
-EXPORT_SYMBOL(lustre_msg_get_version);
-
void lustre_msg_add_version(struct lustre_msg *msg, int version)
{
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_version |= version;
return;
@@ -1011,6 +946,7 @@ __u32 lustre_msg_get_opc(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return 0;
@@ -1018,36 +954,19 @@ __u32 lustre_msg_get_opc(struct lustre_msg *msg)
return pb->pb_opc;
}
default:
- CERROR("incorrect message magic: %08x(msg:%p)\n", msg->lm_magic, msg);
- LBUG();
+ CERROR("incorrect message magic: %08x (msg:%p)\n",
+ msg->lm_magic, msg);
return 0;
}
}
EXPORT_SYMBOL(lustre_msg_get_opc);
-__u64 lustre_msg_get_last_xid(struct lustre_msg *msg)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V2: {
- struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- if (!pb) {
- CERROR("invalid msg %p: no ptlrpc body!\n", msg);
- return 0;
- }
- return pb->pb_last_xid;
- }
- default:
- CERROR("incorrect message magic: %08x\n", msg->lm_magic);
- return 0;
- }
-}
-EXPORT_SYMBOL(lustre_msg_get_last_xid);
-
__u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return 0;
@@ -1064,10 +983,9 @@ EXPORT_SYMBOL(lustre_msg_get_last_committed);
__u64 *lustre_msg_get_versions(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- return NULL;
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return NULL;
@@ -1086,6 +1004,7 @@ __u64 lustre_msg_get_transno(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return 0;
@@ -1104,12 +1023,13 @@ int lustre_msg_get_status(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- if (!pb) {
- CERROR("invalid msg %p: no ptlrpc body!\n", msg);
- return -EINVAL;
- }
- return pb->pb_status;
+
+ if (pb)
+ return pb->pb_status;
+
+ CERROR("invalid msg %p: no ptlrpc body!\n", msg);
}
+ /* no break */
default:
/* status might be printed in debug code while message
* uninitialized */
@@ -1123,6 +1043,7 @@ __u64 lustre_msg_get_slv(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return -EINVAL;
@@ -1136,12 +1057,12 @@ __u64 lustre_msg_get_slv(struct lustre_msg *msg)
}
EXPORT_SYMBOL(lustre_msg_get_slv);
-
void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
{
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return;
@@ -1161,6 +1082,7 @@ __u32 lustre_msg_get_limit(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return -EINVAL;
@@ -1174,12 +1096,12 @@ __u32 lustre_msg_get_limit(struct lustre_msg *msg)
}
EXPORT_SYMBOL(lustre_msg_get_limit);
-
void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
{
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return;
@@ -1199,6 +1121,7 @@ __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return 0;
@@ -1212,18 +1135,6 @@ __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
}
EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
-int lustre_msg_is_v1(struct lustre_msg *msg)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- case LUSTRE_MSG_MAGIC_V1_SWABBED:
- return 1;
- default:
- return 0;
- }
-}
-EXPORT_SYMBOL(lustre_msg_is_v1);
-
__u32 lustre_msg_get_magic(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
@@ -1239,11 +1150,9 @@ EXPORT_SYMBOL(lustre_msg_get_magic);
__u32 lustre_msg_get_timeout(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- case LUSTRE_MSG_MAGIC_V1_SWABBED:
- return 0;
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return 0;
@@ -1253,18 +1162,16 @@ __u32 lustre_msg_get_timeout(struct lustre_msg *msg)
}
default:
CERROR("incorrect message magic: %08x\n", msg->lm_magic);
- return 0;
+ return -EPROTO;
}
}
__u32 lustre_msg_get_service_time(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- case LUSTRE_MSG_MAGIC_V1_SWABBED:
- return 0;
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
if (!pb) {
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
return 0;
@@ -1278,28 +1185,6 @@ __u32 lustre_msg_get_service_time(struct lustre_msg *msg)
}
}
-char *lustre_msg_get_jobid(struct lustre_msg *msg)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- case LUSTRE_MSG_MAGIC_V1_SWABBED:
- return NULL;
- case LUSTRE_MSG_MAGIC_V2: {
- struct ptlrpc_body *pb =
- lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
- sizeof(struct ptlrpc_body));
- if (!pb)
- return NULL;
-
- return pb->pb_jobid;
- }
- default:
- CERROR("incorrect message magic: %08x\n", msg->lm_magic);
- return NULL;
- }
-}
-EXPORT_SYMBOL(lustre_msg_get_jobid);
-
__u32 lustre_msg_get_cksum(struct lustre_msg *msg)
{
switch (msg->lm_magic) {
@@ -1318,6 +1203,7 @@ __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
__u32 crc;
unsigned int hsize = 4;
+
cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF),
NULL, 0, (unsigned char *)&crc, &hsize);
@@ -1334,6 +1220,7 @@ void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_handle = *handle;
return;
@@ -1349,6 +1236,7 @@ void lustre_msg_set_type(struct lustre_msg *msg, __u32 type)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_type = type;
return;
@@ -1364,6 +1252,7 @@ void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_opc = opc;
return;
@@ -1374,43 +1263,12 @@ void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc)
}
EXPORT_SYMBOL(lustre_msg_set_opc);
-void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V2: {
- struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
- pb->pb_last_xid = last_xid;
- return;
- }
- default:
- LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
- }
-}
-EXPORT_SYMBOL(lustre_msg_set_last_xid);
-
-void lustre_msg_set_last_committed(struct lustre_msg *msg, __u64 last_committed)
-{
- switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V2: {
- struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
- LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
- pb->pb_last_committed = last_committed;
- return;
- }
- default:
- LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
- }
-}
-EXPORT_SYMBOL(lustre_msg_set_last_committed);
-
void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- return;
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_pre_versions[0] = versions[0];
pb->pb_pre_versions[1] = versions[1];
@@ -1429,6 +1287,7 @@ void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_transno = transno;
return;
@@ -1444,6 +1303,7 @@ void lustre_msg_set_status(struct lustre_msg *msg, __u32 status)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_status = status;
return;
@@ -1459,6 +1319,7 @@ void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt)
switch (msg->lm_magic) {
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_conn_cnt = conn_cnt;
return;
@@ -1472,10 +1333,9 @@ EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- return;
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_timeout = timeout;
return;
@@ -1488,10 +1348,9 @@ void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- return;
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
pb->pb_service_time = service_time;
return;
@@ -1504,8 +1363,6 @@ void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time)
void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- return;
case LUSTRE_MSG_MAGIC_V2: {
__u32 opc = lustre_msg_get_opc(msg);
struct ptlrpc_body *pb;
@@ -1535,8 +1392,6 @@ EXPORT_SYMBOL(lustre_msg_set_jobid);
void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
{
switch (msg->lm_magic) {
- case LUSTRE_MSG_MAGIC_V1:
- return;
case LUSTRE_MSG_MAGIC_V2:
msg->lm_cksum = cksum;
return;
@@ -1545,7 +1400,6 @@ void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
}
}
-
void ptlrpc_request_set_replen(struct ptlrpc_request *req)
{
int count = req_capsule_filled_sizes(&req->rq_pill, RCL_SERVER);
@@ -1557,14 +1411,6 @@ void ptlrpc_request_set_replen(struct ptlrpc_request *req)
}
EXPORT_SYMBOL(ptlrpc_request_set_replen);
-void ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, __u32 *lens)
-{
- req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
- if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
- req->rq_reqmsg->lm_repsize = req->rq_replen;
-}
-EXPORT_SYMBOL(ptlrpc_req_set_repsize);
-
/**
* Send a remote set_info_async.
*
@@ -1577,8 +1423,8 @@ int do_set_info_async(struct obd_import *imp,
struct ptlrpc_request_set *set)
{
struct ptlrpc_request *req;
- char *tmp;
- int rc;
+ char *tmp;
+ int rc;
req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
if (req == NULL)
@@ -1688,7 +1534,7 @@ void lustre_swab_connect(struct obd_connect_data *ocd)
CLASSERT(offsetof(typeof(*ocd), paddingF) != 0);
}
-void lustre_swab_obdo(struct obdo *o)
+static void lustre_swab_obdo(struct obdo *o)
{
__swab64s(&o->o_valid);
lustre_swab_ost_id(&o->o_oi);
@@ -1720,7 +1566,6 @@ void lustre_swab_obdo(struct obdo *o)
CLASSERT(offsetof(typeof(*o), o_padding_6) != 0);
}
-EXPORT_SYMBOL(lustre_swab_obdo);
void lustre_swab_obd_statfs(struct obd_statfs *os)
{
@@ -1872,6 +1717,7 @@ EXPORT_SYMBOL(lustre_swab_mdt_ioepoch);
void lustre_swab_mgs_target_info(struct mgs_target_info *mti)
{
int i;
+
__swab32s(&mti->mti_lustre_ver);
__swab32s(&mti->mti_stripe_index);
__swab32s(&mti->mti_config_ver);
@@ -1977,7 +1823,7 @@ void lustre_swab_fid2path(struct getinfo_fid2path *gf)
}
EXPORT_SYMBOL(lustre_swab_fid2path);
-void lustre_swab_fiemap_extent(struct ll_fiemap_extent *fm_extent)
+static void lustre_swab_fiemap_extent(struct ll_fiemap_extent *fm_extent)
{
__swab64s(&fm_extent->fe_logical);
__swab64s(&fm_extent->fe_physical);
@@ -2016,15 +1862,6 @@ void lustre_swab_idx_info(struct idx_info *ii)
__swab16s(&ii->ii_recsize);
}
-void lustre_swab_lip_header(struct lu_idxpage *lip)
-{
- /* swab header */
- __swab32s(&lip->lip_magic);
- __swab16s(&lip->lip_flags);
- __swab16s(&lip->lip_nr);
-}
-EXPORT_SYMBOL(lustre_swab_lip_header);
-
void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr)
{
__swab32s(&rr->rr_opcode);
@@ -2067,46 +1904,6 @@ void lustre_swab_lov_desc(struct lov_desc *ld)
}
EXPORT_SYMBOL(lustre_swab_lov_desc);
-void lustre_swab_lmv_desc(struct lmv_desc *ld)
-{
- __swab32s(&ld->ld_tgt_count);
- __swab32s(&ld->ld_active_tgt_count);
- __swab32s(&ld->ld_default_stripe_count);
- __swab32s(&ld->ld_pattern);
- __swab64s(&ld->ld_default_hash_size);
- __swab32s(&ld->ld_qos_maxage);
- /* uuid endian insensitive */
-}
-
-void lustre_swab_lmv_stripe_md(struct lmv_stripe_md *mea)
-{
- __swab32s(&mea->mea_magic);
- __swab32s(&mea->mea_count);
- __swab32s(&mea->mea_master);
- CLASSERT(offsetof(typeof(*mea), mea_padding) != 0);
-}
-
-void lustre_swab_lmv_user_md(struct lmv_user_md *lum)
-{
- int i;
-
- __swab32s(&lum->lum_magic);
- __swab32s(&lum->lum_stripe_count);
- __swab32s(&lum->lum_stripe_offset);
- __swab32s(&lum->lum_hash_type);
- __swab32s(&lum->lum_type);
- CLASSERT(offsetof(typeof(*lum), lum_padding1) != 0);
- CLASSERT(offsetof(typeof(*lum), lum_padding2) != 0);
- CLASSERT(offsetof(typeof(*lum), lum_padding3) != 0);
-
- for (i = 0; i < lum->lum_stripe_count; i++) {
- __swab32s(&lum->lum_objects[i].lum_mds);
- lustre_swab_lu_fid(&lum->lum_objects[i].lum_fid);
- }
-
-}
-EXPORT_SYMBOL(lustre_swab_lmv_user_md);
-
static void print_lum(struct lov_user_md *lum)
{
CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
@@ -2177,16 +1974,15 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
}
EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
-void lustre_swab_ldlm_res_id(struct ldlm_res_id *id)
+static void lustre_swab_ldlm_res_id(struct ldlm_res_id *id)
{
- int i;
+ int i;
for (i = 0; i < RES_NAME_SIZE; i++)
__swab64s(&id->name[i]);
}
-EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
-void lustre_swab_ldlm_policy_data(ldlm_wire_policy_data_t *d)
+static void lustre_swab_ldlm_policy_data(ldlm_wire_policy_data_t *d)
{
/* the lock data is a union and the first two fields are always an
* extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock
@@ -2197,7 +1993,6 @@ void lustre_swab_ldlm_policy_data(ldlm_wire_policy_data_t *d)
__swab64s(&d->l_flock.lfw_owner);
__swab32s(&d->l_flock.lfw_pid);
}
-EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
void lustre_swab_ldlm_intent(struct ldlm_intent *i)
{
@@ -2205,22 +2000,20 @@ void lustre_swab_ldlm_intent(struct ldlm_intent *i)
}
EXPORT_SYMBOL(lustre_swab_ldlm_intent);
-void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r)
+static void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r)
{
__swab32s(&r->lr_type);
CLASSERT(offsetof(typeof(*r), lr_padding) != 0);
lustre_swab_ldlm_res_id(&r->lr_name);
}
-EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
-void lustre_swab_ldlm_lock_desc(struct ldlm_lock_desc *l)
+static void lustre_swab_ldlm_lock_desc(struct ldlm_lock_desc *l)
{
lustre_swab_ldlm_resource_desc(&l->l_resource);
__swab32s(&l->l_req_mode);
__swab32s(&l->l_granted_mode);
lustre_swab_ldlm_policy_data(&l->l_policy_data);
}
-EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
void lustre_swab_ldlm_request(struct ldlm_request *rq)
{
@@ -2269,7 +2062,7 @@ void dump_rniobuf(struct niobuf_remote *nb)
}
EXPORT_SYMBOL(dump_rniobuf);
-void dump_obdo(struct obdo *oa)
+static void dump_obdo(struct obdo *oa)
{
__u32 valid = oa->o_valid;
@@ -2330,7 +2123,6 @@ void dump_obdo(struct obdo *oa)
if (valid & OBD_MD_FLCOOKIE)
CDEBUG(D_RPCTRACE, "obdo: o_lcookie = (llog_cookie dumping not yet implemented)\n");
}
-EXPORT_SYMBOL(dump_obdo);
void dump_ost_body(struct ost_body *ob)
{
@@ -2392,7 +2184,7 @@ void _debug_req(struct ptlrpc_request *req,
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 %d dl " CFS_TIME_T " ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n",
+ " 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,
@@ -2404,8 +2196,8 @@ void _debug_req(struct ptlrpc_request *req,
libcfs_nid2str(nid),
req->rq_request_portal, req->rq_reply_portal,
req->rq_reqlen, req->rq_replen,
- req->rq_early_count, req->rq_timedout,
- req->rq_deadline,
+ 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,
@@ -2429,14 +2221,6 @@ void lustre_swab_lustre_capa(struct lustre_capa *c)
}
EXPORT_SYMBOL(lustre_swab_lustre_capa);
-void lustre_swab_lustre_capa_key(struct lustre_capa_key *k)
-{
- __swab64s(&k->lk_seq);
- __swab32s(&k->lk_keyid);
- CLASSERT(offsetof(typeof(*k), lk_padding) != 0);
-}
-EXPORT_SYMBOL(lustre_swab_lustre_capa_key);
-
void lustre_swab_hsm_user_state(struct hsm_user_state *state)
{
__swab32s(&state->hus_states);
@@ -2453,7 +2237,7 @@ void lustre_swab_hsm_state_set(struct hsm_state_set *hss)
}
EXPORT_SYMBOL(lustre_swab_hsm_state_set);
-void lustre_swab_hsm_extent(struct hsm_extent *extent)
+static void lustre_swab_hsm_extent(struct hsm_extent *extent)
{
__swab64s(&extent->offset);
__swab64s(&extent->length);
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/pers.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/pers.c
index e1334c24e..2a2a9fb65 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/pers.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/pers.c
@@ -42,7 +42,6 @@
#include "ptlrpc_internal.h"
-
void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc,
int mdidx)
{
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 9dbda9332..5c719f175 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -44,20 +44,10 @@
#include "../include/obd_class.h"
#include "ptlrpc_internal.h"
-static int suppress_pings;
-module_param(suppress_pings, int, 0644);
-MODULE_PARM_DESC(suppress_pings, "Suppress pings");
-
struct mutex pinger_mutex;
static LIST_HEAD(pinger_imports);
static struct list_head timeout_list = LIST_HEAD_INIT(timeout_list);
-int ptlrpc_pinger_suppress_pings(void)
-{
- return suppress_pings;
-}
-EXPORT_SYMBOL(ptlrpc_pinger_suppress_pings);
-
struct ptlrpc_request *
ptlrpc_prep_ping(struct obd_import *imp)
{
@@ -91,7 +81,7 @@ int ptlrpc_obd_ping(struct obd_device *obd)
}
EXPORT_SYMBOL(ptlrpc_obd_ping);
-int ptlrpc_ping(struct obd_import *imp)
+static int ptlrpc_ping(struct obd_import *imp)
{
struct ptlrpc_request *req;
@@ -105,14 +95,15 @@ int ptlrpc_ping(struct obd_import *imp)
DEBUG_REQ(D_INFO, req, "pinging %s->%s",
imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
- ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
+ ptlrpcd_add_req(req);
return 0;
}
-void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
+static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
{
int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL;
+
if (imp->imp_state == LUSTRE_IMP_DISCON) {
int dtime = max_t(int, CONNECTION_SWITCH_MIN,
AT_OFF ? 0 :
@@ -122,11 +113,6 @@ void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
imp->imp_next_ping = cfs_time_shift(time);
}
-void ptlrpc_ping_import_soon(struct obd_import *imp)
-{
- imp->imp_next_ping = cfs_time_current();
-}
-
static inline int imp_is_deactive(struct obd_import *imp)
{
return (imp->imp_deactive ||
@@ -141,7 +127,7 @@ static inline int ptlrpc_next_reconnect(struct obd_import *imp)
return cfs_time_shift(obd_timeout);
}
-long pinger_check_timeout(unsigned long time)
+static long pinger_check_timeout(unsigned long time)
{
struct timeout_item *item;
unsigned long timeout = PING_INTERVAL;
@@ -150,6 +136,7 @@ long pinger_check_timeout(unsigned long time)
mutex_lock(&pinger_mutex);
list_for_each_entry(item, &timeout_list, ti_chain) {
int ti_timeout = item->ti_timeout;
+
if (timeout > ti_timeout)
timeout = ti_timeout;
break;
@@ -234,7 +221,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
static int ptlrpc_pinger_main(void *arg)
{
- struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
+ struct ptlrpc_thread *thread = arg;
/* Record that the thread is running */
thread_set_flags(thread, SVC_RUNNING);
@@ -266,8 +253,6 @@ static int ptlrpc_pinger_main(void *arg)
ptlrpc_update_next_ping(imp, 0);
}
mutex_unlock(&pinger_mutex);
- /* update memory usage info */
- obd_update_maxusage();
/* Wait until the next ping time, or until we're stopped. */
time_to_next_wake = pinger_check_timeout(this_ping);
@@ -277,8 +262,8 @@ static int ptlrpc_pinger_main(void *arg)
next ping time to next_ping + .01 sec, which means
we will SKIP the next ping at next_ping, and the
ping will get sent 2 timeouts from now! Beware. */
- CDEBUG(D_INFO, "next wakeup in "CFS_DURATION_T" ("
- CFS_TIME_T")\n", time_to_next_wake,
+ CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
+ time_to_next_wake,
cfs_time_add(this_ping,
cfs_time_seconds(PING_INTERVAL)));
if (time_to_next_wake > 0) {
@@ -289,12 +274,10 @@ static int ptlrpc_pinger_main(void *arg)
thread_is_stopping(thread) ||
thread_is_event(thread),
&lwi);
- if (thread_test_and_clear_flags(thread, SVC_STOPPING)) {
+ if (thread_test_and_clear_flags(thread, SVC_STOPPING))
break;
- } else {
- /* woken after adding import to reset timer */
- thread_test_and_clear_flags(thread, SVC_EVENT);
- }
+ /* woken after adding import to reset timer */
+ thread_test_and_clear_flags(thread, SVC_EVENT);
}
}
@@ -320,8 +303,6 @@ int ptlrpc_start_pinger(void)
strcpy(pinger_thread.t_name, "ll_ping");
- /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
- * just drop the VM and FILES in cfs_daemonize_ctxt() right away. */
rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, &pinger_thread,
"%s", pinger_thread.t_name));
if (IS_ERR_VALUE(rc)) {
@@ -331,13 +312,10 @@ int ptlrpc_start_pinger(void)
l_wait_event(pinger_thread.t_ctl_waitq,
thread_is_running(&pinger_thread), &lwi);
- if (suppress_pings)
- CWARN("Pings will be suppressed at the request of the administrator. The configuration shall meet the additional requirements described in the manual. (Search for the \"suppress_pings\" kernel module parameter.)\n");
-
return 0;
}
-int ptlrpc_pinger_remove_timeouts(void);
+static int ptlrpc_pinger_remove_timeouts(void);
int ptlrpc_stop_pinger(void)
{
@@ -422,12 +400,12 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import);
* Register a timeout callback to the pinger list, and the callback will
* be called when timeout happens.
*/
-struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event,
- timeout_cb_t cb, void *data)
+static struct timeout_item *ptlrpc_new_timeout(int time,
+ enum timeout_event event, timeout_cb_t cb, void *data)
{
struct timeout_item *ti;
- OBD_ALLOC_PTR(ti);
+ ti = kzalloc(sizeof(*ti), GFP_NOFS);
if (!ti)
return NULL;
@@ -514,14 +492,14 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list,
LASSERTF(ti != NULL, "ti is NULL !\n");
if (list_empty(&ti->ti_obd_list)) {
list_del(&ti->ti_chain);
- OBD_FREE_PTR(ti);
+ kfree(ti);
}
mutex_unlock(&pinger_mutex);
return 0;
}
EXPORT_SYMBOL(ptlrpc_del_timeout_client);
-int ptlrpc_pinger_remove_timeouts(void)
+static int ptlrpc_pinger_remove_timeouts(void)
{
struct timeout_item *item, *tmp;
@@ -529,7 +507,7 @@ int ptlrpc_pinger_remove_timeouts(void)
list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) {
LASSERT(list_empty(&item->ti_obd_list));
list_del(&item->ti_chain);
- OBD_FREE_PTR(item);
+ kfree(item);
}
mutex_unlock(&pinger_mutex);
return 0;
@@ -540,139 +518,3 @@ void ptlrpc_pinger_wake_up(void)
thread_add_flags(&pinger_thread, SVC_EVENT);
wake_up(&pinger_thread.t_ctl_waitq);
}
-
-/* Ping evictor thread */
-#define PET_READY 1
-#define PET_TERMINATE 2
-
-static int pet_refcount;
-static int pet_state;
-static wait_queue_head_t pet_waitq;
-LIST_HEAD(pet_list);
-static DEFINE_SPINLOCK(pet_lock);
-
-int ping_evictor_wake(struct obd_export *exp)
-{
- struct obd_device *obd;
-
- spin_lock(&pet_lock);
- if (pet_state != PET_READY) {
- /* eventually the new obd will call here again. */
- spin_unlock(&pet_lock);
- return 1;
- }
-
- obd = class_exp2obd(exp);
- if (list_empty(&obd->obd_evict_list)) {
- class_incref(obd, "evictor", obd);
- list_add(&obd->obd_evict_list, &pet_list);
- }
- spin_unlock(&pet_lock);
-
- wake_up(&pet_waitq);
- return 0;
-}
-
-static int ping_evictor_main(void *arg)
-{
- struct obd_device *obd;
- struct obd_export *exp;
- struct l_wait_info lwi = { 0 };
- time_t expire_time;
-
- unshare_fs_struct();
-
- CDEBUG(D_HA, "Starting Ping Evictor\n");
- pet_state = PET_READY;
- while (1) {
- l_wait_event(pet_waitq, (!list_empty(&pet_list)) ||
- (pet_state == PET_TERMINATE), &lwi);
-
- /* loop until all obd's will be removed */
- if ((pet_state == PET_TERMINATE) && list_empty(&pet_list))
- break;
-
- /* we only get here if pet_exp != NULL, and the end of this
- * loop is the only place which sets it NULL again, so lock
- * is not strictly necessary. */
- spin_lock(&pet_lock);
- obd = list_entry(pet_list.next, struct obd_device,
- obd_evict_list);
- spin_unlock(&pet_lock);
-
- expire_time = get_seconds() - PING_EVICT_TIMEOUT;
-
- CDEBUG(D_HA, "evicting all exports of obd %s older than %ld\n",
- obd->obd_name, expire_time);
-
- /* Exports can't be deleted out of the list while we hold
- * the obd lock (class_unlink_export), which means we can't
- * lose the last ref on the export. If they've already been
- * removed from the list, we won't find them here. */
- spin_lock(&obd->obd_dev_lock);
- while (!list_empty(&obd->obd_exports_timed)) {
- exp = list_entry(obd->obd_exports_timed.next,
- struct obd_export,
- exp_obd_chain_timed);
- if (expire_time > exp->exp_last_request_time) {
- class_export_get(exp);
- spin_unlock(&obd->obd_dev_lock);
- LCONSOLE_WARN("%s: haven't heard from client %s (at %s) in %ld seconds. I think it's dead, and I am evicting it. exp %p, cur %ld expire %ld last %ld\n",
- obd->obd_name,
- obd_uuid2str(&exp->exp_client_uuid),
- obd_export_nid2str(exp),
- (long)(get_seconds() -
- exp->exp_last_request_time),
- exp, (long)get_seconds(),
- (long)expire_time,
- (long)exp->exp_last_request_time);
- CDEBUG(D_HA, "Last request was at %ld\n",
- exp->exp_last_request_time);
- class_fail_export(exp);
- class_export_put(exp);
- spin_lock(&obd->obd_dev_lock);
- } else {
- /* List is sorted, so everyone below is ok */
- break;
- }
- }
- spin_unlock(&obd->obd_dev_lock);
-
- spin_lock(&pet_lock);
- list_del_init(&obd->obd_evict_list);
- spin_unlock(&pet_lock);
-
- class_decref(obd, "evictor", obd);
- }
- CDEBUG(D_HA, "Exiting Ping Evictor\n");
-
- return 0;
-}
-
-void ping_evictor_start(void)
-{
- struct task_struct *task;
-
- if (++pet_refcount > 1)
- return;
-
- init_waitqueue_head(&pet_waitq);
-
- task = kthread_run(ping_evictor_main, NULL, "ll_evictor");
- if (IS_ERR(task)) {
- pet_refcount--;
- CERROR("Cannot start ping evictor thread: %ld\n",
- PTR_ERR(task));
- }
-}
-EXPORT_SYMBOL(ping_evictor_start);
-
-void ping_evictor_stop(void)
-{
- if (--pet_refcount > 0)
- return;
-
- pet_state = PET_TERMINATE;
- wake_up(&pet_waitq);
-}
-EXPORT_SYMBOL(ping_evictor_stop);
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
index a66dc3c6d..ab6c4580f 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
@@ -47,10 +47,14 @@ struct ldlm_res_id;
struct ptlrpc_request_set;
extern int test_req_buffer_pressure;
extern struct mutex ptlrpc_all_services_mutex;
+extern struct list_head ptlrpc_all_services;
+
+extern struct mutex ptlrpcd_mutex;
+extern struct mutex pinger_mutex;
int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait);
/* ptlrpcd.c */
-int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc);
+int ptlrpcd_start(struct ptlrpcd_ctl *pc);
/* client.c */
struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw,
@@ -76,19 +80,16 @@ void ptlrpc_initiate_recovery(struct obd_import *imp);
int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset);
int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset);
-#if defined(CONFIG_PROC_FS)
-void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
- struct ptlrpc_service *svc);
+int ptlrpc_sysfs_register_service(struct kset *parent,
+ struct ptlrpc_service *svc);
+void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc);
+
+void ptlrpc_ldebugfs_register_service(struct dentry *debugfs_entry,
+ struct ptlrpc_service *svc);
void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount);
void ptlrpc_lprocfs_do_request_stat(struct ptlrpc_request *req,
long q_usec, long work_usec);
-#else
-#define ptlrpc_lprocfs_register_service(params...) do {} while (0)
-#define ptlrpc_lprocfs_unregister_service(params...) do {} while (0)
-#define ptlrpc_lprocfs_rpc_sent(params...) do {} while (0)
-#define ptlrpc_lprocfs_do_request_stat(params...) do {} while (0)
-#endif /* CONFIG_PROC_FS */
/* NRS */
@@ -113,6 +114,8 @@ struct nrs_core {
};
+extern struct nrs_core nrs_core;
+
int ptlrpc_service_nrs_setup(struct ptlrpc_service *svc);
void ptlrpc_service_nrs_cleanup(struct ptlrpc_service *svc);
@@ -134,13 +137,6 @@ ptlrpc_nrs_req_get_nolock(struct ptlrpc_service_part *svcpt, bool hp,
return ptlrpc_nrs_req_get_nolock0(svcpt, hp, false, force);
}
-static inline struct ptlrpc_request *
-ptlrpc_nrs_req_peek_nolock(struct ptlrpc_service_part *svcpt, bool hp)
-{
- return ptlrpc_nrs_req_get_nolock0(svcpt, hp, true, false);
-}
-
-void ptlrpc_nrs_req_del_nolock(struct ptlrpc_request *req);
bool ptlrpc_nrs_req_pending_nolock(struct ptlrpc_service_part *svcpt, bool hp);
int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc,
@@ -246,8 +242,6 @@ int ptlrpc_stop_pinger(void);
void ptlrpc_pinger_sending_on_import(struct obd_import *imp);
void ptlrpc_pinger_commit_expected(struct obd_import *imp);
void ptlrpc_pinger_wake_up(void);
-void ptlrpc_ping_import_soon(struct obd_import *imp);
-int ping_evictor_wake(struct obd_export *exp);
/* sec_null.c */
int sptlrpc_null_init(void);
@@ -263,14 +257,8 @@ void sptlrpc_enc_pool_fini(void);
int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v);
/* sec_lproc.c */
-#if defined(CONFIG_PROC_FS)
int sptlrpc_lproc_init(void);
void sptlrpc_lproc_fini(void);
-#else
-static inline int sptlrpc_lproc_init(void)
-{ return 0; }
-static inline void sptlrpc_lproc_fini(void) {}
-#endif
/* sec_gc.c */
int sptlrpc_gc_init(void);
@@ -307,6 +295,6 @@ static inline void tgt_mod_exit(void)
static inline void ptlrpc_reqset_put(struct ptlrpc_request_set *set)
{
if (atomic_dec_and_test(&set->set_refcount))
- OBD_FREE_PTR(set);
+ kfree(set);
}
#endif /* PTLRPC_INTERNAL_H */
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
index 5268887ca..9deeb2441 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
@@ -36,7 +36,6 @@
#define DEBUG_SUBSYSTEM S_RPC
-
#include "../include/obd_support.h"
#include "../include/obd_class.h"
#include "../include/lustre_net.h"
@@ -48,10 +47,8 @@ extern spinlock_t ptlrpc_last_xid_lock;
#if RS_DEBUG
extern spinlock_t ptlrpc_rs_debug_lock;
#endif
-extern struct mutex pinger_mutex;
-extern struct mutex ptlrpcd_mutex;
-__init int ptlrpc_init(void)
+static int __init ptlrpc_init(void)
{
int rc, cleanup_phase = 0;
@@ -143,7 +140,8 @@ cleanup:
ptlrpc_hr_fini();
req_layout_fini();
/* Fall through */
- default: ;
+ default:
+ ;
}
return rc;
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index 0c178ec0e..ce036a1ac 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -67,22 +67,94 @@
#include "ptlrpc_internal.h"
+/* One of these per CPT. */
struct ptlrpcd {
- int pd_size;
- int pd_index;
- int pd_nthreads;
- struct ptlrpcd_ctl pd_thread_rcv;
+ int pd_size;
+ int pd_index;
+ int pd_cpt;
+ int pd_cursor;
+ int pd_nthreads;
+ int pd_groupsize;
struct ptlrpcd_ctl pd_threads[0];
};
+/*
+ * max_ptlrpcds is obsolete, but retained to ensure that the kernel
+ * module will load on a system where it has been tuned.
+ * A value other than 0 implies it was tuned, in which case the value
+ * is used to derive a setting for ptlrpcd_per_cpt_max.
+ */
static int max_ptlrpcds;
module_param(max_ptlrpcds, int, 0644);
MODULE_PARM_DESC(max_ptlrpcds, "Max ptlrpcd thread count to be started.");
-static int ptlrpcd_bind_policy = PDB_POLICY_PAIR;
+/*
+ * ptlrpcd_bind_policy is obsolete, but retained to ensure that
+ * the kernel module will load on a system where it has been tuned.
+ * A value other than 0 implies it was tuned, in which case the value
+ * is used to derive a setting for ptlrpcd_partner_group_size.
+ */
+static int ptlrpcd_bind_policy;
module_param(ptlrpcd_bind_policy, int, 0644);
-MODULE_PARM_DESC(ptlrpcd_bind_policy, "Ptlrpcd threads binding mode.");
-static struct ptlrpcd *ptlrpcds;
+MODULE_PARM_DESC(ptlrpcd_bind_policy,
+ "Ptlrpcd threads binding mode (obsolete).");
+
+/*
+ * ptlrpcd_per_cpt_max: The maximum number of ptlrpcd threads to run
+ * in a CPT.
+ */
+static int ptlrpcd_per_cpt_max;
+module_param(ptlrpcd_per_cpt_max, int, 0644);
+MODULE_PARM_DESC(ptlrpcd_per_cpt_max,
+ "Max ptlrpcd thread count to be started per cpt.");
+
+/*
+ * ptlrpcd_partner_group_size: The desired number of threads in each
+ * ptlrpcd partner thread group. Default is 2, corresponding to the
+ * old PDB_POLICY_PAIR. A negative value makes all ptlrpcd threads in
+ * a CPT partners of each other.
+ */
+static int ptlrpcd_partner_group_size;
+module_param(ptlrpcd_partner_group_size, int, 0644);
+MODULE_PARM_DESC(ptlrpcd_partner_group_size,
+ "Number of ptlrpcd threads in a partner group.");
+
+/*
+ * ptlrpcd_cpts: A CPT string describing the CPU partitions that
+ * ptlrpcd threads should run on. Used to make ptlrpcd threads run on
+ * a subset of all CPTs.
+ *
+ * ptlrpcd_cpts=2
+ * ptlrpcd_cpts=[2]
+ * run ptlrpcd threads only on CPT 2.
+ *
+ * ptlrpcd_cpts=0-3
+ * ptlrpcd_cpts=[0-3]
+ * run ptlrpcd threads on CPTs 0, 1, 2, and 3.
+ *
+ * ptlrpcd_cpts=[0-3,5,7]
+ * run ptlrpcd threads on CPTS 0, 1, 2, 3, 5, and 7.
+ */
+static char *ptlrpcd_cpts;
+module_param(ptlrpcd_cpts, charp, 0644);
+MODULE_PARM_DESC(ptlrpcd_cpts,
+ "CPU partitions ptlrpcd threads should run in");
+
+/* ptlrpcds_cpt_idx maps cpt numbers to an index in the ptlrpcds array. */
+static int *ptlrpcds_cpt_idx;
+
+/* ptlrpcds_num is the number of entries in the ptlrpcds array. */
+static int ptlrpcds_num;
+static struct ptlrpcd **ptlrpcds;
+
+/*
+ * In addition to the regular thread pool above, there is a single
+ * global recovery thread. Recovery isn't critical for performance,
+ * and doesn't block, but must always be able to proceed, and it is
+ * possible that all normal ptlrpcd threads are blocked. Hence the
+ * need for a dedicated thread.
+ */
+static struct ptlrpcd_ctl ptlrpcd_rcv;
struct mutex ptlrpcd_mutex;
static int ptlrpcd_users;
@@ -98,88 +170,30 @@ void ptlrpcd_wake(struct ptlrpc_request *req)
EXPORT_SYMBOL(ptlrpcd_wake);
static struct ptlrpcd_ctl *
-ptlrpcd_select_pc(struct ptlrpc_request *req, pdl_policy_t policy, int index)
+ptlrpcd_select_pc(struct ptlrpc_request *req)
{
- int idx = 0;
+ struct ptlrpcd *pd;
+ int cpt;
+ int idx;
if (req != NULL && req->rq_send_state != LUSTRE_IMP_FULL)
- return &ptlrpcds->pd_thread_rcv;
-
- switch (policy) {
- case PDL_POLICY_SAME:
- idx = smp_processor_id() % ptlrpcds->pd_nthreads;
- break;
- case PDL_POLICY_LOCAL:
- /* Before CPU partition patches available, process it the same
- * as "PDL_POLICY_ROUND". */
-# ifdef CFS_CPU_MODE_NUMA
-# warning "fix this code to use new CPU partition APIs"
-# endif
- /* Fall through to PDL_POLICY_ROUND until the CPU
- * CPU partition patches are available. */
- index = -1;
- case PDL_POLICY_PREFERRED:
- if (index >= 0 && index < num_online_cpus()) {
- idx = index % ptlrpcds->pd_nthreads;
- break;
- }
- /* Fall through to PDL_POLICY_ROUND for bad index. */
- default:
- /* Fall through to PDL_POLICY_ROUND for unknown policy. */
- case PDL_POLICY_ROUND:
- /* We do not care whether it is strict load balance. */
- idx = ptlrpcds->pd_index + 1;
- if (idx == smp_processor_id())
- idx++;
- idx %= ptlrpcds->pd_nthreads;
- ptlrpcds->pd_index = idx;
- break;
- }
-
- return &ptlrpcds->pd_threads[idx];
-}
-
-/**
- * Move all request from an existing request set to the ptlrpcd queue.
- * All requests from the set must be in phase RQ_PHASE_NEW.
- */
-void ptlrpcd_add_rqset(struct ptlrpc_request_set *set)
-{
- struct list_head *tmp, *pos;
- struct ptlrpcd_ctl *pc;
- struct ptlrpc_request_set *new;
- int count, i;
+ return &ptlrpcd_rcv;
- pc = ptlrpcd_select_pc(NULL, PDL_POLICY_LOCAL, -1);
- new = pc->pc_set;
+ cpt = cfs_cpt_current(cfs_cpt_table, 1);
+ if (!ptlrpcds_cpt_idx)
+ idx = cpt;
+ else
+ idx = ptlrpcds_cpt_idx[cpt];
+ pd = ptlrpcds[idx];
- list_for_each_safe(pos, tmp, &set->set_requests) {
- struct ptlrpc_request *req =
- list_entry(pos, struct ptlrpc_request,
- rq_set_chain);
-
- LASSERT(req->rq_phase == RQ_PHASE_NEW);
- req->rq_set = new;
- req->rq_queued_time = cfs_time_current();
- }
+ /* We do not care whether it is strict load balance. */
+ idx = pd->pd_cursor;
+ if (++idx == pd->pd_nthreads)
+ idx = 0;
+ pd->pd_cursor = idx;
- spin_lock(&new->set_new_req_lock);
- list_splice_init(&set->set_requests, &new->set_new_requests);
- i = atomic_read(&set->set_remaining);
- count = atomic_add_return(i, &new->set_new_count);
- atomic_set(&set->set_remaining, 0);
- spin_unlock(&new->set_new_req_lock);
- if (count == i) {
- wake_up(&new->set_waitq);
-
- /* XXX: It maybe unnecessary to wakeup all the partners. But to
- * guarantee the async RPC can be processed ASAP, we have
- * no other better choice. It maybe fixed in future. */
- for (i = 0; i < pc->pc_npartners; i++)
- wake_up(&pc->pc_partners[i]->pc_set->set_waitq);
- }
+ return &pd->pd_threads[idx];
}
-EXPORT_SYMBOL(ptlrpcd_add_rqset);
/**
* Return transferred RPCs count.
@@ -212,7 +226,7 @@ static int ptlrpcd_steal_rqset(struct ptlrpc_request_set *des,
* Requests that are added to the ptlrpcd queue are sent via
* ptlrpcd_check->ptlrpc_check_set().
*/
-void ptlrpcd_add_req(struct ptlrpc_request *req, pdl_policy_t policy, int idx)
+void ptlrpcd_add_req(struct ptlrpc_request *req)
{
struct ptlrpcd_ctl *pc;
@@ -242,7 +256,7 @@ void ptlrpcd_add_req(struct ptlrpc_request *req, pdl_policy_t policy, int idx)
spin_unlock(&req->rq_lock);
}
- pc = ptlrpcd_select_pc(req, policy, idx);
+ pc = ptlrpcd_select_pc(req);
DEBUG_REQ(D_INFO, req, "add req [%p] to pc [%s:%d]",
req, pc->pc_name, pc->pc_index);
@@ -372,25 +386,29 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc)
static int ptlrpcd(void *arg)
{
struct ptlrpcd_ctl *pc = arg;
- struct ptlrpc_request_set *set = pc->pc_set;
+ struct ptlrpc_request_set *set;
struct lu_env env = { .le_ses = NULL };
- int rc, exit = 0;
+ int rc = 0;
+ int exit = 0;
unshare_fs_struct();
-#if defined(CONFIG_SMP)
- if (test_bit(LIOD_BIND, &pc->pc_flags)) {
- int index = pc->pc_index;
-
- if (index >= 0 && index < num_possible_cpus()) {
- while (!cpu_online(index)) {
- if (++index >= num_possible_cpus())
- index = 0;
- }
- set_cpus_allowed_ptr(current,
- cpumask_of_node(cpu_to_node(index)));
- }
+ if (cfs_cpt_bind(cfs_cpt_table, pc->pc_cpt) != 0)
+ CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt);
+
+ /*
+ * Allocate the request set after the thread has been bound
+ * above. This is safe because no requests will be queued
+ * until all ptlrpcd threads have confirmed that they have
+ * successfully started.
+ */
+ set = ptlrpc_prep_set();
+ if (!set) {
+ rc = -ENOMEM;
+ goto failed;
}
-#endif
+ spin_lock(&pc->pc_lock);
+ pc->pc_set = set;
+ spin_unlock(&pc->pc_lock);
/*
* XXX So far only "client" ptlrpcd uses an environment. In
* the future, ptlrpcd thread (or a thread-set) has to given
@@ -398,10 +416,10 @@ static int ptlrpcd(void *arg)
*/
rc = lu_context_init(&env.le_ctx,
LCT_CL_THREAD|LCT_REMEMBER|LCT_NOREF);
- complete(&pc->pc_starting);
-
if (rc != 0)
- return rc;
+ goto failed;
+
+ complete(&pc->pc_starting);
/*
* This mainloop strongly resembles ptlrpc_set_wait() except that our
@@ -447,173 +465,97 @@ static int ptlrpcd(void *arg)
complete(&pc->pc_finishing);
return 0;
+failed:
+ pc->pc_error = rc;
+ complete(&pc->pc_starting);
+ return rc;
}
-/* XXX: We want multiple CPU cores to share the async RPC load. So we start many
- * ptlrpcd threads. We also want to reduce the ptlrpcd overhead caused by
- * data transfer cross-CPU cores. So we bind ptlrpcd thread to specified
- * CPU core. But binding all ptlrpcd threads maybe cause response delay
- * because of some CPU core(s) busy with other loads.
- *
- * For example: "ls -l", some async RPCs for statahead are assigned to
- * ptlrpcd_0, and ptlrpcd_0 is bound to CPU_0, but CPU_0 may be quite busy
- * with other non-ptlrpcd, like "ls -l" itself (we want to the "ls -l"
- * thread, statahead thread, and ptlrpcd thread can run in parallel), under
- * such case, the statahead async RPCs can not be processed in time, it is
- * unexpected. If ptlrpcd_0 can be re-scheduled on other CPU core, it may
- * be better. But it breaks former data transfer policy.
- *
- * So we shouldn't be blind for avoiding the data transfer. We make some
- * compromise: divide the ptlrpcd threads pool into two parts. One part is
- * for bound mode, each ptlrpcd thread in this part is bound to some CPU
- * core. The other part is for free mode, all the ptlrpcd threads in the
- * part can be scheduled on any CPU core. We specify some partnership
- * between bound mode ptlrpcd thread(s) and free mode ptlrpcd thread(s),
- * and the async RPC load within the partners are shared.
+static void ptlrpcd_ctl_init(struct ptlrpcd_ctl *pc, int index, int cpt)
+{
+ pc->pc_index = index;
+ pc->pc_cpt = cpt;
+ init_completion(&pc->pc_starting);
+ init_completion(&pc->pc_finishing);
+ spin_lock_init(&pc->pc_lock);
+
+ if (index < 0) {
+ /* Recovery thread. */
+ snprintf(pc->pc_name, sizeof(pc->pc_name), "ptlrpcd_rcv");
+ } else {
+ /* Regular thread. */
+ snprintf(pc->pc_name, sizeof(pc->pc_name),
+ "ptlrpcd_%02d_%02d", cpt, index);
+ }
+}
+
+/* XXX: We want multiple CPU cores to share the async RPC load. So we
+ * start many ptlrpcd threads. We also want to reduce the ptlrpcd
+ * overhead caused by data transfer cross-CPU cores. So we bind
+ * all ptlrpcd threads to a CPT, in the expectation that CPTs
+ * will be defined in a way that matches these boundaries. Within
+ * a CPT a ptlrpcd thread can be scheduled on any available core.
*
- * It can partly avoid data transfer cross-CPU (if the bound mode ptlrpcd
- * thread can be scheduled in time), and try to guarantee the async RPC
- * processed ASAP (as long as the free mode ptlrpcd thread can be scheduled
- * on any CPU core).
+ * Each ptlrpcd thread has its own request queue. This can cause
+ * response delay if the thread is already busy. To help with
+ * this we define partner threads: these are other threads bound
+ * to the same CPT which will check for work in each other's
+ * request queues if they have no work to do.
*
- * As for how to specify the partnership between bound mode ptlrpcd
- * thread(s) and free mode ptlrpcd thread(s), the simplest way is to use
- * <free bound> pair. In future, we can specify some more complex
- * partnership based on the patches for CPU partition. But before such
- * patches are available, we prefer to use the simplest one.
+ * The desired number of partner threads can be tuned by setting
+ * ptlrpcd_partner_group_size. The default is to create pairs of
+ * partner threads.
*/
-# ifdef CFS_CPU_MODE_NUMA
-# warning "fix ptlrpcd_bind() to use new CPU partition APIs"
-# endif
-static int ptlrpcd_bind(int index, int max)
+static int ptlrpcd_partners(struct ptlrpcd *pd, int index)
{
struct ptlrpcd_ctl *pc;
+ struct ptlrpcd_ctl **ppc;
+ int first;
+ int i;
int rc = 0;
-#if defined(CONFIG_NUMA)
- cpumask_t mask;
-#endif
+ int size;
- LASSERT(index <= max - 1);
- pc = &ptlrpcds->pd_threads[index];
- switch (ptlrpcd_bind_policy) {
- case PDB_POLICY_NONE:
- pc->pc_npartners = -1;
- break;
- case PDB_POLICY_FULL:
+ LASSERT(index >= 0 && index < pd->pd_nthreads);
+ pc = &pd->pd_threads[index];
+ pc->pc_npartners = pd->pd_groupsize - 1;
+
+ if (pc->pc_npartners <= 0)
+ goto out;
+
+ size = sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners;
+ pc->pc_partners = kzalloc_node(size, GFP_NOFS,
+ cfs_cpt_spread_node(cfs_cpt_table,
+ pc->pc_cpt));
+ if (!pc->pc_partners) {
pc->pc_npartners = 0;
- set_bit(LIOD_BIND, &pc->pc_flags);
- break;
- case PDB_POLICY_PAIR:
- LASSERT(max % 2 == 0);
- pc->pc_npartners = 1;
- break;
- case PDB_POLICY_NEIGHBOR:
-#if defined(CONFIG_NUMA)
- {
- int i;
- cpumask_copy(&mask, cpumask_of_node(cpu_to_node(index)));
- for (i = max; i < num_online_cpus(); i++)
- cpumask_clear_cpu(i, &mask);
- pc->pc_npartners = cpumask_weight(&mask) - 1;
- set_bit(LIOD_BIND, &pc->pc_flags);
- }
-#else
- LASSERT(max >= 3);
- pc->pc_npartners = 2;
-#endif
- break;
- default:
- CERROR("unknown ptlrpcd bind policy %d\n", ptlrpcd_bind_policy);
- rc = -EINVAL;
+ rc = -ENOMEM;
+ goto out;
}
- if (rc == 0 && pc->pc_npartners > 0) {
- OBD_ALLOC(pc->pc_partners,
- sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners);
- if (pc->pc_partners == NULL) {
- pc->pc_npartners = 0;
- rc = -ENOMEM;
- } else {
- switch (ptlrpcd_bind_policy) {
- case PDB_POLICY_PAIR:
- if (index & 0x1) {
- set_bit(LIOD_BIND, &pc->pc_flags);
- pc->pc_partners[0] = &ptlrpcds->
- pd_threads[index - 1];
- ptlrpcds->pd_threads[index - 1].
- pc_partners[0] = pc;
- }
- break;
- case PDB_POLICY_NEIGHBOR:
-#if defined(CONFIG_NUMA)
- {
- struct ptlrpcd_ctl *ppc;
- int i, pidx;
- /* partners are cores in the same NUMA node.
- * setup partnership only with ptlrpcd threads
- * that are already initialized
- */
- for (pidx = 0, i = 0; i < index; i++) {
- if (cpumask_test_cpu(i, &mask)) {
- ppc = &ptlrpcds->pd_threads[i];
- pc->pc_partners[pidx++] = ppc;
- ppc->pc_partners[ppc->
- pc_npartners++] = pc;
- }
- }
- /* adjust number of partners to the number
- * of partnership really setup */
- pc->pc_npartners = pidx;
- }
-#else
- if (index & 0x1)
- set_bit(LIOD_BIND, &pc->pc_flags);
- if (index > 0) {
- pc->pc_partners[0] = &ptlrpcds->
- pd_threads[index - 1];
- ptlrpcds->pd_threads[index - 1].
- pc_partners[1] = pc;
- if (index == max - 1) {
- pc->pc_partners[1] =
- &ptlrpcds->pd_threads[0];
- ptlrpcds->pd_threads[0].
- pc_partners[0] = pc;
- }
- }
-#endif
- break;
- }
- }
+ first = index - index % pd->pd_groupsize;
+ ppc = pc->pc_partners;
+ for (i = first; i < first + pd->pd_groupsize; i++) {
+ if (i != index)
+ *ppc++ = &pd->pd_threads[i];
}
-
+out:
return rc;
}
-
-int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc)
+int ptlrpcd_start(struct ptlrpcd_ctl *pc)
{
- int rc;
+ struct task_struct *task;
+ int rc = 0;
/*
* Do not allow start second thread for one pc.
*/
if (test_and_set_bit(LIOD_START, &pc->pc_flags)) {
CWARN("Starting second thread (%s) for same pc %p\n",
- name, pc);
+ pc->pc_name, pc);
return 0;
}
- pc->pc_index = index;
- init_completion(&pc->pc_starting);
- init_completion(&pc->pc_finishing);
- spin_lock_init(&pc->pc_lock);
- strlcpy(pc->pc_name, name, sizeof(pc->pc_name));
- pc->pc_set = ptlrpc_prep_set();
- if (pc->pc_set == NULL) {
- rc = -ENOMEM;
- goto out;
- }
-
/*
* So far only "client" ptlrpcd uses an environment. In the future,
* ptlrpcd thread (or a thread-set) has to be given an argument,
@@ -621,29 +563,21 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc)
*/
rc = lu_context_init(&pc->pc_env.le_ctx, LCT_CL_THREAD|LCT_REMEMBER);
if (rc != 0)
- goto out_set;
+ goto out;
- {
- struct task_struct *task;
- if (index >= 0) {
- rc = ptlrpcd_bind(index, max);
- if (rc < 0)
- goto out_env;
- }
+ task = kthread_run(ptlrpcd, pc, "%s", pc->pc_name);
+ if (IS_ERR(task)) {
+ rc = PTR_ERR(task);
+ goto out_set;
+ }
- task = kthread_run(ptlrpcd, pc, "%s", pc->pc_name);
- if (IS_ERR(task)) {
- rc = PTR_ERR(task);
- goto out_env;
- }
+ wait_for_completion(&pc->pc_starting);
+ rc = pc->pc_error;
+ if (rc != 0)
+ goto out_set;
- wait_for_completion(&pc->pc_starting);
- }
return 0;
-out_env:
- lu_context_fini(&pc->pc_env.le_ctx);
-
out_set:
if (pc->pc_set != NULL) {
struct ptlrpc_request_set *set = pc->pc_set;
@@ -653,7 +587,7 @@ out_set:
spin_unlock(&pc->pc_lock);
ptlrpc_set_destroy(set);
}
- clear_bit(LIOD_BIND, &pc->pc_flags);
+ lu_context_fini(&pc->pc_env.le_ctx);
out:
clear_bit(LIOD_START, &pc->pc_flags);
@@ -693,99 +627,271 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc)
clear_bit(LIOD_START, &pc->pc_flags);
clear_bit(LIOD_STOP, &pc->pc_flags);
clear_bit(LIOD_FORCE, &pc->pc_flags);
- clear_bit(LIOD_BIND, &pc->pc_flags);
out:
if (pc->pc_npartners > 0) {
LASSERT(pc->pc_partners != NULL);
- OBD_FREE(pc->pc_partners,
- sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners);
+ kfree(pc->pc_partners);
pc->pc_partners = NULL;
}
pc->pc_npartners = 0;
+ pc->pc_error = 0;
}
static void ptlrpcd_fini(void)
{
int i;
+ int j;
if (ptlrpcds != NULL) {
- for (i = 0; i < ptlrpcds->pd_nthreads; i++)
- ptlrpcd_stop(&ptlrpcds->pd_threads[i], 0);
- for (i = 0; i < ptlrpcds->pd_nthreads; i++)
- ptlrpcd_free(&ptlrpcds->pd_threads[i]);
- ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0);
- ptlrpcd_free(&ptlrpcds->pd_thread_rcv);
- OBD_FREE(ptlrpcds, ptlrpcds->pd_size);
- ptlrpcds = NULL;
+ for (i = 0; i < ptlrpcds_num; i++) {
+ if (!ptlrpcds[i])
+ break;
+ for (j = 0; j < ptlrpcds[i]->pd_nthreads; j++)
+ ptlrpcd_stop(&ptlrpcds[i]->pd_threads[j], 0);
+ for (j = 0; j < ptlrpcds[i]->pd_nthreads; j++)
+ ptlrpcd_free(&ptlrpcds[i]->pd_threads[j]);
+ kfree(ptlrpcds[i]);
+ ptlrpcds[i] = NULL;
+ }
+ kfree(ptlrpcds);
}
+ ptlrpcds_num = 0;
+
+ ptlrpcd_stop(&ptlrpcd_rcv, 0);
+ ptlrpcd_free(&ptlrpcd_rcv);
+
+ kfree(ptlrpcds_cpt_idx);
+ ptlrpcds_cpt_idx = NULL;
}
static int ptlrpcd_init(void)
{
- int nthreads = num_online_cpus();
- char name[16];
- int size, i = -1, j, rc = 0;
-
- if (max_ptlrpcds > 0 && max_ptlrpcds < nthreads)
- nthreads = max_ptlrpcds;
- if (nthreads < 2)
- nthreads = 2;
- if (nthreads < 3 && ptlrpcd_bind_policy == PDB_POLICY_NEIGHBOR)
- ptlrpcd_bind_policy = PDB_POLICY_PAIR;
- else if (nthreads % 2 != 0 && ptlrpcd_bind_policy == PDB_POLICY_PAIR)
- nthreads &= ~1; /* make sure it is even */
-
- size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
- OBD_ALLOC(ptlrpcds, size);
- if (ptlrpcds == NULL) {
+ int nthreads;
+ int groupsize;
+ int size;
+ int i;
+ int j;
+ int rc = 0;
+ struct cfs_cpt_table *cptable;
+ __u32 *cpts = NULL;
+ int ncpts;
+ int cpt;
+ struct ptlrpcd *pd;
+
+ /*
+ * Determine the CPTs that ptlrpcd threads will run on.
+ */
+ cptable = cfs_cpt_table;
+ ncpts = cfs_cpt_number(cptable);
+ if (ptlrpcd_cpts) {
+ struct cfs_expr_list *el;
+
+ size = ncpts * sizeof(ptlrpcds_cpt_idx[0]);
+ ptlrpcds_cpt_idx = kzalloc(size, GFP_KERNEL);
+ if (!ptlrpcds_cpt_idx) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ rc = cfs_expr_list_parse(ptlrpcd_cpts,
+ strlen(ptlrpcd_cpts),
+ 0, ncpts - 1, &el);
+
+ if (rc != 0) {
+ CERROR("ptlrpcd_cpts: invalid CPT pattern string: %s",
+ ptlrpcd_cpts);
+ rc = -EINVAL;
+ goto out;
+ }
+
+ rc = cfs_expr_list_values(el, ncpts, &cpts);
+ cfs_expr_list_free(el);
+ if (rc <= 0) {
+ CERROR("ptlrpcd_cpts: failed to parse CPT array %s: %d\n",
+ ptlrpcd_cpts, rc);
+ if (rc == 0)
+ rc = -EINVAL;
+ goto out;
+ }
+
+ /*
+ * Create the cpt-to-index map. When there is no match
+ * in the cpt table, pick a cpt at random. This could
+ * be changed to take the topology of the system into
+ * account.
+ */
+ for (cpt = 0; cpt < ncpts; cpt++) {
+ for (i = 0; i < rc; i++)
+ if (cpts[i] == cpt)
+ break;
+ if (i >= rc)
+ i = cpt % rc;
+ ptlrpcds_cpt_idx[cpt] = i;
+ }
+
+ cfs_expr_list_values_free(cpts, rc);
+ ncpts = rc;
+ }
+ ptlrpcds_num = ncpts;
+
+ size = ncpts * sizeof(ptlrpcds[0]);
+ ptlrpcds = kzalloc(size, GFP_KERNEL);
+ if (!ptlrpcds) {
rc = -ENOMEM;
goto out;
}
- snprintf(name, sizeof(name), "ptlrpcd_rcv");
- set_bit(LIOD_RECOVERY, &ptlrpcds->pd_thread_rcv.pc_flags);
- rc = ptlrpcd_start(-1, nthreads, name, &ptlrpcds->pd_thread_rcv);
+ /*
+ * The max_ptlrpcds parameter is obsolete, but do something
+ * sane if it has been tuned, and complain if
+ * ptlrpcd_per_cpt_max has also been tuned.
+ */
+ if (max_ptlrpcds != 0) {
+ CWARN("max_ptlrpcds is obsolete.\n");
+ if (ptlrpcd_per_cpt_max == 0) {
+ ptlrpcd_per_cpt_max = max_ptlrpcds / ncpts;
+ /* Round up if there is a remainder. */
+ if (max_ptlrpcds % ncpts != 0)
+ ptlrpcd_per_cpt_max++;
+ CWARN("Setting ptlrpcd_per_cpt_max = %d\n",
+ ptlrpcd_per_cpt_max);
+ } else {
+ CWARN("ptlrpd_per_cpt_max is also set!\n");
+ }
+ }
+
+ /*
+ * The ptlrpcd_bind_policy parameter is obsolete, but do
+ * something sane if it has been tuned, and complain if
+ * ptlrpcd_partner_group_size is also tuned.
+ */
+ if (ptlrpcd_bind_policy != 0) {
+ CWARN("ptlrpcd_bind_policy is obsolete.\n");
+ if (ptlrpcd_partner_group_size == 0) {
+ switch (ptlrpcd_bind_policy) {
+ case 1: /* PDB_POLICY_NONE */
+ case 2: /* PDB_POLICY_FULL */
+ ptlrpcd_partner_group_size = 1;
+ break;
+ case 3: /* PDB_POLICY_PAIR */
+ ptlrpcd_partner_group_size = 2;
+ break;
+ case 4: /* PDB_POLICY_NEIGHBOR */
+#ifdef CONFIG_NUMA
+ ptlrpcd_partner_group_size = -1; /* CPT */
+#else
+ ptlrpcd_partner_group_size = 3; /* Triplets */
+#endif
+ break;
+ default: /* Illegal value, use the default. */
+ ptlrpcd_partner_group_size = 2;
+ break;
+ }
+ CWARN("Setting ptlrpcd_partner_group_size = %d\n",
+ ptlrpcd_partner_group_size);
+ } else {
+ CWARN("ptlrpcd_partner_group_size is also set!\n");
+ }
+ }
+
+ if (ptlrpcd_partner_group_size == 0)
+ ptlrpcd_partner_group_size = 2;
+ else if (ptlrpcd_partner_group_size < 0)
+ ptlrpcd_partner_group_size = -1;
+ else if (ptlrpcd_per_cpt_max > 0 &&
+ ptlrpcd_partner_group_size > ptlrpcd_per_cpt_max)
+ ptlrpcd_partner_group_size = ptlrpcd_per_cpt_max;
+
+ /*
+ * Start the recovery thread first.
+ */
+ set_bit(LIOD_RECOVERY, &ptlrpcd_rcv.pc_flags);
+ ptlrpcd_ctl_init(&ptlrpcd_rcv, -1, CFS_CPT_ANY);
+ rc = ptlrpcd_start(&ptlrpcd_rcv);
if (rc < 0)
goto out;
- /* XXX: We start nthreads ptlrpc daemons. Each of them can process any
- * non-recovery async RPC to improve overall async RPC efficiency.
- *
- * But there are some issues with async I/O RPCs and async non-I/O
- * RPCs processed in the same set under some cases. The ptlrpcd may
- * be blocked by some async I/O RPC(s), then will cause other async
- * non-I/O RPC(s) can not be processed in time.
- *
- * Maybe we should distinguish blocked async RPCs from non-blocked
- * async RPCs, and process them in different ptlrpcd sets to avoid
- * unnecessary dependency. But how to distribute async RPCs load
- * among all the ptlrpc daemons becomes another trouble. */
- for (i = 0; i < nthreads; i++) {
- snprintf(name, sizeof(name), "ptlrpcd_%d", i);
- rc = ptlrpcd_start(i, nthreads, name, &ptlrpcds->pd_threads[i]);
- if (rc < 0)
+ for (i = 0; i < ncpts; i++) {
+ if (!cpts)
+ cpt = i;
+ else
+ cpt = cpts[i];
+
+ nthreads = cfs_cpt_weight(cptable, cpt);
+ if (ptlrpcd_per_cpt_max > 0 && ptlrpcd_per_cpt_max < nthreads)
+ nthreads = ptlrpcd_per_cpt_max;
+ if (nthreads < 2)
+ nthreads = 2;
+
+ if (ptlrpcd_partner_group_size <= 0) {
+ groupsize = nthreads;
+ } else if (nthreads <= ptlrpcd_partner_group_size) {
+ groupsize = nthreads;
+ } else {
+ groupsize = ptlrpcd_partner_group_size;
+ if (nthreads % groupsize != 0)
+ nthreads += groupsize - (nthreads % groupsize);
+ }
+
+ size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
+ pd = kzalloc_node(size, GFP_NOFS,
+ cfs_cpt_spread_node(cfs_cpt_table, cpt));
+ if (!pd) {
+ rc = -ENOMEM;
goto out;
- }
+ }
+ pd->pd_size = size;
+ pd->pd_index = i;
+ pd->pd_cpt = cpt;
+ pd->pd_cursor = 0;
+ pd->pd_nthreads = nthreads;
+ pd->pd_groupsize = groupsize;
+ ptlrpcds[i] = pd;
- ptlrpcds->pd_size = size;
- ptlrpcds->pd_index = 0;
- ptlrpcds->pd_nthreads = nthreads;
+ /*
+ * The ptlrpcd threads in a partner group can access
+ * each other's struct ptlrpcd_ctl, so these must be
+ * initialized before any thread is started.
+ */
+ for (j = 0; j < nthreads; j++) {
+ ptlrpcd_ctl_init(&pd->pd_threads[j], j, cpt);
+ rc = ptlrpcd_partners(pd, j);
+ if (rc < 0)
+ goto out;
+ }
-out:
- if (rc != 0 && ptlrpcds != NULL) {
- for (j = 0; j <= i; j++)
- ptlrpcd_stop(&ptlrpcds->pd_threads[j], 0);
- for (j = 0; j <= i; j++)
- ptlrpcd_free(&ptlrpcds->pd_threads[j]);
- ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0);
- ptlrpcd_free(&ptlrpcds->pd_thread_rcv);
- OBD_FREE(ptlrpcds, size);
- ptlrpcds = NULL;
+ /* XXX: We start nthreads ptlrpc daemons.
+ * Each of them can process any non-recovery
+ * async RPC to improve overall async RPC
+ * efficiency.
+ *
+ * But there are some issues with async I/O RPCs
+ * and async non-I/O RPCs processed in the same
+ * set under some cases. The ptlrpcd may be
+ * blocked by some async I/O RPC(s), then will
+ * cause other async non-I/O RPC(s) can not be
+ * processed in time.
+ *
+ * Maybe we should distinguish blocked async RPCs
+ * from non-blocked async RPCs, and process them
+ * in different ptlrpcd sets to avoid unnecessary
+ * dependency. But how to distribute async RPCs
+ * load among all the ptlrpc daemons becomes
+ * another trouble.
+ */
+ for (j = 0; j < nthreads; j++) {
+ rc = ptlrpcd_start(&pd->pd_threads[j]);
+ if (rc < 0)
+ goto out;
+ }
}
+out:
+ if (rc != 0)
+ ptlrpcd_fini();
- return 0;
+ return rc;
}
int ptlrpcd_addref(void)
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 21e9dc9d5..39f5261c9 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -113,10 +113,10 @@ static
struct ptlrpc_sec_policy *sptlrpc_wireflavor2policy(__u32 flavor)
{
static DEFINE_MUTEX(load_mutex);
- static atomic_t loaded = ATOMIC_INIT(0);
+ static atomic_t loaded = ATOMIC_INIT(0);
struct ptlrpc_sec_policy *policy;
- __u16 number = SPTLRPC_FLVR_POLICY(flavor);
- __u16 flag = 0;
+ __u16 number = SPTLRPC_FLVR_POLICY(flavor);
+ __u16 flag = 0;
if (number >= SPTLRPC_POLICY_MAX)
return NULL;
@@ -227,7 +227,7 @@ char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize)
}
EXPORT_SYMBOL(sptlrpc_flavor2name);
-char *sptlrpc_secflags2str(__u32 flags, char *buf, int bufsize)
+static char *sptlrpc_secflags2str(__u32 flags, char *buf, int bufsize)
{
buf[0] = '\0';
@@ -244,7 +244,6 @@ char *sptlrpc_secflags2str(__u32 flags, char *buf, int bufsize)
return buf;
}
-EXPORT_SYMBOL(sptlrpc_secflags2str);
/**************************************************
* client context APIs *
@@ -297,53 +296,13 @@ void sptlrpc_cli_ctx_put(struct ptlrpc_cli_ctx *ctx, int sync)
}
EXPORT_SYMBOL(sptlrpc_cli_ctx_put);
-/**
- * Expire the client context immediately.
- *
- * \pre Caller must hold at least 1 reference on the \a ctx.
- */
-void sptlrpc_cli_ctx_expire(struct ptlrpc_cli_ctx *ctx)
-{
- LASSERT(ctx->cc_ops->force_die);
- ctx->cc_ops->force_die(ctx, 0);
-}
-EXPORT_SYMBOL(sptlrpc_cli_ctx_expire);
-
-/**
- * To wake up the threads who are waiting for this client context. Called
- * after some status change happened on \a ctx.
- */
-void sptlrpc_cli_ctx_wakeup(struct ptlrpc_cli_ctx *ctx)
-{
- struct ptlrpc_request *req, *next;
-
- spin_lock(&ctx->cc_lock);
- list_for_each_entry_safe(req, next, &ctx->cc_req_list,
- rq_ctx_chain) {
- list_del_init(&req->rq_ctx_chain);
- ptlrpc_client_wake_req(req);
- }
- spin_unlock(&ctx->cc_lock);
-}
-EXPORT_SYMBOL(sptlrpc_cli_ctx_wakeup);
-
-int sptlrpc_cli_ctx_display(struct ptlrpc_cli_ctx *ctx, char *buf, int bufsize)
-{
- LASSERT(ctx->cc_ops);
-
- if (ctx->cc_ops->display == NULL)
- return 0;
-
- return ctx->cc_ops->display(ctx, buf, bufsize);
-}
-
static int import_sec_check_expire(struct obd_import *imp)
{
- int adapt = 0;
+ int adapt = 0;
spin_lock(&imp->imp_lock);
if (imp->imp_sec_expire &&
- imp->imp_sec_expire < get_seconds()) {
+ imp->imp_sec_expire < ktime_get_real_seconds()) {
adapt = 1;
imp->imp_sec_expire = 0;
}
@@ -359,7 +318,7 @@ static int import_sec_check_expire(struct obd_import *imp)
static int import_sec_validate_get(struct obd_import *imp,
struct ptlrpc_sec **sec)
{
- int rc;
+ int rc;
if (unlikely(imp->imp_sec_expire)) {
rc = import_sec_check_expire(imp);
@@ -447,10 +406,10 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,
struct ptlrpc_cli_ctx *oldctx,
struct ptlrpc_cli_ctx *newctx)
{
- struct sptlrpc_flavor old_flvr;
- char *reqmsg = NULL; /* to workaround old gcc */
- int reqmsg_size;
- int rc = 0;
+ struct sptlrpc_flavor old_flvr;
+ char *reqmsg = NULL; /* to workaround old gcc */
+ int reqmsg_size;
+ int rc = 0;
LASSERT(req->rq_reqmsg);
LASSERT(req->rq_reqlen);
@@ -469,7 +428,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,
/* save request message */
reqmsg_size = req->rq_reqlen;
if (reqmsg_size != 0) {
- OBD_ALLOC_LARGE(reqmsg, reqmsg_size);
+ reqmsg = libcfs_kvzalloc(reqmsg_size, GFP_NOFS);
if (reqmsg == NULL)
return -ENOMEM;
memcpy(reqmsg, req->rq_reqmsg, reqmsg_size);
@@ -497,7 +456,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,
req->rq_flvr = old_flvr;
}
- OBD_FREE_LARGE(reqmsg, reqmsg_size);
+ kvfree(reqmsg);
}
return rc;
}
@@ -510,11 +469,11 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,
* \note a request must have a context, to keep other parts of code happy.
* In any case of failure during the switching, we must restore the old one.
*/
-int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)
+static int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)
{
struct ptlrpc_cli_ctx *oldctx = req->rq_cli_ctx;
struct ptlrpc_cli_ctx *newctx;
- int rc;
+ int rc;
LASSERT(oldctx);
@@ -563,7 +522,6 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)
sptlrpc_cli_ctx_put(oldctx, 1);
return 0;
}
-EXPORT_SYMBOL(sptlrpc_req_replace_dead_ctx);
static
int ctx_check_refresh(struct ptlrpc_cli_ctx *ctx)
@@ -629,10 +587,10 @@ void req_off_ctx_list(struct ptlrpc_request *req, struct ptlrpc_cli_ctx *ctx)
*/
int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout)
{
- struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
- struct ptlrpc_sec *sec;
- struct l_wait_info lwi;
- int rc;
+ struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
+ struct ptlrpc_sec *sec;
+ struct l_wait_info lwi;
+ int rc;
LASSERT(ctx);
@@ -866,7 +824,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req)
if (req->rq_pool || !req->rq_reqbuf)
return;
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ kfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
@@ -878,7 +836,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req)
*/
int sptlrpc_import_check_ctx(struct obd_import *imp)
{
- struct ptlrpc_sec *sec;
+ struct ptlrpc_sec *sec;
struct ptlrpc_cli_ctx *ctx;
struct ptlrpc_request *req = NULL;
int rc;
@@ -974,7 +932,7 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req)
static int do_cli_unwrap_reply(struct ptlrpc_request *req)
{
struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
- int rc;
+ int rc;
LASSERT(ctx);
LASSERT(ctx->cc_sec);
@@ -1082,10 +1040,10 @@ int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req)
int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
struct ptlrpc_request **req_ret)
{
- struct ptlrpc_request *early_req;
- char *early_buf;
- int early_bufsz, early_size;
- int rc;
+ struct ptlrpc_request *early_req;
+ char *early_buf;
+ int early_bufsz, early_size;
+ int rc;
early_req = ptlrpc_request_cache_alloc(GFP_NOFS);
if (early_req == NULL)
@@ -1093,7 +1051,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
early_size = req->rq_nob_received;
early_bufsz = size_roundup_power2(early_size);
- OBD_ALLOC_LARGE(early_buf, early_bufsz);
+ early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS);
if (early_buf == NULL) {
rc = -ENOMEM;
goto err_req;
@@ -1163,7 +1121,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
err_ctx:
sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
err_buf:
- OBD_FREE_LARGE(early_buf, early_bufsz);
+ kvfree(early_buf);
err_req:
ptlrpc_request_cache_free(early_req);
return rc;
@@ -1181,7 +1139,7 @@ void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req)
LASSERT(early_req->rq_repmsg);
sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
- OBD_FREE_LARGE(early_req->rq_repbuf, early_req->rq_repbuf_len);
+ kvfree(early_req->rq_repbuf);
ptlrpc_request_cache_free(early_req);
}
@@ -1229,12 +1187,6 @@ static void sec_cop_destroy_sec(struct ptlrpc_sec *sec)
sptlrpc_policy_put(policy);
}
-void sptlrpc_sec_destroy(struct ptlrpc_sec *sec)
-{
- sec_cop_destroy_sec(sec);
-}
-EXPORT_SYMBOL(sptlrpc_sec_destroy);
-
static void sptlrpc_sec_kill(struct ptlrpc_sec *sec)
{
LASSERT_ATOMIC_POS(&sec->ps_refcount);
@@ -1246,14 +1198,13 @@ static void sptlrpc_sec_kill(struct ptlrpc_sec *sec)
}
}
-struct ptlrpc_sec *sptlrpc_sec_get(struct ptlrpc_sec *sec)
+static struct ptlrpc_sec *sptlrpc_sec_get(struct ptlrpc_sec *sec)
{
if (sec)
atomic_inc(&sec->ps_refcount);
return sec;
}
-EXPORT_SYMBOL(sptlrpc_sec_get);
void sptlrpc_sec_put(struct ptlrpc_sec *sec)
{
@@ -1273,13 +1224,13 @@ EXPORT_SYMBOL(sptlrpc_sec_put);
*/
static
struct ptlrpc_sec *sptlrpc_sec_create(struct obd_import *imp,
- struct ptlrpc_svc_ctx *svc_ctx,
- struct sptlrpc_flavor *sf,
- enum lustre_sec_part sp)
+ struct ptlrpc_svc_ctx *svc_ctx,
+ struct sptlrpc_flavor *sf,
+ enum lustre_sec_part sp)
{
struct ptlrpc_sec_policy *policy;
- struct ptlrpc_sec *sec;
- char str[32];
+ struct ptlrpc_sec *sec;
+ char str[32];
if (svc_ctx) {
LASSERT(imp->imp_dlm_fake == 1);
@@ -1369,7 +1320,7 @@ static void sptlrpc_import_sec_adapt_inplace(struct obd_import *imp,
struct ptlrpc_sec *sec,
struct sptlrpc_flavor *sf)
{
- char str1[32], str2[32];
+ char str1[32], str2[32];
if (sec->ps_flvr.sf_flags != sf->sf_flags)
CDEBUG(D_SEC, "changing sec flags: %s -> %s\n",
@@ -1394,12 +1345,12 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp,
struct ptlrpc_svc_ctx *svc_ctx,
struct sptlrpc_flavor *flvr)
{
- struct ptlrpc_connection *conn;
- struct sptlrpc_flavor sf;
- struct ptlrpc_sec *sec, *newsec;
- enum lustre_sec_part sp;
- char str[24];
- int rc = 0;
+ struct ptlrpc_connection *conn;
+ struct sptlrpc_flavor sf;
+ struct ptlrpc_sec *sec, *newsec;
+ enum lustre_sec_part sp;
+ char str[24];
+ int rc = 0;
might_sleep();
@@ -1436,7 +1387,7 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp,
sec = sptlrpc_import_sec_ref(imp);
if (sec) {
- char str2[24];
+ char str2[24];
if (flavor_equal(&sf, &sec->ps_flvr))
goto out;
@@ -1507,13 +1458,6 @@ static void import_flush_ctx_common(struct obd_import *imp,
sptlrpc_sec_put(sec);
}
-void sptlrpc_import_flush_root_ctx(struct obd_import *imp)
-{
- /* it's important to use grace mode, see explain in
- * sptlrpc_req_refresh_ctx() */
- import_flush_ctx_common(imp, 0, 1, 1);
-}
-
void sptlrpc_import_flush_my_ctx(struct obd_import *imp)
{
import_flush_ctx_common(imp, from_kuid(&init_user_ns, current_uid()),
@@ -1585,8 +1529,8 @@ void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req)
void _sptlrpc_enlarge_msg_inplace(struct lustre_msg *msg,
int segment, int newsize)
{
- void *src, *dst;
- int oldsize, oldmsg_size, movesize;
+ void *src, *dst;
+ int oldsize, oldmsg_size, movesize;
LASSERT(segment < msg->lm_bufcount);
LASSERT(msg->lm_buflens[segment] <= newsize);
@@ -1635,9 +1579,9 @@ EXPORT_SYMBOL(_sptlrpc_enlarge_msg_inplace);
int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req,
int segment, int newsize)
{
- struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
- struct ptlrpc_sec_cops *cops;
- struct lustre_msg *msg = req->rq_reqmsg;
+ struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
+ struct ptlrpc_sec_cops *cops;
+ struct lustre_msg *msg = req->rq_reqmsg;
LASSERT(ctx);
LASSERT(msg);
@@ -1697,18 +1641,8 @@ void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req)
req->rq_repmsg = NULL;
}
-int sptlrpc_cli_install_rvs_ctx(struct obd_import *imp,
- struct ptlrpc_cli_ctx *ctx)
-{
- struct ptlrpc_sec_policy *policy = ctx->cc_sec->ps_policy;
-
- if (!policy->sp_cops->install_rctx)
- return 0;
- return policy->sp_cops->install_rctx(imp, ctx->cc_sec, ctx);
-}
-
-int sptlrpc_svc_install_rvs_ctx(struct obd_import *imp,
- struct ptlrpc_svc_ctx *ctx)
+static int sptlrpc_svc_install_rvs_ctx(struct obd_import *imp,
+ struct ptlrpc_svc_ctx *ctx)
{
struct ptlrpc_sec_policy *policy = ctx->sc_policy;
@@ -1748,7 +1682,7 @@ static int flavor_allowed(struct sptlrpc_flavor *exp,
int sptlrpc_target_export_check(struct obd_export *exp,
struct ptlrpc_request *req)
{
- struct sptlrpc_flavor flavor;
+ struct sptlrpc_flavor flavor;
if (exp == NULL)
return 0;
@@ -1779,7 +1713,7 @@ int sptlrpc_target_export_check(struct obd_export *exp,
exp->exp_flvr_old[1] = exp->exp_flvr_old[0];
exp->exp_flvr_expire[1] = exp->exp_flvr_expire[0];
exp->exp_flvr_old[0] = exp->exp_flvr;
- exp->exp_flvr_expire[0] = get_seconds() +
+ exp->exp_flvr_expire[0] = ktime_get_real_seconds() +
EXP_FLVR_UPDATE_EXPIRE;
exp->exp_flvr = flavor;
@@ -1853,14 +1787,14 @@ int sptlrpc_target_export_check(struct obd_export *exp,
}
if (exp->exp_flvr_expire[0]) {
- if (exp->exp_flvr_expire[0] >= get_seconds()) {
+ if (exp->exp_flvr_expire[0] >= ktime_get_real_seconds()) {
if (flavor_allowed(&exp->exp_flvr_old[0], req)) {
- CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the middle one (" CFS_DURATION_T ")\n", exp,
+ CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the middle one (%lld)\n", exp,
exp->exp_flvr.sf_rpc,
exp->exp_flvr_old[0].sf_rpc,
exp->exp_flvr_old[1].sf_rpc,
- exp->exp_flvr_expire[0] -
- get_seconds());
+ (s64)(exp->exp_flvr_expire[0] -
+ ktime_get_real_seconds()));
spin_unlock(&exp->exp_lock);
return 0;
}
@@ -1877,15 +1811,15 @@ int sptlrpc_target_export_check(struct obd_export *exp,
/* now it doesn't match the current flavor, the only chance we can
* accept it is match the old flavors which is not expired. */
if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) {
- if (exp->exp_flvr_expire[1] >= get_seconds()) {
+ if (exp->exp_flvr_expire[1] >= ktime_get_real_seconds()) {
if (flavor_allowed(&exp->exp_flvr_old[1], req)) {
- CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the oldest one (" CFS_DURATION_T ")\n",
+ CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the oldest one (%lld)\n",
exp,
exp->exp_flvr.sf_rpc,
exp->exp_flvr_old[0].sf_rpc,
exp->exp_flvr_old[1].sf_rpc,
- exp->exp_flvr_expire[1] -
- get_seconds());
+ (s64)(exp->exp_flvr_expire[1] -
+ ktime_get_real_seconds()));
spin_unlock(&exp->exp_lock);
return 0;
}
@@ -1905,7 +1839,7 @@ int sptlrpc_target_export_check(struct obd_export *exp,
spin_unlock(&exp->exp_lock);
- CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with unauthorized flavor %x, expect %x|%x(%+ld)|%x(%+ld)\n",
+ CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with unauthorized flavor %x, expect %x|%x(%+lld)|%x(%+lld)\n",
exp, exp->exp_obd->obd_name,
req, req->rq_auth_gss, req->rq_ctx_init, req->rq_ctx_fini,
req->rq_auth_usr_root, req->rq_auth_usr_mdt, req->rq_auth_usr_ost,
@@ -1913,56 +1847,14 @@ int sptlrpc_target_export_check(struct obd_export *exp,
exp->exp_flvr.sf_rpc,
exp->exp_flvr_old[0].sf_rpc,
exp->exp_flvr_expire[0] ?
- (unsigned long) (exp->exp_flvr_expire[0] -
- get_seconds()) : 0,
+ (s64)(exp->exp_flvr_expire[0] - ktime_get_real_seconds()) : 0,
exp->exp_flvr_old[1].sf_rpc,
exp->exp_flvr_expire[1] ?
- (unsigned long) (exp->exp_flvr_expire[1] -
- get_seconds()) : 0);
+ (s64)(exp->exp_flvr_expire[1] - ktime_get_real_seconds()) : 0);
return -EACCES;
}
EXPORT_SYMBOL(sptlrpc_target_export_check);
-void sptlrpc_target_update_exp_flavor(struct obd_device *obd,
- struct sptlrpc_rule_set *rset)
-{
- struct obd_export *exp;
- struct sptlrpc_flavor new_flvr;
-
- LASSERT(obd);
-
- spin_lock(&obd->obd_dev_lock);
-
- list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) {
- if (exp->exp_connection == NULL)
- continue;
-
- /* note if this export had just been updated flavor
- * (exp_flvr_changed == 1), this will override the
- * previous one. */
- spin_lock(&exp->exp_lock);
- sptlrpc_target_choose_flavor(rset, exp->exp_sp_peer,
- exp->exp_connection->c_peer.nid,
- &new_flvr);
- if (exp->exp_flvr_changed ||
- !flavor_equal(&new_flvr, &exp->exp_flvr)) {
- exp->exp_flvr_old[1] = new_flvr;
- exp->exp_flvr_expire[1] = 0;
- exp->exp_flvr_changed = 1;
- exp->exp_flvr_adapt = 1;
-
- CDEBUG(D_SEC, "exp %p (%s): updated flavor %x->%x\n",
- exp, sptlrpc_part2name(exp->exp_sp_peer),
- exp->exp_flvr.sf_rpc,
- exp->exp_flvr_old[1].sf_rpc);
- }
- spin_unlock(&exp->exp_lock);
- }
-
- spin_unlock(&obd->obd_dev_lock);
-}
-EXPORT_SYMBOL(sptlrpc_target_update_exp_flavor);
-
static int sptlrpc_svc_check_from(struct ptlrpc_request *req, int svc_rc)
{
/* peer's claim is unreliable unless gss is being used */
@@ -2019,8 +1911,8 @@ static int sptlrpc_svc_check_from(struct ptlrpc_request *req, int svc_rc)
int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req)
{
struct ptlrpc_sec_policy *policy;
- struct lustre_msg *msg = req->rq_reqbuf;
- int rc;
+ struct lustre_msg *msg = req->rq_reqbuf;
+ int rc;
LASSERT(msg);
LASSERT(req->rq_reqmsg == NULL);
@@ -2090,6 +1982,7 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen)
rc = policy->sp_sops->alloc_rs(req, msglen);
if (unlikely(rc == -ENOMEM)) {
struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
+
if (svcpt->scp_service->srv_max_reply_size <
msglen + sizeof(struct ptlrpc_reply_state)) {
/* Just return failure if the size is too big */
@@ -2185,19 +2078,6 @@ void sptlrpc_svc_ctx_decref(struct ptlrpc_request *req)
req->rq_svc_ctx = NULL;
}
-void sptlrpc_svc_ctx_invalidate(struct ptlrpc_request *req)
-{
- struct ptlrpc_svc_ctx *ctx = req->rq_svc_ctx;
-
- if (ctx == NULL)
- return;
-
- LASSERT_ATOMIC_POS(&ctx->sc_refcount);
- if (ctx->sc_policy->sp_sops->invalidate_ctx)
- ctx->sc_policy->sp_sops->invalidate_ctx(ctx);
-}
-EXPORT_SYMBOL(sptlrpc_svc_ctx_invalidate);
-
/****************************************
* bulk security *
****************************************/
@@ -2231,8 +2111,8 @@ int sptlrpc_cli_unwrap_bulk_read(struct ptlrpc_request *req,
struct ptlrpc_bulk_desc *desc,
int nob)
{
- struct ptlrpc_cli_ctx *ctx;
- int rc;
+ struct ptlrpc_cli_ctx *ctx;
+ int rc;
LASSERT(req->rq_bulk_read && !req->rq_bulk_write);
@@ -2256,8 +2136,8 @@ EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_read);
int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req,
struct ptlrpc_bulk_desc *desc)
{
- struct ptlrpc_cli_ctx *ctx;
- int rc;
+ struct ptlrpc_cli_ctx *ctx;
+ int rc;
LASSERT(!req->rq_bulk_read && req->rq_bulk_write);
@@ -2285,7 +2165,6 @@ int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req,
}
EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_write);
-
/****************************************
* user descriptor helpers *
****************************************/
@@ -2329,7 +2208,7 @@ EXPORT_SYMBOL(sptlrpc_pack_user_desc);
int sptlrpc_unpack_user_desc(struct lustre_msg *msg, int offset, int swabbed)
{
struct ptlrpc_user_desc *pud;
- int i;
+ int i;
pud = lustre_msg_buf(msg, offset, sizeof(*pud));
if (!pud)
@@ -2382,14 +2261,14 @@ EXPORT_SYMBOL(sec2target_str);
/*
* return true if the bulk data is protected
*/
-int sptlrpc_flavor_has_bulk(struct sptlrpc_flavor *flvr)
+bool sptlrpc_flavor_has_bulk(struct sptlrpc_flavor *flvr)
{
switch (SPTLRPC_FLVR_BULK_SVC(flvr->sf_rpc)) {
case SPTLRPC_BULK_SVC_INTG:
case SPTLRPC_BULK_SVC_PRIV:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
EXPORT_SYMBOL(sptlrpc_flavor_has_bulk);
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index c05a8554d..cd8a9987f 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
@@ -58,11 +58,10 @@
* bulk encryption page pools *
****************************************/
-
#define POINTERS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *))
#define PAGES_PER_POOL (POINTERS_PER_PAGE)
-#define IDLE_IDX_MAX (100)
+#define IDLE_IDX_MAX (100)
#define IDLE_IDX_WEIGHT (3)
#define CACHE_QUIESCENT_PERIOD (20)
@@ -92,8 +91,8 @@ static struct ptlrpc_enc_page_pool {
unsigned long epp_idle_idx;
/* last shrink time due to mem tight */
- long epp_last_shrink;
- long epp_last_access;
+ time64_t epp_last_shrink;
+ time64_t epp_last_access;
/*
* in-pool pages bookkeeping
@@ -145,7 +144,7 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v)
"cache missing: %lu\n"
"low free mark: %lu\n"
"max waitqueue depth: %u\n"
- "max wait time: " CFS_TIME_T "/%u\n",
+ "max wait time: %ld/%u\n",
totalram_pages,
PAGES_PER_POOL,
page_pools.epp_max_pages,
@@ -153,8 +152,8 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v)
page_pools.epp_total_pages,
page_pools.epp_free_pages,
page_pools.epp_idle_idx,
- get_seconds() - page_pools.epp_last_shrink,
- get_seconds() - page_pools.epp_last_access,
+ (long)(ktime_get_seconds() - page_pools.epp_last_shrink),
+ (long)(ktime_get_seconds() - page_pools.epp_last_access),
page_pools.epp_st_max_pages,
page_pools.epp_st_grows,
page_pools.epp_st_grow_fails,
@@ -173,8 +172,8 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v)
static void enc_pools_release_free_pages(long npages)
{
- int p_idx, g_idx;
- int p_idx_max1, p_idx_max2;
+ int p_idx, g_idx;
+ int p_idx_max1, p_idx_max2;
LASSERT(npages > 0);
LASSERT(npages <= page_pools.epp_free_pages);
@@ -210,7 +209,7 @@ static void enc_pools_release_free_pages(long npages)
/* free unused pools */
while (p_idx_max1 < p_idx_max2) {
LASSERT(page_pools.epp_pools[p_idx_max2]);
- OBD_FREE(page_pools.epp_pools[p_idx_max2], PAGE_CACHE_SIZE);
+ kfree(page_pools.epp_pools[p_idx_max2]);
page_pools.epp_pools[p_idx_max2] = NULL;
p_idx_max2--;
}
@@ -226,7 +225,7 @@ static unsigned long enc_pools_shrink_count(struct shrinker *s,
* if no pool access for a long time, we consider it's fully idle.
* a little race here is fine.
*/
- if (unlikely(get_seconds() - page_pools.epp_last_access >
+ if (unlikely(ktime_get_seconds() - page_pools.epp_last_access >
CACHE_QUIESCENT_PERIOD)) {
spin_lock(&page_pools.epp_lock);
page_pools.epp_idle_idx = IDLE_IDX_MAX;
@@ -253,7 +252,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s,
(long)sc->nr_to_scan, page_pools.epp_free_pages);
page_pools.epp_st_shrinks++;
- page_pools.epp_last_shrink = get_seconds();
+ page_pools.epp_last_shrink = ktime_get_seconds();
}
spin_unlock(&page_pools.epp_lock);
@@ -261,7 +260,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s,
* if no pool access for a long time, we consider it's fully idle.
* a little race here is fine.
*/
- if (unlikely(get_seconds() - page_pools.epp_last_access >
+ if (unlikely(ktime_get_seconds() - page_pools.epp_last_access >
CACHE_QUIESCENT_PERIOD)) {
spin_lock(&page_pools.epp_lock);
page_pools.epp_idle_idx = IDLE_IDX_MAX;
@@ -284,7 +283,7 @@ int npages_to_npools(unsigned long npages)
static unsigned long enc_pools_cleanup(struct page ***pools, int npools)
{
unsigned long cleaned = 0;
- int i, j;
+ int i, j;
for (i = 0; i < npools; i++) {
if (pools[i]) {
@@ -294,7 +293,7 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools)
cleaned++;
}
}
- OBD_FREE(pools[i], PAGE_CACHE_SIZE);
+ kfree(pools[i]);
pools[i] = NULL;
}
}
@@ -302,150 +301,6 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools)
return cleaned;
}
-/*
- * merge @npools pointed by @pools which contains @npages new pages
- * into current pools.
- *
- * we have options to avoid most memory copy with some tricks. but we choose
- * the simplest way to avoid complexity. It's not frequently called.
- */
-static void enc_pools_insert(struct page ***pools, int npools, int npages)
-{
- int freeslot;
- int op_idx, np_idx, og_idx, ng_idx;
- int cur_npools, end_npools;
-
- LASSERT(npages > 0);
- LASSERT(page_pools.epp_total_pages+npages <= page_pools.epp_max_pages);
- LASSERT(npages_to_npools(npages) == npools);
- LASSERT(page_pools.epp_growing);
-
- spin_lock(&page_pools.epp_lock);
-
- /*
- * (1) fill all the free slots of current pools.
- */
- /* free slots are those left by rent pages, and the extra ones with
- * index >= total_pages, locate at the tail of last pool. */
- freeslot = page_pools.epp_total_pages % PAGES_PER_POOL;
- if (freeslot != 0)
- freeslot = PAGES_PER_POOL - freeslot;
- freeslot += page_pools.epp_total_pages - page_pools.epp_free_pages;
-
- op_idx = page_pools.epp_free_pages / PAGES_PER_POOL;
- og_idx = page_pools.epp_free_pages % PAGES_PER_POOL;
- np_idx = npools - 1;
- ng_idx = (npages - 1) % PAGES_PER_POOL;
-
- while (freeslot) {
- LASSERT(page_pools.epp_pools[op_idx][og_idx] == NULL);
- LASSERT(pools[np_idx][ng_idx] != NULL);
-
- page_pools.epp_pools[op_idx][og_idx] = pools[np_idx][ng_idx];
- pools[np_idx][ng_idx] = NULL;
-
- freeslot--;
-
- if (++og_idx == PAGES_PER_POOL) {
- op_idx++;
- og_idx = 0;
- }
- if (--ng_idx < 0) {
- if (np_idx == 0)
- break;
- np_idx--;
- ng_idx = PAGES_PER_POOL - 1;
- }
- }
-
- /*
- * (2) add pools if needed.
- */
- cur_npools = (page_pools.epp_total_pages + PAGES_PER_POOL - 1) /
- PAGES_PER_POOL;
- end_npools = (page_pools.epp_total_pages + npages + PAGES_PER_POOL - 1)
- / PAGES_PER_POOL;
- LASSERT(end_npools <= page_pools.epp_max_pools);
-
- np_idx = 0;
- while (cur_npools < end_npools) {
- LASSERT(page_pools.epp_pools[cur_npools] == NULL);
- LASSERT(np_idx < npools);
- LASSERT(pools[np_idx] != NULL);
-
- page_pools.epp_pools[cur_npools++] = pools[np_idx];
- pools[np_idx++] = NULL;
- }
-
- page_pools.epp_total_pages += npages;
- page_pools.epp_free_pages += npages;
- page_pools.epp_st_lowfree = page_pools.epp_free_pages;
-
- if (page_pools.epp_total_pages > page_pools.epp_st_max_pages)
- page_pools.epp_st_max_pages = page_pools.epp_total_pages;
-
- CDEBUG(D_SEC, "add %d pages to total %lu\n", npages,
- page_pools.epp_total_pages);
-
- spin_unlock(&page_pools.epp_lock);
-}
-
-static int enc_pools_add_pages(int npages)
-{
- static DEFINE_MUTEX(add_pages_mutex);
- struct page ***pools;
- int npools, alloced = 0;
- int i, j, rc = -ENOMEM;
-
- if (npages < PTLRPC_MAX_BRW_PAGES)
- npages = PTLRPC_MAX_BRW_PAGES;
-
- mutex_lock(&add_pages_mutex);
-
- if (npages + page_pools.epp_total_pages > page_pools.epp_max_pages)
- npages = page_pools.epp_max_pages - page_pools.epp_total_pages;
- LASSERT(npages > 0);
-
- page_pools.epp_st_grows++;
-
- npools = npages_to_npools(npages);
- OBD_ALLOC(pools, npools * sizeof(*pools));
- if (pools == NULL)
- goto out;
-
- for (i = 0; i < npools; i++) {
- OBD_ALLOC(pools[i], PAGE_CACHE_SIZE);
- if (pools[i] == NULL)
- goto out_pools;
-
- for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) {
- pools[i][j] = alloc_page(GFP_NOFS |
- __GFP_HIGHMEM);
- if (pools[i][j] == NULL)
- goto out_pools;
-
- alloced++;
- }
- }
- LASSERT(alloced == npages);
-
- enc_pools_insert(pools, npools, npages);
- CDEBUG(D_SEC, "added %d pages into pools\n", npages);
- rc = 0;
-
-out_pools:
- enc_pools_cleanup(pools, npools);
- OBD_FREE(pools, npools * sizeof(*pools));
-out:
- if (rc) {
- page_pools.epp_st_grow_fails++;
- CERROR("Failed to allocate %d enc pages\n", npages);
- }
-
- mutex_unlock(&add_pages_mutex);
- return rc;
-}
-
static inline void enc_pools_wakeup(void)
{
assert_spin_locked(&page_pools.epp_lock);
@@ -457,160 +312,10 @@ static inline void enc_pools_wakeup(void)
}
}
-static int enc_pools_should_grow(int page_needed, long now)
-{
- /* don't grow if someone else is growing the pools right now,
- * or the pools has reached its full capacity
- */
- if (page_pools.epp_growing ||
- page_pools.epp_total_pages == page_pools.epp_max_pages)
- return 0;
-
- /* if total pages is not enough, we need to grow */
- if (page_pools.epp_total_pages < page_needed)
- return 1;
-
- /*
- * we wanted to return 0 here if there was a shrink just happened
- * moment ago, but this may cause deadlock if both client and ost
- * live on single node.
- */
-#if 0
- if (now - page_pools.epp_last_shrink < 2)
- return 0;
-#endif
-
- /*
- * here we perhaps need consider other factors like wait queue
- * length, idle index, etc. ?
- */
-
- /* grow the pools in any other cases */
- return 1;
-}
-
-/*
- * we allocate the requested pages atomically.
- */
-int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc)
-{
- wait_queue_t waitlink;
- unsigned long this_idle = -1;
- unsigned long tick = 0;
- long now;
- int p_idx, g_idx;
- int i;
-
- LASSERT(desc->bd_iov_count > 0);
- LASSERT(desc->bd_iov_count <= page_pools.epp_max_pages);
-
- /* resent bulk, enc iov might have been allocated previously */
- if (desc->bd_enc_iov != NULL)
- return 0;
-
- OBD_ALLOC(desc->bd_enc_iov,
- desc->bd_iov_count * sizeof(*desc->bd_enc_iov));
- if (desc->bd_enc_iov == NULL)
- return -ENOMEM;
-
- spin_lock(&page_pools.epp_lock);
-
- page_pools.epp_st_access++;
-again:
- if (unlikely(page_pools.epp_free_pages < desc->bd_iov_count)) {
- if (tick == 0)
- tick = cfs_time_current();
-
- now = get_seconds();
-
- page_pools.epp_st_missings++;
- page_pools.epp_pages_short += desc->bd_iov_count;
-
- if (enc_pools_should_grow(desc->bd_iov_count, now)) {
- page_pools.epp_growing = 1;
-
- spin_unlock(&page_pools.epp_lock);
- enc_pools_add_pages(page_pools.epp_pages_short / 2);
- spin_lock(&page_pools.epp_lock);
-
- page_pools.epp_growing = 0;
-
- enc_pools_wakeup();
- } else {
- if (++page_pools.epp_waitqlen >
- page_pools.epp_st_max_wqlen)
- page_pools.epp_st_max_wqlen =
- page_pools.epp_waitqlen;
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- init_waitqueue_entry(&waitlink, current);
- add_wait_queue(&page_pools.epp_waitq, &waitlink);
-
- spin_unlock(&page_pools.epp_lock);
- schedule();
- remove_wait_queue(&page_pools.epp_waitq, &waitlink);
- LASSERT(page_pools.epp_waitqlen > 0);
- spin_lock(&page_pools.epp_lock);
- page_pools.epp_waitqlen--;
- }
-
- LASSERT(page_pools.epp_pages_short >= desc->bd_iov_count);
- page_pools.epp_pages_short -= desc->bd_iov_count;
-
- this_idle = 0;
- goto again;
- }
-
- /* record max wait time */
- if (unlikely(tick != 0)) {
- tick = cfs_time_current() - tick;
- if (tick > page_pools.epp_st_max_wait)
- page_pools.epp_st_max_wait = tick;
- }
-
- /* proceed with rest of allocation */
- page_pools.epp_free_pages -= desc->bd_iov_count;
-
- p_idx = page_pools.epp_free_pages / PAGES_PER_POOL;
- g_idx = page_pools.epp_free_pages % PAGES_PER_POOL;
-
- for (i = 0; i < desc->bd_iov_count; i++) {
- LASSERT(page_pools.epp_pools[p_idx][g_idx] != NULL);
- desc->bd_enc_iov[i].kiov_page =
- page_pools.epp_pools[p_idx][g_idx];
- page_pools.epp_pools[p_idx][g_idx] = NULL;
-
- if (++g_idx == PAGES_PER_POOL) {
- p_idx++;
- g_idx = 0;
- }
- }
-
- if (page_pools.epp_free_pages < page_pools.epp_st_lowfree)
- page_pools.epp_st_lowfree = page_pools.epp_free_pages;
-
- /*
- * new idle index = (old * weight + new) / (weight + 1)
- */
- if (this_idle == -1) {
- this_idle = page_pools.epp_free_pages * IDLE_IDX_MAX /
- page_pools.epp_total_pages;
- }
- page_pools.epp_idle_idx = (page_pools.epp_idle_idx * IDLE_IDX_WEIGHT +
- this_idle) /
- (IDLE_IDX_WEIGHT + 1);
-
- page_pools.epp_last_access = get_seconds();
-
- spin_unlock(&page_pools.epp_lock);
- return 0;
-}
-EXPORT_SYMBOL(sptlrpc_enc_pool_get_pages);
-
void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
{
- int p_idx, g_idx;
- int i;
+ int p_idx, g_idx;
+ int i;
if (desc->bd_enc_iov == NULL)
return;
@@ -646,53 +351,18 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
spin_unlock(&page_pools.epp_lock);
- OBD_FREE(desc->bd_enc_iov,
- desc->bd_iov_count * sizeof(*desc->bd_enc_iov));
+ kfree(desc->bd_enc_iov);
desc->bd_enc_iov = NULL;
}
EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages);
-/*
- * we don't do much stuff for add_user/del_user anymore, except adding some
- * initial pages in add_user() if current pools are empty, rest would be
- * handled by the pools's self-adaption.
- */
-int sptlrpc_enc_pool_add_user(void)
-{
- int need_grow = 0;
-
- spin_lock(&page_pools.epp_lock);
- if (page_pools.epp_growing == 0 && page_pools.epp_total_pages == 0) {
- page_pools.epp_growing = 1;
- need_grow = 1;
- }
- spin_unlock(&page_pools.epp_lock);
-
- if (need_grow) {
- enc_pools_add_pages(PTLRPC_MAX_BRW_PAGES +
- PTLRPC_MAX_BRW_PAGES);
-
- spin_lock(&page_pools.epp_lock);
- page_pools.epp_growing = 0;
- enc_pools_wakeup();
- spin_unlock(&page_pools.epp_lock);
- }
- return 0;
-}
-EXPORT_SYMBOL(sptlrpc_enc_pool_add_user);
-
-int sptlrpc_enc_pool_del_user(void)
-{
- return 0;
-}
-EXPORT_SYMBOL(sptlrpc_enc_pool_del_user);
-
static inline void enc_pools_alloc(void)
{
LASSERT(page_pools.epp_max_pools);
- OBD_ALLOC_LARGE(page_pools.epp_pools,
- page_pools.epp_max_pools *
- sizeof(*page_pools.epp_pools));
+ page_pools.epp_pools =
+ libcfs_kvzalloc(page_pools.epp_max_pools *
+ sizeof(*page_pools.epp_pools),
+ GFP_NOFS);
}
static inline void enc_pools_free(void)
@@ -700,9 +370,7 @@ static inline void enc_pools_free(void)
LASSERT(page_pools.epp_max_pools);
LASSERT(page_pools.epp_pools);
- OBD_FREE_LARGE(page_pools.epp_pools,
- page_pools.epp_max_pools *
- sizeof(*page_pools.epp_pools));
+ kvfree(page_pools.epp_pools);
}
static struct shrinker pools_shrinker = {
@@ -727,8 +395,8 @@ int sptlrpc_enc_pool_init(void)
page_pools.epp_growing = 0;
page_pools.epp_idle_idx = 0;
- page_pools.epp_last_shrink = get_seconds();
- page_pools.epp_last_access = get_seconds();
+ page_pools.epp_last_shrink = ktime_get_seconds();
+ page_pools.epp_last_access = ktime_get_seconds();
spin_lock_init(&page_pools.epp_lock);
page_pools.epp_total_pages = 0;
@@ -770,8 +438,7 @@ void sptlrpc_enc_pool_fini(void)
if (page_pools.epp_st_access > 0) {
CDEBUG(D_SEC,
- "max pages %lu, grows %u, grow fails %u, shrinks %u, access %lu, missing %lu, max qlen %u, max wait "
- CFS_TIME_T"/%d\n",
+ "max pages %lu, grows %u, grow fails %u, shrinks %u, access %lu, missing %lu, max qlen %u, max wait %ld/%d\n",
page_pools.epp_st_max_pages, page_pools.epp_st_grows,
page_pools.epp_st_grow_fails,
page_pools.epp_st_shrinks, page_pools.epp_st_access,
@@ -780,7 +447,6 @@ void sptlrpc_enc_pool_fini(void)
}
}
-
static int cfs_hash_alg_id[] = {
[BULK_HASH_ALG_NULL] = CFS_HASH_ALG_NULL,
[BULK_HASH_ALG_ADLER32] = CFS_HASH_ALG_ADLER32,
@@ -791,6 +457,7 @@ static int cfs_hash_alg_id[] = {
[BULK_HASH_ALG_SHA384] = CFS_HASH_ALG_SHA384,
[BULK_HASH_ALG_SHA512] = CFS_HASH_ALG_SHA512,
};
+
const char *sptlrpc_get_hash_name(__u8 hash_alg)
{
return cfs_crypto_hash_name(cfs_hash_alg_id[hash_alg]);
@@ -843,11 +510,11 @@ EXPORT_SYMBOL(bulk_sec_desc_unpack);
int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg,
void *buf, int buflen)
{
- struct cfs_crypto_hash_desc *hdesc;
- int hashsize;
- char hashbuf[64];
- unsigned int bufsize;
- int i, err;
+ struct cfs_crypto_hash_desc *hdesc;
+ int hashsize;
+ char hashbuf[64];
+ unsigned int bufsize;
+ int i, err;
LASSERT(alg > BULK_HASH_ALG_NULL && alg < BULK_HASH_ALG_MAX);
LASSERT(buflen >= 4);
@@ -873,8 +540,7 @@ int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg,
memcpy(buf, hashbuf, buflen);
} else {
bufsize = buflen;
- err = cfs_crypto_hash_final(hdesc, (unsigned char *)buf,
- &bufsize);
+ err = cfs_crypto_hash_final(hdesc, buf, &bufsize);
}
if (err)
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
index 56ba9e4e5..7ff948fe1 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
@@ -48,27 +48,6 @@
#include "ptlrpc_internal.h"
-const char *sptlrpc_part2name(enum lustre_sec_part part)
-{
- switch (part) {
- case LUSTRE_SP_CLI:
- return "cli";
- case LUSTRE_SP_MDT:
- return "mdt";
- case LUSTRE_SP_OST:
- return "ost";
- case LUSTRE_SP_MGC:
- return "mgc";
- case LUSTRE_SP_MGS:
- return "mgs";
- case LUSTRE_SP_ANY:
- return "any";
- default:
- return "err";
- }
-}
-EXPORT_SYMBOL(sptlrpc_part2name);
-
enum lustre_sec_part sptlrpc_target_sec_part(struct obd_device *obd)
{
const char *type = obd->obd_type->typ_name;
@@ -94,8 +73,8 @@ EXPORT_SYMBOL(sptlrpc_target_sec_part);
*/
int sptlrpc_parse_flavor(const char *str, struct sptlrpc_flavor *flvr)
{
- char buf[32];
- char *bulk, *alg;
+ char buf[32];
+ char *bulk, *alg;
memset(flvr, 0, sizeof(*flvr));
@@ -180,10 +159,10 @@ static void sptlrpc_rule_init(struct sptlrpc_rule *rule)
/*
* format: network[.direction]=flavor
*/
-int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule)
+static int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule)
{
- char *flavor, *dir;
- int rc;
+ char *flavor, *dir;
+ int rc;
sptlrpc_rule_init(rule);
@@ -234,25 +213,22 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule)
return 0;
}
-EXPORT_SYMBOL(sptlrpc_parse_rule);
-void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset)
+static void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset)
{
LASSERT(rset->srs_nslot ||
(rset->srs_nrule == 0 && rset->srs_rules == NULL));
if (rset->srs_nslot) {
- OBD_FREE(rset->srs_rules,
- rset->srs_nslot * sizeof(*rset->srs_rules));
+ kfree(rset->srs_rules);
sptlrpc_rule_set_init(rset);
}
}
-EXPORT_SYMBOL(sptlrpc_rule_set_free);
/*
* return 0 if the rule set could accommodate one more rule.
*/
-int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
+static int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
{
struct sptlrpc_rule *rules;
int nslot;
@@ -265,7 +241,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
nslot = rset->srs_nslot + 8;
/* better use realloc() if available */
- OBD_ALLOC(rules, nslot * sizeof(*rset->srs_rules));
+ rules = kcalloc(nslot, sizeof(*rset->srs_rules), GFP_NOFS);
if (rules == NULL)
return -ENOMEM;
@@ -274,30 +250,31 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
memcpy(rules, rset->srs_rules,
rset->srs_nrule * sizeof(*rset->srs_rules));
- OBD_FREE(rset->srs_rules,
- rset->srs_nslot * sizeof(*rset->srs_rules));
+ kfree(rset->srs_rules);
}
rset->srs_rules = rules;
rset->srs_nslot = nslot;
return 0;
}
-EXPORT_SYMBOL(sptlrpc_rule_set_expand);
static inline int rule_spec_dir(struct sptlrpc_rule *rule)
{
return (rule->sr_from != LUSTRE_SP_ANY ||
rule->sr_to != LUSTRE_SP_ANY);
}
+
static inline int rule_spec_net(struct sptlrpc_rule *rule)
{
return (rule->sr_netid != LNET_NIDNET(LNET_NID_ANY));
}
+
static inline int rule_match_dir(struct sptlrpc_rule *r1,
struct sptlrpc_rule *r2)
{
return (r1->sr_from == r2->sr_from && r1->sr_to == r2->sr_to);
}
+
static inline int rule_match_net(struct sptlrpc_rule *r1,
struct sptlrpc_rule *r2)
{
@@ -308,12 +285,12 @@ static inline int rule_match_net(struct sptlrpc_rule *r1,
* merge @rule into @rset.
* the @rset slots might be expanded.
*/
-int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset,
- struct sptlrpc_rule *rule)
+static int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset,
+ struct sptlrpc_rule *rule)
{
- struct sptlrpc_rule *p = rset->srs_rules;
- int spec_dir, spec_net;
- int rc, n, match = 0;
+ struct sptlrpc_rule *p = rset->srs_rules;
+ int spec_dir, spec_net;
+ int rc, n, match = 0;
might_sleep();
@@ -393,20 +370,19 @@ int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset,
return 0;
}
-EXPORT_SYMBOL(sptlrpc_rule_set_merge);
/**
* given from/to/nid, determine a matching flavor in ruleset.
* return 1 if a match found, otherwise return 0.
*/
-int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
- enum lustre_sec_part from,
- enum lustre_sec_part to,
- lnet_nid_t nid,
- struct sptlrpc_flavor *sf)
+static int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
+ enum lustre_sec_part from,
+ enum lustre_sec_part to,
+ lnet_nid_t nid,
+ struct sptlrpc_flavor *sf)
{
- struct sptlrpc_rule *r;
- int n;
+ struct sptlrpc_rule *r;
+ int n;
for (n = 0; n < rset->srs_nrule; n++) {
r = &rset->srs_rules[n];
@@ -430,20 +406,6 @@ int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
return 0;
}
-EXPORT_SYMBOL(sptlrpc_rule_set_choose);
-
-void sptlrpc_rule_set_dump(struct sptlrpc_rule_set *rset)
-{
- struct sptlrpc_rule *r;
- int n;
-
- for (n = 0; n < rset->srs_nrule; n++) {
- r = &rset->srs_rules[n];
- CDEBUG(D_SEC, "<%02d> from %x to %x, net %x, rpc %x\n", n,
- r->sr_from, r->sr_to, r->sr_netid, r->sr_flvr.sf_rpc);
- }
-}
-EXPORT_SYMBOL(sptlrpc_rule_set_dump);
/**********************************
* sptlrpc configuration support *
@@ -476,8 +438,8 @@ static inline int is_hex(char c)
static void target2fsname(const char *tgt, char *fsname, int buflen)
{
- const char *ptr;
- int len;
+ const char *ptr;
+ int len;
ptr = strrchr(tgt, '-');
if (ptr) {
@@ -509,7 +471,7 @@ static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf)
&conf->sc_tgts, sct_list) {
sptlrpc_rule_set_free(&conf_tgt->sct_rset);
list_del(&conf_tgt->sct_list);
- OBD_FREE_PTR(conf_tgt);
+ kfree(conf_tgt);
}
LASSERT(list_empty(&conf->sc_tgts));
@@ -523,7 +485,7 @@ static void sptlrpc_conf_free(struct sptlrpc_conf *conf)
sptlrpc_conf_free_rsets(conf);
list_del(&conf->sc_list);
- OBD_FREE_PTR(conf);
+ kfree(conf);
}
static
@@ -541,7 +503,7 @@ struct sptlrpc_conf_tgt *sptlrpc_conf_get_tgt(struct sptlrpc_conf *conf,
if (!create)
return NULL;
- OBD_ALLOC_PTR(conf_tgt);
+ conf_tgt = kzalloc(sizeof(*conf_tgt), GFP_NOFS);
if (conf_tgt) {
strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name));
sptlrpc_rule_set_init(&conf_tgt->sct_rset);
@@ -565,8 +527,8 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname,
if (!create)
return NULL;
- OBD_ALLOC_PTR(conf);
- if (conf == NULL)
+ conf = kzalloc(sizeof(*conf), GFP_NOFS);
+ if (!conf)
return NULL;
strcpy(conf->sc_fsname, fsname);
@@ -585,8 +547,8 @@ static int sptlrpc_conf_merge_rule(struct sptlrpc_conf *conf,
const char *target,
struct sptlrpc_rule *rule)
{
- struct sptlrpc_conf_tgt *conf_tgt;
- struct sptlrpc_rule_set *rule_set;
+ struct sptlrpc_conf_tgt *conf_tgt;
+ struct sptlrpc_rule_set *rule_set;
/* fsname == target means general rules for the whole fs */
if (strcmp(conf->sc_fsname, target) == 0) {
@@ -612,10 +574,10 @@ static int sptlrpc_conf_merge_rule(struct sptlrpc_conf *conf,
static int __sptlrpc_process_config(struct lustre_cfg *lcfg,
struct sptlrpc_conf *conf)
{
- char *target, *param;
- char fsname[MTI_NAME_MAXLEN];
- struct sptlrpc_rule rule;
- int rc;
+ char *target, *param;
+ char fsname[MTI_NAME_MAXLEN];
+ struct sptlrpc_rule rule;
+ int rc;
target = lustre_cfg_string(lcfg, 1);
if (target == NULL) {
@@ -673,8 +635,8 @@ EXPORT_SYMBOL(sptlrpc_process_config);
static int logname2fsname(const char *logname, char *buf, int buflen)
{
- char *ptr;
- int len;
+ char *ptr;
+ int len;
ptr = strrchr(logname, '-');
if (ptr == NULL || strcmp(ptr, "-sptlrpc")) {
@@ -692,7 +654,7 @@ static int logname2fsname(const char *logname, char *buf, int buflen)
void sptlrpc_conf_log_update_begin(const char *logname)
{
struct sptlrpc_conf *conf;
- char fsname[16];
+ char fsname[16];
if (logname2fsname(logname, fsname, sizeof(fsname)))
return;
@@ -718,7 +680,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_update_begin);
void sptlrpc_conf_log_update_end(const char *logname)
{
struct sptlrpc_conf *conf;
- char fsname[16];
+ char fsname[16];
if (logname2fsname(logname, fsname, sizeof(fsname)))
return;
@@ -743,7 +705,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_update_end);
void sptlrpc_conf_log_start(const char *logname)
{
- char fsname[16];
+ char fsname[16];
if (logname2fsname(logname, fsname, sizeof(fsname)))
return;
@@ -757,7 +719,7 @@ EXPORT_SYMBOL(sptlrpc_conf_log_start);
void sptlrpc_conf_log_stop(const char *logname)
{
struct sptlrpc_conf *conf;
- char fsname[16];
+ char fsname[16];
if (logname2fsname(logname, fsname, sizeof(fsname)))
return;
@@ -801,10 +763,10 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from,
lnet_nid_t nid,
struct sptlrpc_flavor *sf)
{
- struct sptlrpc_conf *conf;
+ struct sptlrpc_conf *conf;
struct sptlrpc_conf_tgt *conf_tgt;
- char name[MTI_NAME_MAXLEN];
- int len, rc = 0;
+ char name[MTI_NAME_MAXLEN];
+ int len, rc = 0;
target2fsname(target->uuid, name, sizeof(name));
@@ -838,20 +800,6 @@ out:
flavor_set_flags(sf, from, to, 1);
}
-/**
- * called by target devices, determine the expected flavor from
- * certain peer (from, nid).
- */
-void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
- enum lustre_sec_part from,
- lnet_nid_t nid,
- struct sptlrpc_flavor *sf)
-{
- if (sptlrpc_rule_set_choose(rset, from, LUSTRE_SP_ANY, nid, sf) == 0)
- get_default_flavor(sf);
-}
-EXPORT_SYMBOL(sptlrpc_target_choose_flavor);
-
#define SEC_ADAPT_DELAY (10)
/**
@@ -860,7 +808,7 @@ EXPORT_SYMBOL(sptlrpc_target_choose_flavor);
*/
void sptlrpc_conf_client_adapt(struct obd_device *obd)
{
- struct obd_import *imp;
+ struct obd_import *imp;
LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0);
@@ -873,7 +821,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd)
if (imp) {
spin_lock(&imp->imp_lock);
if (imp->imp_sec)
- imp->imp_sec_expire = get_seconds() +
+ imp->imp_sec_expire = ktime_get_real_seconds() +
SEC_ADAPT_DELAY;
spin_unlock(&imp->imp_lock);
}
@@ -882,7 +830,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd)
}
EXPORT_SYMBOL(sptlrpc_conf_client_adapt);
-int sptlrpc_conf_init(void)
+int sptlrpc_conf_init(void)
{
mutex_init(&sptlrpc_conf_lock);
return 0;
@@ -890,7 +838,7 @@ int sptlrpc_conf_init(void)
void sptlrpc_conf_fini(void)
{
- struct sptlrpc_conf *conf, *conf_next;
+ struct sptlrpc_conf *conf, *conf_next;
mutex_lock(&sptlrpc_conf_lock);
list_for_each_entry_safe(conf, conf_next, &sptlrpc_confs, sc_list) {
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
index 81de68edb..6e58d5f95 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
@@ -51,7 +51,6 @@
#define SEC_GC_INTERVAL (30 * 60)
-
static struct mutex sec_gc_mutex;
static LIST_HEAD(sec_gc_list);
static spinlock_t sec_gc_list_lock;
@@ -62,14 +61,13 @@ static spinlock_t sec_gc_ctx_list_lock;
static struct ptlrpc_thread sec_gc_thread;
static atomic_t sec_gc_wait_del = ATOMIC_INIT(0);
-
void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec)
{
LASSERT(sec->ps_policy->sp_cops->gc_ctx);
LASSERT(sec->ps_gc_interval > 0);
LASSERT(list_empty(&sec->ps_gc_list));
- sec->ps_gc_next = get_seconds() + sec->ps_gc_interval;
+ sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval;
spin_lock(&sec_gc_list_lock);
list_add_tail(&sec_gc_list, &sec->ps_gc_list);
@@ -103,21 +101,6 @@ void sptlrpc_gc_del_sec(struct ptlrpc_sec *sec)
}
EXPORT_SYMBOL(sptlrpc_gc_del_sec);
-void sptlrpc_gc_add_ctx(struct ptlrpc_cli_ctx *ctx)
-{
- LASSERT(list_empty(&ctx->cc_gc_chain));
-
- CDEBUG(D_SEC, "hand over ctx %p(%u->%s)\n",
- ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec));
- spin_lock(&sec_gc_ctx_list_lock);
- list_add(&ctx->cc_gc_chain, &sec_gc_ctx_list);
- spin_unlock(&sec_gc_ctx_list_lock);
-
- thread_add_flags(&sec_gc_thread, SVC_SIGNAL);
- wake_up(&sec_gc_thread.t_ctl_waitq);
-}
-EXPORT_SYMBOL(sptlrpc_gc_add_ctx);
-
static void sec_process_ctx_list(void)
{
struct ptlrpc_cli_ctx *ctx;
@@ -154,17 +137,17 @@ static void sec_do_gc(struct ptlrpc_sec *sec)
CDEBUG(D_SEC, "check on sec %p(%s)\n", sec, sec->ps_policy->sp_name);
- if (cfs_time_after(sec->ps_gc_next, get_seconds()))
+ if (sec->ps_gc_next > ktime_get_real_seconds())
return;
sec->ps_policy->sp_cops->gc_ctx(sec);
- sec->ps_gc_next = get_seconds() + sec->ps_gc_interval;
+ sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval;
}
static int sec_gc_main(void *arg)
{
- struct ptlrpc_thread *thread = (struct ptlrpc_thread *) arg;
- struct l_wait_info lwi;
+ struct ptlrpc_thread *thread = arg;
+ struct l_wait_info lwi;
unshare_fs_struct();
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
index 0d08145a6..bda9a77af 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
@@ -51,10 +51,6 @@
#include "ptlrpc_internal.h"
-
-struct proc_dir_entry *sptlrpc_proc_root = NULL;
-EXPORT_SYMBOL(sptlrpc_proc_root);
-
static char *sec_flags2str(unsigned long flags, char *buf, int bufsize)
{
buf[0] = '\0';
@@ -78,7 +74,7 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v)
struct obd_device *dev = seq->private;
struct client_obd *cli = &dev->u.cli;
struct ptlrpc_sec *sec = NULL;
- char str[32];
+ char str[32];
LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
@@ -102,14 +98,15 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v)
atomic_read(&sec->ps_refcount));
seq_printf(seq, "nctx: %d\n", atomic_read(&sec->ps_nctx));
seq_printf(seq, "gc internal %ld\n", sec->ps_gc_interval);
- seq_printf(seq, "gc next %ld\n",
+ seq_printf(seq, "gc next %lld\n",
sec->ps_gc_interval ?
- sec->ps_gc_next - get_seconds() : 0);
+ (s64)(sec->ps_gc_next - ktime_get_real_seconds()) : 0ll);
sptlrpc_sec_put(sec);
out:
return 0;
}
+
LPROC_SEQ_FOPS_RO(sptlrpc_info_lprocfs);
static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
@@ -134,11 +131,12 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
out:
return 0;
}
+
LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
{
- int rc;
+ int rc;
if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
@@ -148,16 +146,16 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
return -EINVAL;
}
- rc = lprocfs_obd_seq_create(dev, "srpc_info", 0444,
- &sptlrpc_info_lprocfs_fops, dev);
+ rc = ldebugfs_obd_seq_create(dev, "srpc_info", 0444,
+ &sptlrpc_info_lprocfs_fops, dev);
if (rc) {
CERROR("create proc entry srpc_info for %s: %d\n",
dev->obd_name, rc);
return rc;
}
- rc = lprocfs_obd_seq_create(dev, "srpc_contexts", 0444,
- &sptlrpc_ctxs_lprocfs_fops, dev);
+ rc = ldebugfs_obd_seq_create(dev, "srpc_contexts", 0444,
+ &sptlrpc_ctxs_lprocfs_fops, dev);
if (rc) {
CERROR("create proc entry srpc_contexts for %s: %d\n",
dev->obd_name, rc);
@@ -174,17 +172,20 @@ static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
{ NULL }
};
+static struct dentry *sptlrpc_debugfs_dir;
+
int sptlrpc_lproc_init(void)
{
- int rc;
+ int rc;
- LASSERT(sptlrpc_proc_root == NULL);
+ LASSERT(sptlrpc_debugfs_dir == NULL);
- sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
- sptlrpc_lprocfs_vars, NULL);
- if (IS_ERR(sptlrpc_proc_root)) {
- rc = PTR_ERR(sptlrpc_proc_root);
- sptlrpc_proc_root = NULL;
+ sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root,
+ sptlrpc_lprocfs_vars, NULL);
+ if (IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) {
+ rc = sptlrpc_debugfs_dir ? PTR_ERR(sptlrpc_debugfs_dir)
+ : -ENOMEM;
+ sptlrpc_debugfs_dir = NULL;
return rc;
}
return 0;
@@ -192,8 +193,6 @@ int sptlrpc_lproc_init(void)
void sptlrpc_lproc_fini(void)
{
- if (sptlrpc_proc_root) {
- lprocfs_remove(&sptlrpc_proc_root);
- sptlrpc_proc_root = NULL;
- }
+ if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir))
+ ldebugfs_remove(&sptlrpc_debugfs_dir);
}
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_null.c
index 4e132435b..ebfa6092b 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_null.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_null.c
@@ -40,13 +40,14 @@
#define DEBUG_SUBSYSTEM S_SEC
-
#include "../include/obd_support.h"
#include "../include/obd_cksum.h"
#include "../include/obd_class.h"
#include "../include/lustre_net.h"
#include "../include/lustre_sec.h"
+#include "ptlrpc_internal.h"
+
static struct ptlrpc_sec_policy null_policy;
static struct ptlrpc_sec null_sec;
static struct ptlrpc_cli_ctx null_cli_ctx;
@@ -82,6 +83,7 @@ int null_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
if (!req->rq_import->imp_dlm_fake) {
struct obd_device *obd = req->rq_import->imp_obd;
+
null_encode_sec_part(req->rq_reqbuf,
obd->u.cli.cl_sp_me);
}
@@ -92,7 +94,7 @@ int null_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
static
int null_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
{
- __u32 cksums, cksumc;
+ __u32 cksums, cksumc;
LASSERT(req->rq_repdata);
@@ -159,7 +161,7 @@ int null_alloc_reqbuf(struct ptlrpc_sec *sec,
int alloc_size = size_roundup_power2(msgsize);
LASSERT(!req->rq_pool);
- OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_size);
+ req->rq_reqbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS);
if (!req->rq_reqbuf)
return -ENOMEM;
@@ -186,7 +188,7 @@ void null_free_reqbuf(struct ptlrpc_sec *sec,
"req %p: reqlen %d should smaller than buflen %d\n",
req, req->rq_reqlen, req->rq_reqbuf_len);
- OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+ kvfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
@@ -202,7 +204,7 @@ int null_alloc_repbuf(struct ptlrpc_sec *sec,
msgsize = size_roundup_power2(msgsize);
- OBD_ALLOC_LARGE(req->rq_repbuf, msgsize);
+ req->rq_repbuf = libcfs_kvzalloc(msgsize, GFP_NOFS);
if (!req->rq_repbuf)
return -ENOMEM;
@@ -216,7 +218,7 @@ void null_free_repbuf(struct ptlrpc_sec *sec,
{
LASSERT(req->rq_repbuf);
- OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
+ kvfree(req->rq_repbuf);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
}
@@ -226,9 +228,9 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req,
int segment, int newsize)
{
- struct lustre_msg *newbuf;
- struct lustre_msg *oldbuf = req->rq_reqmsg;
- int oldsize, newmsg_size, alloc_size;
+ struct lustre_msg *newbuf;
+ struct lustre_msg *oldbuf = req->rq_reqmsg;
+ int oldsize, newmsg_size, alloc_size;
LASSERT(req->rq_reqbuf);
LASSERT(req->rq_reqbuf == req->rq_reqmsg);
@@ -247,7 +249,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
if (req->rq_reqbuf_len < newmsg_size) {
alloc_size = size_roundup_power2(newmsg_size);
- OBD_ALLOC_LARGE(newbuf, alloc_size);
+ newbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS);
if (newbuf == NULL)
return -ENOMEM;
@@ -261,7 +263,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
spin_lock(&req->rq_import->imp_lock);
memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);
- OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+ kvfree(req->rq_reqbuf);
req->rq_reqbuf = req->rq_reqmsg = newbuf;
req->rq_reqbuf_len = alloc_size;
@@ -316,7 +318,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize)
/* pre-allocated */
LASSERT(rs->rs_size >= rs_size);
} else {
- OBD_ALLOC_LARGE(rs, rs_size);
+ rs = libcfs_kvzalloc(rs_size, GFP_NOFS);
if (rs == NULL)
return -ENOMEM;
@@ -341,7 +343,7 @@ void null_free_rs(struct ptlrpc_reply_state *rs)
atomic_dec(&rs->rs_svc_ctx->sc_refcount);
if (!rs->rs_prealloc)
- OBD_FREE_LARGE(rs, rs->rs_size);
+ kvfree(rs);
}
static
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index a79cd5301..f448b4567 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -40,12 +40,12 @@
#define DEBUG_SUBSYSTEM S_SEC
-
#include "../include/obd_support.h"
#include "../include/obd_cksum.h"
#include "../include/obd_class.h"
#include "../include/lustre_net.h"
#include "../include/lustre_sec.h"
+#include "ptlrpc_internal.h"
struct plain_sec {
struct ptlrpc_sec pls_base;
@@ -136,7 +136,7 @@ static int plain_verify_bulk_csum(struct ptlrpc_bulk_desc *desc,
struct plain_bulk_token *tokenr)
{
struct plain_bulk_token tokenv;
- int rc;
+ int rc;
if (hash_alg == BULK_HASH_ALG_NULL)
return 0;
@@ -154,8 +154,8 @@ static int plain_verify_bulk_csum(struct ptlrpc_bulk_desc *desc,
static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc)
{
- char *ptr;
- unsigned int off, i;
+ char *ptr;
+ unsigned int off, i;
for (i = 0; i < desc->bd_iov_count; i++) {
if (desc->bd_iov[i].kiov_len == 0)
@@ -190,7 +190,7 @@ int plain_ctx_validate(struct ptlrpc_cli_ctx *ctx)
static
int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
{
- struct lustre_msg *msg = req->rq_reqbuf;
+ struct lustre_msg *msg = req->rq_reqbuf;
struct plain_header *phdr;
msg->lm_secflvr = req->rq_flvr.sf_rpc;
@@ -214,10 +214,10 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
static
int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
{
- struct lustre_msg *msg = req->rq_repdata;
+ struct lustre_msg *msg = req->rq_repdata;
struct plain_header *phdr;
- __u32 cksum;
- int swabbed;
+ __u32 cksum;
+ int swabbed;
if (msg->lm_bufcount != PLAIN_PACK_SEGMENTS) {
CERROR("unexpected reply buf count %u\n", msg->lm_bufcount);
@@ -290,8 +290,8 @@ int plain_cli_wrap_bulk(struct ptlrpc_cli_ctx *ctx,
struct ptlrpc_bulk_desc *desc)
{
struct ptlrpc_bulk_sec_desc *bsd;
- struct plain_bulk_token *token;
- int rc;
+ struct plain_bulk_token *token;
+ int rc;
LASSERT(req->rq_pack_bulk);
LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS);
@@ -333,9 +333,9 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx,
struct ptlrpc_bulk_desc *desc)
{
struct ptlrpc_bulk_sec_desc *bsdv;
- struct plain_bulk_token *tokenv;
- int rc;
- int i, nob;
+ struct plain_bulk_token *tokenv;
+ int rc;
+ int i, nob;
LASSERT(req->rq_pack_bulk);
LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS);
@@ -374,9 +374,9 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx,
static
struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec)
{
- struct ptlrpc_cli_ctx *ctx, *ctx_new;
+ struct ptlrpc_cli_ctx *ctx, *ctx_new;
- OBD_ALLOC_PTR(ctx_new);
+ ctx_new = kzalloc(sizeof(*ctx_new), GFP_NOFS);
write_lock(&plsec->pls_lock);
@@ -384,8 +384,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec)
if (ctx) {
atomic_inc(&ctx->cc_refcount);
- if (ctx_new)
- OBD_FREE_PTR(ctx_new);
+ kfree(ctx_new);
} else if (ctx_new) {
ctx = ctx_new;
@@ -414,7 +413,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec)
static
void plain_destroy_sec(struct ptlrpc_sec *sec)
{
- struct plain_sec *plsec = sec2plsec(sec);
+ struct plain_sec *plsec = sec2plsec(sec);
LASSERT(sec->ps_policy == &plain_policy);
LASSERT(sec->ps_import);
@@ -424,7 +423,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec)
class_import_put(sec->ps_import);
- OBD_FREE_PTR(plsec);
+ kfree(plsec);
}
static
@@ -438,14 +437,14 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp,
struct ptlrpc_svc_ctx *svc_ctx,
struct sptlrpc_flavor *sf)
{
- struct plain_sec *plsec;
- struct ptlrpc_sec *sec;
- struct ptlrpc_cli_ctx *ctx;
+ struct plain_sec *plsec;
+ struct ptlrpc_sec *sec;
+ struct ptlrpc_cli_ctx *ctx;
LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN);
- OBD_ALLOC_PTR(plsec);
- if (plsec == NULL)
+ plsec = kzalloc(sizeof(*plsec), GFP_NOFS);
+ if (!plsec)
return NULL;
/*
@@ -484,8 +483,8 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec,
struct vfs_cred *vcred,
int create, int remove_dead)
{
- struct plain_sec *plsec = sec2plsec(sec);
- struct ptlrpc_cli_ctx *ctx;
+ struct plain_sec *plsec = sec2plsec(sec);
+ struct ptlrpc_cli_ctx *ctx;
read_lock(&plsec->pls_lock);
ctx = plsec->pls_ctx;
@@ -508,7 +507,7 @@ void plain_release_ctx(struct ptlrpc_sec *sec,
LASSERT(atomic_read(&ctx->cc_refcount) == 0);
LASSERT(ctx->cc_sec == sec);
- OBD_FREE_PTR(ctx);
+ kfree(ctx);
atomic_dec(&sec->ps_nctx);
sptlrpc_sec_put(sec);
@@ -518,8 +517,8 @@ static
int plain_flush_ctx_cache(struct ptlrpc_sec *sec,
uid_t uid, int grace, int force)
{
- struct plain_sec *plsec = sec2plsec(sec);
- struct ptlrpc_cli_ctx *ctx;
+ struct plain_sec *plsec = sec2plsec(sec);
+ struct ptlrpc_cli_ctx *ctx;
/* do nothing unless caller want to flush for 'all' */
if (uid != -1)
@@ -541,7 +540,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
int msgsize)
{
__u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
- int alloc_len;
+ int alloc_len;
buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header);
buflens[PLAIN_PACK_MSG_OFF] = msgsize;
@@ -560,7 +559,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
LASSERT(!req->rq_pool);
alloc_len = size_roundup_power2(alloc_len);
- OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len);
+ req->rq_reqbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS);
if (!req->rq_reqbuf)
return -ENOMEM;
@@ -585,7 +584,7 @@ void plain_free_reqbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req)
{
if (!req->rq_pool) {
- OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+ kvfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
@@ -614,7 +613,7 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec,
alloc_len = size_roundup_power2(alloc_len);
- OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len);
+ req->rq_repbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS);
if (!req->rq_repbuf)
return -ENOMEM;
@@ -626,7 +625,7 @@ static
void plain_free_repbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req)
{
- OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
+ kvfree(req->rq_repbuf);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
}
@@ -636,9 +635,9 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req,
int segment, int newsize)
{
- struct lustre_msg *newbuf;
- int oldsize;
- int newmsg_size, newbuf_size;
+ struct lustre_msg *newbuf;
+ int oldsize;
+ int newmsg_size, newbuf_size;
LASSERT(req->rq_reqbuf);
LASSERT(req->rq_reqbuf_len >= req->rq_reqlen);
@@ -665,7 +664,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
if (req->rq_reqbuf_len < newbuf_size) {
newbuf_size = size_roundup_power2(newbuf_size);
- OBD_ALLOC_LARGE(newbuf, newbuf_size);
+ newbuf = libcfs_kvzalloc(newbuf_size, GFP_NOFS);
if (newbuf == NULL)
return -ENOMEM;
@@ -680,7 +679,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
- OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+ kvfree(req->rq_reqbuf);
req->rq_reqbuf = newbuf;
req->rq_reqbuf_len = newbuf_size;
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf,
@@ -710,9 +709,9 @@ static struct ptlrpc_svc_ctx plain_svc_ctx = {
static
int plain_accept(struct ptlrpc_request *req)
{
- struct lustre_msg *msg = req->rq_reqbuf;
+ struct lustre_msg *msg = req->rq_reqbuf;
struct plain_header *phdr;
- int swabbed;
+ int swabbed;
LASSERT(SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) ==
SPTLRPC_POLICY_PLAIN);
@@ -781,9 +780,9 @@ int plain_accept(struct ptlrpc_request *req)
static
int plain_alloc_rs(struct ptlrpc_request *req, int msgsize)
{
- struct ptlrpc_reply_state *rs;
- __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
- int rs_size = sizeof(*rs);
+ struct ptlrpc_reply_state *rs;
+ __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
+ int rs_size = sizeof(*rs);
LASSERT(msgsize % 8 == 0);
@@ -801,7 +800,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize)
/* pre-allocated */
LASSERT(rs->rs_size >= rs_size);
} else {
- OBD_ALLOC_LARGE(rs, rs_size);
+ rs = libcfs_kvzalloc(rs_size, GFP_NOFS);
if (rs == NULL)
return -ENOMEM;
@@ -827,16 +826,16 @@ void plain_free_rs(struct ptlrpc_reply_state *rs)
atomic_dec(&rs->rs_svc_ctx->sc_refcount);
if (!rs->rs_prealloc)
- OBD_FREE_LARGE(rs, rs->rs_size);
+ kvfree(rs);
}
static
int plain_authorize(struct ptlrpc_request *req)
{
struct ptlrpc_reply_state *rs = req->rq_reply_state;
- struct lustre_msg_v2 *msg = rs->rs_repbuf;
- struct plain_header *phdr;
- int len;
+ struct lustre_msg_v2 *msg = rs->rs_repbuf;
+ struct plain_header *phdr;
+ int len;
LASSERT(rs);
LASSERT(msg);
@@ -871,7 +870,7 @@ int plain_authorize(struct ptlrpc_request *req)
lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0),
lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF),
NULL, 0, (unsigned char *)&msg->lm_cksum, &hsize);
- req->rq_reply_off = 0;
+ req->rq_reply_off = 0;
}
return 0;
@@ -881,10 +880,10 @@ static
int plain_svc_unwrap_bulk(struct ptlrpc_request *req,
struct ptlrpc_bulk_desc *desc)
{
- struct ptlrpc_reply_state *rs = req->rq_reply_state;
+ struct ptlrpc_reply_state *rs = req->rq_reply_state;
struct ptlrpc_bulk_sec_desc *bsdr, *bsdv;
- struct plain_bulk_token *tokenr;
- int rc;
+ struct plain_bulk_token *tokenr;
+ int rc;
LASSERT(req->rq_bulk_write);
LASSERT(req->rq_pack_bulk);
@@ -915,10 +914,10 @@ static
int plain_svc_wrap_bulk(struct ptlrpc_request *req,
struct ptlrpc_bulk_desc *desc)
{
- struct ptlrpc_reply_state *rs = req->rq_reply_state;
+ struct ptlrpc_reply_state *rs = req->rq_reply_state;
struct ptlrpc_bulk_sec_desc *bsdr, *bsdv;
- struct plain_bulk_token *tokenv;
- int rc;
+ struct plain_bulk_token *tokenv;
+ int rc;
LASSERT(req->rq_bulk_read);
LASSERT(req->rq_pack_bulk);
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/service.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/service.c
index 8e6142151..f45898f17 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -43,7 +43,7 @@
#include "ptlrpc_internal.h"
/* The following are visible and mutable through /sys/module/ptlrpc */
-int test_req_buffer_pressure = 0;
+int test_req_buffer_pressure;
module_param(test_req_buffer_pressure, int, 0444);
MODULE_PARM_DESC(test_req_buffer_pressure, "set non-zero to put pressure on request buffer pools");
module_param(at_min, int, 0644);
@@ -58,7 +58,6 @@ MODULE_PARM_DESC(at_early_margin, "How soon before an RPC deadline to send an ea
module_param(at_extra, int, 0644);
MODULE_PARM_DESC(at_extra, "How much extra time to give with each early reply");
-
/* forward ref */
static int ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt);
static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req);
@@ -69,13 +68,15 @@ LIST_HEAD(ptlrpc_all_services);
/** Used to protect the \e ptlrpc_all_services list */
struct mutex ptlrpc_all_services_mutex;
-struct ptlrpc_request_buffer_desc *
+static struct ptlrpc_request_buffer_desc *
ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt)
{
- struct ptlrpc_service *svc = svcpt->scp_service;
+ struct ptlrpc_service *svc = svcpt->scp_service;
struct ptlrpc_request_buffer_desc *rqbd;
- OBD_CPT_ALLOC_PTR(rqbd, svc->srv_cptable, svcpt->scp_cpt);
+ rqbd = kzalloc_node(sizeof(*rqbd), GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable,
+ svcpt->scp_cpt));
if (rqbd == NULL)
return NULL;
@@ -84,10 +85,12 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt)
rqbd->rqbd_cbid.cbid_fn = request_in_callback;
rqbd->rqbd_cbid.cbid_arg = rqbd;
INIT_LIST_HEAD(&rqbd->rqbd_reqs);
- OBD_CPT_ALLOC_LARGE(rqbd->rqbd_buffer, svc->srv_cptable,
- svcpt->scp_cpt, svc->srv_buf_size);
+ rqbd->rqbd_buffer = libcfs_kvzalloc_cpt(svc->srv_cptable,
+ svcpt->scp_cpt,
+ svc->srv_buf_size,
+ GFP_KERNEL);
if (rqbd->rqbd_buffer == NULL) {
- OBD_FREE_PTR(rqbd);
+ kfree(rqbd);
return NULL;
}
@@ -99,7 +102,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt)
return rqbd;
}
-void
+static void
ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
{
struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt;
@@ -112,17 +115,17 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
svcpt->scp_nrqbds_total--;
spin_unlock(&svcpt->scp_lock);
- OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size);
- OBD_FREE_PTR(rqbd);
+ kvfree(rqbd->rqbd_buffer);
+ kfree(rqbd);
}
-int
+static int
ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post)
{
- struct ptlrpc_service *svc = svcpt->scp_service;
+ struct ptlrpc_service *svc = svcpt->scp_service;
struct ptlrpc_request_buffer_desc *rqbd;
- int rc = 0;
- int i;
+ int rc = 0;
+ int i;
if (svcpt->scp_rqbd_allocating)
goto try_post;
@@ -139,7 +142,6 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post)
svcpt->scp_rqbd_allocating++;
spin_unlock(&svcpt->scp_lock);
-
for (i = 0; i < svc->srv_nbuf_per_group; i++) {
/* NB: another thread might have recycled enough rqbds, we
* need to make sure it wouldn't over-allocate, see LU-1212. */
@@ -175,33 +177,6 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post)
return rc;
}
-/**
- * Part of Rep-Ack logic.
- * Puts a lock and its mode into reply state associated to request reply.
- */
-void
-ptlrpc_save_lock(struct ptlrpc_request *req,
- struct lustre_handle *lock, int mode, int no_ack)
-{
- struct ptlrpc_reply_state *rs = req->rq_reply_state;
- int idx;
-
- LASSERT(rs != NULL);
- LASSERT(rs->rs_nlocks < RS_MAX_LOCKS);
-
- if (req->rq_export->exp_disconnected) {
- ldlm_lock_decref(lock, mode);
- } else {
- idx = rs->rs_nlocks++;
- rs->rs_locks[idx] = *lock;
- rs->rs_modes[idx] = mode;
- rs->rs_difficult = 1;
- rs->rs_no_ack = !!no_ack;
- }
-}
-EXPORT_SYMBOL(ptlrpc_save_lock);
-
-
struct ptlrpc_hr_partition;
struct ptlrpc_hr_thread {
@@ -242,39 +217,17 @@ struct ptlrpc_hr_service {
struct ptlrpc_hr_partition **hr_partitions;
};
-struct rs_batch {
- struct list_head rsb_replies;
- unsigned int rsb_n_replies;
- struct ptlrpc_service_part *rsb_svcpt;
-};
-
/** reply handling service. */
static struct ptlrpc_hr_service ptlrpc_hr;
/**
- * maximum number of replies scheduled in one batch
- */
-#define MAX_SCHEDULED 256
-
-/**
- * Initialize a reply batch.
- *
- * \param b batch
- */
-static void rs_batch_init(struct rs_batch *b)
-{
- memset(b, 0, sizeof(*b));
- INIT_LIST_HEAD(&b->rsb_replies);
-}
-
-/**
* Choose an hr thread to dispatch requests to.
*/
static struct ptlrpc_hr_thread *
ptlrpc_hr_select(struct ptlrpc_service_part *svcpt)
{
- struct ptlrpc_hr_partition *hrp;
- unsigned int rotor;
+ struct ptlrpc_hr_partition *hrp;
+ unsigned int rotor;
if (svcpt->scp_cpt >= 0 &&
svcpt->scp_service->srv_cptable == ptlrpc_hr.hr_cpt_table) {
@@ -293,76 +246,6 @@ ptlrpc_hr_select(struct ptlrpc_service_part *svcpt)
}
/**
- * Dispatch all replies accumulated in the batch to one from
- * dedicated reply handling threads.
- *
- * \param b batch
- */
-static void rs_batch_dispatch(struct rs_batch *b)
-{
- if (b->rsb_n_replies != 0) {
- struct ptlrpc_hr_thread *hrt;
-
- hrt = ptlrpc_hr_select(b->rsb_svcpt);
-
- spin_lock(&hrt->hrt_lock);
- list_splice_init(&b->rsb_replies, &hrt->hrt_queue);
- spin_unlock(&hrt->hrt_lock);
-
- wake_up(&hrt->hrt_waitq);
- b->rsb_n_replies = 0;
- }
-}
-
-/**
- * Add a reply to a batch.
- * Add one reply object to a batch, schedule batched replies if overload.
- *
- * \param b batch
- * \param rs reply
- */
-static void rs_batch_add(struct rs_batch *b, struct ptlrpc_reply_state *rs)
-{
- struct ptlrpc_service_part *svcpt = rs->rs_svcpt;
-
- if (svcpt != b->rsb_svcpt || b->rsb_n_replies >= MAX_SCHEDULED) {
- if (b->rsb_svcpt != NULL) {
- rs_batch_dispatch(b);
- spin_unlock(&b->rsb_svcpt->scp_rep_lock);
- }
- spin_lock(&svcpt->scp_rep_lock);
- b->rsb_svcpt = svcpt;
- }
- spin_lock(&rs->rs_lock);
- rs->rs_scheduled_ever = 1;
- if (rs->rs_scheduled == 0) {
- list_move(&rs->rs_list, &b->rsb_replies);
- rs->rs_scheduled = 1;
- b->rsb_n_replies++;
- }
- rs->rs_committed = 1;
- spin_unlock(&rs->rs_lock);
-}
-
-/**
- * Reply batch finalization.
- * Dispatch remaining replies from the batch
- * and release remaining spinlock.
- *
- * \param b batch
- */
-static void rs_batch_fini(struct rs_batch *b)
-{
- if (b->rsb_svcpt != NULL) {
- rs_batch_dispatch(b);
- spin_unlock(&b->rsb_svcpt->scp_rep_lock);
- }
-}
-
-#define DECLARE_RS_BATCH(b) struct rs_batch b
-
-
-/**
* Put reply state into a queue for processing because we received
* ACK from the client
*/
@@ -399,38 +282,12 @@ ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs)
}
EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply);
-void ptlrpc_commit_replies(struct obd_export *exp)
-{
- struct ptlrpc_reply_state *rs, *nxt;
- DECLARE_RS_BATCH(batch);
-
- rs_batch_init(&batch);
- /* Find any replies that have been committed and get their service
- * to attend to complete them. */
-
- /* CAVEAT EMPTOR: spinlock ordering!!! */
- spin_lock(&exp->exp_uncommitted_replies_lock);
- list_for_each_entry_safe(rs, nxt, &exp->exp_uncommitted_replies,
- rs_obd_list) {
- LASSERT(rs->rs_difficult);
- /* VBR: per-export last_committed */
- LASSERT(rs->rs_export);
- if (rs->rs_transno <= exp->exp_last_committed) {
- list_del_init(&rs->rs_obd_list);
- rs_batch_add(&batch, rs);
- }
- }
- spin_unlock(&exp->exp_uncommitted_replies_lock);
- rs_batch_fini(&batch);
-}
-EXPORT_SYMBOL(ptlrpc_commit_replies);
-
static int
ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt)
{
struct ptlrpc_request_buffer_desc *rqbd;
- int rc;
- int posted = 0;
+ int rc;
+ int posted = 0;
for (;;) {
spin_lock(&svcpt->scp_lock);
@@ -487,11 +344,11 @@ static void
ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
struct ptlrpc_service_conf *conf)
{
- struct ptlrpc_service_thr_conf *tc = &conf->psc_thr;
- unsigned init;
- unsigned total;
- unsigned nthrs;
- int weight;
+ struct ptlrpc_service_thr_conf *tc = &conf->psc_thr;
+ unsigned init;
+ unsigned total;
+ unsigned nthrs;
+ int weight;
/*
* Common code for estimating & validating threads number.
@@ -515,7 +372,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
* be up to 8 * nthrs_max */
total = min(tc->tc_nthrs_max * 8, tc->tc_nthrs_user);
nthrs = total / svc->srv_ncpts;
- init = max(init, nthrs);
+ init = max(init, nthrs);
goto out;
}
@@ -529,7 +386,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
nthrs = tc->tc_nthrs_base;
if (svc->srv_ncpts == 1) {
- int i;
+ int i;
/* NB: Increase the base number if it's single partition
* and total number of cores/HTs is larger or equal to 4.
@@ -541,7 +398,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
}
if (tc->tc_thr_factor != 0) {
- int factor = tc->tc_thr_factor;
+ int factor = tc->tc_thr_factor;
const int fade = 4;
/*
@@ -557,7 +414,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
* there are.
*/
/* weight is # of HTs */
- if (cpumask_weight(topology_thread_cpumask(0)) > 1) {
+ if (cpumask_weight(topology_sibling_cpumask(0)) > 1) {
/* depress thread factor for hyper-thread */
factor = factor - (factor >> 1) + (factor >> 3);
}
@@ -593,9 +450,9 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
struct ptlrpc_service_part *svcpt, int cpt)
{
struct ptlrpc_at_array *array;
- int size;
- int index;
- int rc;
+ int size;
+ int index;
+ int rc;
svcpt->scp_cpt = cpt;
INIT_LIST_HEAD(&svcpt->scp_threads);
@@ -625,25 +482,29 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
array = &svcpt->scp_at_array;
size = at_est2timeout(at_max);
- array->paa_size = size;
- array->paa_count = 0;
+ array->paa_size = size;
+ array->paa_count = 0;
array->paa_deadline = -1;
/* allocate memory for scp_at_array (ptlrpc_at_array) */
- OBD_CPT_ALLOC(array->paa_reqs_array,
- svc->srv_cptable, cpt, sizeof(struct list_head) * size);
+ array->paa_reqs_array =
+ kzalloc_node(sizeof(struct list_head) * size, GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable, cpt));
if (array->paa_reqs_array == NULL)
return -ENOMEM;
for (index = 0; index < size; index++)
INIT_LIST_HEAD(&array->paa_reqs_array[index]);
- OBD_CPT_ALLOC(array->paa_reqs_count,
- svc->srv_cptable, cpt, sizeof(__u32) * size);
+ array->paa_reqs_count =
+ kzalloc_node(sizeof(__u32) * size, GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable, cpt));
if (array->paa_reqs_count == NULL)
- goto failed;
+ goto free_reqs_array;
+
+ setup_timer(&svcpt->scp_at_timer, ptlrpc_at_timer,
+ (unsigned long)svcpt);
- cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt);
/* At SOW, service time should be quick; 10s seems generous. If client
* timeout is less than this, we'll be sending an early reply. */
at_init(&svcpt->scp_at_estimate, 10, 0);
@@ -655,21 +516,16 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
/* We shouldn't be under memory pressure at startup, so
* fail if we can't allocate all our buffers at this time. */
if (rc != 0)
- goto failed;
+ goto free_reqs_count;
return 0;
- failed:
- if (array->paa_reqs_count != NULL) {
- OBD_FREE(array->paa_reqs_count, sizeof(__u32) * size);
- array->paa_reqs_count = NULL;
- }
-
- if (array->paa_reqs_array != NULL) {
- OBD_FREE(array->paa_reqs_array,
- sizeof(struct list_head) * array->paa_size);
- array->paa_reqs_array = NULL;
- }
+free_reqs_count:
+ kfree(array->paa_reqs_count);
+ array->paa_reqs_count = NULL;
+free_reqs_array:
+ kfree(array->paa_reqs_array);
+ array->paa_reqs_array = NULL;
return -ENOMEM;
}
@@ -681,17 +537,18 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
*/
struct ptlrpc_service *
ptlrpc_register_service(struct ptlrpc_service_conf *conf,
- struct proc_dir_entry *proc_entry)
+ struct kset *parent,
+ struct dentry *debugfs_entry)
{
- struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt;
- struct ptlrpc_service *service;
- struct ptlrpc_service_part *svcpt;
- struct cfs_cpt_table *cptable;
- __u32 *cpts = NULL;
- int ncpts;
- int cpt;
- int rc;
- int i;
+ struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt;
+ struct ptlrpc_service *service;
+ struct ptlrpc_service_part *svcpt;
+ struct cfs_cpt_table *cptable;
+ __u32 *cpts = NULL;
+ int ncpts;
+ int cpt;
+ int rc;
+ int i;
LASSERT(conf->psc_buf.bc_nbufs > 0);
LASSERT(conf->psc_buf.bc_buf_size >=
@@ -707,7 +564,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
} else {
ncpts = cfs_cpt_number(cptable);
if (cconf->cc_pattern != NULL) {
- struct cfs_expr_list *el;
+ struct cfs_expr_list *el;
rc = cfs_expr_list_parse(cconf->cc_pattern,
strlen(cconf->cc_pattern),
@@ -723,24 +580,23 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
if (rc <= 0) {
CERROR("%s: failed to parse CPT array %s: %d\n",
conf->psc_name, cconf->cc_pattern, rc);
- if (cpts != NULL)
- OBD_FREE(cpts, sizeof(*cpts) * ncpts);
+ kfree(cpts);
return ERR_PTR(rc < 0 ? rc : -EINVAL);
}
ncpts = rc;
}
}
- OBD_ALLOC(service, offsetof(struct ptlrpc_service, srv_parts[ncpts]));
- if (service == NULL) {
- if (cpts != NULL)
- OBD_FREE(cpts, sizeof(*cpts) * ncpts);
+ service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
+ GFP_NOFS);
+ if (!service) {
+ kfree(cpts);
return ERR_PTR(-ENOMEM);
}
- service->srv_cptable = cptable;
- service->srv_cpts = cpts;
- service->srv_ncpts = ncpts;
+ service->srv_cptable = cptable;
+ service->srv_cpts = cpts;
+ service->srv_ncpts = ncpts;
service->srv_cpt_bits = 0; /* it's zero already, easy to read... */
while ((1 << service->srv_cpt_bits) < cfs_cpt_number(cptable))
@@ -748,18 +604,18 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
/* public members */
spin_lock_init(&service->srv_lock);
- service->srv_name = conf->psc_name;
- service->srv_watchdog_factor = conf->psc_watchdog_factor;
+ service->srv_name = conf->psc_name;
+ service->srv_watchdog_factor = conf->psc_watchdog_factor;
INIT_LIST_HEAD(&service->srv_list); /* for safety of cleanup */
/* buffer configuration */
- service->srv_nbuf_per_group = test_req_buffer_pressure ?
+ service->srv_nbuf_per_group = test_req_buffer_pressure ?
1 : conf->psc_buf.bc_nbufs;
- service->srv_max_req_size = conf->psc_buf.bc_req_max_size +
+ service->srv_max_req_size = conf->psc_buf.bc_req_max_size +
SPTLRPC_MAX_PAYLOAD;
- service->srv_buf_size = conf->psc_buf.bc_buf_size;
- service->srv_rep_portal = conf->psc_buf.bc_rep_portal;
- service->srv_req_portal = conf->psc_buf.bc_req_portal;
+ service->srv_buf_size = conf->psc_buf.bc_buf_size;
+ service->srv_rep_portal = conf->psc_buf.bc_rep_portal;
+ service->srv_req_portal = conf->psc_buf.bc_req_portal;
/* Increase max reply size to next power of two */
service->srv_max_reply_size = 1;
@@ -767,10 +623,10 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
conf->psc_buf.bc_rep_max_size + SPTLRPC_MAX_PAYLOAD)
service->srv_max_reply_size <<= 1;
- service->srv_thread_name = conf->psc_thr.tc_thr_name;
- service->srv_ctx_tags = conf->psc_thr.tc_ctx_tags;
- service->srv_hpreq_ratio = PTLRPC_SVC_HP_RATIO;
- service->srv_ops = conf->psc_ops;
+ service->srv_thread_name = conf->psc_thr.tc_thr_name;
+ service->srv_ctx_tags = conf->psc_thr.tc_ctx_tags;
+ service->srv_hpreq_ratio = PTLRPC_SVC_HP_RATIO;
+ service->srv_ops = conf->psc_ops;
for (i = 0; i < ncpts; i++) {
if (!conf->psc_thr.tc_cpu_affinity)
@@ -778,7 +634,8 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
else
cpt = cpts != NULL ? cpts[i] : i;
- OBD_CPT_ALLOC(svcpt, cptable, cpt, sizeof(*svcpt));
+ svcpt = kzalloc_node(sizeof(*svcpt), GFP_NOFS,
+ cfs_cpt_spread_node(cptable, cpt));
if (svcpt == NULL) {
rc = -ENOMEM;
goto failed;
@@ -799,8 +656,14 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
list_add(&service->srv_list, &ptlrpc_all_services);
mutex_unlock(&ptlrpc_all_services_mutex);
- if (proc_entry != NULL)
- ptlrpc_lprocfs_register_service(proc_entry, service);
+ if (parent) {
+ rc = ptlrpc_sysfs_register_service(parent, service);
+ if (rc)
+ goto failed;
+ }
+
+ if (!IS_ERR_OR_NULL(debugfs_entry))
+ ptlrpc_ldebugfs_register_service(debugfs_entry, service);
rc = ptlrpc_service_nrs_setup(service);
if (rc != 0)
@@ -850,14 +713,14 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req)
* drop a reference count of the request. if it reaches 0, we either
* put it into history list, or free it immediately.
*/
-void ptlrpc_server_drop_request(struct ptlrpc_request *req)
+static void ptlrpc_server_drop_request(struct ptlrpc_request *req)
{
struct ptlrpc_request_buffer_desc *rqbd = req->rq_rqbd;
- struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt;
- struct ptlrpc_service *svc = svcpt->scp_service;
- int refcount;
- struct list_head *tmp;
- struct list_head *nxt;
+ struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt;
+ struct ptlrpc_service *svc = svcpt->scp_service;
+ int refcount;
+ struct list_head *tmp;
+ struct list_head *nxt;
if (!atomic_dec_and_test(&req->rq_refcount))
return;
@@ -954,35 +817,6 @@ void ptlrpc_server_drop_request(struct ptlrpc_request *req)
}
}
-/** Change request export and move hp request from old export to new */
-void ptlrpc_request_change_export(struct ptlrpc_request *req,
- struct obd_export *export)
-{
- if (req->rq_export != NULL) {
- if (!list_empty(&req->rq_exp_list)) {
- /* remove rq_exp_list from last export */
- spin_lock_bh(&req->rq_export->exp_rpc_lock);
- list_del_init(&req->rq_exp_list);
- spin_unlock_bh(&req->rq_export->exp_rpc_lock);
-
- /* export has one reference already, so it`s safe to
- * add req to export queue here and get another
- * reference for request later */
- spin_lock_bh(&export->exp_rpc_lock);
- list_add(&req->rq_exp_list, &export->exp_hp_rpcs);
- spin_unlock_bh(&export->exp_rpc_lock);
- }
- class_export_rpc_dec(req->rq_export);
- class_export_put(req->rq_export);
- }
-
- /* request takes one export refcount */
- req->rq_export = class_export_get(export);
- class_export_rpc_inc(export);
-
- return;
-}
-
/**
* to finish a request: stop sending more early replies, and release
* the request.
@@ -1019,82 +853,6 @@ static void ptlrpc_server_finish_active_request(
}
/**
- * This function makes sure dead exports are evicted in a timely manner.
- * This function is only called when some export receives a message (i.e.,
- * the network is up.)
- */
-static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay)
-{
- struct obd_export *oldest_exp;
- time_t oldest_time, new_time;
-
- LASSERT(exp);
-
- /* Compensate for slow machines, etc, by faking our request time
- into the future. Although this can break the strict time-ordering
- of the list, we can be really lazy here - we don't have to evict
- at the exact right moment. Eventually, all silent exports
- will make it to the top of the list. */
-
- /* Do not pay attention on 1sec or smaller renewals. */
- new_time = get_seconds() + extra_delay;
- if (exp->exp_last_request_time + 1 /*second */ >= new_time)
- return;
-
- exp->exp_last_request_time = new_time;
-
- /* exports may get disconnected from the chain even though the
- export has references, so we must keep the spin lock while
- manipulating the lists */
- spin_lock(&exp->exp_obd->obd_dev_lock);
-
- if (list_empty(&exp->exp_obd_chain_timed)) {
- /* this one is not timed */
- spin_unlock(&exp->exp_obd->obd_dev_lock);
- return;
- }
-
- list_move_tail(&exp->exp_obd_chain_timed,
- &exp->exp_obd->obd_exports_timed);
-
- oldest_exp = list_entry(exp->exp_obd->obd_exports_timed.next,
- struct obd_export, exp_obd_chain_timed);
- oldest_time = oldest_exp->exp_last_request_time;
- spin_unlock(&exp->exp_obd->obd_dev_lock);
-
- if (exp->exp_obd->obd_recovering) {
- /* be nice to everyone during recovery */
- return;
- }
-
- /* Note - racing to start/reset the obd_eviction timer is safe */
- if (exp->exp_obd->obd_eviction_timer == 0) {
- /* Check if the oldest entry is expired. */
- if (get_seconds() > (oldest_time + PING_EVICT_TIMEOUT +
- extra_delay)) {
- /* We need a second timer, in case the net was down and
- * it just came back. Since the pinger may skip every
- * other PING_INTERVAL (see note in ptlrpc_pinger_main),
- * we better wait for 3. */
- exp->exp_obd->obd_eviction_timer =
- get_seconds() + 3 * PING_INTERVAL;
- CDEBUG(D_HA, "%s: Think about evicting %s from "CFS_TIME_T"\n",
- exp->exp_obd->obd_name,
- obd_export_nid2str(oldest_exp), oldest_time);
- }
- } else {
- if (get_seconds() >
- (exp->exp_obd->obd_eviction_timer + extra_delay)) {
- /* The evictor won't evict anyone who we've heard from
- * recently, so we don't have to check before we start
- * it. */
- if (!ping_evictor_wake(exp))
- exp->exp_obd->obd_eviction_timer = 0;
- }
- }
-}
-
-/**
* Sanity check request \a req.
* Return 0 if all is ok, error code otherwise.
*/
@@ -1120,18 +878,16 @@ static int ptlrpc_check_req(struct ptlrpc_request *req)
req, (obd != NULL) ? obd->obd_name : "unknown");
rc = -ENODEV;
} else if (lustre_msg_get_flags(req->rq_reqmsg) &
- (MSG_REPLAY | MSG_REQ_REPLAY_DONE) &&
- !obd->obd_recovering) {
- DEBUG_REQ(D_ERROR, req,
- "Invalid replay without recovery");
- class_fail_export(req->rq_export);
- rc = -ENODEV;
- } else if (lustre_msg_get_transno(req->rq_reqmsg) != 0 &&
- !obd->obd_recovering) {
- DEBUG_REQ(D_ERROR, req, "Invalid req with transno %llu without recovery",
- lustre_msg_get_transno(req->rq_reqmsg));
- class_fail_export(req->rq_export);
- rc = -ENODEV;
+ (MSG_REPLAY | MSG_REQ_REPLAY_DONE)) {
+ DEBUG_REQ(D_ERROR, req, "Invalid replay without recovery");
+ class_fail_export(req->rq_export);
+ rc = -ENODEV;
+ } else if (lustre_msg_get_transno(req->rq_reqmsg) != 0) {
+ DEBUG_REQ(D_ERROR, req,
+ "Invalid req with transno %llu without recovery",
+ lustre_msg_get_transno(req->rq_reqmsg));
+ class_fail_export(req->rq_export);
+ rc = -ENODEV;
}
if (unlikely(rc < 0)) {
@@ -1147,17 +903,17 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
__s32 next;
if (array->paa_count == 0) {
- cfs_timer_disarm(&svcpt->scp_at_timer);
+ del_timer(&svcpt->scp_at_timer);
return;
}
/* Set timer for closest deadline */
- next = (__s32)(array->paa_deadline - get_seconds() -
+ next = (__s32)(array->paa_deadline - ktime_get_real_seconds() -
at_early_margin);
if (next <= 0) {
ptlrpc_at_timer((unsigned long)svcpt);
} else {
- cfs_timer_arm(&svcpt->scp_at_timer, cfs_time_shift(next));
+ mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
CDEBUG(D_INFO, "armed %s at %+ds\n",
svcpt->scp_service->srv_name, next);
}
@@ -1183,7 +939,7 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req)
spin_lock(&svcpt->scp_at_lock);
LASSERT(list_empty(&req->rq_timed_list));
- index = (unsigned long)req->rq_deadline % array->paa_size;
+ div_u64_rem(req->rq_deadline, array->paa_size, &index);
if (array->paa_reqs_count[index] > 0) {
/* latest rpcs will have the latest deadlines in the list,
* so search backward. */
@@ -1242,8 +998,8 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req)
struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
struct ptlrpc_request *reqcopy;
struct lustre_msg *reqmsg;
- long olddl = req->rq_deadline - get_seconds();
- time_t newdl;
+ long olddl = req->rq_deadline - ktime_get_real_seconds();
+ time64_t newdl;
int rc;
/* deadline is when the client expects us to reply, margin is the
@@ -1270,41 +1026,27 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req)
return -ENOSYS;
}
- if (req->rq_export &&
- lustre_msg_get_flags(req->rq_reqmsg) &
- (MSG_REPLAY | MSG_REQ_REPLAY_DONE | MSG_LOCK_REPLAY_DONE)) {
- /* During recovery, we don't want to send too many early
- * replies, but on the other hand we want to make sure the
- * client has enough time to resend if the rpc is lost. So
- * during the recovery period send at least 4 early replies,
- * spacing them every at_extra if we can. at_estimate should
- * always equal this fixed value during recovery. */
- at_measured(&svcpt->scp_at_estimate, min(at_extra,
- req->rq_export->exp_obd->obd_recovery_timeout / 4));
- } else {
- /* Fake our processing time into the future to ask the clients
- * for some extra amount of time */
- at_measured(&svcpt->scp_at_estimate, at_extra +
- get_seconds() -
- req->rq_arrival_time.tv_sec);
-
- /* Check to see if we've actually increased the deadline -
- * we may be past adaptive_max */
- if (req->rq_deadline >= req->rq_arrival_time.tv_sec +
- at_get(&svcpt->scp_at_estimate)) {
- DEBUG_REQ(D_WARNING, req, "Couldn't add any time (%ld/%ld), not sending early reply\n",
- olddl, req->rq_arrival_time.tv_sec +
- at_get(&svcpt->scp_at_estimate) -
- get_seconds());
- return -ETIMEDOUT;
- }
+ /* Fake our processing time into the future to ask the clients
+ * for some extra amount of time */
+ at_measured(&svcpt->scp_at_estimate, at_extra +
+ ktime_get_real_seconds() - req->rq_arrival_time.tv_sec);
+
+ /* Check to see if we've actually increased the deadline -
+ * we may be past adaptive_max */
+ if (req->rq_deadline >= req->rq_arrival_time.tv_sec +
+ at_get(&svcpt->scp_at_estimate)) {
+ DEBUG_REQ(D_WARNING, req, "Couldn't add any time (%ld/%lld), not sending early reply\n",
+ olddl, req->rq_arrival_time.tv_sec +
+ at_get(&svcpt->scp_at_estimate) -
+ ktime_get_real_seconds());
+ return -ETIMEDOUT;
}
- newdl = get_seconds() + at_get(&svcpt->scp_at_estimate);
+ newdl = ktime_get_real_seconds() + at_get(&svcpt->scp_at_estimate);
reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS);
if (reqcopy == NULL)
return -ENOMEM;
- OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen);
+ reqmsg = libcfs_kvzalloc(req->rq_reqlen, GFP_NOFS);
if (!reqmsg) {
rc = -ENOMEM;
goto out_free;
@@ -1368,7 +1110,7 @@ out_put:
class_export_put(reqcopy->rq_export);
out:
sptlrpc_svc_ctx_decref(reqcopy);
- OBD_FREE_LARGE(reqmsg, req->rq_reqlen);
+ kvfree(reqmsg);
out_free:
ptlrpc_request_cache_free(reqcopy);
return rc;
@@ -1381,9 +1123,9 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
struct ptlrpc_at_array *array = &svcpt->scp_at_array;
struct ptlrpc_request *rq, *n;
struct list_head work_list;
- __u32 index, count;
- time_t deadline;
- time_t now = get_seconds();
+ __u32 index, count;
+ time64_t deadline;
+ time64_t now = ktime_get_real_seconds();
long delay;
int first, counter = 0;
@@ -1413,7 +1155,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
server will take. Send early replies to everyone expiring soon. */
INIT_LIST_HEAD(&work_list);
deadline = -1;
- index = (unsigned long)array->paa_deadline % array->paa_size;
+ div_u64_rem(array->paa_deadline, array->paa_size, &index);
count = array->paa_count;
while (count > 0) {
count -= array->paa_reqs_count[index];
@@ -1455,7 +1197,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
chance to send early replies */
LCONSOLE_WARN("%s: This server is not able to keep up with request traffic (cpu-bound).\n",
svcpt->scp_service->srv_name);
- CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=" CFS_DURATION_T "(jiff)\n",
+ CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%ld(jiff)\n",
counter, svcpt->scp_nreqs_incoming,
svcpt->scp_nreqs_active,
at_get(&svcpt->scp_at_estimate), delay);
@@ -1540,30 +1282,6 @@ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req)
}
}
-static int ptlrpc_hpreq_check(struct ptlrpc_request *req)
-{
- return 1;
-}
-
-static struct ptlrpc_hpreq_ops ptlrpc_hpreq_common = {
- .hpreq_check = ptlrpc_hpreq_check,
-};
-
-/* Hi-Priority RPC check by RPC operation code. */
-int ptlrpc_hpreq_handler(struct ptlrpc_request *req)
-{
- int opc = lustre_msg_get_opc(req->rq_reqmsg);
-
- /* Check for export to let only reconnects for not yet evicted
- * export to become a HP rpc. */
- if ((req->rq_export != NULL) &&
- (opc == OBD_PING || opc == MDS_CONNECT || opc == OST_CONNECT))
- req->rq_ops = &ptlrpc_hpreq_common;
-
- return 0;
-}
-EXPORT_SYMBOL(ptlrpc_hpreq_handler);
-
static int ptlrpc_server_request_add(struct ptlrpc_service_part *svcpt,
struct ptlrpc_request *req)
{
@@ -1632,6 +1350,7 @@ static bool ptlrpc_server_allow_normal(struct ptlrpc_service_part *svcpt,
bool force)
{
int running = svcpt->scp_nthrs_running;
+
if (unlikely(svcpt->scp_service->srv_req_portal == MDS_REQUEST_PORTAL &&
CFS_FAIL_PRECHECK(OBD_FAIL_PTLRPC_CANCEL_RESEND))) {
/* leave just 1 thread for normal RPCs */
@@ -1726,10 +1445,10 @@ static int
ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt,
struct ptlrpc_thread *thread)
{
- struct ptlrpc_service *svc = svcpt->scp_service;
- struct ptlrpc_request *req;
- __u32 deadline;
- int rc;
+ struct ptlrpc_service *svc = svcpt->scp_service;
+ struct ptlrpc_request *req;
+ __u32 deadline;
+ int rc;
spin_lock(&svcpt->scp_lock);
if (list_empty(&svcpt->scp_req_incoming)) {
@@ -1822,14 +1541,13 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt,
if (rc)
goto err_req;
- ptlrpc_update_export_timer(req->rq_export, 0);
}
/* req_in handling should/must be fast */
- if (get_seconds() - req->rq_arrival_time.tv_sec > 5)
+ if (ktime_get_real_seconds() - req->rq_arrival_time.tv_sec > 5)
DEBUG_REQ(D_WARNING, req, "Slow req_in handling "CFS_DURATION_T"s",
- cfs_time_sub(get_seconds(),
- req->rq_arrival_time.tv_sec));
+ (long)(ktime_get_real_seconds() -
+ req->rq_arrival_time.tv_sec));
/* Set rpc server deadline and add it to the timed list */
deadline = (lustre_msghdr_get_flags(req->rq_reqmsg) &
@@ -1870,11 +1588,14 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
{
struct ptlrpc_service *svc = svcpt->scp_service;
struct ptlrpc_request *request;
- struct timeval work_start;
- struct timeval work_end;
- long timediff;
- int rc;
- int fail_opc = 0;
+ struct timespec64 work_start;
+ struct timespec64 work_end;
+ struct timespec64 timediff;
+ struct timespec64 arrived;
+ unsigned long timediff_usecs;
+ unsigned long arrived_usecs;
+ int rc;
+ int fail_opc = 0;
request = ptlrpc_server_request_get(svcpt, false);
if (request == NULL)
@@ -1895,12 +1616,13 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DUMP_LOG))
libcfs_debug_dumplog();
- do_gettimeofday(&work_start);
- timediff = cfs_timeval_sub(&work_start, &request->rq_arrival_time,
- NULL);
+ ktime_get_real_ts64(&work_start);
+ timediff = timespec64_sub(work_start, request->rq_arrival_time);
+ timediff_usecs = timediff.tv_sec * USEC_PER_SEC +
+ timediff.tv_nsec / NSEC_PER_USEC;
if (likely(svc->srv_stats != NULL)) {
lprocfs_counter_add(svc->srv_stats, PTLRPC_REQWAIT_CNTR,
- timediff);
+ timediff_usecs);
lprocfs_counter_add(svc->srv_stats, PTLRPC_REQQDEPTH_CNTR,
svcpt->scp_nreqs_incoming);
lprocfs_counter_add(svc->srv_stats, PTLRPC_REQACTIVE_CNTR,
@@ -1927,18 +1649,17 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
if (likely(request->rq_export)) {
if (unlikely(ptlrpc_check_req(request)))
goto put_conn;
- ptlrpc_update_export_timer(request->rq_export, timediff >> 19);
}
/* Discard requests queued for longer than the deadline.
The deadline is increased if we send an early reply. */
- if (get_seconds() > request->rq_deadline) {
+ if (ktime_get_real_seconds() > request->rq_deadline) {
DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s: deadline " CFS_DURATION_T ":" CFS_DURATION_T "s ago\n",
libcfs_id2str(request->rq_peer),
- cfs_time_sub(request->rq_deadline,
- request->rq_arrival_time.tv_sec),
- cfs_time_sub(get_seconds(),
- request->rq_deadline));
+ (long)(request->rq_deadline -
+ request->rq_arrival_time.tv_sec),
+ (long)(ktime_get_real_seconds() -
+ request->rq_deadline));
goto put_conn;
}
@@ -1963,19 +1684,22 @@ put_conn:
lu_context_exit(&request->rq_session);
lu_context_fini(&request->rq_session);
- if (unlikely(get_seconds() > request->rq_deadline)) {
+ if (unlikely(ktime_get_real_seconds() > request->rq_deadline)) {
DEBUG_REQ(D_WARNING, request,
- "Request took longer than estimated ("
- CFS_DURATION_T":"CFS_DURATION_T
- "s); client may timeout.",
- cfs_time_sub(request->rq_deadline,
- request->rq_arrival_time.tv_sec),
- cfs_time_sub(get_seconds(),
- request->rq_deadline));
- }
-
- do_gettimeofday(&work_end);
- timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
+ "Request took longer than estimated (%lld:%llds); "
+ "client may timeout.",
+ (s64)request->rq_deadline -
+ request->rq_arrival_time.tv_sec,
+ (s64)ktime_get_real_seconds() - request->rq_deadline);
+ }
+
+ ktime_get_real_ts64(&work_end);
+ timediff = timespec64_sub(work_end, work_start);
+ timediff_usecs = timediff.tv_sec * USEC_PER_SEC +
+ timediff.tv_nsec / NSEC_PER_USEC;
+ arrived = timespec64_sub(work_end, request->rq_arrival_time);
+ arrived_usecs = arrived.tv_sec * USEC_PER_SEC +
+ arrived.tv_nsec / NSEC_PER_USEC;
CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc %s:%s+%d:%d:x%llu:%s:%d Request processed in %ldus (%ldus total) trans %llu rc %d/%d\n",
current_comm(),
(request->rq_export ?
@@ -1986,8 +1710,8 @@ put_conn:
request->rq_xid,
libcfs_id2str(request->rq_peer),
lustre_msg_get_opc(request->rq_reqmsg),
- timediff,
- cfs_timeval_sub(&work_end, &request->rq_arrival_time, NULL),
+ timediff_usecs,
+ arrived_usecs,
(request->rq_repmsg ?
lustre_msg_get_transno(request->rq_repmsg) :
request->rq_transno),
@@ -1997,20 +1721,20 @@ put_conn:
if (likely(svc->srv_stats != NULL && request->rq_reqmsg != NULL)) {
__u32 op = lustre_msg_get_opc(request->rq_reqmsg);
int opc = opcode_offset(op);
+
if (opc > 0 && !(op == LDLM_ENQUEUE || op == MDS_REINT)) {
LASSERT(opc < LUSTRE_MAX_OPCODES);
lprocfs_counter_add(svc->srv_stats,
opc + EXTRA_MAX_OPCODES,
- timediff);
+ timediff_usecs);
}
}
if (unlikely(request->rq_early_count)) {
DEBUG_REQ(D_ADAPTTO, request,
- "sent %d early replies before finishing in "
- CFS_DURATION_T"s",
+ "sent %d early replies before finishing in %llds",
request->rq_early_count,
- cfs_time_sub(work_end.tv_sec,
- request->rq_arrival_time.tv_sec));
+ (s64)work_end.tv_sec -
+ request->rq_arrival_time.tv_sec);
}
out_req:
@@ -2026,10 +1750,10 @@ static int
ptlrpc_handle_rs(struct ptlrpc_reply_state *rs)
{
struct ptlrpc_service_part *svcpt = rs->rs_svcpt;
- struct ptlrpc_service *svc = svcpt->scp_service;
- struct obd_export *exp;
- int nlocks;
- int been_handled;
+ struct ptlrpc_service *svc = svcpt->scp_service;
+ struct obd_export *exp;
+ int nlocks;
+ int been_handled;
exp = rs->rs_export;
@@ -2122,7 +1846,6 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs)
return 1;
}
-
static void
ptlrpc_check_rqbd_pool(struct ptlrpc_service_part *svcpt)
{
@@ -2149,7 +1872,7 @@ ptlrpc_check_rqbd_pool(struct ptlrpc_service_part *svcpt)
static int
ptlrpc_retry_rqbds(void *arg)
{
- struct ptlrpc_service_part *svcpt = (struct ptlrpc_service_part *)arg;
+ struct ptlrpc_service_part *svcpt = arg;
svcpt->scp_rqbd_timeout = 0;
return -ETIMEDOUT;
@@ -2256,10 +1979,10 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt,
*/
static int ptlrpc_main(void *arg)
{
- struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
- struct ptlrpc_service_part *svcpt = thread->t_svcpt;
- struct ptlrpc_service *svc = svcpt->scp_service;
- struct ptlrpc_reply_state *rs;
+ struct ptlrpc_thread *thread = arg;
+ struct ptlrpc_service_part *svcpt = thread->t_svcpt;
+ struct ptlrpc_service *svc = svcpt->scp_service;
+ struct ptlrpc_reply_state *rs;
struct group_info *ginfo = NULL;
struct lu_env *env;
int counter = 0, rc = 0;
@@ -2291,8 +2014,8 @@ static int ptlrpc_main(void *arg)
goto out;
}
- OBD_ALLOC_PTR(env);
- if (env == NULL) {
+ env = kzalloc(sizeof(*env), GFP_NOFS);
+ if (!env) {
rc = -ENOMEM;
goto out_srv_fini;
}
@@ -2317,7 +2040,7 @@ static int ptlrpc_main(void *arg)
}
/* Alloc reply state structure for this one */
- OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size);
+ rs = libcfs_kvzalloc(svc->srv_max_reply_size, GFP_NOFS);
if (!rs) {
rc = -ENOMEM;
goto out_srv_fini;
@@ -2414,7 +2137,7 @@ out_srv_fini:
if (env != NULL) {
lu_context_fini(&env->le_ctx);
- OBD_FREE_PTR(env);
+ kfree(env);
}
out:
CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n",
@@ -2458,11 +2181,11 @@ static int hrt_dont_sleep(struct ptlrpc_hr_thread *hrt,
*/
static int ptlrpc_hr_main(void *arg)
{
- struct ptlrpc_hr_thread *hrt = (struct ptlrpc_hr_thread *)arg;
- struct ptlrpc_hr_partition *hrp = hrt->hrt_partition;
- LIST_HEAD (replies);
- char threadname[20];
- int rc;
+ struct ptlrpc_hr_thread *hrt = arg;
+ struct ptlrpc_hr_partition *hrp = hrt->hrt_partition;
+ LIST_HEAD (replies);
+ char threadname[20];
+ int rc;
snprintf(threadname, sizeof(threadname), "ptlrpc_hr%02d_%03d",
hrp->hrp_cpt, hrt->hrt_id);
@@ -2499,9 +2222,9 @@ static int ptlrpc_hr_main(void *arg)
static void ptlrpc_stop_hr_threads(void)
{
- struct ptlrpc_hr_partition *hrp;
- int i;
- int j;
+ struct ptlrpc_hr_partition *hrp;
+ int i;
+ int j;
ptlrpc_hr.hr_stopping = 1;
@@ -2523,15 +2246,16 @@ static void ptlrpc_stop_hr_threads(void)
static int ptlrpc_start_hr_threads(void)
{
- struct ptlrpc_hr_partition *hrp;
- int i;
- int j;
+ struct ptlrpc_hr_partition *hrp;
+ int i;
+ int j;
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
- int rc = 0;
+ int rc = 0;
for (j = 0; j < hrp->hrp_nthrs; j++) {
struct ptlrpc_hr_thread *hrt = &hrp->hrp_thrs[j];
+
rc = PTR_ERR(kthread_run(ptlrpc_hr_main,
&hrp->hrp_thrs[j],
"ptlrpc_hr%02d_%03d",
@@ -2555,9 +2279,9 @@ static int ptlrpc_start_hr_threads(void)
static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt)
{
- struct l_wait_info lwi = { 0 };
- struct ptlrpc_thread *thread;
- LIST_HEAD (zombie);
+ struct l_wait_info lwi = { 0 };
+ struct ptlrpc_thread *thread;
+ LIST_HEAD (zombie);
CDEBUG(D_INFO, "Stopping threads for service %s\n",
svcpt->scp_service->srv_name);
@@ -2596,30 +2320,29 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt)
thread = list_entry(zombie.next,
struct ptlrpc_thread, t_link);
list_del(&thread->t_link);
- OBD_FREE_PTR(thread);
+ kfree(thread);
}
}
/**
* Stops all threads of a particular service \a svc
*/
-void ptlrpc_stop_all_threads(struct ptlrpc_service *svc)
+static void ptlrpc_stop_all_threads(struct ptlrpc_service *svc)
{
struct ptlrpc_service_part *svcpt;
- int i;
+ int i;
ptlrpc_service_for_each_part(svcpt, i, svc) {
if (svcpt->scp_service != NULL)
ptlrpc_svcpt_stop_threads(svcpt);
}
}
-EXPORT_SYMBOL(ptlrpc_stop_all_threads);
int ptlrpc_start_threads(struct ptlrpc_service *svc)
{
- int rc = 0;
- int i;
- int j;
+ int rc = 0;
+ int i;
+ int j;
/* We require 2 threads min, see note in ptlrpc_server_handle_request */
LASSERT(svc->srv_nthrs_cpt_init >= PTLRPC_NTHRS_INIT);
@@ -2648,10 +2371,10 @@ EXPORT_SYMBOL(ptlrpc_start_threads);
int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
{
- struct l_wait_info lwi = { 0 };
- struct ptlrpc_thread *thread;
- struct ptlrpc_service *svc;
- int rc;
+ struct l_wait_info lwi = { 0 };
+ struct ptlrpc_thread *thread;
+ struct ptlrpc_service *svc;
+ int rc;
LASSERT(svcpt != NULL);
@@ -2670,7 +2393,9 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
svcpt->scp_nthrs_running == svc->srv_nthrs_cpt_init - 1))
return -EMFILE;
- OBD_CPT_ALLOC_PTR(thread, svc->srv_cptable, svcpt->scp_cpt);
+ thread = kzalloc_node(sizeof(*thread), GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable,
+ svcpt->scp_cpt));
if (thread == NULL)
return -ENOMEM;
init_waitqueue_head(&thread->t_ctl_waitq);
@@ -2678,7 +2403,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
spin_lock(&svcpt->scp_lock);
if (!ptlrpc_threads_increasable(svcpt)) {
spin_unlock(&svcpt->scp_lock);
- OBD_FREE_PTR(thread);
+ kfree(thread);
return -EMFILE;
}
@@ -2687,7 +2412,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
* might require unique and contiguous t_id */
LASSERT(svcpt->scp_nthrs_starting == 1);
spin_unlock(&svcpt->scp_lock);
- OBD_FREE_PTR(thread);
+ kfree(thread);
if (wait) {
CDEBUG(D_INFO, "Waiting for creating thread %s #%d\n",
svc->srv_thread_name, svcpt->scp_thr_nextid);
@@ -2733,7 +2458,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
} else {
list_del(&thread->t_link);
spin_unlock(&svcpt->scp_lock);
- OBD_FREE_PTR(thread);
+ kfree(thread);
}
return rc;
}
@@ -2751,12 +2476,12 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
int ptlrpc_hr_init(void)
{
- struct ptlrpc_hr_partition *hrp;
- struct ptlrpc_hr_thread *hrt;
- int rc;
- int i;
- int j;
- int weight;
+ struct ptlrpc_hr_partition *hrp;
+ struct ptlrpc_hr_thread *hrt;
+ int rc;
+ int i;
+ int j;
+ int weight;
memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr));
ptlrpc_hr.hr_cpt_table = cfs_cpt_table;
@@ -2768,7 +2493,7 @@ int ptlrpc_hr_init(void)
init_waitqueue_head(&ptlrpc_hr.hr_waitq);
- weight = cpumask_weight(topology_thread_cpumask(0));
+ weight = cpumask_weight(topology_sibling_cpumask(0));
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
hrp->hrp_cpt = i;
@@ -2780,8 +2505,10 @@ int ptlrpc_hr_init(void)
hrp->hrp_nthrs /= weight;
LASSERT(hrp->hrp_nthrs > 0);
- OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i,
- hrp->hrp_nthrs * sizeof(*hrt));
+ hrp->hrp_thrs =
+ kzalloc_node(hrp->hrp_nthrs * sizeof(*hrt), GFP_NOFS,
+ cfs_cpt_spread_node(ptlrpc_hr.hr_cpt_table,
+ i));
if (hrp->hrp_thrs == NULL) {
rc = -ENOMEM;
goto out;
@@ -2807,8 +2534,8 @@ out:
void ptlrpc_hr_fini(void)
{
- struct ptlrpc_hr_partition *hrp;
- int i;
+ struct ptlrpc_hr_partition *hrp;
+ int i;
if (ptlrpc_hr.hr_partitions == NULL)
return;
@@ -2816,17 +2543,13 @@ void ptlrpc_hr_fini(void)
ptlrpc_stop_hr_threads();
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
- if (hrp->hrp_thrs != NULL) {
- OBD_FREE(hrp->hrp_thrs,
- hrp->hrp_nthrs * sizeof(hrp->hrp_thrs[0]));
- }
+ kfree(hrp->hrp_thrs);
}
cfs_percpt_free(ptlrpc_hr.hr_partitions);
ptlrpc_hr.hr_partitions = NULL;
}
-
/**
* Wait until all already scheduled replies are processed.
*/
@@ -2849,24 +2572,24 @@ static void ptlrpc_wait_replies(struct ptlrpc_service_part *svcpt)
static void
ptlrpc_service_del_atimer(struct ptlrpc_service *svc)
{
- struct ptlrpc_service_part *svcpt;
- int i;
+ struct ptlrpc_service_part *svcpt;
+ int i;
/* early disarm AT timer... */
ptlrpc_service_for_each_part(svcpt, i, svc) {
if (svcpt->scp_service != NULL)
- cfs_timer_disarm(&svcpt->scp_at_timer);
+ del_timer(&svcpt->scp_at_timer);
}
}
static void
ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc)
{
- struct ptlrpc_service_part *svcpt;
+ struct ptlrpc_service_part *svcpt;
struct ptlrpc_request_buffer_desc *rqbd;
- struct l_wait_info lwi;
- int rc;
- int i;
+ struct l_wait_info lwi;
+ int rc;
+ int i;
/* All history will be culled when the next request buffer is
* freed in ptlrpc_service_purge_all() */
@@ -2918,11 +2641,11 @@ ptlrpc_service_unlink_rqbd(struct ptlrpc_service *svc)
static void
ptlrpc_service_purge_all(struct ptlrpc_service *svc)
{
- struct ptlrpc_service_part *svcpt;
- struct ptlrpc_request_buffer_desc *rqbd;
- struct ptlrpc_request *req;
- struct ptlrpc_reply_state *rs;
- int i;
+ struct ptlrpc_service_part *svcpt;
+ struct ptlrpc_request_buffer_desc *rqbd;
+ struct ptlrpc_request *req;
+ struct ptlrpc_reply_state *rs;
+ int i;
ptlrpc_service_for_each_part(svcpt, i, svc) {
if (svcpt->scp_service == NULL)
@@ -2978,7 +2701,7 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc)
struct ptlrpc_reply_state,
rs_list);
list_del(&rs->rs_list);
- OBD_FREE_LARGE(rs, svc->srv_max_reply_size);
+ kvfree(rs);
}
}
}
@@ -2986,39 +2709,31 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc)
static void
ptlrpc_service_free(struct ptlrpc_service *svc)
{
- struct ptlrpc_service_part *svcpt;
- struct ptlrpc_at_array *array;
- int i;
+ struct ptlrpc_service_part *svcpt;
+ struct ptlrpc_at_array *array;
+ int i;
ptlrpc_service_for_each_part(svcpt, i, svc) {
if (svcpt->scp_service == NULL)
break;
/* In case somebody rearmed this in the meantime */
- cfs_timer_disarm(&svcpt->scp_at_timer);
+ del_timer(&svcpt->scp_at_timer);
array = &svcpt->scp_at_array;
- if (array->paa_reqs_array != NULL) {
- OBD_FREE(array->paa_reqs_array,
- sizeof(struct list_head) * array->paa_size);
- array->paa_reqs_array = NULL;
- }
-
- if (array->paa_reqs_count != NULL) {
- OBD_FREE(array->paa_reqs_count,
- sizeof(__u32) * array->paa_size);
- array->paa_reqs_count = NULL;
- }
+ kfree(array->paa_reqs_array);
+ array->paa_reqs_array = NULL;
+ kfree(array->paa_reqs_count);
+ array->paa_reqs_count = NULL;
}
ptlrpc_service_for_each_part(svcpt, i, svc)
- OBD_FREE_PTR(svcpt);
+ kfree(svcpt);
if (svc->srv_cpts != NULL)
cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts);
- OBD_FREE(svc, offsetof(struct ptlrpc_service,
- srv_parts[svc->srv_ncpts]));
+ kfree(svc);
}
int ptlrpc_unregister_service(struct ptlrpc_service *service)
@@ -3039,67 +2754,10 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service)
ptlrpc_service_nrs_cleanup(service);
ptlrpc_lprocfs_unregister_service(service);
+ ptlrpc_sysfs_unregister_service(service);
ptlrpc_service_free(service);
return 0;
}
EXPORT_SYMBOL(ptlrpc_unregister_service);
-
-/**
- * Returns 0 if the service is healthy.
- *
- * Right now, it just checks to make sure that requests aren't languishing
- * in the queue. We'll use this health check to govern whether a node needs
- * to be shot, so it's intentionally non-aggressive. */
-int ptlrpc_svcpt_health_check(struct ptlrpc_service_part *svcpt)
-{
- struct ptlrpc_request *request = NULL;
- struct timeval right_now;
- long timediff;
-
- do_gettimeofday(&right_now);
-
- spin_lock(&svcpt->scp_req_lock);
- /* How long has the next entry been waiting? */
- if (ptlrpc_server_high_pending(svcpt, true))
- request = ptlrpc_nrs_req_peek_nolock(svcpt, true);
- else if (ptlrpc_server_normal_pending(svcpt, true))
- request = ptlrpc_nrs_req_peek_nolock(svcpt, false);
-
- if (request == NULL) {
- spin_unlock(&svcpt->scp_req_lock);
- return 0;
- }
-
- timediff = cfs_timeval_sub(&right_now, &request->rq_arrival_time, NULL);
- spin_unlock(&svcpt->scp_req_lock);
-
- if ((timediff / ONE_MILLION) >
- (AT_OFF ? obd_timeout * 3 / 2 : at_max)) {
- CERROR("%s: unhealthy - request has been waiting %lds\n",
- svcpt->scp_service->srv_name, timediff / ONE_MILLION);
- return -1;
- }
-
- return 0;
-}
-
-int
-ptlrpc_service_health_check(struct ptlrpc_service *svc)
-{
- struct ptlrpc_service_part *svcpt;
- int i;
-
- if (svc == NULL)
- return 0;
-
- ptlrpc_service_for_each_part(svcpt, i, svc) {
- int rc = ptlrpc_svcpt_health_check(svcpt);
-
- if (rc != 0)
- return rc;
- }
- return 0;
-}
-EXPORT_SYMBOL(ptlrpc_service_health_check);
diff --git a/kernel/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/kernel/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
index d6d92046c..40f720ca3 100644
--- a/kernel/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
+++ b/kernel/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
@@ -43,6 +43,8 @@
#include "../include/obd_class.h"
#include "../include/lustre_net.h"
#include "../include/lustre_disk.h"
+#include "ptlrpc_internal.h"
+
void lustre_assert_wire_constants(void)
{
/* Wire protocol assertions generated by 'wirecheck'
@@ -636,12 +638,8 @@ void lustre_assert_wire_constants(void)
(long long)(int)offsetof(struct lustre_msg_v2, lm_buflens[0]));
LASSERTF((int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0]) == 4, "found %lld\n",
(long long)(int)sizeof(((struct lustre_msg_v2 *)0)->lm_buflens[0]));
- LASSERTF(LUSTRE_MSG_MAGIC_V1 == 0x0BD00BD0, "found 0x%.8x\n",
- LUSTRE_MSG_MAGIC_V1);
LASSERTF(LUSTRE_MSG_MAGIC_V2 == 0x0BD00BD3, "found 0x%.8x\n",
LUSTRE_MSG_MAGIC_V2);
- LASSERTF(LUSTRE_MSG_MAGIC_V1_SWABBED == 0xD00BD00B, "found 0x%.8x\n",
- LUSTRE_MSG_MAGIC_V1_SWABBED);
LASSERTF(LUSTRE_MSG_MAGIC_V2_SWABBED == 0xD30BD00B, "found 0x%.8x\n",
LUSTRE_MSG_MAGIC_V2_SWABBED);
diff --git a/kernel/drivers/staging/lustre/sysfs-fs-lustre b/kernel/drivers/staging/lustre/sysfs-fs-lustre
new file mode 100644
index 000000000..873e2cf31
--- /dev/null
+++ b/kernel/drivers/staging/lustre/sysfs-fs-lustre
@@ -0,0 +1,646 @@
+What: /sys/fs/lustre/version
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows current running lustre version.
+
+What: /sys/fs/lustre/pinger
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows if the lustre module has pinger support.
+ "on" means yes and "off" means no.
+
+What: /sys/fs/lustre/health
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows whenever current system state believed to be "healthy",
+ "NOT HEALTHY", or "LBUG" whenever lustre has experienced
+ an internal assertion failure
+
+What: /sys/fs/lustre/jobid_name
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Currently running job "name" for this node to be transferred
+ to Lustre servers for purposes of QoS and statistics gathering.
+ Writing into this file will change the name, reading outputs
+ currently set value.
+
+What: /sys/fs/lustre/jobid_var
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Control file for lustre "jobstats" functionality, write new
+ value from the list below to change the mode:
+ disable - disable job name reporting to the servers (default)
+ procname_uid - form the job name as the current running
+ command name and pid with a dot in between
+ e.g. dd.1253
+ nodelocal - use jobid_name value from above.
+
+What: /sys/fs/lustre/timeout
+Date: June 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls "lustre timeout" variable, also known as obd_timeout
+ in some old manual. In the past obd_timeout was of paramount
+ importance as the timeout value used everywhere and where
+ other timeouts were derived from. These days it's much less
+ important as network timeouts are mostly determined by
+ AT (adaptive timeouts).
+ Unit: seconds, default: 100
+
+What: /sys/fs/lustre/max_dirty_mb
+Date: June 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls total number of dirty cache (in megabytes) allowed
+ across all mounted lustre filesystems.
+ Since writeout of dirty pages in Lustre is somewhat expensive,
+ when you allow to many dirty pages, this might lead to
+ performance degradations as kernel tries to desperately
+ find some pages to free/writeout.
+ Default 1/2 RAM. Min value 4, max value 9/10 of RAM.
+
+What: /sys/fs/lustre/debug_peer_on_timeout
+Date: June 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Control if lnet debug information should be printed when
+ an RPC timeout occurs.
+ 0 disabled (default)
+ 1 enabled
+
+What: /sys/fs/lustre/dump_on_timeout
+Date: June 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls if Lustre debug log should be dumped when an RPC
+ timeout occurs. This is useful if yout debug buffer typically
+ rolls over by the time you notice RPC timeouts.
+
+What: /sys/fs/lustre/dump_on_eviction
+Date: June 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls if Lustre debug log should be dumped when an this
+ client is evicted from one of the servers.
+ This is useful if yout debug buffer typically rolls over
+ by the time you notice the eviction event.
+
+What: /sys/fs/lustre/at_min
+Date: July 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls minimum adaptive timeout in seconds. If you encounter
+ a case where clients timeout due to server-reported processing
+ time being too short, you might consider increasing this value.
+ One common case of this if the underlying network has
+ unpredictable long delays.
+ Default: 0
+
+What: /sys/fs/lustre/at_max
+Date: July 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls maximum adaptive timeout in seconds. If at_max timeout
+ is reached for an RPC, the RPC will time out.
+ Some genuinuely slow network hardware might warrant increasing
+ this value.
+ Setting this value to 0 disables Adaptive Timeouts
+ functionality and old-style obd_timeout value is then used.
+ Default: 600
+
+What: /sys/fs/lustre/at_extra
+Date: July 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls how much extra time to request for unfinished requests
+ in processing in seconds. Normally a server-side parameter, it
+ is also used on the client for responses to various LDLM ASTs
+ that are handled with a special server thread on the client.
+ This is a way for the servers to ask the clients not to time
+ out the request that reached current servicing time estimate
+ yet and give it some more time.
+ Default: 30
+
+What: /sys/fs/lustre/at_early_margin
+Date: July 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls when to send the early reply for requests that are
+ about to timeout as an offset to the estimated service time in
+ seconds..
+ Default: 5
+
+What: /sys/fs/lustre/at_history
+Date: July 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls for how many seconds to remember slowest events
+ encountered by adaptive timeouts code.
+ Default: 600
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Biggest blocksize on object storage server for this filesystem.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/kbytestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of kilobytes of space on this filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/kbytesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of free kilobytes of space on this filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/kbytesavail
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of free kilobytes of space on this filesystem
+ actually available for use (taking into account per-client
+ grants and filesystem reservations).
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/filestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of inodes on the filesystem.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/filesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows estimated number of free inodes on the filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/client_type
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows whenever this filesystem considers this client to be
+ compute cluster-local or remote. Remote clients have
+ additional uid/gid convrting logic applied.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/fstype
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows filesystem type of the filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/uuid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows this filesystem superblock uuid
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_read_ahead_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Sets maximum number of megabytes in system memory to be
+ given to read-ahead cache.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_read_ahead_per_file_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Sets maximum number of megabytes to read-ahead for a single file
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_read_ahead_whole_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ For small reads, how many megabytes to actually request from
+ the server as initial read-ahead.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/checksum_pages
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Enables or disables per-page checksum at llite layer, before
+ the pages are actually given to lower level for network transfer
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/stats_track_pid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Limit Lustre vfs operations gathering to just a single pid.
+ 0 to track everything.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/stats_track_ppid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Limit Lustre vfs operations gathering to just a single ppid.
+ 0 to track everything.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/stats_track_gid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Limit Lustre vfs operations gathering to just a single gid.
+ 0 to track everything.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/statahead_max
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls maximum number of statahead requests to send when
+ sequential readdir+stat pattern is detected.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/statahead_agl
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls if AGL (async glimpse ahead - obtain object information
+ from OSTs in parallel with MDS during statahead) should be
+ enabled or disabled.
+ 0 to disable, 1 to enable.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/lazystatfs
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls statfs(2) behaviour in the face of down servers.
+ If 0, always wait for all servers to come online,
+ if 1, ignote inactive servers.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_easize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows maximum number of bytes file striping data could be
+ in current configuration of storage.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/default_easize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows maximum observed file striping data seen by this
+ filesystem client instance.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/xattr_cache
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls extended attributes client-side cache.
+ 1 to enable, 0 to disable.
+
+What: /sys/fs/lustre/ldlm/cancel_unused_locks_before_replay
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls if client should replay unused locks during recovery
+ If a client tends to have a lot of unused locks in LRU,
+ recovery times might become prolonged.
+ 1 - just locally cancel unused locks (default)
+ 0 - replay unused locks.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/resource_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays number of lock resources (objects on which individual
+ locks are taken) currently allocated in this namespace.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lock_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays number or locks allocated in this namespace.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lru_size
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls and displays LRU size limit for unused locks for this
+ namespace.
+ 0 - LRU size is unlimited, controlled by server resources
+ positive number - number of locks to allow in lock LRU list
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lock_unused_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Display number of locks currently sitting in the LRU list
+ of this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lru_max_age
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of milliseconds a lock could sit in LRU list
+ before client would voluntarily cancel it as unused.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/early_lock_cancel
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls "early lock cancellation" feature on this namespace
+ if supported by the server.
+ When enabled, tries to preemtively cancel locks that would be
+ cancelled by verious operations and bundle the cancellation
+ requests in the same RPC as the main operation, which results
+ in significant speedups due to reduced lock-pingpong RPCs.
+ 0 - disabled
+ 1 - enabled (default)
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/granted
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays number of granted locks in this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/grant_rate
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of granted locks in this namespace during last
+ time interval
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/cancel_rate
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of lock cancellations in this namespace during
+ last time interval
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/grant_speed
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Calculated speed of lock granting (grant_rate - cancel_rate)
+ in this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/grant_plan
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Estimated number of locks to be granted in the next time
+ interval in this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/limit
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls number of allowed locks in this pool.
+ When lru_size is 0, this is the actual limit then.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/lock_volume_factor
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Multiplier for all lock volume calculations above.
+ Default is 1. Increase to make the client to more agressively
+ clean it's lock LRU list for this namespace.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/server_lock_volume
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Calculated server lock volume.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/recalc_period
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls length of time between recalculation of above
+ values (in seconds).
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_min
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls minimum number of ldlm callback threads to start.
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_max
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls maximum number of ldlm callback threads to start.
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_started
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows actual number of ldlm callback threads running.
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/high_priority_ratio
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls what percentage of ldlm callback threads is dedicated
+ to "high priority" incoming requests.
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/blocksize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Blocksize on backend filesystem for service behind this obd
+ device (or biggest blocksize for compound devices like lov
+ and lmv)
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Total number of kilobytes of space on backend filesystem
+ for service behind this obd (or total amount for compound
+ devices like lov lmv)
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of free kilobytes on backend filesystem for service
+ behind this obd (or total amount for compound devices
+ like lov lmv)
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytesavail
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of kilobytes of free space on backend filesystem
+ for service behind this obd (or total amount for compound
+ devices like lov lmv) that is actually available for use
+ (taking into account per-client and filesystem reservations).
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/filestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of inodes on backend filesystem for service behind this
+ obd.
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/filesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of free inodes on backend filesystem for service
+ behind this obd.
+
+What: /sys/fs/lustre/mdc/{connection_name}/max_pages_per_rpc
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of readdir pages to fit into a single readdir
+ RPC.
+
+What: /sys/fs/lustre/{mdc,osc}/{connection_name}/max_rpcs_in_flight
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of parallel RPCs on the wire to allow on
+ this connection. Increasing this number would help on higher
+ latency links, but has a chance of overloading a server
+ if you have too many clients like this.
+ Default: 8
+
+What: /sys/fs/lustre/osc/{connection_name}/max_pages_per_rpc
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of pages to fit into a single RPC.
+ Typically bigger RPCs allow for better performance.
+ Default: however many pages to form 1M of data (256 pages
+ for 4K page sized platforms)
+
+What: /sys/fs/lustre/osc/{connection_name}/active
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls accessibility of this connection. If set to 0,
+ fail all accesses immediately.
+
+What: /sys/fs/lustre/osc/{connection_name}/checksums
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls whenever to checksum bulk RPC data over the wire
+ to this target.
+ 1: enable (default) ; 0: disable
+
+What: /sys/fs/lustre/osc/{connection_name}/contention_seconds
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls for how long to consider a file contended once
+ indicated as such by the server.
+ When a file is considered contended, all operations switch to
+ synchronous lockless mode to avoid cache and lock pingpong.
+
+What: /sys/fs/lustre/osc/{connection_name}/cur_dirty_bytes
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays how many dirty bytes is presently in the cache for this
+ target.
+
+What: /sys/fs/lustre/osc/{connection_name}/cur_grant_bytes
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows how many bytes we have as a "dirty cache" grant from the
+ server. Writing a value smaller than shown allows to release
+ some grant back to the server.
+ Dirty cache grant is a way Lustre ensures that cached successful
+ writes on client do not end up discarded by the server due to
+ lack of space later on.
+
+What: /sys/fs/lustre/osc/{connection_name}/cur_lost_grant_bytes
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows how many granted bytes were released to the server due
+ to lack of write activity on this client.
+
+What: /sys/fs/lustre/osc/{connection_name}/grant_shrink_interval
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of seconds with no write activity for this target
+ to start releasing dirty grant back to the server.
+
+What: /sys/fs/lustre/osc/{connection_name}/destroys_in_flight
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of DESTROY RPCs currently in flight to this target.
+
+What: /sys/fs/lustre/osc/{connection_name}/lockless_truncate
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls whether lockless truncate RPCs are allowed to this
+ target.
+ Lockless truncate causes server to perform the locking which
+ is beneficial if the truncate is not followed by a write
+ immediately.
+ 1: enable ; 0: disable (default)
+
+What: /sys/fs/lustre/osc/{connection_name}/max_dirty_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls how much dirty data this client can accumulate
+ for this target. This is orthogonal to dirty grant and is
+ a hard limit even if the server would allow a bigger dirty
+ cache.
+ While allowing higher dirty cache is beneficial for write
+ performance, flushing write cache takes longer and as such
+ the node might be more prone to OOMs.
+ Having this value set too low might result in not being able
+ to sent too many parallel WRITE RPCs.
+ Default: 32
+
+What: /sys/fs/lustre/osc/{connection_name}/resend_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls how many times to try and resend RPCs to this target
+ that failed with "recoverable" status, such as EAGAIN,
+ ENOMEM.
+
+What: /sys/fs/lustre/lov/{connection_name}/numobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of OSC targets managed by this LOV instance.
+
+What: /sys/fs/lustre/lov/{connection_name}/activeobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of OSC targets managed by this LOV instance that are
+ actually active.
+
+What: /sys/fs/lustre/lmv/{connection_name}/numobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of MDC targets managed by this LMV instance.
+
+What: /sys/fs/lustre/lmv/{connection_name}/activeobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of MDC targets managed by this LMV instance that are
+ actually active.
+
+What: /sys/fs/lustre/lmv/{connection_name}/placement
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Determines policy of inode placement in case of multiple
+ metadata servers:
+ CHAR - based on a hash of the file name used at creation time
+ (Default)
+ NID - based on a hash of creating client network id.