From b4b7ff4b08e691656c9d77c758fc355833128ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fabian=20Silva=20Delgado?= Date: Wed, 20 Jan 2016 14:01:31 -0300 Subject: Linux-libre 4.4-gnu --- .../staging/lustre/include/linux/libcfs/libcfs.h | 13 +- .../lustre/include/linux/libcfs/libcfs_debug.h | 1 + .../lustre/include/linux/libcfs/libcfs_hash.h | 189 +-- .../lustre/include/linux/libcfs/libcfs_ioctl.h | 1 - .../lustre/include/linux/libcfs/libcfs_prim.h | 13 - .../lustre/include/linux/libcfs/libcfs_private.h | 4 +- .../lustre/include/linux/libcfs/libcfs_string.h | 5 +- .../lustre/include/linux/libcfs/libcfs_time.h | 49 - .../lustre/include/linux/libcfs/linux/libcfs.h | 3 - .../lustre/include/linux/libcfs/linux/linux-time.h | 35 +- .../staging/lustre/include/linux/lnet/lib-lnet.h | 4 +- .../staging/lustre/include/linux/lnet/lib-types.h | 2 +- drivers/staging/lustre/include/linux/lnet/nidstr.h | 47 +- drivers/staging/lustre/include/linux/lnet/types.h | 2 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 44 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 293 ++-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 100 +- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 1 - .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 61 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 6 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 21 +- .../lustre/lnet/klnds/socklnd/socklnd_lib.c | 6 +- .../lustre/lnet/klnds/socklnd/socklnd_modparams.c | 1 - drivers/staging/lustre/lnet/lnet/Makefile | 2 +- drivers/staging/lustre/lnet/lnet/acceptor.c | 2 - drivers/staging/lustre/lnet/lnet/api-ni.c | 18 +- drivers/staging/lustre/lnet/lnet/config.c | 4 +- drivers/staging/lustre/lnet/lnet/lib-eq.c | 12 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 7 +- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 4 +- drivers/staging/lustre/lnet/lnet/nidstrings.c | 1260 +++++++++++++++++ drivers/staging/lustre/lnet/lnet/router.c | 17 +- drivers/staging/lustre/lnet/lnet/router_proc.c | 45 +- drivers/staging/lustre/lnet/selftest/brw_test.c | 6 +- drivers/staging/lustre/lnet/selftest/conctl.c | 4 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 20 +- drivers/staging/lustre/lnet/selftest/conrpc.h | 5 +- drivers/staging/lustre/lnet/selftest/console.c | 20 +- drivers/staging/lustre/lnet/selftest/console.h | 3 +- drivers/staging/lustre/lnet/selftest/framework.c | 12 +- drivers/staging/lustre/lnet/selftest/module.c | 1 - drivers/staging/lustre/lnet/selftest/ping_test.c | 16 +- drivers/staging/lustre/lnet/selftest/rpc.c | 13 +- drivers/staging/lustre/lnet/selftest/rpc.h | 1 - drivers/staging/lustre/lnet/selftest/selftest.h | 27 +- drivers/staging/lustre/lnet/selftest/timer.c | 17 +- drivers/staging/lustre/lnet/selftest/timer.h | 2 +- drivers/staging/lustre/lustre/fid/fid_request.c | 132 +- drivers/staging/lustre/lustre/fid/lproc_fid.c | 3 - drivers/staging/lustre/lustre/fld/fld_cache.c | 3 +- drivers/staging/lustre/lustre/fld/fld_internal.h | 3 - drivers/staging/lustre/lustre/fld/fld_request.c | 1 - drivers/staging/lustre/lustre/fld/lproc_fld.c | 1 - drivers/staging/lustre/lustre/include/cl_object.h | 59 +- drivers/staging/lustre/lustre/include/dt_object.h | 1496 -------------------- .../staging/lustre/lustre/include/interval_tree.h | 36 - drivers/staging/lustre/lustre/include/lclient.h | 28 +- .../lustre/lustre/include/linux/lustre_compat25.h | 1 - .../lustre/lustre/include/linux/lustre_lite.h | 4 +- .../lustre/include/linux/lustre_patchless_compat.h | 1 - drivers/staging/lustre/lustre/include/linux/obd.h | 2 +- .../staging/lustre/lustre/include/lprocfs_status.h | 61 +- drivers/staging/lustre/lustre/include/lu_object.h | 61 +- drivers/staging/lustre/lustre/include/lu_ref.h | 1 - .../staging/lustre/lustre/include/lustre/libiam.h | 145 -- .../lustre/lustre/include/lustre/ll_fiemap.h | 3 - .../lustre/lustre/include/lustre/lustre_idl.h | 98 +- .../lustre/include/lustre/lustre_lfsck_user.h | 95 -- .../lustre/lustre/include/lustre/lustre_user.h | 40 +- .../staging/lustre/lustre/include/lustre_capa.h | 305 ---- drivers/staging/lustre/lustre/include/lustre_cfg.h | 10 +- .../staging/lustre/lustre/include/lustre_debug.h | 1 - .../staging/lustre/lustre/include/lustre_disk.h | 159 +-- drivers/staging/lustre/lustre/include/lustre_dlm.h | 117 +- .../lustre/lustre/include/lustre_dlm_flags.h | 228 +-- .../staging/lustre/lustre/include/lustre_eacl.h | 5 - .../staging/lustre/lustre/include/lustre_export.h | 37 +- drivers/staging/lustre/lustre/include/lustre_fid.h | 96 +- drivers/staging/lustre/lustre/include/lustre_fld.h | 5 - drivers/staging/lustre/lustre/include/lustre_ha.h | 1 - .../staging/lustre/lustre/include/lustre_handles.h | 3 +- .../staging/lustre/lustre/include/lustre_import.h | 22 +- drivers/staging/lustre/lustre/include/lustre_lib.h | 19 +- .../staging/lustre/lustre/include/lustre_lite.h | 1 - drivers/staging/lustre/lustre/include/lustre_log.h | 167 +-- drivers/staging/lustre/lustre/include/lustre_mdc.h | 1 - drivers/staging/lustre/lustre/include/lustre_mds.h | 5 - drivers/staging/lustre/lustre/include/lustre_net.h | 152 +- .../staging/lustre/lustre/include/lustre_param.h | 12 - .../lustre/lustre/include/lustre_req_layout.h | 11 - drivers/staging/lustre/lustre/include/lustre_sec.h | 48 +- drivers/staging/lustre/lustre/include/obd.h | 188 +-- drivers/staging/lustre/lustre/include/obd_cache.h | 39 - drivers/staging/lustre/lustre/include/obd_cksum.h | 1 - drivers/staging/lustre/lustre/include/obd_class.h | 236 +-- .../staging/lustre/lustre/include/obd_support.h | 284 +--- drivers/staging/lustre/lustre/lclient/glimpse.c | 6 +- drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 102 +- .../staging/lustre/lustre/lclient/lcommon_misc.c | 1 - drivers/staging/lustre/lustre/ldlm/interval_tree.c | 274 +--- drivers/staging/lustre/lustre/ldlm/l_lock.c | 7 +- drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 27 +- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 278 +--- .../staging/lustre/lustre/ldlm/ldlm_inodebits.c | 1 - drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 36 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 38 - drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 391 +---- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 132 +- drivers/staging/lustre/lustre/ldlm/ldlm_plain.c | 1 - drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 441 +----- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 380 +---- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 209 +-- drivers/staging/lustre/lustre/libcfs/Makefile | 2 +- drivers/staging/lustre/lustre/libcfs/debug.c | 5 +- drivers/staging/lustre/lustre/libcfs/fail.c | 4 +- drivers/staging/lustre/lustre/libcfs/hash.c | 131 +- .../lustre/lustre/libcfs/kernel_user_comm.c | 1 + drivers/staging/lustre/lustre/libcfs/libcfs_lock.c | 8 +- drivers/staging/lustre/lustre/libcfs/libcfs_mem.c | 10 +- .../staging/lustre/lustre/libcfs/libcfs_string.c | 144 +- .../staging/lustre/lustre/libcfs/linux/linux-cpu.c | 3 +- .../lustre/libcfs/linux/linux-crypto-adler.c | 3 +- .../lustre/lustre/libcfs/linux/linux-crypto.c | 9 +- .../lustre/lustre/libcfs/linux/linux-curproc.c | 1 + .../lustre/lustre/libcfs/linux/linux-debug.c | 2 +- .../lustre/lustre/libcfs/linux/linux-module.c | 1 - .../lustre/lustre/libcfs/linux/linux-prim.c | 70 - .../lustre/lustre/libcfs/linux/linux-tracefile.c | 32 +- drivers/staging/lustre/lustre/libcfs/module.c | 204 ++- drivers/staging/lustre/lustre/libcfs/nidstrings.c | 842 ----------- drivers/staging/lustre/lustre/libcfs/tracefile.c | 8 +- drivers/staging/lustre/lustre/libcfs/tracefile.h | 3 - drivers/staging/lustre/lustre/libcfs/workitem.c | 16 +- drivers/staging/lustre/lustre/llite/Makefile | 2 +- drivers/staging/lustre/lustre/llite/dcache.c | 1 - drivers/staging/lustre/lustre/llite/dir.c | 15 +- drivers/staging/lustre/lustre/llite/file.c | 89 +- drivers/staging/lustre/lustre/llite/llite_capa.c | 661 --------- drivers/staging/lustre/lustre/llite/llite_close.c | 9 +- .../staging/lustre/lustre/llite/llite_internal.h | 49 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 179 +-- drivers/staging/lustre/lustre/llite/llite_mmap.c | 2 - drivers/staging/lustre/lustre/llite/llite_nfs.c | 9 +- drivers/staging/lustre/lustre/llite/llite_rmtacl.c | 1 - drivers/staging/lustre/lustre/llite/lloop.c | 10 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 38 +- drivers/staging/lustre/lustre/llite/namei.c | 58 +- drivers/staging/lustre/lustre/llite/remote_perm.c | 16 +- drivers/staging/lustre/lustre/llite/rw.c | 42 +- drivers/staging/lustre/lustre/llite/rw26.c | 1 + drivers/staging/lustre/lustre/llite/statahead.c | 40 +- drivers/staging/lustre/lustre/llite/super25.c | 42 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 11 +- drivers/staging/lustre/lustre/llite/vvp_internal.h | 1 - drivers/staging/lustre/lustre/llite/vvp_io.c | 10 +- drivers/staging/lustre/lustre/llite/vvp_lock.c | 1 - drivers/staging/lustre/lustre/llite/vvp_object.c | 13 +- drivers/staging/lustre/lustre/llite/vvp_page.c | 1 - drivers/staging/lustre/lustre/llite/xattr.c | 19 +- drivers/staging/lustre/lustre/llite/xattr_cache.c | 24 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 78 +- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 2 + .../staging/lustre/lustre/lov/lov_cl_internal.h | 5 - drivers/staging/lustre/lustre/lov/lov_dev.c | 15 +- drivers/staging/lustre/lustre/lov/lov_ea.c | 7 +- drivers/staging/lustre/lustre/lov/lov_internal.h | 5 +- drivers/staging/lustre/lustre/lov/lov_io.c | 9 +- drivers/staging/lustre/lustre/lov/lov_lock.c | 21 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 52 +- drivers/staging/lustre/lustre/lov/lov_object.c | 18 +- drivers/staging/lustre/lustre/lov/lov_pack.c | 22 - drivers/staging/lustre/lustre/lov/lov_page.c | 2 - drivers/staging/lustre/lustre/lov/lov_pool.c | 32 +- drivers/staging/lustre/lustre/lov/lov_request.c | 17 +- drivers/staging/lustre/lustre/lov/lovsub_dev.c | 5 +- drivers/staging/lustre/lustre/lov/lovsub_lock.c | 4 +- drivers/staging/lustre/lustre/lov/lovsub_object.c | 6 +- drivers/staging/lustre/lustre/lov/lproc_lov.c | 5 + drivers/staging/lustre/lustre/mdc/mdc_internal.h | 18 +- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 50 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 47 +- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 24 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 258 +--- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 1 + drivers/staging/lustre/lustre/mgc/mgc_request.c | 71 +- drivers/staging/lustre/lustre/obdclass/Makefile | 2 +- drivers/staging/lustre/lustre/obdclass/acl.c | 120 -- drivers/staging/lustre/lustre/obdclass/capa.c | 421 ------ drivers/staging/lustre/lustre/obdclass/cl_io.c | 106 +- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 49 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 68 +- drivers/staging/lustre/lustre/obdclass/cl_page.c | 5 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 119 +- drivers/staging/lustre/lustre/obdclass/debug.c | 10 - drivers/staging/lustre/lustre/obdclass/dt_object.c | 1054 -------------- drivers/staging/lustre/lustre/obdclass/genops.c | 600 +------- .../lustre/lustre/obdclass/linux/linux-module.c | 3 - .../lustre/lustre/obdclass/linux/linux-obdo.c | 137 -- .../lustre/lustre/obdclass/linux/linux-sysctl.c | 4 - drivers/staging/lustre/lustre/obdclass/llog.c | 549 +------ drivers/staging/lustre/lustre/obdclass/llog_cat.c | 590 +------- .../staging/lustre/lustre/obdclass/llog_internal.h | 21 - drivers/staging/lustre/lustre/obdclass/llog_obd.c | 31 - drivers/staging/lustre/lustre/obdclass/llog_swab.c | 7 +- .../lustre/lustre/obdclass/lprocfs_counters.c | 9 - .../lustre/lustre/obdclass/lprocfs_status.c | 440 +----- drivers/staging/lustre/lustre/obdclass/lu_object.c | 383 +---- .../lustre/lustre/obdclass/lustre_handles.c | 22 +- .../staging/lustre/lustre/obdclass/obd_config.c | 468 +----- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 162 +-- drivers/staging/lustre/lustre/obdclass/obdo.c | 173 +-- .../staging/lustre/lustre/obdclass/statfs_pack.c | 14 - .../staging/lustre/lustre/obdecho/echo_client.c | 67 +- .../staging/lustre/lustre/obdecho/echo_internal.h | 1 - drivers/staging/lustre/lustre/osc/lproc_osc.c | 46 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 44 +- .../staging/lustre/lustre/osc/osc_cl_internal.h | 3 +- drivers/staging/lustre/lustre/osc/osc_dev.c | 8 +- drivers/staging/lustre/lustre/osc/osc_internal.h | 7 +- drivers/staging/lustre/lustre/osc/osc_io.c | 14 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 4 +- drivers/staging/lustre/lustre/osc/osc_object.c | 6 +- drivers/staging/lustre/lustre/osc/osc_page.c | 9 +- drivers/staging/lustre/lustre/osc/osc_quota.c | 11 +- drivers/staging/lustre/lustre/osc/osc_request.c | 238 ++-- drivers/staging/lustre/lustre/ptlrpc/client.c | 512 +++---- drivers/staging/lustre/lustre/ptlrpc/connection.c | 10 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 12 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 70 +- drivers/staging/lustre/lustre/ptlrpc/layout.c | 144 +- drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 37 +- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 134 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 22 +- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 129 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 362 +---- drivers/staging/lustre/lustre/ptlrpc/pers.c | 1 - drivers/staging/lustre/lustre/ptlrpc/pinger.c | 170 +-- .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 19 +- .../staging/lustre/lustre/ptlrpc/ptlrpc_module.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 740 +++++----- drivers/staging/lustre/lustre/ptlrpc/sec.c | 165 +-- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 358 +---- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 78 +- drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 25 +- drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 526 ++----- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 6 +- 249 files changed, 4621 insertions(+), 17729 deletions(-) create mode 100644 drivers/staging/lustre/lnet/lnet/nidstrings.c delete mode 100644 drivers/staging/lustre/lustre/include/dt_object.h delete mode 100644 drivers/staging/lustre/lustre/include/lustre/libiam.h delete mode 100644 drivers/staging/lustre/lustre/include/lustre/lustre_lfsck_user.h delete mode 100644 drivers/staging/lustre/lustre/include/lustre_capa.h delete mode 100644 drivers/staging/lustre/lustre/include/obd_cache.h delete mode 100644 drivers/staging/lustre/lustre/libcfs/nidstrings.c delete mode 100644 drivers/staging/lustre/lustre/llite/llite_capa.c delete mode 100644 drivers/staging/lustre/lustre/obdclass/capa.c delete mode 100644 drivers/staging/lustre/lustre/obdclass/dt_object.c (limited to 'drivers/staging/lustre') diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 01961d9e6..4d74e8af5 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -62,9 +62,6 @@ static inline int __is_po2(unsigned long long val) #include -int libcfs_arch_init(void); -void libcfs_arch_cleanup(void); - /* need both kernel and user-land acceptor */ #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512 #define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023 @@ -155,10 +152,16 @@ extern struct miscdevice libcfs_dev; extern char lnet_upcall[1024]; extern char lnet_debug_log_upcall[1024]; -extern void libcfs_init_nidstrings(void); - 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/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index a3aa64415..a1787bb43 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -73,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/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index c40814591..70b8b29e8 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/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/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index f5d741f25..485ab2670 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/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) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index 978d3e2f1..082fe6de9 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/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/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index 9544860e3..f0b0423a7 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -79,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 { \ @@ -95,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) \ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h index 478e9582f..d8d2e7dc2 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h +++ b/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,8 +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); #endif diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h index 5de6da085..2c7ec2d28 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h +++ b/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/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index 3e2502a69..aac59008a 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -41,7 +41,6 @@ #error Do not #include this file directly. #include instead #endif - #include #include #include @@ -86,7 +85,6 @@ #include "linux-time.h" #include "linux-mem.h" - #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) #if !defined(__x86_64__) @@ -142,5 +140,4 @@ typedef long long_ptr_t; #define WITH_WATCHDOG #endif - #endif /* _LINUX_LIBCFS_H */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index 0fc490bac..ed8764b11 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -59,13 +59,6 @@ #include - -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/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index bc3d907fd..b61d5045a 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -443,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); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 81a63dbde..d792c4adb 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -264,7 +264,7 @@ typedef struct lnet_ni { 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 */ + 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]; diff --git a/drivers/staging/lustre/include/linux/lnet/nidstr.h b/drivers/staging/lustre/include/linux/lnet/nidstr.h index a627be9fc..46ad9147a 100644 --- a/drivers/staging/lustre/include/linux/lnet/nidstr.h +++ b/drivers/staging/lustre/include/linux/lnet/nidstr.h @@ -57,21 +57,58 @@ struct list_head; #define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ #define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ -int libcfs_isknown_lnd(int type); -char *libcfs_lnd2modname(int type); -char *libcfs_lnd2str(int type); +/* 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(__u32 net); -char *libcfs_nid2str(lnet_nid_t nid); +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/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 940f73f26..11630180c 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -303,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; } /** diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index c29d2ced2..7c730e3f7 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -2154,23 +2154,23 @@ static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev) if (rc != 0) return rc; - LIBCFS_ALLOC(hdev->ibh_mrs, 1 * sizeof(*hdev->ibh_mrs)); - if (hdev->ibh_mrs == NULL) { - CERROR("Failed to allocate MRs table\n"); - return -ENOMEM; - } + 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; + 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); - } + 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; + hdev->ibh_mrs[0] = mr; return 0; } @@ -2228,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) @@ -2752,7 +2749,7 @@ int kiblnd_startup(lnet_ni_t *ni) char *ifname; kib_dev_t *ibdev = NULL; kib_net_t *net; - struct timeval tv; + struct timespec64 tv; unsigned long flags; int rc; int newdev; @@ -2770,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; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index f4b6c33ac..263db37de 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -79,38 +79,33 @@ #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_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 */ + 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; @@ -128,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) @@ -199,8 +196,7 @@ typedef struct { 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 */ + 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; @@ -249,28 +245,26 @@ typedef struct kib_poolset { 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 */ + 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_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 { @@ -295,8 +289,8 @@ typedef struct { 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 */ + unsigned long fps_next_retry; /* time stamp for retry if*/ + /* failed to allocate */ } kib_fmr_poolset_t; typedef struct { @@ -344,31 +338,22 @@ struct kib_sched_info { }; typedef struct { - 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 - */ + 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 @@ -480,10 +465,10 @@ typedef struct { #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_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 */ /***********************************************************************/ @@ -491,8 +476,7 @@ 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) */ + 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) */ @@ -501,38 +485,35 @@ typedef struct kib_rx /* receive message */ 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 */ { - 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) */ + 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 */ - kib_fmr_t fmr; /* FMR */ - int tx_dmadir; /* dma direction */ + 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 { @@ -540,53 +521,44 @@ typedef struct kib_connvars { } 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 */ + 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 */ + 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 */ @@ -780,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 @@ -878,7 +850,6 @@ kiblnd_rd_msg_size(kib_rdma_desc_t *rd, int msgtype, int 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) { @@ -928,23 +899,19 @@ 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" */ +/* 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); 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); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index a23a6d956..260750354 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -40,6 +40,8 @@ #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) { @@ -178,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) @@ -205,7 +211,9 @@ 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 * @@ -253,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; @@ -591,8 +598,7 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob) return 0; } -void -kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx) +static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx) { kib_net_t *net = ni->ni_data; @@ -610,9 +616,8 @@ 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; @@ -650,7 +655,6 @@ kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, 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) @@ -834,7 +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; @@ -1008,7 +1012,7 @@ 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]; + 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; @@ -1027,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++; } @@ -1044,7 +1048,7 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type, 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]; + struct ib_rdma_wr *wrq = &tx->tx_wrq[0], *next; int rc = resid; int srcidx; int dstidx; @@ -1090,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); @@ -1422,6 +1427,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) 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; @@ -1465,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); @@ -1485,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; @@ -1650,7 +1654,6 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, 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; @@ -1687,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, @@ -1705,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", @@ -1723,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; @@ -1736,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) { @@ -2148,6 +2154,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) unsigned long flags; int rc; struct sockaddr_in *peer_addr; + LASSERT(!in_interrupt()); /* cmid inherits 'context' from the corresponding listener id */ @@ -2163,6 +2170,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) 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; @@ -3227,7 +3235,7 @@ 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; + kib_conn_t *conn = arg; struct kib_sched_info *sched = conn->ibc_sched; unsigned long flags; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index b3d1b5d62..1d4e7efb5 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -135,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"); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index d8bfcadd1..ecfe73302 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1838,7 +1838,6 @@ 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 @@ -1874,52 +1873,51 @@ 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 *start; + struct list_head *end; struct list_head *tmp; - int index; - int i; - int j; int rc = -ENOENT; + unsigned int hsize = ksocknal_data.ksnd_peer_hash_size; - for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { - for (j = 0; ; j++) { - read_lock(&ksocknal_data.ksnd_global_lock); + 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; } @@ -2261,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)); @@ -2427,7 +2424,7 @@ 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_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) @@ -2441,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); @@ -2706,6 +2703,7 @@ ksocknal_start_schedulers(struct ksock_sched_info *info) 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", @@ -2835,7 +2833,6 @@ ksocknal_startup(lnet_ni_t *ni) return -ENETDOWN; } - static void __exit ksocknal_module_fini(void) { diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index a0fcbc39f..b349847f9 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -216,13 +216,13 @@ typedef struct { wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */ int ksnd_connd_connecting; /* # connds connecting */ - long ksnd_connd_failed_stamp;/* time stamp of the + time64_t ksnd_connd_failed_stamp;/* time stamp of the * last failed * connecting attempt */ - unsigned ksnd_connd_starting; /* # starting connd */ - long ksnd_connd_starting_stamp;/* time stamp of the + 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 */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 0d5aac6a2..477b385f1 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -89,7 +89,6 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk) return tx; } - void ksocknal_free_tx (ksock_tx_t *tx) { @@ -299,6 +298,7 @@ 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); /* Never touch conn->ksnc_rx_kiov or change connection @@ -626,7 +626,7 @@ ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk) 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; + c->ksnc_sock->sk->sk_wmem_queued; int rc; LASSERT(!c->ksnc_closing); @@ -714,7 +714,7 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) 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); @@ -772,7 +772,6 @@ 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) { @@ -1092,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)); @@ -1313,7 +1312,7 @@ 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); @@ -1998,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; @@ -2048,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; } @@ -2060,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; @@ -2141,7 +2140,7 @@ 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; @@ -2240,6 +2239,7 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) list_for_each (ctmp, &peer->ksnp_conns) { int error; + conn = list_entry (ctmp, ksock_conn_t, ksnc_list); /* Don't need the {get,put}connsock dance to deref ksnc_sock */ @@ -2394,7 +2394,6 @@ ksocknal_send_keepalive_locked(ksock_peer_t *peer) return -EIO; } - static void ksocknal_check_peer_timeouts (int idx) { diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c index 340706110..679785b02 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c @@ -355,9 +355,9 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn) 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. */ + * 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) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c index c3ac67698..fdb2b23e2 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c +++ b/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); diff --git a/drivers/staging/lustre/lnet/lnet/Makefile b/drivers/staging/lustre/lnet/lnet/Makefile index 52492fb10..e276fe2bf 100644 --- a/drivers/staging/lustre/lnet/lnet/Makefile +++ b/drivers/staging/lustre/lnet/lnet/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_LNET) += lnet.o -lnet-y := api-ni.o config.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/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 99f8396f3..92ca1dd64 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -202,7 +202,6 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, } EXPORT_SYMBOL(lnet_connect); - /* Below is the code common for both kernel and MT user-space */ static int @@ -447,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) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index d14fe70a5..395412639 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -45,7 +45,6 @@ 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"); @@ -264,7 +263,7 @@ 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; @@ -273,7 +272,7 @@ lnet_find_lnd_by_type(int type) 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; } @@ -529,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 @@ -964,7 +962,7 @@ lnet_startup_lndnis(void) struct list_head nilist; int i; int rc = 0; - int lnd_type; + __u32 lnd_type; int nicount = 0; char *nets = lnet_get_networks(); @@ -1262,7 +1260,7 @@ LNetNIInit(lnet_pid_t requested_pid) if (rc != 0) goto failed4; - lnet_proc_init(); + lnet_router_debugfs_init(); goto out; failed4: @@ -1305,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(); @@ -1343,6 +1341,7 @@ LNetCtl(unsigned int cmd, void *arg) 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); @@ -1370,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 */ diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 9c576ce2f..1b3bc8386 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -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: @@ -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; } diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index f19ce9ae6..60889ebd2 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -318,7 +318,6 @@ 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) @@ -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. diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 433faae9a..5631f60a3 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -275,7 +275,6 @@ 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) { @@ -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 @@ -867,7 +865,6 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) return 0; } - static lnet_rtrbufpool_t * lnet_msg2bufpool(lnet_msg_t *msg) { @@ -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; diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 84707c5cb..b4f573ab6 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -420,9 +420,9 @@ 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 diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c new file mode 100644 index 000000000..80f585afa --- /dev/null +++ b/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 + */ + +#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 + * + * :== [ ' ' ] + * :== '@' + * :== '*' | + * | + * + * :== ... + * + * :== | + * + * :== '[' [ ',' ] ']' + * :== | + * '-' | + * '-' '/' + * :== | + * :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" | + * "vib" | "ra" | "elan" | "mx" | "ptl" + * \endverbatim + */ + +/** + * Structure to represent \ token of the syntax. + * + * One of this is created for each \ 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 *@ is found. + */ + int nr_all; + /** + * Pointer to corresponding element of libcfs_netstrfns. + */ + struct netstrfns *nr_netstrfns; + /** + * Number of network. E.g. 5 if \ is "elan5". + */ + int nr_netnum; +}; + +/** + * Structure to represent \ 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 \ token on the syntax. + * + * Allocates struct addrrange and links to \a nidrange via + * (nidrange::nr_addrranges) + * + * \retval 0 if \a src parses to '*' | \ | \ + * \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 \ token of the syntax. + * + * \retval 1 if \a src parses to \ '@' \ + * \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 + * \ [ ' ' \ ], 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, ¤t_start_nid, + ¤t_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, ¤t_start_nid, + ¤t_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/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 4fbae5ef4..4ea651c6d 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -162,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) { @@ -236,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; @@ -256,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; } @@ -789,7 +788,7 @@ static void lnet_update_ni_status_locked(void) { lnet_ni_t *ni; - long now; + time64_t now; int timeout; LASSERT(the_lnet.ln_routing); @@ -797,7 +796,7 @@ lnet_update_ni_status_locked(void) 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; @@ -1246,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); @@ -1497,7 +1496,7 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) 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), diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 40f418b82..396c7c4e5 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -25,13 +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 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 @@ -696,7 +692,7 @@ 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(); + time64_t now = ktime_get_real_seconds(); int last_alive = -1; int i; int j; @@ -914,44 +910,11 @@ static struct ctl_table lnet_table[] = { } }; -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) +void lnet_router_debugfs_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_proc_fini(void) -{ -} - -#endif diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index de11f1bc8..0605c651f 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -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--; diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 1a7870e91..556c837cf 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -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; } @@ -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/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index a1a4e08f7..64a033593 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -40,7 +40,6 @@ * Author: Liang Zhen */ - #include "../../include/linux/libcfs/libcfs.h" #include "../../include/linux/lnet/lib-lnet.h" #include "timer.h" @@ -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)) || @@ -861,7 +860,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats, 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); @@ -1176,7 +1175,7 @@ lstcon_rpc_pinger(void *arg) srpc_debug_reqst_t *drq; lstcon_ndlink_t *ndl; lstcon_node_t *nd; - time_t intv; + int intv; int count = 0; int rc; @@ -1191,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; @@ -1248,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, @@ -1278,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); @@ -1301,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); diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h index 7d33cf9e9..95c832ff7 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.h +++ b/drivers/staging/lustre/lnet/selftest/conrpc.h @@ -105,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); @@ -140,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/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index f47c8f27f..d315dd44a 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -40,7 +40,6 @@ * Author: Liang Zhen */ - #include "../../include/linux/libcfs/libcfs.h" #include "../../include/linux/lnet/lib-lnet.h" #include "console.h" @@ -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); @@ -527,7 +526,7 @@ lstcon_group_add(char *name) lstcon_group_t *grp; 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); @@ -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)); @@ -847,7 +846,7 @@ lstcon_batch_add(char *name) 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; @@ -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; } } @@ -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; } @@ -1683,7 +1682,7 @@ 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 @@ -2004,7 +2003,7 @@ lstcon_console_init(void) 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_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(); diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index cdce2dd6b..3f3286c0c 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/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" @@ -142,7 +141,7 @@ typedef struct { 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) + time64_t ses_laststamp; /* last operation stamp (seconds) */ unsigned ses_features; /* tests features of the session */ diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 257de3537..f18e50036 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -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; } @@ -238,7 +237,6 @@ sfw_deactivate_session(void) spin_lock(&sfw_data.fw_lock); } - static void sfw_session_expired(void *data) { @@ -372,7 +370,6 @@ sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) sfw_session_t *sn = sfw_data.fw_session; sfw_counters_t *cnt = &reply->str_fw; sfw_batch_t *bat; - struct timeval tv; reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -391,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); @@ -1638,7 +1632,6 @@ 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) { @@ -1648,7 +1641,6 @@ sfw_startup(void) srpc_service_t *sv; sfw_test_case_t *tsc; - if (session_timeout < 0) { CERROR("Session timeout must be non-negative: %d\n", session_timeout); diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index 09b8f4649..46cbdf045 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -150,7 +150,6 @@ error: return rc; } - MODULE_DESCRIPTION("LNet Selftest"); MODULE_LICENSE("GPL"); MODULE_VERSION("0.9.0"); diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c index 1dab9984c..d42653654 100644 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c @@ -92,7 +92,7 @@ ping_client_prep_rpc(sfw_test_unit_t *tsu, 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; + struct timespec64 ts; int rc; LASSERT(sn != NULL); @@ -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; } @@ -124,7 +124,7 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) 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; + struct timespec64 ts; LASSERT(sn != NULL); @@ -161,10 +161,10 @@ 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; } diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 6ae133138..7005002c1 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -146,7 +146,7 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink) 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); @@ -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); @@ -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; } @@ -1355,7 +1354,6 @@ srpc_post_rpc(srpc_client_rpc_t *rpc) return; } - int srpc_send_reply(struct srpc_server_rpc *rpc) { @@ -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/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h index b7b00c6b1..6b4a32a90 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.h +++ b/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. diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 7939e4e04..8a77d3fdf 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -56,7 +56,6 @@ #define MADE_WITHOUT_COMPROMISE #endif - #define SWI_STATE_NEWBORN 0 #define SWI_STATE_REPLY_SUBMITTED 1 #define SWI_STATE_REPLY_SENT 2 @@ -279,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 */ @@ -497,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); @@ -562,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 } @@ -583,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/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index 6133b54f4..b98c08a10 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/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 @@ -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,7 +121,7 @@ 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; stt_timer_t *timer; @@ -130,7 +129,7 @@ stt_expire_list(struct list_head *slot, unsigned long now) 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); @@ -149,10 +148,10 @@ static int stt_check_timers(unsigned long *last) { int expired = 0; - unsigned long now; + 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/drivers/staging/lustre/lnet/selftest/timer.h b/drivers/staging/lustre/lnet/selftest/timer.h index 2a8803d89..03e2ee294 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.h +++ b/drivers/staging/lustre/lnet/selftest/timer.h @@ -40,7 +40,7 @@ typedef struct { struct list_head stt_list; - unsigned long stt_expires; + time64_t stt_expires; void (*stt_func) (void *); void *stt_data; } stt_timer_t; diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index a16d577c6..7c45e7479 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -150,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; } @@ -173,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; } @@ -248,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) @@ -438,18 +379,26 @@ out_cleanup: return rc; } -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 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; + } +} + +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); @@ -462,10 +411,7 @@ 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); @@ -475,20 +421,6 @@ int seq_client_init(struct lu_client_seq *seq, seq_client_fini(seq); return rc; } -EXPORT_SYMBOL(seq_client_init); - -void seq_client_fini(struct lu_client_seq *seq) -{ - seq_client_debugfs_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) @@ -510,7 +442,7 @@ 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); + rc = seq_client_init(cli->cl_seq, exp, type, prefix); kfree(prefix); if (rc) goto out_free_seq; diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index cc2201c25..ce90c1c54 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/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" @@ -205,8 +204,6 @@ ldebugfs_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; diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 1b1066b24..446917484 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/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" @@ -266,7 +265,7 @@ 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) { kfree(f_new); /* overlap is not allowed, so dont mess up list. */ diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 844576b9b..fbb232de6 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/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" @@ -175,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/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 1e450bf95..3fd91bc77 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/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" diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index da822101e..603f56e60 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/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" diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index d56c8bea8..73564f8e3 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/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/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h deleted file mode 100644 index abae31b41..000000000 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ /dev/null @@ -1,1496 +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 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); - -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 /* __LUSTRE_DT_OBJECT_H */ diff --git a/drivers/staging/lustre/lustre/include/interval_tree.h b/drivers/staging/lustre/lustre/include/interval_tree.h index bf9027d5f..f6df3f33e 100644 --- a/drivers/staging/lustre/lustre/include/interval_tree.h +++ b/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/drivers/staging/lustre/lustre/include/lclient.h b/drivers/staging/lustre/lustre/include/lclient.h index c5c3a8d9e..36e7a6767 100644 --- a/drivers/staging/lustre/lustre/include/lclient.h +++ b/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/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 6b14406b2..79d8f9307 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -61,7 +61,6 @@ #define module_init(a) late_initcall(a) #endif - #define LTIME_S(time) (time.tv_sec) #ifndef QUOTA_OK diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index 45651caf4..3420cfd12 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -39,8 +39,7 @@ #error Do not #include this file directly. #include instead #endif - -#include +#include #include #include @@ -93,5 +92,4 @@ enum { LPROC_LL_FILE_OPCODES }; - #endif diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h index ebe8d68ed..33e0b99e1 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h @@ -43,7 +43,6 @@ #include #include - #define ll_delete_from_page_cache(page) delete_from_page_cache(page) static inline void diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 2817e88e0..468bc28be 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -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/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index fd3c4df31..9e654b218 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -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) + \ @@ -358,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 @@ -536,26 +540,14 @@ extern struct lprocfs_stats * lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags); void lprocfs_clear_stats(struct lprocfs_stats *stats); void lprocfs_free_stats(struct lprocfs_stats **stats); -void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats); -void lprocfs_init_mps_stats(int num_private_stats, struct lprocfs_stats *stats); -void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats); -int lprocfs_alloc_obd_stats(struct obd_device *obddev, - unsigned int num_private_stats); -int lprocfs_alloc_md_stats(struct obd_device *obddev, - unsigned int num_private_stats); void lprocfs_counter_init(struct lprocfs_stats *stats, int index, unsigned conf, const char *name, const char *units); -void lprocfs_free_obd_stats(struct obd_device *obddev); -void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; int lprocfs_exp_cleanup(struct obd_export *exp); struct dentry *ldebugfs_add_simple(struct dentry *root, char *name, void *data, struct file_operations *fops); -struct dentry * -ldebugfs_add_symlink(const char *name, struct dentry *parent, - const char *format, ...); int ldebugfs_register_stats(struct dentry *parent, const char *name, @@ -590,14 +582,9 @@ int ldebugfs_obd_seq_create(struct obd_device *dev, /* Generic callbacks */ -int lprocfs_rd_u64(struct seq_file *m, void *data); -int lprocfs_rd_atomic(struct seq_file *m, void *data); -int lprocfs_wr_atomic(struct file *file, const char __user *buffer, - unsigned long count, 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_name(struct seq_file *m, 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); @@ -607,10 +594,6 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data); struct adaptive_timeout; 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_timeouts(struct file *file, const char __user *buffer, - unsigned long count, void *data); -int lprocfs_wr_evict_client(struct file *file, const char __user *buffer, - size_t count, loff_t *off); 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, @@ -623,7 +606,6 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, int lprocfs_write_helper(const char __user *buffer, unsigned long count, int *val); -int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult); int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count, __u64 *val); int lprocfs_write_frac_u64_helper(const char *buffer, @@ -642,20 +624,9 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, int lprocfs_single_release(struct inode *, struct file *); 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) #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, @@ -730,22 +701,8 @@ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) #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) -ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr, - char *buf); -ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t len); - extern const struct sysfs_ops lustre_sysfs_ops; -/* lproc_ptlrpc.c */ -struct ptlrpc_request; -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 */ int lprocfs_quota_rd_bunit(char *page, char **start, loff_t off, int count, diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index e1d72a7a5..fa7868974 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -554,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. @@ -584,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 }; @@ -670,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. */ @@ -709,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, @@ -790,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) @@ -805,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) @@ -820,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, @@ -1125,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, \ @@ -1139,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); \ @@ -1166,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. @@ -1193,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__); \ @@ -1240,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. */ @@ -1265,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 */ @@ -1318,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/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h index b451a888c..97cd157dd 100644 --- a/drivers/staging/lustre/lustre/include/lu_ref.h +++ b/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/drivers/staging/lustre/lustre/include/lustre/libiam.h b/drivers/staging/lustre/lustre/include/lustre/libiam.h deleted file mode 100644 index e8e0b084a..000000000 --- a/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 - * Author: Nikita Danilov - * Author: Fan Yong - */ - -/* - * 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/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h b/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h index ad253c6de..06ce8c9ae 100644 --- a/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h +++ b/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/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index ac78dbc38..0b721c65c 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -154,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 @@ -297,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 * @{ */ @@ -325,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) /** @@ -365,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 @@ -827,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, @@ -956,7 +960,6 @@ struct luda_type { #define DTTOIF(dirtype) ((dirtype) << IFSHIFT) #endif - struct lu_dirpage { __u64 ldp_hash_start; __u64 ldp_hash_end; @@ -1002,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 @@ -1041,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) @@ -1105,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 { @@ -1269,7 +1275,6 @@ 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 | \ @@ -1386,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 @@ -1394,7 +1400,6 @@ struct obd_connect_data { * the matching OBD_CONNECT flag, so that can be approved and landed easily to * reserve the flag for future use. */ - void lustre_swab_connect(struct obd_connect_data *ocd); /* @@ -1404,9 +1409,9 @@ 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; /* @@ -1444,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 */ @@ -1931,6 +1936,7 @@ enum { LQUOTA_LAST_RES, LQUOTA_FIRST_RES = LQUOTA_RES_MD }; + #define LQUOTA_NR_RES (LQUOTA_LAST_RES - LQUOTA_FIRST_RES + 1) /* @@ -1978,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 */ @@ -2046,7 +2053,6 @@ typedef enum { #define MDS_FIRST_OPC MDS_GETATTR - /* opcodes for object update */ typedef enum { UPDATE_OBJ = 1000, @@ -2112,8 +2118,6 @@ 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) -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). */ @@ -2366,23 +2370,6 @@ 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, @@ -2600,8 +2587,6 @@ struct lmv_desc { struct obd_uuid ld_uuid; }; -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; @@ -2612,8 +2597,6 @@ struct lmv_stripe_md { struct lu_fid mea_ids[0]; }; -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 @@ -2697,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] -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) { @@ -2774,8 +2755,6 @@ typedef union { struct ldlm_inodebits l_inodebits; } ldlm_wire_policy_data_t; -void lustre_swab_ldlm_policy_data(ldlm_wire_policy_data_t *d); - union ldlm_gl_desc { struct ldlm_gl_lquota_desc lquota_desc; }; @@ -2794,8 +2773,6 @@ struct ldlm_resource_desc { struct ldlm_res_id lr_name; }; -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; @@ -2803,8 +2780,6 @@ struct ldlm_lock_desc { ldlm_wire_policy_data_t l_policy_data; }; -void lustre_swab_ldlm_lock_desc(struct ldlm_lock_desc *l); - #define LDLM_LOCKREQ_HANDLES 2 #define LDLM_ENQUEUE_CANCEL_OFF 1 @@ -3337,8 +3312,6 @@ static inline void lustre_get_wire_obdo(struct obd_connect_data *ocd, } } -void lustre_swab_obdo(struct obdo *o); - /* request structure for OST's */ struct ost_body { struct obdo oa; @@ -3366,7 +3339,6 @@ 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); -void lustre_swab_llog_id(struct llog_logid *lid); struct lustre_cfg; void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg); @@ -3374,7 +3346,6 @@ 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); @@ -3455,8 +3426,6 @@ struct lu_idxpage { char lip_entries[0]; }; -void lustre_swab_lip_header(struct lu_idxpage *lip); - #define LIP_HDR_SIZE (offsetof(struct lu_idxpage, lip_entries)) /* Gather all possible type associated with a 4KB container */ @@ -3491,6 +3460,7 @@ 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)); @@ -3522,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# */ @@ -3553,8 +3499,6 @@ struct lustre_capa_key { __u8 lk_key[CAPA_HMAC_KEY_MAX_LEN]; /**< key */ } __attribute__((packed)); -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 { @@ -3574,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 { diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_lfsck_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_lfsck_user.h deleted file mode 100644 index 1c87a61a7..000000000 --- a/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 - */ - -#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/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 9b1bb23c4..80f8ec529 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -261,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 @@ -313,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) */ @@ -345,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) { @@ -365,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 */ @@ -406,8 +405,6 @@ static inline int lmv_user_md_size(int stripes, int lmm_magic) stripes * sizeof(struct lmv_user_mds_data); } -void lustre_swab_lmv_user_md(struct lmv_user_md *lum); - struct ll_recreate_obj { __u64 lrc_id; __u32 lrc_ost_idx; @@ -449,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; @@ -489,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 */ @@ -631,7 +628,6 @@ struct lustre_swap_layouts { __u64 sl_dv2; }; - /********* Changelogs **********/ /** Changelog record types */ enum changelog_rec_type { @@ -658,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", @@ -769,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 @@ -791,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) @@ -836,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. */ @@ -845,7 +843,6 @@ struct ioc_data_version { #define dot_lustre_name ".lustre" - /********* HSM **********/ /** HSM per-file state @@ -881,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) @@ -896,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. @@ -980,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; @@ -988,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) @@ -1054,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 @@ -1098,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 @@ -1116,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/drivers/staging/lustre/lustre/include/lustre_capa.h b/drivers/staging/lustre/lustre/include/lustre_capa.h deleted file mode 100644 index fe19534eb..000000000 --- a/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 - */ - -#ifndef __LINUX_CAPA_H_ -#define __LINUX_CAPA_H_ - -/** \defgroup capa capa - * - * @{ - */ - -/* - * capability - */ -#include -#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/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index 7b385b872..eb6b292b7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h index 6c92d0bc9..8a089413c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_debug.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 9b2833131..5e1ac129a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -52,24 +52,6 @@ #include "../../include/linux/lnet/types.h" #include -/****************** 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/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 355254689..0e75a15fe 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -60,9 +60,6 @@ struct obd_ops; struct obd_device; -extern struct kset *ldlm_ns_kset; -extern struct kset *ldlm_svc_kset; - #define OBD_LDLM_DEVICENAME "ldlm" #define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus()) @@ -213,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. */ @@ -256,9 +252,9 @@ 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. */ @@ -271,10 +267,6 @@ struct ldlm_pool { struct completion pl_kobj_unregister; }; -typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **, - void *req_cookie, ldlm_mode_t mode, __u64 flags, - void *data); - typedef int (*ldlm_cancel_for_recovery)(struct ldlm_lock *lock); /** @@ -427,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 @@ -471,32 +460,6 @@ struct ldlm_namespace { struct completion ns_kobj_unregister; }; -/** - * 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; -} - /** * Returns 1 if namespace \a ns supports early lock cancel (ELC). */ @@ -552,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) /** @@ -595,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); @@ -749,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. @@ -883,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 */ @@ -1016,7 +975,6 @@ struct ldlm_enqueue_info { extern struct obd_ops ldlm_obd_ops; extern char *ldlm_lockname[]; -extern char *ldlm_typename[]; char *ldlm_it2str(int it); /** @@ -1025,7 +983,7 @@ 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. @@ -1051,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) @@ -1062,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); \ } \ @@ -1087,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 */ @@ -1110,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); @@ -1165,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 @@ -1214,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, @@ -1230,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); @@ -1245,10 +1186,6 @@ 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); int ldlm_debugfs_setup(void); @@ -1259,7 +1196,6 @@ 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, @@ -1281,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 */ @@ -1314,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); @@ -1346,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, @@ -1364,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 @@ -1417,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/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h index d4cc09635..0d3ed87d3 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -50,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 */ @@ -112,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) /** @@ -142,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) /** @@ -232,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) /** @@ -244,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) /** @@ -281,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) /** @@ -316,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) /** @@ -334,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) /** @@ -344,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/drivers/staging/lustre/lustre/include/lustre_eacl.h b/drivers/staging/lustre/lustre/include/lustre_eacl.h index 0f8f76c43..fee4d2c75 100644 --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 5189fad0b..1daf4c572 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -147,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; /** @@ -179,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; /** @@ -193,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; @@ -265,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); @@ -369,7 +337,6 @@ static inline bool imp_connect_disp_stripe(struct obd_import *imp) } struct obd_export *class_conn2export(struct lustre_handle *conn); -struct obd_device *class_conn2obd(struct lustre_handle *conn); /** @} export */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index c7c8fe4cd..47c3f3750 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/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. */ @@ -366,108 +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; - - /* 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); @@ -626,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; @@ -641,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/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index c1f08dee3..d8b3db9cd 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/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; @@ -70,10 +69,6 @@ struct lu_fld_target { }; struct lu_server_fld { - /** - * /fld file object device */ - struct dt_object *lsf_obj; - /** * super sequence controller export, needed to forward fld * lookup request. */ diff --git a/drivers/staging/lustre/lustre/include/lustre_ha.h b/drivers/staging/lustre/lustre/include/lustre_ha.h index f3ae02b3e..49dfbb14f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_ha.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 726bbd3ea..f39780ae4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 5a38f3d5e..4e4230e94 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/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; @@ -376,7 +375,6 @@ extern unsigned int at_max; /* genops.c */ struct obd_export; struct obd_import *class_exp2cliimp(struct obd_export *); -struct obd_import *class_conn2cliimp(struct lustre_handle *); /** @} import */ diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index 43ee9f0eb..428469fec 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/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//-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. @@ -557,9 +554,9 @@ do { \ if (__timeout == 0) { \ 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, \ @@ -604,8 +601,6 @@ do { \ remove_wait_queue(&wq, &__wait); \ } while (0) - - #define l_wait_event(wq, condition, info) \ ({ \ int __ret; \ diff --git a/drivers/staging/lustre/lustre/include/lustre_lite.h b/drivers/staging/lustre/lustre/include/lustre_lite.h index df557c22a..f6d7aae3a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lite.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 2187fb615..1de0c4d6f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index b1b05c8a3..3da373315 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_mds.h b/drivers/staging/lustre/lustre/include/lustre_mds.h index f0cce41c5..a16eb8b61 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mds.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 48ad60b22..0127f45ca 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -46,7 +46,6 @@ * @{ */ - #ifndef _LUSTRE_NET_H #define _LUSTRE_NET_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 */ /** @@ -2065,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 */ @@ -2191,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 */ @@ -2228,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, }; /** @@ -2299,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); -lnet_pid_t ptl_get_pid(void); /* ptlrpc/niobuf.c */ /** @@ -2307,7 +2296,6 @@ 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) @@ -2319,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) @@ -2353,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 *); @@ -2381,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, @@ -2402,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, @@ -2420,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, @@ -2521,26 +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 kset *parent, struct dentry *debugfs_entry); -void ptlrpc_stop_all_threads(struct ptlrpc_service *svc); 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); @@ -2556,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); @@ -2575,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, @@ -2599,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); @@ -2610,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); @@ -2626,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); @@ -2725,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; } @@ -2737,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; } @@ -2747,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; } @@ -2759,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; } @@ -2878,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) @@ -2887,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); @@ -2898,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, - /* ... */ - PDB_POLICY_PAIR = 3, - /* ... , - * 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); @@ -2959,7 +2878,6 @@ void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes); /* ptlrpc/llog_client.c */ extern struct llog_operations llog_client_ops; - /** @} net */ #endif diff --git a/drivers/staging/lustre/lustre/include/lustre_param.h b/drivers/staging/lustre/lustre/include/lustre_param.h index ed654684c..8f6c0b26c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_param.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index c6457b27c..df292f6d4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/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/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index 707ff6971..dd1033be6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/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,15 +1021,11 @@ 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); @@ -1078,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, @@ -1123,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/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 9ad8c268d..5e93afca3 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/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); @@ -406,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; @@ -439,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 { @@ -455,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 @@ -499,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 */ @@ -524,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 */ @@ -728,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; } @@ -742,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; } @@ -822,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 */ @@ -843,8 +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; atomic_t obd_refcount; wait_queue_head_t obd_refcount_waitq; struct list_head obd_exports; @@ -867,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; @@ -954,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" @@ -975,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" @@ -1057,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; @@ -1161,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, @@ -1184,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, @@ -1252,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 { @@ -1267,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 *); @@ -1300,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 **); @@ -1311,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); @@ -1343,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 *, @@ -1399,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); @@ -1421,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); \ } \ }) diff --git a/drivers/staging/lustre/lustre/include/obd_cache.h b/drivers/staging/lustre/lustre/include/obd_cache.h deleted file mode 100644 index c8249fbb0..000000000 --- a/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/drivers/staging/lustre/lustre/include/obd_cksum.h b/drivers/staging/lustre/lustre/include/obd_cksum.h index 3a63462aa..a0099d717 100644 --- a/drivers/staging/lustre/lustre/include/obd_cksum.h +++ b/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/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 87bb2cedc..fd5f3731d 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/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,7 +63,6 @@ extern struct obd_device *obd_devs[MAX_OBD_DEVICES]; extern rwlock_t obd_dev_lock; /* OBD Operations Declarations */ -struct obd_device *class_conn2obd(struct lustre_handle *); struct obd_device *class_exp2obd(struct obd_export *); int class_handle_ioctl(unsigned int cmd, unsigned long arg); int lustre_get_jobid(char *jobid); @@ -84,58 +82,36 @@ 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*/ @@ -157,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, @@ -215,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); @@ -230,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 @@ -398,17 +349,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) (export)->exp_md_stats, coffset); \ } - -#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) { \ @@ -427,7 +367,6 @@ do { \ } \ } while (0) - #define OBD_CHECK_DT_OP(obd, op, err) \ do { \ if (!OBT(obd) || !OBP((obd), op)) { \ @@ -531,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); @@ -622,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; } @@ -769,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; } @@ -1118,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(); @@ -1177,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; @@ -1186,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; } @@ -1434,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; } @@ -1616,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; } @@ -1668,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, @@ -1677,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, @@ -1691,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); } @@ -1762,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) @@ -1820,7 +1728,6 @@ static inline int md_revalidate_lock(struct obd_export *exp, return rc; } - /* OBD Metadata Support */ int obd_init_caches(void); @@ -1829,17 +1736,6 @@ 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 */ diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 18aec796a..a22a5308f 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -43,13 +43,6 @@ #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; @@ -66,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 @@ -428,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 @@ -486,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) @@ -501,151 +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 -void obd_update_maxusage(void); - -#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) - -__u64 obd_memory_max(void); -__u64 obd_pages_max(void); - -#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\n", \ - obd_memory_sum()); \ - } 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) - - -#define OBD_ALLOC_LARGE(ptr, size) \ -do { \ - ptr = libcfs_kvzalloc(size, GFP_NOFS); \ -} while (0) - -#define OBD_CPT_ALLOC_LARGE(ptr, cptab, cpt, size) \ -do { \ - ptr = libcfs_kvzalloc_cpt(cptab, cpt, size, GFP_NOFS); \ -} while (0) - -#define OBD_FREE_LARGE(ptr, size) \ -do { \ - (void)(size); \ - kvfree(ptr); \ -} while (0) - - #ifdef CONFIG_DEBUG_SLAB #define POISON(ptr, c, s) do {} while (0) #define POISON_PTR(ptr) ((void)0) @@ -655,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); \ @@ -680,117 +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\n", \ - obd_memory_sum(), \ - obd_pages_sum() << PAGE_CACHE_SHIFT, \ - obd_pages_sum()); \ - } 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/drivers/staging/lustre/lustre/lclient/glimpse.c b/drivers/staging/lustre/lustre/lclient/glimpse.c index b9f2bb66d..8533a1e53 100644 --- a/drivers/staging/lustre/lustre/lclient/glimpse.c +++ b/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/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 9053f8116..0b8e4d217 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/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); */ @@ -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) @@ -875,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); } /** @@ -896,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, @@ -911,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; @@ -936,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; @@ -956,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/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c index 01bf894d4..8389a0eda 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c +++ b/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/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index eab2bd602..39b571721 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/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->endin_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/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c index cd8ab40e3..e5d1344e8 100644 --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c +++ b/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/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index fd9b05936..c787888eb 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/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/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index a4c252feb..4310154e1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -63,9 +63,6 @@ #include #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) { @@ -151,79 +114,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) ldlm_lock_destroy_nolock(lock); } -/** - * 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/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c index 40d333850..b1bed1e17 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c +++ b/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/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index fa4b7c760..db3c9b7af 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/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,13 +169,6 @@ 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); @@ -207,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 */ -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); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index badd227e4..ccce1e503 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -335,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), @@ -627,7 +626,6 @@ out_disconnect: } EXPORT_SYMBOL(client_disconnect_export); - /** * Packs current SLV and Limit into \a req. */ @@ -815,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/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index cd340fc8c..7f8c70056 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/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. * @@ -244,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); @@ -258,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); @@ -276,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); @@ -289,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); @@ -325,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"); @@ -372,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; @@ -411,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, }; @@ -434,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; @@ -487,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) { @@ -625,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."); @@ -646,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; @@ -663,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) @@ -808,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"); @@ -823,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)) { @@ -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; @@ -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; @@ -1861,54 +1767,6 @@ out: 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); @@ -2011,175 +1861,6 @@ struct export_cl_data { int ecl_loop; }; -/** - * 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. * diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index ac79db952..ca1151195 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -58,9 +58,9 @@ MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on"); static struct mutex ldlm_ref_mutex; static int ldlm_refcount; -struct kobject *ldlm_kobj; +static struct kobject *ldlm_kobj; struct kset *ldlm_ns_kset; -struct kset *ldlm_svc_kset; +static struct kset *ldlm_svc_kset; struct ldlm_cb_async_args { struct ldlm_cb_set_arg *ca_set_arg; @@ -71,11 +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); -} - #define ELT_STOPPED 0 #define ELT_READY 1 #define ELT_TERMINATE 2 @@ -116,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. * @@ -461,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) { @@ -713,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; @@ -855,7 +835,6 @@ static int ldlm_bl_thread_main(void *arg) return 0; } - static int ldlm_setup(void); static int ldlm_cleanup(void); @@ -892,111 +871,6 @@ 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); -} - -static void * -ldlm_export_lock_key(struct hlist_node *hnode) -{ - struct ldlm_lock *lock; - - lock = hlist_entry(hnode, struct ldlm_lock, l_exp_hash); - return &lock->l_remote_handle; -} - -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) -{ - int rc; - - 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); - if (rc) - goto err; - - return 0; -err: - ldlm_destroy_export(exp); - return rc; -} -EXPORT_SYMBOL(ldlm_init_export); - -void ldlm_destroy_export(struct obd_export *exp) -{ - cfs_hash_putref(exp->exp_lock_hash); - exp->exp_lock_hash = NULL; - - ldlm_destroy_flock_export(exp); -} -EXPORT_SYMBOL(ldlm_destroy_export); - extern unsigned int ldlm_cancel_unused_locks_before_replay; static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj, @@ -1005,6 +879,7 @@ static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj, { return sprintf(buf, "%d\n", ldlm_cancel_unused_locks_before_replay); } + static ssize_t cancel_unused_locks_before_replay_store(struct kobject *kobj, struct attribute *attr, const char *buffer, @@ -1112,7 +987,6 @@ static int ldlm_setup(void) goto out; } - blp = kzalloc(sizeof(*blp), GFP_NOFS); if (!blp) { rc = -ENOMEM; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c index a1fe2c161..0c1965dda 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c +++ b/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/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index c234acb85..1a4eef646 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -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); } /** @@ -302,147 +253,6 @@ static void ldlm_pool_recalc_stats(struct ldlm_pool *pl) cancel_rate); } -/** - * 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. */ @@ -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,26 +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); 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; @@ -666,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" @@ -681,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, @@ -693,6 +474,7 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused) return 0; } + LPROC_SEQ_FOPS_RO(lprocfs_pool_state); static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr, @@ -893,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); @@ -903,17 +685,10 @@ 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_debugfs_init(pl); if (rc) @@ -966,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); @@ -987,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); @@ -1007,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. @@ -1049,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. @@ -1076,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) { @@ -1189,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, @@ -1218,81 +925,13 @@ 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. */ @@ -1366,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); @@ -1385,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) || @@ -1459,12 +1096,6 @@ static void ldlm_pools_thread_stop(void) 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, @@ -1476,20 +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) { - if (ldlm_pools_thread) { - unregister_shrinker(&ldlm_pools_srv_shrinker); + if (ldlm_pools_thread) unregister_shrinker(&ldlm_pools_cli_shrinker); - } + ldlm_pools_thread_stop(); } EXPORT_SYMBOL(ldlm_pools_fini); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 6245a2c36..fdf81b87a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/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) { @@ -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/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 4bb3173bc..c0a54bf40 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/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,7 +59,7 @@ 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); static struct dentry *ldlm_debugfs_dir; static struct dentry *ldlm_ns_debugfs_dir; @@ -67,7 +67,7 @@ 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; static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, @@ -77,6 +77,7 @@ lprocfs_wr_dump_ns(struct file *file, const char __user *buffer, 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); @@ -383,13 +384,13 @@ static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns) lprocfs_free_stats(&ns->ns_stats); } -void ldlm_namespace_sysfs_unregister(struct ldlm_namespace *ns) +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_sysfs_register(struct ldlm_namespace *ns) +static int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) { int err; @@ -426,8 +427,19 @@ static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns) return 0; } + #undef MAX_STRING_SIZE +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) { @@ -519,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 { @@ -548,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, @@ -593,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. */ @@ -718,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. */ @@ -767,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); } @@ -792,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; @@ -921,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 @@ -949,33 +977,6 @@ void ldlm_namespace_free_post(struct ldlm_namespace *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 -> - * -> ldebugfs_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); @@ -983,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); } @@ -997,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) @@ -1035,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. */ @@ -1054,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. */ @@ -1148,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. */ @@ -1194,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)); @@ -1204,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) { @@ -1224,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(); @@ -1257,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; @@ -1287,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; @@ -1315,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; @@ -1406,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; @@ -1451,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/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index ec98f44a1..03d3f3d7b 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -10,7 +10,7 @@ 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/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index e93f556fa..1d1c67164 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -452,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); @@ -562,6 +562,7 @@ int libcfs_debug_mark_buffer(const char *text) return 0; } + #undef DEBUG_SUBSYSTEM #define DEBUG_SUBSYSTEM S_LNET diff --git a/drivers/staging/lustre/lustre/libcfs/fail.c b/drivers/staging/lustre/lustre/libcfs/fail.c index 42d615fbd..d39fecebd 100644 --- a/drivers/staging/lustre/lustre/libcfs/fail.c +++ b/drivers/staging/lustre/lustre/libcfs/fail.c @@ -35,10 +35,10 @@ #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); DECLARE_WAIT_QUEUE_HEAD(cfs_race_waitq); diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 0ed063145..030874428 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/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,28 +435,28 @@ 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 = { +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 = { +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 = { +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 = { +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, @@ -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/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index d9b7c6b69..ad661a33a 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/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/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c index 2c199c725..94bc00785 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c +++ b/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/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c index 1debdda72..f4e08daba 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c +++ b/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/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index efe5e667a..d40be5396 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/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. @@ -242,6 +243,7 @@ cfs_str2num_check(char *str, int nob, unsigned *num, return (*num >= min && *num <= max); } +EXPORT_SYMBOL(cfs_str2num_check); /** * Parses \ token of the syntax. If \a bracketed is false, @@ -320,6 +322,73 @@ cfs_range_expr_parse(struct cfs_lstr *src, unsigned min, unsigned max, return -EINVAL; } +/** + * 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. * @@ -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 @@ -412,8 +482,8 @@ EXPORT_SYMBOL(cfs_expr_list_free); /** * Parses \ token of the syntax. * - * \retval 1 if \a str parses to \ | \ - * \retval 0 otherwise + * \retval 0 if \a str parses to \ | \ + * \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/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index f9262243f..209736454 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -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/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c index 5e185fa59..5d8d8b79f 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto-adler.c +++ b/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/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c index fbbc8a7e3..079d50ebf 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c +++ b/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); @@ -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/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 277f6b890..c74c80915 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/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/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 4545d54f7..8689ea757 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/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/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 64a984b42..70a99cf01 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -62,7 +62,6 @@ 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; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index 838f5f3bd..890844602 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/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(¤t->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/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index eb10e3b47..64a136cd5 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -191,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; @@ -212,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"; } } @@ -225,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/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 806f9747a..e7c2b2615 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -66,9 +66,6 @@ MODULE_AUTHOR("Peter J. Braam "); MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); -static void insert_debugfs(void); -static void remove_debugfs(void); - static struct dentry *lnet_debugfs_root; static void kportal_memhog_free(struct libcfs_device_userstate *ldu) @@ -277,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) { @@ -321,7 +302,7 @@ 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; @@ -340,7 +321,6 @@ out: return err; } - struct cfs_psdev_ops libcfs_psdev_ops = { libcfs_psdev_open, libcfs_psdev_release, @@ -349,90 +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(); - - 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; - } - - insert_debugfs(); - - 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 exit_libcfs_module(void) -{ - int rc; - - remove_debugfs(); - - if (cfs_sched_rehash != NULL) { - cfs_wi_sched_destroy(cfs_sched_rehash); - cfs_sched_rehash = NULL; - } - - cfs_crypto_unregister(); - cfs_wi_shutdown(); - - misc_deregister(&libcfs_dev); - - cfs_cpu_fini(); - - 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, @@ -700,11 +596,6 @@ static struct ctl_table lnet_table[] = { } }; -struct lnet_debugfs_symlink_def { - char *name; - char *target; -}; - static const struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = { { "console_ratelimit", "/sys/module/libcfs/parameters/libcfs_console_ratelimit"}, @@ -756,11 +647,10 @@ static const struct file_operations lnet_debugfs_file_operations = { .llseek = default_llseek, }; -static void insert_debugfs(void) +void lustre_insert_debugfs(struct ctl_table *table, + const struct lnet_debugfs_symlink_def *symlinks) { - struct ctl_table *table; struct dentry *entry; - const struct lnet_debugfs_symlink_def *symlinks; if (lnet_debugfs_root == NULL) lnet_debugfs_root = debugfs_create_dir("lnet", NULL); @@ -769,19 +659,20 @@ static void insert_debugfs(void) if (IS_ERR_OR_NULL(lnet_debugfs_root)) return; - for (table = lnet_table; table->procname; table++) + for (; table->procname; table++) entry = debugfs_create_file(table->procname, table->mode, lnet_debugfs_root, table, &lnet_debugfs_file_operations); - for (symlinks = lnet_debugfs_symlinks; symlinks->name; symlinks++) + for (; symlinks && symlinks->name; symlinks++) entry = debugfs_create_symlink(symlinks->name, lnet_debugfs_root, symlinks->target); } +EXPORT_SYMBOL_GPL(lustre_insert_debugfs); -static void remove_debugfs(void) +static void lustre_remove_debugfs(void) { if (lnet_debugfs_root != NULL) debugfs_remove_recursive(lnet_debugfs_root); @@ -789,6 +680,85 @@ static void remove_debugfs(void) 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 exit_libcfs_module(void) +{ + 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(); + + 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"); module_init(init_libcfs_module); diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c deleted file mode 100644 index 087449f4e..000000000 --- a/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 - */ - -#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 - * - * :== [ ' ' ] - * :== '@' - * :== '*' | - * | - * - * :== ... - * - * :== | - * - * :== '[' [ ',' ] ']' - * :== | - * '-' | - * '-' '/' - * :== | - * :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" | - * "vib" | "ra" | "elan" | "mx" | "ptl" - * \endverbatim - */ - -/** - * Structure to represent \ token of the syntax. - * - * One of this is created for each \ 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 *@ is found. - */ - int nr_all; - /** - * Pointer to corresponding element of libcfs_netstrfns. - */ - struct netstrfns *nr_netstrfns; - /** - * Number of network. E.g. 5 if \ is "elan5". - */ - int nr_netnum; -}; - -/** - * Structure to represent \ 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 \ token on the syntax. - * - * Allocates struct addrrange and links to \a nidrange via - * (nidrange::nr_addrranges) - * - * \retval 1 if \a src parses to '*' | \ | \ - * \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 \ token of the syntax. - * - * \retval 1 if \a src parses to \ '@' \ - * \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 - * \ [ ' ' \ ], 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/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index effa2af58..f2d018d78 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -39,7 +39,6 @@ * Author: Phil Schwan */ - #define DEBUG_SUBSYSTEM S_LNET #define LUSTRE_TRACEFILE_PRIVATE #include "tracefile.h" @@ -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; diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.h b/drivers/staging/lustre/lustre/libcfs/tracefile.h index e931f6d98..cb7a39635 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.h +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.h @@ -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, @@ -309,7 +307,6 @@ 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); diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index 48009b775..e1143a566 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/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/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index 2cbc46838..9ac29e718 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -2,7 +2,7 @@ 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 lproc_llite.o diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index b86685912..80cba0448 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -344,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/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index a9bc6e23f..5c9502b5b 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -660,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); @@ -838,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: @@ -907,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; @@ -1047,7 +1046,6 @@ progress: return rc; } - static int copy_and_ioctl(int cmd, struct obd_export *exp, const void __user *data, size_t size) { @@ -1554,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( @@ -1563,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( @@ -1734,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; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index dcd0c6d65..02f275930 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/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; } @@ -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)) { @@ -694,7 +690,7 @@ out_och_free: if (rc) { if (och_p && *och_p) { kfree(*och_p); - *och_p = NULL; /* OBD_FREE writes some magic there */ + *och_p = NULL; (*och_usecount)--; } mutex_unlock(&lli->lli_och_mutex); @@ -912,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); @@ -932,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; @@ -963,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; @@ -1038,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; @@ -1268,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; @@ -1303,7 +1295,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, u32 ost_idx) goto out; out: ccc_inode_lsm_put(inode, lsm); - OBDO_FREE(oa); + kmem_cache_free(obdo_cachep, oa); return rc; } @@ -1433,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); @@ -1874,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; @@ -1899,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)); @@ -1931,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); @@ -2118,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)) @@ -2144,7 +2143,6 @@ 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; @@ -2494,8 +2492,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 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, @@ -2504,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); @@ -2565,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; @@ -2577,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); @@ -2601,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; } @@ -2611,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, @@ -2633,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) @@ -2670,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; @@ -2763,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; @@ -2850,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; @@ -2954,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) { @@ -3083,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; @@ -3181,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; @@ -3307,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; @@ -3327,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; diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c deleted file mode 100644 index 24590ae36..000000000 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ /dev/null @@ -1,661 +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 - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include - -#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) { - 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); - - 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/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 7bdae723f..3f348a3aa 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/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,14 +293,13 @@ 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) { diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index ec8fff463..9096d311e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -71,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 @@ -134,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. @@ -398,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 */ @@ -659,7 +657,6 @@ 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 */ int ldebugfs_register_mountpoint(struct dentry *parent, @@ -690,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); @@ -791,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, @@ -801,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; @@ -823,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); @@ -850,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 @@ -1000,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; @@ -1052,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; @@ -1296,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) @@ -1344,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); @@ -1465,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/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index b4ed6c89a..4a8c759fe 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -146,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; @@ -182,7 +181,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, 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 | @@ -334,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; @@ -445,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; @@ -466,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) @@ -480,12 +468,9 @@ 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); kfree(op_data); if (err) { CERROR("%s: md_getattr failed for root: rc = %d\n", @@ -619,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); @@ -838,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; @@ -994,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); @@ -1126,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)); @@ -1183,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); @@ -1219,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. @@ -1325,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) { @@ -1413,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) @@ -1517,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; @@ -1706,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; @@ -1825,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)) @@ -1853,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; @@ -1863,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) @@ -1974,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) { @@ -1986,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); @@ -2048,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; } @@ -2160,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(); @@ -2197,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; @@ -2209,8 +2172,6 @@ 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); kfree(op_data); } diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index a90214bb8..7df978371 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/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/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 8d1c253d4..e578a1130 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/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, @@ -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/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index c8a450b5c..b27c3f2fc 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -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) { diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 5f0d80cc9..fed50d538 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -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,7 +333,7 @@ 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); @@ -365,18 +364,20 @@ 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: 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; bio->bi_error = ret; bio_endio(bio); @@ -430,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); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 486dca607..190fc4411 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -218,6 +218,7 @@ static int ll_site_stats_seq_show(struct seq_file *m, void *v) */ return cl_site_stats_print(lu2cl_site(ll_s2sbi(sb)->ll_site), m); } + LPROC_SEQ_FOPS_RO(ll_site_stats); static ssize_t max_read_ahead_mb_show(struct kobject *kobj, @@ -478,6 +479,7 @@ out: } return rc; } + LPROC_SEQ_FOPS(ll_max_cached_mb); static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr, @@ -684,6 +686,7 @@ 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 ssize_t lazystatfs_show(struct kobject *kobj, @@ -775,6 +778,7 @@ 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 ssize_t xattr_cache_show(struct kobject *kobj, @@ -960,7 +964,6 @@ int ldebugfs_register_mountpoint(struct dentry *parent, char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; - name[MAX_STRING_SIZE] = '\0'; LASSERT(sbi != NULL); @@ -1017,6 +1020,7 @@ int ldebugfs_register_mountpoint(struct dentry *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) @@ -1049,7 +1053,6 @@ int ldebugfs_register_mountpoint(struct dentry *parent, if (err) goto out; - err = ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); if (err) @@ -1094,6 +1097,7 @@ void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) lprocfs_free_stats(&sbi->ll_stats); } } + #undef MAX_STRING_SIZE #define pct(a, b) (b ? a * 100 / b : 0) @@ -1140,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%", @@ -1219,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", @@ -1288,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, @@ -1325,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]++; @@ -1395,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" @@ -1410,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"); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 05e7dc859..2ca22001a 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/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 @@ -409,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 */ @@ -439,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)) { @@ -471,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, @@ -668,7 +673,6 @@ out_release: 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) { @@ -864,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; @@ -899,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 */ @@ -928,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; @@ -951,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; } diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 39022ea88..fe4a72268 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -61,7 +61,7 @@ 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; @@ -106,8 +104,7 @@ void free_rmtperm_hash(struct hlist_head *hash) for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) 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) @@ -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; diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 991d20c50..f79193fa2 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/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/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index b17b7cea5..3da4c01e2 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -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, diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index f97371dd8..18f5f2b7e 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -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; @@ -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); 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); @@ -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); diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index e4020ce8c..013136860 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/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) @@ -90,7 +92,7 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); static int __init init_lustre_lite(void) { 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); @@ -152,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_sysfs; + 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) @@ -175,26 +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_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; } @@ -209,11 +196,6 @@ static void __exit exit_lustre_lite(void) 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/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index b8f6a8779..d16d6cfce 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/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. diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index 2162bf6c0..b5a6661d4 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/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/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index a659962e0..37773c181 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/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; } @@ -643,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) { @@ -661,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))); @@ -698,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; /* @@ -1039,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/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index f354e82d4..f7b1144aa 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/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/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index b6f6d4cb6..e13afb7e8 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/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/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index a3cf5ad20..92f60c350 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/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" diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 362a87d0d..4b7eb33f7 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/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, + rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, name, pv, size, 0, flags, ll_i2suppgid(inode), &req); - capa_put(oc); #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/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 9e763ce24..e1e599ceb 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/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; @@ -146,7 +141,7 @@ static int ll_xattr_cache_add(struct list_head *cache, err_value: 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); kfree(xattr->xe_name); kfree(xattr->xe_value); - OBD_SLAB_FREE_PTR(xattr, xattr_kmem); + 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. */ @@ -359,8 +345,6 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) __u32 *xsizes; int rc, i; - - rc = ll_xattr_find_get_lock(inode, oit, &req); if (rc) goto out_no_unlock; @@ -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/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index c9e0536e9..635a93cc9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -560,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; @@ -593,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; - } - if (lmv->lmv_tgts_kobj) - sysfs_remove_link(lmv->lmv_tgts_kobj, - mdc_obd->obd_name); + 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) @@ -862,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) { @@ -1084,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 @@ -1335,6 +1334,7 @@ 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; @@ -1438,8 +1438,7 @@ out_free_temp: } 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; @@ -1449,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) { @@ -1471,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) @@ -1496,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); @@ -1586,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) { @@ -1814,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)); @@ -1849,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)) @@ -2014,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; @@ -2029,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; } @@ -2099,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); @@ -2322,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) @@ -2606,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; @@ -2622,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) @@ -2724,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) @@ -2759,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); @@ -2820,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 diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 311fc1b70..40cf4d9f0 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -143,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]; } diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index 314ce8525..1c0fe6524 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/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/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 8c3bbe574..2e8b56645 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/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; diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 3f51b573e..34c1346f0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -100,7 +100,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) 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,7 +110,7 @@ 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)); + kmem_cache_free(lov_oinfo_slab, lsm->lsm_oinfo[i]); kvfree(lsm); return NULL; } @@ -121,8 +121,7 @@ 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)); + kmem_cache_free(lov_oinfo_slab, lsm->lsm_oinfo[i]); kvfree(lsm); } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index dde9656d4..515a5c147 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -220,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); @@ -235,7 +234,7 @@ void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars); 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); @@ -248,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); @@ -271,5 +269,4 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi) return false; } - #endif diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index bf3629151..5e6228b9c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/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--; @@ -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; @@ -273,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) { @@ -332,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; @@ -546,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) @@ -729,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); @@ -990,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/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index a6938085f..d866791d7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/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, @@ -443,7 +444,7 @@ static void lov_lock_fini(const struct lu_env *env, LASSERT(lck->lls_sub[i].sub_lock == NULL); 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, @@ -517,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); @@ -677,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) { @@ -981,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, @@ -1026,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, @@ -1138,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); @@ -1151,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, @@ -1173,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; @@ -1193,5 +1195,4 @@ static struct cl_lock_closure *lov_closure_get(const struct lu_env *env, return closure; } - /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index c5c67d982..7abe484c0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/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++) { @@ -121,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) @@ -169,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)); @@ -833,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; @@ -869,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]) @@ -913,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) @@ -1061,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; @@ -1094,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 " @@ -1257,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); @@ -1349,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); @@ -1365,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 @@ -1487,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]; @@ -1672,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; @@ -1862,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); @@ -2067,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) { @@ -2092,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; @@ -2101,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; @@ -2132,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 && diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 4d7cd924a..c7ff817bb 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/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 * @{ @@ -809,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, @@ -892,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); @@ -909,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; @@ -924,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/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 6b1c135c9..2fb1e974c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/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. * @@ -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; @@ -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. */ diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index c4596e8e5..463cadbd9 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/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/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index c59b14026..b03827ef6 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -142,12 +142,12 @@ 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, }; @@ -282,6 +282,7 @@ 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 = inode->i_private; } return rc; @@ -294,28 +295,6 @@ static struct file_operations pool_proc_operations = { .release = seq_release, }; -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) { @@ -418,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; @@ -530,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; @@ -547,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/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 416e42ed7..1a150c267 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -67,7 +67,7 @@ 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); + kmem_cache_free(obdo_cachep, req->rq_oi.oi_oa); kfree(req->rq_oi.oi_osfs); kfree(req); } @@ -202,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; @@ -236,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; } @@ -309,7 +309,8 @@ 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) { kfree(req); rc = -ENOMEM; @@ -319,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); } @@ -392,7 +392,8 @@ 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) { kfree(req); rc = -ENOMEM; @@ -507,7 +508,8 @@ int lov_prep_setattr_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) { kfree(req); rc = -ENOMEM; @@ -518,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, diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 90d9ec386..8bc04c8d3 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/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); } /** @@ -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; @@ -205,5 +205,4 @@ struct lu_device_type lovsub_device_type = { .ldt_ctx_tags = LCT_CL_THREAD }; - /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 62b696d25..1a3e30a14 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/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/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 57e3629fc..d775e28d4 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/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/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 380b8271b..a0be15c6b 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/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,6 +167,7 @@ static ssize_t lov_stripecount_seq_write(struct file *file, desc->ld_default_stripe_count = val; return count; } + LPROC_SEQ_FOPS(lov_stripecount); static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, @@ -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) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 4d149435e..29b46f754 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -43,17 +43,14 @@ void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars); 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, @@ -140,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/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 1a850ea26..227fc9ee0 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/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); @@ -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/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index bcb6c00c4..d4bf34b61 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/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 */ @@ -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); @@ -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/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 5e9c6296c..c87c7d8ef 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/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/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 204d51262..16a5a10d3 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/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); - } - - 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); @@ -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); @@ -1799,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); @@ -2220,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; @@ -2260,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; @@ -2270,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); @@ -2544,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; @@ -2560,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)); @@ -2583,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, @@ -2694,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 diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 34a9317d6..8d5bc5a75 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -52,6 +52,7 @@ 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[] = { diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 019ee2f25..5f53f3b7c 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -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; @@ -454,8 +440,12 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *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; @@ -770,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) { @@ -874,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, @@ -899,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, @@ -975,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; @@ -992,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; } @@ -1078,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; } @@ -1112,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; @@ -1127,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); - inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); + 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) { - kfree(inst); - return -E2BIG; - } - } else { - LASSERT(IS_MDT(lsi)); - rc = server_name2svname(lsi->lsi_svname, inst, NULL, - PAGE_CACHE_SIZE); - if (rc) { - kfree(inst); - 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; @@ -1334,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; - pages = kcalloc(nrpages, sizeof(*pages), GFP_NOFS); + 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; @@ -1492,7 +1466,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc, if (cld->cld_cfg.cfg_sb) lsi = s2lsi(cld->cld_cfg.cfg_sb); - env = kzalloc(sizeof(*env), GFP_NOFS); + env = kzalloc(sizeof(*env), GFP_KERNEL); if (!env) return -ENOMEM; @@ -1588,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) @@ -1609,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). @@ -1680,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); } @@ -1724,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, diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index d0f70b41a..acc685712 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -5,5 +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 \ + 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/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 933456c50..2e20cf635 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/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) @@ -286,125 +285,6 @@ again: return NULL; } -/* - * 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); - new = kzalloc(posix_size, GFP_NOFS); - 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); - new = kzalloc(posix_size, GFP_NOFS); - 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) { - kfree(new); - posix_size = rc; - } - return posix_size; -} -EXPORT_SYMBOL(lustre_acl_xattr_merge2posix); - /* * Merge the posix ACL and the extended ACL into new extended ACL. */ diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c deleted file mode 100644 index d8d1a66ad..000000000 --- a/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 - */ - -#define DEBUG_SUBSYSTEM S_SEC - -#include -#include -#include -#include -#include - -#include "../include/obd_class.h" -#include "../include/lustre_debug.h" -#include "../include/lustre/lustre_idl.h" - -#include -#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; - - hash = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); - 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); - - kfree(hash); -} -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/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index fd1a4c542..e67cea758 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/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; @@ -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. @@ -1296,17 +1246,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. */ @@ -1340,14 +1279,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. * @@ -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, diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index b081167f9..5621bebf3 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/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) @@ -1275,32 +1276,6 @@ static int cl_enqueue_locked(const struct lu_env *env, struct cl_lock *lock, return result; } -/** - * 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. * @@ -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/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 163fe0cd7..a1a602422 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -97,16 +97,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. * @@ -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) @@ -927,21 +902,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. * @@ -1074,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/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index d5fb81f84..2f569edd0 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -283,8 +283,7 @@ 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; @@ -442,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) @@ -904,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. * diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 2c705d762..3e9c24684 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/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; @@ -81,7 +68,7 @@ EXPORT_SYMBOL(obd_timeout); unsigned int obd_timeout_set; EXPORT_SYMBOL(obd_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); @@ -132,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\n", - obd_memory_sum(), - obd_pages_sum() << PAGE_CACHE_SHIFT, - obd_pages_sum()); - return 1; - } - return 0; -} -EXPORT_SYMBOL(obd_alloc_fail); - static inline void obd_data2conn(struct lustre_handle *conn, struct obd_ioctl_data *data) { @@ -164,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; @@ -434,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]; @@ -470,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) { @@ -508,32 +476,14 @@ extern int class_procfs_clean(void); 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(); - 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; @@ -583,7 +533,6 @@ static int __init init_obdclass(void) if (err != 0) return err; - err = llog_info_init(); if (err) return err; @@ -593,60 +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); - -__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); - /* 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? */ @@ -665,20 +574,6 @@ static void cleanup_obdclass(void) 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. "); diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c index c61add46b..43a7f7a79 100644 --- a/drivers/staging/lustre/lustre/obdclass/debug.c +++ b/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/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c deleted file mode 100644 index b67b0feb0..000000000 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ /dev/null @@ -1,1054 +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 - */ - -#define DEBUG_SUBSYSTEM S_CLASS - -#include "../include/obd.h" -#include "../include/dt_object.h" -#include -/* fid_be_to_cpu() */ -#include "../include/lustre_fid.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); - -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); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 0ca730948..6477aeb88 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -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,7 +68,7 @@ static struct obd_device *obd_device_alloc(void) { struct obd_device *obd; - OBD_SLAB_ALLOC_PTR_GFP(obd, obd_device_cachep, GFP_NOFS); + obd = kmem_cache_alloc(obd_device_cachep, GFP_NOFS | __GFP_ZERO); if (obd != NULL) obd->obd_magic = OBD_DEVICE_MAGIC; return obd; @@ -87,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; @@ -106,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); @@ -140,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) { @@ -178,9 +174,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, 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; @@ -293,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; } @@ -339,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); @@ -439,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[] * @@ -462,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, @@ -477,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. */ @@ -539,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; @@ -566,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; @@ -577,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; @@ -608,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 */ @@ -638,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(); @@ -720,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) @@ -849,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); @@ -870,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; } @@ -895,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); @@ -927,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); @@ -954,7 +850,7 @@ static void class_import_destroy(struct obd_import *imp) 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); } @@ -1001,6 +897,7 @@ EXPORT_SYMBOL(class_import_put); 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 @@ -1078,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; } @@ -1115,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); @@ -1132,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 @@ -1187,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; } @@ -1200,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); @@ -1221,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 ? "" : - 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; @@ -1388,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; @@ -1661,8 +1206,7 @@ static void obd_zombie_export_add(struct obd_export *exp) */ static void obd_zombie_import_add(struct obd_import *imp) { - LASSERT(imp->imp_sec == NULL); - LASSERT(imp->imp_rq_pool == NULL); + LASSERT(!imp->imp_sec); spin_lock(&obd_zombie_impexp_lock); LASSERT(list_empty(&imp->imp_zombie_chain)); zombies_count++; @@ -1713,7 +1257,6 @@ void obd_zombie_barrier(void) } EXPORT_SYMBOL(obd_zombie_barrier); - /** * destroy zombie export/import thread. */ @@ -1743,7 +1286,6 @@ static int obd_zombie_impexp_thread(void *unused) return 0; } - /** * start destroy zombie import/export thread */ @@ -1766,6 +1308,7 @@ int obd_zombie_impexp_init(void) wait_for_completion(&obd_zombie_start); return 0; } + /** * stop destroy zombie import/export thread */ @@ -1775,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); - - lh = kzalloc(len, GFP_NOFS); - if (!lh) - 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); - kfree(lh); -} -EXPORT_SYMBOL(kuc_free); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 6218ef34e..a055cbb4f 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -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) { @@ -215,7 +213,6 @@ struct miscdevice obd_psdev = { .fops = &obd_psdev_fops, }; - static ssize_t version_show(struct kobject *kobj, struct attribute *attr, char *buf) { diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c index 62ed706b1..9496c09b2 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c @@ -49,102 +49,6 @@ #include #include /* 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/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 1515163a8..518288df4 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -162,7 +162,3 @@ int obd_sysctl_init(void) { return sysfs_create_group(lustre_kobj, &lustre_attr_group); } - -void obd_sysctl_clean(void) -{ -} diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index facc8351f..7cb55ef79 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/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" @@ -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)); @@ -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 { @@ -475,380 +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; - - buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS); - 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: - kfree(buf); - 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) @@ -902,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; - - 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/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index 48dbbcf97..c442cae5f 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/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,285 +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; - } - 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; - } - 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) @@ -571,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; @@ -610,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) @@ -619,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/drivers/staging/lustre/lustre/obdclass/llog_internal.h b/drivers/staging/lustre/lustre/obdclass/llog_internal.h index 5332131a2..b9fe4b01c 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_internal.h +++ b/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/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 81ab27e73..3900b9d40 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/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" @@ -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/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index a2d5aa105..9354f75b5 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/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/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c index c49dfe541..6acc4a10f 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_counters.c +++ b/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/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 08d1f0edf..333ac7d26 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/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" @@ -264,36 +263,6 @@ struct dentry *ldebugfs_add_simple(struct dentry *root, } EXPORT_SYMBOL(ldebugfs_add_simple); -struct dentry *ldebugfs_add_symlink(const char *name, struct dentry *parent, - const char *format, ...) -{ - struct dentry *entry; - char *dest; - va_list ap; - - if (parent == NULL || format == NULL) - return NULL; - - dest = kzalloc(MAX_STRING_SIZE + 1, GFP_KERNEL); - if (!dest) - return NULL; - - va_start(ap, format); - vsnprintf(dest, MAX_STRING_SIZE, format, ap); - va_end(ap); - - entry = debugfs_create_symlink(name, parent, dest); - if (IS_ERR_OR_NULL(entry)) { - CERROR("LdebugFS: Could not create symbolic link from %s to %s", - name, dest); - entry = NULL; - } - - kfree(dest); - return entry; -} -EXPORT_SYMBOL(ldebugfs_add_symlink); - static struct file_operations lprocfs_generic_fops = { }; int ldebugfs_add_vars(struct dentry *parent, @@ -388,41 +357,6 @@ 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) -{ - atomic_t *atm = data; - int val = 0; - int rc; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc < 0) - return rc; - - if (val <= 0) - return -ERANGE; - - atomic_set(atm, val); - return count; -} -EXPORT_SYMBOL(lprocfs_wr_atomic); - static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -433,16 +367,6 @@ static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(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); - static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -565,9 +489,13 @@ 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", @@ -584,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); @@ -663,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) @@ -685,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, @@ -722,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 ? "" : - libcfs_nid2str(imp->imp_connection->c_peer.nid), + imp->imp_connection == NULL ? "" : nidstr, imp->imp_conn_cnt, imp->imp_generation, atomic_read(&imp->imp_inval_count)); @@ -747,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 @@ -793,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, @@ -808,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, @@ -829,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", @@ -846,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); @@ -859,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"); @@ -869,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++) { @@ -902,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]); } @@ -917,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"); @@ -1082,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; @@ -1190,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]; @@ -1300,227 +1254,6 @@ 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_debugfs_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 - * , 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 = ldebugfs_register_stats(obd->obd_debugfs_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_debugfs_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 = ldebugfs_register_stats(obd->obd_debugfs_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_cleanup(struct obd_export *exp) { return 0; @@ -1576,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) { @@ -1635,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 */ @@ -1788,36 +1497,21 @@ 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) -{ - struct obd_device *dev = data; - struct client_obd *cli = &dev->u.cli; - - 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); - - return 0; -} -EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc); - -ssize_t lustre_attr_show(struct kobject *kobj, - struct attribute *attr, char *buf) +static ssize_t lustre_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf) { struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); return a->show ? a->show(kobj, attr, buf) : 0; } -EXPORT_SYMBOL_GPL(lustre_attr_show); -ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t len) +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 a->store ? a->store(kobj, attr, buf, len) : len; } -EXPORT_SYMBOL_GPL(lustre_attr_store); const struct sysfs_ops lustre_sysfs_ops = { .show = lustre_attr_show, diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 8e472327c..0193608a9 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -59,6 +59,7 @@ #include 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; } @@ -153,17 +156,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,7 +588,6 @@ 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 (IS_ERR(o)) @@ -607,9 +595,7 @@ static struct lu_object *lu_object_new(const struct lu_env *env, 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; } @@ -675,11 +661,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, shadow = htable_lookup(s, &bd, f, waiter, &version); if (likely(PTR_ERR(shadow) == -ENOENT)) { - struct lu_site_bkt_data *bkt; - - 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; } @@ -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. * @@ -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. + * 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. * - * 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. - * - * 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, @@ -1992,6 +1876,13 @@ static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx) 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; } @@ -2001,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, @@ -2017,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); @@ -2052,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); - kvfree(buf->lb_buf); - 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); - buf->lb_buf = libcfs_kvzalloc(size, GFP_NOFS); - 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; - - ptr = libcfs_kvzalloc(len, GFP_NOFS); - if (ptr == NULL) - return -ENOMEM; - - /* Free the old buf */ - if (buf->lb_buf != NULL) { - memcpy(ptr, buf->lb_buf, buf->lb_len); - kvfree(buf->lb_buf); - } - - buf->lb_buf = ptr; - buf->lb_len = len; - return 0; -} -EXPORT_SYMBOL(lu_buf_check_and_grow); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 35a94a8f4..fb9147cc6 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/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; @@ -193,7 +180,7 @@ 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); @@ -212,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); @@ -246,6 +233,7 @@ static int cleanup_all_handles(void) void class_handle_cleanup(void) { int count; + LASSERT(handle_hash != NULL); count = cleanup_all_handles(); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 93805ac93..c231e0da0 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -47,8 +47,7 @@ #include "llog_internal.h" -static cfs_hash_ops_t uuid_hash_ops; -static cfs_hash_ops_t nid_hash_ops; +static struct cfs_hash_ops uuid_hash_ops; /*********** string parsing utils *********/ @@ -61,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) @@ -71,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; @@ -194,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) @@ -211,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)); @@ -243,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; @@ -278,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; @@ -381,7 +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); spin_lock_init(&obd->obd_nid_lock); spin_lock_init(&obd->obd_dev_lock); mutex_init(&obd->obd_dev_mutex); @@ -393,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); @@ -441,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; @@ -483,7 +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; spin_unlock(&obd->obd_dev_lock); /* create an uuid-export lustre hash */ @@ -499,19 +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; - } - exp = class_new_export(obd, &obd->obd_uuid); if (IS_ERR(exp)) { err = PTR_ERR(exp); @@ -519,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); @@ -547,20 +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; - } 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); @@ -582,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; @@ -644,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) @@ -668,18 +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; - } - 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) @@ -743,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; @@ -774,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; @@ -826,8 +620,8 @@ 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; @@ -841,14 +635,14 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, LASSERT(proflen == (strlen(prof) + 1)); lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS); - if (lprof->lp_profile == NULL) { + if (!lprof->lp_profile) { err = -ENOMEM; goto free_lprof; } LASSERT(osclen == (strlen(osc) + 1)); lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS); - if (lprof->lp_dt == NULL) { + if (!lprof->lp_dt) { err = -ENOMEM; goto free_lp_profile; } @@ -856,7 +650,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, if (mdclen > 0) { LASSERT(mdclen == (strlen(mdc) + 1)); lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS); - if (lprof->lp_md == NULL) { + if (!lprof->lp_md) { err = -ENOMEM; goto free_lp_dt; } @@ -928,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)) { @@ -940,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; - - new_param = kzalloc(new_len, GFP_NOFS); - if (!new_param) - return ERR_PTR(-ENOMEM); - - strcpy(new_param, new_name); - if (value != NULL) - strcat(new_param, value); - - bufs = kzalloc(sizeof(*bufs), GFP_NOFS); - if (!bufs) { - kfree(new_param); - 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); - - kfree(new_param); - kfree(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); @@ -1022,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. @@ -1135,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); @@ -1178,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 @@ -1299,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, @@ -1354,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; @@ -1377,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", @@ -1439,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); @@ -1451,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; - inst_name = kzalloc(inst_len, GFP_NOFS); + 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); @@ -1482,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]); @@ -1582,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; @@ -1602,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); @@ -1649,31 +1366,6 @@ int class_config_dump_handler(const struct lu_env *env, 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. */ @@ -1781,81 +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, -}; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 7c5bab377..48003d532 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -40,7 +40,6 @@ * Author: Nathan Rutman */ - #define DEBUG_SUBSYSTEM S_CLASS #define D_MOUNT (D_SUPER|D_CONFIG/*|D_WARNING */) #define PRINT_CMD CDEBUG @@ -143,8 +142,8 @@ 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; @@ -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,9 +227,9 @@ int lustre_start_mgc(struct super_block *sb) mutex_lock(&mgc_start_lock); - len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1; + libcfs_nid2str_r(nid, nidstr, sizeof(nidstr)); mgcname = kasprintf(GFP_NOFS, - "%s%s", LUSTRE_MGC_OBDNAME, libcfs_nid2str(nid)); + "%s%s", LUSTRE_MGC_OBDNAME, nidstr); niduuid = kasprintf(GFP_NOFS, "%s_%x", mgcname, i); if (!mgcname || !niduuid) { rc = -ENOMEM; @@ -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,45 +301,15 @@ int lustre_start_mgc(struct super_block *sb) /* Add the primary nids for the MGS */ i = 0; - 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"); @@ -543,7 +488,7 @@ 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; @@ -602,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); @@ -610,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; } @@ -640,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; @@ -660,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; @@ -732,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 ***************/ @@ -929,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); @@ -1069,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 @@ -1117,7 +1029,8 @@ 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 */ lmd->lmd_profile = kasprintf(GFP_NOFS, "%s-client", s1); if (!lmd->lmd_profile) @@ -1162,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; @@ -1188,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; @@ -1233,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, @@ -1265,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); @@ -1273,7 +1185,7 @@ 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, diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 307ffe347..75e1deadd 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/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/drivers/staging/lustre/lustre/obdclass/statfs_pack.c b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c index cc785ab3f..fb4e3ae84 100644 --- a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c +++ b/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/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 27bd170c3..a4a9a763f 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/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 @@ -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, @@ -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); @@ -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,7 +1633,7 @@ 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); } kfree(pga); kfree(pages); @@ -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); @@ -1907,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); @@ -1917,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; @@ -1934,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; @@ -2065,12 +2068,6 @@ 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); - } kfree(ocd); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_internal.h b/drivers/staging/lustre/lustre/obdecho/echo_internal.h index 8e9dbc235..69063fa65 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_internal.h +++ b/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/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index ff6d2e2ff..c4d44e70f 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -63,7 +63,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, rc = kstrtoul(buffer, 10, &val); if (rc) return rc; - if (val < 0 || val > 1) + if (val > 1) return -ERANGE; /* opposite senses */ @@ -96,9 +96,9 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, 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 rc; unsigned long val; + int adding, added, req_count; rc = kstrtoul(buffer, 10, &val); if (rc) @@ -107,8 +107,19 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, if (val < 1 || val > OSC_MAX_RIF_MAX) return -ERANGE; - 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; @@ -216,6 +227,7 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, return count; } + LPROC_SEQ_FOPS(osc_cached_mb); static ssize_t cur_dirty_bytes_show(struct kobject *kobj, @@ -366,6 +378,7 @@ 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) @@ -389,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]; @@ -414,6 +428,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, } return -EINVAL; } + LPROC_SEQ_FOPS(osc_checksum_type); static ssize_t resend_count_show(struct kobject *kobj, @@ -440,9 +455,6 @@ static ssize_t resend_count_store(struct kobject *kobj, if (rc) return rc; - if (val < 0) - return -EINVAL; - atomic_set(&obd->u.cli.cl_resends, val); return count; @@ -586,18 +598,18 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = { 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", @@ -619,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", @@ -642,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", @@ -665,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", @@ -679,6 +694,7 @@ 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, @@ -703,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", diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index c72035e04..b1d1a87f0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -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)) { @@ -305,7 +306,6 @@ out: __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) @@ -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); @@ -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; @@ -1025,7 +1027,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, 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) { @@ -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); @@ -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,7 +1779,6 @@ 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, @@ -1934,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; @@ -1986,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)); } @@ -2006,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; @@ -2033,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); @@ -2079,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; @@ -2109,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); @@ -2133,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); } @@ -2149,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; @@ -2161,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 { @@ -2175,14 +2177,13 @@ 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) { - /* 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, @@ -2568,6 +2569,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, 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) @@ -2853,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; @@ -2922,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/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 365b2787b..d2d68452d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/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/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 91fdec447..69b523c0f 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -122,7 +122,7 @@ static void *osc_key_init(const struct lu_context *ctx, { 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 = { diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 470698b0d..5ed30ecc8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/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; @@ -181,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/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index fa24e9ed1..d413496c0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/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. @@ -402,7 +401,7 @@ static int osc_io_setattr_start(const struct lu_env *env, __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 } } }; + 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) @@ -518,7 +516,7 @@ static int osc_io_read_start(const struct lu_env *env, 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); } @@ -534,7 +532,7 @@ static int osc_io_write_start(const struct lu_env *env, 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); @@ -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, @@ -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); } /** @@ -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/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 70b1b43f6..194490dca 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -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, @@ -1555,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; diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index c628a250e..ba57f8df5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -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, @@ -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) { @@ -193,7 +192,6 @@ static int osc_object_glimpse(const struct lu_env *env, return 0; } - void osc_object_set_contended(struct osc_object *obj) { obj->oo_contention_time = cfs_time_current(); @@ -257,7 +255,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, struct osc_object *osc; 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/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index f9cf5cea6..61eaf7172 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/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); } @@ -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) ? "-" : "+"; @@ -512,6 +512,7 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, 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); @@ -553,7 +554,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, 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_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/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 2ff253f45..199783103 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/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, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 12113dfd8..367f83af1 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/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; }; @@ -191,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) { @@ -217,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, @@ -270,7 +249,6 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, 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); @@ -301,7 +279,6 @@ static int osc_getattr(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_GETATTR); if (rc) { ptlrpc_request_free(req); @@ -347,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); @@ -411,7 +387,6 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, 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); @@ -428,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); } @@ -557,7 +532,6 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, 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); @@ -570,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_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); @@ -600,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; } @@ -624,7 +597,6 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, 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); @@ -636,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; @@ -648,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); @@ -754,8 +725,7 @@ 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 ptlrpc_request *req; @@ -777,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) { @@ -794,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, @@ -817,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; } @@ -910,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; } @@ -1100,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 */ @@ -1210,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); } @@ -1247,7 +1216,7 @@ 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; @@ -1268,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; @@ -1287,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) { @@ -1326,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++) { @@ -1435,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; @@ -1571,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; } @@ -1582,19 +1547,17 @@ 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; + 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); } @@ -1654,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; @@ -1681,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; @@ -1702,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; @@ -1786,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); @@ -1832,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); @@ -1850,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; } @@ -1860,7 +1815,7 @@ 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 list_head *ext_list, int cmd) { struct ptlrpc_request *req = NULL; struct osc_extent *ext; @@ -1920,7 +1875,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, 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,35 +1990,20 @@ 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); - kfree(crattr); - } + kfree(crattr); if (rc != 0) { LASSERT(req == NULL); if (oa) - OBDO_FREE(oa); + 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 */ @@ -2149,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); @@ -2335,6 +2277,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, no_match: if (intent) { LIST_HEAD(cancels); + req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE_LVB); if (req == NULL) @@ -2359,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; @@ -2373,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) { @@ -2645,7 +2589,6 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) return rc; } - static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { @@ -2720,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); @@ -2787,8 +2730,7 @@ 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 ll_fiemap_info_key *fm_key = key; struct ldlm_res_id res_id; ldlm_policy_data_t policy; struct lustre_handle lockh; @@ -2910,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; @@ -2973,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; @@ -2988,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; } @@ -3081,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); @@ -3101,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; @@ -3153,7 +3096,7 @@ 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; } @@ -3163,6 +3106,9 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct client_obd *cli = &obd->u.cli; void *handler; int rc; + int adding; + int added; + int req_count; rc = ptlrpcd_addref(); if (rc) @@ -3191,15 +3137,20 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) 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); @@ -3219,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 */ @@ -3339,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 @@ -3354,14 +3308,45 @@ static int __init osc_init(void) 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; } @@ -3369,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. "); diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index c83a34a01..a9f1bf536 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -72,9 +72,11 @@ struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid) 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); @@ -117,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]); @@ -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,7 +355,7 @@ 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; + time64_t olddl; int rc; req->rq_early = 0; @@ -376,16 +388,18 @@ 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; } @@ -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); } /** @@ -446,7 +460,7 @@ 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; + 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,7 +509,7 @@ 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; @@ -502,8 +517,10 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize, 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 */ - kfree(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; @@ -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); @@ -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; - set = kzalloc(sizeof(*set), GFP_NOFS); + 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); @@ -960,28 +936,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; - - cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS); - if (!cbdata) - 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); @@ -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); @@ -1404,7 +1361,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) 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-> @@ -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; @@ -1970,13 +1942,11 @@ int ptlrpc_expired_set(void *data) { struct ptlrpc_request_set *set = data; struct list_head *tmp; - time_t now = get_seconds(); + 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); } @@ -2053,31 +2025,25 @@ EXPORT_SYMBOL(ptlrpc_interrupted_set); int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) { struct list_head *tmp; - time_t now = get_seconds(); + 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; @@ -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, @@ -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. @@ -2357,40 +2321,28 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) 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), @@ -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; } @@ -3031,7 +2977,7 @@ 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, diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index ffe36e222..da1f0b1ac 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/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, @@ -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 && @@ -230,12 +230,12 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode) 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/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index c8ef9e578..9c2fd34e2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -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; @@ -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 @@ -246,7 +246,7 @@ 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 */ + __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, @@ -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; @@ -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; @@ -521,7 +520,7 @@ static 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; @@ -560,7 +559,6 @@ static int ptlrpc_ni_init(void) return -ENOMEM; } - int ptlrpc_init_portals(void) { int rc = ptlrpc_ni_init(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 1eae3896c..bfa410f7e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/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); @@ -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; @@ -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) @@ -749,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; } @@ -906,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))) { @@ -931,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, @@ -948,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; @@ -968,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)); @@ -981,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); @@ -1264,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; } @@ -1511,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; @@ -1531,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) @@ -1561,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/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index d14c20008..d7c4f4780 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/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; @@ -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. @@ -1995,55 +1994,6 @@ static void *__req_capsule_get(struct req_capsule *pill, return value; } -/** - * 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. @@ -2135,21 +2085,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 @@ -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/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index 1c701e0a0..5122205cb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -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,41 +143,6 @@ 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, @@ -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/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 53f9af1f2..afab0dee7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/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); @@ -239,6 +238,7 @@ ptlrpc_ldebugfs_register(struct dentry *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"); @@ -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 @@ -322,8 +323,8 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max); +LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max); static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -420,7 +421,6 @@ 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); @@ -714,6 +714,7 @@ out: return rc < 0 ? rc : count; } + LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs); /** @} nrs */ @@ -891,36 +892,6 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s, 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, "\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; @@ -938,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); } @@ -990,7 +964,7 @@ 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; + time64_t worstt; unsigned int cur; unsigned int worst; int i; @@ -1005,17 +979,18 @@ 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 ssize_t high_priority_ratio_show(struct kobject *kobj, @@ -1208,55 +1183,6 @@ void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) } 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; - - kbuf = kzalloc(BUFLEN, GFP_NOFS); - if (!kbuf) - 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 ldebugfs_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: - kfree(kbuf); - return count; -} -EXPORT_SYMBOL(lprocfs_wr_evict_client); - #undef BUFLEN int lprocfs_wr_ping(struct file *file, const char __user *buffer, @@ -1266,7 +1192,10 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer, struct ptlrpc_request *req; int rc; - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + req = ptlrpc_prep_ping(obd->u.cli.cl_import); LPROCFS_CLIMP_EXIT(obd); if (req == NULL) @@ -1328,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) { @@ -1355,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); @@ -1379,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); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 92c746b44..09ddeef6b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -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; @@ -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 @@ -252,7 +250,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) /* 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 */ @@ -303,7 +301,7 @@ 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() - + 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); } @@ -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) ? @@ -601,7 +597,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) /* Manage remote for early replies */ reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MANAGE_REMOTE | - LNET_MD_TRUNCATE; /* allow to make EOVERFLOW error */; + LNET_MD_TRUNCATE; /* allow to make EOVERFLOW error */ reply_md.user_ptr = &request->rq_reply_cbid; reply_md.eq_handle = ptlrpc_eq_h; @@ -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 + diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index d37cdd5ac..7044e1ff6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/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. @@ -478,7 +477,6 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs, * * \param resp the resource hierarchy that is being released * - * \see ptlrpc_nrs_req_hp_move() * \see ptlrpc_nrs_req_finalize() */ static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp) @@ -1113,7 +1111,7 @@ 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; @@ -1249,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); - kfree(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 @@ -1553,22 +1486,6 @@ ptlrpc_nrs_req_get_nolock0(struct ptlrpc_service_part *svcpt, bool hp, return NULL; } -/** - * 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 @@ -1589,48 +1506,6 @@ bool ptlrpc_nrs_req_pending_nolock(struct ptlrpc_service_part *svcpt, bool hp) return nrs->nrs_req_queued > 0; }; -/** - * 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 @@ -1698,7 +1573,6 @@ out: return rc; } - /* ptlrpc/nrs_fifo.c */ extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; @@ -1720,7 +1594,6 @@ int ptlrpc_nrs_init(void) if (rc != 0) goto fail; - return rc; fail: /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 84937ad90..f3cb5184f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -94,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 @@ -129,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; @@ -209,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); } } @@ -433,14 +414,15 @@ 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; @@ -593,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); @@ -605,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); @@ -692,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) @@ -802,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; } } @@ -818,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; @@ -833,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 */ @@ -852,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; @@ -867,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; @@ -882,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: @@ -897,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; } @@ -914,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; @@ -937,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; @@ -962,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; @@ -975,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; @@ -1013,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; @@ -1020,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; @@ -1066,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; @@ -1088,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; @@ -1106,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 */ @@ -1125,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; @@ -1138,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; @@ -1163,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; @@ -1176,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; @@ -1201,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; @@ -1214,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) { @@ -1241,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; @@ -1255,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; @@ -1280,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) { @@ -1320,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); @@ -1336,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; @@ -1351,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; @@ -1366,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; @@ -1376,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]; @@ -1431,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; @@ -1446,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; @@ -1461,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; @@ -1474,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; @@ -1490,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; @@ -1506,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; @@ -1537,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; @@ -1547,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); @@ -1559,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. * @@ -1690,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); @@ -1722,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) { @@ -1874,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); @@ -1979,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); @@ -2018,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); @@ -2069,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); @@ -2179,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; 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 @@ -2199,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) { @@ -2207,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) { @@ -2271,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; @@ -2332,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) { @@ -2394,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, @@ -2406,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, @@ -2431,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); @@ -2455,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/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c index e1334c24e..2a2a9fb65 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c +++ b/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/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index f8edb791a..5c719f175 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/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) { @@ -105,7 +95,7 @@ static 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; } @@ -113,6 +103,7 @@ static int ptlrpc_ping(struct obd_import *imp) 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 @@ static 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 || @@ -150,6 +136,7 @@ static 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) { @@ -327,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) { @@ -517,7 +499,7 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list, } EXPORT_SYMBOL(ptlrpc_del_timeout_client); -int ptlrpc_pinger_remove_timeouts(void) +static int ptlrpc_pinger_remove_timeouts(void) { struct timeout_item *item, *tmp; @@ -536,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; -static 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/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 6dc3998dc..ab6c4580f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/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, @@ -110,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); @@ -131,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, @@ -243,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); @@ -298,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/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index ae99180d6..9deeb2441 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/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,8 +47,6 @@ 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; static int __init ptlrpc_init(void) { @@ -143,7 +140,8 @@ cleanup: ptlrpc_hr_fini(); req_layout_fini(); /* Fall through */ - default: ; + default: + ; } return rc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 17cc81d50..ce036a1ac 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/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_cpt; + int pd_cursor; int pd_nthreads; - struct ptlrpcd_ctl pd_thread_rcv; + 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,174 +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 - * 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) { - pc->pc_partners = kcalloc(pc->pc_npartners, - sizeof(struct ptlrpcd_ctl *), - GFP_NOFS); - 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, @@ -622,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; @@ -654,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); @@ -694,7 +627,6 @@ 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) { @@ -704,88 +636,262 @@ out: 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); + 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 = NULL; } + 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]); - ptlrpcds = kzalloc(size, GFP_NOFS); + 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); - kfree(ptlrpcds); - 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/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index b9821db22..39f5261c9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -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; 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; } @@ -510,7 +469,7 @@ 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; @@ -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) @@ -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) { @@ -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()), @@ -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; @@ -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 */ @@ -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 * ****************************************/ @@ -2285,7 +2165,6 @@ int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req, } EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_write); - /**************************************** * user descriptor helpers * ****************************************/ @@ -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/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 2ee3e8b2e..cd8a9987f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -58,7 +58,6 @@ * bulk encryption page pools * ****************************************/ - #define POINTERS_PER_PAGE (PAGE_CACHE_SIZE / sizeof(void *)) #define PAGES_PER_POOL (POINTERS_PER_PAGE) @@ -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, @@ -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; @@ -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); - pools = kcalloc(npools, sizeof(*pools), GFP_NOFS); - if (pools == NULL) - goto out; - - for (i = 0; i < npools; i++) { - pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); - if (!pools[i]) - 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); - kfree(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,156 +312,6 @@ 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; - - desc->bd_enc_iov = kcalloc(desc->bd_iov_count, - sizeof(*desc->bd_enc_iov), GFP_NOFS); - 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; @@ -651,41 +356,6 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc) } 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); @@ -725,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; @@ -768,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, @@ -778,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, @@ -789,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]); @@ -871,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/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index e7f2f3332..7ff948fe1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/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; @@ -180,7 +159,7 @@ 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; @@ -234,9 +213,8 @@ 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)); @@ -246,12 +224,11 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset) 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; @@ -280,22 +257,24 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset) 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) { @@ -306,8 +285,8 @@ 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; @@ -391,17 +370,16 @@ 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; @@ -428,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 * @@ -836,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) /** @@ -871,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); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index cdad608bd..6e58d5f95 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/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,16 +137,16 @@ 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 ptlrpc_thread *thread = arg; struct l_wait_info lwi; unshare_fs_struct(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index 68fcac14b..bda9a77af 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -98,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) @@ -130,6 +131,7 @@ 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) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index ce1c563d0..ebfa6092b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/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); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index a243db60f..f448b4567 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/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; diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 003344ccf..f45898f17 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -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); @@ -86,8 +85,10 @@ 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) { kfree(rqbd); return NULL; @@ -141,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. */ @@ -177,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 { @@ -244,31 +217,9 @@ 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. */ @@ -294,76 +245,6 @@ ptlrpc_hr_select(struct ptlrpc_service_part *svcpt) return &hrp->hrp_thrs[rotor % hrp->hrp_nthrs]; } -/** - * 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 @@ -401,32 +282,6 @@ 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) { @@ -647,7 +502,9 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, if (array->paa_reqs_count == NULL) goto free_reqs_array; - cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt); + setup_timer(&svcpt->scp_at_timer, ptlrpc_at_timer, + (unsigned long)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); @@ -856,7 +713,7 @@ 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; @@ -960,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. @@ -1024,82 +852,6 @@ static void ptlrpc_server_finish_active_request( ptlrpc_server_finish_request(svcpt, req); } -/** - * 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. @@ -1126,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)) { @@ -1153,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); } @@ -1189,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. */ @@ -1248,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 @@ -1276,36 +1026,22 @@ 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) @@ -1388,8 +1124,8 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) struct ptlrpc_request *rq, *n; struct list_head work_list; __u32 index, count; - time_t deadline; - time_t now = get_seconds(); + time64_t deadline; + time64_t now = ktime_get_real_seconds(); long delay; int first, counter = 0; @@ -1419,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]; @@ -1461,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); @@ -1546,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) { @@ -1638,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 */ @@ -1828,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) & @@ -1876,9 +1588,12 @@ 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; + 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; @@ -1901,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, @@ -1933,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; } @@ -1969,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 ? @@ -1992,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), @@ -2003,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: @@ -2128,7 +1846,6 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) return 1; } - static void ptlrpc_check_rqbd_pool(struct ptlrpc_service_part *svcpt) { @@ -2155,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; @@ -2262,7 +1979,7 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, */ static int ptlrpc_main(void *arg) { - struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; + 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; @@ -2464,7 +2181,7 @@ 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_thread *hrt = arg; struct ptlrpc_hr_partition *hrp = hrt->hrt_partition; LIST_HEAD (replies); char threadname[20]; @@ -2538,6 +2255,7 @@ static int ptlrpc_start_hr_threads(void) 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", @@ -2609,7 +2327,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) /** * 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; @@ -2619,7 +2337,6 @@ void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) ptlrpc_svcpt_stop_threads(svcpt); } } -EXPORT_SYMBOL(ptlrpc_stop_all_threads); int ptlrpc_start_threads(struct ptlrpc_service *svc) { @@ -2833,7 +2550,6 @@ void ptlrpc_hr_fini(void) ptlrpc_hr.hr_partitions = NULL; } - /** * Wait until all already scheduled replies are processed. */ @@ -2862,7 +2578,7 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc) /* 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); } } @@ -3002,7 +2718,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc) 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; kfree(array->paa_reqs_array); @@ -3045,61 +2761,3 @@ int ptlrpc_unregister_service(struct ptlrpc_service *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. */ -static 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/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index d6d92046c..40f720ca3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/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); -- cgit v1.2.3