diff options
Diffstat (limited to 'drivers/staging/lustre')
119 files changed, 1957 insertions, 1634 deletions
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h index 8f34c5ddc63e..3f773a4a344b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h @@ -53,16 +53,56 @@ enum cfs_crypto_hash_alg { }; static struct cfs_crypto_hash_type hash_types[] = { - [CFS_HASH_ALG_NULL] = { "null", 0, 0 }, - [CFS_HASH_ALG_ADLER32] = { "adler32", 1, 4 }, - [CFS_HASH_ALG_CRC32] = { "crc32", ~0, 4 }, - [CFS_HASH_ALG_CRC32C] = { "crc32c", ~0, 4 }, - [CFS_HASH_ALG_MD5] = { "md5", 0, 16 }, - [CFS_HASH_ALG_SHA1] = { "sha1", 0, 20 }, - [CFS_HASH_ALG_SHA256] = { "sha256", 0, 32 }, - [CFS_HASH_ALG_SHA384] = { "sha384", 0, 48 }, - [CFS_HASH_ALG_SHA512] = { "sha512", 0, 64 }, - [CFS_HASH_ALG_MAX] = { NULL, 0, 64 }, + [CFS_HASH_ALG_NULL] = { + .cht_name = "null", + .cht_key = 0, + .cht_size = 0 + }, + [CFS_HASH_ALG_ADLER32] = { + .cht_name = "adler32", + .cht_key = 1, + .cht_size = 4 + }, + [CFS_HASH_ALG_CRC32] = { + .cht_name = "crc32", + .cht_key = ~0, + .cht_size = 4 + }, + [CFS_HASH_ALG_CRC32C] = { + .cht_name = "crc32c", + .cht_key = ~0, + .cht_size = 4 + }, + [CFS_HASH_ALG_MD5] = { + .cht_name = "md5", + .cht_key = 0, + .cht_size = 16 + }, + [CFS_HASH_ALG_SHA1] = { + .cht_name = "sha1", + .cht_key = 0, + .cht_size = 20 + }, + [CFS_HASH_ALG_SHA256] = { + .cht_name = "sha256", + .cht_key = 0, + .cht_size = 32 + }, + [CFS_HASH_ALG_SHA384] = { + .cht_name = "sha384", + .cht_key = 0, + .cht_size = 48 + }, + [CFS_HASH_ALG_SHA512] = { + .cht_name = "sha512", + .cht_key = 0, + .cht_size = 64 + }, + [CFS_HASH_ALG_MAX] = { + .cht_name = NULL, + .cht_key = 0, + .cht_size = 64 + }, }; /* Maximum size of hash_types[].cht_size */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index aab15d8112a4..2dae85798ec1 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -277,22 +277,6 @@ do { \ #define CFS_ALLOC_PTR(ptr) LIBCFS_ALLOC(ptr, sizeof(*(ptr))) #define CFS_FREE_PTR(ptr) LIBCFS_FREE(ptr, sizeof(*(ptr))) -/** Compile-time assertion. - * - * Check an invariant described by a constant expression at compile time by - * forcing a compiler error if it does not hold. \a cond must be a constant - * expression as defined by the ISO C Standard: - * - * 6.8.4.2 The switch statement - * .... - * [#3] The expression of each case label shall be an integer - * constant expression and no two of the case constant - * expressions in the same switch statement shall have the same - * value after conversion... - * - */ -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) - /* max value for numeric network address */ #define MAX_NUMERIC_VALUE 0xffffffff diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index e8695e4a39d1..fa0808d2953b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -125,10 +125,6 @@ do { \ #include <linux/capability.h> -/* long integer with size equal to pointer */ -typedef unsigned long ulong_ptr_t; -typedef long long_ptr_t; - #ifndef WITH_WATCHDOG #define WITH_WATCHDOG #endif diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index a59c5e99cbd3..3d19402ba728 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -78,7 +78,7 @@ static inline int lnet_is_route_alive(lnet_route_t *route) return route->lr_downis == 0; } -static inline int lnet_is_wire_handle_none(lnet_handle_wire_t *wh) +static inline int lnet_is_wire_handle_none(struct lnet_handle_wire *wh) { return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE && wh->wh_object_cookie == LNET_WIRE_HANDLE_COOKIE_NONE); @@ -323,7 +323,7 @@ lnet_handle2md(lnet_handle_md_t *handle) } static inline lnet_libmd_t * -lnet_wire_handle2md(lnet_handle_wire_t *wh) +lnet_wire_handle2md(struct lnet_handle_wire *wh) { /* ALWAYS called with resource lock held */ lnet_libhandle_t *lh; @@ -552,7 +552,7 @@ int lnet_portals_create(void); void lnet_portals_destroy(void); /* message functions */ -int lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, +int lnet_parse(lnet_ni_t *ni, struct lnet_hdr *hdr, lnet_nid_t fromnid, void *private, int rdma_req); int lnet_parse_local(lnet_ni_t *ni, lnet_msg_t *msg); int lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg); @@ -579,7 +579,7 @@ void lnet_msg_containers_destroy(void); int lnet_msg_containers_create(void); char *lnet_msgtyp2str(int type); -void lnet_print_hdr(lnet_hdr_t *hdr); +void lnet_print_hdr(struct lnet_hdr *hdr); int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold); /** \addtogroup lnet_fault_simulation @{ */ @@ -588,7 +588,7 @@ int lnet_fault_ctl(int cmd, struct libcfs_ioctl_data *data); int lnet_fault_init(void); void lnet_fault_fini(void); -bool lnet_drop_rule_match(lnet_hdr_t *hdr); +bool lnet_drop_rule_match(struct lnet_hdr *hdr); int lnet_delay_rule_add(struct lnet_fault_attr *attr); int lnet_delay_rule_del(lnet_nid_t src, lnet_nid_t dst, bool shutdown); @@ -596,7 +596,7 @@ int lnet_delay_rule_list(int pos, struct lnet_fault_attr *attr, struct lnet_fault_stat *stat); void lnet_delay_rule_reset(void); void lnet_delay_rule_check(void); -bool lnet_delay_rule_match_locked(lnet_hdr_t *hdr, struct lnet_msg *msg); +bool lnet_delay_rule_match_locked(struct lnet_hdr *hdr, struct lnet_msg *msg); /** @} lnet_fault_simulation */ @@ -664,7 +664,7 @@ int lnet_peer_buffer_credits(lnet_ni_t *ni); int lnet_router_checker_start(void); void lnet_router_checker_stop(void); void lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net); -void lnet_swap_pinginfo(lnet_ping_info_t *info); +void lnet_swap_pinginfo(struct lnet_ping_info *info); int lnet_parse_ip2nets(char **networksp, char *ip2nets); int lnet_parse_routes(char *route_str, int *im_a_router); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index b84a5bb9186c..9850398bf29a 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -105,7 +105,7 @@ typedef struct lnet_msg { lnet_kiov_t *msg_kiov; lnet_event_t msg_ev; - lnet_hdr_t msg_hdr; + struct lnet_hdr msg_hdr; } lnet_msg_t; typedef struct lnet_libhandle { @@ -270,7 +270,7 @@ typedef struct lnet_ni { struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */ int **ni_refs; /* percpt reference count */ time64_t ni_last_alive;/* when I was last alive */ - lnet_ni_status_t *ni_status; /* my health status */ + struct lnet_ni_status *ni_status; /* my health status */ /* per NI LND tunables */ struct lnet_ioctl_config_lnd_tunables *ni_lnd_tunables; /* equivalent interfaces to use */ @@ -295,13 +295,13 @@ typedef struct lnet_ni { /* router checker data, per router */ #define LNET_MAX_RTR_NIS 16 -#define LNET_PINGINFO_SIZE offsetof(lnet_ping_info_t, pi_ni[LNET_MAX_RTR_NIS]) +#define LNET_PINGINFO_SIZE offsetof(struct lnet_ping_info, pi_ni[LNET_MAX_RTR_NIS]) typedef struct { /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */ struct list_head rcd_list; lnet_handle_md_t rcd_mdh; /* ping buffer MD */ struct lnet_peer *rcd_gateway; /* reference to gateway */ - lnet_ping_info_t *rcd_pinginfo; /* ping buffer */ + struct lnet_ping_info *rcd_pinginfo; /* ping buffer */ } lnet_rc_data_t; typedef struct lnet_peer { @@ -599,7 +599,7 @@ typedef struct { lnet_handle_md_t ln_ping_target_md; lnet_handle_eq_t ln_ping_target_eq; - lnet_ping_info_t *ln_ping_info; + struct lnet_ping_info *ln_ping_info; /* router checker startup/shutdown state */ int ln_rc_state; diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index 8a84888635ff..c81c246ef221 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -68,16 +68,16 @@ #define LSTIO_BATCH_QUERY 0xC27 /* query batch status */ #define LSTIO_STAT_QUERY 0xC30 /* get stats */ -typedef struct { +struct lst_sid { lnet_nid_t ses_nid; /* nid of console node */ __u64 ses_stamp; /* time stamp */ -} lst_sid_t; /*** session id */ +}; /*** session id */ -extern lst_sid_t LST_INVALID_SID; +extern struct lst_sid LST_INVALID_SID; -typedef struct { +struct lst_bid { __u64 bat_id; /* unique id in session */ -} lst_bid_t; /*** batch id (group of tests) */ +}; /*** batch id (group of tests) */ /* Status of test node */ #define LST_NODE_ACTIVE 0x1 /* node in this session */ @@ -85,59 +85,59 @@ typedef struct { #define LST_NODE_DOWN 0x4 /* node is down */ #define LST_NODE_UNKNOWN 0x8 /* node not in session */ -typedef struct { +struct lstcon_node_ent { lnet_process_id_t nde_id; /* id of node */ int nde_state; /* state of node */ -} lstcon_node_ent_t; /*** node entry, for list_group command */ +}; /*** node entry, for list_group command */ -typedef struct { +struct lstcon_ndlist_ent { int nle_nnode; /* # of nodes */ int nle_nactive; /* # of active nodes */ int nle_nbusy; /* # of busy nodes */ int nle_ndown; /* # of down nodes */ int nle_nunknown; /* # of unknown nodes */ -} lstcon_ndlist_ent_t; /*** node_list entry, for list_batch command */ +}; /*** node_list entry, for list_batch command */ -typedef struct { +struct lstcon_test_ent { int tse_type; /* test type */ int tse_loop; /* loop count */ int tse_concur; /* concurrency of test */ -} lstcon_test_ent_t; /*** test summary entry, for +}; /*** test summary entry, for *** list_batch command */ -typedef struct { +struct lstcon_batch_ent { int bae_state; /* batch status */ int bae_timeout; /* batch timeout */ int bae_ntest; /* # of tests in the batch */ -} lstcon_batch_ent_t; /*** batch summary entry, for +}; /*** batch summary entry, for *** list_batch command */ -typedef struct { - lstcon_ndlist_ent_t tbe_cli_nle; /* client (group) node_list +struct lstcon_test_batch_ent { + struct lstcon_ndlist_ent tbe_cli_nle; /* client (group) node_list * entry */ - lstcon_ndlist_ent_t tbe_srv_nle; /* server (group) node_list + struct lstcon_ndlist_ent tbe_srv_nle; /* server (group) node_list * entry */ union { - lstcon_test_ent_t tbe_test; /* test entry */ - lstcon_batch_ent_t tbe_batch; /* batch entry */ + struct lstcon_test_ent tbe_test; /* test entry */ + struct lstcon_batch_ent tbe_batch;/* batch entry */ } u; -} lstcon_test_batch_ent_t; /*** test/batch verbose information entry, +}; /*** test/batch verbose information entry, *** for list_batch command */ -typedef struct { +struct lstcon_rpc_ent { struct list_head rpe_link; /* link chain */ lnet_process_id_t rpe_peer; /* peer's id */ struct timeval rpe_stamp; /* time stamp of RPC */ int rpe_state; /* peer's state */ int rpe_rpc_errno; /* RPC errno */ - lst_sid_t rpe_sid; /* peer's session id */ + struct lst_sid rpe_sid; /* peer's session id */ int rpe_fwk_errno; /* framework errno */ int rpe_priv[4]; /* private data */ char rpe_payload[0]; /* private reply payload */ -} lstcon_rpc_ent_t; +}; -typedef struct { +struct lstcon_trans_stat { int trs_rpc_stat[4]; /* RPCs stat (0: total 1: failed 2: finished @@ -146,125 +146,125 @@ typedef struct { int trs_fwk_stat[8]; /* framework stat */ int trs_fwk_errno; /* errno of the first remote error */ void *trs_fwk_private; /* private framework stat */ -} lstcon_trans_stat_t; +}; static inline int -lstcon_rpc_stat_total(lstcon_trans_stat_t *stat, int inc) +lstcon_rpc_stat_total(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_rpc_stat[0] : stat->trs_rpc_stat[0]; } static inline int -lstcon_rpc_stat_success(lstcon_trans_stat_t *stat, int inc) +lstcon_rpc_stat_success(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_rpc_stat[1] : stat->trs_rpc_stat[1]; } static inline int -lstcon_rpc_stat_failure(lstcon_trans_stat_t *stat, int inc) +lstcon_rpc_stat_failure(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_rpc_stat[2] : stat->trs_rpc_stat[2]; } static inline int -lstcon_sesop_stat_success(lstcon_trans_stat_t *stat, int inc) +lstcon_sesop_stat_success(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0]; } static inline int -lstcon_sesop_stat_failure(lstcon_trans_stat_t *stat, int inc) +lstcon_sesop_stat_failure(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1]; } static inline int -lstcon_sesqry_stat_active(lstcon_trans_stat_t *stat, int inc) +lstcon_sesqry_stat_active(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0]; } static inline int -lstcon_sesqry_stat_busy(lstcon_trans_stat_t *stat, int inc) +lstcon_sesqry_stat_busy(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1]; } static inline int -lstcon_sesqry_stat_unknown(lstcon_trans_stat_t *stat, int inc) +lstcon_sesqry_stat_unknown(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[2] : stat->trs_fwk_stat[2]; } static inline int -lstcon_tsbop_stat_success(lstcon_trans_stat_t *stat, int inc) +lstcon_tsbop_stat_success(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0]; } static inline int -lstcon_tsbop_stat_failure(lstcon_trans_stat_t *stat, int inc) +lstcon_tsbop_stat_failure(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1]; } static inline int -lstcon_tsbqry_stat_idle(lstcon_trans_stat_t *stat, int inc) +lstcon_tsbqry_stat_idle(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0]; } static inline int -lstcon_tsbqry_stat_run(lstcon_trans_stat_t *stat, int inc) +lstcon_tsbqry_stat_run(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1]; } static inline int -lstcon_tsbqry_stat_failure(lstcon_trans_stat_t *stat, int inc) +lstcon_tsbqry_stat_failure(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[2] : stat->trs_fwk_stat[2]; } static inline int -lstcon_statqry_stat_success(lstcon_trans_stat_t *stat, int inc) +lstcon_statqry_stat_success(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0]; } static inline int -lstcon_statqry_stat_failure(lstcon_trans_stat_t *stat, int inc) +lstcon_statqry_stat_failure(struct lstcon_trans_stat *stat, int inc) { return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1]; } /* create a session */ -typedef struct { +struct lstio_session_new_args { int lstio_ses_key; /* IN: local key */ int lstio_ses_timeout; /* IN: session timeout */ int lstio_ses_force; /* IN: force create ? */ /** IN: session features */ unsigned int lstio_ses_feats; - lst_sid_t __user *lstio_ses_idp; /* OUT: session id */ + struct lst_sid __user *lstio_ses_idp; /* OUT: session id */ int lstio_ses_nmlen; /* IN: name length */ char __user *lstio_ses_namep; /* IN: session name */ -} lstio_session_new_args_t; +}; /* query current session */ -typedef struct { - lst_sid_t __user *lstio_ses_idp; /* OUT: session id */ +struct lstio_session_info_args { + struct lst_sid __user *lstio_ses_idp; /* OUT: session id */ int __user *lstio_ses_keyp; /* OUT: local key */ /** OUT: session features */ unsigned int __user *lstio_ses_featp; - lstcon_ndlist_ent_t __user *lstio_ses_ndinfo; /* OUT: */ + struct lstcon_ndlist_ent __user *lstio_ses_ndinfo;/* OUT: */ int lstio_ses_nmlen; /* IN: name length */ char __user *lstio_ses_namep; /* OUT: session name */ -} lstio_session_info_args_t; +}; /* delete a session */ -typedef struct { +struct lstio_session_end_args { int lstio_ses_key; /* IN: session key */ -} lstio_session_end_args_t; +}; #define LST_OPC_SESSION 1 #define LST_OPC_GROUP 2 @@ -272,7 +272,7 @@ typedef struct { #define LST_OPC_BATCHCLI 4 #define LST_OPC_BATCHSRV 5 -typedef struct { +struct lstio_debug_args { int lstio_dbg_key; /* IN: session key */ int lstio_dbg_type; /* IN: debug session|batch| @@ -291,26 +291,26 @@ typedef struct { nodes */ struct list_head __user *lstio_dbg_resultp; /* OUT: list head of result buffer */ -} lstio_debug_args_t; +}; -typedef struct { +struct lstio_group_add_args { int lstio_grp_key; /* IN: session key */ int lstio_grp_nmlen; /* IN: name length */ char __user *lstio_grp_namep; /* IN: group name */ -} lstio_group_add_args_t; +}; -typedef struct { +struct lstio_group_del_args { int lstio_grp_key; /* IN: session key */ int lstio_grp_nmlen; /* IN: name length */ char __user *lstio_grp_namep; /* IN: group name */ -} lstio_group_del_args_t; +}; #define LST_GROUP_CLEAN 1 /* remove inactive nodes in the group */ #define LST_GROUP_REFRESH 2 /* refresh inactive nodes * in the group */ #define LST_GROUP_RMND 3 /* delete nodes from the group */ -typedef struct { +struct lstio_group_update_args { int lstio_grp_key; /* IN: session key */ int lstio_grp_opc; /* IN: OPC */ int lstio_grp_args; /* IN: arguments */ @@ -320,9 +320,9 @@ typedef struct { lnet_process_id_t __user *lstio_grp_idsp; /* IN: array of nodes */ struct list_head __user *lstio_grp_resultp; /* OUT: list head of result buffer */ -} lstio_group_update_args_t; +}; -typedef struct { +struct lstio_group_nodes_args { int lstio_grp_key; /* IN: session key */ int lstio_grp_nmlen; /* IN: name length */ char __user *lstio_grp_namep; /* IN: group name */ @@ -332,41 +332,41 @@ typedef struct { lnet_process_id_t __user *lstio_grp_idsp; /* IN: nodes */ struct list_head __user *lstio_grp_resultp; /* OUT: list head of result buffer */ -} lstio_group_nodes_args_t; +}; -typedef struct { +struct lstio_group_list_args { int lstio_grp_key; /* IN: session key */ int lstio_grp_idx; /* IN: group idx */ int lstio_grp_nmlen; /* IN: name len */ char __user *lstio_grp_namep; /* OUT: name */ -} lstio_group_list_args_t; +}; -typedef struct { +struct lstio_group_info_args { int lstio_grp_key; /* IN: session key */ int lstio_grp_nmlen; /* IN: name len */ char __user *lstio_grp_namep; /* IN: name */ - lstcon_ndlist_ent_t __user *lstio_grp_entp; /* OUT: description of - group */ + struct lstcon_ndlist_ent __user *lstio_grp_entp;/* OUT: description of + group */ int __user *lstio_grp_idxp; /* IN/OUT: node index */ int __user *lstio_grp_ndentp; /* IN/OUT: # of nodent */ - lstcon_node_ent_t __user *lstio_grp_dentsp; /* OUT: nodent array */ -} lstio_group_info_args_t; + struct lstcon_node_ent __user *lstio_grp_dentsp;/* OUT: nodent array */ +}; #define LST_DEFAULT_BATCH "batch" /* default batch name */ -typedef struct { +struct lstio_batch_add_args { int lstio_bat_key; /* IN: session key */ int lstio_bat_nmlen; /* IN: name length */ char __user *lstio_bat_namep; /* IN: batch name */ -} lstio_batch_add_args_t; +}; -typedef struct { +struct lstio_batch_del_args { int lstio_bat_key; /* IN: session key */ int lstio_bat_nmlen; /* IN: name length */ char __user *lstio_bat_namep; /* IN: batch name */ -} lstio_batch_del_args_t; +}; -typedef struct { +struct lstio_batch_run_args { int lstio_bat_key; /* IN: session key */ int lstio_bat_timeout; /* IN: timeout for the batch */ @@ -374,9 +374,9 @@ typedef struct { char __user *lstio_bat_namep; /* IN: batch name */ struct list_head __user *lstio_bat_resultp; /* OUT: list head of result buffer */ -} lstio_batch_run_args_t; +}; -typedef struct { +struct lstio_batch_stop_args { int lstio_bat_key; /* IN: session key */ int lstio_bat_force; /* IN: abort unfinished test RPC */ @@ -384,9 +384,9 @@ typedef struct { char __user *lstio_bat_namep; /* IN: batch name */ struct list_head __user *lstio_bat_resultp; /* OUT: list head of result buffer */ -} lstio_batch_stop_args_t; +}; -typedef struct { +struct lstio_batch_query_args { int lstio_bat_key; /* IN: session key */ int lstio_bat_testidx; /* IN: test index */ int lstio_bat_client; /* IN: we testing @@ -397,31 +397,31 @@ typedef struct { char __user *lstio_bat_namep; /* IN: batch name */ struct list_head __user *lstio_bat_resultp; /* OUT: list head of result buffer */ -} lstio_batch_query_args_t; +}; -typedef struct { +struct lstio_batch_list_args { int lstio_bat_key; /* IN: session key */ int lstio_bat_idx; /* IN: index */ int lstio_bat_nmlen; /* IN: name length */ char __user *lstio_bat_namep; /* IN: batch name */ -} lstio_batch_list_args_t; +}; -typedef struct { +struct lstio_batch_info_args { int lstio_bat_key; /* IN: session key */ int lstio_bat_nmlen; /* IN: name length */ char __user *lstio_bat_namep; /* IN: name */ int lstio_bat_server; /* IN: query server or not */ int lstio_bat_testidx; /* IN: test index */ - lstcon_test_batch_ent_t __user *lstio_bat_entp; /* OUT: batch ent */ + struct lstcon_test_batch_ent __user *lstio_bat_entp;/* OUT: batch ent */ int __user *lstio_bat_idxp; /* IN/OUT: index of node */ int __user *lstio_bat_ndentp; /* IN/OUT: # of nodent */ - lstcon_node_ent_t __user *lstio_bat_dentsp; /* array of nodent */ -} lstio_batch_info_args_t; + struct lstcon_node_ent __user *lstio_bat_dentsp;/* array of nodent */ +}; /* add stat in session */ -typedef struct { +struct lstio_stat_args { int lstio_sta_key; /* IN: session key */ int lstio_sta_timeout; /* IN: timeout for stat request */ @@ -432,17 +432,17 @@ typedef struct { lnet_process_id_t __user *lstio_sta_idsp; /* IN: pid */ struct list_head __user *lstio_sta_resultp; /* OUT: list head of result buffer */ -} lstio_stat_args_t; +}; -typedef enum { +enum lst_test_type { LST_TEST_BULK = 1, LST_TEST_PING = 2 -} lst_test_type_t; +}; /* create a test in a batch */ #define LST_MAX_CONCUR 1024 /* Max concurrency of test */ -typedef struct { +struct lstio_test_args { int lstio_tes_key; /* IN: session key */ int lstio_tes_bat_nmlen; /* IN: batch name len */ char __user *lstio_tes_bat_name; /* IN: batch name */ @@ -472,36 +472,36 @@ typedef struct { value */ struct list_head __user *lstio_tes_resultp;/* OUT: list head of result buffer */ -} lstio_test_args_t; +}; -typedef enum { +enum lst_brw_type { LST_BRW_READ = 1, LST_BRW_WRITE = 2 -} lst_brw_type_t; +}; -typedef enum { +enum lst_brw_flags { LST_BRW_CHECK_NONE = 1, LST_BRW_CHECK_SIMPLE = 2, LST_BRW_CHECK_FULL = 3 -} lst_brw_flags_t; +}; -typedef struct { +struct lst_test_bulk_param { int blk_opc; /* bulk operation code */ int blk_size; /* size (bytes) */ int blk_time; /* time of running the test*/ int blk_flags; /* reserved flags */ int blk_cli_off; /* bulk offset on client */ int blk_srv_off; /* reserved: bulk offset on server */ -} lst_test_bulk_param_t; +}; -typedef struct { +struct lst_test_ping_param { int png_size; /* size of ping message */ int png_time; /* time */ int png_loop; /* loop */ int png_flags; /* reserved flags */ -} lst_test_ping_param_t; +}; -typedef struct { +struct srpc_counters { __u32 errors; __u32 rpcs_sent; __u32 rpcs_rcvd; @@ -509,15 +509,15 @@ typedef struct { __u32 rpcs_expired; __u64 bulk_get; __u64 bulk_put; -} WIRE_ATTR srpc_counters_t; +} WIRE_ATTR; -typedef struct { +struct sfw_counters { /** milliseconds since current session started */ __u32 running_ms; __u32 active_batches; __u32 zombie_sessions; __u32 brw_errors; __u32 ping_errors; -} WIRE_ATTR sfw_counters_t; +} WIRE_ATTR; #endif diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h index bc32403f4a08..acf20ce6f403 100644 --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h @@ -60,7 +60,7 @@ typedef struct { } WIRE_ATTR ksock_hello_msg_t; typedef struct { - lnet_hdr_t ksnm_hdr; /* lnet hdr */ + struct lnet_hdr ksnm_hdr; /* lnet hdr */ /* * ksnm_payload is removed because of winnt compiler's limitation: @@ -80,15 +80,6 @@ typedef struct { } WIRE_ATTR ksm_u; } WIRE_ATTR ksock_msg_t; -static inline void -socklnd_init_msg(ksock_msg_t *msg, int type) -{ - msg->ksm_csum = 0; - msg->ksm_type = type; - msg->ksm_zc_cookies[0] = 0; - msg->ksm_zc_cookies[1] = 0; -} - #define KSOCK_MSG_NOOP 0xC0 /* ksm_u empty */ #define KSOCK_MSG_LNET 0xC1 /* lnet msg */ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 8ca1e9d0cfe2..1c8de72e6d6b 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -115,11 +115,11 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num) #define WIRE_ATTR __packed /* Packed version of lnet_process_id_t to transfer via network */ -typedef struct { +struct lnet_process_id_packed { /* node id / process id */ lnet_nid_t nid; lnet_pid_t pid; -} WIRE_ATTR lnet_process_id_packed_t; +} WIRE_ATTR; /* * The wire handle's interface cookie only matches one network interface in @@ -127,10 +127,10 @@ typedef struct { * reboots). The object cookie only matches one object on that interface * during that object's lifetime (i.e. no cookie re-use). */ -typedef struct { +struct lnet_handle_wire { __u64 wh_interface_cookie; __u64 wh_object_cookie; -} WIRE_ATTR lnet_handle_wire_t; +} WIRE_ATTR; typedef enum { LNET_MSG_ACK = 0, @@ -146,38 +146,38 @@ typedef enum { * wire structs MUST be fixed size and the smaller types are placed at the * end. */ -typedef struct lnet_ack { - lnet_handle_wire_t dst_wmd; +struct lnet_ack { + struct lnet_handle_wire dst_wmd; __u64 match_bits; __u32 mlength; -} WIRE_ATTR lnet_ack_t; +} WIRE_ATTR; -typedef struct lnet_put { - lnet_handle_wire_t ack_wmd; +struct lnet_put { + struct lnet_handle_wire ack_wmd; __u64 match_bits; __u64 hdr_data; __u32 ptl_index; __u32 offset; -} WIRE_ATTR lnet_put_t; +} WIRE_ATTR; -typedef struct lnet_get { - lnet_handle_wire_t return_wmd; +struct lnet_get { + struct lnet_handle_wire return_wmd; __u64 match_bits; __u32 ptl_index; __u32 src_offset; __u32 sink_length; -} WIRE_ATTR lnet_get_t; +} WIRE_ATTR; -typedef struct lnet_reply { - lnet_handle_wire_t dst_wmd; -} WIRE_ATTR lnet_reply_t; +struct lnet_reply { + struct lnet_handle_wire dst_wmd; +} WIRE_ATTR; -typedef struct lnet_hello { +struct lnet_hello { __u64 incarnation; __u32 type; -} WIRE_ATTR lnet_hello_t; +} WIRE_ATTR; -typedef struct { +struct lnet_hdr { lnet_nid_t dest_nid; lnet_nid_t src_nid; lnet_pid_t dest_pid; @@ -186,13 +186,13 @@ typedef struct { __u32 payload_length; /* payload data to follow */ /*<------__u64 aligned------->*/ union { - lnet_ack_t ack; - lnet_put_t put; - lnet_get_t get; - lnet_reply_t reply; - lnet_hello_t hello; + struct lnet_ack ack; + struct lnet_put put; + struct lnet_get get; + struct lnet_reply reply; + struct lnet_hello hello; } msg; -} WIRE_ATTR lnet_hdr_t; +} WIRE_ATTR; /* * A HELLO message contains a magic number and protocol version @@ -202,13 +202,13 @@ typedef struct { * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is * running the same protocol and to find out its NID. These LNDs should * exchange HELLO messages when a connection is first established. Individual - * LNDs can put whatever else they fancy in lnet_hdr_t::msg. + * LNDs can put whatever else they fancy in struct lnet_hdr::msg. */ -typedef struct { +struct lnet_magicversion { __u32 magic; /* LNET_PROTO_TCP_MAGIC */ __u16 version_major; /* increment on incompatible change */ __u16 version_minor; /* increment on compatible change */ -} WIRE_ATTR lnet_magicversion_t; +} WIRE_ATTR; /* PROTO MAGIC for LNDs */ #define LNET_PROTO_IB_MAGIC 0x0be91b91 @@ -228,27 +228,27 @@ typedef struct { #define LNET_PROTO_TCP_VERSION_MINOR 0 /* Acceptor connection request */ -typedef struct { +struct lnet_acceptor_connreq { __u32 acr_magic; /* PTL_ACCEPTOR_PROTO_MAGIC */ __u32 acr_version; /* protocol version */ __u64 acr_nid; /* target NID */ -} WIRE_ATTR lnet_acceptor_connreq_t; +} WIRE_ATTR; #define LNET_PROTO_ACCEPTOR_VERSION 1 -typedef struct { +struct lnet_ni_status { lnet_nid_t ns_nid; __u32 ns_status; __u32 ns_unused; -} WIRE_ATTR lnet_ni_status_t; +} WIRE_ATTR; -typedef struct { +struct lnet_ping_info { __u32 pi_magic; __u32 pi_features; lnet_pid_t pi_pid; __u32 pi_nnis; - lnet_ni_status_t pi_ni[0]; -} WIRE_ATTR lnet_ping_info_t; + struct lnet_ni_status pi_ni[0]; +} WIRE_ATTR; typedef struct lnet_counters { __u32 msgs_alloc; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 7f761b327166..b1e8508f9fc7 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -258,8 +258,8 @@ int kiblnd_unpack_msg(struct kib_msg *msg, int nob) if (flip) { /* leave magic unflipped as a clue to peer endianness */ msg->ibm_version = version; - CLASSERT(sizeof(msg->ibm_type) == 1); - CLASSERT(sizeof(msg->ibm_credits) == 1); + BUILD_BUG_ON(sizeof(msg->ibm_type) != 1); + BUILD_BUG_ON(sizeof(msg->ibm_credits) != 1); msg->ibm_nob = msg_nob; __swab64s(&msg->ibm_srcnid); __swab64s(&msg->ibm_srcstamp); @@ -1247,10 +1247,10 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) dev = net->ibn_dev; /* pre-mapped messages are not bigger than 1 page */ - CLASSERT(IBLND_MSG_SIZE <= PAGE_SIZE); + BUILD_BUG_ON(IBLND_MSG_SIZE > PAGE_SIZE); /* No fancy arithmetic when we do the buffer calculations */ - CLASSERT(!(PAGE_SIZE % IBLND_MSG_SIZE)); + BUILD_BUG_ON(PAGE_SIZE % IBLND_MSG_SIZE); tpo->tpo_hdev = kiblnd_current_hdev(dev); @@ -2943,7 +2943,7 @@ static int kiblnd_startup(lnet_ni_t *ni) if (ni->ni_interfaces[0]) { /* Use the IPoIB interface specified in 'networks=' */ - CLASSERT(LNET_MAX_INTERFACES > 1); + BUILD_BUG_ON(LNET_MAX_INTERFACES <= 1); if (ni->ni_interfaces[1]) { CERROR("Multiple interfaces not supported\n"); goto failed; @@ -3020,11 +3020,11 @@ static void __exit ko2iblnd_exit(void) static int __init ko2iblnd_init(void) { - CLASSERT(sizeof(struct kib_msg) <= IBLND_MSG_SIZE); - CLASSERT(offsetof(struct kib_msg, + BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); + BUILD_BUG_ON(!offsetof(struct kib_msg, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) <= IBLND_MSG_SIZE); - CLASSERT(offsetof(struct kib_msg, + BUILD_BUG_ON(!offsetof(struct kib_msg, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) <= IBLND_MSG_SIZE); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 14576977200f..2cb429830681 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -364,7 +364,7 @@ struct kib_connparams { } WIRE_ATTR; struct kib_immediate_msg { - lnet_hdr_t ibim_hdr; /* portals header */ + struct lnet_hdr ibim_hdr; /* portals header */ char ibim_payload[0]; /* piggy-backed payload */ } WIRE_ATTR; @@ -380,7 +380,7 @@ struct kib_rdma_desc { } WIRE_ATTR; struct kib_putreq_msg { - lnet_hdr_t ibprm_hdr; /* portals header */ + struct lnet_hdr ibprm_hdr; /* portals header */ __u64 ibprm_cookie; /* opaque completion cookie */ } WIRE_ATTR; @@ -391,7 +391,7 @@ struct kib_putack_msg { } WIRE_ATTR; struct kib_get_msg { - lnet_hdr_t ibgm_hdr; /* portals header */ + struct lnet_hdr ibgm_hdr; /* portals header */ __u64 ibgm_cookie; /* opaque completion cookie */ struct kib_rdma_desc ibgm_rd; /* rdma descriptor */ } WIRE_ATTR; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index c7917abf9944..e2f3f7294260 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -1490,7 +1490,7 @@ kiblnd_launch_tx(lnet_ni_t *ni, struct kib_tx *tx, lnet_nid_t nid) int kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) { - lnet_hdr_t *hdr = &lntmsg->msg_hdr; + struct lnet_hdr *hdr = &lntmsg->msg_hdr; int type = lntmsg->msg_type; lnet_process_id_t target = lntmsg->msg_target; int target_is_router = lntmsg->msg_target_is_router; @@ -3546,7 +3546,7 @@ kiblnd_scheduler(void *arg) rc = cfs_cpt_bind(lnet_cpt_table(), sched->ibs_cpt); if (rc) { - CWARN("Failed to bind on CPT %d, please verify whether all CPUs are healthy and reload modules if necessary, otherwise your system might under risk of low performance\n", + CWARN("Unable to bind on CPU partition %d, please verify whether all CPUs are healthy and reload modules if necessary, otherwise your system might under risk of low performance\n", sched->ibs_cpt); } diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index b74cf635faee..f25de3d7f6e8 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1108,12 +1108,12 @@ ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route, write_unlock_bh(global_lock); if (!conn->ksnc_proto) { - conn->ksnc_proto = &ksocknal_protocol_v3x; + conn->ksnc_proto = &ksocknal_protocol_v3x; #if SOCKNAL_VERSION_DEBUG - if (*ksocknal_tunables.ksnd_protocol == 2) - conn->ksnc_proto = &ksocknal_protocol_v2x; - else if (*ksocknal_tunables.ksnd_protocol == 1) - conn->ksnc_proto = &ksocknal_protocol_v1x; + if (*ksocknal_tunables.ksnd_protocol == 2) + conn->ksnc_proto = &ksocknal_protocol_v2x; + else if (*ksocknal_tunables.ksnd_protocol == 1) + conn->ksnc_proto = &ksocknal_protocol_v1x; #endif } @@ -2507,7 +2507,7 @@ ksocknal_base_startup(void) snprintf(name, sizeof(name), "socknal_cd%02d", i); rc = ksocknal_thread_start(ksocknal_connd, - (void *)((ulong_ptr_t)i), name); + (void *)((uintptr_t)i), name); if (rc) { spin_lock_bh(&ksocknal_data.ksnd_connd_lock); ksocknal_data.ksnd_connd_starting--; @@ -2904,8 +2904,8 @@ static int __init ksocklnd_init(void) int rc; /* check ksnr_connected/connecting field large enough */ - CLASSERT(SOCKLND_CONN_NTYPES <= 4); - CLASSERT(SOCKLND_CONN_ACK == SOCKLND_CONN_BULK_IN); + BUILD_BUG_ON(SOCKLND_CONN_NTYPES > 4); + BUILD_BUG_ON(SOCKLND_CONN_ACK != SOCKLND_CONN_BULK_IN); /* initialize the_ksocklnd */ the_ksocklnd.lnd_type = SOCKLND; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 842c45393b38..9e86563b8c70 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -373,7 +373,7 @@ struct ksock_conn { * V2.x message takes the * whole struct * V1.x message is a bare - * lnet_hdr_t, it's stored in + * struct lnet_hdr, it's stored in * ksnc_msg.ksm_u.lnetmsg */ /* WRITER */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 972f6094be75..4c9f92725a44 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -80,7 +80,9 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk) tx->tx_niov = 1; tx->tx_nonblk = nonblk; - socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP); + tx->tx_msg.ksm_csum = 0; + tx->tx_msg.ksm_type = KSOCK_MSG_NOOP; + tx->tx_msg.ksm_zc_cookies[0] = 0; tx->tx_msg.ksm_zc_cookies[1] = cookie; return tx; @@ -1004,7 +1006,10 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) tx->tx_zc_capable = 1; } - socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_LNET); + tx->tx_msg.ksm_csum = 0; + tx->tx_msg.ksm_type = KSOCK_MSG_LNET; + tx->tx_msg.ksm_zc_cookies[0] = 0; + tx->tx_msg.ksm_zc_cookies[1] = 0; /* The first fragment will be set later in pro_pack */ rc = ksocknal_launch_packet(ni, tx, target); @@ -1073,14 +1078,14 @@ ksocknal_new_packet(struct ksock_conn *conn, int nob_to_skip) break; case KSOCK_PROTO_V1: - /* Receiving bare lnet_hdr_t */ + /* Receiving bare struct lnet_hdr */ conn->ksnc_rx_state = SOCKNAL_RX_LNET_HEADER; - conn->ksnc_rx_nob_wanted = sizeof(lnet_hdr_t); - conn->ksnc_rx_nob_left = sizeof(lnet_hdr_t); + conn->ksnc_rx_nob_wanted = sizeof(struct lnet_hdr); + conn->ksnc_rx_nob_left = sizeof(struct lnet_hdr); conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space; conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg.ksm_u.lnetmsg; - conn->ksnc_rx_iov[0].iov_len = sizeof(lnet_hdr_t); + conn->ksnc_rx_iov[0].iov_len = sizeof(struct lnet_hdr); break; default: @@ -1126,7 +1131,7 @@ ksocknal_new_packet(struct ksock_conn *conn, int nob_to_skip) static int ksocknal_process_receive(struct ksock_conn *conn) { - lnet_hdr_t *lhdr; + struct lnet_hdr *lhdr; lnet_process_id_t *id; int rc; @@ -1414,8 +1419,8 @@ int ksocknal_scheduler(void *arg) rc = cfs_cpt_bind(lnet_cpt_table(), info->ksi_cpt); if (rc) { - CERROR("Can't set CPT affinity to %d: %d\n", - info->ksi_cpt, rc); + CWARN("Can't set CPU partition affinity to %d: %d\n", + info->ksi_cpt, rc); } spin_lock_bh(&sched->kss_lock); @@ -1656,9 +1661,9 @@ ksocknal_parse_proto_version(ksock_hello_msg_t *hello) } if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) { - lnet_magicversion_t *hmv = (lnet_magicversion_t *)hello; + struct lnet_magicversion *hmv = (struct lnet_magicversion *)hello; - CLASSERT(sizeof(lnet_magicversion_t) == + BUILD_BUG_ON(sizeof(struct lnet_magicversion) != offsetof(ksock_hello_msg_t, kshm_src_nid)); if (hmv->version_major == cpu_to_le16(KSOCK_PROTO_V1_MAJOR) && @@ -2456,6 +2461,7 @@ ksocknal_check_peer_timeouts(int idx) list_for_each_entry(peer, peers, ksnp_list) { unsigned long deadline = 0; + struct ksock_tx *tx_stale; int resid = 0; int n = 0; @@ -2503,6 +2509,7 @@ ksocknal_check_peer_timeouts(int idx) if (list_empty(&peer->ksnp_zc_req_list)) continue; + tx_stale = NULL; spin_lock(&peer->ksnp_lock); list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) { if (!cfs_time_aftereq(cfs_time_current(), @@ -2511,26 +2518,26 @@ ksocknal_check_peer_timeouts(int idx) /* ignore the TX if connection is being closed */ if (tx->tx_conn->ksnc_closing) continue; + if (!tx_stale) + tx_stale = tx; n++; } - if (!n) { + if (!tx_stale) { spin_unlock(&peer->ksnp_lock); continue; } - tx = list_entry(peer->ksnp_zc_req_list.next, - struct ksock_tx, tx_zc_list); - deadline = tx->tx_deadline; - resid = tx->tx_resid; - conn = tx->tx_conn; + deadline = tx_stale->tx_deadline; + resid = tx_stale->tx_resid; + conn = tx_stale->tx_conn; ksocknal_conn_addref(conn); spin_unlock(&peer->ksnp_lock); read_unlock(&ksocknal_data.ksnd_global_lock); CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n", - n, libcfs_nid2str(peer->ksnp_id.nid), tx, + n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale, cfs_duration_sec(cfs_time_current() - deadline), resid, conn->ksnc_sock->sk->sk_wmem_queued); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index 8f0ff6ca1f39..d367e74d46c2 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -291,7 +291,7 @@ ksocknal_match_tx(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk) } else { nob = tx->tx_lnetmsg->msg_len + ((conn->ksnc_proto == &ksocknal_protocol_v1x) ? - sizeof(lnet_hdr_t) : sizeof(ksock_msg_t)); + sizeof(struct lnet_hdr) : sizeof(ksock_msg_t)); } /* default checking for typed connection */ @@ -459,23 +459,23 @@ static int ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello) { struct socket *sock = conn->ksnc_sock; - lnet_hdr_t *hdr; - lnet_magicversion_t *hmv; + struct lnet_hdr *hdr; + struct lnet_magicversion *hmv; int rc; int i; - CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid)); + BUILD_BUG_ON(sizeof(struct lnet_magicversion) != offsetof(struct lnet_hdr, src_nid)); LIBCFS_ALLOC(hdr, sizeof(*hdr)); if (!hdr) { - CERROR("Can't allocate lnet_hdr_t\n"); + CERROR("Can't allocate struct lnet_hdr\n"); return -ENOMEM; } - hmv = (lnet_magicversion_t *)&hdr->dest_nid; + hmv = (struct lnet_magicversion *)&hdr->dest_nid; /* - * Re-organize V2.x message header to V1.x (lnet_hdr_t) + * Re-organize V2.x message header to V1.x (struct lnet_hdr) * header and send out */ hmv->magic = cpu_to_le32(LNET_PROTO_TCP_MAGIC); @@ -577,18 +577,18 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello, int timeout) { struct socket *sock = conn->ksnc_sock; - lnet_hdr_t *hdr; + struct lnet_hdr *hdr; int rc; int i; LIBCFS_ALLOC(hdr, sizeof(*hdr)); if (!hdr) { - CERROR("Can't allocate lnet_hdr_t\n"); + CERROR("Can't allocate struct lnet_hdr\n"); return -ENOMEM; } rc = lnet_sock_read(sock, &hdr->src_nid, - sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid), + sizeof(*hdr) - offsetof(struct lnet_hdr, src_nid), timeout); if (rc) { CERROR("Error %d reading rest of HELLO hdr from %pI4h\n", @@ -723,10 +723,10 @@ ksocknal_pack_msg_v1(struct ksock_tx *tx) LASSERT(tx->tx_lnetmsg); tx->tx_iov[0].iov_base = &tx->tx_lnetmsg->msg_hdr; - tx->tx_iov[0].iov_len = sizeof(lnet_hdr_t); + tx->tx_iov[0].iov_len = sizeof(struct lnet_hdr); - tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(lnet_hdr_t); - tx->tx_resid = tx->tx_lnetmsg->msg_len + sizeof(lnet_hdr_t); + tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr); + tx->tx_resid = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr); } static void diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c index a38db2322225..3408041355e3 100644 --- a/drivers/staging/lustre/lnet/libcfs/debug.c +++ b/drivers/staging/lustre/lnet/libcfs/debug.c @@ -343,7 +343,7 @@ void libcfs_debug_dumplog_internal(void *arg) last_dump_time = current_time; snprintf(debug_file_name, sizeof(debug_file_name) - 1, "%s.%lld.%ld", libcfs_debug_file_path_arr, - (s64)current_time, (long_ptr_t)arg); + (s64)current_time, (long)arg); pr_alert("LustreError: dumping log to %s\n", debug_file_name); cfs_tracefile_dump_all_pages(debug_file_name); libcfs_run_debug_log_upcall(debug_file_name); diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c index c93c59d8fe6c..5c2ce2ee6fd9 100644 --- a/drivers/staging/lustre/lnet/libcfs/hash.c +++ b/drivers/staging/lustre/lnet/libcfs/hash.c @@ -1000,7 +1000,7 @@ cfs_hash_create(char *name, unsigned int cur_bits, unsigned int max_bits, struct cfs_hash *hs; int len; - CLASSERT(CFS_HASH_THETA_BITS < 15); + BUILD_BUG_ON(CFS_HASH_THETA_BITS >= 15); LASSERT(name); LASSERT(ops->hs_key); diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c index 427e2198bb9e..4d35a371216c 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c @@ -59,7 +59,7 @@ MODULE_PARM_DESC(cpu_npartitions, "# of CPU partitions"); * * NB: If user specified cpu_pattern, cpu_npartitions will be ignored */ -static char *cpu_pattern = ""; +static char *cpu_pattern = "N"; module_param(cpu_pattern, charp, 0444); MODULE_PARM_DESC(cpu_pattern, "CPU partitions pattern"); @@ -1050,7 +1050,15 @@ cfs_cpu_init(void) ret = -EINVAL; if (*cpu_pattern) { - cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); + char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL); + + if (!cpu_pattern_dup) { + CERROR("Failed to duplicate cpu_pattern\n"); + goto failed; + } + + cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern_dup); + kfree(cpu_pattern_dup); if (!cfs_cpt_table) { CERROR("Failed to create cptab from pattern %s\n", cpu_pattern); @@ -1074,8 +1082,9 @@ cfs_cpu_init(void) } spin_unlock(&cpt_data.cpt_lock); - LCONSOLE(0, "HW CPU cores: %d, npartitions: %d\n", - num_online_cpus(), cfs_cpt_number(cfs_cpt_table)); + LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n", + num_online_nodes(), num_online_cpus(), + cfs_cpt_number(cfs_cpt_table)); return 0; failed: diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c index 3f5d58babc2f..075826bd3a2a 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c @@ -122,7 +122,7 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp, const struct libcfs_ioctl_hdr __user *uhdr) { struct libcfs_ioctl_hdr hdr; - int err = 0; + int err; if (copy_from_user(&hdr, uhdr, sizeof(hdr))) return -EFAULT; @@ -150,9 +150,20 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp, return -ENOMEM; if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) { - LIBCFS_FREE(*hdr_pp, hdr.ioc_len); err = -EFAULT; + goto free; } + + if ((*hdr_pp)->ioc_version != hdr.ioc_version || + (*hdr_pp)->ioc_len != hdr.ioc_len) { + err = -EINVAL; + goto free; + } + + return 0; + +free: + LIBCFS_FREE(*hdr_pp, hdr.ioc_len); return err; } diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c index 161e04226521..c388550c2d10 100644 --- a/drivers/staging/lustre/lnet/libcfs/module.c +++ b/drivers/staging/lustre/lnet/libcfs/module.c @@ -488,10 +488,10 @@ static const struct file_operations lnet_debugfs_file_operations_wo = { static const struct file_operations *lnet_debugfs_fops_select(umode_t mode) { - if (!(mode & S_IWUGO)) + if (!(mode & 0222)) return &lnet_debugfs_file_operations_ro; - if (!(mode & S_IRUGO)) + if (!(mode & 0444)) return &lnet_debugfs_file_operations_wo; return &lnet_debugfs_file_operations_rw; diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c b/drivers/staging/lustre/lnet/libcfs/workitem.c index d0512da6bcde..dbc2a9b8dff8 100644 --- a/drivers/staging/lustre/lnet/libcfs/workitem.c +++ b/drivers/staging/lustre/lnet/libcfs/workitem.c @@ -209,7 +209,7 @@ static int cfs_wi_scheduler(void *arg) /* CPT affinity scheduler? */ if (sched->ws_cptab) if (cfs_cpt_bind(sched->ws_cptab, sched->ws_cpt)) - CWARN("Failed to bind %s on CPT %d\n", + CWARN("Unable to bind %s on CPU partition %d\n", sched->ws_name, sched->ws_cpt); spin_lock(&cfs_wi_data.wi_glock); diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 8c50c99d82d5..69bbd594b9bd 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -143,13 +143,13 @@ int lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, __u32 local_ip, __u32 peer_ip, int peer_port) { - lnet_acceptor_connreq_t cr; + struct lnet_acceptor_connreq cr; struct socket *sock; int rc; int port; int fatal; - CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */ + BUILD_BUG_ON(sizeof(cr) > 16); /* too big to be on the stack */ for (port = LNET_ACCEPTOR_MAX_RESERVED_PORT; port >= LNET_ACCEPTOR_MIN_RESERVED_PORT; @@ -164,7 +164,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, continue; } - CLASSERT(LNET_PROTO_ACCEPTOR_VERSION == 1); + BUILD_BUG_ON(LNET_PROTO_ACCEPTOR_VERSION != 1); cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; @@ -206,7 +206,7 @@ EXPORT_SYMBOL(lnet_connect); static int lnet_accept(struct socket *sock, __u32 magic) { - lnet_acceptor_connreq_t cr; + struct lnet_acceptor_connreq cr; __u32 peer_ip; int peer_port; int rc; @@ -284,7 +284,7 @@ lnet_accept(struct socket *sock, __u32 magic) rc = lnet_sock_read(sock, &cr.acr_nid, sizeof(cr) - - offsetof(lnet_acceptor_connreq_t, acr_nid), + offsetof(struct lnet_acceptor_connreq, acr_nid), accept_timeout); if (rc) { CERROR("Error %d reading connection request from %pI4h\n", @@ -330,7 +330,7 @@ lnet_acceptor(void *arg) __u32 magic; __u32 peer_ip; int peer_port; - int secure = (int)((long_ptr_t)arg); + int secure = (int)((long)arg); LASSERT(!lnet_acceptor_state.pta_sock); @@ -459,7 +459,7 @@ lnet_acceptor_start(void) if (!lnet_count_acceptor_nis()) /* not required */ return 0; - task = kthread_run(lnet_acceptor, (void *)(ulong_ptr_t)secure, + task = kthread_run(lnet_acceptor, (void *)(uintptr_t)secure, "acceptor_%03ld", secure); if (IS_ERR(task)) { rc2 = PTR_ERR(task); diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index b2ba10d59f84..08b38ef67784 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -180,89 +180,89 @@ static void lnet_assert_wire_constants(void) */ /* Constants... */ - CLASSERT(LNET_PROTO_TCP_MAGIC == 0xeebc0ded); - CLASSERT(LNET_PROTO_TCP_VERSION_MAJOR == 1); - CLASSERT(LNET_PROTO_TCP_VERSION_MINOR == 0); - CLASSERT(LNET_MSG_ACK == 0); - CLASSERT(LNET_MSG_PUT == 1); - CLASSERT(LNET_MSG_GET == 2); - CLASSERT(LNET_MSG_REPLY == 3); - CLASSERT(LNET_MSG_HELLO == 4); + BUILD_BUG_ON(LNET_PROTO_TCP_MAGIC != 0xeebc0ded); + BUILD_BUG_ON(LNET_PROTO_TCP_VERSION_MAJOR != 1); + BUILD_BUG_ON(LNET_PROTO_TCP_VERSION_MINOR != 0); + BUILD_BUG_ON(LNET_MSG_ACK != 0); + BUILD_BUG_ON(LNET_MSG_PUT != 1); + BUILD_BUG_ON(LNET_MSG_GET != 2); + BUILD_BUG_ON(LNET_MSG_REPLY != 3); + BUILD_BUG_ON(LNET_MSG_HELLO != 4); /* Checks for struct ptl_handle_wire_t */ - CLASSERT((int)sizeof(lnet_handle_wire_t) == 16); - CLASSERT((int)offsetof(lnet_handle_wire_t, wh_interface_cookie) == 0); - CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_interface_cookie) == 8); - CLASSERT((int)offsetof(lnet_handle_wire_t, wh_object_cookie) == 8); - CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_object_cookie) == 8); - - /* Checks for struct lnet_magicversion_t */ - CLASSERT((int)sizeof(lnet_magicversion_t) == 8); - CLASSERT((int)offsetof(lnet_magicversion_t, magic) == 0); - CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->magic) == 4); - CLASSERT((int)offsetof(lnet_magicversion_t, version_major) == 4); - CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->version_major) == 2); - CLASSERT((int)offsetof(lnet_magicversion_t, version_minor) == 6); - CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->version_minor) == 2); - - /* Checks for struct lnet_hdr_t */ - CLASSERT((int)sizeof(lnet_hdr_t) == 72); - CLASSERT((int)offsetof(lnet_hdr_t, dest_nid) == 0); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->dest_nid) == 8); - CLASSERT((int)offsetof(lnet_hdr_t, src_nid) == 8); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->src_nid) == 8); - CLASSERT((int)offsetof(lnet_hdr_t, dest_pid) == 16); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->dest_pid) == 4); - CLASSERT((int)offsetof(lnet_hdr_t, src_pid) == 20); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->src_pid) == 4); - CLASSERT((int)offsetof(lnet_hdr_t, type) == 24); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->type) == 4); - CLASSERT((int)offsetof(lnet_hdr_t, payload_length) == 28); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->payload_length) == 4); - CLASSERT((int)offsetof(lnet_hdr_t, msg) == 32); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg) == 40); + BUILD_BUG_ON((int)sizeof(struct lnet_handle_wire) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_handle_wire, wh_interface_cookie) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_handle_wire *)0)->wh_interface_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_handle_wire, wh_object_cookie) != 8); + BUILD_BUG_ON((int)sizeof(((struct lnet_handle_wire *)0)->wh_object_cookie) != 8); + + /* Checks for struct struct lnet_magicversion */ + BUILD_BUG_ON((int)sizeof(struct lnet_magicversion) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, magic) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->magic) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, version_major) != 4); + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->version_major) != 2); + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, version_minor) != 6); + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->version_minor) != 2); + + /* Checks for struct struct lnet_hdr */ + BUILD_BUG_ON((int)sizeof(struct lnet_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_nid) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_nid) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_nid) != 8); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_nid) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_pid) != 16); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_pid) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_pid) != 20); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_pid) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, type) != 24); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->type) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, payload_length) != 28); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->payload_length) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg) != 40); /* Ack */ - CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.dst_wmd) == 32); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.dst_wmd) == 16); - CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.match_bits) == 48); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.match_bits) == 8); - CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.mlength) == 56); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.mlength) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.dst_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.dst_wmd) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.match_bits) != 48); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.match_bits) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.mlength) != 56); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.mlength) != 4); /* Put */ - CLASSERT((int)offsetof(lnet_hdr_t, msg.put.ack_wmd) == 32); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.ack_wmd) == 16); - CLASSERT((int)offsetof(lnet_hdr_t, msg.put.match_bits) == 48); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.match_bits) == 8); - CLASSERT((int)offsetof(lnet_hdr_t, msg.put.hdr_data) == 56); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.hdr_data) == 8); - CLASSERT((int)offsetof(lnet_hdr_t, msg.put.ptl_index) == 64); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.ptl_index) == 4); - CLASSERT((int)offsetof(lnet_hdr_t, msg.put.offset) == 68); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.offset) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ack_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ack_wmd) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.match_bits) != 48); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.match_bits) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.hdr_data) != 56); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.hdr_data) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ptl_index) != 64); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ptl_index) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.offset) != 68); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.offset) != 4); /* Get */ - CLASSERT((int)offsetof(lnet_hdr_t, msg.get.return_wmd) == 32); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.return_wmd) == 16); - CLASSERT((int)offsetof(lnet_hdr_t, msg.get.match_bits) == 48); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.match_bits) == 8); - CLASSERT((int)offsetof(lnet_hdr_t, msg.get.ptl_index) == 56); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.ptl_index) == 4); - CLASSERT((int)offsetof(lnet_hdr_t, msg.get.src_offset) == 60); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.src_offset) == 4); - CLASSERT((int)offsetof(lnet_hdr_t, msg.get.sink_length) == 64); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.sink_length) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.return_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.return_wmd) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.match_bits) != 48); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.match_bits) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.ptl_index) != 56); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.ptl_index) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.src_offset) != 60); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.src_offset) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.sink_length) != 64); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.sink_length) != 4); /* Reply */ - CLASSERT((int)offsetof(lnet_hdr_t, msg.reply.dst_wmd) == 32); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.reply.dst_wmd) == 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.reply.dst_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.reply.dst_wmd) != 16); /* Hello */ - CLASSERT((int)offsetof(lnet_hdr_t, msg.hello.incarnation) == 32); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.hello.incarnation) == 8); - CLASSERT((int)offsetof(lnet_hdr_t, msg.hello.type) == 40); - CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.hello.type) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.incarnation) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.incarnation) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.type) != 40); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.type) != 4); } static lnd_t * @@ -822,13 +822,13 @@ lnet_count_acceptor_nis(void) return count; } -static lnet_ping_info_t * +static struct lnet_ping_info * lnet_ping_info_create(int num_ni) { - lnet_ping_info_t *ping_info; + struct lnet_ping_info *ping_info; unsigned int infosz; - infosz = offsetof(lnet_ping_info_t, pi_ni[num_ni]); + infosz = offsetof(struct lnet_ping_info, pi_ni[num_ni]); LIBCFS_ALLOC(ping_info, infosz); if (!ping_info) { CERROR("Can't allocate ping info[%d]\n", num_ni); @@ -860,10 +860,10 @@ lnet_get_ni_count(void) } static inline void -lnet_ping_info_free(lnet_ping_info_t *pinfo) +lnet_ping_info_free(struct lnet_ping_info *pinfo) { LIBCFS_FREE(pinfo, - offsetof(lnet_ping_info_t, + offsetof(struct lnet_ping_info, pi_ni[pinfo->pi_nnis])); } @@ -889,14 +889,14 @@ lnet_ping_info_destroy(void) static void lnet_ping_event_handler(lnet_event_t *event) { - lnet_ping_info_t *pinfo = event->md.user_ptr; + struct lnet_ping_info *pinfo = event->md.user_ptr; if (event->unlinked) pinfo->pi_features = LNET_PING_FEAT_INVAL; } static int -lnet_ping_info_setup(lnet_ping_info_t **ppinfo, lnet_handle_md_t *md_handle, +lnet_ping_info_setup(struct lnet_ping_info **ppinfo, lnet_handle_md_t *md_handle, int ni_count, bool set_eq) { lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY}; @@ -930,7 +930,7 @@ lnet_ping_info_setup(lnet_ping_info_t **ppinfo, lnet_handle_md_t *md_handle, /* initialize md content */ md.start = *ppinfo; - md.length = offsetof(lnet_ping_info_t, + md.length = offsetof(struct lnet_ping_info, pi_ni[(*ppinfo)->pi_nnis]); md.threshold = LNET_MD_THRESH_INF; md.max_size = 0; @@ -961,7 +961,7 @@ failed_0: } static void -lnet_ping_md_unlink(lnet_ping_info_t *pinfo, lnet_handle_md_t *md_handle) +lnet_ping_md_unlink(struct lnet_ping_info *pinfo, lnet_handle_md_t *md_handle) { sigset_t blocked = cfs_block_allsigs(); @@ -979,9 +979,9 @@ lnet_ping_md_unlink(lnet_ping_info_t *pinfo, lnet_handle_md_t *md_handle) } static void -lnet_ping_info_install_locked(lnet_ping_info_t *ping_info) +lnet_ping_info_install_locked(struct lnet_ping_info *ping_info) { - lnet_ni_status_t *ns; + struct lnet_ni_status *ns; lnet_ni_t *ni; int i = 0; @@ -1003,9 +1003,9 @@ lnet_ping_info_install_locked(lnet_ping_info_t *ping_info) } static void -lnet_ping_target_update(lnet_ping_info_t *pinfo, lnet_handle_md_t md_handle) +lnet_ping_target_update(struct lnet_ping_info *pinfo, lnet_handle_md_t md_handle) { - lnet_ping_info_t *old_pinfo = NULL; + struct lnet_ping_info *old_pinfo = NULL; lnet_handle_md_t old_md; /* switch the NIs to point to the new ping info created */ @@ -1496,7 +1496,7 @@ LNetNIInit(lnet_pid_t requested_pid) int im_a_router = 0; int rc; int ni_count; - lnet_ping_info_t *pinfo; + struct lnet_ping_info *pinfo; lnet_handle_md_t md_handle; struct list_head net_head; @@ -1754,7 +1754,7 @@ int lnet_dyn_add_ni(lnet_pid_t requested_pid, struct lnet_ioctl_config_data *conf) { char *nets = conf->cfg_config_u.cfg_net.net_intf; - lnet_ping_info_t *pinfo; + struct lnet_ping_info *pinfo; lnet_handle_md_t md_handle; struct lnet_ni *ni; struct list_head net_head; @@ -1834,7 +1834,7 @@ int lnet_dyn_del_ni(__u32 net) { lnet_ni_t *ni; - lnet_ping_info_t *pinfo; + struct lnet_ping_info *pinfo; lnet_handle_md_t md_handle; int rc; @@ -2147,7 +2147,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, int replied = 0; const int a_long_time = 60000; /* mS */ int infosz; - lnet_ping_info_t *info; + struct lnet_ping_info *info; lnet_process_id_t tmpid; int i; int nob; @@ -2155,7 +2155,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, int rc2; sigset_t blocked; - infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]); + infosz = offsetof(struct lnet_ping_info, pi_ni[n_ids]); if (n_ids <= 0 || id.nid == LNET_NID_ANY || @@ -2283,18 +2283,18 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, goto out_1; } - if (nob < offsetof(lnet_ping_info_t, pi_ni[0])) { + if (nob < offsetof(struct lnet_ping_info, pi_ni[0])) { CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id), - nob, (int)offsetof(lnet_ping_info_t, pi_ni[0])); + nob, (int)offsetof(struct lnet_ping_info, pi_ni[0])); goto out_1; } if (info->pi_nnis < n_ids) n_ids = info->pi_nnis; - if (nob < offsetof(lnet_ping_info_t, pi_ni[n_ids])) { + if (nob < offsetof(struct lnet_ping_info, pi_ni[n_ids])) { CERROR("%s: Short reply %d(%d expected)\n", libcfs_id2str(id), - nob, (int)offsetof(lnet_ping_info_t, pi_ni[n_ids])); + nob, (int)offsetof(struct lnet_ping_info, pi_ni[n_ids])); goto out_1; } diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index f3dd6e42f4d4..6b0be6c23fff 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -641,7 +641,7 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send) !list_empty(&lp->lp_txq)); msg->msg_peertxcredit = 1; - lp->lp_txqnob += msg->msg_len + sizeof(lnet_hdr_t); + lp->lp_txqnob += msg->msg_len + sizeof(struct lnet_hdr); lp->lp_txcredits--; if (lp->lp_txcredits < lp->lp_mintxcredits) @@ -811,7 +811,7 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg) LASSERT((txpeer->lp_txcredits < 0) == !list_empty(&txpeer->lp_txq)); - txpeer->lp_txqnob -= msg->msg_len + sizeof(lnet_hdr_t); + txpeer->lp_txqnob -= msg->msg_len + sizeof(struct lnet_hdr); LASSERT(txpeer->lp_txqnob >= 0); txpeer->lp_txcredits++; @@ -1245,7 +1245,7 @@ lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, unsigned int nob) static void lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; + struct lnet_hdr *hdr = &msg->msg_hdr; if (msg->msg_wanted) lnet_setpayloadbuffer(msg); @@ -1266,7 +1266,7 @@ lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; + struct lnet_hdr *hdr = &msg->msg_hdr; struct lnet_match_info info; bool ready_delay; int rc; @@ -1325,8 +1325,8 @@ static int lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get) { struct lnet_match_info info; - lnet_hdr_t *hdr = &msg->msg_hdr; - lnet_handle_wire_t reply_wmd; + struct lnet_hdr *hdr = &msg->msg_hdr; + struct lnet_handle_wire reply_wmd; int rc; /* Convert get fields to host byte order */ @@ -1389,7 +1389,7 @@ static int lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) { void *private = msg->msg_private; - lnet_hdr_t *hdr = &msg->msg_hdr; + struct lnet_hdr *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; lnet_libmd_t *md; int rlength; @@ -1453,7 +1453,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) static int lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) { - lnet_hdr_t *hdr = &msg->msg_hdr; + struct lnet_hdr *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; lnet_libmd_t *md; int cpt; @@ -1576,7 +1576,7 @@ lnet_msgtyp2str(int type) } void -lnet_print_hdr(lnet_hdr_t *hdr) +lnet_print_hdr(struct lnet_hdr *hdr) { lnet_process_id_t src = {0}; lnet_process_id_t dst = {0}; @@ -1634,7 +1634,7 @@ lnet_print_hdr(lnet_hdr_t *hdr) } int -lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, +lnet_parse(lnet_ni_t *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid, void *private, int rdma_req) { int rc = 0; diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 0897e588bd54..7ee164e67fbe 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -56,7 +56,7 @@ lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev) void lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) { - lnet_hdr_t *hdr = &msg->msg_hdr; + struct lnet_hdr *hdr = &msg->msg_hdr; lnet_event_t *ev = &msg->msg_ev; LASSERT(!msg->msg_routing); @@ -361,7 +361,7 @@ lnet_msg_detach_md(lnet_msg_t *msg, int status) static int lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) { - lnet_handle_wire_t ack_wmd; + struct lnet_handle_wire ack_wmd; int rc; int status = msg->msg_ev.status; diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 3947e8b711c0..fa515af2ac1d 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -680,7 +680,7 @@ lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, again: list_for_each_entry_safe(msg, tmp, head, msg_list) { struct lnet_match_info info; - lnet_hdr_t *hdr; + struct lnet_hdr *hdr; int rc; LASSERT(msg->msg_rx_delayed || head == &ptl->ptl_msg_stealing); diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 4e6dd5149b4f..b7b87ecefcdf 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -97,7 +97,7 @@ lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask) return -EINVAL; } - CLASSERT(sizeof(ifr.ifr_name) >= IFNAMSIZ); + BUILD_BUG_ON(sizeof(ifr.ifr_name) < IFNAMSIZ); if (strlen(name) > sizeof(ifr.ifr_name) - 1) return -E2BIG; @@ -393,8 +393,10 @@ lnet_sock_create(struct socket **sockp, int *fatal, __u32 local_ip, memset(&locaddr, 0, sizeof(locaddr)); locaddr.sin_family = AF_INET; locaddr.sin_port = htons(local_port); - locaddr.sin_addr.s_addr = !local_ip ? - INADDR_ANY : htonl(local_ip); + if (!local_ip) + locaddr.sin_addr.s_addr = htonl(INADDR_ANY); + else + locaddr.sin_addr.s_addr = htonl(local_ip); rc = kernel_bind(sock, (struct sockaddr *)&locaddr, sizeof(locaddr)); diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c index e4aceb71c4ec..18183cbb9859 100644 --- a/drivers/staging/lustre/lnet/lnet/net_fault.c +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c @@ -349,7 +349,7 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src, * Check if message from \a src to \a dst can match any existed drop rule */ bool -lnet_drop_rule_match(lnet_hdr_t *hdr) +lnet_drop_rule_match(struct lnet_hdr *hdr) { struct lnet_drop_rule *rule; lnet_nid_t src = le64_to_cpu(hdr->src_nid); @@ -530,7 +530,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src, * will be delayed if there is a match. */ bool -lnet_delay_rule_match_locked(lnet_hdr_t *hdr, struct lnet_msg *msg) +lnet_delay_rule_match_locked(struct lnet_hdr *hdr, struct lnet_msg *msg) { struct lnet_delay_rule *rule; lnet_nid_t src = le64_to_cpu(hdr->src_nid); @@ -997,10 +997,10 @@ lnet_fault_ctl(int opc, struct libcfs_ioctl_data *data) int lnet_fault_init(void) { - CLASSERT(LNET_PUT_BIT == 1 << LNET_MSG_PUT); - CLASSERT(LNET_ACK_BIT == 1 << LNET_MSG_ACK); - CLASSERT(LNET_GET_BIT == 1 << LNET_MSG_GET); - CLASSERT(LNET_REPLY_BIT == 1 << LNET_MSG_REPLY); + BUILD_BUG_ON(LNET_PUT_BIT != 1 << LNET_MSG_PUT); + BUILD_BUG_ON(LNET_ACK_BIT != 1 << LNET_MSG_ACK); + BUILD_BUG_ON(LNET_GET_BIT != 1 << LNET_MSG_GET); + BUILD_BUG_ON(LNET_REPLY_BIT != 1 << LNET_MSG_REPLY); mutex_init(&delay_dd.dd_mutex); spin_lock_init(&delay_dd.dd_lock); diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 8afa0abf15cd..cf22525d7129 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -621,10 +621,10 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, } void -lnet_swap_pinginfo(lnet_ping_info_t *info) +lnet_swap_pinginfo(struct lnet_ping_info *info) { int i; - lnet_ni_status_t *stat; + struct lnet_ni_status *stat; __swab32s(&info->pi_magic); __swab32s(&info->pi_features); @@ -644,7 +644,7 @@ lnet_swap_pinginfo(lnet_ping_info_t *info) static void lnet_parse_rc_info(lnet_rc_data_t *rcd) { - lnet_ping_info_t *info = rcd->rcd_pinginfo; + struct lnet_ping_info *info = rcd->rcd_pinginfo; struct lnet_peer *gw = rcd->rcd_gateway; lnet_route_t *rte; @@ -683,7 +683,7 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd) } for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) { - lnet_ni_status_t *stat = &info->pi_ni[i]; + struct lnet_ni_status *stat = &info->pi_ni[i]; lnet_nid_t nid = stat->ns_nid; if (nid == LNET_NID_ANY) { @@ -902,7 +902,7 @@ static lnet_rc_data_t * lnet_create_rc_data_locked(lnet_peer_t *gateway) { lnet_rc_data_t *rcd = NULL; - lnet_ping_info_t *pi; + struct lnet_ping_info *pi; lnet_md_t md; int rc; int i; diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 65f65a3fc901..a19e1405e3ea 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -139,7 +139,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, int ver; int off; - CLASSERT(sizeof(loff_t) >= 4); + BUILD_BUG_ON(sizeof(loff_t) < 4); off = LNET_PROC_HOFF_GET(*ppos); ver = LNET_PROC_VER_GET(*ppos); @@ -404,7 +404,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, int rc = 0; int len; - CLASSERT(LNET_PROC_HASH_BITS >= LNET_PEER_HASH_BITS); + BUILD_BUG_ON(LNET_PROC_HASH_BITS < LNET_PEER_HASH_BITS); LASSERT(!write); if (!*lenp) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 67b460f41d6e..b9ac34ecbd53 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -136,7 +136,7 @@ brw_client_init(struct sfw_test_instance *tsi) return 0; } -int brw_inject_one_error(void) +static int brw_inject_one_error(void) { struct timespec64 ts; diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 94383023c1be..6ca7192b03b7 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -42,7 +42,7 @@ #include "console.h" static int -lst_session_new_ioctl(lstio_session_new_args_t *args) +lst_session_new_ioctl(struct lstio_session_new_args *args) { char *name; int rc; @@ -78,7 +78,7 @@ lst_session_new_ioctl(lstio_session_new_args_t *args) } static int -lst_session_end_ioctl(lstio_session_end_args_t *args) +lst_session_end_ioctl(struct lstio_session_end_args *args) { if (args->lstio_ses_key != console_session.ses_key) return -EACCES; @@ -87,7 +87,7 @@ lst_session_end_ioctl(lstio_session_end_args_t *args) } static int -lst_session_info_ioctl(lstio_session_info_args_t *args) +lst_session_info_ioctl(struct lstio_session_info_args *args) { /* no checking of key */ @@ -109,7 +109,7 @@ lst_session_info_ioctl(lstio_session_info_args_t *args) } static int -lst_debug_ioctl(lstio_debug_args_t *args) +lst_debug_ioctl(struct lstio_debug_args *args) { char *name = NULL; int client = 1; @@ -190,7 +190,7 @@ out: } static int -lst_group_add_ioctl(lstio_group_add_args_t *args) +lst_group_add_ioctl(struct lstio_group_add_args *args) { char *name; int rc; @@ -223,7 +223,7 @@ lst_group_add_ioctl(lstio_group_add_args_t *args) } static int -lst_group_del_ioctl(lstio_group_del_args_t *args) +lst_group_del_ioctl(struct lstio_group_del_args *args) { int rc; char *name; @@ -256,7 +256,7 @@ lst_group_del_ioctl(lstio_group_del_args_t *args) } static int -lst_group_update_ioctl(lstio_group_update_args_t *args) +lst_group_update_ioctl(struct lstio_group_update_args *args) { int rc; char *name; @@ -313,7 +313,7 @@ lst_group_update_ioctl(lstio_group_update_args_t *args) } static int -lst_nodes_add_ioctl(lstio_group_nodes_args_t *args) +lst_nodes_add_ioctl(struct lstio_group_nodes_args *args) { unsigned int feats; int rc; @@ -358,7 +358,7 @@ lst_nodes_add_ioctl(lstio_group_nodes_args_t *args) } static int -lst_group_list_ioctl(lstio_group_list_args_t *args) +lst_group_list_ioctl(struct lstio_group_list_args *args) { if (args->lstio_grp_key != console_session.ses_key) return -EACCES; @@ -375,7 +375,7 @@ lst_group_list_ioctl(lstio_group_list_args_t *args) } static int -lst_group_info_ioctl(lstio_group_info_args_t *args) +lst_group_info_ioctl(struct lstio_group_info_args *args) { char *name; int ndent; @@ -438,7 +438,7 @@ lst_group_info_ioctl(lstio_group_info_args_t *args) } static int -lst_batch_add_ioctl(lstio_batch_add_args_t *args) +lst_batch_add_ioctl(struct lstio_batch_add_args *args) { int rc; char *name; @@ -471,7 +471,7 @@ lst_batch_add_ioctl(lstio_batch_add_args_t *args) } static int -lst_batch_run_ioctl(lstio_batch_run_args_t *args) +lst_batch_run_ioctl(struct lstio_batch_run_args *args) { int rc; char *name; @@ -505,7 +505,7 @@ lst_batch_run_ioctl(lstio_batch_run_args_t *args) } static int -lst_batch_stop_ioctl(lstio_batch_stop_args_t *args) +lst_batch_stop_ioctl(struct lstio_batch_stop_args *args) { int rc; char *name; @@ -540,7 +540,7 @@ lst_batch_stop_ioctl(lstio_batch_stop_args_t *args) } static int -lst_batch_query_ioctl(lstio_batch_query_args_t *args) +lst_batch_query_ioctl(struct lstio_batch_query_args *args) { char *name; int rc; @@ -581,7 +581,7 @@ lst_batch_query_ioctl(lstio_batch_query_args_t *args) } static int -lst_batch_list_ioctl(lstio_batch_list_args_t *args) +lst_batch_list_ioctl(struct lstio_batch_list_args *args) { if (args->lstio_bat_key != console_session.ses_key) return -EACCES; @@ -598,7 +598,7 @@ lst_batch_list_ioctl(lstio_batch_list_args_t *args) } static int -lst_batch_info_ioctl(lstio_batch_info_args_t *args) +lst_batch_info_ioctl(struct lstio_batch_info_args *args) { char *name; int rc; @@ -662,7 +662,7 @@ lst_batch_info_ioctl(lstio_batch_info_args_t *args) } static int -lst_stat_query_ioctl(lstio_stat_args_t *args) +lst_stat_query_ioctl(struct lstio_stat_args *args) { int rc; char *name = NULL; @@ -707,7 +707,7 @@ lst_stat_query_ioctl(lstio_stat_args_t *args) return rc; } -static int lst_test_add_ioctl(lstio_test_args_t *args) +static int lst_test_add_ioctl(struct lstio_test_args *args) { char *batch_name; char *src_name = NULL; @@ -851,69 +851,69 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) goto out; } - memset(&console_session.ses_trans_stat, 0, sizeof(lstcon_trans_stat_t)); + memset(&console_session.ses_trans_stat, 0, sizeof(struct lstcon_trans_stat)); switch (opc) { case LSTIO_SESSION_NEW: - rc = lst_session_new_ioctl((lstio_session_new_args_t *)buf); + rc = lst_session_new_ioctl((struct lstio_session_new_args *)buf); break; case LSTIO_SESSION_END: - rc = lst_session_end_ioctl((lstio_session_end_args_t *)buf); + rc = lst_session_end_ioctl((struct lstio_session_end_args *)buf); break; case LSTIO_SESSION_INFO: - rc = lst_session_info_ioctl((lstio_session_info_args_t *)buf); + rc = lst_session_info_ioctl((struct lstio_session_info_args *)buf); break; case LSTIO_DEBUG: - rc = lst_debug_ioctl((lstio_debug_args_t *)buf); + rc = lst_debug_ioctl((struct lstio_debug_args *)buf); break; case LSTIO_GROUP_ADD: - rc = lst_group_add_ioctl((lstio_group_add_args_t *)buf); + rc = lst_group_add_ioctl((struct lstio_group_add_args *)buf); break; case LSTIO_GROUP_DEL: - rc = lst_group_del_ioctl((lstio_group_del_args_t *)buf); + rc = lst_group_del_ioctl((struct lstio_group_del_args *)buf); break; case LSTIO_GROUP_UPDATE: - rc = lst_group_update_ioctl((lstio_group_update_args_t *)buf); + rc = lst_group_update_ioctl((struct lstio_group_update_args *)buf); break; case LSTIO_NODES_ADD: - rc = lst_nodes_add_ioctl((lstio_group_nodes_args_t *)buf); + rc = lst_nodes_add_ioctl((struct lstio_group_nodes_args *)buf); break; case LSTIO_GROUP_LIST: - rc = lst_group_list_ioctl((lstio_group_list_args_t *)buf); + rc = lst_group_list_ioctl((struct lstio_group_list_args *)buf); break; case LSTIO_GROUP_INFO: - rc = lst_group_info_ioctl((lstio_group_info_args_t *)buf); + rc = lst_group_info_ioctl((struct lstio_group_info_args *)buf); break; case LSTIO_BATCH_ADD: - rc = lst_batch_add_ioctl((lstio_batch_add_args_t *)buf); + rc = lst_batch_add_ioctl((struct lstio_batch_add_args *)buf); break; case LSTIO_BATCH_START: - rc = lst_batch_run_ioctl((lstio_batch_run_args_t *)buf); + rc = lst_batch_run_ioctl((struct lstio_batch_run_args *)buf); break; case LSTIO_BATCH_STOP: - rc = lst_batch_stop_ioctl((lstio_batch_stop_args_t *)buf); + rc = lst_batch_stop_ioctl((struct lstio_batch_stop_args *)buf); break; case LSTIO_BATCH_QUERY: - rc = lst_batch_query_ioctl((lstio_batch_query_args_t *)buf); + rc = lst_batch_query_ioctl((struct lstio_batch_query_args *)buf); break; case LSTIO_BATCH_LIST: - rc = lst_batch_list_ioctl((lstio_batch_list_args_t *)buf); + rc = lst_batch_list_ioctl((struct lstio_batch_list_args *)buf); break; case LSTIO_BATCH_INFO: - rc = lst_batch_info_ioctl((lstio_batch_info_args_t *)buf); + rc = lst_batch_info_ioctl((struct lstio_batch_info_args *)buf); break; case LSTIO_TEST_ADD: - rc = lst_test_add_ioctl((lstio_test_args_t *)buf); + rc = lst_test_add_ioctl((struct lstio_test_args *)buf); break; case LSTIO_STAT_QUERY: - rc = lst_stat_query_ioctl((lstio_stat_args_t *)buf); + rc = lst_stat_query_ioctl((struct lstio_stat_args *)buf); break; default: rc = -EINVAL; } if (copy_to_user(data->ioc_pbuf2, &console_session.ses_trans_stat, - sizeof(lstcon_trans_stat_t))) + sizeof(struct lstcon_trans_stat))) rc = -EFAULT; out: mutex_unlock(&console_session.ses_mutex); diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index 994422c62487..c6a683bda75e 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -43,7 +43,7 @@ #include "console.h" void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *, - struct lstcon_node *, lstcon_trans_stat_t *); + struct lstcon_node *, struct lstcon_trans_stat *); static void lstcon_rpc_done(struct srpc_client_rpc *rpc) @@ -420,7 +420,7 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp) } void -lstcon_rpc_trans_stat(struct lstcon_rpc_trans *trans, lstcon_trans_stat_t *stat) +lstcon_rpc_trans_stat(struct lstcon_rpc_trans *trans, struct lstcon_trans_stat *stat) { struct lstcon_rpc *crpc; struct srpc_msg *rep; @@ -469,7 +469,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, { struct list_head tmp; struct list_head __user *next; - lstcon_rpc_ent_t *ent; + struct lstcon_rpc_ent *ent; struct srpc_generic_reply *rep; struct lstcon_rpc *crpc; struct srpc_msg *msg; @@ -492,7 +492,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, next = tmp.next; - ent = list_entry(next, lstcon_rpc_ent_t, rpe_link); + ent = list_entry(next, struct lstcon_rpc_ent, rpe_link); LASSERT(crpc->crp_stamp); @@ -519,7 +519,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, /* RPC is done */ rep = (struct srpc_generic_reply *)&msg->msg_body.reply; - if (copy_to_user(&ent->rpe_sid, &rep->sid, sizeof(lst_sid_t)) || + if (copy_to_user(&ent->rpe_sid, &rep->sid, sizeof(rep->sid)) || copy_to_user(&ent->rpe_fwk_errno, &rep->status, sizeof(rep->status))) return -EFAULT; @@ -698,17 +698,17 @@ lstcon_statrpc_prep(struct lstcon_node *nd, unsigned int feats, return 0; } -static lnet_process_id_packed_t * +static struct lnet_process_id_packed * lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov) { - lnet_process_id_packed_t *pid; + struct lnet_process_id_packed *pid; int i; i = idx / SFW_ID_PER_PAGE; LASSERT(i < nkiov); - pid = (lnet_process_id_packed_t *)page_address(kiov[i].bv_page); + pid = (struct lnet_process_id_packed *)page_address(kiov[i].bv_page); return &pid[idx % SFW_ID_PER_PAGE]; } @@ -717,7 +717,7 @@ static int lstcon_dstnodes_prep(struct lstcon_group *grp, int idx, int dist, int span, int nkiov, lnet_kiov_t *kiov) { - lnet_process_id_packed_t *pid; + struct lnet_process_id_packed *pid; struct lstcon_ndlink *ndl; struct lstcon_node *nd; int start; @@ -768,7 +768,7 @@ lstcon_dstnodes_prep(struct lstcon_group *grp, int idx, } static int -lstcon_pingrpc_prep(lst_test_ping_param_t *param, struct srpc_test_reqst *req) +lstcon_pingrpc_prep(struct lst_test_ping_param *param, struct srpc_test_reqst *req) { struct test_ping_req *prq = &req->tsr_u.ping; @@ -779,7 +779,7 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, struct srpc_test_reqst *req) } static int -lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, +lstcon_bulkrpc_v0_prep(struct lst_test_bulk_param *param, struct srpc_test_reqst *req) { struct test_bulk_req *brq = &req->tsr_u.bulk_v0; @@ -793,7 +793,7 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, } static int -lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, bool is_client, +lstcon_bulkrpc_v1_prep(struct lst_test_bulk_param *param, bool is_client, struct srpc_test_reqst *req) { struct test_bulk_req_v1 *brq = &req->tsr_u.bulk_v1; @@ -823,7 +823,7 @@ lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned int feats, npg = sfw_id_pages(test->tes_span); nob = !(feats & LST_FEAT_BULK_LEN) ? npg * PAGE_SIZE : - sizeof(lnet_process_id_packed_t) * test->tes_span; + sizeof(struct lnet_process_id_packed) * test->tes_span; } rc = lstcon_rpc_prep(nd, SRPC_SERVICE_TEST, feats, npg, nob, crpc); @@ -891,17 +891,17 @@ lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned int feats, switch (test->tes_type) { case LST_TEST_PING: trq->tsr_service = SRPC_SERVICE_PING; - rc = lstcon_pingrpc_prep((lst_test_ping_param_t *) + rc = lstcon_pingrpc_prep((struct lst_test_ping_param *) &test->tes_param[0], trq); break; case LST_TEST_BULK: trq->tsr_service = SRPC_SERVICE_BRW; if (!(feats & LST_FEAT_BULK_LEN)) { - rc = lstcon_bulkrpc_v0_prep((lst_test_bulk_param_t *) + rc = lstcon_bulkrpc_v0_prep((struct lst_test_bulk_param *) &test->tes_param[0], trq); } else { - rc = lstcon_bulkrpc_v1_prep((lst_test_bulk_param_t *) + rc = lstcon_bulkrpc_v1_prep((struct lst_test_bulk_param *) &test->tes_param[0], trq->tsr_is_client, trq); } @@ -964,7 +964,7 @@ lstcon_sesnew_stat_reply(struct lstcon_rpc_trans *trans, void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *trans, struct srpc_msg *msg, - struct lstcon_node *nd, lstcon_trans_stat_t *stat) + struct lstcon_node *nd, struct lstcon_trans_stat *stat) { struct srpc_rmsn_reply *rmsn_rep; struct srpc_debug_reply *dbg_rep; @@ -1320,7 +1320,7 @@ lstcon_rpc_pinger_stop(void) lstcon_rpc_trans_stat(console_session.ses_ping, lstcon_trans_stat()); lstcon_rpc_trans_destroy(console_session.ses_ping); - memset(lstcon_trans_stat(), 0, sizeof(lstcon_trans_stat_t)); + memset(lstcon_trans_stat(), 0, sizeof(struct lstcon_trans_stat)); console_session.ses_ping = NULL; } diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h index e629e87c461c..7141d2c902a5 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.h +++ b/drivers/staging/lustre/lnet/selftest/conrpc.h @@ -103,7 +103,7 @@ struct lstcon_rpc_trans { typedef int (*lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *); typedef int (*lstcon_rpc_readent_func_t)(int, struct srpc_msg *, - lstcon_rpc_ent_t __user *); + struct lstcon_rpc_ent __user *); int lstcon_sesrpc_prep(struct lstcon_node *nd, int transop, unsigned int version, struct lstcon_rpc **crpc); @@ -125,7 +125,7 @@ int lstcon_rpc_trans_ndlist(struct list_head *ndlist, void *arg, lstcon_rpc_cond_func_t condition, struct lstcon_rpc_trans **transpp); void lstcon_rpc_trans_stat(struct lstcon_rpc_trans *trans, - lstcon_trans_stat_t *stat); + struct lstcon_trans_stat *stat); int lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, struct list_head __user *head_up, lstcon_rpc_readent_func_t readent); diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 1456d2395cc9..4e7e5c862c64 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -368,7 +368,7 @@ lstcon_sesrpc_condition(int transop, struct lstcon_node *nd, void *arg) static int lstcon_sesrpc_readent(int transop, struct srpc_msg *msg, - lstcon_rpc_ent_t __user *ent_up) + struct lstcon_rpc_ent __user *ent_up) { struct srpc_debug_reply *rep; @@ -741,7 +741,7 @@ lstcon_group_list(int index, int len, char __user *name_up) static int lstcon_nodes_getent(struct list_head *head, int *index_p, - int *count_p, lstcon_node_ent_t __user *dents_up) + int *count_p, struct lstcon_node_ent __user *dents_up) { struct lstcon_ndlink *ndl; struct lstcon_node *nd; @@ -780,11 +780,11 @@ lstcon_nodes_getent(struct list_head *head, int *index_p, } int -lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gents_p, +lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gents_p, int *index_p, int *count_p, - lstcon_node_ent_t __user *dents_up) + struct lstcon_node_ent __user *dents_up) { - lstcon_ndlist_ent_t *gentp; + struct lstcon_ndlist_ent *gentp; struct lstcon_group *grp; struct lstcon_ndlink *ndl; int rc; @@ -805,7 +805,7 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gents_p, } /* non-verbose query */ - LIBCFS_ALLOC(gentp, sizeof(lstcon_ndlist_ent_t)); + LIBCFS_ALLOC(gentp, sizeof(struct lstcon_ndlist_ent)); if (!gentp) { CERROR("Can't allocate ndlist_ent\n"); lstcon_group_decref(grp); @@ -817,9 +817,9 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *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(struct lstcon_ndlist_ent)) ? -EFAULT : 0; - LIBCFS_FREE(gentp, sizeof(lstcon_ndlist_ent_t)); + LIBCFS_FREE(gentp, sizeof(struct lstcon_ndlist_ent)); lstcon_group_decref(grp); @@ -926,11 +926,11 @@ lstcon_batch_list(int index, int len, char __user *name_up) } int -lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up, +lstcon_batch_info(char *name, struct lstcon_test_batch_ent __user *ent_up, int server, int testidx, int *index_p, int *ndent_p, - lstcon_node_ent_t __user *dents_up) + struct lstcon_node_ent __user *dents_up) { - lstcon_test_batch_ent_t *entp; + struct lstcon_test_batch_ent *entp; struct list_head *clilst; struct list_head *srvlst; struct lstcon_test *test = NULL; @@ -969,7 +969,7 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up, } /* non-verbose query */ - LIBCFS_ALLOC(entp, sizeof(lstcon_test_batch_ent_t)); + LIBCFS_ALLOC(entp, sizeof(struct lstcon_test_batch_ent)); if (!entp) return -ENOMEM; @@ -989,9 +989,9 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up, LST_NODE_STATE_COUNTER(ndl->ndl_node, &entp->tbe_srv_nle); rc = copy_to_user(ent_up, entp, - sizeof(lstcon_test_batch_ent_t)) ? -EFAULT : 0; + sizeof(struct lstcon_test_batch_ent)) ? -EFAULT : 0; - LIBCFS_FREE(entp, sizeof(lstcon_test_batch_ent_t)); + LIBCFS_FREE(entp, sizeof(struct lstcon_test_batch_ent)); return rc; } @@ -1385,7 +1385,7 @@ lstcon_test_find(struct lstcon_batch *batch, int idx, static int lstcon_tsbrpc_readent(int transop, struct srpc_msg *msg, - lstcon_rpc_ent_t __user *ent_up) + struct lstcon_rpc_ent __user *ent_up) { struct srpc_batch_reply *rep = &msg->msg_body.bat_reply; @@ -1464,18 +1464,18 @@ lstcon_test_batch_query(char *name, int testidx, int client, static int lstcon_statrpc_readent(int transop, struct srpc_msg *msg, - lstcon_rpc_ent_t __user *ent_up) + struct lstcon_rpc_ent __user *ent_up) { struct srpc_stat_reply *rep = &msg->msg_body.stat_reply; - sfw_counters_t __user *sfwk_stat; - srpc_counters_t __user *srpc_stat; + struct sfw_counters __user *sfwk_stat; + struct srpc_counters __user *srpc_stat; lnet_counters_t __user *lnet_stat; if (rep->str_status) return 0; - sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0]; - srpc_stat = (srpc_counters_t __user *)(sfwk_stat + 1); + sfwk_stat = (struct sfw_counters __user *)&ent_up->rpe_payload[0]; + srpc_stat = (struct srpc_counters __user *)(sfwk_stat + 1); lnet_stat = (lnet_counters_t __user *)(srpc_stat + 1); if (copy_to_user(sfwk_stat, &rep->str_fw, sizeof(*sfwk_stat)) || @@ -1688,14 +1688,14 @@ lstcon_nodes_debug(int timeout, } int -lstcon_session_match(lst_sid_t sid) +lstcon_session_match(struct lst_sid sid) { return (console_session.ses_id.ses_nid == sid.ses_nid && console_session.ses_id.ses_stamp == sid.ses_stamp) ? 1 : 0; } static void -lstcon_new_session_id(lst_sid_t *sid) +lstcon_new_session_id(struct lst_sid *sid) { lnet_process_id_t id; @@ -1708,7 +1708,7 @@ lstcon_new_session_id(lst_sid_t *sid) int lstcon_session_new(char *name, int key, unsigned int feats, - int timeout, int force, lst_sid_t __user *sid_up) + int timeout, int force, struct lst_sid __user *sid_up) { int rc = 0; int i; @@ -1767,7 +1767,7 @@ lstcon_session_new(char *name, int key, unsigned int feats, } if (!copy_to_user(sid_up, &console_session.ses_id, - sizeof(lst_sid_t))) + sizeof(struct lst_sid))) return rc; lstcon_session_end(); @@ -1776,12 +1776,12 @@ lstcon_session_new(char *name, int key, unsigned int feats, } int -lstcon_session_info(lst_sid_t __user *sid_up, int __user *key_up, +lstcon_session_info(struct lst_sid __user *sid_up, int __user *key_up, unsigned __user *featp, - lstcon_ndlist_ent_t __user *ndinfo_up, + struct lstcon_ndlist_ent __user *ndinfo_up, char __user *name_up, int len) { - lstcon_ndlist_ent_t *entp; + struct lstcon_ndlist_ent *entp; struct lstcon_ndlink *ndl; int rc = 0; @@ -1796,7 +1796,7 @@ lstcon_session_info(lst_sid_t __user *sid_up, int __user *key_up, LST_NODE_STATE_COUNTER(ndl->ndl_node, entp); if (copy_to_user(sid_up, &console_session.ses_id, - sizeof(lst_sid_t)) || + sizeof(*sid_up)) || copy_to_user(key_up, &console_session.ses_key, sizeof(*key_up)) || copy_to_user(featp, &console_session.ses_features, diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index 5dc1de48a10e..05b4b7013d2e 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/drivers/staging/lustre/lnet/selftest/console.h @@ -81,7 +81,7 @@ struct lstcon_group { #define LST_BATCH_RUNNING 0xB1 /* running batch */ struct lstcon_tsb_hdr { - lst_bid_t tsb_id; /* batch ID */ + struct lst_bid tsb_id; /* batch ID */ int tsb_index; /* test index */ }; @@ -140,7 +140,7 @@ struct lstcon_test { struct lstcon_session { struct mutex ses_mutex; /* only 1 thread in session */ - lst_sid_t ses_id; /* global session id */ + struct lst_sid ses_id; /* global session id */ int ses_key; /* local session key */ int ses_state; /* state of session */ int ses_timeout; /* timeout in seconds */ @@ -158,7 +158,7 @@ struct lstcon_session { char ses_name[LST_NAME_SIZE];/* session name */ struct lstcon_rpc_trans *ses_ping; /* session pinger */ struct stt_timer ses_ping_timer; /* timer for pinger */ - lstcon_trans_stat_t ses_trans_stat; /* transaction stats */ + struct lstcon_trans_stat ses_trans_stat; /* transaction stats */ struct list_head ses_trans_list; /* global list of transaction */ struct list_head ses_grp_list; /* global list of groups */ @@ -173,7 +173,7 @@ struct lstcon_session { extern struct lstcon_session console_session; -static inline lstcon_trans_stat_t * +static inline struct lstcon_trans_stat * lstcon_trans_stat(void) { return &console_session.ses_trans_stat; @@ -190,11 +190,11 @@ lstcon_id2hash(lnet_process_id_t id, struct list_head *hash) int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr); int lstcon_console_init(void); int lstcon_console_fini(void); -int lstcon_session_match(lst_sid_t sid); +int lstcon_session_match(struct lst_sid sid); int lstcon_session_new(char *name, int key, unsigned int version, - int timeout, int flags, lst_sid_t __user *sid_up); -int lstcon_session_info(lst_sid_t __user *sid_up, int __user *key, - unsigned __user *verp, lstcon_ndlist_ent_t __user *entp, + int timeout, int flags, struct lst_sid __user *sid_up); +int lstcon_session_info(struct lst_sid __user *sid_up, int __user *key, + unsigned __user *verp, struct lstcon_ndlist_ent __user *entp, char __user *name_up, int len); int lstcon_session_end(void); int lstcon_session_debug(int timeout, struct list_head __user *result_up); @@ -213,9 +213,9 @@ int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t __user *nds_up, unsigned int *featp, struct list_head __user *result_up); int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t __user *nds_up, struct list_head __user *result_up); -int lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gent_up, +int lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gent_up, int *index_p, int *ndent_p, - lstcon_node_ent_t __user *ndents_up); + struct lstcon_node_ent __user *ndents_up); int lstcon_group_list(int idx, int len, char __user *name_up); int lstcon_batch_add(char *name); int lstcon_batch_run(char *name, int timeout, @@ -227,9 +227,9 @@ int lstcon_test_batch_query(char *name, int testidx, struct list_head __user *result_up); int lstcon_batch_del(char *name); int lstcon_batch_list(int idx, int namelen, char __user *name_up); -int lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up, +int lstcon_batch_info(char *name, struct lstcon_test_batch_ent __user *ent_up, int server, int testidx, int *index_p, - int *ndent_p, lstcon_node_ent_t __user *dents_up); + int *ndent_p, struct lstcon_node_ent __user *dents_up); int lstcon_group_stat(char *grp_name, int timeout, struct list_head __user *result_up); int lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up, diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 48dcc330dc9b..9dd4e1a70329 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -39,7 +39,7 @@ #include "selftest.h" -lst_sid_t LST_INVALID_SID = {LNET_NID_ANY, -1}; +struct lst_sid LST_INVALID_SID = {LNET_NID_ANY, -1}; static int session_timeout = 100; module_param(session_timeout, int, 0444); @@ -254,7 +254,7 @@ sfw_session_expired(void *data) } static inline void -sfw_init_session(struct sfw_session *sn, lst_sid_t sid, +sfw_init_session(struct sfw_session *sn, struct lst_sid sid, unsigned int features, const char *name) { struct stt_timer *timer = &sn->sn_timer; @@ -316,7 +316,7 @@ sfw_client_rpc_fini(struct srpc_client_rpc *rpc) } static struct sfw_batch * -sfw_find_batch(lst_bid_t bid) +sfw_find_batch(struct lst_bid bid) { struct sfw_session *sn = sfw_data.fw_session; struct sfw_batch *bat; @@ -332,7 +332,7 @@ sfw_find_batch(lst_bid_t bid) } static struct sfw_batch * -sfw_bid2batch(lst_bid_t bid) +sfw_bid2batch(struct lst_bid bid) { struct sfw_session *sn = sfw_data.fw_session; struct sfw_batch *bat; @@ -361,7 +361,7 @@ static int sfw_get_stats(struct srpc_stat_reqst *request, struct srpc_stat_reply *reply) { struct sfw_session *sn = sfw_data.fw_session; - sfw_counters_t *cnt = &reply->str_fw; + struct sfw_counters *cnt = &reply->str_fw; struct sfw_batch *bat; reply->str_sid = !sn ? LST_INVALID_SID : sn->sn_id; @@ -777,14 +777,14 @@ sfw_add_test_instance(struct sfw_batch *tsb, struct srpc_server_rpc *rpc) LASSERT(bk); LASSERT(bk->bk_niov * SFW_ID_PER_PAGE >= (unsigned int)ndest); LASSERT((unsigned int)bk->bk_len >= - sizeof(lnet_process_id_packed_t) * ndest); + sizeof(struct lnet_process_id_packed) * ndest); sfw_unpack_addtest_req(msg); memcpy(&tsi->tsi_u, &req->tsr_u, sizeof(tsi->tsi_u)); for (i = 0; i < ndest; i++) { - lnet_process_id_packed_t *dests; - lnet_process_id_packed_t id; + struct lnet_process_id_packed *dests; + struct lnet_process_id_packed id; int j; dests = page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].bv_page); @@ -1164,7 +1164,7 @@ sfw_add_test(struct srpc_server_rpc *rpc) len = npg * PAGE_SIZE; } else { - len = sizeof(lnet_process_id_packed_t) * + len = sizeof(struct lnet_process_id_packed) * request->tsr_ndest; } diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index 71485f992297..b5d556fa48ab 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -112,7 +112,8 @@ lnet_selftest_init(void) rc = cfs_wi_sched_create("lst_t", lnet_cpt_table(), i, nthrs, &lst_sched_test[i]); if (rc) { - CERROR("Failed to create CPT affinity WI scheduler %d for LST\n", i); + CWARN("Failed to create CPU partition affinity WI scheduler %d for LST\n", + i); goto error; } } diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index ce9de8c9be57..92cd4113cf75 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -55,7 +55,7 @@ static struct smoketest_rpc { struct srpc_service *rpc_services[SRPC_SERVICE_MAX_ID + 1]; lnet_handle_eq_t rpc_lnet_eq; /* _the_ LNet event queue */ enum srpc_state rpc_state; - srpc_counters_t rpc_counters; + struct srpc_counters rpc_counters; __u64 rpc_matchbits; /* matchbits counter */ } srpc_data; @@ -69,14 +69,14 @@ srpc_serv_portal(int svc_id) /* forward ref's */ int srpc_handle_rpc(struct swi_workitem *wi); -void srpc_get_counters(srpc_counters_t *cnt) +void srpc_get_counters(struct srpc_counters *cnt) { spin_lock(&srpc_data.rpc_glock); *cnt = srpc_data.rpc_counters; spin_unlock(&srpc_data.rpc_glock); } -void srpc_set_counters(const srpc_counters_t *cnt) +void srpc_set_counters(const struct srpc_counters *cnt) { spin_lock(&srpc_data.rpc_glock); srpc_data.rpc_counters = *cnt; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h index f353a634cc8e..418c9c96abe6 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.h +++ b/drivers/staging/lustre/lnet/selftest/rpc.h @@ -75,43 +75,43 @@ struct srpc_generic_reqst { struct srpc_generic_reply { __u32 status; - lst_sid_t sid; + struct lst_sid sid; } WIRE_ATTR; /* FRAMEWORK RPCs */ struct srpc_mksn_reqst { __u64 mksn_rpyid; /* reply buffer matchbits */ - lst_sid_t mksn_sid; /* session id */ + struct lst_sid mksn_sid; /* session id */ __u32 mksn_force; /* use brute force */ char mksn_name[LST_NAME_SIZE]; } WIRE_ATTR; /* make session request */ struct srpc_mksn_reply { __u32 mksn_status; /* session status */ - lst_sid_t mksn_sid; /* session id */ + struct lst_sid mksn_sid; /* session id */ __u32 mksn_timeout; /* session timeout */ char mksn_name[LST_NAME_SIZE]; } WIRE_ATTR; /* make session reply */ struct srpc_rmsn_reqst { __u64 rmsn_rpyid; /* reply buffer matchbits */ - lst_sid_t rmsn_sid; /* session id */ + struct lst_sid rmsn_sid; /* session id */ } WIRE_ATTR; /* remove session request */ struct srpc_rmsn_reply { __u32 rmsn_status; - lst_sid_t rmsn_sid; /* session id */ + struct lst_sid rmsn_sid; /* session id */ } WIRE_ATTR; /* remove session reply */ struct srpc_join_reqst { __u64 join_rpyid; /* reply buffer matchbits */ - lst_sid_t join_sid; /* session id to join */ + struct lst_sid join_sid; /* session id to join */ char join_group[LST_NAME_SIZE]; /* group name */ } WIRE_ATTR; struct srpc_join_reply { __u32 join_status; /* returned status */ - lst_sid_t join_sid; /* session id */ + struct lst_sid join_sid; /* session id */ __u32 join_timeout; /* # seconds' inactivity to * expire */ @@ -120,13 +120,13 @@ struct srpc_join_reply { struct srpc_debug_reqst { __u64 dbg_rpyid; /* reply buffer matchbits */ - lst_sid_t dbg_sid; /* session id */ + struct lst_sid dbg_sid; /* session id */ __u32 dbg_flags; /* bitmap of debug */ } WIRE_ATTR; struct srpc_debug_reply { __u32 dbg_status; /* returned code */ - lst_sid_t dbg_sid; /* session id */ + struct lst_sid dbg_sid; /* session id */ __u32 dbg_timeout; /* session timeout */ __u32 dbg_nbatch; /* # of batches in the node */ char dbg_name[LST_NAME_SIZE]; /* session name */ @@ -138,8 +138,8 @@ struct srpc_debug_reply { struct srpc_batch_reqst { __u64 bar_rpyid; /* reply buffer matchbits */ - lst_sid_t bar_sid; /* session id */ - lst_bid_t bar_bid; /* batch id */ + struct lst_sid bar_sid; /* session id */ + struct lst_bid bar_bid; /* batch id */ __u32 bar_opc; /* create/start/stop batch */ __u32 bar_testidx; /* index of test */ __u32 bar_arg; /* parameters */ @@ -147,22 +147,22 @@ struct srpc_batch_reqst { struct srpc_batch_reply { __u32 bar_status; /* status of request */ - lst_sid_t bar_sid; /* session id */ + struct lst_sid bar_sid; /* session id */ __u32 bar_active; /* # of active tests in batch/test */ __u32 bar_time; /* remained time */ } WIRE_ATTR; struct srpc_stat_reqst { __u64 str_rpyid; /* reply buffer matchbits */ - lst_sid_t str_sid; /* session id */ + struct lst_sid str_sid; /* session id */ __u32 str_type; /* type of stat */ } WIRE_ATTR; struct srpc_stat_reply { __u32 str_status; - lst_sid_t str_sid; - sfw_counters_t str_fw; - srpc_counters_t str_rpc; + struct lst_sid str_sid; + struct sfw_counters str_fw; + struct srpc_counters str_rpc; lnet_counters_t str_lnet; } WIRE_ATTR; @@ -187,8 +187,8 @@ struct test_ping_req { struct srpc_test_reqst { __u64 tsr_rpyid; /* reply buffer matchbits */ __u64 tsr_bulkid; /* bulk buffer matchbits */ - lst_sid_t tsr_sid; /* session id */ - lst_bid_t tsr_bid; /* batch id */ + struct lst_sid tsr_sid; /* session id */ + struct lst_bid tsr_bid; /* batch id */ __u32 tsr_service; /* test type: bulk|ping|... */ __u32 tsr_loop; /* test client loop count or * # server buffers needed @@ -207,7 +207,7 @@ struct srpc_test_reqst { struct srpc_test_reply { __u32 tsr_status; /* returned code */ - lst_sid_t tsr_sid; + struct lst_sid tsr_sid; } WIRE_ATTR; /* TEST RPCs */ diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index c8833a016b6d..f25948087ee0 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -322,7 +322,7 @@ struct srpc_service { struct sfw_session { struct list_head sn_list; /* chain on fw_zombie_sessions */ - lst_sid_t sn_id; /* unique identifier */ + struct lst_sid sn_id; /* unique identifier */ unsigned int sn_timeout; /* # seconds' inactivity to expire */ int sn_timer_active; unsigned int sn_features; @@ -340,7 +340,7 @@ struct sfw_session { struct sfw_batch { struct list_head bat_list; /* chain on sn_batches */ - lst_bid_t bat_id; /* batch id */ + struct lst_bid bat_id; /* batch id */ int bat_error; /* error code of batch */ struct sfw_session *bat_session; /* batch's session */ atomic_t bat_nactive; /* # of active tests */ @@ -396,7 +396,7 @@ struct sfw_test_instance { * pages are not used */ #define SFW_MAX_CONCUR LST_MAX_CONCUR -#define SFW_ID_PER_PAGE (PAGE_SIZE / sizeof(lnet_process_id_packed_t)) +#define SFW_ID_PER_PAGE (PAGE_SIZE / sizeof(struct lnet_process_id_packed)) #define SFW_MAX_NDESTS (LNET_MAX_IOV * SFW_ID_PER_PAGE) #define sfw_id_pages(n) (((n) + SFW_ID_PER_PAGE - 1) / SFW_ID_PER_PAGE) @@ -453,8 +453,8 @@ void srpc_abort_service(struct srpc_service *sv); int srpc_finish_service(struct srpc_service *sv); int srpc_service_add_buffers(struct srpc_service *sv, int nbuffer); void srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer); -void srpc_get_counters(srpc_counters_t *cnt); -void srpc_set_counters(const srpc_counters_t *cnt); +void srpc_get_counters(struct srpc_counters *cnt); +void srpc_set_counters(const struct srpc_counters *cnt); extern struct cfs_wi_sched *lst_sched_serial; extern struct cfs_wi_sched **lst_sched_test; diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c index 4e49cb356d64..9eb405905d1a 100644 --- a/drivers/staging/lustre/lustre/fid/fid_lib.c +++ b/drivers/staging/lustre/lustre/fid/fid_lib.c @@ -60,14 +60,13 @@ * FID_SEQ_START + 2 is for .lustre directory and its objects */ const struct lu_seq_range LUSTRE_SEQ_SPACE_RANGE = { - FID_SEQ_NORMAL, - (__u64)~0ULL + .lsr_start = FID_SEQ_NORMAL, + .lsr_end = (__u64)~0ULL, }; /* Zero range, used for init and other purposes. */ const struct lu_seq_range LUSTRE_SEQ_ZERO_RANGE = { - 0, - 0 + .lsr_start = 0, }; /* Lustre Big Fs Lock fid. */ diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 97d4849c7199..3eed83808545 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -203,9 +203,13 @@ LPROC_SEQ_FOPS_RO(ldebugfs_fid_server); LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid); struct lprocfs_vars seq_client_debugfs_list[] = { - { "space", &ldebugfs_fid_space_fops }, - { "width", &ldebugfs_fid_width_fops }, - { "server", &ldebugfs_fid_server_fops }, - { "fid", &ldebugfs_fid_fid_fops }, + { .name = "space", + .fops = &ldebugfs_fid_space_fops }, + { .name = "width", + .fops = &ldebugfs_fid_width_fops }, + { .name = "server", + .fops = &ldebugfs_fid_server_fops }, + { .name = "fid", + .fops = &ldebugfs_fid_fid_fops }, { NULL } }; diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index dc685610c4c4..e4c0c440f01b 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -284,12 +284,6 @@ struct cl_layout { size_t cl_size; /** Layout generation. */ u32 cl_layout_gen; - /** - * True if this is a released file. - * Temporarily added for released file truncate in ll_setattr_raw(). - * It will be removed later. -Jinshan - */ - bool cl_is_released; }; /** @@ -1458,8 +1452,10 @@ struct cl_read_ahead { * cra_end is included. */ pgoff_t cra_end; + /* optimal RPC size for this read, by pages */ + unsigned long cra_rpc_size; /* - * Release routine. If readahead holds resources underneath, this + * Release callback. If readahead holds resources underneath, this * function should be called to release it. */ void (*cra_release)(const struct lu_env *env, void *cbdata); @@ -2311,7 +2307,7 @@ struct cl_io *cl_io_top(struct cl_io *io); do { \ typeof(foo_io) __foo_io = (foo_io); \ \ - CLASSERT(offsetof(typeof(*__foo_io), base) == 0); \ + BUILD_BUG_ON(offsetof(typeof(*__foo_io), base) != 0); \ memset(&__foo_io->base + 1, 0, \ sizeof(*__foo_io) - sizeof(__foo_io->base)); \ } while (0) diff --git a/drivers/staging/lustre/lustre/include/interval_tree.h b/drivers/staging/lustre/lustre/include/interval_tree.h index 5d387d372547..0d4f92ec8334 100644 --- a/drivers/staging/lustre/lustre/include/interval_tree.h +++ b/drivers/staging/lustre/lustre/include/interval_tree.h @@ -36,7 +36,9 @@ #ifndef _INTERVAL_H__ #define _INTERVAL_H__ -#include "../../include/linux/libcfs/libcfs.h" /* LASSERT. */ +#include <linux/errno.h> +#include <linux/string.h> +#include <linux/types.h> struct interval_node { struct interval_node *in_left; @@ -73,13 +75,15 @@ static inline __u64 interval_high(struct interval_node *node) return node->in_extent.end; } -static inline void interval_set(struct interval_node *node, - __u64 start, __u64 end) +static inline int interval_set(struct interval_node *node, + __u64 start, __u64 end) { - LASSERT(start <= end); + if (start > end) + return -ERANGE; node->in_extent.start = start; node->in_extent.end = end; node->in_max_high = end; + return 0; } /* diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 260643ee0d48..7a4f412a85a3 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -34,6 +34,7 @@ #define __LUSTRE_LU_OBJECT_H #include <stdarg.h> +#include <linux/percpu_counter.h> #include "../../include/linux/libcfs/libcfs.h" #include "lustre/lustre_idl.h" #include "lu_ref.h" @@ -580,7 +581,6 @@ 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 }; @@ -635,6 +635,10 @@ struct lu_site { * XXX: a hack! fld has to find md_site via site, remove when possible */ struct seq_server_site *ld_seq_site; + /** + * Number of objects in lsb_lru_lists - used for shrinking + */ + struct percpu_counter ls_lru_len_counter; }; static inline struct lu_site_bkt_data * @@ -708,8 +712,14 @@ 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_unhash(const struct lu_env *env, struct lu_object *o); +int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s, int nr, + bool canblock); -int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr); +static inline int lu_site_purge(const struct lu_env *env, struct lu_site *s, + int nr) +{ + return lu_site_purge_objects(env, s, nr, true); +} void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie, lu_printer_t printer); @@ -1120,7 +1130,7 @@ struct lu_context_key { { \ type *value; \ \ - CLASSERT(PAGE_SIZE >= sizeof(*value)); \ + BUILD_BUG_ON(PAGE_SIZE < sizeof(*value)); \ \ value = kzalloc(sizeof(*value), GFP_NOFS); \ if (!value) \ @@ -1326,5 +1336,8 @@ void lu_buf_realloc(struct lu_buf *buf, size_t size); int lu_buf_check_and_grow(struct lu_buf *buf, size_t len); struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, size_t len); +extern __u32 lu_context_tags_default; +extern __u32 lu_session_tags_default; + /** @} lu */ #endif /* __LUSTRE_LU_OBJECT_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 65ce503ad595..b0eb80d70c23 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -3130,52 +3130,6 @@ struct obdo { #define o_cksum o_nlink #define o_grant_used o_data_version -static inline void lustre_set_wire_obdo(const struct obd_connect_data *ocd, - struct obdo *wobdo, - const struct obdo *lobdo) -{ - *wobdo = *lobdo; - wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - if (!ocd) - return; - - if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && - fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { - /* Currently OBD_FL_OSTID will only be used when 2.4 echo - * client communicate with pre-2.4 server - */ - wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); - wobdo->o_oi.oi.oi_seq = fid_seq(&lobdo->o_oi.oi_fid); - } -} - -static inline void lustre_get_wire_obdo(const struct obd_connect_data *ocd, - struct obdo *lobdo, - const struct obdo *wobdo) -{ - __u32 local_flags = 0; - - if (lobdo->o_valid & OBD_MD_FLFLAGS) - local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; - - *lobdo = *wobdo; - if (local_flags != 0) { - lobdo->o_valid |= OBD_MD_FLFLAGS; - lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - lobdo->o_flags |= local_flags; - } - if (!ocd) - return; - - if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && - fid_seq_is_echo(wobdo->o_oi.oi.oi_seq)) { - /* see above */ - lobdo->o_oi.oi_fid.f_seq = wobdo->o_oi.oi.oi_seq; - lobdo->o_oi.oi_fid.f_oid = wobdo->o_oi.oi.oi_id; - lobdo->o_oi.oi_fid.f_ver = 0; - } -} - /* request structure for OST's */ struct ost_body { struct obdo oa; diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 3301ad652db1..21aec0ca9ad3 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -1209,23 +1209,21 @@ struct hsm_action_item { * \retval buffer */ static inline char *hai_dump_data_field(struct hsm_action_item *hai, - char *buffer, int len) + char *buffer, size_t len) { - int i, sz, data_len; + int i, data_len; char *ptr; ptr = buffer; - sz = len; data_len = hai->hai_len - sizeof(*hai); - for (i = 0 ; (i < data_len) && (sz > 0) ; i++) { - int cnt; - - cnt = snprintf(ptr, sz, "%.2X", - (unsigned char)hai->hai_data[i]); - ptr += cnt; - sz -= cnt; + for (i = 0; (i < data_len) && (len > 2); i++) { + snprintf(ptr, 3, "%02X", (unsigned char)hai->hai_data[i]); + ptr += 2; + len -= 2; } + *ptr = '\0'; + return buffer; } diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 411eb0dc7f38..1b48df0d4862 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -315,8 +315,8 @@ struct ptlrpc_client { 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, kmalloc a struct and store + * cast to the struct of their choosing, and BUILD_BUG_ON oversized + * arguments. 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. */ @@ -1661,10 +1661,6 @@ struct ptlrpcd_ctl { */ char pc_name[16]; /** - * Environment for request interpreters to run in. - */ - struct lu_env pc_env; - /** * CPT the thread is bound on. */ int pc_cpt; diff --git a/drivers/staging/lustre/lustre/include/lustre_obdo.h b/drivers/staging/lustre/lustre/include/lustre_obdo.h new file mode 100644 index 000000000000..1e12f8c0f157 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre_obdo.h @@ -0,0 +1,54 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Copyright 2015 Cray Inc, all rights reserved. + * Author: Ben Evans. + * + * Define obdo associated functions + * obdo: OBject Device o... + */ + +#ifndef _LUSTRE_OBDO_H_ +#define _LUSTRE_OBDO_H_ + +#include "lustre/lustre_idl.h" + +/** + * Create an obdo to send over the wire + */ +void lustre_set_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *wobdo, + const struct obdo *lobdo); + +/** + * Create a local obdo from a wire based odbo + */ +void lustre_get_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *lobdo, + const struct obdo *wobdo); + +#endif diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index fbcd39572cd0..cd62ccd53e2c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -39,6 +39,8 @@ #ifndef _LUSTRE_REQ_LAYOUT_H__ #define _LUSTRE_REQ_LAYOUT_H__ +#include <linux/types.h> + /** \defgroup req_layout req_layout * * @{ @@ -66,11 +68,6 @@ struct req_capsule { __u32 rc_area[RCL_NR][REQ_MAX_FIELD_NR]; }; -#if !defined(__REQ_LAYOUT_USER__) - -/* struct ptlrpc_request, lustre_msg* */ -#include "lustre_net.h" - void req_capsule_init(struct req_capsule *pill, struct ptlrpc_request *req, enum req_location location); void req_capsule_fini(struct req_capsule *pill); @@ -120,9 +117,6 @@ void req_capsule_shrink(struct req_capsule *pill, int req_layout_init(void); void req_layout_fini(void); -/* __REQ_LAYOUT_USER__ */ -#endif - extern struct req_format RQF_OBD_PING; extern struct req_format RQF_OBD_SET_INFO; extern struct req_format RQF_SEC_CTX; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 0f48e9c3d9e3..4ce85064f9d0 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -43,6 +43,7 @@ #include "lustre_fld.h" #include "lustre_handles.h" #include "lustre_intent.h" +#include "cl_object.h" #define MAX_OBD_DEVICES 8192 @@ -76,6 +77,8 @@ static inline void loi_init(struct lov_oinfo *loi) struct lov_stripe_md; struct obd_info; +int lov_read_and_clear_async_rc(struct cl_object *clob); + typedef int (*obd_enqueue_update_f)(void *cookie, int rc); /* obd info for a particular level (lov, osc). */ @@ -284,6 +287,8 @@ struct client_obd { * the transaction has NOT yet committed. */ atomic_long_t cl_unstable_count; + /** Link to osc_shrinker_list */ + struct list_head cl_shrink_list; /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */ atomic_t cl_destroy_in_flight; @@ -398,18 +403,10 @@ struct lmv_tgt_desc { unsigned long ltd_active:1; /* target up for requests */ }; -enum placement_policy { - PLACEMENT_CHAR_POLICY = 0, - PLACEMENT_NID_POLICY = 1, - PLACEMENT_INVAL_POLICY = 2, - PLACEMENT_MAX_POLICY -}; - struct lmv_obd { int refcount; struct lu_client_fld lmv_fld; spinlock_t lmv_lock; - enum placement_policy lmv_placement; struct lmv_desc desc; struct obd_uuid cluuid; struct obd_export *exp; @@ -478,16 +475,12 @@ struct niobuf_local { * Events signalled through obd_notify() upcall-chain. */ enum obd_notify_event { - /* target added */ - OBD_NOTIFY_CREATE, /* Device connect start */ OBD_NOTIFY_CONNECT, /* Device activated */ OBD_NOTIFY_ACTIVE, /* Device deactivated */ OBD_NOTIFY_INACTIVE, - /* Device disconnected */ - OBD_NOTIFY_DISCON, /* Connect data for import were changed */ OBD_NOTIFY_OCD, /* Sync request */ @@ -758,6 +751,7 @@ struct md_enqueue_info { struct lookup_intent mi_it; struct lustre_handle mi_lockh; struct inode *mi_dir; + struct ldlm_enqueue_info mi_einfo; int (*mi_cb)(struct ptlrpc_request *req, struct md_enqueue_info *minfo, int rc); void *mi_cbdata; @@ -889,7 +883,7 @@ struct obd_client_handle { struct md_open_data *och_mod; struct lustre_handle och_lease_handle; /* open lock for lease */ __u32 och_magic; - int och_flags; + fmode_t och_flags; }; #define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed @@ -975,8 +969,7 @@ struct md_ops { struct lu_fid *fid); int (*intent_getattr_async)(struct obd_export *, - struct md_enqueue_info *, - struct ldlm_enqueue_info *); + struct md_enqueue_info *); int (*revalidate_lock)(struct obd_export *, struct lookup_intent *, struct lu_fid *, __u64 *bits); diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 7ec25202cd22..083a6ff56a05 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1444,14 +1444,13 @@ static inline int md_init_ea_size(struct obd_export *exp, u32 easize, } static inline int md_intent_getattr_async(struct obd_export *exp, - struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo) + struct md_enqueue_info *minfo) { int rc; EXP_CHECK_MD_OP(exp, intent_getattr_async); EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); - rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo); + rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo); return rc; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 32b73ee62639..08f97e2117ed 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -162,7 +162,7 @@ void ldlm_extent_add_lock(struct ldlm_resource *res, struct interval_node *found, **root; struct ldlm_interval *node; struct ldlm_extent *extent; - int idx; + int idx, rc; LASSERT(lock->l_granted_mode == lock->l_req_mode); @@ -176,7 +176,8 @@ void ldlm_extent_add_lock(struct ldlm_resource *res, /* node extent initialize */ extent = &lock->l_policy_data.l_extent; - interval_set(&node->li_node, extent->start, extent->end); + rc = interval_set(&node->li_node, extent->start, extent->end); + LASSERT(!rc); root = &res->lr_itree[idx].lit_root; found = interval_insert(&node->li_node, root); @@ -243,7 +244,6 @@ void ldlm_extent_unlink_lock(struct ldlm_lock *lock) void ldlm_extent_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, union ldlm_policy_data *lpolicy) { - memset(lpolicy, 0, sizeof(*lpolicy)); lpolicy->l_extent.start = wpolicy->l_extent.start; lpolicy->l_extent.end = wpolicy->l_extent.end; lpolicy->l_extent.gid = wpolicy->l_extent.gid; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 722160784f83..b7f28b39c7b3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int added = (mode == LCK_NL); int overlaps = 0; int splitted = 0; - const struct ldlm_callback_suite null_cbs = { NULL }; + const struct ldlm_callback_suite null_cbs = { }; CDEBUG(D_DLMTRACE, "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", @@ -615,7 +615,6 @@ EXPORT_SYMBOL(ldlm_flock_completion_ast); void ldlm_flock_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, union ldlm_policy_data *lpolicy) { - memset(lpolicy, 0, sizeof(*lpolicy)); lpolicy->l_flock.start = wpolicy->l_flock.lfw_start; lpolicy->l_flock.end = wpolicy->l_flock.lfw_end; lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c index 8e1709dc073c..ae37c3686b1b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c @@ -57,7 +57,6 @@ void ldlm_ibits_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, union ldlm_policy_data *lpolicy) { - memset(lpolicy, 0, sizeof(*lpolicy)); lpolicy->l_inodebits.bits = wpolicy->l_inodebits.bits; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 9be01426c955..3663c5cdb051 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -336,6 +336,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) INIT_LIST_HEAD(&cli->cl_lru_list); spin_lock_init(&cli->cl_lru_list_lock); atomic_long_set(&cli->cl_unstable_count, 0); + INIT_LIST_HEAD(&cli->cl_shrink_list); init_waitqueue_head(&cli->cl_destroy_waitq); atomic_set(&cli->cl_destroy_in_flight, 0); @@ -350,13 +351,11 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cli->cl_supp_cksum_types = OBD_CKSUM_CRC32; atomic_set(&cli->cl_resends, OSC_DEFAULT_RESENDS); - /* This value may be reduced at connect time in - * ptlrpc_connect_interpret() . We initialize it to only - * 1MB until we know what the performance looks like. - * In the future this should likely be increased. LU-1431 + /* + * Set it to possible maximum size. It may be reduced by ocd_brw_size + * from OFD after connecting. */ - cli->cl_max_pages_per_rpc = min_t(int, PTLRPC_MAX_BRW_PAGES, - LNET_MTU >> PAGE_SHIFT); + cli->cl_max_pages_per_rpc = PTLRPC_MAX_BRW_PAGES; /* * set cl_chunkbits default value to PAGE_CACHE_SHIFT, @@ -524,6 +523,8 @@ int client_connect_import(const struct lu_env *env, rc = ptlrpc_connect_import(imp); if (rc != 0) { + if (data && is_mdc) + data->ocd_connect_flags &= ~OBD_CONNECT_MULTIMODRPCS; LASSERT(imp->imp_state == LUSTRE_IMP_DISCON); goto out_ldlm; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index a4a291acb659..5a94265fe60b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -533,6 +533,13 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, if (!lock) return NULL; + if (lock->l_export && lock->l_export->exp_failed) { + CDEBUG(D_INFO, "lock export failed: lock %p, exp %p\n", + lock, lock->l_export); + LDLM_LOCK_PUT(lock); + return NULL; + } + /* It's unlikely but possible that someone marked the lock as * destroyed after we did handle2object on it */ @@ -1131,8 +1138,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) if (!data->lmd_unref && LDLM_HAVE_MASK(lock, GONE)) return INTERVAL_ITER_CONT; - if ((data->lmd_flags & LDLM_FL_LOCAL_ONLY) && - !ldlm_is_local(lock)) + if (!equi(data->lmd_flags & LDLM_FL_LOCAL_ONLY, ldlm_is_local(lock))) return INTERVAL_ITER_CONT; if (data->lmd_flags & LDLM_FL_TEST_LOCK) { @@ -1148,7 +1154,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) return INTERVAL_ITER_STOP; } -static unsigned int itree_overlap_cb(struct interval_node *in, void *args) +static enum interval_iter itree_overlap_cb(struct interval_node *in, void *args) { struct ldlm_interval *node = to_ldlm_interval(in); struct lock_match_data *data = args; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index c1f8693f94a5..ebfda368b057 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1972,7 +1972,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) LDLM_DEBUG(lock, "replaying lock:"); atomic_inc(&req->rq_import->imp_replay_inflight); - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->lock_handle = body->lock_handle[0]; req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index b22f5bae7201..d16f5e95ef0b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1368,7 +1368,7 @@ void ldlm_resource_dump(int level, struct ldlm_resource *res) struct ldlm_lock *lock; unsigned int granted = 0; - CLASSERT(RES_NAME_SIZE == 4); + BUILD_BUG_ON(RES_NAME_SIZE != 4); if (!((libcfs_debug | D_ERROR) & level)) return; diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 65bf0c401b44..966f580e26fb 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -247,17 +247,14 @@ static int ll_revalidate_dentry(struct dentry *dentry, return 1; /* - * if open&create is set, talk to MDS to make sure file is created if - * necessary, because we can't do this in ->open() later since that's - * called on an inode. return 0 here to let lookup to handle this. + * VFS warns us that this is the second go around and previous + * operation failed (most likely open|creat), so this time + * we better talk to the server via the lookup path by name, + * not by fid. */ - if ((lookup_flags & (LOOKUP_OPEN | LOOKUP_CREATE)) == - (LOOKUP_OPEN | LOOKUP_CREATE)) + if (lookup_flags & LOOKUP_REVAL) return 0; - if (lookup_flags & (LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE)) - return 1; - if (!dentry_may_statahead(dir, dentry)) return 1; diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index ea5d247a3f70..13b35922a4ca 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -432,7 +432,7 @@ static int ll_dir_setdirstripe(struct inode *parent, struct lmv_user_md *lump, if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent))) mode &= ~current_umask(); - mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; + mode = (mode & (0777 | S_ISVTX)) | S_IFDIR; op_data = ll_prep_md_op_data(NULL, parent, NULL, dirname, strlen(dirname), mode, LUSTRE_OPC_MKDIR, lump); @@ -521,12 +521,15 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, rc = md_setattr(sbi->ll_md_exp, op_data, lump, lum_size, &req); ll_finish_md_op_data(op_data); ptlrpc_req_finished(req); - if (rc) { - if (rc != -EPERM && rc != -EACCES) - CERROR("mdc_setattr fails: rc = %d\n", rc); - } + if (rc) + return rc; - /* In the following we use the fact that LOV_USER_MAGIC_V1 and +#if OBD_OCD_VERSION(2, 13, 53, 0) > LUSTRE_VERSION_CODE + /* + * 2.9 server has stored filesystem default stripe in ROOT xattr, + * and it's stored into system config for backward compatibility. + * + * In the following we use the fact that LOV_USER_MAGIC_V1 and * LOV_USER_MAGIC_V3 have the same initial fields so we do not * need to make the distinction between the 2 versions */ @@ -567,6 +570,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, end: kfree(param); } +#endif return rc; } diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index f634c11216e6..10adfcdd7035 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -122,26 +122,25 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, enum mds_op_bias bias, void *data) { - struct obd_export *exp = ll_i2mdexp(inode); + const struct ll_inode_info *lli = ll_i2info(inode); struct md_op_data *op_data; struct ptlrpc_request *req = NULL; - struct obd_device *obd = class_exp2obd(exp); int rc; - if (!obd) { - /* - * XXX: in case of LMV, is this correct to access - * ->exp_handle? - */ - CERROR("Invalid MDC connection handle %#llx\n", - ll_i2mdexp(inode)->exp_handle.h_cookie); + if (!class_exp2obd(md_exp)) { + CERROR("%s: invalid MDC connection handle closing " DFID "\n", + ll_get_fsname(inode->i_sb, NULL, 0), + PFID(&lli->lli_fid)); rc = 0; goto out; } op_data = kzalloc(sizeof(*op_data), GFP_NOFS); + /* + * We leak openhandle and request here on error, but not much to be + * done in OOM case since app won't retry close on error either. + */ if (!op_data) { - /* XXX We leak openhandle and request here. */ rc = -ENOMEM; goto out; } @@ -170,10 +169,9 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, } rc = md_close(md_exp, op_data, och->och_mod, &req); - if (rc) { - CERROR("%s: inode "DFID" mdc close failed: rc = %d\n", - ll_i2mdexp(inode)->exp_obd->obd_name, - PFID(ll_inode2fid(inode)), rc); + if (rc && rc != -EINTR) { + CERROR("%s: inode " DFID " mdc close failed: rc = %d\n", + md_exp->exp_obd->obd_name, PFID(&lli->lli_fid), rc); } if (op_data->op_bias & (MDS_HSM_RELEASE | MDS_CLOSE_LAYOUT_SWAP) && @@ -192,8 +190,7 @@ out: och->och_fh.cookie = DEAD_HANDLE_MAGIC; kfree(och); - if (req) /* This is close request */ - ptlrpc_req_finished(req); + ptlrpc_req_finished(req); return rc; } @@ -420,6 +417,17 @@ out: ptlrpc_req_finished(req); ll_intent_drop_lock(itp); + /* + * We did open by fid, but by the time we got to the server, + * the object disappeared. If this is a create, we cannot really + * tell the userspace that the file it was trying to create + * does not exist. Instead let's return -ESTALE, and the VFS will + * retry the create with LOOKUP_REVAL that we are going to catch + * in ll_revalidate_dentry() and use lookup then. + */ + if (rc == -ENOENT && itp->it_op & IT_CREAT) + rc = -ESTALE; + return rc; } @@ -1016,7 +1024,7 @@ static bool file_is_noatime(const struct file *file) return false; } -void ll_io_init(struct cl_io *io, const struct file *file, int write) +static void ll_io_init(struct cl_io *io, const struct file *file, int write) { struct inode *inode = file_inode(file); @@ -1821,7 +1829,7 @@ free: return rc; } -static int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss) +int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss) { struct md_op_data *op_data; int rc; @@ -1883,7 +1891,7 @@ static int ll_hsm_import(struct inode *inode, struct file *file, goto free_hss; } - attr->ia_mode = hui->hui_mode & (S_IRWXU | S_IRWXG | S_IRWXO); + attr->ia_mode = hui->hui_mode & 0777; attr->ia_mode |= S_IFREG; attr->ia_uid = make_kuid(&init_user_ns, hui->hui_uid); attr->ia_gid = make_kgid(&init_user_ns, hui->hui_gid); @@ -2618,18 +2626,18 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, ll_get_fsname(parent->i_sb, NULL, 0), name, PFID(&op_data->op_fid3)); rc = -EINVAL; - goto out_free; + goto out_unlock; } rc = ll_get_mdt_idx_by_fid(ll_i2sbi(parent), &op_data->op_fid3); if (rc < 0) - goto out_free; + goto out_unlock; if (rc == mdtidx) { CDEBUG(D_INFO, "%s:"DFID" is already on MDT%d.\n", name, PFID(&op_data->op_fid3), mdtidx); rc = 0; - goto out_free; + goto out_unlock; } again: if (S_ISREG(child_inode->i_mode)) { @@ -2637,13 +2645,13 @@ again: if (IS_ERR(och)) { rc = PTR_ERR(och); och = NULL; - goto out_free; + goto out_unlock; } rc = ll_data_version(child_inode, &data_version, LL_DV_WR_FLUSH); if (rc) - goto out_free; + goto out_close; op_data->op_handle = och->och_fh; op_data->op_data = och->och_mod; @@ -2656,40 +2664,45 @@ again: op_data->op_cli_flags = CLI_MIGRATE; rc = md_rename(ll_i2sbi(parent)->ll_md_exp, op_data, name, namelen, name, namelen, &request); - if (!rc) + if (!rc) { + LASSERT(request); ll_update_times(request, parent); - body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); - if (!body) { - rc = -EPROTO; - goto out_free; + body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); + LASSERT(body); + + /* + * If the server does release layout lock, then we cleanup + * the client och here, otherwise release it in out_close: + */ + if (och && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { + obd_mod_put(och->och_mod); + md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, + och); + och->och_fh.cookie = DEAD_HANDLE_MAGIC; + kfree(och); + och = NULL; + } } - /* - * If the server does release layout lock, then we cleanup - * the client och here, otherwise release it in out_free: - */ - if (och && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { - obd_mod_put(och->och_mod); - md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, och); - och->och_fh.cookie = DEAD_HANDLE_MAGIC; - kfree(och); - och = NULL; + if (request) { + ptlrpc_req_finished(request); + request = NULL; } - ptlrpc_req_finished(request); /* Try again if the file layout has changed. */ if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) goto again; -out_free: - if (child_inode) { - if (och) /* close the file */ - ll_lease_close(och, child_inode, NULL); - clear_nlink(child_inode); - inode_unlock(child_inode); - iput(child_inode); - } +out_close: + if (och) /* close the file */ + ll_lease_close(och, child_inode, NULL); + if (!rc) + clear_nlink(child_inode); +out_unlock: + inode_unlock(child_inode); + iput(child_inode); +out_free: ll_finish_md_op_data(op_data); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c index dd1cfd8f5213..f1036f477a51 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c @@ -94,6 +94,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr, io = vvp_env_thread_io(env); io->ci_obj = obj; + io->ci_verify_layout = 1; io->u.ci_setattr.sa_attr.lvb_atime = LTIME_S(attr->ia_atime); io->u.ci_setattr.sa_attr.lvb_mtime = LTIME_S(attr->ia_mtime); @@ -120,13 +121,7 @@ again: cl_io_fini(env, io); if (unlikely(io->ci_need_restart)) goto again; - /* HSM import case: file is released, cannot be restored - * no need to fail except if restore registration failed - * with -ENODATA - */ - if (result == -ENODATA && io->ci_restore_needed && - io->ci_result != -ENODATA) - result = 0; + cl_env_put(env, &refcheck); return result; } diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c b/drivers/staging/lustre/lustre/llite/lcommon_misc.c index f48660ed350f..f0c132e2cf92 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c @@ -33,6 +33,7 @@ * future). * */ +#define DEBUG_SUBSYSTEM S_LLITE #include "../include/obd_class.h" #include "../include/obd_support.h" #include "../include/obd.h" @@ -132,7 +133,6 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, io = vvp_env_thread_io(env); io->ci_obj = obj; - io->ci_ignore_layout = 1; rc = cl_io_init(env, io, CIT_MISC, io->ci_obj); if (rc != 0) { diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 065a9a7e120a..ecdfd0c29b7f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -281,10 +281,8 @@ static inline struct ll_inode_info *ll_i2info(struct inode *inode) return container_of(inode, struct ll_inode_info, lli_vfs_inode); } -/* default to about 40meg of readahead on a given system. That much tied - * up in 512k readahead requests serviced at 40ms each is about 1GB/s. - */ -#define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - PAGE_SHIFT)) +/* default to about 64M of readahead on a given system. */ +#define SBI_DEFAULT_READAHEAD_MAX (64UL << (20 - PAGE_SHIFT)) /* default to read-ahead full files smaller than 2MB on the second read */ #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - PAGE_SHIFT)) @@ -321,6 +319,9 @@ struct ll_ra_info { struct ra_io_arg { unsigned long ria_start; /* start offset of read-ahead*/ unsigned long ria_end; /* end offset of read-ahead*/ + unsigned long ria_reserved; /* reserved pages for read-ahead */ + unsigned long ria_end_min; /* minimum end to cover current read */ + bool ria_eof; /* reach end of file */ /* If stride read pattern is detected, ria_stoff means where * stride read is started. Note: for normal read-ahead, the * value here is meaningless, and also it will not be accessed @@ -505,6 +506,7 @@ struct ll_sb_info { */ /* root squash */ struct root_squash_info ll_squash; + struct path ll_mnt; __kernel_fsid_t ll_fsid; struct kobject ll_kobj; /* sysfs object */ @@ -551,6 +553,11 @@ struct ll_readahead_state { */ unsigned long ras_window_start, ras_window_len; /* + * Optimal RPC size. It decides how many pages will be sent + * for each read-ahead. + */ + unsigned long ras_rpc_size; + /* * Where next read-ahead should start at. This lies within read-ahead * window. Read-ahead window is read in pieces rather than at once * because: 1. lustre limits total number of pages under read-ahead by @@ -766,6 +773,7 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode); int ll_fid2path(struct inode *inode, void __user *arg); int ll_data_version(struct inode *inode, __u64 *data_version, int flags); int ll_hsm_release(struct inode *inode); +int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss); /* llite/dcache.c */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 25f5aed97f63..b229cbc7bb33 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -103,6 +103,7 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) sbi->ll_flags |= LL_SBI_CHECKSUM; sbi->ll_flags |= LL_SBI_LRU_RESIZE; + sbi->ll_flags |= LL_SBI_LAZYSTATFS; for (i = 0; i <= LL_PROCESS_HIST_MAX; i++) { spin_lock_init(&sbi->ll_rw_extents_info.pp_extents[i]. @@ -303,6 +304,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, sb->s_magic = LL_SUPER_MAGIC; sb->s_maxbytes = MAX_LFS_FILESIZE; sbi->ll_namelen = osfs->os_namelen; + sbi->ll_mnt.mnt = current->fs->root.mnt; if ((sbi->ll_flags & LL_SBI_USER_XATTR) && !(data->ocd_connect_flags & OBD_CONNECT_XATTR)) { @@ -1402,7 +1404,11 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data) * cache is not cleared yet. */ op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE); + if (S_ISREG(inode->i_mode)) + inode_lock(inode); rc = simple_setattr(dentry, &op_data->op_attr); + if (S_ISREG(inode->i_mode)) + inode_unlock(inode); op_data->op_attr.ia_valid = ia_valid; rc = ll_update_inode(inode, &md); @@ -1431,7 +1437,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) struct inode *inode = d_inode(dentry); struct ll_inode_info *lli = ll_i2info(inode); struct md_op_data *op_data = NULL; - bool file_is_released = false; int rc = 0; CDEBUG(D_VFSTRACE, "%s: setattr inode "DFID"(%p) from %llu to %llu, valid %x, hsm_import %d\n", @@ -1486,76 +1491,35 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime), (s64)ktime_get_real_seconds()); - /* We always do an MDS RPC, even if we're only changing the size; - * only the MDS knows whether truncate() should fail with -ETXTBUSY - */ - - op_data = kzalloc(sizeof(*op_data), GFP_NOFS); - if (!op_data) - return -ENOMEM; - - if (!S_ISDIR(inode->i_mode)) + if (S_ISREG(inode->i_mode)) inode_unlock(inode); - /* truncate on a released file must failed with -ENODATA, - * so size must not be set on MDS for released file - * but other attributes must be set + /* + * We always do an MDS RPC, even if we're only changing the size; + * only the MDS knows whether truncate() should fail with -ETXTBUSY */ - if (S_ISREG(inode->i_mode)) { - struct cl_layout cl = { - .cl_is_released = false, - }; - struct lu_env *env; - int refcheck; - __u32 gen; + op_data = kzalloc(sizeof(*op_data), GFP_NOFS); + if (!op_data) { + rc = -ENOMEM; + goto out; + } - rc = ll_layout_refresh(inode, &gen); - if (rc < 0) - goto out; + op_data->op_attr = *attr; + if (!hsm_import && attr->ia_valid & ATTR_SIZE) { /* - * XXX: the only place we need to know the layout type, - * this will be removed by a later patch. -Jinshan + * If we are changing file size, file content is + * modified, flag it. */ - env = cl_env_get(&refcheck); - if (IS_ERR(env)) { - rc = PTR_ERR(env); - goto out; - } - - rc = cl_object_layout_get(env, lli->lli_clob, &cl); - cl_env_put(env, &refcheck); - if (rc < 0) - goto out; - - file_is_released = cl.cl_is_released; - - if (!hsm_import && attr->ia_valid & ATTR_SIZE) { - if (file_is_released) { - rc = ll_layout_restore(inode, 0, attr->ia_size); - if (rc < 0) - goto out; - - file_is_released = false; - ll_layout_refresh(inode, &gen); - } - - /* - * If we are changing file size, file content is - * modified, flag it. - */ - attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE; - op_data->op_bias |= MDS_DATA_MODIFIED; - } + attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE; + op_data->op_bias |= MDS_DATA_MODIFIED; } - memcpy(&op_data->op_attr, attr, sizeof(*attr)); - rc = ll_md_setattr(dentry, op_data); if (rc) goto out; - if (!S_ISREG(inode->i_mode) || file_is_released) { + if (!S_ISREG(inode->i_mode) || hsm_import) { rc = 0; goto out; } @@ -1572,11 +1536,40 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) */ rc = cl_setattr_ost(ll_i2info(inode)->lli_clob, attr, 0); } + + /* + * If the file was restored, it needs to set dirty flag. + * + * We've already sent MDS_DATA_MODIFIED flag in + * ll_md_setattr() for truncate. However, the MDT refuses to + * set the HS_DIRTY flag on released files, so we have to set + * it again if the file has been restored. Please check how + * LLIF_DATA_MODIFIED is set in vvp_io_setattr_fini(). + * + * Please notice that if the file is not released, the previous + * MDS_DATA_MODIFIED has taken effect and usually + * LLIF_DATA_MODIFIED is not set(see vvp_io_setattr_fini()). + * This way we can save an RPC for common open + trunc + * operation. + */ + if (test_and_clear_bit(LLIF_DATA_MODIFIED, &lli->lli_flags)) { + struct hsm_state_set hss = { + .hss_valid = HSS_SETMASK, + .hss_setmask = HS_DIRTY, + }; + int rc2; + + rc2 = ll_hsm_state_set(inode, &hss); + if (rc2 < 0) + CERROR(DFID "HSM set dirty failed: rc2 = %d\n", + PFID(ll_inode2fid(inode)), rc2); + } + out: if (op_data) ll_finish_md_op_data(op_data); - if (!S_ISDIR(inode->i_mode)) { + if (S_ISREG(inode->i_mode)) { inode_lock(inode); if ((attr->ia_valid & ATTR_SIZE) && !hsm_import) inode_dio_wait(inode); @@ -1599,7 +1592,7 @@ int ll_setattr(struct dentry *de, struct iattr *attr) if (((attr->ia_valid & (ATTR_MODE | ATTR_FORCE | ATTR_SIZE)) == (ATTR_SIZE | ATTR_MODE)) && (((mode & S_ISUID) && !(attr->ia_mode & S_ISUID)) || - (((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) && + (((mode & (S_ISGID | 0010)) == (S_ISGID | 0010)) && !(attr->ia_mode & S_ISGID)))) attr->ia_valid |= ATTR_FORCE; @@ -1610,7 +1603,7 @@ int ll_setattr(struct dentry *de, struct iattr *attr) attr->ia_valid |= ATTR_KILL_SUID; if ((attr->ia_valid & ATTR_MODE) && - ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) && + ((mode & (S_ISGID | 0010)) == (S_ISGID | 0010)) && !(attr->ia_mode & S_ISGID) && !(attr->ia_valid & ATTR_KILL_SGID)) attr->ia_valid |= ATTR_KILL_SGID; @@ -1998,6 +1991,8 @@ void ll_umount_begin(struct super_block *sb) struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; struct obd_ioctl_data *ioc_data; + wait_queue_head_t waitq; + struct l_wait_info lwi; CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, sb->s_count, atomic_read(&sb->s_active)); @@ -2030,9 +2025,14 @@ void ll_umount_begin(struct super_block *sb) } /* Really, we'd like to wait until there are no requests outstanding, - * and then continue. For now, we just invalidate the requests, - * schedule() and sleep one second if needed, and hope. + * and then continue. For now, we just periodically checking for vfs + * to decrement mnt_cnt and hope to finish it within 10sec. */ + init_waitqueue_head(&waitq); + lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(10), + cfs_time_seconds(1), NULL, NULL); + l_wait_event(waitq, may_umount(sbi->ll_mnt.mnt), &lwi); + schedule(); } diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 03682c10fc9e..f3ee584157e0 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -924,27 +924,29 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, } LPROC_SEQ_FOPS(ll_unstable_stats); -static ssize_t root_squash_show(struct kobject *kobj, struct attribute *attr, - char *buf) +static int ll_root_squash_seq_show(struct seq_file *m, void *v) { - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + struct super_block *sb = m->private; + struct ll_sb_info *sbi = ll_s2sbi(sb); struct root_squash_info *squash = &sbi->ll_squash; - return sprintf(buf, "%u:%u\n", squash->rsi_uid, squash->rsi_gid); + seq_printf(m, "%u:%u\n", squash->rsi_uid, squash->rsi_gid); + return 0; } -static ssize_t root_squash_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, size_t count) +static ssize_t ll_root_squash_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + struct seq_file *m = file->private_data; + struct super_block *sb = m->private; + struct ll_sb_info *sbi = ll_s2sbi(sb); struct root_squash_info *squash = &sbi->ll_squash; return lprocfs_wr_root_squash(buffer, count, squash, - ll_get_fsname(sbi->ll_sb, NULL, 0)); + ll_get_fsname(sb, NULL, 0)); } -LUSTRE_RW_ATTR(root_squash); +LPROC_SEQ_FOPS(ll_root_squash); static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v) { @@ -997,6 +999,8 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, { "unstable_stats", &ll_unstable_stats_fops, NULL }, { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, + { .name = "root_squash", + .fops = &ll_root_squash_fops }, { .name = "nosquash_nids", .fops = &ll_nosquash_nids_fops }, { NULL } @@ -1027,7 +1031,6 @@ static struct attribute *llite_attrs[] = { &lustre_attr_max_easize.attr, &lustre_attr_default_easize.attr, &lustre_attr_xattr_cache.attr, - &lustre_attr_root_squash.attr, NULL, }; diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index a8f4e7fb0a46..fc176540bb95 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -994,11 +994,6 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry, return rc; } -/* ll_unlink() doesn't update the inode with the new link count. - * Instead, ll_ddelete() and ll_d_iput() will update it based upon if there - * is any lock existing. They will recycle dentries and inodes based upon locks - * too. b=20433 - */ static int ll_unlink(struct inode *dir, struct dentry *dchild) { struct ptlrpc_request *request = NULL; @@ -1041,7 +1036,7 @@ static int ll_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) if (!IS_POSIXACL(dir) || !exp_connect_umask(ll_i2mdexp(dir))) mode &= ~current_umask(); - mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR; + mode = (mode & (0777 | S_ISVTX)) | S_IFDIR; err = ll_new_node(dir, dentry, NULL, mode, 0, LUSTRE_OPC_MKDIR); if (!err) @@ -1089,7 +1084,7 @@ static int ll_symlink(struct inode *dir, struct dentry *dentry, CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, dir="DFID"(%p),target=%.*s\n", dentry, PFID(ll_inode2fid(dir)), dir, 3000, oldname); - err = ll_new_node(dir, dentry, oldname, S_IFLNK | S_IRWXUGO, + err = ll_new_node(dir, dentry, oldname, S_IFLNK | 0777, 0, LUSTRE_OPC_SYMLINK); if (!err) diff --git a/drivers/staging/lustre/lustre/llite/range_lock.c b/drivers/staging/lustre/lustre/llite/range_lock.c index 94c818f1478b..14148a097476 100644 --- a/drivers/staging/lustre/lustre/llite/range_lock.c +++ b/drivers/staging/lustre/lustre/llite/range_lock.c @@ -61,17 +61,23 @@ void range_lock_tree_init(struct range_lock_tree *tree) * Pre: Caller should have allocated the range lock node. * Post: The range lock node is meant to cover [start, end] region */ -void range_lock_init(struct range_lock *lock, __u64 start, __u64 end) +int range_lock_init(struct range_lock *lock, __u64 start, __u64 end) { + int rc; + memset(&lock->rl_node, 0, sizeof(lock->rl_node)); if (end != LUSTRE_EOF) end >>= PAGE_SHIFT; - interval_set(&lock->rl_node, start >> PAGE_SHIFT, end); + rc = interval_set(&lock->rl_node, start >> PAGE_SHIFT, end); + if (rc) + return rc; + INIT_LIST_HEAD(&lock->rl_next_lock); lock->rl_task = NULL; lock->rl_lock_count = 0; lock->rl_blocking_ranges = 0; lock->rl_sequence = 0; + return rc; } static inline struct range_lock *next_lock(struct range_lock *lock) diff --git a/drivers/staging/lustre/lustre/llite/range_lock.h b/drivers/staging/lustre/lustre/llite/range_lock.h index c6d04a6f99fd..779091ccec4e 100644 --- a/drivers/staging/lustre/lustre/llite/range_lock.h +++ b/drivers/staging/lustre/lustre/llite/range_lock.h @@ -76,7 +76,7 @@ struct range_lock_tree { }; void range_lock_tree_init(struct range_lock_tree *tree); -void range_lock_init(struct range_lock *lock, __u64 start, __u64 end); +int range_lock_init(struct range_lock *lock, __u64 start, __u64 end); int range_lock(struct range_lock_tree *tree, struct range_lock *lock); void range_unlock(struct range_lock_tree *tree, struct range_lock *lock); #endif diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index f10e092979fe..50d027e0cfab 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -92,25 +92,6 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, goto out; } - /* If the non-strided (ria_pages == 0) readahead window - * (ria_start + ret) has grown across an RPC boundary, then trim - * readahead size by the amount beyond the RPC so it ends on an - * RPC boundary. If the readahead window is already ending on - * an RPC boundary (beyond_rpc == 0), or smaller than a full - * RPC (beyond_rpc < ret) the readahead size is unchanged. - * The (beyond_rpc != 0) check is skipped since the conditional - * branch is more expensive than subtracting zero from the result. - * - * Strided read is left unaligned to avoid small fragments beyond - * 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; - } - if (atomic_add_return(ret, &ra->ra_cur_pages) > ra->ra_max_pages) { atomic_sub(ret, &ra->ra_cur_pages); ret = 0; @@ -147,11 +128,12 @@ void ll_ra_stats_inc(struct inode *inode, enum ra_stat which) #define RAS_CDEBUG(ras) \ CDEBUG(D_READA, \ - "lrp %lu cr %lu cp %lu ws %lu wl %lu nra %lu r %lu ri %lu" \ - "csr %lu sf %lu sp %lu sl %lu\n", \ + "lrp %lu cr %lu cp %lu ws %lu wl %lu nra %lu rpc %lu " \ + "r %lu ri %lu csr %lu sf %lu sp %lu sl %lu\n", \ ras->ras_last_readpage, ras->ras_consecutive_requests, \ ras->ras_consecutive_pages, ras->ras_window_start, \ ras->ras_window_len, ras->ras_next_readahead, \ + ras->ras_rpc_size, \ ras->ras_requests, ras->ras_request_index, \ ras->ras_consecutive_stride_requests, ras->ras_stride_offset, \ ras->ras_stride_pages, ras->ras_stride_length) @@ -261,20 +243,6 @@ out: ria->ria_start, ria->ria_end, ria->ria_stoff, ria->ria_length,\ ria->ria_pages) -/* Limit this to the blocksize instead of PTLRPC_BRW_MAX_SIZE, since we don't - * know what the actual RPC size is. If this needs to change, it makes more - * sense to tune the i_blkbits value for the file based on the OSTs it is - * striped over, rather than having a constant value for all files here. - */ - -/* RAS_INCREASE_STEP should be (1UL << (inode->i_blkbits - PAGE_SHIFT)). - * Temporarily set RAS_INCREASE_STEP to 1MB. After 4MB RPC is enabled - * by default, this should be adjusted corresponding with max_read_ahead_mb - * and max_read_ahead_per_file_mb otherwise the readahead budget can be used - * up quickly which will affect read performance significantly. See LU-2816 - */ -#define RAS_INCREASE_STEP(inode) (ONE_MB_BRW_SIZE >> PAGE_SHIFT) - static inline int stride_io_mode(struct ll_readahead_state *ras) { return ras->ras_consecutive_stride_requests > 1; @@ -345,6 +313,17 @@ static int ria_page_count(struct ra_io_arg *ria) length); } +static unsigned long ras_align(struct ll_readahead_state *ras, + unsigned long index, + unsigned long *remainder) +{ + unsigned long rem = index % ras->ras_rpc_size; + + if (remainder) + *remainder = rem; + return index - rem; +} + /*Check whether the index is in the defined ra-window */ static int ras_inside_ra_window(unsigned long idx, struct ra_io_arg *ria) { @@ -358,42 +337,63 @@ static int ras_inside_ra_window(unsigned long idx, struct ra_io_arg *ria) ria->ria_length < ria->ria_pages); } -static int ll_read_ahead_pages(const struct lu_env *env, - struct cl_io *io, struct cl_page_list *queue, - struct ra_io_arg *ria, - unsigned long *reserved_pages, - pgoff_t *ra_end) +static unsigned long +ll_read_ahead_pages(const struct lu_env *env, struct cl_io *io, + struct cl_page_list *queue, struct ll_readahead_state *ras, + struct ra_io_arg *ria) { struct cl_read_ahead ra = { 0 }; - int rc, count = 0; + unsigned long ra_end = 0; bool stride_ria; pgoff_t page_idx; + int rc; LASSERT(ria); RIA_DEBUG(ria); stride_ria = ria->ria_length > ria->ria_pages && ria->ria_pages > 0; for (page_idx = ria->ria_start; - page_idx <= ria->ria_end && *reserved_pages > 0; page_idx++) { + page_idx <= ria->ria_end && ria->ria_reserved > 0; page_idx++) { if (ras_inside_ra_window(page_idx, ria)) { if (!ra.cra_end || ra.cra_end < page_idx) { + unsigned long end; + cl_read_ahead_release(env, &ra); rc = cl_io_read_ahead(env, io, page_idx, &ra); if (rc < 0) break; + CDEBUG(D_READA, "idx: %lu, ra: %lu, rpc: %lu\n", + page_idx, ra.cra_end, ra.cra_rpc_size); LASSERTF(ra.cra_end >= page_idx, "object: %p, indcies %lu / %lu\n", io->ci_obj, ra.cra_end, page_idx); + /* + * update read ahead RPC size. + * NB: it's racy but doesn't matter + */ + if (ras->ras_rpc_size > ra.cra_rpc_size && + ra.cra_rpc_size > 0) + ras->ras_rpc_size = ra.cra_rpc_size; + /* trim it to align with optimal RPC size */ + end = ras_align(ras, ria->ria_end + 1, NULL); + if (end > 0 && !ria->ria_eof) + ria->ria_end = end - 1; + if (ria->ria_end < ria->ria_end_min) + ria->ria_end = ria->ria_end_min; + if (ria->ria_end > ra.cra_end) + ria->ria_end = ra.cra_end; } - /* If the page is inside the read-ahead window*/ + /* If the page is inside the read-ahead window */ rc = ll_read_ahead_page(env, io, queue, page_idx); - if (!rc) { - (*reserved_pages)--; - count++; - } + if (rc < 0) + break; + + ra_end = page_idx; + if (!rc) + ria->ria_reserved--; } else if (stride_ria) { /* If it is not in the read-ahead window, and it is * read-ahead mode, then check whether it should skip @@ -420,8 +420,7 @@ static int ll_read_ahead_pages(const struct lu_env *env, } cl_read_ahead_release(env, &ra); - *ra_end = page_idx; - return count; + return ra_end; } static int ll_readahead(const struct lu_env *env, struct cl_io *io, @@ -431,7 +430,7 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io, struct vvp_io *vio = vvp_env_io(env); struct ll_thread_info *lti = ll_env_info(env); struct cl_attr *attr = vvp_env_thread_attr(env); - unsigned long len, mlen = 0, reserved; + unsigned long len, mlen = 0; pgoff_t ra_end, start = 0, end = 0; struct inode *inode; struct ra_io_arg *ria = <i->lti_ria; @@ -478,29 +477,15 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io, end < vio->vui_ra_start + vio->vui_ra_count - 1) end = vio->vui_ra_start + vio->vui_ra_count - 1; - if (end != 0) { - unsigned long rpc_boundary; - /* - * Align RA window to an optimal boundary. - * - * XXX This would be better to align to cl_max_pages_per_rpc - * instead of PTLRPC_MAX_BRW_PAGES, because the RPC size may - * be aligned to the RAID stripe size in the future and that - * is more important than the RPC size. - */ - /* Note: we only trim the RPC, instead of extending the RPC - * to the boundary, so to avoid reading too much pages during - * random reading. - */ - rpc_boundary = (end + 1) & (~(PTLRPC_MAX_BRW_PAGES - 1)); - if (rpc_boundary > 0) - rpc_boundary--; - - if (rpc_boundary > start) - end = rpc_boundary; + if (end) { + unsigned long end_index; /* Truncate RA window to end of file */ - end = min(end, (unsigned long)((kms - 1) >> PAGE_SHIFT)); + end_index = (unsigned long)((kms - 1) >> PAGE_SHIFT); + if (end_index <= end) { + end = end_index; + ria->ria_eof = true; + } ras->ras_next_readahead = max(end, end + 1); RAS_CDEBUG(ras); @@ -535,28 +520,31 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io, /* at least to extend the readahead window to cover current read */ if (!hit && vio->vui_ra_valid && vio->vui_ra_start + vio->vui_ra_count > ria->ria_start) { + unsigned long remainder; + /* to the end of current read window. */ mlen = vio->vui_ra_start + vio->vui_ra_count - ria->ria_start; /* trim to RPC boundary */ - start = ria->ria_start & (PTLRPC_MAX_BRW_PAGES - 1); - mlen = min(mlen, PTLRPC_MAX_BRW_PAGES - start); + ras_align(ras, ria->ria_start, &remainder); + mlen = min(mlen, ras->ras_rpc_size - remainder); + ria->ria_end_min = ria->ria_start + mlen; } - reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len, mlen); - if (reserved < len) + ria->ria_reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len, mlen); + if (ria->ria_reserved < len) ll_ra_stats_inc(inode, RA_STAT_MAX_IN_FLIGHT); CDEBUG(D_READA, "reserved pages %lu/%lu/%lu, ra_cur %d, ra_max %lu\n", - reserved, len, mlen, + ria->ria_reserved, len, mlen, atomic_read(&ll_i2sbi(inode)->ll_ra_info.ra_cur_pages), ll_i2sbi(inode)->ll_ra_info.ra_max_pages); - ret = ll_read_ahead_pages(env, io, queue, ria, &reserved, &ra_end); + ra_end = ll_read_ahead_pages(env, io, queue, ras, ria); - if (reserved != 0) - ll_ra_count_put(ll_i2sbi(inode), reserved); + if (ria->ria_reserved) + ll_ra_count_put(ll_i2sbi(inode), ria->ria_reserved); - if (ra_end == end + 1 && ra_end == (kms >> PAGE_SHIFT)) + if (ra_end == end && ra_end == (kms >> PAGE_SHIFT)) ll_ra_stats_inc(inode, RA_STAT_EOF); /* if we didn't get to the end of the region we reserved from @@ -568,13 +556,13 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io, CDEBUG(D_READA, "ra_end = %lu end = %lu stride end = %lu pages = %d\n", ra_end, end, ria->ria_end, ret); - if (ra_end != end + 1) { + if (ra_end > 0 && ra_end != end) { ll_ra_stats_inc(inode, RA_STAT_FAILED_REACH_END); spin_lock(&ras->ras_lock); - if (ra_end < ras->ras_next_readahead && + if (ra_end <= ras->ras_next_readahead && index_in_window(ra_end, ras->ras_window_start, 0, ras->ras_window_len)) { - ras->ras_next_readahead = ra_end; + ras->ras_next_readahead = ra_end + 1; RAS_CDEBUG(ras); } spin_unlock(&ras->ras_lock); @@ -586,7 +574,7 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io, static void ras_set_start(struct inode *inode, struct ll_readahead_state *ras, unsigned long index) { - ras->ras_window_start = index & (~(RAS_INCREASE_STEP(inode) - 1)); + ras->ras_window_start = ras_align(ras, index, NULL); } /* called with the ras_lock held or from places where it doesn't matter */ @@ -615,6 +603,7 @@ static void ras_stride_reset(struct ll_readahead_state *ras) void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras) { spin_lock_init(&ras->ras_lock); + ras->ras_rpc_size = PTLRPC_MAX_BRW_PAGES; ras_reset(inode, ras, 0); ras->ras_requests = 0; } @@ -719,12 +708,15 @@ static void ras_increase_window(struct inode *inode, * but current clio architecture does not support retrieve such * information from lower layer. FIXME later */ - if (stride_io_mode(ras)) - ras_stride_increase_window(ras, ra, RAS_INCREASE_STEP(inode)); - else - ras->ras_window_len = min(ras->ras_window_len + - RAS_INCREASE_STEP(inode), - ra->ra_max_pages_per_file); + if (stride_io_mode(ras)) { + ras_stride_increase_window(ras, ra, ras->ras_rpc_size); + } else { + unsigned long wlen; + + wlen = min(ras->ras_window_len + ras->ras_rpc_size, + ra->ra_max_pages_per_file); + ras->ras_window_len = ras_align(ras, wlen, NULL); + } } static void ras_update(struct ll_sb_info *sbi, struct inode *inode, @@ -737,6 +729,10 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode, spin_lock(&ras->ras_lock); + if (!hit) + CDEBUG(D_READA, DFID " pages at %lu miss.\n", + PFID(ll_inode2fid(inode)), index); + ll_ra_stats_inc_sbi(sbi, hit ? RA_STAT_HIT : RA_STAT_MISS); /* reset the read-ahead window in two cases. First when the app seeks @@ -852,6 +848,8 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode, * instead of ras_window_start, which is RPC aligned */ ras->ras_next_readahead = max(index, ras->ras_next_readahead); + ras->ras_window_start = max(ras->ras_stride_offset, + ras->ras_window_start); } else { if (ras->ras_next_readahead < ras->ras_window_start) ras->ras_next_readahead = ras->ras_window_start; @@ -881,7 +879,7 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode, */ ras->ras_next_readahead = max(index, ras->ras_next_readahead); ras->ras_stride_offset = index; - ras->ras_window_len = RAS_INCREASE_STEP(inode); + ras->ras_window_start = max(index, ras->ras_window_start); } /* The initial ras_window_len is set to the request size. To avoid @@ -1098,38 +1096,39 @@ static int ll_io_read_page(const struct lu_env *env, struct cl_io *io, struct cl_2queue *queue = &io->ci_queue; struct ll_sb_info *sbi = ll_i2sbi(inode); struct vvp_page *vpg; + bool uptodate; int rc = 0; vpg = cl2vvp_page(cl_object_page_slice(page->cp_obj, page)); + uptodate = vpg->vpg_defer_uptodate; + if (sbi->ll_ra_info.ra_max_pages_per_file > 0 && sbi->ll_ra_info.ra_max_pages > 0) { struct vvp_io *vio = vvp_env_io(env); enum ras_update_flags flags = 0; - if (vpg->vpg_defer_uptodate) + if (uptodate) flags |= LL_RAS_HIT; if (!vio->vui_ra_valid) flags |= LL_RAS_MMAP; ras_update(sbi, inode, ras, vvp_index(vpg), flags); } - if (vpg->vpg_defer_uptodate) { + cl_2queue_init(queue); + if (uptodate) { vpg->vpg_ra_used = 1; cl_page_export(env, page, 1); + cl_page_disown(env, io, page); + } else { + cl_page_list_add(&queue->c2_qin, page); } - cl_2queue_init(queue); - /* - * Add page into the queue even when it is marked uptodate above. - * this will unlock it automatically as part of cl_page_list_disown(). - */ - cl_page_list_add(&queue->c2_qin, page); if (sbi->ll_ra_info.ra_max_pages_per_file > 0 && sbi->ll_ra_info.ra_max_pages > 0) { int rc2; rc2 = ll_readahead(env, io, &queue->c2_qin, ras, - vpg->vpg_defer_uptodate); + uptodate); CDEBUG(D_READA, DFID "%d pages read ahead at %lu\n", PFID(ll_inode2fid(inode)), rc2, vvp_index(vpg)); } diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 21e06e5b514e..d89e79599199 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -345,6 +345,10 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter) ssize_t tot_bytes = 0, result = 0; long size = MAX_DIO_SIZE; + /* Check EOF by ourselves */ + if (iov_iter_rw(iter) == READ && file_offset >= i_size_read(inode)) + return 0; + /* FIXME: io smaller than PAGE_SIZE is broken on ia64 ??? */ if ((file_offset & ~PAGE_MASK) || (count & ~PAGE_MASK)) return -EINVAL; diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index f1ee17f9ec0d..fb7c315b33cb 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -79,6 +79,8 @@ struct sa_entry { struct inode *se_inode; /* entry name */ struct qstr se_qstr; + /* entry fid */ + struct lu_fid se_fid; }; static unsigned int sai_generation; @@ -169,7 +171,7 @@ static inline int is_omitted_entry(struct ll_statahead_info *sai, __u64 index) /* allocate sa_entry and hash it to allow scanner process to find it */ static struct sa_entry * sa_alloc(struct dentry *parent, struct ll_statahead_info *sai, __u64 index, - const char *name, int len) + const char *name, int len, const struct lu_fid *fid) { struct ll_inode_info *lli; struct sa_entry *entry; @@ -194,6 +196,7 @@ sa_alloc(struct dentry *parent, struct ll_statahead_info *sai, __u64 index, entry->se_qstr.hash = full_name_hash(parent, name, len); entry->se_qstr.len = len; entry->se_qstr.name = dname; + entry->se_fid = *fid; lli = ll_i2info(sai->sai_dentry->d_inode); spin_lock(&lli->lli_sa_lock); @@ -566,24 +569,8 @@ static void sa_instantiate(struct ll_statahead_info *sai, } child = entry->se_inode; - if (!child) { - /* - * lookup. - */ - LASSERT(fid_is_zero(&minfo->mi_data.op_fid2)); - - /* XXX: No fid in reply, this is probably cross-ref case. - * SA can't handle it yet. - */ - if (body->mbo_valid & OBD_MD_MDS) { - rc = -EAGAIN; - goto out; - } - } else { - /* - * revalidate. - */ - /* unlinked and re-created with the same name */ + if (child) { + /* revalidate; unlinked and re-created with the same name */ if (unlikely(!lu_fid_eq(&minfo->mi_data.op_fid2, &body->mbo_fid1))) { entry->se_inode = NULL; iput(child); @@ -720,50 +707,42 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, } /* finish async stat RPC arguments */ -static void sa_fini_data(struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo) +static void sa_fini_data(struct md_enqueue_info *minfo) { - LASSERT(minfo && einfo); iput(minfo->mi_dir); kfree(minfo); - kfree(einfo); } /** * prepare arguments for async stat RPC. */ -static int sa_prep_data(struct inode *dir, struct inode *child, - struct sa_entry *entry, struct md_enqueue_info **pmi, - struct ldlm_enqueue_info **pei) +static struct md_enqueue_info * +sa_prep_data(struct inode *dir, struct inode *child, struct sa_entry *entry) { - const struct qstr *qstr = &entry->se_qstr; struct md_enqueue_info *minfo; struct ldlm_enqueue_info *einfo; struct md_op_data *op_data; - einfo = kzalloc(sizeof(*einfo), GFP_NOFS); - if (!einfo) - return -ENOMEM; - minfo = kzalloc(sizeof(*minfo), GFP_NOFS); - if (!minfo) { - kfree(einfo); - return -ENOMEM; - } + if (!minfo) + return ERR_PTR(-ENOMEM); - op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child, qstr->name, - qstr->len, 0, LUSTRE_OPC_ANY, NULL); + op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child, NULL, 0, 0, + LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) { - kfree(einfo); kfree(minfo); - return PTR_ERR(op_data); + return (struct md_enqueue_info *)op_data; } + if (!child) + op_data->op_fid2 = entry->se_fid; + minfo->mi_it.it_op = IT_GETATTR; minfo->mi_dir = igrab(dir); minfo->mi_cb = ll_statahead_interpret; minfo->mi_cbdata = entry; + einfo = &minfo->mi_einfo; einfo->ei_type = LDLM_IBITS; einfo->ei_mode = it_to_lock_mode(&minfo->mi_it); einfo->ei_cb_bl = ll_md_blocking_ast; @@ -771,26 +750,22 @@ static int sa_prep_data(struct inode *dir, struct inode *child, einfo->ei_cb_gl = NULL; einfo->ei_cbdata = NULL; - *pmi = minfo; - *pei = einfo; - - return 0; + return minfo; } /* async stat for file not found in dcache */ static int sa_lookup(struct inode *dir, struct sa_entry *entry) { struct md_enqueue_info *minfo; - struct ldlm_enqueue_info *einfo; int rc; - rc = sa_prep_data(dir, NULL, entry, &minfo, &einfo); - if (rc) - return rc; + minfo = sa_prep_data(dir, NULL, entry); + if (IS_ERR(minfo)) + return PTR_ERR(minfo); - rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); + rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo); if (rc) - sa_fini_data(minfo, einfo); + sa_fini_data(minfo); return rc; } @@ -809,7 +784,6 @@ static int sa_revalidate(struct inode *dir, struct sa_entry *entry, struct lookup_intent it = { .it_op = IT_GETATTR, .it_lock_handle = 0 }; struct md_enqueue_info *minfo; - struct ldlm_enqueue_info *einfo; int rc; if (unlikely(!inode)) @@ -827,25 +801,26 @@ static int sa_revalidate(struct inode *dir, struct sa_entry *entry, return 1; } - rc = sa_prep_data(dir, inode, entry, &minfo, &einfo); - if (rc) { + minfo = sa_prep_data(dir, inode, entry); + if (IS_ERR(minfo)) { entry->se_inode = NULL; iput(inode); - return rc; + return PTR_ERR(minfo); } - rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); + rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo); if (rc) { entry->se_inode = NULL; iput(inode); - sa_fini_data(minfo, einfo); + sa_fini_data(minfo); } return rc; } /* async stat for file with @name */ -static void sa_statahead(struct dentry *parent, const char *name, int len) +static void sa_statahead(struct dentry *parent, const char *name, int len, + const struct lu_fid *fid) { struct inode *dir = d_inode(parent); struct ll_inode_info *lli = ll_i2info(dir); @@ -854,7 +829,7 @@ static void sa_statahead(struct dentry *parent, const char *name, int len) struct sa_entry *entry; int rc; - entry = sa_alloc(parent, sai, sai->sai_index, name, len); + entry = sa_alloc(parent, sai, sai->sai_index, name, len, fid); if (IS_ERR(entry)) return; @@ -1043,6 +1018,7 @@ static int ll_statahead_thread(void *arg) for (ent = lu_dirent_start(dp); ent && thread_is_running(sa_thread) && !sa_low_hit(sai); ent = lu_dirent_next(ent)) { + struct lu_fid fid; __u64 hash; int namelen; char *name; @@ -1088,6 +1064,8 @@ static int ll_statahead_thread(void *arg) if (unlikely(++first == 1)) continue; + fid_le_to_cpu(&fid, &ent->lde_fid); + /* wait for spare statahead window */ do { l_wait_event(sa_thread->t_ctl_waitq, @@ -1117,7 +1095,7 @@ static int ll_statahead_thread(void *arg) } while (sa_sent_full(sai) && thread_is_running(sa_thread)); - sa_statahead(parent, name, namelen); + sa_statahead(parent, name, namelen, &fid); } pos = le64_to_cpu(dp->ldp_hash_end); diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 106cd00910a7..4759802e062d 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -88,7 +88,7 @@ static int __init lustre_init(void) struct timespec64 ts; int i, rc, seed[2]; - CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1); + BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) != LUSTRE_VOLATILE_HDR_LEN + 1); /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 12c129f7e4ad..3669ea77ee93 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -391,7 +391,7 @@ struct vvp_pgcache_id { static void vvp_pgcache_id_unpack(loff_t pos, struct vvp_pgcache_id *id) { - CLASSERT(sizeof(pos) == sizeof(__u64)); + BUILD_BUG_ON(sizeof(pos) != sizeof(__u64)); id->vpi_index = pos & 0xffffffff; id->vpi_depth = (pos >> PGC_DEPTH_SHIFT) & 0xf; diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index c60d0414ac25..f40fd7f115d1 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -301,8 +301,6 @@ static inline struct vvp_lock *cl2vvp_lock(const struct cl_lock_slice *slice) # define CLOBINVRNT(env, clob, expr) \ ((void)sizeof(env), (void)sizeof(clob), (void)sizeof(!!(expr))) -int lov_read_and_clear_async_rc(struct cl_object *clob); - int vvp_io_init(const struct lu_env *env, struct cl_object *obj, struct cl_io *io); int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io); diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 697cbfbe9374..3e9cf710501b 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -288,7 +288,7 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) io->ci_ignore_layout, io->ci_verify_layout, vio->vui_layout_gen, io->ci_restore_needed); - if (io->ci_restore_needed == 1) { + if (io->ci_restore_needed) { int rc; /* file was detected release, we need to restore it @@ -657,7 +657,15 @@ static void vvp_io_setattr_end(const struct lu_env *env, static void vvp_io_setattr_fini(const struct lu_env *env, const struct cl_io_slice *ios) { + bool restore_needed = ios->cis_io->ci_restore_needed; + struct inode *inode = vvp_object_inode(ios->cis_obj); + vvp_io_fini(env, ios); + + if (restore_needed && !ios->cis_io->ci_restore_needed) { + /* restore finished, set data modified flag for HSM */ + set_bit(LLIF_DATA_MODIFIED, &(ll_i2info(inode))->lli_flags); + } } static int vvp_io_read_start(const struct lu_env *env, @@ -1340,13 +1348,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, io->ci_lockreq = CILR_MANDATORY; } - /* ignore layout change for generic CIT_MISC but not for glimpse. - * io context for glimpse must set ci_verify_layout to true, - * see cl_glimpse_size0() for details. - */ - if (io->ci_type == CIT_MISC && !io->ci_verify_layout) - io->ci_ignore_layout = 1; - /* Enqueue layout lock and get layout version. We need to do this * even for operations requiring to open file, such as read and write, * because it might not grant layout lock in IT_OPEN. diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 23d66308ff20..687c0c79d621 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -227,7 +227,8 @@ static int vvp_page_prep_write(const struct lu_env *env, * This takes inode as a separate argument, because inode on which error is to * be set can be different from \a vmpage inode in case of direct-io. */ -static void vvp_vmpage_error(struct inode *inode, struct page *vmpage, int ioret) +static void vvp_vmpage_error(struct inode *inode, struct page *vmpage, + int ioret) { struct vvp_object *obj = cl_inode2vvp(inode); diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 7a848ebc57c1..421cc04ecf1e 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -132,6 +132,15 @@ ll_xattr_set_common(const struct xattr_handler *handler, (!strcmp(name, "ima") || !strcmp(name, "evm"))) return -EOPNOTSUPP; + /* + * In user.* namespace, only regular files and directories can have + * extended attributes. + */ + if (handler->flags == XATTR_USER_T) { + if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) + return -EPERM; + } + sprintf(fullname, "%s%s\n", handler->prefix, name); rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, fullname, pv, size, 0, flags, diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index b1071cf5a70c..aa42066678e0 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -220,21 +220,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, /* refresh slave from server */ body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(body); - - if (unlikely(body->mbo_nlink < 2)) { - /* - * If this is bad stripe, most likely due - * to the race between close(unlink) and - * getattr, let's return -EONENT, so llite - * will revalidate the dentry see - * ll_inode_revalidate_fini() - */ - CDEBUG(D_INODE, "%s: nlink %d < 2 corrupt stripe %d "DFID":" DFID"\n", - obd->obd_name, body->mbo_nlink, i, - PFID(&lsm->lsm_md_oinfo[i].lmo_fid), - PFID(&lsm->lsm_md_oinfo[0].lmo_fid)); - + if (!body) { if (it.it_lock_mode && lockh) { ldlm_lock_decref(lockh, it.it_lock_mode); it.it_lock_mode = 0; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index f124f6c05ea4..271e18966f50 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -173,14 +173,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, */ obd->obd_self_export->exp_connect_data = *conn_data; } -#if 0 - else if (ev == OBD_NOTIFY_DISCON) { - /* - * For disconnect event, flush fld cache for failout MDS case. - */ - fld_client_flush(&lmv->lmv_fld); - } -#endif + /* * Pass the notification up the chain. */ @@ -736,16 +729,18 @@ static int lmv_hsm_req_count(struct lmv_obd *lmv, /* count how many requests must be sent to the given target */ for (i = 0; i < hur->hur_request.hr_itemcount; i++) { curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid); + if (IS_ERR(curr_tgt)) + return PTR_ERR(curr_tgt); if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) nr++; } return nr; } -static void lmv_hsm_req_build(struct lmv_obd *lmv, - struct hsm_user_request *hur_in, - const struct lmv_tgt_desc *tgt_mds, - struct hsm_user_request *hur_out) +static int lmv_hsm_req_build(struct lmv_obd *lmv, + struct hsm_user_request *hur_in, + const struct lmv_tgt_desc *tgt_mds, + struct hsm_user_request *hur_out) { int i, nr_out; struct lmv_tgt_desc *curr_tgt; @@ -756,6 +751,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) { curr_tgt = lmv_find_target(lmv, &hur_in->hur_user_item[i].hui_fid); + if (IS_ERR(curr_tgt)) + return PTR_ERR(curr_tgt); if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) { hur_out->hur_user_item[nr_out] = hur_in->hur_user_item[i]; @@ -765,13 +762,14 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, hur_out->hur_request.hr_itemcount = nr_out; memcpy(hur_data(hur_out), hur_data(hur_in), hur_in->hur_request.hr_data_len); + + return 0; } static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, struct lustre_kernelcomm *lk, void __user *uarg) { - int rc = 0; __u32 i; /* unregister request (call from llapi_hsm_copytool_fini) */ @@ -791,9 +789,7 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, * Unreached coordinators will get EPIPE on next requests * and will unregister automatically. */ - rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); - - return rc; + return libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); } static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, @@ -1044,15 +1040,17 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, } else { /* split fid list to their respective MDS */ for (i = 0; i < count; i++) { - unsigned int nr, reqlen; - int rc1; struct hsm_user_request *req; + size_t reqlen; + int nr, rc1; tgt = lmv->tgts[i]; if (!tgt || !tgt->ltd_exp) continue; nr = lmv_hsm_req_count(lmv, hur, tgt); + if (nr < 0) + return nr; if (nr == 0) /* nothing for this MDS */ continue; @@ -1064,10 +1062,13 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (!req) return -ENOMEM; - lmv_hsm_req_build(lmv, hur, tgt, req); + rc1 = lmv_hsm_req_build(lmv, hur, tgt, req); + if (rc1 < 0) + goto hsm_req_err; rc1 = obd_iocontrol(cmd, tgt->ltd_exp, reqlen, req, uarg); +hsm_req_err: if (rc1 != 0 && rc == 0) rc = rc1; kvfree(req); @@ -1276,7 +1277,6 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lmv->desc.ld_active_tgt_count = 0; lmv->max_def_easize = 0; lmv->max_easize = 0; - lmv->lmv_placement = PLACEMENT_CHAR_POLICY; spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); @@ -1425,8 +1425,7 @@ static int lmv_getstatus(struct obd_export *exp, if (rc) return rc; - rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid); - return rc; + return md_getstatus(lmv->tgts[0]->ltd_exp, fid); } static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1447,10 +1446,8 @@ 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, valid, name, input, + return 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, @@ -1472,11 +1469,9 @@ 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, valid, name, input, + return md_setxattr(tgt->ltd_exp, fid, valid, name, input, input_size, output_size, flags, suppgid, request); - - return rc; } static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1500,9 +1495,7 @@ static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, return 0; } - rc = md_getattr(tgt->ltd_exp, op_data, request); - - return rc; + return md_getattr(tgt->ltd_exp, op_data, request); } static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) @@ -1549,8 +1542,7 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data, return PTR_ERR(tgt); CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1)); - rc = md_close(tgt->ltd_exp, op_data, mod, request); - return rc; + return md_close(tgt->ltd_exp, op_data, mod, request); } /** @@ -1743,10 +1735,8 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID " -> mds #%u\n", LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx); - rc = md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh, + return md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh, extra_lock_flags); - - return rc; } static int @@ -1894,9 +1884,7 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, if (rc != 0) return rc; - rc = md_link(tgt->ltd_exp, op_data, request); - - return rc; + return md_link(tgt->ltd_exp, op_data, request); } static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -2109,8 +2097,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, request); - return rc; + return md_sync(tgt->ltd_exp, fid, request); } /** @@ -2428,17 +2415,14 @@ static int lmv_read_page(struct obd_export *exp, struct md_op_data *op_data, return rc; if (unlikely(lsm)) { - rc = lmv_read_striped_page(exp, op_data, cb_op, offset, ppage); - return rc; + return lmv_read_striped_page(exp, op_data, cb_op, offset, ppage); } tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) return PTR_ERR(tgt); - rc = md_read_page(tgt->ltd_exp, op_data, cb_op, offset, ppage); - - return rc; + return md_read_page(tgt->ltd_exp, op_data, cb_op, offset, ppage); } /** @@ -2922,13 +2906,11 @@ static int lmv_set_lock_data(struct obd_export *exp, { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; struct lmv_tgt_desc *tgt = lmv->tgts[0]; - int rc; if (!tgt || !tgt->ltd_exp) return -EINVAL; - rc = md_set_lock_data(tgt->ltd_exp, lockh, data, bits); - return rc; + return md_set_lock_data(tgt->ltd_exp, lockh, data, bits); } static enum ldlm_mode lmv_lock_match(struct obd_export *exp, __u64 flags, @@ -3033,25 +3015,40 @@ static int lmv_clear_open_replay_data(struct obd_export *exp, } static int lmv_intent_getattr_async(struct obd_export *exp, - struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo) + struct md_enqueue_info *minfo) { struct md_op_data *op_data = &minfo->mi_data; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgt = NULL; + struct lmv_tgt_desc *ptgt = NULL; + struct lmv_tgt_desc *ctgt = NULL; int rc; + if (!fid_is_sane(&op_data->op_fid2)) + return -EINVAL; + rc = lmv_check_connect(obd); if (rc) return rc; - tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); - if (IS_ERR(tgt)) - return PTR_ERR(tgt); + ptgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); + if (IS_ERR(ptgt)) + return PTR_ERR(ptgt); - rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo); - return rc; + ctgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2); + if (IS_ERR(ctgt)) + return PTR_ERR(ctgt); + + /* + * if child is on remote MDT, we need 2 async RPCs to fetch both LOOKUP + * lock on parent, and UPDATE lock on child MDT, which makes all + * complicated. Considering remote dir is rare case, and not supporting + * it in statahead won't cause any issue, drop its support for now. + */ + if (ptgt != ctgt) + return -ENOTSUPP; + + return md_intent_getattr_async(ptgt->ltd_exp, minfo); } static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, @@ -3070,8 +3067,7 @@ static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, if (IS_ERR(tgt)) return PTR_ERR(tgt); - rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits); - return rc; + return md_revalidate_lock(tgt->ltd_exp, it, fid, bits); } static int @@ -3113,8 +3109,7 @@ static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, } if (oqctl->qc_cmd != Q_GETOQUOTA) { - rc = obd_quotactl(tgt->ltd_exp, oqctl); - return rc; + return obd_quotactl(tgt->ltd_exp, oqctl); } for (i = 0; i < lmv->desc.ld_tgt_count; i++) { @@ -3234,13 +3229,11 @@ static struct md_ops lmv_md_ops = { static int __init lmv_init(void) { struct lprocfs_static_vars lvars; - int rc; lprocfs_lmv_init_vars(&lvars); - rc = class_register_type(&lmv_obd_ops, &lmv_md_ops, + return class_register_type(&lmv_obd_ops, &lmv_md_ops, LUSTRE_LMV_NAME, NULL); - return rc; } static void lmv_exit(void) diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 20bbdfc21d15..ff458020b96a 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -50,73 +50,6 @@ static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(numobd); -static const char *placement_name[] = { - [PLACEMENT_CHAR_POLICY] = "CHAR", - [PLACEMENT_NID_POLICY] = "NID", - [PLACEMENT_INVAL_POLICY] = "INVAL" -}; - -static enum placement_policy placement_name2policy(char *name, int len) -{ - int i; - - for (i = 0; i < PLACEMENT_MAX_POLICY; i++) { - if (!strncmp(placement_name[i], name, len)) - return i; - } - return PLACEMENT_INVAL_POLICY; -} - -static const char *placement_policy2name(enum placement_policy placement) -{ - LASSERT(placement < PLACEMENT_MAX_POLICY); - return placement_name[placement]; -} - -static ssize_t placement_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); - struct lmv_obd *lmv; - - lmv = &dev->u.lmv; - return sprintf(buf, "%s\n", placement_policy2name(lmv->lmv_placement)); -} - -#define MAX_POLICY_STRING_SIZE 64 - -static ssize_t placement_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, - size_t count) -{ - struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); - char dummy[MAX_POLICY_STRING_SIZE + 1]; - enum placement_policy policy; - struct lmv_obd *lmv = &dev->u.lmv; - - memcpy(dummy, buffer, MAX_POLICY_STRING_SIZE); - - if (count > MAX_POLICY_STRING_SIZE) - count = MAX_POLICY_STRING_SIZE; - - if (dummy[count - 1] == '\n') - count--; - dummy[count] = '\0'; - - policy = placement_name2policy(dummy, count); - if (policy != PLACEMENT_INVAL_POLICY) { - spin_lock(&lmv->lmv_lock); - lmv->lmv_placement = policy; - spin_unlock(&lmv->lmv_lock); - } else { - return -EINVAL; - } - return count; -} -LUSTRE_RW_ATTR(placement); - static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -147,7 +80,13 @@ 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]; + while (*pos < lmv->tgts_size) { + if (lmv->tgts[*pos]) + return lmv->tgts[*pos]; + ++*pos; + } + + return NULL; } static void lmv_tgt_seq_stop(struct seq_file *p, void *v) @@ -159,8 +98,15 @@ static void *lmv_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos) { struct obd_device *dev = p->private; struct lmv_obd *lmv = &dev->u.lmv; + ++*pos; - return (*pos >= lmv->desc.ld_tgt_count) ? NULL : lmv->tgts[*pos]; + while (*pos < lmv->tgts_size) { + if (lmv->tgts[*pos]) + return lmv->tgts[*pos]; + ++*pos; + } + + return NULL; } static int lmv_tgt_seq_show(struct seq_file *p, void *v) @@ -213,7 +159,6 @@ const struct file_operations lmv_proc_target_fops = { static struct attribute *lmv_attrs[] = { &lustre_attr_activeobd.attr, &lustre_attr_numobd.attr, - &lustre_attr_placement.attr, NULL, }; diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 002326c282a7..e0f0756ee883 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -1056,9 +1056,12 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, * - in setattr, for truncate */ /* the truncate is for size > 0 so triggers a restore */ - if (cl_io_is_trunc(io)) + if (cl_io_is_trunc(io)) { io->ci_restore_needed = 1; - result = -ENODATA; + result = -ENODATA; + } else { + result = 1; + } break; case CIT_READ: case CIT_WRITE: diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index f3a0583f28f5..8502128e8248 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -134,6 +134,11 @@ static struct lov_lock *lov_lock_sub_init(const struct lu_env *env, struct lov_layout_raid0 *r0 = lov_r0(loo); struct lov_lock *lovlck; + CDEBUG(D_INODE, "%p: lock/io FID " DFID "/" DFID ", lock/io clobj %p/%p\n", + loo, PFID(lu_object_fid(lov2lu(loo))), + PFID(lu_object_fid(&obj->co_lu)), + lov2cl(loo), obj); + file_start = cl_offset(lov2cl(loo), lock->cll_descr.cld_start); file_end = cl_offset(lov2cl(loo), lock->cll_descr.cld_end + 1) - 1; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 63b064523c6a..b3161fb6d4b5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -592,8 +592,6 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n", index, tgt->ltd_gen, lov->desc.ld_tgt_count); - rc = obd_notify(obd, tgt_obd, OBD_NOTIFY_CREATE, &index); - if (lov->lov_connects == 0) { /* lov_connect hasn't been called yet. We'll do the * lov_connect_obd on this target when that fn first runs, diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 76d4256fa828..977579c9c519 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -266,6 +266,13 @@ static int lov_init_raid0(const struct lu_env *env, struct lov_device *dev, if (result != 0) goto out; + if (!dev->ld_target[ost_idx]) { + CERROR("%s: OST %04x is not initialized\n", + lov2obd(dev->ld_lov)->obd_name, ost_idx); + result = -EIO; + goto out; + } + subdev = lovsub2cl_dev(dev->ld_target[ost_idx]); subconf->u.coc_oinfo = oinfo; LASSERTF(subdev, "not init ost %d\n", ost_idx); @@ -650,12 +657,16 @@ static enum lov_layout_type lov_type(struct lov_stripe_md *lsm) static inline void lov_conf_freeze(struct lov_object *lov) { + CDEBUG(D_INODE, "To take share lov(%p) owner %p/%p\n", + lov, lov->lo_owner, current); if (lov->lo_owner != current) down_read(&lov->lo_type_guard); } static inline void lov_conf_thaw(struct lov_object *lov) { + CDEBUG(D_INODE, "To release share lov(%p) owner %p/%p\n", + lov, lov->lo_owner, current); if (lov->lo_owner != current) up_read(&lov->lo_type_guard); } @@ -698,10 +709,14 @@ static void lov_conf_lock(struct lov_object *lov) down_write(&lov->lo_type_guard); LASSERT(!lov->lo_owner); lov->lo_owner = current; + CDEBUG(D_INODE, "Took exclusive lov(%p) owner %p\n", + lov, lov->lo_owner); } static void lov_conf_unlock(struct lov_object *lov) { + CDEBUG(D_INODE, "To release exclusive lov(%p) owner %p\n", + lov, lov->lo_owner); lov->lo_owner = NULL; up_write(&lov->lo_type_guard); } @@ -725,6 +740,7 @@ static int lov_layout_change(const struct lu_env *unused, struct lov_object *lov, struct lov_stripe_md *lsm, const struct cl_object_conf *conf) { + struct lov_device *lov_dev = lov_object_dev(lov); enum lov_layout_type llt = lov_type(lsm); union lov_layout_state *state = &lov->u; const struct lov_layout_operations *old_ops; @@ -760,14 +776,21 @@ static int lov_layout_change(const struct lu_env *unused, LASSERT(!atomic_read(&lov->lo_active_ios)); + CDEBUG(D_INODE, DFID "Apply new layout lov %p, type %d\n", + PFID(lu_object_fid(lov2lu(lov))), lov, llt); + lov->lo_type = LLT_EMPTY; /* page bufsize fixup */ cl_object_header(&lov->lo_cl)->coh_page_bufsize -= lov_page_slice_fixup(lov, NULL); - rc = new_ops->llo_init(env, lov_object_dev(lov), lov, lsm, conf, state); + rc = new_ops->llo_init(env, lov_dev, lov, lsm, conf, state); if (rc) { + struct obd_device *obd = lov2obd(lov_dev->ld_lov); + + CERROR("%s: cannot apply new layout on " DFID " : rc = %d\n", + obd->obd_name, PFID(lu_object_fid(lov2lu(lov))), rc); new_ops->llo_delete(env, lov, state); new_ops->llo_fini(env, lov, state); /* this file becomes an EMPTY file. */ @@ -923,6 +946,11 @@ int lov_io_init(const struct lu_env *env, struct cl_object *obj, struct cl_io *io) { CL_IO_SLICE_CLEAN(lov_env_io(env), lis_cl); + + CDEBUG(D_INODE, DFID "io %p type %d ignore/verify layout %d/%d\n", + PFID(lu_object_fid(&obj->co_lu)), io, io->ci_type, + io->ci_ignore_layout, io->ci_verify_layout); + return LOV_2DISPATCH_MAYLOCK(cl2lov(obj), llo_io_init, !io->ci_ignore_layout, env, obj, io); } @@ -1453,14 +1481,11 @@ static int lov_object_layout_get(const struct lu_env *env, if (!lsm) { cl->cl_size = 0; cl->cl_layout_gen = CL_LAYOUT_GEN_EMPTY; - cl->cl_is_released = false; - return 0; } cl->cl_size = lov_mds_md_size(lsm->lsm_stripe_count, lsm->lsm_magic); cl->cl_layout_gen = lsm->lsm_layout_gen; - cl->cl_is_released = lsm_is_released(lsm); rc = lov_lsm_pack(lsm, buf->lb_buf, buf->lb_len); lov_lsm_put(lsm); diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 6c93d180aef7..2e1bd47337fd 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -136,7 +136,7 @@ ssize_t lov_lsm_pack(const struct lov_stripe_md *lsm, void *buf, lmmv1->lmm_layout_gen = cpu_to_le16(lsm->lsm_layout_gen); if (lsm->lsm_magic == LOV_MAGIC_V3) { - CLASSERT(sizeof(lsm->lsm_pool_name) == + BUILD_BUG_ON(sizeof(lsm->lsm_pool_name) != sizeof(lmmv3->lmm_pool_name)); strlcpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name, sizeof(lmmv3->lmm_pool_name)); @@ -198,7 +198,8 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) return rc; } -struct lov_stripe_md *lov_lsm_alloc(u16 stripe_count, u32 pattern, u32 magic) +static struct lov_stripe_md *lov_lsm_alloc(u16 stripe_count, u32 pattern, + u32 magic) { struct lov_stripe_md *lsm; unsigned int i; @@ -356,8 +357,8 @@ int lov_getstripe(struct lov_object *obj, struct lov_stripe_md *lsm, /* FIXME: Bug 1185 - copy fields properly when structs change */ /* struct lov_user_md_v3 and struct lov_mds_md_v3 must be the same */ - CLASSERT(sizeof(lum) == sizeof(struct lov_mds_md_v3)); - CLASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lmmk->lmm_objects[0])); + BUILD_BUG_ON(sizeof(lum) != sizeof(struct lov_mds_md_v3)); + BUILD_BUG_ON(sizeof(lum.lmm_objects[0]) != sizeof(lmmk->lmm_objects[0])); if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC && (lmmk->lmm_magic == cpu_to_le32(LOV_MAGIC_V1) || diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index d43cc88ae641..3a747913fb4f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -344,9 +344,6 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, continue; } - if (!lov->lov_tgts[i]->ltd_active) - lov_check_and_wait_active(lov, i); - /* skip targets that have been explicitly disabled by the * administrator */ @@ -355,6 +352,9 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, continue; } + if (!lov->lov_tgts[i]->ltd_active) + lov_check_and_wait_active(lov, i); + req = kzalloc(sizeof(*req), GFP_NOFS); if (!req) { rc = -ENOMEM; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 881c6a0676a6..fecedc8819ed 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -116,8 +116,7 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, struct lu_fid *fid, __u64 *bits); int mdc_intent_getattr_async(struct obd_export *exp, - struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo); + struct md_enqueue_info *minfo); enum ldlm_mode mdc_lock_match(struct obd_export *exp, __u64 flags, const struct lu_fid *fid, enum ldlm_type type, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index f35e1f9afdef..b1853ff7f8b9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -125,7 +125,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, char *tmp; __u64 flags; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); + BUILD_BUG_ON(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; @@ -189,7 +189,7 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, char *tmp; __u64 cr_flags; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_create)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); /* XXX do something about time, uid, gid */ @@ -313,7 +313,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data, struct mdt_rec_setattr *rec; struct lov_user_md *lum = NULL; - CLASSERT(sizeof(struct mdt_rec_reint) == + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_setattr)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); mdc_setattr_pack_rec(rec, op_data); @@ -336,7 +336,7 @@ void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { struct mdt_rec_unlink *rec; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_unlink)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_unlink)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->ul_opcode = op_data->op_cli_flags & CLI_RM_ENTRY ? @@ -359,7 +359,7 @@ void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { struct mdt_rec_link *rec; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_link)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_link)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->lk_opcode = REINT_LINK; @@ -407,7 +407,7 @@ void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data, { struct mdt_rec_rename *rec; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_rename)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_rename)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); /* XXX do something about time, uid, gid */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 54ebb9952d66..392b0e38a91e 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -49,7 +49,6 @@ struct mdc_getattr_args { struct obd_export *ga_exp; struct md_enqueue_info *ga_minfo; - struct ldlm_enqueue_info *ga_einfo; }; int it_open_error(int phase, struct lookup_intent *it) @@ -722,7 +721,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, LASSERT(!policy); saved_flags |= LDLM_FL_HAS_INTENT; - if (it->it_op & (IT_OPEN | IT_UNLINK | IT_GETATTR | IT_READDIR)) + if (it->it_op & (IT_UNLINK | IT_GETATTR | IT_READDIR)) policy = &update_policy; else if (it->it_op & IT_LAYOUT) policy = &layout_policy; @@ -1111,7 +1110,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, struct mdc_getattr_args *ga = args; struct obd_export *exp = ga->ga_exp; struct md_enqueue_info *minfo = ga->ga_minfo; - struct ldlm_enqueue_info *einfo = ga->ga_einfo; + struct ldlm_enqueue_info *einfo = &minfo->mi_einfo; struct lookup_intent *it; struct lustre_handle *lockh; struct obd_device *obddev; @@ -1147,14 +1146,12 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh); out: - kfree(einfo); minfo->mi_cb(req, minfo, rc); return 0; } int mdc_intent_getattr_async(struct obd_export *exp, - struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo) + struct md_enqueue_info *minfo) { struct md_op_data *op_data = &minfo->mi_data; struct lookup_intent *it = &minfo->mi_it; @@ -1162,10 +1159,6 @@ int mdc_intent_getattr_async(struct obd_export *exp, struct mdc_getattr_args *ga; struct obd_device *obddev = class_exp2obd(exp); struct ldlm_res_id res_id; - /*XXX: Both MDS_INODELOCK_LOOKUP and MDS_INODELOCK_UPDATE are needed - * for statahead currently. Consider CMD in future, such two bits - * maybe managed by different MDS, should be adjusted then. - */ union ldlm_policy_data policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE } }; @@ -1188,19 +1181,18 @@ int mdc_intent_getattr_async(struct obd_export *exp, return rc; } - rc = ldlm_cli_enqueue(exp, &req, einfo, &res_id, &policy, &flags, NULL, - 0, LVB_T_NONE, &minfo->mi_lockh, 1); + rc = ldlm_cli_enqueue(exp, &req, &minfo->mi_einfo, &res_id, &policy, + &flags, NULL, 0, LVB_T_NONE, &minfo->mi_lockh, 1); if (rc < 0) { obd_put_request_slot(&obddev->u.cli); ptlrpc_req_finished(req); return rc; } - CLASSERT(sizeof(*ga) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*ga) > sizeof(req->rq_async_args)); ga = ptlrpc_req_async_args(req); ga->ga_exp = exp; ga->ga_minfo = minfo; - ga->ga_einfo = einfo; req->rq_interpret_reply = mdc_intent_getattr_async_interpret; ptlrpcd_add_req(req); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2cfd913f9bc5..6bc2fb858680 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -295,7 +295,7 @@ static int mdc_xattr_common(struct obd_export *exp, if (opcode == MDS_REINT) { struct mdt_rec_setxattr *rec; - CLASSERT(sizeof(struct mdt_rec_setxattr) == + BUILD_BUG_ON(sizeof(struct mdt_rec_setxattr) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->sx_opcode = REINT_SETXATTR; @@ -762,6 +762,7 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE); if (rc) { ptlrpc_request_free(req); + req = NULL; goto out; } @@ -2465,13 +2466,6 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, LASSERT(imp->imp_obd == obd); switch (event) { - case IMP_EVENT_DISCON: { -#if 0 - /* XXX Pass event up to OBDs stack. used only for FLD now */ - rc = obd_notify_observer(obd, obd, OBD_NOTIFY_DISCON, NULL); -#endif - break; - } case IMP_EVENT_INACTIVE: { struct client_obd *cli = &obd->u.cli; /* @@ -2503,6 +2497,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, case IMP_EVENT_OCD: rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL); break; + case IMP_EVENT_DISCON: case IMP_EVENT_DEACTIVATE: case IMP_EVENT_ACTIVATE: break; diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index b9c522a3c7a4..6a76605b3c3d 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -142,10 +142,10 @@ static void config_log_put(struct config_llog_data *cld) if (cld->cld_recover) config_log_put(cld->cld_recover); - if (cld->cld_sptlrpc) - config_log_put(cld->cld_sptlrpc); if (cld->cld_params) config_log_put(cld->cld_params); + if (cld->cld_sptlrpc) + config_log_put(cld->cld_sptlrpc); if (cld_is_sptlrpc(cld)) sptlrpc_conf_log_stop(cld->cld_logname); @@ -175,13 +175,10 @@ struct config_llog_data *config_log_find(char *logname, /* instance may be NULL, should check name */ if (strcmp(logname, cld->cld_logname) == 0) { found = cld; + config_log_get(found); break; } } - if (found) { - atomic_inc(&found->cld_refcount); - LASSERT(found->cld_stopping == 0 || cld_is_sptlrpc(found) == 0); - } spin_unlock(&config_list_lock); return found; } @@ -203,6 +200,12 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, if (!cld) return ERR_PTR(-ENOMEM); + rc = mgc_logname2resid(logname, &cld->cld_resid, type); + if (rc) { + kfree(cld); + return ERR_PTR(rc); + } + strcpy(cld->cld_logname, logname); if (cfg) cld->cld_cfg = *cfg; @@ -223,17 +226,10 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, cld->cld_cfg.cfg_obdname = obd->obd_name; } - rc = mgc_logname2resid(logname, &cld->cld_resid, type); - spin_lock(&config_list_lock); list_add(&cld->cld_list_chain, &config_llog_list); spin_unlock(&config_list_lock); - if (rc) { - config_log_put(cld); - return ERR_PTR(rc); - } - if (cld_is_sptlrpc(cld)) { rc = mgc_process_log(obd, cld); if (rc && rc != -ENOENT) @@ -284,14 +280,15 @@ config_params_log_add(struct obd_device *obd, * We have one active log per "mount" - client instance or servername. * Each instance may be at a different point in the log. */ -static int config_log_add(struct obd_device *obd, char *logname, - struct config_llog_instance *cfg, - struct super_block *sb) +static struct config_llog_data * +config_log_add(struct obd_device *obd, char *logname, + struct config_llog_instance *cfg, struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct config_llog_data *cld; struct config_llog_data *sptlrpc_cld; struct config_llog_data *params_cld; + bool locked = false; char seclogname[32]; char *ptr; int rc; @@ -305,7 +302,7 @@ static int config_log_add(struct obd_device *obd, char *logname, ptr = strrchr(logname, '-'); if (!ptr || ptr - logname > 8) { CERROR("logname %s is too long\n", logname); - return -EINVAL; + return ERR_PTR(-EINVAL); } memcpy(seclogname, logname, ptr - logname); @@ -326,14 +323,14 @@ static int config_log_add(struct obd_device *obd, char *logname, rc = PTR_ERR(params_cld); CERROR("%s: can't create params log: rc = %d\n", obd->obd_name, rc); - goto out_err1; + goto out_sptlrpc; } cld = do_config_log_add(obd, logname, CONFIG_T_CONFIG, cfg, sb); if (IS_ERR(cld)) { CERROR("can't create log: %s\n", logname); rc = PTR_ERR(cld); - goto out_err2; + goto out_params; } cld->cld_sptlrpc = sptlrpc_cld; @@ -350,33 +347,52 @@ static int config_log_add(struct obd_device *obd, char *logname, CERROR("%s: sptlrpc log name not correct, %s: rc = %d\n", obd->obd_name, seclogname, -EINVAL); config_log_put(cld); - return -EINVAL; + rc = -EINVAL; + goto out_cld; } recover_cld = config_recover_log_add(obd, seclogname, cfg, sb); if (IS_ERR(recover_cld)) { rc = PTR_ERR(recover_cld); - goto out_err3; + goto out_cld; } + + mutex_lock(&cld->cld_lock); + locked = true; cld->cld_recover = recover_cld; } - return 0; + if (!locked) + mutex_lock(&cld->cld_lock); + cld->cld_params = params_cld; + cld->cld_sptlrpc = sptlrpc_cld; + mutex_unlock(&cld->cld_lock); + + return cld; -out_err3: +out_cld: config_log_put(cld); -out_err2: +out_params: config_log_put(params_cld); -out_err1: +out_sptlrpc: config_log_put(sptlrpc_cld); out_err: - return rc; + return ERR_PTR(rc); } static DEFINE_MUTEX(llog_process_lock); +static inline void config_mark_cld_stop(struct config_llog_data *cld) +{ + mutex_lock(&cld->cld_lock); + spin_lock(&config_list_lock); + cld->cld_stopping = 1; + spin_unlock(&config_list_lock); + mutex_unlock(&cld->cld_lock); +} + /** Stop watching for updates on this log. */ static int config_log_end(char *logname, struct config_llog_instance *cfg) @@ -406,36 +422,32 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) return rc; } + spin_lock(&config_list_lock); cld->cld_stopping = 1; + spin_unlock(&config_list_lock); cld_recover = cld->cld_recover; cld->cld_recover = NULL; + + cld_params = cld->cld_params; + cld->cld_params = NULL; + cld_sptlrpc = cld->cld_sptlrpc; + cld->cld_sptlrpc = NULL; mutex_unlock(&cld->cld_lock); if (cld_recover) { - mutex_lock(&cld_recover->cld_lock); - cld_recover->cld_stopping = 1; - mutex_unlock(&cld_recover->cld_lock); + config_mark_cld_stop(cld_recover); config_log_put(cld_recover); } - spin_lock(&config_list_lock); - cld_sptlrpc = cld->cld_sptlrpc; - cld->cld_sptlrpc = NULL; - cld_params = cld->cld_params; - cld->cld_params = NULL; - spin_unlock(&config_list_lock); - - if (cld_sptlrpc) - config_log_put(cld_sptlrpc); - if (cld_params) { - mutex_lock(&cld_params->cld_lock); - cld_params->cld_stopping = 1; - mutex_unlock(&cld_params->cld_lock); + config_mark_cld_stop(cld_params); config_log_put(cld_params); } + if (cld_sptlrpc) + config_log_put(cld_sptlrpc); + /* drop the ref from the find */ config_log_put(cld); /* drop the start ref */ @@ -531,11 +543,10 @@ static int mgc_requeue_thread(void *data) /* Keep trying failed locks periodically */ spin_lock(&config_list_lock); rq_state |= RQ_RUNNING; - while (1) { + while (!(rq_state & RQ_STOP)) { struct l_wait_info lwi; struct config_llog_data *cld, *cld_prev; int rand = cfs_rand() & MGC_TIMEOUT_RAND_CENTISEC; - int stopped = !!(rq_state & RQ_STOP); int to; /* Any new or requeued lostlocks will change the state */ @@ -571,44 +582,40 @@ static int mgc_requeue_thread(void *data) spin_lock(&config_list_lock); rq_state &= ~RQ_PRECLEANUP; list_for_each_entry(cld, &config_llog_list, cld_list_chain) { - if (!cld->cld_lostlock) + if (!cld->cld_lostlock || cld->cld_stopping) continue; + /* + * hold reference to avoid being freed during + * subsequent processing. + */ + config_log_get(cld); + cld->cld_lostlock = 0; spin_unlock(&config_list_lock); - LASSERT(atomic_read(&cld->cld_refcount) > 0); - - /* Whether we enqueued again or not in mgc_process_log, - * we're done with the ref from the old enqueue - */ if (cld_prev) config_log_put(cld_prev); cld_prev = cld; - cld->cld_lostlock = 0; - if (likely(!stopped)) + if (likely(!(rq_state & RQ_STOP))) { do_requeue(cld); - - spin_lock(&config_list_lock); + spin_lock(&config_list_lock); + } else { + spin_lock(&config_list_lock); + break; + } } spin_unlock(&config_list_lock); if (cld_prev) config_log_put(cld_prev); - /* break after scanning the list so that we can drop - * refcount to losing lock clds - */ - if (unlikely(stopped)) { - spin_lock(&config_list_lock); - break; - } - /* Wait a bit to see if anyone else needs a requeue */ lwi = (struct l_wait_info) { 0 }; l_wait_event(rq_waitq, rq_state & (RQ_NOW | RQ_STOP), &lwi); spin_lock(&config_list_lock); } + /* spinlock and while guarantee RQ_NOW and RQ_LATER are not set */ rq_state &= ~RQ_RUNNING; spin_unlock(&config_list_lock); @@ -624,32 +631,24 @@ static int mgc_requeue_thread(void *data) */ static void mgc_requeue_add(struct config_llog_data *cld) { + bool wakeup = false; + CDEBUG(D_INFO, "log %s: requeue (r=%d sp=%d st=%x)\n", cld->cld_logname, atomic_read(&cld->cld_refcount), cld->cld_stopping, rq_state); LASSERT(atomic_read(&cld->cld_refcount) > 0); mutex_lock(&cld->cld_lock); - if (cld->cld_stopping || cld->cld_lostlock) { - mutex_unlock(&cld->cld_lock); - return; - } - /* this refcount will be released in mgc_requeue_thread. */ - config_log_get(cld); - cld->cld_lostlock = 1; - mutex_unlock(&cld->cld_lock); - - /* Hold lock for rq_state */ spin_lock(&config_list_lock); - if (rq_state & RQ_STOP) { - spin_unlock(&config_list_lock); - cld->cld_lostlock = 0; - config_log_put(cld); - } else { + if (!(rq_state & RQ_STOP) && !cld->cld_stopping && !cld->cld_lostlock) { + cld->cld_lostlock = 1; rq_state |= RQ_NOW; - spin_unlock(&config_list_lock); - wake_up(&rq_waitq); + wakeup = true; } + spin_unlock(&config_list_lock); + mutex_unlock(&cld->cld_lock); + if (wakeup) + wake_up(&rq_waitq); } static int mgc_llog_init(const struct lu_env *env, struct obd_device *obd) @@ -812,6 +811,8 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, /* held at mgc_process_log(). */ LASSERT(atomic_read(&cld->cld_refcount) > 0); + + lock->l_ast_data = NULL; /* Are we done with this log? */ if (cld->cld_stopping) { CDEBUG(D_MGC, "log %s: stopping, won't requeue\n", @@ -1661,16 +1662,18 @@ restart: goto restart; } else { mutex_lock(&cld->cld_lock); + spin_lock(&config_list_lock); cld->cld_lostlock = 1; + spin_unlock(&config_list_lock); } } else { /* mark cld_lostlock so that it will requeue * after MGC becomes available. */ + spin_lock(&config_list_lock); cld->cld_lostlock = 1; + spin_unlock(&config_list_lock); } - /* Get extra reference, it will be put in requeue thread */ - config_log_get(cld); } if (cld_is_recover(cld)) { @@ -1681,7 +1684,9 @@ restart: CERROR("%s: recover log %s failed: rc = %d not fatal.\n", mgc->obd_name, cld->cld_logname, rc); rc = 0; + spin_lock(&config_list_lock); cld->cld_lostlock = 1; + spin_unlock(&config_list_lock); } } } else { @@ -1749,12 +1754,9 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) cfg->cfg_last_idx); /* We're only called through here on the initial mount */ - rc = config_log_add(obd, logname, cfg, sb); - if (rc) - break; - cld = config_log_find(logname, cfg); - if (!cld) { - rc = -ENOENT; + cld = config_log_add(obd, logname, cfg, sb); + if (IS_ERR(cld)) { + rc = PTR_ERR(cld); break; } @@ -1770,11 +1772,15 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) imp_connect_data, IMP_RECOV)) { rc = mgc_process_log(obd, cld->cld_recover); } else { - struct config_llog_data *cir = cld->cld_recover; + struct config_llog_data *cir; + mutex_lock(&cld->cld_lock); + cir = cld->cld_recover; cld->cld_recover = NULL; + mutex_unlock(&cld->cld_lock); config_log_put(cir); } + if (rc) CERROR("Cannot process recover llog %d\n", rc); } @@ -1792,7 +1798,6 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) "%s: can't process params llog: rc = %d\n", obd->obd_name, rc); } - config_log_put(cld); break; } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 3f42457b0d7d..ee7d67761191 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -1119,9 +1119,9 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, LASSERT(atomic_read(&anchor->csi_sync_nr) == 0); /* wait until cl_sync_io_note() has done wakeup */ - while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) { + while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) cpu_relax(); - } + return rc; } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f5d4e23c64b7..703cb67ce42e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -54,6 +54,7 @@ #include <linux/list.h> #include "../../include/linux/libcfs/libcfs_hash.h" /* for cfs_hash stuff */ #include "../include/cl_object.h" +#include "../include/lu_object.h" #include "cl_internal.h" static struct kmem_cache *cl_env_kmem; @@ -61,8 +62,6 @@ static struct kmem_cache *cl_env_kmem; /** Lock class of cl_object_header::coh_attr_guard */ static struct lock_class_key cl_attr_guard_class; -extern __u32 lu_context_tags_default; -extern __u32 lu_session_tags_default; /** * Initialize cl_object_header. */ diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 7971562a3efd..abcf951208d2 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -60,7 +60,7 @@ enum { LU_CACHE_PERCENT_DEFAULT = 20 }; -#define LU_CACHE_NR_MAX_ADJUST 128 +#define LU_CACHE_NR_MAX_ADJUST 512 #define LU_CACHE_NR_UNLIMITED -1 #define LU_CACHE_NR_DEFAULT LU_CACHE_NR_UNLIMITED #define LU_CACHE_NR_LDISKFS_LIMIT LU_CACHE_NR_UNLIMITED @@ -151,7 +151,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) 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); + percpu_counter_inc(&site->ls_lru_len_counter); 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); @@ -202,7 +202,7 @@ void lu_object_unhash(const struct lu_env *env, struct lu_object *o) 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); + percpu_counter_dec(&site->ls_lru_len_counter); } cfs_hash_bd_del_locked(obj_hash, &bd, &top->loh_hash); cfs_hash_bd_unlock(obj_hash, &bd, 1); @@ -329,8 +329,11 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) /** * Free \a nr objects from the cold end of the site LRU list. + * if canblock is false, then don't block awaiting for another + * instance of lu_site_purge() to complete */ -int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) +int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s, + int nr, bool canblock) { struct lu_object_header *h; struct lu_object_header *temp; @@ -360,7 +363,11 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) * It doesn't make any sense to make purge threads parallel, that can * only bring troubles to us. See LU-5331. */ - mutex_lock(&s->ls_purge_mutex); + if (canblock) + mutex_lock(&s->ls_purge_mutex); + else if (!mutex_trylock(&s->ls_purge_mutex)) + goto out; + did_sth = 0; cfs_hash_for_each_bucket(s->ls_obj_hash, &bd, i) { if (i < start) @@ -379,7 +386,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) &bd2, &h->loh_hash); list_move(&h->loh_lru, &dispose); bkt->lsb_lru_len--; - lprocfs_counter_decr(s->ls_stats, LU_SS_LRU_LEN); + percpu_counter_dec(&s->ls_lru_len_counter); if (did_sth == 0) did_sth = 1; @@ -414,10 +421,10 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) } /* race on s->ls_purge_start, but nobody cares */ s->ls_purge_start = i % CFS_HASH_NBKT(s->ls_obj_hash); - +out: return nr; } -EXPORT_SYMBOL(lu_site_purge); +EXPORT_SYMBOL(lu_site_purge_objects); /* * Object printing. @@ -578,7 +585,7 @@ static struct lu_object *htable_lookup(struct lu_site *s, 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); + percpu_counter_dec(&s->ls_lru_len_counter); } return lu_object_top(h); } @@ -625,9 +632,12 @@ static void lu_object_limit(const struct lu_env *env, struct lu_device *dev) size = cfs_hash_size_get(dev->ld_site->ls_obj_hash); nr = (__u64)lu_cache_nr; - if (size > nr) - lu_site_purge(env, dev->ld_site, - min_t(__u64, size - nr, LU_CACHE_NR_MAX_ADJUST)); + if (size <= nr) + return; + + lu_site_purge_objects(env, dev->ld_site, + min_t(__u64, size - nr, LU_CACHE_NR_MAX_ADJUST), + false); } static struct lu_object *lu_object_new(const struct lu_env *env, @@ -820,7 +830,7 @@ EXPORT_SYMBOL(lu_device_type_fini); * Global list of all sites on this node */ static LIST_HEAD(lu_sites); -static DEFINE_MUTEX(lu_sites_guard); +static DECLARE_RWSEM(lu_sites_guard); /** * Global environment used by site shrinker. @@ -994,9 +1004,15 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) unsigned long bits; unsigned long i; char name[16]; + int rc; memset(s, 0, sizeof(*s)); mutex_init(&s->ls_purge_mutex); + + rc = percpu_counter_init(&s->ls_lru_len_counter, 0, GFP_NOFS); + if (rc) + return -ENOMEM; + snprintf(name, sizeof(name), "lu_site_%s", top->ld_type->ldt_name); for (bits = lu_htable_order(top); bits >= LU_SITE_BITS_MIN; bits--) { s->ls_obj_hash = cfs_hash_create(name, bits, bits, @@ -1042,12 +1058,6 @@ 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; @@ -1069,9 +1079,11 @@ EXPORT_SYMBOL(lu_site_init); */ void lu_site_fini(struct lu_site *s) { - mutex_lock(&lu_sites_guard); + down_write(&lu_sites_guard); list_del_init(&s->ls_linkage); - mutex_unlock(&lu_sites_guard); + up_write(&lu_sites_guard); + + percpu_counter_destroy(&s->ls_lru_len_counter); if (s->ls_obj_hash) { cfs_hash_putref(s->ls_obj_hash); @@ -1097,11 +1109,11 @@ int lu_site_init_finish(struct lu_site *s) { int result; - mutex_lock(&lu_sites_guard); + down_write(&lu_sites_guard); result = lu_context_refill(&lu_shrink_env.le_ctx); if (result == 0) list_add(&s->ls_linkage, &lu_sites); - mutex_unlock(&lu_sites_guard); + up_write(&lu_sites_guard); return result; } EXPORT_SYMBOL(lu_site_init_finish); @@ -1820,12 +1832,15 @@ static void lu_site_stats_get(struct cfs_hash *hs, } /* - * 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. + * lu_cache_shrink_count() returns an approximate number of cached objects + * that can be freed by shrink_slab(). A counter, which tracks the + * number of items in the site's lru, is maintained in a percpu_counter + * for each site. The percpu values are incremented and decremented as + * objects are added or removed from the lru. The percpu values are summed + * and saved whenever a percpu value exceeds a threshold. Thus the saved, + * summed value at any given time may not accurately reflect the current + * lru length. But this value is sufficiently accurate for the needs of + * a shrinker. * * Using a per cpu counter is a compromise solution to concurrent access: * lu_object_put() can update the counter without locking the site and @@ -1842,11 +1857,10 @@ static unsigned long lu_cache_shrink_count(struct shrinker *sk, if (!(sc->gfp_mask & __GFP_FS)) return 0; - mutex_lock(&lu_sites_guard); - list_for_each_entry_safe(s, tmp, &lu_sites, ls_linkage) { - cached += ls_stats_read(s->ls_stats, LU_SS_LRU_LEN); - } - mutex_unlock(&lu_sites_guard); + down_read(&lu_sites_guard); + list_for_each_entry_safe(s, tmp, &lu_sites, ls_linkage) + cached += percpu_counter_read_positive(&s->ls_lru_len_counter); + up_read(&lu_sites_guard); cached = (cached / 100) * sysctl_vfs_cache_pressure; CDEBUG(D_INODE, "%ld objects cached, cache pressure %d\n", @@ -1877,7 +1891,7 @@ static unsigned long lu_cache_shrink_scan(struct shrinker *sk, */ return SHRINK_STOP; - mutex_lock(&lu_sites_guard); + down_write(&lu_sites_guard); list_for_each_entry_safe(s, tmp, &lu_sites, ls_linkage) { freed = lu_site_purge(&lu_shrink_env, s, remain); remain -= freed; @@ -1888,7 +1902,7 @@ static unsigned long lu_cache_shrink_scan(struct shrinker *sk, list_move_tail(&s->ls_linkage, &splice); } list_splice(&splice, lu_sites.prev); - mutex_unlock(&lu_sites_guard); + up_write(&lu_sites_guard); return sc->nr_to_scan - remain; } @@ -1925,9 +1939,9 @@ int lu_global_init(void) * conservatively. This should not be too bad, because this * environment is global. */ - mutex_lock(&lu_sites_guard); + down_write(&lu_sites_guard); result = lu_env_init(&lu_shrink_env, LCT_SHRINKER); - mutex_unlock(&lu_sites_guard); + up_write(&lu_sites_guard); if (result != 0) return result; @@ -1953,9 +1967,9 @@ void lu_global_fini(void) * Tear shrinker environment down _after_ de-registering * lu_global_key, because the latter has a value in the former. */ - mutex_lock(&lu_sites_guard); + down_write(&lu_sites_guard); lu_env_fini(&lu_shrink_env); - mutex_unlock(&lu_sites_guard); + up_write(&lu_sites_guard); lu_ref_global_fini(); } @@ -1965,13 +1979,6 @@ 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; } @@ -1986,7 +1993,7 @@ int lu_site_stats_print(const struct lu_site *s, struct seq_file *m) memset(&stats, 0, sizeof(stats)); lu_site_stats_get(s->ls_obj_hash, &stats, 1); - seq_printf(m, "%d/%d %d/%ld %d %d %d %d %d %d %d %d\n", + seq_printf(m, "%d/%d %d/%ld %d %d %d %d %d %d %d\n", stats.lss_busy, stats.lss_total, stats.lss_populated, @@ -1997,8 +2004,7 @@ 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_LEN)); + ls_stats_read(s->ls_stats, LU_SS_LRU_PURGED)); return 0; } EXPORT_SYMBOL(lu_site_stats_print); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 2283e920d839..8e0d4b1d86dc 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -877,7 +877,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr) */ static int lmd_parse(char *options, struct lustre_mount_data *lmd) { - char *s1, *s2, *s3, *devname = NULL; + char *s1, *s2, *devname = NULL; struct lustre_mount_data *raw = (struct lustre_mount_data *)options; int rc = 0; @@ -906,6 +906,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) while (*s1) { int clear = 0; int time_min = OBD_RECOVERY_TIME_MIN; + char *s3; /* Skip whitespace and extra commas */ while (*s1 == ' ' || *s1 == ',') diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index c52b9e07d7dd..b1dfa1622ae7 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -40,6 +40,7 @@ #include "../include/obd_class.h" #include "../include/lustre/lustre_idl.h" +#include "../include/lustre_obdo.h" void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent) { @@ -124,3 +125,56 @@ void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj) ioobj->ioo_max_brw = 0; } EXPORT_SYMBOL(obdo_to_ioobj); + +/** + * Create an obdo to send over the wire + */ +void lustre_set_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *wobdo, const struct obdo *lobdo) +{ + *wobdo = *lobdo; + wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; + if (!ocd) + return; + + if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && + fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { + /* + * Currently OBD_FL_OSTID will only be used when 2.4 echo + * client communicate with pre-2.4 server + */ + wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); + wobdo->o_oi.oi.oi_seq = fid_seq(&lobdo->o_oi.oi_fid); + } +} +EXPORT_SYMBOL(lustre_set_wire_obdo); + +/** + * Create a local obdo from a wire based odbo + */ +void lustre_get_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *lobdo, const struct obdo *wobdo) +{ + u32 local_flags = 0; + + if (lobdo->o_valid & OBD_MD_FLFLAGS) + local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; + + *lobdo = *wobdo; + if (local_flags) { + lobdo->o_valid |= OBD_MD_FLFLAGS; + lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; + lobdo->o_flags |= local_flags; + } + if (!ocd) + return; + + if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && + fid_seq_is_echo(wobdo->o_oi.oi.oi_seq)) { + /* see above */ + lobdo->o_oi.oi_fid.f_seq = wobdo->o_oi.oi.oi_seq; + lobdo->o_oi.oi_fid.f_oid = wobdo->o_oi.oi.oi_id; + lobdo->o_oi.oi_fid.f_ver = 0; + } +} +EXPORT_SYMBOL(lustre_get_wire_obdo); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b0f030c6c9c9..0490478393df 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -142,10 +142,7 @@ static const char *oes_strings[] = { static inline struct osc_extent *rb_extent(struct rb_node *n) { - if (!n) - return NULL; - - return container_of(n, struct osc_extent, oe_node); + return rb_entry_safe(n, struct osc_extent, oe_node); } static inline struct osc_extent *next_extent(struct osc_extent *ext) @@ -247,7 +244,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, goto out; } - if (ext->oe_dlmlock) { + if (ext->oe_dlmlock && !ldlm_is_failed(ext->oe_dlmlock)) { struct ldlm_extent *extent; extent = &ext->oe_dlmlock->l_policy_data.l_extent; @@ -1004,6 +1001,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, env = cl_env_get(&refcheck); io = &osc_env_info(env)->oti_io; io->ci_obj = cl_object_top(osc2cl(obj)); + io->ci_ignore_layout = 1; rc = cl_io_init(env, io, CIT_MISC, io->ci_obj); if (rc < 0) goto out; @@ -1884,16 +1882,32 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, oap, osc, rc); } +struct extent_rpc_data { + struct list_head *erd_rpc_list; + unsigned int erd_page_count; + unsigned int erd_max_pages; + unsigned int erd_max_chunks; +}; + +static inline unsigned osc_extent_chunks(const struct osc_extent *ext) +{ + struct client_obd *cli = osc_cli(ext->oe_obj); + unsigned ppc_bits = cli->cl_chunkbits - PAGE_SHIFT; + + return (ext->oe_end >> ppc_bits) - (ext->oe_start >> ppc_bits) + 1; +} + /** * Try to add extent to one RPC. We need to think about the following things: * - # of pages must not be over max_pages_per_rpc * - extent must be compatible with previous ones */ static int try_to_add_extent_for_io(struct client_obd *cli, - struct osc_extent *ext, struct list_head *rpclist, - unsigned int *pc, unsigned int *max_pages) + struct osc_extent *ext, + struct extent_rpc_data *data) { struct osc_extent *tmp; + unsigned int chunk_count; struct osc_async_page *oap = list_first_entry(&ext->oe_pages, struct osc_async_page, oap_pending_item); @@ -1901,19 +1915,22 @@ static int try_to_add_extent_for_io(struct client_obd *cli, EASSERT((ext->oe_state == OES_CACHE || ext->oe_state == OES_LOCK_DONE), ext); - *max_pages = max(ext->oe_mppr, *max_pages); - if (*pc + ext->oe_nr_pages > *max_pages) + chunk_count = osc_extent_chunks(ext); + if (chunk_count > data->erd_max_chunks) + return 0; + + data->erd_max_pages = max(ext->oe_mppr, data->erd_max_pages); + if (data->erd_page_count + ext->oe_nr_pages > data->erd_max_pages) return 0; - list_for_each_entry(tmp, rpclist, oe_link) { + list_for_each_entry(tmp, data->erd_rpc_list, oe_link) { struct osc_async_page *oap2; oap2 = list_first_entry(&tmp->oe_pages, struct osc_async_page, oap_pending_item); EASSERT(tmp->oe_owner == current, tmp); if (oap2cl_page(oap)->cp_type != oap2cl_page(oap2)->cp_type) { - CDEBUG(D_CACHE, "Do not permit different type of IO" - " for a same RPC\n"); + CDEBUG(D_CACHE, "Do not permit different type of IO in one RPC\n"); return 0; } @@ -1926,12 +1943,41 @@ static int try_to_add_extent_for_io(struct client_obd *cli, break; } - *pc += ext->oe_nr_pages; - list_move_tail(&ext->oe_link, rpclist); + data->erd_max_chunks -= chunk_count; + data->erd_page_count += ext->oe_nr_pages; + list_move_tail(&ext->oe_link, data->erd_rpc_list); ext->oe_owner = current; return 1; } +static inline unsigned osc_max_write_chunks(const struct client_obd *cli) +{ + /* + * LU-8135: + * + * The maximum size of a single transaction is about 64MB in ZFS. + * #define DMU_MAX_ACCESS (64 * 1024 * 1024) + * + * Since ZFS is a copy-on-write file system, a single dirty page in + * a chunk will result in the rewrite of the whole chunk, therefore + * an RPC shouldn't be allowed to contain too many chunks otherwise + * it will make transaction size much bigger than 64MB, especially + * with big block size for ZFS. + * + * This piece of code is to make sure that OSC won't send write RPCs + * with too many chunks. The maximum chunk size that an RPC can cover + * is set to PTLRPC_MAX_BRW_SIZE, which is defined to 16MB. Ideally + * OST should tell the client what the biggest transaction size is, + * but it's good enough for now. + * + * This limitation doesn't apply to ldiskfs, which allows as many + * chunks in one RPC as we want. However, it won't have any benefits + * to have too many discontiguous pages in one RPC. Therefore, it + * can only have 256 chunks at most in one RPC. + */ + return min(PTLRPC_MAX_BRW_SIZE >> cli->cl_chunkbits, 256); +} + /** * In order to prevent multiple ptlrpcd from breaking contiguous extents, * get_write_extent() takes all appropriate extents in atomic. @@ -1951,26 +1997,28 @@ static unsigned int get_write_extents(struct osc_object *obj, struct client_obd *cli = osc_cli(obj); struct osc_extent *ext; struct osc_extent *temp; - unsigned int page_count = 0; - unsigned int max_pages = cli->cl_max_pages_per_rpc; + struct extent_rpc_data data = { + .erd_rpc_list = rpclist, + .erd_page_count = 0, + .erd_max_pages = cli->cl_max_pages_per_rpc, + .erd_max_chunks = osc_max_write_chunks(cli), + }; LASSERT(osc_object_is_locked(obj)); list_for_each_entry_safe(ext, temp, &obj->oo_hp_exts, oe_link) { LASSERT(ext->oe_state == OES_CACHE); - if (!try_to_add_extent_for_io(cli, ext, rpclist, &page_count, - &max_pages)) - return page_count; - EASSERT(ext->oe_nr_pages <= max_pages, ext); + if (!try_to_add_extent_for_io(cli, ext, &data)) + return data.erd_page_count; + EASSERT(ext->oe_nr_pages <= data.erd_max_pages, ext); } - if (page_count == max_pages) - return page_count; + if (data.erd_page_count == data.erd_max_pages) + return data.erd_page_count; while (!list_empty(&obj->oo_urgent_exts)) { ext = list_entry(obj->oo_urgent_exts.next, struct osc_extent, oe_link); - if (!try_to_add_extent_for_io(cli, ext, rpclist, &page_count, - &max_pages)) - return page_count; + if (!try_to_add_extent_for_io(cli, ext, &data)) + return data.erd_page_count; if (!ext->oe_intree) continue; @@ -1981,13 +2029,12 @@ static unsigned int get_write_extents(struct osc_object *obj, ext->oe_owner)) continue; - if (!try_to_add_extent_for_io(cli, ext, rpclist, - &page_count, &max_pages)) - return page_count; + if (!try_to_add_extent_for_io(cli, ext, &data)) + return data.erd_page_count; } } - if (page_count == max_pages) - return page_count; + if (data.erd_page_count == data.erd_max_pages) + return data.erd_page_count; ext = first_extent(obj); while (ext) { @@ -1998,13 +2045,12 @@ static unsigned int get_write_extents(struct osc_object *obj, continue; } - if (!try_to_add_extent_for_io(cli, ext, rpclist, &page_count, - &max_pages)) - return page_count; + if (!try_to_add_extent_for_io(cli, ext, &data)) + return data.erd_page_count; ext = next_extent(ext); } - return page_count; + return data.erd_page_count; } static int @@ -2089,27 +2135,29 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, struct osc_extent *ext; struct osc_extent *next; LIST_HEAD(rpclist); - unsigned int page_count = 0; - unsigned int max_pages = cli->cl_max_pages_per_rpc; + struct extent_rpc_data data = { + .erd_rpc_list = &rpclist, + .erd_page_count = 0, + .erd_max_pages = cli->cl_max_pages_per_rpc, + .erd_max_chunks = UINT_MAX, + }; int rc = 0; LASSERT(osc_object_is_locked(osc)); list_for_each_entry_safe(ext, next, &osc->oo_reading_exts, oe_link) { EASSERT(ext->oe_state == OES_LOCK_DONE, ext); - if (!try_to_add_extent_for_io(cli, ext, &rpclist, &page_count, - &max_pages)) + if (!try_to_add_extent_for_io(cli, ext, &data)) break; osc_extent_state_set(ext, OES_RPC); - EASSERT(ext->oe_nr_pages <= max_pages, ext); + EASSERT(ext->oe_nr_pages <= data.erd_max_pages, ext); } - LASSERT(page_count <= max_pages); + LASSERT(data.erd_page_count <= data.erd_max_pages); - osc_update_pending(osc, OBD_BRW_READ, -page_count); + osc_update_pending(osc, OBD_BRW_READ, -data.erd_page_count); if (!list_empty(&rpclist)) { osc_object_unlock(osc); - LASSERT(page_count > 0); rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ); LASSERT(list_empty(&rpclist)); @@ -2710,8 +2758,8 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, /** * Called by osc_io_setattr_start() to freeze and destroy covering extents. */ -int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj, __u64 size) +int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, + u64 size, struct osc_extent **extp) { struct client_obd *cli = osc_cli(obj); struct osc_extent *ext; @@ -2808,9 +2856,11 @@ again: /* we need to hold this extent in OES_TRUNC state so * that no writeback will happen. This is to avoid * BUG 17397. + * Only partial truncate can reach here, if @size is + * not zero, the caller should provide a valid @extp. */ - LASSERT(!oio->oi_trunc); - oio->oi_trunc = osc_extent_get(ext); + LASSERT(!*extp); + *extp = osc_extent_get(ext); OSC_EXTENT_DUMP(D_CACHE, ext, "trunc at %llu\n", size); } @@ -2836,13 +2886,10 @@ again: /** * Called after osc_io_setattr_end to add oio->oi_trunc back to cache. */ -void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj) +void osc_cache_truncate_end(const struct lu_env *env, struct osc_extent *ext) { - struct osc_extent *ext = oio->oi_trunc; - - oio->oi_trunc = NULL; if (ext) { + struct osc_object *obj = ext->oe_obj; bool unplug = false; EASSERT(ext->oe_nr_pages > 0, ext); @@ -3183,8 +3230,10 @@ static int discard_cb(const struct lu_env *env, struct cl_io *io, /* page is top page. */ info->oti_next_index = osc_index(ops) + 1; if (cl_page_own(env, io, page) == 0) { - KLASSERT(ergo(page->cp_type == CPT_CACHEABLE, - !PageDirty(cl_page_vmpage(page)))); + if (page->cp_type == CPT_CACHEABLE && + PageDirty(cl_page_vmpage(page))) + CL_PAGE_DEBUG(D_ERROR, env, page, + "discard dirty page?\n"); /* discard the page */ cl_page_discard(env, io, page); diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index cce55a9689f0..c09ab97d64ae 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -159,6 +159,10 @@ struct osc_object { /* Protect osc_lock this osc_object has */ spinlock_t oo_ol_spin; struct list_head oo_ol_list; + + /** number of active IOs of this object */ + atomic_t oo_nr_ios; + wait_queue_head_t oo_io_waitq; }; static inline void osc_object_lock(struct osc_object *obj) @@ -399,10 +403,9 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, struct osc_page *ops); int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, struct list_head *list, int cmd, int brw_flags); -int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj, __u64 size); -void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj); +int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, + u64 size, struct osc_extent **extp); +void osc_cache_truncate_end(const struct lu_env *env, struct osc_extent *ext); int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, pgoff_t start, pgoff_t end, int hp, int discard); int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 688783dcc1e4..8abd83f26716 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -114,9 +114,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, struct ptlrpc_request_set *rqset, int async, int agl); int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, - __u32 type, union ldlm_policy_data *policy, __u32 mode, - __u64 *flags, void *data, struct lustre_handle *lockh, - int unref); + enum ldlm_type type, union ldlm_policy_data *policy, + enum ldlm_mode mode, __u64 *flags, void *data, + struct lustre_handle *lockh, int unref); int osc_setattr_async(struct obd_export *exp, struct obdo *oa, obd_enqueue_update_f upcall, void *cookie, @@ -181,6 +181,8 @@ static inline struct osc_device *obd2osc_dev(const struct obd_device *d) return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev); } +extern struct lu_kmem_descr osc_caches[]; + extern struct kmem_cache *osc_quota_kmem; struct osc_quota_info { /** linkage for quota hash table */ @@ -218,4 +220,15 @@ struct ldlm_lock *osc_dlmlock_at_pgoff(const struct lu_env *env, struct osc_object *obj, pgoff_t index, enum osc_dap_flags flags); +int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc); + +/** osc shrink list to link all osc client obd */ +extern struct list_head osc_shrink_list; +/** spin lock to protect osc_shrink_list */ +extern spinlock_t osc_shrink_lock; +unsigned long osc_cache_shrink_count(struct shrinker *sk, + struct shrink_control *sc); +unsigned long osc_cache_shrink_scan(struct shrinker *sk, + struct shrink_control *sc); + #endif /* OSC_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 228a97c098fe..0b4cc4283b05 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -37,6 +37,8 @@ #define DEBUG_SUBSYSTEM S_OSC +#include "../include/lustre_obdo.h" + #include "osc_cl_internal.h" /** \addtogroup osc @@ -97,6 +99,7 @@ static int osc_io_read_ahead(const struct lu_env *env, ldlm_lock_decref(&lockh, dlmlock->l_req_mode); } + ra->cra_rpc_size = osc_cli(osc)->cl_max_pages_per_rpc; ra->cra_end = cl_index(osc2cl(osc), dlmlock->l_policy_data.l_extent.end); ra->cra_release = osc_read_ahead_release; @@ -136,7 +139,7 @@ static int osc_io_submit(const struct lu_env *env, LASSERT(qin->pl_nr > 0); - CDEBUG(D_CACHE, "%d %d\n", qin->pl_nr, crt); + CDEBUG(D_CACHE | D_READA, "%d %d\n", qin->pl_nr, crt); osc = cl2osc(ios->cis_obj); cli = osc_cli(osc); @@ -207,6 +210,18 @@ static int osc_io_submit(const struct lu_env *env, if (queued > 0) result = osc_queue_sync_pages(env, osc, &list, cmd, brw_flags); + /* Update c/mtime for sync write. LU-7310 */ + if (qout->pl_nr > 0 && !result) { + struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_object *obj = ios->cis_obj; + + cl_object_attr_lock(obj); + attr->cat_mtime = LTIME_S(CURRENT_TIME); + attr->cat_ctime = attr->cat_mtime; + cl_object_attr_update(env, obj, attr, CAT_MTIME | CAT_CTIME); + cl_object_attr_unlock(obj); + } + CDEBUG(D_INFO, "%d/%d %d\n", qin->pl_nr, qout->pl_nr, result); return qout->pl_nr > 0 ? 0 : result; } @@ -330,8 +345,25 @@ static int osc_io_commit_async(const struct lu_env *env, return result; } -static int osc_io_rw_iter_init(const struct lu_env *env, - const struct cl_io_slice *ios) +static int osc_io_iter_init(const struct lu_env *env, + const struct cl_io_slice *ios) +{ + struct osc_object *osc = cl2osc(ios->cis_obj); + struct obd_import *imp = osc_cli(osc)->cl_import; + int rc = -EIO; + + spin_lock(&imp->imp_lock); + if (likely(!imp->imp_invalid)) { + atomic_inc(&osc->oo_nr_ios); + rc = 0; + } + spin_unlock(&imp->imp_lock); + + return rc; +} + +static int osc_io_write_iter_init(const struct lu_env *env, + const struct cl_io_slice *ios) { struct cl_io *io = ios->cis_io; struct osc_io *oio = osc_env_io(env); @@ -342,7 +374,7 @@ static int osc_io_rw_iter_init(const struct lu_env *env, unsigned long max_pages; if (cl_io_is_append(io)) - return 0; + return osc_io_iter_init(env, ios); npages = io->u.ci_rw.crw_count >> PAGE_SHIFT; if (io->u.ci_rw.crw_pos & ~PAGE_MASK) @@ -374,11 +406,21 @@ static int osc_io_rw_iter_init(const struct lu_env *env, (void)ptlrpcd_queue_work(cli->cl_lru_work); } - return 0; + return osc_io_iter_init(env, ios); } -static void osc_io_rw_iter_fini(const struct lu_env *env, - const struct cl_io_slice *ios) +static void osc_io_iter_fini(const struct lu_env *env, + const struct cl_io_slice *ios) +{ + struct osc_object *osc = cl2osc(ios->cis_obj); + + LASSERT(atomic_read(&osc->oo_nr_ios) > 0); + if (atomic_dec_and_test(&osc->oo_nr_ios)) + wake_up_all(&osc->oo_io_waitq); +} + +static void osc_io_write_iter_fini(const struct lu_env *env, + const struct cl_io_slice *ios) { struct osc_io *oio = osc_env_io(env); struct osc_object *osc = cl2osc(ios->cis_obj); @@ -389,6 +431,8 @@ static void osc_io_rw_iter_fini(const struct lu_env *env, oio->oi_lru_reserved = 0; } oio->oi_write_osclock = NULL; + + osc_io_iter_fini(env, ios); } static int osc_io_fault_start(const struct lu_env *env, @@ -479,7 +523,8 @@ static int osc_io_setattr_start(const struct lu_env *env, /* truncate cache dirty pages first */ if (cl_io_is_trunc(io)) - result = osc_cache_truncate_start(env, oio, cl2osc(obj), size); + result = osc_cache_truncate_start(env, cl2osc(obj), size, + &oio->oi_trunc); if (result == 0 && oio->oi_lockless == 0) { cl_object_attr_lock(obj); @@ -589,10 +634,8 @@ static void osc_io_setattr_end(const struct lu_env *env, __u64 size = io->u.ci_setattr.sa_attr.lvb_size; osc_trunc_check(env, io, oio, size); - if (oio->oi_trunc) { - osc_cache_truncate_end(env, oio, cl2osc(obj)); - oio->oi_trunc = NULL; - } + osc_cache_truncate_end(env, oio->oi_trunc); + oio->oi_trunc = NULL; } } @@ -669,7 +712,7 @@ static int osc_io_data_version_start(const struct lu_env *env, ptlrpc_request_set_replen(req); req->rq_interpret_reply = osc_data_version_interpret; - CLASSERT(sizeof(*dva) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*dva) > sizeof(req->rq_async_args)); dva = ptlrpc_req_async_args(req); dva->dva_oio = oio; @@ -832,17 +875,21 @@ static void osc_io_end(const struct lu_env *env, static const struct cl_io_operations osc_io_ops = { .op = { [CIT_READ] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_read_start, .cio_fini = osc_io_fini }, [CIT_WRITE] = { - .cio_iter_init = osc_io_rw_iter_init, - .cio_iter_fini = osc_io_rw_iter_fini, + .cio_iter_init = osc_io_write_iter_init, + .cio_iter_fini = osc_io_write_iter_fini, .cio_start = osc_io_write_start, .cio_end = osc_io_end, .cio_fini = osc_io_fini }, [CIT_SETATTR] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_setattr_start, .cio_end = osc_io_setattr_end }, @@ -851,6 +898,8 @@ static const struct cl_io_operations osc_io_ops = { .cio_end = osc_io_data_version_end, }, [CIT_FAULT] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_fault_start, .cio_end = osc_io_end, .cio_fini = osc_io_fini diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index e0c3324857dd..d3e5ca7db7b2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -78,6 +78,9 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj, INIT_LIST_HEAD(&osc->oo_write_item); INIT_LIST_HEAD(&osc->oo_read_item); + atomic_set(&osc->oo_nr_ios, 0); + init_waitqueue_head(&osc->oo_io_waitq); + osc->oo_root.rb_node = NULL; INIT_LIST_HEAD(&osc->oo_hp_exts); INIT_LIST_HEAD(&osc->oo_urgent_exts); @@ -112,6 +115,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj) LASSERT(atomic_read(&osc->oo_nr_reads) == 0); LASSERT(atomic_read(&osc->oo_nr_writes) == 0); LASSERT(list_empty(&osc->oo_ol_list)); + LASSERT(!atomic_read(&osc->oo_nr_ios)); lu_object_fini(obj); kmem_cache_free(osc_object_kmem, osc); @@ -444,4 +448,19 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, return obj; } +int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc) +{ + struct l_wait_info lwi = { 0 }; + + CDEBUG(D_INODE, "Invalidate osc object: %p, # of active IOs: %d\n", + osc, atomic_read(&osc->oo_nr_ios)); + + l_wait_event(osc->oo_io_waitq, !atomic_read(&osc->oo_nr_ios), &lwi); + + /* Discard all pages of this object. */ + osc_cache_truncate_start(env, osc, 0, NULL); + + return 0; +} + /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index e356e4af08e1..ab9d0d7bb943 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -370,12 +370,17 @@ static int osc_cache_too_much(struct client_obd *cli) return lru_shrink_min(cli); } else { time64_t duration = ktime_get_real_seconds(); + long timediff; /* knock out pages by duration of no IO activity */ duration -= cli->cl_lru_last_used; - duration >>= 6; /* approximately 1 minute */ - if (duration > 0 && - pages >= div64_s64((s64)budget, duration)) + /* + * The difference shouldn't be more than 70 years + * so we can safely case to a long. Round to + * approximately 1 minute. + */ + timediff = (long)(duration >> 6); + if (timediff > 0 && pages >= budget / timediff) return lru_shrink_min(cli); } return 0; @@ -943,4 +948,91 @@ bool osc_over_unstable_soft_limit(struct client_obd *cli) cli->cl_max_rpcs_in_flight; } +/** + * Return how many LRU pages in the cache of all OSC devices + * + * Return: return # of cached LRU pages times reclaimation tendency + * SHRINK_STOP if it cannot do any scanning in this time + */ +unsigned long osc_cache_shrink_count(struct shrinker *sk, + struct shrink_control *sc) +{ + struct client_obd *cli; + unsigned long cached = 0; + + spin_lock(&osc_shrink_lock); + list_for_each_entry(cli, &osc_shrink_list, cl_shrink_list) + cached += atomic_long_read(&cli->cl_lru_in_list); + spin_unlock(&osc_shrink_lock); + + return (cached * sysctl_vfs_cache_pressure) / 100; +} + +/** + * Scan and try to reclaim sc->nr_to_scan cached LRU pages + * + * Return: number of cached LRU pages reclaimed + * SHRINK_STOP if it cannot do any scanning in this time + * + * Linux kernel will loop calling this shrinker scan routine with + * sc->nr_to_scan = SHRINK_BATCH(128 for now) until kernel got enough memory. + * + * If sc->nr_to_scan is 0, the VM is querying the cache size, we don't need + * to scan and try to reclaim LRU pages, just return 0 and + * osc_cache_shrink_count() will report the LRU page number. + */ +unsigned long osc_cache_shrink_scan(struct shrinker *sk, + struct shrink_control *sc) +{ + struct client_obd *stop_anchor = NULL; + struct client_obd *cli; + struct lu_env *env; + long shrank = 0; + int refcheck; + int rc; + + if (!sc->nr_to_scan) + return 0; + + if (!(sc->gfp_mask & __GFP_FS)) + return SHRINK_STOP; + + env = cl_env_get(&refcheck); + if (IS_ERR(env)) + return SHRINK_STOP; + + spin_lock(&osc_shrink_lock); + while (!list_empty(&osc_shrink_list)) { + cli = list_entry(osc_shrink_list.next, struct client_obd, + cl_shrink_list); + + if (!stop_anchor) + stop_anchor = cli; + else if (cli == stop_anchor) + break; + + list_move_tail(&cli->cl_shrink_list, &osc_shrink_list); + spin_unlock(&osc_shrink_lock); + + /* shrink no more than max_pages_per_rpc for an OSC */ + rc = osc_lru_shrink(env, cli, (sc->nr_to_scan - shrank) > + cli->cl_max_pages_per_rpc ? + cli->cl_max_pages_per_rpc : + sc->nr_to_scan - shrank, true); + if (rc > 0) + shrank += rc; + + if (shrank >= sc->nr_to_scan) + goto out; + + spin_lock(&osc_shrink_lock); + } + spin_unlock(&osc_shrink_lock); + +out: + cl_env_put(env, &refcheck); + + return shrank; +} + /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7143564ae7e7..c4cfe18c3294 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -43,6 +43,7 @@ #include "../include/lprocfs_status.h" #include "../include/lustre/lustre_ioctl.h" #include "../include/lustre_debug.h" +#include "../include/lustre_obdo.h" #include "../include/lustre_param.h" #include "../include/lustre_fid.h" #include "../include/obd_class.h" @@ -250,7 +251,7 @@ int osc_setattr_async(struct obd_export *exp, struct obdo *oa, req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; - CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); sa->sa_oa = oa; sa->sa_upcall = upcall; @@ -348,7 +349,7 @@ int osc_punch_base(struct obd_export *exp, struct obdo *oa, ptlrpc_request_set_replen(req); req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; - CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); sa->sa_oa = oa; sa->sa_upcall = upcall; @@ -429,7 +430,7 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa, ptlrpc_request_set_replen(req); req->rq_interpret_reply = osc_sync_interpret; - CLASSERT(sizeof(*fa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*fa) > sizeof(req->rq_async_args)); fa = ptlrpc_req_async_args(req); fa->fa_obj = obj; fa->fa_oa = oa; @@ -1170,7 +1171,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, } ptlrpc_request_set_replen(req); - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->aa_oa = oa; aa->aa_requested_nob = requested_nob; @@ -1757,7 +1758,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, cl_req_attr_set(env, osc2cl(obj), crattr); lustre_msg_set_jobid(req->rq_reqmsg, crattr->cra_jobid); - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); INIT_LIST_HEAD(&aa->aa_oaps); list_splice_init(&rpc_list, &aa->aa_oaps); @@ -2038,7 +2039,7 @@ no_match: if (!rc) { struct osc_enqueue_args *aa; - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->oa_exp = exp; aa->oa_mode = einfo->ei_mode; @@ -2080,9 +2081,9 @@ no_match: } int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, - __u32 type, union ldlm_policy_data *policy, __u32 mode, - __u64 *flags, void *data, struct lustre_handle *lockh, - int unref) + enum ldlm_type type, union ldlm_policy_data *policy, + enum ldlm_mode mode, __u64 *flags, void *data, + struct lustre_handle *lockh, int unref) { struct obd_device *obd = exp->exp_obd; __u64 lflags = *flags; @@ -2195,7 +2196,7 @@ static int osc_statfs_async(struct obd_export *exp, } req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_statfs_interpret; - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->aa_oi = oinfo; @@ -2400,7 +2401,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, struct osc_brw_async_args *aa; struct obdo *oa; - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS); if (!oa) { @@ -2479,6 +2480,33 @@ static int osc_disconnect(struct obd_export *exp) return rc; } +static int osc_ldlm_resource_invalidate(struct cfs_hash *hs, + struct cfs_hash_bd *bd, + struct hlist_node *hnode, void *arg) +{ + struct ldlm_resource *res = cfs_hash_object(hs, hnode); + struct osc_object *osc = NULL; + struct lu_env *env = arg; + struct ldlm_lock *lock; + + lock_res(res); + list_for_each_entry(lock, &res->lr_granted, l_res_link) { + if (lock->l_ast_data && !osc) { + osc = lock->l_ast_data; + cl_object_get(osc2cl(osc)); + } + lock->l_ast_data = NULL; + } + unlock_res(res); + + if (osc) { + osc_object_invalidate(env, osc); + cl_object_put(env, osc2cl(osc)); + } + + return 0; +} + static int osc_import_event(struct obd_device *obd, struct obd_import *imp, enum obd_import_event event) @@ -2506,17 +2534,18 @@ static int osc_import_event(struct obd_device *obd, struct lu_env *env; int refcheck; + ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); + env = cl_env_get(&refcheck); if (!IS_ERR(env)) { - /* Reset grants */ - cli = &obd->u.cli; - /* all pages go to failing rpcs due to the invalid - * import - */ - osc_io_unplug(env, cli, NULL); + osc_io_unplug(env, &obd->u.cli, NULL); - ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); + cfs_hash_for_each_nolock(ns->ns_rs_hash, + osc_ldlm_resource_invalidate, + env, 0); cl_env_put(env, &refcheck); + + ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); } else { rc = PTR_ERR(env); } @@ -2646,6 +2675,11 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) INIT_LIST_HEAD(&cli->cl_grant_shrink_list); ns_register_cancel(obd->obd_namespace, osc_cancel_weight); + + spin_lock(&osc_shrink_lock); + list_add_tail(&cli->cl_shrink_list, &osc_shrink_list); + spin_unlock(&osc_shrink_lock); + return rc; out_ptlrpcd_work: @@ -2699,6 +2733,10 @@ static int osc_cleanup(struct obd_device *obd) struct client_obd *cli = &obd->u.cli; int rc; + spin_lock(&osc_shrink_lock); + list_del(&cli->cl_shrink_list); + spin_unlock(&osc_shrink_lock); + /* lru cleanup */ if (cli->cl_cache) { LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0); @@ -2766,7 +2804,14 @@ static struct obd_ops osc_obd_ops = { .quotactl = osc_quotactl, }; -extern struct lu_kmem_descr osc_caches[]; +struct list_head osc_shrink_list = LIST_HEAD_INIT(osc_shrink_list); +DEFINE_SPINLOCK(osc_shrink_lock); + +static struct shrinker osc_cache_shrinker = { + .count_objects = osc_cache_shrink_count, + .scan_objects = osc_cache_shrink_scan, + .seeks = DEFAULT_SEEKS, +}; static int __init osc_init(void) { @@ -2792,6 +2837,8 @@ static int __init osc_init(void) if (rc) goto out_kmem; + register_shrinker(&osc_cache_shrinker); + /* This is obviously too much memory, only prevent overflow here */ if (osc_reqpool_mem_max >= 1 << 12 || osc_reqpool_mem_max == 0) { rc = -EINVAL; @@ -2830,6 +2877,7 @@ out_kmem: static void /*__exit*/ osc_exit(void) { + unregister_shrinker(&osc_cache_shrinker); class_unregister_type(LUSTRE_OSC_NAME); lu_kmem_fini(osc_caches); ptlrpc_free_rq_pool(osc_rq_pool); diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 804741362bc0..04a98a08ece1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -1160,7 +1160,7 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, if (atomic_read(&imp->imp_inval_count) != 0) { DEBUG_REQ(D_ERROR, req, "invalidate in flight"); *status = -EIO; - } else if (imp->imp_dlm_fake || req->rq_no_delay) { + } else if (req->rq_no_delay) { *status = -EWOULDBLOCK; } else if (req->rq_allow_replay && (imp->imp_state == LUSTRE_IMP_REPLAY || @@ -2662,11 +2662,16 @@ free_req: list_for_each_entry_safe(req, saved, &imp->imp_committed_list, rq_replay_list) { LASSERT(req->rq_transno != 0); - if (req->rq_import_generation < imp->imp_generation) { - DEBUG_REQ(D_RPCTRACE, req, "free stale open request"); - ptlrpc_free_request(req); - } else if (!req->rq_replay) { - DEBUG_REQ(D_RPCTRACE, req, "free closed open request"); + if (req->rq_import_generation < imp->imp_generation || + !req->rq_replay) { + DEBUG_REQ(D_RPCTRACE, req, "free %s open request", + req->rq_import_generation < + imp->imp_generation ? "stale" : "closed"); + + if (imp->imp_replay_cursor == &req->rq_replay_list) + imp->imp_replay_cursor = + req->rq_replay_list.next; + ptlrpc_free_request(req); } } @@ -3070,7 +3075,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 - 1) & PTLRPC_BULK_OPS_COUNT) == 0); + BUILD_BUG_ON(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) != 0); ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK; } @@ -3123,8 +3128,11 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req) req->rq_mbits = ptlrpc_next_xid(); } else { /* old version transfers rq_xid to peer as matchbits */ - req->rq_mbits = ptlrpc_next_xid(); - req->rq_xid = req->rq_mbits; + spin_lock(&req->rq_import->imp_lock); + list_del_init(&req->rq_unreplied_list); + ptlrpc_assign_next_xid_nolock(req); + req->rq_mbits = req->rq_xid; + spin_unlock(&req->rq_import->imp_lock); } CDEBUG(D_HA, "resend bulk old x%llu new x%llu\n", @@ -3256,7 +3264,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, req->rq_no_resend = 1; req->rq_pill.rc_fmt = (void *)&worker_format; - CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*args) > sizeof(req->rq_async_args)); args = ptlrpc_req_async_args(req); args->cb = cb; args->cbdata = cbdata; diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 49f3e6368415..dc0fe9d660da 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -277,7 +277,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, * then we hope there will be less RPCs per bucket at some * point, and sequence will catch up again */ - svcpt->scp_hist_seq += (1U << REQS_SEQ_SHIFT(svcpt)); + svcpt->scp_hist_seq += (1ULL << REQS_SEQ_SHIFT(svcpt)); new_seq = svcpt->scp_hist_seq; } @@ -420,7 +420,8 @@ void reply_out_callback(lnet_event_t *ev) rs->rs_on_net = 0; if (!rs->rs_no_ack || rs->rs_transno <= - rs->rs_export->exp_obd->obd_last_committed) + rs->rs_export->exp_obd->obd_last_committed || + list_empty(&rs->rs_obd_list)) ptlrpc_schedule_difficult_reply(rs); spin_unlock(&rs->rs_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index e8280194001c..93e172fe9ce4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -703,7 +703,7 @@ int ptlrpc_connect_import(struct obd_import *imp) ptlrpc_request_set_replen(request); request->rq_interpret_reply = ptlrpc_connect_interpret; - CLASSERT(sizeof(*aa) <= sizeof(request->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(request->rq_async_args)); aa = ptlrpc_req_async_args(request); memset(aa, 0, sizeof(*aa)); diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 99d7c667df28..356d73511ea3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -42,8 +42,6 @@ * of the format that the request conforms to. */ -#if !defined(__REQ_LAYOUT_USER__) - #define DEBUG_SUBSYSTEM S_RPC #include <linux/module.h> @@ -57,8 +55,6 @@ #include "../include/obd.h" #include "../include/obd_support.h" -/* __REQ_LAYOUT_USER__ */ -#endif /* struct ptlrpc_request, lustre_msg* */ #include "../include/lustre_req_layout.h" #include "../include/lustre_acl.h" @@ -1181,6 +1177,23 @@ struct req_format RQF_FLD_QUERY = DEFINE_REQ_FMT0("FLD_QUERY", fld_query_client, fld_query_server); EXPORT_SYMBOL(RQF_FLD_QUERY); +/* + * The 'fld_read_server' uses 'RMF_GENERIC_DATA' to hold the 'FLD_QUERY' + * RPC reply that is composed of 'struct lu_seq_range_array'. But there + * is not registered swabber function for 'RMF_GENERIC_DATA'. So the RPC + * peers need to handle the RPC reply with fixed little-endian format. + * + * In theory, we can define new structure with some swabber registered to + * handle the 'FLD_QUERY' RPC reply result automatically. But from the + * implementation view, it is not easy to be done within current "struct + * req_msg_field" framework. Because the sequence range array in the RPC + * reply is not fixed length, instead, its length depends on 'lu_seq_range' + * count, that is unknown when prepare the RPC buffer. Generally, for such + * flexible length RPC usage, there will be a field in the RPC layout to + * indicate the data length. But for the 'FLD_READ' RPC, we have no way to + * do that unless we add new length filed that will broken the on-wire RPC + * protocol and cause interoperability trouble with old peer. + */ struct req_format RQF_FLD_READ = DEFINE_REQ_FMT0("FLD_READ", fld_read_client, fld_read_server); EXPORT_SYMBOL(RQF_FLD_READ); @@ -1541,8 +1554,6 @@ struct req_format RQF_OST_GET_INFO_FIEMAP = ost_get_fiemap_server); EXPORT_SYMBOL(RQF_OST_GET_INFO_FIEMAP); -#if !defined(__REQ_LAYOUT_USER__) - /* Convenience macro */ #define FMT_FIELD(fmt, i, j) (fmt)->rf_fields[(i)].d[(j)] @@ -2221,6 +2232,3 @@ void req_capsule_shrink(struct req_capsule *pill, 1); } EXPORT_SYMBOL(req_capsule_shrink); - -/* __REQ_LAYOUT_USER__ */ -#endif diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index da1209e40f03..b8701841ab4a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -522,13 +522,14 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) */ spin_lock(&imp->imp_lock); ptlrpc_assign_next_xid_nolock(request); - request->rq_mbits = request->rq_xid; min_xid = ptlrpc_known_replied_xid(imp); spin_unlock(&imp->imp_lock); lustre_msg_set_last_xid(request->rq_reqmsg, min_xid); DEBUG_REQ(D_RPCTRACE, request, "Allocating new xid for resend on EINPROGRESS"); - } else if (request->rq_bulk) { + } + + if (request->rq_bulk) { ptlrpc_set_bulk_mbits(request); lustre_msg_set_mbits(request->rq_reqmsg, request->rq_mbits); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 7b6ffb195834..ef19dbe2ea5c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -1559,9 +1559,6 @@ out: return rc; } -/* ptlrpc/nrs_fifo.c */ -extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; - /** * Adds all policies that ship with the ptlrpc module, to NRS core's list of * policies \e nrs_core.nrs_policies. diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 13f00b7cbbe5..9456a1825918 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -469,6 +469,7 @@ int lustre_shrink_msg(struct lustre_msg *msg, int segment, default: LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); } + return 0; } EXPORT_SYMBOL(lustre_shrink_msg); @@ -509,8 +510,8 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len) __swab32s(&m->lm_repsize); __swab32s(&m->lm_cksum); __swab32s(&m->lm_flags); - CLASSERT(offsetof(typeof(*m), lm_padding_2) != 0); - CLASSERT(offsetof(typeof(*m), lm_padding_3) != 0); + BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_2) == 0); + BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_3) == 0); } required_len = lustre_msg_hdr_size_v2(m->lm_bufcount); @@ -1525,18 +1526,18 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *b) __swab64s(&b->pb_pre_versions[2]); __swab64s(&b->pb_pre_versions[3]); __swab64s(&b->pb_mbits); - CLASSERT(offsetof(typeof(*b), pb_padding0) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding1) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding64_0) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding64_1) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding64_2) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding0) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding1) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_0) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_1) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_2) == 0); /* While we need to maintain compatibility between * clients and servers without ptlrpc_body_v2 (< 2.3) * do not swab any fields beyond pb_jobid, as we are * using this swab function for both ptlrpc_body * and ptlrpc_body_v2. */ - CLASSERT(offsetof(typeof(*b), pb_jobid) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_jobid) == 0); } void lustre_swab_connect(struct obd_connect_data *ocd) @@ -1567,23 +1568,23 @@ void lustre_swab_connect(struct obd_connect_data *ocd) __swab64s(&ocd->ocd_maxbytes); if (ocd->ocd_connect_flags & OBD_CONNECT_MULTIMODRPCS) __swab16s(&ocd->ocd_maxmodrpcs); - CLASSERT(offsetof(typeof(*ocd), padding0)); - CLASSERT(offsetof(typeof(*ocd), padding1) != 0); + BUILD_BUG_ON(!offsetof(typeof(*ocd), padding0)); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding1) == 0); if (ocd->ocd_connect_flags & OBD_CONNECT_FLAGS2) __swab64s(&ocd->ocd_connect_flags2); - CLASSERT(offsetof(typeof(*ocd), padding3) != 0); - CLASSERT(offsetof(typeof(*ocd), padding4) != 0); - CLASSERT(offsetof(typeof(*ocd), padding5) != 0); - CLASSERT(offsetof(typeof(*ocd), padding6) != 0); - CLASSERT(offsetof(typeof(*ocd), padding7) != 0); - CLASSERT(offsetof(typeof(*ocd), padding8) != 0); - CLASSERT(offsetof(typeof(*ocd), padding9) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingA) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingB) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingC) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingD) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingE) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingF) != 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding3) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding4) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding5) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding6) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding7) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding8) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding9) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingA) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingB) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingC) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingD) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingE) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingF) == 0); } static void lustre_swab_obdo(struct obdo *o) @@ -1613,9 +1614,9 @@ static void lustre_swab_obdo(struct obdo *o) __swab32s(&o->o_uid_h); __swab32s(&o->o_gid_h); __swab64s(&o->o_data_version); - CLASSERT(offsetof(typeof(*o), o_padding_4) != 0); - CLASSERT(offsetof(typeof(*o), o_padding_5) != 0); - CLASSERT(offsetof(typeof(*o), o_padding_6) != 0); + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_4) == 0); + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_5) == 0); + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_6) == 0); } void lustre_swab_obd_statfs(struct obd_statfs *os) @@ -1631,15 +1632,15 @@ void lustre_swab_obd_statfs(struct obd_statfs *os) __swab32s(&os->os_namelen); __swab64s(&os->os_maxbytes); __swab32s(&os->os_state); - CLASSERT(offsetof(typeof(*os), os_fprecreated) != 0); - CLASSERT(offsetof(typeof(*os), os_spare2) != 0); - CLASSERT(offsetof(typeof(*os), os_spare3) != 0); - CLASSERT(offsetof(typeof(*os), os_spare4) != 0); - CLASSERT(offsetof(typeof(*os), os_spare5) != 0); - CLASSERT(offsetof(typeof(*os), os_spare6) != 0); - CLASSERT(offsetof(typeof(*os), os_spare7) != 0); - CLASSERT(offsetof(typeof(*os), os_spare8) != 0); - CLASSERT(offsetof(typeof(*os), os_spare9) != 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_fprecreated) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare2) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare3) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare4) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare5) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare6) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare7) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare8) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare9) == 0); } void lustre_swab_obd_ioobj(struct obd_ioobj *ioo) @@ -1679,7 +1680,7 @@ void lustre_swab_gl_desc(union ldlm_gl_desc *desc) __swab64s(&desc->lquota_desc.gl_hardlimit); __swab64s(&desc->lquota_desc.gl_softlimit); __swab64s(&desc->lquota_desc.gl_time); - CLASSERT(offsetof(typeof(desc->lquota_desc), gl_pad2) != 0); + BUILD_BUG_ON(offsetof(typeof(desc->lquota_desc), gl_pad2) == 0); } void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb) @@ -1738,24 +1739,24 @@ void lustre_swab_mdt_body(struct mdt_body *b) __swab32s(&b->mbo_flags); __swab32s(&b->mbo_rdev); __swab32s(&b->mbo_nlink); - CLASSERT(offsetof(typeof(*b), mbo_unused2) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), mbo_unused2) == 0); __swab32s(&b->mbo_suppgid); __swab32s(&b->mbo_eadatasize); __swab32s(&b->mbo_aclsize); __swab32s(&b->mbo_max_mdsize); - CLASSERT(offsetof(typeof(*b), mbo_unused3)); + BUILD_BUG_ON(!offsetof(typeof(*b), mbo_unused3)); __swab32s(&b->mbo_uid_h); __swab32s(&b->mbo_gid_h); - CLASSERT(offsetof(typeof(*b), mbo_padding_5) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_5) == 0); } void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b) { /* handle is opaque */ /* mio_handle is opaque */ - CLASSERT(offsetof(typeof(*b), mio_unused1)); - CLASSERT(offsetof(typeof(*b), mio_unused2)); - CLASSERT(offsetof(typeof(*b), mio_padding)); + BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused1)); + BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused2)); + BUILD_BUG_ON(!offsetof(typeof(*b), mio_padding)); } void lustre_swab_mgs_target_info(struct mgs_target_info *mti) @@ -1768,7 +1769,7 @@ void lustre_swab_mgs_target_info(struct mgs_target_info *mti) __swab32s(&mti->mti_flags); __swab32s(&mti->mti_instance); __swab32s(&mti->mti_nid_count); - CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64)); + BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); for (i = 0; i < MTI_NIDS_MAX; i++) __swab64s(&mti->mti_nids[i]); } @@ -1784,13 +1785,13 @@ void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *entry) /* mne_nid_(count|type) must be one byte size because we're gonna * access it w/o swapping. */ - CLASSERT(sizeof(entry->mne_nid_count) == sizeof(__u8)); - CLASSERT(sizeof(entry->mne_nid_type) == sizeof(__u8)); + BUILD_BUG_ON(sizeof(entry->mne_nid_count) != sizeof(__u8)); + BUILD_BUG_ON(sizeof(entry->mne_nid_type) != sizeof(__u8)); /* remove this assertion if ipv6 is supported. */ LASSERT(entry->mne_nid_type == 0); for (i = 0; i < entry->mne_nid_count; i++) { - CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64)); + BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); __swab64s(&entry->u.nids[i]); } } @@ -1828,7 +1829,7 @@ static void lustre_swab_obd_dqblk(struct obd_dqblk *b) __swab64s(&b->dqb_btime); __swab64s(&b->dqb_itime); __swab32s(&b->dqb_valid); - CLASSERT(offsetof(typeof(*b), dqb_padding) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), dqb_padding) == 0); } void lustre_swab_obd_quotactl(struct obd_quotactl *q) @@ -1899,7 +1900,7 @@ void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr) __swab32s(&rr->rr_flags_h); __swab32s(&rr->rr_umask); - CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0); + BUILD_BUG_ON(offsetof(typeof(*rr), rr_padding_4) == 0); }; void lustre_swab_lov_desc(struct lov_desc *ld) @@ -1948,7 +1949,7 @@ void lustre_swab_lmv_user_md(struct lmv_user_md *lum) __swab32s(&lum->lum_stripe_offset); __swab32s(&lum->lum_hash_type); __swab32s(&lum->lum_type); - CLASSERT(offsetof(typeof(*lum), lum_padding1)); + BUILD_BUG_ON(!offsetof(typeof(*lum), lum_padding1)); } EXPORT_SYMBOL(lustre_swab_lmv_user_md); @@ -2037,7 +2038,7 @@ void lustre_swab_ldlm_intent(struct ldlm_intent *i) static void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r) { __swab32s(&r->lr_type); - CLASSERT(offsetof(typeof(*r), lr_padding) != 0); + BUILD_BUG_ON(offsetof(typeof(*r), lr_padding) == 0); lustre_swab_ldlm_res_id(&r->lr_name); } @@ -2060,7 +2061,7 @@ void lustre_swab_ldlm_request(struct ldlm_request *rq) void lustre_swab_ldlm_reply(struct ldlm_reply *r) { __swab32s(&r->lock_flags); - CLASSERT(offsetof(typeof(*r), lock_padding) != 0); + BUILD_BUG_ON(offsetof(typeof(*r), lock_padding) == 0); lustre_swab_ldlm_lock_desc(&r->lock_desc); /* lock_handle opaque */ __swab64s(&r->lock_policy_res1); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c index 94e9fa85d774..601acb84f343 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c @@ -45,7 +45,7 @@ void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc, { int offset = mdidx * LNET_MAX_IOV; - CLASSERT(PTLRPC_MAX_BRW_PAGES < LI_POISON); + BUILD_BUG_ON(PTLRPC_MAX_BRW_PAGES >= LI_POISON); LASSERT(mdidx < desc->bd_md_max_brw); LASSERT(desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index e0f859ca6223..8e6a805487ec 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -226,6 +226,9 @@ struct ptlrpc_nrs_policy *nrs_request_policy(struct ptlrpc_nrs_request *nrq) sizeof(NRS_LPROCFS_QUANTUM_NAME_REG __stringify(LPROCFS_NRS_QUANTUM_MAX) " " \ NRS_LPROCFS_QUANTUM_NAME_HP __stringify(LPROCFS_NRS_QUANTUM_MAX)) +/* ptlrpc/nrs_fifo.c */ +extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; + /* recovd_thread.c */ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 1f55d642aa75..59b5813bd559 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -82,7 +82,8 @@ struct ptlrpcd { */ static int max_ptlrpcds; module_param(max_ptlrpcds, int, 0644); -MODULE_PARM_DESC(max_ptlrpcds, "Max ptlrpcd thread count to be started."); +MODULE_PARM_DESC(max_ptlrpcds, + "Max ptlrpcd thread count to be started (obsolete)."); /* * ptlrpcd_bind_policy is obsolete, but retained to ensure that @@ -102,7 +103,7 @@ MODULE_PARM_DESC(ptlrpcd_bind_policy, 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."); + "Max ptlrpcd thread count to be started per CPT."); /* * ptlrpcd_partner_group_size: The desired number of threads in each @@ -562,15 +563,6 @@ int ptlrpcd_start(struct ptlrpcd_ctl *pc) return 0; } - /* - * So far only "client" ptlrpcd uses an environment. In the future, - * ptlrpcd thread (or a thread-set) has to be given an argument, - * describing its "scope". - */ - rc = lu_context_init(&pc->pc_env.le_ctx, LCT_CL_THREAD | LCT_REMEMBER); - if (rc != 0) - goto out; - task = kthread_run(ptlrpcd, pc, "%s", pc->pc_name); if (IS_ERR(task)) { rc = PTR_ERR(task); @@ -593,9 +585,6 @@ out_set: spin_unlock(&pc->pc_lock); ptlrpc_set_destroy(set); } - lu_context_fini(&pc->pc_env.le_ctx); - -out: clear_bit(LIOD_START, &pc->pc_flags); return rc; } @@ -623,7 +612,6 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc) } wait_for_completion(&pc->pc_finishing); - lu_context_fini(&pc->pc_env.le_ctx); spin_lock(&pc->pc_lock); pc->pc_set = NULL; diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index c00449036884..7b58545c2de4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -78,28 +78,11 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) imp->imp_last_transno_checked = 0; ptlrpc_free_committed(imp); last_transno = imp->imp_last_replay_transno; - spin_unlock(&imp->imp_lock); CDEBUG(D_HA, "import %p from %s committed %llu last %llu\n", imp, obd2cli_tgt(imp->imp_obd), imp->imp_peer_committed_transno, last_transno); - /* Do I need to hold a lock across this iteration? We shouldn't be - * racing with any additions to the list, because we're in recovery - * and are therefore not processing additional requests to add. Calls - * to ptlrpc_free_committed might commit requests, but nothing "newer" - * than the one we're replaying (it can't be committed until it's - * replayed, and we're doing that here). l_f_e_safe protects against - * problems with the current request being committed, in the unlikely - * event of that race. So, in conclusion, I think that it's safe to - * perform this list-walk without the imp_lock held. - * - * But, the {mdc,osc}_replay_open callbacks both iterate - * request lists, and have comments saying they assume the - * imp_lock is being held by ptlrpc_replay, but it's not. it's - * just a little race... - */ - /* Replay all the committed open requests on committed_list first */ if (!list_empty(&imp->imp_committed_list)) { tmp = imp->imp_committed_list.prev; @@ -107,10 +90,6 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) /* The last request on committed_list hasn't been replayed */ if (req->rq_transno > last_transno) { - /* Since the imp_committed_list is immutable before - * all of it's requests being replayed, it's safe to - * use a cursor to accelerate the search - */ if (!imp->imp_resend_replay || imp->imp_replay_cursor == &imp->imp_committed_list) imp->imp_replay_cursor = imp->imp_replay_cursor->next; @@ -124,6 +103,7 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) break; req = NULL; + LASSERT(!list_empty(imp->imp_replay_cursor)); imp->imp_replay_cursor = imp->imp_replay_cursor->next; } @@ -156,7 +136,6 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) if (req && imp->imp_resend_replay) lustre_msg_add_flags(req->rq_reqmsg, MSG_RESENT); - spin_lock(&imp->imp_lock); /* The resend replay request may have been removed from the * unreplied list. */ @@ -221,6 +200,7 @@ int ptlrpc_resend(struct obd_import *imp) } spin_unlock(&imp->imp_lock); + OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT, 2); return 0; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 70c70558e177..b8091c118302 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1264,20 +1264,15 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, */ if (req->rq_ops->hpreq_check) { rc = req->rq_ops->hpreq_check(req); - /** - * XXX: Out of all current - * ptlrpc_hpreq_ops::hpreq_check(), only - * ldlm_cancel_hpreq_check() can return an error code; - * other functions assert in similar places, which seems - * odd. What also does not seem right is that handlers - * for those RPCs do not assert on the same checks, but - * rather handle the error cases. e.g. see - * ost_rw_hpreq_check(), and ost_brw_read(), - * ost_brw_write(). + if (rc == -ESTALE) { + req->rq_status = rc; + ptlrpc_error(req); + } + /** can only return error, + * 0 for normal request, + * or 1 for high priority request */ - if (rc < 0) - return rc; - LASSERT(rc == 0 || rc == 1); + LASSERT(rc <= 1); } spin_lock_bh(&req->rq_export->exp_rpc_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index a04e36cf6dd4..367f7e24e3da 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -61,7 +61,7 @@ void lustre_assert_wire_constants(void) MDS_DIR_END_OFF); LASSERTF(DEAD_HANDLE_MAGIC == 0xdeadbeefcafebabeULL, "found 0x%.16llxULL\n", DEAD_HANDLE_MAGIC); - CLASSERT(MTI_NAME_MAXLEN == 64); + BUILD_BUG_ON(MTI_NAME_MAXLEN != 64); LASSERTF(OST_REPLY == 0, "found %lld\n", (long long)OST_REPLY); LASSERTF(OST_GETATTR == 1, "found %lld\n", @@ -306,16 +306,16 @@ void lustre_assert_wire_constants(void) (long long)LCK_MAXMODE); LASSERTF(LCK_MODE_NUM == 8, "found %lld\n", (long long)LCK_MODE_NUM); - CLASSERT(LDLM_PLAIN == 10); - CLASSERT(LDLM_EXTENT == 11); - CLASSERT(LDLM_FLOCK == 12); - CLASSERT(LDLM_IBITS == 13); - CLASSERT(LDLM_MAX_TYPE == 14); - CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); - CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); - CLASSERT(LUSTRE_RES_ID_QUOTA_SEQ_OFF == 2); - CLASSERT(LUSTRE_RES_ID_QUOTA_VER_OID_OFF == 3); - CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); + BUILD_BUG_ON(LDLM_PLAIN != 10); + BUILD_BUG_ON(LDLM_EXTENT != 11); + BUILD_BUG_ON(LDLM_FLOCK != 12); + BUILD_BUG_ON(LDLM_IBITS != 13); + BUILD_BUG_ON(LDLM_MAX_TYPE != 14); + BUILD_BUG_ON(LUSTRE_RES_ID_SEQ_OFF != 0); + BUILD_BUG_ON(LUSTRE_RES_ID_VER_OID_OFF != 1); + BUILD_BUG_ON(LUSTRE_RES_ID_QUOTA_SEQ_OFF != 2); + BUILD_BUG_ON(LUSTRE_RES_ID_QUOTA_VER_OID_OFF != 3); + BUILD_BUG_ON(LUSTRE_RES_ID_HSH_OFF != 3); LASSERTF(OBD_PING == 400, "found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n", @@ -661,7 +661,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ptlrpc_body_v3, pb_slv)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_slv) == 8, "found %lld\n", (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_slv)); - CLASSERT(PTLRPC_NUM_VERSIONS == 4); + BUILD_BUG_ON(PTLRPC_NUM_VERSIONS != 4); LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_pre_versions) == 88, "found %lld\n", (long long)(int)offsetof(struct ptlrpc_body_v3, pb_pre_versions)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_pre_versions) == 32, "found %lld\n", @@ -682,7 +682,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ptlrpc_body_v3, pb_padding64_2)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding64_2) == 8, "found %lld\n", (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding64_2)); - CLASSERT(LUSTRE_JOBID_SIZE == 32); + BUILD_BUG_ON(LUSTRE_JOBID_SIZE != 32); LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_jobid) == 152, "found %lld\n", (long long)(int)offsetof(struct ptlrpc_body_v3, pb_jobid)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_jobid) == 32, "found %lld\n", @@ -1319,27 +1319,27 @@ void lustre_assert_wire_constants(void) OBD_MD_FLGETATTRLOCK); LASSERTF(OBD_MD_FLDATAVERSION == (0x0010000000000000ULL), "found 0x%.16llxULL\n", OBD_MD_FLDATAVERSION); - CLASSERT(OBD_FL_INLINEDATA == 0x00000001); - CLASSERT(OBD_FL_OBDMDEXISTS == 0x00000002); - CLASSERT(OBD_FL_DELORPHAN == 0x00000004); - CLASSERT(OBD_FL_NORPC == 0x00000008); - CLASSERT(OBD_FL_IDONLY == 0x00000010); - CLASSERT(OBD_FL_RECREATE_OBJS == 0x00000020); - CLASSERT(OBD_FL_DEBUG_CHECK == 0x00000040); - CLASSERT(OBD_FL_NO_USRQUOTA == 0x00000100); - CLASSERT(OBD_FL_NO_GRPQUOTA == 0x00000200); - CLASSERT(OBD_FL_CREATE_CROW == 0x00000400); - CLASSERT(OBD_FL_SRVLOCK == 0x00000800); - CLASSERT(OBD_FL_CKSUM_CRC32 == 0x00001000); - CLASSERT(OBD_FL_CKSUM_ADLER == 0x00002000); - CLASSERT(OBD_FL_CKSUM_CRC32C == 0x00004000); - CLASSERT(OBD_FL_CKSUM_RSVD2 == 0x00008000); - CLASSERT(OBD_FL_CKSUM_RSVD3 == 0x00010000); - CLASSERT(OBD_FL_SHRINK_GRANT == 0x00020000); - CLASSERT(OBD_FL_MMAP == 0x00040000); - CLASSERT(OBD_FL_RECOV_RESEND == 0x00080000); - CLASSERT(OBD_FL_NOSPC_BLK == 0x00100000); - CLASSERT(OBD_FL_LOCAL_MASK == 0xf0000000); + BUILD_BUG_ON(OBD_FL_INLINEDATA != 0x00000001); + BUILD_BUG_ON(OBD_FL_OBDMDEXISTS != 0x00000002); + BUILD_BUG_ON(OBD_FL_DELORPHAN != 0x00000004); + BUILD_BUG_ON(OBD_FL_NORPC != 0x00000008); + BUILD_BUG_ON(OBD_FL_IDONLY != 0x00000010); + BUILD_BUG_ON(OBD_FL_RECREATE_OBJS != 0x00000020); + BUILD_BUG_ON(OBD_FL_DEBUG_CHECK != 0x00000040); + BUILD_BUG_ON(OBD_FL_NO_USRQUOTA != 0x00000100); + BUILD_BUG_ON(OBD_FL_NO_GRPQUOTA != 0x00000200); + BUILD_BUG_ON(OBD_FL_CREATE_CROW != 0x00000400); + BUILD_BUG_ON(OBD_FL_SRVLOCK != 0x00000800); + BUILD_BUG_ON(OBD_FL_CKSUM_CRC32 != 0x00001000); + BUILD_BUG_ON(OBD_FL_CKSUM_ADLER != 0x00002000); + BUILD_BUG_ON(OBD_FL_CKSUM_CRC32C != 0x00004000); + BUILD_BUG_ON(OBD_FL_CKSUM_RSVD2 != 0x00008000); + BUILD_BUG_ON(OBD_FL_CKSUM_RSVD3 != 0x00010000); + BUILD_BUG_ON(OBD_FL_SHRINK_GRANT != 0x00020000); + BUILD_BUG_ON(OBD_FL_MMAP != 0x00040000); + BUILD_BUG_ON(OBD_FL_RECOV_RESEND != 0x00080000); + BUILD_BUG_ON(OBD_FL_NOSPC_BLK != 0x00100000); + BUILD_BUG_ON(OBD_FL_LOCAL_MASK != 0xf0000000); /* Checks for struct lov_ost_data_v1 */ LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, "found %lld\n", @@ -1388,7 +1388,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_mds_md_v1, lmm_objects[0])); LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects[0]) == 24, "found %lld\n", (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects[0])); - CLASSERT(LOV_MAGIC_V1 == (0x0BD10000 | 0x0BD0)); + BUILD_BUG_ON(LOV_MAGIC_V1 != (0x0BD10000 | 0x0BD0)); /* Checks for struct lov_mds_md_v3 */ LASSERTF((int)sizeof(struct lov_mds_md_v3) == 48, "found %lld\n", @@ -1417,7 +1417,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_mds_md_v3, lmm_layout_gen)); LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen) == 2, "found %lld\n", (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen)); - CLASSERT(LOV_MAXPOOLNAME == 15); + BUILD_BUG_ON(LOV_MAXPOOLNAME != 15); LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16]) == 48, "found %lld\n", (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16])); LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name[16]) == 1, "found %lld\n", @@ -1426,7 +1426,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_mds_md_v3, lmm_objects[0])); LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects[0]) == 24, "found %lld\n", (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects[0])); - CLASSERT(LOV_MAGIC_V3 == (0x0BD30000 | 0x0BD0)); + BUILD_BUG_ON(LOV_MAGIC_V3 != (0x0BD30000 | 0x0BD0)); LASSERTF(LOV_PATTERN_RAID0 == 0x00000001UL, "found 0x%.8xUL\n", (unsigned int)LOV_PATTERN_RAID0); LASSERTF(LOV_PATTERN_RAID1 == 0x00000002UL, "found 0x%.8xUL\n", @@ -1479,11 +1479,11 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lmv_mds_md_v1, lmv_stripe_fids[0])); LASSERTF((int)sizeof(((struct lmv_mds_md_v1 *)0)->lmv_stripe_fids[0]) == 16, "found %lld\n", (long long)(int)sizeof(((struct lmv_mds_md_v1 *)0)->lmv_stripe_fids[0])); - CLASSERT(LMV_MAGIC_V1 == 0x0CD20CD0); - CLASSERT(LMV_MAGIC_STRIPE == 0x0CD40CD0); - CLASSERT(LMV_HASH_TYPE_MASK == 0x0000ffff); - CLASSERT(LMV_HASH_FLAG_MIGRATION == 0x80000000); - CLASSERT(LMV_HASH_FLAG_DEAD == 0x40000000); + BUILD_BUG_ON(LMV_MAGIC_V1 != 0x0CD20CD0); + BUILD_BUG_ON(LMV_MAGIC_STRIPE != 0x0CD40CD0); + BUILD_BUG_ON(LMV_HASH_TYPE_MASK != 0x0000ffff); + BUILD_BUG_ON(LMV_HASH_FLAG_MIGRATION != 0x80000000); + BUILD_BUG_ON(LMV_HASH_FLAG_DEAD != 0x40000000); /* Checks for struct obd_statfs */ LASSERTF((int)sizeof(struct obd_statfs) == 144, "found %lld\n", @@ -2761,12 +2761,12 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_desc, ld_uuid)); LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_uuid) == 40, "found %lld\n", (long long)(int)sizeof(((struct lov_desc *)0)->ld_uuid)); - CLASSERT(LOV_DESC_MAGIC == 0xB0CCDE5C); + BUILD_BUG_ON(LOV_DESC_MAGIC != 0xB0CCDE5C); /* Checks for struct ldlm_res_id */ LASSERTF((int)sizeof(struct ldlm_res_id) == 32, "found %lld\n", (long long)(int)sizeof(struct ldlm_res_id)); - CLASSERT(RES_NAME_SIZE == 4); + BUILD_BUG_ON(RES_NAME_SIZE != 4); LASSERTF((int)offsetof(struct ldlm_res_id, name[4]) == 32, "found %lld\n", (long long)(int)offsetof(struct ldlm_res_id, name[4])); LASSERTF((int)sizeof(((struct ldlm_res_id *)0)->name[4]) == 8, "found %lld\n", @@ -3037,7 +3037,7 @@ void lustre_assert_wire_constants(void) /* Checks for struct mgs_send_param */ LASSERTF((int)sizeof(struct mgs_send_param) == 1024, "found %lld\n", (long long)(int)sizeof(struct mgs_send_param)); - CLASSERT(MGS_PARAM_MAXLEN == 1024); + BUILD_BUG_ON(MGS_PARAM_MAXLEN != 1024); LASSERTF((int)offsetof(struct mgs_send_param, mgs_param[1024]) == 1024, "found %lld\n", (long long)(int)offsetof(struct mgs_send_param, mgs_param[1024])); LASSERTF((int)sizeof(((struct mgs_send_param *)0)->mgs_param[1024]) == 1, "found %lld\n", @@ -3090,16 +3090,16 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct llog_logid, lgl_ogen)); LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4, "found %lld\n", (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogen)); - CLASSERT(OST_SZ_REC == 274730752); - CLASSERT(MDS_UNLINK_REC == 274801668); - CLASSERT(MDS_UNLINK64_REC == 275325956); - CLASSERT(MDS_SETATTR64_REC == 275325953); - CLASSERT(OBD_CFG_REC == 274857984); - CLASSERT(LLOG_GEN_REC == 274989056); - CLASSERT(CHANGELOG_REC == 275120128); - CLASSERT(CHANGELOG_USER_REC == 275185664); - CLASSERT(LLOG_HDR_MAGIC == 275010873); - CLASSERT(LLOG_LOGID_MAGIC == 275010875); + BUILD_BUG_ON(OST_SZ_REC != 274730752); + BUILD_BUG_ON(MDS_UNLINK_REC != 274801668); + BUILD_BUG_ON(MDS_UNLINK64_REC != 275325956); + BUILD_BUG_ON(MDS_SETATTR64_REC != 275325953); + BUILD_BUG_ON(OBD_CFG_REC != 274857984); + BUILD_BUG_ON(LLOG_GEN_REC != 274989056); + BUILD_BUG_ON(CHANGELOG_REC != 275120128); + BUILD_BUG_ON(CHANGELOG_USER_REC != 275185664); + BUILD_BUG_ON(LLOG_HDR_MAGIC != 275010873); + BUILD_BUG_ON(LLOG_LOGID_MAGIC != 275010875); /* Checks for struct llog_catid */ LASSERTF((int)sizeof(struct llog_catid) == 32, "found %lld\n", @@ -3519,30 +3519,30 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct llogd_body, lgd_cur_offset)); LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8, "found %lld\n", (long long)(int)sizeof(((struct llogd_body *)0)->lgd_cur_offset)); - CLASSERT(LLOG_ORIGIN_HANDLE_CREATE == 501); - CLASSERT(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502); - CLASSERT(LLOG_ORIGIN_HANDLE_READ_HEADER == 503); - CLASSERT(LLOG_ORIGIN_HANDLE_WRITE_REC == 504); - CLASSERT(LLOG_ORIGIN_HANDLE_CLOSE == 505); - CLASSERT(LLOG_ORIGIN_CONNECT == 506); - CLASSERT(LLOG_CATINFO == 507); - CLASSERT(LLOG_ORIGIN_HANDLE_PREV_BLOCK == 508); - CLASSERT(LLOG_ORIGIN_HANDLE_DESTROY == 509); - CLASSERT(LLOG_FIRST_OPC == 501); - CLASSERT(LLOG_LAST_OPC == 510); - CLASSERT(LLOG_CONFIG_ORIG_CTXT == 0); - CLASSERT(LLOG_CONFIG_REPL_CTXT == 1); - CLASSERT(LLOG_MDS_OST_ORIG_CTXT == 2); - CLASSERT(LLOG_MDS_OST_REPL_CTXT == 3); - CLASSERT(LLOG_SIZE_ORIG_CTXT == 4); - CLASSERT(LLOG_SIZE_REPL_CTXT == 5); - CLASSERT(LLOG_TEST_ORIG_CTXT == 8); - CLASSERT(LLOG_TEST_REPL_CTXT == 9); - CLASSERT(LLOG_CHANGELOG_ORIG_CTXT == 12); - CLASSERT(LLOG_CHANGELOG_REPL_CTXT == 13); - CLASSERT(LLOG_CHANGELOG_USER_ORIG_CTXT == 14); - CLASSERT(LLOG_AGENT_ORIG_CTXT == 15); - CLASSERT(LLOG_MAX_CTXTS == 16); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_CREATE != 501); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_NEXT_BLOCK != 502); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_READ_HEADER != 503); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_WRITE_REC != 504); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_CLOSE != 505); + BUILD_BUG_ON(LLOG_ORIGIN_CONNECT != 506); + BUILD_BUG_ON(LLOG_CATINFO != 507); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_PREV_BLOCK != 508); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_DESTROY != 509); + BUILD_BUG_ON(LLOG_FIRST_OPC != 501); + BUILD_BUG_ON(LLOG_LAST_OPC != 510); + BUILD_BUG_ON(LLOG_CONFIG_ORIG_CTXT != 0); + BUILD_BUG_ON(LLOG_CONFIG_REPL_CTXT != 1); + BUILD_BUG_ON(LLOG_MDS_OST_ORIG_CTXT != 2); + BUILD_BUG_ON(LLOG_MDS_OST_REPL_CTXT != 3); + BUILD_BUG_ON(LLOG_SIZE_ORIG_CTXT != 4); + BUILD_BUG_ON(LLOG_SIZE_REPL_CTXT != 5); + BUILD_BUG_ON(LLOG_TEST_ORIG_CTXT != 8); + BUILD_BUG_ON(LLOG_TEST_REPL_CTXT != 9); + BUILD_BUG_ON(LLOG_CHANGELOG_ORIG_CTXT != 12); + BUILD_BUG_ON(LLOG_CHANGELOG_REPL_CTXT != 13); + BUILD_BUG_ON(LLOG_CHANGELOG_USER_ORIG_CTXT != 14); + BUILD_BUG_ON(LLOG_AGENT_ORIG_CTXT != 15); + BUILD_BUG_ON(LLOG_MAX_CTXTS != 16); /* Checks for struct llogd_conn_body */ LASSERTF((int)sizeof(struct llogd_conn_body) == 40, "found %lld\n", @@ -3659,7 +3659,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_capa, lc_expiry)); LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_expiry) == 4, "found %lld\n", (long long)(int)sizeof(((struct lustre_capa *)0)->lc_expiry)); - CLASSERT(CAPA_HMAC_MAX_LEN == 64); + BUILD_BUG_ON(CAPA_HMAC_MAX_LEN != 64); LASSERTF((int)offsetof(struct lustre_capa, lc_hmac[64]) == 120, "found %lld\n", (long long)(int)offsetof(struct lustre_capa, lc_hmac[64])); LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_hmac[64]) == 1, "found %lld\n", @@ -3680,7 +3680,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_capa_key, lk_padding)); LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_padding) == 4, "found %lld\n", (long long)(int)sizeof(((struct lustre_capa_key *)0)->lk_padding)); - CLASSERT(CAPA_HMAC_KEY_MAX_LEN == 56); + BUILD_BUG_ON(CAPA_HMAC_KEY_MAX_LEN != 56); LASSERTF((int)offsetof(struct lustre_capa_key, lk_key[56]) == 72, "found %lld\n", (long long)(int)offsetof(struct lustre_capa_key, lk_key[56])); LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_key[56]) == 1, "found %lld\n", @@ -3741,9 +3741,9 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct fiemap, fm_extents)); LASSERTF((int)sizeof(((struct fiemap *)0)->fm_extents) == 0, "found %lld\n", (long long)(int)sizeof(((struct fiemap *)0)->fm_extents)); - CLASSERT(FIEMAP_FLAG_SYNC == 0x00000001); - CLASSERT(FIEMAP_FLAG_XATTR == 0x00000002); - CLASSERT(FIEMAP_FLAG_DEVICE_ORDER == 0x40000000); + BUILD_BUG_ON(FIEMAP_FLAG_SYNC != 0x00000001); + BUILD_BUG_ON(FIEMAP_FLAG_XATTR != 0x00000002); + BUILD_BUG_ON(FIEMAP_FLAG_DEVICE_ORDER != 0x40000000); /* Checks for struct fiemap_extent */ LASSERTF((int)sizeof(struct fiemap_extent) == 56, "found %lld\n", @@ -3768,18 +3768,18 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct fiemap_extent, fe_reserved[0])); LASSERTF((int)sizeof(((struct fiemap_extent *)0)->fe_reserved[0]) == 4, "found %lld\n", (long long)(int)sizeof(((struct fiemap_extent *)0)->fe_reserved[0])); - CLASSERT(FIEMAP_EXTENT_LAST == 0x00000001); - CLASSERT(FIEMAP_EXTENT_UNKNOWN == 0x00000002); - CLASSERT(FIEMAP_EXTENT_DELALLOC == 0x00000004); - CLASSERT(FIEMAP_EXTENT_ENCODED == 0x00000008); - CLASSERT(FIEMAP_EXTENT_DATA_ENCRYPTED == 0x00000080); - CLASSERT(FIEMAP_EXTENT_NOT_ALIGNED == 0x00000100); - CLASSERT(FIEMAP_EXTENT_DATA_INLINE == 0x00000200); - CLASSERT(FIEMAP_EXTENT_DATA_TAIL == 0x00000400); - CLASSERT(FIEMAP_EXTENT_UNWRITTEN == 0x00000800); - CLASSERT(FIEMAP_EXTENT_MERGED == 0x00001000); - CLASSERT(FIEMAP_EXTENT_NO_DIRECT == 0x40000000); - CLASSERT(FIEMAP_EXTENT_NET == 0x80000000); + BUILD_BUG_ON(FIEMAP_EXTENT_LAST != 0x00000001); + BUILD_BUG_ON(FIEMAP_EXTENT_UNKNOWN != 0x00000002); + BUILD_BUG_ON(FIEMAP_EXTENT_DELALLOC != 0x00000004); + BUILD_BUG_ON(FIEMAP_EXTENT_ENCODED != 0x00000008); + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_ENCRYPTED != 0x00000080); + BUILD_BUG_ON(FIEMAP_EXTENT_NOT_ALIGNED != 0x00000100); + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_INLINE != 0x00000200); + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_TAIL != 0x00000400); + BUILD_BUG_ON(FIEMAP_EXTENT_UNWRITTEN != 0x00000800); + BUILD_BUG_ON(FIEMAP_EXTENT_MERGED != 0x00001000); + BUILD_BUG_ON(FIEMAP_EXTENT_NO_DIRECT != 0x40000000); + BUILD_BUG_ON(FIEMAP_EXTENT_NET != 0x80000000); /* Checks for type posix_acl_xattr_entry */ LASSERTF((int)sizeof(struct posix_acl_xattr_entry) == 8, "found %lld\n", @@ -3828,7 +3828,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct link_ea_header, padding2)); LASSERTF((int)sizeof(((struct link_ea_header *)0)->padding2) == 4, "found %lld\n", (long long)(int)sizeof(((struct link_ea_header *)0)->padding2)); - CLASSERT(LINK_EA_MAGIC == 0x11EAF1DFUL); + BUILD_BUG_ON(LINK_EA_MAGIC != 0x11EAF1DFUL); /* Checks for struct link_ea_entry */ LASSERTF((int)sizeof(struct link_ea_entry) == 18, "found %lld\n", |