staging: lustre: Replace typedef with struct
v2 cover staging: lustre: Replace typedef with struct
Remove struct typedefs and rename structs accordingly as per kernel coding conventions.
---
Changes in v2:
- Split multiple typedef replacements into different patches.
Gargi Sharma (6):
staging: lustre: Replace typedef lnet_rc_data_t with struct
staging: lustre: Replace typedef lnet_remotenet_t with struct
staging: lustre: Replace typedef lnet_route_t with struct
staging: lustre: Replace typedef lnet_rtrbuf_t with struct
staging: lustre: Replace typedef lnet_test_peer_t with struct
staging: lustre: Replace typedef lnet_rtrbufpool_t with struct
.../staging/lustre/include/linux/lnet/lib-lnet.h | 8 +- .../staging/lustre/include/linux/lnet/lib-types.h | 32 +++---- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 48 +++++----- drivers/staging/lustre/lnet/lnet/router.c | 103 +++++++++++---------- drivers/staging/lustre/lnet/lnet/router_proc.c | 15 +-- 6 files changed, 106 insertions(+), 102 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/6 staging: lustre: Replace typedef lnet_rc_data_t with struct
Using typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurences of typedefs have been removed in the lib-types.h file. The typedef is detected by Script 1, and modified manually. Script 2 replaces all instances of the typedef.
Script 1:
@r1@
type T;
@@
* typedef struct { ... } T;
Script 2:
@@
typedef lnet_rc_data_t;
@@
(
- lnet_rc_data_t
+ struct lnet_rc_data
)
--- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/lnet/lnet/router.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-types.h +3 -3
@@ -296,13 +296,13 @@ typedef struct lnet_ni {/* router checker data, per router */ #define LNET_MAX_RTR_NIS 16#define LNET_PINGINFO_SIZE offsetof(struct lnet_ping_info, pi_ni[LNET_MAX_RTR_NIS]) -typedef struct { +struct lnet_rc_data {/* 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 */ struct lnet_ping_info *rcd_pinginfo;/* ping buffer */ -}lnet_rc_data_t ; +}; typedef struct lnet_peer { struct list_head lp_hashlist; /* chain on peer hash */
@@ -344,7 +344,7 @@ typedef struct lnet_peer {/* returned RC ping features */ unsigned int lp_ping_feats;struct list_head lp_routes;/* routers on this peer */ -lnet_rc_data_t *lp_rcd;/* router checker state */ +struct lnet_rc_data *lp_rcd;/* router checker state */ } lnet_peer_t;/* peer hash size */
drivers/staging/lustre/lnet/lnet/router.c +9 -9
@@ -642,7 +642,7 @@ lnet_swap_pinginfo(struct lnet_ping_info *info)* networks on that router. */ static void -lnet_parse_rc_info (lnet_rc_data_t *rcd) +lnet_parse_rc_info (struct lnet_rc_data *rcd) {struct lnet_ping_info *info = rcd->rcd_pinginfo;struct lnet_peer *gw = rcd->rcd_gateway;
@@ -733,7 +733,7 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd)static void lnet_router_checker_event (lnet_event_t *event) { -lnet_rc_data_t *rcd = event->md.user_ptr; +struct lnet_rc_data *rcd = event->md.user_ptr;struct lnet_peer *lp;LASSERT (rcd);
@@ -878,7 +878,7 @@ lnet_update_ni_status_locked(void) }static void -lnet_destroy_rc_data (lnet_rc_data_t *rcd) +lnet_destroy_rc_data (struct lnet_rc_data *rcd) {LASSERT (list_empty (&rcd->rcd_list));/* detached from network */
@@ -898,10 +898,10 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd)LIBCFS_FREE (rcd,sizeof (*rcd)); } -static lnet_rc_data_t * +static struct lnet_rc_data *lnet_create_rc_data_locked (lnet_peer_t *gateway) { -lnet_rc_data_t *rcd =NULL ; +struct lnet_rc_data *rcd =NULL ;struct lnet_ping_info *pi;lnet_md_t md;int rc;
@@ -984,7 +984,7 @@ lnet_router_check_interval(lnet_peer_t *rtr)static void lnet_ping_router_locked (lnet_peer_t *rtr) { -lnet_rc_data_t *rcd =NULL ; +struct lnet_rc_data *rcd =NULL ;unsigned long now =cfs_time_current ();int secs;
@@ -1124,8 +1124,8 @@ lnet_router_checker_stop(void)static void lnet_prune_rc_data (int wait_unlink) { -lnet_rc_data_t *rcd; -lnet_rc_data_t *tmp; +struct lnet_rc_data *rcd; +struct lnet_rc_data *tmp;lnet_peer_t *lp;struct list_head head;int i =2 ;
@@ -1182,7 +1182,7 @@ lnet_prune_rc_data(int wait_unlink)while (!list_empty (&head)) { rcd =list_entry (head.next, - lnet_rc_data_t, rcd_list); + struct lnet_rc_data, rcd_list);list_del_init (&rcd->rcd_list);lnet_destroy_rc_data (rcd); }
Signature · 1 line
2.7.4
PATCH v2 2/6 staging: lustre: Replace typedef lnet_remotenet_t with struct
In reply to Gargi SharmaUsing typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurences of typedefs have been removed in the lib-types.h file. The typedef is detected using Script 1 and the changes are done manually. Script 2 replaces all the instances of lnet_remotenet_t with struct lnet_remotenet.
Script 1:
@r1@
type T;
@@
* typedef struct { ... } T;
Script 2:
@@
typedef lnet_remotenet_t;
@@
(
- lnet_remotenet_t
+ struct lnet_remotenet
)
--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- .../staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 6 +++--- drivers/staging/lustre/lnet/lnet/router.c | 24 +++++++++++----------- drivers/staging/lustre/lnet/lnet/router_proc.c | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +1 -1
@@ -473,7 +473,7 @@ int lnet_rtrpools_adjust(int tiny, int small, int large);int lnet_rtrpools_enable (void );void lnet_rtrpools_disable (void );void lnet_rtrpools_free (int keep_pools); -lnet_remotenet_t *lnet_find_net_locked (__u32 net); +struct lnet_remotenet *lnet_find_net_locked (__u32 net);int lnet_dyn_add_ni (lnet_pid_t requested_pid,struct lnet_ioctl_config_data *conf);int lnet_dyn_del_ni (__u32 net);
drivers/staging/lustre/include/linux/lnet/lib-types.h +2 -2
@@ -383,12 +383,12 @@ typedef struct {#define LNET_REMOTE_NETS_HASH_MAX (1U << 16)#define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits) -typedef struct { +struct lnet_remotenet {struct list_head lrn_list;/* chain on ln_remote_nets_hash */ struct list_head lrn_routes;/* routes to me */ __u32 lrn_net;/* my net number */ -}lnet_remotenet_t ; +};/** lnet message has credit and can be submitted to lnd for send/receive */ #define LNET_CREDIT_OK 0
drivers/staging/lustre/lnet/lnet/api-ni.c +1 -1
@@ -1758,7 +1758,7 @@ lnet_dyn_add_ni(lnet_pid_t requested_pid, struct lnet_ioctl_config_data *conf)lnet_handle_md_t md_handle;struct lnet_ni *ni;struct list_head net_head; -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;int rc;INIT_LIST_HEAD (&net_head);
drivers/staging/lustre/lnet/lnet/lib-move.c +3 -3
@@ -996,7 +996,7 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2)static lnet_peer_t *lnet_find_route_locked (lnet_ni_t *ni,lnet_nid_t target,lnet_nid_t rtr_nid) { -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;lnet_route_t *route;lnet_route_t *best_route;lnet_route_t *last_route;
@@ -2288,7 +2288,7 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) {struct list_head *e;struct lnet_ni *ni; -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;__u32 dstnet =LNET_NIDNET (dstnid);int hops;int cpt;
@@ -2345,7 +2345,7 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) rn_list =lnet_net2rnethash (dstnet);list_for_each (e, rn_list) { - rnet =list_entry (e, lnet_remotenet_t, lrn_list); + rnet = list_entry(e, struct lnet_remotenet, lrn_list);if (rnet->lrn_net == dstnet) {lnet_route_t *route;
drivers/staging/lustre/lnet/lnet/router.c +12 -12
@@ -217,10 +217,10 @@ lnet_rtr_decref_locked(lnet_peer_t *lp) } } -lnet_remotenet_t * +struct lnet_remotenet *lnet_find_net_locked (__u32 net) { -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;struct list_head *tmp;struct list_head *rn_list;
@@ -228,7 +228,7 @@ lnet_find_net_locked(__u32 net) rn_list =lnet_net2rnethash (net);list_for_each (tmp, rn_list) { - rnet =list_entry (tmp, lnet_remotenet_t, lrn_list); + rnet = list_entry(tmp, struct lnet_remotenet, lrn_list);if (rnet->lrn_net == net)return rnet;
@@ -268,7 +268,7 @@ static void lnet_shuffle_seed(void)/* NB expects LNET_LOCK held */ static void -lnet_add_route_to_rnet (lnet_remotenet_t *rnet,lnet_route_t *route) +lnet_add_route_to_rnet (struct lnet_remotenet *rnet,lnet_route_t *route) {unsigned int len =0 ;unsigned int offset =0 ;
@@ -299,8 +299,8 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, unsigned int priority) {struct list_head *e; -lnet_remotenet_t *rnet; -lnet_remotenet_t *rnet2; +struct lnet_remotenet *rnet; +struct lnet_remotenet *rnet2;lnet_route_t *route;lnet_ni_t *ni;int add_route;
@@ -415,7 +415,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway,int lnet_check_routes (void ) { -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;lnet_route_t *route;lnet_route_t *route2;struct list_head *e1;
@@ -429,7 +429,7 @@ lnet_check_routes(void)for (i =0 ; i <LNET_REMOTE_NETS_HASH_SIZE ; i++) { rn_list = &the_lnet.ln_remote_nets_hash[i];list_for_each (e1, rn_list) { - rnet =list_entry (e1, lnet_remotenet_t, lrn_list); + rnet = list_entry(e1, struct lnet_remotenet, lrn_list); route2 =NULL ;list_for_each (e2, &rnet->lrn_routes) {
@@ -471,7 +471,7 @@ int lnet_del_route(__u32 net, lnet_nid_t gw_nid) {struct lnet_peer *gateway; -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;lnet_route_t *route;struct list_head *e1;struct list_head *e2;
@@ -494,7 +494,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid) again:list_for_each (e1, rn_list) { - rnet =list_entry (e1, lnet_remotenet_t, lrn_list); + rnet = list_entry(e1, struct lnet_remotenet, lrn_list);if (!(net ==LNET_NIDNET (LNET_NID_ANY ) || net == rnet->lrn_net))
@@ -587,7 +587,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, {struct list_head *e1;struct list_head *e2; -lnet_remotenet_t *rnet; +struct lnet_remotenet *rnet;lnet_route_t *route;int cpt;int i;
@@ -598,7 +598,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,for (i =0 ; i <LNET_REMOTE_NETS_HASH_SIZE ; i++) { rn_list = &the_lnet.ln_remote_nets_hash[i];list_for_each (e1, rn_list) { - rnet =list_entry (e1, lnet_remotenet_t, lrn_list); + rnet = list_entry(e1, struct lnet_remotenet, lrn_list);list_for_each (e2, &rnet->lrn_routes) { route =list_entry (e2, lnet_route_t, lr_list);
drivers/staging/lustre/lnet/lnet/router_proc.c +2 -2
@@ -172,7 +172,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,struct list_head *n;struct list_head *r;lnet_route_t *route =NULL ; -lnet_remotenet_t *rnet =NULL ; +struct lnet_remotenet *rnet =NULL ;int skip = off -1 ;struct list_head *rn_list;int i;
@@ -191,7 +191,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, n = rn_list->next;while (n != rn_list && !route) { - rnet =list_entry (n, lnet_remotenet_t, + rnet = list_entry(n, struct lnet_remotenet, lrn_list); r = rnet->lrn_routes.next;
Signature · 1 line
2.7.4
PATCH v2 3/6 staging: lustre: Replace typedef lnet_route_t with struct
In reply to Gargi SharmaUsing typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurences of typedefs have been removed in the lib-types.h file. Script 1 was used to identify typedef and changes were done manually. Script 2 was used to convert all instances of typedef lnet_route_t to struct lnet_route.
Script 1:
@r1@
type T;
@@
* typedef struct { ... } T;
Script 2:
@@
typedef lnet_route_t;
@@
(
- lnet_route_t
+ struct lnet_route
)
--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- .../staging/lustre/include/linux/lnet/lib-types.h | 6 ++--- drivers/staging/lustre/lnet/lnet/lib-move.c | 12 +++++----- drivers/staging/lustre/lnet/lnet/router.c | 27 ++++++++++++---------- drivers/staging/lustre/lnet/lnet/router_proc.c | 9 ++++---- 5 files changed, 30 insertions(+), 26 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +1 -1
@@ -65,7 +65,7 @@ extern lnet_t the_lnet; /* THE network *//** exclusive lock */ #define LNET_LOCK_EX CFS_PERCPT_LOCK_EX -static inline int lnet_is_route_alive (lnet_route_t *route) +static inline int lnet_is_route_alive (struct lnet_route *route) {/* gateway is down */ if (!route->lr_gateway->lp_alive)
drivers/staging/lustre/include/linux/lnet/lib-types.h +3 -3
@@ -339,7 +339,7 @@ typedef struct lnet_peer {lnet_nid_t lp_nid;/* peer's NID */ int lp_refcount;/* # refs */ int lp_cpt;/* CPT this peer attached on */ -/* # refs from lnet_route_t::lr_gateway */ +/* # refs from struct lnet_route::lr_gateway */ int lp_rtr_refcount;/* returned RC ping features */ unsigned int lp_ping_feats;
@@ -368,7 +368,7 @@ struct lnet_peer_table {#define lnet_peer_aliveness_enabled (lp) (the_lnet.ln_routing && \ (lp)->lp_ni->ni_peertimeout > 0) -typedef struct { +struct lnet_route {struct list_head lr_list;/* chain on net */ struct list_head lr_gwlist;/* chain on gateway */ lnet_peer_t *lr_gateway;/* router node */
@@ -377,7 +377,7 @@ typedef struct {unsigned int lr_downis;/* number of down NIs */ __u32 lr_hops;/* how far I am */ unsigned int lr_priority;/* route priority */ -} lnet_route_t; +};#define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)#define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
drivers/staging/lustre/lnet/lnet/lib-move.c +6 -6
@@ -956,7 +956,7 @@ lnet_return_rx_credits_locked(lnet_msg_t *msg) }static int -lnet_compare_routes (lnet_route_t *r1,lnet_route_t *r2) +lnet_compare_routes (struct lnet_route *r1,struct lnet_route *r2) {lnet_peer_t *p1 = r1->lr_gateway;lnet_peer_t *p2 = r2->lr_gateway;
@@ -997,9 +997,9 @@ static lnet_peer_t * lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) {struct lnet_remotenet *rnet; -lnet_route_t *route; -lnet_route_t *best_route; -lnet_route_t *last_route; +struct lnet_route *route; +struct lnet_route *best_route; +struct lnet_route *last_route;struct lnet_peer *lp_best;struct lnet_peer *lp;int rc;
@@ -2348,8 +2348,8 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) rnet = list_entry(e, struct lnet_remotenet, lrn_list);if (rnet->lrn_net == dstnet) { -lnet_route_t *route; -lnet_route_t *shortest =NULL ; +struct lnet_route *route; +struct lnet_route *shortest =NULL ;__u32 shortest_hops =LNET_UNDEFINED_HOPS ;__u32 route_hops;
drivers/staging/lustre/lnet/lnet/router.c +15 -12
@@ -268,7 +268,7 @@ static void lnet_shuffle_seed(void)/* NB expects LNET_LOCK held */ static void -lnet_add_route_to_rnet (struct lnet_remotenet *rnet,lnet_route_t *route) +lnet_add_route_to_rnet (struct lnet_remotenet *rnet,struct lnet_route *route) {unsigned int len =0 ;unsigned int offset =0 ;
@@ -301,7 +301,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway,struct list_head *e;struct lnet_remotenet *rnet;struct lnet_remotenet *rnet2; -lnet_route_t *route; +struct lnet_route *route;lnet_ni_t *ni;int add_route;int rc;
@@ -368,7 +368,8 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway,/* Search for a duplicate route (it's a NOOP if it is) */ add_route =1 ;list_for_each (e, &rnet2->lrn_routes) { -lnet_route_t *route2 =list_entry (e, lnet_route_t, lr_list); + struct lnet_route *route2 = list_entry(e, struct lnet_route, + lr_list);if (route2->lr_gateway == route->lr_gateway) { add_route =0 ;
@@ -416,8 +417,8 @@ intlnet_check_routes (void) {struct lnet_remotenet *rnet; -lnet_route_t *route; -lnet_route_t *route2; +struct lnet_route *route; +struct lnet_route *route2;struct list_head *e1;struct list_head *e2;int cpt;
@@ -437,7 +438,8 @@ lnet_check_routes(void)lnet_nid_t nid2;int net; - route =list_entry (e2, lnet_route_t, lr_list); + route = list_entry(e2, struct lnet_route, + lr_list);if (!route2) { route2 = route;
@@ -472,7 +474,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid) {struct lnet_peer *gateway;struct lnet_remotenet *rnet; -lnet_route_t *route; +struct lnet_route *route;struct list_head *e1;struct list_head *e2;int rc = -ENOENT ;
@@ -501,7 +503,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid)continue ;list_for_each (e2, &rnet->lrn_routes) { - route =list_entry (e2, lnet_route_t, lr_list); + route = list_entry(e2, struct lnet_route, lr_list); gateway = route->lr_gateway; if (!(gw_nid == LNET_NID_ANY ||
@@ -588,7 +590,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,struct list_head *e1;struct list_head *e2;struct lnet_remotenet *rnet; -lnet_route_t *route; +struct lnet_route *route;int cpt;int i;struct list_head *rn_list;
@@ -601,7 +603,8 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, rnet = list_entry(e1, struct lnet_remotenet, lrn_list);list_for_each (e2, &rnet->lrn_routes) { - route =list_entry (e2, lnet_route_t, lr_list); + route = list_entry(e2, struct lnet_route, + lr_list);if (!idx--) { *net = rnet->lrn_net;
@@ -646,7 +649,7 @@ lnet_parse_rc_info(struct lnet_rc_data *rcd) {struct lnet_ping_info *info = rcd->rcd_pinginfo;struct lnet_peer *gw = rcd->rcd_gateway; -lnet_route_t *rte; +struct lnet_route *rte;if (!gw->lp_alive)return ;
@@ -823,7 +826,7 @@ lnet_wait_known_routerstate(void)void lnet_router_ni_update_locked (lnet_peer_t *gw,__u32 net) { -lnet_route_t *rte; +struct lnet_route *rte;if ((gw->lp_ping_feats &LNET_PING_FEAT_NI_STATUS )) {list_for_each_entry (rte, &gw->lp_routes, lr_gwlist) {
drivers/staging/lustre/lnet/lnet/router_proc.c +5 -4
@@ -171,7 +171,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, }else {struct list_head *n;struct list_head *r; -lnet_route_t *route =NULL ; +struct lnet_route *route =NULL ;struct lnet_remotenet *rnet =NULL ;int skip = off -1 ;struct list_head *rn_list;
@@ -197,8 +197,9 @@ static int proc_lnet_routes(struct ctl_table *table, int write, r = rnet->lrn_routes.next;while (r != &rnet->lrn_routes) { -lnet_route_t *re = -list_entry (r, lnet_route_t, +struct lnet_route *re = +list_entry (r, + struct lnet_route, lr_list);if (!skip) { route = re;
@@ -331,7 +332,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,int last_ping =cfs_duration_sec (cfs_time_sub (now, peer->lp_ping_timestamp));int down_ni =0 ; -lnet_route_t *rtr; +struct lnet_route *rtr;if ((peer->lp_ping_feats &LNET_PING_FEAT_NI_STATUS )) {
Signature · 1 line
2.7.4
PATCH v2 4/6 staging: lustre: Replace typedef lnet_rtrbuf_t with struct
In reply to Gargi SharmaUsing typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurences of lnet_rtrbuf_t has been removed. Script 1 was used to identify typedef and changes were done manually. Script 2 was used to replace lnet_rtrbuf_t with struct lnet_rtrbuf.
Script 1:
@r1@
type T;
@@
* typedef struct { ... } T;
Script 2:
@@
typedef lnet_rtrbuf_t;
@@
(
- lnet_rtrbuf_t
+ struct lnet_rtrbuf
)
--- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 8 ++++---- drivers/staging/lustre/lnet/lnet/router.c | 18 +++++++++--------- 4 files changed, 16 insertions(+), 16 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +1 -1
@@ -468,7 +468,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg);void lnet_router_debugfs_init (void );void lnet_router_debugfs_fini (void );int lnet_rtrpools_alloc (int im_a_router); -void lnet_destroy_rtrbuf (lnet_rtrbuf_t *rb,int npages); +void lnet_destroy_rtrbuf (struct lnet_rtrbuf *rb,int npages);int lnet_rtrpools_adjust (int tiny,int small,int large);int lnet_rtrpools_enable (void );void lnet_rtrpools_disable (void );
drivers/staging/lustre/include/linux/lnet/lib-types.h +2 -2
@@ -409,11 +409,11 @@ typedef struct {int rbp_mincredits;/* low water mark */ } lnet_rtrbufpool_t; -typedef struct { +struct lnet_rtrbuf {struct list_head rb_list;/* chain on rbp_bufs */ lnet_rtrbufpool_t *rb_pool;/* owning pool */ lnet_kiov_t rb_kiov[0 ];/* the buffer space */ -}lnet_rtrbuf_t ; +};#define LNET_PEER_HASHSIZE 503/* prime! */
drivers/staging/lustre/lnet/lnet/lib-move.c +4 -4
@@ -710,7 +710,7 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv)*/ lnet_peer_t *lp = msg->msg_rxpeer;lnet_rtrbufpool_t *rbp; -lnet_rtrbuf_t *rb; +struct lnet_rtrbuf *rb;LASSERT (!msg->msg_iov);LASSERT (!msg->msg_kiov);
@@ -758,7 +758,7 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) }LASSERT (!list_empty (&rbp->rbp_bufs)); - rb =list_entry (rbp->rbp_bufs.next, lnet_rtrbuf_t, rb_list); + rb = list_entry(rbp->rbp_bufs.next, struct lnet_rtrbuf, rb_list);list_del (&rb->rb_list); msg->msg_niov = rbp->rbp_npages;
@@ -878,7 +878,7 @@ lnet_return_rx_credits_locked(lnet_msg_t *msg)if (msg->msg_rtrcredit) {/* give back global router credits */ -lnet_rtrbuf_t *rb; +struct lnet_rtrbuf *rb;lnet_rtrbufpool_t *rbp;/*
@@ -888,7 +888,7 @@ lnet_return_rx_credits_locked(lnet_msg_t *msg)*/ LASSERT (msg->msg_kiov); - rb =list_entry (msg->msg_kiov, lnet_rtrbuf_t, rb_kiov[0 ]); + rb = list_entry(msg->msg_kiov, struct lnet_rtrbuf, rb_kiov[0]); rbp = rb->rb_pool; msg->msg_kiov =NULL ;
drivers/staging/lustre/lnet/lnet/router.c +9 -9
@@ -1306,9 +1306,9 @@ lnet_router_checker(void *arg) }void -lnet_destroy_rtrbuf (lnet_rtrbuf_t *rb,int npages) +lnet_destroy_rtrbuf (struct lnet_rtrbuf *rb,int npages) { - int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); + int sz = offsetof(struct lnet_rtrbuf, rb_kiov[npages]);while (--npages >=0 )__free_page (rb->rb_kiov[npages].bv_page);
@@ -1316,13 +1316,13 @@ lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages)LIBCFS_FREE (rb, sz); } -static lnet_rtrbuf_t * +static struct lnet_rtrbuf *lnet_new_rtrbuf (lnet_rtrbufpool_t *rbp,int cpt) {int npages = rbp->rbp_npages; - int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); + int sz = offsetof(struct lnet_rtrbuf, rb_kiov[npages]);struct page *page; -lnet_rtrbuf_t *rb; +struct lnet_rtrbuf *rb;int i;LIBCFS_CPT_ALLOC (rb,lnet_cpt_table (), cpt, sz);
@@ -1356,8 +1356,8 @@ lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp, int cpt) {int npages = rbp->rbp_npages;struct list_head tmp; -lnet_rtrbuf_t *rb; -lnet_rtrbuf_t *temp; +struct lnet_rtrbuf *rb; +struct lnet_rtrbuf *temp;if (!rbp->rbp_nbuffers)/* not initialized or already freed */ return ;
@@ -1384,7 +1384,7 @@ static int lnet_rtrpool_adjust_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) {struct list_head rb_list; -lnet_rtrbuf_t *rb; +struct lnet_rtrbuf *rb;int num_rb;int num_buffers =0 ;int old_req_nbufs;
@@ -1459,7 +1459,7 @@ lnet_rtrpool_adjust_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) failed:while (!list_empty (&rb_list)) { - rb =list_entry (rb_list.next, lnet_rtrbuf_t, rb_list); + rb = list_entry(rb_list.next, struct lnet_rtrbuf, rb_list);list_del (&rb->rb_list);lnet_destroy_rtrbuf (rb, npages); }
Signature · 1 line
2.7.4
PATCH v2 5/6 staging: lustre: Replace typedef lnet_test_peer_t with struct
In reply to Gargi SharmaUsing typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurence of typedef lnet_test_peer_t has been removed. Script 1 was used to detect typedef and changes were done manually. Script 2 was used to replace lnet_test_peer_t with struct lnet_test_peer.
Script 1:
@r1@
type T;
@@
* typedef struct { ... } T;
Script 2:
@@
typedef lnet_test_peer_t;
@@
(
- lnet_test_peer_t
+ struct lnet_test_peer
)
--- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-types.h +2 -2
@@ -164,12 +164,12 @@ typedef struct lnet_libmd {#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1)#define LNET_MD_FLAG_ABORTED (1 << 2) -typedef struct { +struct lnet_test_peer {/* info about peers we are trying to fail */ struct list_head tp_list;/* ln_test_peers */ lnet_nid_t tp_nid;/* matching nid */ unsigned int tp_threshold;/* # failures to simulate */ -}lnet_test_peer_t ; +};#define LNET_COOKIE_TYPE_MD 1#define LNET_COOKIE_TYPE_ME 2
drivers/staging/lustre/lnet/lnet/lib-move.c +6 -6
@@ -47,8 +47,8 @@ MODULE_PARM_DESC(local_nid_dist_zero, "Reserved");int lnet_fail_nid (lnet_nid_t nid,unsigned int threshold) { -lnet_test_peer_t *tp; -lnet_test_peer_t *temp; +struct lnet_test_peer *tp; +struct lnet_test_peer *temp;struct list_head *el;struct list_head *next;struct list_head cull;
@@ -75,7 +75,7 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold)lnet_net_lock (0 );list_for_each_safe (el, next, &the_lnet.ln_test_peers) { - tp =list_entry (el, lnet_test_peer_t, tp_list); + tp = list_entry(el, struct lnet_test_peer, tp_list); if (!tp->tp_threshold || /* needs culling anyway */ nid == LNET_NID_ANY || /* removing all entries */
@@ -97,8 +97,8 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold)static int fail_peer (lnet_nid_t nid,int outgoing) { -lnet_test_peer_t *tp; -lnet_test_peer_t *temp; +struct lnet_test_peer *tp; +struct lnet_test_peer *temp;struct list_head *el;struct list_head *next;struct list_head cull;
@@ -110,7 +110,7 @@ fail_peer(lnet_nid_t nid, int outgoing)lnet_net_lock (0 );list_for_each_safe (el, next, &the_lnet.ln_test_peers) { - tp =list_entry (el, lnet_test_peer_t, tp_list); + tp = list_entry(el, struct lnet_test_peer, tp_list);if (!tp->tp_threshold) {/* zombie entry */
Signature · 1 line
2.7.4
PATCH v2 6/6 staging: lustre: Replace typedef lnet_rtrbufpool_t with struct
In reply to Gargi SharmaUsing typedef for a structure type is not suggested in Linux kernel coding style guidelines. Hence, occurence of typedef lnet_rtrbufpool_t has been remove. Script 1 was used to detect the typedef and changes were done manually. Script 2 was used to replace lnet_rtrbufpool_t with struct lnet_rtrbufpool.
Script 1:
@r1@
type T;
@@
* typedef struct { ... } T;
Script 2:
@@
typedef lnet_rtrbufpool_t;
@@
(
- lnet_rtrbufpool_t
+ struct lnet_rtrbufpool
)
--- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 8 ++++---- drivers/staging/lustre/lnet/lnet/lib-move.c | 10 +++++----- drivers/staging/lustre/lnet/lnet/router.c | 18 +++++++++--------- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +1 -1
@@ -496,7 +496,7 @@ void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,int lnet_send (lnet_nid_t nid,lnet_msg_t *msg,lnet_nid_t rtr_nid);void lnet_return_tx_credits_locked (lnet_msg_t *msg);void lnet_return_rx_credits_locked (lnet_msg_t *msg); -void lnet_schedule_blocked_locked (lnet_rtrbufpool_t *rbp); +void lnet_schedule_blocked_locked (struct lnet_rtrbufpool *rbp);void lnet_drop_routed_msgs_locked (struct list_head *list,int cpt);/* portals functions */
drivers/staging/lustre/include/linux/lnet/lib-types.h +4 -4
@@ -395,7 +395,7 @@ struct lnet_remotenet {/** lnet message is waiting for credit */ #define LNET_CREDIT_WAIT 1 -typedef struct { +struct lnet_rtrbufpool {struct list_head rbp_bufs;/* my free buffer pool */ struct list_head rbp_msgs;/* messages blocking for a buffer */
@@ -407,11 +407,11 @@ typedef struct {int rbp_credits;/* # free buffers / blocked messages */ int rbp_mincredits;/* low water mark */ -} lnet_rtrbufpool_t; +};struct lnet_rtrbuf {struct list_head rb_list;/* chain on rbp_bufs */ -lnet_rtrbufpool_t *rb_pool;/* owning pool */ +struct lnet_rtrbufpool *rb_pool;/* owning pool */ lnet_kiov_t rb_kiov[0 ];/* the buffer space */ };
@@ -595,7 +595,7 @@ typedef struct {/* validity stamp */ __u64 ln_routers_version;/* percpt router buffer pools */ -lnet_rtrbufpool_t **ln_rtrpools; +struct lnet_rtrbufpool **ln_rtrpools;lnet_handle_md_t ln_ping_target_md;lnet_handle_eq_t ln_ping_target_eq;
drivers/staging/lustre/lnet/lnet/lib-move.c +5 -5
@@ -679,10 +679,10 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)return LNET_CREDIT_OK ; } -static lnet_rtrbufpool_t * +static struct lnet_rtrbufpool *lnet_msg2bufpool (lnet_msg_t *msg) { -lnet_rtrbufpool_t *rbp; +struct lnet_rtrbufpool *rbp;int cpt;LASSERT (msg->msg_rx_committed);
@@ -709,7 +709,7 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv)* received or OK to receive */ lnet_peer_t *lp = msg->msg_rxpeer; -lnet_rtrbufpool_t *rbp; +struct lnet_rtrbufpool *rbp;struct lnet_rtrbuf *rb;LASSERT (!msg->msg_iov);
@@ -834,7 +834,7 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg) }void -lnet_schedule_blocked_locked (lnet_rtrbufpool_t *rbp) +lnet_schedule_blocked_locked (struct lnet_rtrbufpool *rbp) {lnet_msg_t *msg;
@@ -879,7 +879,7 @@ lnet_return_rx_credits_locked(lnet_msg_t *msg)if (msg->msg_rtrcredit) {/* give back global router credits */ struct lnet_rtrbuf *rb; -lnet_rtrbufpool_t *rbp; +struct lnet_rtrbufpool *rbp;/* * NB If a msg ever blocks for a buffer in rbp_msgs, it stays
drivers/staging/lustre/lnet/lnet/router.c +9 -9
@@ -559,7 +559,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg)return rc;for (i =0 ; i <LNET_NRBPOOLS ; i++) { -lnet_rtrbufpool_t *rbp; +struct lnet_rtrbufpool *rbp;lnet_net_lock (LNET_LOCK_EX );cfs_percpt_for_each (rbp, j, the_lnet.ln_rtrpools) {
@@ -1317,7 +1317,7 @@ lnet_destroy_rtrbuf(struct lnet_rtrbuf *rb, int npages) }static struct lnet_rtrbuf * -lnet_new_rtrbuf (lnet_rtrbufpool_t *rbp,int cpt) +lnet_new_rtrbuf (struct lnet_rtrbufpool *rbp,int cpt) {int npages = rbp->rbp_npages; int sz = offsetof(struct lnet_rtrbuf, rb_kiov[npages]);
@@ -1352,7 +1352,7 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) }static void -lnet_rtrpool_free_bufs (lnet_rtrbufpool_t *rbp,int cpt) +lnet_rtrpool_free_bufs (struct lnet_rtrbufpool *rbp,int cpt) {int npages = rbp->rbp_npages;struct list_head tmp;
@@ -1381,7 +1381,7 @@ lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp, int cpt) }static int -lnet_rtrpool_adjust_bufs (lnet_rtrbufpool_t *rbp,int nbufs,int cpt) +lnet_rtrpool_adjust_bufs (struct lnet_rtrbufpool *rbp,int nbufs,int cpt) {struct list_head rb_list;struct lnet_rtrbuf *rb;
@@ -1468,7 +1468,7 @@ lnet_rtrpool_adjust_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) }static void -lnet_rtrpool_init (lnet_rtrbufpool_t *rbp,int npages) +lnet_rtrpool_init (struct lnet_rtrbufpool *rbp,int npages) {INIT_LIST_HEAD (&rbp->rbp_msgs);INIT_LIST_HEAD (&rbp->rbp_bufs);
@@ -1481,7 +1481,7 @@ lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages)void lnet_rtrpools_free (int keep_pools) { -lnet_rtrbufpool_t *rtrp; +struct lnet_rtrbufpool *rtrp;int i;if (!the_lnet.ln_rtrpools)/* uninitialized or freed */
@@ -1559,7 +1559,7 @@ lnet_nrb_large_calculate(void)int lnet_rtrpools_alloc (int im_a_router) { -lnet_rtrbufpool_t *rtrp; +struct lnet_rtrbufpool *rtrp;int nrb_tiny;int nrb_small;int nrb_large;
@@ -1594,7 +1594,7 @@ lnet_rtrpools_alloc(int im_a_router) the_lnet.ln_rtrpools =cfs_percpt_alloc (lnet_cpt_table (),LNET_NRBPOOLS * -sizeof (lnet_rtrbufpool_t)); +sizeof (struct lnet_rtrbufpool ));if (!the_lnet.ln_rtrpools) {LCONSOLE_ERROR_MSG (0x10c ,"Failed to initialize router buffe pool\n" );
@@ -1640,7 +1640,7 @@ lnet_rtrpools_adjust_helper(int tiny, int small, int large)int nrb =0 ;int rc =0 ;int i; -lnet_rtrbufpool_t *rtrp; +struct lnet_rtrbufpool *rtrp;/* * If the provided values for each buffer pool are different than the
drivers/staging/lustre/lnet/lnet/router_proc.c +1 -1
@@ -590,7 +590,7 @@ static int __proc_lnet_buffers(void *data, int write, goto out;/* I'm not a router */ for (idx =0 ; idx <LNET_NRBPOOLS ; idx++) { -lnet_rtrbufpool_t *rbp; +struct lnet_rtrbufpool *rbp;lnet_net_lock (LNET_LOCK_EX );cfs_percpt_for_each (rbp, i, the_lnet.ln_rtrpools) {
Signature · 1 line
2.7.4
Quoted 3 lines · Gargi Sharma
Remove struct typedefs and rename structs accordingly as per kernel coding conventions.
Please ignore this patchset since these changes were already done by someone else.
Thanks,
Gargi
Quoted 23 lines
---
Changes in v2:
- Split multiple typedef replacements into different patches.Gargi Sharma (6):
staging: lustre: Replace typedeflnet_rc_data_twith struct
staging: lustre: Replace typedeflnet_remotenet_twith struct
staging: lustre: Replace typedeflnet_route_twith struct
staging: lustre: Replace typedeflnet_rtrbuf_twith struct
staging: lustre: Replace typedeflnet_test_peer_twith struct
staging: lustre: Replace typedeflnet_rtrbufpool_twith struct.../staging/lustre/include/linux/lnet/lib-lnet.h | 8 +- .../staging/lustre/include/linux/lnet/lib-types.h | 32 +++---- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 48 +++++----- drivers/staging/lustre/lnet/lnet/router.c | 103 +++++++++++---------- drivers/staging/lustre/lnet/lnet/router_proc.c | 15 +-- 6 files changed, 106 insertions(+), 102 deletions(-)--
2.7.4