From lochoa at whamcloud.com Fri Feb 1 00:43:58 2019 From: lochoa at whamcloud.com (Leonel Ochoa) Date: Fri, 1 Feb 2019 00:43:58 +0000 Subject: [lustre-devel] Maloo Unscheduled Maintenance Message-ID: <6DF7A165-B104-4A84-92F3-85770D7D7D7A@ddn.com> UPDATE: At this point we’re all caught up with all sessions that were pending. If you notice a session missing between 1/19 and now, or a missing gerrit score please feel free to reach out and we can work on troubleshooting missing results/scores. At this point the only missing data is sub tests and test logs EARLIER than 1/19, this will populate slowly and I’ll announce once they’re all ingested. Lee Ochoa lochoa at whamcloud.com From: lustre-devel on behalf of Leonel Ochoa Date: Wednesday, January 30, 2019 at 21:49 To: "lustre-devel at lists.lustre.org" Subject: Re: [lustre-devel] Maloo Unscheduled Maintenance UPDATE: Maloo is back up…but not fully restored yet. For the time being you’ll notice the following things: 1. Test queue pages DO show accurate state of ongoing tests in Autotest 2. The main test session page is missing results from 1/19 – 1/30, these results will start getting ingested from oldest to newest, please be patient and all results will eventually show up 3. For test sessions EARLIER than 1/19, sub test and test log pages are missing and will slowly populate, also from oldest to newest, also please be patient I’ll be sending periodic updates as we fill in the missing data Lee Ochoa lochoa at whamcloud.com From: Leonel Ochoa Date: Tuesday, January 29, 2019 at 14:12 To: "lustre-devel at lists.lustre.org" Subject: Maloo Unscheduled Maintenance NOTICE TO ALL MALOO USERS The Maloo web server has been down since yesterday 1/28 due to unscheduled maintenance, at present we expect the downtime to last all of today 1/29 and possibly tomorrow 1/30 as well. Once service has been restored we’ll post a notification to this mailing list. Gerrit can still receive patches and Autotest will continue to run test sessions while Maloo remains offline, once the server is back up all pending results and gerrit +/- notifications (from Maloo) will be sent for all completed tests. Thank you for your patience. Lee Ochoa lochoa at whamcloud.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From degremoa at amazon.com Fri Feb 1 10:32:01 2019 From: degremoa at amazon.com (Degremont, Aurelien) Date: Fri, 1 Feb 2019 10:32:01 +0000 Subject: [lustre-devel] LibCFS and LNET module versions In-Reply-To: References: <41616FC6-B2B4-4B72-B7D6-69D1B5713653@amazon.com> Message-ID: <645F25BD-4088-437F-901A-DCA11D38A596@amazon.com> Le 31/01/2019 18:47, « James Simmons » a écrit : > All Lustre modules uses the Lustre version as their module version except for lnet and libcfs modules. Is there a specific > reason to that? The idea here is that lnet/libcfs is really an independent layer from lustre. In theory other sub systems could use it. Its true we don't really have a numbering system. Suggestions? This is what I thought, but that really means we should bump the version from time to time. If this is a separate "product" it should have its own release, and so be bumped every time there is changes/new features. Let's say, at short term, LIBCFS_VERSION = LUSTRE_VERSION. When LNET will starting being used as a separate software, starting updating this value independently. Ok with that? I can open a ticket if you think that's good. Aurélien From degremoa at amazon.com Fri Feb 1 15:46:11 2019 From: degremoa at amazon.com (Degremont, Aurelien) Date: Fri, 1 Feb 2019 15:46:11 +0000 Subject: [lustre-devel] Run acceptance tests on client side only In-Reply-To: References: <9E0B8A72-3AFF-4141-8E94-28AF402B0CC9@amazon.com> Message-ID: <8D2B81B6-81CC-47AE-853B-931906283753@amazon.com> Hi Patrick, I’m working with a non-production FS, so I do not care about destructive actions, but you’re right, the acceptance test system is not really designed to be used really differently. Even if you have access to the servers, it requires a lot of tunings to have this working properly. I wanted to know if I missed something and there was an easy solution, but I will try do this differently. Thanks Aurélien De : Patrick Farrell Date : mercredi 30 janvier 2019 à 20:02 À : "Degremont, Aurelien" , "lustre-devel at lists.lustre.org" Objet : Re: Run acceptance tests on client side only Aurelien, We played with this idea some when I was at Cray, and I believe we decided it wasn't worth it. Many, many tests - maybe a majority - depend on running commands on the server. Many are intentionally destructive in various ways, and since we don't test them with other data on the file system, some of them are probably *accidentally* destructive as well. My conclusion then was that the test framework tests (acceptance small included) are not designed to be run A) without server access, or B ) on any kind of production file system. It would be possible to create a curated client only & non-destructive list, but it would be a lot of work, and it would miss large areas of the test framework. (Many tests which are primarily client require some manipulation of the server (settings, cache dropping, fail loc...) to work.) - Patrick ________________________________ From: lustre-devel on behalf of Degremont, Aurelien Sent: Wednesday, January 30, 2019 8:53:12 AM To: lustre-devel at lists.lustre.org Subject: [lustre-devel] Run acceptance tests on client side only Hello I’m trying to run test suites without having access to servers. A lot of tests in acc-sm assume that servers are reachable. Is there way to automatically skip these tests? Does somebody has a smart way to run acc-sm? Thanks Aurélien -------------- next part -------------- An HTML attachment was scrubbed... URL: From neilb at suse.com Mon Feb 4 03:13:10 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 04 Feb 2019 14:13:10 +1100 Subject: [lustre-devel] [PATCH 24/26] lnet: cleanup white spaces In-Reply-To: <1548955170-13456-25-git-send-email-jsimmons@infradead.org> References: <1548955170-13456-1-git-send-email-jsimmons@infradead.org> <1548955170-13456-25-git-send-email-jsimmons@infradead.org> Message-ID: <87a7jcjlfd.fsf@notabene.neil.brown.name> On Thu, Jan 31 2019, James Simmons wrote: > The LNet core code is very messy and difficult to read. Remove > excess white space and properly align data structures so they > are easy on the eyes. > > Signed-off-by: James Simmons > --- > @@ -218,7 +218,7 @@ struct lnet_lnd { > */ > > /* > - * Start sending a preformatted message. 'private' is NULL for PUT and > + * Start sending a preformatted message.x 'private' is NULL for PUT and > * GET messages; otherwise this is a response to an incoming message > * and 'private' is the 'private' passed to lnet_parse(). Return > * non-zero for immediate failure, otherwise complete later with I suspect you just added that 'x' to see if anyone really read you patch I did. I found it. I've removed it. :-) NeilBrown > @@ -267,7 +267,7 @@ struct lnet_tx_queue { > > enum lnet_ni_state { > /* set when NI block is allocated */ > - LNET_NI_STATE_INIT = 0, > + LNET_NI_STATE_INIT = 0, > /* set when NI is started successfully */ > LNET_NI_STATE_ACTIVE, > /* set when LND notifies NI failed */ > @@ -279,23 +279,23 @@ enum lnet_ni_state { > }; > > enum lnet_stats_type { > - LNET_STATS_TYPE_SEND = 0, > + LNET_STATS_TYPE_SEND = 0, > LNET_STATS_TYPE_RECV, > LNET_STATS_TYPE_DROP > }; > > struct lnet_comm_count { > - atomic_t co_get_count; > - atomic_t co_put_count; > - atomic_t co_reply_count; > - atomic_t co_ack_count; > - atomic_t co_hello_count; > + atomic_t co_get_count; > + atomic_t co_put_count; > + atomic_t co_reply_count; > + atomic_t co_ack_count; > + atomic_t co_hello_count; > }; > > struct lnet_element_stats { > - struct lnet_comm_count el_send_stats; > - struct lnet_comm_count el_recv_stats; > - struct lnet_comm_count el_drop_stats; > + struct lnet_comm_count el_send_stats; > + struct lnet_comm_count el_recv_stats; > + struct lnet_comm_count el_drop_stats; > }; > > struct lnet_net { > @@ -376,7 +376,7 @@ struct lnet_ni { > struct lnet_lnd_tunables ni_lnd_tunables; > > /* lnd tunables set explicitly */ > - bool ni_lnd_tunables_set; > + bool ni_lnd_tunables_set; > > /* NI statistics */ > struct lnet_element_stats ni_stats; > @@ -391,9 +391,9 @@ struct lnet_ni { > * equivalent interfaces to use > * This is an array because socklnd bonding can still be configured > */ > - char *ni_interfaces[LNET_INTERFACES_NUM]; > + char *ni_interfaces[LNET_INTERFACES_NUM]; > /* original net namespace */ > - struct net *ni_net_ns; > + struct net *ni_net_ns; > }; > > #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL > @@ -434,9 +434,9 @@ struct lnet_rc_data { > > struct lnet_peer_ni { > /* chain on lpn_peer_nis */ > - struct list_head lpni_peer_nis; > + struct list_head lpni_peer_nis; > /* chain on remote peer list */ > - struct list_head lpni_on_remote_peer_ni_list; > + struct list_head lpni_on_remote_peer_ni_list; > /* chain on peer hash */ > struct list_head lpni_hashlist; > /* messages blocking for tx credits */ > @@ -448,7 +448,7 @@ struct lnet_peer_ni { > /* statistics kept on each peer NI */ > struct lnet_element_stats lpni_stats; > /* spin lock protecting credits and lpni_txq / lpni_rtrq */ > - spinlock_t lpni_lock; > + spinlock_t lpni_lock; > /* # tx credits available */ > int lpni_txcredits; > struct lnet_peer_net *lpni_peer_net; > @@ -491,26 +491,26 @@ struct lnet_peer_ni { > /* CPT this peer attached on */ > int lpni_cpt; > /* state flags -- protected by lpni_lock */ > - unsigned int lpni_state; > + unsigned int lpni_state; > /* # refs from lnet_route::lr_gateway */ > int lpni_rtr_refcount; > /* sequence number used to round robin over peer nis within a net */ > - u32 lpni_seq; > + u32 lpni_seq; > /* sequence number used to round robin over gateways */ > - u32 lpni_gw_seq; > + u32 lpni_gw_seq; > /* health flag */ > - bool lpni_healthy; > + bool lpni_healthy; > /* returned RC ping features. Protected with lpni_lock */ > unsigned int lpni_ping_feats; > /* routers on this peer */ > struct list_head lpni_routes; > /* preferred local nids: if only one, use lpni_pref.nid */ > union lpni_pref { > - lnet_nid_t nid; > + lnet_nid_t nid; > lnet_nid_t *nids; > } lpni_pref; > /* number of preferred NIDs in lnpi_pref_nids */ > - u32 lpni_pref_nnids; > + u32 lpni_pref_nnids; > /* router checker state */ > struct lnet_rc_data *lpni_rcd; > }; > @@ -676,9 +676,9 @@ struct lnet_peer_table { > /* # peers extant */ > atomic_t pt_number; > /* peers */ > - struct list_head pt_peer_list; > + struct list_head pt_peer_list; > /* # peers */ > - int pt_peers; > + int pt_peers; > /* # zombies to go to deathrow (and not there yet) */ > int pt_zombies; > /* zombie peers_ni */ > @@ -704,7 +704,7 @@ struct lnet_route { > /* chain on gateway */ > struct list_head lr_gwlist; > /* router node */ > - struct lnet_peer_ni *lr_gateway; > + struct lnet_peer_ni *lr_gateway; > /* remote network number */ > u32 lr_net; > /* sequence for round-robin */ > @@ -754,9 +754,9 @@ struct lnet_rtrbufpool { > }; > > struct lnet_rtrbuf { > - struct list_head rb_list; /* chain on rbp_bufs */ > - struct lnet_rtrbufpool *rb_pool; /* owning pool */ > - struct bio_vec rb_kiov[0]; /* the buffer space */ > + struct list_head rb_list; /* chain on rbp_bufs */ > + struct lnet_rtrbufpool *rb_pool; /* owning pool */ > + struct bio_vec rb_kiov[0]; /* the buffer space */ > }; > > #define LNET_PEER_HASHSIZE 503 /* prime! */ > @@ -904,58 +904,58 @@ enum lnet_state { > > struct lnet { > /* CPU partition table of LNet */ > - struct cfs_cpt_table *ln_cpt_table; > + struct cfs_cpt_table *ln_cpt_table; > /* number of CPTs in ln_cpt_table */ > - unsigned int ln_cpt_number; > - unsigned int ln_cpt_bits; > + unsigned int ln_cpt_number; > + unsigned int ln_cpt_bits; > > /* protect LNet resources (ME/MD/EQ) */ > - struct cfs_percpt_lock *ln_res_lock; > + struct cfs_percpt_lock *ln_res_lock; > /* # portals */ > - int ln_nportals; > + int ln_nportals; > /* the vector of portals */ > - struct lnet_portal **ln_portals; > + struct lnet_portal **ln_portals; > /* percpt ME containers */ > - struct lnet_res_container **ln_me_containers; > + struct lnet_res_container **ln_me_containers; > /* percpt MD container */ > - struct lnet_res_container **ln_md_containers; > + struct lnet_res_container **ln_md_containers; > > /* Event Queue container */ > - struct lnet_res_container ln_eq_container; > - wait_queue_head_t ln_eq_waitq; > - spinlock_t ln_eq_wait_lock; > - unsigned int ln_remote_nets_hbits; > + struct lnet_res_container ln_eq_container; > + wait_queue_head_t ln_eq_waitq; > + spinlock_t ln_eq_wait_lock; > + unsigned int ln_remote_nets_hbits; > > /* protect NI, peer table, credits, routers, rtrbuf... */ > - struct cfs_percpt_lock *ln_net_lock; > + struct cfs_percpt_lock *ln_net_lock; > /* percpt message containers for active/finalizing/freed message */ > - struct lnet_msg_container **ln_msg_containers; > - struct lnet_counters **ln_counters; > - struct lnet_peer_table **ln_peer_tables; > + struct lnet_msg_container **ln_msg_containers; > + struct lnet_counters **ln_counters; > + struct lnet_peer_table **ln_peer_tables; > /* list of peer nis not on a local network */ > struct list_head ln_remote_peer_ni_list; > /* failure simulation */ > - struct list_head ln_test_peers; > - struct list_head ln_drop_rules; > - struct list_head ln_delay_rules; > + struct list_head ln_test_peers; > + struct list_head ln_drop_rules; > + struct list_head ln_delay_rules; > > /* LND instances */ > struct list_head ln_nets; > /* network zombie list */ > struct list_head ln_net_zombie; > /* the loopback NI */ > - struct lnet_ni *ln_loni; > + struct lnet_ni *ln_loni; > > /* remote networks with routes to them */ > - struct list_head *ln_remote_nets_hash; > + struct list_head *ln_remote_nets_hash; > /* validity stamp */ > - u64 ln_remote_nets_version; > + u64 ln_remote_nets_version; > /* list of all known routers */ > - struct list_head ln_routers; > + struct list_head ln_routers; > /* validity stamp */ > - u64 ln_routers_version; > + u64 ln_routers_version; > /* percpt router buffer pools */ > - struct lnet_rtrbufpool **ln_rtrpools; > + struct lnet_rtrbufpool **ln_rtrpools; > > /* > * Ping target / Push source > @@ -964,9 +964,9 @@ struct lnet { > * ln_ping_target is protected against concurrent updates by > * ln_api_mutex. > */ > - struct lnet_handle_md ln_ping_target_md; > - struct lnet_handle_eq ln_ping_target_eq; > - struct lnet_ping_buffer *ln_ping_target; > + struct lnet_handle_md ln_ping_target_md; > + struct lnet_handle_eq ln_ping_target_eq; > + struct lnet_ping_buffer *ln_ping_target; > atomic_t ln_ping_target_seqno; > > /* > @@ -979,7 +979,7 @@ struct lnet { > */ > struct lnet_handle_eq ln_push_target_eq; > struct lnet_handle_md ln_push_target_md; > - struct lnet_ping_buffer *ln_push_target; > + struct lnet_ping_buffer *ln_push_target; > int ln_push_target_nnis; > > /* discovery event queue handle */ > @@ -996,35 +996,35 @@ struct lnet { > int ln_dc_state; > > /* router checker startup/shutdown state */ > - enum lnet_rc_state ln_rc_state; > + enum lnet_rc_state ln_rc_state; > /* router checker's event queue */ > - struct lnet_handle_eq ln_rc_eqh; > + struct lnet_handle_eq ln_rc_eqh; > /* rcd still pending on net */ > - struct list_head ln_rcd_deathrow; > + struct list_head ln_rcd_deathrow; > /* rcd ready for free */ > - struct list_head ln_rcd_zombie; > + struct list_head ln_rcd_zombie; > /* serialise startup/shutdown */ > - struct completion ln_rc_signal; > + struct completion ln_rc_signal; > > - struct mutex ln_api_mutex; > - struct mutex ln_lnd_mutex; > - struct mutex ln_delay_mutex; > + struct mutex ln_api_mutex; > + struct mutex ln_lnd_mutex; > + struct mutex ln_delay_mutex; > /* Have I called LNetNIInit myself? */ > - int ln_niinit_self; > + int ln_niinit_self; > /* LNetNIInit/LNetNIFini counter */ > - int ln_refcount; > + int ln_refcount; > /* SHUTDOWN/RUNNING/STOPPING */ > - enum lnet_state ln_state; > + enum lnet_state ln_state; > > - int ln_routing; /* am I a router? */ > - lnet_pid_t ln_pid; /* requested pid */ > + int ln_routing; /* am I a router? */ > + lnet_pid_t ln_pid; /* requested pid */ > /* uniquely identifies this ni in this epoch */ > - u64 ln_interface_cookie; > + u64 ln_interface_cookie; > /* registered LNDs */ > - struct list_head ln_lnds; > + struct list_head ln_lnds; > > /* test protocol compatibility flags */ > - int ln_testprotocompat; > + int ln_testprotocompat; > > /* > * 0 - load the NIs from the mod params > @@ -1032,14 +1032,14 @@ struct lnet { > * Reverse logic to ensure that other calls to LNetNIInit > * need no change > */ > - bool ln_nis_from_mod_params; > + bool ln_nis_from_mod_params; > > /* > * waitq for router checker. As long as there are no routes in > * the list, the router checker will sleep on this queue. when > * routes are added the thread will wake up > */ > - wait_queue_head_t ln_rc_waitq; > + wait_queue_head_t ln_rc_waitq; > > }; > > diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c > index aa28a9f..83ab3b1 100644 > --- a/drivers/staging/lustre/lnet/lnet/acceptor.c > +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c > @@ -36,9 +36,9 @@ > #include > #include > > -static int accept_port = 988; > -static int accept_backlog = 127; > -static int accept_timeout = 5; > +static int accept_port = 988; > +static int accept_backlog = 127; > +static int accept_timeout = 5; > > static struct { > int pta_shutdown; > @@ -167,9 +167,9 @@ > > BUILD_BUG_ON(LNET_PROTO_ACCEPTOR_VERSION != 1); > > - cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; > + cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; > cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; > - cr.acr_nid = peer_nid; > + cr.acr_nid = peer_nid; > > if (the_lnet.ln_testprotocompat) { > /* single-shot proto check */ > @@ -196,9 +196,9 @@ > rc = -EADDRINUSE; > goto failed; > > - failed_sock: > +failed_sock: > sock_release(sock); > - failed: > +failed: > lnet_connect_console_error(rc, peer_nid, peer_ip, peer_port); > return rc; > } > @@ -297,7 +297,7 @@ > __swab64s(&cr.acr_nid); > > ni = lnet_nid2ni_addref(cr.acr_nid); > - if (!ni || /* no matching net */ > + if (!ni || /* no matching net */ > ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */ > if (ni) > lnet_ni_decref(ni); > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index be77e10..64b8bef9 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -47,7 +47,7 @@ > * before module init completes. The mutex needs to be ready for use then. > */ > struct lnet the_lnet = { > - .ln_api_mutex = __MUTEX_INITIALIZER(the_lnet.ln_api_mutex), > + .ln_api_mutex = __MUTEX_INITIALIZER(the_lnet.ln_api_mutex), > }; /* THE state of the network */ > EXPORT_SYMBOL(the_lnet); > > @@ -281,7 +281,7 @@ static int lnet_discover(struct lnet_process_id id, u32 force, > > return 0; > > - failed: > +failed: > lnet_destroy_locks(); > return -ENOMEM; > } > @@ -476,17 +476,17 @@ static void lnet_assert_wire_constants(void) > lnet_net_lock(LNET_LOCK_EX); > > cfs_percpt_for_each(ctr, i, the_lnet.ln_counters) { > - counters->msgs_max += ctr->msgs_max; > - counters->msgs_alloc += ctr->msgs_alloc; > - counters->errors += ctr->errors; > - counters->send_count += ctr->send_count; > - counters->recv_count += ctr->recv_count; > - counters->route_count += ctr->route_count; > - counters->drop_count += ctr->drop_count; > - counters->send_length += ctr->send_length; > - counters->recv_length += ctr->recv_length; > + counters->msgs_max += ctr->msgs_max; > + counters->msgs_alloc += ctr->msgs_alloc; > + counters->errors += ctr->errors; > + counters->send_count += ctr->send_count; > + counters->recv_count += ctr->recv_count; > + counters->route_count += ctr->route_count; > + counters->drop_count += ctr->drop_count; > + counters->send_length += ctr->send_length; > + counters->recv_length += ctr->recv_length; > counters->route_length += ctr->route_length; > - counters->drop_length += ctr->drop_length; > + counters->drop_length += ctr->drop_length; > } > lnet_net_unlock(LNET_LOCK_EX); > } > @@ -755,7 +755,7 @@ struct lnet_libhandle * > > return 0; > > - failed: > +failed: > lnet_unprepare(); > return rc; > } > @@ -942,7 +942,7 @@ struct lnet_net * > return false; > } > > -struct lnet_ni * > +struct lnet_ni * > lnet_nid2ni_locked(lnet_nid_t nid, int cpt) > { > struct lnet_net *net; > @@ -1146,8 +1146,10 @@ struct lnet_ping_buffer * > struct lnet_handle_md *ping_mdh, > int ni_count, bool set_eq) > { > - struct lnet_process_id id = { .nid = LNET_NID_ANY, > - .pid = LNET_PID_ANY }; > + struct lnet_process_id id = { > + .nid = LNET_NID_ANY, > + .pid = LNET_PID_ANY > + }; > struct lnet_handle_me me_handle; > struct lnet_md md = { NULL }; > int rc, rc2; > @@ -1244,7 +1246,7 @@ struct lnet_ping_buffer * > > lnet_ni_lock(ni); > ns->ns_status = ni->ni_status ? > - ni->ni_status->ns_status : > + ni->ni_status->ns_status : > LNET_NI_STATUS_UP; > ni->ni_status = ns; > lnet_ni_unlock(ni); > @@ -1322,7 +1324,10 @@ struct lnet_ping_buffer * > /* Resize the push target. */ > int lnet_push_target_resize(void) > { > - struct lnet_process_id id = { LNET_NID_ANY, LNET_PID_ANY }; > + struct lnet_process_id id = { > + .nid = LNET_NID_ANY, > + .pid = LNET_PID_ANY > + }; > struct lnet_md md = { NULL }; > struct lnet_handle_me meh; > struct lnet_handle_md mdh; > @@ -1353,13 +1358,13 @@ int lnet_push_target_resize(void) > } > > /* initialize md content */ > - md.start = &pbuf->pb_info; > - md.length = LNET_PING_INFO_SIZE(nnis); > + md.start = &pbuf->pb_info; > + md.length = LNET_PING_INFO_SIZE(nnis); > md.threshold = LNET_MD_THRESH_INF; > - md.max_size = 0; > - md.options = LNET_MD_OP_PUT | LNET_MD_TRUNCATE | > - LNET_MD_MANAGE_REMOTE; > - md.user_ptr = pbuf; > + md.max_size = 0; > + md.options = LNET_MD_OP_PUT | LNET_MD_TRUNCATE | > + LNET_MD_MANAGE_REMOTE; > + md.user_ptr = pbuf; > md.eq_handle = the_lnet.ln_push_target_eq; > > rc = LNetMDAttach(meh, md, LNET_RETAIN, &mdh); > @@ -1428,7 +1433,6 @@ static int lnet_push_target_init(void) > the_lnet.ln_push_target_nnis = LNET_INTERFACES_MIN; > > rc = lnet_push_target_resize(); > - > if (rc) { > LNetEQFree(the_lnet.ln_push_target_eq); > LNetInvalidateEQHandle(&the_lnet.ln_push_target_eq); > @@ -1723,10 +1727,10 @@ static void lnet_push_target_fini(void) > > CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n", > libcfs_nid2str(ni->ni_nid), > - ni->ni_net->net_tunables.lct_peer_tx_credits, > + ni->ni_net->net_tunables.lct_peer_tx_credits, > lnet_ni_tq_credits(ni) * LNET_CPT_NUMBER, > ni->ni_net->net_tunables.lct_peer_rtr_credits, > - ni->ni_net->net_tunables.lct_peer_timeout); > + ni->ni_net->net_tunables.lct_peer_timeout); > > return 0; > failed0: > @@ -1932,7 +1936,6 @@ static void lnet_push_target_fini(void) > list_del_init(&net->net_list); > > rc = lnet_startup_lndnet(net, NULL); > - > if (rc < 0) > goto failed; > > @@ -1963,8 +1966,8 @@ int lnet_lib_init(void) > lnet_assert_wire_constants(); > > /* refer to global cfs_cpt_tab for now */ > - the_lnet.ln_cpt_table = cfs_cpt_tab; > - the_lnet.ln_cpt_number = cfs_cpt_number(cfs_cpt_tab); > + the_lnet.ln_cpt_table = cfs_cpt_tab; > + the_lnet.ln_cpt_number = cfs_cpt_number(cfs_cpt_tab); > > LASSERT(the_lnet.ln_cpt_number > 0); > if (the_lnet.ln_cpt_number > LNET_CPT_MAX) { > @@ -2409,7 +2412,7 @@ struct lnet_ni * > if (!prev) { > if (!net) > net = list_entry(the_lnet.ln_nets.next, struct lnet_net, > - net_list); > + net_list); > ni = list_entry(net->net_ni_list.next, struct lnet_ni, > ni_netlist); > > @@ -2455,7 +2458,6 @@ struct lnet_ni * > cpt = lnet_net_lock_current(); > > ni = lnet_get_ni_idx_locked(idx); > - > if (ni) { > rc = 0; > lnet_ni_lock(ni); > @@ -2483,7 +2485,6 @@ struct lnet_ni * > cpt = lnet_net_lock_current(); > > ni = lnet_get_ni_idx_locked(cfg_ni->lic_idx); > - > if (ni) { > rc = 0; > lnet_ni_lock(ni); > @@ -2705,7 +2706,7 @@ int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf) > struct lnet_ni *ni; > u32 net_id = LNET_NIDNET(conf->lic_nid); > struct lnet_ping_buffer *pbuf; > - struct lnet_handle_md ping_mdh; > + struct lnet_handle_md ping_mdh; > int rc; > int net_count; > u32 addr; > @@ -2912,7 +2913,7 @@ u32 lnet_get_dlc_seq_locked(void) > { > struct libcfs_ioctl_data *data = arg; > struct lnet_ioctl_config_data *config; > - struct lnet_process_id id = {0}; > + struct lnet_process_id id = { 0 }; > struct lnet_ni *ni; > int rc; > > @@ -3357,7 +3358,7 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout, > int which; > int unlinked = 0; > int replied = 0; > - const signed long a_long_time = 60*HZ; > + const signed long a_long_time = 60 * HZ; > struct lnet_ping_buffer *pbuf; > struct lnet_process_id tmpid; > int i; > @@ -3384,12 +3385,12 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout, > } > > /* initialize md content */ > - md.start = &pbuf->pb_info; > - md.length = LNET_PING_INFO_SIZE(n_ids); > + md.start = &pbuf->pb_info; > + md.length = LNET_PING_INFO_SIZE(n_ids); > md.threshold = 2; /* GET/REPLY */ > - md.max_size = 0; > - md.options = LNET_MD_TRUNCATE; > - md.user_ptr = NULL; > + md.max_size = 0; > + md.options = LNET_MD_TRUNCATE; > + md.user_ptr = NULL; > md.eq_handle = eqh; > > rc = LNetMDBind(md, LNET_UNLINK, &mdh); > @@ -3401,7 +3402,6 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout, > rc = LNetGet(LNET_NID_ANY, mdh, id, > LNET_RESERVED_PORTAL, > LNET_PROTO_PING_MATCHBITS, 0); > - > if (rc) { > /* Don't CERROR; this could be deliberate! */ > rc2 = LNetMDUnlink(mdh); > @@ -3414,7 +3414,6 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout, > > do { > /* MUST block for unlink to complete */ > - > rc2 = LNetEQPoll(&eqh, 1, timeout, !unlinked, > &event, &which); > > @@ -3510,13 +3509,13 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout, > } > rc = pbuf->pb_info.pi_nnis; > > - fail_free_eq: > +fail_free_eq: > rc2 = LNetEQFree(eqh); > if (rc2) > CERROR("rc2 %d\n", rc2); > LASSERT(!rc2); > > - fail_ping_buffer_decref: > +fail_ping_buffer_decref: > lnet_ping_buffer_decref(pbuf); > return rc; > } > diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c > index 16c42bf..ecf656b 100644 > --- a/drivers/staging/lustre/lnet/lnet/config.c > +++ b/drivers/staging/lustre/lnet/lnet/config.c > @@ -38,15 +38,15 @@ > #include > #include > > -struct lnet_text_buf { /* tmp struct for parsing routes */ > - struct list_head ltb_list; /* stash on lists */ > - int ltb_size; /* allocated size */ > - char ltb_text[0]; /* text buffer */ > +struct lnet_text_buf { /* tmp struct for parsing routes */ > + struct list_head ltb_list; /* stash on lists */ > + int ltb_size; /* allocated size */ > + char ltb_text[0]; /* text buffer */ > }; > > -static int lnet_tbnob; /* track text buf allocation */ > -#define LNET_MAX_TEXTBUF_NOB (64 << 10) /* bound allocation */ > -#define LNET_SINGLE_TEXTBUF_NOB (4 << 10) > +static int lnet_tbnob; /* track text buf allocation */ > +#define LNET_MAX_TEXTBUF_NOB (64 << 10) /* bound allocation */ > +#define LNET_SINGLE_TEXTBUF_NOB (4 << 10) > > #define SPACESTR " \t\v\r\n" > #define DELIMITERS ":()[]" > @@ -126,6 +126,7 @@ struct lnet_text_buf { /* tmp struct for parsing routes */ > lnet_ni_unique_ni(char *iface_list[LNET_INTERFACES_NUM], char *iface) > { > int i; > + > for (i = 0; i < LNET_INTERFACES_NUM; i++) { > if (iface_list[i] && > strncmp(iface_list[i], iface, strlen(iface)) == 0) > @@ -554,7 +555,7 @@ struct lnet_ni * > goto failed; > > return ni; > - failed: > +failed: > lnet_ni_free(ni); > return NULL; > } > @@ -743,9 +744,9 @@ struct lnet_ni * > goto failed_syntax; > } > rc = cfs_expr_list_parse(elstr, > - nistr - elstr + 1, > - 0, LNET_CPT_NUMBER - 1, > - &ni_el); > + nistr - elstr + 1, > + 0, LNET_CPT_NUMBER - 1, > + &ni_el); > if (rc != 0) { > str = elstr; > goto failed_syntax; > @@ -812,9 +813,9 @@ struct lnet_ni * > kfree(tokens); > return nnets; > > - failed_syntax: > +failed_syntax: > lnet_syntax("networks", networks, (int)(str - tokens), strlen(str)); > - failed: > +failed: > /* free the net list and all the nis on each net */ > while (!list_empty(netlist)) { > net = list_entry(netlist->next, struct lnet_net, net_list); > @@ -1038,7 +1039,7 @@ struct lnet_ni * > list_splice(&pending, tbs->prev); > return 1; > > - failed: > +failed: > lnet_free_text_bufs(&pending); > return -EINVAL; > } > @@ -1093,7 +1094,6 @@ struct lnet_ni * > { > /* static scratch buffer OK (single threaded) */ > static char cmd[LNET_SINGLE_TEXTBUF_NOB]; > - > struct list_head nets; > struct list_head gateways; > struct list_head *tmp1; > @@ -1226,9 +1226,9 @@ struct lnet_ni * > myrc = 0; > goto out; > > - token_error: > +token_error: > lnet_syntax("routes", cmd, (int)(token - str), strlen(token)); > - out: > +out: > lnet_free_text_bufs(&nets); > lnet_free_text_bufs(&gateways); > return myrc; > @@ -1298,7 +1298,6 @@ struct lnet_ni * > lnet_match_network_tokens(char *net_entry, u32 *ipaddrs, int nip) > { > static char tokens[LNET_SINGLE_TEXTBUF_NOB]; > - > int matched = 0; > int ntokens = 0; > int len; > @@ -1451,7 +1450,6 @@ struct lnet_ni * > { > static char networks[LNET_SINGLE_TEXTBUF_NOB]; > static char source[LNET_SINGLE_TEXTBUF_NOB]; > - > struct list_head raw_entries; > struct list_head matched_nets; > struct list_head current_nets; > @@ -1549,7 +1547,7 @@ struct lnet_ni * > count++; > } > > - out: > +out: > lnet_free_text_bufs(&raw_entries); > lnet_free_text_bufs(&matched_nets); > lnet_free_text_bufs(¤t_nets); > diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c > index f085388..f500b49 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c > @@ -198,7 +198,7 @@ > lnet_res_lh_invalidate(&eq->eq_lh); > list_del(&eq->eq_list); > kfree(eq); > - out: > +out: > lnet_eq_wait_unlock(); > lnet_res_unlock(LNET_LOCK_EX); > > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index 639f67ed..92c6a34 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -489,7 +489,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > > if (mlen) { > niov = msg->msg_niov; > - iov = msg->msg_iov; > + iov = msg->msg_iov; > kiov = msg->msg_kiov; > > LASSERT(niov > 0); > @@ -541,12 +541,12 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > lnet_setpayloadbuffer(msg); > > memset(&msg->msg_hdr, 0, sizeof(msg->msg_hdr)); > - msg->msg_hdr.type = cpu_to_le32(type); > + msg->msg_hdr.type = cpu_to_le32(type); > /* dest_nid will be overwritten by lnet_select_pathway() */ > - msg->msg_hdr.dest_nid = cpu_to_le64(target.nid); > - msg->msg_hdr.dest_pid = cpu_to_le32(target.pid); > + msg->msg_hdr.dest_nid = cpu_to_le64(target.nid); > + msg->msg_hdr.dest_pid = cpu_to_le32(target.pid); > /* src_nid will be set later */ > - msg->msg_hdr.src_pid = cpu_to_le32(the_lnet.ln_pid); > + msg->msg_hdr.src_pid = cpu_to_le32(the_lnet.ln_pid); > msg->msg_hdr.payload_length = cpu_to_le32(len); > } > > @@ -635,7 +635,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > } > > deadline = lp->lpni_last_alive + > - lp->lpni_net->net_tunables.lct_peer_timeout; > + lp->lpni_net->net_tunables.lct_peer_timeout; > alive = deadline > now; > > /* Update obsolete lpni_alive except for routers assumed to be dead > @@ -911,7 +911,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > { > struct lnet_peer_ni *txpeer = msg->msg_txpeer; > struct lnet_msg *msg2; > - struct lnet_ni *txni = msg->msg_txni; > + struct lnet_ni *txni = msg->msg_txni; > > if (msg->msg_txcredit) { > struct lnet_ni *ni = msg->msg_txni; > @@ -1044,7 +1044,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > lnet_return_rx_credits_locked(struct lnet_msg *msg) > { > struct lnet_peer_ni *rxpeer = msg->msg_rxpeer; > - struct lnet_ni *rxni = msg->msg_rxni; > + struct lnet_ni *rxni = msg->msg_rxni; > struct lnet_msg *msg2; > > if (msg->msg_rtrcredit) { > @@ -1796,7 +1796,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > /* if we still can't find a peer ni then we can't reach it */ > if (!best_lpni) { > u32 net_id = peer_net ? peer_net->lpn_net_id : > - LNET_NIDNET(dst_nid); > + LNET_NIDNET(dst_nid); > > lnet_net_unlock(cpt); > LCONSOLE_WARN("no peer_ni found on peer net %s\n", > @@ -1912,7 +1912,6 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > } > > rc = lnet_post_send_locked(msg, 0); > - > if (!rc) > CDEBUG(D_NET, "TRACE: %s(%s:%s) -> %s(%s:%s) : %s\n", > libcfs_nid2str(msg->msg_hdr.src_nid), > @@ -1931,8 +1930,8 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > int > lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid) > { > - lnet_nid_t dst_nid = msg->msg_target.nid; > - int rc; > + lnet_nid_t dst_nid = msg->msg_target.nid; > + int rc; > > /* > * NB: rtr_nid is set to LNET_NID_ANY for all current use-cases, > @@ -2008,19 +2007,19 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > le32_to_cpus(&hdr->msg.put.offset); > > /* Primary peer NID. */ > - info.mi_id.nid = msg->msg_initiator; > - info.mi_id.pid = hdr->src_pid; > - info.mi_opc = LNET_MD_OP_PUT; > - info.mi_portal = hdr->msg.put.ptl_index; > + info.mi_id.nid = msg->msg_initiator; > + info.mi_id.pid = hdr->src_pid; > + info.mi_opc = LNET_MD_OP_PUT; > + info.mi_portal = hdr->msg.put.ptl_index; > info.mi_rlength = hdr->payload_length; > info.mi_roffset = hdr->msg.put.offset; > - info.mi_mbits = hdr->msg.put.match_bits; > - info.mi_cpt = lnet_cpt_of_nid(msg->msg_rxpeer->lpni_nid, ni); > + info.mi_mbits = hdr->msg.put.match_bits; > + info.mi_cpt = lnet_cpt_of_nid(msg->msg_rxpeer->lpni_nid, ni); > > msg->msg_rx_ready_delay = !ni->ni_net->net_lnd->lnd_eager_recv; > ready_delay = msg->msg_rx_ready_delay; > > - again: > +again: > rc = lnet_ptl_match_md(&info, msg); > switch (rc) { > default: > @@ -2069,17 +2068,17 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > le32_to_cpus(&hdr->msg.get.sink_length); > le32_to_cpus(&hdr->msg.get.src_offset); > > - source_id.nid = hdr->src_nid; > - source_id.pid = hdr->src_pid; > + source_id.nid = hdr->src_nid; > + source_id.pid = hdr->src_pid; > /* Primary peer NID */ > - info.mi_id.nid = msg->msg_initiator; > - info.mi_id.pid = hdr->src_pid; > - info.mi_opc = LNET_MD_OP_GET; > - info.mi_portal = hdr->msg.get.ptl_index; > + info.mi_id.nid = msg->msg_initiator; > + info.mi_id.pid = hdr->src_pid; > + info.mi_opc = LNET_MD_OP_GET; > + info.mi_portal = hdr->msg.get.ptl_index; > info.mi_rlength = hdr->msg.get.sink_length; > info.mi_roffset = hdr->msg.get.src_offset; > - info.mi_mbits = hdr->msg.get.match_bits; > - info.mi_cpt = lnet_cpt_of_nid(msg->msg_rxpeer->lpni_nid, ni); > + info.mi_mbits = hdr->msg.get.match_bits; > + info.mi_cpt = lnet_cpt_of_nid(msg->msg_rxpeer->lpni_nid, ni); > > rc = lnet_ptl_match_md(&info, msg); > if (rc == LNET_MATCHMD_DROP) { > @@ -2128,7 +2127,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > { > void *private = msg->msg_private; > struct lnet_hdr *hdr = &msg->msg_hdr; > - struct lnet_process_id src = {0}; > + struct lnet_process_id src = { 0 }; > struct lnet_libmd *md; > int rlength; > int mlength; > @@ -2192,7 +2191,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > lnet_parse_ack(struct lnet_ni *ni, struct lnet_msg *msg) > { > struct lnet_hdr *hdr = &msg->msg_hdr; > - struct lnet_process_id src = {0}; > + struct lnet_process_id src = { 0 }; > struct lnet_libmd *md; > int cpt; > > @@ -2316,8 +2315,8 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > void > lnet_print_hdr(struct lnet_hdr *hdr) > { > - struct lnet_process_id src = {0}; > - struct lnet_process_id dst = {0}; > + struct lnet_process_id src = { 0 }; > + struct lnet_process_id dst = { 0 }; > char *type_str = lnet_msgtyp2str(hdr->type); > > src.nid = hdr->src_nid; > @@ -2533,17 +2532,16 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > /* for building message event */ > msg->msg_from = from_nid; > if (!for_me) { > - msg->msg_target.pid = dest_pid; > - msg->msg_target.nid = dest_nid; > - msg->msg_routing = 1; > - > + msg->msg_target.pid = dest_pid; > + msg->msg_target.nid = dest_nid; > + msg->msg_routing = 1; > } else { > /* convert common msg->hdr fields to host byteorder */ > - msg->msg_hdr.type = type; > - msg->msg_hdr.src_nid = src_nid; > + msg->msg_hdr.type = type; > + msg->msg_hdr.src_nid = src_nid; > le32_to_cpus(&msg->msg_hdr.src_pid); > - msg->msg_hdr.dest_nid = dest_nid; > - msg->msg_hdr.dest_pid = dest_pid; > + msg->msg_hdr.dest_nid = dest_nid; > + msg->msg_hdr.dest_pid = dest_pid; > msg->msg_hdr.payload_length = payload_length; > } > > @@ -2609,11 +2607,11 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > goto free_drop; > return 0; > > - free_drop: > +free_drop: > LASSERT(!msg->msg_md); > lnet_finalize(msg, rc); > > - drop: > +drop: > lnet_drop_message(ni, cpt, private, payload_length, type); > return 0; > } > @@ -2623,7 +2621,7 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > lnet_drop_delayed_msg_list(struct list_head *head, char *reason) > { > while (!list_empty(head)) { > - struct lnet_process_id id = {0}; > + struct lnet_process_id id = { 0 }; > struct lnet_msg *msg; > > msg = list_entry(head->next, struct lnet_msg, msg_list); > @@ -2887,7 +2885,7 @@ struct lnet_msg * > > return msg; > > - drop: > +drop: > cpt = lnet_cpt_of_nid(peer_id.nid, ni); > > lnet_net_lock(cpt); > diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c > index 7f58cfe..b9e9257 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c > @@ -44,9 +44,9 @@ > { > memset(ev, 0, sizeof(*ev)); > > - ev->status = 0; > + ev->status = 0; > ev->unlinked = 1; > - ev->type = LNET_EVENT_UNLINK; > + ev->type = LNET_EVENT_UNLINK; > lnet_md_deconstruct(md, &ev->md); > lnet_md2handle(&ev->md_handle, md); > } > @@ -58,7 +58,7 @@ > lnet_build_msg_event(struct lnet_msg *msg, enum lnet_event_kind ev_type) > { > struct lnet_hdr *hdr = &msg->msg_hdr; > - struct lnet_event *ev = &msg->msg_ev; > + struct lnet_event *ev = &msg->msg_ev; > > LASSERT(!msg->msg_routing); > > @@ -67,27 +67,27 @@ > > if (ev_type == LNET_EVENT_SEND) { > /* event for active message */ > - ev->target.nid = le64_to_cpu(hdr->dest_nid); > - ev->target.pid = le32_to_cpu(hdr->dest_pid); > + ev->target.nid = le64_to_cpu(hdr->dest_nid); > + ev->target.pid = le32_to_cpu(hdr->dest_pid); > ev->initiator.nid = LNET_NID_ANY; > ev->initiator.pid = the_lnet.ln_pid; > - ev->source.nid = LNET_NID_ANY; > - ev->source.pid = the_lnet.ln_pid; > - ev->sender = LNET_NID_ANY; > + ev->source.nid = LNET_NID_ANY; > + ev->source.pid = the_lnet.ln_pid; > + ev->sender = LNET_NID_ANY; > } else { > /* event for passive message */ > - ev->target.pid = hdr->dest_pid; > - ev->target.nid = hdr->dest_nid; > + ev->target.pid = hdr->dest_pid; > + ev->target.nid = hdr->dest_nid; > ev->initiator.pid = hdr->src_pid; > /* Multi-Rail: resolve src_nid to "primary" peer NID */ > ev->initiator.nid = msg->msg_initiator; > /* Multi-Rail: track source NID. */ > - ev->source.pid = hdr->src_pid; > - ev->source.nid = hdr->src_nid; > - ev->rlength = hdr->payload_length; > - ev->sender = msg->msg_from; > - ev->mlength = msg->msg_wanted; > - ev->offset = msg->msg_offset; > + ev->source.pid = hdr->src_pid; > + ev->source.nid = hdr->src_nid; > + ev->rlength = hdr->payload_length; > + ev->sender = msg->msg_from; > + ev->mlength = msg->msg_wanted; > + ev->offset = msg->msg_offset; > } > > switch (ev_type) { > @@ -95,20 +95,20 @@ > LBUG(); > > case LNET_EVENT_PUT: /* passive PUT */ > - ev->pt_index = hdr->msg.put.ptl_index; > + ev->pt_index = hdr->msg.put.ptl_index; > ev->match_bits = hdr->msg.put.match_bits; > - ev->hdr_data = hdr->msg.put.hdr_data; > + ev->hdr_data = hdr->msg.put.hdr_data; > return; > > case LNET_EVENT_GET: /* passive GET */ > - ev->pt_index = hdr->msg.get.ptl_index; > + ev->pt_index = hdr->msg.get.ptl_index; > ev->match_bits = hdr->msg.get.match_bits; > - ev->hdr_data = 0; > + ev->hdr_data = 0; > return; > > case LNET_EVENT_ACK: /* ACK */ > ev->match_bits = hdr->msg.ack.match_bits; > - ev->mlength = hdr->msg.ack.mlength; > + ev->mlength = hdr->msg.ack.mlength; > return; > > case LNET_EVENT_REPLY: /* REPLY */ > @@ -116,21 +116,21 @@ > > case LNET_EVENT_SEND: /* active message */ > if (msg->msg_type == LNET_MSG_PUT) { > - ev->pt_index = le32_to_cpu(hdr->msg.put.ptl_index); > + ev->pt_index = le32_to_cpu(hdr->msg.put.ptl_index); > ev->match_bits = le64_to_cpu(hdr->msg.put.match_bits); > - ev->offset = le32_to_cpu(hdr->msg.put.offset); > - ev->mlength = > - ev->rlength = le32_to_cpu(hdr->payload_length); > - ev->hdr_data = le64_to_cpu(hdr->msg.put.hdr_data); > + ev->offset = le32_to_cpu(hdr->msg.put.offset); > + ev->mlength = > + ev->rlength = le32_to_cpu(hdr->payload_length); > + ev->hdr_data = le64_to_cpu(hdr->msg.put.hdr_data); > > } else { > LASSERT(msg->msg_type == LNET_MSG_GET); > - ev->pt_index = le32_to_cpu(hdr->msg.get.ptl_index); > + ev->pt_index = le32_to_cpu(hdr->msg.get.ptl_index); > ev->match_bits = le64_to_cpu(hdr->msg.get.match_bits); > - ev->mlength = > - ev->rlength = le32_to_cpu(hdr->msg.get.sink_length); > - ev->offset = le32_to_cpu(hdr->msg.get.src_offset); > - ev->hdr_data = 0; > + ev->mlength = > + ev->rlength = le32_to_cpu(hdr->msg.get.sink_length); > + ev->offset = le32_to_cpu(hdr->msg.get.src_offset); > + ev->hdr_data = 0; > } > return; > } > @@ -140,7 +140,7 @@ > lnet_msg_commit(struct lnet_msg *msg, int cpt) > { > struct lnet_msg_container *container = the_lnet.ln_msg_containers[cpt]; > - struct lnet_counters *counters = the_lnet.ln_counters[cpt]; > + struct lnet_counters *counters = the_lnet.ln_counters[cpt]; > > /* routed message can be committed for both receiving and sending */ > LASSERT(!msg->msg_tx_committed); > @@ -172,7 +172,7 @@ > static void > lnet_msg_decommit_tx(struct lnet_msg *msg, int status) > { > - struct lnet_counters *counters; > + struct lnet_counters *counters; > struct lnet_event *ev = &msg->msg_ev; > > LASSERT(msg->msg_tx_committed); > @@ -294,7 +294,7 @@ > if (ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_REPLY) > counters->recv_length += msg->msg_wanted; > > - out: > +out: > lnet_return_rx_credits_locked(msg); > msg->msg_rx_committed = 0; > } > @@ -375,7 +375,7 @@ > > unlink = lnet_md_unlinkable(md); > if (md->md_eq) { > - msg->msg_ev.status = status; > + msg->msg_ev.status = status; > msg->msg_ev.unlinked = unlink; > lnet_eq_enqueue_event(md->md_eq, &msg->msg_ev); > } > @@ -488,7 +488,7 @@ > lnet_res_unlock(cpt); > } > > - again: > +again: > rc = 0; > if (!msg->msg_tx_committed && !msg->msg_rx_committed) { > /* not committed to network yet */ > diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c > index fa391ee..ea232c7 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c > @@ -74,7 +74,7 @@ > > return 1; > > - match: > +match: > if ((lnet_ptl_is_unique(ptl) && !unique) || > (lnet_ptl_is_wildcard(ptl) && unique)) > return 0; > @@ -387,7 +387,7 @@ struct list_head * > head = &mtable->mt_mhash[LNET_MT_HASH_IGNORE]; > else > head = lnet_mt_match_head(mtable, info->mi_id, info->mi_mbits); > - again: > +again: > /* NB: only wildcard portal needs to return LNET_MATCHMD_EXHAUSTED */ > if (lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal])) > exhausted = LNET_MATCHMD_EXHAUSTED; > @@ -634,9 +634,9 @@ struct list_head * > info->mi_mbits, info->mi_roffset, info->mi_rlength); > } > goto out0; > - out1: > +out1: > lnet_res_unlock(mtable->mt_cpt); > - out0: > +out0: > /* EXHAUSTED bit is only meaningful for internal functions */ > return rc & ~LNET_MATCHMD_EXHAUSTED; > } > @@ -678,7 +678,7 @@ struct list_head * > > lnet_ptl_lock(ptl); > head = &ptl->ptl_msg_stealing; > - again: > +again: > list_for_each_entry_safe(msg, tmp, head, msg_list) { > struct lnet_match_info info; > struct lnet_hdr *hdr; > @@ -688,13 +688,13 @@ struct list_head * > > hdr = &msg->msg_hdr; > /* Multi-Rail: Primary peer NID */ > - info.mi_id.nid = msg->msg_initiator; > - info.mi_id.pid = hdr->src_pid; > - info.mi_opc = LNET_MD_OP_PUT; > - info.mi_portal = hdr->msg.put.ptl_index; > + info.mi_id.nid = msg->msg_initiator; > + info.mi_id.pid = hdr->src_pid; > + info.mi_opc = LNET_MD_OP_PUT; > + info.mi_portal = hdr->msg.put.ptl_index; > info.mi_rlength = hdr->payload_length; > info.mi_roffset = hdr->msg.put.offset; > - info.mi_mbits = hdr->msg.put.match_bits; > + info.mi_mbits = hdr->msg.put.match_bits; > > rc = lnet_try_match_md(md, &info, msg); > > @@ -824,7 +824,7 @@ struct list_head * > } > > return 0; > - failed: > +failed: > lnet_ptl_cleanup(ptl); > return -ENOMEM; > } > diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c > index cff3d1e..095f9f5 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c > @@ -50,8 +50,11 @@ > long jiffies_left = timeout * msecs_to_jiffies(MSEC_PER_SEC); > unsigned long then; > struct timeval tv; > - struct kvec iov = { .iov_base = buffer, .iov_len = nob }; > - struct msghdr msg = {NULL,}; > + struct kvec iov = { > + .iov_base = buffer, > + .iov_len = nob > + }; > + struct msghdr msg = { NULL, }; > > LASSERT(nob > 0); > /* > @@ -102,9 +105,9 @@ > long jiffies_left = timeout * msecs_to_jiffies(MSEC_PER_SEC); > unsigned long then; > struct timeval tv; > - struct kvec iov = { > + struct kvec iov = { > .iov_base = buffer, > - .iov_len = nob > + .iov_len = nob > }; > struct msghdr msg = { > .msg_flags = 0 > diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c > index 4c08c74..f306569 100644 > --- a/drivers/staging/lustre/lnet/lnet/module.c > +++ b/drivers/staging/lustre/lnet/lnet/module.c > @@ -52,7 +52,6 @@ > > if (!the_lnet.ln_niinit_self) { > rc = try_module_get(THIS_MODULE); > - > if (rc != 1) > goto out; > > @@ -229,7 +228,7 @@ > } > > static struct notifier_block lnet_ioctl_handler = { > - .notifier_call = lnet_ioctl, > + .notifier_call = lnet_ioctl, > }; > > static int __init lnet_init(void) > diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c > index e2c7468..4234ce1 100644 > --- a/drivers/staging/lustre/lnet/lnet/net_fault.c > +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c > @@ -614,7 +614,6 @@ struct delay_daemon_data { > rc = lnet_parse_local(ni, msg); > if (!rc) > continue; > - > } else { > lnet_net_lock(cpt); > rc = lnet_parse_forward_locked(ni, msg); > diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c > index 0f2b75e..8f3d87c 100644 > --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c > +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c > @@ -60,8 +60,8 @@ > * between getting its string and using it. > */ > > -static char libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE]; > -static int libcfs_nidstring_idx; > +static char libcfs_nidstrings[LNET_NIDSTR_COUNT][LNET_NIDSTR_SIZE]; > +static int libcfs_nidstring_idx; > > static DEFINE_SPINLOCK(libcfs_nidstring_lock); > > @@ -117,23 +117,23 @@ struct nidrange { > * Link to list of this structures which is built on nid range > * list parsing. > */ > - struct list_head nr_link; > + struct list_head nr_link; > /** > * List head for addrrange::ar_link. > */ > - struct list_head nr_addrranges; > + struct list_head nr_addrranges; > /** > * Flag indicating that *@ is found. > */ > - int nr_all; > + int nr_all; > /** > * Pointer to corresponding element of libcfs_netstrfns. > */ > - struct netstrfns *nr_netstrfns; > + struct netstrfns *nr_netstrfns; > /** > * Number of network. E.g. 5 if \ is "elan5". > */ > - int nr_netnum; > + int nr_netnum; > }; > > /** > @@ -143,11 +143,11 @@ struct addrrange { > /** > * Link to nidrange::nr_addrranges. > */ > - struct list_head ar_link; > + struct list_head ar_link; > /** > * List head for cfs_expr_list::el_list. > */ > - struct list_head ar_numaddr_ranges; > + struct list_head ar_numaddr_ranges; > }; > > /** > @@ -471,8 +471,8 @@ static void cfs_ip_ar_min_max(struct addrrange *ar, u32 *min_nid, > struct cfs_expr_list *el; > struct cfs_range_expr *re; > u32 tmp_ip_addr = 0; > - unsigned int min_ip[4] = {0}; > - unsigned int max_ip[4] = {0}; > + unsigned int min_ip[4] = { 0 }; > + unsigned int max_ip[4] = { 0 }; > int re_count = 0; > > list_for_each_entry(el, &ar->ar_numaddr_ranges, el_link) { > @@ -794,11 +794,11 @@ static void cfs_ip_min_max(struct list_head *nidlist, u32 *min_nid, > static int > libcfs_ip_str2addr(const char *str, int nob, u32 *addr) > { > - unsigned int a; > - unsigned int b; > - unsigned int c; > - unsigned int d; > - int n = nob; /* XscanfX */ > + unsigned int a; > + unsigned int b; > + unsigned int c; > + unsigned int d; > + int n = nob; /* XscanfX */ > > /* numeric IP? */ > if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 && > @@ -897,7 +897,7 @@ static void cfs_ip_min_max(struct list_head *nidlist, u32 *min_nid, > static int > libcfs_num_str2addr(const char *str, int nob, u32 *addr) > { > - int n; > + int n; > > n = nob; > if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob) > @@ -926,7 +926,7 @@ static void cfs_ip_min_max(struct list_head *nidlist, u32 *min_nid, > libcfs_num_parse(char *str, int len, struct list_head *list) > { > struct cfs_expr_list *el; > - int rc; > + int rc; > > rc = cfs_expr_list_parse(str, len, 0, MAX_NUMERIC_VALUE, &el); > if (!rc) > @@ -1049,7 +1049,7 @@ static void cfs_ip_min_max(struct list_head *nidlist, u32 *min_nid, > static struct netstrfns * > libcfs_name2netstrfns(const char *name) > { > - int i; > + int i; > > for (i = 0; i < libcfs_nnetstrfns; i++) > if (!strcmp(libcfs_netstrfns[i].nf_name, name)) > @@ -1194,7 +1194,7 @@ static void cfs_ip_min_max(struct list_head *nidlist, u32 *min_nid, > u32 > libcfs_str2net(const char *str) > { > - u32 net; > + u32 net; > > if (libcfs_str2net_internal(str, &net)) > return net; > diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c > index d807dd4..dfe1f3d 100644 > --- a/drivers/staging/lustre/lnet/lnet/peer.c > +++ b/drivers/staging/lustre/lnet/lnet/peer.c > @@ -586,8 +586,8 @@ void lnet_peer_uninit(void) > static struct lnet_peer_ni * > lnet_get_peer_ni_locked(struct lnet_peer_table *ptable, lnet_nid_t nid) > { > - struct list_head *peers; > - struct lnet_peer_ni *lp; > + struct list_head *peers; > + struct lnet_peer_ni *lp; > > LASSERT(the_lnet.ln_state == LNET_STATE_RUNNING); > > @@ -1069,6 +1069,7 @@ struct lnet_peer_net * > lnet_peer_get_net_locked(struct lnet_peer *peer, u32 net_id) > { > struct lnet_peer_net *peer_net; > + > list_for_each_entry(peer_net, &peer->lp_peer_nets, lpn_peer_nets) { > if (peer_net->lpn_net_id == net_id) > return peer_net; > @@ -1088,9 +1089,9 @@ struct lnet_peer_net * > */ > static int > lnet_peer_attach_peer_ni(struct lnet_peer *lp, > - struct lnet_peer_net *lpn, > - struct lnet_peer_ni *lpni, > - unsigned int flags) > + struct lnet_peer_net *lpn, > + struct lnet_peer_ni *lpni, > + unsigned int flags) > { > struct lnet_peer_table *ptable; > > @@ -2686,12 +2687,12 @@ static int lnet_peer_send_ping(struct lnet_peer *lp) > } > > /* initialize md content */ > - md.start = &pbuf->pb_info; > - md.length = LNET_PING_INFO_SIZE(nnis); > + md.start = &pbuf->pb_info; > + md.length = LNET_PING_INFO_SIZE(nnis); > md.threshold = 2; /* GET/REPLY */ > - md.max_size = 0; > - md.options = LNET_MD_TRUNCATE; > - md.user_ptr = lp; > + md.max_size = 0; > + md.options = LNET_MD_TRUNCATE; > + md.user_ptr = lp; > md.eq_handle = the_lnet.ln_dc_eqh; > > rc = LNetMDBind(md, LNET_UNLINK, &lp->lp_ping_mdh); > @@ -2715,7 +2716,6 @@ static int lnet_peer_send_ping(struct lnet_peer *lp) > rc = LNetGet(LNET_NID_ANY, lp->lp_ping_mdh, id, > LNET_RESERVED_PORTAL, > LNET_PROTO_PING_MATCHBITS, 0); > - > if (rc) > goto fail_unlink_md; > > @@ -2792,13 +2792,13 @@ static int lnet_peer_send_push(struct lnet_peer *lp) > lnet_net_unlock(cpt); > > /* Push source MD */ > - md.start = &pbuf->pb_info; > - md.length = LNET_PING_INFO_SIZE(pbuf->pb_nnis); > + md.start = &pbuf->pb_info; > + md.length = LNET_PING_INFO_SIZE(pbuf->pb_nnis); > md.threshold = 2; /* Put/Ack */ > - md.max_size = 0; > - md.options = 0; > + md.max_size = 0; > + md.options = 0; > md.eq_handle = the_lnet.ln_dc_eqh; > - md.user_ptr = lp; > + md.user_ptr = lp; > > rc = LNetMDBind(md, LNET_UNLINK, &lp->lp_push_mdh); > if (rc) { > @@ -2821,7 +2821,6 @@ static int lnet_peer_send_push(struct lnet_peer *lp) > rc = LNetPut(LNET_NID_ANY, lp->lp_push_mdh, > LNET_ACK_REQ, id, LNET_RESERVED_PORTAL, > LNET_PROTO_PING_MATCHBITS, 0, 0); > - > if (rc) > goto fail_unlink; > > @@ -3315,8 +3314,8 @@ int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk) > goto out; > } > > - size = sizeof(nid) + sizeof(*lpni_info) + sizeof(*lpni_stats) > - + sizeof(*lpni_msg_stats); > + size = sizeof(nid) + sizeof(*lpni_info) + sizeof(*lpni_stats) + > + sizeof(*lpni_msg_stats); > size *= lp->lp_nnis; > if (size > cfg->prcfg_size) { > cfg->prcfg_size = size; > diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c > index 22c88ec..463b123 100644 > --- a/drivers/staging/lustre/lnet/lnet/router.c > +++ b/drivers/staging/lustre/lnet/lnet/router.c > @@ -172,7 +172,7 @@ > notifylnd = lp->lpni_notifylnd; > > lp->lpni_notifylnd = 0; > - lp->lpni_notify = 0; > + lp->lpni_notify = 0; > > if (notifylnd && ni->ni_net->net_lnd->lnd_notify) { > spin_unlock(&lp->lpni_lock); > @@ -274,6 +274,7 @@ static void lnet_shuffle_seed(void) > * the NID for this node gives the most entropy in the low bits */ > while ((ni = lnet_get_next_ni_locked(NULL, ni))) { > u32 lnd_type, seed; > + > lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid)); > if (lnd_type != LOLND) { > seed = (LNET_NIDADDR(ni->ni_nid) | lnd_type); > @@ -386,7 +387,6 @@ static void lnet_shuffle_seed(void) > /* Search for a duplicate route (it's a NOOP if it is) */ > add_route = 1; > list_for_each_entry(route2, &rnet2->lrn_routes, lr_list) { > - > if (route2->lr_gateway == route->lr_gateway) { > add_route = 0; > break; > @@ -501,7 +501,7 @@ static void lnet_shuffle_seed(void) > else > rn_list = lnet_net2rnethash(net); > > - again: > +again: > list_for_each_entry(rnet, rn_list, lrn_list) { > if (!(net == LNET_NIDNET(LNET_NID_ANY) || > net == rnet->lrn_net)) > @@ -601,10 +601,10 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) > list_for_each_entry(rnet, rn_list, lrn_list) { > list_for_each_entry(route, &rnet->lrn_routes, lr_list) { > if (!idx--) { > - *net = rnet->lrn_net; > - *hops = route->lr_hops; > + *net = rnet->lrn_net; > + *hops = route->lr_hops; > *priority = route->lr_priority; > - *gateway = route->lr_gateway->lpni_nid; > + *gateway = route->lr_gateway->lpni_nid; > *alive = lnet_is_route_alive(route); > lnet_net_unlock(cpt); > return 0; > @@ -648,7 +648,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) > struct lnet_ping_buffer *pbuf = rcd->rcd_pingbuffer; > struct lnet_peer_ni *gw = rcd->rcd_gateway; > struct lnet_route *rte; > - int nnis; > + int nnis; > > if (!gw->lpni_alive || !pbuf) > return; > @@ -799,7 +799,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) > if (avoid_asym_router_failure && !event->status) > lnet_parse_rc_info(rcd); > > - out: > +out: > lnet_net_unlock(lp->lpni_cpt); > } > > @@ -1069,14 +1069,14 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) > id.pid = LNET_PID_LUSTRE; > CDEBUG(D_NET, "Check: %s\n", libcfs_id2str(id)); > > - rtr->lpni_ping_notsent = 1; > + rtr->lpni_ping_notsent = 1; > rtr->lpni_ping_timestamp = now; > > mdh = rcd->rcd_mdh; > > if (!rtr->lpni_ping_deadline) { > rtr->lpni_ping_deadline = ktime_get_seconds() + > - router_ping_timeout; > + router_ping_timeout; > } > > lnet_net_unlock(rtr->lpni_cpt); > @@ -1652,7 +1652,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) > > return 0; > > - failed: > +failed: > lnet_rtrpools_free(0); > return rc; > } > @@ -1797,8 +1797,8 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) > return -EINVAL; > } > > - if (ni && !alive && /* LND telling me she's down */ > - !auto_down) { /* auto-down disabled */ > + if (ni && !alive && /* LND telling me she's down */ > + !auto_down) { /* auto-down disabled */ > CDEBUG(D_NET, "Auto-down disabled\n"); > return 0; > } > diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c > index e8cc70f..94ef441 100644 > --- a/drivers/staging/lustre/lnet/lnet/router_proc.c > +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c > @@ -66,8 +66,8 @@ > #define LNET_PROC_HOFF_GET(pos) \ > (int)((pos) & LNET_PROC_HOFF_MASK) > > -#define LNET_PROC_POS_MAKE(cpt, ver, hash, off) \ > - (((((loff_t)(cpt)) & LNET_PROC_CPT_MASK) << LNET_PROC_VPOS_BITS) | \ > +#define LNET_PROC_POS_MAKE(cpt, ver, hash, off) \ > + (((((loff_t)(cpt)) & LNET_PROC_CPT_MASK) << LNET_PROC_VPOS_BITS) | \ > ((((loff_t)(ver)) & LNET_PROC_VER_MASK) << LNET_PROC_HPOS_BITS) | \ > ((((loff_t)(hash)) & LNET_PROC_HASH_MASK) << LNET_PROC_HOFF_BITS) | \ > ((off) & LNET_PROC_HOFF_MASK)) > @@ -91,7 +91,6 @@ static int proc_lnet_stats(struct ctl_table *table, int write, > } > > /* read */ > - > ctrs = kzalloc(sizeof(*ctrs), GFP_NOFS); > if (!ctrs) > return -ENOMEM; > @@ -395,8 +394,8 @@ static int proc_lnet_peers(struct ctl_table *table, int write, > struct lnet_peer_table *ptable; > char *tmpstr = NULL; > char *s; > - int cpt = LNET_PROC_CPT_GET(*ppos); > - int ver = LNET_PROC_VER_GET(*ppos); > + int cpt = LNET_PROC_CPT_GET(*ppos); > + int ver = LNET_PROC_VER_GET(*ppos); > int hash = LNET_PROC_HASH_GET(*ppos); > int hoff = LNET_PROC_HOFF_GET(*ppos); > int rc = 0; > @@ -456,7 +455,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, > struct lnet_peer_ni *peer; > struct list_head *p; > int skip; > - again: > +again: > p = NULL; > peer = NULL; > skip = hoff - 1; > @@ -630,7 +629,7 @@ static int proc_lnet_buffers(struct ctl_table *table, int write, > lnet_net_unlock(LNET_LOCK_EX); > } > > - out: > +out: > len = s - tmpstr; > > if (pos >= min_t(int, len, strlen(tmpstr))) > @@ -787,9 +786,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write, > } > > struct lnet_portal_rotors { > - int pr_value; > - const char *pr_name; > - const char *pr_desc; > + int pr_value; > + const char *pr_name; > + const char *pr_desc; > }; > > static struct lnet_portal_rotors portal_rotors[] = { > @@ -890,39 +889,39 @@ static int proc_lnet_portal_rotor(struct ctl_table *table, int write, > * to go via /proc for portability. > */ > { > - .procname = "stats", > - .mode = 0644, > - .proc_handler = &proc_lnet_stats, > + .procname = "stats", > + .mode = 0644, > + .proc_handler = &proc_lnet_stats, > }, > { > - .procname = "routes", > - .mode = 0444, > - .proc_handler = &proc_lnet_routes, > + .procname = "routes", > + .mode = 0444, > + .proc_handler = &proc_lnet_routes, > }, > { > - .procname = "routers", > - .mode = 0444, > - .proc_handler = &proc_lnet_routers, > + .procname = "routers", > + .mode = 0444, > + .proc_handler = &proc_lnet_routers, > }, > { > - .procname = "peers", > - .mode = 0644, > - .proc_handler = &proc_lnet_peers, > + .procname = "peers", > + .mode = 0644, > + .proc_handler = &proc_lnet_peers, > }, > { > - .procname = "buffers", > - .mode = 0444, > - .proc_handler = &proc_lnet_buffers, > + .procname = "buffers", > + .mode = 0444, > + .proc_handler = &proc_lnet_buffers, > }, > { > - .procname = "nis", > - .mode = 0644, > - .proc_handler = &proc_lnet_nis, > + .procname = "nis", > + .mode = 0644, > + .proc_handler = &proc_lnet_nis, > }, > { > - .procname = "portal_rotor", > - .mode = 0644, > - .proc_handler = &proc_lnet_portal_rotor, > + .procname = "portal_rotor", > + .mode = 0644, > + .proc_handler = &proc_lnet_portal_rotor, > }, > { > } > -- > 1.8.3.1 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 4 03:18:38 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 04 Feb 2019 14:18:38 +1100 Subject: [lustre-devel] [PATCH 19/26] ptlrpc: cleanup white spaces In-Reply-To: <1548955170-13456-20-git-send-email-jsimmons@infradead.org> References: <1548955170-13456-1-git-send-email-jsimmons@infradead.org> <1548955170-13456-20-git-send-email-jsimmons@infradead.org> Message-ID: <877eegjl69.fsf@notabene.neil.brown.name> On Thu, Jan 31 2019, James Simmons wrote: > The ptlrpc code is very messy and difficult to read. Remove excess > white space and properly align data structures so they are easy on > the eyes. > > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/ptlrpc/client.c | 45 ++-- > drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- > drivers/staging/lustre/lustre/ptlrpc/layout.c | 3 - > .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 278 ++++++++++----------- > drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 7 +- > drivers/staging/lustre/lustre/ptlrpc/nrs.c | 1 - > .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 14 +- > drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 20 +- > drivers/staging/lustre/lustre/ptlrpc/recover.c | 1 + > drivers/staging/lustre/lustre/ptlrpc/sec.c | 4 +- > drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 74 +++--- > drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 22 +- > drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 34 +-- > drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 68 ++--- > drivers/staging/lustre/lustre/ptlrpc/service.c | 20 +- > 15 files changed, 293 insertions(+), 300 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c > index f4b3875..0831810 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/client.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c > @@ -49,14 +49,14 @@ > #include "ptlrpc_internal.h" > > const struct ptlrpc_bulk_frag_ops ptlrpc_bulk_kiov_pin_ops = { > - .add_kiov_frag = ptlrpc_prep_bulk_page_pin, > - .release_frags = ptlrpc_release_bulk_page_pin, > + .add_kiov_frag = ptlrpc_prep_bulk_page_pin, > + .release_frags = ptlrpc_release_bulk_page_pin, > }; > EXPORT_SYMBOL(ptlrpc_bulk_kiov_pin_ops); > > const struct ptlrpc_bulk_frag_ops ptlrpc_bulk_kiov_nopin_ops = { > - .add_kiov_frag = ptlrpc_prep_bulk_page_nopin, > - .release_frags = NULL, > + .add_kiov_frag = ptlrpc_prep_bulk_page_nopin, > + .release_frags = NULL, > }; > EXPORT_SYMBOL(ptlrpc_bulk_kiov_nopin_ops); > > @@ -658,15 +658,14 @@ static void __ptlrpc_free_req_to_pool(struct ptlrpc_request *request) > > void ptlrpc_add_unreplied(struct ptlrpc_request *req) > { > - struct obd_import *imp = req->rq_import; > - struct ptlrpc_request *iter; > + struct obd_import *imp = req->rq_import; > + struct ptlrpc_request *iter; > > assert_spin_locked(&imp->imp_lock); > LASSERT(list_empty(&req->rq_unreplied_list)); > > /* unreplied list is sorted by xid in ascending order */ > list_for_each_entry_reverse(iter, &imp->imp_unreplied_list, rq_unreplied_list) { > - > LASSERT(req->rq_xid != iter->rq_xid); > if (req->rq_xid < iter->rq_xid) > continue; > @@ -1318,10 +1317,10 @@ static int after_reply(struct ptlrpc_request *req) > * reply). NB: no need to round up because alloc_repbuf will > * round it up > */ > - req->rq_replen = req->rq_nob_received; > + req->rq_replen = req->rq_nob_received; > req->rq_nob_received = 0; > spin_lock(&req->rq_lock); > - req->rq_resend = 1; > + req->rq_resend = 1; > spin_unlock(&req->rq_lock); > return 0; > } > @@ -1359,7 +1358,7 @@ static int after_reply(struct ptlrpc_request *req) > spin_unlock(&req->rq_lock); > req->rq_nr_resend++; > > - /* Readjust the timeout for current conditions */ > + /* Read just the timeout for current conditions */ > ptlrpc_at_set_req_timeout(req); > /* > * delay resend to give a chance to the server to get ready. Uhmm... I don't think this function us reading anything, not even "just the timeout". I think it is adjusting the timeout - which has already been done previously. So this time it is re-adjusting. ?? I've changed this to Re-adjust There is a similar comment in ptlrpc_replay_req which I've also changed from readjust to re-adjust. NeilBrown > @@ -1620,7 +1619,7 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) > rc = set->set_producer(set, set->set_producer_arg); > if (rc == -ENOENT) { > /* no more RPC to produce */ > - set->set_producer = NULL; > + set->set_producer = NULL; > set->set_producer_arg = NULL; > return 0; > } > @@ -1654,7 +1653,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) > > /* > * This schedule point is mainly for the ptlrpcd caller of this > - * function. Most ptlrpc sets are not long-lived and unbounded > + * function. Most ptlrpc sets are not long-lived and unbounded > * in length, but at the least the set used by the ptlrpcd is. > * Since the processing time is unbounded, we need to insert an > * explicit schedule point to make the thread well-behaved. > @@ -2130,7 +2129,6 @@ void ptlrpc_expired_set(struct ptlrpc_request_set *set) > > /* A timeout expired. See which reqs it applies to... */ > list_for_each_entry(req, &set->set_requests, rq_set_chain) { > - > /* don't expire request waiting for context */ > if (req->rq_wait_ctx) > continue; > @@ -2185,7 +2183,6 @@ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) > time64_t deadline; > > list_for_each_entry(req, &set->set_requests, rq_set_chain) { > - > /* Request in-flight? */ > if (!(((req->rq_phase == RQ_PHASE_RPC) && !req->rq_waiting) || > (req->rq_phase == RQ_PHASE_BULK) || > @@ -2568,7 +2565,7 @@ static void ptlrpc_free_request(struct ptlrpc_request *req) > */ > void ptlrpc_request_committed(struct ptlrpc_request *req, int force) > { > - struct obd_import *imp = req->rq_import; > + struct obd_import *imp = req->rq_import; > > spin_lock(&imp->imp_lock); > if (list_empty(&req->rq_replay_list)) { > @@ -2896,7 +2893,7 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, > > /* continue with recovery */ > rc = ptlrpc_import_recovery_state_machine(imp); > - out: > +out: > req->rq_send_state = aa->praa_old_state; > > if (rc != 0) > @@ -3031,7 +3028,7 @@ void ptlrpc_abort_set(struct ptlrpc_request_set *set) > /** > * Initialize the XID for the node. This is common among all requests on > * this node, and only requires the property that it is monotonically > - * increasing. It does not need to be sequential. Since this is also used > + * increasing. It does not need to be sequential. Since this is also used > * as the RDMA match bits, it is important that a single client NOT have > * the same match bits for two different in-flight requests, hence we do > * NOT want to have an XID per target or similar. > @@ -3198,12 +3195,12 @@ struct ptlrpc_work_async_args { > static void ptlrpcd_add_work_req(struct ptlrpc_request *req) > { > /* re-initialize the req */ > - req->rq_timeout = obd_timeout; > - req->rq_sent = ktime_get_real_seconds(); > - req->rq_deadline = req->rq_sent + req->rq_timeout; > - req->rq_phase = RQ_PHASE_INTERPRET; > - req->rq_next_phase = RQ_PHASE_COMPLETE; > - req->rq_xid = ptlrpc_next_xid(); > + req->rq_timeout = obd_timeout; > + req->rq_sent = ktime_get_real_seconds(); > + req->rq_deadline = req->rq_sent + req->rq_timeout; > + req->rq_phase = RQ_PHASE_INTERPRET; > + req->rq_next_phase = RQ_PHASE_COMPLETE; > + req->rq_xid = ptlrpc_next_xid(); > req->rq_import_generation = req->rq_import->imp_generation; > > ptlrpcd_add_req(req); > @@ -3241,7 +3238,7 @@ static int ptlrpcd_check_work(struct ptlrpc_request *req) > void *ptlrpcd_alloc_work(struct obd_import *imp, > int (*cb)(const struct lu_env *, void *), void *cbdata) > { > - struct ptlrpc_request *req = NULL; > + struct ptlrpc_request *req = NULL; > struct ptlrpc_work_async_args *args; > > might_sleep(); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c > index 56a0b76..7bb2e06 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/import.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c > @@ -51,7 +51,7 @@ > #include "ptlrpc_internal.h" > > struct ptlrpc_connect_async_args { > - u64 pcaa_peer_committed; > + u64 pcaa_peer_committed; > int pcaa_initial_connect; > }; > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c > index 2848f2f..f1f7d70 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c > @@ -1907,9 +1907,7 @@ static void *__req_capsule_get(struct req_capsule *pill, > void *value; > u32 len; > u32 offset; > - > void *(*getter)(struct lustre_msg *m, u32 n, u32 minlen); > - > static const char *rcl_names[RCL_NR] = { > [RCL_CLIENT] = "client", > [RCL_SERVER] = "server" > @@ -2176,7 +2174,6 @@ void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt) > { > int i; > size_t j; > - > const struct req_format *old; > > LASSERT(pill->rc_fmt); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c > index 92e3e0f..25858b8 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c > @@ -42,115 +42,115 @@ > #include "ptlrpc_internal.h" > > static struct ll_rpc_opcode { > - u32 opcode; > - const char *opname; > + u32 opcode; > + const char *opname; > } ll_rpc_opcode_table[LUSTRE_MAX_OPCODES] = { > - { OST_REPLY, "ost_reply" }, > - { OST_GETATTR, "ost_getattr" }, > - { OST_SETATTR, "ost_setattr" }, > - { OST_READ, "ost_read" }, > - { OST_WRITE, "ost_write" }, > - { OST_CREATE, "ost_create" }, > - { OST_DESTROY, "ost_destroy" }, > - { OST_GET_INFO, "ost_get_info" }, > - { OST_CONNECT, "ost_connect" }, > - { OST_DISCONNECT, "ost_disconnect" }, > - { OST_PUNCH, "ost_punch" }, > - { OST_OPEN, "ost_open" }, > - { OST_CLOSE, "ost_close" }, > - { OST_STATFS, "ost_statfs" }, > - { 14, NULL }, /* formerly OST_SAN_READ */ > - { 15, NULL }, /* formerly OST_SAN_WRITE */ > - { OST_SYNC, "ost_sync" }, > - { OST_SET_INFO, "ost_set_info" }, > - { OST_QUOTACHECK, "ost_quotacheck" }, > - { OST_QUOTACTL, "ost_quotactl" }, > - { OST_QUOTA_ADJUST_QUNIT, "ost_quota_adjust_qunit" }, > - { OST_LADVISE, "ost_ladvise" }, > - { MDS_GETATTR, "mds_getattr" }, > - { MDS_GETATTR_NAME, "mds_getattr_lock" }, > - { MDS_CLOSE, "mds_close" }, > - { MDS_REINT, "mds_reint" }, > - { MDS_READPAGE, "mds_readpage" }, > - { MDS_CONNECT, "mds_connect" }, > - { MDS_DISCONNECT, "mds_disconnect" }, > - { MDS_GET_ROOT, "mds_get_root" }, > - { MDS_STATFS, "mds_statfs" }, > - { MDS_PIN, "mds_pin" }, > - { MDS_UNPIN, "mds_unpin" }, > - { MDS_SYNC, "mds_sync" }, > - { MDS_DONE_WRITING, "mds_done_writing" }, > - { MDS_SET_INFO, "mds_set_info" }, > - { MDS_QUOTACHECK, "mds_quotacheck" }, > - { MDS_QUOTACTL, "mds_quotactl" }, > - { MDS_GETXATTR, "mds_getxattr" }, > - { MDS_SETXATTR, "mds_setxattr" }, > - { MDS_WRITEPAGE, "mds_writepage" }, > - { MDS_IS_SUBDIR, "mds_is_subdir" }, > - { MDS_GET_INFO, "mds_get_info" }, > - { MDS_HSM_STATE_GET, "mds_hsm_state_get" }, > - { MDS_HSM_STATE_SET, "mds_hsm_state_set" }, > - { MDS_HSM_ACTION, "mds_hsm_action" }, > - { MDS_HSM_PROGRESS, "mds_hsm_progress" }, > - { MDS_HSM_REQUEST, "mds_hsm_request" }, > - { MDS_HSM_CT_REGISTER, "mds_hsm_ct_register" }, > - { MDS_HSM_CT_UNREGISTER, "mds_hsm_ct_unregister" }, > - { MDS_SWAP_LAYOUTS, "mds_swap_layouts" }, > - { LDLM_ENQUEUE, "ldlm_enqueue" }, > - { LDLM_CONVERT, "ldlm_convert" }, > - { LDLM_CANCEL, "ldlm_cancel" }, > - { LDLM_BL_CALLBACK, "ldlm_bl_callback" }, > - { LDLM_CP_CALLBACK, "ldlm_cp_callback" }, > - { LDLM_GL_CALLBACK, "ldlm_gl_callback" }, > - { LDLM_SET_INFO, "ldlm_set_info" }, > - { MGS_CONNECT, "mgs_connect" }, > - { MGS_DISCONNECT, "mgs_disconnect" }, > - { MGS_EXCEPTION, "mgs_exception" }, > - { MGS_TARGET_REG, "mgs_target_reg" }, > - { MGS_TARGET_DEL, "mgs_target_del" }, > - { MGS_SET_INFO, "mgs_set_info" }, > - { MGS_CONFIG_READ, "mgs_config_read" }, > - { OBD_PING, "obd_ping" }, > - { OBD_LOG_CANCEL, "llog_cancel" }, > - { OBD_QC_CALLBACK, "obd_quota_callback" }, > - { OBD_IDX_READ, "dt_index_read" }, > - { LLOG_ORIGIN_HANDLE_CREATE, "llog_origin_handle_open" }, > - { LLOG_ORIGIN_HANDLE_NEXT_BLOCK, "llog_origin_handle_next_block" }, > - { LLOG_ORIGIN_HANDLE_READ_HEADER, "llog_origin_handle_read_header" }, > - { LLOG_ORIGIN_HANDLE_WRITE_REC, "llog_origin_handle_write_rec" }, > - { LLOG_ORIGIN_HANDLE_CLOSE, "llog_origin_handle_close" }, > - { LLOG_ORIGIN_CONNECT, "llog_origin_connect" }, > - { LLOG_CATINFO, "llog_catinfo" }, > - { LLOG_ORIGIN_HANDLE_PREV_BLOCK, "llog_origin_handle_prev_block" }, > - { LLOG_ORIGIN_HANDLE_DESTROY, "llog_origin_handle_destroy" }, > - { QUOTA_DQACQ, "quota_acquire" }, > - { QUOTA_DQREL, "quota_release" }, > - { SEQ_QUERY, "seq_query" }, > - { SEC_CTX_INIT, "sec_ctx_init" }, > - { SEC_CTX_INIT_CONT, "sec_ctx_init_cont" }, > - { SEC_CTX_FINI, "sec_ctx_fini" }, > - { FLD_QUERY, "fld_query" }, > - { FLD_READ, "fld_read" }, > + { OST_REPLY, "ost_reply" }, > + { OST_GETATTR, "ost_getattr" }, > + { OST_SETATTR, "ost_setattr" }, > + { OST_READ, "ost_read" }, > + { OST_WRITE, "ost_write" }, > + { OST_CREATE, "ost_create" }, > + { OST_DESTROY, "ost_destroy" }, > + { OST_GET_INFO, "ost_get_info" }, > + { OST_CONNECT, "ost_connect" }, > + { OST_DISCONNECT, "ost_disconnect" }, > + { OST_PUNCH, "ost_punch" }, > + { OST_OPEN, "ost_open" }, > + { OST_CLOSE, "ost_close" }, > + { OST_STATFS, "ost_statfs" }, > + { 14, NULL }, /* formerly OST_SAN_READ */ > + { 15, NULL }, /* formerly OST_SAN_WRITE */ > + { OST_SYNC, "ost_sync" }, > + { OST_SET_INFO, "ost_set_info" }, > + { OST_QUOTACHECK, "ost_quotacheck" }, > + { OST_QUOTACTL, "ost_quotactl" }, > + { OST_QUOTA_ADJUST_QUNIT, "ost_quota_adjust_qunit" }, > + { OST_LADVISE, "ost_ladvise" }, > + { MDS_GETATTR, "mds_getattr" }, > + { MDS_GETATTR_NAME, "mds_getattr_lock" }, > + { MDS_CLOSE, "mds_close" }, > + { MDS_REINT, "mds_reint" }, > + { MDS_READPAGE, "mds_readpage" }, > + { MDS_CONNECT, "mds_connect" }, > + { MDS_DISCONNECT, "mds_disconnect" }, > + { MDS_GET_ROOT, "mds_get_root" }, > + { MDS_STATFS, "mds_statfs" }, > + { MDS_PIN, "mds_pin" }, > + { MDS_UNPIN, "mds_unpin" }, > + { MDS_SYNC, "mds_sync" }, > + { MDS_DONE_WRITING, "mds_done_writing" }, > + { MDS_SET_INFO, "mds_set_info" }, > + { MDS_QUOTACHECK, "mds_quotacheck" }, > + { MDS_QUOTACTL, "mds_quotactl" }, > + { MDS_GETXATTR, "mds_getxattr" }, > + { MDS_SETXATTR, "mds_setxattr" }, > + { MDS_WRITEPAGE, "mds_writepage" }, > + { MDS_IS_SUBDIR, "mds_is_subdir" }, > + { MDS_GET_INFO, "mds_get_info" }, > + { MDS_HSM_STATE_GET, "mds_hsm_state_get" }, > + { MDS_HSM_STATE_SET, "mds_hsm_state_set" }, > + { MDS_HSM_ACTION, "mds_hsm_action" }, > + { MDS_HSM_PROGRESS, "mds_hsm_progress" }, > + { MDS_HSM_REQUEST, "mds_hsm_request" }, > + { MDS_HSM_CT_REGISTER, "mds_hsm_ct_register" }, > + { MDS_HSM_CT_UNREGISTER, "mds_hsm_ct_unregister" }, > + { MDS_SWAP_LAYOUTS, "mds_swap_layouts" }, > + { LDLM_ENQUEUE, "ldlm_enqueue" }, > + { LDLM_CONVERT, "ldlm_convert" }, > + { LDLM_CANCEL, "ldlm_cancel" }, > + { LDLM_BL_CALLBACK, "ldlm_bl_callback" }, > + { LDLM_CP_CALLBACK, "ldlm_cp_callback" }, > + { LDLM_GL_CALLBACK, "ldlm_gl_callback" }, > + { LDLM_SET_INFO, "ldlm_set_info" }, > + { MGS_CONNECT, "mgs_connect" }, > + { MGS_DISCONNECT, "mgs_disconnect" }, > + { MGS_EXCEPTION, "mgs_exception" }, > + { MGS_TARGET_REG, "mgs_target_reg" }, > + { MGS_TARGET_DEL, "mgs_target_del" }, > + { MGS_SET_INFO, "mgs_set_info" }, > + { MGS_CONFIG_READ, "mgs_config_read" }, > + { OBD_PING, "obd_ping" }, > + { OBD_LOG_CANCEL, "llog_cancel" }, > + { OBD_QC_CALLBACK, "obd_quota_callback" }, > + { OBD_IDX_READ, "dt_index_read" }, > + { LLOG_ORIGIN_HANDLE_CREATE, "llog_origin_handle_open" }, > + { LLOG_ORIGIN_HANDLE_NEXT_BLOCK, "llog_origin_handle_next_block" }, > + { LLOG_ORIGIN_HANDLE_READ_HEADER, "llog_origin_handle_read_header" }, > + { LLOG_ORIGIN_HANDLE_WRITE_REC, "llog_origin_handle_write_rec" }, > + { LLOG_ORIGIN_HANDLE_CLOSE, "llog_origin_handle_close" }, > + { LLOG_ORIGIN_CONNECT, "llog_origin_connect" }, > + { LLOG_CATINFO, "llog_catinfo" }, > + { LLOG_ORIGIN_HANDLE_PREV_BLOCK, "llog_origin_handle_prev_block" }, > + { LLOG_ORIGIN_HANDLE_DESTROY, "llog_origin_handle_destroy" }, > + { QUOTA_DQACQ, "quota_acquire" }, > + { QUOTA_DQREL, "quota_release" }, > + { SEQ_QUERY, "seq_query" }, > + { SEC_CTX_INIT, "sec_ctx_init" }, > + { SEC_CTX_INIT_CONT, "sec_ctx_init_cont" }, > + { SEC_CTX_FINI, "sec_ctx_fini" }, > + { FLD_QUERY, "fld_query" }, > + { FLD_READ, "fld_read" }, > }; > > static struct ll_eopcode { > - u32 opcode; > - const char *opname; > + u32 opcode; > + const char *opname; > } ll_eopcode_table[EXTRA_LAST_OPC] = { > - { LDLM_GLIMPSE_ENQUEUE, "ldlm_glimpse_enqueue" }, > - { LDLM_PLAIN_ENQUEUE, "ldlm_plain_enqueue" }, > - { LDLM_EXTENT_ENQUEUE, "ldlm_extent_enqueue" }, > - { LDLM_FLOCK_ENQUEUE, "ldlm_flock_enqueue" }, > - { LDLM_IBITS_ENQUEUE, "ldlm_ibits_enqueue" }, > - { MDS_REINT_SETATTR, "mds_reint_setattr" }, > - { MDS_REINT_CREATE, "mds_reint_create" }, > - { MDS_REINT_LINK, "mds_reint_link" }, > - { MDS_REINT_UNLINK, "mds_reint_unlink" }, > - { MDS_REINT_RENAME, "mds_reint_rename" }, > - { MDS_REINT_OPEN, "mds_reint_open" }, > - { MDS_REINT_SETXATTR, "mds_reint_setxattr" }, > - { BRW_READ_BYTES, "read_bytes" }, > - { BRW_WRITE_BYTES, "write_bytes" }, > + { LDLM_GLIMPSE_ENQUEUE, "ldlm_glimpse_enqueue" }, > + { LDLM_PLAIN_ENQUEUE, "ldlm_plain_enqueue" }, > + { LDLM_EXTENT_ENQUEUE, "ldlm_extent_enqueue" }, > + { LDLM_FLOCK_ENQUEUE, "ldlm_flock_enqueue" }, > + { LDLM_IBITS_ENQUEUE, "ldlm_ibits_enqueue" }, > + { MDS_REINT_SETATTR, "mds_reint_setattr" }, > + { MDS_REINT_CREATE, "mds_reint_create" }, > + { MDS_REINT_LINK, "mds_reint_link" }, > + { MDS_REINT_UNLINK, "mds_reint_unlink" }, > + { MDS_REINT_RENAME, "mds_reint_rename" }, > + { MDS_REINT_OPEN, "mds_reint_open" }, > + { MDS_REINT_SETXATTR, "mds_reint_setxattr" }, > + { BRW_READ_BYTES, "read_bytes" }, > + { BRW_WRITE_BYTES, "write_bytes" }, > }; > > const char *ll_opcode2str(u32 opcode) > @@ -450,13 +450,13 @@ static void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy, > > memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX); > > - info->pi_fallback = !!(policy->pol_flags & PTLRPC_NRS_FL_FALLBACK); > - info->pi_state = policy->pol_state; > + info->pi_fallback = !!(policy->pol_flags & PTLRPC_NRS_FL_FALLBACK); > + info->pi_state = policy->pol_state; > /** > * XXX: These are accessed without holding > * ptlrpc_service_part::scp_req_lock. > */ > - info->pi_req_queued = policy->pol_req_queued; > + info->pi_req_queued = policy->pol_req_queued; > info->pi_req_started = policy->pol_req_started; > } > > @@ -788,18 +788,18 @@ struct ptlrpc_srh_iterator { > /* convert position to sequence */ > #define PTLRPC_REQ_POS2SEQ(svc, pos) \ > ((svc)->srv_cpt_bits == 0 ? (pos) : \ > - ((u64)(pos) << (svc)->srv_cpt_bits) | \ > + ((u64)(pos) << (svc)->srv_cpt_bits) | \ > ((u64)(pos) >> (64 - (svc)->srv_cpt_bits))) > > static void * > ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos) > { > - struct ptlrpc_service *svc = s->private; > - struct ptlrpc_service_part *svcpt; > - struct ptlrpc_srh_iterator *srhi; > - unsigned int cpt; > - int rc; > - int i; > + struct ptlrpc_service *svc = s->private; > + struct ptlrpc_service_part *svcpt; > + struct ptlrpc_srh_iterator *srhi; > + unsigned int cpt; > + int rc; > + int i; > > if (sizeof(loff_t) != sizeof(u64)) { /* can't support */ > CWARN("Failed to read request history because size of loff_t %d can't match size of u64\n", > @@ -940,10 +940,10 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) > ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file) > { > static const struct seq_operations sops = { > - .start = ptlrpc_lprocfs_svc_req_history_start, > - .stop = ptlrpc_lprocfs_svc_req_history_stop, > - .next = ptlrpc_lprocfs_svc_req_history_next, > - .show = ptlrpc_lprocfs_svc_req_history_show, > + .start = ptlrpc_lprocfs_svc_req_history_start, > + .stop = ptlrpc_lprocfs_svc_req_history_stop, > + .next = ptlrpc_lprocfs_svc_req_history_next, > + .show = ptlrpc_lprocfs_svc_req_history_show, > }; > struct seq_file *seqf; > int rc; > @@ -975,9 +975,9 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) > } > > ptlrpc_service_for_each_part(svcpt, i, svc) { > - cur = at_get(&svcpt->scp_at_estimate); > - worst = svcpt->scp_at_estimate.at_worst_ever; > - worstt = svcpt->scp_at_estimate.at_worst_time; > + cur = at_get(&svcpt->scp_at_estimate); > + worst = svcpt->scp_at_estimate.at_worst_ever; > + worstt = svcpt->scp_at_estimate.at_worst_time; > s2dhms(&ts, ktime_get_real_seconds() - worstt); > > seq_printf(m, "%10s : cur %3u worst %3u (at %lld, " > @@ -1074,26 +1074,26 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry, > struct ptlrpc_service *svc) > { > struct lprocfs_vars lproc_vars[] = { > - {.name = "req_buffer_history_len", > - .fops = &ptlrpc_lprocfs_req_history_len_fops, > - .data = svc}, > - {.name = "req_buffer_history_max", > - .fops = &ptlrpc_lprocfs_req_history_max_fops, > - .data = svc}, > - {.name = "timeouts", > - .fops = &ptlrpc_lprocfs_timeouts_fops, > - .data = svc}, > - {.name = "nrs_policies", > - .fops = &ptlrpc_lprocfs_nrs_fops, > - .data = svc}, > - {NULL} > + { .name = "req_buffer_history_len", > + .fops = &ptlrpc_lprocfs_req_history_len_fops, > + .data = svc }, > + { .name = "req_buffer_history_max", > + .fops = &ptlrpc_lprocfs_req_history_max_fops, > + .data = svc }, > + { .name = "timeouts", > + .fops = &ptlrpc_lprocfs_timeouts_fops, > + .data = svc }, > + { .name = "nrs_policies", > + .fops = &ptlrpc_lprocfs_nrs_fops, > + .data = svc }, > + { NULL } > }; > static const struct file_operations req_history_fops = { > - .owner = THIS_MODULE, > - .open = ptlrpc_lprocfs_svc_req_history_open, > - .read = seq_read, > - .llseek = seq_lseek, > - .release = lprocfs_seq_release, > + .owner = THIS_MODULE, > + .open = ptlrpc_lprocfs_svc_req_history_open, > + .read = seq_read, > + .llseek = seq_lseek, > + .release = lprocfs_seq_release, > }; > > ptlrpc_ldebugfs_register(entry, svc->srv_name, > diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c > index d3044a7..ea7a7f9 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c > @@ -280,6 +280,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) > * timeout lets us CWARN for visibility of sluggish LNDs > */ > int cnt = 0; > + > while (cnt < LONG_UNLINK && > (rc = wait_event_idle_timeout(*wq, > !ptlrpc_client_bulk_active(req), > @@ -685,7 +686,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) > * add the network latency for our local timeout. > */ > request->rq_deadline = request->rq_sent + request->rq_timeout + > - ptlrpc_at_get_net_latency(request); > + ptlrpc_at_get_net_latency(request); > > ptlrpc_pinger_sending_on_import(imp); > > @@ -705,7 +706,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) > if (noreply) > goto out; > > - cleanup_me: > +cleanup_me: > /* MEUnlink is safe; the PUT didn't even get off the ground, and > * nobody apart from the PUT's target has the right nid+XID to > * access the reply buffer. > @@ -715,7 +716,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) > /* UNLINKED callback called synchronously */ > LASSERT(!request->rq_receiving_reply); > > - cleanup_bulk: > +cleanup_bulk: > /* We do sync unlink here as there was no real transfer here so > * the chance to have long unlink to sluggish net is smaller here. > */ > diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c > index 248ba04..ef7dd5d 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c > @@ -118,7 +118,6 @@ static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) > /* Immediately make it invisible */ > if (nrs->nrs_policy_primary == policy) { > nrs->nrs_policy_primary = NULL; > - > } else { > LASSERT(nrs->nrs_policy_fallback == policy); > nrs->nrs_policy_fallback = NULL; > diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > index 10c2520..5383b68 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > @@ -111,12 +111,12 @@ struct nrs_core { > * Protects nrs_core::nrs_policies, serializes external policy > * registration/unregistration, and NRS core lprocfs operations. > */ > - struct mutex nrs_mutex; > + struct mutex nrs_mutex; > /** > * List of all policy descriptors registered with NRS core; protected > * by nrs_core::nrs_mutex. > */ > - struct list_head nrs_policies; > + struct list_head nrs_policies; > > }; > > @@ -251,15 +251,15 @@ struct ptlrpc_reply_state * > void ptlrpc_pinger_wake_up(void); > > /* sec_null.c */ > -int sptlrpc_null_init(void); > +int sptlrpc_null_init(void); > void sptlrpc_null_fini(void); > > /* sec_plain.c */ > -int sptlrpc_plain_init(void); > +int sptlrpc_plain_init(void); > void sptlrpc_plain_fini(void); > > /* sec_bulk.c */ > -int sptlrpc_enc_pool_init(void); > +int sptlrpc_enc_pool_init(void); > void sptlrpc_enc_pool_fini(void); > int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v); > > @@ -277,11 +277,11 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, > struct obd_uuid *target, > lnet_nid_t nid, > struct sptlrpc_flavor *sf); > -int sptlrpc_conf_init(void); > +int sptlrpc_conf_init(void); > void sptlrpc_conf_fini(void); > > /* sec.c */ > -int sptlrpc_init(void); > +int sptlrpc_init(void); > void sptlrpc_fini(void); > > /* layout.c */ > diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c > index e39c38a..f0ac296 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c > @@ -69,13 +69,13 @@ > > /* One of these per CPT. */ > struct ptlrpcd { > - int pd_size; > - int pd_index; > - int pd_cpt; > - int pd_cursor; > - int pd_nthreads; > - int pd_groupsize; > - struct ptlrpcd_ctl pd_threads[0]; > + int pd_size; > + int pd_index; > + int pd_cpt; > + int pd_cursor; > + int pd_nthreads; > + int pd_groupsize; > + struct ptlrpcd_ctl pd_threads[0]; > }; > > /* > @@ -171,9 +171,9 @@ void ptlrpcd_wake(struct ptlrpc_request *req) > static struct ptlrpcd_ctl * > ptlrpcd_select_pc(struct ptlrpc_request *req) > { > - struct ptlrpcd *pd; > - int cpt; > - int idx; > + struct ptlrpcd *pd; > + int cpt; > + int idx; > > if (req && req->rq_send_state != LUSTRE_IMP_FULL) > return &ptlrpcd_rcv; > diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c > index ed769a4..af672ab 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c > @@ -119,6 +119,7 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) > */ > if (!req) { > struct ptlrpc_request *tmp; > + > list_for_each_entry_safe(tmp, pos, &imp->imp_replay_list, > rq_replay_list) { > if (tmp->rq_transno > last_transno) { > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c > index 165082a..6dc7731 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c > @@ -171,7 +171,7 @@ u32 sptlrpc_name2flavor_base(const char *name) > > const char *sptlrpc_flavor2name_base(u32 flvr) > { > - u32 base = SPTLRPC_FLVR_BASE(flvr); > + u32 base = SPTLRPC_FLVR_BASE(flvr); > > if (base == SPTLRPC_FLVR_BASE(SPTLRPC_FLVR_NULL)) > return "null"; > @@ -365,7 +365,7 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) > { > struct obd_import *imp = req->rq_import; > struct ptlrpc_sec *sec; > - int rc; > + int rc; > > LASSERT(!req->rq_cli_ctx); > LASSERT(imp); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c > index 93dcb6d..74cfdd8 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c > @@ -57,8 +57,8 @@ > #define POINTERS_PER_PAGE (PAGE_SIZE / sizeof(void *)) > #define PAGES_PER_POOL (POINTERS_PER_PAGE) > > -#define IDLE_IDX_MAX (100) > -#define IDLE_IDX_WEIGHT (3) > +#define IDLE_IDX_MAX (100) > +#define IDLE_IDX_WEIGHT (3) > > #define CACHE_QUIESCENT_PERIOD (20) > > @@ -66,16 +66,16 @@ > /* > * constants > */ > - unsigned long epp_max_pages; /* maximum pages can hold, const */ > - unsigned int epp_max_pools; /* number of pools, const */ > + unsigned long epp_max_pages; /* maximum pages can hold, const */ > + unsigned int epp_max_pools; /* number of pools, const */ > > /* > * wait queue in case of not enough free pages. > */ > - wait_queue_head_t epp_waitq; /* waiting threads */ > - unsigned int epp_waitqlen; /* wait queue length */ > - unsigned long epp_pages_short; /* # of pages wanted of in-q users */ > - unsigned int epp_growing:1; /* during adding pages */ > + wait_queue_head_t epp_waitq; /* waiting threads */ > + unsigned int epp_waitqlen; /* wait queue length */ > + unsigned long epp_pages_short; /* # of pages wanted of in-q users */ > + unsigned int epp_growing:1; /* during adding pages */ > > /* > * indicating how idle the pools are, from 0 to MAX_IDLE_IDX > @@ -84,36 +84,36 @@ > * is idled for a while but the idle_idx might still be low if no > * activities happened in the pools. > */ > - unsigned long epp_idle_idx; > + unsigned long epp_idle_idx; > > /* last shrink time due to mem tight */ > - time64_t epp_last_shrink; > - time64_t epp_last_access; > + time64_t epp_last_shrink; > + time64_t epp_last_access; > > /* > * in-pool pages bookkeeping > */ > - spinlock_t epp_lock; /* protect following fields */ > - unsigned long epp_total_pages; /* total pages in pools */ > - unsigned long epp_free_pages; /* current pages available */ > + spinlock_t epp_lock; /* protect following fields */ > + unsigned long epp_total_pages; /* total pages in pools */ > + unsigned long epp_free_pages; /* current pages available */ > > /* > * statistics > */ > - unsigned long epp_st_max_pages; /* # of pages ever reached */ > - unsigned int epp_st_grows; /* # of grows */ > - unsigned int epp_st_grow_fails; /* # of add pages failures */ > - unsigned int epp_st_shrinks; /* # of shrinks */ > - unsigned long epp_st_access; /* # of access */ > - unsigned long epp_st_missings; /* # of cache missing */ > - unsigned long epp_st_lowfree; /* lowest free pages reached */ > - unsigned int epp_st_max_wqlen; /* highest waitqueue length */ > - unsigned long epp_st_max_wait; /* in jiffies */ > - unsigned long epp_st_outofmem; /* # of out of mem requests */ > + unsigned long epp_st_max_pages; /* # of pages ever reached */ > + unsigned int epp_st_grows; /* # of grows */ > + unsigned int epp_st_grow_fails; /* # of add pages failures */ > + unsigned int epp_st_shrinks; /* # of shrinks */ > + unsigned long epp_st_access; /* # of access */ > + unsigned long epp_st_missings; /* # of cache missing */ > + unsigned long epp_st_lowfree; /* lowest free pages reached */ > + unsigned int epp_st_max_wqlen; /* highest waitqueue length */ > + unsigned long epp_st_max_wait; /* in jiffies */ > + unsigned long epp_st_outofmem; /* # of out of mem requests */ > /* > * pointers to pools > */ > - struct page ***epp_pools; > + struct page ***epp_pools; > } page_pools; > > /* > @@ -394,9 +394,9 @@ static inline void enc_pools_free(void) > } > > static struct shrinker pools_shrinker = { > - .count_objects = enc_pools_shrink_count, > - .scan_objects = enc_pools_shrink_scan, > - .seeks = DEFAULT_SEEKS, > + .count_objects = enc_pools_shrink_count, > + .scan_objects = enc_pools_shrink_scan, > + .seeks = DEFAULT_SEEKS, > }; > > int sptlrpc_enc_pool_init(void) > @@ -475,14 +475,14 @@ void sptlrpc_enc_pool_fini(void) > } > > static int cfs_hash_alg_id[] = { > - [BULK_HASH_ALG_NULL] = CFS_HASH_ALG_NULL, > - [BULK_HASH_ALG_ADLER32] = CFS_HASH_ALG_ADLER32, > - [BULK_HASH_ALG_CRC32] = CFS_HASH_ALG_CRC32, > - [BULK_HASH_ALG_MD5] = CFS_HASH_ALG_MD5, > - [BULK_HASH_ALG_SHA1] = CFS_HASH_ALG_SHA1, > - [BULK_HASH_ALG_SHA256] = CFS_HASH_ALG_SHA256, > - [BULK_HASH_ALG_SHA384] = CFS_HASH_ALG_SHA384, > - [BULK_HASH_ALG_SHA512] = CFS_HASH_ALG_SHA512, > + [BULK_HASH_ALG_NULL] = CFS_HASH_ALG_NULL, > + [BULK_HASH_ALG_ADLER32] = CFS_HASH_ALG_ADLER32, > + [BULK_HASH_ALG_CRC32] = CFS_HASH_ALG_CRC32, > + [BULK_HASH_ALG_MD5] = CFS_HASH_ALG_MD5, > + [BULK_HASH_ALG_SHA1] = CFS_HASH_ALG_SHA1, > + [BULK_HASH_ALG_SHA256] = CFS_HASH_ALG_SHA256, > + [BULK_HASH_ALG_SHA384] = CFS_HASH_ALG_SHA384, > + [BULK_HASH_ALG_SHA512] = CFS_HASH_ALG_SHA512, > }; > > const char *sptlrpc_get_hash_name(u8 hash_alg) > @@ -498,7 +498,7 @@ u8 sptlrpc_get_hash_alg(const char *algname) > int bulk_sec_desc_unpack(struct lustre_msg *msg, int offset, int swabbed) > { > struct ptlrpc_bulk_sec_desc *bsd; > - int size = msg->lm_buflens[offset]; > + int size = msg->lm_buflens[offset]; > > bsd = lustre_msg_buf(msg, offset, sizeof(*bsd)); > if (!bsd) { > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c > index 1844ada..54130ae 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c > @@ -408,19 +408,19 @@ static int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset, > **********************************/ > > struct sptlrpc_conf_tgt { > - struct list_head sct_list; > - char sct_name[MAX_OBD_NAME]; > - struct sptlrpc_rule_set sct_rset; > + struct list_head sct_list; > + char sct_name[MAX_OBD_NAME]; > + struct sptlrpc_rule_set sct_rset; > }; > > struct sptlrpc_conf { > - struct list_head sc_list; > - char sc_fsname[MTI_NAME_MAXLEN]; > - unsigned int sc_modified; /* modified during updating */ > - unsigned int sc_updated:1, /* updated copy from MGS */ > - sc_local:1; /* local copy from target */ > - struct sptlrpc_rule_set sc_rset; /* fs general rules */ > - struct list_head sc_tgts; /* target-specific rules */ > + struct list_head sc_list; > + char sc_fsname[MTI_NAME_MAXLEN]; > + unsigned int sc_modified; /* modified during updating */ > + unsigned int sc_updated:1, /* updated copy from MGS */ > + sc_local:1; /* local copy from target */ > + struct sptlrpc_rule_set sc_rset; /* fs general rules */ > + struct list_head sc_tgts; /* target-specific rules */ > }; > > static struct mutex sptlrpc_conf_lock; > @@ -801,7 +801,7 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, > flavor_set_flags(sf, from, to, 1); > } > > -#define SEC_ADAPT_DELAY (10) > +#define SEC_ADAPT_DELAY (10) > > /** > * called by client devices, notify the sptlrpc config has changed and > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c > index 6933a53..df6ef4f 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c > @@ -277,8 +277,8 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, > } > > static struct ptlrpc_svc_ctx null_svc_ctx = { > - .sc_refcount = ATOMIC_INIT(1), > - .sc_policy = &null_policy, > + .sc_refcount = ATOMIC_INIT(1), > + .sc_policy = &null_policy, > }; > > static > @@ -373,33 +373,33 @@ int null_authorize(struct ptlrpc_request *req) > > static struct ptlrpc_ctx_ops null_ctx_ops = { > .refresh = null_ctx_refresh, > - .sign = null_ctx_sign, > - .verify = null_ctx_verify, > + .sign = null_ctx_sign, > + .verify = null_ctx_verify, > }; > > static struct ptlrpc_sec_cops null_sec_cops = { > - .create_sec = null_create_sec, > - .destroy_sec = null_destroy_sec, > - .lookup_ctx = null_lookup_ctx, > + .create_sec = null_create_sec, > + .destroy_sec = null_destroy_sec, > + .lookup_ctx = null_lookup_ctx, > .flush_ctx_cache = null_flush_ctx_cache, > - .alloc_reqbuf = null_alloc_reqbuf, > - .alloc_repbuf = null_alloc_repbuf, > - .free_reqbuf = null_free_reqbuf, > - .free_repbuf = null_free_repbuf, > - .enlarge_reqbuf = null_enlarge_reqbuf, > + .alloc_reqbuf = null_alloc_reqbuf, > + .alloc_repbuf = null_alloc_repbuf, > + .free_reqbuf = null_free_reqbuf, > + .free_repbuf = null_free_repbuf, > + .enlarge_reqbuf = null_enlarge_reqbuf, > }; > > static struct ptlrpc_sec_sops null_sec_sops = { > - .accept = null_accept, > - .alloc_rs = null_alloc_rs, > - .authorize = null_authorize, > + .accept = null_accept, > + .alloc_rs = null_alloc_rs, > + .authorize = null_authorize, > .free_rs = null_free_rs, > }; > > static struct ptlrpc_sec_policy null_policy = { > - .sp_owner = THIS_MODULE, > + .sp_owner = THIS_MODULE, > .sp_name = "sec.null", > - .sp_policy = SPTLRPC_POLICY_NULL, > + .sp_policy = SPTLRPC_POLICY_NULL, > .sp_cops = &null_sec_cops, > .sp_sops = &null_sec_sops, > }; > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c > index 0a31ff4..021bf7f 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c > @@ -46,9 +46,9 @@ > #include "ptlrpc_internal.h" > > struct plain_sec { > - struct ptlrpc_sec pls_base; > - rwlock_t pls_lock; > - struct ptlrpc_cli_ctx *pls_ctx; > + struct ptlrpc_sec pls_base; > + rwlock_t pls_lock; > + struct ptlrpc_cli_ctx *pls_ctx; > }; > > static inline struct plain_sec *sec2plsec(struct ptlrpc_sec *sec) > @@ -65,15 +65,15 @@ static inline struct plain_sec *sec2plsec(struct ptlrpc_sec *sec) > /* > * for simplicity, plain policy rpc use fixed layout. > */ > -#define PLAIN_PACK_SEGMENTS (4) > +#define PLAIN_PACK_SEGMENTS (4) > > -#define PLAIN_PACK_HDR_OFF (0) > -#define PLAIN_PACK_MSG_OFF (1) > -#define PLAIN_PACK_USER_OFF (2) > -#define PLAIN_PACK_BULK_OFF (3) > +#define PLAIN_PACK_HDR_OFF (0) > +#define PLAIN_PACK_MSG_OFF (1) > +#define PLAIN_PACK_USER_OFF (2) > +#define PLAIN_PACK_BULK_OFF (3) > > -#define PLAIN_FL_USER (0x01) > -#define PLAIN_FL_BULK (0x02) > +#define PLAIN_FL_USER (0x01) > +#define PLAIN_FL_BULK (0x02) > > struct plain_header { > u8 ph_ver; /* 0 */ > @@ -711,8 +711,8 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, > ****************************************/ > > static struct ptlrpc_svc_ctx plain_svc_ctx = { > - .sc_refcount = ATOMIC_INIT(1), > - .sc_policy = &plain_policy, > + .sc_refcount = ATOMIC_INIT(1), > + .sc_policy = &plain_policy, > }; > > static > @@ -961,40 +961,40 @@ int plain_svc_wrap_bulk(struct ptlrpc_request *req, > > static struct ptlrpc_ctx_ops plain_ctx_ops = { > .refresh = plain_ctx_refresh, > - .validate = plain_ctx_validate, > - .sign = plain_ctx_sign, > - .verify = plain_ctx_verify, > - .wrap_bulk = plain_cli_wrap_bulk, > - .unwrap_bulk = plain_cli_unwrap_bulk, > + .validate = plain_ctx_validate, > + .sign = plain_ctx_sign, > + .verify = plain_ctx_verify, > + .wrap_bulk = plain_cli_wrap_bulk, > + .unwrap_bulk = plain_cli_unwrap_bulk, > }; > > static struct ptlrpc_sec_cops plain_sec_cops = { > - .create_sec = plain_create_sec, > - .destroy_sec = plain_destroy_sec, > - .kill_sec = plain_kill_sec, > - .lookup_ctx = plain_lookup_ctx, > - .release_ctx = plain_release_ctx, > + .create_sec = plain_create_sec, > + .destroy_sec = plain_destroy_sec, > + .kill_sec = plain_kill_sec, > + .lookup_ctx = plain_lookup_ctx, > + .release_ctx = plain_release_ctx, > .flush_ctx_cache = plain_flush_ctx_cache, > - .alloc_reqbuf = plain_alloc_reqbuf, > - .free_reqbuf = plain_free_reqbuf, > - .alloc_repbuf = plain_alloc_repbuf, > - .free_repbuf = plain_free_repbuf, > - .enlarge_reqbuf = plain_enlarge_reqbuf, > + .alloc_reqbuf = plain_alloc_reqbuf, > + .free_reqbuf = plain_free_reqbuf, > + .alloc_repbuf = plain_alloc_repbuf, > + .free_repbuf = plain_free_repbuf, > + .enlarge_reqbuf = plain_enlarge_reqbuf, > }; > > static struct ptlrpc_sec_sops plain_sec_sops = { > - .accept = plain_accept, > - .alloc_rs = plain_alloc_rs, > - .authorize = plain_authorize, > + .accept = plain_accept, > + .alloc_rs = plain_alloc_rs, > + .authorize = plain_authorize, > .free_rs = plain_free_rs, > - .unwrap_bulk = plain_svc_unwrap_bulk, > - .wrap_bulk = plain_svc_wrap_bulk, > + .unwrap_bulk = plain_svc_unwrap_bulk, > + .wrap_bulk = plain_svc_wrap_bulk, > }; > > static struct ptlrpc_sec_policy plain_policy = { > - .sp_owner = THIS_MODULE, > + .sp_owner = THIS_MODULE, > .sp_name = "plain", > - .sp_policy = SPTLRPC_POLICY_PLAIN, > + .sp_policy = SPTLRPC_POLICY_PLAIN, > .sp_cops = &plain_sec_cops, > .sp_sops = &plain_sec_sops, > }; > diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c > index 1030f65..5b97f2a 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/service.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c > @@ -173,7 +173,7 @@ > svc->srv_name, i, svc->srv_buf_size, svcpt->scp_nrqbds_posted, > svcpt->scp_nrqbds_total, rc); > > - try_post: > +try_post: > if (post && rc == 0) > rc = ptlrpc_server_post_idle_rqbds(svcpt); > > @@ -185,8 +185,8 @@ > struct ptlrpc_hr_thread { > int hrt_id; /* thread ID */ > spinlock_t hrt_lock; > - wait_queue_head_t hrt_waitq; > - struct list_head hrt_queue; /* RS queue */ > + wait_queue_head_t hrt_waitq; > + struct list_head hrt_queue; /* RS queue */ > struct ptlrpc_hr_partition *hrt_partition; > }; > > @@ -212,7 +212,7 @@ struct ptlrpc_hr_service { > /* CPU partition table, it's just cfs_cpt_tab for now */ > struct cfs_cpt_table *hr_cpt_table; > /** controller sleep waitq */ > - wait_queue_head_t hr_waitq; > + wait_queue_head_t hr_waitq; > unsigned int hr_stopping; > /** roundrobin rotor for non-affinity service */ > unsigned int hr_rotor; > @@ -236,7 +236,6 @@ struct ptlrpc_hr_service { > svcpt->scp_service->srv_cptable == ptlrpc_hr.hr_cpt_table) { > /* directly match partition */ > hrp = ptlrpc_hr.hr_partitions[svcpt->scp_cpt]; > - > } else { > rotor = ptlrpc_hr.hr_rotor++; > rotor %= cfs_cpt_number(ptlrpc_hr.hr_cpt_table); > @@ -440,7 +439,7 @@ static void ptlrpc_at_timer(struct timer_list *t) > nthrs = max(tc->tc_nthrs_base, > tc->tc_nthrs_max / svc->srv_ncpts); > } > - out: > +out: > nthrs = max(nthrs, tc->tc_nthrs_init); > svc->srv_nthrs_cpt_limit = nthrs; > svc->srv_nthrs_cpt_init = init; > @@ -459,7 +458,7 @@ static void ptlrpc_at_timer(struct timer_list *t) > ptlrpc_service_part_init(struct ptlrpc_service *svc, > struct ptlrpc_service_part *svcpt, int cpt) > { > - struct ptlrpc_at_array *array; > + struct ptlrpc_at_array *array; > int size; > int index; > int rc; > @@ -1125,7 +1124,6 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) > goto out_put; > > rc = ptlrpc_send_reply(reqcopy, PTLRPC_REPLY_EARLY); > - > if (!rc) { > /* Adjust our own deadline to what we told the client */ > req->rq_deadline = newdl; > @@ -1316,7 +1314,7 @@ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req) > static int ptlrpc_server_request_add(struct ptlrpc_service_part *svcpt, > struct ptlrpc_request *req) > { > - int rc; > + int rc; > > rc = ptlrpc_server_hpreq_init(svcpt, req); > if (rc < 0) > @@ -2412,7 +2410,7 @@ int ptlrpc_start_threads(struct ptlrpc_service *svc) > } > > return 0; > - failed: > +failed: > CERROR("cannot start %s thread #%d_%d: rc %d\n", > svc->srv_thread_name, i, j, rc); > ptlrpc_stop_all_threads(svc); > @@ -2432,7 +2430,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) > svc->srv_name, svcpt->scp_cpt, svcpt->scp_nthrs_running, > svc->srv_nthrs_cpt_init, svc->srv_nthrs_cpt_limit); > > - again: > +again: > if (unlikely(svc->srv_is_stopping)) > return -ESRCH; > > -- > 1.8.3.1 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From adilger at whamcloud.com Mon Feb 4 07:36:25 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 4 Feb 2019 07:36:25 +0000 Subject: [lustre-devel] Run acceptance tests on client side only In-Reply-To: <9E0B8A72-3AFF-4141-8E94-28AF402B0CC9@amazon.com> References: <9E0B8A72-3AFF-4141-8E94-28AF402B0CC9@amazon.com> Message-ID: <10A6B545-A2DD-4DB7-A8DE-6FFE2D174A6A@whamcloud.com> On Jan 30, 2019, at 07:53, Degremont, Aurelien wrote: > > Hello > > I’m trying to run test suites without having access to servers. > A lot of tests in acc-sm assume that servers are reachable. Is there way to automatically skip these tests? > > Does somebody has a smart way to run acc-sm? Aurelien, at one time in the past it was possible to run sanity and runtests only on the client by setting "CLIENTONLY=yes". However, this isn't commonly used so is likely missing from a bunch of subtests. There are also checks in some subtests "remote_mds_nodsh" and/or "remote_ost_nodsh" to skip tests that depend on remote access to the servers when the MDS is not accessible from the client. This is not _exactly_ the same as CLIENTONLY in that they are still run if the MDS/OSS are running on the same node as the client. If running tests in this manner is of interest to you, patches would be welcome to add test skips as needed to get this working again. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 4 08:44:27 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 4 Feb 2019 08:44:27 +0000 Subject: [lustre-devel] [PATCH 00/26] lustre: cleanups with no code changes In-Reply-To: <1548955170-13456-1-git-send-email-jsimmons@infradead.org> References: <1548955170-13456-1-git-send-email-jsimmons@infradead.org> Message-ID: <06C4519C-E507-463B-8119-53270093A3D8@whamcloud.com> On Jan 31, 2019, at 10:19, James Simmons wrote: > > > 192 files changed, 6805 insertions(+), 6827 deletions(-) Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From green at whamcloud.com Mon Feb 4 17:10:08 2019 From: green at whamcloud.com (Oleg Drokin) Date: Mon, 4 Feb 2019 17:10:08 +0000 Subject: [lustre-devel] New tag 2.12.51 Message-ID: <56386C0E-6303-44AF-8205-99E90961977A@whamcloud.com> Hello! I just tagged 2.12.51 tag in lustre community development branch. here’s the changelog: Alex Zhuravlev (3): LU-11737 lfsck: do not ignore dryrun LU-10953 tests: disable sanity/300k on small setups LU-11889 tests: disable sanity/156 for ZFS OST Alexander Boyko (2): LU-11716 tests: fix scrub tests LU-11852 osc: skip cache entry wakeup without grants Amir Shehata (1): LU-11415 socklnd: improve scheduling algorithm Andreas Dilger (18): LU-11453 misc: add compat for INIT_LIST_HEAD_RCU LU-11398 ptlrpc: clean up rq_interpret_reply callbacks LU-11579 lov: quiet lov_dump_lmm_ console messages LU-11736 utils: don't set max_sectors_kb on MDT/MGT LU-11771 osd: avoid use of HZ in brw_stats LU-8066 lnet: properly isolate kernel_param_ops LU-11820 tests: skip conf-sanity test_106 for SLOW=no LU-11579 llite: remove cl_file_inode_init() LASSERT LU-11810 misc: allow Fixes: tag in commit signoff block LU-11834 llite: fix temporary instance buffer size LU-11625 ofd: handle upgraded filter_fid properly LU-11845 zfs: put configure checks in version order LU-11665 tests: check number of pages correctly LU-11566 utils: fix lctl llog_print for large configs LU-11770 osd-ldiskfs: clean up inline macro usage LU-8066 ldlm: match store macro prototype LU-930 doc: move server man pages to server package LU-11721 tests: wait for statfs to update on DNE Andrew Perepechko (1): LU-11296 osc: speed up page cache cleanup during blocking ASTs Andriy Skulysh (4): LU-11699 lfsck: Umount while running LFSCK LU-11700 osp: GPF in osp_reserved_mb_low_seq_write() LU-11757 lod: use calculated stripe count LU-7558 ptlrpc: connect vs import invalidate race Arshad Hussain (10): LU-6142 lmv: Fix style issues for lmv_fld.c LU-6142 lod: Fix style issues for lod_dev.c LU-6142 mgs: Fix style issues for mgs_fs.c LU-6142 llite: Fix style issues for glimpse.c LU-6142 llite: Fix style issues for llite_nfs.c LU-6142 llite: Fix style issues for lcommon_misc.c LU-6142 llite: Fix style issues for symlink.c LU-11606 utils: Call llapi_error() for errors in liblustreapi files LU-9010 ptlrpc: Change static defines to use macro for gss_svc_upcall.c LU-9010 tests: Change static defines to use macro for kinode.c Artem Blagodarenko (5): LU-10384 mgs: replace_nids large string and failover support LU-10883 llog: fix backup file name comparison LU-7159 tests: fix 224c fault injection LU-1365 utils: allow set block size for ldiskfs backend LU-1365 tests: LARGEDIR and 3-level htree for local ldiskfs Ben Evans (1): LU-10171 headers: define pct(a,b) once Bobi Jam (1): LU-10239 osc: limit chunk number of write submit Chris Horn (1): LU-11712 osd-ldiskfs: Wrap blk integrity with config check Elena Gryaznova (7): LU-11078 tests: customise run_ior() LU-11503 tests: fix "division by 0" defect LU-11504 tests: trigger lfsck after/during failover/failback LU-11717 tests: exit_status () defect LU-10815 tests: all_mdts_nodes() all_osts_nodes() defect LU-11496 tests: start_client_loads () fix LU-11843 tests: customise sanity-quota George Melikov (1): LU-10966 utils: Fix `lfs check` documentation and arguments Gu Zheng (1): LU-11575 build: install systemd stuff only for debian with systemd enabled Hongchao Zhang (1): LU-11647 ptlrpc: always unregister bulk James Nunez (6): LU-7631 tests: add debug info to conf-sanity 82a LU-10447 tests: deprecate $SETSTRIPE/$GETSTRIPE in sanity LU-11402 tests: add version check sanity-quota 60 LU-10447 tests: replace $SET/$GETSTRIPE in replay tests LU-11607 tests: create routine to get Lustre env LU-11161 tests: start running sanity 160g again James Simmons (8): LU-7004 mgs: remove using obdname2fsname() from mgs layer. LU-8066 obdclass: report all obd states for OBD_IOC_GETDEVICE LU-8066 mdd: migrate from proc to sysfs LU-8066 sysfs: make ping sysfs file read and writable LU-10937 sptlrpc: split sptlrpc_process_config() LU-9325 msg: replace obsolete simple_strtoul use LU-11838 kernel: harden current_time autoconf test LU-11828 clio: fix incorrect invariant in cl_io_iter_fini() Jeremy Filizetti (1): LU-10866 pacemaker: Support additional mount options Jian Yu (3): LU-11669 tests: add project in yml_test_group() LU-11723 kernel: kernel update RHEL7.6 [3.10.0-957.1.3.el7] LU-11739 lod: don't inherit default layout from root directory John L. Hammond (1): LU-10862 ldlm: remove trace from ldlm_pool_{count,skrink}() Kit Westneat (1): LU-8939 nodemap: remove deprecated lproc files Lai Siyao (3): LU-11620 lfsck: change llsd_rb_lock to rwsemaphore LU-11661 test: improve sanityn test_47g LU-11418 mdd: delete name if orphan doesn't exist Li Dongyang (1): LU-11790 ldiskfs: add terminating u32 when expanding inodes Nathaniel Clark (2): LU-11683 build: Update ZFS to 0.7.12 LU-11555 utils: ZFS check multihost enabled in read_ldd() NeilBrown (4): LU-11838 lustre: discard LTIME_S macro LU-11838 lnet: change lnet_ipaddr_enumerate() to use for_each_netdev() LU-9859 libcfs: add watchdog for ptlrpc service threads. LU-11838 o2iblnd: get IP address more directly. Nikitas Angelinas (2): LU-11755 ldlm: remove LASSERT() in ns_is_{client,server}() LU-11721 utils: print used inodes ratio when using "lfs df -i" Olaf Faaland (1): LU-7239 mdd: make mdd_attr_set() synchronous less often Oleg Drokin (1): New tag 2.12.51 Patrick Farrell (5): LU-11719 ldlm: Adjust search_* functions LU-10070 tests: Fix replay-single test_85b LU-11825 clio: Remove pio feature LU-11868 mdc: Improve xattr buffer allocations LU-10059 tests: sanityn 32a restore parameters Qian Yingjin (1): LU-11696 utils: "lfs getsom" returns "24" to userspace Sebastien Buisson (5): LU-11750 krb5: krb5int_derive_key has 'hash' extra parameter LU-8955 cfg: reserve flags for SELinux status checking LU-8955 nodemap: add SELinux policy info to nodemap LU-8955 sec: create new function sptlrpc_get_sepol() LU-11871 doc: man page for lctl nodemap_set_fileset Sergey Cheremencev (2): LU-11537 osp: avoid nested transaction LU-11605 osp: max_create_count and create_count changes Wang Shilong (1): LU-11689 lfs: make sure project proceed all dirs Yang Sheng (2): LU-11658 lov: cl_cache could miss initialize LU-11658 tests: fix typo in previous patch From lochoa at whamcloud.com Mon Feb 4 18:26:42 2019 From: lochoa at whamcloud.com (Leonel Ochoa) Date: Mon, 4 Feb 2019 18:26:42 +0000 Subject: [lustre-devel] Maloo Unscheduled Maintenance In-Reply-To: <6DF7A165-B104-4A84-92F3-85770D7D7D7A@ddn.com> References: <6DF7A165-B104-4A84-92F3-85770D7D7D7A@ddn.com> Message-ID: <4DCFCF25-8AC4-47B0-9D1F-EB62AEBE0598@ddn.com> FINAL UPDATE: The Maloo server has been running nominally since last week, results data is available going back to Jan 2017, the remaining sub test and test log results from 2016 will be ingested overnight Lee Ochoa lochoa at whamcloud.com From: lustre-devel on behalf of Leonel Ochoa Date: Thursday, January 31, 2019 at 17:44 To: "lustre-devel at lists.lustre.org" Subject: Re: [lustre-devel] Maloo Unscheduled Maintenance UPDATE: At this point we’re all caught up with all sessions that were pending. If you notice a session missing between 1/19 and now, or a missing gerrit score please feel free to reach out and we can work on troubleshooting missing results/scores. At this point the only missing data is sub tests and test logs EARLIER than 1/19, this will populate slowly and I’ll announce once they’re all ingested. Lee Ochoa lochoa at whamcloud.com From: lustre-devel on behalf of Leonel Ochoa Date: Wednesday, January 30, 2019 at 21:49 To: "lustre-devel at lists.lustre.org" Subject: Re: [lustre-devel] Maloo Unscheduled Maintenance UPDATE: Maloo is back up…but not fully restored yet. For the time being you’ll notice the following things: 1. Test queue pages DO show accurate state of ongoing tests in Autotest 2. The main test session page is missing results from 1/19 – 1/30, these results will start getting ingested from oldest to newest, please be patient and all results will eventually show up 3. For test sessions EARLIER than 1/19, sub test and test log pages are missing and will slowly populate, also from oldest to newest, also please be patient I’ll be sending periodic updates as we fill in the missing data Lee Ochoa lochoa at whamcloud.com From: Leonel Ochoa Date: Tuesday, January 29, 2019 at 14:12 To: "lustre-devel at lists.lustre.org" Subject: Maloo Unscheduled Maintenance NOTICE TO ALL MALOO USERS The Maloo web server has been down since yesterday 1/28 due to unscheduled maintenance, at present we expect the downtime to last all of today 1/29 and possibly tomorrow 1/30 as well. Once service has been restored we’ll post a notification to this mailing list. Gerrit can still receive patches and Autotest will continue to run test sessions while Maloo remains offline, once the server is back up all pending results and gerrit +/- notifications (from Maloo) will be sent for all completed tests. Thank you for your patience. Lee Ochoa lochoa at whamcloud.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From degremoa at amazon.com Tue Feb 5 17:09:23 2019 From: degremoa at amazon.com (Degremont, Aurelien) Date: Tue, 5 Feb 2019 17:09:23 +0000 Subject: [lustre-devel] Run acceptance tests on client side only In-Reply-To: <10A6B545-A2DD-4DB7-A8DE-6FFE2D174A6A@whamcloud.com> References: <9E0B8A72-3AFF-4141-8E94-28AF402B0CC9@amazon.com> <10A6B545-A2DD-4DB7-A8DE-6FFE2D174A6A@whamcloud.com> Message-ID: <61A33E81-F7E8-450B-A3A5-81D52B4A1E95@amazon.com> Thanks Andreas for this info. I will look at the scripts and see if we want to go deeper in this direction. Aurélien Le 04/02/2019 08:37, « Andreas Dilger » a écrit : On Jan 30, 2019, at 07:53, Degremont, Aurelien wrote: > > Hello > > I’m trying to run test suites without having access to servers. > A lot of tests in acc-sm assume that servers are reachable. Is there way to automatically skip these tests? > > Does somebody has a smart way to run acc-sm? Aurelien, at one time in the past it was possible to run sanity and runtests only on the client by setting "CLIENTONLY=yes". However, this isn't commonly used so is likely missing from a bunch of subtests. There are also checks in some subtests "remote_mds_nodsh" and/or "remote_ost_nodsh" to skip tests that depend on remote access to the servers when the MDS is not accessible from the client. This is not _exactly_ the same as CLIENTONLY in that they are still run if the MDS/OSS are running on the same node as the client. If running tests in this manner is of interest to you, patches would be welcome to add test skips as needed to get this working again. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From neilb at suse.com Thu Feb 7 00:03:32 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:32 +1100 Subject: [lustre-devel] [PATCH 00/21] lustre: Assorted cleanups for obdclass Message-ID: <154949776249.10620.1215070753973826063.stgit@noble.brown> I've been reading through obdclass and writing patches as I go. I'm not done yet, but this patch set to big enough to send for review. NeilBrown --- NeilBrown (21): lustre: obdclass: discard csi_end_io lustre: obd_class: remove csi_barrier from struct cl_sync_io lustre: obdclass: use list_sort() to sort a list. lustre: use list*entry macros in place of container_of() lustre: use list_first_entry() in lustre subdirectory. lustre: use list_first_entry() in lnet/lnet subdirectory. lustre: use list_first_entry() in lnet/klnds subdirectory. lustre: use list_first_entry() throughout lustre: use list_last_entry() throughout lustre: obdclass: use cl_object_for_each where appropriate lustre: cl_object: remove vestigial debugging. lustre: cl_page.c: remove PINVRNT() lustre: make cp_ref in cl_page a refcount_t lustre: make ccc_users in cl_client_cache a refcount_t lustre: obdclass: char obd_ioctl_getdata type. lustre: obdclass: normalize a switch statement. lustre: obdclass: result of try_module_get() should not be ignored. lustre: move debug.c from obdclass to obdecho lustre: obdclass: avoid races in class_register_type() lustre: obdclass: fix module load locking. lustre: make exp_refcount in obd_export a refcount_t .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 19 ++- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 61 ++++++----- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 9 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 79 +++++++------- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 4 - drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 12 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 111 ++++++++++---------- drivers/staging/lustre/lnet/lnet/config.c | 22 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 53 +++++----- drivers/staging/lustre/lnet/lnet/lib-msg.c | 16 +-- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 7 + drivers/staging/lustre/lnet/lnet/net_fault.c | 24 ++-- drivers/staging/lustre/lnet/lnet/nidstrings.c | 9 +- drivers/staging/lustre/lnet/lnet/peer.c | 24 ++-- drivers/staging/lustre/lnet/lnet/router.c | 13 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 5 - drivers/staging/lustre/lnet/selftest/console.c | 39 +++---- drivers/staging/lustre/lnet/selftest/framework.c | 44 ++++---- drivers/staging/lustre/lnet/selftest/rpc.c | 27 ++--- drivers/staging/lustre/lnet/selftest/timer.c | 4 - drivers/staging/lustre/lustre/include/cl_object.h | 19 +-- .../staging/lustre/lustre/include/lustre_debug.h | 52 --------- .../staging/lustre/lustre/include/lustre_export.h | 2 drivers/staging/lustre/lustre/include/obd.h | 1 drivers/staging/lustre/lustre/include/obd_class.h | 3 - drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 10 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 - drivers/staging/lustre/lustre/llite/dir.c | 17 +-- .../staging/lustre/lustre/llite/llite_internal.h | 2 drivers/staging/lustre/lustre/llite/llite_lib.c | 8 + drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 drivers/staging/lustre/lustre/llite/statahead.c | 23 ++-- drivers/staging/lustre/lustre/llite/vvp_page.c | 9 +- drivers/staging/lustre/lustre/lov/lov_io.c | 9 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 15 +-- drivers/staging/lustre/lustre/lov/lov_page.c | 3 - drivers/staging/lustre/lustre/obdclass/Makefile | 2 drivers/staging/lustre/lustre/obdclass/cl_io.c | 91 ++++------------ drivers/staging/lustre/lustre/obdclass/cl_lock.c | 5 - drivers/staging/lustre/lustre/obdclass/cl_object.c | 110 ++++++++------------ drivers/staging/lustre/lustre/obdclass/cl_page.c | 77 ++++---------- drivers/staging/lustre/lustre/obdclass/class_obd.c | 32 ++---- drivers/staging/lustre/lustre/obdclass/debug.c | 96 ----------------- drivers/staging/lustre/lustre/obdclass/genops.c | 90 ++++++++++------ drivers/staging/lustre/lustre/obdclass/lu_object.c | 7 + .../staging/lustre/lustre/obdclass/lustre_peer.c | 5 - drivers/staging/lustre/lustre/obdecho/Makefile | 2 drivers/staging/lustre/lustre/obdecho/debug.c | 96 +++++++++++++++++ .../staging/lustre/lustre/obdecho/echo_client.c | 3 - .../staging/lustre/lustre/obdecho/echo_internal.h | 4 + drivers/staging/lustre/lustre/osc/osc_cache.c | 17 ++- drivers/staging/lustre/lustre/osc/osc_lock.c | 7 + drivers/staging/lustre/lustre/osc/osc_page.c | 21 ++-- drivers/staging/lustre/lustre/osc/osc_request.c | 11 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 14 +-- drivers/staging/lustre/lustre/ptlrpc/layout.c | 1 drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c | 6 + .../staging/lustre/lustre/ptlrpc/pack_generic.c | 4 - drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 + drivers/staging/lustre/lustre/ptlrpc/service.c | 68 ++++++------ 60 files changed, 689 insertions(+), 847 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/include/lustre_debug.h delete mode 100644 drivers/staging/lustre/lustre/obdclass/debug.c create mode 100644 drivers/staging/lustre/lustre/obdecho/debug.c -- Signature From neilb at suse.com Thu Feb 7 00:03:32 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:32 +1100 Subject: [lustre-devel] [PATCH 01/21] lustre: obdclass: discard csi_end_io In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781233.10620.15965903498344624062.stgit@noble.brown> The csi_end_io field in "struct cl_sync_io" is always set to cl_sync_io_end(), which is a tiny function. This indirection doesn't help clarity, so remove it. Inline the function in the one place where ->csi_end_io() is called, and discard the field. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 7 +----- drivers/staging/lustre/lustre/obdclass/cl_io.c | 26 ++++++--------------- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index b8ae41de7192..71ba73cdbb5e 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2395,18 +2395,13 @@ struct cl_sync_io { atomic_t csi_barrier; /** completion to be signaled when transfer is complete. */ wait_queue_head_t csi_waitq; - /** callback to invoke when this IO is finished */ - void (*csi_end_io)(const struct lu_env *, - struct cl_sync_io *); }; -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, - void (*end)(const struct lu_env *, struct cl_sync_io *)); +void cl_sync_io_init(struct cl_sync_io *anchor, int nr); int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, long timeout); void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, int ioret); -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor); /** @} cl_sync_io */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 09fd45d5394a..e9ad055f84b8 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -668,7 +668,7 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io, pg->cp_sync_io = anchor; } - cl_sync_io_init(anchor, queue->c2_qin.pl_nr, &cl_sync_io_end); + cl_sync_io_init(anchor, queue->c2_qin.pl_nr); rc = cl_io_submit_rw(env, io, iot, queue); if (rc == 0) { /* @@ -1039,31 +1039,16 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_object *obj, } EXPORT_SYMBOL(cl_req_attr_set); -/* cl_sync_io_callback assumes the caller must call cl_sync_io_wait() to - * wait for the IO to finish. - */ -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor) -{ - wake_up_all(&anchor->csi_waitq); - - /* it's safe to nuke or reuse anchor now */ - atomic_set(&anchor->csi_barrier, 0); -} -EXPORT_SYMBOL(cl_sync_io_end); - /** * Initialize synchronous io wait anchor */ -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, - void (*end)(const struct lu_env *, struct cl_sync_io *)) +void cl_sync_io_init(struct cl_sync_io *anchor, int nr) { memset(anchor, 0, sizeof(*anchor)); init_waitqueue_head(&anchor->csi_waitq); atomic_set(&anchor->csi_sync_nr, nr); atomic_set(&anchor->csi_barrier, nr > 0); anchor->csi_sync_rc = 0; - anchor->csi_end_io = end; - LASSERT(end); } EXPORT_SYMBOL(cl_sync_io_init); @@ -1120,8 +1105,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, */ LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); if (atomic_dec_and_test(&anchor->csi_sync_nr)) { - LASSERT(anchor->csi_end_io); - anchor->csi_end_io(env, anchor); + + wake_up_all(&anchor->csi_waitq); + /* it's safe to nuke or reuse anchor now */ + atomic_set(&anchor->csi_barrier, 0); + /* Can't access anchor any more */ } } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index d7bcb8c203dd..8133d992cc73 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -189,7 +189,7 @@ int cl_lock_request(const struct lu_env *env, struct cl_io *io, if ((enq_flags & CEF_ASYNC) && !(enq_flags & CEF_AGL)) { anchor = &cl_env_info(env)->clt_anchor; - cl_sync_io_init(anchor, 1, cl_sync_io_end); + cl_sync_io_init(anchor, 1); } rc = cl_lock_enqueue(env, io, lock, anchor); diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 5a1717c7d132..da8c3978fab8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -877,7 +877,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, continue; /* wait for conflicting lock to be canceled */ - cl_sync_io_init(waiter, 1, cl_sync_io_end); + cl_sync_io_init(waiter, 1); oscl->ols_owner = waiter; spin_lock(&tmp_oscl->ols_lock); From neilb at suse.com Thu Feb 7 00:03:32 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:32 +1100 Subject: [lustre-devel] [PATCH 02/21] lustre: obd_class: remove csi_barrier from struct cl_sync_io In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781242.10620.4427066512247634121.stgit@noble.brown> This flag is used to ensure that structure isn't freed before the wakeup completes. The same can be achieved using the csi_waitq.lock and calling wake_up_all_locked(). Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 2 -- drivers/staging/lustre/lustre/obdclass/cl_io.c | 16 +++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 71ba73cdbb5e..13d79810dd39 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2391,8 +2391,6 @@ struct cl_sync_io { atomic_t csi_sync_nr; /** error code. */ int csi_sync_rc; - /** barrier of destroy this structure */ - atomic_t csi_barrier; /** completion to be signaled when transfer is complete. */ wait_queue_head_t csi_waitq; }; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index e9ad055f84b8..beac7e8bc92a 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -1047,7 +1047,6 @@ void cl_sync_io_init(struct cl_sync_io *anchor, int nr) memset(anchor, 0, sizeof(*anchor)); init_waitqueue_head(&anchor->csi_waitq); atomic_set(&anchor->csi_sync_nr, nr); - atomic_set(&anchor->csi_barrier, nr > 0); anchor->csi_sync_rc = 0; } EXPORT_SYMBOL(cl_sync_io_init); @@ -1080,11 +1079,10 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, } else { rc = anchor->csi_sync_rc; } + /* We take the lock to ensure that cl_sync_io_note() has finished */ + spin_lock(&anchor->csi_waitq.lock); 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)) - cpu_relax(); + spin_unlock(&anchor->csi_waitq.lock); return rc; } @@ -1104,11 +1102,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, * IO. */ LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); - if (atomic_dec_and_test(&anchor->csi_sync_nr)) { + if (atomic_dec_and_lock(&anchor->csi_sync_nr, + &anchor->csi_waitq.lock)) { - wake_up_all(&anchor->csi_waitq); - /* it's safe to nuke or reuse anchor now */ - atomic_set(&anchor->csi_barrier, 0); + wake_up_all_locked(&anchor->csi_waitq); + spin_unlock(&anchor->csi_waitq.lock); /* Can't access anchor any more */ } From neilb at suse.com Thu Feb 7 00:03:32 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:32 +1100 Subject: [lustre-devel] [PATCH 03/21] lustre: obdclass: use list_sort() to sort a list. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781252.10620.13626213918115345779.stgit@noble.brown> Rather than a bespoke bubble-sort, use list_sort() to sort this linked list. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/cl_io.c | 51 +++++------------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index beac7e8bc92a..7bf02350f19d 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include "cl_internal.h" @@ -213,9 +214,15 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, } EXPORT_SYMBOL(cl_io_rw_init); -static int cl_lock_descr_sort(const struct cl_lock_descr *d0, - const struct cl_lock_descr *d1) +static int cl_lock_descr_cmp(void *priv, + struct list_head *a, struct list_head *b) { + const struct cl_io_lock_link *l0 = list_entry(a, struct cl_io_lock_link, cill_linkage); + const struct cl_io_lock_link *l1 = list_entry(b, struct cl_io_lock_link, cill_linkage); + + const struct cl_lock_descr *d0 = &l0->cill_descr; + const struct cl_lock_descr *d1 = &l1->cill_descr; + return lu_fid_cmp(lu_object_fid(&d0->cld_obj->co_lu), lu_object_fid(&d1->cld_obj->co_lu)); } @@ -225,45 +232,7 @@ static int cl_lock_descr_sort(const struct cl_lock_descr *d0, */ static void cl_io_locks_sort(struct cl_io *io) { - int done = 0; - - /* hidden treasure: bubble sort for now. */ - do { - struct cl_io_lock_link *curr; - struct cl_io_lock_link *prev; - struct cl_io_lock_link *temp; - - done = 1; - prev = NULL; - - list_for_each_entry_safe(curr, temp, - &io->ci_lockset.cls_todo, - cill_linkage) { - if (prev) { - switch (cl_lock_descr_sort(&prev->cill_descr, - &curr->cill_descr)) { - case 0: - /* - * IMPOSSIBLE: Identical locks are - * already removed at - * this point. - */ - default: - LBUG(); - case 1: - list_move_tail(&curr->cill_linkage, - &prev->cill_linkage); - done = 0; - continue; /* don't change prev: it's - * still "previous" - */ - case -1: /* already in order */ - break; - } - } - prev = curr; - } - } while (!done); + list_sort(NULL, &io->ci_lockset.cls_todo, cl_lock_descr_cmp); } static void cl_lock_descr_merge(struct cl_lock_descr *d0, From neilb at suse.com Thu Feb 7 00:03:32 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:32 +1100 Subject: [lustre-devel] [PATCH 04/21] lustre: use list*entry macros in place of container_of() In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781267.10620.8365663638954760207.stgit@noble.brown> There are a number of places that use container_of() but where list_first_entry(), or list_last_entry() make the meaning more clear. So change them over. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/cl_io.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/cl_object.c | 13 ++++++++----- drivers/staging/lustre/lustre/obdclass/cl_page.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/lu_object.c | 7 +++---- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 85c5047f4ba2..74c7644d6ef8 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -987,8 +987,8 @@ struct ldlm_namespace *ldlm_namespace_first_locked(enum ldlm_side client) { LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); LASSERT(!list_empty(ldlm_namespace_list(client))); - return container_of(ldlm_namespace_list(client)->next, - struct ldlm_namespace, ns_list_chain); + return list_first_entry(ldlm_namespace_list(client), + struct ldlm_namespace, ns_list_chain); } /** Create and initialize new resource. */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 7bf02350f19d..34b4e63e7d1a 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -93,8 +93,8 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_invariant(io)); while (!list_empty(&io->ci_layers)) { - slice = container_of(io->ci_layers.prev, struct cl_io_slice, - cis_linkage); + slice = list_last_entry(&io->ci_layers, struct cl_io_slice, + cis_linkage); list_del_init(&slice->cis_linkage); if (slice->cis_iop->op[io->ci_type].cio_fini) slice->cis_iop->op[io->ci_type].cio_fini(env, slice); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 05d784ae7a6c..f724b2d62df1 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -649,8 +649,8 @@ static struct lu_env *cl_env_obtain(void *debug) if (cl_envs[cpu].cec_count > 0) { int rc; - cle = container_of(cl_envs[cpu].cec_envs.next, struct cl_env, - ce_linkage); + cle = list_first_entry(&cl_envs[cpu].cec_envs, struct cl_env, + ce_linkage); list_del_init(&cle->ce_linkage); cl_envs[cpu].cec_count--; read_unlock(&cl_envs[cpu].cec_guard); @@ -748,9 +748,12 @@ unsigned int cl_env_cache_purge(unsigned int nr) for_each_possible_cpu(i) { write_lock(&cl_envs[i].cec_guard); - for (; !list_empty(&cl_envs[i].cec_envs) && nr > 0; --nr) { - cle = container_of(cl_envs[i].cec_envs.next, - struct cl_env, ce_linkage); + for (; nr >0 && + (cle = list_first_entry_or_null( + &cl_envs[i].cec_envs, + struct cl_env, + ce_linkage)) != NULL; + --nr) { list_del_init(&cle->ce_linkage); LASSERT(cl_envs[i].cec_count > 0); cl_envs[i].cec_count--; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index b1b4dc7ea22f..d025ea55818f 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -690,8 +690,8 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) const struct cl_page_slice *slice; int result; - slice = container_of(pg->cp_layers.next, - const struct cl_page_slice, cpl_linkage); + slice = list_first_entry(&pg->cp_layers, + const struct cl_page_slice, cpl_linkage); PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked); /* * Call ->cpo_is_vmlocked() directly instead of going through diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 3bd48748f46c..639c298b6a90 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -349,7 +349,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) * lives as long as possible and ->loo_object_free() methods * can look at its contents. */ - o = container_of(splice.prev, struct lu_object, lo_linkage); + o = list_last_entry(&splice, struct lu_object, lo_linkage); list_del_init(&o->lo_linkage); o->lo_ops->loo_object_free(env, o); } @@ -432,9 +432,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s, * Free everything on the dispose list. This is safe against * races due to the reasons described in lu_object_put(). */ - while (!list_empty(&dispose)) { - h = container_of(dispose.next, - struct lu_object_header, loh_lru); + while ((h = list_first_entry_or_null( + &dispose, struct lu_object_header, loh_lru)) != NULL) { list_del_init(&h->loh_lru); lu_object_free(env, lu_object_top(h)); lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED); From neilb at suse.com Thu Feb 7 00:03:32 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:32 +1100 Subject: [lustre-devel] [PATCH 05/21] lustre: use list_first_entry() in lustre subdirectory. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781279.10620.5804477141390456723.stgit@noble.brown> Convert list_entry(foo->next .....) to list_first_entry(foo, ....) in 'lustre' In several cases the call is combined with a list_empty() test and list_first_entry_or_null() is used Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 2 - drivers/staging/lustre/lustre/llite/statahead.c | 23 ++++---- drivers/staging/lustre/lustre/lov/lov_io.c | 9 +-- drivers/staging/lustre/lustre/obdclass/cl_page.c | 9 +-- drivers/staging/lustre/lustre/obdclass/genops.c | 22 ++++--- .../staging/lustre/lustre/obdclass/lustre_peer.c | 5 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 17 +++--- drivers/staging/lustre/lustre/osc/osc_lock.c | 5 +- drivers/staging/lustre/lustre/osc/osc_page.c | 17 +++--- drivers/staging/lustre/lustre/osc/osc_request.c | 8 +-- drivers/staging/lustre/lustre/ptlrpc/client.c | 8 +-- drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c | 6 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 4 + drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 59 ++++++++++---------- 15 files changed, 101 insertions(+), 99 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 13d79810dd39..53fd8d469e55 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2335,7 +2335,7 @@ static inline struct cl_page *cl_page_list_last(struct cl_page_list *plist) static inline struct cl_page *cl_page_list_first(struct cl_page_list *plist) { LASSERT(plist->pl_nr > 0); - return list_entry(plist->pl_pages.next, struct cl_page, cp_batch); + return list_first_entry(&plist->pl_pages, struct cl_page, cp_batch); } /** diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 0c305ba2b178..de7586d11d14 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -643,8 +643,8 @@ static void sa_handle_callback(struct ll_statahead_info *sai) spin_unlock(&lli->lli_sa_lock); break; } - entry = list_entry(sai->sai_interim_entries.next, - struct sa_entry, se_list); + entry = list_first_entry(&sai->sai_interim_entries, + struct sa_entry, se_list); list_del_init(&entry->se_list); spin_unlock(&lli->lli_sa_lock); @@ -893,9 +893,10 @@ static int ll_agl_thread(void *arg) /* The statahead thread maybe help to process AGL entries, * so check whether list empty again. */ - if (!list_empty(&sai->sai_agls)) { - clli = list_entry(sai->sai_agls.next, - struct ll_inode_info, lli_agl_list); + clli = list_first_entry_or_null(&sai->sai_agls, + struct ll_inode_info, + lli_agl_list); + if (clli) { list_del_init(&clli->lli_agl_list); spin_unlock(&plli->lli_agl_lock); ll_agl_trigger(&clli->lli_vfs_inode, sai); @@ -912,9 +913,9 @@ static int ll_agl_thread(void *arg) spin_lock(&plli->lli_agl_lock); sai->sai_agl_valid = 0; - while (!list_empty(&sai->sai_agls)) { - clli = list_entry(sai->sai_agls.next, - struct ll_inode_info, lli_agl_list); + while ((clli = list_first_entry_or_null(&sai->sai_agls, + struct ll_inode_info, + lli_agl_list)) != NULL) { list_del_init(&clli->lli_agl_list); spin_unlock(&plli->lli_agl_lock); clli->lli_agl_index = 0; @@ -1055,9 +1056,9 @@ static int ll_statahead_thread(void *arg) !agl_list_empty(sai)) { struct ll_inode_info *clli; - clli = list_entry(sai->sai_agls.next, - struct ll_inode_info, - lli_agl_list); + clli = list_first_entry(&sai->sai_agls, + struct ll_inode_info, + lli_agl_list); list_del_init(&clli->lli_agl_list); spin_unlock(&lli->lli_agl_lock); diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index de43f47d455e..77efb86d8683 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -270,14 +270,13 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) { struct lov_io *lio = cl2lov_io(env, ios); struct lov_object *lov = cl2lov(ios->cis_obj); + struct lov_io_sub *sub; LASSERT(list_empty(&lio->lis_active)); - while (!list_empty(&lio->lis_subios)) { - struct lov_io_sub *sub = list_entry(lio->lis_subios.next, - struct lov_io_sub, - sub_list); - + while ((sub = list_first_entry_or_null(&lio->lis_subios, + struct lov_io_sub, + sub_list)) != NULL) { list_del_init(&sub->sub_list); lio->lis_nr_subios--; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index d025ea55818f..057318deaa4e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -96,16 +96,15 @@ cl_page_at_trusted(const struct cl_page *page, static void cl_page_free(const struct lu_env *env, struct cl_page *page) { struct cl_object *obj = page->cp_obj; + struct cl_page_slice *slice; PASSERT(env, page, list_empty(&page->cp_batch)); PASSERT(env, page, !page->cp_owner); PASSERT(env, page, page->cp_state == CPS_FREEING); - while (!list_empty(&page->cp_layers)) { - struct cl_page_slice *slice; - - slice = list_entry(page->cp_layers.next, - struct cl_page_slice, cpl_linkage); + while ((slice = list_first_entry_or_null(&page->cp_layers, + struct cl_page_slice, + cpl_linkage)) != NULL) { list_del_init(page->cp_layers.next); if (unlikely(slice->cpl_ops->cpo_fini)) slice->cpl_ops->cpo_fini(env, slice); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index cee144c0ac6c..382eaf519a79 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -939,6 +939,8 @@ void class_unlink_export(struct obd_export *exp) /* Import management functions */ static void class_import_destroy(struct obd_import *imp) { + struct obd_import_conn *imp_conn; + CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp, imp->imp_obd->obd_name); @@ -946,11 +948,9 @@ static void class_import_destroy(struct obd_import *imp) ptlrpc_put_connection_superhack(imp->imp_connection); - while (!list_empty(&imp->imp_conn_list)) { - struct obd_import_conn *imp_conn; - - imp_conn = list_entry(imp->imp_conn_list.next, - struct obd_import_conn, oic_item); + while ((imp_conn = list_first_entry_or_null(&imp->imp_conn_list, + struct obd_import_conn, + oic_item)) != NULL) { list_del_init(&imp_conn->oic_item); ptlrpc_put_connection_superhack(imp_conn->oic_conn); kfree(imp_conn); @@ -1356,8 +1356,9 @@ void obd_put_request_slot(struct client_obd *cli) /* If there is free slot, wakeup the first waiter. */ if (!list_empty(&cli->cl_loi_read_list) && likely(cli->cl_r_in_flight < cli->cl_max_rpcs_in_flight)) { - orsw = list_entry(cli->cl_loi_read_list.next, - struct obd_request_slot_waiter, orsw_entry); + orsw = list_first_entry(&cli->cl_loi_read_list, + struct obd_request_slot_waiter, + orsw_entry); list_del_init(&orsw->orsw_entry); cli->cl_r_in_flight++; wake_up(&orsw->orsw_waitq); @@ -1409,11 +1410,12 @@ int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max) /* We increase the max_rpcs_in_flight, then wakeup some waiters. */ for (i = 0; i < diff; i++) { - if (list_empty(&cli->cl_loi_read_list)) + orsw = list_first_entry_or_null(&cli->cl_loi_read_list, + struct obd_request_slot_waiter, + orsw_entry); + if (!orsw) break; - orsw = list_entry(cli->cl_loi_read_list.next, - struct obd_request_slot_waiter, orsw_entry); list_del_init(&orsw->orsw_entry); cli->cl_r_in_flight++; wake_up(&orsw->orsw_waitq); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index 0c3e0ca8c03c..69a3b322119d 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -156,9 +156,8 @@ int class_del_uuid(const char *uuid) return -EINVAL; } - while (!list_empty(&deathrow)) { - data = list_entry(deathrow.next, struct uuid_nid_data, - un_list); + while ((data = list_first_entry_or_null(&deathrow, struct uuid_nid_data, + un_list)) != NULL) { list_del(&data->un_list); CDEBUG(D_INFO, "del uuid %s %s/%d\n", diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 673e139bff82..4359a9320f37 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2000,9 +2000,9 @@ static unsigned int get_write_extents(struct osc_object *obj, EASSERT(ext->oe_nr_pages <= data.erd_max_pages, ext); } - while (!list_empty(&obj->oo_urgent_exts)) { - ext = list_entry(obj->oo_urgent_exts.next, - struct osc_extent, oe_link); + while ((ext = list_first_entry_or_null(&obj->oo_urgent_exts, + struct osc_extent, + oe_link)) != NULL) { if (!try_to_add_extent_for_io(cli, ext, &data)) return data.erd_page_count; } @@ -2014,9 +2014,9 @@ static unsigned int get_write_extents(struct osc_object *obj, * is so we don't miss adding extra extents to an RPC containing high * priority or urgent extents. */ - while (!list_empty(&obj->oo_full_exts)) { - ext = list_entry(obj->oo_full_exts.next, - struct osc_extent, oe_link); + while ((ext = list_first_entry_or_null(&obj->oo_full_exts, + struct osc_extent, + oe_link)) != NULL) { if (!try_to_add_extent_for_io(cli, ext, &data)) break; } @@ -2751,10 +2751,11 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, osc_list_maint(cli, obj); - while (!list_empty(&list)) { + while ((ext = list_first_entry_or_null(&list, + struct osc_extent, + oe_link)) != NULL) { int rc; - ext = list_entry(list.next, struct osc_extent, oe_link); list_del_init(&ext->oe_link); /* extent may be in OES_ACTIVE state because inode mutex diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index da8c3978fab8..75b5dedd4fbb 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -834,8 +834,9 @@ static void osc_lock_wake_waiters(const struct lu_env *env, while (!list_empty(&oscl->ols_waiting_list)) { struct osc_lock *scan; - scan = list_entry(oscl->ols_waiting_list.next, struct osc_lock, - ols_wait_entry); + scan = list_first_entry(&oscl->ols_waiting_list, + struct osc_lock, + ols_wait_entry); list_del_init(&scan->ols_wait_entry); cl_sync_io_note(env, scan->ols_owner, 0); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 71f548570fec..135bfe5e1b37 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -572,8 +572,8 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, if (--maxscan < 0) break; - opg = list_entry(cli->cl_lru_list.next, struct osc_page, - ops_lru); + opg = list_first_entry(&cli->cl_lru_list, struct osc_page, + ops_lru); page = opg->ops_cl.cpl_page; if (lru_page_busy(cli, page)) { list_move_tail(&opg->ops_lru, &cli->cl_lru_list); @@ -708,9 +708,10 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru); max_scans = atomic_read(&cache->ccc_users) - 2; - while (--max_scans > 0 && !list_empty(&cache->ccc_lru)) { - cli = list_entry(cache->ccc_lru.next, struct client_obd, - cl_lru_osc); + while (--max_scans > 0 && + (cli = list_first_entry_or_null(&cache->ccc_lru, + struct client_obd, + cl_lru_osc)) != NULL) { CDEBUG(D_CACHE, "%s: cli %p LRU pages: %ld, busy: %ld.\n", cli_name(cli), cli, @@ -1047,9 +1048,9 @@ unsigned long osc_cache_shrink_scan(struct shrinker *sk, 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); + while ((cli = list_first_entry_or_null(&osc_shrink_list, + struct client_obd, + cl_shrink_list)) != NULL) { if (!stop_anchor) stop_anchor = cli; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 86f9de611221..9e72fa8f68b3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1936,7 +1936,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, } /* first page in the list */ - oap = list_entry(rpc_list.next, typeof(*oap), oap_rpc_item); + oap = list_first_entry(&rpc_list, typeof(*oap), oap_rpc_item); crattr = &osc_env_info(env)->oti_req_attr; memset(crattr, 0, sizeof(*crattr)); @@ -2019,9 +2019,9 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, /* this should happen rarely and is pretty bad, it makes the * pending list not follow the dirty order */ - while (!list_empty(ext_list)) { - ext = list_entry(ext_list->next, struct osc_extent, - oe_link); + while ((ext = list_first_entry_or_null(ext_list, + struct osc_extent, + oe_link)) != NULL) { list_del_init(&ext->oe_link); osc_extent_finish(env, ext, 0, rc); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 2c519ad6f7cc..a78d49621c42 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -625,8 +625,8 @@ ptlrpc_prep_req_from_pool(struct ptlrpc_request_pool *pool) return NULL; } - request = list_entry(pool->prp_req_list.next, struct ptlrpc_request, - rq_list); + request = list_first_entry(&pool->prp_req_list, struct ptlrpc_request, + rq_list); list_del_init(&request->rq_list); spin_unlock(&pool->prp_lock); @@ -1274,8 +1274,8 @@ u64 ptlrpc_known_replied_xid(struct obd_import *imp) if (list_empty(&imp->imp_unreplied_list)) return 0; - req = list_entry(imp->imp_unreplied_list.next, struct ptlrpc_request, - rq_unreplied_list); + req = list_first_entry(&imp->imp_unreplied_list, struct ptlrpc_request, + rq_unreplied_list); LASSERTF(req->rq_xid >= 1, "XID:%llu\n", req->rq_xid); if (imp->imp_known_replied_xid < req->rq_xid - 1) diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c index 7fe8aeeff428..ab186d84aefe 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c @@ -163,9 +163,9 @@ struct ptlrpc_nrs_request *nrs_fifo_req_get(struct ptlrpc_nrs_policy *policy, struct nrs_fifo_head *head = policy->pol_private; struct ptlrpc_nrs_request *nrq; - nrq = unlikely(list_empty(&head->fh_list)) ? NULL : - list_entry(head->fh_list.next, struct ptlrpc_nrs_request, - nr_u.fifo.fr_list); + nrq = list_first_entry_or_null(&head->fh_list, + struct ptlrpc_nrs_request, + nr_u.fifo.fr_list); if (likely(!peek && nrq)) { struct ptlrpc_request *req = container_of(nrq, diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 1fadba2be16b..c7cc86c3fbc3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -272,8 +272,8 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) spin_lock(&svcpt->scp_rep_lock); } - rs = list_entry(svcpt->scp_rep_idle.next, - struct ptlrpc_reply_state, rs_list); + rs = list_first_entry(&svcpt->scp_rep_idle, + struct ptlrpc_reply_state, rs_list); list_del(&rs->rs_list); spin_unlock(&svcpt->scp_rep_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 2c8bad7b7877..c4dba675db52 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -101,9 +101,9 @@ static void sec_process_ctx_list(void) spin_lock(&sec_gc_ctx_list_lock); - while (!list_empty(&sec_gc_ctx_list)) { - ctx = list_entry(sec_gc_ctx_list.next, - struct ptlrpc_cli_ctx, cc_gc_chain); + while ((ctx = list_first_entry_or_null(&sec_gc_ctx_list, + struct ptlrpc_cli_ctx, + cc_gc_chain)) != NULL) { list_del_init(&ctx->cc_gc_chain); spin_unlock(&sec_gc_ctx_list_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 5b97f2a1fea1..a69736dfe8b7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -299,9 +299,9 @@ ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) return posted; } - rqbd = list_entry(svcpt->scp_rqbd_idle.next, - struct ptlrpc_request_buffer_desc, - rqbd_list); + rqbd = list_first_entry(&svcpt->scp_rqbd_idle, + struct ptlrpc_request_buffer_desc, + rqbd_list); list_del(&rqbd->rqbd_list); /* assume we will post successfully */ @@ -769,9 +769,9 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) * I expect only about 1 or 2 rqbds need to be recycled here */ while (svcpt->scp_hist_nrqbds > svc->srv_hist_nrqbds_cpt_max) { - rqbd = list_entry(svcpt->scp_hist_rqbds.next, - struct ptlrpc_request_buffer_desc, - rqbd_list); + rqbd = list_first_entry(&svcpt->scp_hist_rqbds, + struct ptlrpc_request_buffer_desc, + rqbd_list); list_del(&rqbd->rqbd_list); svcpt->scp_hist_nrqbds--; @@ -1240,9 +1240,9 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) /* we took additional refcount so entries can't be deleted from list, no * locking is needed */ - while (!list_empty(&work_list)) { - rq = list_entry(work_list.next, struct ptlrpc_request, - rq_timed_list); + while ((rq = list_first_entry_or_null(&work_list, + struct ptlrpc_request, + rq_timed_list)) != NULL) { list_del_init(&rq->rq_timed_list); if (ptlrpc_at_send_early_reply(rq) == 0) @@ -1485,8 +1485,8 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, return 0; } - req = list_entry(svcpt->scp_req_incoming.next, - struct ptlrpc_request, rq_list); + req = list_first_entry(&svcpt->scp_req_incoming, + struct ptlrpc_request, rq_list); list_del_init(&req->rq_list); svcpt->scp_nreqs_incoming--; /* Consider this still a "queued" request as far as stats are @@ -2345,9 +2345,9 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) wake_up_all(&svcpt->scp_waitq); - while (!list_empty(&svcpt->scp_threads)) { - thread = list_entry(svcpt->scp_threads.next, - struct ptlrpc_thread, t_link); + while ((thread = list_first_entry_or_null(&svcpt->scp_threads, + struct ptlrpc_thread, + t_link)) != NULL) { if (thread_is_stopped(thread)) { list_del(&thread->t_link); list_add(&thread->t_link, &zombie); @@ -2365,9 +2365,9 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) spin_unlock(&svcpt->scp_lock); - while (!list_empty(&zombie)) { - thread = list_entry(zombie.next, - struct ptlrpc_thread, t_link); + while ((thread = list_first_entry(&zombie, + struct ptlrpc_thread, + t_link)) != NULL) { list_del(&thread->t_link); kfree(thread); } @@ -2707,9 +2707,9 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) break; spin_lock(&svcpt->scp_rep_lock); - while (!list_empty(&svcpt->scp_rep_active)) { - rs = list_entry(svcpt->scp_rep_active.next, - struct ptlrpc_reply_state, rs_list); + while ((rs = list_first_entry_or_null(&svcpt->scp_rep_active, + struct ptlrpc_reply_state, + rs_list)) != NULL) { spin_lock(&rs->rs_lock); ptlrpc_schedule_difficult_reply(rs); spin_unlock(&rs->rs_lock); @@ -2720,10 +2720,9 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) * all unlinked) and no service threads, so I'm the only * thread noodling the request queue now */ - while (!list_empty(&svcpt->scp_req_incoming)) { - req = list_entry(svcpt->scp_req_incoming.next, - struct ptlrpc_request, rq_list); - + while ((req = list_first_entry_or_null(&svcpt->scp_req_incoming, + struct ptlrpc_request, + rq_list)) != NULL) { list_del(&req->rq_list); svcpt->scp_nreqs_incoming--; ptlrpc_server_finish_request(svcpt, req); @@ -2747,17 +2746,17 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) */ while (!list_empty(&svcpt->scp_rqbd_idle)) { - rqbd = list_entry(svcpt->scp_rqbd_idle.next, - struct ptlrpc_request_buffer_desc, - rqbd_list); + rqbd = list_first_entry(&svcpt->scp_rqbd_idle, + struct ptlrpc_request_buffer_desc, + rqbd_list); ptlrpc_free_rqbd(rqbd); } ptlrpc_wait_replies(svcpt); while (!list_empty(&svcpt->scp_rep_idle)) { - rs = list_entry(svcpt->scp_rep_idle.next, - struct ptlrpc_reply_state, - rs_list); + rs = list_first_entry(&svcpt->scp_rep_idle, + struct ptlrpc_reply_state, + rs_list); list_del(&rs->rs_list); kvfree(rs); } From neilb at suse.com Thu Feb 7 00:03:32 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:32 +1100 Subject: [lustre-devel] [PATCH 06/21] lustre: use list_first_entry() in lnet/lnet subdirectory. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781293.10620.13774044385661376106.stgit@noble.brown> Convert list_entry(foo->next .....) to list_first_entry(foo, ....) in 'lnet/lnet' In several cases the call is combined with a list_empty() test and list_first_entry_or_null() is used In one case, list_splice_init() is used. Signed-off-by: NeilBrown --- drivers/staging/lustre/lnet/lnet/api-ni.c | 111 ++++++++++++------------- drivers/staging/lustre/lnet/lnet/config.c | 22 ++--- drivers/staging/lustre/lnet/lnet/lib-move.c | 53 ++++++------ drivers/staging/lustre/lnet/lnet/lib-msg.c | 16 ++-- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 7 +- drivers/staging/lustre/lnet/lnet/net_fault.c | 24 +++-- drivers/staging/lustre/lnet/lnet/nidstrings.c | 9 +- drivers/staging/lustre/lnet/lnet/peer.c | 24 +++-- drivers/staging/lustre/lnet/lnet/router.c | 13 ++- 9 files changed, 141 insertions(+), 138 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 64b8bef91915..671591a092ac 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -812,8 +812,8 @@ lnet_net2ni_locked(u32 net_id, int cpt) list_for_each_entry(net, &the_lnet.ln_nets, net_list) { if (net->net_id == net_id) { - ni = list_entry(net->net_ni_list.next, struct lnet_ni, - ni_netlist); + ni = list_first_entry(&net->net_ni_list, struct lnet_ni, + ni_netlist); return ni; } } @@ -1504,12 +1504,12 @@ lnet_clear_zombies_nis_locked(struct lnet_net *net) * list and shut them down in guaranteed thread context */ i = 2; - while (!list_empty(zombie_list)) { + while ((ni = list_first_entry_or_null(zombie_list, + struct lnet_ni, + ni_netlist)) != NULL) { int *ref; int j; - ni = list_entry(zombie_list->next, - struct lnet_ni, ni_netlist); list_del_init(&ni->ni_netlist); /* the ni should be in deleting state. If it's not it's * a bug */ @@ -1583,9 +1583,9 @@ lnet_shutdown_lndnet(struct lnet_net *net) list_del_init(&net->net_list); - while (!list_empty(&net->net_ni_list)) { - ni = list_entry(net->net_ni_list.next, - struct lnet_ni, ni_netlist); + while ((ni = list_first_entry_or_null(&net->net_ni_list, + struct lnet_ni, + ni_netlist)) != NULL) { lnet_net_unlock(LNET_LOCK_EX); lnet_shutdown_lndni(ni); lnet_net_lock(LNET_LOCK_EX); @@ -1622,16 +1622,12 @@ lnet_shutdown_lndnets(void) lnet_net_lock(LNET_LOCK_EX); the_lnet.ln_state = LNET_STATE_STOPPING; - while (!list_empty(&the_lnet.ln_nets)) { - /* - * move the nets to the zombie list to avoid them being - * picked up for new work. LONET is also included in the - * Nets that will be moved to the zombie list - */ - net = list_entry(the_lnet.ln_nets.next, - struct lnet_net, net_list); - list_move(&net->net_list, &the_lnet.ln_net_zombie); - } + /* + * move the nets to the zombie list to avoid them being + * picked up for new work. LONET is also included in the + * Nets that will be moved to the zombie list + */ + list_splice_init(&the_lnet.ln_nets, &the_lnet.ln_net_zombie); /* Drop the cached loopback Net. */ if (the_lnet.ln_loni) { @@ -1641,11 +1637,10 @@ lnet_shutdown_lndnets(void) lnet_net_unlock(LNET_LOCK_EX); /* iterate through the net zombie list and delete each net */ - while (!list_empty(&the_lnet.ln_net_zombie)) { - net = list_entry(the_lnet.ln_net_zombie.next, - struct lnet_net, net_list); + while ((net = list_first_entry_or_null(&the_lnet.ln_net_zombie, + struct lnet_net, + net_list)) != NULL) lnet_shutdown_lndnet(net); - } lnet_net_lock(LNET_LOCK_EX); the_lnet.ln_state = LNET_STATE_SHUTDOWN; @@ -1833,9 +1828,9 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun) goto failed0; } - while (!list_empty(&net->net_ni_added)) { - ni = list_entry(net->net_ni_added.next, struct lnet_ni, - ni_netlist); + while ((ni = list_first_entry_or_null(&net->net_ni_added, + struct lnet_ni, + ni_netlist)) != NULL) { list_del_init(&ni->ni_netlist); /* make sure that the the NI we're about to start @@ -1902,12 +1897,10 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun) * shutdown the new NIs that are being started up * free the NET being started */ - while (!list_empty(&local_ni_list)) { - ni = list_entry(local_ni_list.next, struct lnet_ni, - ni_netlist); - + while ((ni = list_first_entry_or_null(&local_ni_list, + struct lnet_ni, + ni_netlist)) != NULL) lnet_shutdown_lndni(ni); - } failed0: lnet_net_free(net); @@ -1931,8 +1924,9 @@ lnet_startup_lndnets(struct list_head *netlist) the_lnet.ln_state = LNET_STATE_RUNNING; lnet_net_unlock(LNET_LOCK_EX); - while (!list_empty(netlist)) { - net = list_entry(netlist->next, struct lnet_net, net_list); + while ((net = list_first_entry_or_null(netlist, + struct lnet_net, + net_list)) != NULL) { list_del_init(&net->net_list); rc = lnet_startup_lndnet(net, NULL); @@ -2022,11 +2016,13 @@ int lnet_lib_init(void) */ void lnet_lib_exit(void) { + struct lnet_lnd *lnd; LASSERT(!the_lnet.ln_refcount); - while (!list_empty(&the_lnet.ln_lnds)) - lnet_unregister_lnd(list_entry(the_lnet.ln_lnds.next, - struct lnet_lnd, lnd_list)); + while ((lnd = list_first_entry_or_null(&the_lnet.ln_lnds, + struct lnet_lnd, + lnd_list)) != NULL) + lnet_unregister_lnd(lnd); lnet_destroy_locks(); } @@ -2172,10 +2168,9 @@ LNetNIInit(lnet_pid_t requested_pid) lnet_unprepare(); LASSERT(rc < 0); mutex_unlock(&the_lnet.ln_api_mutex); - while (!list_empty(&net_head)) { - struct lnet_net *net; - - net = list_entry(net_head.next, struct lnet_net, net_list); + while ((net = list_first_entry_or_null(&net_head, + struct lnet_net, + net_list)) != NULL) { list_del_init(&net->net_list); lnet_net_free(net); } @@ -2411,10 +2406,11 @@ lnet_get_next_ni_locked(struct lnet_net *mynet, struct lnet_ni *prev) if (!prev) { if (!net) - net = list_entry(the_lnet.ln_nets.next, struct lnet_net, - net_list); - ni = list_entry(net->net_ni_list.next, struct lnet_ni, - ni_netlist); + net = list_first_entry(&the_lnet.ln_nets, + struct lnet_net, + net_list); + ni = list_first_entry(&net->net_ni_list, struct lnet_ni, + ni_netlist); return ni; } @@ -2432,17 +2428,17 @@ lnet_get_next_ni_locked(struct lnet_net *mynet, struct lnet_ni *prev) return NULL; /* get the next net */ - net = list_entry(prev->ni_net->net_list.next, struct lnet_net, - net_list); + net = list_first_entry(&prev->ni_net->net_list, struct lnet_net, + net_list); /* get the ni on it */ - ni = list_entry(net->net_ni_list.next, struct lnet_ni, - ni_netlist); + ni = list_first_entry(&net->net_ni_list, struct lnet_ni, + ni_netlist); return ni; } /* there are more nis left */ - ni = list_entry(prev->ni_netlist.next, struct lnet_ni, ni_netlist); + ni = list_first_entry(&prev->ni_netlist, struct lnet_ni, ni_netlist); return ni; } @@ -2637,8 +2633,9 @@ static int lnet_handle_legacy_ip2nets(char *ip2nets, return rc; mutex_lock(&the_lnet.ln_api_mutex); - while (!list_empty(&net_head)) { - net = list_entry(net_head.next, struct lnet_net, net_list); + while ((net = list_first_entry_or_null(&net_head, + struct lnet_net, + net_list)) != NULL) { list_del_init(&net->net_list); rc = lnet_add_net_common(net, tun); if (rc < 0) @@ -2648,8 +2645,9 @@ static int lnet_handle_legacy_ip2nets(char *ip2nets, out: mutex_unlock(&the_lnet.ln_api_mutex); - while (!list_empty(&net_head)) { - net = list_entry(net_head.next, struct lnet_net, net_list); + while ((net = list_first_entry_or_null(&net_head, + struct lnet_net, + net_list)) != NULL) { list_del_init(&net->net_list); lnet_net_free(net); } @@ -2819,7 +2817,7 @@ lnet_dyn_add_net(struct lnet_ioctl_config_data *conf) goto out_unlock_clean; } - net = list_entry(net_head.next, struct lnet_net, net_list); + net = list_first_entry(&net_head, struct lnet_net, net_list); list_del_init(&net->net_list); LASSERT(lnet_net_unique(net->net_id, &the_lnet.ln_nets, NULL)); @@ -2839,9 +2837,10 @@ lnet_dyn_add_net(struct lnet_ioctl_config_data *conf) out_unlock_clean: mutex_unlock(&the_lnet.ln_api_mutex); - while (!list_empty(&net_head)) { - /* net_head list is empty in success case */ - net = list_entry(net_head.next, struct lnet_net, net_list); + /* net_head list is empty in success case */ + while ((net = list_first_entry_or_null(&net_head, + struct lnet_net, + net_list)) != NULL) { list_del_init(&net->net_list); lnet_net_free(net); } diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index ecf656bce73f..f34844465d01 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -817,8 +817,9 @@ lnet_parse_networks(struct list_head *netlist, char *networks, lnet_syntax("networks", networks, (int)(str - tokens), strlen(str)); failed: /* free the net list and all the nis on each net */ - while (!list_empty(netlist)) { - net = list_entry(netlist->next, struct lnet_net, net_list); + while ((net = list_first_entry_or_null(netlist, + struct lnet_net, + net_list)) != NULL) { list_del_init(&net->net_list); lnet_net_free(net); @@ -875,9 +876,8 @@ lnet_free_text_bufs(struct list_head *tbs) { struct lnet_text_buf *ltb; - while (!list_empty(tbs)) { - ltb = list_entry(tbs->next, struct lnet_text_buf, ltb_list); - + while ((ltb = list_first_entry_or_null(tbs, struct lnet_text_buf, + ltb_list)) != NULL) { list_del(<b->ltb_list); lnet_free_text_buf(ltb); } @@ -1239,8 +1239,8 @@ lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router) { struct lnet_text_buf *ltb; - while (!list_empty(tbs)) { - ltb = list_entry(tbs->next, struct lnet_text_buf, ltb_list); + while ((ltb = list_first_entry_or_null(tbs, struct lnet_text_buf, + ltb_list)) != NULL) { if (lnet_parse_route(ltb->ltb_text, im_a_router) < 0) { lnet_free_text_bufs(tbs); @@ -1383,7 +1383,7 @@ lnet_splitnets(char *source, struct list_head *nets) LASSERT(!list_empty(nets)); LASSERT(nets->next == nets->prev); /* single entry */ - tb = list_entry(nets->next, struct lnet_text_buf, ltb_list); + tb = list_first_entry(nets, struct lnet_text_buf, ltb_list); for (;;) { sep = strchr(tb->ltb_text, ','); @@ -1478,9 +1478,9 @@ lnet_match_networks(char **networksp, char *ip2nets, u32 *ipaddrs, int nip) len = 0; rc = 0; - while (!list_empty(&raw_entries)) { - tb = list_entry(raw_entries.next, struct lnet_text_buf, - ltb_list); + while ((tb = list_first_entry_or_null(&raw_entries, + struct lnet_text_buf, + ltb_list)) != NULL) { strncpy(source, tb->ltb_text, sizeof(source)); source[sizeof(source) - 1] = '\0'; diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 92c6a34b44e6..185ea51d2771 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -185,9 +185,9 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) lnet_net_unlock(0); - while (!list_empty(&cull)) { - tp = list_entry(cull.next, struct lnet_test_peer, tp_list); - + while ((tp = list_first_entry_or_null(&cull, + struct lnet_test_peer, + tp_list)) != NULL) { list_del(&tp->tp_list); kfree(tp); } @@ -244,8 +244,9 @@ fail_peer(lnet_nid_t nid, int outgoing) lnet_net_unlock(0); - while (!list_empty(&cull)) { - tp = list_entry(cull.next, struct lnet_test_peer, tp_list); + while ((tp = list_first_entry_or_null(&cull, + struct lnet_test_peer, + tp_list)) != NULL) { list_del(&tp->tp_list); kfree(tp); @@ -889,7 +890,7 @@ lnet_post_routed_recv_locked(struct lnet_msg *msg, int do_recv) } LASSERT(!list_empty(&rbp->rbp_bufs)); - rb = list_entry(rbp->rbp_bufs.next, struct lnet_rtrbuf, rb_list); + rb = list_first_entry(&rbp->rbp_bufs, struct lnet_rtrbuf, rb_list); list_del(&rb->rb_list); msg->msg_niov = rbp->rbp_npages; @@ -926,8 +927,8 @@ lnet_return_tx_credits_locked(struct lnet_msg *msg) tq->tq_credits++; atomic_inc(&ni->ni_tx_credits); if (tq->tq_credits <= 0) { - msg2 = list_entry(tq->tq_delayed.next, - struct lnet_msg, msg_list); + msg2 = list_first_entry(&tq->tq_delayed, + struct lnet_msg, msg_list); list_del(&msg2->msg_list); LASSERT(msg2->msg_txni == ni); @@ -953,8 +954,8 @@ lnet_return_tx_credits_locked(struct lnet_msg *msg) if (txpeer->lpni_txcredits <= 0) { int msg2_cpt; - msg2 = list_entry(txpeer->lpni_txq.next, - struct lnet_msg, msg_list); + msg2 = list_first_entry(&txpeer->lpni_txq, + struct lnet_msg, msg_list); list_del(&msg2->msg_list); spin_unlock(&txpeer->lpni_lock); @@ -1015,8 +1016,8 @@ lnet_schedule_blocked_locked(struct lnet_rtrbufpool *rbp) if (list_empty(&rbp->rbp_msgs)) return; - msg = list_entry(rbp->rbp_msgs.next, - struct lnet_msg, msg_list); + msg = list_first_entry(&rbp->rbp_msgs, + struct lnet_msg, msg_list); list_del(&msg->msg_list); (void)lnet_post_routed_recv_locked(msg, 1); @@ -1117,8 +1118,8 @@ lnet_return_rx_credits_locked(struct lnet_msg *msg) spin_unlock(&rxpeer->lpni_lock); lnet_drop_routed_msgs_locked(&drop, msg->msg_rx_cpt); } else if (rxpeer->lpni_rtrcredits <= 0) { - msg2 = list_entry(rxpeer->lpni_rtrq.next, - struct lnet_msg, msg_list); + msg2 = list_first_entry(&rxpeer->lpni_rtrq, + struct lnet_msg, msg_list); list_del(&msg2->msg_list); spin_unlock(&rxpeer->lpni_lock); (void)lnet_post_routed_recv_locked(msg2, 1); @@ -1553,8 +1554,8 @@ lnet_select_pathway(lnet_nid_t src_nid, lnet_nid_t dst_nid, libcfs_net2str(best_lpni->lpni_net->net_id)); return -EHOSTUNREACH; } - lpni = list_entry(peer_net->lpn_peer_nis.next, - struct lnet_peer_ni, + lpni = list_first_entry(&peer_net->lpn_peer_nis, + struct lnet_peer_ni, lpni_peer_nis); } /* Set preferred NI if necessary. */ @@ -1595,9 +1596,9 @@ lnet_select_pathway(lnet_nid_t src_nid, lnet_nid_t dst_nid, if (!local_net && !routing && !local_found) { struct lnet_peer_ni *net_gw; - lpni = list_entry(peer_net->lpn_peer_nis.next, - struct lnet_peer_ni, - lpni_peer_nis); + lpni = list_first_entry(&peer_net->lpn_peer_nis, + struct lnet_peer_ni, + lpni_peer_nis); net_gw = lnet_find_route_locked(NULL, lpni->lpni_nid, @@ -2620,11 +2621,12 @@ EXPORT_SYMBOL(lnet_parse); void lnet_drop_delayed_msg_list(struct list_head *head, char *reason) { - while (!list_empty(head)) { + struct lnet_msg *msg; + + while ((msg = list_first_entry_or_null(head, struct lnet_msg, + msg_list)) != NULL) { struct lnet_process_id id = { 0 }; - struct lnet_msg *msg; - msg = list_entry(head->next, struct lnet_msg, msg_list); list_del(&msg->msg_list); id.nid = msg->msg_hdr.src_nid; @@ -2662,11 +2664,12 @@ lnet_drop_delayed_msg_list(struct list_head *head, char *reason) void lnet_recv_delayed_msg_list(struct list_head *head) { - while (!list_empty(head)) { - struct lnet_msg *msg; + struct lnet_msg *msg; + + while ((msg = list_first_entry_or_null(head, struct lnet_msg, + msg_list)) != NULL) { struct lnet_process_id id; - msg = list_entry(head->next, struct lnet_msg, msg_list); list_del(&msg->msg_list); /* diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index b9e9257a4c5a..02620fe2a0fa 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -528,10 +528,9 @@ lnet_finalize(struct lnet_msg *msg, int status) container->msc_finalizers[my_slot] = current; - while (!list_empty(&container->msc_finalizing)) { - msg = list_entry(container->msc_finalizing.next, - struct lnet_msg, msg_list); - + while ((msg = list_first_entry_or_null(&container->msc_finalizing, + struct lnet_msg, + msg_list)) != NULL) { list_del(&msg->msg_list); /* @@ -561,15 +560,14 @@ void lnet_msg_container_cleanup(struct lnet_msg_container *container) { int count = 0; + struct lnet_msg *msg; if (!container->msc_init) return; - while (!list_empty(&container->msc_active)) { - struct lnet_msg *msg; - - msg = list_entry(container->msc_active.next, - struct lnet_msg, msg_activelist); + while ((msg = list_first_entry_or_null(&container->msc_active, + struct lnet_msg, + msg_activelist)) != NULL) { LASSERT(msg->msg_onactivelist); msg->msg_onactivelist = 0; list_del(&msg->msg_activelist); diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index ea232c76b64d..4a12d86e6d64 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -767,9 +767,10 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) mhash = mtable->mt_mhash; /* cleanup ME */ for (j = 0; j < LNET_MT_HASH_SIZE + 1; j++) { - while (!list_empty(&mhash[j])) { - me = list_entry(mhash[j].next, - struct lnet_me, me_list); + while ((me = list_first_entry_or_null(&mhash[j], + struct lnet_me, + me_list)) + != NULL) { CERROR("Active ME %p on exit\n", me); list_del(&me->me_list); kfree(me); diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c index 4234ce1ce539..130a7c90965d 100644 --- a/drivers/staging/lustre/lnet/lnet/net_fault.c +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c @@ -581,8 +581,8 @@ delayed_msg_check(struct lnet_delay_rule *rule, bool all, * dequeued some timedout messages, update timer for the * next delayed message on rule */ - msg = list_entry(rule->dl_msg_list.next, - struct lnet_msg, msg_list); + msg = list_first_entry(&rule->dl_msg_list, + struct lnet_msg, msg_list); rule->dl_msg_send = msg->msg_delay_send; mod_timer(&rule->dl_timer, rule->dl_msg_send); } @@ -594,12 +594,12 @@ delayed_msg_process(struct list_head *msg_list, bool drop) { struct lnet_msg *msg; - while (!list_empty(msg_list)) { + while ((msg = list_first_entry_or_null(msg_list, struct lnet_msg, + msg_list)) != NULL) { struct lnet_ni *ni; int cpt; int rc; - msg = list_entry(msg_list->next, struct lnet_msg, msg_list); LASSERT(msg->msg_rxpeer); LASSERT(msg->msg_rxni); @@ -653,16 +653,16 @@ lnet_delay_rule_check(void) break; spin_lock_bh(&delay_dd.dd_lock); - if (list_empty(&delay_dd.dd_sched_rules)) { - spin_unlock_bh(&delay_dd.dd_lock); - break; - } - - rule = list_entry(delay_dd.dd_sched_rules.next, - struct lnet_delay_rule, dl_sched_link); - list_del_init(&rule->dl_sched_link); + rule = list_first_entry_or_null(&delay_dd.dd_sched_rules, + struct lnet_delay_rule, + dl_sched_link); + if (!rule) + list_del_init(&rule->dl_sched_link); spin_unlock_bh(&delay_dd.dd_lock); + if (!rule) + break; + delayed_msg_check(rule, false, &msgs); delay_rule_decref(rule); /* -1 for delay_dd.dd_sched_rules */ } diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c index 8f3d87c5467c..2df9ce4995f3 100644 --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c @@ -282,10 +282,11 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist) static void free_addrranges(struct list_head *list) { - while (!list_empty(list)) { - struct addrrange *ar; + struct addrrange *ar; - ar = list_entry(list->next, struct addrrange, ar_link); + while ((ar = list_first_entry_or_null(list, + struct addrrange, + ar_link)) != NULL) { cfs_expr_list_free_list(&ar->ar_numaddr_ranges); list_del(&ar->ar_link); @@ -960,7 +961,7 @@ libcfs_num_match(u32 addr, struct list_head *numaddr) struct cfs_expr_list *el; LASSERT(!list_empty(numaddr)); - el = list_entry(numaddr->next, struct cfs_expr_list, el_link); + el = list_first_entry(numaddr, struct cfs_expr_list, el_link); return cfs_expr_list_match(addr, el); } diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index dfe1f3d09bc6..ade7f23b3bf4 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -649,12 +649,12 @@ lnet_get_next_peer_ni_locked(struct lnet_peer *peer, if (list_empty(&peer->lp_peer_nets)) return NULL; - net = list_entry(peer->lp_peer_nets.next, - struct lnet_peer_net, - lpn_peer_nets); + net = list_first_entry(&peer->lp_peer_nets, + struct lnet_peer_net, + lpn_peer_nets); } - lpni = list_entry(net->lpn_peer_nis.next, struct lnet_peer_ni, - lpni_peer_nis); + lpni = list_first_entry(&net->lpn_peer_nis, struct lnet_peer_ni, + lpni_peer_nis); return lpni; } @@ -678,19 +678,19 @@ lnet_get_next_peer_ni_locked(struct lnet_peer *peer, return NULL; /* get the next net */ - net = list_entry(prev->lpni_peer_net->lpn_peer_nets.next, - struct lnet_peer_net, - lpn_peer_nets); + net = list_first_entry(&prev->lpni_peer_net->lpn_peer_nets, + struct lnet_peer_net, + lpn_peer_nets); /* get the ni on it */ - lpni = list_entry(net->lpn_peer_nis.next, struct lnet_peer_ni, - lpni_peer_nis); + lpni = list_first_entry(&net->lpn_peer_nis, struct lnet_peer_ni, + lpni_peer_nis); return lpni; } /* there are more nis left */ - lpni = list_entry(prev->lpni_peer_nis.next, - struct lnet_peer_ni, lpni_peer_nis); + lpni = list_first_entry(&prev->lpni_peer_nis, + struct lnet_peer_ni, lpni_peer_nis); return lpni; } diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 463b123e0e5c..bcde61d2a984 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -1220,9 +1220,9 @@ lnet_prune_rc_data(int wait_unlink) lnet_net_unlock(LNET_LOCK_EX); - while (!list_empty(&head)) { - rcd = list_entry(head.next, - struct lnet_rc_data, rcd_list); + while ((rcd = list_first_entry_or_null(&head, + struct lnet_rc_data, + rcd_list)) != NULL) { list_del_init(&rcd->rcd_list); lnet_destroy_rc_data(rcd); } @@ -1397,7 +1397,7 @@ lnet_rtrpool_free_bufs(struct lnet_rtrbufpool *rbp, int cpt) /* Free buffers on the free list. */ while (!list_empty(&tmp)) { - rb = list_entry(tmp.next, struct lnet_rtrbuf, rb_list); + rb = list_first_entry(&tmp, struct lnet_rtrbuf, rb_list); list_del(&rb->rb_list); lnet_destroy_rtrbuf(rb, npages); } @@ -1481,8 +1481,9 @@ lnet_rtrpool_adjust_bufs(struct lnet_rtrbufpool *rbp, int nbufs, int cpt) return 0; failed: - while (!list_empty(&rb_list)) { - rb = list_entry(rb_list.next, struct lnet_rtrbuf, rb_list); + while ((rb = list_first_entry_or_null(&rb_list, + struct lnet_rtrbuf, + rb_list)) != NULL) { list_del(&rb->rb_list); lnet_destroy_rtrbuf(rb, npages); } From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 07/21] lustre: use list_first_entry() in lnet/klnds subdirectory. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781297.10620.13452862524706335326.stgit@noble.brown> Convert list_entry(foo->next .....) to list_first_entry(foo, ....) in 'lnet/klnds In several cases the call is combined with a list_empty() test and list_first_entry_or_null() is used Signed-off-by: NeilBrown --- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 19 +++-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 61 ++++++++------- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 9 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 79 ++++++++++---------- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 4 + 5 files changed, 88 insertions(+), 84 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 74b21fe2c091..df6b1b134709 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -1386,8 +1386,8 @@ static void kiblnd_destroy_fmr_pool_list(struct list_head *head) { struct kib_fmr_pool *fpo; - while (!list_empty(head)) { - fpo = list_entry(head->next, struct kib_fmr_pool, fpo_list); + while ((fpo = list_first_entry_or_null(head, struct kib_fmr_pool, + fpo_list)) != NULL) { list_del(&fpo->fpo_list); kiblnd_destroy_fmr_pool(fpo); } @@ -1544,14 +1544,16 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps, static void kiblnd_fail_fmr_poolset(struct kib_fmr_poolset *fps, struct list_head *zombies) { + struct kib_fmr_pool *fpo; + if (!fps->fps_net) /* initialized? */ return; spin_lock(&fps->fps_lock); - while (!list_empty(&fps->fps_pool_list)) { - struct kib_fmr_pool *fpo = list_entry(fps->fps_pool_list.next, - struct kib_fmr_pool, fpo_list); + while ((fpo = list_first_entry_or_null(&fps->fps_pool_list, + struct kib_fmr_pool, + fpo_list)) != NULL) { fpo->fpo_failed = 1; list_del(&fpo->fpo_list); if (!fpo->fpo_map_count) @@ -1853,8 +1855,9 @@ static void kiblnd_destroy_pool_list(struct list_head *head) { struct kib_pool *pool; - while (!list_empty(head)) { - pool = list_entry(head->next, struct kib_pool, po_list); + while ((pool = list_first_entry_or_null(head, + struct kib_pool, + po_list)) != NULL) { list_del(&pool->po_list); LASSERT(pool->po_owner); @@ -1869,7 +1872,7 @@ static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombie spin_lock(&ps->ps_lock); while (!list_empty(&ps->ps_pool_list)) { - struct kib_pool *po = list_entry(ps->ps_pool_list.next, + struct kib_pool *po = list_first_entry(&ps->ps_pool_list, struct kib_pool, po_list); po->po_failed = 1; list_del(&po->po_list); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index ad1726098ea3..b9585f607463 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -98,9 +98,9 @@ kiblnd_txlist_done(struct list_head *txlist, int status) { struct kib_tx *tx; - while (!list_empty(txlist)) { - tx = list_entry(txlist->next, struct kib_tx, tx_list); - + while ((tx = list_first_entry_or_null(txlist, + struct kib_tx, + tx_list)) != NULL) { list_del(&tx->tx_list); /* complete now */ tx->tx_waiting = 0; @@ -958,9 +958,9 @@ kiblnd_check_sends_locked(struct kib_conn *conn) LASSERT(conn->ibc_reserved_credits >= 0); while (conn->ibc_reserved_credits > 0 && - !list_empty(&conn->ibc_tx_queue_rsrvd)) { - tx = list_entry(conn->ibc_tx_queue_rsrvd.next, - struct kib_tx, tx_list); + (tx = list_first_entry_or_null( + &conn->ibc_tx_queue_rsrvd, + struct kib_tx, tx_list)) != NULL) { list_del(&tx->tx_list); list_add_tail(&tx->tx_list, &conn->ibc_tx_queue); conn->ibc_reserved_credits--; @@ -983,17 +983,17 @@ kiblnd_check_sends_locked(struct kib_conn *conn) if (!list_empty(&conn->ibc_tx_queue_nocred)) { credit = 0; - tx = list_entry(conn->ibc_tx_queue_nocred.next, - struct kib_tx, tx_list); + tx = list_first_entry(&conn->ibc_tx_queue_nocred, + struct kib_tx, tx_list); } else if (!list_empty(&conn->ibc_tx_noops)) { LASSERT(!IBLND_OOB_CAPABLE(ver)); credit = 1; - tx = list_entry(conn->ibc_tx_noops.next, - struct kib_tx, tx_list); + tx = list_first_entry(&conn->ibc_tx_noops, + struct kib_tx, tx_list); } else if (!list_empty(&conn->ibc_tx_queue)) { credit = 1; - tx = list_entry(conn->ibc_tx_queue.next, - struct kib_tx, tx_list); + tx = list_first_entry(&conn->ibc_tx_queue, + struct kib_tx, tx_list); } else { break; } @@ -2013,9 +2013,9 @@ kiblnd_handle_early_rxs(struct kib_conn *conn) LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED); write_lock_irqsave(&kiblnd_data.kib_global_lock, flags); - while (!list_empty(&conn->ibc_early_rxs)) { - rx = list_entry(conn->ibc_early_rxs.next, - struct kib_rx, rx_list); + while ((rx = list_first_entry_or_null(&conn->ibc_early_rxs, + struct kib_rx, + rx_list)) != NULL) { list_del(&rx->rx_list); write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); @@ -3311,8 +3311,9 @@ kiblnd_check_conns(int idx) * NOOP, but there were no non-blocking tx descs * free to do it last time... */ - while (!list_empty(&checksends)) { - conn = list_entry(checksends.next, struct kib_conn, ibc_connd_list); + while ((conn = list_first_entry_or_null(&checksends, + struct kib_conn, + ibc_connd_list)) != NULL) { list_del(&conn->ibc_connd_list); spin_lock(&conn->ibc_lock); @@ -3370,11 +3371,12 @@ kiblnd_connd(void *arg) dropped_lock = 0; - if (!list_empty(&kiblnd_data.kib_connd_zombies)) { + conn = list_first_entry_or_null( + &kiblnd_data.kib_connd_zombies, + struct kib_conn, ibc_list); + if (conn) { struct kib_peer_ni *peer_ni = NULL; - conn = list_entry(kiblnd_data.kib_connd_zombies.next, - struct kib_conn, ibc_list); list_del(&conn->ibc_list); if (conn->ibc_reconnect) { peer_ni = conn->ibc_peer; @@ -3401,9 +3403,9 @@ kiblnd_connd(void *arg) &kiblnd_data.kib_reconn_wait); } - if (!list_empty(&kiblnd_data.kib_connd_conns)) { - conn = list_entry(kiblnd_data.kib_connd_conns.next, - struct kib_conn, ibc_list); + conn = list_first_entry_or_null(&kiblnd_data.kib_connd_conns, + struct kib_conn, ibc_list); + if (conn) { list_del(&conn->ibc_list); spin_unlock_irqrestore(lock, flags); @@ -3423,11 +3425,11 @@ kiblnd_connd(void *arg) &kiblnd_data.kib_reconn_list); } - if (list_empty(&kiblnd_data.kib_reconn_list)) + conn = list_first_entry_or_null(&kiblnd_data.kib_reconn_list, + struct kib_conn, ibc_list); + if (!conn) break; - conn = list_entry(kiblnd_data.kib_reconn_list.next, - struct kib_conn, ibc_list); list_del(&conn->ibc_list); spin_unlock_irqrestore(lock, flags); @@ -3636,9 +3638,10 @@ kiblnd_scheduler(void *arg) did_something = 0; - if (!list_empty(&sched->ibs_conns)) { - conn = list_entry(sched->ibs_conns.next, struct kib_conn, - ibc_sched_list); + conn = list_first_entry_or_null(&sched->ibs_conns, + struct kib_conn, + ibc_sched_list); + if (conn) { /* take over kib_sched_conns' ref on conn... */ LASSERT(conn->ibc_scheduled); list_del(&conn->ibc_sched_list); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 785f76cf9067..08feaf7ce33a 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1566,9 +1566,8 @@ ksocknal_finalize_zcreq(struct ksock_conn *conn) spin_unlock(&peer_ni->ksnp_lock); - while (!list_empty(&zlist)) { - tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list); - + while ((tx = list_first_entry_or_null(&zlist, struct ksock_tx, + tx_zc_list)) != NULL) { list_del(&tx->tx_zc_list); ksocknal_tx_decref(tx); } @@ -2267,8 +2266,8 @@ ksocknal_free_buffers(void) list_del_init(&ksocknal_data.ksnd_idle_noop_txs); spin_unlock(&ksocknal_data.ksnd_tx_lock); - while (!list_empty(&zlist)) { - tx = list_entry(zlist.next, struct ksock_tx, tx_list); + while ((tx = list_first_entry_or_null(&zlist, struct ksock_tx, + tx_list)) != NULL) { list_del(&tx->tx_list); kfree(tx); } diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 8e20f430a3f3..208b8d360d5c 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -36,9 +36,9 @@ ksocknal_alloc_tx(int type, int size) /* searching for a noop tx in free list */ spin_lock(&ksocknal_data.ksnd_tx_lock); - if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) { - tx = list_entry(ksocknal_data.ksnd_idle_noop_txs.next, - struct ksock_tx, tx_list); + tx = list_first_entry_or_null(&ksocknal_data.ksnd_idle_noop_txs, + struct ksock_tx, tx_list); + if (tx) { LASSERT(tx->tx_desc_size == size); list_del(&tx->tx_list); } @@ -347,8 +347,8 @@ ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int error) { struct ksock_tx *tx; - while (!list_empty(txlist)) { - tx = list_entry(txlist->next, struct ksock_tx, tx_list); + while ((tx = list_first_entry_or_null(txlist, struct ksock_tx, + tx_list)) != NULL) { if (error && tx->tx_lnetmsg) { CNETERR("Deleting packet type %d len %d %s->%s\n", @@ -1322,9 +1322,10 @@ int ksocknal_scheduler(void *arg) /* Ensure I progress everything semi-fairly */ - if (!list_empty(&sched->kss_rx_conns)) { - conn = list_entry(sched->kss_rx_conns.next, - struct ksock_conn, ksnc_rx_list); + conn = list_first_entry_or_null(&sched->kss_rx_conns, + struct ksock_conn, + ksnc_rx_list); + if (conn) { list_del(&conn->ksnc_rx_list); LASSERT(conn->ksnc_rx_scheduled); @@ -1378,16 +1379,17 @@ int ksocknal_scheduler(void *arg) list_del_init(&sched->kss_zombie_noop_txs); } - conn = list_entry(sched->kss_tx_conns.next, - struct ksock_conn, ksnc_tx_list); + conn = list_first_entry(&sched->kss_tx_conns, + struct ksock_conn, + ksnc_tx_list); list_del(&conn->ksnc_tx_list); LASSERT(conn->ksnc_tx_scheduled); LASSERT(conn->ksnc_tx_ready); LASSERT(!list_empty(&conn->ksnc_tx_queue)); - tx = list_entry(conn->ksnc_tx_queue.next, - struct ksock_tx, tx_list); + tx = list_first_entry(&conn->ksnc_tx_queue, + struct ksock_tx, tx_list); if (conn->ksnc_tx_carrier == tx) ksocknal_next_tx_carrier(conn); @@ -1900,8 +1902,8 @@ ksocknal_connect(struct ksock_route *route) * connection for V1.x and V2.x */ if (!list_empty(&peer_ni->ksnp_conns)) { - conn = list_entry(peer_ni->ksnp_conns.next, - struct ksock_conn, ksnc_list); + conn = list_first_entry(&peer_ni->ksnp_conns, + struct ksock_conn, ksnc_list); LASSERT(conn->ksnc_proto == &ksocknal_protocol_v3x); } @@ -2082,10 +2084,10 @@ ksocknal_connd(void *arg) dropped_lock = 1; } - if (!list_empty(&ksocknal_data.ksnd_connd_connreqs)) { + cr = list_first_entry_or_null(&ksocknal_data.ksnd_connd_connreqs, + struct ksock_connreq, ksncr_list); + if (cr) { /* Connection accepted by the listener */ - cr = list_entry(ksocknal_data.ksnd_connd_connreqs.next, - struct ksock_connreq, ksncr_list); list_del(&cr->ksncr_list); spin_unlock_bh(connd_lock); @@ -2246,9 +2248,9 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer_ni) write_lock_bh(&ksocknal_data.ksnd_global_lock); - while (!list_empty(&peer_ni->ksnp_tx_queue)) { - tx = list_entry(peer_ni->ksnp_tx_queue.next, struct ksock_tx, - tx_list); + while ((tx = list_first_entry_or_null(&peer_ni->ksnp_tx_queue, + struct ksock_tx, + tx_list)) != NULL) { if (ktime_get_seconds() < tx->tx_deadline) break; @@ -2372,19 +2374,16 @@ ksocknal_check_peer_timeouts(int idx) * we can't process stale txs right here because we're * holding only shared lock */ - if (!list_empty(&peer_ni->ksnp_tx_queue)) { - tx = list_entry(peer_ni->ksnp_tx_queue.next, - struct ksock_tx, tx_list); - - if (ktime_get_seconds() >= tx->tx_deadline) { - ksocknal_peer_addref(peer_ni); - read_unlock(&ksocknal_data.ksnd_global_lock); + tx = list_first_entry_or_null(&peer_ni->ksnp_tx_queue, + struct ksock_tx, tx_list); + if (tx && ktime_get_seconds() >= tx->tx_deadline) { + ksocknal_peer_addref(peer_ni); + read_unlock(&ksocknal_data.ksnd_global_lock); - ksocknal_flush_stale_txs(peer_ni); + ksocknal_flush_stale_txs(peer_ni); - ksocknal_peer_decref(peer_ni); - goto again; - } + ksocknal_peer_decref(peer_ni); + goto again; } if (list_empty(&peer_ni->ksnp_zc_req_list)) @@ -2449,9 +2448,9 @@ ksocknal_reaper(void *arg) spin_lock_bh(&ksocknal_data.ksnd_reaper_lock); while (!ksocknal_data.ksnd_shuttingdown) { - if (!list_empty(&ksocknal_data.ksnd_deathrow_conns)) { - conn = list_entry(ksocknal_data.ksnd_deathrow_conns.next, - struct ksock_conn, ksnc_list); + conn = list_first_entry_or_null(&ksocknal_data.ksnd_deathrow_conns, + struct ksock_conn, ksnc_list); + if (conn) { list_del(&conn->ksnc_list); spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock); @@ -2463,9 +2462,9 @@ ksocknal_reaper(void *arg) continue; } - if (!list_empty(&ksocknal_data.ksnd_zombie_conns)) { - conn = list_entry(ksocknal_data.ksnd_zombie_conns.next, - struct ksock_conn, ksnc_list); + conn = list_first_entry_or_null(&ksocknal_data.ksnd_zombie_conns, + struct ksock_conn, ksnc_list); + if (conn) { list_del(&conn->ksnc_list); spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock); @@ -2486,9 +2485,9 @@ ksocknal_reaper(void *arg) /* reschedule all the connections that stalled with ENOMEM... */ nenomem_conns = 0; - while (!list_empty(&enomem_conns)) { - conn = list_entry(enomem_conns.next, struct ksock_conn, - ksnc_tx_list); + while ((conn = list_first_entry_or_null(&enomem_conns, + struct ksock_conn, + ksnc_tx_list)) != NULL) { list_del(&conn->ksnc_tx_list); sched = conn->ksnc_scheduler; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index c694feceaaf2..e8b95affee96 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -447,8 +447,8 @@ ksocknal_handle_zcack(struct ksock_conn *conn, u64 cookie1, u64 cookie2) spin_unlock(&peer_ni->ksnp_lock); - while (!list_empty(&zlist)) { - tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list); + while ((tx = list_first_entry_or_null(&zlist, struct ksock_tx, + tx_zc_list)) != NULL) { list_del(&tx->tx_zc_list); ksocknal_tx_decref(tx); } From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 08/21] lustre: use list_first_entry() throughout In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781303.10620.10579175228046856433.stgit@noble.brown> Convert list_entry(foo->next .....) to list_first_entry(foo, ....) in remainder of lustre. In several cases the call is combined with a list_empty() test and list_first_entry_or_null() is used Signed-off-by: NeilBrown --- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 12 +++-- drivers/staging/lustre/lnet/selftest/conrpc.c | 5 +- drivers/staging/lustre/lnet/selftest/console.c | 39 ++++++++---------- drivers/staging/lustre/lnet/selftest/framework.c | 44 ++++++++++---------- drivers/staging/lustre/lnet/selftest/rpc.c | 27 ++++++------ drivers/staging/lustre/lnet/selftest/timer.c | 4 +- 6 files changed, 62 insertions(+), 69 deletions(-) diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c index 5fb85247525d..ae17b4d44cac 100644 --- a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c @@ -468,11 +468,11 @@ EXPORT_SYMBOL(cfs_expr_list_values); void cfs_expr_list_free(struct cfs_expr_list *expr_list) { - while (!list_empty(&expr_list->el_exprs)) { - struct cfs_range_expr *expr; + struct cfs_range_expr *expr; - expr = list_entry(expr_list->el_exprs.next, - struct cfs_range_expr, re_link); + while ((expr = list_first_entry_or_null(&expr_list->el_exprs, + struct cfs_range_expr, + re_link)) != NULL) { list_del(&expr->re_link); kfree(expr); } @@ -553,8 +553,8 @@ cfs_expr_list_free_list(struct list_head *list) { struct cfs_expr_list *el; - while (!list_empty(list)) { - el = list_entry(list->next, struct cfs_expr_list, el_link); + while ((el = list_first_entry_or_null(list, struct cfs_expr_list, + el_link)) != NULL) { list_del(&el->el_link); cfs_expr_list_free(el); } diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index d9bcfa8c92ae..af0d2aa3b6e8 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -1362,9 +1362,8 @@ lstcon_rpc_cleanup_wait(void) spin_unlock(&console_session.ses_rpc_lock); - while (!list_empty(&zlist)) { - crpc = list_entry(zlist.next, struct lstcon_rpc, crp_link); - + while ((crpc = list_first_entry_or_null(&zlist, struct lstcon_rpc, + crp_link)) != NULL) { list_del(&crpc->crp_link); kfree(crpc); } diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 045d79f44321..abc342c6a842 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -330,11 +330,10 @@ lstcon_group_move(struct lstcon_group *old, struct lstcon_group *new) { struct lstcon_ndlink *ndl; - while (!list_empty(&old->grp_ndl_list)) { - ndl = list_entry(old->grp_ndl_list.next, - struct lstcon_ndlink, ndl_link); + while ((ndl = list_first_entry_or_null(&old->grp_ndl_list, + struct lstcon_ndlink, + ndl_link)) != NULL) lstcon_group_ndlink_move(old, new, ndl); - } } static int @@ -1095,9 +1094,9 @@ lstcon_batch_destroy(struct lstcon_batch *bat) list_del(&bat->bat_link); - while (!list_empty(&bat->bat_test_list)) { - test = list_entry(bat->bat_test_list.next, - struct lstcon_test, tes_link); + while ((test = list_first_entry_or_null(&bat->bat_test_list, + struct lstcon_test, + tes_link)) != NULL) { LASSERT(list_empty(&test->tes_trans_list)); list_del(&test->tes_link); @@ -1110,17 +1109,17 @@ lstcon_batch_destroy(struct lstcon_batch *bat) LASSERT(list_empty(&bat->bat_trans_list)); - while (!list_empty(&bat->bat_cli_list)) { - ndl = list_entry(bat->bat_cli_list.next, - struct lstcon_ndlink, ndl_link); + while ((ndl = list_first_entry_or_null(&bat->bat_cli_list, + struct lstcon_ndlink, + ndl_link)) != NULL) { list_del_init(&ndl->ndl_link); lstcon_ndlink_release(ndl); } - while (!list_empty(&bat->bat_srv_list)) { - ndl = list_entry(bat->bat_srv_list.next, - struct lstcon_ndlink, ndl_link); + while ((ndl = list_first_entry_or_null(&bat->bat_srv_list, + struct lstcon_ndlink, + ndl_link)) != NULL) { list_del_init(&ndl->ndl_link); lstcon_ndlink_release(ndl); @@ -1844,17 +1843,15 @@ lstcon_session_end(void) console_session.ses_feats_updated = 0; /* destroy all batches */ - while (!list_empty(&console_session.ses_bat_list)) { - bat = list_entry(console_session.ses_bat_list.next, - struct lstcon_batch, bat_link); - + while ((bat = list_first_entry_or_null(&console_session.ses_bat_list, + struct lstcon_batch, + bat_link)) != NULL) lstcon_batch_destroy(bat); - } /* destroy all groups */ - while (!list_empty(&console_session.ses_grp_list)) { - grp = list_entry(console_session.ses_grp_list.next, - struct lstcon_group, grp_link); + while ((grp = list_first_entry_or_null(&console_session.ses_grp_list, + struct lstcon_group, + grp_link)) != NULL) { LASSERT(grp->grp_ref == 1); lstcon_group_decref(grp); diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index a82efc394659..958f627580e7 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -628,16 +628,16 @@ sfw_destroy_test_instance(struct sfw_test_instance *tsi) LASSERT(list_empty(&tsi->tsi_active_rpcs)); LASSERT(!sfw_test_active(tsi)); - while (!list_empty(&tsi->tsi_units)) { - tsu = list_entry(tsi->tsi_units.next, - struct sfw_test_unit, tsu_list); + while ((tsu = list_first_entry_or_null(&tsi->tsi_units, + struct sfw_test_unit, + tsu_list)) != NULL) { list_del(&tsu->tsu_list); kfree(tsu); } - while (!list_empty(&tsi->tsi_free_rpcs)) { - rpc = list_entry(tsi->tsi_free_rpcs.next, - struct srpc_client_rpc, crpc_list); + while ((rpc = list_first_entry_or_null(&tsi->tsi_free_rpcs, + struct srpc_client_rpc, + crpc_list)) != NULL) { list_del(&rpc->crpc_list); kfree(rpc); } @@ -655,9 +655,9 @@ sfw_destroy_batch(struct sfw_batch *tsb) LASSERT(!sfw_batch_active(tsb)); LASSERT(list_empty(&tsb->bat_list)); - while (!list_empty(&tsb->bat_tests)) { - tsi = list_entry(tsb->bat_tests.next, - struct sfw_test_instance, tsi_list); + while ((tsi = list_first_entry_or_null(&tsb->bat_tests, + struct sfw_test_instance, + tsi_list)) != NULL) { list_del_init(&tsi->tsi_list); sfw_destroy_test_instance(tsi); } @@ -673,9 +673,9 @@ sfw_destroy_session(struct sfw_session *sn) LASSERT(list_empty(&sn->sn_list)); LASSERT(sn != sfw_data.fw_session); - while (!list_empty(&sn->sn_batches)) { - batch = list_entry(sn->sn_batches.next, - struct sfw_batch, bat_list); + while ((batch = list_first_entry_or_null(&sn->sn_batches, + struct sfw_batch, + bat_list)) != NULL) { list_del_init(&batch->bat_list); sfw_destroy_batch(batch); } @@ -1389,8 +1389,8 @@ sfw_create_rpc(struct lnet_process_id peer, int service, LASSERT(service <= SRPC_FRAMEWORK_SERVICE_MAX_ID); if (!nbulkiov && !list_empty(&sfw_data.fw_zombie_rpcs)) { - rpc = list_entry(sfw_data.fw_zombie_rpcs.next, - struct srpc_client_rpc, crpc_list); + rpc = list_first_entry(&sfw_data.fw_zombie_rpcs, + struct srpc_client_rpc, crpc_list); list_del(&rpc->crpc_list); srpc_init_client_rpc(rpc, peer, service, 0, 0, @@ -1722,6 +1722,7 @@ sfw_shutdown(void) { struct srpc_service *sv; struct sfw_test_case *tsc; + struct srpc_client_rpc *rpc; int i; spin_lock(&sfw_data.fw_lock); @@ -1757,11 +1758,9 @@ sfw_shutdown(void) srpc_remove_service(sv); } - while (!list_empty(&sfw_data.fw_zombie_rpcs)) { - struct srpc_client_rpc *rpc; - - rpc = list_entry(sfw_data.fw_zombie_rpcs.next, - struct srpc_client_rpc, crpc_list); + while ((rpc = list_first_entry_or_null(&sfw_data.fw_zombie_rpcs, + struct srpc_client_rpc, + crpc_list)) != NULL) { list_del(&rpc->crpc_list); kfree(rpc); @@ -1775,10 +1774,9 @@ sfw_shutdown(void) srpc_wait_service_shutdown(sv); } - while (!list_empty(&sfw_data.fw_tests)) { - tsc = list_entry(sfw_data.fw_tests.next, - struct sfw_test_case, tsc_list); - + while ((tsc = list_first_entry_or_null(&sfw_data.fw_tests, + struct sfw_test_case, + tsc_list)) != NULL) { srpc_wait_service_shutdown(tsc->tsc_srv_service); list_del(&tsc->tsc_list); diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 2a3010774dbe..abb6f8fb011e 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -210,9 +210,9 @@ srpc_service_fini(struct srpc_service *svc) else break; - while (!list_empty(q)) { - buf = list_entry(q->next, struct srpc_buffer, - buf_list); + while ((buf = list_first_entry_or_null( + q, struct srpc_buffer, + buf_list)) != NULL) { list_del(&buf->buf_list); kfree(buf); } @@ -220,10 +220,9 @@ srpc_service_fini(struct srpc_service *svc) LASSERT(list_empty(&scd->scd_rpc_active)); - while (!list_empty(&scd->scd_rpc_free)) { - rpc = list_entry(scd->scd_rpc_free.next, - struct srpc_server_rpc, - srpc_list); + while ((rpc = list_first_entry_or_null(&scd->scd_rpc_free, + struct srpc_server_rpc, + srpc_list)) != NULL) { list_del(&rpc->srpc_list); kfree(rpc); } @@ -674,8 +673,8 @@ srpc_finish_service(struct srpc_service *sv) continue; } - rpc = list_entry(scd->scd_rpc_active.next, - struct srpc_server_rpc, srpc_list); + rpc = list_first_entry(&scd->scd_rpc_active, + struct srpc_server_rpc, srpc_list); CNETERR("Active RPC %p on shutdown: sv %s, peer %s, wi %s, ev fired %d type %d status %d lnet %d\n", rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer), swi_state2str(rpc->srpc_wi.swi_state), @@ -943,8 +942,8 @@ srpc_server_rpc_done(struct srpc_server_rpc *rpc, int status) LASSERT(rpc->srpc_ev.ev_fired); if (!sv->sv_shuttingdown && !list_empty(&scd->scd_buf_blocked)) { - buffer = list_entry(scd->scd_buf_blocked.next, - struct srpc_buffer, buf_list); + buffer = list_first_entry(&scd->scd_buf_blocked, + struct srpc_buffer, buf_list); list_del(&buffer->buf_list); srpc_init_server_rpc(rpc, scd, buffer); @@ -1535,9 +1534,9 @@ srpc_lnet_ev_handler(struct lnet_event *ev) } if (!list_empty(&scd->scd_rpc_free)) { - srpc = list_entry(scd->scd_rpc_free.next, - struct srpc_server_rpc, - srpc_list); + srpc = list_first_entry(&scd->scd_rpc_free, + struct srpc_server_rpc, + srpc_list); list_del(&srpc->srpc_list); srpc_init_server_rpc(srpc, scd, buffer); diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index c83473ebb368..bb61e3aa11e9 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -125,8 +125,8 @@ stt_expire_list(struct list_head *slot, time64_t now) int expired = 0; struct stt_timer *timer; - while (!list_empty(slot)) { - timer = list_entry(slot->next, struct stt_timer, stt_list); + while ((timer = list_first_entry_or_null(slot, struct stt_timer, + stt_list)) != NULL) { if (timer->stt_expires > now) break; From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 09/21] lustre: use list_last_entry() throughout In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781307.10620.3918792136275031845.stgit@noble.brown> Convert list_entry(foo->prev .....) to list_last_entry(foo, ....) throughout lustre. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 6 +++--- drivers/staging/lustre/lustre/ptlrpc/service.c | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 53fd8d469e55..bf7678aed6bf 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2329,7 +2329,7 @@ do { \ static inline struct cl_page *cl_page_list_last(struct cl_page_list *plist) { LASSERT(plist->pl_nr > 0); - return list_entry(plist->pl_pages.prev, struct cl_page, cp_batch); + return list_last_entry(&plist->pl_pages, struct cl_page, cp_batch); } static inline struct cl_page *cl_page_list_first(struct cl_page_list *plist) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index a78d49621c42..b2b11047ea19 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -1464,9 +1464,9 @@ static int after_reply(struct ptlrpc_request *req) if (!list_empty(&imp->imp_replay_list)) { struct ptlrpc_request *last; - last = list_entry(imp->imp_replay_list.prev, - struct ptlrpc_request, - rq_replay_list); + last = list_last_entry(&imp->imp_replay_list, + struct ptlrpc_request, + rq_replay_list); /* * Requests with rq_replay stay on the list even if no * commit is expected. diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index a69736dfe8b7..35a59e5a5e9d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -2255,8 +2255,9 @@ static int ptlrpc_hr_main(void *arg) while (!list_empty(&replies)) { struct ptlrpc_reply_state *rs; - rs = list_entry(replies.prev, struct ptlrpc_reply_state, - rs_list); + rs = list_last_entry(&replies, + struct ptlrpc_reply_state, + rs_list); list_del_init(&rs->rs_list); ptlrpc_handle_rs(rs); } From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781310.10620.8883358407999258821.stgit@noble.brown> There are various places which have a list_for_each_entry() where cl_object_for_each (or .._reverse) is more appropriate. Several of these re-use the 'obj' function parameter as a loop iterator, which is a little confusing. Change these to use cl_object_for_each{_reverse}, and where needed, introduce a new iterator variable 'o'. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/lov/lov_page.c | 3 - drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 - drivers/staging/lustre/lustre/obdclass/cl_object.c | 82 +++++++++----------- drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 +-- 4 files changed, 44 insertions(+), 55 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 08485a95ec01..e64b350601d2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -103,8 +103,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, return PTR_ERR(sub); subobj = lovsub2cl(r0->lo_sub[stripe]); - list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers, - co_lu.lo_linkage) { + cl_object_for_each(o, subobj) { if (o->co_ops->coo_page_init) { rc = o->co_ops->coo_page_init(sub->sub_env, o, page, cl_index(subobj, suboff)); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 8133d992cc73..fc5976d8b37b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -103,8 +103,7 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, LASSERT(obj); INIT_LIST_HEAD(&lock->cll_layers); - list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, - co_lu.lo_linkage) { + cl_object_for_each(scan, obj) { result = scan->co_ops->coo_lock_init(env, scan, lock, io); if (result != 0) { cl_lock_fini(env, lock); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f724b2d62df1..d71a680660da 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -190,16 +190,15 @@ EXPORT_SYMBOL(cl_object_attr_unlock); int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, struct cl_attr *attr) { - struct lu_object_header *top; + struct cl_object *o; int result; assert_spin_locked(cl_object_attr_guard(obj)); - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_get) { - result = obj->co_ops->coo_attr_get(env, obj, attr); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_attr_get) { + result = o->co_ops->coo_attr_get(env, o, attr); if (result != 0) { if (result > 0) result = 0; @@ -221,17 +220,16 @@ EXPORT_SYMBOL(cl_object_attr_get); int cl_object_attr_update(const struct lu_env *env, struct cl_object *obj, const struct cl_attr *attr, unsigned int v) { - struct lu_object_header *top; + struct cl_object *o; int result; assert_spin_locked(cl_object_attr_guard(obj)); - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_update) { - result = obj->co_ops->coo_attr_update(env, obj, attr, - v); + cl_object_for_each_reverse(o, obj) { + if (o->co_ops->coo_attr_update) { + result = o->co_ops->coo_attr_update(env, o, attr, + v); if (result != 0) { if (result > 0) result = 0; @@ -254,19 +252,18 @@ EXPORT_SYMBOL(cl_object_attr_update); int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, struct ost_lvb *lvb) { - struct lu_object_header *top; + struct cl_object *o; int result; - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_glimpse) { - result = obj->co_ops->coo_glimpse(env, obj, lvb); + cl_object_for_each_reverse(o, obj) { + if (o->co_ops->coo_glimpse) { + result = o->co_ops->coo_glimpse(env, o, lvb); if (result != 0) break; } } - LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), + LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(obj->co_lu.lo_header), "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); @@ -280,14 +277,13 @@ EXPORT_SYMBOL(cl_object_glimpse); int cl_conf_set(const struct lu_env *env, struct cl_object *obj, const struct cl_object_conf *conf) { - struct lu_object_header *top; + struct cl_object *o; int result; - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_conf_set) { - result = obj->co_ops->coo_conf_set(env, obj, conf); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_conf_set) { + result = o->co_ops->coo_conf_set(env, o, conf); if (result != 0) break; } @@ -301,13 +297,11 @@ EXPORT_SYMBOL(cl_conf_set); */ int cl_object_prune(const struct lu_env *env, struct cl_object *obj) { - struct lu_object_header *top; struct cl_object *o; int result; - top = obj->co_lu.lo_header; result = 0; - list_for_each_entry(o, &top->loh_layers, co_lu.lo_linkage) { + cl_object_for_each(o, obj) { if (o->co_ops->coo_prune) { result = o->co_ops->coo_prune(env, o); if (result != 0) @@ -325,14 +319,13 @@ EXPORT_SYMBOL(cl_object_prune); int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, struct lov_user_md __user *uarg, size_t size) { - struct lu_object_header *top; + struct cl_object *o; int result = 0; - top = obj->co_lu.lo_header; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_getstripe) { - result = obj->co_ops->coo_getstripe(env, obj, uarg, - size); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_getstripe) { + result = o->co_ops->coo_getstripe(env, o, uarg, + size); if (result) break; } @@ -357,14 +350,13 @@ int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj, struct ll_fiemap_info_key *key, struct fiemap *fiemap, size_t *buflen) { - struct lu_object_header *top; + struct cl_object *o; int result = 0; - top = obj->co_lu.lo_header; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_fiemap) { - result = obj->co_ops->coo_fiemap(env, obj, key, fiemap, - buflen); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_fiemap) { + result = o->co_ops->coo_fiemap(env, o, key, fiemap, + buflen); if (result) break; } @@ -376,11 +368,11 @@ EXPORT_SYMBOL(cl_object_fiemap); int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, struct cl_layout *cl) { - struct lu_object_header *top = obj->co_lu.lo_header; + struct cl_object *o; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_layout_get) - return obj->co_ops->coo_layout_get(env, obj, cl); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_layout_get) + return o->co_ops->coo_layout_get(env, o, cl); } return -EOPNOTSUPP; @@ -389,12 +381,12 @@ EXPORT_SYMBOL(cl_object_layout_get); loff_t cl_object_maxbytes(struct cl_object *obj) { - struct lu_object_header *top = obj->co_lu.lo_header; + struct cl_object *o; loff_t maxbytes = LLONG_MAX; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_maxbytes) - maxbytes = min_t(loff_t, obj->co_ops->coo_maxbytes(obj), + cl_object_for_each(o, obj) { + if (o->co_ops->coo_maxbytes) + maxbytes = min_t(loff_t, o->co_ops->coo_maxbytes(o), maxbytes); } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 057318deaa4e..7d00a9233a3b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -132,7 +132,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, enum cl_page_type type) { struct cl_page *page; - struct lu_object_header *head; + struct cl_object *o2; page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); if (page) { @@ -149,11 +149,10 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, INIT_LIST_HEAD(&page->cp_layers); INIT_LIST_HEAD(&page->cp_batch); lu_ref_init(&page->cp_reference); - head = o->co_lu.lo_header; - list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { - if (o->co_ops->coo_page_init) { - result = o->co_ops->coo_page_init(env, o, page, - ind); + cl_object_for_each(o2, o) { + if (o2->co_ops->coo_page_init) { + result = o2->co_ops->coo_page_init(env, o2, page, + ind); if (result != 0) { __cl_page_delete(env, page); cl_page_free(env, page); From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781313.10620.6363156783936746853.stgit@noble.brown> cl_env_inc() and cl_env_dec() don't do anything, so discard them. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index d71a680660da..1e704078664e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -565,14 +565,6 @@ struct cl_env { void *ce_debug; }; -static void cl_env_inc(enum cache_stats_item item) -{ -} - -static void cl_env_dec(enum cache_stats_item item) -{ -} - static void cl_env_init0(struct cl_env *cle, void *debug) { LASSERT(cle->ce_ref == 0); @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) cle->ce_ref = 1; cle->ce_debug = debug; - cl_env_inc(CS_busy); } static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) if (rc != 0) { kmem_cache_free(cl_env_kmem, cle); env = ERR_PTR(rc); - } else { - cl_env_inc(CS_create); - cl_env_inc(CS_total); } } else { env = ERR_PTR(-ENOMEM); @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) static void cl_env_fini(struct cl_env *cle) { - cl_env_dec(CS_total); lu_context_fini(&cle->ce_lu.le_ctx); lu_context_fini(&cle->ce_ses); kmem_cache_free(cl_env_kmem, cle); @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) if (--cle->ce_ref == 0) { int cpu = get_cpu(); - cl_env_dec(CS_busy); cle->ce_debug = NULL; cl_env_exit(cle); /* @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) cle->ce_ref--; LASSERT(cle->ce_ref == 0); - cl_env_dec(CS_busy); cle->ce_debug = NULL; put_cpu(); From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 12/21] lustre: cl_page.c: remove PINVRNT() In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781317.10620.17224594880512218856.stgit@noble.brown> This macro does nothing (it once was like 'assert'), so remove it. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/cl_page.c | 33 ---------------------- 1 file changed, 33 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 7d00a9233a3b..31ded52e0499 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -55,9 +55,6 @@ static void __cl_page_delete(const struct lu_env *env, struct cl_page *pg); } \ } while (0) -# define PINVRNT(env, page, exp) \ - ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp)) - /** * Internal version of cl_page_get(). * @@ -382,8 +379,6 @@ void __cl_page_disown(const struct lu_env *env, enum cl_page_state state; state = pg->cp_state; - PINVRNT(env, pg, state == CPS_OWNED || state == CPS_FREEING); - PINVRNT(env, pg, cl_page_invariant(pg) || state == CPS_FREEING); cl_page_owner_clear(pg); if (state == CPS_OWNED) @@ -437,8 +432,6 @@ static int __cl_page_own(const struct lu_env *env, struct cl_io *io, const struct cl_page_slice *slice; int result = 0; - PINVRNT(env, pg, !cl_page_is_owned(pg, io)); - io = cl_io_top(io); if (pg->cp_state == CPS_FREEING) { @@ -468,7 +461,6 @@ static int __cl_page_own(const struct lu_env *env, struct cl_io *io, } } out: - PINVRNT(env, pg, ergo(result == 0, cl_page_invariant(pg))); return result; } @@ -510,8 +502,6 @@ void cl_page_assume(const struct lu_env *env, { const struct cl_page_slice *slice; - PINVRNT(env, pg, cl_object_same(pg->cp_obj, io->ci_obj)); - io = cl_io_top(io); list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { @@ -542,9 +532,6 @@ void cl_page_unassume(const struct lu_env *env, { const struct cl_page_slice *slice; - PINVRNT(env, pg, cl_page_is_owned(pg, io)); - PINVRNT(env, pg, cl_page_invariant(pg)); - io = cl_io_top(io); cl_page_owner_clear(pg); cl_page_state_set(env, pg, CPS_CACHED); @@ -570,9 +557,6 @@ EXPORT_SYMBOL(cl_page_unassume); void cl_page_disown(const struct lu_env *env, struct cl_io *io, struct cl_page *pg) { - PINVRNT(env, pg, cl_page_is_owned(pg, io) || - pg->cp_state == CPS_FREEING); - io = cl_io_top(io); __cl_page_disown(env, io, pg); } @@ -593,9 +577,6 @@ void cl_page_discard(const struct lu_env *env, { const struct cl_page_slice *slice; - PINVRNT(env, pg, cl_page_is_owned(pg, io)); - PINVRNT(env, pg, cl_page_invariant(pg)); - list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { if (slice->cpl_ops->cpo_discard) (*slice->cpl_ops->cpo_discard)(env, slice, io); @@ -652,7 +633,6 @@ static void __cl_page_delete(const struct lu_env *env, struct cl_page *pg) */ void cl_page_delete(const struct lu_env *env, struct cl_page *pg) { - PINVRNT(env, pg, cl_page_invariant(pg)); __cl_page_delete(env, pg); } EXPORT_SYMBOL(cl_page_delete); @@ -670,8 +650,6 @@ void cl_page_export(const struct lu_env *env, struct cl_page *pg, int uptodate) { const struct cl_page_slice *slice; - PINVRNT(env, pg, cl_page_invariant(pg)); - list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { if (slice->cpl_ops->cpo_export) (*slice->cpl_ops->cpo_export)(env, slice, uptodate); @@ -730,10 +708,6 @@ int cl_page_prep(const struct lu_env *env, struct cl_io *io, const struct cl_page_slice *slice; int result = 0; - PINVRNT(env, pg, cl_page_is_owned(pg, io)); - PINVRNT(env, pg, cl_page_invariant(pg)); - PINVRNT(env, pg, crt < CRT_NR); - /* * XXX this has to be called bottom-to-top, so that llite can set up * PG_writeback without risking other layers deciding to skip this @@ -819,8 +793,6 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg, const struct cl_page_slice *sli; int result = 0; - PINVRNT(env, pg, crt < CRT_NR); - if (crt >= CRT_NR) return -EINVAL; @@ -856,9 +828,6 @@ int cl_page_flush(const struct lu_env *env, struct cl_io *io, const struct cl_page_slice *slice; int result = 0; - PINVRNT(env, pg, cl_page_is_owned(pg, io)); - PINVRNT(env, pg, cl_page_invariant(pg)); - list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { if (slice->cpl_ops->cpo_flush) result = (*slice->cpl_ops->cpo_flush)(env, slice, io); @@ -883,8 +852,6 @@ void cl_page_clip(const struct lu_env *env, struct cl_page *pg, { const struct cl_page_slice *slice; - PINVRNT(env, pg, cl_page_invariant(pg)); - CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", from, to); list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 13/21] lustre: make cp_ref in cl_page a refcount_t In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781321.10620.15836497514344103445.stgit@noble.brown> As this is used as a refcount, it should be declared as one. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 4 ++-- drivers/staging/lustre/lustre/llite/vvp_page.c | 9 +++++---- drivers/staging/lustre/lustre/obdclass/cl_page.c | 14 +++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index bf7678aed6bf..c2273c3100e8 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -717,7 +717,7 @@ enum cl_page_type { */ struct cl_page { /** Reference counter. */ - atomic_t cp_ref; + refcount_t cp_ref; /** An object this page is a part of. Immutable after creation. */ struct cl_object *cp_obj; /** vmpage */ @@ -1021,7 +1021,7 @@ static inline struct page *cl_page_vmpage(struct cl_page *page) */ static inline bool __page_in_use(const struct cl_page *page, int refc) { - return (atomic_read(&page->cp_ref) > refc + 1); + return (refcount_read(&page->cp_ref) > refc + 1); } /** diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 77bf923f2578..ec0d93313f55 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -157,15 +157,16 @@ static void vvp_page_delete(const struct lu_env *env, struct inode *inode = vmpage->mapping->host; struct cl_object *obj = slice->cpl_obj; struct cl_page *page = slice->cpl_page; - int refc; LASSERT(PageLocked(vmpage)); LASSERT((struct cl_page *)vmpage->private == page); LASSERT(inode == vvp_object_inode(obj)); /* Drop the reference count held in vvp_page_init */ - refc = atomic_dec_return(&page->cp_ref); - LASSERTF(refc >= 1, "page = %p, refc = %d\n", page, refc); + if (refcount_dec_and_test(&page->cp_ref)) { + /* It mustn't reach zero here! */ + LASSERTF(0, "page = %p, refc reached zero\n", page); + } ClearPagePrivate(vmpage); vmpage->private = 0; @@ -507,7 +508,7 @@ int vvp_page_init(const struct lu_env *env, struct cl_object *obj, if (page->cp_type == CPT_CACHEABLE) { /* in cache, decref in vvp_page_delete */ - atomic_inc(&page->cp_ref); + refcount_inc(&page->cp_ref); SetPagePrivate(vmpage); vmpage->private = (unsigned long)page; cl_page_slice_add(page, &vpg->vpg_cl, obj, index, diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 31ded52e0499..f0ece7e9a4ac 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -67,8 +67,8 @@ static void __cl_page_delete(const struct lu_env *env, struct cl_page *pg); */ static void cl_page_get_trust(struct cl_page *page) { - LASSERT(atomic_read(&page->cp_ref) > 0); - atomic_inc(&page->cp_ref); + LASSERT(refcount_read(&page->cp_ref) > 0); + refcount_inc(&page->cp_ref); } /** @@ -135,7 +135,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, if (page) { int result = 0; - atomic_set(&page->cp_ref, 1); + refcount_set(&page->cp_ref, 1); page->cp_obj = o; cl_object_get(o); lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page", @@ -310,12 +310,12 @@ EXPORT_SYMBOL(cl_page_get); void cl_page_put(const struct lu_env *env, struct cl_page *page) { CL_PAGE_HEADER(D_TRACE, env, page, "%d\n", - atomic_read(&page->cp_ref)); + refcount_read(&page->cp_ref)); - if (atomic_dec_and_test(&page->cp_ref)) { + if (refcount_dec_and_test(&page->cp_ref)) { LASSERT(page->cp_state == CPS_FREEING); - LASSERT(atomic_read(&page->cp_ref) == 0); + LASSERT(refcount_read(&page->cp_ref) == 0); PASSERT(env, page, !page->cp_owner); PASSERT(env, page, list_empty(&page->cp_batch)); /* @@ -869,7 +869,7 @@ void cl_page_header_print(const struct lu_env *env, void *cookie, { (*printer)(env, cookie, "page@%p[%d %p %d %d %p]\n", - pg, atomic_read(&pg->cp_ref), pg->cp_obj, + pg, refcount_read(&pg->cp_ref), pg->cp_obj, pg->cp_state, pg->cp_type, pg->cp_owner); } From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 14/21] lustre: make ccc_users in cl_client_cache a refcount_t In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781324.10620.6961645123977299300.stgit@noble.brown> As this is used as a refcount, it should be declared as one. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_page.c | 6 +++--- drivers/staging/lustre/lustre/osc/osc_page.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index c2273c3100e8..05be85306663 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2181,7 +2181,7 @@ struct cl_client_cache { * # of client cache refcount * # of users (OSCs) + 2 (held by llite and lov) */ - atomic_t ccc_users; + refcount_t ccc_users; /** * # of threads are doing shrinking */ diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 001bed90f4da..8215296dc15d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -467,7 +467,7 @@ static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v) "used_mb: %ld\n" "unused_mb: %ld\n" "reclaim_count: %u\n", - atomic_read(&cache->ccc_users), + refcount_read(&cache->ccc_users), max_cached_mb, max_cached_mb - unused_mb, unused_mb, diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index f0ece7e9a4ac..7dcd3aff229f 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -960,7 +960,7 @@ struct cl_client_cache *cl_cache_init(unsigned long lru_page_max) return NULL; /* Initialize cache data */ - atomic_set(&cache->ccc_users, 1); + refcount_set(&cache->ccc_users, 1); cache->ccc_lru_max = lru_page_max; atomic_long_set(&cache->ccc_lru_left, lru_page_max); spin_lock_init(&cache->ccc_lru_lock); @@ -978,7 +978,7 @@ EXPORT_SYMBOL(cl_cache_init); */ void cl_cache_incref(struct cl_client_cache *cache) { - atomic_inc(&cache->ccc_users); + refcount_inc(&cache->ccc_users); } EXPORT_SYMBOL(cl_cache_incref); @@ -989,7 +989,7 @@ EXPORT_SYMBOL(cl_cache_incref); */ void cl_cache_decref(struct cl_client_cache *cache) { - if (atomic_dec_and_test(&cache->ccc_users)) + if (refcount_dec_and_test(&cache->ccc_users)) kfree(cache); } EXPORT_SYMBOL(cl_cache_decref); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 135bfe5e1b37..ce911b82512d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -346,7 +346,7 @@ static int osc_cache_too_much(struct client_obd *cli) long pages = atomic_long_read(&cli->cl_lru_in_list); unsigned long budget; - budget = cache->ccc_lru_max / (atomic_read(&cache->ccc_users) - 2); + budget = cache->ccc_lru_max / (refcount_read(&cache->ccc_users) - 2); /* if it's going to run out LRU slots, we should free some, but not * too much to maintain fairness among OSCs. @@ -707,7 +707,7 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) cache->ccc_lru_shrinkers++; list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru); - max_scans = atomic_read(&cache->ccc_users) - 2; + max_scans = refcount_read(&cache->ccc_users) - 2; while (--max_scans > 0 && (cli = list_first_entry_or_null(&cache->ccc_lru, struct client_obd, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 9e72fa8f68b3..0dfc506f6d01 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2959,7 +2959,7 @@ static int osc_cleanup(struct obd_device *obd) /* lru cleanup */ if (cli->cl_cache) { - LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0); + LASSERT(refcount_read(&cli->cl_cache->ccc_users) > 0); spin_lock(&cli->cl_cache->ccc_lru_lock); list_del_init(&cli->cl_lru_osc); spin_unlock(&cli->cl_cache->ccc_lru_lock); From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 15/21] lustre: obdclass: char obd_ioctl_getdata type. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781327.10620.2294752316778817915.stgit@noble.brown> Instead of having obd_ioctl_getdata() return the allocated data as a "char *", return it as it really is, struct obd_ioctl_data * This avoids the need for extra variables and casts. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd_class.h | 3 ++- drivers/staging/lustre/lustre/llite/dir.c | 17 +++++------------ drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +++----- drivers/staging/lustre/lustre/lov/lov_obd.c | 15 ++++++--------- drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 ++++++++---------- 5 files changed, 24 insertions(+), 37 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 30b3e2c69f83..32d4ab6e78a0 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1697,6 +1697,7 @@ struct root_squash_info { }; /* linux-module.c */ -int obd_ioctl_getdata(char **buf, int *len, void __user *arg); +struct obd_ioctl_data; +int obd_ioctl_getdata(struct obd_ioctl_data **data, int *len, void __user *arg); #endif /* __LINUX_OBD_CLASS_H */ diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index fd1af4a5cdad..0c49244eaee8 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1130,13 +1130,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } case IOC_MDC_LOOKUP: { int namelen, len = 0; - char *buf = NULL; char *filename; - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); if (rc) return rc; - data = (void *)buf; filename = data->ioc_inlbuf1; namelen = strlen(filename); @@ -1155,12 +1153,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) goto out_free; } out_free: - kvfree(buf); + kvfree(data); return rc; } case LL_IOC_LMV_SETSTRIPE: { struct lmv_user_md *lum; - char *buf = NULL; char *filename; int namelen = 0; int lumlen = 0; @@ -1168,11 +1165,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) int len; int rc; - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); if (rc) return rc; - data = (void *)buf; if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0) { rc = -EINVAL; @@ -1205,7 +1201,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) #endif rc = ll_dir_setdirstripe(dentry, lum, filename, mode); lmv_out_free: - kvfree(buf); + kvfree(data); return rc; } case LL_IOC_LMV_SET_DEFAULT_STRIPE: { @@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return rc; } case LL_IOC_MIGRATE: { - char *buf = NULL; const char *filename; int namelen = 0; int len; int rc; int mdtidx; - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); if (rc < 0) return rc; - data = (struct obd_ioctl_data *)buf; if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || !data->ioc_inllen1 || !data->ioc_inllen2) { rc = -EINVAL; @@ -1684,7 +1678,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1); migrate_free: - kvfree(buf); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 8e09fdd7a96e..e2417cd5aaed 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2295,7 +2295,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) { struct ll_sb_info *sbi = NULL; struct obd_export *exp; - char *buf = NULL; struct obd_ioctl_data *data = NULL; u32 type; int len = 0, rc; @@ -2311,11 +2310,10 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) goto out_statfs; } - rc = obd_ioctl_getdata(&buf, &len, arg); + rc = obd_ioctl_getdata(&data, &len, arg); if (rc) goto out_statfs; - data = (void *)buf; if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || !data->ioc_pbuf1 || !data->ioc_pbuf2) { rc = -EINVAL; @@ -2340,11 +2338,11 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) goto out_statfs; } - rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL); + rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, data, NULL); if (rc) goto out_statfs; out_statfs: - kvfree(buf); + kvfree(data); return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 04d0a9ed1d05..fd769c39b482 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1039,27 +1039,24 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, case OBD_IOC_LOV_GET_CONFIG: { struct obd_ioctl_data *data; struct lov_desc *desc; - char *buf = NULL; u32 *genp; len = 0; - if (obd_ioctl_getdata(&buf, &len, uarg)) + if (obd_ioctl_getdata(&data, &len, uarg)) return -EINVAL; - data = (struct obd_ioctl_data *)buf; - if (sizeof(*desc) > data->ioc_inllen1) { - kvfree(buf); + kvfree(data); return -EINVAL; } if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { - kvfree(buf); + kvfree(data); return -EINVAL; } if (sizeof(u32) * count > data->ioc_inllen3) { - kvfree(buf); + kvfree(data); return -EINVAL; } @@ -1076,9 +1073,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, *genp = lov->lov_tgts[i]->ltd_gen; } - if (copy_to_user(uarg, buf, len)) + if (copy_to_user(uarg, data, len)) rc = -EFAULT; - kvfree(buf); + kvfree(data); break; } case OBD_IOC_QUOTACTL: { diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index b859ab19b9f6..2ef4fd41cdd0 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -230,7 +230,7 @@ static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) } /* buffer MUST be at least the size of obd_ioctl_hdr */ -int obd_ioctl_getdata(char **buf, int *len, void __user *arg) +int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg) { struct obd_ioctl_data *data; struct obd_ioctl_hdr hdr; @@ -262,16 +262,16 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) * obdfilter-survey is an example, which relies on ioctl. So we'd * better avoid vmalloc on ioctl path. LU-66 */ - *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); - if (!*buf) { + data = kvzalloc(hdr.ioc_len, GFP_KERNEL); + if (!data) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); return -EINVAL; } *len = hdr.ioc_len; - data = (struct obd_ioctl_data *)*buf; + *datap = data; - if (copy_from_user(*buf, arg, hdr.ioc_len)) { + if (copy_from_user(data, arg, hdr.ioc_len)) { err = -EFAULT; goto free_buf; } @@ -308,14 +308,13 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) return 0; free_buf: - kvfree(*buf); + kvfree(data); return err; } EXPORT_SYMBOL(obd_ioctl_getdata); int class_handle_ioctl(unsigned int cmd, unsigned long arg) { - char *buf = NULL; struct obd_ioctl_data *data; struct libcfs_debug_ioctl_data *debug_data; struct obd_device *obd = NULL; @@ -330,11 +329,10 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } CDEBUG(D_IOCTL, "cmd = %x\n", cmd); - if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) { + if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) { CERROR("OBD ioctl: data error\n"); return -EINVAL; } - data = (struct obd_ioctl_data *)buf; switch (cmd) { case OBD_IOC_PROCESS_CFG: { @@ -545,7 +543,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } out: - kvfree(buf); + kvfree(data); return err; } /* class_handle_ioctl */ From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 16/21] lustre: obdclass: normalize a switch statement. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781331.10620.12767117536447190491.stgit@noble.brown> Remove the unnecessary {}, and use "break" rather than "goto out;" for normal exit from the cases. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/class_obd.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 2ef4fd41cdd0..48d1dabafa65 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -518,7 +518,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } switch (cmd) { - case OBD_IOC_NO_TRANSNO: { + case OBD_IOC_NO_TRANSNO: if (!obd->obd_attached) { CERROR("Device %d not attached\n", obd->obd_minor); err = -ENODEV; @@ -528,18 +528,16 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) obd->obd_name); obd->obd_no_transno = 1; err = 0; - goto out; - } + break; - default: { + default: err = obd_iocontrol(cmd, obd->obd_self_export, len, data, NULL); if (err) goto out; if (copy_to_user((void __user *)arg, data, len)) err = -EFAULT; - goto out; - } + break; } out: From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 17/21] lustre: obdclass: result of try_module_get() should not be ignored. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781334.10620.18347323437724979128.stgit@noble.brown> If try_module_get() fails, the open must fail. In practice this should be impossible, but it is best to make the code look right. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/class_obd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 48d1dabafa65..982d47b6f50e 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -548,8 +548,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) /* opening /dev/obd */ static int obd_class_open(struct inode *inode, struct file *file) { - try_module_get(THIS_MODULE); - return 0; + return try_module_get(THIS_MODULE) ? 0 : -ENODEV; } /* closing /dev/obd */ From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 18/21] lustre: move debug.c from obdclass to obdecho In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781337.10620.11481546344215316629.stgit@noble.brown> The functions defined in debug.c are only used in obdecho, so move it there, and make the functions local to that unit. This allows lustre_debug.h to be removed. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_debug.h | 52 ----------- .../staging/lustre/lustre/llite/llite_internal.h | 2 drivers/staging/lustre/lustre/obdclass/Makefile | 2 drivers/staging/lustre/lustre/obdclass/class_obd.c | 1 drivers/staging/lustre/lustre/obdclass/debug.c | 96 -------------------- drivers/staging/lustre/lustre/obdecho/Makefile | 2 drivers/staging/lustre/lustre/obdecho/debug.c | 96 ++++++++++++++++++++ .../staging/lustre/lustre/obdecho/echo_client.c | 1 .../staging/lustre/lustre/obdecho/echo_internal.h | 4 + drivers/staging/lustre/lustre/osc/osc_request.c | 1 drivers/staging/lustre/lustre/ptlrpc/layout.c | 1 11 files changed, 103 insertions(+), 155 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/include/lustre_debug.h delete mode 100644 drivers/staging/lustre/lustre/obdclass/debug.c create mode 100644 drivers/staging/lustre/lustre/obdecho/debug.c diff --git a/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h deleted file mode 100644 index b9414fc73f00..000000000000 --- a/drivers/staging/lustre/lustre/include/lustre_debug.h +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef _LUSTRE_DEBUG_H -#define _LUSTRE_DEBUG_H - -/** \defgroup debug debug - * - * @{ - */ - -#include -#include - -/* lib/debug.c */ -int dump_req(struct ptlrpc_request *req); -int block_debug_setup(void *addr, int len, u64 off, u64 id); -int block_debug_check(char *who, void *addr, int len, u64 off, u64 id); - -/** @} debug */ - -#endif diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index bf7e46fe9ec6..c8860904bdd4 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -33,7 +33,7 @@ #ifndef LLITE_INTERNAL_H #define LLITE_INTERNAL_H -#include +#include #include #include /* for s2sbi */ #include diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index b1fac48b3adc..1669c24a0b03 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -4,7 +4,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LUSTRE_FS) += obdclass.o -obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ +obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o \ genops.o obd_sysfs.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \ diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 982d47b6f50e..4a717a29e385 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c deleted file mode 100644 index 2e526c7389d8..000000000000 --- a/drivers/staging/lustre/lustre/obdclass/debug.c +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/obdclass/debug.c - * - * Helper routines for dumping data structs for debugging. - */ - -#define DEBUG_SUBSYSTEM D_OTHER - -#include - -#include -#include -#include - -#define LPDS sizeof(u64) -int block_debug_setup(void *addr, int len, u64 off, u64 id) -{ - LASSERT(addr); - - put_unaligned_le64(off, addr); - put_unaligned_le64(id, addr + LPDS); - addr += len - LPDS - LPDS; - put_unaligned_le64(off, addr); - put_unaligned_le64(id, addr + LPDS); - - return 0; -} -EXPORT_SYMBOL(block_debug_setup); - -int block_debug_check(char *who, void *addr, int end, u64 off, u64 id) -{ - u64 ne_off; - int err = 0; - - LASSERT(addr); - - ne_off = le64_to_cpu(off); - id = le64_to_cpu(id); - if (memcmp(addr, (char *)&ne_off, LPDS)) { - CDEBUG(D_ERROR, "%s: id %#llx offset %llu off: %#llx != %#llx\n", - who, id, off, *(u64 *)addr, ne_off); - err = -EINVAL; - } - if (memcmp(addr + LPDS, (char *)&id, LPDS)) { - CDEBUG(D_ERROR, "%s: id %#llx offset %llu id: %#llx != %#llx\n", - who, id, off, *(u64 *)(addr + LPDS), id); - err = -EINVAL; - } - - addr += end - LPDS - LPDS; - if (memcmp(addr, (char *)&ne_off, LPDS)) { - CDEBUG(D_ERROR, "%s: id %#llx offset %llu end off: %#llx != %#llx\n", - who, id, off, *(u64 *)addr, ne_off); - err = -EINVAL; - } - if (memcmp(addr + LPDS, (char *)&id, LPDS)) { - CDEBUG(D_ERROR, "%s: id %#llx offset %llu end id: %#llx != %#llx\n", - who, id, off, *(u64 *)(addr + LPDS), id); - err = -EINVAL; - } - - return err; -} -EXPORT_SYMBOL(block_debug_check); -#undef LPDS diff --git a/drivers/staging/lustre/lustre/obdecho/Makefile b/drivers/staging/lustre/lustre/obdecho/Makefile index ff85ef1db70a..0a02efae036d 100644 --- a/drivers/staging/lustre/lustre/obdecho/Makefile +++ b/drivers/staging/lustre/lustre/obdecho/Makefile @@ -2,4 +2,4 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/include ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LUSTRE_FS) += obdecho.o -obdecho-y := echo_client.o +obdecho-y := echo_client.o debug.o diff --git a/drivers/staging/lustre/lustre/obdecho/debug.c b/drivers/staging/lustre/lustre/obdecho/debug.c new file mode 100644 index 000000000000..149aca54c776 --- /dev/null +++ b/drivers/staging/lustre/lustre/obdecho/debug.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2012, Intel Corporation. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * lustre/obdclass/debug.c + * + * Helper routines for dumping data structs for debugging. + */ + +#define DEBUG_SUBSYSTEM D_OTHER + +#include + +#include +#include "echo_internal.h" +#include + +#define LPDS sizeof(u64) +int block_debug_setup(void *addr, int len, u64 off, u64 id) +{ + LASSERT(addr); + + put_unaligned_le64(off, addr); + put_unaligned_le64(id, addr + LPDS); + addr += len - LPDS - LPDS; + put_unaligned_le64(off, addr); + put_unaligned_le64(id, addr + LPDS); + + return 0; +} +EXPORT_SYMBOL(block_debug_setup); + +int block_debug_check(char *who, void *addr, int end, u64 off, u64 id) +{ + u64 ne_off; + int err = 0; + + LASSERT(addr); + + ne_off = le64_to_cpu(off); + id = le64_to_cpu(id); + if (memcmp(addr, (char *)&ne_off, LPDS)) { + CDEBUG(D_ERROR, "%s: id %#llx offset %llu off: %#llx != %#llx\n", + who, id, off, *(u64 *)addr, ne_off); + err = -EINVAL; + } + if (memcmp(addr + LPDS, (char *)&id, LPDS)) { + CDEBUG(D_ERROR, "%s: id %#llx offset %llu id: %#llx != %#llx\n", + who, id, off, *(u64 *)(addr + LPDS), id); + err = -EINVAL; + } + + addr += end - LPDS - LPDS; + if (memcmp(addr, (char *)&ne_off, LPDS)) { + CDEBUG(D_ERROR, "%s: id %#llx offset %llu end off: %#llx != %#llx\n", + who, id, off, *(u64 *)addr, ne_off); + err = -EINVAL; + } + if (memcmp(addr + LPDS, (char *)&id, LPDS)) { + CDEBUG(D_ERROR, "%s: id %#llx offset %llu end id: %#llx != %#llx\n", + who, id, off, *(u64 *)(addr + LPDS), id); + err = -EINVAL; + } + + return err; +} +EXPORT_SYMBOL(block_debug_check); +#undef LPDS diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 1ebd98513239..1b7d98c649b6 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/lustre/lustre/obdecho/echo_internal.h b/drivers/staging/lustre/lustre/obdecho/echo_internal.h index 8094a94f605c..f9bb0b91d399 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_internal.h +++ b/drivers/staging/lustre/lustre/obdecho/echo_internal.h @@ -39,4 +39,8 @@ /* block size to use for data verification */ #define OBD_ECHO_BLOCK_SIZE (4 << 10) +/* debug.c */ +int block_debug_setup(void *addr, int len, u64 off, u64 id); +int block_debug_check(char *who, void *addr, int len, u64 off, u64 id); + #endif diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 0dfc506f6d01..3fedfaf249c4 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index f1f7d70b9790..d9f2b3d9e526 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -50,7 +50,6 @@ #include #include -#include #include #include #include From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 19/21] lustre: obdclass: avoid races in class_register_type() In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781342.10620.11880180011933935219.stgit@noble.brown> If there are two parallel attempts to register the same class name, it could get registered twice. So re-check after allocation to make sure the name is still unique. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/genops.c | 29 +++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 382eaf519a79..a174f538dd0d 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -86,17 +86,23 @@ static void obd_device_free(struct obd_device *obd) kmem_cache_free(obd_device_cachep, obd); } -static struct obd_type *class_search_type(const char *name) +static struct obd_type *__class_search_type(const char *name) { struct obd_type *type; - spin_lock(&obd_types_lock); list_for_each_entry(type, &obd_types, typ_chain) { - if (strcmp(type->typ_name, name) == 0) { - spin_unlock(&obd_types_lock); + if (strcmp(type->typ_name, name) == 0) return type; - } } + return NULL; +} + +static struct obd_type *class_search_type(const char *name) +{ + struct obd_type *type; + + spin_lock(&obd_types_lock); + type = __class_search_type(name); spin_unlock(&obd_types_lock); return NULL; } @@ -214,19 +220,22 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); - if (rc != 0) { - kobject_put(type->typ_kobj); + if (rc != 0) goto failed; - } } + INIT_LIST_HEAD(&type->typ_chain); spin_lock(&obd_types_lock); - list_add(&type->typ_chain, &obd_types); + if (__class_search_type(name) == NULL) + list_add(&type->typ_chain, &obd_types); spin_unlock(&obd_types_lock); - return 0; + if (!list_empty(&type->typ_chain)) + return 0; failed: + if (!IS_ERR_OR_NULL(type->typ_kobj)) + kobject_put(type->typ_kobj); kfree(type->typ_name); kfree(type->typ_md_ops); kfree(type->typ_dt_ops); From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 20/21] lustre: obdclass: fix module load locking. In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781345.10620.8278067573811049130.stgit@noble.brown> Safe module loading requires that we try_module_get() in a context where the module cannot be unloaded, typically prodected by a spinlock that module-unload has to take. This doesn't currently happen in class_get_type(). There is a per-type spinlock, but it is almost entirely unused, and cannot be used to protect the module from being unloaded. So discard ->obd_type_lock, and ensure that __class_search_type() and try_module_get() are both called while obd_types_lock is held - this prevent class_unregister_type() from completing (so the 'type' won't get freed. That is always called from a module-unload function - if it has got that far, try_module_get() will fail. So also check the return status of try_module_get(). Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd.h | 1 - drivers/staging/lustre/lustre/obdclass/genops.c | 24 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 171d2c214be6..463ab680b524 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -106,7 +106,6 @@ struct obd_type { char *typ_name; int typ_refcnt; struct lu_device_type *typ_lu; - spinlock_t obd_type_lock; struct kobject *typ_kobj; }; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index a174f538dd0d..dad21d9fa328 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -109,35 +109,42 @@ static struct obd_type *class_search_type(const char *name) static struct obd_type *class_get_type(const char *name) { - struct obd_type *type = class_search_type(name); + struct obd_type *type; + + spin_lock(&obd_types_lock); + type = __class_search_type(name); if (!type) { const char *modname = name; + spin_unlock(&obd_types_lock); if (!request_module("%s", modname)) { CDEBUG(D_INFO, "Loaded module '%s'\n", modname); - type = class_search_type(name); } else { LCONSOLE_ERROR_MSG(0x158, "Can't load module '%s'\n", modname); } + spin_lock(&obd_types_lock); + type = __class_search_type(name); } if (type) { - spin_lock(&type->obd_type_lock); - type->typ_refcnt++; - try_module_get(type->typ_dt_ops->owner); - spin_unlock(&type->obd_type_lock); + if (try_module_get(type->typ_dt_ops->owner)) + type->typ_refcnt++; + else + type = NULL; } + spin_unlock(&obd_types_lock); return type; } void class_put_type(struct obd_type *type) { LASSERT(type); - spin_lock(&type->obd_type_lock); + spin_lock(&obd_types_lock); + LASSERT(type->typ_refcnt > 0); type->typ_refcnt--; module_put(type->typ_dt_ops->owner); - spin_unlock(&type->obd_type_lock); + spin_unlock(&obd_types_lock); } static void class_sysfs_release(struct kobject *kobj) @@ -206,7 +213,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, if (md_ops) *type->typ_md_ops = *md_ops; strcpy(type->typ_name, name); - spin_lock_init(&type->obd_type_lock); type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, debugfs_lustre_root); From neilb at suse.com Thu Feb 7 00:03:33 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 07 Feb 2019 11:03:33 +1100 Subject: [lustre-devel] [PATCH 21/21] lustre: make exp_refcount in obd_export a refcount_t In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> Message-ID: <154949781349.10620.3269248433038576631.stgit@noble.brown> As this is used as a refcount, it should be declared as one. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_export.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 10 +++++----- drivers/staging/lustre/lustre/obdclass/genops.c | 15 ++++++++------- .../staging/lustre/lustre/obdecho/echo_client.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 63fa656eb7ba..fb34e0b7de35 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -67,7 +67,7 @@ struct obd_export { * what export they are talking to. */ struct portals_handle exp_handle; - atomic_t exp_refcount; + refcount_t exp_refcount; /** * Set of counters below is to track where export references are * kept. The exp_rpc_count is used for reconnect handling also, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index cea0e22d064b..f2433dc0e558 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1998,7 +1998,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, ldlm_lockname[lock->l_req_mode], lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_refcount) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); va_end(args); @@ -2024,7 +2024,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, lock->l_req_extent.end, lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_refcount) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); break; @@ -2046,7 +2046,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, lock->l_policy_data.l_flock.end, lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_refcount) : -99, lock->l_pid, lock->l_callback_timeout); break; @@ -2065,7 +2065,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, ldlm_typename[resource->lr_type], lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_refcount) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); break; @@ -2084,7 +2084,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, ldlm_typename[resource->lr_type], lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_refcount) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); break; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index dad21d9fa328..39919f1c5b71 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -757,7 +757,7 @@ static void class_export_destroy(struct obd_export *exp) { struct obd_device *obd = exp->exp_obd; - LASSERT_ATOMIC_ZERO(&exp->exp_refcount); + LASSERT(refcount_read(&exp->exp_refcount) == 0); LASSERT(obd); CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, @@ -793,20 +793,21 @@ static struct portals_handle_ops export_handle_ops = { struct obd_export *class_export_get(struct obd_export *exp) { - atomic_inc(&exp->exp_refcount); + refcount_inc(&exp->exp_refcount); CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp, - atomic_read(&exp->exp_refcount)); + refcount_read(&exp->exp_refcount)); return exp; } EXPORT_SYMBOL(class_export_get); void class_export_put(struct obd_export *exp) { - LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, LI_POISON); + LASSERT(refcount_read(&exp->exp_refcount) > 0); + LASSERT(refcount_read(&exp->exp_refcount) < LI_POISON); CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp, - atomic_read(&exp->exp_refcount) - 1); + refcount_read(&exp->exp_refcount) - 1); - if (atomic_dec_and_test(&exp->exp_refcount)) { + if (refcount_dec_and_test(&exp->exp_refcount)) { struct obd_device *obd = exp->exp_obd; CDEBUG(D_IOCTL, "final put %p/%s\n", @@ -856,7 +857,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd, export->exp_conn_cnt = 0; /* 2 = class_handle_hash + last */ - atomic_set(&export->exp_refcount, 2); + refcount_set(&export->exp_refcount, 2); atomic_set(&export->exp_rpc_count, 0); atomic_set(&export->exp_cb_count, 0); atomic_set(&export->exp_locks_count, 0); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 1b7d98c649b6..317123fd27cb 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -1638,7 +1638,7 @@ static int echo_client_cleanup(struct obd_device *obddev) return -EBUSY; } - LASSERT(atomic_read(&ec->ec_exp->exp_refcount) > 0); + LASSERT(refcount_read(&ec->ec_exp->exp_refcount) > 0); rc = obd_disconnect(ec->ec_exp); if (rc != 0) CERROR("fail to disconnect device: %d\n", rc); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 35a59e5a5e9d..b7d44fc21d73 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1697,7 +1697,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? - atomic_read(&request->rq_export->exp_refcount) : -99), + refcount_read(&request->rq_export->exp_refcount) : -99), lustre_msg_get_status(request->rq_reqmsg), request->rq_xid, libcfs_id2str(request->rq_peer), lustre_msg_get_opc(request->rq_reqmsg)); @@ -1741,7 +1741,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? - atomic_read(&request->rq_export->exp_refcount) : -99), + refcount_read(&request->rq_export->exp_refcount) : -99), lustre_msg_get_status(request->rq_reqmsg), request->rq_xid, libcfs_id2str(request->rq_peer), From adilger at whamcloud.com Thu Feb 7 00:20:08 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Thu, 7 Feb 2019 00:20:08 +0000 Subject: [lustre-devel] [PATCH 01/21] lustre: obdclass: discard csi_end_io In-Reply-To: <154949781233.10620.15965903498344624062.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781233.10620.15965903498344624062.stgit@noble.brown> Message-ID: On Feb 6, 2019, at 17:03, NeilBrown wrote: > > The csi_end_io field in "struct cl_sync_io" is always > set to cl_sync_io_end(), which is a tiny function. > This indirection doesn't help clarity, so remove it. > > Inline the function in the one place where ->csi_end_io() > is called, and discard the field. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/lustre/include/cl_object.h | 7 +----- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 26 ++++++--------------- > drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- > drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- > 4 files changed, 10 insertions(+), 27 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index b8ae41de7192..71ba73cdbb5e 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -2395,18 +2395,13 @@ struct cl_sync_io { > atomic_t csi_barrier; > /** completion to be signaled when transfer is complete. */ > wait_queue_head_t csi_waitq; > - /** callback to invoke when this IO is finished */ > - void (*csi_end_io)(const struct lu_env *, > - struct cl_sync_io *); > }; > > -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, > - void (*end)(const struct lu_env *, struct cl_sync_io *)); > +void cl_sync_io_init(struct cl_sync_io *anchor, int nr); > int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, > long timeout); > void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, > int ioret); > -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor); > > /** @} cl_sync_io */ > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index 09fd45d5394a..e9ad055f84b8 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -668,7 +668,7 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io, > pg->cp_sync_io = anchor; > } > > - cl_sync_io_init(anchor, queue->c2_qin.pl_nr, &cl_sync_io_end); > + cl_sync_io_init(anchor, queue->c2_qin.pl_nr); > rc = cl_io_submit_rw(env, io, iot, queue); > if (rc == 0) { > /* > @@ -1039,31 +1039,16 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_object *obj, > } > EXPORT_SYMBOL(cl_req_attr_set); > > -/* cl_sync_io_callback assumes the caller must call cl_sync_io_wait() to > - * wait for the IO to finish. > - */ > -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor) > -{ > - wake_up_all(&anchor->csi_waitq); > - > - /* it's safe to nuke or reuse anchor now */ > - atomic_set(&anchor->csi_barrier, 0); > -} > -EXPORT_SYMBOL(cl_sync_io_end); > - > /** > * Initialize synchronous io wait anchor > */ > -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, > - void (*end)(const struct lu_env *, struct cl_sync_io *)) > +void cl_sync_io_init(struct cl_sync_io *anchor, int nr) > { > memset(anchor, 0, sizeof(*anchor)); > init_waitqueue_head(&anchor->csi_waitq); > atomic_set(&anchor->csi_sync_nr, nr); > atomic_set(&anchor->csi_barrier, nr > 0); > anchor->csi_sync_rc = 0; > - anchor->csi_end_io = end; > - LASSERT(end); > } > EXPORT_SYMBOL(cl_sync_io_init); > > @@ -1120,8 +1105,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, > */ > LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); > if (atomic_dec_and_test(&anchor->csi_sync_nr)) { > - LASSERT(anchor->csi_end_io); > - anchor->csi_end_io(env, anchor); > + > + wake_up_all(&anchor->csi_waitq); > + /* it's safe to nuke or reuse anchor now */ > + atomic_set(&anchor->csi_barrier, 0); > + > /* Can't access anchor any more */ > } > } > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > index d7bcb8c203dd..8133d992cc73 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > @@ -189,7 +189,7 @@ int cl_lock_request(const struct lu_env *env, struct cl_io *io, > > if ((enq_flags & CEF_ASYNC) && !(enq_flags & CEF_AGL)) { > anchor = &cl_env_info(env)->clt_anchor; > - cl_sync_io_init(anchor, 1, cl_sync_io_end); > + cl_sync_io_init(anchor, 1); > } > > rc = cl_lock_enqueue(env, io, lock, anchor); > diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c > index 5a1717c7d132..da8c3978fab8 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_lock.c > +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c > @@ -877,7 +877,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, > continue; > > /* wait for conflicting lock to be canceled */ > - cl_sync_io_init(waiter, 1, cl_sync_io_end); > + cl_sync_io_init(waiter, 1); > oscl->ols_owner = waiter; > > spin_lock(&tmp_oscl->ols_lock); > > Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 00:09:51 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 00:09:51 +0000 Subject: [lustre-devel] [PATCH 02/21] lustre: obd_class: remove csi_barrier from struct cl_sync_io In-Reply-To: <154949781242.10620.4427066512247634121.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781242.10620.4427066512247634121.stgit@noble.brown> Message-ID: <28122F36-DB60-49B8-82E5-1C2F9546C83E@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > This flag is used to ensure that structure isn't freed before > the wakeup completes. The same can be achieved using the > csi_waitq.lock and calling wake_up_all_locked(). > > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 2 -- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 16 +++++++--------- > 2 files changed, 7 insertions(+), 11 deletions(-) > > @@ -1080,11 +1079,10 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, > } else { > rc = anchor->csi_sync_rc; > } > + /* We take the lock to ensure that cl_sync_io_note() has finished */ > + spin_lock(&anchor->csi_waitq.lock); > 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)) > - cpu_relax(); > + spin_unlock(&anchor->csi_waitq.lock); > > return rc; > } > @@ -1104,11 +1102,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, > * IO. > */ > LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); > - if (atomic_dec_and_test(&anchor->csi_sync_nr)) { > + if (atomic_dec_and_lock(&anchor->csi_sync_nr, > + &anchor->csi_waitq.lock)) { > > - wake_up_all(&anchor->csi_waitq); > - /* it's safe to nuke or reuse anchor now */ > - atomic_set(&anchor->csi_barrier, 0); > + wake_up_all_locked(&anchor->csi_waitq); > + spin_unlock(&anchor->csi_waitq.lock); Maybe a matching comment here that the lock is to synchronize with cl_sync_io_wait() cleanup? Either way, Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 00:13:50 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 00:13:50 +0000 Subject: [lustre-devel] [PATCH 03/21] lustre: obdclass: use list_sort() to sort a list. In-Reply-To: <154949781252.10620.13626213918115345779.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781252.10620.13626213918115345779.stgit@noble.brown> Message-ID: On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Rather than a bespoke bubble-sort, use list_sort() to > sort this linked list. > > Signed-off-by: NeilBrown Probably a performance win as well, since it looks like list_sort() uses merge sort instead of bubble sort. Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 51 +++++------------------- > 1 file changed, 10 insertions(+), 41 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index beac7e8bc92a..7bf02350f19d 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -42,6 +42,7 @@ > #include > #include > #include > +#include > #include > #include > #include "cl_internal.h" > @@ -213,9 +214,15 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, > } > EXPORT_SYMBOL(cl_io_rw_init); > > -static int cl_lock_descr_sort(const struct cl_lock_descr *d0, > - const struct cl_lock_descr *d1) > +static int cl_lock_descr_cmp(void *priv, > + struct list_head *a, struct list_head *b) > { > + const struct cl_io_lock_link *l0 = list_entry(a, struct cl_io_lock_link, cill_linkage); > + const struct cl_io_lock_link *l1 = list_entry(b, struct cl_io_lock_link, cill_linkage); > + > + const struct cl_lock_descr *d0 = &l0->cill_descr; > + const struct cl_lock_descr *d1 = &l1->cill_descr; > + > return lu_fid_cmp(lu_object_fid(&d0->cld_obj->co_lu), > lu_object_fid(&d1->cld_obj->co_lu)); > } > @@ -225,45 +232,7 @@ static int cl_lock_descr_sort(const struct cl_lock_descr *d0, > */ > static void cl_io_locks_sort(struct cl_io *io) > { > - int done = 0; > - > - /* hidden treasure: bubble sort for now. */ > - do { > - struct cl_io_lock_link *curr; > - struct cl_io_lock_link *prev; > - struct cl_io_lock_link *temp; > - > - done = 1; > - prev = NULL; > - > - list_for_each_entry_safe(curr, temp, > - &io->ci_lockset.cls_todo, > - cill_linkage) { > - if (prev) { > - switch (cl_lock_descr_sort(&prev->cill_descr, > - &curr->cill_descr)) { > - case 0: > - /* > - * IMPOSSIBLE: Identical locks are > - * already removed at > - * this point. > - */ > - default: > - LBUG(); > - case 1: > - list_move_tail(&curr->cill_linkage, > - &prev->cill_linkage); > - done = 0; > - continue; /* don't change prev: it's > - * still "previous" > - */ > - case -1: /* already in order */ > - break; > - } > - } > - prev = curr; > - } > - } while (!done); > + list_sort(NULL, &io->ci_lockset.cls_todo, cl_lock_descr_cmp); > } > > static void cl_lock_descr_merge(struct cl_lock_descr *d0, > > Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 00:25:02 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 00:25:02 +0000 Subject: [lustre-devel] [PATCH 04/21] lustre: use list*entry macros in place of container_of() In-Reply-To: <154949781267.10620.8365663638954760207.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781267.10620.8365663638954760207.stgit@noble.brown> Message-ID: <688B6498-5053-4A9C-988C-D2292006801C@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > There are a number of places that use container_of() but where > list_first_entry(), or list_last_entry() make the meaning more clear. > So change them over. > > Signed-off-by: NeilBrown Interesting, all these new helpers that I wasn't aware of. IMHO, the common list_* implementation in the kernel is really a major win for code efficiency and bug avoidance if used properly. Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ++-- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 4 ++-- > drivers/staging/lustre/lustre/obdclass/cl_object.c | 13 ++++++++----- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 4 ++-- > drivers/staging/lustre/lustre/obdclass/lu_object.c | 7 +++---- > 5 files changed, 17 insertions(+), 15 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index 85c5047f4ba2..74c7644d6ef8 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -987,8 +987,8 @@ struct ldlm_namespace *ldlm_namespace_first_locked(enum ldlm_side client) > { > LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); > LASSERT(!list_empty(ldlm_namespace_list(client))); > - return container_of(ldlm_namespace_list(client)->next, > - struct ldlm_namespace, ns_list_chain); > + return list_first_entry(ldlm_namespace_list(client), > + struct ldlm_namespace, ns_list_chain); > } > > /** Create and initialize new resource. */ > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index 7bf02350f19d..34b4e63e7d1a 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -93,8 +93,8 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) > LINVRNT(cl_io_invariant(io)); > > while (!list_empty(&io->ci_layers)) { > - slice = container_of(io->ci_layers.prev, struct cl_io_slice, > - cis_linkage); > + slice = list_last_entry(&io->ci_layers, struct cl_io_slice, > + cis_linkage); > list_del_init(&slice->cis_linkage); > if (slice->cis_iop->op[io->ci_type].cio_fini) > slice->cis_iop->op[io->ci_type].cio_fini(env, slice); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index 05d784ae7a6c..f724b2d62df1 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -649,8 +649,8 @@ static struct lu_env *cl_env_obtain(void *debug) > if (cl_envs[cpu].cec_count > 0) { > int rc; > > - cle = container_of(cl_envs[cpu].cec_envs.next, struct cl_env, > - ce_linkage); > + cle = list_first_entry(&cl_envs[cpu].cec_envs, struct cl_env, > + ce_linkage); > list_del_init(&cle->ce_linkage); > cl_envs[cpu].cec_count--; > read_unlock(&cl_envs[cpu].cec_guard); > @@ -748,9 +748,12 @@ unsigned int cl_env_cache_purge(unsigned int nr) > > for_each_possible_cpu(i) { > write_lock(&cl_envs[i].cec_guard); > - for (; !list_empty(&cl_envs[i].cec_envs) && nr > 0; --nr) { > - cle = container_of(cl_envs[i].cec_envs.next, > - struct cl_env, ce_linkage); > + for (; nr >0 && > + (cle = list_first_entry_or_null( > + &cl_envs[i].cec_envs, > + struct cl_env, > + ce_linkage)) != NULL; > + --nr) { > list_del_init(&cle->ce_linkage); > LASSERT(cl_envs[i].cec_count > 0); > cl_envs[i].cec_count--; > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index b1b4dc7ea22f..d025ea55818f 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -690,8 +690,8 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) > const struct cl_page_slice *slice; > int result; > > - slice = container_of(pg->cp_layers.next, > - const struct cl_page_slice, cpl_linkage); > + slice = list_first_entry(&pg->cp_layers, > + const struct cl_page_slice, cpl_linkage); > PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked); > /* > * Call ->cpo_is_vmlocked() directly instead of going through > diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c > index 3bd48748f46c..639c298b6a90 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c > @@ -349,7 +349,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) > * lives as long as possible and ->loo_object_free() methods > * can look at its contents. > */ > - o = container_of(splice.prev, struct lu_object, lo_linkage); > + o = list_last_entry(&splice, struct lu_object, lo_linkage); > list_del_init(&o->lo_linkage); > o->lo_ops->loo_object_free(env, o); > } > @@ -432,9 +432,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s, > * Free everything on the dispose list. This is safe against > * races due to the reasons described in lu_object_put(). > */ > - while (!list_empty(&dispose)) { > - h = container_of(dispose.next, > - struct lu_object_header, loh_lru); > + while ((h = list_first_entry_or_null( > + &dispose, struct lu_object_header, loh_lru)) != NULL) { > list_del_init(&h->loh_lru); > lu_object_free(env, lu_object_top(h)); > lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED); > > Cheers, Andreas --- Andreas Dilger CTO Whamcloud From adilger at whamcloud.com Fri Feb 8 00:31:37 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 00:31:37 +0000 Subject: [lustre-devel] [PATCH 05/21] lustre: use list_first_entry() in lustre subdirectory. In-Reply-To: <154949781279.10620.5804477141390456723.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781279.10620.5804477141390456723.stgit@noble.brown> Message-ID: <06F9EA63-3FD8-4BE3-A27C-1AE9BB65A97F@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in 'lustre' > > In several cases the call is combined with > a list_empty() test and list_first_entry_or_null() is used > > Signed-off-by: NeilBrown One question below: > @@ -912,9 +913,9 @@ static int ll_agl_thread(void *arg) > > spin_lock(&plli->lli_agl_lock); > sai->sai_agl_valid = 0; > - while (!list_empty(&sai->sai_agls)) { > - clli = list_entry(sai->sai_agls.next, > - struct ll_inode_info, lli_agl_list); > + while ((clli = list_first_entry_or_null(&sai->sai_agls, > + struct ll_inode_info, > + lli_agl_list)) != NULL) { Lustre coding style used to require explicit comparisons against NULL or 0 to avoid subtle bugs when developers treat pointers like booleans, so I'm not against this, but the kernel style is to not do this, like: while ((clli = list_first_entry_or_null(&sai->sai_agls, struct ll_inode_info, lli_agl_list))) { Will there be grief when this is pushed upstream? In that case, it might be better to just use the implicit "!= NULL" and avoid the complaints. Either way, the technical aspects of the patch are OK, so: Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 00:44:48 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 00:44:48 +0000 Subject: [lustre-devel] [PATCH 06/21] lustre: use list_first_entry() in lnet/lnet subdirectory. In-Reply-To: <154949781293.10620.13774044385661376106.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781293.10620.13774044385661376106.stgit@noble.brown> Message-ID: <4B487DA9-C27B-4A03-A21D-27F00C81858E@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in 'lnet/lnet' > > In several cases the call is combined with > a list_empty() test and list_first_entry_or_null() is used > > In one case, list_splice_init() is used. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 00:59:42 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 00:59:42 +0000 Subject: [lustre-devel] [PATCH 07/21] lustre: use list_first_entry() in lnet/klnds subdirectory. In-Reply-To: <154949781297.10620.13452862524706335326.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781297.10620.13452862524706335326.stgit@noble.brown> Message-ID: <1F487FF7-BF02-4FD7-9026-51CBD34610FE@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in 'lnet/klnds > > In several cases the call is combined with a list_empty() test and > list_first_entry_or_null() is used > > Signed-off-by: NeilBrown > > @@ -1853,8 +1855,9 @@ static void kiblnd_destroy_pool_list(struct list_head *head) > { > struct kib_pool *pool; > > - while (!list_empty(head)) { > - pool = list_entry(head->next, struct kib_pool, po_list); > + while ((pool = list_first_entry_or_null(head, > + struct kib_pool, > + po_list)) != NULL) { > list_del(&pool->po_list); > > LASSERT(pool->po_owner); > @@ -1869,7 +1872,7 @@ static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombie > > spin_lock(&ps->ps_lock); > while (!list_empty(&ps->ps_pool_list)) { > - struct kib_pool *po = list_entry(ps->ps_pool_list.next, > + struct kib_pool *po = list_first_entry(&ps->ps_pool_list, > struct kib_pool, po_list); > po->po_failed = 1; > list_del(&po->po_list); Why not use the same style as elsewhere in the code: while ((po = list_first_entry_or_null(&ps->ps_pool_list, struct kib_pool, po_list)) != NULL) { ? Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 01:06:23 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 01:06:23 +0000 Subject: [lustre-devel] [PATCH 08/21] lustre: use list_first_entry() throughout In-Reply-To: <154949781303.10620.10579175228046856433.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781303.10620.10579175228046856433.stgit@noble.brown> Message-ID: > On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in remainder of lustre. > > In several cases the call is combined with a list_empty() test and > list_first_entry_or_null() is used > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 01:07:03 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 01:07:03 +0000 Subject: [lustre-devel] [PATCH 09/21] lustre: use list_last_entry() throughout In-Reply-To: <154949781307.10620.3918792136275031845.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781307.10620.3918792136275031845.stgit@noble.brown> Message-ID: <202E06D9-38C1-436A-A761-59B6301DD68E@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Convert > list_entry(foo->prev .....) > to > list_last_entry(foo, ....) > > throughout lustre. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 01:10:43 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 01:10:43 +0000 Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate In-Reply-To: <154949781310.10620.8883358407999258821.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781310.10620.8883358407999258821.stgit@noble.brown> Message-ID: On Feb 6, 2019, at 17:03, NeilBrown wrote: > > There are various places which have a list_for_each_entry() > where cl_object_for_each (or .._reverse) is more appropriate. > > Several of these re-use the 'obj' function parameter as a loop > iterator, which is a little confusing. > > Change these to use cl_object_for_each{_reverse}, and where needed, > introduce a new iterator variable 'o'. > > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/lov/lov_page.c | 3 - > drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 - > drivers/staging/lustre/lustre/obdclass/cl_object.c | 82 +++++++++----------- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 +-- > 4 files changed, 44 insertions(+), 55 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index f724b2d62df1..d71a680660da 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -190,16 +190,15 @@ EXPORT_SYMBOL(cl_object_attr_unlock); > int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, > struct cl_attr *attr) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result; > > assert_spin_locked(cl_object_attr_guard(obj)); > > - top = obj->co_lu.lo_header; > result = 0; May as well move the "result = 0" initialization to the declaration for all of these? Another 5 fewer lines of code under your belt. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 01:31:57 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 01:31:57 +0000 Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: <154949781313.10620.6363156783936746853.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> Message-ID: On Feb 6, 2019, at 17:03, NeilBrown wrote: > > cl_env_inc() and cl_env_dec() don't do anything, > so discard them. > > Signed-off-by: NeilBrown It looks like these were being used for debugging page allocations, wrapped under CONFIG_DEBUG_PAGESTATE_TRACKING, but that was dropped from the upstream kernel. It looks like you could also delete cs_page_inc() and cs_page_dec() along with enum cache_stat_item, since they are also wrapped under the same CONFIG value. Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- > 1 file changed, 15 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index d71a680660da..1e704078664e 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -565,14 +565,6 @@ struct cl_env { > void *ce_debug; > }; > > -static void cl_env_inc(enum cache_stats_item item) > -{ > -} > - > -static void cl_env_dec(enum cache_stats_item item) > -{ > -} > - > static void cl_env_init0(struct cl_env *cle, void *debug) > { > LASSERT(cle->ce_ref == 0); > @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) > > cle->ce_ref = 1; > cle->ce_debug = debug; > - cl_env_inc(CS_busy); > } > > static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > if (rc != 0) { > kmem_cache_free(cl_env_kmem, cle); > env = ERR_PTR(rc); > - } else { > - cl_env_inc(CS_create); > - cl_env_inc(CS_total); > } > } else { > env = ERR_PTR(-ENOMEM); > @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > > static void cl_env_fini(struct cl_env *cle) > { > - cl_env_dec(CS_total); > lu_context_fini(&cle->ce_lu.le_ctx); > lu_context_fini(&cle->ce_ses); > kmem_cache_free(cl_env_kmem, cle); > @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) > if (--cle->ce_ref == 0) { > int cpu = get_cpu(); > > - cl_env_dec(CS_busy); > cle->ce_debug = NULL; > cl_env_exit(cle); > /* > @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) > cle->ce_ref--; > LASSERT(cle->ce_ref == 0); > > - cl_env_dec(CS_busy); > cle->ce_debug = NULL; > > put_cpu(); > > Cheers, Andreas --- Andreas Dilger CTO Whamcloud From adilger at whamcloud.com Fri Feb 8 05:43:36 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 05:43:36 +0000 Subject: [lustre-devel] [PATCH 12/21] lustre: cl_page.c: remove PINVRNT() In-Reply-To: <154949781317.10620.17224594880512218856.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781317.10620.17224594880512218856.stgit@noble.brown> Message-ID: <95F5F7CE-B5F6-4D4C-9860-E075D321B154@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > This macro does nothing (it once was like 'assert'), > so remove it. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 05:45:26 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 05:45:26 +0000 Subject: [lustre-devel] [PATCH 13/21] lustre: make cp_ref in cl_page a refcount_t In-Reply-To: <154949781321.10620.15836497514344103445.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781321.10620.15836497514344103445.stgit@noble.brown> Message-ID: On Feb 6, 2019, at 17:03, NeilBrown wrote: > > As this is used as a refcount, it should be declared > as one. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 05:46:16 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 05:46:16 +0000 Subject: [lustre-devel] [PATCH 14/21] lustre: make ccc_users in cl_client_cache a refcount_t In-Reply-To: <154949781324.10620.6961645123977299300.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781324.10620.6961645123977299300.stgit@noble.brown> Message-ID: <149B4014-1F4A-43A3-BA75-D6F363C0C15B@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > As this is used as a refcount, it should be declared > as one. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 05:56:41 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 05:56:41 +0000 Subject: [lustre-devel] [PATCH 15/21] lustre: obdclass: char obd_ioctl_getdata type. In-Reply-To: <154949781327.10620.2294752316778817915.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781327.10620.2294752316778817915.stgit@noble.brown> Message-ID: <3F216582-D826-4002-8F8D-A27488E24B02@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Instead of having obd_ioctl_getdata() return the allocated > data as a "char *", return it as it really is, > struct obd_ioctl_data * > > This avoids the need for extra variables and casts. > > Signed-off-by: NeilBrown Most of the patch looks like a no-op, except at one part below: > @@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > return rc; > } > case LL_IOC_MIGRATE: { > - char *buf = NULL; > const char *filename; > int namelen = 0; > int len; > int rc; > int mdtidx; > > - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); > + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); > if (rc < 0) > return rc; > > - data = (struct obd_ioctl_data *)buf; > if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || > !data->ioc_inllen1 || !data->ioc_inllen2) { > rc = -EINVAL; > @@ -1684,7 +1678,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > > rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1); > migrate_free: > - kvfree(buf); This removes the call to kvfree(buf) but it isn't clear why, since the rest of the patch is mostly variable renaming? Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 05:57:24 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 05:57:24 +0000 Subject: [lustre-devel] [PATCH 16/21] lustre: obdclass: normalize a switch statement. In-Reply-To: <154949781331.10620.12767117536447190491.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781331.10620.12767117536447190491.stgit@noble.brown> Message-ID: On Feb 6, 2019, at 17:03, NeilBrown wrote: > > Remove the unnecessary {}, and use "break" rather than > "goto out;" for normal exit from the cases. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 05:58:32 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 05:58:32 +0000 Subject: [lustre-devel] [PATCH 17/21] lustre: obdclass: result of try_module_get() should not be ignored. In-Reply-To: <154949781334.10620.18347323437724979128.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781334.10620.18347323437724979128.stgit@noble.brown> Message-ID: <858E7527-2583-4332-B8E2-550342482D20@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > If try_module_get() fails, the open must fail. > > In practice this should be impossible, but it is > best to make the code look right. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 06:02:30 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 06:02:30 +0000 Subject: [lustre-devel] [PATCH 18/21] lustre: move debug.c from obdclass to obdecho In-Reply-To: <154949781337.10620.11481546344215316629.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781337.10620.11481546344215316629.stgit@noble.brown> Message-ID: <9603E88A-ECFC-4D98-90D7-2E90E59DD93D@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > The functions defined in debug.c are only used in > obdecho, so move it there, and make the functions local > to that unit. > This allows lustre_debug.h to be removed. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 06:41:14 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 06:41:14 +0000 Subject: [lustre-devel] [PATCH 19/21] lustre: obdclass: avoid races in class_register_type() In-Reply-To: <154949781342.10620.11880180011933935219.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781342.10620.11880180011933935219.stgit@noble.brown> Message-ID: <36A43FA1-9CD0-4A9A-BDA4-A184F04B54BE@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > If there are two parallel attempts to register the > same class name, it could get registered twice. > So re-check after allocation to make sure the name is > still unique. The patch itself seems reasonable, but I don't see how this scenario could ever happen? class_register_type() is only called once per device type from the module init code, and I don't think it is possible to insert the same module twice? Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Fri Feb 8 07:07:07 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 8 Feb 2019 07:07:07 +0000 Subject: [lustre-devel] [PATCH 21/21] lustre: make exp_refcount in obd_export a refcount_t In-Reply-To: <154949781349.10620.3269248433038576631.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781349.10620.3269248433038576631.stgit@noble.brown> Message-ID: <4AB76021-DEB7-4081-ADF4-58E8F3101803@whamcloud.com> On Feb 6, 2019, at 17:03, NeilBrown wrote: > > As this is used as a refcount, it should be declared > as one. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From neilb at suse.com Mon Feb 11 00:13:21 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 11:13:21 +1100 Subject: [lustre-devel] [PATCH 05/21] lustre: use list_first_entry() in lustre subdirectory. In-Reply-To: <06F9EA63-3FD8-4BE3-A27C-1AE9BB65A97F@whamcloud.com> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781279.10620.5804477141390456723.stgit@noble.brown> <06F9EA63-3FD8-4BE3-A27C-1AE9BB65A97F@whamcloud.com> Message-ID: <87y36ngp26.fsf@notabene.neil.brown.name> On Fri, Feb 08 2019, Andreas Dilger wrote: > On Feb 6, 2019, at 17:03, NeilBrown wrote: >> >> Convert >> list_entry(foo->next .....) >> to >> list_first_entry(foo, ....) >> >> in 'lustre' >> >> In several cases the call is combined with >> a list_empty() test and list_first_entry_or_null() is used >> >> Signed-off-by: NeilBrown > > One question below: > >> @@ -912,9 +913,9 @@ static int ll_agl_thread(void *arg) >> >> spin_lock(&plli->lli_agl_lock); >> sai->sai_agl_valid = 0; >> - while (!list_empty(&sai->sai_agls)) { >> - clli = list_entry(sai->sai_agls.next, >> - struct ll_inode_info, lli_agl_list); >> + while ((clli = list_first_entry_or_null(&sai->sai_agls, >> + struct ll_inode_info, >> + lli_agl_list)) != NULL) { > > Lustre coding style used to require explicit comparisons against NULL or 0 > to avoid subtle bugs when developers treat pointers like booleans, so I'm > not against this, but the kernel style is to not do this, like: > > while ((clli = list_first_entry_or_null(&sai->sai_agls, > struct ll_inode_info, > lli_agl_list))) { > > Will there be grief when this is pushed upstream? In that case, it might > be better to just use the implicit "!= NULL" and avoid the complaints. > I don't think there will be grief. I personally prefer the explicit test, and I think I recall Linus once saying he did too. If you have while (p = func()) { The compile will warn that maybe you meant '=='. So you need while ((p = func())) { and the extra parentheses look odd. Make it while ((p = func()) != NULL) { clears it all up. The pattern while.* = .* != NULL occurs 589 times in the kernel at present including fs/* mm/* net/* so we certainly would be alone in using it. > Either way, the technical aspects of the patch are OK, so: > > Reviewed-by: Andreas Dilger Thanks, NeilBrown > > > Cheers, Andreas > --- > Andreas Dilger > Principal Lustre Architect > Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Mon Feb 11 00:19:07 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 00:19:07 +0000 (GMT) Subject: [lustre-devel] [PATCH 01/21] lustre: obdclass: discard csi_end_io In-Reply-To: <154949781233.10620.15965903498344624062.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781233.10620.15965903498344624062.stgit@noble.brown> Message-ID: > The csi_end_io field in "struct cl_sync_io" is always > set to cl_sync_io_end(), which is a tiny function. > This indirection doesn't help clarity, so remove it. > > Inline the function in the one place where ->csi_end_io() > is called, and discard the field. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 7 +----- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 26 ++++++--------------- > drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- > drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- > 4 files changed, 10 insertions(+), 27 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index b8ae41de7192..71ba73cdbb5e 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -2395,18 +2395,13 @@ struct cl_sync_io { > atomic_t csi_barrier; > /** completion to be signaled when transfer is complete. */ > wait_queue_head_t csi_waitq; > - /** callback to invoke when this IO is finished */ > - void (*csi_end_io)(const struct lu_env *, > - struct cl_sync_io *); > }; > > -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, > - void (*end)(const struct lu_env *, struct cl_sync_io *)); > +void cl_sync_io_init(struct cl_sync_io *anchor, int nr); > int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, > long timeout); > void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, > int ioret); > -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor); > > /** @} cl_sync_io */ > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index 09fd45d5394a..e9ad055f84b8 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -668,7 +668,7 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io, > pg->cp_sync_io = anchor; > } > > - cl_sync_io_init(anchor, queue->c2_qin.pl_nr, &cl_sync_io_end); > + cl_sync_io_init(anchor, queue->c2_qin.pl_nr); > rc = cl_io_submit_rw(env, io, iot, queue); > if (rc == 0) { > /* > @@ -1039,31 +1039,16 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_object *obj, > } > EXPORT_SYMBOL(cl_req_attr_set); > > -/* cl_sync_io_callback assumes the caller must call cl_sync_io_wait() to > - * wait for the IO to finish. > - */ > -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor) > -{ > - wake_up_all(&anchor->csi_waitq); > - > - /* it's safe to nuke or reuse anchor now */ > - atomic_set(&anchor->csi_barrier, 0); > -} > -EXPORT_SYMBOL(cl_sync_io_end); > - > /** > * Initialize synchronous io wait anchor > */ > -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, > - void (*end)(const struct lu_env *, struct cl_sync_io *)) > +void cl_sync_io_init(struct cl_sync_io *anchor, int nr) > { > memset(anchor, 0, sizeof(*anchor)); > init_waitqueue_head(&anchor->csi_waitq); > atomic_set(&anchor->csi_sync_nr, nr); > atomic_set(&anchor->csi_barrier, nr > 0); > anchor->csi_sync_rc = 0; > - anchor->csi_end_io = end; > - LASSERT(end); > } > EXPORT_SYMBOL(cl_sync_io_init); > > @@ -1120,8 +1105,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, > */ > LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); > if (atomic_dec_and_test(&anchor->csi_sync_nr)) { > - LASSERT(anchor->csi_end_io); > - anchor->csi_end_io(env, anchor); > + > + wake_up_all(&anchor->csi_waitq); > + /* it's safe to nuke or reuse anchor now */ > + atomic_set(&anchor->csi_barrier, 0); > + > /* Can't access anchor any more */ > } > } > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > index d7bcb8c203dd..8133d992cc73 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > @@ -189,7 +189,7 @@ int cl_lock_request(const struct lu_env *env, struct cl_io *io, > > if ((enq_flags & CEF_ASYNC) && !(enq_flags & CEF_AGL)) { > anchor = &cl_env_info(env)->clt_anchor; > - cl_sync_io_init(anchor, 1, cl_sync_io_end); > + cl_sync_io_init(anchor, 1); > } > > rc = cl_lock_enqueue(env, io, lock, anchor); > diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c > index 5a1717c7d132..da8c3978fab8 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_lock.c > +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c > @@ -877,7 +877,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, > continue; > > /* wait for conflicting lock to be canceled */ > - cl_sync_io_init(waiter, 1, cl_sync_io_end); > + cl_sync_io_init(waiter, 1); > oscl->ols_owner = waiter; > > spin_lock(&tmp_oscl->ols_lock); > > > From neilb at suse.com Mon Feb 11 00:24:26 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 11:24:26 +1100 Subject: [lustre-devel] [PATCH 02/21] lustre: obd_class: remove csi_barrier from struct cl_sync_io In-Reply-To: <28122F36-DB60-49B8-82E5-1C2F9546C83E@whamcloud.com> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781242.10620.4427066512247634121.stgit@noble.brown> <28122F36-DB60-49B8-82E5-1C2F9546C83E@whamcloud.com> Message-ID: <87va1rgojp.fsf@notabene.neil.brown.name> On Fri, Feb 08 2019, Andreas Dilger wrote: > On Feb 6, 2019, at 17:03, NeilBrown wrote: >> >> This flag is used to ensure that structure isn't freed before >> the wakeup completes. The same can be achieved using the >> csi_waitq.lock and calling wake_up_all_locked(). >> >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/include/cl_object.h | 2 -- >> drivers/staging/lustre/lustre/obdclass/cl_io.c | 16 +++++++--------- >> 2 files changed, 7 insertions(+), 11 deletions(-) >> >> @@ -1080,11 +1079,10 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, >> } else { >> rc = anchor->csi_sync_rc; >> } >> + /* We take the lock to ensure that cl_sync_io_note() has finished */ >> + spin_lock(&anchor->csi_waitq.lock); >> 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)) >> - cpu_relax(); >> + spin_unlock(&anchor->csi_waitq.lock); >> >> return rc; >> } >> @@ -1104,11 +1102,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, >> * IO. >> */ >> LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); >> - if (atomic_dec_and_test(&anchor->csi_sync_nr)) { >> + if (atomic_dec_and_lock(&anchor->csi_sync_nr, >> + &anchor->csi_waitq.lock)) { >> >> - wake_up_all(&anchor->csi_waitq); >> - /* it's safe to nuke or reuse anchor now */ >> - atomic_set(&anchor->csi_barrier, 0); >> + wake_up_all_locked(&anchor->csi_waitq); >> + spin_unlock(&anchor->csi_waitq.lock); > > Maybe a matching comment here that the lock is to synchronize with cl_sync_io_wait() cleanup? > Either way, > Good idea. I added /* * Holding the lock across both the decrement and * the wakeup ensures cl_sync_io_wait() doesn't complete * before the wakeup completes. */ > Reviewed-by: Andreas Dilger Thanks, NeilBrown > > Cheers, Andreas > --- > Andreas Dilger > Principal Lustre Architect > Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Mon Feb 11 00:34:45 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 00:34:45 +0000 (GMT) Subject: [lustre-devel] [PATCH 02/21] lustre: obd_class: remove csi_barrier from struct cl_sync_io In-Reply-To: <154949781242.10620.4427066512247634121.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781242.10620.4427066512247634121.stgit@noble.brown> Message-ID: > This flag is used to ensure that structure isn't freed before > the wakeup completes. The same can be achieved using the > csi_waitq.lock and calling wake_up_all_locked(). > Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 2 -- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 16 +++++++--------- > 2 files changed, 7 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index 71ba73cdbb5e..13d79810dd39 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -2391,8 +2391,6 @@ struct cl_sync_io { > atomic_t csi_sync_nr; > /** error code. */ > int csi_sync_rc; > - /** barrier of destroy this structure */ > - atomic_t csi_barrier; > /** completion to be signaled when transfer is complete. */ > wait_queue_head_t csi_waitq; > }; > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index e9ad055f84b8..beac7e8bc92a 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -1047,7 +1047,6 @@ void cl_sync_io_init(struct cl_sync_io *anchor, int nr) > memset(anchor, 0, sizeof(*anchor)); > init_waitqueue_head(&anchor->csi_waitq); > atomic_set(&anchor->csi_sync_nr, nr); > - atomic_set(&anchor->csi_barrier, nr > 0); > anchor->csi_sync_rc = 0; > } > EXPORT_SYMBOL(cl_sync_io_init); > @@ -1080,11 +1079,10 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, > } else { > rc = anchor->csi_sync_rc; > } > + /* We take the lock to ensure that cl_sync_io_note() has finished */ > + spin_lock(&anchor->csi_waitq.lock); I don't think I every seen any use the internal lock for the wait_queue in such a method. Most creative approach. > 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)) > - cpu_relax(); > + spin_unlock(&anchor->csi_waitq.lock); > > return rc; > } > @@ -1104,11 +1102,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, > * IO. > */ > LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); > - if (atomic_dec_and_test(&anchor->csi_sync_nr)) { > + if (atomic_dec_and_lock(&anchor->csi_sync_nr, > + &anchor->csi_waitq.lock)) { > > - wake_up_all(&anchor->csi_waitq); > - /* it's safe to nuke or reuse anchor now */ > - atomic_set(&anchor->csi_barrier, 0); > + wake_up_all_locked(&anchor->csi_waitq); > + spin_unlock(&anchor->csi_waitq.lock); > > /* Can't access anchor any more */ > } > > > From neilb at suse.com Mon Feb 11 00:34:55 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 11:34:55 +1100 Subject: [lustre-devel] [PATCH 07/21] lustre: use list_first_entry() in lnet/klnds subdirectory. In-Reply-To: <1F487FF7-BF02-4FD7-9026-51CBD34610FE@whamcloud.com> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781297.10620.13452862524706335326.stgit@noble.brown> <1F487FF7-BF02-4FD7-9026-51CBD34610FE@whamcloud.com> Message-ID: <87sgwvgo28.fsf@notabene.neil.brown.name> On Fri, Feb 08 2019, Andreas Dilger wrote: > On Feb 6, 2019, at 17:03, NeilBrown wrote: >> >> Convert >> list_entry(foo->next .....) >> to >> list_first_entry(foo, ....) >> >> in 'lnet/klnds >> >> In several cases the call is combined with a list_empty() test and >> list_first_entry_or_null() is used >> >> Signed-off-by: NeilBrown >> >> @@ -1853,8 +1855,9 @@ static void kiblnd_destroy_pool_list(struct list_head *head) >> { >> struct kib_pool *pool; >> >> - while (!list_empty(head)) { >> - pool = list_entry(head->next, struct kib_pool, po_list); >> + while ((pool = list_first_entry_or_null(head, >> + struct kib_pool, >> + po_list)) != NULL) { >> list_del(&pool->po_list); >> >> LASSERT(pool->po_owner); >> @@ -1869,7 +1872,7 @@ static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombie >> >> spin_lock(&ps->ps_lock); >> while (!list_empty(&ps->ps_pool_list)) { >> - struct kib_pool *po = list_entry(ps->ps_pool_list.next, >> + struct kib_pool *po = list_first_entry(&ps->ps_pool_list, >> struct kib_pool, po_list); >> po->po_failed = 1; >> list_del(&po->po_list); > > Why not use the same style as elsewhere in the code: > > while ((po = list_first_entry_or_null(&ps->ps_pool_list, > struct kib_pool, > po_list)) != NULL) { > No good reason - just fatigue probably. I could automate most of finding these, but automating the fixing of them didn't quite seem worth the effort. Maybe I should play with coccinelle... I've merged: diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index df6b1b134709..d67a197e718d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -1867,13 +1867,15 @@ static void kiblnd_destroy_pool_list(struct list_head *head) static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombies) { + struct kib_pool *po; + if (!ps->ps_net) /* initialized? */ return; spin_lock(&ps->ps_lock); - while (!list_empty(&ps->ps_pool_list)) { - struct kib_pool *po = list_first_entry(&ps->ps_pool_list, - struct kib_pool, po_list); + while ((po = list_first_entry_or_null(&ps->ps_pool_list, + struct kib_pool, + po_list)) == NULL) { po->po_failed = 1; list_del(&po->po_list); if (!po->po_allocated) Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Mon Feb 11 00:39:53 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 00:39:53 +0000 (GMT) Subject: [lustre-devel] [PATCH 03/21] lustre: obdclass: use list_sort() to sort a list. In-Reply-To: <154949781252.10620.13626213918115345779.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781252.10620.13626213918115345779.stgit@noble.brown> Message-ID: > Rather than a bespoke bubble-sort, use list_sort() to > sort this linked list. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 51 +++++------------------- > 1 file changed, 10 insertions(+), 41 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index beac7e8bc92a..7bf02350f19d 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -42,6 +42,7 @@ > #include > #include > #include > +#include > #include > #include > #include "cl_internal.h" > @@ -213,9 +214,15 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, > } > EXPORT_SYMBOL(cl_io_rw_init); > > -static int cl_lock_descr_sort(const struct cl_lock_descr *d0, > - const struct cl_lock_descr *d1) > +static int cl_lock_descr_cmp(void *priv, > + struct list_head *a, struct list_head *b) > { > + const struct cl_io_lock_link *l0 = list_entry(a, struct cl_io_lock_link, cill_linkage); > + const struct cl_io_lock_link *l1 = list_entry(b, struct cl_io_lock_link, cill_linkage); > + > + const struct cl_lock_descr *d0 = &l0->cill_descr; > + const struct cl_lock_descr *d1 = &l1->cill_descr; > + > return lu_fid_cmp(lu_object_fid(&d0->cld_obj->co_lu), > lu_object_fid(&d1->cld_obj->co_lu)); > } > @@ -225,45 +232,7 @@ static int cl_lock_descr_sort(const struct cl_lock_descr *d0, > */ > static void cl_io_locks_sort(struct cl_io *io) > { > - int done = 0; > - > - /* hidden treasure: bubble sort for now. */ > - do { > - struct cl_io_lock_link *curr; > - struct cl_io_lock_link *prev; > - struct cl_io_lock_link *temp; > - > - done = 1; > - prev = NULL; > - > - list_for_each_entry_safe(curr, temp, > - &io->ci_lockset.cls_todo, > - cill_linkage) { > - if (prev) { > - switch (cl_lock_descr_sort(&prev->cill_descr, > - &curr->cill_descr)) { > - case 0: > - /* > - * IMPOSSIBLE: Identical locks are > - * already removed at > - * this point. > - */ > - default: > - LBUG(); > - case 1: > - list_move_tail(&curr->cill_linkage, > - &prev->cill_linkage); > - done = 0; > - continue; /* don't change prev: it's > - * still "previous" > - */ > - case -1: /* already in order */ > - break; > - } > - } > - prev = curr; > - } > - } while (!done); > + list_sort(NULL, &io->ci_lockset.cls_todo, cl_lock_descr_cmp); > } While this fine cl_io_locks_sort() is discussed in one comment in cl_object.h and used once in cl_io.c. We could remove this one line function completely and update the comment in cl_object.h. > static void cl_lock_descr_merge(struct cl_lock_descr *d0, > > > From neilb at suse.com Mon Feb 11 00:42:46 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 11:42:46 +1100 Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781310.10620.8883358407999258821.stgit@noble.brown> Message-ID: <87pnrzgnp5.fsf@notabene.neil.brown.name> On Fri, Feb 08 2019, Andreas Dilger wrote: > On Feb 6, 2019, at 17:03, NeilBrown wrote: >> >> There are various places which have a list_for_each_entry() >> where cl_object_for_each (or .._reverse) is more appropriate. >> >> Several of these re-use the 'obj' function parameter as a loop >> iterator, which is a little confusing. >> >> Change these to use cl_object_for_each{_reverse}, and where needed, >> introduce a new iterator variable 'o'. >> >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/lov/lov_page.c | 3 - >> drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 - >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 82 +++++++++----------- >> drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 +-- >> 4 files changed, 44 insertions(+), 55 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> index f724b2d62df1..d71a680660da 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> @@ -190,16 +190,15 @@ EXPORT_SYMBOL(cl_object_attr_unlock); >> int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, >> struct cl_attr *attr) >> { >> - struct lu_object_header *top; >> + struct cl_object *o; >> int result; >> >> assert_spin_locked(cl_object_attr_guard(obj)); >> >> - top = obj->co_lu.lo_header; >> result = 0; > > May as well move the "result = 0" initialization to the declaration for > all of these? Another 5 fewer lines of code under your belt. Yes, that seem good. New patch below. Thanks, NeilBrown From: NeilBrown Subject: [PATCH] lustre: obdclass: use cl_object_for_each where appropriate There are various places which have a list_for_each_entry() where cl_object_for_each (or .._reverse) is more appropriate. Several of these re-use the 'obj' function parameter as a loop iterator, which is a little confusing. Change these to use cl_object_for_each{_reverse}, and where needed, introduce a new iterator variable 'o'. To further clean up these function, move initializtion of 'result' to the variable declaration. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/lov/lov_page.c | 3 +- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 97 ++++++++++------------ drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 ++- 4 files changed, 49 insertions(+), 65 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 08485a95ec01..e64b350601d2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -103,8 +103,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, return PTR_ERR(sub); subobj = lovsub2cl(r0->lo_sub[stripe]); - list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers, - co_lu.lo_linkage) { + cl_object_for_each(o, subobj) { if (o->co_ops->coo_page_init) { rc = o->co_ops->coo_page_init(sub->sub_env, o, page, cl_index(subobj, suboff)); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 8133d992cc73..fc5976d8b37b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -103,8 +103,7 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, LASSERT(obj); INIT_LIST_HEAD(&lock->cll_layers); - list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, - co_lu.lo_linkage) { + cl_object_for_each(scan, obj) { result = scan->co_ops->coo_lock_init(env, scan, lock, io); if (result != 0) { cl_lock_fini(env, lock); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f724b2d62df1..43bf1a422635 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -190,16 +190,14 @@ EXPORT_SYMBOL(cl_object_attr_unlock); int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, struct cl_attr *attr) { - struct lu_object_header *top; - int result; + struct cl_object *o; + int result = 0; assert_spin_locked(cl_object_attr_guard(obj)); - top = obj->co_lu.lo_header; - result = 0; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_get) { - result = obj->co_ops->coo_attr_get(env, obj, attr); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_attr_get) { + result = o->co_ops->coo_attr_get(env, o, attr); if (result != 0) { if (result > 0) result = 0; @@ -221,17 +219,15 @@ EXPORT_SYMBOL(cl_object_attr_get); int cl_object_attr_update(const struct lu_env *env, struct cl_object *obj, const struct cl_attr *attr, unsigned int v) { - struct lu_object_header *top; - int result; + struct cl_object *o; + int result = 0; assert_spin_locked(cl_object_attr_guard(obj)); - top = obj->co_lu.lo_header; - result = 0; - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_attr_update) { - result = obj->co_ops->coo_attr_update(env, obj, attr, - v); + cl_object_for_each_reverse(o, obj) { + if (o->co_ops->coo_attr_update) { + result = o->co_ops->coo_attr_update(env, o, attr, + v); if (result != 0) { if (result > 0) result = 0; @@ -254,19 +250,17 @@ EXPORT_SYMBOL(cl_object_attr_update); int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, struct ost_lvb *lvb) { - struct lu_object_header *top; - int result; + struct cl_object *o; + int result = 0; - top = obj->co_lu.lo_header; - result = 0; - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_glimpse) { - result = obj->co_ops->coo_glimpse(env, obj, lvb); + cl_object_for_each_reverse(o, obj) { + if (o->co_ops->coo_glimpse) { + result = o->co_ops->coo_glimpse(env, o, lvb); if (result != 0) break; } } - LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), + LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(obj->co_lu.lo_header), "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); @@ -280,14 +274,12 @@ EXPORT_SYMBOL(cl_object_glimpse); int cl_conf_set(const struct lu_env *env, struct cl_object *obj, const struct cl_object_conf *conf) { - struct lu_object_header *top; - int result; + struct cl_object *o; + int result = 0; - top = obj->co_lu.lo_header; - result = 0; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_conf_set) { - result = obj->co_ops->coo_conf_set(env, obj, conf); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_conf_set) { + result = o->co_ops->coo_conf_set(env, o, conf); if (result != 0) break; } @@ -301,13 +293,10 @@ EXPORT_SYMBOL(cl_conf_set); */ int cl_object_prune(const struct lu_env *env, struct cl_object *obj) { - struct lu_object_header *top; struct cl_object *o; - int result; + int result = 0; - top = obj->co_lu.lo_header; - result = 0; - list_for_each_entry(o, &top->loh_layers, co_lu.lo_linkage) { + cl_object_for_each(o, obj) { if (o->co_ops->coo_prune) { result = o->co_ops->coo_prune(env, o); if (result != 0) @@ -325,14 +314,13 @@ EXPORT_SYMBOL(cl_object_prune); int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, struct lov_user_md __user *uarg, size_t size) { - struct lu_object_header *top; + struct cl_object *o; int result = 0; - top = obj->co_lu.lo_header; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_getstripe) { - result = obj->co_ops->coo_getstripe(env, obj, uarg, - size); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_getstripe) { + result = o->co_ops->coo_getstripe(env, o, uarg, + size); if (result) break; } @@ -357,14 +345,13 @@ int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj, struct ll_fiemap_info_key *key, struct fiemap *fiemap, size_t *buflen) { - struct lu_object_header *top; + struct cl_object *o; int result = 0; - top = obj->co_lu.lo_header; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_fiemap) { - result = obj->co_ops->coo_fiemap(env, obj, key, fiemap, - buflen); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_fiemap) { + result = o->co_ops->coo_fiemap(env, o, key, fiemap, + buflen); if (result) break; } @@ -376,11 +363,11 @@ EXPORT_SYMBOL(cl_object_fiemap); int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, struct cl_layout *cl) { - struct lu_object_header *top = obj->co_lu.lo_header; + struct cl_object *o; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_layout_get) - return obj->co_ops->coo_layout_get(env, obj, cl); + cl_object_for_each(o, obj) { + if (o->co_ops->coo_layout_get) + return o->co_ops->coo_layout_get(env, o, cl); } return -EOPNOTSUPP; @@ -389,12 +376,12 @@ EXPORT_SYMBOL(cl_object_layout_get); loff_t cl_object_maxbytes(struct cl_object *obj) { - struct lu_object_header *top = obj->co_lu.lo_header; + struct cl_object *o; loff_t maxbytes = LLONG_MAX; - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { - if (obj->co_ops->coo_maxbytes) - maxbytes = min_t(loff_t, obj->co_ops->coo_maxbytes(obj), + cl_object_for_each(o, obj) { + if (o->co_ops->coo_maxbytes) + maxbytes = min_t(loff_t, o->co_ops->coo_maxbytes(o), maxbytes); } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 057318deaa4e..7d00a9233a3b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -132,7 +132,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, enum cl_page_type type) { struct cl_page *page; - struct lu_object_header *head; + struct cl_object *o2; page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); if (page) { @@ -149,11 +149,10 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, INIT_LIST_HEAD(&page->cp_layers); INIT_LIST_HEAD(&page->cp_batch); lu_ref_init(&page->cp_reference); - head = o->co_lu.lo_header; - list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { - if (o->co_ops->coo_page_init) { - result = o->co_ops->coo_page_init(env, o, page, - ind); + cl_object_for_each(o2, o) { + if (o2->co_ops->coo_page_init) { + result = o2->co_ops->coo_page_init(env, o2, page, + ind); if (result != 0) { __cl_page_delete(env, page); cl_page_free(env, page); -- 2.14.0.rc0.dirty -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 00:48:47 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 11:48:47 +1100 Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> Message-ID: <87mun3gnf4.fsf@notabene.neil.brown.name> On Fri, Feb 08 2019, Andreas Dilger wrote: > On Feb 6, 2019, at 17:03, NeilBrown wrote: >> >> cl_env_inc() and cl_env_dec() don't do anything, >> so discard them. >> >> Signed-off-by: NeilBrown > > It looks like these were being used for debugging page allocations, > wrapped under CONFIG_DEBUG_PAGESTATE_TRACKING, but that was dropped > from the upstream kernel. It looks like you could also delete > cs_page_inc() and cs_page_dec() along with enum cache_stat_item, > since they are also wrapped under the same CONFIG value. cs_page_inc/dec were never in driver/staging. CS_PAGE_INC/DEC were for a while, but were removed nearly 4 years ago. Commit 76c807210aea ("staging: lustre: cl_page: delete empty macros") > > Reviewed-by: Andreas Dilger Thanks, NeilBrown > >> --- >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- >> 1 file changed, 15 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> index d71a680660da..1e704078664e 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> @@ -565,14 +565,6 @@ struct cl_env { >> void *ce_debug; >> }; >> >> -static void cl_env_inc(enum cache_stats_item item) >> -{ >> -} >> - >> -static void cl_env_dec(enum cache_stats_item item) >> -{ >> -} >> - >> static void cl_env_init0(struct cl_env *cle, void *debug) >> { >> LASSERT(cle->ce_ref == 0); >> @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) >> >> cle->ce_ref = 1; >> cle->ce_debug = debug; >> - cl_env_inc(CS_busy); >> } >> >> static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> if (rc != 0) { >> kmem_cache_free(cl_env_kmem, cle); >> env = ERR_PTR(rc); >> - } else { >> - cl_env_inc(CS_create); >> - cl_env_inc(CS_total); >> } >> } else { >> env = ERR_PTR(-ENOMEM); >> @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> static void cl_env_fini(struct cl_env *cle) >> { >> - cl_env_dec(CS_total); >> lu_context_fini(&cle->ce_lu.le_ctx); >> lu_context_fini(&cle->ce_ses); >> kmem_cache_free(cl_env_kmem, cle); >> @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) >> if (--cle->ce_ref == 0) { >> int cpu = get_cpu(); >> >> - cl_env_dec(CS_busy); >> cle->ce_debug = NULL; >> cl_env_exit(cle); >> /* >> @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) >> cle->ce_ref--; >> LASSERT(cle->ce_ref == 0); >> >> - cl_env_dec(CS_busy); >> cle->ce_debug = NULL; >> >> put_cpu(); >> >> > > Cheers, Andreas > --- > Andreas Dilger > CTO Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 00:52:39 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 11:52:39 +1100 Subject: [lustre-devel] [PATCH 15/21] lustre: obdclass: char obd_ioctl_getdata type. In-Reply-To: <3F216582-D826-4002-8F8D-A27488E24B02@whamcloud.com> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781327.10620.2294752316778817915.stgit@noble.brown> <3F216582-D826-4002-8F8D-A27488E24B02@whamcloud.com> Message-ID: <87k1i7gn8o.fsf@notabene.neil.brown.name> On Fri, Feb 08 2019, Andreas Dilger wrote: > On Feb 6, 2019, at 17:03, NeilBrown wrote: >> >> Instead of having obd_ioctl_getdata() return the allocated >> data as a "char *", return it as it really is, >> struct obd_ioctl_data * >> >> This avoids the need for extra variables and casts. >> >> Signed-off-by: NeilBrown > > Most of the patch looks like a no-op, except at one part below: > >> @@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) >> return rc; >> } >> case LL_IOC_MIGRATE: { >> - char *buf = NULL; >> const char *filename; >> int namelen = 0; >> int len; >> int rc; >> int mdtidx; >> >> - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); >> + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); >> if (rc < 0) >> return rc; >> >> - data = (struct obd_ioctl_data *)buf; >> if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || >> !data->ioc_inllen1 || !data->ioc_inllen2) { >> rc = -EINVAL; >> @@ -1684,7 +1678,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) >> >> rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1); >> migrate_free: >> - kvfree(buf); > > This removes the call to kvfree(buf) but it isn't clear why, since the rest of > the patch is mostly variable renaming? Thanks for catching that! It should be: migrate_free: - kvfree(buf); + kvfree(data); of course. Fixed now. NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 00:58:55 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 11:58:55 +1100 Subject: [lustre-devel] [PATCH 19/21] lustre: obdclass: avoid races in class_register_type() In-Reply-To: <36A43FA1-9CD0-4A9A-BDA4-A184F04B54BE@whamcloud.com> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781342.10620.11880180011933935219.stgit@noble.brown> <36A43FA1-9CD0-4A9A-BDA4-A184F04B54BE@whamcloud.com> Message-ID: <87h8dbgmy8.fsf@notabene.neil.brown.name> On Fri, Feb 08 2019, Andreas Dilger wrote: > On Feb 6, 2019, at 17:03, NeilBrown wrote: >> >> If there are two parallel attempts to register the >> same class name, it could get registered twice. >> So re-check after allocation to make sure the name is >> still unique. > > The patch itself seems reasonable, but I don't see how this > scenario could ever happen? class_register_type() is only > called once per device type from the module init code, and > I don't think it is possible to insert the same module twice? I agree. I don't think it can happen. By the same logic, the test if (class_search_type(name)) { CDEBUG(D_IOCTL, "Type %s already registered\n", name); return -EEXIST; } at the start of class_register_type() is pointless, as it is not possible for the same name to be registered twice. But I think it is still good to have this test, and to fail-safe. To me the test as it is "looks" prone to races, so I wanted to fix it. When I'm analysining obscure bugs, it helps a lot to have code that is "obviously correct" without having the understand (and double check) various assumptions about usage which are necessary for it to be correct. So this patch isn't needed for correctness. It is needed (I think) to make the code understandable and maintainable. Thanks, NeilBrown > > Cheers, Andreas > --- > Andreas Dilger > Principal Lustre Architect > Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 01:05:16 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 12:05:16 +1100 Subject: [lustre-devel] [PATCH 03/21] lustre: obdclass: use list_sort() to sort a list. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781252.10620.13626213918115345779.stgit@noble.brown> Message-ID: <87ef8fgmnn.fsf@notabene.neil.brown.name> On Mon, Feb 11 2019, James Simmons wrote: >> Rather than a bespoke bubble-sort, use list_sort() to >> sort this linked list. > > Reviewed-by: James Simmons > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/obdclass/cl_io.c | 51 +++++------------------- >> 1 file changed, 10 insertions(+), 41 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c >> index beac7e8bc92a..7bf02350f19d 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c >> @@ -42,6 +42,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include "cl_internal.h" >> @@ -213,9 +214,15 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, >> } >> EXPORT_SYMBOL(cl_io_rw_init); >> >> -static int cl_lock_descr_sort(const struct cl_lock_descr *d0, >> - const struct cl_lock_descr *d1) >> +static int cl_lock_descr_cmp(void *priv, >> + struct list_head *a, struct list_head *b) >> { >> + const struct cl_io_lock_link *l0 = list_entry(a, struct cl_io_lock_link, cill_linkage); >> + const struct cl_io_lock_link *l1 = list_entry(b, struct cl_io_lock_link, cill_linkage); >> + >> + const struct cl_lock_descr *d0 = &l0->cill_descr; >> + const struct cl_lock_descr *d1 = &l1->cill_descr; >> + >> return lu_fid_cmp(lu_object_fid(&d0->cld_obj->co_lu), >> lu_object_fid(&d1->cld_obj->co_lu)); >> } >> @@ -225,45 +232,7 @@ static int cl_lock_descr_sort(const struct cl_lock_descr *d0, >> */ >> static void cl_io_locks_sort(struct cl_io *io) >> { >> - int done = 0; >> - >> - /* hidden treasure: bubble sort for now. */ >> - do { >> - struct cl_io_lock_link *curr; >> - struct cl_io_lock_link *prev; >> - struct cl_io_lock_link *temp; >> - >> - done = 1; >> - prev = NULL; >> - >> - list_for_each_entry_safe(curr, temp, >> - &io->ci_lockset.cls_todo, >> - cill_linkage) { >> - if (prev) { >> - switch (cl_lock_descr_sort(&prev->cill_descr, >> - &curr->cill_descr)) { >> - case 0: >> - /* >> - * IMPOSSIBLE: Identical locks are >> - * already removed at >> - * this point. >> - */ >> - default: >> - LBUG(); >> - case 1: >> - list_move_tail(&curr->cill_linkage, >> - &prev->cill_linkage); >> - done = 0; >> - continue; /* don't change prev: it's >> - * still "previous" >> - */ >> - case -1: /* already in order */ >> - break; >> - } >> - } >> - prev = curr; >> - } >> - } while (!done); >> + list_sort(NULL, &io->ci_lockset.cls_todo, cl_lock_descr_cmp); >> } > > While this fine cl_io_locks_sort() is discussed in one comment in > cl_object.h and used once in cl_io.c. We could remove this one line > function completely and update the comment in cl_object.h. > Excellent idea. New patch is below. Thanks, NeilBrown From: NeilBrown Subject: [PATCH] lustre: obdclass: use list_sort() to sort a list. Rather than a bespoke bubble-sort, use list_sort() to sort this linked list. As this would become a 1-line function that is only called once, call list_sort() directly from the one call site. Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/cl_io.c | 63 ++++++-------------------- 1 file changed, 14 insertions(+), 49 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 5191fba8bbc0..c8a99b61ecd2 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include "cl_internal.h" @@ -213,57 +214,17 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, } EXPORT_SYMBOL(cl_io_rw_init); -static int cl_lock_descr_sort(const struct cl_lock_descr *d0, - const struct cl_lock_descr *d1) +static int cl_lock_descr_cmp(void *priv, + struct list_head *a, struct list_head *b) { - return lu_fid_cmp(lu_object_fid(&d0->cld_obj->co_lu), - lu_object_fid(&d1->cld_obj->co_lu)); -} + const struct cl_io_lock_link *l0 = list_entry(a, struct cl_io_lock_link, cill_linkage); + const struct cl_io_lock_link *l1 = list_entry(b, struct cl_io_lock_link, cill_linkage); -/* - * Sort locks in lexicographical order of their (fid, start-offset) pairs. - */ -static void cl_io_locks_sort(struct cl_io *io) -{ - int done = 0; + const struct cl_lock_descr *d0 = &l0->cill_descr; + const struct cl_lock_descr *d1 = &l1->cill_descr; - /* hidden treasure: bubble sort for now. */ - do { - struct cl_io_lock_link *curr; - struct cl_io_lock_link *prev; - struct cl_io_lock_link *temp; - - done = 1; - prev = NULL; - - list_for_each_entry_safe(curr, temp, - &io->ci_lockset.cls_todo, - cill_linkage) { - if (prev) { - switch (cl_lock_descr_sort(&prev->cill_descr, - &curr->cill_descr)) { - case 0: - /* - * IMPOSSIBLE: Identical locks are - * already removed at - * this point. - */ - default: - LBUG(); - case 1: - list_move_tail(&curr->cill_linkage, - &prev->cill_linkage); - done = 0; - continue; /* don't change prev: it's - * still "previous" - */ - case -1: /* already in order */ - break; - } - } - prev = curr; - } - } while (!done); + return lu_fid_cmp(lu_object_fid(&d0->cld_obj->co_lu), + lu_object_fid(&d1->cld_obj->co_lu)); } static void cl_lock_descr_merge(struct cl_lock_descr *d0, @@ -347,7 +308,11 @@ int cl_io_lock(const struct lu_env *env, struct cl_io *io) } if (result == 0) { - cl_io_locks_sort(io); + /* + * Sort locks in lexicographical order of their (fid, + * start-offset) pairs to avoid deadlocks. + */ + list_sort(NULL, &io->ci_lockset.cls_todo, cl_lock_descr_cmp); result = cl_lockset_lock(env, io, &io->ci_lockset); } if (result != 0) -- 2.14.0.rc0.dirty -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 01:09:59 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 12:09:59 +1100 Subject: [lustre-devel] [PATCH 02/21] lustre: obd_class: remove csi_barrier from struct cl_sync_io In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781242.10620.4427066512247634121.stgit@noble.brown> Message-ID: <87bm3jgmfs.fsf@notabene.neil.brown.name> On Mon, Feb 11 2019, James Simmons wrote: >> This flag is used to ensure that structure isn't freed before >> the wakeup completes. The same can be achieved using the >> csi_waitq.lock and calling wake_up_all_locked(). >> > > Reviewed-by: James Simmons > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/include/cl_object.h | 2 -- >> drivers/staging/lustre/lustre/obdclass/cl_io.c | 16 +++++++--------- >> 2 files changed, 7 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h >> index 71ba73cdbb5e..13d79810dd39 100644 >> --- a/drivers/staging/lustre/lustre/include/cl_object.h >> +++ b/drivers/staging/lustre/lustre/include/cl_object.h >> @@ -2391,8 +2391,6 @@ struct cl_sync_io { >> atomic_t csi_sync_nr; >> /** error code. */ >> int csi_sync_rc; >> - /** barrier of destroy this structure */ >> - atomic_t csi_barrier; >> /** completion to be signaled when transfer is complete. */ >> wait_queue_head_t csi_waitq; >> }; >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c >> index e9ad055f84b8..beac7e8bc92a 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c >> @@ -1047,7 +1047,6 @@ void cl_sync_io_init(struct cl_sync_io *anchor, int nr) >> memset(anchor, 0, sizeof(*anchor)); >> init_waitqueue_head(&anchor->csi_waitq); >> atomic_set(&anchor->csi_sync_nr, nr); >> - atomic_set(&anchor->csi_barrier, nr > 0); >> anchor->csi_sync_rc = 0; >> } >> EXPORT_SYMBOL(cl_sync_io_init); >> @@ -1080,11 +1079,10 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, >> } else { >> rc = anchor->csi_sync_rc; >> } >> + /* We take the lock to ensure that cl_sync_io_note() has finished */ >> + spin_lock(&anchor->csi_waitq.lock); > > I don't think I every seen any use the internal lock for the wait_queue > in such a method. Most creative approach. You need to get more :-) There is a macro wait_event_interruptible_locked() which explicitly supports this model. Only used 4 times in the kernel so not very popular yet. The various forms of wake_up_locked are used a bit more often. I don't remember where I first saw it. It is a neat idea! Thanks, NeilBrown > >> 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)) >> - cpu_relax(); >> + spin_unlock(&anchor->csi_waitq.lock); >> >> return rc; >> } >> @@ -1104,11 +1102,11 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, >> * IO. >> */ >> LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); >> - if (atomic_dec_and_test(&anchor->csi_sync_nr)) { >> + if (atomic_dec_and_lock(&anchor->csi_sync_nr, >> + &anchor->csi_waitq.lock)) { >> >> - wake_up_all(&anchor->csi_waitq); >> - /* it's safe to nuke or reuse anchor now */ >> - atomic_set(&anchor->csi_barrier, 0); >> + wake_up_all_locked(&anchor->csi_waitq); >> + spin_unlock(&anchor->csi_waitq.lock); >> >> /* Can't access anchor any more */ >> } >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Mon Feb 11 01:32:38 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 01:32:38 +0000 (GMT) Subject: [lustre-devel] [PATCH 04/21] lustre: use list*entry macros in place of container_of() In-Reply-To: <154949781267.10620.8365663638954760207.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781267.10620.8365663638954760207.stgit@noble.brown> Message-ID: > There are a number of places that use container_of() but where > list_first_entry(), or list_last_entry() make the meaning more clear. > So change them over. I have to say normally the patches you see genernally use the basic functionality of the linux list implementation. I wonder if a deep dive on LUG's developers day would be a good idea. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ++-- > drivers/staging/lustre/lustre/obdclass/cl_io.c | 4 ++-- > drivers/staging/lustre/lustre/obdclass/cl_object.c | 13 ++++++++----- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 4 ++-- > drivers/staging/lustre/lustre/obdclass/lu_object.c | 7 +++---- > 5 files changed, 17 insertions(+), 15 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index 85c5047f4ba2..74c7644d6ef8 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -987,8 +987,8 @@ struct ldlm_namespace *ldlm_namespace_first_locked(enum ldlm_side client) > { > LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); > LASSERT(!list_empty(ldlm_namespace_list(client))); > - return container_of(ldlm_namespace_list(client)->next, > - struct ldlm_namespace, ns_list_chain); > + return list_first_entry(ldlm_namespace_list(client), > + struct ldlm_namespace, ns_list_chain); > } > > /** Create and initialize new resource. */ > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index 7bf02350f19d..34b4e63e7d1a 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -93,8 +93,8 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) > LINVRNT(cl_io_invariant(io)); > > while (!list_empty(&io->ci_layers)) { > - slice = container_of(io->ci_layers.prev, struct cl_io_slice, > - cis_linkage); > + slice = list_last_entry(&io->ci_layers, struct cl_io_slice, > + cis_linkage); > list_del_init(&slice->cis_linkage); > if (slice->cis_iop->op[io->ci_type].cio_fini) > slice->cis_iop->op[io->ci_type].cio_fini(env, slice); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index 05d784ae7a6c..f724b2d62df1 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -649,8 +649,8 @@ static struct lu_env *cl_env_obtain(void *debug) > if (cl_envs[cpu].cec_count > 0) { > int rc; > > - cle = container_of(cl_envs[cpu].cec_envs.next, struct cl_env, > - ce_linkage); > + cle = list_first_entry(&cl_envs[cpu].cec_envs, struct cl_env, > + ce_linkage); > list_del_init(&cle->ce_linkage); > cl_envs[cpu].cec_count--; > read_unlock(&cl_envs[cpu].cec_guard); > @@ -748,9 +748,12 @@ unsigned int cl_env_cache_purge(unsigned int nr) > > for_each_possible_cpu(i) { > write_lock(&cl_envs[i].cec_guard); > - for (; !list_empty(&cl_envs[i].cec_envs) && nr > 0; --nr) { > - cle = container_of(cl_envs[i].cec_envs.next, > - struct cl_env, ce_linkage); > + for (; nr >0 && > + (cle = list_first_entry_or_null( > + &cl_envs[i].cec_envs, > + struct cl_env, > + ce_linkage)) != NULL; > + --nr) { > list_del_init(&cle->ce_linkage); > LASSERT(cl_envs[i].cec_count > 0); > cl_envs[i].cec_count--; > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index b1b4dc7ea22f..d025ea55818f 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -690,8 +690,8 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) > const struct cl_page_slice *slice; > int result; > > - slice = container_of(pg->cp_layers.next, > - const struct cl_page_slice, cpl_linkage); > + slice = list_first_entry(&pg->cp_layers, > + const struct cl_page_slice, cpl_linkage); > PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked); > /* > * Call ->cpo_is_vmlocked() directly instead of going through > diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c > index 3bd48748f46c..639c298b6a90 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c > @@ -349,7 +349,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) > * lives as long as possible and ->loo_object_free() methods > * can look at its contents. > */ > - o = container_of(splice.prev, struct lu_object, lo_linkage); > + o = list_last_entry(&splice, struct lu_object, lo_linkage); > list_del_init(&o->lo_linkage); > o->lo_ops->loo_object_free(env, o); > } > @@ -432,9 +432,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s, > * Free everything on the dispose list. This is safe against > * races due to the reasons described in lu_object_put(). > */ > - while (!list_empty(&dispose)) { > - h = container_of(dispose.next, > - struct lu_object_header, loh_lru); > + while ((h = list_first_entry_or_null( > + &dispose, struct lu_object_header, loh_lru)) != NULL) { > list_del_init(&h->loh_lru); > lu_object_free(env, lu_object_top(h)); > lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED); > > > From jsimmons at infradead.org Mon Feb 11 01:45:00 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 01:45:00 +0000 (GMT) Subject: [lustre-devel] [PATCH 05/21] lustre: use list_first_entry() in lustre subdirectory. In-Reply-To: <154949781279.10620.5804477141390456723.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781279.10620.5804477141390456723.stgit@noble.brown> Message-ID: > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in 'lustre' > > In several cases the call is combined with > a list_empty() test and list_first_entry_or_null() is used Nak. One of the changes below breaks things. > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 2 - > drivers/staging/lustre/lustre/llite/statahead.c | 23 ++++---- > drivers/staging/lustre/lustre/lov/lov_io.c | 9 +-- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 9 +-- > drivers/staging/lustre/lustre/obdclass/genops.c | 22 ++++--- > .../staging/lustre/lustre/obdclass/lustre_peer.c | 5 +- > drivers/staging/lustre/lustre/osc/osc_cache.c | 17 +++--- > drivers/staging/lustre/lustre/osc/osc_lock.c | 5 +- > drivers/staging/lustre/lustre/osc/osc_page.c | 17 +++--- > drivers/staging/lustre/lustre/osc/osc_request.c | 8 +-- > drivers/staging/lustre/lustre/ptlrpc/client.c | 8 +-- > drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c | 6 +- > .../staging/lustre/lustre/ptlrpc/pack_generic.c | 4 + > drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 +- > drivers/staging/lustre/lustre/ptlrpc/service.c | 59 ++++++++++---------- > 15 files changed, 101 insertions(+), 99 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index 13d79810dd39..53fd8d469e55 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -2335,7 +2335,7 @@ static inline struct cl_page *cl_page_list_last(struct cl_page_list *plist) > static inline struct cl_page *cl_page_list_first(struct cl_page_list *plist) > { > LASSERT(plist->pl_nr > 0); > - return list_entry(plist->pl_pages.next, struct cl_page, cp_batch); > + return list_first_entry(&plist->pl_pages, struct cl_page, cp_batch); > } > > /** ... > diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c > index 5b97f2a1fea1..a69736dfe8b7 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/service.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c > @@ -299,9 +299,9 @@ ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) > return posted; > } > > - rqbd = list_entry(svcpt->scp_rqbd_idle.next, > - struct ptlrpc_request_buffer_desc, > - rqbd_list); > + rqbd = list_first_entry(&svcpt->scp_rqbd_idle, > + struct ptlrpc_request_buffer_desc, > + rqbd_list); > list_del(&rqbd->rqbd_list); > > /* assume we will post successfully */ > @@ -769,9 +769,9 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) > * I expect only about 1 or 2 rqbds need to be recycled here > */ > while (svcpt->scp_hist_nrqbds > svc->srv_hist_nrqbds_cpt_max) { > - rqbd = list_entry(svcpt->scp_hist_rqbds.next, > - struct ptlrpc_request_buffer_desc, > - rqbd_list); > + rqbd = list_first_entry(&svcpt->scp_hist_rqbds, > + struct ptlrpc_request_buffer_desc, > + rqbd_list); > > list_del(&rqbd->rqbd_list); > svcpt->scp_hist_nrqbds--; > @@ -1240,9 +1240,9 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) > /* we took additional refcount so entries can't be deleted from list, no > * locking is needed > */ > - while (!list_empty(&work_list)) { > - rq = list_entry(work_list.next, struct ptlrpc_request, > - rq_timed_list); > + while ((rq = list_first_entry_or_null(&work_list, > + struct ptlrpc_request, > + rq_timed_list)) != NULL) { > list_del_init(&rq->rq_timed_list); > > if (ptlrpc_at_send_early_reply(rq) == 0) > @@ -1485,8 +1485,8 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, > return 0; > } > > - req = list_entry(svcpt->scp_req_incoming.next, > - struct ptlrpc_request, rq_list); > + req = list_first_entry(&svcpt->scp_req_incoming, > + struct ptlrpc_request, rq_list); > list_del_init(&req->rq_list); > svcpt->scp_nreqs_incoming--; > /* Consider this still a "queued" request as far as stats are > @@ -2345,9 +2345,9 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) > > wake_up_all(&svcpt->scp_waitq); > > - while (!list_empty(&svcpt->scp_threads)) { > - thread = list_entry(svcpt->scp_threads.next, > - struct ptlrpc_thread, t_link); > + while ((thread = list_first_entry_or_null(&svcpt->scp_threads, > + struct ptlrpc_thread, > + t_link)) != NULL) { > if (thread_is_stopped(thread)) { > list_del(&thread->t_link); > list_add(&thread->t_link, &zombie); > @@ -2365,9 +2365,9 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) > > spin_unlock(&svcpt->scp_lock); > > - while (!list_empty(&zombie)) { > - thread = list_entry(zombie.next, > - struct ptlrpc_thread, t_link); > + while ((thread = list_first_entry(&zombie, > + struct ptlrpc_thread, > + t_link)) != NULL) { > list_del(&thread->t_link); > kfree(thread); > } The above change causes sanity tests 77j: client only supporting ADLER32 to fail with: 2019-02-07 18:38:26 [ 4346.464550] Lustre: Unmounted lustre-client 2019-02-07 18:38:26 [ 4346.471990] BUG: unable to handle kernel paging request at ffffeb02001c89c8 2019-02-07 18:38:26 [ 4346.480489] #PF error: [normal kernel read fault] 2019-02-07 18:38:26 [ 4346.486719] PGD 0 P4D 0 2019-02-07 18:38:26 [ 4346.490758] Oops: 0000 [#1] PREEMPT SMP PTI 2019-02-07 18:38:26 [ 4346.496420] CPU: 0 PID: 2478 Comm: kworker/0:1 Tainted: G WC 5.0.0-rc4+ #1 2019-02-07 18:38:26 [ 4346.505976] Hardware name: Supermicro SYS-6028TR-HTFR/X10DRT-HIBF, BIOS 2.0b 08/12/2016 2019-02-07 18:38:26 [ 4346.515461] Workqueue: obd_zombid obd_zombie_imp_cull [obdclass] 2019-02-07 18:38:26 [ 4346.522917] RIP: 0010:kfree+0x52/0x1b0 > @@ -2707,9 +2707,9 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) > break; > > spin_lock(&svcpt->scp_rep_lock); > - while (!list_empty(&svcpt->scp_rep_active)) { > - rs = list_entry(svcpt->scp_rep_active.next, > - struct ptlrpc_reply_state, rs_list); > + while ((rs = list_first_entry_or_null(&svcpt->scp_rep_active, > + struct ptlrpc_reply_state, > + rs_list)) != NULL) { > spin_lock(&rs->rs_lock); > ptlrpc_schedule_difficult_reply(rs); > spin_unlock(&rs->rs_lock); > @@ -2720,10 +2720,9 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) > * all unlinked) and no service threads, so I'm the only > * thread noodling the request queue now > */ > - while (!list_empty(&svcpt->scp_req_incoming)) { > - req = list_entry(svcpt->scp_req_incoming.next, > - struct ptlrpc_request, rq_list); > - > + while ((req = list_first_entry_or_null(&svcpt->scp_req_incoming, > + struct ptlrpc_request, > + rq_list)) != NULL) { > list_del(&req->rq_list); > svcpt->scp_nreqs_incoming--; > ptlrpc_server_finish_request(svcpt, req); > @@ -2747,17 +2746,17 @@ ptlrpc_service_purge_all(struct ptlrpc_service *svc) > */ > > while (!list_empty(&svcpt->scp_rqbd_idle)) { > - rqbd = list_entry(svcpt->scp_rqbd_idle.next, > - struct ptlrpc_request_buffer_desc, > - rqbd_list); > + rqbd = list_first_entry(&svcpt->scp_rqbd_idle, > + struct ptlrpc_request_buffer_desc, > + rqbd_list); > ptlrpc_free_rqbd(rqbd); > } > ptlrpc_wait_replies(svcpt); > > while (!list_empty(&svcpt->scp_rep_idle)) { > - rs = list_entry(svcpt->scp_rep_idle.next, > - struct ptlrpc_reply_state, > - rs_list); > + rs = list_first_entry(&svcpt->scp_rep_idle, > + struct ptlrpc_reply_state, > + rs_list); > list_del(&rs->rs_list); > kvfree(rs); > } > > > From jsimmons at infradead.org Mon Feb 11 01:46:24 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 01:46:24 +0000 (GMT) Subject: [lustre-devel] [PATCH 06/21] lustre: use list_first_entry() in lnet/lnet subdirectory. In-Reply-To: <154949781293.10620.13774044385661376106.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781293.10620.13774044385661376106.stgit@noble.brown> Message-ID: > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in 'lnet/lnet' > > In several cases the call is combined with > a list_empty() test and list_first_entry_or_null() is used > > In one case, list_splice_init() is used. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/api-ni.c | 111 ++++++++++++------------- > drivers/staging/lustre/lnet/lnet/config.c | 22 ++--- > drivers/staging/lustre/lnet/lnet/lib-move.c | 53 ++++++------ > drivers/staging/lustre/lnet/lnet/lib-msg.c | 16 ++-- > drivers/staging/lustre/lnet/lnet/lib-ptl.c | 7 +- > drivers/staging/lustre/lnet/lnet/net_fault.c | 24 +++-- > drivers/staging/lustre/lnet/lnet/nidstrings.c | 9 +- > drivers/staging/lustre/lnet/lnet/peer.c | 24 +++-- > drivers/staging/lustre/lnet/lnet/router.c | 13 ++- > 9 files changed, 141 insertions(+), 138 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index 64b8bef91915..671591a092ac 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -812,8 +812,8 @@ lnet_net2ni_locked(u32 net_id, int cpt) > > list_for_each_entry(net, &the_lnet.ln_nets, net_list) { > if (net->net_id == net_id) { > - ni = list_entry(net->net_ni_list.next, struct lnet_ni, > - ni_netlist); > + ni = list_first_entry(&net->net_ni_list, struct lnet_ni, > + ni_netlist); > return ni; > } > } > @@ -1504,12 +1504,12 @@ lnet_clear_zombies_nis_locked(struct lnet_net *net) > * list and shut them down in guaranteed thread context > */ > i = 2; > - while (!list_empty(zombie_list)) { > + while ((ni = list_first_entry_or_null(zombie_list, > + struct lnet_ni, > + ni_netlist)) != NULL) { > int *ref; > int j; > > - ni = list_entry(zombie_list->next, > - struct lnet_ni, ni_netlist); > list_del_init(&ni->ni_netlist); > /* the ni should be in deleting state. If it's not it's > * a bug */ > @@ -1583,9 +1583,9 @@ lnet_shutdown_lndnet(struct lnet_net *net) > > list_del_init(&net->net_list); > > - while (!list_empty(&net->net_ni_list)) { > - ni = list_entry(net->net_ni_list.next, > - struct lnet_ni, ni_netlist); > + while ((ni = list_first_entry_or_null(&net->net_ni_list, > + struct lnet_ni, > + ni_netlist)) != NULL) { > lnet_net_unlock(LNET_LOCK_EX); > lnet_shutdown_lndni(ni); > lnet_net_lock(LNET_LOCK_EX); > @@ -1622,16 +1622,12 @@ lnet_shutdown_lndnets(void) > lnet_net_lock(LNET_LOCK_EX); > the_lnet.ln_state = LNET_STATE_STOPPING; > > - while (!list_empty(&the_lnet.ln_nets)) { > - /* > - * move the nets to the zombie list to avoid them being > - * picked up for new work. LONET is also included in the > - * Nets that will be moved to the zombie list > - */ > - net = list_entry(the_lnet.ln_nets.next, > - struct lnet_net, net_list); > - list_move(&net->net_list, &the_lnet.ln_net_zombie); > - } > + /* > + * move the nets to the zombie list to avoid them being > + * picked up for new work. LONET is also included in the > + * Nets that will be moved to the zombie list > + */ > + list_splice_init(&the_lnet.ln_nets, &the_lnet.ln_net_zombie); > > /* Drop the cached loopback Net. */ > if (the_lnet.ln_loni) { > @@ -1641,11 +1637,10 @@ lnet_shutdown_lndnets(void) > lnet_net_unlock(LNET_LOCK_EX); > > /* iterate through the net zombie list and delete each net */ > - while (!list_empty(&the_lnet.ln_net_zombie)) { > - net = list_entry(the_lnet.ln_net_zombie.next, > - struct lnet_net, net_list); > + while ((net = list_first_entry_or_null(&the_lnet.ln_net_zombie, > + struct lnet_net, > + net_list)) != NULL) > lnet_shutdown_lndnet(net); > - } > > lnet_net_lock(LNET_LOCK_EX); > the_lnet.ln_state = LNET_STATE_SHUTDOWN; > @@ -1833,9 +1828,9 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun) > goto failed0; > } > > - while (!list_empty(&net->net_ni_added)) { > - ni = list_entry(net->net_ni_added.next, struct lnet_ni, > - ni_netlist); > + while ((ni = list_first_entry_or_null(&net->net_ni_added, > + struct lnet_ni, > + ni_netlist)) != NULL) { > list_del_init(&ni->ni_netlist); > > /* make sure that the the NI we're about to start > @@ -1902,12 +1897,10 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun) > * shutdown the new NIs that are being started up > * free the NET being started > */ > - while (!list_empty(&local_ni_list)) { > - ni = list_entry(local_ni_list.next, struct lnet_ni, > - ni_netlist); > - > + while ((ni = list_first_entry_or_null(&local_ni_list, > + struct lnet_ni, > + ni_netlist)) != NULL) > lnet_shutdown_lndni(ni); > - } > > failed0: > lnet_net_free(net); > @@ -1931,8 +1924,9 @@ lnet_startup_lndnets(struct list_head *netlist) > the_lnet.ln_state = LNET_STATE_RUNNING; > lnet_net_unlock(LNET_LOCK_EX); > > - while (!list_empty(netlist)) { > - net = list_entry(netlist->next, struct lnet_net, net_list); > + while ((net = list_first_entry_or_null(netlist, > + struct lnet_net, > + net_list)) != NULL) { > list_del_init(&net->net_list); > > rc = lnet_startup_lndnet(net, NULL); > @@ -2022,11 +2016,13 @@ int lnet_lib_init(void) > */ > void lnet_lib_exit(void) > { > + struct lnet_lnd *lnd; > LASSERT(!the_lnet.ln_refcount); > > - while (!list_empty(&the_lnet.ln_lnds)) > - lnet_unregister_lnd(list_entry(the_lnet.ln_lnds.next, > - struct lnet_lnd, lnd_list)); > + while ((lnd = list_first_entry_or_null(&the_lnet.ln_lnds, > + struct lnet_lnd, > + lnd_list)) != NULL) > + lnet_unregister_lnd(lnd); > lnet_destroy_locks(); > } > > @@ -2172,10 +2168,9 @@ LNetNIInit(lnet_pid_t requested_pid) > lnet_unprepare(); > LASSERT(rc < 0); > mutex_unlock(&the_lnet.ln_api_mutex); > - while (!list_empty(&net_head)) { > - struct lnet_net *net; > - > - net = list_entry(net_head.next, struct lnet_net, net_list); > + while ((net = list_first_entry_or_null(&net_head, > + struct lnet_net, > + net_list)) != NULL) { > list_del_init(&net->net_list); > lnet_net_free(net); > } > @@ -2411,10 +2406,11 @@ lnet_get_next_ni_locked(struct lnet_net *mynet, struct lnet_ni *prev) > > if (!prev) { > if (!net) > - net = list_entry(the_lnet.ln_nets.next, struct lnet_net, > - net_list); > - ni = list_entry(net->net_ni_list.next, struct lnet_ni, > - ni_netlist); > + net = list_first_entry(&the_lnet.ln_nets, > + struct lnet_net, > + net_list); > + ni = list_first_entry(&net->net_ni_list, struct lnet_ni, > + ni_netlist); > > return ni; > } > @@ -2432,17 +2428,17 @@ lnet_get_next_ni_locked(struct lnet_net *mynet, struct lnet_ni *prev) > return NULL; > > /* get the next net */ > - net = list_entry(prev->ni_net->net_list.next, struct lnet_net, > - net_list); > + net = list_first_entry(&prev->ni_net->net_list, struct lnet_net, > + net_list); > /* get the ni on it */ > - ni = list_entry(net->net_ni_list.next, struct lnet_ni, > - ni_netlist); > + ni = list_first_entry(&net->net_ni_list, struct lnet_ni, > + ni_netlist); > > return ni; > } > > /* there are more nis left */ > - ni = list_entry(prev->ni_netlist.next, struct lnet_ni, ni_netlist); > + ni = list_first_entry(&prev->ni_netlist, struct lnet_ni, ni_netlist); > > return ni; > } > @@ -2637,8 +2633,9 @@ static int lnet_handle_legacy_ip2nets(char *ip2nets, > return rc; > > mutex_lock(&the_lnet.ln_api_mutex); > - while (!list_empty(&net_head)) { > - net = list_entry(net_head.next, struct lnet_net, net_list); > + while ((net = list_first_entry_or_null(&net_head, > + struct lnet_net, > + net_list)) != NULL) { > list_del_init(&net->net_list); > rc = lnet_add_net_common(net, tun); > if (rc < 0) > @@ -2648,8 +2645,9 @@ static int lnet_handle_legacy_ip2nets(char *ip2nets, > out: > mutex_unlock(&the_lnet.ln_api_mutex); > > - while (!list_empty(&net_head)) { > - net = list_entry(net_head.next, struct lnet_net, net_list); > + while ((net = list_first_entry_or_null(&net_head, > + struct lnet_net, > + net_list)) != NULL) { > list_del_init(&net->net_list); > lnet_net_free(net); > } > @@ -2819,7 +2817,7 @@ lnet_dyn_add_net(struct lnet_ioctl_config_data *conf) > goto out_unlock_clean; > } > > - net = list_entry(net_head.next, struct lnet_net, net_list); > + net = list_first_entry(&net_head, struct lnet_net, net_list); > list_del_init(&net->net_list); > > LASSERT(lnet_net_unique(net->net_id, &the_lnet.ln_nets, NULL)); > @@ -2839,9 +2837,10 @@ lnet_dyn_add_net(struct lnet_ioctl_config_data *conf) > > out_unlock_clean: > mutex_unlock(&the_lnet.ln_api_mutex); > - while (!list_empty(&net_head)) { > - /* net_head list is empty in success case */ > - net = list_entry(net_head.next, struct lnet_net, net_list); > + /* net_head list is empty in success case */ > + while ((net = list_first_entry_or_null(&net_head, > + struct lnet_net, > + net_list)) != NULL) { > list_del_init(&net->net_list); > lnet_net_free(net); > } > diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c > index ecf656bce73f..f34844465d01 100644 > --- a/drivers/staging/lustre/lnet/lnet/config.c > +++ b/drivers/staging/lustre/lnet/lnet/config.c > @@ -817,8 +817,9 @@ lnet_parse_networks(struct list_head *netlist, char *networks, > lnet_syntax("networks", networks, (int)(str - tokens), strlen(str)); > failed: > /* free the net list and all the nis on each net */ > - while (!list_empty(netlist)) { > - net = list_entry(netlist->next, struct lnet_net, net_list); > + while ((net = list_first_entry_or_null(netlist, > + struct lnet_net, > + net_list)) != NULL) { > > list_del_init(&net->net_list); > lnet_net_free(net); > @@ -875,9 +876,8 @@ lnet_free_text_bufs(struct list_head *tbs) > { > struct lnet_text_buf *ltb; > > - while (!list_empty(tbs)) { > - ltb = list_entry(tbs->next, struct lnet_text_buf, ltb_list); > - > + while ((ltb = list_first_entry_or_null(tbs, struct lnet_text_buf, > + ltb_list)) != NULL) { > list_del(<b->ltb_list); > lnet_free_text_buf(ltb); > } > @@ -1239,8 +1239,8 @@ lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router) > { > struct lnet_text_buf *ltb; > > - while (!list_empty(tbs)) { > - ltb = list_entry(tbs->next, struct lnet_text_buf, ltb_list); > + while ((ltb = list_first_entry_or_null(tbs, struct lnet_text_buf, > + ltb_list)) != NULL) { > > if (lnet_parse_route(ltb->ltb_text, im_a_router) < 0) { > lnet_free_text_bufs(tbs); > @@ -1383,7 +1383,7 @@ lnet_splitnets(char *source, struct list_head *nets) > LASSERT(!list_empty(nets)); > LASSERT(nets->next == nets->prev); /* single entry */ > > - tb = list_entry(nets->next, struct lnet_text_buf, ltb_list); > + tb = list_first_entry(nets, struct lnet_text_buf, ltb_list); > > for (;;) { > sep = strchr(tb->ltb_text, ','); > @@ -1478,9 +1478,9 @@ lnet_match_networks(char **networksp, char *ip2nets, u32 *ipaddrs, int nip) > len = 0; > rc = 0; > > - while (!list_empty(&raw_entries)) { > - tb = list_entry(raw_entries.next, struct lnet_text_buf, > - ltb_list); > + while ((tb = list_first_entry_or_null(&raw_entries, > + struct lnet_text_buf, > + ltb_list)) != NULL) { > strncpy(source, tb->ltb_text, sizeof(source)); > source[sizeof(source) - 1] = '\0'; > > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index 92c6a34b44e6..185ea51d2771 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -185,9 +185,9 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) > > lnet_net_unlock(0); > > - while (!list_empty(&cull)) { > - tp = list_entry(cull.next, struct lnet_test_peer, tp_list); > - > + while ((tp = list_first_entry_or_null(&cull, > + struct lnet_test_peer, > + tp_list)) != NULL) { > list_del(&tp->tp_list); > kfree(tp); > } > @@ -244,8 +244,9 @@ fail_peer(lnet_nid_t nid, int outgoing) > > lnet_net_unlock(0); > > - while (!list_empty(&cull)) { > - tp = list_entry(cull.next, struct lnet_test_peer, tp_list); > + while ((tp = list_first_entry_or_null(&cull, > + struct lnet_test_peer, > + tp_list)) != NULL) { > list_del(&tp->tp_list); > > kfree(tp); > @@ -889,7 +890,7 @@ lnet_post_routed_recv_locked(struct lnet_msg *msg, int do_recv) > } > > LASSERT(!list_empty(&rbp->rbp_bufs)); > - rb = list_entry(rbp->rbp_bufs.next, struct lnet_rtrbuf, rb_list); > + rb = list_first_entry(&rbp->rbp_bufs, struct lnet_rtrbuf, rb_list); > list_del(&rb->rb_list); > > msg->msg_niov = rbp->rbp_npages; > @@ -926,8 +927,8 @@ lnet_return_tx_credits_locked(struct lnet_msg *msg) > tq->tq_credits++; > atomic_inc(&ni->ni_tx_credits); > if (tq->tq_credits <= 0) { > - msg2 = list_entry(tq->tq_delayed.next, > - struct lnet_msg, msg_list); > + msg2 = list_first_entry(&tq->tq_delayed, > + struct lnet_msg, msg_list); > list_del(&msg2->msg_list); > > LASSERT(msg2->msg_txni == ni); > @@ -953,8 +954,8 @@ lnet_return_tx_credits_locked(struct lnet_msg *msg) > if (txpeer->lpni_txcredits <= 0) { > int msg2_cpt; > > - msg2 = list_entry(txpeer->lpni_txq.next, > - struct lnet_msg, msg_list); > + msg2 = list_first_entry(&txpeer->lpni_txq, > + struct lnet_msg, msg_list); > list_del(&msg2->msg_list); > spin_unlock(&txpeer->lpni_lock); > > @@ -1015,8 +1016,8 @@ lnet_schedule_blocked_locked(struct lnet_rtrbufpool *rbp) > > if (list_empty(&rbp->rbp_msgs)) > return; > - msg = list_entry(rbp->rbp_msgs.next, > - struct lnet_msg, msg_list); > + msg = list_first_entry(&rbp->rbp_msgs, > + struct lnet_msg, msg_list); > list_del(&msg->msg_list); > > (void)lnet_post_routed_recv_locked(msg, 1); > @@ -1117,8 +1118,8 @@ lnet_return_rx_credits_locked(struct lnet_msg *msg) > spin_unlock(&rxpeer->lpni_lock); > lnet_drop_routed_msgs_locked(&drop, msg->msg_rx_cpt); > } else if (rxpeer->lpni_rtrcredits <= 0) { > - msg2 = list_entry(rxpeer->lpni_rtrq.next, > - struct lnet_msg, msg_list); > + msg2 = list_first_entry(&rxpeer->lpni_rtrq, > + struct lnet_msg, msg_list); > list_del(&msg2->msg_list); > spin_unlock(&rxpeer->lpni_lock); > (void)lnet_post_routed_recv_locked(msg2, 1); > @@ -1553,8 +1554,8 @@ lnet_select_pathway(lnet_nid_t src_nid, lnet_nid_t dst_nid, > libcfs_net2str(best_lpni->lpni_net->net_id)); > return -EHOSTUNREACH; > } > - lpni = list_entry(peer_net->lpn_peer_nis.next, > - struct lnet_peer_ni, > + lpni = list_first_entry(&peer_net->lpn_peer_nis, > + struct lnet_peer_ni, > lpni_peer_nis); > } > /* Set preferred NI if necessary. */ > @@ -1595,9 +1596,9 @@ lnet_select_pathway(lnet_nid_t src_nid, lnet_nid_t dst_nid, > if (!local_net && !routing && !local_found) { > struct lnet_peer_ni *net_gw; > > - lpni = list_entry(peer_net->lpn_peer_nis.next, > - struct lnet_peer_ni, > - lpni_peer_nis); > + lpni = list_first_entry(&peer_net->lpn_peer_nis, > + struct lnet_peer_ni, > + lpni_peer_nis); > > net_gw = lnet_find_route_locked(NULL, > lpni->lpni_nid, > @@ -2620,11 +2621,12 @@ EXPORT_SYMBOL(lnet_parse); > void > lnet_drop_delayed_msg_list(struct list_head *head, char *reason) > { > - while (!list_empty(head)) { > + struct lnet_msg *msg; > + > + while ((msg = list_first_entry_or_null(head, struct lnet_msg, > + msg_list)) != NULL) { > struct lnet_process_id id = { 0 }; > - struct lnet_msg *msg; > > - msg = list_entry(head->next, struct lnet_msg, msg_list); > list_del(&msg->msg_list); > > id.nid = msg->msg_hdr.src_nid; > @@ -2662,11 +2664,12 @@ lnet_drop_delayed_msg_list(struct list_head *head, char *reason) > void > lnet_recv_delayed_msg_list(struct list_head *head) > { > - while (!list_empty(head)) { > - struct lnet_msg *msg; > + struct lnet_msg *msg; > + > + while ((msg = list_first_entry_or_null(head, struct lnet_msg, > + msg_list)) != NULL) { > struct lnet_process_id id; > > - msg = list_entry(head->next, struct lnet_msg, msg_list); > list_del(&msg->msg_list); > > /* > diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c > index b9e9257a4c5a..02620fe2a0fa 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c > @@ -528,10 +528,9 @@ lnet_finalize(struct lnet_msg *msg, int status) > > container->msc_finalizers[my_slot] = current; > > - while (!list_empty(&container->msc_finalizing)) { > - msg = list_entry(container->msc_finalizing.next, > - struct lnet_msg, msg_list); > - > + while ((msg = list_first_entry_or_null(&container->msc_finalizing, > + struct lnet_msg, > + msg_list)) != NULL) { > list_del(&msg->msg_list); > > /* > @@ -561,15 +560,14 @@ void > lnet_msg_container_cleanup(struct lnet_msg_container *container) > { > int count = 0; > + struct lnet_msg *msg; > > if (!container->msc_init) > return; > > - while (!list_empty(&container->msc_active)) { > - struct lnet_msg *msg; > - > - msg = list_entry(container->msc_active.next, > - struct lnet_msg, msg_activelist); > + while ((msg = list_first_entry_or_null(&container->msc_active, > + struct lnet_msg, > + msg_activelist)) != NULL) { > LASSERT(msg->msg_onactivelist); > msg->msg_onactivelist = 0; > list_del(&msg->msg_activelist); > diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c > index ea232c76b64d..4a12d86e6d64 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c > @@ -767,9 +767,10 @@ lnet_ptl_cleanup(struct lnet_portal *ptl) > mhash = mtable->mt_mhash; > /* cleanup ME */ > for (j = 0; j < LNET_MT_HASH_SIZE + 1; j++) { > - while (!list_empty(&mhash[j])) { > - me = list_entry(mhash[j].next, > - struct lnet_me, me_list); > + while ((me = list_first_entry_or_null(&mhash[j], > + struct lnet_me, > + me_list)) > + != NULL) { > CERROR("Active ME %p on exit\n", me); > list_del(&me->me_list); > kfree(me); > diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c > index 4234ce1ce539..130a7c90965d 100644 > --- a/drivers/staging/lustre/lnet/lnet/net_fault.c > +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c > @@ -581,8 +581,8 @@ delayed_msg_check(struct lnet_delay_rule *rule, bool all, > * dequeued some timedout messages, update timer for the > * next delayed message on rule > */ > - msg = list_entry(rule->dl_msg_list.next, > - struct lnet_msg, msg_list); > + msg = list_first_entry(&rule->dl_msg_list, > + struct lnet_msg, msg_list); > rule->dl_msg_send = msg->msg_delay_send; > mod_timer(&rule->dl_timer, rule->dl_msg_send); > } > @@ -594,12 +594,12 @@ delayed_msg_process(struct list_head *msg_list, bool drop) > { > struct lnet_msg *msg; > > - while (!list_empty(msg_list)) { > + while ((msg = list_first_entry_or_null(msg_list, struct lnet_msg, > + msg_list)) != NULL) { > struct lnet_ni *ni; > int cpt; > int rc; > > - msg = list_entry(msg_list->next, struct lnet_msg, msg_list); > LASSERT(msg->msg_rxpeer); > LASSERT(msg->msg_rxni); > > @@ -653,16 +653,16 @@ lnet_delay_rule_check(void) > break; > > spin_lock_bh(&delay_dd.dd_lock); > - if (list_empty(&delay_dd.dd_sched_rules)) { > - spin_unlock_bh(&delay_dd.dd_lock); > - break; > - } > - > - rule = list_entry(delay_dd.dd_sched_rules.next, > - struct lnet_delay_rule, dl_sched_link); > - list_del_init(&rule->dl_sched_link); > + rule = list_first_entry_or_null(&delay_dd.dd_sched_rules, > + struct lnet_delay_rule, > + dl_sched_link); > + if (!rule) > + list_del_init(&rule->dl_sched_link); > spin_unlock_bh(&delay_dd.dd_lock); > > + if (!rule) > + break; > + > delayed_msg_check(rule, false, &msgs); > delay_rule_decref(rule); /* -1 for delay_dd.dd_sched_rules */ > } > diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c > index 8f3d87c5467c..2df9ce4995f3 100644 > --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c > +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c > @@ -282,10 +282,11 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist) > static void > free_addrranges(struct list_head *list) > { > - while (!list_empty(list)) { > - struct addrrange *ar; > + struct addrrange *ar; > > - ar = list_entry(list->next, struct addrrange, ar_link); > + while ((ar = list_first_entry_or_null(list, > + struct addrrange, > + ar_link)) != NULL) { > > cfs_expr_list_free_list(&ar->ar_numaddr_ranges); > list_del(&ar->ar_link); > @@ -960,7 +961,7 @@ libcfs_num_match(u32 addr, struct list_head *numaddr) > struct cfs_expr_list *el; > > LASSERT(!list_empty(numaddr)); > - el = list_entry(numaddr->next, struct cfs_expr_list, el_link); > + el = list_first_entry(numaddr, struct cfs_expr_list, el_link); > > return cfs_expr_list_match(addr, el); > } > diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c > index dfe1f3d09bc6..ade7f23b3bf4 100644 > --- a/drivers/staging/lustre/lnet/lnet/peer.c > +++ b/drivers/staging/lustre/lnet/lnet/peer.c > @@ -649,12 +649,12 @@ lnet_get_next_peer_ni_locked(struct lnet_peer *peer, > if (list_empty(&peer->lp_peer_nets)) > return NULL; > > - net = list_entry(peer->lp_peer_nets.next, > - struct lnet_peer_net, > - lpn_peer_nets); > + net = list_first_entry(&peer->lp_peer_nets, > + struct lnet_peer_net, > + lpn_peer_nets); > } > - lpni = list_entry(net->lpn_peer_nis.next, struct lnet_peer_ni, > - lpni_peer_nis); > + lpni = list_first_entry(&net->lpn_peer_nis, struct lnet_peer_ni, > + lpni_peer_nis); > > return lpni; > } > @@ -678,19 +678,19 @@ lnet_get_next_peer_ni_locked(struct lnet_peer *peer, > return NULL; > > /* get the next net */ > - net = list_entry(prev->lpni_peer_net->lpn_peer_nets.next, > - struct lnet_peer_net, > - lpn_peer_nets); > + net = list_first_entry(&prev->lpni_peer_net->lpn_peer_nets, > + struct lnet_peer_net, > + lpn_peer_nets); > /* get the ni on it */ > - lpni = list_entry(net->lpn_peer_nis.next, struct lnet_peer_ni, > - lpni_peer_nis); > + lpni = list_first_entry(&net->lpn_peer_nis, struct lnet_peer_ni, > + lpni_peer_nis); > > return lpni; > } > > /* there are more nis left */ > - lpni = list_entry(prev->lpni_peer_nis.next, > - struct lnet_peer_ni, lpni_peer_nis); > + lpni = list_first_entry(&prev->lpni_peer_nis, > + struct lnet_peer_ni, lpni_peer_nis); > > return lpni; > } > diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c > index 463b123e0e5c..bcde61d2a984 100644 > --- a/drivers/staging/lustre/lnet/lnet/router.c > +++ b/drivers/staging/lustre/lnet/lnet/router.c > @@ -1220,9 +1220,9 @@ lnet_prune_rc_data(int wait_unlink) > > lnet_net_unlock(LNET_LOCK_EX); > > - while (!list_empty(&head)) { > - rcd = list_entry(head.next, > - struct lnet_rc_data, rcd_list); > + while ((rcd = list_first_entry_or_null(&head, > + struct lnet_rc_data, > + rcd_list)) != NULL) { > list_del_init(&rcd->rcd_list); > lnet_destroy_rc_data(rcd); > } > @@ -1397,7 +1397,7 @@ lnet_rtrpool_free_bufs(struct lnet_rtrbufpool *rbp, int cpt) > > /* Free buffers on the free list. */ > while (!list_empty(&tmp)) { > - rb = list_entry(tmp.next, struct lnet_rtrbuf, rb_list); > + rb = list_first_entry(&tmp, struct lnet_rtrbuf, rb_list); > list_del(&rb->rb_list); > lnet_destroy_rtrbuf(rb, npages); > } > @@ -1481,8 +1481,9 @@ lnet_rtrpool_adjust_bufs(struct lnet_rtrbufpool *rbp, int nbufs, int cpt) > return 0; > > failed: > - while (!list_empty(&rb_list)) { > - rb = list_entry(rb_list.next, struct lnet_rtrbuf, rb_list); > + while ((rb = list_first_entry_or_null(&rb_list, > + struct lnet_rtrbuf, > + rb_list)) != NULL) { > list_del(&rb->rb_list); > lnet_destroy_rtrbuf(rb, npages); > } > > > From jsimmons at infradead.org Mon Feb 11 01:47:00 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 01:47:00 +0000 (GMT) Subject: [lustre-devel] [PATCH 07/21] lustre: use list_first_entry() in lnet/klnds subdirectory. In-Reply-To: <154949781297.10620.13452862524706335326.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781297.10620.13452862524706335326.stgit@noble.brown> Message-ID: > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in 'lnet/klnds > > In several cases the call is combined with a list_empty() test and > list_first_entry_or_null() is used tested on IB with no problems. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 19 +++-- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 61 ++++++++------- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 9 +- > .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 79 ++++++++++---------- > .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 4 + > 5 files changed, 88 insertions(+), 84 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index 74b21fe2c091..df6b1b134709 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -1386,8 +1386,8 @@ static void kiblnd_destroy_fmr_pool_list(struct list_head *head) > { > struct kib_fmr_pool *fpo; > > - while (!list_empty(head)) { > - fpo = list_entry(head->next, struct kib_fmr_pool, fpo_list); > + while ((fpo = list_first_entry_or_null(head, struct kib_fmr_pool, > + fpo_list)) != NULL) { > list_del(&fpo->fpo_list); > kiblnd_destroy_fmr_pool(fpo); > } > @@ -1544,14 +1544,16 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps, > static void kiblnd_fail_fmr_poolset(struct kib_fmr_poolset *fps, > struct list_head *zombies) > { > + struct kib_fmr_pool *fpo; > + > if (!fps->fps_net) /* initialized? */ > return; > > spin_lock(&fps->fps_lock); > > - while (!list_empty(&fps->fps_pool_list)) { > - struct kib_fmr_pool *fpo = list_entry(fps->fps_pool_list.next, > - struct kib_fmr_pool, fpo_list); > + while ((fpo = list_first_entry_or_null(&fps->fps_pool_list, > + struct kib_fmr_pool, > + fpo_list)) != NULL) { > fpo->fpo_failed = 1; > list_del(&fpo->fpo_list); > if (!fpo->fpo_map_count) > @@ -1853,8 +1855,9 @@ static void kiblnd_destroy_pool_list(struct list_head *head) > { > struct kib_pool *pool; > > - while (!list_empty(head)) { > - pool = list_entry(head->next, struct kib_pool, po_list); > + while ((pool = list_first_entry_or_null(head, > + struct kib_pool, > + po_list)) != NULL) { > list_del(&pool->po_list); > > LASSERT(pool->po_owner); > @@ -1869,7 +1872,7 @@ static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombie > > spin_lock(&ps->ps_lock); > while (!list_empty(&ps->ps_pool_list)) { > - struct kib_pool *po = list_entry(ps->ps_pool_list.next, > + struct kib_pool *po = list_first_entry(&ps->ps_pool_list, > struct kib_pool, po_list); > po->po_failed = 1; > list_del(&po->po_list); > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > index ad1726098ea3..b9585f607463 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > @@ -98,9 +98,9 @@ kiblnd_txlist_done(struct list_head *txlist, int status) > { > struct kib_tx *tx; > > - while (!list_empty(txlist)) { > - tx = list_entry(txlist->next, struct kib_tx, tx_list); > - > + while ((tx = list_first_entry_or_null(txlist, > + struct kib_tx, > + tx_list)) != NULL) { > list_del(&tx->tx_list); > /* complete now */ > tx->tx_waiting = 0; > @@ -958,9 +958,9 @@ kiblnd_check_sends_locked(struct kib_conn *conn) > LASSERT(conn->ibc_reserved_credits >= 0); > > while (conn->ibc_reserved_credits > 0 && > - !list_empty(&conn->ibc_tx_queue_rsrvd)) { > - tx = list_entry(conn->ibc_tx_queue_rsrvd.next, > - struct kib_tx, tx_list); > + (tx = list_first_entry_or_null( > + &conn->ibc_tx_queue_rsrvd, > + struct kib_tx, tx_list)) != NULL) { > list_del(&tx->tx_list); > list_add_tail(&tx->tx_list, &conn->ibc_tx_queue); > conn->ibc_reserved_credits--; > @@ -983,17 +983,17 @@ kiblnd_check_sends_locked(struct kib_conn *conn) > > if (!list_empty(&conn->ibc_tx_queue_nocred)) { > credit = 0; > - tx = list_entry(conn->ibc_tx_queue_nocred.next, > - struct kib_tx, tx_list); > + tx = list_first_entry(&conn->ibc_tx_queue_nocred, > + struct kib_tx, tx_list); > } else if (!list_empty(&conn->ibc_tx_noops)) { > LASSERT(!IBLND_OOB_CAPABLE(ver)); > credit = 1; > - tx = list_entry(conn->ibc_tx_noops.next, > - struct kib_tx, tx_list); > + tx = list_first_entry(&conn->ibc_tx_noops, > + struct kib_tx, tx_list); > } else if (!list_empty(&conn->ibc_tx_queue)) { > credit = 1; > - tx = list_entry(conn->ibc_tx_queue.next, > - struct kib_tx, tx_list); > + tx = list_first_entry(&conn->ibc_tx_queue, > + struct kib_tx, tx_list); > } else { > break; > } > @@ -2013,9 +2013,9 @@ kiblnd_handle_early_rxs(struct kib_conn *conn) > LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED); > > write_lock_irqsave(&kiblnd_data.kib_global_lock, flags); > - while (!list_empty(&conn->ibc_early_rxs)) { > - rx = list_entry(conn->ibc_early_rxs.next, > - struct kib_rx, rx_list); > + while ((rx = list_first_entry_or_null(&conn->ibc_early_rxs, > + struct kib_rx, > + rx_list)) != NULL) { > list_del(&rx->rx_list); > write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); > > @@ -3311,8 +3311,9 @@ kiblnd_check_conns(int idx) > * NOOP, but there were no non-blocking tx descs > * free to do it last time... > */ > - while (!list_empty(&checksends)) { > - conn = list_entry(checksends.next, struct kib_conn, ibc_connd_list); > + while ((conn = list_first_entry_or_null(&checksends, > + struct kib_conn, > + ibc_connd_list)) != NULL) { > list_del(&conn->ibc_connd_list); > > spin_lock(&conn->ibc_lock); > @@ -3370,11 +3371,12 @@ kiblnd_connd(void *arg) > > dropped_lock = 0; > > - if (!list_empty(&kiblnd_data.kib_connd_zombies)) { > + conn = list_first_entry_or_null( > + &kiblnd_data.kib_connd_zombies, > + struct kib_conn, ibc_list); > + if (conn) { > struct kib_peer_ni *peer_ni = NULL; > > - conn = list_entry(kiblnd_data.kib_connd_zombies.next, > - struct kib_conn, ibc_list); > list_del(&conn->ibc_list); > if (conn->ibc_reconnect) { > peer_ni = conn->ibc_peer; > @@ -3401,9 +3403,9 @@ kiblnd_connd(void *arg) > &kiblnd_data.kib_reconn_wait); > } > > - if (!list_empty(&kiblnd_data.kib_connd_conns)) { > - conn = list_entry(kiblnd_data.kib_connd_conns.next, > - struct kib_conn, ibc_list); > + conn = list_first_entry_or_null(&kiblnd_data.kib_connd_conns, > + struct kib_conn, ibc_list); > + if (conn) { > list_del(&conn->ibc_list); > > spin_unlock_irqrestore(lock, flags); > @@ -3423,11 +3425,11 @@ kiblnd_connd(void *arg) > &kiblnd_data.kib_reconn_list); > } > > - if (list_empty(&kiblnd_data.kib_reconn_list)) > + conn = list_first_entry_or_null(&kiblnd_data.kib_reconn_list, > + struct kib_conn, ibc_list); > + if (!conn) > break; > > - conn = list_entry(kiblnd_data.kib_reconn_list.next, > - struct kib_conn, ibc_list); > list_del(&conn->ibc_list); > > spin_unlock_irqrestore(lock, flags); > @@ -3636,9 +3638,10 @@ kiblnd_scheduler(void *arg) > > did_something = 0; > > - if (!list_empty(&sched->ibs_conns)) { > - conn = list_entry(sched->ibs_conns.next, struct kib_conn, > - ibc_sched_list); > + conn = list_first_entry_or_null(&sched->ibs_conns, > + struct kib_conn, > + ibc_sched_list); > + if (conn) { > /* take over kib_sched_conns' ref on conn... */ > LASSERT(conn->ibc_scheduled); > list_del(&conn->ibc_sched_list); > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index 785f76cf9067..08feaf7ce33a 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -1566,9 +1566,8 @@ ksocknal_finalize_zcreq(struct ksock_conn *conn) > > spin_unlock(&peer_ni->ksnp_lock); > > - while (!list_empty(&zlist)) { > - tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list); > - > + while ((tx = list_first_entry_or_null(&zlist, struct ksock_tx, > + tx_zc_list)) != NULL) { > list_del(&tx->tx_zc_list); > ksocknal_tx_decref(tx); > } > @@ -2267,8 +2266,8 @@ ksocknal_free_buffers(void) > list_del_init(&ksocknal_data.ksnd_idle_noop_txs); > spin_unlock(&ksocknal_data.ksnd_tx_lock); > > - while (!list_empty(&zlist)) { > - tx = list_entry(zlist.next, struct ksock_tx, tx_list); > + while ((tx = list_first_entry_or_null(&zlist, struct ksock_tx, > + tx_list)) != NULL) { > list_del(&tx->tx_list); > kfree(tx); > } > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > index 8e20f430a3f3..208b8d360d5c 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > @@ -36,9 +36,9 @@ ksocknal_alloc_tx(int type, int size) > /* searching for a noop tx in free list */ > spin_lock(&ksocknal_data.ksnd_tx_lock); > > - if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) { > - tx = list_entry(ksocknal_data.ksnd_idle_noop_txs.next, > - struct ksock_tx, tx_list); > + tx = list_first_entry_or_null(&ksocknal_data.ksnd_idle_noop_txs, > + struct ksock_tx, tx_list); > + if (tx) { > LASSERT(tx->tx_desc_size == size); > list_del(&tx->tx_list); > } > @@ -347,8 +347,8 @@ ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int error) > { > struct ksock_tx *tx; > > - while (!list_empty(txlist)) { > - tx = list_entry(txlist->next, struct ksock_tx, tx_list); > + while ((tx = list_first_entry_or_null(txlist, struct ksock_tx, > + tx_list)) != NULL) { > > if (error && tx->tx_lnetmsg) { > CNETERR("Deleting packet type %d len %d %s->%s\n", > @@ -1322,9 +1322,10 @@ int ksocknal_scheduler(void *arg) > > /* Ensure I progress everything semi-fairly */ > > - if (!list_empty(&sched->kss_rx_conns)) { > - conn = list_entry(sched->kss_rx_conns.next, > - struct ksock_conn, ksnc_rx_list); > + conn = list_first_entry_or_null(&sched->kss_rx_conns, > + struct ksock_conn, > + ksnc_rx_list); > + if (conn) { > list_del(&conn->ksnc_rx_list); > > LASSERT(conn->ksnc_rx_scheduled); > @@ -1378,16 +1379,17 @@ int ksocknal_scheduler(void *arg) > list_del_init(&sched->kss_zombie_noop_txs); > } > > - conn = list_entry(sched->kss_tx_conns.next, > - struct ksock_conn, ksnc_tx_list); > + conn = list_first_entry(&sched->kss_tx_conns, > + struct ksock_conn, > + ksnc_tx_list); > list_del(&conn->ksnc_tx_list); > > LASSERT(conn->ksnc_tx_scheduled); > LASSERT(conn->ksnc_tx_ready); > LASSERT(!list_empty(&conn->ksnc_tx_queue)); > > - tx = list_entry(conn->ksnc_tx_queue.next, > - struct ksock_tx, tx_list); > + tx = list_first_entry(&conn->ksnc_tx_queue, > + struct ksock_tx, tx_list); > > if (conn->ksnc_tx_carrier == tx) > ksocknal_next_tx_carrier(conn); > @@ -1900,8 +1902,8 @@ ksocknal_connect(struct ksock_route *route) > * connection for V1.x and V2.x > */ > if (!list_empty(&peer_ni->ksnp_conns)) { > - conn = list_entry(peer_ni->ksnp_conns.next, > - struct ksock_conn, ksnc_list); > + conn = list_first_entry(&peer_ni->ksnp_conns, > + struct ksock_conn, ksnc_list); > LASSERT(conn->ksnc_proto == &ksocknal_protocol_v3x); > } > > @@ -2082,10 +2084,10 @@ ksocknal_connd(void *arg) > dropped_lock = 1; > } > > - if (!list_empty(&ksocknal_data.ksnd_connd_connreqs)) { > + cr = list_first_entry_or_null(&ksocknal_data.ksnd_connd_connreqs, > + struct ksock_connreq, ksncr_list); > + if (cr) { > /* Connection accepted by the listener */ > - cr = list_entry(ksocknal_data.ksnd_connd_connreqs.next, > - struct ksock_connreq, ksncr_list); > > list_del(&cr->ksncr_list); > spin_unlock_bh(connd_lock); > @@ -2246,9 +2248,9 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer_ni) > > write_lock_bh(&ksocknal_data.ksnd_global_lock); > > - while (!list_empty(&peer_ni->ksnp_tx_queue)) { > - tx = list_entry(peer_ni->ksnp_tx_queue.next, struct ksock_tx, > - tx_list); > + while ((tx = list_first_entry_or_null(&peer_ni->ksnp_tx_queue, > + struct ksock_tx, > + tx_list)) != NULL) { > > if (ktime_get_seconds() < tx->tx_deadline) > break; > @@ -2372,19 +2374,16 @@ ksocknal_check_peer_timeouts(int idx) > * we can't process stale txs right here because we're > * holding only shared lock > */ > - if (!list_empty(&peer_ni->ksnp_tx_queue)) { > - tx = list_entry(peer_ni->ksnp_tx_queue.next, > - struct ksock_tx, tx_list); > - > - if (ktime_get_seconds() >= tx->tx_deadline) { > - ksocknal_peer_addref(peer_ni); > - read_unlock(&ksocknal_data.ksnd_global_lock); > + tx = list_first_entry_or_null(&peer_ni->ksnp_tx_queue, > + struct ksock_tx, tx_list); > + if (tx && ktime_get_seconds() >= tx->tx_deadline) { > + ksocknal_peer_addref(peer_ni); > + read_unlock(&ksocknal_data.ksnd_global_lock); > > - ksocknal_flush_stale_txs(peer_ni); > + ksocknal_flush_stale_txs(peer_ni); > > - ksocknal_peer_decref(peer_ni); > - goto again; > - } > + ksocknal_peer_decref(peer_ni); > + goto again; > } > > if (list_empty(&peer_ni->ksnp_zc_req_list)) > @@ -2449,9 +2448,9 @@ ksocknal_reaper(void *arg) > spin_lock_bh(&ksocknal_data.ksnd_reaper_lock); > > while (!ksocknal_data.ksnd_shuttingdown) { > - if (!list_empty(&ksocknal_data.ksnd_deathrow_conns)) { > - conn = list_entry(ksocknal_data.ksnd_deathrow_conns.next, > - struct ksock_conn, ksnc_list); > + conn = list_first_entry_or_null(&ksocknal_data.ksnd_deathrow_conns, > + struct ksock_conn, ksnc_list); > + if (conn) { > list_del(&conn->ksnc_list); > > spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock); > @@ -2463,9 +2462,9 @@ ksocknal_reaper(void *arg) > continue; > } > > - if (!list_empty(&ksocknal_data.ksnd_zombie_conns)) { > - conn = list_entry(ksocknal_data.ksnd_zombie_conns.next, > - struct ksock_conn, ksnc_list); > + conn = list_first_entry_or_null(&ksocknal_data.ksnd_zombie_conns, > + struct ksock_conn, ksnc_list); > + if (conn) { > list_del(&conn->ksnc_list); > > spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock); > @@ -2486,9 +2485,9 @@ ksocknal_reaper(void *arg) > > /* reschedule all the connections that stalled with ENOMEM... */ > nenomem_conns = 0; > - while (!list_empty(&enomem_conns)) { > - conn = list_entry(enomem_conns.next, struct ksock_conn, > - ksnc_tx_list); > + while ((conn = list_first_entry_or_null(&enomem_conns, > + struct ksock_conn, > + ksnc_tx_list)) != NULL) { > list_del(&conn->ksnc_tx_list); > > sched = conn->ksnc_scheduler; > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > index c694feceaaf2..e8b95affee96 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > @@ -447,8 +447,8 @@ ksocknal_handle_zcack(struct ksock_conn *conn, u64 cookie1, u64 cookie2) > > spin_unlock(&peer_ni->ksnp_lock); > > - while (!list_empty(&zlist)) { > - tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list); > + while ((tx = list_first_entry_or_null(&zlist, struct ksock_tx, > + tx_zc_list)) != NULL) { > list_del(&tx->tx_zc_list); > ksocknal_tx_decref(tx); > } > > > From jsimmons at infradead.org Mon Feb 11 01:48:27 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 01:48:27 +0000 (GMT) Subject: [lustre-devel] [PATCH 08/21] lustre: use list_first_entry() throughout In-Reply-To: <154949781303.10620.10579175228046856433.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781303.10620.10579175228046856433.stgit@noble.brown> Message-ID: > Convert > list_entry(foo->next .....) > to > list_first_entry(foo, ....) > > in remainder of lustre. > > In several cases the call is combined with a list_empty() test and > list_first_entry_or_null() is used Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 12 +++-- > drivers/staging/lustre/lnet/selftest/conrpc.c | 5 +- > drivers/staging/lustre/lnet/selftest/console.c | 39 ++++++++---------- > drivers/staging/lustre/lnet/selftest/framework.c | 44 ++++++++++---------- > drivers/staging/lustre/lnet/selftest/rpc.c | 27 ++++++------ > drivers/staging/lustre/lnet/selftest/timer.c | 4 +- > 6 files changed, 62 insertions(+), 69 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c > index 5fb85247525d..ae17b4d44cac 100644 > --- a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c > +++ b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c > @@ -468,11 +468,11 @@ EXPORT_SYMBOL(cfs_expr_list_values); > void > cfs_expr_list_free(struct cfs_expr_list *expr_list) > { > - while (!list_empty(&expr_list->el_exprs)) { > - struct cfs_range_expr *expr; > + struct cfs_range_expr *expr; > > - expr = list_entry(expr_list->el_exprs.next, > - struct cfs_range_expr, re_link); > + while ((expr = list_first_entry_or_null(&expr_list->el_exprs, > + struct cfs_range_expr, > + re_link)) != NULL) { > list_del(&expr->re_link); > kfree(expr); > } > @@ -553,8 +553,8 @@ cfs_expr_list_free_list(struct list_head *list) > { > struct cfs_expr_list *el; > > - while (!list_empty(list)) { > - el = list_entry(list->next, struct cfs_expr_list, el_link); > + while ((el = list_first_entry_or_null(list, struct cfs_expr_list, > + el_link)) != NULL) { > list_del(&el->el_link); > cfs_expr_list_free(el); > } > diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c > index d9bcfa8c92ae..af0d2aa3b6e8 100644 > --- a/drivers/staging/lustre/lnet/selftest/conrpc.c > +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c > @@ -1362,9 +1362,8 @@ lstcon_rpc_cleanup_wait(void) > > spin_unlock(&console_session.ses_rpc_lock); > > - while (!list_empty(&zlist)) { > - crpc = list_entry(zlist.next, struct lstcon_rpc, crp_link); > - > + while ((crpc = list_first_entry_or_null(&zlist, struct lstcon_rpc, > + crp_link)) != NULL) { > list_del(&crpc->crp_link); > kfree(crpc); > } > diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c > index 045d79f44321..abc342c6a842 100644 > --- a/drivers/staging/lustre/lnet/selftest/console.c > +++ b/drivers/staging/lustre/lnet/selftest/console.c > @@ -330,11 +330,10 @@ lstcon_group_move(struct lstcon_group *old, struct lstcon_group *new) > { > struct lstcon_ndlink *ndl; > > - while (!list_empty(&old->grp_ndl_list)) { > - ndl = list_entry(old->grp_ndl_list.next, > - struct lstcon_ndlink, ndl_link); > + while ((ndl = list_first_entry_or_null(&old->grp_ndl_list, > + struct lstcon_ndlink, > + ndl_link)) != NULL) > lstcon_group_ndlink_move(old, new, ndl); > - } > } > > static int > @@ -1095,9 +1094,9 @@ lstcon_batch_destroy(struct lstcon_batch *bat) > > list_del(&bat->bat_link); > > - while (!list_empty(&bat->bat_test_list)) { > - test = list_entry(bat->bat_test_list.next, > - struct lstcon_test, tes_link); > + while ((test = list_first_entry_or_null(&bat->bat_test_list, > + struct lstcon_test, > + tes_link)) != NULL) { > LASSERT(list_empty(&test->tes_trans_list)); > > list_del(&test->tes_link); > @@ -1110,17 +1109,17 @@ lstcon_batch_destroy(struct lstcon_batch *bat) > > LASSERT(list_empty(&bat->bat_trans_list)); > > - while (!list_empty(&bat->bat_cli_list)) { > - ndl = list_entry(bat->bat_cli_list.next, > - struct lstcon_ndlink, ndl_link); > + while ((ndl = list_first_entry_or_null(&bat->bat_cli_list, > + struct lstcon_ndlink, > + ndl_link)) != NULL) { > list_del_init(&ndl->ndl_link); > > lstcon_ndlink_release(ndl); > } > > - while (!list_empty(&bat->bat_srv_list)) { > - ndl = list_entry(bat->bat_srv_list.next, > - struct lstcon_ndlink, ndl_link); > + while ((ndl = list_first_entry_or_null(&bat->bat_srv_list, > + struct lstcon_ndlink, > + ndl_link)) != NULL) { > list_del_init(&ndl->ndl_link); > > lstcon_ndlink_release(ndl); > @@ -1844,17 +1843,15 @@ lstcon_session_end(void) > console_session.ses_feats_updated = 0; > > /* destroy all batches */ > - while (!list_empty(&console_session.ses_bat_list)) { > - bat = list_entry(console_session.ses_bat_list.next, > - struct lstcon_batch, bat_link); > - > + while ((bat = list_first_entry_or_null(&console_session.ses_bat_list, > + struct lstcon_batch, > + bat_link)) != NULL) > lstcon_batch_destroy(bat); > - } > > /* destroy all groups */ > - while (!list_empty(&console_session.ses_grp_list)) { > - grp = list_entry(console_session.ses_grp_list.next, > - struct lstcon_group, grp_link); > + while ((grp = list_first_entry_or_null(&console_session.ses_grp_list, > + struct lstcon_group, > + grp_link)) != NULL) { > LASSERT(grp->grp_ref == 1); > > lstcon_group_decref(grp); > diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c > index a82efc394659..958f627580e7 100644 > --- a/drivers/staging/lustre/lnet/selftest/framework.c > +++ b/drivers/staging/lustre/lnet/selftest/framework.c > @@ -628,16 +628,16 @@ sfw_destroy_test_instance(struct sfw_test_instance *tsi) > LASSERT(list_empty(&tsi->tsi_active_rpcs)); > LASSERT(!sfw_test_active(tsi)); > > - while (!list_empty(&tsi->tsi_units)) { > - tsu = list_entry(tsi->tsi_units.next, > - struct sfw_test_unit, tsu_list); > + while ((tsu = list_first_entry_or_null(&tsi->tsi_units, > + struct sfw_test_unit, > + tsu_list)) != NULL) { > list_del(&tsu->tsu_list); > kfree(tsu); > } > > - while (!list_empty(&tsi->tsi_free_rpcs)) { > - rpc = list_entry(tsi->tsi_free_rpcs.next, > - struct srpc_client_rpc, crpc_list); > + while ((rpc = list_first_entry_or_null(&tsi->tsi_free_rpcs, > + struct srpc_client_rpc, > + crpc_list)) != NULL) { > list_del(&rpc->crpc_list); > kfree(rpc); > } > @@ -655,9 +655,9 @@ sfw_destroy_batch(struct sfw_batch *tsb) > LASSERT(!sfw_batch_active(tsb)); > LASSERT(list_empty(&tsb->bat_list)); > > - while (!list_empty(&tsb->bat_tests)) { > - tsi = list_entry(tsb->bat_tests.next, > - struct sfw_test_instance, tsi_list); > + while ((tsi = list_first_entry_or_null(&tsb->bat_tests, > + struct sfw_test_instance, > + tsi_list)) != NULL) { > list_del_init(&tsi->tsi_list); > sfw_destroy_test_instance(tsi); > } > @@ -673,9 +673,9 @@ sfw_destroy_session(struct sfw_session *sn) > LASSERT(list_empty(&sn->sn_list)); > LASSERT(sn != sfw_data.fw_session); > > - while (!list_empty(&sn->sn_batches)) { > - batch = list_entry(sn->sn_batches.next, > - struct sfw_batch, bat_list); > + while ((batch = list_first_entry_or_null(&sn->sn_batches, > + struct sfw_batch, > + bat_list)) != NULL) { > list_del_init(&batch->bat_list); > sfw_destroy_batch(batch); > } > @@ -1389,8 +1389,8 @@ sfw_create_rpc(struct lnet_process_id peer, int service, > LASSERT(service <= SRPC_FRAMEWORK_SERVICE_MAX_ID); > > if (!nbulkiov && !list_empty(&sfw_data.fw_zombie_rpcs)) { > - rpc = list_entry(sfw_data.fw_zombie_rpcs.next, > - struct srpc_client_rpc, crpc_list); > + rpc = list_first_entry(&sfw_data.fw_zombie_rpcs, > + struct srpc_client_rpc, crpc_list); > list_del(&rpc->crpc_list); > > srpc_init_client_rpc(rpc, peer, service, 0, 0, > @@ -1722,6 +1722,7 @@ sfw_shutdown(void) > { > struct srpc_service *sv; > struct sfw_test_case *tsc; > + struct srpc_client_rpc *rpc; > int i; > > spin_lock(&sfw_data.fw_lock); > @@ -1757,11 +1758,9 @@ sfw_shutdown(void) > srpc_remove_service(sv); > } > > - while (!list_empty(&sfw_data.fw_zombie_rpcs)) { > - struct srpc_client_rpc *rpc; > - > - rpc = list_entry(sfw_data.fw_zombie_rpcs.next, > - struct srpc_client_rpc, crpc_list); > + while ((rpc = list_first_entry_or_null(&sfw_data.fw_zombie_rpcs, > + struct srpc_client_rpc, > + crpc_list)) != NULL) { > list_del(&rpc->crpc_list); > > kfree(rpc); > @@ -1775,10 +1774,9 @@ sfw_shutdown(void) > srpc_wait_service_shutdown(sv); > } > > - while (!list_empty(&sfw_data.fw_tests)) { > - tsc = list_entry(sfw_data.fw_tests.next, > - struct sfw_test_case, tsc_list); > - > + while ((tsc = list_first_entry_or_null(&sfw_data.fw_tests, > + struct sfw_test_case, > + tsc_list)) != NULL) { > srpc_wait_service_shutdown(tsc->tsc_srv_service); > > list_del(&tsc->tsc_list); > diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c > index 2a3010774dbe..abb6f8fb011e 100644 > --- a/drivers/staging/lustre/lnet/selftest/rpc.c > +++ b/drivers/staging/lustre/lnet/selftest/rpc.c > @@ -210,9 +210,9 @@ srpc_service_fini(struct srpc_service *svc) > else > break; > > - while (!list_empty(q)) { > - buf = list_entry(q->next, struct srpc_buffer, > - buf_list); > + while ((buf = list_first_entry_or_null( > + q, struct srpc_buffer, > + buf_list)) != NULL) { > list_del(&buf->buf_list); > kfree(buf); > } > @@ -220,10 +220,9 @@ srpc_service_fini(struct srpc_service *svc) > > LASSERT(list_empty(&scd->scd_rpc_active)); > > - while (!list_empty(&scd->scd_rpc_free)) { > - rpc = list_entry(scd->scd_rpc_free.next, > - struct srpc_server_rpc, > - srpc_list); > + while ((rpc = list_first_entry_or_null(&scd->scd_rpc_free, > + struct srpc_server_rpc, > + srpc_list)) != NULL) { > list_del(&rpc->srpc_list); > kfree(rpc); > } > @@ -674,8 +673,8 @@ srpc_finish_service(struct srpc_service *sv) > continue; > } > > - rpc = list_entry(scd->scd_rpc_active.next, > - struct srpc_server_rpc, srpc_list); > + rpc = list_first_entry(&scd->scd_rpc_active, > + struct srpc_server_rpc, srpc_list); > CNETERR("Active RPC %p on shutdown: sv %s, peer %s, wi %s, ev fired %d type %d status %d lnet %d\n", > rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer), > swi_state2str(rpc->srpc_wi.swi_state), > @@ -943,8 +942,8 @@ srpc_server_rpc_done(struct srpc_server_rpc *rpc, int status) > LASSERT(rpc->srpc_ev.ev_fired); > > if (!sv->sv_shuttingdown && !list_empty(&scd->scd_buf_blocked)) { > - buffer = list_entry(scd->scd_buf_blocked.next, > - struct srpc_buffer, buf_list); > + buffer = list_first_entry(&scd->scd_buf_blocked, > + struct srpc_buffer, buf_list); > list_del(&buffer->buf_list); > > srpc_init_server_rpc(rpc, scd, buffer); > @@ -1535,9 +1534,9 @@ srpc_lnet_ev_handler(struct lnet_event *ev) > } > > if (!list_empty(&scd->scd_rpc_free)) { > - srpc = list_entry(scd->scd_rpc_free.next, > - struct srpc_server_rpc, > - srpc_list); > + srpc = list_first_entry(&scd->scd_rpc_free, > + struct srpc_server_rpc, > + srpc_list); > list_del(&srpc->srpc_list); > > srpc_init_server_rpc(srpc, scd, buffer); > diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c > index c83473ebb368..bb61e3aa11e9 100644 > --- a/drivers/staging/lustre/lnet/selftest/timer.c > +++ b/drivers/staging/lustre/lnet/selftest/timer.c > @@ -125,8 +125,8 @@ stt_expire_list(struct list_head *slot, time64_t now) > int expired = 0; > struct stt_timer *timer; > > - while (!list_empty(slot)) { > - timer = list_entry(slot->next, struct stt_timer, stt_list); > + while ((timer = list_first_entry_or_null(slot, struct stt_timer, > + stt_list)) != NULL) { > > if (timer->stt_expires > now) > break; > > > From jsimmons at infradead.org Mon Feb 11 01:48:54 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 01:48:54 +0000 (GMT) Subject: [lustre-devel] [PATCH 09/21] lustre: use list_last_entry() throughout In-Reply-To: <154949781307.10620.3918792136275031845.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781307.10620.3918792136275031845.stgit@noble.brown> Message-ID: > Convert > list_entry(foo->prev .....) > to > list_last_entry(foo, ....) > > throughout lustre. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 2 +- > drivers/staging/lustre/lustre/ptlrpc/client.c | 6 +++--- > drivers/staging/lustre/lustre/ptlrpc/service.c | 5 +++-- > 3 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index 53fd8d469e55..bf7678aed6bf 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -2329,7 +2329,7 @@ do { \ > static inline struct cl_page *cl_page_list_last(struct cl_page_list *plist) > { > LASSERT(plist->pl_nr > 0); > - return list_entry(plist->pl_pages.prev, struct cl_page, cp_batch); > + return list_last_entry(&plist->pl_pages, struct cl_page, cp_batch); > } > > static inline struct cl_page *cl_page_list_first(struct cl_page_list *plist) > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c > index a78d49621c42..b2b11047ea19 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/client.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c > @@ -1464,9 +1464,9 @@ static int after_reply(struct ptlrpc_request *req) > if (!list_empty(&imp->imp_replay_list)) { > struct ptlrpc_request *last; > > - last = list_entry(imp->imp_replay_list.prev, > - struct ptlrpc_request, > - rq_replay_list); > + last = list_last_entry(&imp->imp_replay_list, > + struct ptlrpc_request, > + rq_replay_list); > /* > * Requests with rq_replay stay on the list even if no > * commit is expected. > diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c > index a69736dfe8b7..35a59e5a5e9d 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/service.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c > @@ -2255,8 +2255,9 @@ static int ptlrpc_hr_main(void *arg) > while (!list_empty(&replies)) { > struct ptlrpc_reply_state *rs; > > - rs = list_entry(replies.prev, struct ptlrpc_reply_state, > - rs_list); > + rs = list_last_entry(&replies, > + struct ptlrpc_reply_state, > + rs_list); > list_del_init(&rs->rs_list); > ptlrpc_handle_rs(rs); > } > > > From jsimmons at infradead.org Mon Feb 11 01:57:32 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 01:57:32 +0000 (GMT) Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate In-Reply-To: <154949781310.10620.8883358407999258821.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781310.10620.8883358407999258821.stgit@noble.brown> Message-ID: > There are various places which have a list_for_each_entry() > where cl_object_for_each (or .._reverse) is more appropriate. > > Several of these re-use the 'obj' function parameter as a loop > iterator, which is a little confusing. > > Change these to use cl_object_for_each{_reverse}, and where needed, > introduce a new iterator variable 'o'. Surprised the reverse wasn't done in that the cl_* macro was removed :-) Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/lov/lov_page.c | 3 - > drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 - > drivers/staging/lustre/lustre/obdclass/cl_object.c | 82 +++++++++----------- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 +-- > 4 files changed, 44 insertions(+), 55 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c > index 08485a95ec01..e64b350601d2 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_page.c > +++ b/drivers/staging/lustre/lustre/lov/lov_page.c > @@ -103,8 +103,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, > return PTR_ERR(sub); > > subobj = lovsub2cl(r0->lo_sub[stripe]); > - list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers, > - co_lu.lo_linkage) { > + cl_object_for_each(o, subobj) { > if (o->co_ops->coo_page_init) { > rc = o->co_ops->coo_page_init(sub->sub_env, o, page, > cl_index(subobj, suboff)); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > index 8133d992cc73..fc5976d8b37b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > @@ -103,8 +103,7 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, > LASSERT(obj); > > INIT_LIST_HEAD(&lock->cll_layers); > - list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, > - co_lu.lo_linkage) { > + cl_object_for_each(scan, obj) { > result = scan->co_ops->coo_lock_init(env, scan, lock, io); > if (result != 0) { > cl_lock_fini(env, lock); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index f724b2d62df1..d71a680660da 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -190,16 +190,15 @@ EXPORT_SYMBOL(cl_object_attr_unlock); > int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, > struct cl_attr *attr) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result; > > assert_spin_locked(cl_object_attr_guard(obj)); > > - top = obj->co_lu.lo_header; > result = 0; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_attr_get) { > - result = obj->co_ops->coo_attr_get(env, obj, attr); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_attr_get) { > + result = o->co_ops->coo_attr_get(env, o, attr); > if (result != 0) { > if (result > 0) > result = 0; > @@ -221,17 +220,16 @@ EXPORT_SYMBOL(cl_object_attr_get); > int cl_object_attr_update(const struct lu_env *env, struct cl_object *obj, > const struct cl_attr *attr, unsigned int v) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result; > > assert_spin_locked(cl_object_attr_guard(obj)); > > - top = obj->co_lu.lo_header; > result = 0; > - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_attr_update) { > - result = obj->co_ops->coo_attr_update(env, obj, attr, > - v); > + cl_object_for_each_reverse(o, obj) { > + if (o->co_ops->coo_attr_update) { > + result = o->co_ops->coo_attr_update(env, o, attr, > + v); > if (result != 0) { > if (result > 0) > result = 0; > @@ -254,19 +252,18 @@ EXPORT_SYMBOL(cl_object_attr_update); > int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, > struct ost_lvb *lvb) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result; > > - top = obj->co_lu.lo_header; > result = 0; > - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_glimpse) { > - result = obj->co_ops->coo_glimpse(env, obj, lvb); > + cl_object_for_each_reverse(o, obj) { > + if (o->co_ops->coo_glimpse) { > + result = o->co_ops->coo_glimpse(env, o, lvb); > if (result != 0) > break; > } > } > - LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), > + LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(obj->co_lu.lo_header), > "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", > lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, > lvb->lvb_ctime, lvb->lvb_blocks); > @@ -280,14 +277,13 @@ EXPORT_SYMBOL(cl_object_glimpse); > int cl_conf_set(const struct lu_env *env, struct cl_object *obj, > const struct cl_object_conf *conf) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result; > > - top = obj->co_lu.lo_header; > result = 0; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_conf_set) { > - result = obj->co_ops->coo_conf_set(env, obj, conf); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_conf_set) { > + result = o->co_ops->coo_conf_set(env, o, conf); > if (result != 0) > break; > } > @@ -301,13 +297,11 @@ EXPORT_SYMBOL(cl_conf_set); > */ > int cl_object_prune(const struct lu_env *env, struct cl_object *obj) > { > - struct lu_object_header *top; > struct cl_object *o; > int result; > > - top = obj->co_lu.lo_header; > result = 0; > - list_for_each_entry(o, &top->loh_layers, co_lu.lo_linkage) { > + cl_object_for_each(o, obj) { > if (o->co_ops->coo_prune) { > result = o->co_ops->coo_prune(env, o); > if (result != 0) > @@ -325,14 +319,13 @@ EXPORT_SYMBOL(cl_object_prune); > int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, > struct lov_user_md __user *uarg, size_t size) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result = 0; > > - top = obj->co_lu.lo_header; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_getstripe) { > - result = obj->co_ops->coo_getstripe(env, obj, uarg, > - size); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_getstripe) { > + result = o->co_ops->coo_getstripe(env, o, uarg, > + size); > if (result) > break; > } > @@ -357,14 +350,13 @@ int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj, > struct ll_fiemap_info_key *key, > struct fiemap *fiemap, size_t *buflen) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result = 0; > > - top = obj->co_lu.lo_header; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_fiemap) { > - result = obj->co_ops->coo_fiemap(env, obj, key, fiemap, > - buflen); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_fiemap) { > + result = o->co_ops->coo_fiemap(env, o, key, fiemap, > + buflen); > if (result) > break; > } > @@ -376,11 +368,11 @@ EXPORT_SYMBOL(cl_object_fiemap); > int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, > struct cl_layout *cl) > { > - struct lu_object_header *top = obj->co_lu.lo_header; > + struct cl_object *o; > > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_layout_get) > - return obj->co_ops->coo_layout_get(env, obj, cl); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_layout_get) > + return o->co_ops->coo_layout_get(env, o, cl); > } > > return -EOPNOTSUPP; > @@ -389,12 +381,12 @@ EXPORT_SYMBOL(cl_object_layout_get); > > loff_t cl_object_maxbytes(struct cl_object *obj) > { > - struct lu_object_header *top = obj->co_lu.lo_header; > + struct cl_object *o; > loff_t maxbytes = LLONG_MAX; > > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_maxbytes) > - maxbytes = min_t(loff_t, obj->co_ops->coo_maxbytes(obj), > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_maxbytes) > + maxbytes = min_t(loff_t, o->co_ops->coo_maxbytes(o), > maxbytes); > } > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index 057318deaa4e..7d00a9233a3b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -132,7 +132,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > enum cl_page_type type) > { > struct cl_page *page; > - struct lu_object_header *head; > + struct cl_object *o2; > > page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); > if (page) { > @@ -149,11 +149,10 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > INIT_LIST_HEAD(&page->cp_layers); > INIT_LIST_HEAD(&page->cp_batch); > lu_ref_init(&page->cp_reference); > - head = o->co_lu.lo_header; > - list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { > - if (o->co_ops->coo_page_init) { > - result = o->co_ops->coo_page_init(env, o, page, > - ind); > + cl_object_for_each(o2, o) { > + if (o2->co_ops->coo_page_init) { > + result = o2->co_ops->coo_page_init(env, o2, page, > + ind); > if (result != 0) { > __cl_page_delete(env, page); > cl_page_free(env, page); > > > From jsimmons at infradead.org Mon Feb 11 02:04:29 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 02:04:29 +0000 (GMT) Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: <154949781313.10620.6363156783936746853.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> Message-ID: > cl_env_inc() and cl_env_dec() don't do anything, > so discard them. I don't know about this one. I saw Andreas response as well. So this was apart of "LU-744 obdclass: revise stats for cl_object cache" In the end it was turned off by default in the OpenSFS branch since it made performance take a hit. To enable in OpenSFS branch you have to run ./configure --enable-pgstate-track. We have a few like this for Lustre so I was going to bring this up. Do we want to remove this work for both the upstream client as well as OpenSFS tree or properly implement this by making it a Kconfig option when CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is enabled? Its just a matter of porting OpenSFS commit 5cae09a2409dcd396a1ee7be1eca7d3bbf77365e What do you think? > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- > 1 file changed, 15 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index d71a680660da..1e704078664e 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -565,14 +565,6 @@ struct cl_env { > void *ce_debug; > }; > > -static void cl_env_inc(enum cache_stats_item item) > -{ > -} > - > -static void cl_env_dec(enum cache_stats_item item) > -{ > -} > - > static void cl_env_init0(struct cl_env *cle, void *debug) > { > LASSERT(cle->ce_ref == 0); > @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) > > cle->ce_ref = 1; > cle->ce_debug = debug; > - cl_env_inc(CS_busy); > } > > static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > if (rc != 0) { > kmem_cache_free(cl_env_kmem, cle); > env = ERR_PTR(rc); > - } else { > - cl_env_inc(CS_create); > - cl_env_inc(CS_total); > } > } else { > env = ERR_PTR(-ENOMEM); > @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > > static void cl_env_fini(struct cl_env *cle) > { > - cl_env_dec(CS_total); > lu_context_fini(&cle->ce_lu.le_ctx); > lu_context_fini(&cle->ce_ses); > kmem_cache_free(cl_env_kmem, cle); > @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) > if (--cle->ce_ref == 0) { > int cpu = get_cpu(); > > - cl_env_dec(CS_busy); > cle->ce_debug = NULL; > cl_env_exit(cle); > /* > @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) > cle->ce_ref--; > LASSERT(cle->ce_ref == 0); > > - cl_env_dec(CS_busy); > cle->ce_debug = NULL; > > put_cpu(); > > > From neilb at suse.com Mon Feb 11 03:08:46 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 14:08:46 +1100 Subject: [lustre-devel] [PATCH 05/21] lustre: use list_first_entry() in lustre subdirectory. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781279.10620.5804477141390456723.stgit@noble.brown> Message-ID: <875ztrggxt.fsf@notabene.neil.brown.name> On Mon, Feb 11 2019, James Simmons wrote: >> Convert >> list_entry(foo->next .....) >> to >> list_first_entry(foo, ....) >> >> in 'lustre' >> >> In several cases the call is combined with >> a list_empty() test and list_first_entry_or_null() is used > > Nak. One of the changes below breaks things. > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/include/cl_object.h | 2 - >> drivers/staging/lustre/lustre/llite/statahead.c | 23 ++++---- >> drivers/staging/lustre/lustre/lov/lov_io.c | 9 +-- >> drivers/staging/lustre/lustre/obdclass/cl_page.c | 9 +-- >> drivers/staging/lustre/lustre/obdclass/genops.c | 22 ++++--- >> .../staging/lustre/lustre/obdclass/lustre_peer.c | 5 +- >> drivers/staging/lustre/lustre/osc/osc_cache.c | 17 +++--- >> drivers/staging/lustre/lustre/osc/osc_lock.c | 5 +- >> drivers/staging/lustre/lustre/osc/osc_page.c | 17 +++--- >> drivers/staging/lustre/lustre/osc/osc_request.c | 8 +-- >> drivers/staging/lustre/lustre/ptlrpc/client.c | 8 +-- >> drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c | 6 +- >> .../staging/lustre/lustre/ptlrpc/pack_generic.c | 4 + >> drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 +- >> drivers/staging/lustre/lustre/ptlrpc/service.c | 59 ++++++++++---------- >> 15 files changed, 101 insertions(+), 99 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h >> index 13d79810dd39..53fd8d469e55 100644 >> --- a/drivers/staging/lustre/lustre/include/cl_object.h >> +++ b/drivers/staging/lustre/lustre/include/cl_object.h >> @@ -2335,7 +2335,7 @@ static inline struct cl_page *cl_page_list_last(struct cl_page_list *plist) >> static inline struct cl_page *cl_page_list_first(struct cl_page_list *plist) >> { >> LASSERT(plist->pl_nr > 0); >> - return list_entry(plist->pl_pages.next, struct cl_page, cp_batch); >> + return list_first_entry(&plist->pl_pages, struct cl_page, cp_batch); >> } >> >> /** > > ... > >> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c >> index 5b97f2a1fea1..a69736dfe8b7 100644 >> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c >> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c >> @@ -299,9 +299,9 @@ ptlrpc_server_post_idle_rqbds(struct ptlrpc_service_part *svcpt) >> return posted; >> } >> >> - rqbd = list_entry(svcpt->scp_rqbd_idle.next, >> - struct ptlrpc_request_buffer_desc, >> - rqbd_list); >> + rqbd = list_first_entry(&svcpt->scp_rqbd_idle, >> + struct ptlrpc_request_buffer_desc, >> + rqbd_list); >> list_del(&rqbd->rqbd_list); >> >> /* assume we will post successfully */ >> @@ -769,9 +769,9 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req) >> * I expect only about 1 or 2 rqbds need to be recycled here >> */ >> while (svcpt->scp_hist_nrqbds > svc->srv_hist_nrqbds_cpt_max) { >> - rqbd = list_entry(svcpt->scp_hist_rqbds.next, >> - struct ptlrpc_request_buffer_desc, >> - rqbd_list); >> + rqbd = list_first_entry(&svcpt->scp_hist_rqbds, >> + struct ptlrpc_request_buffer_desc, >> + rqbd_list); >> >> list_del(&rqbd->rqbd_list); >> svcpt->scp_hist_nrqbds--; >> @@ -1240,9 +1240,9 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) >> /* we took additional refcount so entries can't be deleted from list, no >> * locking is needed >> */ >> - while (!list_empty(&work_list)) { >> - rq = list_entry(work_list.next, struct ptlrpc_request, >> - rq_timed_list); >> + while ((rq = list_first_entry_or_null(&work_list, >> + struct ptlrpc_request, >> + rq_timed_list)) != NULL) { >> list_del_init(&rq->rq_timed_list); >> >> if (ptlrpc_at_send_early_reply(rq) == 0) >> @@ -1485,8 +1485,8 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, >> return 0; >> } >> >> - req = list_entry(svcpt->scp_req_incoming.next, >> - struct ptlrpc_request, rq_list); >> + req = list_first_entry(&svcpt->scp_req_incoming, >> + struct ptlrpc_request, rq_list); >> list_del_init(&req->rq_list); >> svcpt->scp_nreqs_incoming--; >> /* Consider this still a "queued" request as far as stats are >> @@ -2345,9 +2345,9 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) >> >> wake_up_all(&svcpt->scp_waitq); >> >> - while (!list_empty(&svcpt->scp_threads)) { >> - thread = list_entry(svcpt->scp_threads.next, >> - struct ptlrpc_thread, t_link); >> + while ((thread = list_first_entry_or_null(&svcpt->scp_threads, >> + struct ptlrpc_thread, >> + t_link)) != NULL) { >> if (thread_is_stopped(thread)) { >> list_del(&thread->t_link); >> list_add(&thread->t_link, &zombie); >> @@ -2365,9 +2365,9 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) >> >> spin_unlock(&svcpt->scp_lock); >> >> - while (!list_empty(&zombie)) { >> - thread = list_entry(zombie.next, >> - struct ptlrpc_thread, t_link); >> + while ((thread = list_first_entry(&zombie, >> + struct ptlrpc_thread, >> + t_link)) != NULL) { >> list_del(&thread->t_link); >> kfree(thread); >> } > > The above change causes sanity tests 77j: client only supporting ADLER32 > to fail with: > > 2019-02-07 18:38:26 [ 4346.464550] Lustre: Unmounted lustre-client > 2019-02-07 18:38:26 [ 4346.471990] BUG: unable to handle kernel paging > request at ffffeb02001c89c8 > 2019-02-07 18:38:26 [ 4346.480489] #PF error: [normal kernel read fault] > 2019-02-07 18:38:26 [ 4346.486719] PGD 0 P4D 0 > 2019-02-07 18:38:26 [ 4346.490758] Oops: 0000 [#1] PREEMPT SMP PTI > 2019-02-07 18:38:26 [ 4346.496420] CPU: 0 PID: 2478 Comm: kworker/0:1 > Tainted: G WC 5.0.0-rc4+ #1 > 2019-02-07 18:38:26 [ 4346.505976] Hardware name: Supermicro > SYS-6028TR-HTFR/X10DRT-HIBF, BIOS 2.0b 08/12/2016 > 2019-02-07 18:38:26 [ 4346.515461] Workqueue: obd_zombid > obd_zombie_imp_cull [obdclass] > 2019-02-07 18:38:26 [ 4346.522917] RIP: 0010:kfree+0x52/0x1b0 > Thanks so much for testing and finding this. The above should, of course, be >> + while ((thread = list_first_entry_or_null(&zombie, >> + struct ptlrpc_thread, >> + t_link)) != NULL) { (with _or_null). I've fixed it in my tree. Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 03:14:15 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 14:14:15 +1100 Subject: [lustre-devel] [PATCH 04/21] lustre: use list*entry macros in place of container_of() In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781267.10620.8365663638954760207.stgit@noble.brown> Message-ID: <8736ovggoo.fsf@notabene.neil.brown.name> On Mon, Feb 11 2019, James Simmons wrote: >> There are a number of places that use container_of() but where >> list_first_entry(), or list_last_entry() make the meaning more clear. >> So change them over. > > I have to say normally the patches you see genernally use the basic > functionality of the linux list implementation. I wonder if a deep > dive on LUG's developers day would be a good idea. It is possible to take the "new macro for subtly different case" exercise too far, though in this particular case, I think using replacing container_of with list_entry is a clear win. Maybe a broader discussion would help > > Reviewed-by: James Simmons Thanks, NeilBrown > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ++-- >> drivers/staging/lustre/lustre/obdclass/cl_io.c | 4 ++-- >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 13 ++++++++----- >> drivers/staging/lustre/lustre/obdclass/cl_page.c | 4 ++-- >> drivers/staging/lustre/lustre/obdclass/lu_object.c | 7 +++---- >> 5 files changed, 17 insertions(+), 15 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c >> index 85c5047f4ba2..74c7644d6ef8 100644 >> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c >> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c >> @@ -987,8 +987,8 @@ struct ldlm_namespace *ldlm_namespace_first_locked(enum ldlm_side client) >> { >> LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); >> LASSERT(!list_empty(ldlm_namespace_list(client))); >> - return container_of(ldlm_namespace_list(client)->next, >> - struct ldlm_namespace, ns_list_chain); >> + return list_first_entry(ldlm_namespace_list(client), >> + struct ldlm_namespace, ns_list_chain); >> } >> >> /** Create and initialize new resource. */ >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c >> index 7bf02350f19d..34b4e63e7d1a 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c >> @@ -93,8 +93,8 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) >> LINVRNT(cl_io_invariant(io)); >> >> while (!list_empty(&io->ci_layers)) { >> - slice = container_of(io->ci_layers.prev, struct cl_io_slice, >> - cis_linkage); >> + slice = list_last_entry(&io->ci_layers, struct cl_io_slice, >> + cis_linkage); >> list_del_init(&slice->cis_linkage); >> if (slice->cis_iop->op[io->ci_type].cio_fini) >> slice->cis_iop->op[io->ci_type].cio_fini(env, slice); >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> index 05d784ae7a6c..f724b2d62df1 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> @@ -649,8 +649,8 @@ static struct lu_env *cl_env_obtain(void *debug) >> if (cl_envs[cpu].cec_count > 0) { >> int rc; >> >> - cle = container_of(cl_envs[cpu].cec_envs.next, struct cl_env, >> - ce_linkage); >> + cle = list_first_entry(&cl_envs[cpu].cec_envs, struct cl_env, >> + ce_linkage); >> list_del_init(&cle->ce_linkage); >> cl_envs[cpu].cec_count--; >> read_unlock(&cl_envs[cpu].cec_guard); >> @@ -748,9 +748,12 @@ unsigned int cl_env_cache_purge(unsigned int nr) >> >> for_each_possible_cpu(i) { >> write_lock(&cl_envs[i].cec_guard); >> - for (; !list_empty(&cl_envs[i].cec_envs) && nr > 0; --nr) { >> - cle = container_of(cl_envs[i].cec_envs.next, >> - struct cl_env, ce_linkage); >> + for (; nr >0 && >> + (cle = list_first_entry_or_null( >> + &cl_envs[i].cec_envs, >> + struct cl_env, >> + ce_linkage)) != NULL; >> + --nr) { >> list_del_init(&cle->ce_linkage); >> LASSERT(cl_envs[i].cec_count > 0); >> cl_envs[i].cec_count--; >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> index b1b4dc7ea22f..d025ea55818f 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> @@ -690,8 +690,8 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) >> const struct cl_page_slice *slice; >> int result; >> >> - slice = container_of(pg->cp_layers.next, >> - const struct cl_page_slice, cpl_linkage); >> + slice = list_first_entry(&pg->cp_layers, >> + const struct cl_page_slice, cpl_linkage); >> PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked); >> /* >> * Call ->cpo_is_vmlocked() directly instead of going through >> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c >> index 3bd48748f46c..639c298b6a90 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c >> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c >> @@ -349,7 +349,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) >> * lives as long as possible and ->loo_object_free() methods >> * can look at its contents. >> */ >> - o = container_of(splice.prev, struct lu_object, lo_linkage); >> + o = list_last_entry(&splice, struct lu_object, lo_linkage); >> list_del_init(&o->lo_linkage); >> o->lo_ops->loo_object_free(env, o); >> } >> @@ -432,9 +432,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s, >> * Free everything on the dispose list. This is safe against >> * races due to the reasons described in lu_object_put(). >> */ >> - while (!list_empty(&dispose)) { >> - h = container_of(dispose.next, >> - struct lu_object_header, loh_lru); >> + while ((h = list_first_entry_or_null( >> + &dispose, struct lu_object_header, loh_lru)) != NULL) { >> list_del_init(&h->loh_lru); >> lu_object_free(env, lu_object_top(h)); >> lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED); >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 03:19:47 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 14:19:47 +1100 Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781310.10620.8883358407999258821.stgit@noble.brown> Message-ID: <87zhr3f1v0.fsf@notabene.neil.brown.name> On Mon, Feb 11 2019, James Simmons wrote: >> There are various places which have a list_for_each_entry() >> where cl_object_for_each (or .._reverse) is more appropriate. >> >> Several of these re-use the 'obj' function parameter as a loop >> iterator, which is a little confusing. >> >> Change these to use cl_object_for_each{_reverse}, and where needed, >> introduce a new iterator variable 'o'. > > Surprised the reverse wasn't done in that the cl_* macro was > removed :-) Hmmm.... maybe ..... But ->co_lu.lo_header->loh_layers is sufficiently scary looking that hiding it in a macro seems like a good idea. > > Reviewed-by: James Simmons Thanks, NeilBrown > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/lov/lov_page.c | 3 - >> drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 - >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 82 +++++++++----------- >> drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 +-- >> 4 files changed, 44 insertions(+), 55 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c >> index 08485a95ec01..e64b350601d2 100644 >> --- a/drivers/staging/lustre/lustre/lov/lov_page.c >> +++ b/drivers/staging/lustre/lustre/lov/lov_page.c >> @@ -103,8 +103,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, >> return PTR_ERR(sub); >> >> subobj = lovsub2cl(r0->lo_sub[stripe]); >> - list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers, >> - co_lu.lo_linkage) { >> + cl_object_for_each(o, subobj) { >> if (o->co_ops->coo_page_init) { >> rc = o->co_ops->coo_page_init(sub->sub_env, o, page, >> cl_index(subobj, suboff)); >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c >> index 8133d992cc73..fc5976d8b37b 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c >> @@ -103,8 +103,7 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, >> LASSERT(obj); >> >> INIT_LIST_HEAD(&lock->cll_layers); >> - list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, >> - co_lu.lo_linkage) { >> + cl_object_for_each(scan, obj) { >> result = scan->co_ops->coo_lock_init(env, scan, lock, io); >> if (result != 0) { >> cl_lock_fini(env, lock); >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> index f724b2d62df1..d71a680660da 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> @@ -190,16 +190,15 @@ EXPORT_SYMBOL(cl_object_attr_unlock); >> int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, >> struct cl_attr *attr) >> { >> - struct lu_object_header *top; >> + struct cl_object *o; >> int result; >> >> assert_spin_locked(cl_object_attr_guard(obj)); >> >> - top = obj->co_lu.lo_header; >> result = 0; >> - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_attr_get) { >> - result = obj->co_ops->coo_attr_get(env, obj, attr); >> + cl_object_for_each(o, obj) { >> + if (o->co_ops->coo_attr_get) { >> + result = o->co_ops->coo_attr_get(env, o, attr); >> if (result != 0) { >> if (result > 0) >> result = 0; >> @@ -221,17 +220,16 @@ EXPORT_SYMBOL(cl_object_attr_get); >> int cl_object_attr_update(const struct lu_env *env, struct cl_object *obj, >> const struct cl_attr *attr, unsigned int v) >> { >> - struct lu_object_header *top; >> + struct cl_object *o; >> int result; >> >> assert_spin_locked(cl_object_attr_guard(obj)); >> >> - top = obj->co_lu.lo_header; >> result = 0; >> - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_attr_update) { >> - result = obj->co_ops->coo_attr_update(env, obj, attr, >> - v); >> + cl_object_for_each_reverse(o, obj) { >> + if (o->co_ops->coo_attr_update) { >> + result = o->co_ops->coo_attr_update(env, o, attr, >> + v); >> if (result != 0) { >> if (result > 0) >> result = 0; >> @@ -254,19 +252,18 @@ EXPORT_SYMBOL(cl_object_attr_update); >> int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, >> struct ost_lvb *lvb) >> { >> - struct lu_object_header *top; >> + struct cl_object *o; >> int result; >> >> - top = obj->co_lu.lo_header; >> result = 0; >> - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_glimpse) { >> - result = obj->co_ops->coo_glimpse(env, obj, lvb); >> + cl_object_for_each_reverse(o, obj) { >> + if (o->co_ops->coo_glimpse) { >> + result = o->co_ops->coo_glimpse(env, o, lvb); >> if (result != 0) >> break; >> } >> } >> - LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), >> + LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(obj->co_lu.lo_header), >> "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", >> lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, >> lvb->lvb_ctime, lvb->lvb_blocks); >> @@ -280,14 +277,13 @@ EXPORT_SYMBOL(cl_object_glimpse); >> int cl_conf_set(const struct lu_env *env, struct cl_object *obj, >> const struct cl_object_conf *conf) >> { >> - struct lu_object_header *top; >> + struct cl_object *o; >> int result; >> >> - top = obj->co_lu.lo_header; >> result = 0; >> - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_conf_set) { >> - result = obj->co_ops->coo_conf_set(env, obj, conf); >> + cl_object_for_each(o, obj) { >> + if (o->co_ops->coo_conf_set) { >> + result = o->co_ops->coo_conf_set(env, o, conf); >> if (result != 0) >> break; >> } >> @@ -301,13 +297,11 @@ EXPORT_SYMBOL(cl_conf_set); >> */ >> int cl_object_prune(const struct lu_env *env, struct cl_object *obj) >> { >> - struct lu_object_header *top; >> struct cl_object *o; >> int result; >> >> - top = obj->co_lu.lo_header; >> result = 0; >> - list_for_each_entry(o, &top->loh_layers, co_lu.lo_linkage) { >> + cl_object_for_each(o, obj) { >> if (o->co_ops->coo_prune) { >> result = o->co_ops->coo_prune(env, o); >> if (result != 0) >> @@ -325,14 +319,13 @@ EXPORT_SYMBOL(cl_object_prune); >> int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, >> struct lov_user_md __user *uarg, size_t size) >> { >> - struct lu_object_header *top; >> + struct cl_object *o; >> int result = 0; >> >> - top = obj->co_lu.lo_header; >> - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_getstripe) { >> - result = obj->co_ops->coo_getstripe(env, obj, uarg, >> - size); >> + cl_object_for_each(o, obj) { >> + if (o->co_ops->coo_getstripe) { >> + result = o->co_ops->coo_getstripe(env, o, uarg, >> + size); >> if (result) >> break; >> } >> @@ -357,14 +350,13 @@ int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj, >> struct ll_fiemap_info_key *key, >> struct fiemap *fiemap, size_t *buflen) >> { >> - struct lu_object_header *top; >> + struct cl_object *o; >> int result = 0; >> >> - top = obj->co_lu.lo_header; >> - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_fiemap) { >> - result = obj->co_ops->coo_fiemap(env, obj, key, fiemap, >> - buflen); >> + cl_object_for_each(o, obj) { >> + if (o->co_ops->coo_fiemap) { >> + result = o->co_ops->coo_fiemap(env, o, key, fiemap, >> + buflen); >> if (result) >> break; >> } >> @@ -376,11 +368,11 @@ EXPORT_SYMBOL(cl_object_fiemap); >> int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, >> struct cl_layout *cl) >> { >> - struct lu_object_header *top = obj->co_lu.lo_header; >> + struct cl_object *o; >> >> - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_layout_get) >> - return obj->co_ops->coo_layout_get(env, obj, cl); >> + cl_object_for_each(o, obj) { >> + if (o->co_ops->coo_layout_get) >> + return o->co_ops->coo_layout_get(env, o, cl); >> } >> >> return -EOPNOTSUPP; >> @@ -389,12 +381,12 @@ EXPORT_SYMBOL(cl_object_layout_get); >> >> loff_t cl_object_maxbytes(struct cl_object *obj) >> { >> - struct lu_object_header *top = obj->co_lu.lo_header; >> + struct cl_object *o; >> loff_t maxbytes = LLONG_MAX; >> >> - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { >> - if (obj->co_ops->coo_maxbytes) >> - maxbytes = min_t(loff_t, obj->co_ops->coo_maxbytes(obj), >> + cl_object_for_each(o, obj) { >> + if (o->co_ops->coo_maxbytes) >> + maxbytes = min_t(loff_t, o->co_ops->coo_maxbytes(o), >> maxbytes); >> } >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> index 057318deaa4e..7d00a9233a3b 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> @@ -132,7 +132,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, >> enum cl_page_type type) >> { >> struct cl_page *page; >> - struct lu_object_header *head; >> + struct cl_object *o2; >> >> page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); >> if (page) { >> @@ -149,11 +149,10 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, >> INIT_LIST_HEAD(&page->cp_layers); >> INIT_LIST_HEAD(&page->cp_batch); >> lu_ref_init(&page->cp_reference); >> - head = o->co_lu.lo_header; >> - list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { >> - if (o->co_ops->coo_page_init) { >> - result = o->co_ops->coo_page_init(env, o, page, >> - ind); >> + cl_object_for_each(o2, o) { >> + if (o2->co_ops->coo_page_init) { >> + result = o2->co_ops->coo_page_init(env, o2, page, >> + ind); >> if (result != 0) { >> __cl_page_delete(env, page); >> cl_page_free(env, page); >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 03:25:33 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 14:25:33 +1100 Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> Message-ID: <87wom7f1le.fsf@notabene.neil.brown.name> On Mon, Feb 11 2019, James Simmons wrote: >> cl_env_inc() and cl_env_dec() don't do anything, >> so discard them. > > I don't know about this one. I saw Andreas response as well. > So this was apart of "LU-744 obdclass: revise stats for cl_object cache" > In the end it was turned off by default in the OpenSFS branch since it > made performance take a hit. To enable in OpenSFS branch you have to run > ./configure --enable-pgstate-track. We have a few like this for Lustre so > I was going to bring this up. Do we want to remove this work for both the > upstream client as well as OpenSFS tree or properly implement this by > making it a Kconfig option when CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is > enabled? Its just a matter of porting OpenSFS commit > 5cae09a2409dcd396a1ee7be1eca7d3bbf77365e > > What do you think? How useful are these stats? Stats that are never compiled in aren't likely to tell you much :-) Has any thought been given to per-cpu stats counting? That seems to be the preferred approach for high-frequency accounting. I think having a CONFIG option to enable expensive consistency checks is a good idea - developers will enable it when they don't care about performance. Having a CONFIG option for expensive performance stats seems... weird. Who would use it, and how meaningful would the number be? NeilBrown > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- >> 1 file changed, 15 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> index d71a680660da..1e704078664e 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> @@ -565,14 +565,6 @@ struct cl_env { >> void *ce_debug; >> }; >> >> -static void cl_env_inc(enum cache_stats_item item) >> -{ >> -} >> - >> -static void cl_env_dec(enum cache_stats_item item) >> -{ >> -} >> - >> static void cl_env_init0(struct cl_env *cle, void *debug) >> { >> LASSERT(cle->ce_ref == 0); >> @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) >> >> cle->ce_ref = 1; >> cle->ce_debug = debug; >> - cl_env_inc(CS_busy); >> } >> >> static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> if (rc != 0) { >> kmem_cache_free(cl_env_kmem, cle); >> env = ERR_PTR(rc); >> - } else { >> - cl_env_inc(CS_create); >> - cl_env_inc(CS_total); >> } >> } else { >> env = ERR_PTR(-ENOMEM); >> @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> static void cl_env_fini(struct cl_env *cle) >> { >> - cl_env_dec(CS_total); >> lu_context_fini(&cle->ce_lu.le_ctx); >> lu_context_fini(&cle->ce_ses); >> kmem_cache_free(cl_env_kmem, cle); >> @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) >> if (--cle->ce_ref == 0) { >> int cpu = get_cpu(); >> >> - cl_env_dec(CS_busy); >> cle->ce_debug = NULL; >> cl_env_exit(cle); >> /* >> @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) >> cle->ce_ref--; >> LASSERT(cle->ce_ref == 0); >> >> - cl_env_dec(CS_busy); >> cle->ce_debug = NULL; >> >> put_cpu(); >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Mon Feb 11 04:00:42 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:00:42 +0000 (GMT) Subject: [lustre-devel] [PATCH 13/21] lustre: make cp_ref in cl_page a refcount_t In-Reply-To: <154949781321.10620.15836497514344103445.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781321.10620.15836497514344103445.stgit@noble.brown> Message-ID: > As this is used as a refcount, it should be declared > as one. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 4 ++-- > drivers/staging/lustre/lustre/llite/vvp_page.c | 9 +++++---- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 14 +++++++------- > 3 files changed, 14 insertions(+), 13 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index bf7678aed6bf..c2273c3100e8 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -717,7 +717,7 @@ enum cl_page_type { > */ > struct cl_page { > /** Reference counter. */ > - atomic_t cp_ref; > + refcount_t cp_ref; > /** An object this page is a part of. Immutable after creation. */ > struct cl_object *cp_obj; > /** vmpage */ > @@ -1021,7 +1021,7 @@ static inline struct page *cl_page_vmpage(struct cl_page *page) > */ > static inline bool __page_in_use(const struct cl_page *page, int refc) > { > - return (atomic_read(&page->cp_ref) > refc + 1); > + return (refcount_read(&page->cp_ref) > refc + 1); > } > > /** > diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c > index 77bf923f2578..ec0d93313f55 100644 > --- a/drivers/staging/lustre/lustre/llite/vvp_page.c > +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c > @@ -157,15 +157,16 @@ static void vvp_page_delete(const struct lu_env *env, > struct inode *inode = vmpage->mapping->host; > struct cl_object *obj = slice->cpl_obj; > struct cl_page *page = slice->cpl_page; > - int refc; > > LASSERT(PageLocked(vmpage)); > LASSERT((struct cl_page *)vmpage->private == page); > LASSERT(inode == vvp_object_inode(obj)); > > /* Drop the reference count held in vvp_page_init */ > - refc = atomic_dec_return(&page->cp_ref); > - LASSERTF(refc >= 1, "page = %p, refc = %d\n", page, refc); > + if (refcount_dec_and_test(&page->cp_ref)) { > + /* It mustn't reach zero here! */ > + LASSERTF(0, "page = %p, refc reached zero\n", page); > + } > > ClearPagePrivate(vmpage); > vmpage->private = 0; > @@ -507,7 +508,7 @@ int vvp_page_init(const struct lu_env *env, struct cl_object *obj, > > if (page->cp_type == CPT_CACHEABLE) { > /* in cache, decref in vvp_page_delete */ > - atomic_inc(&page->cp_ref); > + refcount_inc(&page->cp_ref); > SetPagePrivate(vmpage); > vmpage->private = (unsigned long)page; > cl_page_slice_add(page, &vpg->vpg_cl, obj, index, > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index 31ded52e0499..f0ece7e9a4ac 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -67,8 +67,8 @@ static void __cl_page_delete(const struct lu_env *env, struct cl_page *pg); > */ > static void cl_page_get_trust(struct cl_page *page) > { > - LASSERT(atomic_read(&page->cp_ref) > 0); > - atomic_inc(&page->cp_ref); > + LASSERT(refcount_read(&page->cp_ref) > 0); > + refcount_inc(&page->cp_ref); > } > > /** > @@ -135,7 +135,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > if (page) { > int result = 0; > > - atomic_set(&page->cp_ref, 1); > + refcount_set(&page->cp_ref, 1); > page->cp_obj = o; > cl_object_get(o); > lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page", > @@ -310,12 +310,12 @@ EXPORT_SYMBOL(cl_page_get); > void cl_page_put(const struct lu_env *env, struct cl_page *page) > { > CL_PAGE_HEADER(D_TRACE, env, page, "%d\n", > - atomic_read(&page->cp_ref)); > + refcount_read(&page->cp_ref)); > > - if (atomic_dec_and_test(&page->cp_ref)) { > + if (refcount_dec_and_test(&page->cp_ref)) { > LASSERT(page->cp_state == CPS_FREEING); > > - LASSERT(atomic_read(&page->cp_ref) == 0); > + LASSERT(refcount_read(&page->cp_ref) == 0); > PASSERT(env, page, !page->cp_owner); > PASSERT(env, page, list_empty(&page->cp_batch)); > /* > @@ -869,7 +869,7 @@ void cl_page_header_print(const struct lu_env *env, void *cookie, > { > (*printer)(env, cookie, > "page@%p[%d %p %d %d %p]\n", > - pg, atomic_read(&pg->cp_ref), pg->cp_obj, > + pg, refcount_read(&pg->cp_ref), pg->cp_obj, > pg->cp_state, pg->cp_type, > pg->cp_owner); > } > > > From jsimmons at infradead.org Mon Feb 11 04:01:40 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:01:40 +0000 (GMT) Subject: [lustre-devel] [PATCH 12/21] lustre: cl_page.c: remove PINVRNT() In-Reply-To: <154949781317.10620.17224594880512218856.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781317.10620.17224594880512218856.stgit@noble.brown> Message-ID: On Thu, 7 Feb 2019, NeilBrown wrote: > This macro does nothing (it once was like 'assert'), > so remove it. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 33 ---------------------- > 1 file changed, 33 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index 7d00a9233a3b..31ded52e0499 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -55,9 +55,6 @@ static void __cl_page_delete(const struct lu_env *env, struct cl_page *pg); > } \ > } while (0) > > -# define PINVRNT(env, page, exp) \ > - ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp)) > - > /** > * Internal version of cl_page_get(). > * > @@ -382,8 +379,6 @@ void __cl_page_disown(const struct lu_env *env, > enum cl_page_state state; > > state = pg->cp_state; > - PINVRNT(env, pg, state == CPS_OWNED || state == CPS_FREEING); > - PINVRNT(env, pg, cl_page_invariant(pg) || state == CPS_FREEING); > cl_page_owner_clear(pg); > > if (state == CPS_OWNED) > @@ -437,8 +432,6 @@ static int __cl_page_own(const struct lu_env *env, struct cl_io *io, > const struct cl_page_slice *slice; > int result = 0; > > - PINVRNT(env, pg, !cl_page_is_owned(pg, io)); > - > io = cl_io_top(io); > > if (pg->cp_state == CPS_FREEING) { > @@ -468,7 +461,6 @@ static int __cl_page_own(const struct lu_env *env, struct cl_io *io, > } > } > out: > - PINVRNT(env, pg, ergo(result == 0, cl_page_invariant(pg))); > return result; > } > > @@ -510,8 +502,6 @@ void cl_page_assume(const struct lu_env *env, > { > const struct cl_page_slice *slice; > > - PINVRNT(env, pg, cl_object_same(pg->cp_obj, io->ci_obj)); > - > io = cl_io_top(io); > > list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { > @@ -542,9 +532,6 @@ void cl_page_unassume(const struct lu_env *env, > { > const struct cl_page_slice *slice; > > - PINVRNT(env, pg, cl_page_is_owned(pg, io)); > - PINVRNT(env, pg, cl_page_invariant(pg)); > - > io = cl_io_top(io); > cl_page_owner_clear(pg); > cl_page_state_set(env, pg, CPS_CACHED); > @@ -570,9 +557,6 @@ EXPORT_SYMBOL(cl_page_unassume); > void cl_page_disown(const struct lu_env *env, > struct cl_io *io, struct cl_page *pg) > { > - PINVRNT(env, pg, cl_page_is_owned(pg, io) || > - pg->cp_state == CPS_FREEING); > - > io = cl_io_top(io); > __cl_page_disown(env, io, pg); > } > @@ -593,9 +577,6 @@ void cl_page_discard(const struct lu_env *env, > { > const struct cl_page_slice *slice; > > - PINVRNT(env, pg, cl_page_is_owned(pg, io)); > - PINVRNT(env, pg, cl_page_invariant(pg)); > - > list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { > if (slice->cpl_ops->cpo_discard) > (*slice->cpl_ops->cpo_discard)(env, slice, io); > @@ -652,7 +633,6 @@ static void __cl_page_delete(const struct lu_env *env, struct cl_page *pg) > */ > void cl_page_delete(const struct lu_env *env, struct cl_page *pg) > { > - PINVRNT(env, pg, cl_page_invariant(pg)); > __cl_page_delete(env, pg); > } > EXPORT_SYMBOL(cl_page_delete); > @@ -670,8 +650,6 @@ void cl_page_export(const struct lu_env *env, struct cl_page *pg, int uptodate) > { > const struct cl_page_slice *slice; > > - PINVRNT(env, pg, cl_page_invariant(pg)); > - > list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { > if (slice->cpl_ops->cpo_export) > (*slice->cpl_ops->cpo_export)(env, slice, uptodate); > @@ -730,10 +708,6 @@ int cl_page_prep(const struct lu_env *env, struct cl_io *io, > const struct cl_page_slice *slice; > int result = 0; > > - PINVRNT(env, pg, cl_page_is_owned(pg, io)); > - PINVRNT(env, pg, cl_page_invariant(pg)); > - PINVRNT(env, pg, crt < CRT_NR); > - > /* > * XXX this has to be called bottom-to-top, so that llite can set up > * PG_writeback without risking other layers deciding to skip this > @@ -819,8 +793,6 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg, > const struct cl_page_slice *sli; > int result = 0; > > - PINVRNT(env, pg, crt < CRT_NR); > - > if (crt >= CRT_NR) > return -EINVAL; > > @@ -856,9 +828,6 @@ int cl_page_flush(const struct lu_env *env, struct cl_io *io, > const struct cl_page_slice *slice; > int result = 0; > > - PINVRNT(env, pg, cl_page_is_owned(pg, io)); > - PINVRNT(env, pg, cl_page_invariant(pg)); > - > list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { > if (slice->cpl_ops->cpo_flush) > result = (*slice->cpl_ops->cpo_flush)(env, slice, io); > @@ -883,8 +852,6 @@ void cl_page_clip(const struct lu_env *env, struct cl_page *pg, > { > const struct cl_page_slice *slice; > > - PINVRNT(env, pg, cl_page_invariant(pg)); > - > CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", from, to); > > list_for_each_entry(slice, &pg->cp_layers, cpl_linkage) { > > > From jsimmons at infradead.org Mon Feb 11 04:01:55 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:01:55 +0000 (GMT) Subject: [lustre-devel] [PATCH 14/21] lustre: make ccc_users in cl_client_cache a refcount_t In-Reply-To: <154949781324.10620.6961645123977299300.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781324.10620.6961645123977299300.stgit@noble.brown> Message-ID: > As this is used as a refcount, it should be declared > as one. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 2 +- > drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- > drivers/staging/lustre/lustre/obdclass/cl_page.c | 6 +++--- > drivers/staging/lustre/lustre/osc/osc_page.c | 4 ++-- > drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- > 5 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index c2273c3100e8..05be85306663 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -2181,7 +2181,7 @@ struct cl_client_cache { > * # of client cache refcount > * # of users (OSCs) + 2 (held by llite and lov) > */ > - atomic_t ccc_users; > + refcount_t ccc_users; > /** > * # of threads are doing shrinking > */ > diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c > index 001bed90f4da..8215296dc15d 100644 > --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c > +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c > @@ -467,7 +467,7 @@ static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v) > "used_mb: %ld\n" > "unused_mb: %ld\n" > "reclaim_count: %u\n", > - atomic_read(&cache->ccc_users), > + refcount_read(&cache->ccc_users), > max_cached_mb, > max_cached_mb - unused_mb, > unused_mb, > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index f0ece7e9a4ac..7dcd3aff229f 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -960,7 +960,7 @@ struct cl_client_cache *cl_cache_init(unsigned long lru_page_max) > return NULL; > > /* Initialize cache data */ > - atomic_set(&cache->ccc_users, 1); > + refcount_set(&cache->ccc_users, 1); > cache->ccc_lru_max = lru_page_max; > atomic_long_set(&cache->ccc_lru_left, lru_page_max); > spin_lock_init(&cache->ccc_lru_lock); > @@ -978,7 +978,7 @@ EXPORT_SYMBOL(cl_cache_init); > */ > void cl_cache_incref(struct cl_client_cache *cache) > { > - atomic_inc(&cache->ccc_users); > + refcount_inc(&cache->ccc_users); > } > EXPORT_SYMBOL(cl_cache_incref); > > @@ -989,7 +989,7 @@ EXPORT_SYMBOL(cl_cache_incref); > */ > void cl_cache_decref(struct cl_client_cache *cache) > { > - if (atomic_dec_and_test(&cache->ccc_users)) > + if (refcount_dec_and_test(&cache->ccc_users)) > kfree(cache); > } > EXPORT_SYMBOL(cl_cache_decref); > diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c > index 135bfe5e1b37..ce911b82512d 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_page.c > +++ b/drivers/staging/lustre/lustre/osc/osc_page.c > @@ -346,7 +346,7 @@ static int osc_cache_too_much(struct client_obd *cli) > long pages = atomic_long_read(&cli->cl_lru_in_list); > unsigned long budget; > > - budget = cache->ccc_lru_max / (atomic_read(&cache->ccc_users) - 2); > + budget = cache->ccc_lru_max / (refcount_read(&cache->ccc_users) - 2); > > /* if it's going to run out LRU slots, we should free some, but not > * too much to maintain fairness among OSCs. > @@ -707,7 +707,7 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) > cache->ccc_lru_shrinkers++; > list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru); > > - max_scans = atomic_read(&cache->ccc_users) - 2; > + max_scans = refcount_read(&cache->ccc_users) - 2; > while (--max_scans > 0 && > (cli = list_first_entry_or_null(&cache->ccc_lru, > struct client_obd, > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 9e72fa8f68b3..0dfc506f6d01 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -2959,7 +2959,7 @@ static int osc_cleanup(struct obd_device *obd) > > /* lru cleanup */ > if (cli->cl_cache) { > - LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0); > + LASSERT(refcount_read(&cli->cl_cache->ccc_users) > 0); > spin_lock(&cli->cl_cache->ccc_lru_lock); > list_del_init(&cli->cl_lru_osc); > spin_unlock(&cli->cl_cache->ccc_lru_lock); > > > From jsimmons at infradead.org Mon Feb 11 04:03:37 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:03:37 +0000 (GMT) Subject: [lustre-devel] [PATCH 15/21] lustre: obdclass: char obd_ioctl_getdata type. In-Reply-To: <154949781327.10620.2294752316778817915.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781327.10620.2294752316778817915.stgit@noble.brown> Message-ID: > Instead of having obd_ioctl_getdata() return the allocated > data as a "char *", return it as it really is, > struct obd_ioctl_data * > > This avoids the need for extra variables and casts. I think this needs the fix Andreas pointed out. > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/obd_class.h | 3 ++- > drivers/staging/lustre/lustre/llite/dir.c | 17 +++++------------ > drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +++----- > drivers/staging/lustre/lustre/lov/lov_obd.c | 15 ++++++--------- > drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 ++++++++---------- > 5 files changed, 24 insertions(+), 37 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h > index 30b3e2c69f83..32d4ab6e78a0 100644 > --- a/drivers/staging/lustre/lustre/include/obd_class.h > +++ b/drivers/staging/lustre/lustre/include/obd_class.h > @@ -1697,6 +1697,7 @@ struct root_squash_info { > }; > > /* linux-module.c */ > -int obd_ioctl_getdata(char **buf, int *len, void __user *arg); > +struct obd_ioctl_data; > +int obd_ioctl_getdata(struct obd_ioctl_data **data, int *len, void __user *arg); > > #endif /* __LINUX_OBD_CLASS_H */ > diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c > index fd1af4a5cdad..0c49244eaee8 100644 > --- a/drivers/staging/lustre/lustre/llite/dir.c > +++ b/drivers/staging/lustre/lustre/llite/dir.c > @@ -1130,13 +1130,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > } > case IOC_MDC_LOOKUP: { > int namelen, len = 0; > - char *buf = NULL; > char *filename; > > - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); > + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); > if (rc) > return rc; > - data = (void *)buf; > > filename = data->ioc_inlbuf1; > namelen = strlen(filename); > @@ -1155,12 +1153,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > goto out_free; > } > out_free: > - kvfree(buf); > + kvfree(data); > return rc; > } > case LL_IOC_LMV_SETSTRIPE: { > struct lmv_user_md *lum; > - char *buf = NULL; > char *filename; > int namelen = 0; > int lumlen = 0; > @@ -1168,11 +1165,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > int len; > int rc; > > - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); > + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); > if (rc) > return rc; > > - data = (void *)buf; > if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || > data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0) { > rc = -EINVAL; > @@ -1205,7 +1201,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > #endif > rc = ll_dir_setdirstripe(dentry, lum, filename, mode); > lmv_out_free: > - kvfree(buf); > + kvfree(data); > return rc; > } > case LL_IOC_LMV_SET_DEFAULT_STRIPE: { > @@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > return rc; > } > case LL_IOC_MIGRATE: { > - char *buf = NULL; > const char *filename; > int namelen = 0; > int len; > int rc; > int mdtidx; > > - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); > + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); > if (rc < 0) > return rc; > > - data = (struct obd_ioctl_data *)buf; > if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || > !data->ioc_inllen1 || !data->ioc_inllen2) { > rc = -EINVAL; > @@ -1684,7 +1678,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > > rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1); > migrate_free: > - kvfree(buf); > > return rc; > } > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index 8e09fdd7a96e..e2417cd5aaed 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -2295,7 +2295,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) > { > struct ll_sb_info *sbi = NULL; > struct obd_export *exp; > - char *buf = NULL; > struct obd_ioctl_data *data = NULL; > u32 type; > int len = 0, rc; > @@ -2311,11 +2310,10 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) > goto out_statfs; > } > > - rc = obd_ioctl_getdata(&buf, &len, arg); > + rc = obd_ioctl_getdata(&data, &len, arg); > if (rc) > goto out_statfs; > > - data = (void *)buf; > if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || > !data->ioc_pbuf1 || !data->ioc_pbuf2) { > rc = -EINVAL; > @@ -2340,11 +2338,11 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) > goto out_statfs; > } > > - rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL); > + rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, data, NULL); > if (rc) > goto out_statfs; > out_statfs: > - kvfree(buf); > + kvfree(data); > return rc; > } > > diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c > index 04d0a9ed1d05..fd769c39b482 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_obd.c > +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c > @@ -1039,27 +1039,24 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, > case OBD_IOC_LOV_GET_CONFIG: { > struct obd_ioctl_data *data; > struct lov_desc *desc; > - char *buf = NULL; > u32 *genp; > > len = 0; > - if (obd_ioctl_getdata(&buf, &len, uarg)) > + if (obd_ioctl_getdata(&data, &len, uarg)) > return -EINVAL; > > - data = (struct obd_ioctl_data *)buf; > - > if (sizeof(*desc) > data->ioc_inllen1) { > - kvfree(buf); > + kvfree(data); > return -EINVAL; > } > > if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { > - kvfree(buf); > + kvfree(data); > return -EINVAL; > } > > if (sizeof(u32) * count > data->ioc_inllen3) { > - kvfree(buf); > + kvfree(data); > return -EINVAL; > } > > @@ -1076,9 +1073,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, > *genp = lov->lov_tgts[i]->ltd_gen; > } > > - if (copy_to_user(uarg, buf, len)) > + if (copy_to_user(uarg, data, len)) > rc = -EFAULT; > - kvfree(buf); > + kvfree(data); > break; > } > case OBD_IOC_QUOTACTL: { > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index b859ab19b9f6..2ef4fd41cdd0 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -230,7 +230,7 @@ static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) > } > > /* buffer MUST be at least the size of obd_ioctl_hdr */ > -int obd_ioctl_getdata(char **buf, int *len, void __user *arg) > +int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg) > { > struct obd_ioctl_data *data; > struct obd_ioctl_hdr hdr; > @@ -262,16 +262,16 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) > * obdfilter-survey is an example, which relies on ioctl. So we'd > * better avoid vmalloc on ioctl path. LU-66 > */ > - *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); > - if (!*buf) { > + data = kvzalloc(hdr.ioc_len, GFP_KERNEL); > + if (!data) { > CERROR("Cannot allocate control buffer of len %d\n", > hdr.ioc_len); > return -EINVAL; > } > *len = hdr.ioc_len; > - data = (struct obd_ioctl_data *)*buf; > + *datap = data; > > - if (copy_from_user(*buf, arg, hdr.ioc_len)) { > + if (copy_from_user(data, arg, hdr.ioc_len)) { > err = -EFAULT; > goto free_buf; > } > @@ -308,14 +308,13 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) > return 0; > > free_buf: > - kvfree(*buf); > + kvfree(data); > return err; > } > EXPORT_SYMBOL(obd_ioctl_getdata); > > int class_handle_ioctl(unsigned int cmd, unsigned long arg) > { > - char *buf = NULL; > struct obd_ioctl_data *data; > struct libcfs_debug_ioctl_data *debug_data; > struct obd_device *obd = NULL; > @@ -330,11 +329,10 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > } > > CDEBUG(D_IOCTL, "cmd = %x\n", cmd); > - if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) { > + if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) { > CERROR("OBD ioctl: data error\n"); > return -EINVAL; > } > - data = (struct obd_ioctl_data *)buf; > > switch (cmd) { > case OBD_IOC_PROCESS_CFG: { > @@ -545,7 +543,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > } > > out: > - kvfree(buf); > + kvfree(data); > return err; > } /* class_handle_ioctl */ > > > > From jsimmons at infradead.org Mon Feb 11 04:03:59 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:03:59 +0000 (GMT) Subject: [lustre-devel] [PATCH 16/21] lustre: obdclass: normalize a switch statement. In-Reply-To: <154949781331.10620.12767117536447190491.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781331.10620.12767117536447190491.stgit@noble.brown> Message-ID: > Remove the unnecessary {}, and use "break" rather than > "goto out;" for normal exit from the cases. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/class_obd.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index 2ef4fd41cdd0..48d1dabafa65 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -518,7 +518,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > } > > switch (cmd) { > - case OBD_IOC_NO_TRANSNO: { > + case OBD_IOC_NO_TRANSNO: > if (!obd->obd_attached) { > CERROR("Device %d not attached\n", obd->obd_minor); > err = -ENODEV; > @@ -528,18 +528,16 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > obd->obd_name); > obd->obd_no_transno = 1; > err = 0; > - goto out; > - } > + break; > > - default: { > + default: > err = obd_iocontrol(cmd, obd->obd_self_export, len, data, NULL); > if (err) > goto out; > > if (copy_to_user((void __user *)arg, data, len)) > err = -EFAULT; > - goto out; > - } > + break; > } > > out: > > > From jsimmons at infradead.org Mon Feb 11 04:17:12 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:17:12 +0000 (GMT) Subject: [lustre-devel] [PATCH 18/21] lustre: move debug.c from obdclass to obdecho In-Reply-To: <154949781337.10620.11481546344215316629.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781337.10620.11481546344215316629.stgit@noble.brown> Message-ID: > The functions defined in debug.c are only used in > obdecho, so move it there, and make the functions local > to that unit. > This allows lustre_debug.h to be removed. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lustre/include/lustre_debug.h | 52 ----------- > .../staging/lustre/lustre/llite/llite_internal.h | 2 > drivers/staging/lustre/lustre/obdclass/Makefile | 2 > drivers/staging/lustre/lustre/obdclass/class_obd.c | 1 > drivers/staging/lustre/lustre/obdclass/debug.c | 96 -------------------- > drivers/staging/lustre/lustre/obdecho/Makefile | 2 > drivers/staging/lustre/lustre/obdecho/debug.c | 96 ++++++++++++++++++++ > .../staging/lustre/lustre/obdecho/echo_client.c | 1 > .../staging/lustre/lustre/obdecho/echo_internal.h | 4 + > drivers/staging/lustre/lustre/osc/osc_request.c | 1 > drivers/staging/lustre/lustre/ptlrpc/layout.c | 1 > 11 files changed, 103 insertions(+), 155 deletions(-) > delete mode 100644 drivers/staging/lustre/lustre/include/lustre_debug.h > delete mode 100644 drivers/staging/lustre/lustre/obdclass/debug.c > create mode 100644 drivers/staging/lustre/lustre/obdecho/debug.c > > diff --git a/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h > deleted file mode 100644 > index b9414fc73f00..000000000000 > --- a/drivers/staging/lustre/lustre/include/lustre_debug.h > +++ /dev/null > @@ -1,52 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0 > -/* > - * GPL HEADER START > - * > - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License version 2 only, > - * as published by the Free Software Foundation. > - * > - * This program is distributed in the hope that it will be useful, but > - * WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - * General Public License version 2 for more details (a copy is included > - * in the LICENSE file that accompanied this code). > - * > - * You should have received a copy of the GNU General Public License > - * version 2 along with this program; If not, see > - * http://www.gnu.org/licenses/gpl-2.0.html > - * > - * GPL HEADER END > - */ > -/* > - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. > - * Use is subject to license terms. > - * > - * Copyright (c) 2011, Intel Corporation. > - */ > -/* > - * This file is part of Lustre, http://www.lustre.org/ > - * Lustre is a trademark of Sun Microsystems, Inc. > - */ > - > -#ifndef _LUSTRE_DEBUG_H > -#define _LUSTRE_DEBUG_H > - > -/** \defgroup debug debug > - * > - * @{ > - */ > - > -#include > -#include > - > -/* lib/debug.c */ > -int dump_req(struct ptlrpc_request *req); > -int block_debug_setup(void *addr, int len, u64 off, u64 id); > -int block_debug_check(char *who, void *addr, int len, u64 off, u64 id); > - > -/** @} debug */ > - > -#endif > diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h > index bf7e46fe9ec6..c8860904bdd4 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_internal.h > +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h > @@ -33,7 +33,7 @@ > > #ifndef LLITE_INTERNAL_H > #define LLITE_INTERNAL_H > -#include > +#include > #include > #include /* for s2sbi */ > #include > diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile > index b1fac48b3adc..1669c24a0b03 100644 > --- a/drivers/staging/lustre/lustre/obdclass/Makefile > +++ b/drivers/staging/lustre/lustre/obdclass/Makefile > @@ -4,7 +4,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include > > obj-$(CONFIG_LUSTRE_FS) += obdclass.o > > -obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ > +obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o \ > genops.o obd_sysfs.o lprocfs_status.o lprocfs_counters.o \ > lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ > obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \ > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index 982d47b6f50e..4a717a29e385 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -41,7 +41,6 @@ > #include > #include > #include > -#include > #include > #include > #include > diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c > deleted file mode 100644 > index 2e526c7389d8..000000000000 > --- a/drivers/staging/lustre/lustre/obdclass/debug.c > +++ /dev/null > @@ -1,96 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0 > -/* > - * GPL HEADER START > - * > - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License version 2 only, > - * as published by the Free Software Foundation. > - * > - * This program is distributed in the hope that it will be useful, but > - * WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - * General Public License version 2 for more details (a copy is included > - * in the LICENSE file that accompanied this code). > - * > - * You should have received a copy of the GNU General Public License > - * version 2 along with this program; If not, see > - * http://www.gnu.org/licenses/gpl-2.0.html > - * > - * GPL HEADER END > - */ > -/* > - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. > - * Use is subject to license terms. > - * > - * Copyright (c) 2011, 2012, Intel Corporation. > - */ > -/* > - * This file is part of Lustre, http://www.lustre.org/ > - * Lustre is a trademark of Sun Microsystems, Inc. > - * > - * lustre/obdclass/debug.c > - * > - * Helper routines for dumping data structs for debugging. > - */ > - > -#define DEBUG_SUBSYSTEM D_OTHER > - > -#include > - > -#include > -#include > -#include > - > -#define LPDS sizeof(u64) > -int block_debug_setup(void *addr, int len, u64 off, u64 id) > -{ > - LASSERT(addr); > - > - put_unaligned_le64(off, addr); > - put_unaligned_le64(id, addr + LPDS); > - addr += len - LPDS - LPDS; > - put_unaligned_le64(off, addr); > - put_unaligned_le64(id, addr + LPDS); > - > - return 0; > -} > -EXPORT_SYMBOL(block_debug_setup); > - > -int block_debug_check(char *who, void *addr, int end, u64 off, u64 id) > -{ > - u64 ne_off; > - int err = 0; > - > - LASSERT(addr); > - > - ne_off = le64_to_cpu(off); > - id = le64_to_cpu(id); > - if (memcmp(addr, (char *)&ne_off, LPDS)) { > - CDEBUG(D_ERROR, "%s: id %#llx offset %llu off: %#llx != %#llx\n", > - who, id, off, *(u64 *)addr, ne_off); > - err = -EINVAL; > - } > - if (memcmp(addr + LPDS, (char *)&id, LPDS)) { > - CDEBUG(D_ERROR, "%s: id %#llx offset %llu id: %#llx != %#llx\n", > - who, id, off, *(u64 *)(addr + LPDS), id); > - err = -EINVAL; > - } > - > - addr += end - LPDS - LPDS; > - if (memcmp(addr, (char *)&ne_off, LPDS)) { > - CDEBUG(D_ERROR, "%s: id %#llx offset %llu end off: %#llx != %#llx\n", > - who, id, off, *(u64 *)addr, ne_off); > - err = -EINVAL; > - } > - if (memcmp(addr + LPDS, (char *)&id, LPDS)) { > - CDEBUG(D_ERROR, "%s: id %#llx offset %llu end id: %#llx != %#llx\n", > - who, id, off, *(u64 *)(addr + LPDS), id); > - err = -EINVAL; > - } > - > - return err; > -} > -EXPORT_SYMBOL(block_debug_check); > -#undef LPDS > diff --git a/drivers/staging/lustre/lustre/obdecho/Makefile b/drivers/staging/lustre/lustre/obdecho/Makefile > index ff85ef1db70a..0a02efae036d 100644 > --- a/drivers/staging/lustre/lustre/obdecho/Makefile > +++ b/drivers/staging/lustre/lustre/obdecho/Makefile > @@ -2,4 +2,4 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/include > ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include > > obj-$(CONFIG_LUSTRE_FS) += obdecho.o > -obdecho-y := echo_client.o > +obdecho-y := echo_client.o debug.o > diff --git a/drivers/staging/lustre/lustre/obdecho/debug.c b/drivers/staging/lustre/lustre/obdecho/debug.c > new file mode 100644 > index 000000000000..149aca54c776 > --- /dev/null > +++ b/drivers/staging/lustre/lustre/obdecho/debug.c > @@ -0,0 +1,96 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * GPL HEADER START > + * > + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 only, > + * as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but > + * WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * General Public License version 2 for more details (a copy is included > + * in the LICENSE file that accompanied this code). > + * > + * You should have received a copy of the GNU General Public License > + * version 2 along with this program; If not, see > + * http://www.gnu.org/licenses/gpl-2.0.html > + * > + * GPL HEADER END > + */ > +/* > + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. > + * Use is subject to license terms. > + * > + * Copyright (c) 2011, 2012, Intel Corporation. > + */ > +/* > + * This file is part of Lustre, http://www.lustre.org/ > + * Lustre is a trademark of Sun Microsystems, Inc. > + * > + * lustre/obdclass/debug.c > + * > + * Helper routines for dumping data structs for debugging. > + */ > + > +#define DEBUG_SUBSYSTEM D_OTHER > + > +#include > + > +#include > +#include "echo_internal.h" > +#include > + > +#define LPDS sizeof(u64) > +int block_debug_setup(void *addr, int len, u64 off, u64 id) > +{ > + LASSERT(addr); > + > + put_unaligned_le64(off, addr); > + put_unaligned_le64(id, addr + LPDS); > + addr += len - LPDS - LPDS; > + put_unaligned_le64(off, addr); > + put_unaligned_le64(id, addr + LPDS); > + > + return 0; > +} > +EXPORT_SYMBOL(block_debug_setup); > + > +int block_debug_check(char *who, void *addr, int end, u64 off, u64 id) > +{ > + u64 ne_off; > + int err = 0; > + > + LASSERT(addr); > + > + ne_off = le64_to_cpu(off); > + id = le64_to_cpu(id); > + if (memcmp(addr, (char *)&ne_off, LPDS)) { > + CDEBUG(D_ERROR, "%s: id %#llx offset %llu off: %#llx != %#llx\n", > + who, id, off, *(u64 *)addr, ne_off); > + err = -EINVAL; > + } > + if (memcmp(addr + LPDS, (char *)&id, LPDS)) { > + CDEBUG(D_ERROR, "%s: id %#llx offset %llu id: %#llx != %#llx\n", > + who, id, off, *(u64 *)(addr + LPDS), id); > + err = -EINVAL; > + } > + > + addr += end - LPDS - LPDS; > + if (memcmp(addr, (char *)&ne_off, LPDS)) { > + CDEBUG(D_ERROR, "%s: id %#llx offset %llu end off: %#llx != %#llx\n", > + who, id, off, *(u64 *)addr, ne_off); > + err = -EINVAL; > + } > + if (memcmp(addr + LPDS, (char *)&id, LPDS)) { > + CDEBUG(D_ERROR, "%s: id %#llx offset %llu end id: %#llx != %#llx\n", > + who, id, off, *(u64 *)(addr + LPDS), id); > + err = -EINVAL; > + } > + > + return err; > +} > +EXPORT_SYMBOL(block_debug_check); > +#undef LPDS > diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c > index 1ebd98513239..1b7d98c649b6 100644 > --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c > +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c > @@ -37,7 +37,6 @@ > #include > #include > #include > -#include > #include > #include > #include > diff --git a/drivers/staging/lustre/lustre/obdecho/echo_internal.h b/drivers/staging/lustre/lustre/obdecho/echo_internal.h > index 8094a94f605c..f9bb0b91d399 100644 > --- a/drivers/staging/lustre/lustre/obdecho/echo_internal.h > +++ b/drivers/staging/lustre/lustre/obdecho/echo_internal.h > @@ -39,4 +39,8 @@ > /* block size to use for data verification */ > #define OBD_ECHO_BLOCK_SIZE (4 << 10) > > +/* debug.c */ > +int block_debug_setup(void *addr, int len, u64 off, u64 id); > +int block_debug_check(char *who, void *addr, int len, u64 off, u64 id); > + > #endif > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 0dfc506f6d01..3fedfaf249c4 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -45,7 +45,6 @@ > #include > #include > #include > -#include > #include > #include > #include > diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c > index f1f7d70b9790..d9f2b3d9e526 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c > @@ -50,7 +50,6 @@ > #include > > #include > -#include > #include > #include > #include > > > From jsimmons at infradead.org Mon Feb 11 04:18:05 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:18:05 +0000 (GMT) Subject: [lustre-devel] [PATCH 21/21] lustre: make exp_refcount in obd_export a refcount_t In-Reply-To: <154949781349.10620.3269248433038576631.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781349.10620.3269248433038576631.stgit@noble.brown> Message-ID: > As this is used as a refcount, it should be declared > as one. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lustre/include/lustre_export.h | 2 +- > drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 10 +++++----- > drivers/staging/lustre/lustre/obdclass/genops.c | 15 ++++++++------- > .../staging/lustre/lustre/obdecho/echo_client.c | 2 +- > drivers/staging/lustre/lustre/ptlrpc/service.c | 4 ++-- > 5 files changed, 17 insertions(+), 16 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h > index 63fa656eb7ba..fb34e0b7de35 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_export.h > +++ b/drivers/staging/lustre/lustre/include/lustre_export.h > @@ -67,7 +67,7 @@ struct obd_export { > * what export they are talking to. > */ > struct portals_handle exp_handle; > - atomic_t exp_refcount; > + refcount_t exp_refcount; > /** > * Set of counters below is to track where export references are > * kept. The exp_rpc_count is used for reconnect handling also, > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > index cea0e22d064b..f2433dc0e558 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > @@ -1998,7 +1998,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > ldlm_lockname[lock->l_req_mode], > lock->l_flags, nid, > lock->l_remote_handle.cookie, > - exp ? atomic_read(&exp->exp_refcount) : -99, > + exp ? refcount_read(&exp->exp_refcount) : -99, > lock->l_pid, lock->l_callback_timeout, > lock->l_lvb_type); > va_end(args); > @@ -2024,7 +2024,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > lock->l_req_extent.end, > lock->l_flags, nid, > lock->l_remote_handle.cookie, > - exp ? atomic_read(&exp->exp_refcount) : -99, > + exp ? refcount_read(&exp->exp_refcount) : -99, > lock->l_pid, lock->l_callback_timeout, > lock->l_lvb_type); > break; > @@ -2046,7 +2046,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > lock->l_policy_data.l_flock.end, > lock->l_flags, nid, > lock->l_remote_handle.cookie, > - exp ? atomic_read(&exp->exp_refcount) : -99, > + exp ? refcount_read(&exp->exp_refcount) : -99, > lock->l_pid, lock->l_callback_timeout); > break; > > @@ -2065,7 +2065,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > ldlm_typename[resource->lr_type], > lock->l_flags, nid, > lock->l_remote_handle.cookie, > - exp ? atomic_read(&exp->exp_refcount) : -99, > + exp ? refcount_read(&exp->exp_refcount) : -99, > lock->l_pid, lock->l_callback_timeout, > lock->l_lvb_type); > break; > @@ -2084,7 +2084,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > ldlm_typename[resource->lr_type], > lock->l_flags, nid, > lock->l_remote_handle.cookie, > - exp ? atomic_read(&exp->exp_refcount) : -99, > + exp ? refcount_read(&exp->exp_refcount) : -99, > lock->l_pid, lock->l_callback_timeout, > lock->l_lvb_type); > break; > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index dad21d9fa328..39919f1c5b71 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -757,7 +757,7 @@ static void class_export_destroy(struct obd_export *exp) > { > struct obd_device *obd = exp->exp_obd; > > - LASSERT_ATOMIC_ZERO(&exp->exp_refcount); > + LASSERT(refcount_read(&exp->exp_refcount) == 0); > LASSERT(obd); > > CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, > @@ -793,20 +793,21 @@ static struct portals_handle_ops export_handle_ops = { > > struct obd_export *class_export_get(struct obd_export *exp) > { > - atomic_inc(&exp->exp_refcount); > + refcount_inc(&exp->exp_refcount); > CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp, > - atomic_read(&exp->exp_refcount)); > + refcount_read(&exp->exp_refcount)); > return exp; > } > EXPORT_SYMBOL(class_export_get); > > void class_export_put(struct obd_export *exp) > { > - LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, LI_POISON); > + LASSERT(refcount_read(&exp->exp_refcount) > 0); > + LASSERT(refcount_read(&exp->exp_refcount) < LI_POISON); > CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp, > - atomic_read(&exp->exp_refcount) - 1); > + refcount_read(&exp->exp_refcount) - 1); > > - if (atomic_dec_and_test(&exp->exp_refcount)) { > + if (refcount_dec_and_test(&exp->exp_refcount)) { > struct obd_device *obd = exp->exp_obd; > > CDEBUG(D_IOCTL, "final put %p/%s\n", > @@ -856,7 +857,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd, > > export->exp_conn_cnt = 0; > /* 2 = class_handle_hash + last */ > - atomic_set(&export->exp_refcount, 2); > + refcount_set(&export->exp_refcount, 2); > atomic_set(&export->exp_rpc_count, 0); > atomic_set(&export->exp_cb_count, 0); > atomic_set(&export->exp_locks_count, 0); > diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c > index 1b7d98c649b6..317123fd27cb 100644 > --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c > +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c > @@ -1638,7 +1638,7 @@ static int echo_client_cleanup(struct obd_device *obddev) > return -EBUSY; > } > > - LASSERT(atomic_read(&ec->ec_exp->exp_refcount) > 0); > + LASSERT(refcount_read(&ec->ec_exp->exp_refcount) > 0); > rc = obd_disconnect(ec->ec_exp); > if (rc != 0) > CERROR("fail to disconnect device: %d\n", rc); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c > index 35a59e5a5e9d..b7d44fc21d73 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/service.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c > @@ -1697,7 +1697,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, > (request->rq_export ? > (char *)request->rq_export->exp_client_uuid.uuid : "0"), > (request->rq_export ? > - atomic_read(&request->rq_export->exp_refcount) : -99), > + refcount_read(&request->rq_export->exp_refcount) : -99), > lustre_msg_get_status(request->rq_reqmsg), request->rq_xid, > libcfs_id2str(request->rq_peer), > lustre_msg_get_opc(request->rq_reqmsg)); > @@ -1741,7 +1741,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, > (request->rq_export ? > (char *)request->rq_export->exp_client_uuid.uuid : "0"), > (request->rq_export ? > - atomic_read(&request->rq_export->exp_refcount) : -99), > + refcount_read(&request->rq_export->exp_refcount) : -99), > lustre_msg_get_status(request->rq_reqmsg), > request->rq_xid, > libcfs_id2str(request->rq_peer), > > > From jsimmons at infradead.org Mon Feb 11 04:19:27 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:19:27 +0000 (GMT) Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate In-Reply-To: <87pnrzgnp5.fsf@notabene.neil.brown.name> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781310.10620.8883358407999258821.stgit@noble.brown> <87pnrzgnp5.fsf@notabene.neil.brown.name> Message-ID: > On Fri, Feb 08 2019, Andreas Dilger wrote: > > > On Feb 6, 2019, at 17:03, NeilBrown wrote: > >> > >> There are various places which have a list_for_each_entry() > >> where cl_object_for_each (or .._reverse) is more appropriate. > >> > >> Several of these re-use the 'obj' function parameter as a loop > >> iterator, which is a little confusing. > >> > >> Change these to use cl_object_for_each{_reverse}, and where needed, > >> introduce a new iterator variable 'o'. > >> > >> Signed-off-by: NeilBrown > >> --- > >> drivers/staging/lustre/lustre/lov/lov_page.c | 3 - > >> drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 - > >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 82 +++++++++----------- > >> drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 +-- > >> 4 files changed, 44 insertions(+), 55 deletions(-) > >> > >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> index f724b2d62df1..d71a680660da 100644 > >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> @@ -190,16 +190,15 @@ EXPORT_SYMBOL(cl_object_attr_unlock); > >> int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, > >> struct cl_attr *attr) > >> { > >> - struct lu_object_header *top; > >> + struct cl_object *o; > >> int result; > >> > >> assert_spin_locked(cl_object_attr_guard(obj)); > >> > >> - top = obj->co_lu.lo_header; > >> result = 0; > > > > May as well move the "result = 0" initialization to the declaration for > > all of these? Another 5 fewer lines of code under your belt. > > Yes, that seem good. New patch below. > Thanks, > NeilBrown > > > From: NeilBrown > Subject: [PATCH] lustre: obdclass: use cl_object_for_each where appropriate > > There are various places which have a list_for_each_entry() > where cl_object_for_each (or .._reverse) is more appropriate. > > Several of these re-use the 'obj' function parameter as a loop > iterator, which is a little confusing. > > Change these to use cl_object_for_each{_reverse}, and where needed, > introduce a new iterator variable 'o'. > > To further clean up these function, move initializtion of 'result' > to the variable declaration. Good with this version as well. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/lov/lov_page.c | 3 +- > drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 +- > drivers/staging/lustre/lustre/obdclass/cl_object.c | 97 ++++++++++------------ > drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 ++- > 4 files changed, 49 insertions(+), 65 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c > index 08485a95ec01..e64b350601d2 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_page.c > +++ b/drivers/staging/lustre/lustre/lov/lov_page.c > @@ -103,8 +103,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, > return PTR_ERR(sub); > > subobj = lovsub2cl(r0->lo_sub[stripe]); > - list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers, > - co_lu.lo_linkage) { > + cl_object_for_each(o, subobj) { > if (o->co_ops->coo_page_init) { > rc = o->co_ops->coo_page_init(sub->sub_env, o, page, > cl_index(subobj, suboff)); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > index 8133d992cc73..fc5976d8b37b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > @@ -103,8 +103,7 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, > LASSERT(obj); > > INIT_LIST_HEAD(&lock->cll_layers); > - list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, > - co_lu.lo_linkage) { > + cl_object_for_each(scan, obj) { > result = scan->co_ops->coo_lock_init(env, scan, lock, io); > if (result != 0) { > cl_lock_fini(env, lock); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index f724b2d62df1..43bf1a422635 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -190,16 +190,14 @@ EXPORT_SYMBOL(cl_object_attr_unlock); > int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, > struct cl_attr *attr) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > assert_spin_locked(cl_object_attr_guard(obj)); > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_attr_get) { > - result = obj->co_ops->coo_attr_get(env, obj, attr); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_attr_get) { > + result = o->co_ops->coo_attr_get(env, o, attr); > if (result != 0) { > if (result > 0) > result = 0; > @@ -221,17 +219,15 @@ EXPORT_SYMBOL(cl_object_attr_get); > int cl_object_attr_update(const struct lu_env *env, struct cl_object *obj, > const struct cl_attr *attr, unsigned int v) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > assert_spin_locked(cl_object_attr_guard(obj)); > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_attr_update) { > - result = obj->co_ops->coo_attr_update(env, obj, attr, > - v); > + cl_object_for_each_reverse(o, obj) { > + if (o->co_ops->coo_attr_update) { > + result = o->co_ops->coo_attr_update(env, o, attr, > + v); > if (result != 0) { > if (result > 0) > result = 0; > @@ -254,19 +250,17 @@ EXPORT_SYMBOL(cl_object_attr_update); > int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, > struct ost_lvb *lvb) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_glimpse) { > - result = obj->co_ops->coo_glimpse(env, obj, lvb); > + cl_object_for_each_reverse(o, obj) { > + if (o->co_ops->coo_glimpse) { > + result = o->co_ops->coo_glimpse(env, o, lvb); > if (result != 0) > break; > } > } > - LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), > + LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(obj->co_lu.lo_header), > "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", > lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, > lvb->lvb_ctime, lvb->lvb_blocks); > @@ -280,14 +274,12 @@ EXPORT_SYMBOL(cl_object_glimpse); > int cl_conf_set(const struct lu_env *env, struct cl_object *obj, > const struct cl_object_conf *conf) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_conf_set) { > - result = obj->co_ops->coo_conf_set(env, obj, conf); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_conf_set) { > + result = o->co_ops->coo_conf_set(env, o, conf); > if (result != 0) > break; > } > @@ -301,13 +293,10 @@ EXPORT_SYMBOL(cl_conf_set); > */ > int cl_object_prune(const struct lu_env *env, struct cl_object *obj) > { > - struct lu_object_header *top; > struct cl_object *o; > - int result; > + int result = 0; > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry(o, &top->loh_layers, co_lu.lo_linkage) { > + cl_object_for_each(o, obj) { > if (o->co_ops->coo_prune) { > result = o->co_ops->coo_prune(env, o); > if (result != 0) > @@ -325,14 +314,13 @@ EXPORT_SYMBOL(cl_object_prune); > int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, > struct lov_user_md __user *uarg, size_t size) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result = 0; > > - top = obj->co_lu.lo_header; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_getstripe) { > - result = obj->co_ops->coo_getstripe(env, obj, uarg, > - size); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_getstripe) { > + result = o->co_ops->coo_getstripe(env, o, uarg, > + size); > if (result) > break; > } > @@ -357,14 +345,13 @@ int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj, > struct ll_fiemap_info_key *key, > struct fiemap *fiemap, size_t *buflen) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result = 0; > > - top = obj->co_lu.lo_header; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_fiemap) { > - result = obj->co_ops->coo_fiemap(env, obj, key, fiemap, > - buflen); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_fiemap) { > + result = o->co_ops->coo_fiemap(env, o, key, fiemap, > + buflen); > if (result) > break; > } > @@ -376,11 +363,11 @@ EXPORT_SYMBOL(cl_object_fiemap); > int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, > struct cl_layout *cl) > { > - struct lu_object_header *top = obj->co_lu.lo_header; > + struct cl_object *o; > > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_layout_get) > - return obj->co_ops->coo_layout_get(env, obj, cl); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_layout_get) > + return o->co_ops->coo_layout_get(env, o, cl); > } > > return -EOPNOTSUPP; > @@ -389,12 +376,12 @@ EXPORT_SYMBOL(cl_object_layout_get); > > loff_t cl_object_maxbytes(struct cl_object *obj) > { > - struct lu_object_header *top = obj->co_lu.lo_header; > + struct cl_object *o; > loff_t maxbytes = LLONG_MAX; > > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_maxbytes) > - maxbytes = min_t(loff_t, obj->co_ops->coo_maxbytes(obj), > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_maxbytes) > + maxbytes = min_t(loff_t, o->co_ops->coo_maxbytes(o), > maxbytes); > } > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index 057318deaa4e..7d00a9233a3b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -132,7 +132,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > enum cl_page_type type) > { > struct cl_page *page; > - struct lu_object_header *head; > + struct cl_object *o2; > > page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); > if (page) { > @@ -149,11 +149,10 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > INIT_LIST_HEAD(&page->cp_layers); > INIT_LIST_HEAD(&page->cp_batch); > lu_ref_init(&page->cp_reference); > - head = o->co_lu.lo_header; > - list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { > - if (o->co_ops->coo_page_init) { > - result = o->co_ops->coo_page_init(env, o, page, > - ind); > + cl_object_for_each(o2, o) { > + if (o2->co_ops->coo_page_init) { > + result = o2->co_ops->coo_page_init(env, o2, page, > + ind); > if (result != 0) { > __cl_page_delete(env, page); > cl_page_free(env, page); > -- > 2.14.0.rc0.dirty > > From jsimmons at infradead.org Mon Feb 11 04:22:35 2019 From: jsimmons at infradead.org (James Simmons) Date: Mon, 11 Feb 2019 04:22:35 +0000 (GMT) Subject: [lustre-devel] [PATCH 17/21] lustre: obdclass: result of try_module_get() should not be ignored. In-Reply-To: <154949781334.10620.18347323437724979128.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781334.10620.18347323437724979128.stgit@noble.brown> Message-ID: > If try_module_get() fails, the open must fail. > > In practice this should be impossible, but it is > best to make the code look right. I remembar having discussion with Greg about this approach in libcfs. He though it was racey to do this in general. The discussion was a while ago so I need to dig up the thread. In the end we remove the whole module handling in the xxx_open() and such. > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/class_obd.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index 48d1dabafa65..982d47b6f50e 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -548,8 +548,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > /* opening /dev/obd */ > static int obd_class_open(struct inode *inode, struct file *file) > { > - try_module_get(THIS_MODULE); > - return 0; > + return try_module_get(THIS_MODULE) ? 0 : -ENODEV; > } > > /* closing /dev/obd */ > > > From neilb at suse.com Mon Feb 11 05:01:42 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 16:01:42 +1100 Subject: [lustre-devel] [PATCH 17/21] lustre: obdclass: result of try_module_get() should not be ignored. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781334.10620.18347323437724979128.stgit@noble.brown> Message-ID: <87tvhagbpl.fsf@notabene.neil.brown.name> On Mon, Feb 11 2019, James Simmons wrote: >> If try_module_get() fails, the open must fail. >> >> In practice this should be impossible, but it is >> best to make the code look right. > > I remembar having discussion with Greg about this approach in libcfs. > He though it was racey to do this in general. The discussion was a > while ago so I need to dig up the thread. In the end we remove the > whole module handling in the xxx_open() and such. Yes, you are right. This should just be removed. This is a chardev, and the .owner of a chardev will always have a reference held while the device is open - cdev_get/cdev_put ensure that. We can just get rid of the obd_class_open and obd_class_release. I'll drop this patch and replace it. Thanks, NeilBrown > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/obdclass/class_obd.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c >> index 48d1dabafa65..982d47b6f50e 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c >> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c >> @@ -548,8 +548,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) >> /* opening /dev/obd */ >> static int obd_class_open(struct inode *inode, struct file *file) >> { >> - try_module_get(THIS_MODULE); >> - return 0; >> + return try_module_get(THIS_MODULE) ? 0 : -ENODEV; >> } >> >> /* closing /dev/obd */ >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 11 05:09:58 2019 From: neilb at suse.com (NeilBrown) Date: Mon, 11 Feb 2019 16:09:58 +1100 Subject: [lustre-devel] [PATCH] lustre: don't manage module refs in obd_class_open/close. In-Reply-To: <87tvhagbpl.fsf@notabene.neil.brown.name> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781334.10620.18347323437724979128.stgit@noble.brown> <87tvhagbpl.fsf@notabene.neil.brown.name> Message-ID: <87r2cegbbt.fsf@notabene.neil.brown.name> Core Linux code for managed char-devs ensures that the relevant module is held active which a char-dev is open - see cdev_get() and cdev_put(). So there is no need for lustre/obd_class to manage the module ref count as well. As this is all that obd_class_open and obd_class_close do, those functions can be removed. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 84c077ec0116..b8fc74044fe3 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -544,20 +544,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) return err; } /* class_handle_ioctl */ -/* opening /dev/obd */ -static int obd_class_open(struct inode *inode, struct file *file) -{ - try_module_get(THIS_MODULE); - return 0; -} - -/* closing /dev/obd */ -static int obd_class_release(struct inode *inode, struct file *file) -{ - module_put(THIS_MODULE); - return 0; -} - /* to control /dev/obd */ static long obd_class_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) @@ -575,9 +561,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, /* declare character device */ static const struct file_operations obd_psdev_fops = { .owner = THIS_MODULE, - .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */ - .open = obd_class_open, /* open */ - .release = obd_class_release, /* release */ + .unlocked_ioctl = obd_class_ioctl, }; /* modules setup */ -- 2.14.0.rc0.dirty -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Tue Feb 12 04:17:04 2019 From: jsimmons at infradead.org (James Simmons) Date: Tue, 12 Feb 2019 04:17:04 +0000 (GMT) Subject: [lustre-devel] [PATCH] lustre: don't manage module refs in obd_class_open/close. In-Reply-To: <87r2cegbbt.fsf@notabene.neil.brown.name> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781334.10620.18347323437724979128.stgit@noble.brown> <87tvhagbpl.fsf@notabene.neil.brown.name> <87r2cegbbt.fsf@notabene.neil.brown.name> Message-ID: > Core Linux code for managed char-devs ensures that the relevant > module is held active which a char-dev is open - see cdev_get() > and cdev_put(). > So there is no need for lustre/obd_class to manage the module > ref count as well. > > As this is all that obd_class_open and obd_class_close do, those > functions can be removed. I was planning to do this but didn't get around to it. Thanks. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 +----------------- > 1 file changed, 1 insertion(+), 17 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index 84c077ec0116..b8fc74044fe3 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -544,20 +544,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > return err; > } /* class_handle_ioctl */ > > -/* opening /dev/obd */ > -static int obd_class_open(struct inode *inode, struct file *file) > -{ > - try_module_get(THIS_MODULE); > - return 0; > -} > - > -/* closing /dev/obd */ > -static int obd_class_release(struct inode *inode, struct file *file) > -{ > - module_put(THIS_MODULE); > - return 0; > -} > - > /* to control /dev/obd */ > static long obd_class_ioctl(struct file *filp, unsigned int cmd, > unsigned long arg) > @@ -575,9 +561,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, > /* declare character device */ > static const struct file_operations obd_psdev_fops = { > .owner = THIS_MODULE, > - .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */ > - .open = obd_class_open, /* open */ > - .release = obd_class_release, /* release */ > + .unlocked_ioctl = obd_class_ioctl, > }; > > /* modules setup */ > -- > 2.14.0.rc0.dirty > > From jsimmons at infradead.org Tue Feb 12 05:03:43 2019 From: jsimmons at infradead.org (James Simmons) Date: Tue, 12 Feb 2019 05:03:43 +0000 (GMT) Subject: [lustre-devel] [PATCH 19/21] lustre: obdclass: avoid races in class_register_type() In-Reply-To: <154949781342.10620.11880180011933935219.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781342.10620.11880180011933935219.stgit@noble.brown> Message-ID: > If there are two parallel attempts to register the > same class name, it could get registered twice. > So re-check after allocation to make sure the name is > still unique. > > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/genops.c | 29 +++++++++++++++-------- > 1 file changed, 19 insertions(+), 10 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index 382eaf519a79..a174f538dd0d 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -86,17 +86,23 @@ static void obd_device_free(struct obd_device *obd) > kmem_cache_free(obd_device_cachep, obd); > } > > -static struct obd_type *class_search_type(const char *name) > +static struct obd_type *__class_search_type(const char *name) > { > struct obd_type *type; > > - spin_lock(&obd_types_lock); > list_for_each_entry(type, &obd_types, typ_chain) { This change is fine but we really don't need typ_chain anymore. We have a list of obd_types already due to the power of kobjects!!!! We can do an static struct obd_type *class_search_type(const char *name) { struct kobject *kobj; struct obd_type *type; kobj = kset_find_obj(lustre_kset, name); return "some_mapping from kobj to type" Hmm. This kobj is not embedded in struct obd_types. Might need more surgery to make that work. > - if (strcmp(type->typ_name, name) == 0) { > - spin_unlock(&obd_types_lock); > + if (strcmp(type->typ_name, name) == 0) > return type; > - } > } > + return NULL; > +} > + > +static struct obd_type *class_search_type(const char *name) > +{ > + struct obd_type *type; > + > + spin_lock(&obd_types_lock); > + type = __class_search_type(name); > spin_unlock(&obd_types_lock); > return NULL; > } > @@ -214,19 +220,22 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > if (ldt) { > type->typ_lu = ldt; > rc = lu_device_type_init(ldt); > - if (rc != 0) { > - kobject_put(type->typ_kobj); > + if (rc != 0) > goto failed; > - } > } > > + INIT_LIST_HEAD(&type->typ_chain); > spin_lock(&obd_types_lock); > - list_add(&type->typ_chain, &obd_types); > + if (__class_search_type(name) == NULL) > + list_add(&type->typ_chain, &obd_types); > spin_unlock(&obd_types_lock); > > - return 0; > + if (!list_empty(&type->typ_chain)) > + return 0; > > failed: > + if (!IS_ERR_OR_NULL(type->typ_kobj)) > + kobject_put(type->typ_kobj); > kfree(type->typ_name); > kfree(type->typ_md_ops); > kfree(type->typ_dt_ops); > > > From jsimmons at infradead.org Tue Feb 12 05:19:45 2019 From: jsimmons at infradead.org (James Simmons) Date: Tue, 12 Feb 2019 05:19:45 +0000 (GMT) Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: <87wom7f1le.fsf@notabene.neil.brown.name> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> <87wom7f1le.fsf@notabene.neil.brown.name> Message-ID: > >> cl_env_inc() and cl_env_dec() don't do anything, > >> so discard them. > > > > I don't know about this one. I saw Andreas response as well. > > So this was apart of "LU-744 obdclass: revise stats for cl_object cache" > > In the end it was turned off by default in the OpenSFS branch since it > > made performance take a hit. To enable in OpenSFS branch you have to run > > ./configure --enable-pgstate-track. We have a few like this for Lustre so > > I was going to bring this up. Do we want to remove this work for both the > > upstream client as well as OpenSFS tree or properly implement this by > > making it a Kconfig option when CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is > > enabled? Its just a matter of porting OpenSFS commit > > 5cae09a2409dcd396a1ee7be1eca7d3bbf77365e > > > > What do you think? > > How useful are these stats? > Stats that are never compiled in aren't likely to tell you much :-) > > Has any thought been given to per-cpu stats counting? That seems to be > the preferred approach for high-frequency accounting. > > I think having a CONFIG option to enable expensive consistency checks is > a good idea - developers will enable it when they don't care about > performance. > Having a CONFIG option for expensive performance stats seems... weird. > Who would use it, and how meaningful would the number be? Which per-cpu stats are you talking about? I know perf can do this kind of profiling with performance counters but I don't think you can use those with cl_pages specifically. I know the lustre developers really dislike trace point but this could be one of those cases where it makes sense. > NeilBrown > > > > > >> Signed-off-by: NeilBrown > >> --- > >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- > >> 1 file changed, 15 deletions(-) > >> > >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> index d71a680660da..1e704078664e 100644 > >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> @@ -565,14 +565,6 @@ struct cl_env { > >> void *ce_debug; > >> }; > >> > >> -static void cl_env_inc(enum cache_stats_item item) > >> -{ > >> -} > >> - > >> -static void cl_env_dec(enum cache_stats_item item) > >> -{ > >> -} > >> - > >> static void cl_env_init0(struct cl_env *cle, void *debug) > >> { > >> LASSERT(cle->ce_ref == 0); > >> @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) > >> > >> cle->ce_ref = 1; > >> cle->ce_debug = debug; > >> - cl_env_inc(CS_busy); > >> } > >> > >> static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> if (rc != 0) { > >> kmem_cache_free(cl_env_kmem, cle); > >> env = ERR_PTR(rc); > >> - } else { > >> - cl_env_inc(CS_create); > >> - cl_env_inc(CS_total); > >> } > >> } else { > >> env = ERR_PTR(-ENOMEM); > >> @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> > >> static void cl_env_fini(struct cl_env *cle) > >> { > >> - cl_env_dec(CS_total); > >> lu_context_fini(&cle->ce_lu.le_ctx); > >> lu_context_fini(&cle->ce_ses); > >> kmem_cache_free(cl_env_kmem, cle); > >> @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) > >> if (--cle->ce_ref == 0) { > >> int cpu = get_cpu(); > >> > >> - cl_env_dec(CS_busy); > >> cle->ce_debug = NULL; > >> cl_env_exit(cle); > >> /* > >> @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) > >> cle->ce_ref--; > >> LASSERT(cle->ce_ref == 0); > >> > >> - cl_env_dec(CS_busy); > >> cle->ce_debug = NULL; > >> > >> put_cpu(); > >> > >> > >> > From pfarrell at whamcloud.com Tue Feb 12 13:56:59 2019 From: pfarrell at whamcloud.com (Patrick Farrell) Date: Tue, 12 Feb 2019 13:56:59 +0000 Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> <87wom7f1le.fsf@notabene.neil.brown.name>, Message-ID: If this state tracking has been off for as long as it has (I’ve never come across it before), I feel like it can probably go without a fight. I just don’t think the info provided is particularly important/useful. Trace points or even really just blunter tracing tools can probably get the desired info in a pinch... - Patrick ________________________________ From: lustre-devel on behalf of James Simmons Sent: Monday, February 11, 2019 11:19:45 PM To: NeilBrown Cc: Lustre Development List Subject: Re: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. > >> cl_env_inc() and cl_env_dec() don't do anything, > >> so discard them. > > > > I don't know about this one. I saw Andreas response as well. > > So this was apart of "LU-744 obdclass: revise stats for cl_object cache" > > In the end it was turned off by default in the OpenSFS branch since it > > made performance take a hit. To enable in OpenSFS branch you have to run > > ./configure --enable-pgstate-track. We have a few like this for Lustre so > > I was going to bring this up. Do we want to remove this work for both the > > upstream client as well as OpenSFS tree or properly implement this by > > making it a Kconfig option when CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is > > enabled? Its just a matter of porting OpenSFS commit > > 5cae09a2409dcd396a1ee7be1eca7d3bbf77365e > > > > What do you think? > > How useful are these stats? > Stats that are never compiled in aren't likely to tell you much :-) > > Has any thought been given to per-cpu stats counting? That seems to be > the preferred approach for high-frequency accounting. > > I think having a CONFIG option to enable expensive consistency checks is > a good idea - developers will enable it when they don't care about > performance. > Having a CONFIG option for expensive performance stats seems... weird. > Who would use it, and how meaningful would the number be? Which per-cpu stats are you talking about? I know perf can do this kind of profiling with performance counters but I don't think you can use those with cl_pages specifically. I know the lustre developers really dislike trace point but this could be one of those cases where it makes sense. > NeilBrown > > > > > >> Signed-off-by: NeilBrown > >> --- > >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- > >> 1 file changed, 15 deletions(-) > >> > >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> index d71a680660da..1e704078664e 100644 > >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> @@ -565,14 +565,6 @@ struct cl_env { > >> void *ce_debug; > >> }; > >> > >> -static void cl_env_inc(enum cache_stats_item item) > >> -{ > >> -} > >> - > >> -static void cl_env_dec(enum cache_stats_item item) > >> -{ > >> -} > >> - > >> static void cl_env_init0(struct cl_env *cle, void *debug) > >> { > >> LASSERT(cle->ce_ref == 0); > >> @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) > >> > >> cle->ce_ref = 1; > >> cle->ce_debug = debug; > >> - cl_env_inc(CS_busy); > >> } > >> > >> static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> if (rc != 0) { > >> kmem_cache_free(cl_env_kmem, cle); > >> env = ERR_PTR(rc); > >> - } else { > >> - cl_env_inc(CS_create); > >> - cl_env_inc(CS_total); > >> } > >> } else { > >> env = ERR_PTR(-ENOMEM); > >> @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> > >> static void cl_env_fini(struct cl_env *cle) > >> { > >> - cl_env_dec(CS_total); > >> lu_context_fini(&cle->ce_lu.le_ctx); > >> lu_context_fini(&cle->ce_ses); > >> kmem_cache_free(cl_env_kmem, cle); > >> @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) > >> if (--cle->ce_ref == 0) { > >> int cpu = get_cpu(); > >> > >> - cl_env_dec(CS_busy); > >> cle->ce_debug = NULL; > >> cl_env_exit(cle); > >> /* > >> @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) > >> cle->ce_ref--; > >> LASSERT(cle->ce_ref == 0); > >> > >> - cl_env_dec(CS_busy); > >> cle->ce_debug = NULL; > >> > >> put_cpu(); > >> > >> > >> > _______________________________________________ lustre-devel mailing list lustre-devel at lists.lustre.org http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From neilb at suse.com Tue Feb 12 22:12:11 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 13 Feb 2019 09:12:11 +1100 Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> <87wom7f1le.fsf@notabene.neil.brown.name> Message-ID: <87ftssfyh0.fsf@notabene.neil.brown.name> On Tue, Feb 12 2019, James Simmons wrote: >> >> cl_env_inc() and cl_env_dec() don't do anything, >> >> so discard them. >> > >> > I don't know about this one. I saw Andreas response as well. >> > So this was apart of "LU-744 obdclass: revise stats for cl_object cache" >> > In the end it was turned off by default in the OpenSFS branch since it >> > made performance take a hit. To enable in OpenSFS branch you have to run >> > ./configure --enable-pgstate-track. We have a few like this for Lustre so >> > I was going to bring this up. Do we want to remove this work for both the >> > upstream client as well as OpenSFS tree or properly implement this by >> > making it a Kconfig option when CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is >> > enabled? Its just a matter of porting OpenSFS commit >> > 5cae09a2409dcd396a1ee7be1eca7d3bbf77365e >> > >> > What do you think? >> >> How useful are these stats? >> Stats that are never compiled in aren't likely to tell you much :-) >> >> Has any thought been given to per-cpu stats counting? That seems to be >> the preferred approach for high-frequency accounting. >> >> I think having a CONFIG option to enable expensive consistency checks is >> a good idea - developers will enable it when they don't care about >> performance. >> Having a CONFIG option for expensive performance stats seems... weird. >> Who would use it, and how meaningful would the number be? > > Which per-cpu stats are you talking about? include/linux/percpu_counter.h I guess - or something similar. NeilBrown > I know perf can do this kind of > profiling with performance counters but I don't think you can use those > with cl_pages specifically. I know the lustre developers really dislike > trace point but this could be one of those cases where it makes sense. > >> NeilBrown >> >> >> > >> >> Signed-off-by: NeilBrown >> >> --- >> >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- >> >> 1 file changed, 15 deletions(-) >> >> >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> >> index d71a680660da..1e704078664e 100644 >> >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c >> >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> >> @@ -565,14 +565,6 @@ struct cl_env { >> >> void *ce_debug; >> >> }; >> >> >> >> -static void cl_env_inc(enum cache_stats_item item) >> >> -{ >> >> -} >> >> - >> >> -static void cl_env_dec(enum cache_stats_item item) >> >> -{ >> >> -} >> >> - >> >> static void cl_env_init0(struct cl_env *cle, void *debug) >> >> { >> >> LASSERT(cle->ce_ref == 0); >> >> @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) >> >> >> >> cle->ce_ref = 1; >> >> cle->ce_debug = debug; >> >> - cl_env_inc(CS_busy); >> >> } >> >> >> >> static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> if (rc != 0) { >> >> kmem_cache_free(cl_env_kmem, cle); >> >> env = ERR_PTR(rc); >> >> - } else { >> >> - cl_env_inc(CS_create); >> >> - cl_env_inc(CS_total); >> >> } >> >> } else { >> >> env = ERR_PTR(-ENOMEM); >> >> @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> >> >> static void cl_env_fini(struct cl_env *cle) >> >> { >> >> - cl_env_dec(CS_total); >> >> lu_context_fini(&cle->ce_lu.le_ctx); >> >> lu_context_fini(&cle->ce_ses); >> >> kmem_cache_free(cl_env_kmem, cle); >> >> @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) >> >> if (--cle->ce_ref == 0) { >> >> int cpu = get_cpu(); >> >> >> >> - cl_env_dec(CS_busy); >> >> cle->ce_debug = NULL; >> >> cl_env_exit(cle); >> >> /* >> >> @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) >> >> cle->ce_ref--; >> >> LASSERT(cle->ce_ref == 0); >> >> >> >> - cl_env_dec(CS_busy); >> >> cle->ce_debug = NULL; >> >> >> >> put_cpu(); >> >> >> >> >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Wed Feb 13 00:19:41 2019 From: jsimmons at infradead.org (James Simmons) Date: Wed, 13 Feb 2019 00:19:41 +0000 (GMT) Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: <87ftssfyh0.fsf@notabene.neil.brown.name> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> <87wom7f1le.fsf@notabene.neil.brown.name> <87ftssfyh0.fsf@notabene.neil.brown.name> Message-ID: > >> >> cl_env_inc() and cl_env_dec() don't do anything, > >> >> so discard them. > >> > > >> > I don't know about this one. I saw Andreas response as well. > >> > So this was apart of "LU-744 obdclass: revise stats for cl_object cache" > >> > In the end it was turned off by default in the OpenSFS branch since it > >> > made performance take a hit. To enable in OpenSFS branch you have to run > >> > ./configure --enable-pgstate-track. We have a few like this for Lustre so > >> > I was going to bring this up. Do we want to remove this work for both the > >> > upstream client as well as OpenSFS tree or properly implement this by > >> > making it a Kconfig option when CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is > >> > enabled? Its just a matter of porting OpenSFS commit > >> > 5cae09a2409dcd396a1ee7be1eca7d3bbf77365e > >> > > >> > What do you think? > >> > >> How useful are these stats? > >> Stats that are never compiled in aren't likely to tell you much :-) > >> > >> Has any thought been given to per-cpu stats counting? That seems to be > >> the preferred approach for high-frequency accounting. > >> > >> I think having a CONFIG option to enable expensive consistency checks is > >> a good idea - developers will enable it when they don't care about > >> performance. > >> Having a CONFIG option for expensive performance stats seems... weird. > >> Who would use it, and how meaningful would the number be? > > > > Which per-cpu stats are you talking about? > > include/linux/percpu_counter.h I guess - or something similar. Ouch 4K per counter. This would crush our clients. Does this scale well? I also looked at the page counter which also atomic counting orientated. I expect that too also to struggle. The page counter don't match as well as what these cl_page stats monitor. > > I know perf can do this kind of > > profiling with performance counters but I don't think you can use those > > with cl_pages specifically. I know the lustre developers really dislike > > trace point but this could be one of those cases where it makes sense. > > > >> NeilBrown > >> > >> > >> > > >> >> Signed-off-by: NeilBrown > >> >> --- > >> >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- > >> >> 1 file changed, 15 deletions(-) > >> >> > >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> >> index d71a680660da..1e704078664e 100644 > >> >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > >> >> @@ -565,14 +565,6 @@ struct cl_env { > >> >> void *ce_debug; > >> >> }; > >> >> > >> >> -static void cl_env_inc(enum cache_stats_item item) > >> >> -{ > >> >> -} > >> >> - > >> >> -static void cl_env_dec(enum cache_stats_item item) > >> >> -{ > >> >> -} > >> >> - > >> >> static void cl_env_init0(struct cl_env *cle, void *debug) > >> >> { > >> >> LASSERT(cle->ce_ref == 0); > >> >> @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) > >> >> > >> >> cle->ce_ref = 1; > >> >> cle->ce_debug = debug; > >> >> - cl_env_inc(CS_busy); > >> >> } > >> >> > >> >> static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> >> @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> >> if (rc != 0) { > >> >> kmem_cache_free(cl_env_kmem, cle); > >> >> env = ERR_PTR(rc); > >> >> - } else { > >> >> - cl_env_inc(CS_create); > >> >> - cl_env_inc(CS_total); > >> >> } > >> >> } else { > >> >> env = ERR_PTR(-ENOMEM); > >> >> @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) > >> >> > >> >> static void cl_env_fini(struct cl_env *cle) > >> >> { > >> >> - cl_env_dec(CS_total); > >> >> lu_context_fini(&cle->ce_lu.le_ctx); > >> >> lu_context_fini(&cle->ce_ses); > >> >> kmem_cache_free(cl_env_kmem, cle); > >> >> @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) > >> >> if (--cle->ce_ref == 0) { > >> >> int cpu = get_cpu(); > >> >> > >> >> - cl_env_dec(CS_busy); > >> >> cle->ce_debug = NULL; > >> >> cl_env_exit(cle); > >> >> /* > >> >> @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) > >> >> cle->ce_ref--; > >> >> LASSERT(cle->ce_ref == 0); > >> >> > >> >> - cl_env_dec(CS_busy); > >> >> cle->ce_debug = NULL; > >> >> > >> >> put_cpu(); > >> >> > >> >> > >> >> > >> > From neilb at suse.com Wed Feb 13 00:29:59 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 13 Feb 2019 11:29:59 +1100 Subject: [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging. In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781313.10620.6363156783936746853.stgit@noble.brown> <87wom7f1le.fsf@notabene.neil.brown.name> <87ftssfyh0.fsf@notabene.neil.brown.name> Message-ID: <877ee4fs3c.fsf@notabene.neil.brown.name> On Wed, Feb 13 2019, James Simmons wrote: >> >> >> cl_env_inc() and cl_env_dec() don't do anything, >> >> >> so discard them. >> >> > >> >> > I don't know about this one. I saw Andreas response as well. >> >> > So this was apart of "LU-744 obdclass: revise stats for cl_object cache" >> >> > In the end it was turned off by default in the OpenSFS branch since it >> >> > made performance take a hit. To enable in OpenSFS branch you have to run >> >> > ./configure --enable-pgstate-track. We have a few like this for Lustre so >> >> > I was going to bring this up. Do we want to remove this work for both the >> >> > upstream client as well as OpenSFS tree or properly implement this by >> >> > making it a Kconfig option when CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is >> >> > enabled? Its just a matter of porting OpenSFS commit >> >> > 5cae09a2409dcd396a1ee7be1eca7d3bbf77365e >> >> > >> >> > What do you think? >> >> >> >> How useful are these stats? >> >> Stats that are never compiled in aren't likely to tell you much :-) >> >> >> >> Has any thought been given to per-cpu stats counting? That seems to be >> >> the preferred approach for high-frequency accounting. >> >> >> >> I think having a CONFIG option to enable expensive consistency checks is >> >> a good idea - developers will enable it when they don't care about >> >> performance. >> >> Having a CONFIG option for expensive performance stats seems... weird. >> >> Who would use it, and how meaningful would the number be? >> > >> > Which per-cpu stats are you talking about? >> >> include/linux/percpu_counter.h I guess - or something similar. > > Ouch 4K per counter. This would crush our clients. Does this scale well? > I also looked at the page counter which also atomic counting orientated. > I expect that too also to struggle. The page counter don't match as well > as what these cl_page stats monitor. Why? How many counters are there? enum cl_page_state defines 5 per "site". enum cache_stats_item defines 5, which think are global. That makes 4, to order of 16K. That isn't all that much. NeilBrown > >> > I know perf can do this kind of >> > profiling with performance counters but I don't think you can use those >> > with cl_pages specifically. I know the lustre developers really dislike >> > trace point but this could be one of those cases where it makes sense. >> > >> >> NeilBrown >> >> >> >> >> >> > >> >> >> Signed-off-by: NeilBrown >> >> >> --- >> >> >> drivers/staging/lustre/lustre/obdclass/cl_object.c | 15 --------------- >> >> >> 1 file changed, 15 deletions(-) >> >> >> >> >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> >> >> index d71a680660da..1e704078664e 100644 >> >> >> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c >> >> >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c >> >> >> @@ -565,14 +565,6 @@ struct cl_env { >> >> >> void *ce_debug; >> >> >> }; >> >> >> >> >> >> -static void cl_env_inc(enum cache_stats_item item) >> >> >> -{ >> >> >> -} >> >> >> - >> >> >> -static void cl_env_dec(enum cache_stats_item item) >> >> >> -{ >> >> >> -} >> >> >> - >> >> >> static void cl_env_init0(struct cl_env *cle, void *debug) >> >> >> { >> >> >> LASSERT(cle->ce_ref == 0); >> >> >> @@ -581,7 +573,6 @@ static void cl_env_init0(struct cl_env *cle, void *debug) >> >> >> >> >> >> cle->ce_ref = 1; >> >> >> cle->ce_debug = debug; >> >> >> - cl_env_inc(CS_busy); >> >> >> } >> >> >> >> >> >> static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> >> @@ -611,9 +602,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> >> if (rc != 0) { >> >> >> kmem_cache_free(cl_env_kmem, cle); >> >> >> env = ERR_PTR(rc); >> >> >> - } else { >> >> >> - cl_env_inc(CS_create); >> >> >> - cl_env_inc(CS_total); >> >> >> } >> >> >> } else { >> >> >> env = ERR_PTR(-ENOMEM); >> >> >> @@ -623,7 +611,6 @@ static struct lu_env *cl_env_new(u32 ctx_tags, u32 ses_tags, void *debug) >> >> >> >> >> >> static void cl_env_fini(struct cl_env *cle) >> >> >> { >> >> >> - cl_env_dec(CS_total); >> >> >> lu_context_fini(&cle->ce_lu.le_ctx); >> >> >> lu_context_fini(&cle->ce_ses); >> >> >> kmem_cache_free(cl_env_kmem, cle); >> >> >> @@ -782,7 +769,6 @@ void cl_env_put(struct lu_env *env, u16 *refcheck) >> >> >> if (--cle->ce_ref == 0) { >> >> >> int cpu = get_cpu(); >> >> >> >> >> >> - cl_env_dec(CS_busy); >> >> >> cle->ce_debug = NULL; >> >> >> cl_env_exit(cle); >> >> >> /* >> >> >> @@ -903,7 +889,6 @@ void cl_env_percpu_put(struct lu_env *env) >> >> >> cle->ce_ref--; >> >> >> LASSERT(cle->ce_ref == 0); >> >> >> >> >> >> - cl_env_dec(CS_busy); >> >> >> cle->ce_debug = NULL; >> >> >> >> >> >> put_cpu(); >> >> >> >> >> >> >> >> >> >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Wed Feb 13 01:53:59 2019 From: jsimmons at infradead.org (James Simmons) Date: Wed, 13 Feb 2019 01:53:59 +0000 (GMT) Subject: [lustre-devel] [PATCH 20/21] lustre: obdclass: fix module load locking. In-Reply-To: <154949781345.10620.8278067573811049130.stgit@noble.brown> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781345.10620.8278067573811049130.stgit@noble.brown> Message-ID: > Safe module loading requires that we try_module_get() in a context > where the module cannot be unloaded, typically prodected by > a spinlock that module-unload has to take. > This doesn't currently happen in class_get_type(). > > There is a per-type spinlock, but it is almost entirely unused, and > cannot be used to protect the module from being unloaded. > > So discard ->obd_type_lock, and ensure that __class_search_type() and > try_module_get() are both called while obd_types_lock is held - this > prevent class_unregister_type() from completing (so the 'type' won't get > freed. That is always called from a module-unload function - if it > has got that far, try_module_get() will fail. > > So also check the return status of try_module_get(). Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/obd.h | 1 - > drivers/staging/lustre/lustre/obdclass/genops.c | 24 ++++++++++++++--------- > 2 files changed, 15 insertions(+), 10 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index 171d2c214be6..463ab680b524 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -106,7 +106,6 @@ struct obd_type { > char *typ_name; > int typ_refcnt; > struct lu_device_type *typ_lu; > - spinlock_t obd_type_lock; > struct kobject *typ_kobj; > }; > > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index a174f538dd0d..dad21d9fa328 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -109,35 +109,42 @@ static struct obd_type *class_search_type(const char *name) > > static struct obd_type *class_get_type(const char *name) > { > - struct obd_type *type = class_search_type(name); > + struct obd_type *type; > + > + spin_lock(&obd_types_lock); > + type = __class_search_type(name); > > if (!type) { > const char *modname = name; > > + spin_unlock(&obd_types_lock); > if (!request_module("%s", modname)) { > CDEBUG(D_INFO, "Loaded module '%s'\n", modname); > - type = class_search_type(name); > } else { > LCONSOLE_ERROR_MSG(0x158, "Can't load module '%s'\n", > modname); > } > + spin_lock(&obd_types_lock); > + type = __class_search_type(name); > } > if (type) { > - spin_lock(&type->obd_type_lock); > - type->typ_refcnt++; > - try_module_get(type->typ_dt_ops->owner); > - spin_unlock(&type->obd_type_lock); > + if (try_module_get(type->typ_dt_ops->owner)) > + type->typ_refcnt++; > + else > + type = NULL; > } > + spin_unlock(&obd_types_lock); > return type; > } > > void class_put_type(struct obd_type *type) > { > LASSERT(type); > - spin_lock(&type->obd_type_lock); > + spin_lock(&obd_types_lock); > + LASSERT(type->typ_refcnt > 0); > type->typ_refcnt--; > module_put(type->typ_dt_ops->owner); > - spin_unlock(&type->obd_type_lock); > + spin_unlock(&obd_types_lock); > } > > static void class_sysfs_release(struct kobject *kobj) > @@ -206,7 +213,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > if (md_ops) > *type->typ_md_ops = *md_ops; > strcpy(type->typ_name, name); > - spin_lock_init(&type->obd_type_lock); > > type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, > debugfs_lustre_root); > > > From neilb at suse.com Thu Feb 14 03:43:52 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 14 Feb 2019 14:43:52 +1100 Subject: [lustre-devel] [PATCH 19/21] lustre: obdclass: avoid races in class_register_type() In-Reply-To: References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781342.10620.11880180011933935219.stgit@noble.brown> Message-ID: <87y36jdog7.fsf@notabene.neil.brown.name> On Tue, Feb 12 2019, James Simmons wrote: >> If there are two parallel attempts to register the >> same class name, it could get registered twice. >> So re-check after allocation to make sure the name is >> still unique. >> >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/obdclass/genops.c | 29 +++++++++++++++-------- >> 1 file changed, 19 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c >> index 382eaf519a79..a174f538dd0d 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/genops.c >> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c >> @@ -86,17 +86,23 @@ static void obd_device_free(struct obd_device *obd) >> kmem_cache_free(obd_device_cachep, obd); >> } >> >> -static struct obd_type *class_search_type(const char *name) >> +static struct obd_type *__class_search_type(const char *name) >> { >> struct obd_type *type; >> >> - spin_lock(&obd_types_lock); >> list_for_each_entry(type, &obd_types, typ_chain) { > > This change is fine but we really don't need typ_chain anymore. > We have a list of obd_types already due to the power of kobjects!!!! > > We can do an > > static struct obd_type *class_search_type(const char *name) > { > struct kobject *kobj; > struct obd_type *type; > > kobj = kset_find_obj(lustre_kset, name); > > return "some_mapping from kobj to type" > > Hmm. This kobj is not embedded in struct obd_types. Might need more > surgery to make that work. > Well.... that was a fun rabbit-hole to fall down. I now have 8 patches where before I had two - definitely a better result. typ_chain and several other fields are gone. I'll post them in my next series which will probably go out tomorrow. Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From adilger at whamcloud.com Fri Feb 15 18:15:08 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 15 Feb 2019 18:15:08 +0000 Subject: [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate In-Reply-To: <87pnrzgnp5.fsf@notabene.neil.brown.name> References: <154949776249.10620.1215070753973826063.stgit@noble.brown> <154949781310.10620.8883358407999258821.stgit@noble.brown> <87pnrzgnp5.fsf@notabene.neil.brown.name> Message-ID: <78025893-9DAF-46C1-A407-D979BA5D2057@whamcloud.com> On Feb 10, 2019, at 17:42, NeilBrown wrote: > From: NeilBrown > Subject: [PATCH] lustre: obdclass: use cl_object_for_each where appropriate > > There are various places which have a list_for_each_entry() > where cl_object_for_each (or .._reverse) is more appropriate. > > Several of these re-use the 'obj' function parameter as a loop > iterator, which is a little confusing. > > Change these to use cl_object_for_each{_reverse}, and where needed, > introduce a new iterator variable 'o'. > > To further clean up these function, move initializtion of 'result' > to the variable declaration. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/lustre/lov/lov_page.c | 3 +- > drivers/staging/lustre/lustre/obdclass/cl_lock.c | 3 +- > drivers/staging/lustre/lustre/obdclass/cl_object.c | 97 ++++++++++------------ > drivers/staging/lustre/lustre/obdclass/cl_page.c | 11 ++- > 4 files changed, 49 insertions(+), 65 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c > index 08485a95ec01..e64b350601d2 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_page.c > +++ b/drivers/staging/lustre/lustre/lov/lov_page.c > @@ -103,8 +103,7 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj, > return PTR_ERR(sub); > > subobj = lovsub2cl(r0->lo_sub[stripe]); > - list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers, > - co_lu.lo_linkage) { > + cl_object_for_each(o, subobj) { > if (o->co_ops->coo_page_init) { > rc = o->co_ops->coo_page_init(sub->sub_env, o, page, > cl_index(subobj, suboff)); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > index 8133d992cc73..fc5976d8b37b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c > @@ -103,8 +103,7 @@ int cl_lock_init(const struct lu_env *env, struct cl_lock *lock, > LASSERT(obj); > > INIT_LIST_HEAD(&lock->cll_layers); > - list_for_each_entry(scan, &obj->co_lu.lo_header->loh_layers, > - co_lu.lo_linkage) { > + cl_object_for_each(scan, obj) { > result = scan->co_ops->coo_lock_init(env, scan, lock, io); > if (result != 0) { > cl_lock_fini(env, lock); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index f724b2d62df1..43bf1a422635 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -190,16 +190,14 @@ EXPORT_SYMBOL(cl_object_attr_unlock); > int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, > struct cl_attr *attr) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > assert_spin_locked(cl_object_attr_guard(obj)); > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_attr_get) { > - result = obj->co_ops->coo_attr_get(env, obj, attr); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_attr_get) { > + result = o->co_ops->coo_attr_get(env, o, attr); > if (result != 0) { > if (result > 0) > result = 0; > @@ -221,17 +219,15 @@ EXPORT_SYMBOL(cl_object_attr_get); > int cl_object_attr_update(const struct lu_env *env, struct cl_object *obj, > const struct cl_attr *attr, unsigned int v) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > assert_spin_locked(cl_object_attr_guard(obj)); > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_attr_update) { > - result = obj->co_ops->coo_attr_update(env, obj, attr, > - v); > + cl_object_for_each_reverse(o, obj) { > + if (o->co_ops->coo_attr_update) { > + result = o->co_ops->coo_attr_update(env, o, attr, > + v); > if (result != 0) { > if (result > 0) > result = 0; > @@ -254,19 +250,17 @@ EXPORT_SYMBOL(cl_object_attr_update); > int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, > struct ost_lvb *lvb) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry_reverse(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_glimpse) { > - result = obj->co_ops->coo_glimpse(env, obj, lvb); > + cl_object_for_each_reverse(o, obj) { > + if (o->co_ops->coo_glimpse) { > + result = o->co_ops->coo_glimpse(env, o, lvb); > if (result != 0) > break; > } > } > - LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(top), > + LU_OBJECT_HEADER(D_DLMTRACE, env, lu_object_top(obj->co_lu.lo_header), > "size: %llu mtime: %llu atime: %llu ctime: %llu blocks: %llu\n", > lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, > lvb->lvb_ctime, lvb->lvb_blocks); > @@ -280,14 +274,12 @@ EXPORT_SYMBOL(cl_object_glimpse); > int cl_conf_set(const struct lu_env *env, struct cl_object *obj, > const struct cl_object_conf *conf) > { > - struct lu_object_header *top; > - int result; > + struct cl_object *o; > + int result = 0; > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_conf_set) { > - result = obj->co_ops->coo_conf_set(env, obj, conf); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_conf_set) { > + result = o->co_ops->coo_conf_set(env, o, conf); > if (result != 0) > break; > } > @@ -301,13 +293,10 @@ EXPORT_SYMBOL(cl_conf_set); > */ > int cl_object_prune(const struct lu_env *env, struct cl_object *obj) > { > - struct lu_object_header *top; > struct cl_object *o; > - int result; > + int result = 0; > > - top = obj->co_lu.lo_header; > - result = 0; > - list_for_each_entry(o, &top->loh_layers, co_lu.lo_linkage) { > + cl_object_for_each(o, obj) { > if (o->co_ops->coo_prune) { > result = o->co_ops->coo_prune(env, o); > if (result != 0) > @@ -325,14 +314,13 @@ EXPORT_SYMBOL(cl_object_prune); > int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, > struct lov_user_md __user *uarg, size_t size) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result = 0; > > - top = obj->co_lu.lo_header; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_getstripe) { > - result = obj->co_ops->coo_getstripe(env, obj, uarg, > - size); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_getstripe) { > + result = o->co_ops->coo_getstripe(env, o, uarg, > + size); > if (result) > break; > } > @@ -357,14 +345,13 @@ int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj, > struct ll_fiemap_info_key *key, > struct fiemap *fiemap, size_t *buflen) > { > - struct lu_object_header *top; > + struct cl_object *o; > int result = 0; > > - top = obj->co_lu.lo_header; > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_fiemap) { > - result = obj->co_ops->coo_fiemap(env, obj, key, fiemap, > - buflen); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_fiemap) { > + result = o->co_ops->coo_fiemap(env, o, key, fiemap, > + buflen); > if (result) > break; > } > @@ -376,11 +363,11 @@ EXPORT_SYMBOL(cl_object_fiemap); > int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj, > struct cl_layout *cl) > { > - struct lu_object_header *top = obj->co_lu.lo_header; > + struct cl_object *o; > > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_layout_get) > - return obj->co_ops->coo_layout_get(env, obj, cl); > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_layout_get) > + return o->co_ops->coo_layout_get(env, o, cl); > } > > return -EOPNOTSUPP; > @@ -389,12 +376,12 @@ EXPORT_SYMBOL(cl_object_layout_get); > > loff_t cl_object_maxbytes(struct cl_object *obj) > { > - struct lu_object_header *top = obj->co_lu.lo_header; > + struct cl_object *o; > loff_t maxbytes = LLONG_MAX; > > - list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { > - if (obj->co_ops->coo_maxbytes) > - maxbytes = min_t(loff_t, obj->co_ops->coo_maxbytes(obj), > + cl_object_for_each(o, obj) { > + if (o->co_ops->coo_maxbytes) > + maxbytes = min_t(loff_t, o->co_ops->coo_maxbytes(o), > maxbytes); > } > > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index 057318deaa4e..7d00a9233a3b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -132,7 +132,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > enum cl_page_type type) > { > struct cl_page *page; > - struct lu_object_header *head; > + struct cl_object *o2; > > page = kzalloc(cl_object_header(o)->coh_page_bufsize, GFP_NOFS); > if (page) { > @@ -149,11 +149,10 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > INIT_LIST_HEAD(&page->cp_layers); > INIT_LIST_HEAD(&page->cp_batch); > lu_ref_init(&page->cp_reference); > - head = o->co_lu.lo_header; > - list_for_each_entry(o, &head->loh_layers, co_lu.lo_linkage) { > - if (o->co_ops->coo_page_init) { > - result = o->co_ops->coo_page_init(env, o, page, > - ind); > + cl_object_for_each(o2, o) { > + if (o2->co_ops->coo_page_init) { > + result = o2->co_ops->coo_page_init(env, o2, page, > + ind); > if (result != 0) { > __cl_page_delete(env, page); > cl_page_free(env, page); > -- > 2.14.0.rc0.dirty Cheers, Andreas --- Andreas Dilger CTO Whamcloud From neilb at suse.com Tue Feb 19 00:09:04 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:04 +1100 Subject: [lustre-devel] [PATCH 00/37] More lustre patches from obdclass Message-ID: <155053473693.24125.6976971762921761309.stgit@noble.brown> These patches are all a result of my reading of obdclass code, though some of them extend will beyond obdclass. One has been posted already but was buggy, another few replace an earlier patch which, as James pointed out, didn't really go far enough. I've done some testing (and found a bug) but haven't completed a full test run yet. So both comments and testing most welcome. NeilBrown --- NeilBrown (37): lustre: obdclass: char obd_ioctl_getdata type. lustre: llite: don't use class_setup_tunables() lustre: embed typ_kobj if obd_type lustre: collect all resource releasing for obj_type. lustre: obd_type: use typ_kobj.name as typ_name lustre: obd_type: discard obd_types linked list. lustre: obd_type: discard obd_type_lock lustre: obdclass: don't copy ops structures in to new type. lustre: obdclass: fix module load locking. lustre: kernelcomm: pass correct gfp_t to kmalloc. lustre: kernelcomm: make libcfs_kkuc_msg_put static. lustre: remove unused function in linkea. lustre: llog: remove lgh_hdr_lock. lustre: llog: change lgh_refcount to struct kref. lustre: llog_obd: Convert loc_refcount to refcount_t lustre: obdclass: typo: Banlance -> Balance lustre: simplify lprocfs_read_frac_helper. lustre: obdclass: discard lprocfs_single/seq_release lustre: discard lprocfs_strnstr() lustre: convert rsi_sem to a spinlock. lustre: remove several MAX_STRING_SIZE defines. lustre: lprocfs: use log2.h macros instead of shift loop. lustre: prefer to use tabs for alignment. lustre: lu_object: remove extra newline from debug printing. lustre: deprecate libcfs_debug_vmsg2 lustre: remove libcfs_debug_vmsg2 lustre: discard lu_ref lustre: remove scope and source from class_incref and class_decref. lustre: handles: discard h_owner in favour of h_ops lustre: handle: move refcount into the lustre_handle. lustre: discard OBD_FREE_RCU lustre: portals_handle: rename ops to owner lustre: portals_handle: remove locking from class_handle2object() lustre: portals_handle: use hlist for hash lists. lustre: portals_handle: discard h_lock. lustre: remove unused fields from struct obd_device lustre: obd_sysfs: error-check value stored in jobid_var .../lustre/include/linux/libcfs/libcfs_cpu.h | 2 .../lustre/include/linux/libcfs/libcfs_crypto.h | 10 - .../lustre/include/linux/libcfs/libcfs_debug.h | 35 +- .../lustre/include/linux/libcfs/libcfs_fail.h | 12 - .../lustre/include/linux/libcfs/libcfs_hash.h | 24 + .../lustre/include/linux/libcfs/libcfs_private.h | 2 .../staging/lustre/include/linux/lnet/lib-lnet.h | 4 .../staging/lustre/include/linux/lnet/socklnd.h | 2 .../lustre/include/uapi/linux/lnet/libcfs_debug.h | 124 +++---- .../lustre/include/uapi/linux/lnet/libcfs_ioctl.h | 56 +-- .../lustre/include/uapi/linux/lnet/lnet-types.h | 10 - .../lustre/include/uapi/linux/lnet/lnetst.h | 14 - .../lustre/include/uapi/linux/lnet/nidstr.h | 6 .../include/uapi/linux/lustre/lustre_fiemap.h | 2 .../lustre/include/uapi/linux/lustre/lustre_idl.h | 350 +++++++++---------- .../lustre/include/uapi/linux/lustre/lustre_user.h | 378 ++++++++++---------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 60 ++- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 32 +- drivers/staging/lustre/lnet/libcfs/tracefile.c | 63 +-- drivers/staging/lustre/lnet/libcfs/tracefile.h | 2 drivers/staging/lustre/lnet/lnet/nidstrings.c | 4 drivers/staging/lustre/lnet/selftest/timer.c | 8 drivers/staging/lustre/lustre/fld/lproc_fld.c | 2 drivers/staging/lustre/lustre/include/cl_object.h | 6 .../staging/lustre/lustre/include/lprocfs_status.h | 7 drivers/staging/lustre/lustre/include/lu_object.h | 45 -- drivers/staging/lustre/lustre/include/lu_ref.h | 178 --------- drivers/staging/lustre/lustre/include/lustre_dlm.h | 26 - .../staging/lustre/lustre/include/lustre_export.h | 1 .../staging/lustre/lustre/include/lustre_handles.h | 22 - .../staging/lustre/lustre/include/lustre_import.h | 8 .../lustre/lustre/include/lustre_kernelcomm.h | 1 .../staging/lustre/lustre/include/lustre_linkea.h | 8 drivers/staging/lustre/lustre/include/lustre_log.h | 21 - drivers/staging/lustre/lustre/include/lustre_net.h | 4 drivers/staging/lustre/lustre/include/obd.h | 62 +-- drivers/staging/lustre/lustre/include/obd_class.h | 18 - .../staging/lustre/lustre/include/obd_support.h | 10 - drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 252 ++++++------- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 12 - drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 12 - drivers/staging/lustre/lustre/llite/dir.c | 18 - drivers/staging/lustre/lustre/llite/file.c | 2 drivers/staging/lustre/lustre/llite/lcommon_cl.c | 2 drivers/staging/lustre/lustre/llite/llite_lib.c | 20 - drivers/staging/lustre/lustre/llite/lproc_llite.c | 10 - drivers/staging/lustre/lustre/llite/rw.c | 6 drivers/staging/lustre/lustre/llite/rw26.c | 6 drivers/staging/lustre/lustre/llite/vvp_dev.c | 20 - drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 drivers/staging/lustre/lustre/llite/vvp_io.c | 5 drivers/staging/lustre/lustre/llite/xattr.c | 2 drivers/staging/lustre/lustre/lmv/lmv_obd.c | 6 drivers/staging/lustre/lustre/lov/lov_ea.c | 2 drivers/staging/lustre/lustre/lov/lov_obd.c | 43 +- drivers/staging/lustre/lustre/lov/lov_object.c | 2 drivers/staging/lustre/lustre/lov/lovsub_dev.c | 1 drivers/staging/lustre/lustre/lov/lproc_lov.c | 2 drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 drivers/staging/lustre/lustre/mdc/mdc_request.c | 6 drivers/staging/lustre/lustre/mgc/mgc_request.c | 32 +- drivers/staging/lustre/lustre/obdclass/Makefile | 2 drivers/staging/lustre/lustre/obdclass/cl_io.c | 8 drivers/staging/lustre/lustre/obdclass/cl_object.c | 2 drivers/staging/lustre/lustre/obdclass/cl_page.c | 5 drivers/staging/lustre/lustre/obdclass/class_obd.c | 19 - drivers/staging/lustre/lustre/obdclass/genops.c | 258 ++++++-------- .../staging/lustre/lustre/obdclass/kernelcomm.c | 5 drivers/staging/lustre/lustre/obdclass/linkea.c | 150 -------- drivers/staging/lustre/lustre/obdclass/llog.c | 17 - drivers/staging/lustre/lustre/obdclass/llog_obd.c | 14 - .../lustre/lustre/obdclass/lprocfs_status.c | 102 +---- drivers/staging/lustre/lustre/obdclass/lu_object.c | 46 +- drivers/staging/lustre/lustre/obdclass/lu_ref.c | 45 -- .../lustre/lustre/obdclass/lustre_handles.c | 59 +-- .../staging/lustre/lustre/obdclass/obd_config.c | 20 - drivers/staging/lustre/lustre/obdclass/obd_sysfs.c | 27 + .../staging/lustre/lustre/obdecho/echo_client.c | 4 drivers/staging/lustre/lustre/osc/osc_cache.c | 12 - drivers/staging/lustre/lustre/osc/osc_lock.c | 2 drivers/staging/lustre/lustre/osc/osc_page.c | 2 drivers/staging/lustre/lustre/osc/osc_request.c | 44 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 2 .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 .../staging/lustre/lustre/ptlrpc/pack_generic.c | 42 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 88 files changed, 1077 insertions(+), 1904 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/include/lu_ref.h delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ref.c -- Signature From neilb at suse.com Tue Feb 19 00:09:04 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:04 +1100 Subject: [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494481.24125.17153359714439231322.stgit@noble.brown> Instead of having obd_ioctl_getdata() return the allocated data as a "char *", return it as it really is, struct obd_ioctl_data * This avoids the need for extra variables and casts. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd_class.h | 3 ++- drivers/staging/lustre/lustre/llite/dir.c | 18 ++++++------------ drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +++----- drivers/staging/lustre/lustre/lov/lov_obd.c | 15 ++++++--------- drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 ++++++++---------- 5 files changed, 25 insertions(+), 37 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 30b3e2c69f83..32d4ab6e78a0 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1697,6 +1697,7 @@ struct root_squash_info { }; /* linux-module.c */ -int obd_ioctl_getdata(char **buf, int *len, void __user *arg); +struct obd_ioctl_data; +int obd_ioctl_getdata(struct obd_ioctl_data **data, int *len, void __user *arg); #endif /* __LINUX_OBD_CLASS_H */ diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index fd1af4a5cdad..17bb6185ba87 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1130,13 +1130,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } case IOC_MDC_LOOKUP: { int namelen, len = 0; - char *buf = NULL; char *filename; - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); if (rc) return rc; - data = (void *)buf; filename = data->ioc_inlbuf1; namelen = strlen(filename); @@ -1155,12 +1153,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) goto out_free; } out_free: - kvfree(buf); + kvfree(data); return rc; } case LL_IOC_LMV_SETSTRIPE: { struct lmv_user_md *lum; - char *buf = NULL; char *filename; int namelen = 0; int lumlen = 0; @@ -1168,11 +1165,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) int len; int rc; - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); if (rc) return rc; - data = (void *)buf; if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0) { rc = -EINVAL; @@ -1205,7 +1201,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) #endif rc = ll_dir_setdirstripe(dentry, lum, filename, mode); lmv_out_free: - kvfree(buf); + kvfree(data); return rc; } case LL_IOC_LMV_SET_DEFAULT_STRIPE: { @@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return rc; } case LL_IOC_MIGRATE: { - char *buf = NULL; const char *filename; int namelen = 0; int len; int rc; int mdtidx; - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); if (rc < 0) return rc; - data = (struct obd_ioctl_data *)buf; if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || !data->ioc_inllen1 || !data->ioc_inllen2) { rc = -EINVAL; @@ -1684,7 +1678,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1); migrate_free: - kvfree(buf); + kvfree(data); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 8e09fdd7a96e..e2417cd5aaed 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2295,7 +2295,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) { struct ll_sb_info *sbi = NULL; struct obd_export *exp; - char *buf = NULL; struct obd_ioctl_data *data = NULL; u32 type; int len = 0, rc; @@ -2311,11 +2310,10 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) goto out_statfs; } - rc = obd_ioctl_getdata(&buf, &len, arg); + rc = obd_ioctl_getdata(&data, &len, arg); if (rc) goto out_statfs; - data = (void *)buf; if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || !data->ioc_pbuf1 || !data->ioc_pbuf2) { rc = -EINVAL; @@ -2340,11 +2338,11 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) goto out_statfs; } - rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL); + rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, data, NULL); if (rc) goto out_statfs; out_statfs: - kvfree(buf); + kvfree(data); return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 04d0a9ed1d05..fd769c39b482 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1039,27 +1039,24 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, case OBD_IOC_LOV_GET_CONFIG: { struct obd_ioctl_data *data; struct lov_desc *desc; - char *buf = NULL; u32 *genp; len = 0; - if (obd_ioctl_getdata(&buf, &len, uarg)) + if (obd_ioctl_getdata(&data, &len, uarg)) return -EINVAL; - data = (struct obd_ioctl_data *)buf; - if (sizeof(*desc) > data->ioc_inllen1) { - kvfree(buf); + kvfree(data); return -EINVAL; } if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { - kvfree(buf); + kvfree(data); return -EINVAL; } if (sizeof(u32) * count > data->ioc_inllen3) { - kvfree(buf); + kvfree(data); return -EINVAL; } @@ -1076,9 +1073,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, *genp = lov->lov_tgts[i]->ltd_gen; } - if (copy_to_user(uarg, buf, len)) + if (copy_to_user(uarg, data, len)) rc = -EFAULT; - kvfree(buf); + kvfree(data); break; } case OBD_IOC_QUOTACTL: { diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 2ee6b96f4830..b8fc74044fe3 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -229,7 +229,7 @@ static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) } /* buffer MUST be at least the size of obd_ioctl_hdr */ -int obd_ioctl_getdata(char **buf, int *len, void __user *arg) +int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg) { struct obd_ioctl_data *data; struct obd_ioctl_hdr hdr; @@ -261,16 +261,16 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) * obdfilter-survey is an example, which relies on ioctl. So we'd * better avoid vmalloc on ioctl path. LU-66 */ - *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); - if (!*buf) { + data = kvzalloc(hdr.ioc_len, GFP_KERNEL); + if (!data) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); return -EINVAL; } *len = hdr.ioc_len; - data = (struct obd_ioctl_data *)*buf; + *datap = data; - if (copy_from_user(*buf, arg, hdr.ioc_len)) { + if (copy_from_user(data, arg, hdr.ioc_len)) { err = -EFAULT; goto free_buf; } @@ -307,14 +307,13 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) return 0; free_buf: - kvfree(*buf); + kvfree(data); return err; } EXPORT_SYMBOL(obd_ioctl_getdata); int class_handle_ioctl(unsigned int cmd, unsigned long arg) { - char *buf = NULL; struct obd_ioctl_data *data; struct libcfs_debug_ioctl_data *debug_data; struct obd_device *obd = NULL; @@ -329,11 +328,10 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } CDEBUG(D_IOCTL, "cmd = %x\n", cmd); - if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) { + if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) { CERROR("OBD ioctl: data error\n"); return -EINVAL; } - data = (struct obd_ioctl_data *)buf; switch (cmd) { case OBD_IOC_PROCESS_CFG: { @@ -542,7 +540,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } out: - kvfree(buf); + kvfree(data); return err; } /* class_handle_ioctl */ From neilb at suse.com Tue Feb 19 00:09:04 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:04 +1100 Subject: [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494490.24125.1514109985903155907.stgit@noble.brown> llite_kobj does not benefit from being in the lustre_kset kset (though it does need lustre_kset as a parent) It also does not need the class_ktype type, as dynamic_kobj_ktype is sufficient. So use the simple kobject_create_and_add() to initialize it. This provides flexibility for making changes to class_setup_tunables(). Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 8215296dc15d..78ec0fa65c58 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -46,7 +46,7 @@ int llite_tunables_register(void) { int rc = 0; - llite_kobj = class_setup_tunables("llite"); + llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj); if (IS_ERR(llite_kobj)) return PTR_ERR(llite_kobj); From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494494.24125.2449884893355897376.stgit@noble.brown> As there is a 1-1 ammping between obd_types and their ->typ_kobj, it is simple and more normal to embed the kobj in the obd_type, rather than allocate it separately. This requires calling "kobject_init()" earlier, so we discard class_setup_tunables() and move the content to appropriate places in the only caller. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd.h | 2 - drivers/staging/lustre/lustre/include/obd_class.h | 1 drivers/staging/lustre/lustre/obdclass/genops.c | 46 ++++++-------------- .../lustre/lustre/obdclass/lprocfs_status.c | 2 - 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 171d2c214be6..b161542855fc 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -107,7 +107,7 @@ struct obd_type { int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; - struct kobject *typ_kobj; + struct kobject typ_kobj; }; struct brw_page { diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 32d4ab6e78a0..e4695f5b748d 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -60,7 +60,6 @@ struct lu_device_type; /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *conn); -struct kobject *class_setup_tunables(const char *name); int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, const char *name, struct lu_device_type *ldt); int class_unregister_type(const char *name); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 75d25b7206fc..2bd72f8a38eb 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -136,7 +136,9 @@ void class_put_type(struct obd_type *type) static void class_sysfs_release(struct kobject *kobj) { - kfree(kobj); + struct obd_type *type = container_of(kobj, struct obd_type, typ_kobj); + + kfree(type); } static struct kobj_type class_ktype = { @@ -144,26 +146,6 @@ static struct kobj_type class_ktype = { .release = class_sysfs_release, }; -struct kobject *class_setup_tunables(const char *name) -{ - struct kobject *kobj; - int rc; - - kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); - if (!kobj) - return ERR_PTR(-ENOMEM); - - kobj->kset = lustre_kset; - kobject_init(kobj, &class_ktype); - rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name); - if (rc) { - kobject_put(kobj); - return ERR_PTR(rc); - } - return kobj; -} -EXPORT_SYMBOL(class_setup_tunables); - #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, @@ -186,6 +168,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, if (!type) return rc; + type->typ_kobj.kset = lustre_kset; + kobject_init(&type->typ_kobj, &class_ktype); + type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS); @@ -205,19 +190,16 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, debugfs_lustre_root); - type->typ_kobj = class_setup_tunables(type->typ_name); - if (IS_ERR(type->typ_kobj)) { - rc = PTR_ERR(type->typ_kobj); + rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name); + + if (rc) goto failed; - } if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); - if (rc != 0) { - kobject_put(type->typ_kobj); + if (rc != 0) goto failed; - } } spin_lock(&obd_types_lock); @@ -230,7 +212,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, kfree(type->typ_name); kfree(type->typ_md_ops); kfree(type->typ_dt_ops); - kfree(type); + kobject_put(&type->typ_kobj); + return rc; } EXPORT_SYMBOL(class_register_type); @@ -253,8 +236,6 @@ int class_unregister_type(const char *name) return -EBUSY; } - kobject_put(type->typ_kobj); - debugfs_remove_recursive(type->typ_debugfs_entry); if (type->typ_lu) @@ -266,7 +247,8 @@ int class_unregister_type(const char *name) kfree(type->typ_name); kfree(type->typ_dt_ops); kfree(type->typ_md_ops); - kfree(type); + kobject_put(&type->typ_kobj); + return 0; } /* class_unregister_type */ EXPORT_SYMBOL(class_unregister_type); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index e1ac610eaed5..568e6623e0c8 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1050,7 +1050,7 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops; obd->obd_ktype.release = obd_sysfs_release; - obd->obd_kset.kobj.parent = obd->obd_type->typ_kobj; + obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj; obd->obd_kset.kobj.ktype = &obd->obd_ktype; init_completion(&obd->obd_kobj_unregister); rc = kset_register(&obd->obd_kset); From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494500.24125.3045348327157278994.stgit@noble.brown> Now that obj_type is managed as a kobject, move all the freeing and deregistering into class_sysfs_release(). Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/genops.c | 27 +++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 2bd72f8a38eb..4c0dc2098823 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -138,6 +138,18 @@ static void class_sysfs_release(struct kobject *kobj) { struct obd_type *type = container_of(kobj, struct obd_type, typ_kobj); + debugfs_remove_recursive(type->typ_debugfs_entry); + + if (type->typ_lu) + lu_device_type_fini(type->typ_lu); + + spin_lock(&obd_types_lock); + list_del(&type->typ_chain); + spin_unlock(&obd_types_lock); + + kfree(type->typ_name); + kfree(type->typ_md_ops); + kfree(type->typ_dt_ops); kfree(type); } @@ -170,6 +182,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_kobj.kset = lustre_kset; kobject_init(&type->typ_kobj, &class_ktype); + INIT_LIST_HEAD(&type->typ_chain); type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); @@ -209,9 +222,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; failed: - kfree(type->typ_name); - kfree(type->typ_md_ops); - kfree(type->typ_dt_ops); kobject_put(&type->typ_kobj); return rc; @@ -236,17 +246,6 @@ int class_unregister_type(const char *name) return -EBUSY; } - debugfs_remove_recursive(type->typ_debugfs_entry); - - if (type->typ_lu) - lu_device_type_fini(type->typ_lu); - - spin_lock(&obd_types_lock); - list_del(&type->typ_chain); - spin_unlock(&obd_types_lock); - kfree(type->typ_name); - kfree(type->typ_dt_ops); - kfree(type->typ_md_ops); kobject_put(&type->typ_kobj); return 0; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494507.24125.1847979512182217144.stgit@noble.brown> As the kobject has a name (after kobject_add has been called), we don't need to also store it in typ_name. So use typ_kobj.name instead of typ_name. This requires changing some "char *" to "const char *" as typ.kobj.name is const. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lustre_net.h | 4 ++- drivers/staging/lustre/lustre/include/obd.h | 2 +- drivers/staging/lustre/lustre/include/obd_class.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 25 ++++++++------------ drivers/staging/lustre/lustre/ptlrpc/client.c | 2 +- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 47b9632e5660..f3b6ba061eed 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -308,7 +308,7 @@ struct ptlrpc_client { /** What portal do we expect replies on */ u32 cli_reply_portal; /** Name of the client */ - char *cli_name; + const char *cli_name; }; /** state flags of requests */ @@ -1817,7 +1817,7 @@ void ptlrpc_request_committed(struct ptlrpc_request *req, int force); int ptlrpc_inc_ref(void); void ptlrpc_dec_ref(void); -void ptlrpc_init_client(int req_portal, int rep_portal, char *name, +void ptlrpc_init_client(int req_portal, int rep_portal, const char *name, struct ptlrpc_client *); struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid, lnet_nid_t nid4refnet); diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index b161542855fc..3aa9cc889949 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -103,12 +103,12 @@ struct obd_type { struct obd_ops *typ_dt_ops; struct md_ops *typ_md_ops; struct dentry *typ_debugfs_entry; - char *typ_name; int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; struct kobject typ_kobj; }; +#define typ_name typ_kobj.name struct brw_page { u64 off; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index e4695f5b748d..a61c7950393c 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -74,7 +74,7 @@ int class_name2dev(const char *name); struct obd_device *class_name2obd(const char *name); int class_uuid2dev(struct obd_uuid *uuid); struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, - const char *typ_name, + const char *type_name, struct obd_uuid *grp_uuid); struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, int *next); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index aef83ffc8bb3..ac0fbb24fc92 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -247,7 +247,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) struct obd_import *imp; struct obd_uuid server_uuid; int rq_portal, rp_portal, connect_op; - char *name = obddev->obd_type->typ_name; + const char *name = obddev->obd_type->typ_name; enum ldlm_ns_type ns_type = LDLM_NS_TYPE_UNKNOWN; struct ptlrpc_connection fake_conn = { .c_self = 0, diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 4c0dc2098823..32581f1a92ac 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -147,7 +147,6 @@ static void class_sysfs_release(struct kobject *kobj) list_del(&type->typ_chain); spin_unlock(&obd_types_lock); - kfree(type->typ_name); kfree(type->typ_md_ops); kfree(type->typ_dt_ops); kfree(type); @@ -186,28 +185,24 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); - type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS); if (!type->typ_dt_ops || - !type->typ_md_ops || - !type->typ_name) + !type->typ_md_ops) goto failed; *type->typ_dt_ops = *dt_ops; /* md_ops is optional */ if (md_ops) *type->typ_md_ops = *md_ops; - strcpy(type->typ_name, name); spin_lock_init(&type->obd_type_lock); - type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, - debugfs_lustre_root); - rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name); - if (rc) goto failed; + type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, + debugfs_lustre_root); + if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); @@ -534,7 +529,7 @@ struct obd_device *class_num2obd(int num) * otherwise any client connected to the tgt is returned. */ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, - const char *typ_name, + const char *type_name, struct obd_uuid *grp_uuid) { int i; @@ -545,8 +540,8 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, if (!obd) continue; - if ((strncmp(obd->obd_type->typ_name, typ_name, - strlen(typ_name)) == 0)) { + if ((strncmp(obd->obd_type->typ_name, type_name, + strlen(type_name)) == 0)) { if (obd_uuid_equals(tgt_uuid, &obd->u.cli.cl_target_uuid) && ((grp_uuid) ? obd_uuid_equals(grp_uuid, @@ -1358,7 +1353,7 @@ EXPORT_SYMBOL(obd_get_max_rpcs_in_flight); int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max) { struct obd_request_slot_waiter *orsw; - const char *typ_name; + const char *type_name; u32 old; int diff; int rc; @@ -1367,8 +1362,8 @@ int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max) if (max > OBD_MAX_RIF_MAX || max < 1) return -ERANGE; - typ_name = cli->cl_import->imp_obd->obd_type->typ_name; - if (!strcmp(typ_name, LUSTRE_MDC_NAME)) { + type_name = cli->cl_import->imp_obd->obd_type->typ_name; + if (!strcmp(type_name, LUSTRE_MDC_NAME)) { /* * adjust max_mod_rpcs_in_flight to ensure it is always * strictly lower that max_rpcs_in_flight diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index b2b11047ea19..0a76a8549fac 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -67,7 +67,7 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async); /** * Initialize passed in client structure \a cl. */ -void ptlrpc_init_client(int req_portal, int rep_portal, char *name, +void ptlrpc_init_client(int req_portal, int rep_portal, const char *name, struct ptlrpc_client *cl) { cl->cli_request_portal = req_portal; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494516.24125.10480743535229018309.stgit@noble.brown> As all obd_types are kobjects in the lustre_kset kset, they are linked together in that kset and don't need any extra linkage. As kset_find_obj() returns a counted reference, we need to put that reference when done. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd.h | 1 - drivers/staging/lustre/lustre/obdclass/genops.c | 41 +++++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 3aa9cc889949..50f33f400075 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -99,7 +99,6 @@ struct obd_info { }; struct obd_type { - struct list_head typ_chain; struct obd_ops *typ_dt_ops; struct md_ops *typ_md_ops; struct dentry *typ_debugfs_entry; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 32581f1a92ac..775e4fa4f6a8 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -42,8 +42,6 @@ #include #include -static DEFINE_SPINLOCK(obd_types_lock); -static LIST_HEAD(obd_types); DEFINE_RWLOCK(obd_dev_lock); static struct obd_device *obd_devs[MAX_OBD_DEVICES]; @@ -88,22 +86,19 @@ static void obd_device_free(struct obd_device *obd) static struct obd_type *class_search_type(const char *name) { - struct obd_type *type; + struct kobject *kobj = kset_find_obj(lustre_kset, name); + + if (kobj) + return container_of(kobj, struct obd_type, typ_kobj); - spin_lock(&obd_types_lock); - list_for_each_entry(type, &obd_types, typ_chain) { - if (strcmp(type->typ_name, name) == 0) { - spin_unlock(&obd_types_lock); - return type; - } - } - spin_unlock(&obd_types_lock); return NULL; } static struct obd_type *class_get_type(const char *name) { - struct obd_type *type = class_search_type(name); + struct obd_type *type; + + type = class_search_type(name); if (!type) { const char *modname = name; @@ -121,6 +116,11 @@ static struct obd_type *class_get_type(const char *name) type->typ_refcnt++; try_module_get(type->typ_dt_ops->owner); spin_unlock(&type->obd_type_lock); + /* class_search_type() returned a counted reference, + * but we don't need that count any more as + * we have one through typ_refcnt. + */ + kobject_put(&type->typ_kobj); } return type; } @@ -143,10 +143,6 @@ static void class_sysfs_release(struct kobject *kobj) if (type->typ_lu) lu_device_type_fini(type->typ_lu); - spin_lock(&obd_types_lock); - list_del(&type->typ_chain); - spin_unlock(&obd_types_lock); - kfree(type->typ_md_ops); kfree(type->typ_dt_ops); kfree(type); @@ -169,8 +165,10 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, /* sanity check */ LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME); - if (class_search_type(name)) { + type = class_search_type(name); + if (type) { CDEBUG(D_IOCTL, "Type %s already registered\n", name); + kobject_put(&type->typ_kobj); return -EEXIST; } @@ -181,7 +179,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_kobj.kset = lustre_kset; kobject_init(&type->typ_kobj, &class_ktype); - INIT_LIST_HEAD(&type->typ_chain); type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); @@ -210,10 +207,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, goto failed; } - spin_lock(&obd_types_lock); - list_add(&type->typ_chain, &obd_types); - spin_unlock(&obd_types_lock); - return 0; failed: @@ -238,9 +231,13 @@ int class_unregister_type(const char *name) /* Remove ops, but leave the name for debugging */ kfree(type->typ_dt_ops); kfree(type->typ_md_ops); + kobject_put(&type->typ_kobj); return -EBUSY; } + /* Put the ref returned by class_search_type() */ + kobject_put(&type->typ_kobj); + /* Put the final ref */ kobject_put(&type->typ_kobj); return 0; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494523.24125.14949515989661790146.stgit@noble.brown> This lock is only used to protect typ_refcnt, so change that to a refcount_t and discard the lock. The lock also covers calls to try_module_get and module_put, but this serves no purpose as it does not prevent the module from being unloaded. Finally, the return value for the call to try_module_get is ignored, which is not safe. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd.h | 3 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 + drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 + drivers/staging/lustre/lustre/obdclass/genops.c | 30 +++++++++----------- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 + 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 50f33f400075..a67eb9a14879 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -102,9 +102,8 @@ struct obd_type { struct obd_ops *typ_dt_ops; struct md_ops *typ_md_ops; struct dentry *typ_debugfs_entry; - int typ_refcnt; + refcount_t typ_refcnt; struct lu_device_type *typ_lu; - spinlock_t obd_type_lock; struct kobject typ_kobj; }; #define typ_name typ_kobj.name diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 3eb89ec80b7e..db2c045aa1cd 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2540,7 +2540,7 @@ static int mdc_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize) static int mdc_precleanup(struct obd_device *obd) { /* Failsafe, ok if racy */ - if (obd->obd_type->typ_refcnt <= 1) + if (refcount_read(&obd->obd_type->typ_refcnt) <= 1) libcfs_kkuc_group_rem(0, KUC_GRP_HSM); mdc_changelog_cdev_finish(obd); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index a4dfdc08cc48..a6ee715921b8 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -715,7 +715,7 @@ static int mgc_cleanup(struct obd_device *obd) /* COMPAT_146 - old config logs may have added profiles we don't * know about */ - if (obd->obd_type->typ_refcnt <= 1) + if (refcount_read(&obd->obd_type->typ_refcnt) <= 1) /* Only for the last mgc */ class_del_profiles(); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 775e4fa4f6a8..a3437c2d07bb 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -112,15 +112,17 @@ static struct obd_type *class_get_type(const char *name) } } if (type) { - spin_lock(&type->obd_type_lock); - type->typ_refcnt++; - try_module_get(type->typ_dt_ops->owner); - spin_unlock(&type->obd_type_lock); - /* class_search_type() returned a counted reference, - * but we don't need that count any more as - * we have one through typ_refcnt. - */ - kobject_put(&type->typ_kobj); + if (try_module_get(type->typ_dt_ops->owner)) { + refcount_inc(&type->typ_refcnt); + /* class_search_type() returned a counted reference, + * but we don't need that count any more as + * we have one through typ_refcnt. + */ + kobject_put(&type->typ_kobj); + } else { + kobject_put(&type->typ_kobj); + type = NULL; + } } return type; } @@ -128,10 +130,7 @@ static struct obd_type *class_get_type(const char *name) void class_put_type(struct obd_type *type) { LASSERT(type); - spin_lock(&type->obd_type_lock); - type->typ_refcnt--; - module_put(type->typ_dt_ops->owner); - spin_unlock(&type->obd_type_lock); + refcount_dec(&type->typ_refcnt); } static void class_sysfs_release(struct kobject *kobj) @@ -191,7 +190,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, /* md_ops is optional */ if (md_ops) *type->typ_md_ops = *md_ops; - spin_lock_init(&type->obd_type_lock); rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name); if (rc) @@ -225,8 +223,8 @@ int class_unregister_type(const char *name) return -EINVAL; } - if (type->typ_refcnt) { - CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt); + if (refcount_read(&type->typ_refcnt)) { + CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt)); /* This is a bad situation, let's make the best of it */ /* Remove ops, but leave the name for debugging */ kfree(type->typ_dt_ops); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 639c298b6a90..69a56cca99f2 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -1267,7 +1267,7 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) next = ldt->ldt_ops->ldto_device_free(env, scan); type = ldt->ldt_obd_type; if (type) { - type->typ_refcnt--; + refcount_dec(&type->typ_refcnt); class_put_type(type); } } From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494530.24125.8326533343171305248.stgit@noble.brown> The obd_ops and md_ops structures passed to class_register_type() are read-only, and have a lifetime that is exceeds the lifetime of the obd_type - they are static in a module which unregisters the type before being unloaded. So there is no need to copy the ops, just store a pointer. Also mark all the structures as read-only to confirm they don't get written. This is best-practice for structures of function pointers. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd.h | 4 ++-- drivers/staging/lustre/lustre/include/obd_class.h | 3 ++- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 ++-- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 4 ++-- drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 22 +++++--------------- .../staging/lustre/lustre/obdecho/echo_client.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index a67eb9a14879..9cffda3741ce 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -99,8 +99,8 @@ struct obd_info { }; struct obd_type { - struct obd_ops *typ_dt_ops; - struct md_ops *typ_md_ops; + const struct obd_ops *typ_dt_ops; + const struct md_ops *typ_md_ops; struct dentry *typ_debugfs_entry; refcount_t typ_refcnt; struct lu_device_type *typ_lu; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index a61c7950393c..7c2e248a8110 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -60,7 +60,8 @@ struct lu_device_type; /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *conn); -int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, +int class_register_type(const struct obd_ops *dt_ops, + const struct md_ops *md_ops, const char *name, struct lu_device_type *ldt); int class_unregister_type(const char *name); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1c7379b14f8c..35dff0e96bf7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -3044,7 +3044,7 @@ static int lmv_merge_attr(struct obd_export *exp, return 0; } -static struct obd_ops lmv_obd_ops = { +static const struct obd_ops lmv_obd_ops = { .owner = THIS_MODULE, .setup = lmv_setup, .cleanup = lmv_cleanup, @@ -3061,7 +3061,7 @@ static struct obd_ops lmv_obd_ops = { .quotactl = lmv_quotactl }; -static struct md_ops lmv_md_ops = { +static const struct md_ops lmv_md_ops = { .get_root = lmv_get_root, .null_inode = lmv_null_inode, .close = lmv_close, diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index fd769c39b482..bad9538706f0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1332,7 +1332,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, return rc; } -static struct obd_ops lov_obd_ops = { +static const struct obd_ops lov_obd_ops = { .owner = THIS_MODULE, .setup = lov_setup, .cleanup = lov_cleanup, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index db2c045aa1cd..72a5264b2d78 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2569,7 +2569,7 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) return count > 0 ? 0 : count; } -static struct obd_ops mdc_obd_ops = { +static const struct obd_ops mdc_obd_ops = { .owner = THIS_MODULE, .setup = mdc_setup, .precleanup = mdc_precleanup, @@ -2591,7 +2591,7 @@ static struct obd_ops mdc_obd_ops = { .quotactl = mdc_quotactl, }; -static struct md_ops mdc_md_ops = { +static const struct md_ops mdc_md_ops = { .get_root = mdc_get_root, .null_inode = mdc_null_inode, .close = mdc_close, diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index a6ee715921b8..3ff0bf1c4a22 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1817,7 +1817,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) return rc; } -static struct obd_ops mgc_obd_ops = { +static const struct obd_ops mgc_obd_ops = { .owner = THIS_MODULE, .setup = mgc_setup, .precleanup = mgc_precleanup, diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index a3437c2d07bb..d013e9a358f1 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -142,8 +142,6 @@ static void class_sysfs_release(struct kobject *kobj) if (type->typ_lu) lu_device_type_fini(type->typ_lu); - kfree(type->typ_md_ops); - kfree(type->typ_dt_ops); kfree(type); } @@ -154,7 +152,8 @@ static struct kobj_type class_ktype = { #define CLASS_MAX_NAME 1024 -int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, +int class_register_type(const struct obd_ops *dt_ops, + const struct md_ops *md_ops, const char *name, struct lu_device_type *ldt) { @@ -179,17 +178,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_kobj.kset = lustre_kset; kobject_init(&type->typ_kobj, &class_ktype); - type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); - type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); - - if (!type->typ_dt_ops || - !type->typ_md_ops) - goto failed; - - *type->typ_dt_ops = *dt_ops; - /* md_ops is optional */ - if (md_ops) - *type->typ_md_ops = *md_ops; + type->typ_dt_ops = dt_ops; + type->typ_md_ops = md_ops; rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name); if (rc) @@ -227,8 +217,8 @@ int class_unregister_type(const char *name) CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt)); /* This is a bad situation, let's make the best of it */ /* Remove ops, but leave the name for debugging */ - kfree(type->typ_dt_ops); - kfree(type->typ_md_ops); + type->typ_dt_ops = NULL; + type->typ_md_ops = NULL; kobject_put(&type->typ_kobj); return -EBUSY; } diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 317123fd27cb..baf34c85c4b5 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -1676,7 +1676,7 @@ static int echo_client_disconnect(struct obd_export *exp) return rc; } -static struct obd_ops echo_client_obd_ops = { +static const struct obd_ops echo_client_obd_ops = { .owner = THIS_MODULE, .iocontrol = echo_client_iocontrol, .connect = echo_client_connect, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 3fedfaf249c4..442b4355d946 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2988,7 +2988,7 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) return osc_process_config_base(obd, buf); } -static struct obd_ops osc_obd_ops = { +static const struct obd_ops osc_obd_ops = { .owner = THIS_MODULE, .setup = osc_setup, .precleanup = osc_precleanup, From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494536.24125.16645429190038913975.stgit@noble.brown> Safe module loading requires that we try_module_get() in a context where the module cannot be unloaded, typically protected by a spinlock that module-unload has to take. This doesn't currently happen in class_get_type(). As free_module() calls synchronize_rcu() between calling the exit function and freeing the module, we can use rcu_read_lock() to check if the exit function has been called, and try_module_get() if it hasn't. We must also check the return status of try_module_get(). Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/genops.c | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index d013e9a358f1..1d1a6b2d436e 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -98,21 +98,31 @@ static struct obd_type *class_get_type(const char *name) { struct obd_type *type; + rcu_read_lock(); type = class_search_type(name); if (!type) { const char *modname = name; + rcu_read_unlock(); if (!request_module("%s", modname)) { CDEBUG(D_INFO, "Loaded module '%s'\n", modname); - type = class_search_type(name); } else { LCONSOLE_ERROR_MSG(0x158, "Can't load module '%s'\n", modname); } + rcu_read_lock(); + type = class_search_type(name); } if (type) { - if (try_module_get(type->typ_dt_ops->owner)) { + /* + * Holding rcu_read_lock() matches the synchronize_rcu() call + * in free_module() and ensures that if type->typ_dt_ops is + * not yet NULL, then the module won't be freed until after + * we rcu_read_unlock(). + */ + const struct obd_ops *dt_ops = READ_ONCE(type->typ_dt_ops); + if (dt_ops && try_module_get(dt_ops->owner)) { refcount_inc(&type->typ_refcnt); /* class_search_type() returned a counted reference, * but we don't need that count any more as @@ -124,6 +134,7 @@ static struct obd_type *class_get_type(const char *name) type = NULL; } } + rcu_read_unlock(); return type; } @@ -213,11 +224,18 @@ int class_unregister_type(const char *name) return -EINVAL; } + /* + * Ensure that class_get_type doesn't try to get the module + * as it could be freed before the obd_type is released. + * synchronize_rcu() will be called before the module + * is freed. + */ + type->typ_dt_ops = NULL; + if (refcount_read(&type->typ_refcnt)) { CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt)); /* This is a bad situation, let's make the best of it */ /* Remove ops, but leave the name for debugging */ - type->typ_dt_ops = NULL; type->typ_md_ops = NULL; kobject_put(&type->typ_kobj); return -EBUSY; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494542.24125.3526135915611952378.stgit@noble.brown> Passing 0 as the gfp_t for kmalloc() is not meaningful, and could change behaviour. Use an explicit GFP_KERNEL instead. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/obdclass/kernelcomm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c index 925ba52c53b4..09d0b1ab8d1c 100644 --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c @@ -133,7 +133,7 @@ int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group, return -EBADF; /* freed in group_rem */ - reg = kmalloc(sizeof(*reg) + data_len, 0); + reg = kmalloc(sizeof(*reg) + data_len, GFP_KERNEL); if (!reg) return -ENOMEM; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494545.24125.14664274760505145343.stgit@noble.brown> libcfs_kkuc_msg_put() is never used outside of kernelcomm.c, so make it static. Signed-off-by: NeilBrown --- .../lustre/lustre/include/lustre_kernelcomm.h | 1 - .../staging/lustre/lustre/obdclass/kernelcomm.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h index 8e3a99057a38..1ed41840ab8f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h +++ b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h @@ -46,7 +46,6 @@ typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg); /* Kernel methods */ void libcfs_kkuc_init(void); -int libcfs_kkuc_msg_put(struct file *fp, void *payload); int libcfs_kkuc_group_put(unsigned int group, void *payload); int libcfs_kkuc_group_add(struct file *fp, int uid, unsigned int group, void *data, size_t data_len); diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c index 09d0b1ab8d1c..27870952b1f0 100644 --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c @@ -49,7 +49,7 @@ * @param payload Payload data. First field of payload is always * struct kuc_hdr */ -int libcfs_kkuc_msg_put(struct file *filp, void *payload) +static int libcfs_kkuc_msg_put(struct file *filp, void *payload) { struct kuc_hdr *kuch = (struct kuc_hdr *)payload; ssize_t count = kuch->kuc_msglen; @@ -80,7 +80,6 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload) return rc; } -EXPORT_SYMBOL(libcfs_kkuc_msg_put); /* * Broadcast groups are global across all mounted filesystems; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494549.24125.14755296858886216830.stgit@noble.brown> Much of the linkea functionality is server-only. Keep the parts used on the client, but remove the rest. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_linkea.h | 8 - drivers/staging/lustre/lustre/obdclass/linkea.c | 150 -------------------- 2 files changed, 1 insertion(+), 157 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_linkea.h b/drivers/staging/lustre/lustre/include/lustre_linkea.h index 03db1511bfd3..a028d91dd151 100644 --- a/drivers/staging/lustre/lustre/include/lustre_linkea.h +++ b/drivers/staging/lustre/lustre/include/lustre_linkea.h @@ -55,17 +55,9 @@ struct linkea_data { }; int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf); -int linkea_init(struct linkea_data *ldata); int linkea_init_with_rec(struct linkea_data *ldata); void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, struct lu_name *lname, struct lu_fid *pfid); -int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname, - const struct lu_fid *pfid); -int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname, - const struct lu_fid *pfid); -void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname); -int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname, - const struct lu_fid *pfid); static inline void linkea_first_entry(struct linkea_data *ldata) { diff --git a/drivers/staging/lustre/lustre/obdclass/linkea.c b/drivers/staging/lustre/lustre/obdclass/linkea.c index 33594bd26794..b1aa80a73a2c 100644 --- a/drivers/staging/lustre/lustre/obdclass/linkea.c +++ b/drivers/staging/lustre/lustre/obdclass/linkea.c @@ -48,7 +48,7 @@ int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf) } EXPORT_SYMBOL(linkea_data_new); -int linkea_init(struct linkea_data *ldata) +static int linkea_init(struct linkea_data *ldata) { struct link_ea_header *leh; @@ -72,7 +72,6 @@ int linkea_init(struct linkea_data *ldata) ldata->ld_leh = leh; return 0; } -EXPORT_SYMBOL(linkea_init); int linkea_init_with_rec(struct linkea_data *ldata) { @@ -86,32 +85,6 @@ int linkea_init_with_rec(struct linkea_data *ldata) } EXPORT_SYMBOL(linkea_init_with_rec); -/** - * Pack a link_ea_entry. - * All elements are stored as chars to avoid alignment issues. - * Numbers are always big-endian - * \retval record length - */ -int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname, - const struct lu_fid *pfid) -{ - struct lu_fid tmpfid; - int reclen; - - tmpfid = *pfid; - if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LINKEA_CRASH)) - tmpfid.f_ver = ~0; - fid_cpu_to_be(&tmpfid, &tmpfid); - memcpy(&lee->lee_parent_fid, &tmpfid, sizeof(tmpfid)); - memcpy(lee->lee_name, lname->ln_name, lname->ln_namelen); - reclen = sizeof(struct link_ea_entry) + lname->ln_namelen; - - lee->lee_reclen[0] = (reclen >> 8) & 0xff; - lee->lee_reclen[1] = reclen & 0xff; - return reclen; -} -EXPORT_SYMBOL(linkea_entry_pack); - void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, struct lu_name *lname, struct lu_fid *pfid) { @@ -126,124 +99,3 @@ void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, } } EXPORT_SYMBOL(linkea_entry_unpack); - -/** - * Add a record to the end of link ea buf - **/ -int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname, - const struct lu_fid *pfid) -{ - struct link_ea_header *leh = ldata->ld_leh; - int reclen; - - LASSERT(leh); - - if (!lname || !pfid) - return -EINVAL; - - reclen = lname->ln_namelen + sizeof(struct link_ea_entry); - if (unlikely(leh->leh_len + reclen > MAX_LINKEA_SIZE)) { - /* - * Use 32-bits to save the overflow time, although it will - * shrink the ktime_get_real_seconds() returned 64-bits value - * to 32-bits value, it is still quite large and can be used - * for about 140 years. That is enough. - */ - leh->leh_overflow_time = ktime_get_real_seconds(); - if (unlikely(leh->leh_overflow_time == 0)) - leh->leh_overflow_time++; - - CDEBUG(D_INODE, "No enough space to hold linkea entry '" DFID ": %.*s' at %u\n", - PFID(pfid), lname->ln_namelen, - lname->ln_name, leh->leh_overflow_time); - return 0; - } - - if (leh->leh_len + reclen > ldata->ld_buf->lb_len) { - /* Note: this never happens as MAX_LINKEA_SIZE is 4096, while - * the initial allocation is PAGE_SIZE. - */ - void *b = krealloc(ldata->ld_buf->lb_buf, leh->leh_len + reclen, GFP_NOFS); - if (!b) - return -ENOMEM; - - ldata->ld_buf->lb_len = leh->leh_len + reclen; - leh = ldata->ld_leh = ldata->ld_buf->lb_buf = b; - } - - ldata->ld_lee = ldata->ld_buf->lb_buf + leh->leh_len; - ldata->ld_reclen = linkea_entry_pack(ldata->ld_lee, lname, pfid); - leh->leh_len += ldata->ld_reclen; - leh->leh_reccount++; - CDEBUG(D_INODE, "New link_ea name '" DFID ":%.*s' is added\n", - PFID(pfid), lname->ln_namelen, lname->ln_name); - return 0; -} -EXPORT_SYMBOL(linkea_add_buf); - -/** Del the current record from the link ea buf */ -void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname) -{ - LASSERT(ldata->ld_leh && ldata->ld_lee); - LASSERT(ldata->ld_leh->leh_reccount > 0); - - ldata->ld_leh->leh_reccount--; - ldata->ld_leh->leh_len -= ldata->ld_reclen; - memmove(ldata->ld_lee, (char *)ldata->ld_lee + ldata->ld_reclen, - (char *)ldata->ld_leh + ldata->ld_leh->leh_len - - (char *)ldata->ld_lee); - CDEBUG(D_INODE, "Old link_ea name '%.*s' is removed\n", - lname->ln_namelen, lname->ln_name); - - if ((char *)ldata->ld_lee >= ((char *)ldata->ld_leh + - ldata->ld_leh->leh_len)) - ldata->ld_lee = NULL; -} -EXPORT_SYMBOL(linkea_del_buf); - -/** - * Check if such a link exists in linkEA. - * - * \param ldata link data the search to be done on - * \param lname name in the parent's directory entry pointing to this object - * \param pfid parent fid the link to be found for - * - * \retval 0 success - * \retval -ENOENT link does not exist - * \retval -ve on error - */ -int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname, - const struct lu_fid *pfid) -{ - struct lu_name tmpname; - struct lu_fid tmpfid; - int count; - - LASSERT(ldata->ld_leh); - - /* link #0, if leh_reccount == 0 we skip the loop and return -ENOENT */ - if (likely(ldata->ld_leh->leh_reccount > 0)) - ldata->ld_lee = (struct link_ea_entry *)(ldata->ld_leh + 1); - - for (count = 0; count < ldata->ld_leh->leh_reccount; count++) { - linkea_entry_unpack(ldata->ld_lee, &ldata->ld_reclen, - &tmpname, &tmpfid); - if (tmpname.ln_namelen == lname->ln_namelen && - lu_fid_eq(&tmpfid, pfid) && - (strncmp(tmpname.ln_name, lname->ln_name, - tmpname.ln_namelen) == 0)) - break; - ldata->ld_lee = (struct link_ea_entry *)((char *)ldata->ld_lee + - ldata->ld_reclen); - } - - if (count == ldata->ld_leh->leh_reccount) { - CDEBUG(D_INODE, "Old link_ea name '%.*s' not found\n", - lname->ln_namelen, lname->ln_name); - ldata->ld_lee = NULL; - ldata->ld_reclen = 0; - return -ENOENT; - } - return 0; -} -EXPORT_SYMBOL(linkea_links_find); From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494552.24125.3519300273247156099.stgit@noble.brown> This lock is unused on the client (and on the server, it has been changed to a mutex). Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lustre_log.h | 1 - drivers/staging/lustre/lustre/obdclass/llog.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index a576d40f03f7..e96bd6ab0fa4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -212,7 +212,6 @@ struct llog_operations { /* In-memory descriptor for a log object or log catalog */ struct llog_handle { struct rw_semaphore lgh_lock; - spinlock_t lgh_hdr_lock; /* protect lgh_hdr data */ struct llog_logid lgh_id; /* id of this log */ struct llog_log_hdr *lgh_hdr; size_t lgh_hdr_size; diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 7aa459bb444e..9d161c16c2f9 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -64,7 +64,6 @@ static struct llog_handle *llog_alloc_handle(void) return NULL; init_rwsem(&loghandle->lgh_lock); - spin_lock_init(&loghandle->lgh_hdr_lock); INIT_LIST_HEAD(&loghandle->u.phd.phd_entry); atomic_set(&loghandle->lgh_refcount, 1); From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494558.24125.11270061933248014691.stgit@noble.brown> This is a refcount that perfectly fits the pattern for kref, so change it to a kref. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lustre_log.h | 9 +-------- drivers/staging/lustre/lustre/obdclass/llog.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index e96bd6ab0fa4..83fc9374d7f0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -226,7 +226,7 @@ struct llog_handle { char *lgh_name; void *private_data; struct llog_operations *lgh_logops; - atomic_t lgh_refcount; + struct kref lgh_refcount; }; #define LLOG_CTXT_FLAG_UNINITIALIZED 0x00000001 @@ -365,13 +365,6 @@ static inline int llog_next_block(const struct lu_env *env, } /* llog.c */ -int llog_declare_write_rec(const struct lu_env *env, - struct llog_handle *handle, - struct llog_rec_hdr *rec, int idx, - struct thandle *th); -int llog_write_rec(const struct lu_env *env, struct llog_handle *handle, - struct llog_rec_hdr *rec, struct llog_cookie *logcookies, - int numcookies, void *buf, int idx, struct thandle *th); int lustre_process_log(struct super_block *sb, char *logname, struct config_llog_instance *cfg); int lustre_end_log(struct super_block *sb, char *logname, diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 9d161c16c2f9..a34b1a7108b7 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -65,7 +65,7 @@ static struct llog_handle *llog_alloc_handle(void) init_rwsem(&loghandle->lgh_lock); INIT_LIST_HEAD(&loghandle->u.phd.phd_entry); - atomic_set(&loghandle->lgh_refcount, 1); + kref_init(&loghandle->lgh_refcount); return loghandle; } @@ -73,8 +73,11 @@ static struct llog_handle *llog_alloc_handle(void) /* * Free llog handle and header data if exists. Used in llog_close() only */ -static void llog_free_handle(struct llog_handle *loghandle) +static void llog_free_handle(struct kref *kref) { + struct llog_handle *loghandle = container_of(kref, struct llog_handle, + lgh_refcount); + /* failed llog_init_handle */ if (!loghandle->lgh_hdr) goto out; @@ -90,14 +93,13 @@ static void llog_free_handle(struct llog_handle *loghandle) void llog_handle_get(struct llog_handle *loghandle) { - atomic_inc(&loghandle->lgh_refcount); + kref_get(&loghandle->lgh_refcount); } void llog_handle_put(struct llog_handle *loghandle) { - LASSERT(atomic_read(&loghandle->lgh_refcount) > 0); - if (atomic_dec_and_test(&loghandle->lgh_refcount)) - llog_free_handle(loghandle); + LASSERT(kref_read(&loghandle->lgh_refcount) > 0); + kref_put(&loghandle->lgh_refcount, llog_free_handle); } static int llog_read_header(const struct lu_env *env, @@ -497,7 +499,7 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, revert_creds(old_cred); if (rc) { - llog_free_handle(*lgh); + llog_free_handle(&(*lgh)->lgh_refcount); *lgh = NULL; } return rc; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494563.24125.5471194386420442456.stgit@noble.brown> Make this a refcount_t for clarity, and also use refcount_dec_and_lock() rather than having separate lock and dec calls. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lustre_log.h | 11 ++++++----- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 12 +++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 83fc9374d7f0..ab0262c20278 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -243,7 +243,7 @@ struct llog_ctxt { struct llog_operations *loc_logops; struct llog_handle *loc_handle; struct mutex loc_mutex; /* protect loc_imp */ - atomic_t loc_refcount; + refcount_t loc_refcount; long loc_flags; /* flags, see above defines */ /* * llog chunk size, and llog record size can not be bigger than @@ -267,9 +267,9 @@ static inline int llog_handle2ops(struct llog_handle *loghandle, static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt) { - atomic_inc(&ctxt->loc_refcount); + refcount_inc(&ctxt->loc_refcount); CDEBUG(D_INFO, "GETting ctxt %p : new refcount %d\n", ctxt, - atomic_read(&ctxt->loc_refcount)); + refcount_read(&ctxt->loc_refcount)); return ctxt; } @@ -277,9 +277,10 @@ static inline void llog_ctxt_put(struct llog_ctxt *ctxt) { if (!ctxt) return; - LASSERT_ATOMIC_GT_LT(&ctxt->loc_refcount, 0, LI_POISON); + LASSERT(refcount_read(&ctxt->loc_refcount) > 0); + LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON); CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt, - atomic_read(&ctxt->loc_refcount) - 1); + refcount_read(&ctxt->loc_refcount) - 1); __llog_ctxt_put(NULL, ctxt); } diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index e074b6ee50e6..2b6489e2632d 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -47,7 +47,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd) return NULL; ctxt->loc_obd = obd; - atomic_set(&ctxt->loc_refcount, 1); + refcount_set(&ctxt->loc_refcount, 1); return ctxt; } @@ -71,11 +71,9 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) struct obd_device *obd; int rc = 0; - spin_lock(&olg->olg_lock); - if (!atomic_dec_and_test(&ctxt->loc_refcount)) { - spin_unlock(&olg->olg_lock); + if (!refcount_dec_and_lock(&ctxt->loc_refcount, &olg->olg_lock)) return rc; - } + olg->olg_ctxts[ctxt->loc_idx] = NULL; spin_unlock(&olg->olg_lock); @@ -116,8 +114,8 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) /* * Banlance the ctxt get when calling llog_cleanup() */ - LASSERT(atomic_read(&ctxt->loc_refcount) < LI_POISON); - LASSERT(atomic_read(&ctxt->loc_refcount) > 1); + LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON); + LASSERT(refcount_read(&ctxt->loc_refcount) > 1); llog_ctxt_put(ctxt); /* From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494567.24125.4188546775209627143.stgit@noble.brown> Fix mistyped "Balance" in a comment. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 2b6489e2632d..a89ec816b043 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -112,7 +112,7 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) idx = ctxt->loc_idx; /* - * Banlance the ctxt get when calling llog_cleanup() + * Balance the ctxt get when calling llog_cleanup() */ LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON); LASSERT(refcount_read(&ctxt->loc_refcount) > 1); From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494572.24125.4002432022455040178.stgit@noble.brown> This function seems overly complex, the same functionality is available with much less effort. Signed-off-by: NeilBrown --- .../lustre/lustre/obdclass/lprocfs_status.c | 47 +++----------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 568e6623e0c8..bd24e48f6145 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m, int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult) { - long decimal_val, frac_val; int prtn; if (count < 10) return -EINVAL; - decimal_val = val / mult; - prtn = snprintf(buffer, count, "%ld", decimal_val); - frac_val = val % mult; - - if (prtn < (count - 4) && frac_val > 0) { - long temp_frac; - int i, temp_mult = 1, frac_bits = 0; - - temp_frac = frac_val * 10; - buffer[prtn++] = '.'; - while (frac_bits < 2 && (temp_frac / mult) < 1) { - /* only reserved 2 bits fraction */ - buffer[prtn++] = '0'; - temp_frac *= 10; - frac_bits++; - } - /* - * Need to think these cases : - * 1. #echo x.00 > /sys/xxx output result : x - * 2. #echo x.0x > /sys/xxx output result : x.0x - * 3. #echo x.x0 > /sys/xxx output result : x.x - * 4. #echo x.xx > /sys/xxx output result : x.xx - * Only reserved 2 bits fraction. - */ - for (i = 0; i < (5 - prtn); i++) - temp_mult *= 10; - - frac_bits = min((int)count - prtn, 3 - frac_bits); - prtn += snprintf(buffer + prtn, frac_bits, "%ld", - frac_val * temp_mult / mult); + prtn = snprintf(buffer, count, "%ld.%02lu", + val / mult, + (val % mult) / (mult / 100)); + /* Strip trailing zeroes, and trailing '.' */ + while (prtn && buffer[prtn-1] == '0') + prtn--; + if (prtn && buffer[prtn-1] == '.') prtn--; - while (buffer[prtn] < '1' || buffer[prtn] > '9') { - prtn--; - if (buffer[prtn] == '.') { - prtn--; - break; - } - } - prtn++; - } buffer[prtn++] = '\n'; return prtn; } From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494576.24125.8952974091192338899.stgit@noble.brown> Neither lprocfs_single_release() or lprocfs_seq_release() add any value to single_release() or seq_release() which they wrap. So just use the base functions and discard the wrapper. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lprocfs_status.h | 7 ++----- drivers/staging/lustre/lustre/lov/lproc_lov.c | 2 +- .../lustre/lustre/obdclass/lprocfs_status.c | 14 +------------- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index d69f395e3d52..8565c28f08ee 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -502,9 +502,6 @@ unsigned long lprocfs_oh_sum(struct obd_histogram *oh); void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, struct lprocfs_counter *cnt); -int lprocfs_single_release(struct inode *inode, struct file *file); -int lprocfs_seq_release(struct inode *inode, struct file *file); - /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only * proc entries; otherwise, you will define name##_seq_write function also for * a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, @@ -521,7 +518,7 @@ static const struct file_operations name##_fops = { \ .read = seq_read, \ .write = custom_seq_write, \ .llseek = seq_lseek, \ - .release = lprocfs_single_release, \ + .release = single_release, \ } #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL) @@ -563,7 +560,7 @@ static const struct file_operations name##_fops = { \ static const struct file_operations name##_##type##_fops = { \ .open = name##_##type##_open, \ .write = name##_##type##_write, \ - .release = lprocfs_single_release, \ + .release = single_release, \ } struct lustre_attr { diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index fc53f2386c39..cfb274498d30 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -264,7 +264,7 @@ static const struct file_operations lov_debugfs_target_fops = { .open = lov_target_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = lprocfs_seq_release, + .release = seq_release, }; static struct attribute *lov_attrs[] = { diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index bd24e48f6145..76d298337e95 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -273,18 +273,6 @@ MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs #define MAX_STRING_SIZE 128 -int lprocfs_single_release(struct inode *inode, struct file *file) -{ - return single_release(inode, file); -} -EXPORT_SYMBOL(lprocfs_single_release); - -int lprocfs_seq_release(struct inode *inode, struct file *file) -{ - return seq_release(inode, file); -} -EXPORT_SYMBOL(lprocfs_seq_release); - /* lprocfs API calls */ static const struct file_operations lprocfs_generic_fops = { }; @@ -1331,7 +1319,7 @@ const struct file_operations lprocfs_stats_seq_fops = { .read = seq_read, .write = lprocfs_stats_seq_write, .llseek = seq_lseek, - .release = lprocfs_seq_release, + .release = seq_release, }; EXPORT_SYMBOL_GPL(lprocfs_stats_seq_fops); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 25858b8f6cbd..d09bddaf88ba 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1093,7 +1093,7 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry, .open = ptlrpc_lprocfs_svc_req_history_open, .read = seq_read, .llseek = seq_lseek, - .release = lprocfs_seq_release, + .release = seq_release, }; ptlrpc_ldebugfs_register(entry, svc->srv_name, From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr() In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494582.24125.9057041272800982944.stgit@noble.brown> This is identical to strnstr() in lib/string.h, so just use that. Signed-off-by: NeilBrown --- .../lustre/lustre/obdclass/lprocfs_status.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 76d298337e95..27d73c95403d 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1552,22 +1552,6 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer, } EXPORT_SYMBOL(lprocfs_write_frac_u64_helper); -static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len) -{ - size_t l2; - - l2 = strlen(s2); - if (!l2) - return (char *)s1; - while (len >= l2) { - len--; - if (!memcmp(s1, s2, l2)) - return (char *)s1; - s1++; - } - return NULL; -} - /** * Find the string \a name in the input \a buffer, and return a pointer to the * value immediately following \a name, reducing \a count appropriately. @@ -1579,8 +1563,7 @@ char *lprocfs_find_named_value(const char *buffer, const char *name, char *val; size_t buflen = *count; - /* there is no strnstr() in rhel5 and ubuntu kernels */ - val = lprocfs_strnstr(buffer, name, buflen); + val = strnstr(buffer, name, buflen); if (!val) return (char *)buffer; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494585.24125.10207641299012244855.stgit@noble.brown> This lock is never held over code that sleeps, and is only ever held for short periods of time. So a simple spinlock is best. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd_class.h | 3 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 +++--- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++-- .../lustre/lustre/obdclass/lprocfs_status.c | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 7c2e248a8110..dd480501d7df 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1688,12 +1688,11 @@ void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs); void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs); /* root squash info */ -struct rw_semaphore; struct root_squash_info { uid_t rsi_uid; gid_t rsi_gid; struct list_head rsi_nosquash_nids; - struct rw_semaphore rsi_sem; + spinlock_t rsi_lock; /* protects rsi_nosquash_nids */ }; /* linux-module.c */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index e2417cd5aaed..d97abbfddccf 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -130,7 +130,7 @@ static struct ll_sb_info *ll_init_sbi(void) sbi->ll_squash.rsi_uid = 0; sbi->ll_squash.rsi_gid = 0; INIT_LIST_HEAD(&sbi->ll_squash.rsi_nosquash_nids); - init_rwsem(&sbi->ll_squash.rsi_sem); + spin_lock_init(&sbi->ll_squash.rsi_lock); return sbi; } @@ -2578,7 +2578,7 @@ void ll_compute_rootsquash_state(struct ll_sb_info *sbi) int i; /* Update norootsquash flag */ - down_write(&squash->rsi_sem); + spin_lock(&squash->rsi_lock); if (list_empty(&squash->rsi_nosquash_nids)) { spin_lock(&sbi->ll_lock); sbi->ll_flags &= ~LL_SBI_NOROOTSQUASH; @@ -2606,7 +2606,7 @@ void ll_compute_rootsquash_state(struct ll_sb_info *sbi) sbi->ll_flags &= ~LL_SBI_NOROOTSQUASH; spin_unlock(&sbi->ll_lock); } - up_write(&squash->rsi_sem); + spin_unlock(&squash->rsi_lock); } /** diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 78ec0fa65c58..db2fbf1f3a50 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1133,7 +1133,7 @@ static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v) struct root_squash_info *squash = &sbi->ll_squash; int len; - down_read(&squash->rsi_sem); + spin_lock(&squash->rsi_lock); if (!list_empty(&squash->rsi_nosquash_nids)) { len = cfs_print_nidlist(m->buf + m->count, m->size - m->count, &squash->rsi_nosquash_nids); @@ -1142,7 +1142,7 @@ static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v) } else { seq_puts(m, "NONE\n"); } - up_read(&squash->rsi_sem); + spin_unlock(&squash->rsi_lock); return 0; } diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 27d73c95403d..aed33068ff3c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, if ((len == 4 && !strncmp(kernbuf, "NONE", len)) || (len == 5 && !strncmp(kernbuf, "clear", len))) { /* empty string is special case */ - down_write(&squash->rsi_sem); + spin_lock(&squash->rsi_lock); if (!list_empty(&squash->rsi_nosquash_nids)) cfs_free_nidlist(&squash->rsi_nosquash_nids); - up_write(&squash->rsi_sem); + spin_unlock(&squash->rsi_lock); LCONSOLE_INFO("%s: nosquash_nids is cleared\n", name); kfree(kernbuf); return count; @@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, kfree(kernbuf); kernbuf = NULL; - down_write(&squash->rsi_sem); + spin_lock(&squash->rsi_lock); if (!list_empty(&squash->rsi_nosquash_nids)) cfs_free_nidlist(&squash->rsi_nosquash_nids); list_splice(&tmp, &squash->rsi_nosquash_nids); - up_write(&squash->rsi_sem); + spin_unlock(&squash->rsi_lock); return count; From neilb at suse.com Tue Feb 19 00:09:05 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:05 +1100 Subject: [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494593.24125.427229089746560574.stgit@noble.brown> Some of these are unused. One is used in a minimal way where it is easier to use an explicit number. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 -- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ---- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 -- .../lustre/lustre/obdclass/lprocfs_status.c | 2 -- 5 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 74c7644d6ef8..261857e4540d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -392,8 +392,6 @@ static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns) return 0; } -#undef MAX_STRING_SIZE - struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res) { LASSERT(res); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d97abbfddccf..fda6d9b07952 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -906,8 +906,6 @@ void ll_lli_init(struct ll_inode_info *lli) memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE); } -#define MAX_STRING_SIZE 128 - int ll_fill_super(struct super_block *sb) { struct lustre_profile *lprof = NULL; @@ -916,7 +914,7 @@ int ll_fill_super(struct super_block *sb) char *dt = NULL, *md = NULL; char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; - char name[MAX_STRING_SIZE]; + char name[128]; char *ptr; int len; int err; @@ -960,7 +958,7 @@ int ll_fill_super(struct super_block *sb) len -= 7; /* Mount info */ - snprintf(name, MAX_STRING_SIZE, "%.*s-%px", len, + snprintf(name, sizeof(name), "%.*s-%px", len, lsi->lsi_lmd->lmd_profile, sb); /* Call ll_debugsfs_register_super() before lustre_process_log() diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index db2fbf1f3a50..5ed703d7bb1e 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1187,8 +1187,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { NULL } }; -#define MAX_STRING_SIZE 128 - static struct attribute *llite_attrs[] = { &lustre_attr_blocksize.attr, &lustre_attr_stat_blocksize.attr, @@ -1434,8 +1432,6 @@ void ll_debugfs_unregister_super(struct super_block *sb) lprocfs_free_stats(&sbi->ll_stats); } -#undef MAX_STRING_SIZE - #define pct(a, b) (b ? a * 100 / b : 0) static void ll_display_extents_info(struct ll_rw_extents_info *io_extents, diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 35dff0e96bf7..138e124bd05e 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -273,8 +273,6 @@ static int lmv_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize) return rc; } -#define MAX_STRING_SIZE 128 - static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) { struct lmv_obd *lmv = &obd->u.lmv; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index aed33068ff3c..a179b0d6979e 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -271,8 +271,6 @@ static int lprocfs_no_percpu_stats; module_param(lprocfs_no_percpu_stats, int, 0644); MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats"); -#define MAX_STRING_SIZE 128 - /* lprocfs API calls */ static const struct file_operations lprocfs_generic_fops = { }; From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494599.24125.1795878344125234751.stgit@noble.brown> These shift loops seem to be trying to avoid doing a multiplication. We same effect can be achieved more transparently using rounddown_pow_of_two(). Even though there is a multiplication in the C code, the resulting machine code just does a single shift. Signed-off-by: NeilBrown --- .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index a179b0d6979e..637aaca96888 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, u32 blk_size = osfs.os_bsize >> 10; u64 result = osfs.os_blocks; - while (blk_size >>= 1) - result <<= 1; - + result *= rounddown_pow_of_two(blk_size); return sprintf(buf, "%llu\n", result); } @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, u32 blk_size = osfs.os_bsize >> 10; u64 result = osfs.os_bfree; - while (blk_size >>= 1) - result <<= 1; + result *= rounddown_pow_of_two(blk_size); return sprintf(buf, "%llu\n", result); } @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, u32 blk_size = osfs.os_bsize >> 10; u64 result = osfs.os_bavail; - while (blk_size >>= 1) - result <<= 1; + result *= rounddown_pow_of_two(blk_size); return sprintf(buf, "%llu\n", result); } From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494604.24125.7873412904407447511.stgit@noble.brown> This patch changes a lot of places that use spaces for alignment to instead use tabs - though in one case in a comment, spaces are used in place of tabs to be more consistent. Signed-off-by: NeilBrown --- .../lustre/include/linux/libcfs/libcfs_cpu.h | 2 .../lustre/include/linux/libcfs/libcfs_crypto.h | 10 - .../lustre/include/linux/libcfs/libcfs_debug.h | 30 +- .../lustre/include/linux/libcfs/libcfs_fail.h | 12 - .../lustre/include/linux/libcfs/libcfs_hash.h | 24 + .../lustre/include/linux/libcfs/libcfs_private.h | 2 .../staging/lustre/include/linux/lnet/lib-lnet.h | 4 .../staging/lustre/include/linux/lnet/socklnd.h | 2 .../lustre/include/uapi/linux/lnet/libcfs_debug.h | 124 +++---- .../lustre/include/uapi/linux/lnet/libcfs_ioctl.h | 56 +-- .../lustre/include/uapi/linux/lnet/lnet-types.h | 10 - .../lustre/include/uapi/linux/lnet/lnetst.h | 14 - .../lustre/include/uapi/linux/lnet/nidstr.h | 6 .../include/uapi/linux/lustre/lustre_fiemap.h | 2 .../lustre/include/uapi/linux/lustre/lustre_idl.h | 350 +++++++++---------- .../lustre/include/uapi/linux/lustre/lustre_user.h | 378 ++++++++++---------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 60 ++- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 32 +- drivers/staging/lustre/lnet/lnet/nidstrings.c | 4 drivers/staging/lustre/lnet/selftest/timer.c | 8 drivers/staging/lustre/lustre/fld/lproc_fld.c | 2 .../staging/lustre/lustre/include/lustre_import.h | 6 drivers/staging/lustre/lustre/include/obd.h | 10 - drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 6 drivers/staging/lustre/lustre/llite/file.c | 2 drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 drivers/staging/lustre/lustre/llite/xattr.c | 2 drivers/staging/lustre/lustre/lov/lov_ea.c | 2 drivers/staging/lustre/lustre/lov/lov_obd.c | 26 + drivers/staging/lustre/lustre/mgc/mgc_request.c | 24 + drivers/staging/lustre/lustre/obdclass/genops.c | 6 drivers/staging/lustre/lustre/obdclass/lu_object.c | 8 drivers/staging/lustre/lustre/obdclass/obd_sysfs.c | 2 drivers/staging/lustre/lustre/osc/osc_request.c | 40 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 35 files changed, 635 insertions(+), 635 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index 3e51752491d0..56905317fab0 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -372,7 +372,7 @@ enum { struct cfs_percpt_lock { /* cpu-partition-table for this lock */ - struct cfs_cpt_table *pcl_cptab; + struct cfs_cpt_table *pcl_cptab; /* exclusively locked */ unsigned int pcl_locked; /* private lock table */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h index ca8620b93de7..03da963b8d33 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h @@ -33,17 +33,17 @@ struct page; struct cfs_crypto_hash_type { - char *cht_name; /*< hash algorithm name, equal to + char *cht_name; /*< hash algorithm name, equal to * format name for crypto api */ - unsigned int cht_key; /*< init key by default (valid for + unsigned int cht_key; /*< init key by default (valid for * 4 bytes context like crc32, adler */ - unsigned int cht_size; /**< hash digest size */ + unsigned int cht_size; /**< hash digest size */ }; enum cfs_crypto_hash_alg { - CFS_HASH_ALG_NULL = 0, + CFS_HASH_ALG_NULL = 0, CFS_HASH_ALG_ADLER32, CFS_HASH_ALG_CRC32, CFS_HASH_ALG_CRC32C, @@ -54,7 +54,7 @@ enum cfs_crypto_hash_alg { CFS_HASH_ALG_SHA384, CFS_HASH_ALG_SHA512, CFS_HASH_ALG_MAX, - CFS_HASH_ALG_SPEED_MAX = CFS_HASH_ALG_MD5, + CFS_HASH_ALG_SPEED_MAX = CFS_HASH_ALG_MD5, CFS_HASH_ALG_UNKNOWN = 0xff }; diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 3fd6ad7a3b56..ba5d5ba2dac2 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -68,11 +68,11 @@ extern unsigned int libcfs_panic_on_lbug; #if !defined(__x86_64__) # ifdef __ia64__ # define CDEBUG_STACK() (THREAD_SIZE - \ - ((unsigned long)__builtin_dwarf_cfa() & \ + ((unsigned long)__builtin_dwarf_cfa() & \ (THREAD_SIZE - 1))) # else # define CDEBUG_STACK() (THREAD_SIZE - \ - ((unsigned long)__builtin_frame_address(0) & \ + ((unsigned long)__builtin_frame_address(0) & \ (THREAD_SIZE - 1))) # endif /* __ia64__ */ @@ -87,7 +87,7 @@ do { \ (msgdata)->msg_mask = mask; \ (msgdata)->msg_cdls = cdls; \ dump_stack(); \ - /*panic("LBUG");*/ \ + /*panic("LBUG");*/ \ } \ } while (0) #define CFS_CHECK_STACK(msgdata, mask, cdls) __CHECK_STACK(msgdata, mask, cdls) @@ -120,22 +120,22 @@ struct libcfs_debug_msg_data { #define LIBCFS_DEBUG_MSG_DATA_INIT(data, mask, cdls) \ do { \ - (data)->msg_subsys = DEBUG_SUBSYSTEM; \ - (data)->msg_file = __FILE__; \ - (data)->msg_fn = __func__; \ - (data)->msg_line = __LINE__; \ - (data)->msg_cdls = (cdls); \ - (data)->msg_mask = (mask); \ + (data)->msg_subsys = DEBUG_SUBSYSTEM; \ + (data)->msg_file = __FILE__; \ + (data)->msg_fn = __func__; \ + (data)->msg_line = __LINE__; \ + (data)->msg_cdls = (cdls); \ + (data)->msg_mask = (mask); \ } while (0) #define LIBCFS_DEBUG_MSG_DATA_DECL(dataname, mask, cdls) \ static struct libcfs_debug_msg_data dataname = { \ - .msg_subsys = DEBUG_SUBSYSTEM, \ - .msg_file = __FILE__, \ - .msg_fn = __func__, \ - .msg_line = __LINE__, \ - .msg_cdls = (cdls) }; \ - dataname.msg_mask = (mask) + .msg_subsys = DEBUG_SUBSYSTEM, \ + .msg_file = __FILE__, \ + .msg_fn = __func__, \ + .msg_line = __LINE__, \ + .msg_cdls = (cdls) }; \ + dataname.msg_mask = (mask) /** * Filters out logging messages based on mask and subsystem. diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h index 4a4197874f80..0e73eef6a992 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h @@ -47,10 +47,10 @@ int __cfs_fail_check_set(u32 id, u32 value, int set); int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set); enum { - CFS_FAIL_LOC_NOSET = 0, - CFS_FAIL_LOC_ORSET = 1, - CFS_FAIL_LOC_RESET = 2, - CFS_FAIL_LOC_VALUE = 3 + CFS_FAIL_LOC_NOSET = 0, + CFS_FAIL_LOC_ORSET = 1, + CFS_FAIL_LOC_RESET = 2, + CFS_FAIL_LOC_VALUE = 3 }; /* Failure injection control */ @@ -76,8 +76,8 @@ enum { static inline bool CFS_FAIL_PRECHECK(u32 id) { return cfs_fail_loc && - ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) || - (cfs_fail_loc & id & CFS_FAULT)); + ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) || + (cfs_fail_loc & id & CFS_FAULT)); } static inline int cfs_fail_check_set(u32 id, u32 value, diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index be315958a4b3..89d25ca57c18 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -304,25 +304,25 @@ struct cfs_hash_ops { unsigned int (*hs_hash)(struct cfs_hash *hs, const void *key, unsigned int mask); /** return key address of @hnode */ - void * (*hs_key)(struct hlist_node *hnode); + void * (*hs_key)(struct hlist_node *hnode); /** copy key from @hnode to @key */ - void (*hs_keycpy)(struct hlist_node *hnode, void *key); + void (*hs_keycpy)(struct hlist_node *hnode, void *key); /** * compare @key with key of @hnode * returns 1 on a match */ - int (*hs_keycmp)(const void *key, struct hlist_node *hnode); + int (*hs_keycmp)(const void *key, struct hlist_node *hnode); /** return object address of @hnode, i.e: container_of(...hnode) */ - void * (*hs_object)(struct hlist_node *hnode); + void * (*hs_object)(struct hlist_node *hnode); /** get refcount of item, always called with holding bucket-lock */ - void (*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode); + void (*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode); /** release refcount of item */ - void (*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode); + void (*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode); /** release refcount of item, always called with holding bucket-lock */ - void (*hs_put_locked)(struct cfs_hash *hs, - struct hlist_node *hnode); + void (*hs_put_locked)(struct cfs_hash *hs, + struct hlist_node *hnode); /** it's called before removing of @hnode */ - void (*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode); + void (*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode); }; /** total number of buckets in @hs */ @@ -460,8 +460,8 @@ static inline int cfs_hash_bkt_size(struct cfs_hash *hs) { return offsetof(struct cfs_hash_bucket, hsb_head[0]) + - hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) + - hs->hs_extra_bytes; + hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) + + hs->hs_extra_bytes; } static inline unsigned @@ -703,7 +703,7 @@ void *cfs_hash_del(struct cfs_hash *hs, const void *key, void *cfs_hash_del_key(struct cfs_hash *hs, const void *key); /* Hash lookup/for_each functions */ -#define CFS_HASH_LOOP_HOG 1024 +#define CFS_HASH_LOOP_HOG 1024 typedef int (*cfs_hash_for_each_cb_t)(struct cfs_hash *hs, struct cfs_hash_bd *bd, diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index d525e4f928fe..515fd63708c0 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -141,7 +141,7 @@ void cfs_array_free(void *vars); #define LASSERT_ATOMIC_GT_LT(a, v1, v2) \ do { \ int __v = atomic_read(a); \ - LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v); \ + LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v); \ } while (0) /** assert value of @a is great than @v1 and little/equal to @v2 */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index fb5d07460243..e60c446fbb27 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -611,7 +611,7 @@ void lnet_counters_reset(void); unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov); int lnet_extract_iov(int dst_niov, struct kvec *dst, int src_niov, const struct kvec *src, - unsigned int offset, unsigned int len); + unsigned int offset, unsigned int len); unsigned int lnet_kiov_nob(unsigned int niov, struct bio_vec *iov); int lnet_extract_kiov(int dst_niov, struct bio_vec *dst, @@ -827,7 +827,7 @@ void lnet_incr_stats(struct lnet_element_stats *stats, enum lnet_stats_type stats_type); u32 lnet_sum_stats(struct lnet_element_stats *stats, - enum lnet_stats_type stats_type); + enum lnet_stats_type stats_type); void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, struct lnet_element_stats *stats); diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h index ca814afd34ef..9f318b73cd34 100644 --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h @@ -41,7 +41,7 @@ struct ksock_hello_msg { u32 kshm_magic; /* magic number of socklnd message */ u32 kshm_version; /* version of socklnd message */ - lnet_nid_t kshm_src_nid; /* sender's nid */ + lnet_nid_t kshm_src_nid; /* sender's nid */ lnet_nid_t kshm_dst_nid; /* destination nid */ lnet_pid_t kshm_src_pid; /* sender's pid */ lnet_pid_t kshm_dst_pid; /* destination pid */ diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h index 2672fe7ae103..91d80ab064ad 100644 --- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h +++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h @@ -62,38 +62,38 @@ struct ptldebug_header { #define PH_FLAG_FIRST_RECORD 1 /* Debugging subsystems (32 bits, non-overlapping) */ -#define S_UNDEFINED 0x00000001 -#define S_MDC 0x00000002 -#define S_MDS 0x00000004 -#define S_OSC 0x00000008 -#define S_OST 0x00000010 -#define S_CLASS 0x00000020 -#define S_LOG 0x00000040 -#define S_LLITE 0x00000080 -#define S_RPC 0x00000100 -#define S_MGMT 0x00000200 -#define S_LNET 0x00000400 -#define S_LND 0x00000800 /* ALL LNDs */ -#define S_PINGER 0x00001000 -#define S_FILTER 0x00002000 -#define S_LIBCFS 0x00004000 -#define S_ECHO 0x00008000 -#define S_LDLM 0x00010000 -#define S_LOV 0x00020000 -#define S_LQUOTA 0x00040000 -#define S_OSD 0x00080000 -#define S_LFSCK 0x00100000 -#define S_SNAPSHOT 0x00200000 +#define S_UNDEFINED 0x00000001 +#define S_MDC 0x00000002 +#define S_MDS 0x00000004 +#define S_OSC 0x00000008 +#define S_OST 0x00000010 +#define S_CLASS 0x00000020 +#define S_LOG 0x00000040 +#define S_LLITE 0x00000080 +#define S_RPC 0x00000100 +#define S_MGMT 0x00000200 +#define S_LNET 0x00000400 +#define S_LND 0x00000800 /* ALL LNDs */ +#define S_PINGER 0x00001000 +#define S_FILTER 0x00002000 +#define S_LIBCFS 0x00004000 +#define S_ECHO 0x00008000 +#define S_LDLM 0x00010000 +#define S_LOV 0x00020000 +#define S_LQUOTA 0x00040000 +#define S_OSD 0x00080000 +#define S_LFSCK 0x00100000 +#define S_SNAPSHOT 0x00200000 /* unused */ -#define S_LMV 0x00800000 /* b_new_cmd */ +#define S_LMV 0x00800000 /* b_new_cmd */ /* unused */ -#define S_SEC 0x02000000 /* upcall cache */ -#define S_GSS 0x04000000 /* b_new_cmd */ +#define S_SEC 0x02000000 /* upcall cache */ +#define S_GSS 0x04000000 /* b_new_cmd */ /* unused */ -#define S_MGC 0x10000000 -#define S_MGS 0x20000000 -#define S_FID 0x40000000 /* b_new_cmd */ -#define S_FLD 0x80000000 /* b_new_cmd */ +#define S_MGC 0x10000000 +#define S_MGS 0x20000000 +#define S_FID 0x40000000 /* b_new_cmd */ +#define S_FLD 0x80000000 /* b_new_cmd */ #define LIBCFS_DEBUG_SUBSYS_NAMES { \ "undefined", "mdc", "mds", "osc", "ost", "class", "log", \ @@ -103,38 +103,38 @@ struct ptldebug_header { "fid", "fld", NULL } /* Debugging masks (32 bits, non-overlapping) */ -#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */ -#define D_INODE 0x00000002 -#define D_SUPER 0x00000004 -#define D_EXT2 0x00000008 /* anything from ext2_debug */ -#define D_MALLOC 0x00000010 /* print malloc, free information */ -#define D_CACHE 0x00000020 /* cache-related items */ -#define D_INFO 0x00000040 /* general information */ -#define D_IOCTL 0x00000080 /* ioctl related information */ -#define D_NETERROR 0x00000100 /* network errors */ -#define D_NET 0x00000200 /* network communications */ -#define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */ -#define D_BUFFS 0x00000800 -#define D_OTHER 0x00001000 -#define D_DENTRY 0x00002000 -#define D_NETTRACE 0x00004000 -#define D_PAGE 0x00008000 /* bulk page handling */ -#define D_DLMTRACE 0x00010000 -#define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */ -#define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */ -#define D_HA 0x00080000 /* recovery and failover */ -#define D_RPCTRACE 0x00100000 /* for distributed debugging */ -#define D_VFSTRACE 0x00200000 -#define D_READA 0x00400000 /* read-ahead */ -#define D_MMAP 0x00800000 -#define D_CONFIG 0x01000000 -#define D_CONSOLE 0x02000000 -#define D_QUOTA 0x04000000 -#define D_SEC 0x08000000 -#define D_LFSCK 0x10000000 /* For both OI scrub and LFSCK */ -#define D_HSM 0x20000000 -#define D_SNAPSHOT 0x40000000 /* snapshot */ -#define D_LAYOUT 0x80000000 +#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */ +#define D_INODE 0x00000002 +#define D_SUPER 0x00000004 +#define D_EXT2 0x00000008 /* anything from ext2_debug */ +#define D_MALLOC 0x00000010 /* print malloc, free information */ +#define D_CACHE 0x00000020 /* cache-related items */ +#define D_INFO 0x00000040 /* general information */ +#define D_IOCTL 0x00000080 /* ioctl related information */ +#define D_NETERROR 0x00000100 /* network errors */ +#define D_NET 0x00000200 /* network communications */ +#define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */ +#define D_BUFFS 0x00000800 +#define D_OTHER 0x00001000 +#define D_DENTRY 0x00002000 +#define D_NETTRACE 0x00004000 +#define D_PAGE 0x00008000 /* bulk page handling */ +#define D_DLMTRACE 0x00010000 +#define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */ +#define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */ +#define D_HA 0x00080000 /* recovery and failover */ +#define D_RPCTRACE 0x00100000 /* for distributed debugging */ +#define D_VFSTRACE 0x00200000 +#define D_READA 0x00400000 /* read-ahead */ +#define D_MMAP 0x00800000 +#define D_CONFIG 0x01000000 +#define D_CONSOLE 0x02000000 +#define D_QUOTA 0x04000000 +#define D_SEC 0x08000000 +#define D_LFSCK 0x10000000 /* For both OI scrub and LFSCK */ +#define D_HSM 0x20000000 +#define D_SNAPSHOT 0x40000000 /* snapshot */ +#define D_LAYOUT 0x80000000 #define LIBCFS_DEBUG_MASKS_NAMES { \ "trace", "inode", "super", "ext2", "malloc", "cache", "info", \ @@ -144,7 +144,7 @@ struct ptldebug_header { "console", "quota", "sec", "lfsck", "hsm", "snapshot", "layout",\ NULL } -#define D_CANTMASK (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE) +#define D_CANTMASK (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE) #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log" diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h index 4590f65c333f..765466f41d61 100644 --- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h @@ -82,41 +82,41 @@ struct libcfs_debug_ioctl_data { }; /* 'f' ioctls are defined in lustre_ioctl.h and lustre_user.h except for: */ -#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long) -#define IOCTL_LIBCFS_TYPE long +#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long) +#define IOCTL_LIBCFS_TYPE long -#define IOC_LIBCFS_TYPE ('e') -#define IOC_LIBCFS_MIN_NR 30 +#define IOC_LIBCFS_TYPE ('e') +#define IOC_LIBCFS_MIN_NR 30 /* libcfs ioctls */ /* IOC_LIBCFS_PANIC obsolete in 2.8.0, was _IOWR('e', 30, IOCTL_LIBCFS_TYPE) */ -#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, IOCTL_LIBCFS_TYPE) /* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */ /* lnet ioctls */ -#define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, IOCTL_LIBCFS_TYPE) /* IOC_LIBCFS_PORTALS_COMPATIBILITY _IOWR('e', 57, IOCTL_LIBCFS_TYPE) */ -#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_PING _IOWR('e', 61, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_PING_PEER _IOWR('e', 62, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_LNETST _IOWR('e', 63, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_LNET_FAULT _IOWR('e', 64, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_PING _IOWR('e', 61, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_PING_PEER _IOWR('e', 62, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_LNETST _IOWR('e', 63, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_LNET_FAULT _IOWR('e', 64, IOCTL_LIBCFS_TYPE) /* lnd ioctls */ -#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_DISCOVER _IOWR('e', 77, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, IOCTL_LIBCFS_TYPE) -#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_DISCOVER _IOWR('e', 77, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, IOCTL_LIBCFS_TYPE) +#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, IOCTL_LIBCFS_TYPE) /* * DLC Specific IOCTL numbers. diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h index 4fcc5336d927..956af3c53cfc 100644 --- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h @@ -289,9 +289,9 @@ struct lnet_counters { __u64 drop_length; } __packed; -#define LNET_NI_STATUS_UP 0x15aac0de -#define LNET_NI_STATUS_DOWN 0xdeadface -#define LNET_NI_STATUS_INVALID 0x00000000 +#define LNET_NI_STATUS_UP 0x15aac0de +#define LNET_NI_STATUS_DOWN 0xdeadface +#define LNET_NI_STATUS_INVALID 0x00000000 #define LNET_INTERFACES_NUM 16 @@ -596,7 +596,7 @@ enum lnet_event_kind { LNET_EVENT_UNLINK, }; -#define LNET_SEQ_GT(a, b) (((signed long)((a) - (b))) > 0) +#define LNET_SEQ_GT(a, b) (((signed long)((a) - (b))) > 0) /** * Information about an event on a MD. @@ -650,7 +650,7 @@ struct lnet_event { * The message type, to ensure a handler for LNET_EVENT_SEND can * distinguish between LNET_MSG_GET and LNET_MSG_PUT. */ - __u32 msg_type; + __u32 msg_type; /** * Indicates the completion status of the operation. It's 0 for * successful operations, otherwise it's an error code. diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h index a6eebee1a69c..27fcd91931a6 100644 --- a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h @@ -58,7 +58,7 @@ */ #define LSTIO_GROUP_DEL 0xC13 /* delete group */ #define LSTIO_NODES_ADD 0xC14 /* add nodes to specified group */ -#define LSTIO_GROUP_UPDATE 0xC15 /* update group */ +#define LSTIO_GROUP_UPDATE 0xC15 /* update group */ #define LSTIO_BATCH_ADD 0xC20 /* add batch */ #define LSTIO_BATCH_START 0xC21 /* start batch */ #define LSTIO_BATCH_STOP 0xC22 /* stop batch */ @@ -100,9 +100,9 @@ struct lstcon_ndlist_ent { }; /*** node_list entry, for list_batch command */ struct lstcon_test_ent { - int tse_type; /* test type */ - int tse_loop; /* loop count */ - int tse_concur; /* concurrency of test */ + int tse_type; /* test type */ + int tse_loop; /* loop count */ + int tse_concur; /* concurrency of test */ }; /* test summary entry, for * list_batch command */ @@ -520,9 +520,9 @@ enum lst_brw_flags { struct lst_test_bulk_param { int blk_opc; /* bulk operation code */ - int blk_size; /* size (bytes) */ - int blk_time; /* time of running the test*/ - int blk_flags; /* reserved flags */ + int blk_size; /* size (bytes) */ + int blk_time; /* time of running the test*/ + int blk_flags; /* reserved flags */ int blk_cli_off; /* bulk offset on client */ int blk_srv_off; /* reserved: bulk offset on server */ }; diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h index 3c5901d81d52..6c49d59f4f85 100644 --- a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h +++ b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h @@ -44,7 +44,7 @@ enum { /*GMLND = 3, removed v2_0_0-rc1a-16-gc660aac */ /*PTLLND = 4, removed v2_7_50 */ O2IBLND = 5, - /*CIBLND = 6, removed v2_0_0-rc1a-175-gd2b8a0e */ + /*CIBLND = 6, removed v2_0_0-rc1a-175-gd2b8a0e */ /*OPENIBLND = 7, removed v2_0_0-rc1a-175-gd2b8a0e */ /*IIBLND = 8, removed v2_0_0-rc1a-175-gd2b8a0e */ LOLND = 9, @@ -57,8 +57,8 @@ enum { struct list_head; -#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ -#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ +#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ +#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ /* support decl needed by both kernel and user space */ char *libcfs_next_nidstring(void); diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h index d24a93e57ed7..7ecb6f6354cc 100644 --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h @@ -49,7 +49,7 @@ static inline size_t fiemap_count_to_size(size_t extent_count) { return sizeof(struct fiemap) + extent_count * - sizeof(struct fiemap_extent); + sizeof(struct fiemap_extent); } static inline unsigned int fiemap_size_to_count(size_t array_size) diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h index bffe62e87e00..62b9a3301c4d 100644 --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -443,14 +443,14 @@ struct luda_type { }; #ifndef IFSHIFT -#define IFSHIFT 12 +#define IFSHIFT 12 #endif #ifndef IFTODT -#define IFTODT(type) (((type) & S_IFMT) >> IFSHIFT) +#define IFTODT(type) (((type) & S_IFMT) >> IFSHIFT) #endif #ifndef DTTOIF -#define DTTOIF(dirtype) ((dirtype) << IFSHIFT) +#define DTTOIF(dirtype) ((dirtype) << IFSHIFT) #endif struct lu_dirpage { @@ -551,8 +551,8 @@ static inline void lustre_handle_copy(struct lustre_handle *tgt, } /* flags for lm_flags */ -#define MSGHDR_AT_SUPPORT 0x1 -#define MSGHDR_CKSUM_INCOMPAT18 0x2 +#define MSGHDR_AT_SUPPORT 0x1 +#define MSGHDR_CKSUM_INCOMPAT18 0x2 #define lustre_msg lustre_msg_v2 /* we depend on this structure to be 8-byte aligned */ @@ -570,7 +570,7 @@ struct lustre_msg_v2 { }; /* without gss, ptlrpc_body is put at the first buffer. */ -#define PTLRPC_NUM_VERSIONS 4 +#define PTLRPC_NUM_VERSIONS 4 struct ptlrpc_body_v3 { struct lustre_handle pb_handle; @@ -578,8 +578,8 @@ struct ptlrpc_body_v3 { __u32 pb_version; __u32 pb_opc; __u32 pb_status; - __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ - __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ + __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ + __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ __u16 pb_padding0; __u32 pb_padding1; __u64 pb_last_committed; @@ -587,13 +587,13 @@ struct ptlrpc_body_v3 { __u32 pb_flags; __u32 pb_op_flags; __u32 pb_conn_cnt; - __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ - __u32 pb_service_time; /* for rep, actual service time */ + __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ + __u32 pb_service_time; /* for rep, actual service time */ __u32 pb_limit; __u64 pb_slv; /* VBR: pre-versions */ __u64 pb_pre_versions[PTLRPC_NUM_VERSIONS]; - __u64 pb_mbits; /**< match bits for bulk request */ + __u64 pb_mbits; /**< match bits for bulk request */ /* padding for future needs */ __u64 pb_padding64_0; __u64 pb_padding64_1; @@ -601,7 +601,7 @@ struct ptlrpc_body_v3 { char pb_jobid[LUSTRE_JOBID_SIZE]; }; -#define ptlrpc_body ptlrpc_body_v3 +#define ptlrpc_body ptlrpc_body_v3 struct ptlrpc_body_v2 { struct lustre_handle pb_handle; @@ -609,8 +609,8 @@ struct ptlrpc_body_v2 { __u32 pb_version; __u32 pb_opc; __u32 pb_status; - __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ - __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ + __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ + __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ __u16 pb_padding0; __u32 pb_padding1; __u64 pb_last_committed; @@ -618,10 +618,10 @@ struct ptlrpc_body_v2 { __u32 pb_flags; __u32 pb_op_flags; __u32 pb_conn_cnt; - __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ - __u32 pb_service_time; /* for rep, actual service time, also used for - * net_latency of req - */ + __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ + __u32 pb_service_time; /* for rep, actual service time, also used for + * net_latency of req + */ __u32 pb_limit; __u64 pb_slv; /* VBR: pre-versions */ @@ -881,66 +881,66 @@ enum cksum_type { /* opcodes */ enum ost_cmd { - OST_REPLY = 0, /* reply ? */ - OST_GETATTR = 1, - OST_SETATTR = 2, - OST_READ = 3, - OST_WRITE = 4, - OST_CREATE = 5, - OST_DESTROY = 6, - OST_GET_INFO = 7, - OST_CONNECT = 8, - OST_DISCONNECT = 9, - OST_PUNCH = 10, - OST_OPEN = 11, - OST_CLOSE = 12, - OST_STATFS = 13, - OST_SYNC = 16, - OST_SET_INFO = 17, - OST_QUOTACHECK = 18, /* not used since 2.4 */ - OST_QUOTACTL = 19, + OST_REPLY = 0, /* reply ? */ + OST_GETATTR = 1, + OST_SETATTR = 2, + OST_READ = 3, + OST_WRITE = 4, + OST_CREATE = 5, + OST_DESTROY = 6, + OST_GET_INFO = 7, + OST_CONNECT = 8, + OST_DISCONNECT = 9, + OST_PUNCH = 10, + OST_OPEN = 11, + OST_CLOSE = 12, + OST_STATFS = 13, + OST_SYNC = 16, + OST_SET_INFO = 17, + OST_QUOTACHECK = 18, /* not used since 2.4 */ + OST_QUOTACTL = 19, OST_QUOTA_ADJUST_QUNIT = 20, /* not used since 2.4 */ - OST_LADVISE = 21, + OST_LADVISE = 21, OST_LAST_OPC /* must be < 33 to avoid MDS_GETATTR */ }; #define OST_FIRST_OPC OST_REPLY enum obdo_flags { - OBD_FL_INLINEDATA = 0x00000001, - OBD_FL_OBDMDEXISTS = 0x00000002, - OBD_FL_DELORPHAN = 0x00000004, /* if set in o_flags delete orphans */ - OBD_FL_NORPC = 0x00000008, /* set in o_flags do in OSC not OST */ - OBD_FL_IDONLY = 0x00000010, /* set in o_flags only adjust obj id*/ - OBD_FL_RECREATE_OBJS = 0x00000020, /* recreate missing obj */ - OBD_FL_DEBUG_CHECK = 0x00000040, /* echo client/server debug check */ - OBD_FL_NO_PRJQUOTA = 0x00000080, /* the object's project is over - * quota - */ - OBD_FL_NO_USRQUOTA = 0x00000100, /* the object's owner is over quota */ - OBD_FL_NO_GRPQUOTA = 0x00000200, /* the object's group is over quota */ - OBD_FL_CREATE_CROW = 0x00000400, /* object should be create on write */ - OBD_FL_SRVLOCK = 0x00000800, /* delegate DLM locking to server */ - OBD_FL_CKSUM_CRC32 = 0x00001000, /* CRC32 checksum type */ - OBD_FL_CKSUM_ADLER = 0x00002000, /* ADLER checksum type */ - OBD_FL_CKSUM_CRC32C = 0x00004000, /* CRC32C checksum type */ - OBD_FL_CKSUM_RSVD2 = 0x00008000, /* for future cksum types */ - OBD_FL_CKSUM_RSVD3 = 0x00010000, /* for future cksum types */ - OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */ - OBD_FL_MMAP = 0x00040000, /* object is mmapped on the client. - * XXX: obsoleted - reserved for old - * clients prior than 2.2 - */ - OBD_FL_RECOV_RESEND = 0x00080000, /* recoverable resent */ - OBD_FL_NOSPC_BLK = 0x00100000, /* no more block space on OST */ - OBD_FL_FLUSH = 0x00200000, /* flush pages on the OST */ - OBD_FL_SHORT_IO = 0x00400000, /* short io request */ + OBD_FL_INLINEDATA = 0x00000001, + OBD_FL_OBDMDEXISTS = 0x00000002, + OBD_FL_DELORPHAN = 0x00000004, /* if set in o_flags delete orphans */ + OBD_FL_NORPC = 0x00000008, /* set in o_flags do in OSC not OST */ + OBD_FL_IDONLY = 0x00000010, /* set in o_flags only adjust obj id*/ + OBD_FL_RECREATE_OBJS = 0x00000020, /* recreate missing obj */ + OBD_FL_DEBUG_CHECK = 0x00000040, /* echo client/server debug check */ + OBD_FL_NO_PRJQUOTA = 0x00000080, /* the object's project is over + * quota + */ + OBD_FL_NO_USRQUOTA = 0x00000100, /* the object's owner is over quota */ + OBD_FL_NO_GRPQUOTA = 0x00000200, /* the object's group is over quota */ + OBD_FL_CREATE_CROW = 0x00000400, /* object should be create on write */ + OBD_FL_SRVLOCK = 0x00000800, /* delegate DLM locking to server */ + OBD_FL_CKSUM_CRC32 = 0x00001000, /* CRC32 checksum type */ + OBD_FL_CKSUM_ADLER = 0x00002000, /* ADLER checksum type */ + OBD_FL_CKSUM_CRC32C = 0x00004000, /* CRC32C checksum type */ + OBD_FL_CKSUM_RSVD2 = 0x00008000, /* for future cksum types */ + OBD_FL_CKSUM_RSVD3 = 0x00010000, /* for future cksum types */ + OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */ + OBD_FL_MMAP = 0x00040000, /* object is mmapped on the client. + * XXX: obsoleted - reserved for old + * clients prior than 2.2 + */ + OBD_FL_RECOV_RESEND = 0x00080000, /* recoverable resent */ + OBD_FL_NOSPC_BLK = 0x00100000, /* no more block space on OST */ + OBD_FL_FLUSH = 0x00200000, /* flush pages on the OST */ + OBD_FL_SHORT_IO = 0x00400000, /* short io request */ /* OBD_FL_LOCAL_MASK = 0xF0000000, was local-only flags until 2.10 */ /* Note that while these checksum values are currently separate bits, * in 2.x we can actually allow all values from 1-31 if we wanted. */ - OBD_FL_CKSUM_ALL = OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER | - OBD_FL_CKSUM_CRC32C, + OBD_FL_CKSUM_ALL = (OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER | + OBD_FL_CKSUM_CRC32C), }; /* @@ -1233,9 +1233,9 @@ struct niobuf_remote { */ #define OST_LVB_ERR_INIT 0xffbadbad80000000ULL #define OST_LVB_ERR_MASK 0xffbadbad00000000ULL -#define OST_LVB_IS_ERR(blocks) \ +#define OST_LVB_IS_ERR(blocks) \ ((blocks & OST_LVB_ERR_MASK) == OST_LVB_ERR_MASK) -#define OST_LVB_SET_ERR(blocks, rc) \ +#define OST_LVB_SET_ERR(blocks, rc) \ do { blocks = OST_LVB_ERR_INIT + rc; } while (0) #define OST_LVB_GET_ERR(blocks) (int)(blocks - OST_LVB_ERR_INIT) @@ -1316,9 +1316,9 @@ struct ldlm_gl_lquota_desc { /* LVB used with quota (global and per-ID) locks */ struct lquota_lvb { __u64 lvb_flags; /* see LQUOTA_FL* above */ - __u64 lvb_id_may_rel; /* space that might be released later */ - __u64 lvb_id_rel; /* space released by the slave for this ID */ - __u64 lvb_id_qunit; /* current qunit value */ + __u64 lvb_id_may_rel; /* space that might be released later */ + __u64 lvb_id_rel; /* space released by the slave for this ID */ + __u64 lvb_id_qunit; /* current qunit value */ __u64 lvb_pad1; }; @@ -1488,17 +1488,17 @@ static inline int ll_inode_to_ext_flags(int iflags) static inline int ll_xflags_to_inode_flags(int xflags) { - return ((xflags & FS_XFLAG_SYNC) ? S_SYNC : 0) | - ((xflags & FS_XFLAG_NOATIME) ? S_NOATIME : 0) | - ((xflags & FS_XFLAG_APPEND) ? S_APPEND : 0) | + return ((xflags & FS_XFLAG_SYNC) ? S_SYNC : 0) | + ((xflags & FS_XFLAG_NOATIME) ? S_NOATIME : 0) | + ((xflags & FS_XFLAG_APPEND) ? S_APPEND : 0) | ((xflags & FS_XFLAG_IMMUTABLE) ? S_IMMUTABLE : 0); } static inline int ll_inode_flags_to_xflags(int flags) { - return ((flags & S_SYNC) ? FS_XFLAG_SYNC : 0) | - ((flags & S_NOATIME) ? FS_XFLAG_NOATIME : 0) | - ((flags & S_APPEND) ? FS_XFLAG_APPEND : 0) | + return ((flags & S_SYNC) ? FS_XFLAG_SYNC : 0) | + ((flags & S_NOATIME) ? FS_XFLAG_NOATIME : 0) | + ((flags & S_APPEND) ? FS_XFLAG_APPEND : 0) | ((flags & S_IMMUTABLE) ? FS_XFLAG_IMMUTABLE : 0); } @@ -1583,7 +1583,7 @@ struct mdt_rec_setattr { __s64 sa_ctime; __u32 sa_attr_flags; __u32 sa_mode; - __u32 sa_bias; /* some operation flags */ + __u32 sa_bias; /* some operation flags */ __u32 sa_projid; __u32 sa_padding_4; __u32 sa_padding_5; @@ -1698,17 +1698,17 @@ struct mdt_rec_create { __s64 cr_time; __u64 cr_rdev; __u64 cr_ioepoch; - __u64 cr_padding_1; /* rr_blocks */ + __u64 cr_padding_1; /* rr_blocks */ __u32 cr_mode; __u32 cr_bias; /* use of helpers set/get_mrc_cr_flags() is needed to access * 64 bits cr_flags [cr_flags_l, cr_flags_h], this is done to * extend cr_flags size without breaking 1.8 compat */ - __u32 cr_flags_l; /* for use with open, low 32 bits */ - __u32 cr_flags_h; /* for use with open, high 32 bits */ - __u32 cr_umask; /* umask for create */ - __u32 cr_padding_4; /* rr_padding_4 */ + __u32 cr_flags_l; /* for use with open, low 32 bits */ + __u32 cr_flags_h; /* for use with open, high 32 bits */ + __u32 cr_umask; /* umask for create */ + __u32 cr_padding_4; /* rr_padding_4 */ }; /* instance of mdt_reint_rec */ @@ -1726,16 +1726,16 @@ struct mdt_rec_link { struct lu_fid lk_fid1; struct lu_fid lk_fid2; __s64 lk_time; - __u64 lk_padding_1; /* rr_atime */ - __u64 lk_padding_2; /* rr_ctime */ - __u64 lk_padding_3; /* rr_size */ - __u64 lk_padding_4; /* rr_blocks */ + __u64 lk_padding_1; /* rr_atime */ + __u64 lk_padding_2; /* rr_ctime */ + __u64 lk_padding_3; /* rr_size */ + __u64 lk_padding_4; /* rr_blocks */ __u32 lk_bias; - __u32 lk_padding_5; /* rr_mode */ - __u32 lk_padding_6; /* rr_flags */ - __u32 lk_padding_7; /* rr_padding_2 */ - __u32 lk_padding_8; /* rr_padding_3 */ - __u32 lk_padding_9; /* rr_padding_4 */ + __u32 lk_padding_5; /* rr_mode */ + __u32 lk_padding_6; /* rr_flags */ + __u32 lk_padding_7; /* rr_padding_2 */ + __u32 lk_padding_8; /* rr_padding_3 */ + __u32 lk_padding_9; /* rr_padding_4 */ }; /* instance of mdt_reint_rec */ @@ -1753,16 +1753,16 @@ struct mdt_rec_unlink { struct lu_fid ul_fid1; struct lu_fid ul_fid2; __s64 ul_time; - __u64 ul_padding_2; /* rr_atime */ - __u64 ul_padding_3; /* rr_ctime */ - __u64 ul_padding_4; /* rr_size */ - __u64 ul_padding_5; /* rr_blocks */ + __u64 ul_padding_2; /* rr_atime */ + __u64 ul_padding_3; /* rr_ctime */ + __u64 ul_padding_4; /* rr_size */ + __u64 ul_padding_5; /* rr_blocks */ __u32 ul_bias; __u32 ul_mode; - __u32 ul_padding_6; /* rr_flags */ - __u32 ul_padding_7; /* rr_padding_2 */ - __u32 ul_padding_8; /* rr_padding_3 */ - __u32 ul_padding_9; /* rr_padding_4 */ + __u32 ul_padding_6; /* rr_flags */ + __u32 ul_padding_7; /* rr_padding_2 */ + __u32 ul_padding_8; /* rr_padding_3 */ + __u32 ul_padding_9; /* rr_padding_4 */ }; /* instance of mdt_reint_rec */ @@ -1777,19 +1777,19 @@ struct mdt_rec_rename { __u32 rn_suppgid1_h; __u32 rn_suppgid2; __u32 rn_suppgid2_h; - struct lu_fid rn_fid1; - struct lu_fid rn_fid2; + struct lu_fid rn_fid1; + struct lu_fid rn_fid2; __s64 rn_time; - __u64 rn_padding_1; /* rr_atime */ - __u64 rn_padding_2; /* rr_ctime */ - __u64 rn_padding_3; /* rr_size */ - __u64 rn_padding_4; /* rr_blocks */ + __u64 rn_padding_1; /* rr_atime */ + __u64 rn_padding_2; /* rr_ctime */ + __u64 rn_padding_3; /* rr_size */ + __u64 rn_padding_4; /* rr_blocks */ __u32 rn_bias; /* some operation flags */ __u32 rn_mode; /* cross-ref rename has mode */ - __u32 rn_padding_5; /* rr_flags */ - __u32 rn_padding_6; /* rr_padding_2 */ - __u32 rn_padding_7; /* rr_padding_3 */ - __u32 rn_padding_8; /* rr_padding_4 */ + __u32 rn_padding_5; /* rr_flags */ + __u32 rn_padding_6; /* rr_padding_2 */ + __u32 rn_padding_7; /* rr_padding_3 */ + __u32 rn_padding_8; /* rr_padding_4 */ }; /* instance of mdt_reint_rec */ @@ -1804,21 +1804,21 @@ struct mdt_rec_setxattr { __u32 sx_suppgid1_h; __u32 sx_suppgid2; __u32 sx_suppgid2_h; - struct lu_fid sx_fid; - __u64 sx_padding_1; /* These three are rr_fid2 */ + struct lu_fid sx_fid; + __u64 sx_padding_1; /* These three are rr_fid2 */ __u32 sx_padding_2; __u32 sx_padding_3; __u64 sx_valid; __s64 sx_time; - __u64 sx_padding_5; /* rr_ctime */ - __u64 sx_padding_6; /* rr_size */ - __u64 sx_padding_7; /* rr_blocks */ + __u64 sx_padding_5; /* rr_ctime */ + __u64 sx_padding_6; /* rr_size */ + __u64 sx_padding_7; /* rr_blocks */ __u32 sx_size; __u32 sx_flags; - __u32 sx_padding_8; /* rr_flags */ - __u32 sx_padding_9; /* rr_padding_2 */ - __u32 sx_padding_10; /* rr_padding_3 */ - __u32 sx_padding_11; /* rr_padding_4 */ + __u32 sx_padding_8; /* rr_flags */ + __u32 sx_padding_9; /* rr_padding_2 */ + __u32 sx_padding_10; /* rr_padding_3 */ + __u32 sx_padding_11; /* rr_padding_4 */ }; /* @@ -1858,13 +1858,13 @@ struct mdt_rec_reint { /* lmv structures */ struct lmv_desc { __u32 ld_tgt_count; /* how many MDS's */ - __u32 ld_active_tgt_count; /* how many active */ - __u32 ld_default_stripe_count; /* how many objects are used */ - __u32 ld_pattern; /* default hash pattern */ + __u32 ld_active_tgt_count; /* how many active */ + __u32 ld_default_stripe_count; /* how many objects are used */ + __u32 ld_pattern; /* default hash pattern */ __u64 ld_default_hash_size; __u64 ld_padding_1; /* also fix lustre_swab_lmv_desc */ __u32 ld_padding_2; /* also fix lustre_swab_lmv_desc */ - __u32 ld_qos_maxage; /* in second */ + __u32 ld_qos_maxage; /* in second */ __u32 ld_padding_3; /* also fix lustre_swab_lmv_desc */ __u32 ld_padding_4; /* also fix lustre_swab_lmv_desc */ struct obd_uuid ld_uuid; @@ -2038,20 +2038,20 @@ struct lov_desc { struct obd_uuid ld_uuid; }; -#define ld_magic ld_active_tgt_count /* for swabbing from llogs */ +#define ld_magic ld_active_tgt_count /* for swabbing from llogs */ /* * LDLM requests: */ /* opcodes -- MUST be distinct from OST/MDS opcodes */ enum ldlm_cmd { - LDLM_ENQUEUE = 101, - LDLM_CONVERT = 102, - LDLM_CANCEL = 103, + LDLM_ENQUEUE = 101, + LDLM_CONVERT = 102, + LDLM_CANCEL = 103, LDLM_BL_CALLBACK = 104, LDLM_CP_CALLBACK = 105, LDLM_GL_CALLBACK = 106, - LDLM_SET_INFO = 107, + LDLM_SET_INFO = 107, LDLM_LAST_OPC }; #define LDLM_FIRST_OPC LDLM_ENQUEUE @@ -2067,25 +2067,25 @@ struct ldlm_res_id { /* lock types */ enum ldlm_mode { - LCK_MINMODE = 0, - LCK_EX = 1, - LCK_PW = 2, - LCK_PR = 4, - LCK_CW = 8, - LCK_CR = 16, - LCK_NL = 32, - LCK_GROUP = 64, - LCK_COS = 128, + LCK_MINMODE = 0, + LCK_EX = 1, + LCK_PW = 2, + LCK_PR = 4, + LCK_CW = 8, + LCK_CR = 16, + LCK_NL = 32, + LCK_GROUP = 64, + LCK_COS = 128, LCK_MAXMODE }; -#define LCK_MODE_NUM 8 +#define LCK_MODE_NUM 8 enum ldlm_type { - LDLM_PLAIN = 10, - LDLM_EXTENT = 11, - LDLM_FLOCK = 12, - LDLM_IBITS = 13, + LDLM_PLAIN = 10, + LDLM_EXTENT = 11, + LDLM_FLOCK = 12, + LDLM_IBITS = 13, LDLM_MAX_TYPE }; @@ -2150,7 +2150,7 @@ struct ldlm_intent { struct ldlm_resource_desc { enum ldlm_type lr_type; - __u32 lr_padding; /* also fix lustre_swab_ldlm_resource_desc */ + __u32 lr_padding; /* also fix lustre_swab_ldlm_resource_desc */ struct ldlm_res_id lr_name; }; @@ -2173,7 +2173,7 @@ struct ldlm_request { struct ldlm_reply { __u32 lock_flags; - __u32 lock_padding; /* also fix lustre_swab_ldlm_reply */ + __u32 lock_padding; /* also fix lustre_swab_ldlm_reply */ struct ldlm_lock_desc lock_desc; struct lustre_handle lock_handle; __u64 lock_policy_res1; @@ -2206,9 +2206,9 @@ struct mgs_send_param { }; /* We pass this info to the MGS so it can write config logs */ -#define MTI_NAME_MAXLEN 64 +#define MTI_NAME_MAXLEN 64 #define MTI_PARAM_MAXLEN 4096 -#define MTI_NIDS_MAX 32 +#define MTI_NIDS_MAX 32 struct mgs_target_info { __u32 mti_lustre_ver; __u32 mti_stripe_index; @@ -2695,8 +2695,8 @@ enum sec_cmd { /* * capa related definitions */ -#define CAPA_HMAC_MAX_LEN 64 -#define CAPA_HMAC_KEY_MAX_LEN 56 +#define CAPA_HMAC_MAX_LEN 64 +#define CAPA_HMAC_KEY_MAX_LEN 56 /* NB take care when changing the sequence of elements this struct, * because the offset info is used in find_capa() @@ -2716,34 +2716,34 @@ struct lustre_capa { /** lustre_capa::lc_opc */ enum { - CAPA_OPC_BODY_WRITE = 1 << 0, /**< write object data */ - CAPA_OPC_BODY_READ = 1 << 1, /**< read object data */ - CAPA_OPC_INDEX_LOOKUP = 1 << 2, /**< lookup object fid */ - CAPA_OPC_INDEX_INSERT = 1 << 3, /**< insert object fid */ - CAPA_OPC_INDEX_DELETE = 1 << 4, /**< delete object fid */ - CAPA_OPC_OSS_WRITE = 1 << 5, /**< write oss object data */ - CAPA_OPC_OSS_READ = 1 << 6, /**< read oss object data */ - CAPA_OPC_OSS_TRUNC = 1 << 7, /**< truncate oss object */ - CAPA_OPC_OSS_DESTROY = 1 << 8, /**< destroy oss object */ - CAPA_OPC_META_WRITE = 1 << 9, /**< write object meta data */ - CAPA_OPC_META_READ = 1 << 10, /**< read object meta data */ + CAPA_OPC_BODY_WRITE = 1 << 0, /**< write object data */ + CAPA_OPC_BODY_READ = 1 << 1, /**< read object data */ + CAPA_OPC_INDEX_LOOKUP = 1 << 2, /**< lookup object fid */ + CAPA_OPC_INDEX_INSERT = 1 << 3, /**< insert object fid */ + CAPA_OPC_INDEX_DELETE = 1 << 4, /**< delete object fid */ + CAPA_OPC_OSS_WRITE = 1 << 5, /**< write oss object data */ + CAPA_OPC_OSS_READ = 1 << 6, /**< read oss object data */ + CAPA_OPC_OSS_TRUNC = 1 << 7, /**< truncate oss object */ + CAPA_OPC_OSS_DESTROY = 1 << 8, /**< destroy oss object */ + CAPA_OPC_META_WRITE = 1 << 9, /**< write object meta data */ + CAPA_OPC_META_READ = 1 << 10, /**< read object meta data */ }; #define CAPA_OPC_OSS_RW (CAPA_OPC_OSS_READ | CAPA_OPC_OSS_WRITE) -#define CAPA_OPC_MDS_ONLY \ +#define CAPA_OPC_MDS_ONLY \ (CAPA_OPC_BODY_WRITE | CAPA_OPC_BODY_READ | CAPA_OPC_INDEX_LOOKUP | \ CAPA_OPC_INDEX_INSERT | CAPA_OPC_INDEX_DELETE) -#define CAPA_OPC_OSS_ONLY \ - (CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC | \ +#define CAPA_OPC_OSS_ONLY \ + (CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC | \ CAPA_OPC_OSS_DESTROY) #define CAPA_OPC_MDS_DEFAULT ~CAPA_OPC_OSS_ONLY #define CAPA_OPC_OSS_DEFAULT ~(CAPA_OPC_MDS_ONLY | CAPA_OPC_OSS_ONLY) struct lustre_capa_key { - __u64 lk_seq; /**< mds# */ - __u32 lk_keyid; /**< key# */ - __u32 lk_padding; - __u8 lk_key[CAPA_HMAC_KEY_MAX_LEN]; /**< key */ + __u64 lk_seq; /**< mds# */ + __u32 lk_keyid; /**< key# */ + __u32 lk_padding; + __u8 lk_key[CAPA_HMAC_KEY_MAX_LEN]; /**< key */ } __packed; /** The link ea holds 1 \a link_ea_entry for each hardlink */ @@ -2751,7 +2751,7 @@ struct lustre_capa_key { struct link_ea_header { __u32 leh_magic; __u32 leh_reccount; - __u64 leh_len; /* total size */ + __u64 leh_len; /* total size */ __u32 leh_overflow_time; __u32 leh_padding; }; @@ -2787,13 +2787,13 @@ struct getparent { } __packed; enum { - LAYOUT_INTENT_ACCESS = 0, /** generic access */ - LAYOUT_INTENT_READ = 1, /** not used */ - LAYOUT_INTENT_WRITE = 2, /** write file, for comp layout */ - LAYOUT_INTENT_GLIMPSE = 3, /** not used */ - LAYOUT_INTENT_TRUNC = 4, /** truncate file, for comp layout */ - LAYOUT_INTENT_RELEASE = 5, /** reserved for HSM release */ - LAYOUT_INTENT_RESTORE = 6 /** reserved for HSM restore */ + LAYOUT_INTENT_ACCESS = 0, /** generic access */ + LAYOUT_INTENT_READ = 1, /** not used */ + LAYOUT_INTENT_WRITE = 2, /** write file, for comp layout */ + LAYOUT_INTENT_GLIMPSE = 3, /** not used */ + LAYOUT_INTENT_TRUNC = 4, /** truncate file, for comp layout */ + LAYOUT_INTENT_RELEASE = 5, /** reserved for HSM release */ + LAYOUT_INTENT_RESTORE = 6 /** reserved for HSM restore */ }; /* enqueue layout lock with intent */ diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h index 178837cedd07..3b80b50543d8 100644 --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h @@ -68,13 +68,13 @@ * are co-existing. */ #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) -typedef struct stat64 lstat_t; -#define lstat_f lstat64 +typedef struct stat64 lstat_t; +#define lstat_f lstat64 #define fstat_f fstat64 #define fstatat_f fstatat64 #else -typedef struct stat lstat_t; -#define lstat_f lstat +typedef struct stat lstat_t; +#define lstat_f lstat #define fstat_f fstat #define fstatat_f fstatat #endif @@ -87,47 +87,47 @@ typedef struct stat lstat_t; #define LL_SUPER_MAGIC 0x0BD00BD0 #ifndef FSFILT_IOC_GETFLAGS -#define FSFILT_IOC_GETFLAGS _IOR('f', 1, long) -#define FSFILT_IOC_SETFLAGS _IOW('f', 2, long) -#define FSFILT_IOC_GETVERSION _IOR('f', 3, long) -#define FSFILT_IOC_SETVERSION _IOW('f', 4, long) -#define FSFILT_IOC_GETVERSION_OLD _IOR('v', 1, long) -#define FSFILT_IOC_SETVERSION_OLD _IOW('v', 2, long) +#define FSFILT_IOC_GETFLAGS _IOR('f', 1, long) +#define FSFILT_IOC_SETFLAGS _IOW('f', 2, long) +#define FSFILT_IOC_GETVERSION _IOR('f', 3, long) +#define FSFILT_IOC_SETVERSION _IOW('f', 4, long) +#define FSFILT_IOC_GETVERSION_OLD _IOR('v', 1, long) +#define FSFILT_IOC_SETVERSION_OLD _IOW('v', 2, long) #endif /* FIEMAP flags supported by Lustre */ #define LUSTRE_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_DEVICE_ORDER) enum obd_statfs_state { - OS_STATE_DEGRADED = 0x00000001, /**< RAID degraded/rebuilding */ - OS_STATE_READONLY = 0x00000002, /**< filesystem is read-only */ - OS_STATE_RDONLY_1 = 0x00000004, /**< obsolete 1.6, was EROFS=30 */ - OS_STATE_RDONLY_2 = 0x00000008, /**< obsolete 1.6, was EROFS=30 */ - OS_STATE_RDONLY_3 = 0x00000010, /**< obsolete 1.6, was EROFS=30 */ + OS_STATE_DEGRADED = 0x00000001, /**< RAID degraded/rebuilding */ + OS_STATE_READONLY = 0x00000002, /**< filesystem is read-only */ + OS_STATE_RDONLY_1 = 0x00000004, /**< obsolete 1.6, was EROFS=30 */ + OS_STATE_RDONLY_2 = 0x00000008, /**< obsolete 1.6, was EROFS=30 */ + OS_STATE_RDONLY_3 = 0x00000010, /**< obsolete 1.6, was EROFS=30 */ }; struct obd_statfs { - __u64 os_type; - __u64 os_blocks; - __u64 os_bfree; - __u64 os_bavail; - __u64 os_files; - __u64 os_ffree; - __u8 os_fsid[40]; - __u32 os_bsize; - __u32 os_namelen; - __u64 os_maxbytes; - __u32 os_state; /**< obd_statfs_state OS_STATE_* flag */ - __u32 os_fprecreated; /* objs available now to the caller */ - /* used in QoS code to find preferred OSTs */ - __u32 os_spare2; - __u32 os_spare3; - __u32 os_spare4; - __u32 os_spare5; - __u32 os_spare6; - __u32 os_spare7; - __u32 os_spare8; - __u32 os_spare9; + __u64 os_type; + __u64 os_blocks; + __u64 os_bfree; + __u64 os_bavail; + __u64 os_files; + __u64 os_ffree; + __u8 os_fsid[40]; + __u32 os_bsize; + __u32 os_namelen; + __u64 os_maxbytes; + __u32 os_state; /**< obd_statfs_state OS_STATE_* flag */ + __u32 os_fprecreated; /* objs available now to the caller + * used in QoS code to find preferred OSTs */ + __u32 os_spare2; + __u32 os_spare3; + __u32 os_spare4; + __u32 os_spare5; + __u32 os_spare6; + __u32 os_spare7; + __u32 os_spare8; + __u32 os_spare9; }; /** @@ -137,12 +137,12 @@ struct obd_statfs { * FIDs are never reused. **/ struct lu_fid { - /** - * FID sequence. Sequence is a unit of migration: all files (objects) - * with FIDs from a given sequence are stored on the same server. - * Lustre should support 2^64 objects, so even if each sequence - * has only a single object we can still enumerate 2^64 objects. - **/ + /** + * FID sequence. Sequence is a unit of migration: all files (objects) + * with FIDs from a given sequence are stored on the same server. + * Lustre should support 2^64 objects, so even if each sequence + * has only a single object we can still enumerate 2^64 objects. + **/ __u64 f_seq; /* FID number within sequence. */ __u32 f_oid; @@ -237,33 +237,33 @@ struct ll_futimes_3 { * *INFO - set/get lov_user_mds_data */ /* lustre_ioctl.h 101-150 */ -#define LL_IOC_GETFLAGS _IOR('f', 151, long) -#define LL_IOC_SETFLAGS _IOW('f', 152, long) -#define LL_IOC_CLRFLAGS _IOW('f', 153, long) -#define LL_IOC_LOV_SETSTRIPE _IOW('f', 154, long) +#define LL_IOC_GETFLAGS _IOR('f', 151, long) +#define LL_IOC_SETFLAGS _IOW('f', 152, long) +#define LL_IOC_CLRFLAGS _IOW('f', 153, long) +#define LL_IOC_LOV_SETSTRIPE _IOW('f', 154, long) #define LL_IOC_LOV_SETSTRIPE_NEW _IOWR('f', 154, struct lov_user_md) -#define LL_IOC_LOV_GETSTRIPE _IOW('f', 155, long) +#define LL_IOC_LOV_GETSTRIPE _IOW('f', 155, long) #define LL_IOC_LOV_GETSTRIPE_NEW _IOR('f', 155, struct lov_user_md) #define LL_IOC_LOV_SETEA _IOW('f', 156, long) /* LL_IOC_RECREATE_OBJ 157 obsolete */ /* LL_IOC_RECREATE_FID 158 obsolete */ -#define LL_IOC_GROUP_LOCK _IOW('f', 158, long) -#define LL_IOC_GROUP_UNLOCK _IOW('f', 159, long) +#define LL_IOC_GROUP_LOCK _IOW('f', 158, long) +#define LL_IOC_GROUP_UNLOCK _IOW('f', 159, long) /* #define LL_IOC_QUOTACHECK 160 OBD_IOC_QUOTACHECK */ /* #define LL_IOC_POLL_QUOTACHECK 161 OBD_IOC_POLL_QUOTACHECK */ /* #define LL_IOC_QUOTACTL 162 OBD_IOC_QUOTACTL */ -#define IOC_OBD_STATFS _IOWR('f', 164, struct obd_statfs *) +#define IOC_OBD_STATFS _IOWR('f', 164, struct obd_statfs *) /* IOC_LOV_GETINFO 165 obsolete */ -#define LL_IOC_FLUSHCTX _IOW('f', 166, long) +#define LL_IOC_FLUSHCTX _IOW('f', 166, long) /* LL_IOC_RMTACL 167 obsolete */ -#define LL_IOC_GETOBDCOUNT _IOR('f', 168, long) -#define LL_IOC_LLOOP_ATTACH _IOWR('f', 169, long) -#define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long) -#define LL_IOC_LLOOP_INFO _IOWR('f', 171, struct lu_fid) -#define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long) -#define LL_IOC_PATH2FID _IOR('f', 173, long) +#define LL_IOC_GETOBDCOUNT _IOR('f', 168, long) +#define LL_IOC_LLOOP_ATTACH _IOWR('f', 169, long) +#define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long) +#define LL_IOC_LLOOP_INFO _IOWR('f', 171, struct lu_fid) +#define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long) +#define LL_IOC_PATH2FID _IOR('f', 173, long) #define LL_IOC_GET_CONNECT_FLAGS _IOWR('f', 174, __u64 *) -#define LL_IOC_GET_MDTIDX _IOR('f', 175, int) +#define LL_IOC_GET_MDTIDX _IOR('f', 175, int) #define LL_IOC_FUTIMES_3 _IOWR('f', 176, struct ll_futimes_3) /* lustre_ioctl.h 177-210 */ @@ -281,8 +281,8 @@ struct ll_futimes_3 { struct hsm_current_action) /* see for ioctl numbers 221-232 */ -#define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md) -#define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md) +#define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md) +#define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md) #define LL_IOC_SET_LEASE _IOWR('f', 243, long) #define LL_IOC_GET_LEASE _IO('f', 244) #define LL_IOC_HSM_IMPORT _IOWR('f', 245, struct hsm_user_import) @@ -299,15 +299,15 @@ enum ll_lease_type { LL_LEASE_UNLCK = 0x4, }; -#define LL_STATFS_LMV 1 -#define LL_STATFS_LOV 2 +#define LL_STATFS_LMV 1 +#define LL_STATFS_LOV 2 #define LL_STATFS_NODELAY 4 -#define IOC_MDC_TYPE 'i' -#define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *) -#define IOC_MDC_GETFILESTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *) -#define IOC_MDC_GETFILEINFO _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *) -#define LL_IOC_MDC_GETINFO _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *) +#define IOC_MDC_TYPE 'i' +#define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *) +#define IOC_MDC_GETFILESTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *) +#define IOC_MDC_GETFILEINFO _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *) +#define LL_IOC_MDC_GETINFO _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *) #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */ @@ -318,12 +318,12 @@ enum ll_lease_type { */ #define O_LOV_DELAY_CREATE (O_NOCTTY | FASYNC) -#define LL_FILE_IGNORE_LOCK 0x00000001 -#define LL_FILE_GROUP_LOCKED 0x00000002 +#define LL_FILE_IGNORE_LOCK 0x00000001 +#define LL_FILE_GROUP_LOCKED 0x00000002 #define LL_FILE_READAHEA 0x00000004 #define LL_FILE_LOCKED_DIRECTIO 0x00000008 /* client-side locks with dio */ -#define LL_FILE_LOCKLESS_IO 0x00000010 /* server-side locks with cio */ -#define LL_FILE_RMTACL 0x00000020 +#define LL_FILE_LOCKLESS_IO 0x00000010 /* server-side locks with cio */ +#define LL_FILE_RMTACL 0x00000020 #define LOV_USER_MAGIC_V1 0x0BD10BD0 #define LOV_USER_MAGIC LOV_USER_MAGIC_V1 @@ -333,7 +333,7 @@ enum ll_lease_type { #define LOV_USER_MAGIC_SPECIFIC 0x0BD50BD0 /* for specific OSTs */ #define LOV_USER_MAGIC_COMP_V1 0x0BD60BD0 -#define LMV_USER_MAGIC 0x0CD30CD0 /*default lmv magic*/ +#define LMV_USER_MAGIC 0x0CD30CD0 /*default lmv magic*/ #define LOV_PATTERN_RAID0 0x001 #define LOV_PATTERN_RAID1 0x002 @@ -347,8 +347,8 @@ enum ll_lease_type { #define LOV_MAXPOOLNAME 15 #define LOV_POOLNAMEF "%.15s" -#define LOV_MIN_STRIPE_BITS 16 /* maximum PAGE_SIZE (ia64), power of 2 */ -#define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS) +#define LOV_MIN_STRIPE_BITS 16 /* maximum PAGE_SIZE (ia64), power of 2 */ +#define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS) #define LOV_MAX_STRIPE_COUNT_OLD 160 /* This calculation is crafted so that input of 4096 will result in 160 * which in turn is equal to old maximal stripe count. @@ -360,49 +360,49 @@ enum ll_lease_type { * * (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1) */ -#define LOV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */ -#define LOV_ALL_STRIPES 0xffff /* only valid for directories */ +#define LOV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */ +#define LOV_ALL_STRIPES 0xffff /* only valid for directories */ #define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */ #define XATTR_LUSTRE_PREFIX "lustre." #define XATTR_LUSTRE_LOV "lustre.lov" #define lov_user_ost_data lov_user_ost_data_v1 -struct lov_user_ost_data_v1 { /* per-stripe data structure */ - struct ost_id l_ost_oi; /* OST object ID */ - __u32 l_ost_gen; /* generation of this OST index */ - __u32 l_ost_idx; /* OST index in LOV */ +struct lov_user_ost_data_v1 { /* per-stripe data structure */ + struct ost_id l_ost_oi; /* OST object ID */ + __u32 l_ost_gen; /* generation of this OST index */ + __u32 l_ost_idx; /* OST index in LOV */ } __packed; #define lov_user_md lov_user_md_v1 -struct lov_user_md_v1 { /* LOV EA user data (host-endian) */ - __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V1 */ +struct lov_user_md_v1 { /* LOV EA user data (host-endian) */ + __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V1 */ __u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */ - struct ost_id lmm_oi; /* LOV object ID */ - __u32 lmm_stripe_size; /* size of stripe in bytes */ - __u16 lmm_stripe_count; /* num stripes in use for this object */ + struct ost_id lmm_oi; /* LOV object ID */ + __u32 lmm_stripe_size; /* size of stripe in bytes */ + __u16 lmm_stripe_count; /* num stripes in use for this object */ union { __u16 lmm_stripe_offset; /* starting stripe offset in * lmm_objects, use when writing */ - __u16 lmm_layout_gen; /* layout generation number + __u16 lmm_layout_gen; /* layout generation number * used when reading */ }; struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */ } __attribute__((packed, __may_alias__)); -struct lov_user_md_v3 { /* LOV EA user data (host-endian) */ - __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V3 */ +struct lov_user_md_v3 { /* LOV EA user data (host-endian) */ + __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V3 */ __u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */ - struct ost_id lmm_oi; /* LOV object ID */ - __u32 lmm_stripe_size; /* size of stripe in bytes */ - __u16 lmm_stripe_count; /* num stripes in use for this object */ + struct ost_id lmm_oi; /* LOV object ID */ + __u32 lmm_stripe_size; /* size of stripe in bytes */ + __u16 lmm_stripe_count; /* num stripes in use for this object */ union { __u16 lmm_stripe_offset; /* starting stripe offset in * lmm_objects, use when writing */ - __u16 lmm_layout_gen; /* layout generation number + __u16 lmm_layout_gen; /* layout generation number * used when reading */ }; @@ -425,9 +425,9 @@ static inline bool lu_extent_is_overlapped(struct lu_extent *e1, } enum lov_comp_md_entry_flags { - LCME_FL_PRIMARY = 0x00000001, /* Not used */ - LCME_FL_STALE = 0x00000002, /* Not used */ - LCME_FL_OFFLINE = 0x00000004, /* Not used */ + LCME_FL_PRIMARY = 0x00000001, /* Not used */ + LCME_FL_STALE = 0x00000002, /* Not used */ + LCME_FL_OFFLINE = 0x00000004, /* Not used */ LCME_FL_PREFERRED = 0x00000008, /* Not used */ LCME_FL_INIT = 0x00000010, /* instantiated */ LCME_FL_NEG = 0x80000000, /* used to indicate a negative @@ -480,7 +480,7 @@ static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic) return sizeof(struct lov_user_md_v1) + stripes * sizeof(struct lov_user_ost_data_v1); return sizeof(struct lov_user_md_v3) + - stripes * sizeof(struct lov_user_ost_data_v1); + stripes * sizeof(struct lov_user_ost_data_v1); } /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to @@ -524,16 +524,16 @@ enum lmv_hash_type { #define LMV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */ #define lmv_user_md lmv_user_md_v1 struct lmv_user_md_v1 { - __u32 lum_magic; /* must be the first field */ - __u32 lum_stripe_count; /* dirstripe count */ - __u32 lum_stripe_offset; /* MDT idx for default dirstripe */ - __u32 lum_hash_type; /* Dir stripe policy */ - __u32 lum_type; /* LMV type: default or normal */ + __u32 lum_magic; /* must be the first field */ + __u32 lum_stripe_count; /* dirstripe count */ + __u32 lum_stripe_offset; /* MDT idx for default dirstripe */ + __u32 lum_hash_type; /* Dir stripe policy */ + __u32 lum_type; /* LMV type: default or normal */ __u32 lum_padding1; __u32 lum_padding2; __u32 lum_padding3; char lum_pool_name[LOV_MAXPOOLNAME + 1]; - struct lmv_user_mds_data lum_objects[0]; + struct lmv_user_mds_data lum_objects[0]; } __packed; static inline int lmv_user_md_size(int stripes, int lmm_magic) @@ -548,11 +548,11 @@ struct ll_recreate_obj { }; struct ll_fid { - __u64 id; /* holds object id */ - __u32 generation; /* holds object generation */ - __u32 f_type; /* holds object type or stripe idx when passing it to - * OST for saving into EA. - */ + __u64 id; /* holds object id */ + __u32 generation; /* holds object generation */ + __u32 f_type; /* holds object type or stripe idx when + * passing it to OST for saving into EA. + */ }; #define UUID_MAX 40 @@ -631,22 +631,22 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) /********* Quotas **********/ -#define Q_QUOTACHECK 0x800100 /* deprecated as of 2.4 */ -#define Q_INITQUOTA 0x800101 /* deprecated as of 2.4 */ -#define Q_GETOINFO 0x800102 /* get obd quota info */ -#define Q_GETOQUOTA 0x800103 /* get obd quotas */ -#define Q_FINVALIDATE 0x800104 /* deprecated as of 2.4 */ +#define Q_QUOTACHECK 0x800100 /* deprecated as of 2.4 */ +#define Q_INITQUOTA 0x800101 /* deprecated as of 2.4 */ +#define Q_GETOINFO 0x800102 /* get obd quota info */ +#define Q_GETOQUOTA 0x800103 /* get obd quotas */ +#define Q_FINVALIDATE 0x800104 /* deprecated as of 2.4 */ /* these must be explicitly translated into linux Q_* in ll_dir_ioctl */ -#define LUSTRE_Q_QUOTAON 0x800002 /* deprecated as of 2.4 */ -#define LUSTRE_Q_QUOTAOFF 0x800003 /* deprecated as of 2.4 */ -#define LUSTRE_Q_GETINFO 0x800005 /* get information about quota files */ -#define LUSTRE_Q_SETINFO 0x800006 /* set information about quota files */ -#define LUSTRE_Q_GETQUOTA 0x800007 /* get user quota structure */ -#define LUSTRE_Q_SETQUOTA 0x800008 /* set user quota structure */ +#define LUSTRE_Q_QUOTAON 0x800002 /* deprecated as of 2.4 */ +#define LUSTRE_Q_QUOTAOFF 0x800003 /* deprecated as of 2.4 */ +#define LUSTRE_Q_GETINFO 0x800005 /* get information about quota files */ +#define LUSTRE_Q_SETINFO 0x800006 /* set information about quota files */ +#define LUSTRE_Q_GETQUOTA 0x800007 /* get user quota structure */ +#define LUSTRE_Q_SETQUOTA 0x800008 /* set user quota structure */ /* lustre-specific control commands */ -#define LUSTRE_Q_INVALIDATE 0x80000b /* deprecated as of 2.4 */ -#define LUSTRE_Q_FINVALIDATE 0x80000c /* deprecated as of 2.4 */ +#define LUSTRE_Q_INVALIDATE 0x80000b /* deprecated as of 2.4 */ +#define LUSTRE_Q_FINVALIDATE 0x80000c /* deprecated as of 2.4 */ #define ALLQUOTA 255 /* set all quota */ @@ -666,7 +666,7 @@ static inline char *qtype_name(int qtype) #define IDENTITY_DOWNCALL_MAGIC 0x6d6dd629 /* permission */ -#define N_PERMS_MAX 64 +#define N_PERMS_MAX 64 struct perm_downcall_data { __u64 pdd_nid; @@ -720,23 +720,23 @@ struct obd_dqblk { }; enum { - QC_GENERAL = 0, - QC_MDTIDX = 1, - QC_OSTIDX = 2, - QC_UUID = 3 + QC_GENERAL = 0, + QC_MDTIDX = 1, + QC_OSTIDX = 2, + QC_UUID = 3 }; struct if_quotactl { - __u32 qc_cmd; - __u32 qc_type; - __u32 qc_id; - __u32 qc_stat; - __u32 qc_valid; - __u32 qc_idx; - struct obd_dqinfo qc_dqinfo; - struct obd_dqblk qc_dqblk; - char obd_type[16]; - struct obd_uuid obd_uuid; + __u32 qc_cmd; + __u32 qc_type; + __u32 qc_id; + __u32 qc_stat; + __u32 qc_valid; + __u32 qc_idx; + struct obd_dqinfo qc_dqinfo; + struct obd_dqblk qc_dqblk; + char obd_type[16]; + struct obd_uuid obd_uuid; }; /* swap layout flags */ @@ -759,26 +759,26 @@ struct lustre_swap_layouts { /********* Changelogs **********/ /** Changelog record types */ enum changelog_rec_type { - CL_MARK = 0, - CL_CREATE = 1, /* namespace */ - CL_MKDIR = 2, /* namespace */ - CL_HARDLINK = 3, /* namespace */ - CL_SOFTLINK = 4, /* namespace */ - CL_MKNOD = 5, /* namespace */ - CL_UNLINK = 6, /* namespace */ - CL_RMDIR = 7, /* namespace */ - CL_RENAME = 8, /* namespace */ - CL_EXT = 9, /* namespace extended record (2nd half of rename) */ - CL_OPEN = 10, /* not currently used */ - CL_CLOSE = 11, /* may be written to log only with mtime change */ - CL_LAYOUT = 12, /* file layout/striping modified */ - CL_TRUNC = 13, - CL_SETATTR = 14, - CL_XATTR = 15, - CL_HSM = 16, /* HSM specific events, see flags */ - CL_MTIME = 17, /* Precedence: setattr > mtime > ctime > atime */ - CL_CTIME = 18, - CL_ATIME = 19, + CL_MARK = 0, + CL_CREATE = 1, /* namespace */ + CL_MKDIR = 2, /* namespace */ + CL_HARDLINK = 3, /* namespace */ + CL_SOFTLINK = 4, /* namespace */ + CL_MKNOD = 5, /* namespace */ + CL_UNLINK = 6, /* namespace */ + CL_RMDIR = 7, /* namespace */ + CL_RENAME = 8, /* namespace */ + CL_EXT = 9, /* namespace extended record (2nd half of rename) */ + CL_OPEN = 10, /* not currently used */ + CL_CLOSE = 11, /* may be written to log only with mtime change */ + CL_LAYOUT = 12, /* file layout/striping modified */ + CL_TRUNC = 13, + CL_SETATTR = 14, + CL_XATTR = 15, + CL_HSM = 16, /* HSM specific events, see flags */ + CL_MTIME = 17, /* Precedence: setattr > mtime > ctime > atime */ + CL_CTIME = 18, + CL_ATIME = 19, CL_LAST }; @@ -808,9 +808,9 @@ enum changelog_rec_flags { /* Anything under the flagmask may be per-type (if desired) */ /* Flags for unlink */ -#define CLF_UNLINK_LAST 0x0001 /* Unlink of last hardlink */ -#define CLF_UNLINK_HSM_EXISTS 0x0002 /* File has something in HSM */ - /* HSM cleaning needed */ +#define CLF_UNLINK_LAST 0x0001 /* Unlink of last hardlink */ +#define CLF_UNLINK_HSM_EXISTS 0x0002 /* File has something in HSM + * HSM cleaning needed */ /* Flags for rename */ #define CLF_RENAME_LAST 0x0001 /* rename unlink last hardlink of * target @@ -827,12 +827,12 @@ enum changelog_rec_flags { */ #define CLF_HSM_ERR_L 0 /* HSM return code, 7 bits */ #define CLF_HSM_ERR_H 6 -#define CLF_HSM_EVENT_L 7 /* HSM event, 3 bits, see enum hsm_event */ -#define CLF_HSM_EVENT_H 9 -#define CLF_HSM_FLAG_L 10 /* HSM flags, 2 bits, 1 used, 1 spare */ -#define CLF_HSM_FLAG_H 11 -#define CLF_HSM_SPARE_L 12 /* 4 spare bits */ -#define CLF_HSM_SPARE_H 15 +#define CLF_HSM_EVENT_L 7 /* HSM event, 3 bits, see enum hsm_event */ +#define CLF_HSM_EVENT_H 9 +#define CLF_HSM_FLAG_L 10 /* HSM flags, 2 bits, 1 used, 1 spare */ +#define CLF_HSM_FLAG_H 11 +#define CLF_HSM_SPARE_L 12 /* 4 spare bits */ +#define CLF_HSM_SPARE_H 15 #define CLF_HSM_LAST 15 /* Remove bits higher than _h, then extract the value @@ -841,22 +841,22 @@ enum changelog_rec_flags { #define CLF_GET_BITS(_b, _h, _l) (((_b << (CLF_HSM_LAST - _h)) & 0xFFFF) \ >> (CLF_HSM_LAST - _h + _l)) -#define CLF_HSM_SUCCESS 0x00 -#define CLF_HSM_MAXERROR 0x7E -#define CLF_HSM_ERROVERFLOW 0x7F +#define CLF_HSM_SUCCESS 0x00 +#define CLF_HSM_MAXERROR 0x7E +#define CLF_HSM_ERROVERFLOW 0x7F #define CLF_HSM_DIRTY 1 /* file is dirty after HSM request end */ /* 3 bits field => 8 values allowed */ enum hsm_event { - HE_ARCHIVE = 0, - HE_RESTORE = 1, - HE_CANCEL = 2, - HE_RELEASE = 3, - HE_REMOVE = 4, + HE_ARCHIVE = 0, + HE_RESTORE = 1, + HE_CANCEL = 2, + HE_RELEASE = 3, + HE_REMOVE = 4, HE_STATE = 5, - HE_SPARE1 = 6, - HE_SPARE2 = 7, + HE_SPARE1 = 6, + HE_SPARE2 = 7, }; static inline enum hsm_event hsm_get_cl_event(__u16 flags) @@ -1070,14 +1070,14 @@ enum changelog_message_type { struct ioc_data_version { __u64 idv_version; - __u64 idv_flags; /* See LL_DV_xxx */ + __u64 idv_flags; /* See LL_DV_xxx */ }; #define LL_DV_RD_FLUSH (1 << 0) /* Flush dirty pages from clients */ #define LL_DV_WR_FLUSH (1 << 1) /* Flush all caching pages from clients */ #ifndef offsetof -# define offsetof(typ, memb) ((unsigned long)((char *)&(((typ *)0)->memb))) +# define offsetof(typ, memb) ((unsigned long)((char *)&(((typ *)0)->memb))) #endif #define dot_lustre_name ".lustre" @@ -1284,14 +1284,14 @@ static inline const char *hsm_copytool_action2name(enum hsm_copytool_action a) /* Copytool item action description */ struct hsm_action_item { - __u32 hai_len; /* valid size of this struct */ - __u32 hai_action; /* hsm_copytool_action, but use known size */ - struct lu_fid hai_fid; /* Lustre FID to operated on */ - struct lu_fid hai_dfid; /* fid used for data access */ + __u32 hai_len; /* valid size of this struct */ + __u32 hai_action; /* hsm_copytool_action, but use known size */ + struct lu_fid hai_fid; /* Lustre FID to operated on */ + struct lu_fid hai_dfid; /* fid used for data access */ struct hsm_extent hai_extent; /* byte range to operate on */ - __u64 hai_cookie; /* action cookie from coordinator */ - __u64 hai_gid; /* grouplock id */ - char hai_data[0]; /* variable length */ + __u64 hai_cookie; /* action cookie from coordinator */ + __u64 hai_gid; /* grouplock id */ + char hai_data[0]; /* variable length */ } __packed; /* @@ -1326,12 +1326,12 @@ static inline char *hai_dump_data_field(struct hsm_action_item *hai, #define HAL_MAXSIZE LNET_MTU /* bytes, used in userspace only */ struct hsm_action_list { __u32 hal_version; - __u32 hal_count; /* number of hai's to follow */ - __u64 hal_compound_id; /* returned by coordinator */ + __u32 hal_count; /* number of hai's to follow */ + __u64 hal_compound_id; /* returned by coordinator */ __u64 hal_flags; - __u32 hal_archive_id; /* which archive backend */ + __u32 hal_archive_id; /* which archive backend */ __u32 padding1; - char hal_fsname[0]; /* null-terminated */ + char hal_fsname[0]; /* null-terminated */ /* struct hsm_action_item[hal_count] follows, aligned on 8-byte * boundaries. See hai_first */ @@ -1384,8 +1384,8 @@ struct hsm_user_import { }; /* Copytool progress reporting */ -#define HP_FLAG_COMPLETED 0x01 -#define HP_FLAG_RETRY 0x02 +#define HP_FLAG_COMPLETED 0x01 +#define HP_FLAG_RETRY 0x02 struct hsm_progress { struct lu_fid hp_fid; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 2bf12284bf43..92427254d74c 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -74,25 +74,25 @@ #define IBLND_N_SCHED_HIGH 4 struct kib_tunables { - int *kib_dev_failover; /* HCA failover */ - unsigned int *kib_service; /* IB service number */ + int *kib_dev_failover; /* HCA failover */ + unsigned int *kib_service; /* IB service number */ int *kib_min_reconnect_interval; /* first failed connection retry... */ int *kib_max_reconnect_interval; /* exponentially increasing to this */ - int *kib_cksum; /* checksum struct kib_msg? */ - int *kib_timeout; /* comms timeout (seconds) */ - int *kib_keepalive; /* keepalive timeout (seconds) */ - int *kib_ntx; /* # tx descs */ - char **kib_default_ipif; /* default IPoIB interface */ + int *kib_cksum; /* checksum struct kib_msg? */ + int *kib_timeout; /* comms timeout (seconds) */ + int *kib_keepalive; /* keepalive timeout (seconds) */ + int *kib_ntx; /* # tx descs */ + char **kib_default_ipif; /* default IPoIB interface */ int *kib_retry_count; int *kib_rnr_retry_count; - int *kib_ib_mtu; /* IB MTU */ - int *kib_require_priv_port; /* accept only privileged ports */ - int *kib_use_priv_port; /* use privileged port for active connect */ - int *kib_nscheds; /* # threads on each CPT */ - int *kib_wrq_sge; /* # sg elements per wrq */ - bool *kib_use_fastreg_gaps; /* enable discontiguous fastreg - * fragment support - */ + int *kib_ib_mtu; /* IB MTU */ + int *kib_require_priv_port; /* accept only privileged ports */ + int *kib_use_priv_port; /* use privileged port for active connect */ + int *kib_nscheds; /* # threads on each CPT */ + int *kib_wrq_sge; /* # sg elements per wrq */ + bool *kib_use_fastreg_gaps; /* enable discontiguous fastreg + * fragment support + */ }; extern struct kib_tunables kiblnd_tunables; @@ -164,11 +164,11 @@ struct kib_dev { int ibd_nnets; /* # nets extant */ time64_t ibd_next_failover; - int ibd_failed_failover; /* # failover failures */ - unsigned int ibd_failover; /* failover in progress */ - unsigned int ibd_can_failover; /* IPoIB interface is a - * bonding master - */ + int ibd_failed_failover; /* # failover failures */ + unsigned int ibd_failover; /* failover in progress */ + unsigned int ibd_can_failover; /* IPoIB interface is a + * bonding master + */ struct list_head ibd_nets; struct kib_hca_dev *ibd_hdev; enum kib_dev_caps ibd_dev_caps; @@ -330,8 +330,8 @@ struct kib_sched_info { struct kib_data { int kib_init; /* initialisation state */ - int kib_shutdown; /* shut down? */ - struct list_head kib_devs; /* IB devices extant */ + int kib_shutdown; /* shut down? */ + struct list_head kib_devs; /* IB devices extant */ struct list_head kib_failed_devs; /* list head of failed devices */ wait_queue_head_t kib_failover_waitq; /* schedulers sleep here */ atomic_t kib_nthreads; /* # live threads */ @@ -540,7 +540,7 @@ struct kib_conn { int ibc_state; /* what's happening */ int ibc_nsends_posted; /* # uncompleted sends */ int ibc_noops_posted; /* # uncompleted NOOPs */ - int ibc_credits; /* # credits I have */ + int ibc_credits; /* # credits I have */ int ibc_outstanding_credits; /* # credits to return */ int ibc_reserved_credits; /* # ACK/DONE msg credits */ int ibc_comms_error; /* set on comms error */ @@ -581,13 +581,13 @@ struct kib_conn { #define IBLND_CONN_DISCONNECTED 5 /* disconnected */ struct kib_peer_ni { - struct list_head ibp_list; /* stash on global peer_ni list */ - lnet_nid_t ibp_nid; /* who's on the other end(s) */ - struct lnet_ni *ibp_ni; /* LNet interface */ - struct list_head ibp_conns; /* all active connections */ - struct kib_conn *ibp_next_conn; /* next connection to send on for - * round robin */ - struct list_head ibp_tx_queue; /* msgs waiting for a conn */ + struct list_head ibp_list; /* stash on global peer_ni list */ + lnet_nid_t ibp_nid; /* who's on the other end(s) */ + struct lnet_ni *ibp_ni; /* LNet interface */ + struct list_head ibp_conns; /* all active connections */ + struct kib_conn *ibp_next_conn; /* next connection to send on for + * round robin */ + struct list_head ibp_tx_queue; /* msgs waiting for a conn */ u64 ibp_incarnation; /* incarnation of peer_ni */ /* when (in seconds) I was last alive */ time64_t ibp_last_alive; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index ce1f9e78b4d9..add2744c9d8d 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -54,15 +54,15 @@ #define SOCKNAL_NSCHEDS 3 #define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1) -#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer_ni lists */ -#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ -#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ -#define SOCKNAL_ENOMEM_RETRY 1 /* seconds between retries */ +#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer_ni lists */ +#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ +#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ +#define SOCKNAL_ENOMEM_RETRY 1 /* seconds between retries */ -#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */ -#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */ +#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */ +#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */ -#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */ +#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */ /* * risk kmap deadlock on multi-frag I/O (backs off to single-frag if disabled). @@ -461,31 +461,31 @@ extern struct ksock_tunables ksocknal_tunables; struct ksock_proto { /* version number of protocol */ - int pro_version; + int pro_version; /* handshake function */ - int (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *); + int (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *); /* handshake function */ - int (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int); + int (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int); /* message pack */ - void (*pro_pack)(struct ksock_tx *); + void (*pro_pack)(struct ksock_tx *); /* message unpack */ - void (*pro_unpack)(struct ksock_msg *); + void (*pro_unpack)(struct ksock_msg *); /* queue tx on the connection */ struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *); /* queue ZC ack on the connection */ - int (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64); + int (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64); /* handle ZC request */ - int (*pro_handle_zcreq)(struct ksock_conn *, u64, int); + int (*pro_handle_zcreq)(struct ksock_conn *, u64, int); /* handle ZC ACK */ - int (*pro_handle_zcack)(struct ksock_conn *, u64, u64); + int (*pro_handle_zcack)(struct ksock_conn *, u64, u64); /* * msg type matches the connection type: @@ -494,7 +494,7 @@ struct ksock_proto { * return MATCH_YES : matching type * return MATCH_MAY : can be backup */ - int (*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int); + int (*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int); }; extern struct ksock_proto ksocknal_protocol_v1x; diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c index 2df9ce4995f3..18f5c6b3b587 100644 --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c @@ -92,9 +92,9 @@ EXPORT_SYMBOL(libcfs_next_nidstring); * :== '@' * :== '*' | * | - * + * * :== ... - * + * * :== | * * :== '[' [ ',' ] ']' diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index bb61e3aa11e9..51ff979ca4ad 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -46,12 +46,12 @@ * sorted by increasing expiry time. The number of slots is 2**7 (128), * to cover a time period of 1024 seconds into the future before wrapping. */ -#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */ +#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */ #define STTIMER_SLOTTIME BIT(STTIMER_MINPOLL) -#define STTIMER_SLOTTIMEMASK (~(STTIMER_SLOTTIME - 1)) +#define STTIMER_SLOTTIMEMASK (~(STTIMER_SLOTTIME - 1)) #define STTIMER_NSLOTS BIT(7) -#define STTIMER_SLOT(t) (&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \ - (STTIMER_NSLOTS - 1))]) +#define STTIMER_SLOT(t) (&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \ + (STTIMER_NSLOTS - 1))]) static struct st_timer_data { spinlock_t stt_lock; diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index c85ef9ec639f..67b002bb1d1d 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -139,7 +139,7 @@ fld_debugfs_cache_flush_release(struct inode *inode, struct file *file) static const struct file_operations fld_debugfs_cache_flush_fops = { .owner = THIS_MODULE, - .open = simple_open, + .open = simple_open, .write = fld_debugfs_cache_flush_write, .release = fld_debugfs_cache_flush_release, }; diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 7d52665a3c33..31b3881fb6c9 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -69,9 +69,9 @@ struct adaptive_timeout { struct ptlrpc_at_array { struct list_head *paa_reqs_array; /** array to hold requests */ - u32 paa_size; /** the size of array */ - u32 paa_count; /** the total count of reqs */ - time64_t paa_deadline; /** the earliest deadline of reqs */ + u32 paa_size; /** the size of array */ + u32 paa_count; /** the total count of reqs */ + time64_t paa_deadline; /** the earliest deadline of reqs */ u32 *paa_reqs_count; /** the count of reqs in each entry */ }; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 9cffda3741ce..e09268f08e5c 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -690,10 +690,10 @@ static inline int it_to_lock_mode(struct lookup_intent *it) enum md_op_flags { MF_MDC_CANCEL_FID1 = BIT(0), - MF_MDC_CANCEL_FID2 = BIT(1), - MF_MDC_CANCEL_FID3 = BIT(2), - MF_MDC_CANCEL_FID4 = BIT(3), - MF_GET_MDT_IDX = BIT(4), + MF_MDC_CANCEL_FID2 = BIT(1), + MF_MDC_CANCEL_FID3 = BIT(2), + MF_MDC_CANCEL_FID4 = BIT(3), + MF_GET_MDT_IDX = BIT(4), }; enum md_cli_flags { @@ -744,7 +744,7 @@ struct md_op_data { u32 op_flags; /* Various operation flags. */ - enum mds_op_bias op_bias; + enum mds_op_bias op_bias; /* Used by readdir */ u64 op_offset; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 261857e4540d..ae2fddd044ea 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -335,9 +335,9 @@ static void ldlm_ns_release(struct kobject *kobj) } static struct kobj_type ldlm_ns_ktype = { - .default_attrs = ldlm_ns_attrs, - .sysfs_ops = &lustre_sysfs_ops, - .release = ldlm_ns_release, + .default_attrs = ldlm_ns_attrs, + .sysfs_ops = &lustre_sysfs_ops, + .release = ldlm_ns_release, }; static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 6afaa9028864..07cb2c92c197 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2636,7 +2636,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -EFAULT; return ll_file_futimes_3(file, &lfu); - } + } case LL_IOC_LADVISE: { struct llapi_ladvise_hdr *ladvise_hdr; int alloc_size = sizeof(*ladvise_hdr); diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index 102d143691b2..0f7c0272d630 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -204,7 +204,7 @@ struct vvp_object { * * \see ll_vm_open(), ll_vm_close(). */ - atomic_t vob_mmap_cnt; + atomic_t vob_mmap_cnt; /** * various flags diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 22f178a3abe2..a1d27061ac19 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -209,7 +209,7 @@ static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump) if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) { entry_count = comp_v1->lcm_entry_count; is_composite = true; - } + } for (i = 0; i < entry_count; i++) { if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) { diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 6db4d5eb46cd..395ef772fc17 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -536,7 +536,7 @@ void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm) DEXT ": id: %u, flags: %x, magic 0x%08X, layout_gen %u, stripe count %u, sstripe size %u, pool: [" LOV_POOLNAMEF "]\n", PEXT(&lse->lsme_extent), lse->lsme_id, lse->lsme_flags, lse->lsme_magic, lse->lsme_layout_gen, - lse->lsme_stripe_count, lse->lsme_stripe_size, + lse->lsme_stripe_count, lse->lsme_stripe_size, lse->lsme_pool_name); if (!lsme_inited(lse) || lse->lsme_pattern & LOV_PATTERN_F_RELEASED) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index bad9538706f0..652ed6a20af3 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1336,19 +1336,19 @@ static const struct obd_ops lov_obd_ops = { .owner = THIS_MODULE, .setup = lov_setup, .cleanup = lov_cleanup, - .connect = lov_connect, - .disconnect = lov_disconnect, - .statfs = lov_statfs, - .statfs_async = lov_statfs_async, - .iocontrol = lov_iocontrol, - .get_info = lov_get_info, - .set_info_async = lov_set_info_async, - .notify = lov_notify, - .pool_new = lov_pool_new, - .pool_rem = lov_pool_remove, - .pool_add = lov_pool_add, - .pool_del = lov_pool_del, - .quotactl = lov_quotactl, + .connect = lov_connect, + .disconnect = lov_disconnect, + .statfs = lov_statfs, + .statfs_async = lov_statfs_async, + .iocontrol = lov_iocontrol, + .get_info = lov_get_info, + .set_info_async = lov_set_info_async, + .notify = lov_notify, + .pool_new = lov_pool_new, + .pool_rem = lov_pool_remove, + .pool_add = lov_pool_add, + .pool_del = lov_pool_del, + .quotactl = lov_quotactl, }; struct kmem_cache *lov_oinfo_slab; diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 3ff0bf1c4a22..ec872e8ae9be 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1818,18 +1818,18 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) } static const struct obd_ops mgc_obd_ops = { - .owner = THIS_MODULE, - .setup = mgc_setup, - .precleanup = mgc_precleanup, - .cleanup = mgc_cleanup, - .add_conn = client_import_add_conn, - .del_conn = client_import_del_conn, - .connect = client_connect_import, - .disconnect = client_disconnect_export, - .set_info_async = mgc_set_info_async, - .get_info = mgc_get_info, - .import_event = mgc_import_event, - .process_config = mgc_process_config, + .owner = THIS_MODULE, + .setup = mgc_setup, + .precleanup = mgc_precleanup, + .cleanup = mgc_cleanup, + .add_conn = client_import_add_conn, + .del_conn = client_import_del_conn, + .connect = client_connect_import, + .disconnect = client_disconnect_export, + .set_info_async = mgc_set_info_async, + .get_info = mgc_get_info, + .import_event = mgc_import_event, + .process_config = mgc_process_config, }; static int __init mgc_init(void) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 1d1a6b2d436e..c91704d87042 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -313,9 +313,9 @@ struct obd_device *class_newdev(const char *type_name, const char *name, llog_group_init(&newdev->obd_olg); /* Detach drops this */ - atomic_set(&newdev->obd_refcount, 1); - lu_ref_init(&newdev->obd_reference); - lu_ref_add(&newdev->obd_reference, "newdev", newdev); + atomic_set(&newdev->obd_refcount, 1); + lu_ref_init(&newdev->obd_reference); + lu_ref_add(&newdev->obd_reference, "newdev", newdev); newdev->obd_conn_inprogress = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 69a56cca99f2..d4f1eddd96ca 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -73,7 +73,7 @@ struct lu_site_bkt_data { * * \see htable_lookup(). */ - wait_queue_head_t lsb_marche_funebre; + wait_queue_head_t lsb_marche_funebre; }; enum { @@ -935,10 +935,10 @@ static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) static struct cfs_hash_ops lu_site_hash_ops = { .hs_hash = lu_obj_hop_hash, .hs_key = lu_obj_hop_key, - .hs_keycmp = lu_obj_hop_keycmp, - .hs_object = lu_obj_hop_object, + .hs_keycmp = lu_obj_hop_keycmp, + .hs_object = lu_obj_hop_object, .hs_get = lu_obj_hop_get, - .hs_put_locked = lu_obj_hop_put_locked, + .hs_put_locked = lu_obj_hop_put_locked, }; static void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c index 71490b75c7ae..e9e0bcf39d4e 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c @@ -105,7 +105,7 @@ static ssize_t static_uintvalue_store(struct kobject *kobj, } #define LUSTRE_STATIC_UINT_ATTR(name, value) \ -static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ +static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ { __ATTR(name, 0644, static_uintvalue_show, \ static_uintvalue_store), value } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 442b4355d946..765b5a7b9662 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2989,26 +2989,26 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) } static const struct obd_ops osc_obd_ops = { - .owner = THIS_MODULE, - .setup = osc_setup, - .precleanup = osc_precleanup, - .cleanup = osc_cleanup, - .add_conn = client_import_add_conn, - .del_conn = client_import_del_conn, - .connect = client_connect_import, - .reconnect = osc_reconnect, - .disconnect = osc_disconnect, - .statfs = osc_statfs, - .statfs_async = osc_statfs_async, - .create = osc_create, - .destroy = osc_destroy, - .getattr = osc_getattr, - .setattr = osc_setattr, - .iocontrol = osc_iocontrol, - .set_info_async = osc_set_info_async, - .import_event = osc_import_event, - .process_config = osc_process_config, - .quotactl = osc_quotactl, + .owner = THIS_MODULE, + .setup = osc_setup, + .precleanup = osc_precleanup, + .cleanup = osc_cleanup, + .add_conn = client_import_add_conn, + .del_conn = client_import_del_conn, + .connect = client_connect_import, + .reconnect = osc_reconnect, + .disconnect = osc_disconnect, + .statfs = osc_statfs, + .statfs_async = osc_statfs_async, + .create = osc_create, + .destroy = osc_destroy, + .getattr = osc_getattr, + .setattr = osc_setattr, + .iocontrol = osc_iocontrol, + .set_info_async = osc_set_info_async, + .import_event = osc_import_event, + .process_config = osc_process_config, + .quotactl = osc_quotactl, }; struct list_head osc_shrink_list = LIST_HEAD_INIT(osc_shrink_list); diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index c2f49a3e0454..5dde3495aaf4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -1508,7 +1508,7 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding) == 16, "found %lld\n", (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding)); LASSERTF(LCME_FL_INIT == 0x00000010UL, "found 0x%.8xUL\n", - (unsigned int)LCME_FL_INIT); + (unsigned int)LCME_FL_INIT); /* Checks for struct lov_comp_md_v1 */ LASSERTF((int)sizeof(struct lov_comp_md_v1) == 32, "found %lld\n", From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494611.24125.2469014113532688461.stgit@noble.brown> In lu_cdebug_printer(), is "complete" is true, then key->lck_area ends with a newline, so there is no need to include on in the format too. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index d4f1eddd96ca..3e23babb329a 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -526,7 +526,7 @@ int lu_cdebug_printer(const struct lu_env *env, ARRAY_SIZE(key->lck_area) - used, format, args); if (complete) { if (cfs_cdebug_show(msgdata->msg_mask, msgdata->msg_subsys)) - libcfs_debug_msg(msgdata, "%s\n", key->lck_area); + libcfs_debug_msg(msgdata, "%s", key->lck_area); key->lck_area[0] = 0; } va_end(args); From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494619.24125.5150721300459339252.stgit@noble.brown> Since 2.6.36, Linux' vsprintf has supported %pV which supports "recursive sprintf" - exactly the task that libcfs_debug_vmsg2 aims to provide. Instead of calling libcfs_debug_vmsg2(), we can put the fmt and args in a 'struct va_format', and pass the address of that structure to the "%pV" format. So do this to remove all users of libcfs_debug_vmsg2(). Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 176 ++++++++++---------- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 42 +++-- 2 files changed, 115 insertions(+), 103 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index f2433dc0e558..6789d3bf0485 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1970,6 +1970,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, struct ldlm_resource *resource = NULL; char *nid = "local"; va_list args; + struct va_format vaf; if (spin_trylock(&lock->l_lock)) { if (lock->l_resource) @@ -1978,6 +1979,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, } va_start(args, fmt); + vaf.fmt = fmt; + vaf.va = &args; if (exp && exp->exp_connection) { nid = libcfs_nid2str(exp->exp_connection->c_peer.nid); @@ -1988,105 +1991,110 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, } if (!resource) { - libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", - lock, - lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - lock->l_flags, nid, - lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, - lock->l_lvb_type); + libcfs_debug_msg(msgdata, + "%pV ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + &vaf, + lock, + lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + lock->l_flags, nid, + lock->l_remote_handle.cookie, + exp ? refcount_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); va_end(args); return; } switch (resource->lr_type) { case LDLM_EXTENT: - libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), lock, - lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_extent.start, - lock->l_policy_data.l_extent.end, - lock->l_req_extent.start, - lock->l_req_extent.end, - lock->l_flags, nid, - lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, - lock->l_lvb_type); + libcfs_debug_msg(msgdata, + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + &vaf, + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_extent.start, + lock->l_policy_data.l_extent.end, + lock->l_req_extent.start, + lock->l_req_extent.end, + lock->l_flags, nid, + lock->l_remote_handle.cookie, + exp ? refcount_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; case LDLM_FLOCK: - libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n", - ldlm_lock_to_ns_name(lock), lock, - lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_flock.pid, - lock->l_policy_data.l_flock.start, - lock->l_policy_data.l_flock.end, - lock->l_flags, nid, - lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout); + libcfs_debug_msg(msgdata, + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n", + &vaf, + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_flock.pid, + lock->l_policy_data.l_flock.start, + lock->l_policy_data.l_flock.end, + lock->l_flags, nid, + lock->l_remote_handle.cookie, + exp ? refcount_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout); break; case LDLM_IBITS: - libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), - lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - lock->l_policy_data.l_inodebits.bits, - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, - lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, - lock->l_lvb_type); + libcfs_debug_msg(msgdata, + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + &vaf, + ldlm_lock_to_ns_name(lock), + lock, lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + lock->l_policy_data.l_inodebits.bits, + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, + lock->l_remote_handle.cookie, + exp ? refcount_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; default: - libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), - lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - PLDLMRES(resource), - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, - lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, - lock->l_lvb_type); + libcfs_debug_msg(msgdata, + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", + &vaf, + ldlm_lock_to_ns_name(lock), + lock, lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, + lock->l_remote_handle.cookie, + exp ? refcount_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; } va_end(args); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index c7cc86c3fbc3..879cb1162cc7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -2276,6 +2276,7 @@ void _debug_req(struct ptlrpc_request *req, int rep_flags = -1; int rep_status = -1; va_list args; + struct va_format vaf; spin_lock(&req->rq_early_free_lock); if (req->rq_repmsg) @@ -2298,25 +2299,28 @@ void _debug_req(struct ptlrpc_request *req, nid = req->rq_export->exp_connection->c_peer.nid; va_start(args, fmt); - libcfs_debug_vmsg2(msgdata, fmt, args, - " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", - req, req->rq_xid, req->rq_transno, - req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0, - req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1, - req->rq_import ? - req->rq_import->imp_obd->obd_name : - req->rq_export ? - req->rq_export->exp_client_uuid.uuid : - "", - libcfs_nid2str(nid), - req->rq_request_portal, req->rq_reply_portal, - req->rq_reqlen, req->rq_replen, - req->rq_early_count, (s64)req->rq_timedout, - (s64)req->rq_deadline, - atomic_read(&req->rq_refcount), - DEBUG_REQ_FLAGS(req), - req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1, - rep_flags, req->rq_status, rep_status); + vaf.fmt = fmt; + vaf.va = &args; + libcfs_debug_msg(msgdata, + "%pV req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", + &vaf, + req, req->rq_xid, req->rq_transno, + req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0, + req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1, + req->rq_import ? + req->rq_import->imp_obd->obd_name : + req->rq_export ? + req->rq_export->exp_client_uuid.uuid : + "", + libcfs_nid2str(nid), + req->rq_request_portal, req->rq_reply_portal, + req->rq_reqlen, req->rq_replen, + req->rq_early_count, (s64)req->rq_timedout, + (s64)req->rq_deadline, + atomic_read(&req->rq_refcount), + DEBUG_REQ_FLAGS(req), + req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1, + rep_flags, req->rq_status, rep_status); va_end(args); } EXPORT_SYMBOL(_debug_req); From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2 In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494624.24125.18162964077735119291.stgit@noble.brown> Now that libcfs_debug_vmsg2 has no (external) users, we can remove it. It is used to implement libcfs_debug_msg(), so simply move the body of the function (suitably modified) into that one caller. Signed-off-by: NeilBrown --- .../lustre/include/linux/libcfs/libcfs_debug.h | 5 -- drivers/staging/lustre/lnet/libcfs/tracefile.c | 63 +++++--------------- drivers/staging/lustre/lnet/libcfs/tracefile.h | 2 - 3 files changed, 18 insertions(+), 52 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index ba5d5ba2dac2..911fd35b81b5 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -192,11 +192,6 @@ int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, const char *format1, ...) __printf(2, 3); -int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, - const char *format1, - va_list args, const char *format2, ...) - __printf(4, 5); - /* other external symbols that tracefile provides: */ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, const char __user *usr_buffer, int usr_buffer_nob); diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c index 40440ce13050..45da892cf276 100644 --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c @@ -409,22 +409,7 @@ static void cfs_print_to_console(struct ptldebug_header *hdr, int mask, } int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, - const char *format, ...) -{ - va_list args; - int rc; - - va_start(args, format); - rc = libcfs_debug_vmsg2(msgdata, format, args, NULL); - va_end(args); - - return rc; -} -EXPORT_SYMBOL(libcfs_debug_msg); - -int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, - const char *format1, va_list args, - const char *format2, ...) + const char *format, ...) { struct cfs_trace_cpu_data *tcd = NULL; struct ptldebug_header header = { 0 }; @@ -488,7 +473,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, } string_buf = (char *)page_address(tage->page) + - tage->used + known_size; + tage->used + known_size; max_nob = PAGE_SIZE - tage->used - known_size; if (max_nob <= 0) { @@ -500,22 +485,15 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, } needed = 0; - if (format1) { - va_copy(ap, args); - needed = vsnprintf(string_buf, max_nob, format1, ap); - va_end(ap); - } - if (format2) { - remain = max_nob - needed; - if (remain < 0) - remain = 0; + remain = max_nob - needed; + if (remain < 0) + remain = 0; - va_start(ap, format2); - needed += vsnprintf(string_buf + needed, remain, - format2, ap); - va_end(ap); - } + va_start(ap, format); + needed += vsnprintf(string_buf + needed, remain, + format, ap); + va_end(ap); if (needed < max_nob) /* well. printing ok.. */ break; @@ -600,22 +578,15 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, string_buf = cfs_trace_get_console_buffer(); needed = 0; - if (format1) { - va_copy(ap, args); - needed = vsnprintf(string_buf, - CFS_TRACE_CONSOLE_BUFFER_SIZE, - format1, ap); + + remain = CFS_TRACE_CONSOLE_BUFFER_SIZE - needed; + if (remain > 0) { + va_start(ap, format); + needed += vsnprintf(string_buf + needed, remain, + format, ap); va_end(ap); } - if (format2) { - remain = CFS_TRACE_CONSOLE_BUFFER_SIZE - needed; - if (remain > 0) { - va_start(ap, format2); - needed += vsnprintf(string_buf + needed, remain, - format2, ap); - va_end(ap); - } - } + cfs_print_to_console(&header, mask, string_buf, needed, file, msgdata->msg_fn); @@ -639,7 +610,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, return 0; } -EXPORT_SYMBOL(libcfs_debug_vmsg2); +EXPORT_SYMBOL(libcfs_debug_msg); void cfs_trace_assertion_failed(const char *str, diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h index 71a031d12f42..3a00a6c60653 100644 --- a/drivers/staging/lustre/lnet/libcfs/tracefile.h +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h @@ -82,7 +82,7 @@ union cfs_trace_data_union { * Even though this structure is meant to be per-CPU, locking * is needed because in some places the data may be accessed * from other CPUs. This lock is directly used in trace_get_tcd - * and trace_put_tcd, which are called in libcfs_debug_vmsg2 and + * and trace_put_tcd, which are called in libcfs_debug_msg and * tcd_for_each_type_lock */ spinlock_t tcd_lock; From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 27/37] lustre: discard lu_ref In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494627.24125.13508435808475179343.stgit@noble.brown> struct lu_ref is always an empty structure, and the functions which manipulate it do nothing. So this is not being tested and so cannot be trusted. So remove all these calls and field declarations. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/cl_object.h | 6 - drivers/staging/lustre/lustre/include/lu_object.h | 45 ----- drivers/staging/lustre/lustre/include/lu_ref.h | 178 -------------------- drivers/staging/lustre/lustre/include/lustre_dlm.h | 20 -- drivers/staging/lustre/lustre/include/obd.h | 7 - drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 36 +--- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 12 - drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 drivers/staging/lustre/lustre/llite/lcommon_cl.c | 2 drivers/staging/lustre/lustre/llite/rw.c | 6 - drivers/staging/lustre/lustre/llite/rw26.c | 6 - drivers/staging/lustre/lustre/llite/vvp_dev.c | 20 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 5 - drivers/staging/lustre/lustre/lov/lov_object.c | 2 drivers/staging/lustre/lustre/lov/lovsub_dev.c | 1 drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 drivers/staging/lustre/lustre/obdclass/Makefile | 2 drivers/staging/lustre/lustre/obdclass/cl_io.c | 8 - drivers/staging/lustre/lustre/obdclass/cl_object.c | 2 drivers/staging/lustre/lustre/obdclass/cl_page.c | 5 - drivers/staging/lustre/lustre/obdclass/genops.c | 3 drivers/staging/lustre/lustre/obdclass/lu_object.c | 34 ---- drivers/staging/lustre/lustre/obdclass/lu_ref.c | 45 ----- .../staging/lustre/lustre/obdclass/obd_config.c | 2 drivers/staging/lustre/lustre/osc/osc_cache.c | 12 - drivers/staging/lustre/lustre/osc/osc_lock.c | 2 drivers/staging/lustre/lustre/osc/osc_page.c | 2 drivers/staging/lustre/lustre/osc/osc_request.c | 2 28 files changed, 19 insertions(+), 452 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/include/lu_ref.h delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ref.c diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 05be85306663..1484821995e9 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -742,12 +742,6 @@ struct cl_page { * by sub-io. Protected by a VM lock. */ struct cl_io *cp_owner; - /** List of references to this page, for debugging. */ - struct lu_ref cp_reference; - /** Link to an object, for debugging. */ - struct lu_ref_link cp_obj_ref; - /** Link to a queue, for debugging. */ - struct lu_ref_link cp_queue_ref; /** Assigned if doing a sync_io */ struct cl_sync_io *cp_sync_io; }; diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 68aa0d05b03a..cef02e66ea8e 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -38,7 +38,6 @@ #include #include #include -#include struct seq_file; struct lustre_cfg; @@ -277,10 +276,6 @@ struct lu_device { /** \todo XXX: temporary back pointer into obd. */ struct obd_device *ld_obd; - /** - * A list of references to this object, for debugging. - */ - struct lu_ref ld_reference; /** * Link the device to the site. **/ @@ -464,10 +459,6 @@ struct lu_object { * Linkage into list of all layers. */ struct list_head lo_linkage; - /** - * Link to the device, for debugging. - */ - struct lu_ref_link lo_dev_ref; }; enum lu_object_header_flags { @@ -536,10 +527,6 @@ struct lu_object_header { * during object destruction). No locking is necessary. */ struct list_head loh_layers; - /** - * A list of references to this object, for debugging. - */ - struct lu_ref loh_reference; }; struct fld; @@ -818,34 +805,6 @@ static inline u32 lu_object_attr(const struct lu_object *o) return o->lo_header->loh_attr; } -static inline void lu_object_ref_add(struct lu_object *o, - const char *scope, - const void *source) -{ - lu_ref_add(&o->lo_header->loh_reference, scope, source); -} - -static inline void lu_object_ref_add_at(struct lu_object *o, - struct lu_ref_link *link, - const char *scope, - const void *source) -{ - lu_ref_add_at(&o->lo_header->loh_reference, link, scope, source); -} - -static inline void lu_object_ref_del(struct lu_object *o, - const char *scope, const void *source) -{ - lu_ref_del(&o->lo_header->loh_reference, scope, source); -} - -static inline void lu_object_ref_del_at(struct lu_object *o, - struct lu_ref_link *link, - const char *scope, const void *source) -{ - lu_ref_del_at(&o->lo_header->loh_reference, link, scope, source); -} - /** input params, should be filled out by mdt */ struct lu_rdpg { /** hash */ @@ -1084,10 +1043,6 @@ struct lu_context_key { * Internal implementation detail: module for this key. */ struct module *lct_owner; - /** - * References to this key. For debugging. - */ - struct lu_ref lct_reference; }; #define LU_KEY_INIT(mod, type) \ diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h deleted file mode 100644 index ad0c24d29ffa..000000000000 --- a/drivers/staging/lustre/lustre/include/lu_ref.h +++ /dev/null @@ -1,178 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - * - * Author: Nikita Danilov - * - * This file is part of Lustre, http://www.lustre.org. - * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * Lustre is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef __LUSTRE_LU_REF_H -#define __LUSTRE_LU_REF_H - -#include - -/** \defgroup lu_ref lu_ref - * - * An interface to track references between objects. Mostly for debugging. - * - * Suppose there is a reference counted data-structure struct foo. To track - * who acquired references to instance of struct foo, add lu_ref field to it: - * - * \code - * struct foo { - * atomic_t foo_refcount; - * struct lu_ref foo_reference; - * ... - * }; - * \endcode - * - * foo::foo_reference has to be initialized by calling - * lu_ref_init(). Typically there will be functions or macros to increment and - * decrement foo::foo_refcount, let's say they are foo_get(struct foo *foo) - * and foo_put(struct foo *foo), respectively. - * - * Whenever foo_get() is called to acquire a reference on a foo, lu_ref_add() - * has to be called to insert into foo::foo_reference a record, describing - * acquired reference. Dually, lu_ref_del() removes matching record. Typical - * usages are: - * - * \code - * struct bar *bar; - * - * // bar owns a reference to foo. - * bar->bar_foo = foo_get(foo); - * lu_ref_add(&foo->foo_reference, "bar", bar); - * - * ... - * - * // reference from bar to foo is released. - * lu_ref_del(&foo->foo_reference, "bar", bar); - * foo_put(bar->bar_foo); - * - * - * // current thread acquired a temporary reference to foo. - * foo_get(foo); - * lu_ref_add(&foo->reference, __func__, current); - * - * ... - * - * // temporary reference is released. - * lu_ref_del(&foo->reference, __func__, current); - * foo_put(foo); - * \endcode - * - * \e Et \e cetera. Often it makes sense to include lu_ref_add() and - * lu_ref_del() calls into foo_get() and foo_put(). When an instance of struct - * foo is destroyed, lu_ref_fini() has to be called that checks that no - * pending references remain. lu_ref_print() can be used to dump a list of - * pending references, while hunting down a leak. - * - * For objects to which a large number of references can be acquired, - * lu_ref_del() can become cpu consuming, as it has to scan the list of - * references. To work around this, remember result of lu_ref_add() (usually - * in the same place where pointer to struct foo is stored), and use - * lu_ref_del_at(): - * - * \code - * // There is a large number of bar's for a single foo. - * bar->bar_foo = foo_get(foo); - * bar->bar_foo_ref = lu_ref_add(&foo->foo_reference, "bar", bar); - * - * ... - * - * // reference from bar to foo is released. - * lu_ref_del_at(&foo->foo_reference, bar->bar_foo_ref, "bar", bar); - * foo_put(bar->bar_foo); - * \endcode - * - * lu_ref interface degrades gracefully in case of memory shortages. - * - * @{ - */ - -/* - * dummy data structures/functions to pass compile for now. - * We need to reimplement them with kref. - */ -struct lu_ref {}; -struct lu_ref_link {}; - -static inline void lu_ref_init(struct lu_ref *ref) -{ -} - -static inline void lu_ref_fini(struct lu_ref *ref) -{ -} - -static inline struct lu_ref_link *lu_ref_add(struct lu_ref *ref, - const char *scope, - const void *source) -{ - return NULL; -} - -static inline struct lu_ref_link *lu_ref_add_atomic(struct lu_ref *ref, - const char *scope, - const void *source) -{ - return NULL; -} - -static inline void lu_ref_add_at(struct lu_ref *ref, - struct lu_ref_link *link, - const char *scope, - const void *source) -{ -} - -static inline void lu_ref_del(struct lu_ref *ref, const char *scope, - const void *source) -{ -} - -static inline void lu_ref_set_at(struct lu_ref *ref, struct lu_ref_link *link, - const char *scope, const void *source0, - const void *source1) -{ -} - -static inline void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link, - const char *scope, const void *source) -{ -} - -static inline int lu_ref_global_init(void) -{ - return 0; -} - -static inline void lu_ref_global_fini(void) -{ -} - -static inline void lu_ref_print(const struct lu_ref *ref) -{ -} - -static inline void lu_ref_print_all(void) -{ -} - -/** @} lu */ - -#endif /* __LUSTRE_LU_REF_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index c561d61d1a49..6c0371ef056c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -49,7 +49,6 @@ #include #include #include -#include #include "lustre_dlm_flags.h" @@ -785,8 +784,6 @@ struct ldlm_lock { struct list_head l_sl_mode; struct list_head l_sl_policy; - /** Reference tracking structure to debug leaked locks. */ - struct lu_ref l_reference; #if LUSTRE_TRACKS_LOCK_EXP_REFS /* Debugging stuff for bug 20498, for tracking export references. */ /** number of export references taken */ @@ -859,9 +856,6 @@ struct ldlm_resource { * Associated inode, used only on client side. */ struct inode *lr_lvb_inode; - - /** List of references to this resource. For debugging. */ - struct lu_ref lr_reference; }; static inline bool ldlm_has_layout(struct ldlm_lock *lock) @@ -1066,17 +1060,12 @@ static inline struct ldlm_lock *ldlm_handle2lock(const struct lustre_handle *h) return __ldlm_handle2lock(h, 0); } -#define LDLM_LOCK_REF_DEL(lock) \ - lu_ref_del(&lock->l_reference, "handle", current) - static inline struct ldlm_lock * ldlm_handle2lock_long(const struct lustre_handle *h, u64 flags) { struct ldlm_lock *lock; lock = __ldlm_handle2lock(h, flags); - if (lock) - LDLM_LOCK_REF_DEL(lock); return lock; } @@ -1107,7 +1096,6 @@ void ldlm_dump_export_locks(struct obd_export *exp); */ #define LDLM_LOCK_PUT(lock) \ do { \ - LDLM_LOCK_REF_DEL(lock); \ /*LDLM_DEBUG((lock), "put");*/ \ ldlm_lock_put(lock); \ } while (0) @@ -1198,14 +1186,6 @@ void ldlm_resource_dump(int level, struct ldlm_resource *); int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *, const struct ldlm_res_id *); -#define LDLM_RESOURCE_ADDREF(res) do { \ - lu_ref_add_atomic(&(res)->lr_reference, __func__, current); \ -} while (0) - -#define LDLM_RESOURCE_DELREF(res) do { \ - lu_ref_del(&(res)->lr_reference, __func__, current); \ -} while (0) - /* ldlm_request.c */ /** \defgroup ldlm_local_ast Default AST handlers for local locks * These AST handlers are typically used for server-side local locks and are diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index e09268f08e5c..f7f4db0481b2 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -40,7 +40,6 @@ #include #include -#include #include #include #include @@ -615,12 +614,6 @@ struct obd_device { int obd_conn_inprogress; - /** - * A list of outstanding class_incref()'s against this obd. For - * debugging. - */ - struct lu_ref obd_reference; - struct kset obd_kset; /* sysfs object collection */ struct kobj_type obd_ktype; struct completion obd_kobj_unregister; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 6789d3bf0485..60a6ec2f7136 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -175,7 +175,6 @@ void ldlm_lock_put(struct ldlm_lock *lock) lprocfs_counter_decr(ldlm_res_to_ns(res)->ns_stats, LDLM_NSS_LOCKS); - lu_ref_del(&res->lr_reference, "lock", lock); ldlm_resource_putref(res); lock->l_resource = NULL; if (lock->l_export) { @@ -185,7 +184,6 @@ void ldlm_lock_put(struct ldlm_lock *lock) kfree(lock->l_lvb_data); - lu_ref_fini(&lock->l_reference); OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle); } } @@ -334,10 +332,8 @@ static void ldlm_lock_destroy(struct ldlm_lock *lock) unlock_res_and_lock(lock); /* drop reference from hashtable only for first destroy */ - if (first) { - lu_ref_del(&lock->l_reference, "hash", lock); + if (first) LDLM_LOCK_RELEASE(lock); - } } /** @@ -349,10 +345,8 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) first = ldlm_lock_destroy_internal(lock); /* drop reference from hashtable only for first destroy */ - if (first) { - lu_ref_del(&lock->l_reference, "hash", lock); + if (first) LDLM_LOCK_RELEASE(lock); - } } /* this is called by portals_handle2object with the handle lock taken */ @@ -392,7 +386,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) spin_lock_init(&lock->l_lock); lock->l_resource = resource; - lu_ref_add(&resource->lr_reference, "lock", lock); atomic_set(&lock->l_refc, 2); INIT_LIST_HEAD(&lock->l_res_link); @@ -412,8 +405,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) INIT_LIST_HEAD(&lock->l_handle.h_link); class_handle_hash(&lock->l_handle, &lock_handle_ops); - lu_ref_init(&lock->l_reference); - lu_ref_add(&lock->l_reference, "hash", lock); lock->l_callback_timeout = 0; #if LUSTRE_TRACKS_LOCK_EXP_REFS @@ -457,7 +448,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, if (IS_ERR(newres)) return PTR_ERR(newres); - lu_ref_add(&newres->lr_reference, "lock", lock); /* * To flip the lock from the old to the new resource, lock, oldres and * newres have to be locked. Resource spin-locks are nested within @@ -480,7 +470,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, unlock_res_and_lock(lock); /* ...and the flowers are still standing! */ - lu_ref_del(&oldres->lr_reference, "lock", lock); ldlm_resource_putref(oldres); return 0; @@ -528,16 +517,13 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, /* It's unlikely but possible that someone marked the lock as * destroyed after we did handle2object on it */ - if (flags == 0 && !ldlm_is_destroyed(lock)) { - lu_ref_add(&lock->l_reference, "handle", current); + if (flags == 0 && !ldlm_is_destroyed(lock)) return lock; - } lock_res_and_lock(lock); LASSERT(lock->l_resource); - lu_ref_add_atomic(&lock->l_reference, "handle", current); if (unlikely(ldlm_is_destroyed(lock))) { unlock_res_and_lock(lock); CDEBUG(D_INFO, "lock already destroyed: lock %p\n", lock); @@ -658,16 +644,13 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock, enum ldlm_mode mode) { ldlm_lock_remove_from_lru(lock); - if (mode & (LCK_NL | LCK_CR | LCK_PR)) { + if (mode & (LCK_NL | LCK_CR | LCK_PR)) lock->l_readers++; - lu_ref_add_atomic(&lock->l_reference, "reader", lock); - } - if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) { + + if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) lock->l_writers++; - lu_ref_add_atomic(&lock->l_reference, "writer", lock); - } + LDLM_LOCK_GET(lock); - lu_ref_add_atomic(&lock->l_reference, "user", lock); LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]); } @@ -725,16 +708,13 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock, LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]); if (mode & (LCK_NL | LCK_CR | LCK_PR)) { LASSERT(lock->l_readers > 0); - lu_ref_del(&lock->l_reference, "reader", lock); lock->l_readers--; } if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) { LASSERT(lock->l_writers > 0); - lu_ref_del(&lock->l_reference, "writer", lock); lock->l_writers--; } - lu_ref_del(&lock->l_reference, "user", lock); LDLM_LOCK_RELEASE(lock); /* matches the LDLM_LOCK_GET() in addref */ } @@ -1285,7 +1265,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags, return 0; } - LDLM_RESOURCE_ADDREF(res); lock_res(res); if (res->lr_type == LDLM_EXTENT) @@ -1307,7 +1286,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags, } out: unlock_res(res); - LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); if (lock) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index b819adef2bfe..1f04a782bd89 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1423,7 +1423,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, LDLM_LOCK_GET(lock); spin_unlock(&ns->ns_lock); - lu_ref_add(&lock->l_reference, __func__, current); /* Pass the lock through the policy filter and see if it * should stay in LRU. @@ -1441,15 +1440,11 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, */ result = pf(ns, lock, unused, added, count); if (result == LDLM_POLICY_KEEP_LOCK) { - lu_ref_del(&lock->l_reference, - __func__, current); LDLM_LOCK_RELEASE(lock); spin_lock(&ns->ns_lock); break; } if (result == LDLM_POLICY_SKIP_LOCK) { - lu_ref_del(&lock->l_reference, - __func__, current); LDLM_LOCK_RELEASE(lock); spin_lock(&ns->ns_lock); continue; @@ -1467,8 +1462,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, * pages could be put under it. */ unlock_res_and_lock(lock); - lu_ref_del(&lock->l_reference, - __func__, current); LDLM_LOCK_RELEASE(lock); spin_lock(&ns->ns_lock); continue; @@ -1507,7 +1500,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, LASSERT(list_empty(&lock->l_bl_ast)); list_add(&lock->l_bl_ast, cancels); unlock_res_and_lock(lock); - lu_ref_del(&lock->l_reference, __func__, current); spin_lock(&ns->ns_lock); added++; unused--; @@ -1695,7 +1687,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, return 0; } - LDLM_RESOURCE_ADDREF(res); count = ldlm_cancel_resource_local(res, &cancels, policy, mode, 0, flags | LCF_BL_AST, opaque); rc = ldlm_cli_cancel_list(&cancels, count, NULL, flags); @@ -1703,7 +1694,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, CERROR("canceling unused lock " DLDLMRES ": rc = %d\n", PLDLMRES(res), rc); - LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); return 0; } @@ -1843,9 +1833,7 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns, if (IS_ERR(res)) return 0; - LDLM_RESOURCE_ADDREF(res); rc = ldlm_resource_foreach(res, iter, data); - LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); return rc; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index ae2fddd044ea..371cc1d5e539 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1021,7 +1021,6 @@ static struct ldlm_resource *ldlm_resource_new(enum ldlm_type ldlm_type) atomic_set(&res->lr_refcount, 1); spin_lock_init(&res->lr_lock); - lu_ref_init(&res->lr_reference); /* The creator of the resource must unlock the mutex after LVB * initialization. @@ -1084,8 +1083,6 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, if (hnode) { /* Someone won the race and already added the resource. */ cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); - /* Clean lu_ref for failed resource. */ - lu_ref_fini(&res->lr_reference); /* We have taken lr_lvb_mutex. Drop it. */ mutex_unlock(&res->lr_lvb_mutex); if (res->lr_itree) @@ -1163,7 +1160,6 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd, cfs_hash_bd_del_locked(ns->ns_rs_hash, bd, &res->lr_hash); - lu_ref_fini(&res->lr_reference); cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1); if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) ns->ns_lvbo->lvbo_free(res); diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c index afcaa5ec13c2..94299fc2f5e3 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c @@ -179,7 +179,6 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md) * locked by I_NEW bit. */ lli->lli_clob = clob; - lu_object_ref_add(&clob->co_lu, "inode", inode); } else { result = PTR_ERR(clob); } @@ -254,7 +253,6 @@ void cl_inode_fini(struct inode *inode) * when its master is evicted. */ cl_object_kill(env, clob); - lu_object_ref_del(&clob->co_lu, "inode", inode); cl_object_put_last(env, clob); lli->lli_clob = NULL; if (emergency) diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index af983ee09e8e..185d1692d79b 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -209,7 +209,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, goto out; } - lu_ref_add(&page->cp_reference, "ra", current); cl_page_assume(env, io, page); vpg = cl2vvp_page(cl_object_page_slice(clob, page)); if (!vpg->vpg_defer_uptodate && !PageUptodate(vmpage)) { @@ -225,7 +224,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, rc = 1; } - lu_ref_del(&page->cp_reference, "ra", current); cl_page_put(env, page); out: if (vmpage) { @@ -936,8 +934,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) page = cl_page_find(env, clob, vmpage->index, vmpage, CPT_CACHEABLE); if (!IS_ERR(page)) { - lu_ref_add(&page->cp_reference, "writepage", - current); cl_page_assume(env, io, page); result = cl_page_flush(env, io, page); if (result != 0) { @@ -954,8 +950,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) } cl_page_disown(env, io, page); unlocked = true; - lu_ref_del(&page->cp_reference, - "writepage", current); cl_page_put(env, page); } else { result = PTR_ERR(page); diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index e4ce3b6f5772..9bcbc8b084e5 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -482,7 +482,6 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, } lcc->lcc_page = page; - lu_ref_add(&page->cp_reference, "cl_io", io); cl_page_assume(env, io, page); if (!PageUptodate(vmpage)) { @@ -511,10 +510,8 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, unlock_page(vmpage); put_page(vmpage); } - if (!IS_ERR_OR_NULL(page)) { - lu_ref_del(&page->cp_reference, "cl_io", io); + if (!IS_ERR_OR_NULL(page)) cl_page_put(env, page); - } if (io) io->ci_result = result; } else { @@ -575,7 +572,6 @@ static int ll_write_end(struct file *file, struct address_space *mapping, cl_page_disown(env, io, page); lcc->lcc_page = NULL; - lu_ref_del(&page->cp_reference, "cl_io", io); cl_page_put(env, page); /* page list is not contiguous now, commit it now */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index c10ca6e7c606..34206166ada4 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -240,10 +240,9 @@ static int vvp_device_init(const struct lu_env *env, struct lu_device *d, rc = next->ld_type->ldt_ops->ldto_device_init(env, next, next->ld_type->ldt_name, NULL); - if (rc == 0) { + if (rc == 0) lu_device_get(next); - lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); - } + return rc; } @@ -420,10 +419,9 @@ static struct cl_object *vvp_pgcache_obj(const struct lu_env *env, struct lu_object *lu_obj; lu_obj = lu_object_locate(id->vpi_obj, dev->ld_type); - if (lu_obj) { - lu_object_ref_add(lu_obj, "dump", current); + if (lu_obj) return lu2cl(lu_obj); - } + lu_object_put(env, lu_object_top(id->vpi_obj)); } return NULL; @@ -456,7 +454,6 @@ static struct page *vvp_pgcache_current(struct vvp_seq_private *priv) priv->vsp_id.vpi_index = vmpage->index; return vmpage; } - lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current); cl_object_put(priv->vsp_env, priv->vsp_clob); priv->vsp_clob = NULL; priv->vsp_id.vpi_index = 0; @@ -527,11 +524,8 @@ static void vvp_pgcache_rewind(struct vvp_seq_private *priv) if (priv->vsp_prev_pos) { memset(&priv->vsp_id, 0, sizeof(priv->vsp_id)); priv->vsp_prev_pos = 0; - if (priv->vsp_clob) { - lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", - current); + if (priv->vsp_clob) cl_object_put(priv->vsp_env, priv->vsp_clob); - } priv->vsp_clob = NULL; } } @@ -607,10 +601,8 @@ static int vvp_dump_pgcache_seq_release(struct inode *inode, struct file *file) struct seq_file *seq = file->private_data; struct vvp_seq_private *priv = seq->private; - if (priv->vsp_clob) { - lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current); + if (priv->vsp_clob) cl_object_put(priv->vsp_env, priv->vsp_clob); - } cl_env_put(priv->vsp_env, &priv->vsp_refcheck); return seq_release_private(inode, file); diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 593b10cecf7d..62b507926c20 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -382,7 +382,6 @@ static void vvp_io_fault_fini(const struct lu_env *env, CLOBINVRNT(env, io->ci_obj, vvp_object_invariant(io->ci_obj)); if (page) { - lu_ref_del(&page->cp_reference, "fault", io); cl_page_put(env, page); io->u.ci_fault.ft_page = NULL; } @@ -824,7 +823,6 @@ static int vvp_io_commit_sync(const struct lu_env *env, struct cl_io *io, cl_page_disown(env, io, page); /* held in ll_cl_init() */ - lu_ref_del(&page->cp_reference, "cl_io", io); cl_page_put(env, page); } } @@ -843,7 +841,6 @@ static void write_commit_callback(const struct lu_env *env, struct cl_io *io, cl_page_disown(env, io, page); /* held in ll_cl_init() */ - lu_ref_del(&page->cp_reference, "cl_io", cl_io_top(io)); cl_page_put(env, page); } @@ -944,7 +941,6 @@ int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io) cl_page_disown(env, io, page); /* held in ll_cl_init() */ - lu_ref_del(&page->cp_reference, "cl_io", io); cl_page_put(env, page); } cl_page_list_fini(env, queue); @@ -1260,7 +1256,6 @@ static int vvp_io_fault_start(const struct lu_env *env, else fio->ft_nob = cl_page_size(obj); - lu_ref_add(&page->cp_reference, "fault", io); fio->ft_page = page; out: diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 397ecc1dbb4c..cde8215a0b4c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -149,7 +149,6 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, subhdr->coh_parent = hdr; spin_unlock(&subhdr->coh_attr_guard); subhdr->coh_nesting = hdr->coh_nesting + 1; - lu_object_ref_add(&subobj->co_lu, "lov-parent", lov); r0->lo_sub[stripe] = cl2lovsub(subobj); r0->lo_sub[stripe]->lso_super = lov; r0->lo_sub[stripe]->lso_index = idx; @@ -405,7 +404,6 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov, cl_object_kill(env, sub); /* release a reference to the sub-object and ... */ - lu_object_ref_del(&sub->co_lu, "lov-parent", lov); cl_object_put(env, sub); /* ... wait until it is actually destroyed---sub-object clears its diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 69380fc6aeab..d9b044e5aca1 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -65,7 +65,6 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d, } lu_device_get(next); - lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); lsd->acid_next = lu2cl_dev(next); return rc; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index e0e7b00fd2be..e878bc76da8a 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -87,12 +87,10 @@ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, NULL, &res_id, 0, 0); if (IS_ERR(res)) return 0; - LDLM_RESOURCE_ADDREF(res); /* Initialize ibits lock policy. */ policy.l_inodebits.bits = bits; count = ldlm_cancel_resource_local(res, cancels, &policy, mode, 0, 0, NULL); - LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); return count; } diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index 1669c24a0b03..ee63ebd3947b 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -7,5 +7,5 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o \ genops.o obd_sysfs.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ - obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \ + obdo.o obd_config.o obd_mount.o lu_object.o \ cl_object.o cl_page.o cl_lock.o cl_io.o kernelcomm.o diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 3b4aca4e4a53..9755174c2db6 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -770,7 +770,6 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) LASSERT(list_empty(&page->cp_batch)); list_add_tail(&page->cp_batch, &plist->pl_pages); ++plist->pl_nr; - lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_get(page); } EXPORT_SYMBOL(cl_page_list_add); @@ -787,7 +786,6 @@ void cl_page_list_del(const struct lu_env *env, struct cl_page_list *plist, list_del_init(&page->cp_batch); --plist->pl_nr; - lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_put(env, page); } EXPORT_SYMBOL(cl_page_list_del); @@ -805,8 +803,6 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src, list_move_tail(&page->cp_batch, &dst->pl_pages); --src->pl_nr; ++dst->pl_nr; - lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue", - src, dst); } EXPORT_SYMBOL(cl_page_list_move); @@ -823,8 +819,6 @@ void cl_page_list_move_head(struct cl_page_list *dst, struct cl_page_list *src, list_move(&page->cp_batch, &dst->pl_pages); --src->pl_nr; ++dst->pl_nr; - lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue", - src, dst); } EXPORT_SYMBOL(cl_page_list_move_head); @@ -869,8 +863,6 @@ void cl_page_list_disown(const struct lu_env *env, * XXX __cl_page_disown() will fail if page is not locked. */ __cl_page_disown(env, io, page); - lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", - plist); cl_page_put(env, page); } } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index b09621f0f1f8..c7cf2e736ff7 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -924,8 +924,6 @@ struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site, rc = ldt->ldt_ops->ldto_device_init(env, d, typename, next); if (rc == 0) { lu_device_get(d); - lu_ref_add(&d->ld_reference, - "lu-stack", &lu_site_init); } else { ldt->ldt_ops->ldto_device_free(env, d); CERROR("can't init device '%s', %d\n", typename, rc); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 7dcd3aff229f..a44533a063df 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -106,9 +106,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) if (unlikely(slice->cpl_ops->cpo_fini)) slice->cpl_ops->cpo_fini(env, slice); } - lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); cl_object_put(env, obj); - lu_ref_fini(&page->cp_reference); kfree(page); } @@ -138,14 +136,11 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, refcount_set(&page->cp_ref, 1); page->cp_obj = o; cl_object_get(o); - lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page", - page); page->cp_vmpage = vmpage; cl_page_state_set_trust(page, CPS_CACHED); page->cp_type = type; INIT_LIST_HEAD(&page->cp_layers); INIT_LIST_HEAD(&page->cp_batch); - lu_ref_init(&page->cp_reference); cl_object_for_each(o2, o) { if (o2->co_ops->coo_page_init) { result = o2->co_ops->coo_page_init(env, o2, page, diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index c91704d87042..ce92c8c1dc75 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -80,7 +80,6 @@ static void obd_device_free(struct obd_device *obd) obd, obd->obd_namespace, obd->obd_force); LBUG(); } - lu_ref_fini(&obd->obd_reference); kmem_cache_free(obd_device_cachep, obd); } @@ -314,8 +313,6 @@ struct obd_device *class_newdev(const char *type_name, const char *name, llog_group_init(&newdev->obd_olg); /* Detach drops this */ atomic_set(&newdev->obd_refcount, 1); - lu_ref_init(&newdev->obd_reference); - lu_ref_add(&newdev->obd_reference, "newdev", newdev); newdev->obd_conn_inprogress = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 3e23babb329a..6a1c3bc3e9e8 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -52,7 +52,6 @@ #include #include #include -#include #include struct lu_site_bkt_data { @@ -1018,7 +1017,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) s->ls_top_dev = top; top->ld_site = s; lu_device_get(top); - lu_ref_add(&top->ld_reference, "site-top", s); INIT_LIST_HEAD(&s->ls_ld_linkage); spin_lock_init(&s->ls_ld_lock); @@ -1047,7 +1045,6 @@ void lu_site_fini(struct lu_site *s) if (s->ls_top_dev) { s->ls_top_dev->ld_site = NULL; - lu_ref_del(&s->ls_top_dev->ld_reference, "site-top", s); lu_device_put(s->ls_top_dev); s->ls_top_dev = NULL; } @@ -1104,7 +1101,6 @@ int lu_device_init(struct lu_device *d, struct lu_device_type *t) memset(d, 0, sizeof(*d)); atomic_set(&d->ld_ref, 0); d->ld_type = t; - lu_ref_init(&d->ld_reference); INIT_LIST_HEAD(&d->ld_linkage); return 0; } @@ -1122,7 +1118,6 @@ void lu_device_fini(struct lu_device *d) d->ld_obd = NULL; } - lu_ref_fini(&d->ld_reference); LASSERTF(atomic_read(&d->ld_ref) == 0, "Refcount is %u\n", atomic_read(&d->ld_ref)); LASSERT(atomic_read(&t->ldt_device_nr) > 0); @@ -1144,7 +1139,6 @@ int lu_object_init(struct lu_object *o, struct lu_object_header *h, o->lo_header = h; o->lo_dev = d; lu_device_get(d); - lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o); INIT_LIST_HEAD(&o->lo_linkage); return 0; @@ -1161,8 +1155,6 @@ void lu_object_fini(struct lu_object *o) LASSERT(list_empty(&o->lo_linkage)); if (dev) { - lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref, - "lu_object", o); lu_device_put(dev); o->lo_dev = NULL; } @@ -1203,7 +1195,6 @@ int lu_object_header_init(struct lu_object_header *h) INIT_HLIST_NODE(&h->loh_hash); INIT_LIST_HEAD(&h->loh_lru); INIT_LIST_HEAD(&h->loh_layers); - lu_ref_init(&h->loh_reference); return 0; } EXPORT_SYMBOL(lu_object_header_init); @@ -1216,7 +1207,6 @@ void lu_object_header_fini(struct lu_object_header *h) LASSERT(list_empty(&h->loh_layers)); LASSERT(list_empty(&h->loh_lru)); LASSERT(hlist_unhashed(&h->loh_hash)); - lu_ref_fini(&h->loh_reference); } EXPORT_SYMBOL(lu_object_header_fini); @@ -1253,7 +1243,6 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) lu_site_purge(env, site, ~0); for (scan = top; scan; scan = next) { next = scan->ld_type->ldt_ops->ldto_device_fini(env, scan); - lu_ref_del(&scan->ld_reference, "lu-stack", &lu_site_init); lu_device_put(scan); } @@ -1306,7 +1295,6 @@ int lu_context_key_register(struct lu_context_key *key) result = -ENFILE; atomic_set(&key->lct_used, 1); - lu_ref_init(&key->lct_reference); for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { if (lu_keys[i]) continue; @@ -1318,10 +1306,9 @@ int lu_context_key_register(struct lu_context_key *key) atomic_inc(&key_set_version); break; } - if (result) { - lu_ref_fini(&key->lct_reference); + if (result) atomic_set(&key->lct_used, 0); - } + return result; } EXPORT_SYMBOL(lu_context_key_register); @@ -1335,7 +1322,6 @@ static void key_fini(struct lu_context *ctx, int index) LASSERT(atomic_read(&key->lct_used) > 1); key->lct_fini(ctx, key, ctx->lc_value[index]); - lu_ref_del(&key->lct_reference, "ctx", ctx); if (atomic_dec_and_test(&key->lct_used)) wake_up_var(&key->lct_used); @@ -1364,8 +1350,7 @@ void lu_context_key_degister(struct lu_context_key *key) atomic_dec(&key->lct_used); wait_var_event(&key->lct_used, atomic_read(&key->lct_used) == 0); - if (!WARN_ON(lu_keys[key->lct_index] == NULL)) - lu_ref_fini(&key->lct_reference); + WARN_ON(lu_keys[key->lct_index] == NULL); smp_store_release(&lu_keys[key->lct_index], NULL); } EXPORT_SYMBOL(lu_context_key_degister); @@ -1562,7 +1547,6 @@ static int keys_fill(struct lu_context *ctx) break; } - lu_ref_add_atomic(&key->lct_reference, "ctx", ctx); atomic_inc(&key->lct_used); /* * This is the only place in the code, where an @@ -1873,16 +1857,10 @@ int lu_global_init(void) CDEBUG(D_INFO, "Lustre LU module (%p).\n", &lu_keys); - result = lu_ref_global_init(); - if (result != 0) - return result; - LU_CONTEXT_KEY_INIT(&lu_global_key); result = lu_context_key_register(&lu_global_key); - if (result != 0) { - lu_ref_global_fini(); + if (result != 0) return result; - } /* * At this level, we don't know what tags are needed, so allocate them @@ -1894,7 +1872,6 @@ int lu_global_init(void) up_write(&lu_sites_guard); if (result != 0) { lu_context_key_degister(&lu_global_key); - lu_ref_global_fini(); return result; } @@ -1912,7 +1889,6 @@ int lu_global_init(void) lu_env_fini(&lu_shrink_env); up_write(&lu_sites_guard); - lu_ref_global_fini(); return result; } @@ -1934,8 +1910,6 @@ void lu_global_fini(void) down_write(&lu_sites_guard); lu_env_fini(&lu_shrink_env); up_write(&lu_sites_guard); - - lu_ref_global_fini(); } static u32 ls_stats_read(struct lprocfs_stats *stats, int idx) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c deleted file mode 100644 index f67cb89ea0ba..000000000000 --- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/obdclass/lu_ref.c - * - * Lustre reference. - * - * Author: Nikita Danilov - */ - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include -#include -#include diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 0cdadea4e63c..45e8f03dec80 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -520,7 +520,6 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) struct obd_device *class_incref(struct obd_device *obd, const char *scope, const void *source) { - lu_ref_add_atomic(&obd->obd_reference, scope, source); atomic_inc(&obd->obd_refcount); CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd, atomic_read(&obd->obd_refcount)); @@ -538,7 +537,6 @@ void class_decref(struct obd_device *obd, const char *scope, const void *source) LASSERT(obd->obd_num_exports >= 0); last = atomic_dec_and_test(&obd->obd_refcount); - lu_ref_del(&obd->obd_reference, scope, source); if (last) { struct obd_export *exp; diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 4359a9320f37..81af452fbd85 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -388,8 +388,6 @@ static void osc_extent_free(struct kref *kref) LASSERT(RB_EMPTY_NODE(&ext->oe_node)); if (ext->oe_dlmlock) { - lu_ref_add(&ext->oe_dlmlock->l_reference, - "osc_extent", ext); LDLM_LOCK_PUT(ext->oe_dlmlock); ext->oe_dlmlock = NULL; } @@ -731,7 +729,6 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, if (olck->ols_dlmlock) { LASSERT(olck->ols_hold); cur->oe_dlmlock = LDLM_LOCK_GET(olck->ols_dlmlock); - lu_ref_add(&olck->ols_dlmlock->l_reference, "osc_extent", cur); } /* grants has been allocated by caller */ @@ -1039,7 +1036,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, list_del_init(&oap->oap_pending_item); cl_page_get(page); - lu_ref_add(&page->cp_reference, "truncate", current); if (cl_page_own(env, io, page) == 0) { cl_page_discard(env, io, page); @@ -1049,7 +1045,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, LASSERT(0); } - lu_ref_del(&page->cp_reference, "truncate", current); cl_page_put(env, page); --ext->oe_nr_pages; @@ -1386,7 +1381,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, * released in cl_page_completion() and nothing except for the * reference counter protects page from concurrent reclaim. */ - lu_ref_del(&page->cp_reference, "transfer", page); cl_page_completion(env, page, crt, rc); cl_page_put(env, page); @@ -2208,7 +2202,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) spin_lock(&cli->cl_loi_list_lock); while ((osc = osc_next_obj(cli)) != NULL) { struct cl_object *obj = osc2cl(osc); - struct lu_ref_link link; OSC_IO_DEBUG(osc, "%lu in flight\n", rpcs_in_flight(cli)); @@ -2219,7 +2212,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) cl_object_get(obj); spin_unlock(&cli->cl_loi_list_lock); - lu_object_ref_add_at(&obj->co_lu, &link, "check", current); /* attempt some read/write balancing by alternating between * reads and writes in an object. The makes_rpc checks here @@ -2256,7 +2248,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) CERROR("Read request failed with %d\n", rc); osc_list_maint(cli, osc); - lu_object_ref_del_at(&obj->co_lu, &link, "check", current); cl_object_put(env, obj); spin_lock(&cli->cl_loi_list_lock); @@ -3065,8 +3056,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, continue; cl_page_get(page); - lu_ref_add_atomic(&page->cp_reference, - "gang_lookup", current); pvec[j++] = ops; } ++idx; @@ -3088,7 +3077,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, res = (*cb)(env, io, ops, cbdata); page = ops->ops_cl.cpl_page; - lu_ref_del(&page->cp_reference, "gang_lookup", current); cl_page_put(env, page); } if (nr < OTI_PVEC_SIZE || end_of_region) diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index bfc1abb47b49..ccdbdeffd1f3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -239,7 +239,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *oscl, /* lock reference taken by ldlm_handle2lock_long() is * owned by osc_lock and released in osc_lock_detach() */ - lu_ref_add(&dlmlock->l_reference, "osc_lock", oscl); oscl->ols_has_ref = 1; LASSERT(!oscl->ols_dlmlock); @@ -1031,7 +1030,6 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck) /* release a reference taken in osc_lock_upcall(). */ LASSERT(olck->ols_has_ref); - lu_ref_del(&dlmlock->l_reference, "osc_lock", olck); LDLM_LOCK_RELEASE(dlmlock); olck->ols_has_ref = 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index ce911b82512d..3ee7f14f7c7a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -61,7 +61,6 @@ static void osc_page_transfer_get(struct osc_page *opg, const char *label) LASSERT(!opg->ops_transfer_pinned); cl_page_get(page); - lu_ref_add_atomic(&page->cp_reference, label, page); opg->ops_transfer_pinned = 1; } @@ -72,7 +71,6 @@ static void osc_page_transfer_put(const struct lu_env *env, if (opg->ops_transfer_pinned) { opg->ops_transfer_pinned = 0; - lu_ref_del(&page->cp_reference, "transfer", page); cl_page_put(env, page); } } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 765b5a7b9662..6ba443be1026 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -556,10 +556,8 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, if (IS_ERR(res)) return 0; - LDLM_RESOURCE_ADDREF(res); count = ldlm_cancel_resource_local(res, cancels, NULL, mode, lock_flags, 0, NULL); - LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); return count; } From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494637.24125.716197573687357279.stgit@noble.brown> These arguments are no longer used, so we can discard them. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd_class.h | 6 ++---- drivers/staging/lustre/lustre/obdclass/genops.c | 12 ++++++------ .../staging/lustre/lustre/obdclass/obd_config.c | 17 ++++++++--------- drivers/staging/lustre/lustre/obdclass/obd_sysfs.c | 4 ++-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index dd480501d7df..a913ef76a008 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -133,10 +133,8 @@ int class_parse_net(char *buf, u32 *net, char **endh); int class_match_nid(char *buf, char *key, lnet_nid_t nid); int class_match_net(char *buf, char *key, u32 net); -struct obd_device *class_incref(struct obd_device *obd, - const char *scope, const void *source); -void class_decref(struct obd_device *obd, - const char *scope, const void *source); +struct obd_device *class_incref(struct obd_device *obd); +void class_decref(struct obd_device *obd); int class_config_llog_handler(const struct lu_env *env, struct llog_handle *handle, struct llog_rec_hdr *rec, void *data); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index ce92c8c1dc75..fc7985a2922c 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -622,13 +622,13 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen) if (strncmp(obd->obd_name, fsname, namelen)) continue; - class_incref(obd, __func__, obd); + class_incref(obd); read_unlock(&obd_dev_lock); rc2 = obd_set_info_async(NULL, obd->obd_self_export, sizeof(KEY_SPTLRPC_CONF), KEY_SPTLRPC_CONF, 0, NULL, NULL); rc = rc ? rc : rc2; - class_decref(obd, __func__, obd); + class_decref(obd); read_lock(&obd_dev_lock); } read_unlock(&obd_dev_lock); @@ -737,7 +737,7 @@ static void class_export_destroy(struct obd_export *exp) * exists until freeing of the obd */ if (exp != obd->obd_self_export) - class_decref(obd, "export", exp); + class_decref(obd); OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); } @@ -863,7 +863,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd, } if (!is_self) { - class_incref(obd, "export", export); + class_incref(obd); list_add(&export->exp_obd_chain, &export->exp_obd->obd_exports); obd->obd_num_exports++; } else { @@ -934,7 +934,7 @@ static void class_import_destroy(struct obd_import *imp) } LASSERT(!imp->imp_sec); - class_decref(imp->imp_obd, "import", imp); + class_decref(imp->imp_obd); OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle); } @@ -1017,7 +1017,7 @@ struct obd_import *class_new_import(struct obd_device *obd) spin_lock_init(&imp->imp_lock); imp->imp_last_success_conn = 0; imp->imp_state = LUSTRE_IMP_NEW; - imp->imp_obd = class_incref(obd, "import", imp); + imp->imp_obd = class_incref(obd); mutex_init(&imp->imp_sec_mutex); init_waitqueue_head(&imp->imp_recovery_waitq); INIT_WORK(&imp->imp_zombie_work, obd_zombie_imp_cull); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 45e8f03dec80..776f251e9f43 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -334,7 +334,7 @@ static int class_attach(struct lustre_cfg *lcfg) rc = class_register_device(obd); if (rc) { - class_decref(obd, "newdev", obd); + class_decref(obd); return rc; } @@ -399,7 +399,7 @@ static int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_lock(&obd->obd_dev_lock); /* cleanup drops this */ - class_incref(obd, "setup", obd); + class_incref(obd); spin_unlock(&obd->obd_dev_lock); CDEBUG(D_IOCTL, "finished setup of obd %s (uuid %s)\n", @@ -439,7 +439,7 @@ static int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) CDEBUG(D_IOCTL, "detach on obd %s (uuid %s)\n", obd->obd_name, obd->obd_uuid.uuid); - class_decref(obd, "newdev", obd); + class_decref(obd); return 0; } @@ -511,14 +511,13 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) /* destroy an uuid-export hash body */ rhashtable_free_and_destroy(&obd->obd_uuid_hash, uuid_export_exit, NULL); - class_decref(obd, "setup", obd); + class_decref(obd); obd->obd_set_up = 0; return 0; } -struct obd_device *class_incref(struct obd_device *obd, - const char *scope, const void *source) +struct obd_device *class_incref(struct obd_device *obd) { atomic_inc(&obd->obd_refcount); CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd, @@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd, } EXPORT_SYMBOL(class_incref); -void class_decref(struct obd_device *obd, const char *scope, const void *source) +void class_decref(struct obd_device *obd) { int last; - CDEBUG(D_INFO, "Decref %s (%p) now %d - %s\n", obd->obd_name, obd, - atomic_read(&obd->obd_refcount), scope); + CDEBUG(D_INFO, "Decref %s (%p) now %d\n", obd->obd_name, obd, + atomic_read(&obd->obd_refcount)); LASSERT(obd->obd_num_exports >= 0); last = atomic_dec_and_test(&obd->obd_refcount); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c index e9e0bcf39d4e..57a6f2c2da1c 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c @@ -188,12 +188,12 @@ health_check_show(struct kobject *kobj, struct attribute *attr, char *buf) if (obd->obd_stopping) continue; - class_incref(obd, __func__, current); + class_incref(obd); read_unlock(&obd_dev_lock); if (obd_health_check(NULL, obd)) healthy = false; - class_decref(obd, __func__, current); + class_decref(obd); read_lock(&obd_dev_lock); } read_unlock(&obd_dev_lock); From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494646.24125.10155576042684274174.stgit@noble.brown> lustre_handles assigned a 64bit unique identifier (a 'cookie') to objects of various types and stored them in a hash table, allowing them to be accessed by the cookie. The is a facility for type checking by recording an 'owner' for each object, and checking the owner on lookup. Unfortunately this is not used - owner is always zero. Eahc object also contains an h_ops pointer which can be used to reliably identify an owner. So discard h_owner, pass and 'ops' pointer to class_handle2object(), and only return objects for which the h_ops matches. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_handles.h | 7 +++---- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 3 ++- .../lustre/lustre/obdclass/lustre_handles.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 683680891e4c..9a4b1a821e7b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -65,8 +65,7 @@ struct portals_handle_ops { struct portals_handle { struct list_head h_link; u64 h_cookie; - const void *h_owner; - struct portals_handle_ops *h_ops; + const struct portals_handle_ops *h_ops; /* newly added fields to handle the RCU issue. -jxiong */ struct rcu_head h_rcu; @@ -79,9 +78,9 @@ struct portals_handle { /* Add a handle to the hash table */ void class_handle_hash(struct portals_handle *, - struct portals_handle_ops *ops); + const struct portals_handle_ops *ops); void class_handle_unhash(struct portals_handle *); -void *class_handle2object(u64 cookie, const void *owner); +void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops); void class_handle_free_cb(struct rcu_head *rcu); int class_handle_init(void); void class_handle_cleanup(void); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 60a6ec2f7136..248331153c68 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -503,7 +503,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, LASSERT(handle); - lock = class_handle2object(handle->cookie, NULL); + lock = class_handle2object(handle->cookie, &lock_handle_ops); if (!lock) return NULL; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index fc7985a2922c..b5fce96e43f7 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -674,6 +674,7 @@ int obd_init_caches(void) return -ENOMEM; } +static struct portals_handle_ops export_handle_ops; /* map connection to client */ struct obd_export *class_conn2export(struct lustre_handle *conn) { @@ -690,7 +691,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn) } CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie); - export = class_handle2object(conn->cookie, NULL); + export = class_handle2object(conn->cookie, &export_handle_ops); return export; } EXPORT_SYMBOL(class_conn2export); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 0674afb0059f..32b70d613f71 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -59,7 +59,7 @@ static struct handle_bucket { * global (per-node) hash-table. */ void class_handle_hash(struct portals_handle *h, - struct portals_handle_ops *ops) + const struct portals_handle_ops *ops) { struct handle_bucket *bucket; @@ -132,7 +132,7 @@ void class_handle_unhash(struct portals_handle *h) } EXPORT_SYMBOL(class_handle_unhash); -void *class_handle2object(u64 cookie, const void *owner) +void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) { struct handle_bucket *bucket; struct portals_handle *h; @@ -147,7 +147,7 @@ void *class_handle2object(u64 cookie, const void *owner) rcu_read_lock(); list_for_each_entry_rcu(h, &bucket->head, h_link) { - if (h->h_cookie != cookie || h->h_owner != owner) + if (h->h_cookie != cookie || h->h_ops != ops) continue; spin_lock(&h->h_lock); From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494654.24125.18407080080202016099.stgit@noble.brown> Every object with a lustre_handle has (and must have) a refcount. The lustre_handles code needs a call-out to increment this. To simplify things, move the refcount into the lustre_handle and discard the call-out. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lustre_dlm.h | 6 --- .../staging/lustre/lustre/include/lustre_export.h | 1 .../staging/lustre/lustre/include/lustre_handles.h | 2 - .../staging/lustre/lustre/include/lustre_import.h | 2 - drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 35 ++++++---------- drivers/staging/lustre/lustre/obdclass/genops.c | 44 +++++++------------- .../lustre/lustre/obdclass/lustre_handles.c | 2 - .../staging/lustre/lustre/obdecho/echo_client.c | 2 - drivers/staging/lustre/lustre/ptlrpc/service.c | 4 +- 9 files changed, 35 insertions(+), 63 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 6c0371ef056c..19c0f74b7c04 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -589,12 +589,6 @@ struct ldlm_lock { * Must be first in the structure. */ struct portals_handle l_handle; - /** - * Lock reference count. - * This is how many users have pointers to actual structure, so that - * we do not accidentally free lock structure that is in use. - */ - atomic_t l_refc; /** * Internal spinlock protects l_resource. We should hold this lock * first before taking res_lock. diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index fb34e0b7de35..d05323313f55 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -67,7 +67,6 @@ struct obd_export { * what export they are talking to. */ struct portals_handle exp_handle; - refcount_t exp_refcount; /** * Set of counters below is to track where export references are * kept. The exp_rpc_count is used for reconnect handling also, diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 9a4b1a821e7b..7e868aecff0e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -46,7 +46,6 @@ #include struct portals_handle_ops { - void (*hop_addref)(void *object); void (*hop_free)(void *object, int size); }; @@ -66,6 +65,7 @@ struct portals_handle { struct list_head h_link; u64 h_cookie; const struct portals_handle_ops *h_ops; + refcount_t h_ref; /* newly added fields to handle the RCU issue. -jxiong */ struct rcu_head h_rcu; diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 31b3881fb6c9..ab7e1d94f4b2 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -154,8 +154,6 @@ struct import_state_hist { struct obd_import { /** Local handle (== id) for this import. */ struct portals_handle imp_handle; - /** Reference counter */ - atomic_t imp_refcount; struct lustre_handle imp_dlm_handle; /* client's ldlm export */ /** Currently active connection */ struct ptlrpc_connection *imp_connection; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 248331153c68..7864f9a7ef90 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -148,7 +148,7 @@ EXPORT_SYMBOL(ldlm_it2str); */ struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock) { - atomic_inc(&lock->l_refc); + refcount_inc(&lock->l_handle.h_ref); return lock; } EXPORT_SYMBOL(ldlm_lock_get); @@ -161,8 +161,8 @@ EXPORT_SYMBOL(ldlm_lock_get); void ldlm_lock_put(struct ldlm_lock *lock) { LASSERT(lock->l_resource != LP_POISON); - LASSERT(atomic_read(&lock->l_refc) > 0); - if (atomic_dec_and_test(&lock->l_refc)) { + LASSERT(refcount_read(&lock->l_handle.h_ref) > 0); + if (refcount_dec_and_test(&lock->l_handle.h_ref)) { struct ldlm_resource *res; LDLM_DEBUG(lock, @@ -349,12 +349,6 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) LDLM_LOCK_RELEASE(lock); } -/* this is called by portals_handle2object with the handle lock taken */ -static void lock_handle_addref(void *lock) -{ - LDLM_LOCK_GET((struct ldlm_lock *)lock); -} - static void lock_handle_free(void *lock, int size) { LASSERT(size == sizeof(struct ldlm_lock)); @@ -362,7 +356,6 @@ static void lock_handle_free(void *lock, int size) } static struct portals_handle_ops lock_handle_ops = { - .hop_addref = lock_handle_addref, .hop_free = lock_handle_free, }; @@ -387,7 +380,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) spin_lock_init(&lock->l_lock); lock->l_resource = resource; - atomic_set(&lock->l_refc, 2); + refcount_set(&lock->l_handle.h_ref, 2); INIT_LIST_HEAD(&lock->l_res_link); INIT_LIST_HEAD(&lock->l_lru); INIT_LIST_HEAD(&lock->l_pending_chain); @@ -1974,13 +1967,13 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, &vaf, lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), + refcount_read(&lock->l_handle.h_ref), lock->l_readers, lock->l_writers, ldlm_lockname[lock->l_granted_mode], ldlm_lockname[lock->l_req_mode], lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_handle.h_ref) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); va_end(args); @@ -1994,7 +1987,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, &vaf, ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), + refcount_read(&lock->l_handle.h_ref), lock->l_readers, lock->l_writers, ldlm_lockname[lock->l_granted_mode], ldlm_lockname[lock->l_req_mode], @@ -2007,7 +2000,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, lock->l_req_extent.end, lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_handle.h_ref) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); break; @@ -2018,7 +2011,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, &vaf, ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), + refcount_read(&lock->l_handle.h_ref), lock->l_readers, lock->l_writers, ldlm_lockname[lock->l_granted_mode], ldlm_lockname[lock->l_req_mode], @@ -2030,7 +2023,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, lock->l_policy_data.l_flock.end, lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_handle.h_ref) : -99, lock->l_pid, lock->l_callback_timeout); break; @@ -2040,7 +2033,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, &vaf, ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), + refcount_read(&lock->l_handle.h_ref), lock->l_readers, lock->l_writers, ldlm_lockname[lock->l_granted_mode], ldlm_lockname[lock->l_req_mode], @@ -2050,7 +2043,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, ldlm_typename[resource->lr_type], lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_handle.h_ref) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); break; @@ -2061,7 +2054,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, &vaf, ldlm_lock_to_ns_name(lock), lock, lock->l_handle.h_cookie, - atomic_read(&lock->l_refc), + refcount_read(&lock->l_handle.h_ref), lock->l_readers, lock->l_writers, ldlm_lockname[lock->l_granted_mode], ldlm_lockname[lock->l_req_mode], @@ -2070,7 +2063,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, ldlm_typename[resource->lr_type], lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? refcount_read(&exp->exp_refcount) : -99, + exp ? refcount_read(&exp->exp_handle.h_ref) : -99, lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); break; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index b5fce96e43f7..4b1e14957a66 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -719,7 +719,7 @@ static void class_export_destroy(struct obd_export *exp) { struct obd_device *obd = exp->exp_obd; - LASSERT(refcount_read(&exp->exp_refcount) == 0); + LASSERT(refcount_read(&exp->exp_handle.h_ref) == 0); LASSERT(obd); CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp, @@ -743,33 +743,27 @@ static void class_export_destroy(struct obd_export *exp) OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); } -static void export_handle_addref(void *export) -{ - class_export_get(export); -} - static struct portals_handle_ops export_handle_ops = { - .hop_addref = export_handle_addref, .hop_free = NULL, }; struct obd_export *class_export_get(struct obd_export *exp) { - refcount_inc(&exp->exp_refcount); + refcount_inc(&exp->exp_handle.h_ref); CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp, - refcount_read(&exp->exp_refcount)); + refcount_read(&exp->exp_handle.h_ref)); return exp; } EXPORT_SYMBOL(class_export_get); void class_export_put(struct obd_export *exp) { - LASSERT(refcount_read(&exp->exp_refcount) > 0); - LASSERT(refcount_read(&exp->exp_refcount) < LI_POISON); + LASSERT(refcount_read(&exp->exp_handle.h_ref) > 0); + LASSERT(refcount_read(&exp->exp_handle.h_ref) < LI_POISON); CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp, - refcount_read(&exp->exp_refcount) - 1); + refcount_read(&exp->exp_handle.h_ref) - 1); - if (refcount_dec_and_test(&exp->exp_refcount)) { + if (refcount_dec_and_test(&exp->exp_handle.h_ref)) { struct obd_device *obd = exp->exp_obd; CDEBUG(D_IOCTL, "final put %p/%s\n", @@ -819,7 +813,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd, export->exp_conn_cnt = 0; /* 2 = class_handle_hash + last */ - refcount_set(&export->exp_refcount, 2); + refcount_set(&export->exp_handle.h_ref, 2); atomic_set(&export->exp_rpc_count, 0); atomic_set(&export->exp_cb_count, 0); atomic_set(&export->exp_locks_count, 0); @@ -922,7 +916,7 @@ static void class_import_destroy(struct obd_import *imp) CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp, imp->imp_obd->obd_name); - LASSERT_ATOMIC_ZERO(&imp->imp_refcount); + LASSERT(refcount_read(&imp->imp_handle.h_ref) == 0); ptlrpc_put_connection_superhack(imp->imp_connection); @@ -939,21 +933,15 @@ static void class_import_destroy(struct obd_import *imp) OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle); } -static void import_handle_addref(void *import) -{ - class_import_get(import); -} - static struct portals_handle_ops import_handle_ops = { - .hop_addref = import_handle_addref, .hop_free = NULL, }; struct obd_import *class_import_get(struct obd_import *import) { - atomic_inc(&import->imp_refcount); + refcount_inc(&import->imp_handle.h_ref); CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", import, - atomic_read(&import->imp_refcount), + refcount_read(&import->imp_handle.h_ref), import->imp_obd->obd_name); return import; } @@ -961,19 +949,19 @@ EXPORT_SYMBOL(class_import_get); void class_import_put(struct obd_import *imp) { - LASSERT_ATOMIC_GT_LT(&imp->imp_refcount, 0, LI_POISON); + LASSERT(refcount_read(&imp->imp_handle.h_ref) > 0); CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp, - atomic_read(&imp->imp_refcount) - 1, + refcount_read(&imp->imp_handle.h_ref) - 1, imp->imp_obd->obd_name); - if (atomic_dec_and_test(&imp->imp_refcount)) { + if (refcount_dec_and_test(&imp->imp_handle.h_ref)) { CDEBUG(D_INFO, "final put import %p\n", imp); obd_zombie_import_add(imp); } /* catch possible import put race */ - LASSERT_ATOMIC_GE_LT(&imp->imp_refcount, 0, LI_POISON); + LASSERT(refcount_read(&imp->imp_handle.h_ref) >= 0); } EXPORT_SYMBOL(class_import_put); @@ -1023,7 +1011,7 @@ struct obd_import *class_new_import(struct obd_device *obd) init_waitqueue_head(&imp->imp_recovery_waitq); INIT_WORK(&imp->imp_zombie_work, obd_zombie_imp_cull); - atomic_set(&imp->imp_refcount, 2); + refcount_set(&imp->imp_handle.h_ref, 2); atomic_set(&imp->imp_unregistering, 0); atomic_set(&imp->imp_inflight, 0); atomic_set(&imp->imp_replay_inflight, 0); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 32b70d613f71..5c722d336c21 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) spin_lock(&h->h_lock); if (likely(h->h_in != 0)) { - h->h_ops->hop_addref(h); + refcount_inc(&h->h_ref); retval = h; } spin_unlock(&h->h_lock); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index baf34c85c4b5..6f00eee6170a 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -1638,7 +1638,7 @@ static int echo_client_cleanup(struct obd_device *obddev) return -EBUSY; } - LASSERT(refcount_read(&ec->ec_exp->exp_refcount) > 0); + LASSERT(refcount_read(&ec->ec_exp->exp_handle.h_ref) > 0); rc = obd_disconnect(ec->ec_exp); if (rc != 0) CERROR("fail to disconnect device: %d\n", rc); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index eda921cce8f5..88a81ab2feb8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1697,7 +1697,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? - refcount_read(&request->rq_export->exp_refcount) : -99), + refcount_read(&request->rq_export->exp_handle.h_ref) : -99), lustre_msg_get_status(request->rq_reqmsg), request->rq_xid, libcfs_id2str(request->rq_peer), lustre_msg_get_opc(request->rq_reqmsg)); @@ -1741,7 +1741,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? - refcount_read(&request->rq_export->exp_refcount) : -99), + refcount_read(&request->rq_export->exp_handle.h_ref) : -99), lustre_msg_get_status(request->rq_reqmsg), request->rq_xid, libcfs_id2str(request->rq_peer), From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 31/37] lustre: discard OBD_FREE_RCU In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494660.24125.14350673827307393026.stgit@noble.brown> OBD_FREE_RCU and the hop_free call-back together form an overly complex mechanism equivalent to kfree_rcu() or call_rcu(...). Discard them and use the simpler approach. This removes the only use for the field h_size, so discard that too. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_handles.h | 3 --- .../staging/lustre/lustre/include/obd_support.h | 10 ---------- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 16 ++++++++-------- drivers/staging/lustre/lustre/obdclass/genops.c | 6 ++---- .../lustre/lustre/obdclass/lustre_handles.c | 15 --------------- 5 files changed, 10 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 7e868aecff0e..7079982ffd31 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -46,7 +46,6 @@ #include struct portals_handle_ops { - void (*hop_free)(void *object, int size); }; /* These handles are most easily used by having them appear at the very top of @@ -70,7 +69,6 @@ struct portals_handle { /* newly added fields to handle the RCU issue. -jxiong */ struct rcu_head h_rcu; spinlock_t h_lock; - unsigned int h_size:31; unsigned int h_in:1; }; @@ -81,7 +79,6 @@ void class_handle_hash(struct portals_handle *, const struct portals_handle_ops *ops); void class_handle_unhash(struct portals_handle *); void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops); -void class_handle_free_cb(struct rcu_head *rcu); int class_handle_init(void); void class_handle_cleanup(void); diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 3e15cac04ac5..91d6a862fa92 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -503,16 +503,6 @@ extern char obd_jobid_var[]; #define POISON_PAGE(page, val) do { } while (0) #endif -#define OBD_FREE_RCU(ptr, size, handle) \ -do { \ - struct portals_handle *__h = (handle); \ - \ - __h->h_cookie = (unsigned long)(ptr); \ - __h->h_size = (size); \ - call_rcu(&__h->h_rcu, class_handle_free_cb); \ - POISON_PTR(ptr); \ -} while (0) - #define KEY_IS(str) \ (keylen >= (sizeof(str) - 1) && \ memcmp(key, str, (sizeof(str) - 1)) == 0) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 7864f9a7ef90..010285b226e6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -153,6 +153,13 @@ struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock) } EXPORT_SYMBOL(ldlm_lock_get); +static void lock_handle_free(struct rcu_head *rcu) +{ + struct ldlm_lock *lock = container_of(rcu, struct ldlm_lock, + l_handle.h_rcu); + kmem_cache_free(ldlm_lock_slab, lock); +} + /** * Release lock reference. * @@ -184,7 +191,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) kfree(lock->l_lvb_data); - OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle); + call_rcu(&lock->l_handle.h_rcu, lock_handle_free); } } EXPORT_SYMBOL(ldlm_lock_put); @@ -349,14 +356,7 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) LDLM_LOCK_RELEASE(lock); } -static void lock_handle_free(void *lock, int size) -{ - LASSERT(size == sizeof(struct ldlm_lock)); - kmem_cache_free(ldlm_lock_slab, lock); -} - static struct portals_handle_ops lock_handle_ops = { - .hop_free = lock_handle_free, }; /** diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 4b1e14957a66..156541ead12e 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -740,11 +740,10 @@ static void class_export_destroy(struct obd_export *exp) if (exp != obd->obd_self_export) class_decref(obd); - OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); + kfree_rcu(exp, exp_handle.h_rcu); } static struct portals_handle_ops export_handle_ops = { - .hop_free = NULL, }; struct obd_export *class_export_get(struct obd_export *exp) @@ -930,11 +929,10 @@ static void class_import_destroy(struct obd_import *imp) LASSERT(!imp->imp_sec); class_decref(imp->imp_obd); - OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle); + kfree_rcu(imp, imp_handle.h_rcu); } static struct portals_handle_ops import_handle_ops = { - .hop_free = NULL, }; struct obd_import *class_import_get(struct obd_import *import) diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 5c722d336c21..f4599ec5b0f0 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -164,21 +164,6 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) } EXPORT_SYMBOL(class_handle2object); -void class_handle_free_cb(struct rcu_head *rcu) -{ - struct portals_handle *h; - void *ptr; - - h = container_of(rcu, struct portals_handle, h_rcu); - ptr = (void *)(unsigned long)h->h_cookie; - - if (h->h_ops->hop_free) - h->h_ops->hop_free(ptr, h->h_size); - else - kfree(ptr); -} -EXPORT_SYMBOL(class_handle_free_cb); - int class_handle_init(void) { struct handle_bucket *bucket; From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 32/37] lustre: portals_handle: rename ops to owner In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494664.24125.9533896496992345951.stgit@noble.brown> Now the portals_handle_ops is empty, it is functioning only to identify the owner of each handle. So change the name to h_owner, and the type to void* Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_handles.h | 10 +++------- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 7 +++---- drivers/staging/lustre/lustre/obdclass/genops.c | 15 ++++++--------- .../lustre/lustre/obdclass/lustre_handles.c | 13 ++++++------- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 7079982ffd31..9d0f0b61b51a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -45,9 +45,6 @@ #include #include -struct portals_handle_ops { -}; - /* These handles are most easily used by having them appear at the very top of * whatever object that you want to make handles for. ie: * @@ -63,7 +60,7 @@ struct portals_handle_ops { struct portals_handle { struct list_head h_link; u64 h_cookie; - const struct portals_handle_ops *h_ops; + void *h_owner; refcount_t h_ref; /* newly added fields to handle the RCU issue. -jxiong */ @@ -75,10 +72,9 @@ struct portals_handle { /* handles.c */ /* Add a handle to the hash table */ -void class_handle_hash(struct portals_handle *, - const struct portals_handle_ops *ops); +void class_handle_hash(struct portals_handle *, void *owner); void class_handle_unhash(struct portals_handle *); -void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops); +void *class_handle2object(u64 cookie, void *owner); int class_handle_init(void); void class_handle_cleanup(void); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 010285b226e6..b22aa640b723 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -356,8 +356,7 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) LDLM_LOCK_RELEASE(lock); } -static struct portals_handle_ops lock_handle_ops = { -}; +static int lock_handle_owner; /** * @@ -396,7 +395,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats, LDLM_NSS_LOCKS); INIT_LIST_HEAD(&lock->l_handle.h_link); - class_handle_hash(&lock->l_handle, &lock_handle_ops); + class_handle_hash(&lock->l_handle, &lock_handle_owner); lock->l_callback_timeout = 0; @@ -496,7 +495,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, LASSERT(handle); - lock = class_handle2object(handle->cookie, &lock_handle_ops); + lock = class_handle2object(handle->cookie, &lock_handle_owner); if (!lock) return NULL; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 156541ead12e..8ddee93b2a9d 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -674,7 +674,8 @@ int obd_init_caches(void) return -ENOMEM; } -static struct portals_handle_ops export_handle_ops; +static int export_handle_owner; + /* map connection to client */ struct obd_export *class_conn2export(struct lustre_handle *conn) { @@ -691,7 +692,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn) } CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie); - export = class_handle2object(conn->cookie, &export_handle_ops); + export = class_handle2object(conn->cookie, &export_handle_owner); return export; } EXPORT_SYMBOL(class_conn2export); @@ -743,9 +744,6 @@ static void class_export_destroy(struct obd_export *exp) kfree_rcu(exp, exp_handle.h_rcu); } -static struct portals_handle_ops export_handle_ops = { -}; - struct obd_export *class_export_get(struct obd_export *exp) { refcount_inc(&exp->exp_handle.h_ref); @@ -828,7 +826,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd, INIT_LIST_HEAD(&export->exp_req_replay_queue); INIT_LIST_HEAD(&export->exp_handle.h_link); INIT_LIST_HEAD(&export->exp_hp_rpcs); - class_handle_hash(&export->exp_handle, &export_handle_ops); + class_handle_hash(&export->exp_handle, &export_handle_owner); spin_lock_init(&export->exp_lock); spin_lock_init(&export->exp_rpc_lock); spin_lock_init(&export->exp_bl_list_lock); @@ -932,8 +930,7 @@ static void class_import_destroy(struct obd_import *imp) kfree_rcu(imp, imp_handle.h_rcu); } -static struct portals_handle_ops import_handle_ops = { -}; +static int import_handle_owner; struct obd_import *class_import_get(struct obd_import *import) { @@ -1016,7 +1013,7 @@ struct obd_import *class_new_import(struct obd_device *obd) atomic_set(&imp->imp_inval_count, 0); INIT_LIST_HEAD(&imp->imp_conn_list); INIT_LIST_HEAD(&imp->imp_handle.h_link); - class_handle_hash(&imp->imp_handle, &import_handle_ops); + class_handle_hash(&imp->imp_handle, &import_handle_owner); init_imp_at(&imp->imp_at); /* the default magic is V2, will be used in connect RPC, and diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index f4599ec5b0f0..30a84ff1e479 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -58,8 +58,7 @@ static struct handle_bucket { * Generate a unique 64bit cookie (hash) for a handle and insert it into * global (per-node) hash-table. */ -void class_handle_hash(struct portals_handle *h, - const struct portals_handle_ops *ops) +void class_handle_hash(struct portals_handle *h, void *owner) { struct handle_bucket *bucket; @@ -85,7 +84,7 @@ void class_handle_hash(struct portals_handle *h, h->h_cookie = handle_base; spin_unlock(&handle_base_lock); - h->h_ops = ops; + h->h_owner = owner; spin_lock_init(&h->h_lock); bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK]; @@ -132,7 +131,7 @@ void class_handle_unhash(struct portals_handle *h) } EXPORT_SYMBOL(class_handle_unhash); -void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) +void *class_handle2object(u64 cookie, void *owner) { struct handle_bucket *bucket; struct portals_handle *h; @@ -147,7 +146,7 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops) rcu_read_lock(); list_for_each_entry_rcu(h, &bucket->head, h_link) { - if (h->h_cookie != cookie || h->h_ops != ops) + if (h->h_cookie != cookie || h->h_owner != owner) continue; spin_lock(&h->h_lock); @@ -198,8 +197,8 @@ static int cleanup_all_handles(void) spin_lock(&handle_hash[i].lock); list_for_each_entry_rcu(h, &handle_hash[i].head, h_link) { - CERROR("force clean handle %#llx addr %p ops %p\n", - h->h_cookie, h, h->h_ops); + CERROR("force clean handle %#llx addr %p owner %p\n", + h->h_cookie, h, h->h_owner); class_handle_unhash_nolock(h); rc++; From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 33/37] lustre: portals_handle: remove locking from class_handle2object() In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494669.24125.10413095649039339042.stgit@noble.brown> There can be no value in this locking and test on h_in. If the lookup could have run in parallel with class_handle_unhash_nolock() and seen "h_in == 0", then it could equally well have run moments earlier and not seen it - no locking would prevent that, so the caller much be prepared to have an object returned which has already been unhashed by the time it sees the object. In other words, an interlock between unhash and lookup much be provided at a higher level than where this code is trying to handle it. So remove this pointless code. Signed-off-by: NeilBrown --- .../lustre/lustre/obdclass/lustre_handles.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 30a84ff1e479..40461c7fc8ef 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -149,12 +149,8 @@ void *class_handle2object(u64 cookie, void *owner) if (h->h_cookie != cookie || h->h_owner != owner) continue; - spin_lock(&h->h_lock); - if (likely(h->h_in != 0)) { - refcount_inc(&h->h_ref); - retval = h; - } - spin_unlock(&h->h_lock); + refcount_inc(&h->h_ref); + retval = h; break; } rcu_read_unlock(); From neilb at suse.com Tue Feb 19 00:09:06 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:06 +1100 Subject: [lustre-devel] [PATCH 34/37] lustre: portals_handle: use hlist for hash lists. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494673.24125.12345558625014859299.stgit@noble.brown> hlist_head/hlist_node is the preferred data structure for hash tables. Not only does it make the 'head' smaller, but is also provides hlist_unhashed() which can be used to check if an object is in the list. This means that we don't need h_in any more. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_handles.h | 3 +-- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 4 ++-- .../lustre/lustre/obdclass/lustre_handles.c | 20 +++++++++----------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 9d0f0b61b51a..17aee8ea63ac 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -58,7 +58,7 @@ * to compute the start of the structure based on the handle field. */ struct portals_handle { - struct list_head h_link; + struct hlist_node h_link; u64 h_cookie; void *h_owner; refcount_t h_ref; @@ -66,7 +66,6 @@ struct portals_handle { /* newly added fields to handle the RCU issue. -jxiong */ struct rcu_head h_rcu; spinlock_t h_lock; - unsigned int h_in:1; }; /* handles.c */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index b22aa640b723..03b2f582c47f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -394,7 +394,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats, LDLM_NSS_LOCKS); - INIT_LIST_HEAD(&lock->l_handle.h_link); + INIT_HLIST_NODE(&lock->l_handle.h_link); class_handle_hash(&lock->l_handle, &lock_handle_owner); lock->l_callback_timeout = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 8ddee93b2a9d..3324f3a82446 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -824,7 +824,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd, spin_lock_init(&export->exp_uncommitted_replies_lock); INIT_LIST_HEAD(&export->exp_uncommitted_replies); INIT_LIST_HEAD(&export->exp_req_replay_queue); - INIT_LIST_HEAD(&export->exp_handle.h_link); + INIT_HLIST_NODE(&export->exp_handle.h_link); INIT_LIST_HEAD(&export->exp_hp_rpcs); class_handle_hash(&export->exp_handle, &export_handle_owner); spin_lock_init(&export->exp_lock); @@ -1012,7 +1012,7 @@ struct obd_import *class_new_import(struct obd_device *obd) atomic_set(&imp->imp_replay_inflight, 0); atomic_set(&imp->imp_inval_count, 0); INIT_LIST_HEAD(&imp->imp_conn_list); - INIT_LIST_HEAD(&imp->imp_handle.h_link); + INIT_HLIST_NODE(&imp->imp_handle.h_link); class_handle_hash(&imp->imp_handle, &import_handle_owner); init_imp_at(&imp->imp_at); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 40461c7fc8ef..78c1ca52fc77 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -48,7 +48,7 @@ static spinlock_t handle_base_lock; static struct handle_bucket { spinlock_t lock; - struct list_head head; + struct hlist_head head; } *handle_hash; #define HANDLE_HASH_SIZE (1 << 16) @@ -63,7 +63,7 @@ void class_handle_hash(struct portals_handle *h, void *owner) struct handle_bucket *bucket; LASSERT(h); - LASSERT(list_empty(&h->h_link)); + LASSERT(hlist_unhashed(&h->h_link)); /* * This is fast, but simplistic cookie generation algorithm, it will @@ -89,8 +89,7 @@ void class_handle_hash(struct portals_handle *h, void *owner) bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK]; spin_lock(&bucket->lock); - list_add_rcu(&h->h_link, &bucket->head); - h->h_in = 1; + hlist_add_head_rcu(&h->h_link, &bucket->head); spin_unlock(&bucket->lock); CDEBUG(D_INFO, "added object %p with handle %#llx to hash\n", @@ -100,7 +99,7 @@ EXPORT_SYMBOL(class_handle_hash); static void class_handle_unhash_nolock(struct portals_handle *h) { - if (list_empty(&h->h_link)) { + if (hlist_unhashed(&h->h_link)) { CERROR("removing an already-removed handle (%#llx)\n", h->h_cookie); return; @@ -110,13 +109,12 @@ static void class_handle_unhash_nolock(struct portals_handle *h) h, h->h_cookie); spin_lock(&h->h_lock); - if (h->h_in == 0) { + if (hlist_unhashed(&h->h_link)) { spin_unlock(&h->h_lock); return; } - h->h_in = 0; + hlist_del_init_rcu(&h->h_link); spin_unlock(&h->h_lock); - list_del_rcu(&h->h_link); } void class_handle_unhash(struct portals_handle *h) @@ -145,7 +143,7 @@ void *class_handle2object(u64 cookie, void *owner) bucket = handle_hash + (cookie & HANDLE_HASH_MASK); rcu_read_lock(); - list_for_each_entry_rcu(h, &bucket->head, h_link) { + hlist_for_each_entry_rcu(h, &bucket->head, h_link) { if (h->h_cookie != cookie || h->h_owner != owner) continue; @@ -173,7 +171,7 @@ int class_handle_init(void) spin_lock_init(&handle_base_lock); for (bucket = handle_hash + HANDLE_HASH_SIZE - 1; bucket >= handle_hash; bucket--) { - INIT_LIST_HEAD(&bucket->head); + INIT_HLIST_HEAD(&bucket->head); spin_lock_init(&bucket->lock); } @@ -192,7 +190,7 @@ static int cleanup_all_handles(void) struct portals_handle *h; spin_lock(&handle_hash[i].lock); - list_for_each_entry_rcu(h, &handle_hash[i].head, h_link) { + hlist_for_each_entry_rcu(h, &handle_hash[i].head, h_link) { CERROR("force clean handle %#llx addr %p owner %p\n", h->h_cookie, h, h->h_owner); From neilb at suse.com Tue Feb 19 00:09:07 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:07 +1100 Subject: [lustre-devel] [PATCH 35/37] lustre: portals_handle: discard h_lock. In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494690.24125.10261783071575748633.stgit@noble.brown> The h_lock spinlock is now only taken while bucket->lock is held. As a handle is associated with precisely one bucket, this means that h_lock can never be contended, so it isn't needed. So discard h_lock. Also discard and increasingly irrelevant comment in the declaration of struct portals_handle. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_handles.h | 3 --- .../lustre/lustre/obdclass/lustre_handles.c | 7 ------- 2 files changed, 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 17aee8ea63ac..d07b0a498bff 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -62,10 +62,7 @@ struct portals_handle { u64 h_cookie; void *h_owner; refcount_t h_ref; - - /* newly added fields to handle the RCU issue. -jxiong */ struct rcu_head h_rcu; - spinlock_t h_lock; }; /* handles.c */ diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 78c1ca52fc77..88a65a19785c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -85,7 +85,6 @@ void class_handle_hash(struct portals_handle *h, void *owner) spin_unlock(&handle_base_lock); h->h_owner = owner; - spin_lock_init(&h->h_lock); bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK]; spin_lock(&bucket->lock); @@ -108,13 +107,7 @@ static void class_handle_unhash_nolock(struct portals_handle *h) CDEBUG(D_INFO, "removing object %p with handle %#llx from hash\n", h, h->h_cookie); - spin_lock(&h->h_lock); - if (hlist_unhashed(&h->h_link)) { - spin_unlock(&h->h_lock); - return; - } hlist_del_init_rcu(&h->h_link); - spin_unlock(&h->h_lock); } void class_handle_unhash(struct portals_handle *h) From neilb at suse.com Tue Feb 19 00:09:07 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:07 +1100 Subject: [lustre-devel] [PATCH 36/37] lustre: remove unused fields from struct obd_device In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494709.24125.7232156100089136403.stgit@noble.brown> One field is set but never access. Another is accessed but never set. Other are never mentioned at all. Also remove the comment /* use separate field as it is set in interrupt to don't mess with * protection of other bits using _bh lock */ This is not correct - were it used, obd_recovery_expired would be part of the same 'unsigned long' as the other fields. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/obd.h | 33 +++++++------------- drivers/staging/lustre/lustre/mgc/mgc_request.c | 4 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 1 - .../staging/lustre/lustre/obdclass/obd_config.c | 1 - 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index f7f4db0481b2..c2716e7c1c58 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -538,27 +538,18 @@ struct obd_device { char obd_name[MAX_OBD_NAME]; /* bitfield modification is protected by obd_dev_lock */ - unsigned long obd_attached:1, /* finished attach */ - obd_set_up:1, /* finished setup */ - obd_version_recov:1, /* obd uses version checking */ - obd_replayable:1,/* recovery is enabled; inform clients */ - obd_no_transno:1, /* no committed-transno notification */ - obd_no_recov:1, /* fail instead of retry messages */ - obd_stopping:1, /* started cleanup */ - obd_starting:1, /* started setup */ - obd_force:1, /* cleanup with > 0 obd refcount */ - obd_fail:1, /* cleanup with failover */ - obd_no_conn:1, /* deny new connections */ - obd_inactive:1, /* device active/inactive - * (for sysfs status only!!) - */ - obd_no_ir:1, /* no imperative recovery. */ - obd_process_conf:1, /* device is processing mgs config */ - obd_checksum_dump:1; /* dump pages upon cksum error */ - /* use separate field as it is set in interrupt to don't mess with - * protection of other bits using _bh lock - */ - unsigned long obd_recovery_expired:1; + unsigned long obd_attached:1, /* finished attach */ + obd_set_up:1, /* finished setup */ + obd_no_recov:1, /* fail instead of retry messages */ + obd_stopping:1, /* started cleanup */ + obd_starting:1, /* started setup */ + obd_force:1, /* cleanup with > 0 obd refcount */ + obd_fail:1, /* cleanup with failover */ + obd_inactive:1, /* device active/inactive + * (for sysfs status only!!) + */ + obd_process_conf:1;/* device is processing mgs config */ + /* uuid-export hash body */ struct rhashtable obd_uuid_hash; wait_queue_head_t obd_refcount_waitq; diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index ec872e8ae9be..a91724013773 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -991,10 +991,10 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, if (vallen != sizeof(int)) return -EINVAL; value = *(int *)val; - CDEBUG(D_MGC, "InitRecov %s %d/d%d:i%d:r%d:or%d:%s\n", + CDEBUG(D_MGC, "InitRecov %s %d/d%d:i%d:r%d:%s\n", imp->imp_obd->obd_name, value, imp->imp_deactive, imp->imp_invalid, - imp->imp_replayable, imp->imp_obd->obd_replayable, + imp->imp_replayable, ptlrpc_import_state_name(imp->imp_state)); /* Resurrect if we previously died */ if ((imp->imp_state != LUSTRE_IMP_FULL && diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index b8fc74044fe3..1fcbda128a58 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -525,7 +525,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } CDEBUG(D_HA, "%s: disabling committed-transno notification\n", obd->obd_name); - obd->obd_no_transno = 1; err = 0; break; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 776f251e9f43..79071b0d38ef 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -487,7 +487,6 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) LCONSOLE_WARN("Failing over %s\n", obd->obd_name); obd->obd_fail = 1; - obd->obd_no_transno = 1; obd->obd_no_recov = 1; if (OBP(obd, iocontrol)) { obd_iocontrol(OBD_IOC_SYNC, From neilb at suse.com Tue Feb 19 00:09:07 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 19 Feb 2019 11:09:07 +1100 Subject: [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var In-Reply-To: <155053473693.24125.6976971762921761309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> Message-ID: <155053494716.24125.12637812266850199400.stgit@noble.brown> The jobid_var sysfs attribute only has 3 meaningful values. Other values cause lustre_get_jobid() to return an error which is uniformly ignored. To improve usability and resilience, check that the value written is acceptable before storing it. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/obdclass/obd_sysfs.c | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c index 57a6f2c2da1c..69ccc6a55947 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c @@ -216,16 +216,25 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) { + static char *valid[] = { + JOBSTATS_DISABLE, + JOBSTATS_PROCNAME_UID, + JOBSTATS_NODELOCAL, + NULL + }; + int i; + if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) return -EINVAL; - memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); - - memcpy(obd_jobid_var, buffer, count); + for (i = 0; valid[i]; i++) + if (sysfs_streq(buffer, valid[i])) + break; + if (!valid[i]) + return -EINVAL; - /* Trim the trailing '\n' if any */ - if (obd_jobid_var[count - 1] == '\n') - obd_jobid_var[count - 1] = 0; + memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); + strcpy(obd_jobid_var, valid[i]); return count; } From jsimmons at infradead.org Wed Feb 20 17:59:38 2019 From: jsimmons at infradead.org (James Simmons) Date: Wed, 20 Feb 2019 17:59:38 +0000 (GMT) Subject: [lustre-devel] Lustre interval tree problems Message-ID: With the port of the interval tree work to the OpenSFS branch several problems have been pointed out in the implementation which impacts performance and the memory footprint in some cases. The biggest issues is the ability to add duplicate locks. The reason the original implementation avoided adding duplicate locks was to avoid the extra compares being done with the same type of locks. Especially in the case of the range lock where you can end up with many duplicate read locks [0-EOF]. Comparing with 1000s of identical read locks will have an impact. Their is teh question of the memory foot print in this case as well. I believe this is the case with the ldlm locks as well since the ability to skip large lock amounts if not matching has been lost. The next problem Vitaly pointed in the implementation is the emebedding of lit_root in ldlm_interval_tree also has a negative impact. Since many locaks are kept in memory he wants to see that ldlm_lock struct stay as small as possible. Explained that is why ldlm_interval was not original embedded but allocated separately. I added him to this chain. From neilb at suse.com Wed Feb 20 22:37:58 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 21 Feb 2019 09:37:58 +1100 Subject: [lustre-devel] Lustre interval tree problems In-Reply-To: References: Message-ID: <87h8cycchl.fsf@notabene.neil.brown.name> On Wed, Feb 20 2019, James Simmons wrote: > With the port of the interval tree work to the OpenSFS branch several > problems have been pointed out in the implementation which impacts > performance and the memory footprint in some cases. > > The biggest issues is the ability to add duplicate locks. The reason > the original implementation avoided adding duplicate locks was to > avoid the extra compares being done with the same type of locks. > Especially in the case of the range lock where you can end up with > many duplicate read locks [0-EOF]. Comparing with 1000s of identical > read locks will have an impact. Their is teh question of the memory > foot print in this case as well. I believe this is the case with the > ldlm locks as well since the ability to skip large lock amounts if > not matching has been lost. > > The next problem Vitaly pointed in the implementation is the emebedding > of lit_root in ldlm_interval_tree also has a negative impact. Since many > locaks are kept in memory he wants to see that ldlm_lock struct stay as > small as possible. Explained that is why ldlm_interval was not original > embedded but allocated separately. I added him to this chain. Thanks for this valuable feedback! I'll look over the code again with these issues in mind, and let you know what I find. NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From pfarrell at whamcloud.com Wed Feb 20 22:54:09 2019 From: pfarrell at whamcloud.com (Patrick Farrell) Date: Wed, 20 Feb 2019 22:54:09 +0000 Subject: [lustre-devel] Lustre interval tree problems In-Reply-To: <87h8cycchl.fsf@notabene.neil.brown.name> References: , <87h8cycchl.fsf@notabene.neil.brown.name> Message-ID: Also, many LDLM locks do not have an interval. The node which has the most of them is generally an MDS, which can have millions in certain scenarios, and makes no use of the interval at all. This is a lot of lost memory if we're really adding part of the interval_tree in to the lock struct (I haven't looked at the patch). ________________________________ From: lustre-devel on behalf of NeilBrown Sent: Wednesday, February 20, 2019 4:37:58 PM To: James Simmons; Lustre Developement Cc: Vitaly Fertman Subject: Re: [lustre-devel] Lustre interval tree problems On Wed, Feb 20 2019, James Simmons wrote: > With the port of the interval tree work to the OpenSFS branch several > problems have been pointed out in the implementation which impacts > performance and the memory footprint in some cases. > > The biggest issues is the ability to add duplicate locks. The reason > the original implementation avoided adding duplicate locks was to > avoid the extra compares being done with the same type of locks. > Especially in the case of the range lock where you can end up with > many duplicate read locks [0-EOF]. Comparing with 1000s of identical > read locks will have an impact. Their is teh question of the memory > foot print in this case as well. I believe this is the case with the > ldlm locks as well since the ability to skip large lock amounts if > not matching has been lost. > > The next problem Vitaly pointed in the implementation is the emebedding > of lit_root in ldlm_interval_tree also has a negative impact. Since many > locaks are kept in memory he wants to see that ldlm_lock struct stay as > small as possible. Explained that is why ldlm_interval was not original > embedded but allocated separately. I added him to this chain. Thanks for this valuable feedback! I'll look over the code again with these issues in mind, and let you know what I find. NeilBrown -------------- next part -------------- An HTML attachment was scrubbed... URL: From neilb at suse.com Thu Feb 21 00:33:14 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 21 Feb 2019 11:33:14 +1100 Subject: [lustre-devel] Lustre interval tree problems In-Reply-To: References: <87h8cycchl.fsf@notabene.neil.brown.name> Message-ID: <87bm36c75h.fsf@notabene.neil.brown.name> Hmmm... The patch which converted ldlm_lock to use a Linux interval-tree rather than a lustre interval tree contained: @@ -619,9 +618,11 @@ struct ldlm_lock { */ struct list_head l_res_link; /** - * Tree node for ldlm_extent. + * Interval-tree node for ldlm_extent. */ - struct interval_node l_tree_node; + struct rb_node l_rb; + __u64 __subtree_last; + /** * Requested mode. * Protected by lr_lock. So a 'struct interval_node' was replaced with a 'struct rb_node' and a '__u64'. A 'struct interval_node' was -struct interval_node { - struct interval_node *in_left; - struct interval_node *in_right; - struct interval_node *in_parent; - unsigned in_color:1, - in_intree:1, /** set if the node is in tree */ - in_res1:30; - __u8 in_res2[4]; /** tags, 8-bytes aligned */ - __u64 in_max_high; - struct interval_node_extent { - __u64 start; - __u64 end; - } in_extent; -}; which, is 7 64-bit words (on a 64-bit host). The 'struct rb_node' is struct rb_node { unsigned long __rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; } __attribute__((aligned(sizeof(long)))); which is 3 64-bit words. Add the __u64, and we have 4. So I replaced 7 64-bit words with 4 64-bit words. I have since also made 'struct portals_handle' (also embedded in 'ldlm_lock') smaller. So I genuinely don't see any evidence in the code that anyone cares about how big a 'ldlm_lock' is. But I'm fairly sure I can keep making it smaller, if you think that would help. (Patrick: I do appreciate that you didn't accuse the patch of making the structure bigger, you were just highlighting the problems that would be caused if that were true - thanks). Thanks, NeilBrown On Wed, Feb 20 2019, Patrick Farrell wrote: > Also, many LDLM locks do not have an interval. The node which has the most of them is generally an MDS, which can have millions in certain scenarios, and makes no use of the interval at all. This is a lot of lost memory if we're really adding part of the interval_tree in to the lock struct (I haven't looked at the patch). > > ________________________________ > From: lustre-devel on behalf of NeilBrown > Sent: Wednesday, February 20, 2019 4:37:58 PM > To: James Simmons; Lustre Developement > Cc: Vitaly Fertman > Subject: Re: [lustre-devel] Lustre interval tree problems > > On Wed, Feb 20 2019, James Simmons wrote: > >> With the port of the interval tree work to the OpenSFS branch several >> problems have been pointed out in the implementation which impacts >> performance and the memory footprint in some cases. >> >> The biggest issues is the ability to add duplicate locks. The reason >> the original implementation avoided adding duplicate locks was to >> avoid the extra compares being done with the same type of locks. >> Especially in the case of the range lock where you can end up with >> many duplicate read locks [0-EOF]. Comparing with 1000s of identical >> read locks will have an impact. Their is teh question of the memory >> foot print in this case as well. I believe this is the case with the >> ldlm locks as well since the ability to skip large lock amounts if >> not matching has been lost. >> >> The next problem Vitaly pointed in the implementation is the emebedding >> of lit_root in ldlm_interval_tree also has a negative impact. Since many >> locaks are kept in memory he wants to see that ldlm_lock struct stay as >> small as possible. Explained that is why ldlm_interval was not original >> embedded but allocated separately. I added him to this chain. > > Thanks for this valuable feedback! I'll look over the code again with > these issues in mind, and let you know what I find. > > NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Thu Feb 21 01:00:30 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 21 Feb 2019 12:00:30 +1100 Subject: [lustre-devel] Lustre interval tree problems In-Reply-To: References: Message-ID: <874l8yc5w1.fsf@notabene.neil.brown.name> On Wed, Feb 20 2019, James Simmons wrote: > With the port of the interval tree work to the OpenSFS branch several > problems have been pointed out in the implementation which impacts > performance and the memory footprint in some cases. > > The biggest issues is the ability to add duplicate locks. The reason > the original implementation avoided adding duplicate locks was to > avoid the extra compares being done with the same type of locks. > Especially in the case of the range lock where you can end up with > many duplicate read locks [0-EOF]. Comparing with 1000s of identical > read locks will have an impact. Their is teh question of the memory > foot print in this case as well. I believe this is the case with the > ldlm locks as well since the ability to skip large lock amounts if > not matching has been lost. > > The next problem Vitaly pointed in the implementation is the emebedding > of lit_root in ldlm_interval_tree also has a negative impact. Since many > locaks are kept in memory he wants to see that ldlm_lock struct stay as > small as possible. Explained that is why ldlm_interval was not original > embedded but allocated separately. I added him to this chain. I've replied separately about the size of struct ldlm_lock, but this last point is either talking about something different, or is badly confused. In either case, I think some clarity might help. lit_root in struct ldlm_interval_tree was indeed changed from a pointer to an embedded 'struct rb_root_cached'. rb_root_cached contains 2 pointers, so this replaces one pointer with two, a growth of one pointer. The ldlm_interval_tree also contains int lit_size; enum ldlm_mode lit_mode; /* lock mode */ which would be equivalent to 1 more (64 bit) pointer. ldlm_interval_tree only exists when allocated when allocated in ldlm_resource_new() and assigned to res->lr_itree (still a pointer) which is only done for resources of type LDLM_EXTENT. Such a resource will also need an interval tree, and now it gets one which uses 3 longs instead of 2. If this space usage is a problem (it isn't a problem for 'struct ldlm_lock'), then I'm fairly sure we can find other places to save space, to make up for it I'll go look into the issue with duplicate ranges now. NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Thu Feb 21 01:21:13 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 21 Feb 2019 12:21:13 +1100 Subject: [lustre-devel] Lustre interval tree problems In-Reply-To: <87bm36c75h.fsf@notabene.neil.brown.name> References: <87h8cycchl.fsf@notabene.neil.brown.name> <87bm36c75h.fsf@notabene.neil.brown.name> Message-ID: <871s42c4xi.fsf@notabene.neil.brown.name> On Thu, Feb 21 2019, NeilBrown wrote: > Hmmm... > > The patch which converted ldlm_lock to use a Linux interval-tree rather > than a lustre interval tree contained: > > @@ -619,9 +618,11 @@ struct ldlm_lock { > */ > struct list_head l_res_link; > /** > - * Tree node for ldlm_extent. > + * Interval-tree node for ldlm_extent. > */ > - struct interval_node l_tree_node; > + struct rb_node l_rb; > + __u64 __subtree_last; > + > /** > * Requested mode. > * Protected by lr_lock. > > So a 'struct interval_node' was replaced with a 'struct rb_node' and a > '__u64'. > > A 'struct interval_node' was > > -struct interval_node { > - struct interval_node *in_left; > - struct interval_node *in_right; > - struct interval_node *in_parent; > - unsigned in_color:1, > - in_intree:1, /** set if the node is in tree */ > - in_res1:30; > - __u8 in_res2[4]; /** tags, 8-bytes aligned */ > - __u64 in_max_high; > - struct interval_node_extent { > - __u64 start; > - __u64 end; > - } in_extent; > -}; > > which, is 7 64-bit words (on a 64-bit host). > The 'struct rb_node' is > struct rb_node { > unsigned long __rb_parent_color; > struct rb_node *rb_right; > struct rb_node *rb_left; > } __attribute__((aligned(sizeof(long)))); > > which is 3 64-bit words. Add the __u64, and we have 4. > > So I replaced 7 64-bit words with 4 64-bit words. I've just noticed that I made a mistake here. I was only looking at one patch. A previous patch had: - struct ldlm_interval *l_tree_node; + struct interval_node l_tree_node; so the interval_ode was not originally embedded, there was just a pointer to an ldlm_interval. So 'ldlm_lock' has had 3 64-bit words added to it. That probably is worth fixing. Shouldn't be too hard (though I've since removed at least 4 __u64s for portals_handle, so I'm still ahead of the game :-) NeilBrown > I have since also made 'struct portals_handle' (also embedded in > 'ldlm_lock') smaller. > So I genuinely don't see any evidence in the code that anyone cares > about how big a 'ldlm_lock' is. > But I'm fairly sure I can keep making it smaller, if you think that > would help. > > (Patrick: I do appreciate that you didn't accuse the patch of making the > structure bigger, you were just highlighting the problems that would be > caused if that were true - thanks). > > Thanks, > NeilBrown > > > On Wed, Feb 20 2019, Patrick Farrell wrote: > >> Also, many LDLM locks do not have an interval. The node which has the most of them is generally an MDS, which can have millions in certain scenarios, and makes no use of the interval at all. This is a lot of lost memory if we're really adding part of the interval_tree in to the lock struct (I haven't looked at the patch). >> >> ________________________________ >> From: lustre-devel on behalf of NeilBrown >> Sent: Wednesday, February 20, 2019 4:37:58 PM >> To: James Simmons; Lustre Developement >> Cc: Vitaly Fertman >> Subject: Re: [lustre-devel] Lustre interval tree problems >> >> On Wed, Feb 20 2019, James Simmons wrote: >> >>> With the port of the interval tree work to the OpenSFS branch several >>> problems have been pointed out in the implementation which impacts >>> performance and the memory footprint in some cases. >>> >>> The biggest issues is the ability to add duplicate locks. The reason >>> the original implementation avoided adding duplicate locks was to >>> avoid the extra compares being done with the same type of locks. >>> Especially in the case of the range lock where you can end up with >>> many duplicate read locks [0-EOF]. Comparing with 1000s of identical >>> read locks will have an impact. Their is teh question of the memory >>> foot print in this case as well. I believe this is the case with the >>> ldlm locks as well since the ability to skip large lock amounts if >>> not matching has been lost. >>> >>> The next problem Vitaly pointed in the implementation is the emebedding >>> of lit_root in ldlm_interval_tree also has a negative impact. Since many >>> locaks are kept in memory he wants to see that ldlm_lock struct stay as >>> small as possible. Explained that is why ldlm_interval was not original >>> embedded but allocated separately. I added him to this chain. >> >> Thanks for this valuable feedback! I'll look over the code again with >> these issues in mind, and let you know what I find. >> >> NeilBrown > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Thu Feb 21 02:25:42 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 21 Feb 2019 13:25:42 +1100 Subject: [lustre-devel] Lustre interval tree problems In-Reply-To: References: Message-ID: <87y369c1y1.fsf@notabene.neil.brown.name> On Wed, Feb 20 2019, James Simmons wrote: > With the port of the interval tree work to the OpenSFS branch several > problems have been pointed out in the implementation which impacts > performance and the memory footprint in some cases. Porting to OpenSFS will have to address one issue that I could skip over. hsm_update_work() in mtd_hsm_cdt_requests.c deliberately doesn't want duplicates - it is the only place in all of lustre which really doesn't want duplicates, and it is server side so I don't have to address it. I wold probably change the code to do a lookup first, then insert only if the lookup failed. > > The biggest issues is the ability to add duplicate locks. The reason > the original implementation avoided adding duplicate locks was to > avoid the extra compares being done with the same type of locks. > Especially in the case of the range lock where you can end up with > many duplicate read locks [0-EOF]. Comparing with 1000s of identical > read locks will have an impact. Their is teh question of the memory > foot print in this case as well. I believe this is the case with the > ldlm locks as well since the ability to skip large lock amounts if > not matching has been lost. The interval tree stores entries in an rb-tree, which is a nearly-balanced binary tree. This provides O(ln n) lookup. If there are 1000s of identical read locks, then a lookup will have 10s of extra compares. Even with 1,000,000 locks, that would be at most 40 compares. The code simplification could well make up for some of these extra compares by reducing i-cache pressure, though that would be hard to measure. Is there any empirical evidence of a slow-down? Does 10s of compares really seem like a big cost? I cannot see the memory foot print issue that you mention. All locks are added to the data structure even if they aren't in the interval tree directly. There is a linked-list of locks that all have the same start/end, so keeping duplicates doesn't mean that more memory is used, it just means that it is linked together differently. So it isn't yet clear to me what the problem is here. I'd be have to have it explained to me in more detail. Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Sun Feb 24 16:35:23 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 16:35:23 +0000 (GMT) Subject: [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() In-Reply-To: <155053494490.24125.1514109985903155907.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494490.24125.1514109985903155907.stgit@noble.brown> Message-ID: y > llite_kobj does not benefit from being in the > lustre_kset kset (though it does need lustre_kset > as a parent) Nak. Yes llite does benefit from being in the kset. On large clusters you can end up with 1000s of clients so keeping the sysfs files setting in sync needs to be done in mass. The way Lustre does this is by running on the MGS server 'lctl conf_param $FSNAME.llite.lazystats=1' or with the newer 'lctl set_param -P llite.$FSNAME-*.lazystats=1' as an example. When this is done on the MGS that new value is first persistently stored and then transmitted to the target nodes. The magic behind this is with class_process_config(). In the code path LCFG_PARAM, which handles the conf_param case' the main function is class_modify_config() which is used by both llite and the obd devices. This function first attempts to find the sysfs attribute from the kobject and call lustre_attr_store() directly to set it. If it can't find the attribute, which means its a debugfs file most likely, then a uevent is created and sent off. The udev rule then exexcutes some application to handle the debugfs settings. For uevents to work the kobject (llite) must belong to a kset. With LCFG_SET_PARAM, which handles the 'set_param -P' case the master function is process_param2_config(). For this case we always send attribute changes with uevents. Besides the requirement of the kobject belonging to the kset this function uses kset_find_object() directly which if llite is not in the kset will never be found. > It also does not need the class_ktype type, as dynamic_kobj_ktype > is sufficient. > > So use the simple kobject_create_and_add() to initialize it. > > This provides flexibility for making changes to > class_setup_tunables(). > > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c > index 8215296dc15d..78ec0fa65c58 100644 > --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c > +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c > @@ -46,7 +46,7 @@ int llite_tunables_register(void) > { > int rc = 0; > > - llite_kobj = class_setup_tunables("llite"); > + llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj); > if (IS_ERR(llite_kobj)) > return PTR_ERR(llite_kobj); > llite_kobj->kset = kset_get(&lustre_kset); > In llite_tunables_unregister() the call for kobject_put() should really be replaced with kobject_del(). This is a bug in my original work. From jsimmons at infradead.org Sun Feb 24 16:52:55 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 16:52:55 +0000 (GMT) Subject: [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type In-Reply-To: <155053494490.24125.1514109985903155907.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494490.24125.1514109985903155907.stgit@noble.brown> Message-ID: For some reason this patch didn't land in my mailbox but I can see it on https://patchwork.kernel.org/patch/10819037. This patch is mostly good since llite now uses dynamic_kobj_ktype with its own ktype. Thus class_sysfs_release() will never be called with llite. What does need fixing is -------------------------------------------------------- type->typ_kobj.kset = lustre_kset; changed to: type->typ_kobj.kset = kset_get(&lustre_kset); -------------------------------------------------------- Next change needed it change all the kobject_put(&type->typ_kobj); -> kobject_del(&type->typ_kobj); So we properly handle the kset referencing. That is currently broken by me :-( From jsimmons at infradead.org Sun Feb 24 16:54:49 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 16:54:49 +0000 (GMT) Subject: [lustre-devel] [PATCH 04/37] lustre: collect all resource releasing for obj_type. In-Reply-To: <155053494500.24125.3045348327157278994.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494500.24125.3045348327157278994.stgit@noble.brown> Message-ID: > Now that obj_type is managed as a kobject, move all > the freeing and deregistering into class_sysfs_release(). This is a really nice change. I would have never considered that. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/genops.c | 27 +++++++++++------------ > 1 file changed, 13 insertions(+), 14 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index 2bd72f8a38eb..4c0dc2098823 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -138,6 +138,18 @@ static void class_sysfs_release(struct kobject *kobj) > { > struct obd_type *type = container_of(kobj, struct obd_type, typ_kobj); > > + debugfs_remove_recursive(type->typ_debugfs_entry); > + > + if (type->typ_lu) > + lu_device_type_fini(type->typ_lu); > + > + spin_lock(&obd_types_lock); > + list_del(&type->typ_chain); > + spin_unlock(&obd_types_lock); > + > + kfree(type->typ_name); > + kfree(type->typ_md_ops); > + kfree(type->typ_dt_ops); > kfree(type); > } > > @@ -170,6 +182,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > > type->typ_kobj.kset = lustre_kset; > kobject_init(&type->typ_kobj, &class_ktype); > + INIT_LIST_HEAD(&type->typ_chain); > > type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); > type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); > @@ -209,9 +222,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > return 0; > > failed: > - kfree(type->typ_name); > - kfree(type->typ_md_ops); > - kfree(type->typ_dt_ops); > kobject_put(&type->typ_kobj); > > return rc; > @@ -236,17 +246,6 @@ int class_unregister_type(const char *name) > return -EBUSY; > } > > - debugfs_remove_recursive(type->typ_debugfs_entry); > - > - if (type->typ_lu) > - lu_device_type_fini(type->typ_lu); > - > - spin_lock(&obd_types_lock); > - list_del(&type->typ_chain); > - spin_unlock(&obd_types_lock); > - kfree(type->typ_name); > - kfree(type->typ_dt_ops); > - kfree(type->typ_md_ops); > kobject_put(&type->typ_kobj); > > return 0; > > > From jsimmons at infradead.org Sun Feb 24 16:56:13 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 16:56:13 +0000 (GMT) Subject: [lustre-devel] [PATCH 05/37] lustre: obd_type: use typ_kobj.name as typ_name In-Reply-To: <155053494507.24125.1847979512182217144.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494507.24125.1847979512182217144.stgit@noble.brown> Message-ID: > As the kobject has a name (after kobject_add has been called), > we don't need to also store it in typ_name. > So use typ_kobj.name instead of typ_name. > > This requires changing some "char *" to "const char *" as > typ.kobj.name is const. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/lustre_net.h | 4 ++- > drivers/staging/lustre/lustre/include/obd.h | 2 +- > drivers/staging/lustre/lustre/include/obd_class.h | 2 +- > drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 +- > drivers/staging/lustre/lustre/obdclass/genops.c | 25 ++++++++------------ > drivers/staging/lustre/lustre/ptlrpc/client.c | 2 +- > 6 files changed, 16 insertions(+), 21 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h > index 47b9632e5660..f3b6ba061eed 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_net.h > +++ b/drivers/staging/lustre/lustre/include/lustre_net.h > @@ -308,7 +308,7 @@ struct ptlrpc_client { > /** What portal do we expect replies on */ > u32 cli_reply_portal; > /** Name of the client */ > - char *cli_name; > + const char *cli_name; > }; > > /** state flags of requests */ > @@ -1817,7 +1817,7 @@ void ptlrpc_request_committed(struct ptlrpc_request *req, int force); > int ptlrpc_inc_ref(void); > void ptlrpc_dec_ref(void); > > -void ptlrpc_init_client(int req_portal, int rep_portal, char *name, > +void ptlrpc_init_client(int req_portal, int rep_portal, const char *name, > struct ptlrpc_client *); > struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid, > lnet_nid_t nid4refnet); > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index b161542855fc..3aa9cc889949 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -103,12 +103,12 @@ struct obd_type { > struct obd_ops *typ_dt_ops; > struct md_ops *typ_md_ops; > struct dentry *typ_debugfs_entry; > - char *typ_name; > int typ_refcnt; > struct lu_device_type *typ_lu; > spinlock_t obd_type_lock; > struct kobject typ_kobj; > }; > +#define typ_name typ_kobj.name > > struct brw_page { > u64 off; > diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h > index e4695f5b748d..a61c7950393c 100644 > --- a/drivers/staging/lustre/lustre/include/obd_class.h > +++ b/drivers/staging/lustre/lustre/include/obd_class.h > @@ -74,7 +74,7 @@ int class_name2dev(const char *name); > struct obd_device *class_name2obd(const char *name); > int class_uuid2dev(struct obd_uuid *uuid); > struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, > - const char *typ_name, > + const char *type_name, > struct obd_uuid *grp_uuid); > struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, > int *next); > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c > index aef83ffc8bb3..ac0fbb24fc92 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c > @@ -247,7 +247,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) > struct obd_import *imp; > struct obd_uuid server_uuid; > int rq_portal, rp_portal, connect_op; > - char *name = obddev->obd_type->typ_name; > + const char *name = obddev->obd_type->typ_name; > enum ldlm_ns_type ns_type = LDLM_NS_TYPE_UNKNOWN; > struct ptlrpc_connection fake_conn = { > .c_self = 0, > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index 4c0dc2098823..32581f1a92ac 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -147,7 +147,6 @@ static void class_sysfs_release(struct kobject *kobj) > list_del(&type->typ_chain); > spin_unlock(&obd_types_lock); > > - kfree(type->typ_name); > kfree(type->typ_md_ops); > kfree(type->typ_dt_ops); > kfree(type); > @@ -186,28 +185,24 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > > type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); > type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); > - type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS); > > if (!type->typ_dt_ops || > - !type->typ_md_ops || > - !type->typ_name) > + !type->typ_md_ops) > goto failed; > > *type->typ_dt_ops = *dt_ops; > /* md_ops is optional */ > if (md_ops) > *type->typ_md_ops = *md_ops; > - strcpy(type->typ_name, name); > spin_lock_init(&type->obd_type_lock); > > - type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, > - debugfs_lustre_root); > - > rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name); > - > if (rc) > goto failed; > > + type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, > + debugfs_lustre_root); > + > if (ldt) { > type->typ_lu = ldt; > rc = lu_device_type_init(ldt); > @@ -534,7 +529,7 @@ struct obd_device *class_num2obd(int num) > * otherwise any client connected to the tgt is returned. > */ > struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, > - const char *typ_name, > + const char *type_name, > struct obd_uuid *grp_uuid) > { > int i; > @@ -545,8 +540,8 @@ struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, > > if (!obd) > continue; > - if ((strncmp(obd->obd_type->typ_name, typ_name, > - strlen(typ_name)) == 0)) { > + if ((strncmp(obd->obd_type->typ_name, type_name, > + strlen(type_name)) == 0)) { > if (obd_uuid_equals(tgt_uuid, > &obd->u.cli.cl_target_uuid) && > ((grp_uuid) ? obd_uuid_equals(grp_uuid, > @@ -1358,7 +1353,7 @@ EXPORT_SYMBOL(obd_get_max_rpcs_in_flight); > int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max) > { > struct obd_request_slot_waiter *orsw; > - const char *typ_name; > + const char *type_name; > u32 old; > int diff; > int rc; > @@ -1367,8 +1362,8 @@ int obd_set_max_rpcs_in_flight(struct client_obd *cli, u32 max) > if (max > OBD_MAX_RIF_MAX || max < 1) > return -ERANGE; > > - typ_name = cli->cl_import->imp_obd->obd_type->typ_name; > - if (!strcmp(typ_name, LUSTRE_MDC_NAME)) { > + type_name = cli->cl_import->imp_obd->obd_type->typ_name; > + if (!strcmp(type_name, LUSTRE_MDC_NAME)) { > /* > * adjust max_mod_rpcs_in_flight to ensure it is always > * strictly lower that max_rpcs_in_flight > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c > index b2b11047ea19..0a76a8549fac 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/client.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c > @@ -67,7 +67,7 @@ static int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async); > /** > * Initialize passed in client structure \a cl. > */ > -void ptlrpc_init_client(int req_portal, int rep_portal, char *name, > +void ptlrpc_init_client(int req_portal, int rep_portal, const char *name, > struct ptlrpc_client *cl) > { > cl->cli_request_portal = req_portal; > > > From jsimmons at infradead.org Sun Feb 24 17:00:58 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:00:58 +0000 (GMT) Subject: [lustre-devel] [PATCH 06/37] lustre: obd_type: discard obd_types linked list. In-Reply-To: <155053494516.24125.10480743535229018309.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494516.24125.10480743535229018309.stgit@noble.brown> Message-ID: > As all obd_types are kobjects in the lustre_kset kset, > they are linked together in that kset and don't > need any extra linkage. > > As kset_find_obj() returns a counted reference, we need > to put that reference when done. > > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/obd.h | 1 - > drivers/staging/lustre/lustre/obdclass/genops.c | 41 +++++++++++------------ > 2 files changed, 19 insertions(+), 23 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index 3aa9cc889949..50f33f400075 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -99,7 +99,6 @@ struct obd_info { > }; > > struct obd_type { > - struct list_head typ_chain; > struct obd_ops *typ_dt_ops; > struct md_ops *typ_md_ops; > struct dentry *typ_debugfs_entry; > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index 32581f1a92ac..775e4fa4f6a8 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -42,8 +42,6 @@ > #include > #include > > -static DEFINE_SPINLOCK(obd_types_lock); > -static LIST_HEAD(obd_types); > DEFINE_RWLOCK(obd_dev_lock); > static struct obd_device *obd_devs[MAX_OBD_DEVICES]; > > @@ -88,22 +86,19 @@ static void obd_device_free(struct obd_device *obd) > > static struct obd_type *class_search_type(const char *name) > { > - struct obd_type *type; > + struct kobject *kobj = kset_find_obj(lustre_kset, name); > + > + if (kobj) > + return container_of(kobj, struct obd_type, typ_kobj); > > - spin_lock(&obd_types_lock); > - list_for_each_entry(type, &obd_types, typ_chain) { > - if (strcmp(type->typ_name, name) == 0) { > - spin_unlock(&obd_types_lock); > - return type; > - } > - } > - spin_unlock(&obd_types_lock); > return NULL; > } > > static struct obd_type *class_get_type(const char *name) > { > - struct obd_type *type = class_search_type(name); > + struct obd_type *type; > + > + type = class_search_type(name); > > if (!type) { > const char *modname = name; > @@ -121,6 +116,11 @@ static struct obd_type *class_get_type(const char *name) > type->typ_refcnt++; > try_module_get(type->typ_dt_ops->owner); > spin_unlock(&type->obd_type_lock); > + /* class_search_type() returned a counted reference, > + * but we don't need that count any more as > + * we have one through typ_refcnt. > + */ > + kobject_put(&type->typ_kobj); > } > return type; > } > @@ -143,10 +143,6 @@ static void class_sysfs_release(struct kobject *kobj) > if (type->typ_lu) > lu_device_type_fini(type->typ_lu); > > - spin_lock(&obd_types_lock); > - list_del(&type->typ_chain); > - spin_unlock(&obd_types_lock); > - > kfree(type->typ_md_ops); > kfree(type->typ_dt_ops); > kfree(type); > @@ -169,8 +165,10 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > /* sanity check */ > LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME); > > - if (class_search_type(name)) { > + type = class_search_type(name); > + if (type) { > CDEBUG(D_IOCTL, "Type %s already registered\n", name); > + kobject_put(&type->typ_kobj); > return -EEXIST; > } > > @@ -181,7 +179,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > > type->typ_kobj.kset = lustre_kset; > kobject_init(&type->typ_kobj, &class_ktype); > - INIT_LIST_HEAD(&type->typ_chain); > > type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); > type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); > @@ -210,10 +207,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > goto failed; > } > > - spin_lock(&obd_types_lock); > - list_add(&type->typ_chain, &obd_types); > - spin_unlock(&obd_types_lock); > - > return 0; > > failed: > @@ -238,9 +231,13 @@ int class_unregister_type(const char *name) > /* Remove ops, but leave the name for debugging */ > kfree(type->typ_dt_ops); > kfree(type->typ_md_ops); > + kobject_put(&type->typ_kobj); > return -EBUSY; > } > > + /* Put the ref returned by class_search_type() */ > + kobject_put(&type->typ_kobj); > + /* Put the final ref */ > kobject_put(&type->typ_kobj); This last part needs to be kobject_del(&type->typ_kobj); but that will be handled in the early patch. > return 0; > > > From jsimmons at infradead.org Sun Feb 24 17:02:04 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:02:04 +0000 (GMT) Subject: [lustre-devel] [PATCH 07/37] lustre: obd_type: discard obd_type_lock In-Reply-To: <155053494523.24125.14949515989661790146.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494523.24125.14949515989661790146.stgit@noble.brown> Message-ID: > This lock is only used to protect typ_refcnt, so change > that to a refcount_t and discard the lock. > > The lock also covers calls to try_module_get and module_put, > but this serves no purpose as it does not prevent the module > from being unloaded. > > Finally, the return value for the call to try_module_get is > ignored, which is not safe. Looks good. I do need to test this work tho. > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/obd.h | 3 +- > drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 + > drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 + > drivers/staging/lustre/lustre/obdclass/genops.c | 30 +++++++++----------- > drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 + > 5 files changed, 18 insertions(+), 21 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index 50f33f400075..a67eb9a14879 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -102,9 +102,8 @@ struct obd_type { > struct obd_ops *typ_dt_ops; > struct md_ops *typ_md_ops; > struct dentry *typ_debugfs_entry; > - int typ_refcnt; > + refcount_t typ_refcnt; > struct lu_device_type *typ_lu; > - spinlock_t obd_type_lock; > struct kobject typ_kobj; > }; > #define typ_name typ_kobj.name > diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c > index 3eb89ec80b7e..db2c045aa1cd 100644 > --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c > +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c > @@ -2540,7 +2540,7 @@ static int mdc_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize) > static int mdc_precleanup(struct obd_device *obd) > { > /* Failsafe, ok if racy */ > - if (obd->obd_type->typ_refcnt <= 1) > + if (refcount_read(&obd->obd_type->typ_refcnt) <= 1) > libcfs_kkuc_group_rem(0, KUC_GRP_HSM); > > mdc_changelog_cdev_finish(obd); > diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c > index a4dfdc08cc48..a6ee715921b8 100644 > --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c > +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c > @@ -715,7 +715,7 @@ static int mgc_cleanup(struct obd_device *obd) > /* COMPAT_146 - old config logs may have added profiles we don't > * know about > */ > - if (obd->obd_type->typ_refcnt <= 1) > + if (refcount_read(&obd->obd_type->typ_refcnt) <= 1) > /* Only for the last mgc */ > class_del_profiles(); > > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index 775e4fa4f6a8..a3437c2d07bb 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -112,15 +112,17 @@ static struct obd_type *class_get_type(const char *name) > } > } > if (type) { > - spin_lock(&type->obd_type_lock); > - type->typ_refcnt++; > - try_module_get(type->typ_dt_ops->owner); > - spin_unlock(&type->obd_type_lock); > - /* class_search_type() returned a counted reference, > - * but we don't need that count any more as > - * we have one through typ_refcnt. > - */ > - kobject_put(&type->typ_kobj); > + if (try_module_get(type->typ_dt_ops->owner)) { > + refcount_inc(&type->typ_refcnt); > + /* class_search_type() returned a counted reference, > + * but we don't need that count any more as > + * we have one through typ_refcnt. > + */ > + kobject_put(&type->typ_kobj); > + } else { > + kobject_put(&type->typ_kobj); > + type = NULL; > + } > } > return type; > } > @@ -128,10 +130,7 @@ static struct obd_type *class_get_type(const char *name) > void class_put_type(struct obd_type *type) > { > LASSERT(type); > - spin_lock(&type->obd_type_lock); > - type->typ_refcnt--; > - module_put(type->typ_dt_ops->owner); > - spin_unlock(&type->obd_type_lock); > + refcount_dec(&type->typ_refcnt); > } > > static void class_sysfs_release(struct kobject *kobj) > @@ -191,7 +190,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > /* md_ops is optional */ > if (md_ops) > *type->typ_md_ops = *md_ops; > - spin_lock_init(&type->obd_type_lock); > > rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name); > if (rc) > @@ -225,8 +223,8 @@ int class_unregister_type(const char *name) > return -EINVAL; > } > > - if (type->typ_refcnt) { > - CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt); > + if (refcount_read(&type->typ_refcnt)) { > + CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt)); > /* This is a bad situation, let's make the best of it */ > /* Remove ops, but leave the name for debugging */ > kfree(type->typ_dt_ops); > diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c > index 639c298b6a90..69a56cca99f2 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c > @@ -1267,7 +1267,7 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) > next = ldt->ldt_ops->ldto_device_free(env, scan); > type = ldt->ldt_obd_type; > if (type) { > - type->typ_refcnt--; > + refcount_dec(&type->typ_refcnt); > class_put_type(type); > } > } > > > From jsimmons at infradead.org Sun Feb 24 17:03:18 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:03:18 +0000 (GMT) Subject: [lustre-devel] [PATCH 08/37] lustre: obdclass: don't copy ops structures in to new type. In-Reply-To: <155053494530.24125.8326533343171305248.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494530.24125.8326533343171305248.stgit@noble.brown> Message-ID: > The obd_ops and md_ops structures passed to class_register_type() are > read-only, and have a lifetime that is exceeds the lifetime of the > obd_type - they are static in a module which unregisters the type before > being unloaded. > > So there is no need to copy the ops, just store a pointer. > > Also mark all the structures as read-only to confirm they don't get > written. This is best-practice for structures of function pointers. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/obd.h | 4 ++-- > drivers/staging/lustre/lustre/include/obd_class.h | 3 ++- > drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 ++-- > drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- > drivers/staging/lustre/lustre/mdc/mdc_request.c | 4 ++-- > drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- > drivers/staging/lustre/lustre/obdclass/genops.c | 22 +++++--------------- > .../staging/lustre/lustre/obdecho/echo_client.c | 2 +- > drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- > 9 files changed, 18 insertions(+), 27 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index a67eb9a14879..9cffda3741ce 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -99,8 +99,8 @@ struct obd_info { > }; > > struct obd_type { > - struct obd_ops *typ_dt_ops; > - struct md_ops *typ_md_ops; > + const struct obd_ops *typ_dt_ops; > + const struct md_ops *typ_md_ops; > struct dentry *typ_debugfs_entry; > refcount_t typ_refcnt; > struct lu_device_type *typ_lu; > diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h > index a61c7950393c..7c2e248a8110 100644 > --- a/drivers/staging/lustre/lustre/include/obd_class.h > +++ b/drivers/staging/lustre/lustre/include/obd_class.h > @@ -60,7 +60,8 @@ struct lu_device_type; > > /* genops.c */ > struct obd_export *class_conn2export(struct lustre_handle *conn); > -int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > +int class_register_type(const struct obd_ops *dt_ops, > + const struct md_ops *md_ops, > const char *name, struct lu_device_type *ldt); > int class_unregister_type(const char *name); > > diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c > index 1c7379b14f8c..35dff0e96bf7 100644 > --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c > +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c > @@ -3044,7 +3044,7 @@ static int lmv_merge_attr(struct obd_export *exp, > return 0; > } > > -static struct obd_ops lmv_obd_ops = { > +static const struct obd_ops lmv_obd_ops = { > .owner = THIS_MODULE, > .setup = lmv_setup, > .cleanup = lmv_cleanup, > @@ -3061,7 +3061,7 @@ static struct obd_ops lmv_obd_ops = { > .quotactl = lmv_quotactl > }; > > -static struct md_ops lmv_md_ops = { > +static const struct md_ops lmv_md_ops = { > .get_root = lmv_get_root, > .null_inode = lmv_null_inode, > .close = lmv_close, > diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c > index fd769c39b482..bad9538706f0 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_obd.c > +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c > @@ -1332,7 +1332,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, > return rc; > } > > -static struct obd_ops lov_obd_ops = { > +static const struct obd_ops lov_obd_ops = { > .owner = THIS_MODULE, > .setup = lov_setup, > .cleanup = lov_cleanup, > diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c > index db2c045aa1cd..72a5264b2d78 100644 > --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c > +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c > @@ -2569,7 +2569,7 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) > return count > 0 ? 0 : count; > } > > -static struct obd_ops mdc_obd_ops = { > +static const struct obd_ops mdc_obd_ops = { > .owner = THIS_MODULE, > .setup = mdc_setup, > .precleanup = mdc_precleanup, > @@ -2591,7 +2591,7 @@ static struct obd_ops mdc_obd_ops = { > .quotactl = mdc_quotactl, > }; > > -static struct md_ops mdc_md_ops = { > +static const struct md_ops mdc_md_ops = { > .get_root = mdc_get_root, > .null_inode = mdc_null_inode, > .close = mdc_close, > diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c > index a6ee715921b8..3ff0bf1c4a22 100644 > --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c > +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c > @@ -1817,7 +1817,7 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) > return rc; > } > > -static struct obd_ops mgc_obd_ops = { > +static const struct obd_ops mgc_obd_ops = { > .owner = THIS_MODULE, > .setup = mgc_setup, > .precleanup = mgc_precleanup, > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index a3437c2d07bb..d013e9a358f1 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -142,8 +142,6 @@ static void class_sysfs_release(struct kobject *kobj) > if (type->typ_lu) > lu_device_type_fini(type->typ_lu); > > - kfree(type->typ_md_ops); > - kfree(type->typ_dt_ops); > kfree(type); > } > > @@ -154,7 +152,8 @@ static struct kobj_type class_ktype = { > > #define CLASS_MAX_NAME 1024 > > -int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > +int class_register_type(const struct obd_ops *dt_ops, > + const struct md_ops *md_ops, > const char *name, > struct lu_device_type *ldt) > { > @@ -179,17 +178,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, > type->typ_kobj.kset = lustre_kset; > kobject_init(&type->typ_kobj, &class_ktype); > > - type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS); > - type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS); > - > - if (!type->typ_dt_ops || > - !type->typ_md_ops) > - goto failed; > - > - *type->typ_dt_ops = *dt_ops; > - /* md_ops is optional */ > - if (md_ops) > - *type->typ_md_ops = *md_ops; > + type->typ_dt_ops = dt_ops; > + type->typ_md_ops = md_ops; > > rc = kobject_add(&type->typ_kobj, &lustre_kset->kobj, "%s", name); > if (rc) > @@ -227,8 +217,8 @@ int class_unregister_type(const char *name) > CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt)); > /* This is a bad situation, let's make the best of it */ > /* Remove ops, but leave the name for debugging */ > - kfree(type->typ_dt_ops); > - kfree(type->typ_md_ops); > + type->typ_dt_ops = NULL; > + type->typ_md_ops = NULL; > kobject_put(&type->typ_kobj); > return -EBUSY; > } > diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c > index 317123fd27cb..baf34c85c4b5 100644 > --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c > +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c > @@ -1676,7 +1676,7 @@ static int echo_client_disconnect(struct obd_export *exp) > return rc; > } > > -static struct obd_ops echo_client_obd_ops = { > +static const struct obd_ops echo_client_obd_ops = { > .owner = THIS_MODULE, > .iocontrol = echo_client_iocontrol, > .connect = echo_client_connect, > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 3fedfaf249c4..442b4355d946 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -2988,7 +2988,7 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) > return osc_process_config_base(obd, buf); > } > > -static struct obd_ops osc_obd_ops = { > +static const struct obd_ops osc_obd_ops = { > .owner = THIS_MODULE, > .setup = osc_setup, > .precleanup = osc_precleanup, > > > From jsimmons at infradead.org Sun Feb 24 17:04:24 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:04:24 +0000 (GMT) Subject: [lustre-devel] [PATCH 09/37] lustre: obdclass: fix module load locking. In-Reply-To: <155053494536.24125.16645429190038913975.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494536.24125.16645429190038913975.stgit@noble.brown> Message-ID: > Safe module loading requires that we try_module_get() in a context > where the module cannot be unloaded, typically protected by > a spinlock that module-unload has to take. > This doesn't currently happen in class_get_type(). > > As free_module() calls synchronize_rcu() between calling the > exit function and freeing the module, we can use rcu_read_lock() > to check if the exit function has been called, and try_module_get() > if it hasn't. > > We must also check the return status of try_module_get(). Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/genops.c | 24 ++++++++++++++++++++--- > 1 file changed, 21 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index d013e9a358f1..1d1a6b2d436e 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -98,21 +98,31 @@ static struct obd_type *class_get_type(const char *name) > { > struct obd_type *type; > > + rcu_read_lock(); > type = class_search_type(name); > > if (!type) { > const char *modname = name; > > + rcu_read_unlock(); > if (!request_module("%s", modname)) { > CDEBUG(D_INFO, "Loaded module '%s'\n", modname); > - type = class_search_type(name); > } else { > LCONSOLE_ERROR_MSG(0x158, "Can't load module '%s'\n", > modname); > } > + rcu_read_lock(); > + type = class_search_type(name); > } > if (type) { > - if (try_module_get(type->typ_dt_ops->owner)) { > + /* > + * Holding rcu_read_lock() matches the synchronize_rcu() call > + * in free_module() and ensures that if type->typ_dt_ops is > + * not yet NULL, then the module won't be freed until after > + * we rcu_read_unlock(). > + */ > + const struct obd_ops *dt_ops = READ_ONCE(type->typ_dt_ops); > + if (dt_ops && try_module_get(dt_ops->owner)) { > refcount_inc(&type->typ_refcnt); > /* class_search_type() returned a counted reference, > * but we don't need that count any more as > @@ -124,6 +134,7 @@ static struct obd_type *class_get_type(const char *name) > type = NULL; > } > } > + rcu_read_unlock(); > return type; > } > > @@ -213,11 +224,18 @@ int class_unregister_type(const char *name) > return -EINVAL; > } > > + /* > + * Ensure that class_get_type doesn't try to get the module > + * as it could be freed before the obd_type is released. > + * synchronize_rcu() will be called before the module > + * is freed. > + */ > + type->typ_dt_ops = NULL; > + > if (refcount_read(&type->typ_refcnt)) { > CERROR("type %s has refcount (%d)\n", name, refcount_read(&type->typ_refcnt)); > /* This is a bad situation, let's make the best of it */ > /* Remove ops, but leave the name for debugging */ > - type->typ_dt_ops = NULL; > type->typ_md_ops = NULL; > kobject_put(&type->typ_kobj); > return -EBUSY; > > > From jsimmons at infradead.org Sun Feb 24 17:05:35 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:05:35 +0000 (GMT) Subject: [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc. In-Reply-To: <155053494542.24125.3526135915611952378.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494542.24125.3526135915611952378.stgit@noble.brown> Message-ID: > Passing 0 as the gfp_t for kmalloc() is not meaningful, and > could change behaviour. > Use an explicit GFP_KERNEL instead. Why did it every do this ?????? Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lustre/obdclass/kernelcomm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > index 925ba52c53b4..09d0b1ab8d1c 100644 > --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > @@ -133,7 +133,7 @@ int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group, > return -EBADF; > > /* freed in group_rem */ > - reg = kmalloc(sizeof(*reg) + data_len, 0); > + reg = kmalloc(sizeof(*reg) + data_len, GFP_KERNEL); > if (!reg) > return -ENOMEM; > > > > From jsimmons at infradead.org Sun Feb 24 17:15:16 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:15:16 +0000 (GMT) Subject: [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static. In-Reply-To: <155053494545.24125.14664274760505145343.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494545.24125.14664274760505145343.stgit@noble.brown> Message-ID: > libcfs_kkuc_msg_put() is never used outside of kernelcomm.c, > so make it static. In the OpenSFS branch libcfs_kkuc_msg_put() is used by the client and server code. While this is okay now in the future this will be reverted. So do we keep it as is so it can handle server code or do this change and then later do what I added below: > Signed-off-by: NeilBrown > --- > .../lustre/lustre/include/lustre_kernelcomm.h | 1 - > .../staging/lustre/lustre/obdclass/kernelcomm.c | 3 +-- > 2 files changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h > index 8e3a99057a38..1ed41840ab8f 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h > +++ b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h > @@ -46,7 +46,6 @@ typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg); > > /* Kernel methods */ > void libcfs_kkuc_init(void); #ifdef CONFIG_LUSTRE_SERVER > -int libcfs_kkuc_msg_put(struct file *fp, void *payload); #endif > int libcfs_kkuc_group_put(unsigned int group, void *payload); > int libcfs_kkuc_group_add(struct file *fp, int uid, unsigned int group, > void *data, size_t data_len); > diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > index 09d0b1ab8d1c..27870952b1f0 100644 > --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > @@ -49,7 +49,7 @@ > * @param payload Payload data. First field of payload is always > * struct kuc_hdr > */ #ifndef CONFIG_LUSTRE_SERVER > -int libcfs_kkuc_msg_put(struct file *filp, void *payload) #else > +static int libcfs_kkuc_msg_put(struct file *filp, void *payload) #endif > { > struct kuc_hdr *kuch = (struct kuc_hdr *)payload; > ssize_t count = kuch->kuc_msglen; > @@ -80,7 +80,6 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload) > > return rc; > } #ifdef CONFIG_LUSTER_SERVER > -EXPORT_SYMBOL(libcfs_kkuc_msg_put); #endif > /* > * Broadcast groups are global across all mounted filesystems; I do say the ifdef do look messy. From jsimmons at infradead.org Sun Feb 24 17:39:22 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:39:22 +0000 (GMT) Subject: [lustre-devel] [PATCH 16/37] lustre: obdclass: typo: Banlance -> Balance In-Reply-To: <155053494567.24125.4188546775209627143.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494567.24125.4188546775209627143.stgit@noble.brown> Message-ID: > Fix mistyped "Balance" in a comment. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/llog_obd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c > index 2b6489e2632d..a89ec816b043 100644 > --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c > @@ -112,7 +112,7 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) > idx = ctxt->loc_idx; > > /* > - * Banlance the ctxt get when calling llog_cleanup() > + * Balance the ctxt get when calling llog_cleanup() > */ > LASSERT(refcount_read(&ctxt->loc_refcount) < LI_POISON); > LASSERT(refcount_read(&ctxt->loc_refcount) > 1); > > > From jsimmons at infradead.org Sun Feb 24 17:52:13 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:52:13 +0000 (GMT) Subject: [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper. In-Reply-To: <155053494572.24125.4002432022455040178.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494572.24125.4002432022455040178.stgit@noble.brown> Message-ID: > This function seems overly complex, the same functionality > is available with much less effort. Actually we are in discussion about removing these functions. The details are at: https://jira.whamcloud.com/browse/LU-11157 Since shells typically don't handle "floating point" representation well you can see the following: sanity 64d with the same error message; '209.9: syntax error: invalid arithmetic operator (error token is ".9")' The second issues is that the read values are not true representation of the desired value. The same issues is with the string helpers as well. Take for example test_string_get_size_one(1100, 1, "1.10 kB", "1.07 KiB"); Which is taken from linux/lib/test-string_helpers.c. If you pass 1100 to string_get_size() you can get either 1.10 kB or 1.07 KiB. Now if do the reverse 1.10 kB you get ~1126 which is not the same as 11000. I discussed how to handle this problem with Andreas and he agreed the best solution is make all the sysfs / debugfs *_mb files turn any values passed in to around up to the nearest MiB. This way we can report the exact MiB settings to the users. We already have a patch to do this for max_dirty_mb which I can push. The other *_mb files need to be updated to round off. If you can wait a few days I can backport the already done patch and push a patch for the rest. > Signed-off-by: NeilBrown > --- > .../lustre/lustre/obdclass/lprocfs_status.c | 47 +++----------------- > 1 file changed, 7 insertions(+), 40 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > index 568e6623e0c8..bd24e48f6145 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > @@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m, > int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, > int mult) > { > - long decimal_val, frac_val; > int prtn; > > if (count < 10) > return -EINVAL; > > - decimal_val = val / mult; > - prtn = snprintf(buffer, count, "%ld", decimal_val); > - frac_val = val % mult; > - > - if (prtn < (count - 4) && frac_val > 0) { > - long temp_frac; > - int i, temp_mult = 1, frac_bits = 0; > - > - temp_frac = frac_val * 10; > - buffer[prtn++] = '.'; > - while (frac_bits < 2 && (temp_frac / mult) < 1) { > - /* only reserved 2 bits fraction */ > - buffer[prtn++] = '0'; > - temp_frac *= 10; > - frac_bits++; > - } > - /* > - * Need to think these cases : > - * 1. #echo x.00 > /sys/xxx output result : x > - * 2. #echo x.0x > /sys/xxx output result : x.0x > - * 3. #echo x.x0 > /sys/xxx output result : x.x > - * 4. #echo x.xx > /sys/xxx output result : x.xx > - * Only reserved 2 bits fraction. > - */ > - for (i = 0; i < (5 - prtn); i++) > - temp_mult *= 10; > - > - frac_bits = min((int)count - prtn, 3 - frac_bits); > - prtn += snprintf(buffer + prtn, frac_bits, "%ld", > - frac_val * temp_mult / mult); > + prtn = snprintf(buffer, count, "%ld.%02lu", > + val / mult, > + (val % mult) / (mult / 100)); > > + /* Strip trailing zeroes, and trailing '.' */ > + while (prtn && buffer[prtn-1] == '0') > + prtn--; > + if (prtn && buffer[prtn-1] == '.') > prtn--; > - while (buffer[prtn] < '1' || buffer[prtn] > '9') { > - prtn--; > - if (buffer[prtn] == '.') { > - prtn--; > - break; > - } > - } > - prtn++; > - } > buffer[prtn++] = '\n'; > return prtn; > } > > > From jsimmons at infradead.org Sun Feb 24 17:53:12 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:53:12 +0000 (GMT) Subject: [lustre-devel] [PATCH 18/37] lustre: obdclass: discard lprocfs_single/seq_release In-Reply-To: <155053494576.24125.8952974091192338899.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494576.24125.8952974091192338899.stgit@noble.brown> Message-ID: > Neither lprocfs_single_release() or lprocfs_seq_release() > add any value to single_release() or seq_release() which > they wrap. > So just use the base functions and discard the wrapper. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lustre/include/lprocfs_status.h | 7 ++----- > drivers/staging/lustre/lustre/lov/lproc_lov.c | 2 +- > .../lustre/lustre/obdclass/lprocfs_status.c | 14 +------------- > .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +- > 4 files changed, 5 insertions(+), 20 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h > index d69f395e3d52..8565c28f08ee 100644 > --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h > +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h > @@ -502,9 +502,6 @@ unsigned long lprocfs_oh_sum(struct obd_histogram *oh); > void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, > struct lprocfs_counter *cnt); > > -int lprocfs_single_release(struct inode *inode, struct file *file); > -int lprocfs_seq_release(struct inode *inode, struct file *file); > - > /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only > * proc entries; otherwise, you will define name##_seq_write function also for > * a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally, > @@ -521,7 +518,7 @@ static const struct file_operations name##_fops = { \ > .read = seq_read, \ > .write = custom_seq_write, \ > .llseek = seq_lseek, \ > - .release = lprocfs_single_release, \ > + .release = single_release, \ > } > > #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL) > @@ -563,7 +560,7 @@ static const struct file_operations name##_fops = { \ > static const struct file_operations name##_##type##_fops = { \ > .open = name##_##type##_open, \ > .write = name##_##type##_write, \ > - .release = lprocfs_single_release, \ > + .release = single_release, \ > } > > struct lustre_attr { > diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c > index fc53f2386c39..cfb274498d30 100644 > --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c > +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c > @@ -264,7 +264,7 @@ static const struct file_operations lov_debugfs_target_fops = { > .open = lov_target_seq_open, > .read = seq_read, > .llseek = seq_lseek, > - .release = lprocfs_seq_release, > + .release = seq_release, > }; > > static struct attribute *lov_attrs[] = { > diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > index bd24e48f6145..76d298337e95 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > @@ -273,18 +273,6 @@ MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs > > #define MAX_STRING_SIZE 128 > > -int lprocfs_single_release(struct inode *inode, struct file *file) > -{ > - return single_release(inode, file); > -} > -EXPORT_SYMBOL(lprocfs_single_release); > - > -int lprocfs_seq_release(struct inode *inode, struct file *file) > -{ > - return seq_release(inode, file); > -} > -EXPORT_SYMBOL(lprocfs_seq_release); > - > /* lprocfs API calls */ > > static const struct file_operations lprocfs_generic_fops = { }; > @@ -1331,7 +1319,7 @@ const struct file_operations lprocfs_stats_seq_fops = { > .read = seq_read, > .write = lprocfs_stats_seq_write, > .llseek = seq_lseek, > - .release = lprocfs_seq_release, > + .release = seq_release, > }; > EXPORT_SYMBOL_GPL(lprocfs_stats_seq_fops); > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c > index 25858b8f6cbd..d09bddaf88ba 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c > @@ -1093,7 +1093,7 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry, > .open = ptlrpc_lprocfs_svc_req_history_open, > .read = seq_read, > .llseek = seq_lseek, > - .release = lprocfs_seq_release, > + .release = seq_release, > }; > > ptlrpc_ldebugfs_register(entry, svc->srv_name, > > > From jsimmons at infradead.org Sun Feb 24 17:53:31 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 17:53:31 +0000 (GMT) Subject: [lustre-devel] [PATCH 19/37] lustre: discard lprocfs_strnstr() In-Reply-To: <155053494582.24125.9057041272800982944.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494582.24125.9057041272800982944.stgit@noble.brown> Message-ID: > This is identical to strnstr() in lib/string.h, > so just use that. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../lustre/lustre/obdclass/lprocfs_status.c | 19 +------------------ > 1 file changed, 1 insertion(+), 18 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > index 76d298337e95..27d73c95403d 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > @@ -1552,22 +1552,6 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer, > } > EXPORT_SYMBOL(lprocfs_write_frac_u64_helper); > > -static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len) > -{ > - size_t l2; > - > - l2 = strlen(s2); > - if (!l2) > - return (char *)s1; > - while (len >= l2) { > - len--; > - if (!memcmp(s1, s2, l2)) > - return (char *)s1; > - s1++; > - } > - return NULL; > -} > - > /** > * Find the string \a name in the input \a buffer, and return a pointer to the > * value immediately following \a name, reducing \a count appropriately. > @@ -1579,8 +1563,7 @@ char *lprocfs_find_named_value(const char *buffer, const char *name, > char *val; > size_t buflen = *count; > > - /* there is no strnstr() in rhel5 and ubuntu kernels */ > - val = lprocfs_strnstr(buffer, name, buflen); > + val = strnstr(buffer, name, buflen); > if (!val) > return (char *)buffer; > > > > From jsimmons at infradead.org Sun Feb 24 18:09:57 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 18:09:57 +0000 (GMT) Subject: [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop. In-Reply-To: <155053494599.24125.1795878344125234751.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494599.24125.1795878344125234751.stgit@noble.brown> Message-ID: > These shift loops seem to be trying to avoid doing a > multiplication. > We same effect can be achieved more transparently using > rounddown_pow_of_two(). Even though there is a multiplication > in the C code, the resulting machine code just does a single shift. Be aware rounddown_pow_of_two(n) is undefined when "n == 0". We should handle the "0" case as well. We are aware of this because this case bit us in the LNet layer. > Signed-off-by: NeilBrown > --- > .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > index a179b0d6979e..637aaca96888 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, > u32 blk_size = osfs.os_bsize >> 10; > u64 result = osfs.os_blocks; > > - while (blk_size >>= 1) > - result <<= 1; > - > + result *= rounddown_pow_of_two(blk_size); > return sprintf(buf, "%llu\n", result); > } > > @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, > u32 blk_size = osfs.os_bsize >> 10; > u64 result = osfs.os_bfree; > > - while (blk_size >>= 1) > - result <<= 1; > + result *= rounddown_pow_of_two(blk_size); > > return sprintf(buf, "%llu\n", result); > } > @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, > u32 blk_size = osfs.os_bsize >> 10; > u64 result = osfs.os_bavail; > > - while (blk_size >>= 1) > - result <<= 1; > + result *= rounddown_pow_of_two(blk_size); > > return sprintf(buf, "%llu\n", result); > } > > > From jsimmons at infradead.org Sun Feb 24 18:35:08 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 18:35:08 +0000 (GMT) Subject: [lustre-devel] [PATCH 01/37] lustre: obdclass: char obd_ioctl_getdata type. In-Reply-To: <155053494481.24125.17153359714439231322.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494481.24125.17153359714439231322.stgit@noble.brown> Message-ID: > Instead of having obd_ioctl_getdata() return the allocated > data as a "char *", return it as it really is, > struct obd_ioctl_data * > > This avoids the need for extra variables and casts. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/obd_class.h | 3 ++- > drivers/staging/lustre/lustre/llite/dir.c | 18 ++++++------------ > drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +++----- > drivers/staging/lustre/lustre/lov/lov_obd.c | 15 ++++++--------- > drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 ++++++++---------- > 5 files changed, 25 insertions(+), 37 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h > index 30b3e2c69f83..32d4ab6e78a0 100644 > --- a/drivers/staging/lustre/lustre/include/obd_class.h > +++ b/drivers/staging/lustre/lustre/include/obd_class.h > @@ -1697,6 +1697,7 @@ struct root_squash_info { > }; > > /* linux-module.c */ > -int obd_ioctl_getdata(char **buf, int *len, void __user *arg); > +struct obd_ioctl_data; > +int obd_ioctl_getdata(struct obd_ioctl_data **data, int *len, void __user *arg); > > #endif /* __LINUX_OBD_CLASS_H */ > diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c > index fd1af4a5cdad..17bb6185ba87 100644 > --- a/drivers/staging/lustre/lustre/llite/dir.c > +++ b/drivers/staging/lustre/lustre/llite/dir.c > @@ -1130,13 +1130,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > } > case IOC_MDC_LOOKUP: { > int namelen, len = 0; > - char *buf = NULL; > char *filename; > > - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); > + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); > if (rc) > return rc; > - data = (void *)buf; > > filename = data->ioc_inlbuf1; > namelen = strlen(filename); > @@ -1155,12 +1153,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > goto out_free; > } > out_free: > - kvfree(buf); > + kvfree(data); > return rc; > } > case LL_IOC_LMV_SETSTRIPE: { > struct lmv_user_md *lum; > - char *buf = NULL; > char *filename; > int namelen = 0; > int lumlen = 0; > @@ -1168,11 +1165,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > int len; > int rc; > > - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); > + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); > if (rc) > return rc; > > - data = (void *)buf; > if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || > data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0) { > rc = -EINVAL; > @@ -1205,7 +1201,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > #endif > rc = ll_dir_setdirstripe(dentry, lum, filename, mode); > lmv_out_free: > - kvfree(buf); > + kvfree(data); > return rc; > } > case LL_IOC_LMV_SET_DEFAULT_STRIPE: { > @@ -1651,18 +1647,16 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > return rc; > } > case LL_IOC_MIGRATE: { > - char *buf = NULL; > const char *filename; > int namelen = 0; > int len; > int rc; > int mdtidx; > > - rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg); > + rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); > if (rc < 0) > return rc; > > - data = (struct obd_ioctl_data *)buf; > if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || > !data->ioc_inllen1 || !data->ioc_inllen2) { > rc = -EINVAL; > @@ -1684,7 +1678,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > > rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1); > migrate_free: > - kvfree(buf); > + kvfree(data); > > return rc; > } > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index 8e09fdd7a96e..e2417cd5aaed 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -2295,7 +2295,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) > { > struct ll_sb_info *sbi = NULL; > struct obd_export *exp; > - char *buf = NULL; > struct obd_ioctl_data *data = NULL; > u32 type; > int len = 0, rc; > @@ -2311,11 +2310,10 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) > goto out_statfs; > } > > - rc = obd_ioctl_getdata(&buf, &len, arg); > + rc = obd_ioctl_getdata(&data, &len, arg); > if (rc) > goto out_statfs; > > - data = (void *)buf; > if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || > !data->ioc_pbuf1 || !data->ioc_pbuf2) { > rc = -EINVAL; > @@ -2340,11 +2338,11 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) > goto out_statfs; > } > > - rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL); > + rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, data, NULL); > if (rc) > goto out_statfs; > out_statfs: > - kvfree(buf); > + kvfree(data); > return rc; > } > > diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c > index 04d0a9ed1d05..fd769c39b482 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_obd.c > +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c > @@ -1039,27 +1039,24 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, > case OBD_IOC_LOV_GET_CONFIG: { > struct obd_ioctl_data *data; > struct lov_desc *desc; > - char *buf = NULL; > u32 *genp; > > len = 0; > - if (obd_ioctl_getdata(&buf, &len, uarg)) > + if (obd_ioctl_getdata(&data, &len, uarg)) > return -EINVAL; > > - data = (struct obd_ioctl_data *)buf; > - > if (sizeof(*desc) > data->ioc_inllen1) { > - kvfree(buf); > + kvfree(data); > return -EINVAL; > } > > if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { > - kvfree(buf); > + kvfree(data); > return -EINVAL; > } > > if (sizeof(u32) * count > data->ioc_inllen3) { > - kvfree(buf); > + kvfree(data); > return -EINVAL; > } > > @@ -1076,9 +1073,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, > *genp = lov->lov_tgts[i]->ltd_gen; > } > > - if (copy_to_user(uarg, buf, len)) > + if (copy_to_user(uarg, data, len)) > rc = -EFAULT; > - kvfree(buf); > + kvfree(data); > break; > } > case OBD_IOC_QUOTACTL: { > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index 2ee6b96f4830..b8fc74044fe3 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -229,7 +229,7 @@ static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) > } > > /* buffer MUST be at least the size of obd_ioctl_hdr */ > -int obd_ioctl_getdata(char **buf, int *len, void __user *arg) > +int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg) > { > struct obd_ioctl_data *data; > struct obd_ioctl_hdr hdr; > @@ -261,16 +261,16 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) > * obdfilter-survey is an example, which relies on ioctl. So we'd > * better avoid vmalloc on ioctl path. LU-66 > */ > - *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); > - if (!*buf) { > + data = kvzalloc(hdr.ioc_len, GFP_KERNEL); > + if (!data) { > CERROR("Cannot allocate control buffer of len %d\n", > hdr.ioc_len); > return -EINVAL; > } > *len = hdr.ioc_len; > - data = (struct obd_ioctl_data *)*buf; > + *datap = data; > > - if (copy_from_user(*buf, arg, hdr.ioc_len)) { > + if (copy_from_user(data, arg, hdr.ioc_len)) { > err = -EFAULT; > goto free_buf; > } > @@ -307,14 +307,13 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) > return 0; > > free_buf: > - kvfree(*buf); > + kvfree(data); > return err; > } > EXPORT_SYMBOL(obd_ioctl_getdata); > > int class_handle_ioctl(unsigned int cmd, unsigned long arg) > { > - char *buf = NULL; > struct obd_ioctl_data *data; > struct libcfs_debug_ioctl_data *debug_data; > struct obd_device *obd = NULL; > @@ -329,11 +328,10 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > } > > CDEBUG(D_IOCTL, "cmd = %x\n", cmd); > - if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) { > + if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) { > CERROR("OBD ioctl: data error\n"); > return -EINVAL; > } > - data = (struct obd_ioctl_data *)buf; > > switch (cmd) { > case OBD_IOC_PROCESS_CFG: { > @@ -542,7 +540,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) > } > > out: > - kvfree(buf); > + kvfree(data); > return err; > } /* class_handle_ioctl */ > > > > From jsimmons at infradead.org Sun Feb 24 18:51:41 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 18:51:41 +0000 (GMT) Subject: [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment. In-Reply-To: <155053494604.24125.7873412904407447511.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494604.24125.7873412904407447511.stgit@noble.brown> Message-ID: > This patch changes a lot of places that use spaces for > alignment to instead use tabs - though in one case in a > comment, spaces are used in place of tabs to be more consistent. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../lustre/include/linux/libcfs/libcfs_cpu.h | 2 > .../lustre/include/linux/libcfs/libcfs_crypto.h | 10 - > .../lustre/include/linux/libcfs/libcfs_debug.h | 30 +- > .../lustre/include/linux/libcfs/libcfs_fail.h | 12 - > .../lustre/include/linux/libcfs/libcfs_hash.h | 24 + > .../lustre/include/linux/libcfs/libcfs_private.h | 2 > .../staging/lustre/include/linux/lnet/lib-lnet.h | 4 > .../staging/lustre/include/linux/lnet/socklnd.h | 2 > .../lustre/include/uapi/linux/lnet/libcfs_debug.h | 124 +++---- > .../lustre/include/uapi/linux/lnet/libcfs_ioctl.h | 56 +-- > .../lustre/include/uapi/linux/lnet/lnet-types.h | 10 - > .../lustre/include/uapi/linux/lnet/lnetst.h | 14 - > .../lustre/include/uapi/linux/lnet/nidstr.h | 6 > .../include/uapi/linux/lustre/lustre_fiemap.h | 2 > .../lustre/include/uapi/linux/lustre/lustre_idl.h | 350 +++++++++---------- > .../lustre/include/uapi/linux/lustre/lustre_user.h | 378 ++++++++++---------- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 60 ++- > .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 32 +- > drivers/staging/lustre/lnet/lnet/nidstrings.c | 4 > drivers/staging/lustre/lnet/selftest/timer.c | 8 > drivers/staging/lustre/lustre/fld/lproc_fld.c | 2 > .../staging/lustre/lustre/include/lustre_import.h | 6 > drivers/staging/lustre/lustre/include/obd.h | 10 - > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 6 > drivers/staging/lustre/lustre/llite/file.c | 2 > drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 > drivers/staging/lustre/lustre/llite/xattr.c | 2 > drivers/staging/lustre/lustre/lov/lov_ea.c | 2 > drivers/staging/lustre/lustre/lov/lov_obd.c | 26 + > drivers/staging/lustre/lustre/mgc/mgc_request.c | 24 + > drivers/staging/lustre/lustre/obdclass/genops.c | 6 > drivers/staging/lustre/lustre/obdclass/lu_object.c | 8 > drivers/staging/lustre/lustre/obdclass/obd_sysfs.c | 2 > drivers/staging/lustre/lustre/osc/osc_request.c | 40 +- > drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 > 35 files changed, 635 insertions(+), 635 deletions(-) > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > index 3e51752491d0..56905317fab0 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h > @@ -372,7 +372,7 @@ enum { > > struct cfs_percpt_lock { > /* cpu-partition-table for this lock */ > - struct cfs_cpt_table *pcl_cptab; > + struct cfs_cpt_table *pcl_cptab; > /* exclusively locked */ > unsigned int pcl_locked; > /* private lock table */ > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h > index ca8620b93de7..03da963b8d33 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h > @@ -33,17 +33,17 @@ > struct page; > > struct cfs_crypto_hash_type { > - char *cht_name; /*< hash algorithm name, equal to > + char *cht_name; /*< hash algorithm name, equal to > * format name for crypto api > */ > - unsigned int cht_key; /*< init key by default (valid for > + unsigned int cht_key; /*< init key by default (valid for > * 4 bytes context like crc32, adler > */ > - unsigned int cht_size; /**< hash digest size */ > + unsigned int cht_size; /**< hash digest size */ > }; > > enum cfs_crypto_hash_alg { > - CFS_HASH_ALG_NULL = 0, > + CFS_HASH_ALG_NULL = 0, > CFS_HASH_ALG_ADLER32, > CFS_HASH_ALG_CRC32, > CFS_HASH_ALG_CRC32C, > @@ -54,7 +54,7 @@ enum cfs_crypto_hash_alg { > CFS_HASH_ALG_SHA384, > CFS_HASH_ALG_SHA512, > CFS_HASH_ALG_MAX, > - CFS_HASH_ALG_SPEED_MAX = CFS_HASH_ALG_MD5, > + CFS_HASH_ALG_SPEED_MAX = CFS_HASH_ALG_MD5, > CFS_HASH_ALG_UNKNOWN = 0xff > }; > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h > index 3fd6ad7a3b56..ba5d5ba2dac2 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h > @@ -68,11 +68,11 @@ extern unsigned int libcfs_panic_on_lbug; > #if !defined(__x86_64__) > # ifdef __ia64__ > # define CDEBUG_STACK() (THREAD_SIZE - \ > - ((unsigned long)__builtin_dwarf_cfa() & \ > + ((unsigned long)__builtin_dwarf_cfa() & \ > (THREAD_SIZE - 1))) > # else > # define CDEBUG_STACK() (THREAD_SIZE - \ > - ((unsigned long)__builtin_frame_address(0) & \ > + ((unsigned long)__builtin_frame_address(0) & \ > (THREAD_SIZE - 1))) > # endif /* __ia64__ */ > > @@ -87,7 +87,7 @@ do { \ > (msgdata)->msg_mask = mask; \ > (msgdata)->msg_cdls = cdls; \ > dump_stack(); \ > - /*panic("LBUG");*/ \ > + /*panic("LBUG");*/ \ > } \ > } while (0) > #define CFS_CHECK_STACK(msgdata, mask, cdls) __CHECK_STACK(msgdata, mask, cdls) > @@ -120,22 +120,22 @@ struct libcfs_debug_msg_data { > > #define LIBCFS_DEBUG_MSG_DATA_INIT(data, mask, cdls) \ > do { \ > - (data)->msg_subsys = DEBUG_SUBSYSTEM; \ > - (data)->msg_file = __FILE__; \ > - (data)->msg_fn = __func__; \ > - (data)->msg_line = __LINE__; \ > - (data)->msg_cdls = (cdls); \ > - (data)->msg_mask = (mask); \ > + (data)->msg_subsys = DEBUG_SUBSYSTEM; \ > + (data)->msg_file = __FILE__; \ > + (data)->msg_fn = __func__; \ > + (data)->msg_line = __LINE__; \ > + (data)->msg_cdls = (cdls); \ > + (data)->msg_mask = (mask); \ > } while (0) > > #define LIBCFS_DEBUG_MSG_DATA_DECL(dataname, mask, cdls) \ > static struct libcfs_debug_msg_data dataname = { \ > - .msg_subsys = DEBUG_SUBSYSTEM, \ > - .msg_file = __FILE__, \ > - .msg_fn = __func__, \ > - .msg_line = __LINE__, \ > - .msg_cdls = (cdls) }; \ > - dataname.msg_mask = (mask) > + .msg_subsys = DEBUG_SUBSYSTEM, \ > + .msg_file = __FILE__, \ > + .msg_fn = __func__, \ > + .msg_line = __LINE__, \ > + .msg_cdls = (cdls) }; \ > + dataname.msg_mask = (mask) > > /** > * Filters out logging messages based on mask and subsystem. > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h > index 4a4197874f80..0e73eef6a992 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h > @@ -47,10 +47,10 @@ int __cfs_fail_check_set(u32 id, u32 value, int set); > int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set); > > enum { > - CFS_FAIL_LOC_NOSET = 0, > - CFS_FAIL_LOC_ORSET = 1, > - CFS_FAIL_LOC_RESET = 2, > - CFS_FAIL_LOC_VALUE = 3 > + CFS_FAIL_LOC_NOSET = 0, > + CFS_FAIL_LOC_ORSET = 1, > + CFS_FAIL_LOC_RESET = 2, > + CFS_FAIL_LOC_VALUE = 3 > }; > > /* Failure injection control */ > @@ -76,8 +76,8 @@ enum { > static inline bool CFS_FAIL_PRECHECK(u32 id) > { > return cfs_fail_loc && > - ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) || > - (cfs_fail_loc & id & CFS_FAULT)); > + ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) || > + (cfs_fail_loc & id & CFS_FAULT)); > } > > static inline int cfs_fail_check_set(u32 id, u32 value, > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h > index be315958a4b3..89d25ca57c18 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h > @@ -304,25 +304,25 @@ struct cfs_hash_ops { > unsigned int (*hs_hash)(struct cfs_hash *hs, const void *key, > unsigned int mask); > /** return key address of @hnode */ > - void * (*hs_key)(struct hlist_node *hnode); > + void * (*hs_key)(struct hlist_node *hnode); > /** copy key from @hnode to @key */ > - void (*hs_keycpy)(struct hlist_node *hnode, void *key); > + void (*hs_keycpy)(struct hlist_node *hnode, void *key); > /** > * compare @key with key of @hnode > * returns 1 on a match > */ > - int (*hs_keycmp)(const void *key, struct hlist_node *hnode); > + int (*hs_keycmp)(const void *key, struct hlist_node *hnode); > /** return object address of @hnode, i.e: container_of(...hnode) */ > - void * (*hs_object)(struct hlist_node *hnode); > + void * (*hs_object)(struct hlist_node *hnode); > /** get refcount of item, always called with holding bucket-lock */ > - void (*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode); > + void (*hs_get)(struct cfs_hash *hs, struct hlist_node *hnode); > /** release refcount of item */ > - void (*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode); > + void (*hs_put)(struct cfs_hash *hs, struct hlist_node *hnode); > /** release refcount of item, always called with holding bucket-lock */ > - void (*hs_put_locked)(struct cfs_hash *hs, > - struct hlist_node *hnode); > + void (*hs_put_locked)(struct cfs_hash *hs, > + struct hlist_node *hnode); > /** it's called before removing of @hnode */ > - void (*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode); > + void (*hs_exit)(struct cfs_hash *hs, struct hlist_node *hnode); > }; > > /** total number of buckets in @hs */ > @@ -460,8 +460,8 @@ static inline int > cfs_hash_bkt_size(struct cfs_hash *hs) > { > return offsetof(struct cfs_hash_bucket, hsb_head[0]) + > - hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) + > - hs->hs_extra_bytes; > + hs->hs_hops->hop_hhead_size(hs) * CFS_HASH_BKT_NHLIST(hs) + > + hs->hs_extra_bytes; > } > > static inline unsigned > @@ -703,7 +703,7 @@ void *cfs_hash_del(struct cfs_hash *hs, const void *key, > void *cfs_hash_del_key(struct cfs_hash *hs, const void *key); > > /* Hash lookup/for_each functions */ > -#define CFS_HASH_LOOP_HOG 1024 > +#define CFS_HASH_LOOP_HOG 1024 > > typedef int (*cfs_hash_for_each_cb_t)(struct cfs_hash *hs, > struct cfs_hash_bd *bd, > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > index d525e4f928fe..515fd63708c0 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > @@ -141,7 +141,7 @@ void cfs_array_free(void *vars); > #define LASSERT_ATOMIC_GT_LT(a, v1, v2) \ > do { \ > int __v = atomic_read(a); \ > - LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v); \ > + LASSERTF(__v > v1 && __v < v2, "value: %d\n", __v); \ > } while (0) > > /** assert value of @a is great than @v1 and little/equal to @v2 */ > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > index fb5d07460243..e60c446fbb27 100644 > --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > @@ -611,7 +611,7 @@ void lnet_counters_reset(void); > unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov); > int lnet_extract_iov(int dst_niov, struct kvec *dst, > int src_niov, const struct kvec *src, > - unsigned int offset, unsigned int len); > + unsigned int offset, unsigned int len); > > unsigned int lnet_kiov_nob(unsigned int niov, struct bio_vec *iov); > int lnet_extract_kiov(int dst_niov, struct bio_vec *dst, > @@ -827,7 +827,7 @@ void lnet_incr_stats(struct lnet_element_stats *stats, > enum lnet_stats_type stats_type); > > u32 lnet_sum_stats(struct lnet_element_stats *stats, > - enum lnet_stats_type stats_type); > + enum lnet_stats_type stats_type); > > void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats, > struct lnet_element_stats *stats); > diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h > index ca814afd34ef..9f318b73cd34 100644 > --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h > +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h > @@ -41,7 +41,7 @@ > struct ksock_hello_msg { > u32 kshm_magic; /* magic number of socklnd message */ > u32 kshm_version; /* version of socklnd message */ > - lnet_nid_t kshm_src_nid; /* sender's nid */ > + lnet_nid_t kshm_src_nid; /* sender's nid */ > lnet_nid_t kshm_dst_nid; /* destination nid */ > lnet_pid_t kshm_src_pid; /* sender's pid */ > lnet_pid_t kshm_dst_pid; /* destination pid */ > diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h > index 2672fe7ae103..91d80ab064ad 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h > +++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_debug.h > @@ -62,38 +62,38 @@ struct ptldebug_header { > #define PH_FLAG_FIRST_RECORD 1 > > /* Debugging subsystems (32 bits, non-overlapping) */ > -#define S_UNDEFINED 0x00000001 > -#define S_MDC 0x00000002 > -#define S_MDS 0x00000004 > -#define S_OSC 0x00000008 > -#define S_OST 0x00000010 > -#define S_CLASS 0x00000020 > -#define S_LOG 0x00000040 > -#define S_LLITE 0x00000080 > -#define S_RPC 0x00000100 > -#define S_MGMT 0x00000200 > -#define S_LNET 0x00000400 > -#define S_LND 0x00000800 /* ALL LNDs */ > -#define S_PINGER 0x00001000 > -#define S_FILTER 0x00002000 > -#define S_LIBCFS 0x00004000 > -#define S_ECHO 0x00008000 > -#define S_LDLM 0x00010000 > -#define S_LOV 0x00020000 > -#define S_LQUOTA 0x00040000 > -#define S_OSD 0x00080000 > -#define S_LFSCK 0x00100000 > -#define S_SNAPSHOT 0x00200000 > +#define S_UNDEFINED 0x00000001 > +#define S_MDC 0x00000002 > +#define S_MDS 0x00000004 > +#define S_OSC 0x00000008 > +#define S_OST 0x00000010 > +#define S_CLASS 0x00000020 > +#define S_LOG 0x00000040 > +#define S_LLITE 0x00000080 > +#define S_RPC 0x00000100 > +#define S_MGMT 0x00000200 > +#define S_LNET 0x00000400 > +#define S_LND 0x00000800 /* ALL LNDs */ > +#define S_PINGER 0x00001000 > +#define S_FILTER 0x00002000 > +#define S_LIBCFS 0x00004000 > +#define S_ECHO 0x00008000 > +#define S_LDLM 0x00010000 > +#define S_LOV 0x00020000 > +#define S_LQUOTA 0x00040000 > +#define S_OSD 0x00080000 > +#define S_LFSCK 0x00100000 > +#define S_SNAPSHOT 0x00200000 > /* unused */ > -#define S_LMV 0x00800000 /* b_new_cmd */ > +#define S_LMV 0x00800000 /* b_new_cmd */ > /* unused */ > -#define S_SEC 0x02000000 /* upcall cache */ > -#define S_GSS 0x04000000 /* b_new_cmd */ > +#define S_SEC 0x02000000 /* upcall cache */ > +#define S_GSS 0x04000000 /* b_new_cmd */ > /* unused */ > -#define S_MGC 0x10000000 > -#define S_MGS 0x20000000 > -#define S_FID 0x40000000 /* b_new_cmd */ > -#define S_FLD 0x80000000 /* b_new_cmd */ > +#define S_MGC 0x10000000 > +#define S_MGS 0x20000000 > +#define S_FID 0x40000000 /* b_new_cmd */ > +#define S_FLD 0x80000000 /* b_new_cmd */ > > #define LIBCFS_DEBUG_SUBSYS_NAMES { \ > "undefined", "mdc", "mds", "osc", "ost", "class", "log", \ > @@ -103,38 +103,38 @@ struct ptldebug_header { > "fid", "fld", NULL } > > /* Debugging masks (32 bits, non-overlapping) */ > -#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */ > -#define D_INODE 0x00000002 > -#define D_SUPER 0x00000004 > -#define D_EXT2 0x00000008 /* anything from ext2_debug */ > -#define D_MALLOC 0x00000010 /* print malloc, free information */ > -#define D_CACHE 0x00000020 /* cache-related items */ > -#define D_INFO 0x00000040 /* general information */ > -#define D_IOCTL 0x00000080 /* ioctl related information */ > -#define D_NETERROR 0x00000100 /* network errors */ > -#define D_NET 0x00000200 /* network communications */ > -#define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */ > -#define D_BUFFS 0x00000800 > -#define D_OTHER 0x00001000 > -#define D_DENTRY 0x00002000 > -#define D_NETTRACE 0x00004000 > -#define D_PAGE 0x00008000 /* bulk page handling */ > -#define D_DLMTRACE 0x00010000 > -#define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */ > -#define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */ > -#define D_HA 0x00080000 /* recovery and failover */ > -#define D_RPCTRACE 0x00100000 /* for distributed debugging */ > -#define D_VFSTRACE 0x00200000 > -#define D_READA 0x00400000 /* read-ahead */ > -#define D_MMAP 0x00800000 > -#define D_CONFIG 0x01000000 > -#define D_CONSOLE 0x02000000 > -#define D_QUOTA 0x04000000 > -#define D_SEC 0x08000000 > -#define D_LFSCK 0x10000000 /* For both OI scrub and LFSCK */ > -#define D_HSM 0x20000000 > -#define D_SNAPSHOT 0x40000000 /* snapshot */ > -#define D_LAYOUT 0x80000000 > +#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */ > +#define D_INODE 0x00000002 > +#define D_SUPER 0x00000004 > +#define D_EXT2 0x00000008 /* anything from ext2_debug */ > +#define D_MALLOC 0x00000010 /* print malloc, free information */ > +#define D_CACHE 0x00000020 /* cache-related items */ > +#define D_INFO 0x00000040 /* general information */ > +#define D_IOCTL 0x00000080 /* ioctl related information */ > +#define D_NETERROR 0x00000100 /* network errors */ > +#define D_NET 0x00000200 /* network communications */ > +#define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */ > +#define D_BUFFS 0x00000800 > +#define D_OTHER 0x00001000 > +#define D_DENTRY 0x00002000 > +#define D_NETTRACE 0x00004000 > +#define D_PAGE 0x00008000 /* bulk page handling */ > +#define D_DLMTRACE 0x00010000 > +#define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */ > +#define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */ > +#define D_HA 0x00080000 /* recovery and failover */ > +#define D_RPCTRACE 0x00100000 /* for distributed debugging */ > +#define D_VFSTRACE 0x00200000 > +#define D_READA 0x00400000 /* read-ahead */ > +#define D_MMAP 0x00800000 > +#define D_CONFIG 0x01000000 > +#define D_CONSOLE 0x02000000 > +#define D_QUOTA 0x04000000 > +#define D_SEC 0x08000000 > +#define D_LFSCK 0x10000000 /* For both OI scrub and LFSCK */ > +#define D_HSM 0x20000000 > +#define D_SNAPSHOT 0x40000000 /* snapshot */ > +#define D_LAYOUT 0x80000000 > > #define LIBCFS_DEBUG_MASKS_NAMES { \ > "trace", "inode", "super", "ext2", "malloc", "cache", "info", \ > @@ -144,7 +144,7 @@ struct ptldebug_header { > "console", "quota", "sec", "lfsck", "hsm", "snapshot", "layout",\ > NULL } > > -#define D_CANTMASK (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE) > +#define D_CANTMASK (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE) > > #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log" > > diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h > index 4590f65c333f..765466f41d61 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h > +++ b/drivers/staging/lustre/include/uapi/linux/lnet/libcfs_ioctl.h > @@ -82,41 +82,41 @@ struct libcfs_debug_ioctl_data { > }; > > /* 'f' ioctls are defined in lustre_ioctl.h and lustre_user.h except for: */ > -#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long) > -#define IOCTL_LIBCFS_TYPE long > +#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long) > +#define IOCTL_LIBCFS_TYPE long > > -#define IOC_LIBCFS_TYPE ('e') > -#define IOC_LIBCFS_MIN_NR 30 > +#define IOC_LIBCFS_TYPE ('e') > +#define IOC_LIBCFS_MIN_NR 30 > /* libcfs ioctls */ > /* IOC_LIBCFS_PANIC obsolete in 2.8.0, was _IOWR('e', 30, IOCTL_LIBCFS_TYPE) */ > -#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, IOCTL_LIBCFS_TYPE) > /* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */ > /* lnet ioctls */ > -#define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, IOCTL_LIBCFS_TYPE) > /* IOC_LIBCFS_PORTALS_COMPATIBILITY _IOWR('e', 57, IOCTL_LIBCFS_TYPE) */ > -#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_PING _IOWR('e', 61, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_PING_PEER _IOWR('e', 62, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_LNETST _IOWR('e', 63, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_LNET_FAULT _IOWR('e', 64, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_PING _IOWR('e', 61, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_PING_PEER _IOWR('e', 62, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_LNETST _IOWR('e', 63, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_LNET_FAULT _IOWR('e', 64, IOCTL_LIBCFS_TYPE) > /* lnd ioctls */ > -#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_DISCOVER _IOWR('e', 77, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, IOCTL_LIBCFS_TYPE) > -#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_DISCOVER _IOWR('e', 77, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, IOCTL_LIBCFS_TYPE) > +#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, IOCTL_LIBCFS_TYPE) > > /* > * DLC Specific IOCTL numbers. > diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h > index 4fcc5336d927..956af3c53cfc 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h > +++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h > @@ -289,9 +289,9 @@ struct lnet_counters { > __u64 drop_length; > } __packed; > > -#define LNET_NI_STATUS_UP 0x15aac0de > -#define LNET_NI_STATUS_DOWN 0xdeadface > -#define LNET_NI_STATUS_INVALID 0x00000000 > +#define LNET_NI_STATUS_UP 0x15aac0de > +#define LNET_NI_STATUS_DOWN 0xdeadface > +#define LNET_NI_STATUS_INVALID 0x00000000 > > #define LNET_INTERFACES_NUM 16 > > @@ -596,7 +596,7 @@ enum lnet_event_kind { > LNET_EVENT_UNLINK, > }; > > -#define LNET_SEQ_GT(a, b) (((signed long)((a) - (b))) > 0) > +#define LNET_SEQ_GT(a, b) (((signed long)((a) - (b))) > 0) > > /** > * Information about an event on a MD. > @@ -650,7 +650,7 @@ struct lnet_event { > * The message type, to ensure a handler for LNET_EVENT_SEND can > * distinguish between LNET_MSG_GET and LNET_MSG_PUT. > */ > - __u32 msg_type; > + __u32 msg_type; > /** > * Indicates the completion status of the operation. It's 0 for > * successful operations, otherwise it's an error code. > diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h > index a6eebee1a69c..27fcd91931a6 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h > +++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnetst.h > @@ -58,7 +58,7 @@ > */ > #define LSTIO_GROUP_DEL 0xC13 /* delete group */ > #define LSTIO_NODES_ADD 0xC14 /* add nodes to specified group */ > -#define LSTIO_GROUP_UPDATE 0xC15 /* update group */ > +#define LSTIO_GROUP_UPDATE 0xC15 /* update group */ > #define LSTIO_BATCH_ADD 0xC20 /* add batch */ > #define LSTIO_BATCH_START 0xC21 /* start batch */ > #define LSTIO_BATCH_STOP 0xC22 /* stop batch */ > @@ -100,9 +100,9 @@ struct lstcon_ndlist_ent { > }; /*** node_list entry, for list_batch command */ > > struct lstcon_test_ent { > - int tse_type; /* test type */ > - int tse_loop; /* loop count */ > - int tse_concur; /* concurrency of test */ > + int tse_type; /* test type */ > + int tse_loop; /* loop count */ > + int tse_concur; /* concurrency of test */ > }; /* test summary entry, for > * list_batch command > */ > @@ -520,9 +520,9 @@ enum lst_brw_flags { > > struct lst_test_bulk_param { > int blk_opc; /* bulk operation code */ > - int blk_size; /* size (bytes) */ > - int blk_time; /* time of running the test*/ > - int blk_flags; /* reserved flags */ > + int blk_size; /* size (bytes) */ > + int blk_time; /* time of running the test*/ > + int blk_flags; /* reserved flags */ > int blk_cli_off; /* bulk offset on client */ > int blk_srv_off; /* reserved: bulk offset on server */ > }; > diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h > index 3c5901d81d52..6c49d59f4f85 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h > +++ b/drivers/staging/lustre/include/uapi/linux/lnet/nidstr.h > @@ -44,7 +44,7 @@ enum { > /*GMLND = 3, removed v2_0_0-rc1a-16-gc660aac */ > /*PTLLND = 4, removed v2_7_50 */ > O2IBLND = 5, > - /*CIBLND = 6, removed v2_0_0-rc1a-175-gd2b8a0e */ > + /*CIBLND = 6, removed v2_0_0-rc1a-175-gd2b8a0e */ > /*OPENIBLND = 7, removed v2_0_0-rc1a-175-gd2b8a0e */ > /*IIBLND = 8, removed v2_0_0-rc1a-175-gd2b8a0e */ > LOLND = 9, > @@ -57,8 +57,8 @@ enum { > > struct list_head; > > -#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ > -#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ > +#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */ > +#define LNET_NIDSTR_SIZE 32 /* size of each one (see below for usage) */ > > /* support decl needed by both kernel and user space */ > char *libcfs_next_nidstring(void); > diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h > index d24a93e57ed7..7ecb6f6354cc 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h > +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_fiemap.h > @@ -49,7 +49,7 @@ > static inline size_t fiemap_count_to_size(size_t extent_count) > { > return sizeof(struct fiemap) + extent_count * > - sizeof(struct fiemap_extent); > + sizeof(struct fiemap_extent); > } > > static inline unsigned int fiemap_size_to_count(size_t array_size) > diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h > index bffe62e87e00..62b9a3301c4d 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h > +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h > @@ -443,14 +443,14 @@ struct luda_type { > }; > > #ifndef IFSHIFT > -#define IFSHIFT 12 > +#define IFSHIFT 12 > #endif > > #ifndef IFTODT > -#define IFTODT(type) (((type) & S_IFMT) >> IFSHIFT) > +#define IFTODT(type) (((type) & S_IFMT) >> IFSHIFT) > #endif > #ifndef DTTOIF > -#define DTTOIF(dirtype) ((dirtype) << IFSHIFT) > +#define DTTOIF(dirtype) ((dirtype) << IFSHIFT) > #endif > > struct lu_dirpage { > @@ -551,8 +551,8 @@ static inline void lustre_handle_copy(struct lustre_handle *tgt, > } > > /* flags for lm_flags */ > -#define MSGHDR_AT_SUPPORT 0x1 > -#define MSGHDR_CKSUM_INCOMPAT18 0x2 > +#define MSGHDR_AT_SUPPORT 0x1 > +#define MSGHDR_CKSUM_INCOMPAT18 0x2 > > #define lustre_msg lustre_msg_v2 > /* we depend on this structure to be 8-byte aligned */ > @@ -570,7 +570,7 @@ struct lustre_msg_v2 { > }; > > /* without gss, ptlrpc_body is put at the first buffer. */ > -#define PTLRPC_NUM_VERSIONS 4 > +#define PTLRPC_NUM_VERSIONS 4 > > struct ptlrpc_body_v3 { > struct lustre_handle pb_handle; > @@ -578,8 +578,8 @@ struct ptlrpc_body_v3 { > __u32 pb_version; > __u32 pb_opc; > __u32 pb_status; > - __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ > - __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ > + __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ > + __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ > __u16 pb_padding0; > __u32 pb_padding1; > __u64 pb_last_committed; > @@ -587,13 +587,13 @@ struct ptlrpc_body_v3 { > __u32 pb_flags; > __u32 pb_op_flags; > __u32 pb_conn_cnt; > - __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ > - __u32 pb_service_time; /* for rep, actual service time */ > + __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ > + __u32 pb_service_time; /* for rep, actual service time */ > __u32 pb_limit; > __u64 pb_slv; > /* VBR: pre-versions */ > __u64 pb_pre_versions[PTLRPC_NUM_VERSIONS]; > - __u64 pb_mbits; /**< match bits for bulk request */ > + __u64 pb_mbits; /**< match bits for bulk request */ > /* padding for future needs */ > __u64 pb_padding64_0; > __u64 pb_padding64_1; > @@ -601,7 +601,7 @@ struct ptlrpc_body_v3 { > char pb_jobid[LUSTRE_JOBID_SIZE]; > }; > > -#define ptlrpc_body ptlrpc_body_v3 > +#define ptlrpc_body ptlrpc_body_v3 > > struct ptlrpc_body_v2 { > struct lustre_handle pb_handle; > @@ -609,8 +609,8 @@ struct ptlrpc_body_v2 { > __u32 pb_version; > __u32 pb_opc; > __u32 pb_status; > - __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ > - __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ > + __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */ > + __u16 pb_tag; /* virtual slot idx for multiple modifying RPCs */ > __u16 pb_padding0; > __u32 pb_padding1; > __u64 pb_last_committed; > @@ -618,10 +618,10 @@ struct ptlrpc_body_v2 { > __u32 pb_flags; > __u32 pb_op_flags; > __u32 pb_conn_cnt; > - __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ > - __u32 pb_service_time; /* for rep, actual service time, also used for > - * net_latency of req > - */ > + __u32 pb_timeout; /* for req, the deadline, for rep, the service est */ > + __u32 pb_service_time; /* for rep, actual service time, also used for > + * net_latency of req > + */ > __u32 pb_limit; > __u64 pb_slv; > /* VBR: pre-versions */ > @@ -881,66 +881,66 @@ enum cksum_type { > > /* opcodes */ > enum ost_cmd { > - OST_REPLY = 0, /* reply ? */ > - OST_GETATTR = 1, > - OST_SETATTR = 2, > - OST_READ = 3, > - OST_WRITE = 4, > - OST_CREATE = 5, > - OST_DESTROY = 6, > - OST_GET_INFO = 7, > - OST_CONNECT = 8, > - OST_DISCONNECT = 9, > - OST_PUNCH = 10, > - OST_OPEN = 11, > - OST_CLOSE = 12, > - OST_STATFS = 13, > - OST_SYNC = 16, > - OST_SET_INFO = 17, > - OST_QUOTACHECK = 18, /* not used since 2.4 */ > - OST_QUOTACTL = 19, > + OST_REPLY = 0, /* reply ? */ > + OST_GETATTR = 1, > + OST_SETATTR = 2, > + OST_READ = 3, > + OST_WRITE = 4, > + OST_CREATE = 5, > + OST_DESTROY = 6, > + OST_GET_INFO = 7, > + OST_CONNECT = 8, > + OST_DISCONNECT = 9, > + OST_PUNCH = 10, > + OST_OPEN = 11, > + OST_CLOSE = 12, > + OST_STATFS = 13, > + OST_SYNC = 16, > + OST_SET_INFO = 17, > + OST_QUOTACHECK = 18, /* not used since 2.4 */ > + OST_QUOTACTL = 19, > OST_QUOTA_ADJUST_QUNIT = 20, /* not used since 2.4 */ > - OST_LADVISE = 21, > + OST_LADVISE = 21, > OST_LAST_OPC /* must be < 33 to avoid MDS_GETATTR */ > }; > #define OST_FIRST_OPC OST_REPLY > > enum obdo_flags { > - OBD_FL_INLINEDATA = 0x00000001, > - OBD_FL_OBDMDEXISTS = 0x00000002, > - OBD_FL_DELORPHAN = 0x00000004, /* if set in o_flags delete orphans */ > - OBD_FL_NORPC = 0x00000008, /* set in o_flags do in OSC not OST */ > - OBD_FL_IDONLY = 0x00000010, /* set in o_flags only adjust obj id*/ > - OBD_FL_RECREATE_OBJS = 0x00000020, /* recreate missing obj */ > - OBD_FL_DEBUG_CHECK = 0x00000040, /* echo client/server debug check */ > - OBD_FL_NO_PRJQUOTA = 0x00000080, /* the object's project is over > - * quota > - */ > - OBD_FL_NO_USRQUOTA = 0x00000100, /* the object's owner is over quota */ > - OBD_FL_NO_GRPQUOTA = 0x00000200, /* the object's group is over quota */ > - OBD_FL_CREATE_CROW = 0x00000400, /* object should be create on write */ > - OBD_FL_SRVLOCK = 0x00000800, /* delegate DLM locking to server */ > - OBD_FL_CKSUM_CRC32 = 0x00001000, /* CRC32 checksum type */ > - OBD_FL_CKSUM_ADLER = 0x00002000, /* ADLER checksum type */ > - OBD_FL_CKSUM_CRC32C = 0x00004000, /* CRC32C checksum type */ > - OBD_FL_CKSUM_RSVD2 = 0x00008000, /* for future cksum types */ > - OBD_FL_CKSUM_RSVD3 = 0x00010000, /* for future cksum types */ > - OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */ > - OBD_FL_MMAP = 0x00040000, /* object is mmapped on the client. > - * XXX: obsoleted - reserved for old > - * clients prior than 2.2 > - */ > - OBD_FL_RECOV_RESEND = 0x00080000, /* recoverable resent */ > - OBD_FL_NOSPC_BLK = 0x00100000, /* no more block space on OST */ > - OBD_FL_FLUSH = 0x00200000, /* flush pages on the OST */ > - OBD_FL_SHORT_IO = 0x00400000, /* short io request */ > + OBD_FL_INLINEDATA = 0x00000001, > + OBD_FL_OBDMDEXISTS = 0x00000002, > + OBD_FL_DELORPHAN = 0x00000004, /* if set in o_flags delete orphans */ > + OBD_FL_NORPC = 0x00000008, /* set in o_flags do in OSC not OST */ > + OBD_FL_IDONLY = 0x00000010, /* set in o_flags only adjust obj id*/ > + OBD_FL_RECREATE_OBJS = 0x00000020, /* recreate missing obj */ > + OBD_FL_DEBUG_CHECK = 0x00000040, /* echo client/server debug check */ > + OBD_FL_NO_PRJQUOTA = 0x00000080, /* the object's project is over > + * quota > + */ > + OBD_FL_NO_USRQUOTA = 0x00000100, /* the object's owner is over quota */ > + OBD_FL_NO_GRPQUOTA = 0x00000200, /* the object's group is over quota */ > + OBD_FL_CREATE_CROW = 0x00000400, /* object should be create on write */ > + OBD_FL_SRVLOCK = 0x00000800, /* delegate DLM locking to server */ > + OBD_FL_CKSUM_CRC32 = 0x00001000, /* CRC32 checksum type */ > + OBD_FL_CKSUM_ADLER = 0x00002000, /* ADLER checksum type */ > + OBD_FL_CKSUM_CRC32C = 0x00004000, /* CRC32C checksum type */ > + OBD_FL_CKSUM_RSVD2 = 0x00008000, /* for future cksum types */ > + OBD_FL_CKSUM_RSVD3 = 0x00010000, /* for future cksum types */ > + OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */ > + OBD_FL_MMAP = 0x00040000, /* object is mmapped on the client. > + * XXX: obsoleted - reserved for old > + * clients prior than 2.2 > + */ > + OBD_FL_RECOV_RESEND = 0x00080000, /* recoverable resent */ > + OBD_FL_NOSPC_BLK = 0x00100000, /* no more block space on OST */ > + OBD_FL_FLUSH = 0x00200000, /* flush pages on the OST */ > + OBD_FL_SHORT_IO = 0x00400000, /* short io request */ > /* OBD_FL_LOCAL_MASK = 0xF0000000, was local-only flags until 2.10 */ > > /* Note that while these checksum values are currently separate bits, > * in 2.x we can actually allow all values from 1-31 if we wanted. > */ > - OBD_FL_CKSUM_ALL = OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER | > - OBD_FL_CKSUM_CRC32C, > + OBD_FL_CKSUM_ALL = (OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER | > + OBD_FL_CKSUM_CRC32C), > }; > > /* > @@ -1233,9 +1233,9 @@ struct niobuf_remote { > */ > #define OST_LVB_ERR_INIT 0xffbadbad80000000ULL > #define OST_LVB_ERR_MASK 0xffbadbad00000000ULL > -#define OST_LVB_IS_ERR(blocks) \ > +#define OST_LVB_IS_ERR(blocks) \ > ((blocks & OST_LVB_ERR_MASK) == OST_LVB_ERR_MASK) > -#define OST_LVB_SET_ERR(blocks, rc) \ > +#define OST_LVB_SET_ERR(blocks, rc) \ > do { blocks = OST_LVB_ERR_INIT + rc; } while (0) > #define OST_LVB_GET_ERR(blocks) (int)(blocks - OST_LVB_ERR_INIT) > > @@ -1316,9 +1316,9 @@ struct ldlm_gl_lquota_desc { > /* LVB used with quota (global and per-ID) locks */ > struct lquota_lvb { > __u64 lvb_flags; /* see LQUOTA_FL* above */ > - __u64 lvb_id_may_rel; /* space that might be released later */ > - __u64 lvb_id_rel; /* space released by the slave for this ID */ > - __u64 lvb_id_qunit; /* current qunit value */ > + __u64 lvb_id_may_rel; /* space that might be released later */ > + __u64 lvb_id_rel; /* space released by the slave for this ID */ > + __u64 lvb_id_qunit; /* current qunit value */ > __u64 lvb_pad1; > }; > > @@ -1488,17 +1488,17 @@ static inline int ll_inode_to_ext_flags(int iflags) > > static inline int ll_xflags_to_inode_flags(int xflags) > { > - return ((xflags & FS_XFLAG_SYNC) ? S_SYNC : 0) | > - ((xflags & FS_XFLAG_NOATIME) ? S_NOATIME : 0) | > - ((xflags & FS_XFLAG_APPEND) ? S_APPEND : 0) | > + return ((xflags & FS_XFLAG_SYNC) ? S_SYNC : 0) | > + ((xflags & FS_XFLAG_NOATIME) ? S_NOATIME : 0) | > + ((xflags & FS_XFLAG_APPEND) ? S_APPEND : 0) | > ((xflags & FS_XFLAG_IMMUTABLE) ? S_IMMUTABLE : 0); > } > > static inline int ll_inode_flags_to_xflags(int flags) > { > - return ((flags & S_SYNC) ? FS_XFLAG_SYNC : 0) | > - ((flags & S_NOATIME) ? FS_XFLAG_NOATIME : 0) | > - ((flags & S_APPEND) ? FS_XFLAG_APPEND : 0) | > + return ((flags & S_SYNC) ? FS_XFLAG_SYNC : 0) | > + ((flags & S_NOATIME) ? FS_XFLAG_NOATIME : 0) | > + ((flags & S_APPEND) ? FS_XFLAG_APPEND : 0) | > ((flags & S_IMMUTABLE) ? FS_XFLAG_IMMUTABLE : 0); > } > > @@ -1583,7 +1583,7 @@ struct mdt_rec_setattr { > __s64 sa_ctime; > __u32 sa_attr_flags; > __u32 sa_mode; > - __u32 sa_bias; /* some operation flags */ > + __u32 sa_bias; /* some operation flags */ > __u32 sa_projid; > __u32 sa_padding_4; > __u32 sa_padding_5; > @@ -1698,17 +1698,17 @@ struct mdt_rec_create { > __s64 cr_time; > __u64 cr_rdev; > __u64 cr_ioepoch; > - __u64 cr_padding_1; /* rr_blocks */ > + __u64 cr_padding_1; /* rr_blocks */ > __u32 cr_mode; > __u32 cr_bias; > /* use of helpers set/get_mrc_cr_flags() is needed to access > * 64 bits cr_flags [cr_flags_l, cr_flags_h], this is done to > * extend cr_flags size without breaking 1.8 compat > */ > - __u32 cr_flags_l; /* for use with open, low 32 bits */ > - __u32 cr_flags_h; /* for use with open, high 32 bits */ > - __u32 cr_umask; /* umask for create */ > - __u32 cr_padding_4; /* rr_padding_4 */ > + __u32 cr_flags_l; /* for use with open, low 32 bits */ > + __u32 cr_flags_h; /* for use with open, high 32 bits */ > + __u32 cr_umask; /* umask for create */ > + __u32 cr_padding_4; /* rr_padding_4 */ > }; > > /* instance of mdt_reint_rec */ > @@ -1726,16 +1726,16 @@ struct mdt_rec_link { > struct lu_fid lk_fid1; > struct lu_fid lk_fid2; > __s64 lk_time; > - __u64 lk_padding_1; /* rr_atime */ > - __u64 lk_padding_2; /* rr_ctime */ > - __u64 lk_padding_3; /* rr_size */ > - __u64 lk_padding_4; /* rr_blocks */ > + __u64 lk_padding_1; /* rr_atime */ > + __u64 lk_padding_2; /* rr_ctime */ > + __u64 lk_padding_3; /* rr_size */ > + __u64 lk_padding_4; /* rr_blocks */ > __u32 lk_bias; > - __u32 lk_padding_5; /* rr_mode */ > - __u32 lk_padding_6; /* rr_flags */ > - __u32 lk_padding_7; /* rr_padding_2 */ > - __u32 lk_padding_8; /* rr_padding_3 */ > - __u32 lk_padding_9; /* rr_padding_4 */ > + __u32 lk_padding_5; /* rr_mode */ > + __u32 lk_padding_6; /* rr_flags */ > + __u32 lk_padding_7; /* rr_padding_2 */ > + __u32 lk_padding_8; /* rr_padding_3 */ > + __u32 lk_padding_9; /* rr_padding_4 */ > }; > > /* instance of mdt_reint_rec */ > @@ -1753,16 +1753,16 @@ struct mdt_rec_unlink { > struct lu_fid ul_fid1; > struct lu_fid ul_fid2; > __s64 ul_time; > - __u64 ul_padding_2; /* rr_atime */ > - __u64 ul_padding_3; /* rr_ctime */ > - __u64 ul_padding_4; /* rr_size */ > - __u64 ul_padding_5; /* rr_blocks */ > + __u64 ul_padding_2; /* rr_atime */ > + __u64 ul_padding_3; /* rr_ctime */ > + __u64 ul_padding_4; /* rr_size */ > + __u64 ul_padding_5; /* rr_blocks */ > __u32 ul_bias; > __u32 ul_mode; > - __u32 ul_padding_6; /* rr_flags */ > - __u32 ul_padding_7; /* rr_padding_2 */ > - __u32 ul_padding_8; /* rr_padding_3 */ > - __u32 ul_padding_9; /* rr_padding_4 */ > + __u32 ul_padding_6; /* rr_flags */ > + __u32 ul_padding_7; /* rr_padding_2 */ > + __u32 ul_padding_8; /* rr_padding_3 */ > + __u32 ul_padding_9; /* rr_padding_4 */ > }; > > /* instance of mdt_reint_rec */ > @@ -1777,19 +1777,19 @@ struct mdt_rec_rename { > __u32 rn_suppgid1_h; > __u32 rn_suppgid2; > __u32 rn_suppgid2_h; > - struct lu_fid rn_fid1; > - struct lu_fid rn_fid2; > + struct lu_fid rn_fid1; > + struct lu_fid rn_fid2; > __s64 rn_time; > - __u64 rn_padding_1; /* rr_atime */ > - __u64 rn_padding_2; /* rr_ctime */ > - __u64 rn_padding_3; /* rr_size */ > - __u64 rn_padding_4; /* rr_blocks */ > + __u64 rn_padding_1; /* rr_atime */ > + __u64 rn_padding_2; /* rr_ctime */ > + __u64 rn_padding_3; /* rr_size */ > + __u64 rn_padding_4; /* rr_blocks */ > __u32 rn_bias; /* some operation flags */ > __u32 rn_mode; /* cross-ref rename has mode */ > - __u32 rn_padding_5; /* rr_flags */ > - __u32 rn_padding_6; /* rr_padding_2 */ > - __u32 rn_padding_7; /* rr_padding_3 */ > - __u32 rn_padding_8; /* rr_padding_4 */ > + __u32 rn_padding_5; /* rr_flags */ > + __u32 rn_padding_6; /* rr_padding_2 */ > + __u32 rn_padding_7; /* rr_padding_3 */ > + __u32 rn_padding_8; /* rr_padding_4 */ > }; > > /* instance of mdt_reint_rec */ > @@ -1804,21 +1804,21 @@ struct mdt_rec_setxattr { > __u32 sx_suppgid1_h; > __u32 sx_suppgid2; > __u32 sx_suppgid2_h; > - struct lu_fid sx_fid; > - __u64 sx_padding_1; /* These three are rr_fid2 */ > + struct lu_fid sx_fid; > + __u64 sx_padding_1; /* These three are rr_fid2 */ > __u32 sx_padding_2; > __u32 sx_padding_3; > __u64 sx_valid; > __s64 sx_time; > - __u64 sx_padding_5; /* rr_ctime */ > - __u64 sx_padding_6; /* rr_size */ > - __u64 sx_padding_7; /* rr_blocks */ > + __u64 sx_padding_5; /* rr_ctime */ > + __u64 sx_padding_6; /* rr_size */ > + __u64 sx_padding_7; /* rr_blocks */ > __u32 sx_size; > __u32 sx_flags; > - __u32 sx_padding_8; /* rr_flags */ > - __u32 sx_padding_9; /* rr_padding_2 */ > - __u32 sx_padding_10; /* rr_padding_3 */ > - __u32 sx_padding_11; /* rr_padding_4 */ > + __u32 sx_padding_8; /* rr_flags */ > + __u32 sx_padding_9; /* rr_padding_2 */ > + __u32 sx_padding_10; /* rr_padding_3 */ > + __u32 sx_padding_11; /* rr_padding_4 */ > }; > > /* > @@ -1858,13 +1858,13 @@ struct mdt_rec_reint { > /* lmv structures */ > struct lmv_desc { > __u32 ld_tgt_count; /* how many MDS's */ > - __u32 ld_active_tgt_count; /* how many active */ > - __u32 ld_default_stripe_count; /* how many objects are used */ > - __u32 ld_pattern; /* default hash pattern */ > + __u32 ld_active_tgt_count; /* how many active */ > + __u32 ld_default_stripe_count; /* how many objects are used */ > + __u32 ld_pattern; /* default hash pattern */ > __u64 ld_default_hash_size; > __u64 ld_padding_1; /* also fix lustre_swab_lmv_desc */ > __u32 ld_padding_2; /* also fix lustre_swab_lmv_desc */ > - __u32 ld_qos_maxage; /* in second */ > + __u32 ld_qos_maxage; /* in second */ > __u32 ld_padding_3; /* also fix lustre_swab_lmv_desc */ > __u32 ld_padding_4; /* also fix lustre_swab_lmv_desc */ > struct obd_uuid ld_uuid; > @@ -2038,20 +2038,20 @@ struct lov_desc { > struct obd_uuid ld_uuid; > }; > > -#define ld_magic ld_active_tgt_count /* for swabbing from llogs */ > +#define ld_magic ld_active_tgt_count /* for swabbing from llogs */ > > /* > * LDLM requests: > */ > /* opcodes -- MUST be distinct from OST/MDS opcodes */ > enum ldlm_cmd { > - LDLM_ENQUEUE = 101, > - LDLM_CONVERT = 102, > - LDLM_CANCEL = 103, > + LDLM_ENQUEUE = 101, > + LDLM_CONVERT = 102, > + LDLM_CANCEL = 103, > LDLM_BL_CALLBACK = 104, > LDLM_CP_CALLBACK = 105, > LDLM_GL_CALLBACK = 106, > - LDLM_SET_INFO = 107, > + LDLM_SET_INFO = 107, > LDLM_LAST_OPC > }; > #define LDLM_FIRST_OPC LDLM_ENQUEUE > @@ -2067,25 +2067,25 @@ struct ldlm_res_id { > > /* lock types */ > enum ldlm_mode { > - LCK_MINMODE = 0, > - LCK_EX = 1, > - LCK_PW = 2, > - LCK_PR = 4, > - LCK_CW = 8, > - LCK_CR = 16, > - LCK_NL = 32, > - LCK_GROUP = 64, > - LCK_COS = 128, > + LCK_MINMODE = 0, > + LCK_EX = 1, > + LCK_PW = 2, > + LCK_PR = 4, > + LCK_CW = 8, > + LCK_CR = 16, > + LCK_NL = 32, > + LCK_GROUP = 64, > + LCK_COS = 128, > LCK_MAXMODE > }; > > -#define LCK_MODE_NUM 8 > +#define LCK_MODE_NUM 8 > > enum ldlm_type { > - LDLM_PLAIN = 10, > - LDLM_EXTENT = 11, > - LDLM_FLOCK = 12, > - LDLM_IBITS = 13, > + LDLM_PLAIN = 10, > + LDLM_EXTENT = 11, > + LDLM_FLOCK = 12, > + LDLM_IBITS = 13, > LDLM_MAX_TYPE > }; > > @@ -2150,7 +2150,7 @@ struct ldlm_intent { > > struct ldlm_resource_desc { > enum ldlm_type lr_type; > - __u32 lr_padding; /* also fix lustre_swab_ldlm_resource_desc */ > + __u32 lr_padding; /* also fix lustre_swab_ldlm_resource_desc */ > struct ldlm_res_id lr_name; > }; > > @@ -2173,7 +2173,7 @@ struct ldlm_request { > > struct ldlm_reply { > __u32 lock_flags; > - __u32 lock_padding; /* also fix lustre_swab_ldlm_reply */ > + __u32 lock_padding; /* also fix lustre_swab_ldlm_reply */ > struct ldlm_lock_desc lock_desc; > struct lustre_handle lock_handle; > __u64 lock_policy_res1; > @@ -2206,9 +2206,9 @@ struct mgs_send_param { > }; > > /* We pass this info to the MGS so it can write config logs */ > -#define MTI_NAME_MAXLEN 64 > +#define MTI_NAME_MAXLEN 64 > #define MTI_PARAM_MAXLEN 4096 > -#define MTI_NIDS_MAX 32 > +#define MTI_NIDS_MAX 32 > struct mgs_target_info { > __u32 mti_lustre_ver; > __u32 mti_stripe_index; > @@ -2695,8 +2695,8 @@ enum sec_cmd { > /* > * capa related definitions > */ > -#define CAPA_HMAC_MAX_LEN 64 > -#define CAPA_HMAC_KEY_MAX_LEN 56 > +#define CAPA_HMAC_MAX_LEN 64 > +#define CAPA_HMAC_KEY_MAX_LEN 56 > > /* NB take care when changing the sequence of elements this struct, > * because the offset info is used in find_capa() > @@ -2716,34 +2716,34 @@ struct lustre_capa { > > /** lustre_capa::lc_opc */ > enum { > - CAPA_OPC_BODY_WRITE = 1 << 0, /**< write object data */ > - CAPA_OPC_BODY_READ = 1 << 1, /**< read object data */ > - CAPA_OPC_INDEX_LOOKUP = 1 << 2, /**< lookup object fid */ > - CAPA_OPC_INDEX_INSERT = 1 << 3, /**< insert object fid */ > - CAPA_OPC_INDEX_DELETE = 1 << 4, /**< delete object fid */ > - CAPA_OPC_OSS_WRITE = 1 << 5, /**< write oss object data */ > - CAPA_OPC_OSS_READ = 1 << 6, /**< read oss object data */ > - CAPA_OPC_OSS_TRUNC = 1 << 7, /**< truncate oss object */ > - CAPA_OPC_OSS_DESTROY = 1 << 8, /**< destroy oss object */ > - CAPA_OPC_META_WRITE = 1 << 9, /**< write object meta data */ > - CAPA_OPC_META_READ = 1 << 10, /**< read object meta data */ > + CAPA_OPC_BODY_WRITE = 1 << 0, /**< write object data */ > + CAPA_OPC_BODY_READ = 1 << 1, /**< read object data */ > + CAPA_OPC_INDEX_LOOKUP = 1 << 2, /**< lookup object fid */ > + CAPA_OPC_INDEX_INSERT = 1 << 3, /**< insert object fid */ > + CAPA_OPC_INDEX_DELETE = 1 << 4, /**< delete object fid */ > + CAPA_OPC_OSS_WRITE = 1 << 5, /**< write oss object data */ > + CAPA_OPC_OSS_READ = 1 << 6, /**< read oss object data */ > + CAPA_OPC_OSS_TRUNC = 1 << 7, /**< truncate oss object */ > + CAPA_OPC_OSS_DESTROY = 1 << 8, /**< destroy oss object */ > + CAPA_OPC_META_WRITE = 1 << 9, /**< write object meta data */ > + CAPA_OPC_META_READ = 1 << 10, /**< read object meta data */ > }; > > #define CAPA_OPC_OSS_RW (CAPA_OPC_OSS_READ | CAPA_OPC_OSS_WRITE) > -#define CAPA_OPC_MDS_ONLY \ > +#define CAPA_OPC_MDS_ONLY \ > (CAPA_OPC_BODY_WRITE | CAPA_OPC_BODY_READ | CAPA_OPC_INDEX_LOOKUP | \ > CAPA_OPC_INDEX_INSERT | CAPA_OPC_INDEX_DELETE) > -#define CAPA_OPC_OSS_ONLY \ > - (CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC | \ > +#define CAPA_OPC_OSS_ONLY \ > + (CAPA_OPC_OSS_WRITE | CAPA_OPC_OSS_READ | CAPA_OPC_OSS_TRUNC | \ > CAPA_OPC_OSS_DESTROY) > #define CAPA_OPC_MDS_DEFAULT ~CAPA_OPC_OSS_ONLY > #define CAPA_OPC_OSS_DEFAULT ~(CAPA_OPC_MDS_ONLY | CAPA_OPC_OSS_ONLY) > > struct lustre_capa_key { > - __u64 lk_seq; /**< mds# */ > - __u32 lk_keyid; /**< key# */ > - __u32 lk_padding; > - __u8 lk_key[CAPA_HMAC_KEY_MAX_LEN]; /**< key */ > + __u64 lk_seq; /**< mds# */ > + __u32 lk_keyid; /**< key# */ > + __u32 lk_padding; > + __u8 lk_key[CAPA_HMAC_KEY_MAX_LEN]; /**< key */ > } __packed; > > /** The link ea holds 1 \a link_ea_entry for each hardlink */ > @@ -2751,7 +2751,7 @@ struct lustre_capa_key { > struct link_ea_header { > __u32 leh_magic; > __u32 leh_reccount; > - __u64 leh_len; /* total size */ > + __u64 leh_len; /* total size */ > __u32 leh_overflow_time; > __u32 leh_padding; > }; > @@ -2787,13 +2787,13 @@ struct getparent { > } __packed; > > enum { > - LAYOUT_INTENT_ACCESS = 0, /** generic access */ > - LAYOUT_INTENT_READ = 1, /** not used */ > - LAYOUT_INTENT_WRITE = 2, /** write file, for comp layout */ > - LAYOUT_INTENT_GLIMPSE = 3, /** not used */ > - LAYOUT_INTENT_TRUNC = 4, /** truncate file, for comp layout */ > - LAYOUT_INTENT_RELEASE = 5, /** reserved for HSM release */ > - LAYOUT_INTENT_RESTORE = 6 /** reserved for HSM restore */ > + LAYOUT_INTENT_ACCESS = 0, /** generic access */ > + LAYOUT_INTENT_READ = 1, /** not used */ > + LAYOUT_INTENT_WRITE = 2, /** write file, for comp layout */ > + LAYOUT_INTENT_GLIMPSE = 3, /** not used */ > + LAYOUT_INTENT_TRUNC = 4, /** truncate file, for comp layout */ > + LAYOUT_INTENT_RELEASE = 5, /** reserved for HSM release */ > + LAYOUT_INTENT_RESTORE = 6 /** reserved for HSM restore */ > }; > > /* enqueue layout lock with intent */ > diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h > index 178837cedd07..3b80b50543d8 100644 > --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h > +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_user.h > @@ -68,13 +68,13 @@ > * are co-existing. > */ > #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) > -typedef struct stat64 lstat_t; > -#define lstat_f lstat64 > +typedef struct stat64 lstat_t; > +#define lstat_f lstat64 > #define fstat_f fstat64 > #define fstatat_f fstatat64 > #else > -typedef struct stat lstat_t; > -#define lstat_f lstat > +typedef struct stat lstat_t; > +#define lstat_f lstat > #define fstat_f fstat > #define fstatat_f fstatat > #endif > @@ -87,47 +87,47 @@ typedef struct stat lstat_t; > #define LL_SUPER_MAGIC 0x0BD00BD0 > > #ifndef FSFILT_IOC_GETFLAGS > -#define FSFILT_IOC_GETFLAGS _IOR('f', 1, long) > -#define FSFILT_IOC_SETFLAGS _IOW('f', 2, long) > -#define FSFILT_IOC_GETVERSION _IOR('f', 3, long) > -#define FSFILT_IOC_SETVERSION _IOW('f', 4, long) > -#define FSFILT_IOC_GETVERSION_OLD _IOR('v', 1, long) > -#define FSFILT_IOC_SETVERSION_OLD _IOW('v', 2, long) > +#define FSFILT_IOC_GETFLAGS _IOR('f', 1, long) > +#define FSFILT_IOC_SETFLAGS _IOW('f', 2, long) > +#define FSFILT_IOC_GETVERSION _IOR('f', 3, long) > +#define FSFILT_IOC_SETVERSION _IOW('f', 4, long) > +#define FSFILT_IOC_GETVERSION_OLD _IOR('v', 1, long) > +#define FSFILT_IOC_SETVERSION_OLD _IOW('v', 2, long) > #endif > > /* FIEMAP flags supported by Lustre */ > #define LUSTRE_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_DEVICE_ORDER) > > enum obd_statfs_state { > - OS_STATE_DEGRADED = 0x00000001, /**< RAID degraded/rebuilding */ > - OS_STATE_READONLY = 0x00000002, /**< filesystem is read-only */ > - OS_STATE_RDONLY_1 = 0x00000004, /**< obsolete 1.6, was EROFS=30 */ > - OS_STATE_RDONLY_2 = 0x00000008, /**< obsolete 1.6, was EROFS=30 */ > - OS_STATE_RDONLY_3 = 0x00000010, /**< obsolete 1.6, was EROFS=30 */ > + OS_STATE_DEGRADED = 0x00000001, /**< RAID degraded/rebuilding */ > + OS_STATE_READONLY = 0x00000002, /**< filesystem is read-only */ > + OS_STATE_RDONLY_1 = 0x00000004, /**< obsolete 1.6, was EROFS=30 */ > + OS_STATE_RDONLY_2 = 0x00000008, /**< obsolete 1.6, was EROFS=30 */ > + OS_STATE_RDONLY_3 = 0x00000010, /**< obsolete 1.6, was EROFS=30 */ > }; > > struct obd_statfs { > - __u64 os_type; > - __u64 os_blocks; > - __u64 os_bfree; > - __u64 os_bavail; > - __u64 os_files; > - __u64 os_ffree; > - __u8 os_fsid[40]; > - __u32 os_bsize; > - __u32 os_namelen; > - __u64 os_maxbytes; > - __u32 os_state; /**< obd_statfs_state OS_STATE_* flag */ > - __u32 os_fprecreated; /* objs available now to the caller */ > - /* used in QoS code to find preferred OSTs */ > - __u32 os_spare2; > - __u32 os_spare3; > - __u32 os_spare4; > - __u32 os_spare5; > - __u32 os_spare6; > - __u32 os_spare7; > - __u32 os_spare8; > - __u32 os_spare9; > + __u64 os_type; > + __u64 os_blocks; > + __u64 os_bfree; > + __u64 os_bavail; > + __u64 os_files; > + __u64 os_ffree; > + __u8 os_fsid[40]; > + __u32 os_bsize; > + __u32 os_namelen; > + __u64 os_maxbytes; > + __u32 os_state; /**< obd_statfs_state OS_STATE_* flag */ > + __u32 os_fprecreated; /* objs available now to the caller > + * used in QoS code to find preferred OSTs */ > + __u32 os_spare2; > + __u32 os_spare3; > + __u32 os_spare4; > + __u32 os_spare5; > + __u32 os_spare6; > + __u32 os_spare7; > + __u32 os_spare8; > + __u32 os_spare9; > }; > > /** > @@ -137,12 +137,12 @@ struct obd_statfs { > * FIDs are never reused. > **/ > struct lu_fid { > - /** > - * FID sequence. Sequence is a unit of migration: all files (objects) > - * with FIDs from a given sequence are stored on the same server. > - * Lustre should support 2^64 objects, so even if each sequence > - * has only a single object we can still enumerate 2^64 objects. > - **/ > + /** > + * FID sequence. Sequence is a unit of migration: all files (objects) > + * with FIDs from a given sequence are stored on the same server. > + * Lustre should support 2^64 objects, so even if each sequence > + * has only a single object we can still enumerate 2^64 objects. > + **/ > __u64 f_seq; > /* FID number within sequence. */ > __u32 f_oid; > @@ -237,33 +237,33 @@ struct ll_futimes_3 { > * *INFO - set/get lov_user_mds_data > */ > /* lustre_ioctl.h 101-150 */ > -#define LL_IOC_GETFLAGS _IOR('f', 151, long) > -#define LL_IOC_SETFLAGS _IOW('f', 152, long) > -#define LL_IOC_CLRFLAGS _IOW('f', 153, long) > -#define LL_IOC_LOV_SETSTRIPE _IOW('f', 154, long) > +#define LL_IOC_GETFLAGS _IOR('f', 151, long) > +#define LL_IOC_SETFLAGS _IOW('f', 152, long) > +#define LL_IOC_CLRFLAGS _IOW('f', 153, long) > +#define LL_IOC_LOV_SETSTRIPE _IOW('f', 154, long) > #define LL_IOC_LOV_SETSTRIPE_NEW _IOWR('f', 154, struct lov_user_md) > -#define LL_IOC_LOV_GETSTRIPE _IOW('f', 155, long) > +#define LL_IOC_LOV_GETSTRIPE _IOW('f', 155, long) > #define LL_IOC_LOV_GETSTRIPE_NEW _IOR('f', 155, struct lov_user_md) > #define LL_IOC_LOV_SETEA _IOW('f', 156, long) > /* LL_IOC_RECREATE_OBJ 157 obsolete */ > /* LL_IOC_RECREATE_FID 158 obsolete */ > -#define LL_IOC_GROUP_LOCK _IOW('f', 158, long) > -#define LL_IOC_GROUP_UNLOCK _IOW('f', 159, long) > +#define LL_IOC_GROUP_LOCK _IOW('f', 158, long) > +#define LL_IOC_GROUP_UNLOCK _IOW('f', 159, long) > /* #define LL_IOC_QUOTACHECK 160 OBD_IOC_QUOTACHECK */ > /* #define LL_IOC_POLL_QUOTACHECK 161 OBD_IOC_POLL_QUOTACHECK */ > /* #define LL_IOC_QUOTACTL 162 OBD_IOC_QUOTACTL */ > -#define IOC_OBD_STATFS _IOWR('f', 164, struct obd_statfs *) > +#define IOC_OBD_STATFS _IOWR('f', 164, struct obd_statfs *) > /* IOC_LOV_GETINFO 165 obsolete */ > -#define LL_IOC_FLUSHCTX _IOW('f', 166, long) > +#define LL_IOC_FLUSHCTX _IOW('f', 166, long) > /* LL_IOC_RMTACL 167 obsolete */ > -#define LL_IOC_GETOBDCOUNT _IOR('f', 168, long) > -#define LL_IOC_LLOOP_ATTACH _IOWR('f', 169, long) > -#define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long) > -#define LL_IOC_LLOOP_INFO _IOWR('f', 171, struct lu_fid) > -#define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long) > -#define LL_IOC_PATH2FID _IOR('f', 173, long) > +#define LL_IOC_GETOBDCOUNT _IOR('f', 168, long) > +#define LL_IOC_LLOOP_ATTACH _IOWR('f', 169, long) > +#define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long) > +#define LL_IOC_LLOOP_INFO _IOWR('f', 171, struct lu_fid) > +#define LL_IOC_LLOOP_DETACH_BYDEV _IOWR('f', 172, long) > +#define LL_IOC_PATH2FID _IOR('f', 173, long) > #define LL_IOC_GET_CONNECT_FLAGS _IOWR('f', 174, __u64 *) > -#define LL_IOC_GET_MDTIDX _IOR('f', 175, int) > +#define LL_IOC_GET_MDTIDX _IOR('f', 175, int) > #define LL_IOC_FUTIMES_3 _IOWR('f', 176, struct ll_futimes_3) > > /* lustre_ioctl.h 177-210 */ > @@ -281,8 +281,8 @@ struct ll_futimes_3 { > struct hsm_current_action) > /* see for ioctl numbers 221-232 */ > > -#define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md) > -#define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md) > +#define LL_IOC_LMV_SETSTRIPE _IOWR('f', 240, struct lmv_user_md) > +#define LL_IOC_LMV_GETSTRIPE _IOWR('f', 241, struct lmv_user_md) > #define LL_IOC_SET_LEASE _IOWR('f', 243, long) > #define LL_IOC_GET_LEASE _IO('f', 244) > #define LL_IOC_HSM_IMPORT _IOWR('f', 245, struct hsm_user_import) > @@ -299,15 +299,15 @@ enum ll_lease_type { > LL_LEASE_UNLCK = 0x4, > }; > > -#define LL_STATFS_LMV 1 > -#define LL_STATFS_LOV 2 > +#define LL_STATFS_LMV 1 > +#define LL_STATFS_LOV 2 > #define LL_STATFS_NODELAY 4 > > -#define IOC_MDC_TYPE 'i' > -#define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *) > -#define IOC_MDC_GETFILESTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *) > -#define IOC_MDC_GETFILEINFO _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *) > -#define LL_IOC_MDC_GETINFO _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *) > +#define IOC_MDC_TYPE 'i' > +#define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *) > +#define IOC_MDC_GETFILESTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *) > +#define IOC_MDC_GETFILEINFO _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *) > +#define LL_IOC_MDC_GETINFO _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *) > > #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */ > > @@ -318,12 +318,12 @@ enum ll_lease_type { > */ > #define O_LOV_DELAY_CREATE (O_NOCTTY | FASYNC) > > -#define LL_FILE_IGNORE_LOCK 0x00000001 > -#define LL_FILE_GROUP_LOCKED 0x00000002 > +#define LL_FILE_IGNORE_LOCK 0x00000001 > +#define LL_FILE_GROUP_LOCKED 0x00000002 > #define LL_FILE_READAHEA 0x00000004 > #define LL_FILE_LOCKED_DIRECTIO 0x00000008 /* client-side locks with dio */ > -#define LL_FILE_LOCKLESS_IO 0x00000010 /* server-side locks with cio */ > -#define LL_FILE_RMTACL 0x00000020 > +#define LL_FILE_LOCKLESS_IO 0x00000010 /* server-side locks with cio */ > +#define LL_FILE_RMTACL 0x00000020 > > #define LOV_USER_MAGIC_V1 0x0BD10BD0 > #define LOV_USER_MAGIC LOV_USER_MAGIC_V1 > @@ -333,7 +333,7 @@ enum ll_lease_type { > #define LOV_USER_MAGIC_SPECIFIC 0x0BD50BD0 /* for specific OSTs */ > #define LOV_USER_MAGIC_COMP_V1 0x0BD60BD0 > > -#define LMV_USER_MAGIC 0x0CD30CD0 /*default lmv magic*/ > +#define LMV_USER_MAGIC 0x0CD30CD0 /*default lmv magic*/ > > #define LOV_PATTERN_RAID0 0x001 > #define LOV_PATTERN_RAID1 0x002 > @@ -347,8 +347,8 @@ enum ll_lease_type { > #define LOV_MAXPOOLNAME 15 > #define LOV_POOLNAMEF "%.15s" > > -#define LOV_MIN_STRIPE_BITS 16 /* maximum PAGE_SIZE (ia64), power of 2 */ > -#define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS) > +#define LOV_MIN_STRIPE_BITS 16 /* maximum PAGE_SIZE (ia64), power of 2 */ > +#define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS) > #define LOV_MAX_STRIPE_COUNT_OLD 160 > /* This calculation is crafted so that input of 4096 will result in 160 > * which in turn is equal to old maximal stripe count. > @@ -360,49 +360,49 @@ enum ll_lease_type { > * > * (max buffer size - lov+rpc header) / sizeof(struct lov_ost_data_v1) > */ > -#define LOV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */ > -#define LOV_ALL_STRIPES 0xffff /* only valid for directories */ > +#define LOV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */ > +#define LOV_ALL_STRIPES 0xffff /* only valid for directories */ > #define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */ > > #define XATTR_LUSTRE_PREFIX "lustre." > #define XATTR_LUSTRE_LOV "lustre.lov" > > #define lov_user_ost_data lov_user_ost_data_v1 > -struct lov_user_ost_data_v1 { /* per-stripe data structure */ > - struct ost_id l_ost_oi; /* OST object ID */ > - __u32 l_ost_gen; /* generation of this OST index */ > - __u32 l_ost_idx; /* OST index in LOV */ > +struct lov_user_ost_data_v1 { /* per-stripe data structure */ > + struct ost_id l_ost_oi; /* OST object ID */ > + __u32 l_ost_gen; /* generation of this OST index */ > + __u32 l_ost_idx; /* OST index in LOV */ > } __packed; > > #define lov_user_md lov_user_md_v1 > -struct lov_user_md_v1 { /* LOV EA user data (host-endian) */ > - __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V1 */ > +struct lov_user_md_v1 { /* LOV EA user data (host-endian) */ > + __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V1 */ > __u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */ > - struct ost_id lmm_oi; /* LOV object ID */ > - __u32 lmm_stripe_size; /* size of stripe in bytes */ > - __u16 lmm_stripe_count; /* num stripes in use for this object */ > + struct ost_id lmm_oi; /* LOV object ID */ > + __u32 lmm_stripe_size; /* size of stripe in bytes */ > + __u16 lmm_stripe_count; /* num stripes in use for this object */ > union { > __u16 lmm_stripe_offset; /* starting stripe offset in > * lmm_objects, use when writing > */ > - __u16 lmm_layout_gen; /* layout generation number > + __u16 lmm_layout_gen; /* layout generation number > * used when reading > */ > }; > struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */ > } __attribute__((packed, __may_alias__)); > > -struct lov_user_md_v3 { /* LOV EA user data (host-endian) */ > - __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V3 */ > +struct lov_user_md_v3 { /* LOV EA user data (host-endian) */ > + __u32 lmm_magic; /* magic number = LOV_USER_MAGIC_V3 */ > __u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */ > - struct ost_id lmm_oi; /* LOV object ID */ > - __u32 lmm_stripe_size; /* size of stripe in bytes */ > - __u16 lmm_stripe_count; /* num stripes in use for this object */ > + struct ost_id lmm_oi; /* LOV object ID */ > + __u32 lmm_stripe_size; /* size of stripe in bytes */ > + __u16 lmm_stripe_count; /* num stripes in use for this object */ > union { > __u16 lmm_stripe_offset; /* starting stripe offset in > * lmm_objects, use when writing > */ > - __u16 lmm_layout_gen; /* layout generation number > + __u16 lmm_layout_gen; /* layout generation number > * used when reading > */ > }; > @@ -425,9 +425,9 @@ static inline bool lu_extent_is_overlapped(struct lu_extent *e1, > } > > enum lov_comp_md_entry_flags { > - LCME_FL_PRIMARY = 0x00000001, /* Not used */ > - LCME_FL_STALE = 0x00000002, /* Not used */ > - LCME_FL_OFFLINE = 0x00000004, /* Not used */ > + LCME_FL_PRIMARY = 0x00000001, /* Not used */ > + LCME_FL_STALE = 0x00000002, /* Not used */ > + LCME_FL_OFFLINE = 0x00000004, /* Not used */ > LCME_FL_PREFERRED = 0x00000008, /* Not used */ > LCME_FL_INIT = 0x00000010, /* instantiated */ > LCME_FL_NEG = 0x80000000, /* used to indicate a negative > @@ -480,7 +480,7 @@ static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic) > return sizeof(struct lov_user_md_v1) + > stripes * sizeof(struct lov_user_ost_data_v1); > return sizeof(struct lov_user_md_v3) + > - stripes * sizeof(struct lov_user_ost_data_v1); > + stripes * sizeof(struct lov_user_ost_data_v1); > } > > /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to > @@ -524,16 +524,16 @@ enum lmv_hash_type { > #define LMV_MAX_STRIPE_COUNT 2000 /* ((12 * 4096 - 256) / 24) */ > #define lmv_user_md lmv_user_md_v1 > struct lmv_user_md_v1 { > - __u32 lum_magic; /* must be the first field */ > - __u32 lum_stripe_count; /* dirstripe count */ > - __u32 lum_stripe_offset; /* MDT idx for default dirstripe */ > - __u32 lum_hash_type; /* Dir stripe policy */ > - __u32 lum_type; /* LMV type: default or normal */ > + __u32 lum_magic; /* must be the first field */ > + __u32 lum_stripe_count; /* dirstripe count */ > + __u32 lum_stripe_offset; /* MDT idx for default dirstripe */ > + __u32 lum_hash_type; /* Dir stripe policy */ > + __u32 lum_type; /* LMV type: default or normal */ > __u32 lum_padding1; > __u32 lum_padding2; > __u32 lum_padding3; > char lum_pool_name[LOV_MAXPOOLNAME + 1]; > - struct lmv_user_mds_data lum_objects[0]; > + struct lmv_user_mds_data lum_objects[0]; > } __packed; > > static inline int lmv_user_md_size(int stripes, int lmm_magic) > @@ -548,11 +548,11 @@ struct ll_recreate_obj { > }; > > struct ll_fid { > - __u64 id; /* holds object id */ > - __u32 generation; /* holds object generation */ > - __u32 f_type; /* holds object type or stripe idx when passing it to > - * OST for saving into EA. > - */ > + __u64 id; /* holds object id */ > + __u32 generation; /* holds object generation */ > + __u32 f_type; /* holds object type or stripe idx when > + * passing it to OST for saving into EA. > + */ > }; > > #define UUID_MAX 40 > @@ -631,22 +631,22 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) > > /********* Quotas **********/ > > -#define Q_QUOTACHECK 0x800100 /* deprecated as of 2.4 */ > -#define Q_INITQUOTA 0x800101 /* deprecated as of 2.4 */ > -#define Q_GETOINFO 0x800102 /* get obd quota info */ > -#define Q_GETOQUOTA 0x800103 /* get obd quotas */ > -#define Q_FINVALIDATE 0x800104 /* deprecated as of 2.4 */ > +#define Q_QUOTACHECK 0x800100 /* deprecated as of 2.4 */ > +#define Q_INITQUOTA 0x800101 /* deprecated as of 2.4 */ > +#define Q_GETOINFO 0x800102 /* get obd quota info */ > +#define Q_GETOQUOTA 0x800103 /* get obd quotas */ > +#define Q_FINVALIDATE 0x800104 /* deprecated as of 2.4 */ > > /* these must be explicitly translated into linux Q_* in ll_dir_ioctl */ > -#define LUSTRE_Q_QUOTAON 0x800002 /* deprecated as of 2.4 */ > -#define LUSTRE_Q_QUOTAOFF 0x800003 /* deprecated as of 2.4 */ > -#define LUSTRE_Q_GETINFO 0x800005 /* get information about quota files */ > -#define LUSTRE_Q_SETINFO 0x800006 /* set information about quota files */ > -#define LUSTRE_Q_GETQUOTA 0x800007 /* get user quota structure */ > -#define LUSTRE_Q_SETQUOTA 0x800008 /* set user quota structure */ > +#define LUSTRE_Q_QUOTAON 0x800002 /* deprecated as of 2.4 */ > +#define LUSTRE_Q_QUOTAOFF 0x800003 /* deprecated as of 2.4 */ > +#define LUSTRE_Q_GETINFO 0x800005 /* get information about quota files */ > +#define LUSTRE_Q_SETINFO 0x800006 /* set information about quota files */ > +#define LUSTRE_Q_GETQUOTA 0x800007 /* get user quota structure */ > +#define LUSTRE_Q_SETQUOTA 0x800008 /* set user quota structure */ > /* lustre-specific control commands */ > -#define LUSTRE_Q_INVALIDATE 0x80000b /* deprecated as of 2.4 */ > -#define LUSTRE_Q_FINVALIDATE 0x80000c /* deprecated as of 2.4 */ > +#define LUSTRE_Q_INVALIDATE 0x80000b /* deprecated as of 2.4 */ > +#define LUSTRE_Q_FINVALIDATE 0x80000c /* deprecated as of 2.4 */ > > #define ALLQUOTA 255 /* set all quota */ > > @@ -666,7 +666,7 @@ static inline char *qtype_name(int qtype) > #define IDENTITY_DOWNCALL_MAGIC 0x6d6dd629 > > /* permission */ > -#define N_PERMS_MAX 64 > +#define N_PERMS_MAX 64 > > struct perm_downcall_data { > __u64 pdd_nid; > @@ -720,23 +720,23 @@ struct obd_dqblk { > }; > > enum { > - QC_GENERAL = 0, > - QC_MDTIDX = 1, > - QC_OSTIDX = 2, > - QC_UUID = 3 > + QC_GENERAL = 0, > + QC_MDTIDX = 1, > + QC_OSTIDX = 2, > + QC_UUID = 3 > }; > > struct if_quotactl { > - __u32 qc_cmd; > - __u32 qc_type; > - __u32 qc_id; > - __u32 qc_stat; > - __u32 qc_valid; > - __u32 qc_idx; > - struct obd_dqinfo qc_dqinfo; > - struct obd_dqblk qc_dqblk; > - char obd_type[16]; > - struct obd_uuid obd_uuid; > + __u32 qc_cmd; > + __u32 qc_type; > + __u32 qc_id; > + __u32 qc_stat; > + __u32 qc_valid; > + __u32 qc_idx; > + struct obd_dqinfo qc_dqinfo; > + struct obd_dqblk qc_dqblk; > + char obd_type[16]; > + struct obd_uuid obd_uuid; > }; > > /* swap layout flags */ > @@ -759,26 +759,26 @@ struct lustre_swap_layouts { > /********* Changelogs **********/ > /** Changelog record types */ > enum changelog_rec_type { > - CL_MARK = 0, > - CL_CREATE = 1, /* namespace */ > - CL_MKDIR = 2, /* namespace */ > - CL_HARDLINK = 3, /* namespace */ > - CL_SOFTLINK = 4, /* namespace */ > - CL_MKNOD = 5, /* namespace */ > - CL_UNLINK = 6, /* namespace */ > - CL_RMDIR = 7, /* namespace */ > - CL_RENAME = 8, /* namespace */ > - CL_EXT = 9, /* namespace extended record (2nd half of rename) */ > - CL_OPEN = 10, /* not currently used */ > - CL_CLOSE = 11, /* may be written to log only with mtime change */ > - CL_LAYOUT = 12, /* file layout/striping modified */ > - CL_TRUNC = 13, > - CL_SETATTR = 14, > - CL_XATTR = 15, > - CL_HSM = 16, /* HSM specific events, see flags */ > - CL_MTIME = 17, /* Precedence: setattr > mtime > ctime > atime */ > - CL_CTIME = 18, > - CL_ATIME = 19, > + CL_MARK = 0, > + CL_CREATE = 1, /* namespace */ > + CL_MKDIR = 2, /* namespace */ > + CL_HARDLINK = 3, /* namespace */ > + CL_SOFTLINK = 4, /* namespace */ > + CL_MKNOD = 5, /* namespace */ > + CL_UNLINK = 6, /* namespace */ > + CL_RMDIR = 7, /* namespace */ > + CL_RENAME = 8, /* namespace */ > + CL_EXT = 9, /* namespace extended record (2nd half of rename) */ > + CL_OPEN = 10, /* not currently used */ > + CL_CLOSE = 11, /* may be written to log only with mtime change */ > + CL_LAYOUT = 12, /* file layout/striping modified */ > + CL_TRUNC = 13, > + CL_SETATTR = 14, > + CL_XATTR = 15, > + CL_HSM = 16, /* HSM specific events, see flags */ > + CL_MTIME = 17, /* Precedence: setattr > mtime > ctime > atime */ > + CL_CTIME = 18, > + CL_ATIME = 19, > CL_LAST > }; > > @@ -808,9 +808,9 @@ enum changelog_rec_flags { > > /* Anything under the flagmask may be per-type (if desired) */ > /* Flags for unlink */ > -#define CLF_UNLINK_LAST 0x0001 /* Unlink of last hardlink */ > -#define CLF_UNLINK_HSM_EXISTS 0x0002 /* File has something in HSM */ > - /* HSM cleaning needed */ > +#define CLF_UNLINK_LAST 0x0001 /* Unlink of last hardlink */ > +#define CLF_UNLINK_HSM_EXISTS 0x0002 /* File has something in HSM > + * HSM cleaning needed */ > /* Flags for rename */ > #define CLF_RENAME_LAST 0x0001 /* rename unlink last hardlink of > * target > @@ -827,12 +827,12 @@ enum changelog_rec_flags { > */ > #define CLF_HSM_ERR_L 0 /* HSM return code, 7 bits */ > #define CLF_HSM_ERR_H 6 > -#define CLF_HSM_EVENT_L 7 /* HSM event, 3 bits, see enum hsm_event */ > -#define CLF_HSM_EVENT_H 9 > -#define CLF_HSM_FLAG_L 10 /* HSM flags, 2 bits, 1 used, 1 spare */ > -#define CLF_HSM_FLAG_H 11 > -#define CLF_HSM_SPARE_L 12 /* 4 spare bits */ > -#define CLF_HSM_SPARE_H 15 > +#define CLF_HSM_EVENT_L 7 /* HSM event, 3 bits, see enum hsm_event */ > +#define CLF_HSM_EVENT_H 9 > +#define CLF_HSM_FLAG_L 10 /* HSM flags, 2 bits, 1 used, 1 spare */ > +#define CLF_HSM_FLAG_H 11 > +#define CLF_HSM_SPARE_L 12 /* 4 spare bits */ > +#define CLF_HSM_SPARE_H 15 > #define CLF_HSM_LAST 15 > > /* Remove bits higher than _h, then extract the value > @@ -841,22 +841,22 @@ enum changelog_rec_flags { > #define CLF_GET_BITS(_b, _h, _l) (((_b << (CLF_HSM_LAST - _h)) & 0xFFFF) \ > >> (CLF_HSM_LAST - _h + _l)) > > -#define CLF_HSM_SUCCESS 0x00 > -#define CLF_HSM_MAXERROR 0x7E > -#define CLF_HSM_ERROVERFLOW 0x7F > +#define CLF_HSM_SUCCESS 0x00 > +#define CLF_HSM_MAXERROR 0x7E > +#define CLF_HSM_ERROVERFLOW 0x7F > > #define CLF_HSM_DIRTY 1 /* file is dirty after HSM request end */ > > /* 3 bits field => 8 values allowed */ > enum hsm_event { > - HE_ARCHIVE = 0, > - HE_RESTORE = 1, > - HE_CANCEL = 2, > - HE_RELEASE = 3, > - HE_REMOVE = 4, > + HE_ARCHIVE = 0, > + HE_RESTORE = 1, > + HE_CANCEL = 2, > + HE_RELEASE = 3, > + HE_REMOVE = 4, > HE_STATE = 5, > - HE_SPARE1 = 6, > - HE_SPARE2 = 7, > + HE_SPARE1 = 6, > + HE_SPARE2 = 7, > }; > > static inline enum hsm_event hsm_get_cl_event(__u16 flags) > @@ -1070,14 +1070,14 @@ enum changelog_message_type { > > struct ioc_data_version { > __u64 idv_version; > - __u64 idv_flags; /* See LL_DV_xxx */ > + __u64 idv_flags; /* See LL_DV_xxx */ > }; > > #define LL_DV_RD_FLUSH (1 << 0) /* Flush dirty pages from clients */ > #define LL_DV_WR_FLUSH (1 << 1) /* Flush all caching pages from clients */ > > #ifndef offsetof > -# define offsetof(typ, memb) ((unsigned long)((char *)&(((typ *)0)->memb))) > +# define offsetof(typ, memb) ((unsigned long)((char *)&(((typ *)0)->memb))) > #endif > > #define dot_lustre_name ".lustre" > @@ -1284,14 +1284,14 @@ static inline const char *hsm_copytool_action2name(enum hsm_copytool_action a) > > /* Copytool item action description */ > struct hsm_action_item { > - __u32 hai_len; /* valid size of this struct */ > - __u32 hai_action; /* hsm_copytool_action, but use known size */ > - struct lu_fid hai_fid; /* Lustre FID to operated on */ > - struct lu_fid hai_dfid; /* fid used for data access */ > + __u32 hai_len; /* valid size of this struct */ > + __u32 hai_action; /* hsm_copytool_action, but use known size */ > + struct lu_fid hai_fid; /* Lustre FID to operated on */ > + struct lu_fid hai_dfid; /* fid used for data access */ > struct hsm_extent hai_extent; /* byte range to operate on */ > - __u64 hai_cookie; /* action cookie from coordinator */ > - __u64 hai_gid; /* grouplock id */ > - char hai_data[0]; /* variable length */ > + __u64 hai_cookie; /* action cookie from coordinator */ > + __u64 hai_gid; /* grouplock id */ > + char hai_data[0]; /* variable length */ > } __packed; > > /* > @@ -1326,12 +1326,12 @@ static inline char *hai_dump_data_field(struct hsm_action_item *hai, > #define HAL_MAXSIZE LNET_MTU /* bytes, used in userspace only */ > struct hsm_action_list { > __u32 hal_version; > - __u32 hal_count; /* number of hai's to follow */ > - __u64 hal_compound_id; /* returned by coordinator */ > + __u32 hal_count; /* number of hai's to follow */ > + __u64 hal_compound_id; /* returned by coordinator */ > __u64 hal_flags; > - __u32 hal_archive_id; /* which archive backend */ > + __u32 hal_archive_id; /* which archive backend */ > __u32 padding1; > - char hal_fsname[0]; /* null-terminated */ > + char hal_fsname[0]; /* null-terminated */ > /* struct hsm_action_item[hal_count] follows, aligned on 8-byte > * boundaries. See hai_first > */ > @@ -1384,8 +1384,8 @@ struct hsm_user_import { > }; > > /* Copytool progress reporting */ > -#define HP_FLAG_COMPLETED 0x01 > -#define HP_FLAG_RETRY 0x02 > +#define HP_FLAG_COMPLETED 0x01 > +#define HP_FLAG_RETRY 0x02 > > struct hsm_progress { > struct lu_fid hp_fid; > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h > index 2bf12284bf43..92427254d74c 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h > @@ -74,25 +74,25 @@ > #define IBLND_N_SCHED_HIGH 4 > > struct kib_tunables { > - int *kib_dev_failover; /* HCA failover */ > - unsigned int *kib_service; /* IB service number */ > + int *kib_dev_failover; /* HCA failover */ > + unsigned int *kib_service; /* IB service number */ > int *kib_min_reconnect_interval; /* first failed connection retry... */ > int *kib_max_reconnect_interval; /* exponentially increasing to this */ > - int *kib_cksum; /* checksum struct kib_msg? */ > - int *kib_timeout; /* comms timeout (seconds) */ > - int *kib_keepalive; /* keepalive timeout (seconds) */ > - int *kib_ntx; /* # tx descs */ > - char **kib_default_ipif; /* default IPoIB interface */ > + int *kib_cksum; /* checksum struct kib_msg? */ > + int *kib_timeout; /* comms timeout (seconds) */ > + int *kib_keepalive; /* keepalive timeout (seconds) */ > + int *kib_ntx; /* # tx descs */ > + char **kib_default_ipif; /* default IPoIB interface */ > int *kib_retry_count; > int *kib_rnr_retry_count; > - int *kib_ib_mtu; /* IB MTU */ > - int *kib_require_priv_port; /* accept only privileged ports */ > - int *kib_use_priv_port; /* use privileged port for active connect */ > - int *kib_nscheds; /* # threads on each CPT */ > - int *kib_wrq_sge; /* # sg elements per wrq */ > - bool *kib_use_fastreg_gaps; /* enable discontiguous fastreg > - * fragment support > - */ > + int *kib_ib_mtu; /* IB MTU */ > + int *kib_require_priv_port; /* accept only privileged ports */ > + int *kib_use_priv_port; /* use privileged port for active connect */ > + int *kib_nscheds; /* # threads on each CPT */ > + int *kib_wrq_sge; /* # sg elements per wrq */ > + bool *kib_use_fastreg_gaps; /* enable discontiguous fastreg > + * fragment support > + */ > }; > > extern struct kib_tunables kiblnd_tunables; > @@ -164,11 +164,11 @@ struct kib_dev { > int ibd_nnets; /* # nets extant */ > > time64_t ibd_next_failover; > - int ibd_failed_failover; /* # failover failures */ > - unsigned int ibd_failover; /* failover in progress */ > - unsigned int ibd_can_failover; /* IPoIB interface is a > - * bonding master > - */ > + int ibd_failed_failover; /* # failover failures */ > + unsigned int ibd_failover; /* failover in progress */ > + unsigned int ibd_can_failover; /* IPoIB interface is a > + * bonding master > + */ > struct list_head ibd_nets; > struct kib_hca_dev *ibd_hdev; > enum kib_dev_caps ibd_dev_caps; > @@ -330,8 +330,8 @@ struct kib_sched_info { > > struct kib_data { > int kib_init; /* initialisation state */ > - int kib_shutdown; /* shut down? */ > - struct list_head kib_devs; /* IB devices extant */ > + int kib_shutdown; /* shut down? */ > + struct list_head kib_devs; /* IB devices extant */ > struct list_head kib_failed_devs; /* list head of failed devices */ > wait_queue_head_t kib_failover_waitq; /* schedulers sleep here */ > atomic_t kib_nthreads; /* # live threads */ > @@ -540,7 +540,7 @@ struct kib_conn { > int ibc_state; /* what's happening */ > int ibc_nsends_posted; /* # uncompleted sends */ > int ibc_noops_posted; /* # uncompleted NOOPs */ > - int ibc_credits; /* # credits I have */ > + int ibc_credits; /* # credits I have */ > int ibc_outstanding_credits; /* # credits to return */ > int ibc_reserved_credits; /* # ACK/DONE msg credits */ > int ibc_comms_error; /* set on comms error */ > @@ -581,13 +581,13 @@ struct kib_conn { > #define IBLND_CONN_DISCONNECTED 5 /* disconnected */ > > struct kib_peer_ni { > - struct list_head ibp_list; /* stash on global peer_ni list */ > - lnet_nid_t ibp_nid; /* who's on the other end(s) */ > - struct lnet_ni *ibp_ni; /* LNet interface */ > - struct list_head ibp_conns; /* all active connections */ > - struct kib_conn *ibp_next_conn; /* next connection to send on for > - * round robin */ > - struct list_head ibp_tx_queue; /* msgs waiting for a conn */ > + struct list_head ibp_list; /* stash on global peer_ni list */ > + lnet_nid_t ibp_nid; /* who's on the other end(s) */ > + struct lnet_ni *ibp_ni; /* LNet interface */ > + struct list_head ibp_conns; /* all active connections */ > + struct kib_conn *ibp_next_conn; /* next connection to send on for > + * round robin */ > + struct list_head ibp_tx_queue; /* msgs waiting for a conn */ > u64 ibp_incarnation; /* incarnation of peer_ni */ > /* when (in seconds) I was last alive */ > time64_t ibp_last_alive; > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h > index ce1f9e78b4d9..add2744c9d8d 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h > @@ -54,15 +54,15 @@ > #define SOCKNAL_NSCHEDS 3 > #define SOCKNAL_NSCHEDS_HIGH (SOCKNAL_NSCHEDS << 1) > > -#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer_ni lists */ > -#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ > -#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ > -#define SOCKNAL_ENOMEM_RETRY 1 /* seconds between retries */ > +#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer_ni lists */ > +#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */ > +#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */ > +#define SOCKNAL_ENOMEM_RETRY 1 /* seconds between retries */ > > -#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */ > -#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */ > +#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */ > +#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */ > > -#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */ > +#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */ > > /* > * risk kmap deadlock on multi-frag I/O (backs off to single-frag if disabled). > @@ -461,31 +461,31 @@ extern struct ksock_tunables ksocknal_tunables; > > struct ksock_proto { > /* version number of protocol */ > - int pro_version; > + int pro_version; > > /* handshake function */ > - int (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *); > + int (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *); > > /* handshake function */ > - int (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int); > + int (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int); > > /* message pack */ > - void (*pro_pack)(struct ksock_tx *); > + void (*pro_pack)(struct ksock_tx *); > > /* message unpack */ > - void (*pro_unpack)(struct ksock_msg *); > + void (*pro_unpack)(struct ksock_msg *); > > /* queue tx on the connection */ > struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *); > > /* queue ZC ack on the connection */ > - int (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64); > + int (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, u64); > > /* handle ZC request */ > - int (*pro_handle_zcreq)(struct ksock_conn *, u64, int); > + int (*pro_handle_zcreq)(struct ksock_conn *, u64, int); > > /* handle ZC ACK */ > - int (*pro_handle_zcack)(struct ksock_conn *, u64, u64); > + int (*pro_handle_zcack)(struct ksock_conn *, u64, u64); > > /* > * msg type matches the connection type: > @@ -494,7 +494,7 @@ struct ksock_proto { > * return MATCH_YES : matching type > * return MATCH_MAY : can be backup > */ > - int (*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int); > + int (*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int); > }; > > extern struct ksock_proto ksocknal_protocol_v1x; > diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c > index 2df9ce4995f3..18f5c6b3b587 100644 > --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c > +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c > @@ -92,9 +92,9 @@ EXPORT_SYMBOL(libcfs_next_nidstring); > * :== '@' > * :== '*' | > * | > - * > + * > * :== ... > - * > + * > * :== | > * > * :== '[' [ ',' ] ']' > diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c > index bb61e3aa11e9..51ff979ca4ad 100644 > --- a/drivers/staging/lustre/lnet/selftest/timer.c > +++ b/drivers/staging/lustre/lnet/selftest/timer.c > @@ -46,12 +46,12 @@ > * sorted by increasing expiry time. The number of slots is 2**7 (128), > * to cover a time period of 1024 seconds into the future before wrapping. > */ > -#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */ > +#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */ > #define STTIMER_SLOTTIME BIT(STTIMER_MINPOLL) > -#define STTIMER_SLOTTIMEMASK (~(STTIMER_SLOTTIME - 1)) > +#define STTIMER_SLOTTIMEMASK (~(STTIMER_SLOTTIME - 1)) > #define STTIMER_NSLOTS BIT(7) > -#define STTIMER_SLOT(t) (&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \ > - (STTIMER_NSLOTS - 1))]) > +#define STTIMER_SLOT(t) (&stt_data.stt_hash[(((t) >> STTIMER_MINPOLL) & \ > + (STTIMER_NSLOTS - 1))]) > > static struct st_timer_data { > spinlock_t stt_lock; > diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c > index c85ef9ec639f..67b002bb1d1d 100644 > --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c > +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c > @@ -139,7 +139,7 @@ fld_debugfs_cache_flush_release(struct inode *inode, struct file *file) > > static const struct file_operations fld_debugfs_cache_flush_fops = { > .owner = THIS_MODULE, > - .open = simple_open, > + .open = simple_open, > .write = fld_debugfs_cache_flush_write, > .release = fld_debugfs_cache_flush_release, > }; > diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h > index 7d52665a3c33..31b3881fb6c9 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_import.h > +++ b/drivers/staging/lustre/lustre/include/lustre_import.h > @@ -69,9 +69,9 @@ struct adaptive_timeout { > > struct ptlrpc_at_array { > struct list_head *paa_reqs_array; /** array to hold requests */ > - u32 paa_size; /** the size of array */ > - u32 paa_count; /** the total count of reqs */ > - time64_t paa_deadline; /** the earliest deadline of reqs */ > + u32 paa_size; /** the size of array */ > + u32 paa_count; /** the total count of reqs */ > + time64_t paa_deadline; /** the earliest deadline of reqs */ > u32 *paa_reqs_count; /** the count of reqs in each entry */ > }; > > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index 9cffda3741ce..e09268f08e5c 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -690,10 +690,10 @@ static inline int it_to_lock_mode(struct lookup_intent *it) > > enum md_op_flags { > MF_MDC_CANCEL_FID1 = BIT(0), > - MF_MDC_CANCEL_FID2 = BIT(1), > - MF_MDC_CANCEL_FID3 = BIT(2), > - MF_MDC_CANCEL_FID4 = BIT(3), > - MF_GET_MDT_IDX = BIT(4), > + MF_MDC_CANCEL_FID2 = BIT(1), > + MF_MDC_CANCEL_FID3 = BIT(2), > + MF_MDC_CANCEL_FID4 = BIT(3), > + MF_GET_MDT_IDX = BIT(4), > }; > > enum md_cli_flags { > @@ -744,7 +744,7 @@ struct md_op_data { > u32 op_flags; > > /* Various operation flags. */ > - enum mds_op_bias op_bias; > + enum mds_op_bias op_bias; > > /* Used by readdir */ > u64 op_offset; > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index 261857e4540d..ae2fddd044ea 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -335,9 +335,9 @@ static void ldlm_ns_release(struct kobject *kobj) > } > > static struct kobj_type ldlm_ns_ktype = { > - .default_attrs = ldlm_ns_attrs, > - .sysfs_ops = &lustre_sysfs_ops, > - .release = ldlm_ns_release, > + .default_attrs = ldlm_ns_attrs, > + .sysfs_ops = &lustre_sysfs_ops, > + .release = ldlm_ns_release, > }; > > static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns) > diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c > index 6afaa9028864..07cb2c92c197 100644 > --- a/drivers/staging/lustre/lustre/llite/file.c > +++ b/drivers/staging/lustre/lustre/llite/file.c > @@ -2636,7 +2636,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > return -EFAULT; > > return ll_file_futimes_3(file, &lfu); > - } > + } > case LL_IOC_LADVISE: { > struct llapi_ladvise_hdr *ladvise_hdr; > int alloc_size = sizeof(*ladvise_hdr); > diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h > index 102d143691b2..0f7c0272d630 100644 > --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h > +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h > @@ -204,7 +204,7 @@ struct vvp_object { > * > * \see ll_vm_open(), ll_vm_close(). > */ > - atomic_t vob_mmap_cnt; > + atomic_t vob_mmap_cnt; > > /** > * various flags > diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c > index 22f178a3abe2..a1d27061ac19 100644 > --- a/drivers/staging/lustre/lustre/llite/xattr.c > +++ b/drivers/staging/lustre/lustre/llite/xattr.c > @@ -209,7 +209,7 @@ static int ll_adjust_lum(struct inode *inode, struct lov_user_md *lump) > if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) { > entry_count = comp_v1->lcm_entry_count; > is_composite = true; > - } > + } > > for (i = 0; i < entry_count; i++) { > if (lump->lmm_magic == LOV_USER_MAGIC_COMP_V1) { > diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c > index 6db4d5eb46cd..395ef772fc17 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_ea.c > +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c > @@ -536,7 +536,7 @@ void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm) > DEXT ": id: %u, flags: %x, magic 0x%08X, layout_gen %u, stripe count %u, sstripe size %u, pool: [" LOV_POOLNAMEF "]\n", > PEXT(&lse->lsme_extent), lse->lsme_id, lse->lsme_flags, > lse->lsme_magic, lse->lsme_layout_gen, > - lse->lsme_stripe_count, lse->lsme_stripe_size, > + lse->lsme_stripe_count, lse->lsme_stripe_size, > lse->lsme_pool_name); > if (!lsme_inited(lse) || > lse->lsme_pattern & LOV_PATTERN_F_RELEASED) > diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c > index bad9538706f0..652ed6a20af3 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_obd.c > +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c > @@ -1336,19 +1336,19 @@ static const struct obd_ops lov_obd_ops = { > .owner = THIS_MODULE, > .setup = lov_setup, > .cleanup = lov_cleanup, > - .connect = lov_connect, > - .disconnect = lov_disconnect, > - .statfs = lov_statfs, > - .statfs_async = lov_statfs_async, > - .iocontrol = lov_iocontrol, > - .get_info = lov_get_info, > - .set_info_async = lov_set_info_async, > - .notify = lov_notify, > - .pool_new = lov_pool_new, > - .pool_rem = lov_pool_remove, > - .pool_add = lov_pool_add, > - .pool_del = lov_pool_del, > - .quotactl = lov_quotactl, > + .connect = lov_connect, > + .disconnect = lov_disconnect, > + .statfs = lov_statfs, > + .statfs_async = lov_statfs_async, > + .iocontrol = lov_iocontrol, > + .get_info = lov_get_info, > + .set_info_async = lov_set_info_async, > + .notify = lov_notify, > + .pool_new = lov_pool_new, > + .pool_rem = lov_pool_remove, > + .pool_add = lov_pool_add, > + .pool_del = lov_pool_del, > + .quotactl = lov_quotactl, > }; > > struct kmem_cache *lov_oinfo_slab; > diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c > index 3ff0bf1c4a22..ec872e8ae9be 100644 > --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c > +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c > @@ -1818,18 +1818,18 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf) > } > > static const struct obd_ops mgc_obd_ops = { > - .owner = THIS_MODULE, > - .setup = mgc_setup, > - .precleanup = mgc_precleanup, > - .cleanup = mgc_cleanup, > - .add_conn = client_import_add_conn, > - .del_conn = client_import_del_conn, > - .connect = client_connect_import, > - .disconnect = client_disconnect_export, > - .set_info_async = mgc_set_info_async, > - .get_info = mgc_get_info, > - .import_event = mgc_import_event, > - .process_config = mgc_process_config, > + .owner = THIS_MODULE, > + .setup = mgc_setup, > + .precleanup = mgc_precleanup, > + .cleanup = mgc_cleanup, > + .add_conn = client_import_add_conn, > + .del_conn = client_import_del_conn, > + .connect = client_connect_import, > + .disconnect = client_disconnect_export, > + .set_info_async = mgc_set_info_async, > + .get_info = mgc_get_info, > + .import_event = mgc_import_event, > + .process_config = mgc_process_config, > }; > > static int __init mgc_init(void) > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index 1d1a6b2d436e..c91704d87042 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -313,9 +313,9 @@ struct obd_device *class_newdev(const char *type_name, const char *name, > > llog_group_init(&newdev->obd_olg); > /* Detach drops this */ > - atomic_set(&newdev->obd_refcount, 1); > - lu_ref_init(&newdev->obd_reference); > - lu_ref_add(&newdev->obd_reference, "newdev", newdev); > + atomic_set(&newdev->obd_refcount, 1); > + lu_ref_init(&newdev->obd_reference); > + lu_ref_add(&newdev->obd_reference, "newdev", newdev); > > newdev->obd_conn_inprogress = 0; > > diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c > index 69a56cca99f2..d4f1eddd96ca 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c > @@ -73,7 +73,7 @@ struct lu_site_bkt_data { > * > * \see htable_lookup(). > */ > - wait_queue_head_t lsb_marche_funebre; > + wait_queue_head_t lsb_marche_funebre; > }; > > enum { > @@ -935,10 +935,10 @@ static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) > static struct cfs_hash_ops lu_site_hash_ops = { > .hs_hash = lu_obj_hop_hash, > .hs_key = lu_obj_hop_key, > - .hs_keycmp = lu_obj_hop_keycmp, > - .hs_object = lu_obj_hop_object, > + .hs_keycmp = lu_obj_hop_keycmp, > + .hs_object = lu_obj_hop_object, > .hs_get = lu_obj_hop_get, > - .hs_put_locked = lu_obj_hop_put_locked, > + .hs_put_locked = lu_obj_hop_put_locked, > }; > > static void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d) > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c > index 71490b75c7ae..e9e0bcf39d4e 100644 > --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c > +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c > @@ -105,7 +105,7 @@ static ssize_t static_uintvalue_store(struct kobject *kobj, > } > > #define LUSTRE_STATIC_UINT_ATTR(name, value) \ > -static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ > +static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ > { __ATTR(name, 0644, static_uintvalue_show, \ > static_uintvalue_store), value } > > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 442b4355d946..765b5a7b9662 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -2989,26 +2989,26 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) > } > > static const struct obd_ops osc_obd_ops = { > - .owner = THIS_MODULE, > - .setup = osc_setup, > - .precleanup = osc_precleanup, > - .cleanup = osc_cleanup, > - .add_conn = client_import_add_conn, > - .del_conn = client_import_del_conn, > - .connect = client_connect_import, > - .reconnect = osc_reconnect, > - .disconnect = osc_disconnect, > - .statfs = osc_statfs, > - .statfs_async = osc_statfs_async, > - .create = osc_create, > - .destroy = osc_destroy, > - .getattr = osc_getattr, > - .setattr = osc_setattr, > - .iocontrol = osc_iocontrol, > - .set_info_async = osc_set_info_async, > - .import_event = osc_import_event, > - .process_config = osc_process_config, > - .quotactl = osc_quotactl, > + .owner = THIS_MODULE, > + .setup = osc_setup, > + .precleanup = osc_precleanup, > + .cleanup = osc_cleanup, > + .add_conn = client_import_add_conn, > + .del_conn = client_import_del_conn, > + .connect = client_connect_import, > + .reconnect = osc_reconnect, > + .disconnect = osc_disconnect, > + .statfs = osc_statfs, > + .statfs_async = osc_statfs_async, > + .create = osc_create, > + .destroy = osc_destroy, > + .getattr = osc_getattr, > + .setattr = osc_setattr, > + .iocontrol = osc_iocontrol, > + .set_info_async = osc_set_info_async, > + .import_event = osc_import_event, > + .process_config = osc_process_config, > + .quotactl = osc_quotactl, > }; > > struct list_head osc_shrink_list = LIST_HEAD_INIT(osc_shrink_list); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c > index c2f49a3e0454..5dde3495aaf4 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c > @@ -1508,7 +1508,7 @@ void lustre_assert_wire_constants(void) > LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding) == 16, "found %lld\n", > (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding)); > LASSERTF(LCME_FL_INIT == 0x00000010UL, "found 0x%.8xUL\n", > - (unsigned int)LCME_FL_INIT); > + (unsigned int)LCME_FL_INIT); > > /* Checks for struct lov_comp_md_v1 */ > LASSERTF((int)sizeof(struct lov_comp_md_v1) == 32, "found %lld\n", > > > From jsimmons at infradead.org Sun Feb 24 19:07:33 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 19:07:33 +0000 (GMT) Subject: [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines. In-Reply-To: <155053494593.24125.427229089746560574.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494593.24125.427229089746560574.stgit@noble.brown> Message-ID: > Some of these are unused. > One is used in a minimal way where it is easier to use > an explicit number. While I dislike mystery meat type defines like MAX_STRING_SIZE I also don't like using raw numbers. In the past using raw numbers has causes problems when requirements changed that were not easy to track down why the new bug appeared. Mind you the same problem exist for constants like MAX_STRING_SIZE which provides no real meaning to why the magically number 128 is used. This number seems to be a limiting factor in the naming of sysfs directory and file naming. I kind of see why this number has no meaning. So such a number belongs in one place, lprocfs_status.h. Now sysfs attributes can have any naming style they want, within reason :-) As for directories that is limited by MAX_OBD_NAME. What do you know MAX_OBD_NAME is equal too MAX_STRING_SIZE (hint hint) :-) > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 -- > drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- > drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ---- > drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 -- > .../lustre/lustre/obdclass/lprocfs_status.c | 2 -- > 5 files changed, 2 insertions(+), 14 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index 74c7644d6ef8..261857e4540d 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -392,8 +392,6 @@ static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns) > return 0; > } > > -#undef MAX_STRING_SIZE > - > struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res) > { > LASSERT(res); > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index d97abbfddccf..fda6d9b07952 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -906,8 +906,6 @@ void ll_lli_init(struct ll_inode_info *lli) > memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE); > } > > -#define MAX_STRING_SIZE 128 > - > int ll_fill_super(struct super_block *sb) > { > struct lustre_profile *lprof = NULL; > @@ -916,7 +914,7 @@ int ll_fill_super(struct super_block *sb) > char *dt = NULL, *md = NULL; > char *profilenm = get_profile_name(sb); > struct config_llog_instance *cfg; > - char name[MAX_STRING_SIZE]; > + char name[128]; > char *ptr; > int len; > int err; > @@ -960,7 +958,7 @@ int ll_fill_super(struct super_block *sb) > len -= 7; > > /* Mount info */ > - snprintf(name, MAX_STRING_SIZE, "%.*s-%px", len, > + snprintf(name, sizeof(name), "%.*s-%px", len, > lsi->lsi_lmd->lmd_profile, sb); > > /* Call ll_debugsfs_register_super() before lustre_process_log() > diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c > index db2fbf1f3a50..5ed703d7bb1e 100644 > --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c > +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c > @@ -1187,8 +1187,6 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { > { NULL } > }; > > -#define MAX_STRING_SIZE 128 > - > static struct attribute *llite_attrs[] = { > &lustre_attr_blocksize.attr, > &lustre_attr_stat_blocksize.attr, > @@ -1434,8 +1432,6 @@ void ll_debugfs_unregister_super(struct super_block *sb) > lprocfs_free_stats(&sbi->ll_stats); > } > > -#undef MAX_STRING_SIZE > - > #define pct(a, b) (b ? a * 100 / b : 0) > > static void ll_display_extents_info(struct ll_rw_extents_info *io_extents, > diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c > index 35dff0e96bf7..138e124bd05e 100644 > --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c > +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c > @@ -273,8 +273,6 @@ static int lmv_init_ea_size(struct obd_export *exp, u32 easize, u32 def_easize) > return rc; > } > > -#define MAX_STRING_SIZE 128 > - > static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) > { > struct lmv_obd *lmv = &obd->u.lmv; > diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > index aed33068ff3c..a179b0d6979e 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > @@ -271,8 +271,6 @@ static int lprocfs_no_percpu_stats; > module_param(lprocfs_no_percpu_stats, int, 0644); > MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats"); > > -#define MAX_STRING_SIZE 128 > - > /* lprocfs API calls */ > > static const struct file_operations lprocfs_generic_fops = { }; > > > From jsimmons at infradead.org Sun Feb 24 19:08:45 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 19:08:45 +0000 (GMT) Subject: [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing. In-Reply-To: <155053494611.24125.2469014113532688461.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494611.24125.2469014113532688461.stgit@noble.brown> Message-ID: > In lu_cdebug_printer(), is "complete" is true, then > key->lck_area ends with a newline, so there is no need to > include on in the format too. We thought we found all those extra or missing newlines. Thanks for finding it. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c > index d4f1eddd96ca..3e23babb329a 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c > @@ -526,7 +526,7 @@ int lu_cdebug_printer(const struct lu_env *env, > ARRAY_SIZE(key->lck_area) - used, format, args); > if (complete) { > if (cfs_cdebug_show(msgdata->msg_mask, msgdata->msg_subsys)) > - libcfs_debug_msg(msgdata, "%s\n", key->lck_area); > + libcfs_debug_msg(msgdata, "%s", key->lck_area); > key->lck_area[0] = 0; > } > va_end(args); > > > From jsimmons at infradead.org Sun Feb 24 20:02:06 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 20:02:06 +0000 (GMT) Subject: [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 In-Reply-To: <155053494619.24125.5150721300459339252.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494619.24125.5150721300459339252.stgit@noble.brown> Message-ID: > Since 2.6.36, Linux' vsprintf has supported %pV > which supports "recursive sprintf" - exactly the task > that libcfs_debug_vmsg2 aims to provide. > > Instead of calling libcfs_debug_vmsg2(), we can put the fmt and > args in a 'struct va_format', and pass the address of that structure > to the "%pV" format. > > So do this to remove all users of libcfs_debug_vmsg2(). This is a really nice cleanup. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 176 ++++++++++---------- > .../staging/lustre/lustre/ptlrpc/pack_generic.c | 42 +++-- > 2 files changed, 115 insertions(+), 103 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > index f2433dc0e558..6789d3bf0485 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > @@ -1970,6 +1970,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > struct ldlm_resource *resource = NULL; > char *nid = "local"; > va_list args; > + struct va_format vaf; > > if (spin_trylock(&lock->l_lock)) { > if (lock->l_resource) > @@ -1978,6 +1979,8 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > } > > va_start(args, fmt); > + vaf.fmt = fmt; > + vaf.va = &args; > > if (exp && exp->exp_connection) { > nid = libcfs_nid2str(exp->exp_connection->c_peer.nid); > @@ -1988,105 +1991,110 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, > } > > if (!resource) { > - libcfs_debug_vmsg2(msgdata, fmt, args, > - " ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > - lock, > - lock->l_handle.h_cookie, > - atomic_read(&lock->l_refc), > - lock->l_readers, lock->l_writers, > - ldlm_lockname[lock->l_granted_mode], > - ldlm_lockname[lock->l_req_mode], > - lock->l_flags, nid, > - lock->l_remote_handle.cookie, > - exp ? refcount_read(&exp->exp_refcount) : -99, > - lock->l_pid, lock->l_callback_timeout, > - lock->l_lvb_type); > + libcfs_debug_msg(msgdata, > + "%pV ns: \?\? lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: \?\? rrc=\?\? type: \?\?\? flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > + &vaf, > + lock, > + lock->l_handle.h_cookie, > + atomic_read(&lock->l_refc), > + lock->l_readers, lock->l_writers, > + ldlm_lockname[lock->l_granted_mode], > + ldlm_lockname[lock->l_req_mode], > + lock->l_flags, nid, > + lock->l_remote_handle.cookie, > + exp ? refcount_read(&exp->exp_refcount) : -99, > + lock->l_pid, lock->l_callback_timeout, > + lock->l_lvb_type); > va_end(args); > return; > } > > switch (resource->lr_type) { > case LDLM_EXTENT: > - libcfs_debug_vmsg2(msgdata, fmt, args, > - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > - ldlm_lock_to_ns_name(lock), lock, > - lock->l_handle.h_cookie, > - atomic_read(&lock->l_refc), > - lock->l_readers, lock->l_writers, > - ldlm_lockname[lock->l_granted_mode], > - ldlm_lockname[lock->l_req_mode], > - PLDLMRES(resource), > - atomic_read(&resource->lr_refcount), > - ldlm_typename[resource->lr_type], > - lock->l_policy_data.l_extent.start, > - lock->l_policy_data.l_extent.end, > - lock->l_req_extent.start, > - lock->l_req_extent.end, > - lock->l_flags, nid, > - lock->l_remote_handle.cookie, > - exp ? refcount_read(&exp->exp_refcount) : -99, > - lock->l_pid, lock->l_callback_timeout, > - lock->l_lvb_type); > + libcfs_debug_msg(msgdata, > + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s [%llu->%llu] (req %llu->%llu) flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > + &vaf, > + ldlm_lock_to_ns_name(lock), lock, > + lock->l_handle.h_cookie, > + atomic_read(&lock->l_refc), > + lock->l_readers, lock->l_writers, > + ldlm_lockname[lock->l_granted_mode], > + ldlm_lockname[lock->l_req_mode], > + PLDLMRES(resource), > + atomic_read(&resource->lr_refcount), > + ldlm_typename[resource->lr_type], > + lock->l_policy_data.l_extent.start, > + lock->l_policy_data.l_extent.end, > + lock->l_req_extent.start, > + lock->l_req_extent.end, > + lock->l_flags, nid, > + lock->l_remote_handle.cookie, > + exp ? refcount_read(&exp->exp_refcount) : -99, > + lock->l_pid, lock->l_callback_timeout, > + lock->l_lvb_type); > break; > > case LDLM_FLOCK: > - libcfs_debug_vmsg2(msgdata, fmt, args, > - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n", > - ldlm_lock_to_ns_name(lock), lock, > - lock->l_handle.h_cookie, > - atomic_read(&lock->l_refc), > - lock->l_readers, lock->l_writers, > - ldlm_lockname[lock->l_granted_mode], > - ldlm_lockname[lock->l_req_mode], > - PLDLMRES(resource), > - atomic_read(&resource->lr_refcount), > - ldlm_typename[resource->lr_type], > - lock->l_policy_data.l_flock.pid, > - lock->l_policy_data.l_flock.start, > - lock->l_policy_data.l_flock.end, > - lock->l_flags, nid, > - lock->l_remote_handle.cookie, > - exp ? refcount_read(&exp->exp_refcount) : -99, > - lock->l_pid, lock->l_callback_timeout); > + libcfs_debug_msg(msgdata, > + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s pid: %d [%llu->%llu] flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu\n", > + &vaf, > + ldlm_lock_to_ns_name(lock), lock, > + lock->l_handle.h_cookie, > + atomic_read(&lock->l_refc), > + lock->l_readers, lock->l_writers, > + ldlm_lockname[lock->l_granted_mode], > + ldlm_lockname[lock->l_req_mode], > + PLDLMRES(resource), > + atomic_read(&resource->lr_refcount), > + ldlm_typename[resource->lr_type], > + lock->l_policy_data.l_flock.pid, > + lock->l_policy_data.l_flock.start, > + lock->l_policy_data.l_flock.end, > + lock->l_flags, nid, > + lock->l_remote_handle.cookie, > + exp ? refcount_read(&exp->exp_refcount) : -99, > + lock->l_pid, lock->l_callback_timeout); > break; > > case LDLM_IBITS: > - libcfs_debug_vmsg2(msgdata, fmt, args, > - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > - ldlm_lock_to_ns_name(lock), > - lock, lock->l_handle.h_cookie, > - atomic_read(&lock->l_refc), > - lock->l_readers, lock->l_writers, > - ldlm_lockname[lock->l_granted_mode], > - ldlm_lockname[lock->l_req_mode], > - PLDLMRES(resource), > - lock->l_policy_data.l_inodebits.bits, > - atomic_read(&resource->lr_refcount), > - ldlm_typename[resource->lr_type], > - lock->l_flags, nid, > - lock->l_remote_handle.cookie, > - exp ? refcount_read(&exp->exp_refcount) : -99, > - lock->l_pid, lock->l_callback_timeout, > - lock->l_lvb_type); > + libcfs_debug_msg(msgdata, > + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " bits %#llx rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > + &vaf, > + ldlm_lock_to_ns_name(lock), > + lock, lock->l_handle.h_cookie, > + atomic_read(&lock->l_refc), > + lock->l_readers, lock->l_writers, > + ldlm_lockname[lock->l_granted_mode], > + ldlm_lockname[lock->l_req_mode], > + PLDLMRES(resource), > + lock->l_policy_data.l_inodebits.bits, > + atomic_read(&resource->lr_refcount), > + ldlm_typename[resource->lr_type], > + lock->l_flags, nid, > + lock->l_remote_handle.cookie, > + exp ? refcount_read(&exp->exp_refcount) : -99, > + lock->l_pid, lock->l_callback_timeout, > + lock->l_lvb_type); > break; > > default: > - libcfs_debug_vmsg2(msgdata, fmt, args, > - " ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > - ldlm_lock_to_ns_name(lock), > - lock, lock->l_handle.h_cookie, > - atomic_read(&lock->l_refc), > - lock->l_readers, lock->l_writers, > - ldlm_lockname[lock->l_granted_mode], > - ldlm_lockname[lock->l_req_mode], > - PLDLMRES(resource), > - atomic_read(&resource->lr_refcount), > - ldlm_typename[resource->lr_type], > - lock->l_flags, nid, > - lock->l_remote_handle.cookie, > - exp ? refcount_read(&exp->exp_refcount) : -99, > - lock->l_pid, lock->l_callback_timeout, > - lock->l_lvb_type); > + libcfs_debug_msg(msgdata, > + "%pV ns: %s lock: %p/%#llx lrc: %d/%d,%d mode: %s/%s res: " DLDLMRES " rrc: %d type: %s flags: %#llx nid: %s remote: %#llx expref: %d pid: %u timeout: %lu lvb_type: %d\n", > + &vaf, > + ldlm_lock_to_ns_name(lock), > + lock, lock->l_handle.h_cookie, > + atomic_read(&lock->l_refc), > + lock->l_readers, lock->l_writers, > + ldlm_lockname[lock->l_granted_mode], > + ldlm_lockname[lock->l_req_mode], > + PLDLMRES(resource), > + atomic_read(&resource->lr_refcount), > + ldlm_typename[resource->lr_type], > + lock->l_flags, nid, > + lock->l_remote_handle.cookie, > + exp ? refcount_read(&exp->exp_refcount) : -99, > + lock->l_pid, lock->l_callback_timeout, > + lock->l_lvb_type); > break; > } > va_end(args); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c > index c7cc86c3fbc3..879cb1162cc7 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c > @@ -2276,6 +2276,7 @@ void _debug_req(struct ptlrpc_request *req, > int rep_flags = -1; > int rep_status = -1; > va_list args; > + struct va_format vaf; > > spin_lock(&req->rq_early_free_lock); > if (req->rq_repmsg) > @@ -2298,25 +2299,28 @@ void _debug_req(struct ptlrpc_request *req, > nid = req->rq_export->exp_connection->c_peer.nid; > > va_start(args, fmt); > - libcfs_debug_vmsg2(msgdata, fmt, args, > - " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", > - req, req->rq_xid, req->rq_transno, > - req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0, > - req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1, > - req->rq_import ? > - req->rq_import->imp_obd->obd_name : > - req->rq_export ? > - req->rq_export->exp_client_uuid.uuid : > - "", > - libcfs_nid2str(nid), > - req->rq_request_portal, req->rq_reply_portal, > - req->rq_reqlen, req->rq_replen, > - req->rq_early_count, (s64)req->rq_timedout, > - (s64)req->rq_deadline, > - atomic_read(&req->rq_refcount), > - DEBUG_REQ_FLAGS(req), > - req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1, > - rep_flags, req->rq_status, rep_status); > + vaf.fmt = fmt; > + vaf.va = &args; > + libcfs_debug_msg(msgdata, > + "%pV req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", > + &vaf, > + req, req->rq_xid, req->rq_transno, > + req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0, > + req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1, > + req->rq_import ? > + req->rq_import->imp_obd->obd_name : > + req->rq_export ? > + req->rq_export->exp_client_uuid.uuid : > + "", > + libcfs_nid2str(nid), > + req->rq_request_portal, req->rq_reply_portal, > + req->rq_reqlen, req->rq_replen, > + req->rq_early_count, (s64)req->rq_timedout, > + (s64)req->rq_deadline, > + atomic_read(&req->rq_refcount), > + DEBUG_REQ_FLAGS(req), > + req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1, > + rep_flags, req->rq_status, rep_status); > va_end(args); > } > EXPORT_SYMBOL(_debug_req); > > > From jsimmons at infradead.org Sun Feb 24 20:28:14 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 20:28:14 +0000 (GMT) Subject: [lustre-devel] [PATCH 27/37] lustre: discard lu_ref In-Reply-To: <155053494627.24125.13508435808475179343.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494627.24125.13508435808475179343.stgit@noble.brown> Message-ID: > struct lu_ref is always an empty structure, and the functions > which manipulate it do nothing. > So this is not being tested and so cannot be trusted. > So remove all these calls and field declarations. Or we can make lu_ref really work and always test with it :-) > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/cl_object.h | 6 - > drivers/staging/lustre/lustre/include/lu_object.h | 45 ----- > drivers/staging/lustre/lustre/include/lu_ref.h | 178 -------------------- > drivers/staging/lustre/lustre/include/lustre_dlm.h | 20 -- > drivers/staging/lustre/lustre/include/obd.h | 7 - > drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 36 +--- > drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 12 - > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 > drivers/staging/lustre/lustre/llite/lcommon_cl.c | 2 > drivers/staging/lustre/lustre/llite/rw.c | 6 - > drivers/staging/lustre/lustre/llite/rw26.c | 6 - > drivers/staging/lustre/lustre/llite/vvp_dev.c | 20 +- > drivers/staging/lustre/lustre/llite/vvp_io.c | 5 - > drivers/staging/lustre/lustre/lov/lov_object.c | 2 > drivers/staging/lustre/lustre/lov/lovsub_dev.c | 1 > drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 > drivers/staging/lustre/lustre/obdclass/Makefile | 2 > drivers/staging/lustre/lustre/obdclass/cl_io.c | 8 - > drivers/staging/lustre/lustre/obdclass/cl_object.c | 2 > drivers/staging/lustre/lustre/obdclass/cl_page.c | 5 - > drivers/staging/lustre/lustre/obdclass/genops.c | 3 > drivers/staging/lustre/lustre/obdclass/lu_object.c | 34 ---- > drivers/staging/lustre/lustre/obdclass/lu_ref.c | 45 ----- > .../staging/lustre/lustre/obdclass/obd_config.c | 2 > drivers/staging/lustre/lustre/osc/osc_cache.c | 12 - > drivers/staging/lustre/lustre/osc/osc_lock.c | 2 > drivers/staging/lustre/lustre/osc/osc_page.c | 2 > drivers/staging/lustre/lustre/osc/osc_request.c | 2 > 28 files changed, 19 insertions(+), 452 deletions(-) > delete mode 100644 drivers/staging/lustre/lustre/include/lu_ref.h > delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ref.c > > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index 05be85306663..1484821995e9 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -742,12 +742,6 @@ struct cl_page { > * by sub-io. Protected by a VM lock. > */ > struct cl_io *cp_owner; > - /** List of references to this page, for debugging. */ > - struct lu_ref cp_reference; > - /** Link to an object, for debugging. */ > - struct lu_ref_link cp_obj_ref; > - /** Link to a queue, for debugging. */ > - struct lu_ref_link cp_queue_ref; > /** Assigned if doing a sync_io */ > struct cl_sync_io *cp_sync_io; > }; > diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h > index 68aa0d05b03a..cef02e66ea8e 100644 > --- a/drivers/staging/lustre/lustre/include/lu_object.h > +++ b/drivers/staging/lustre/lustre/include/lu_object.h > @@ -38,7 +38,6 @@ > #include > #include > #include > -#include > > struct seq_file; > struct lustre_cfg; > @@ -277,10 +276,6 @@ struct lu_device { > > /** \todo XXX: temporary back pointer into obd. */ > struct obd_device *ld_obd; > - /** > - * A list of references to this object, for debugging. > - */ > - struct lu_ref ld_reference; > /** > * Link the device to the site. > **/ > @@ -464,10 +459,6 @@ struct lu_object { > * Linkage into list of all layers. > */ > struct list_head lo_linkage; > - /** > - * Link to the device, for debugging. > - */ > - struct lu_ref_link lo_dev_ref; > }; > > enum lu_object_header_flags { > @@ -536,10 +527,6 @@ struct lu_object_header { > * during object destruction). No locking is necessary. > */ > struct list_head loh_layers; > - /** > - * A list of references to this object, for debugging. > - */ > - struct lu_ref loh_reference; > }; > > struct fld; > @@ -818,34 +805,6 @@ static inline u32 lu_object_attr(const struct lu_object *o) > return o->lo_header->loh_attr; > } > > -static inline void lu_object_ref_add(struct lu_object *o, > - const char *scope, > - const void *source) > -{ > - lu_ref_add(&o->lo_header->loh_reference, scope, source); > -} > - > -static inline void lu_object_ref_add_at(struct lu_object *o, > - struct lu_ref_link *link, > - const char *scope, > - const void *source) > -{ > - lu_ref_add_at(&o->lo_header->loh_reference, link, scope, source); > -} > - > -static inline void lu_object_ref_del(struct lu_object *o, > - const char *scope, const void *source) > -{ > - lu_ref_del(&o->lo_header->loh_reference, scope, source); > -} > - > -static inline void lu_object_ref_del_at(struct lu_object *o, > - struct lu_ref_link *link, > - const char *scope, const void *source) > -{ > - lu_ref_del_at(&o->lo_header->loh_reference, link, scope, source); > -} > - > /** input params, should be filled out by mdt */ > struct lu_rdpg { > /** hash */ > @@ -1084,10 +1043,6 @@ struct lu_context_key { > * Internal implementation detail: module for this key. > */ > struct module *lct_owner; > - /** > - * References to this key. For debugging. > - */ > - struct lu_ref lct_reference; > }; > > #define LU_KEY_INIT(mod, type) \ > diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h > deleted file mode 100644 > index ad0c24d29ffa..000000000000 > --- a/drivers/staging/lustre/lustre/include/lu_ref.h > +++ /dev/null > @@ -1,178 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0 > -/* > - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. > - * Use is subject to license terms. > - * > - * Copyright (c) 2012, Intel Corporation. > - * > - * Author: Nikita Danilov > - * > - * This file is part of Lustre, http://www.lustre.org. > - * > - * Lustre is free software; you can redistribute it and/or > - * modify it under the terms of version 2 of the GNU General Public > - * License as published by the Free Software Foundation. > - * > - * Lustre is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - * GNU General Public License for more details. > - * > - */ > - > -#ifndef __LUSTRE_LU_REF_H > -#define __LUSTRE_LU_REF_H > - > -#include > - > -/** \defgroup lu_ref lu_ref > - * > - * An interface to track references between objects. Mostly for debugging. > - * > - * Suppose there is a reference counted data-structure struct foo. To track > - * who acquired references to instance of struct foo, add lu_ref field to it: > - * > - * \code > - * struct foo { > - * atomic_t foo_refcount; > - * struct lu_ref foo_reference; > - * ... > - * }; > - * \endcode > - * > - * foo::foo_reference has to be initialized by calling > - * lu_ref_init(). Typically there will be functions or macros to increment and > - * decrement foo::foo_refcount, let's say they are foo_get(struct foo *foo) > - * and foo_put(struct foo *foo), respectively. > - * > - * Whenever foo_get() is called to acquire a reference on a foo, lu_ref_add() > - * has to be called to insert into foo::foo_reference a record, describing > - * acquired reference. Dually, lu_ref_del() removes matching record. Typical > - * usages are: > - * > - * \code > - * struct bar *bar; > - * > - * // bar owns a reference to foo. > - * bar->bar_foo = foo_get(foo); > - * lu_ref_add(&foo->foo_reference, "bar", bar); > - * > - * ... > - * > - * // reference from bar to foo is released. > - * lu_ref_del(&foo->foo_reference, "bar", bar); > - * foo_put(bar->bar_foo); > - * > - * > - * // current thread acquired a temporary reference to foo. > - * foo_get(foo); > - * lu_ref_add(&foo->reference, __func__, current); > - * > - * ... > - * > - * // temporary reference is released. > - * lu_ref_del(&foo->reference, __func__, current); > - * foo_put(foo); > - * \endcode > - * > - * \e Et \e cetera. Often it makes sense to include lu_ref_add() and > - * lu_ref_del() calls into foo_get() and foo_put(). When an instance of struct > - * foo is destroyed, lu_ref_fini() has to be called that checks that no > - * pending references remain. lu_ref_print() can be used to dump a list of > - * pending references, while hunting down a leak. > - * > - * For objects to which a large number of references can be acquired, > - * lu_ref_del() can become cpu consuming, as it has to scan the list of > - * references. To work around this, remember result of lu_ref_add() (usually > - * in the same place where pointer to struct foo is stored), and use > - * lu_ref_del_at(): > - * > - * \code > - * // There is a large number of bar's for a single foo. > - * bar->bar_foo = foo_get(foo); > - * bar->bar_foo_ref = lu_ref_add(&foo->foo_reference, "bar", bar); > - * > - * ... > - * > - * // reference from bar to foo is released. > - * lu_ref_del_at(&foo->foo_reference, bar->bar_foo_ref, "bar", bar); > - * foo_put(bar->bar_foo); > - * \endcode > - * > - * lu_ref interface degrades gracefully in case of memory shortages. > - * > - * @{ > - */ > - > -/* > - * dummy data structures/functions to pass compile for now. > - * We need to reimplement them with kref. > - */ > -struct lu_ref {}; > -struct lu_ref_link {}; > - > -static inline void lu_ref_init(struct lu_ref *ref) > -{ > -} > - > -static inline void lu_ref_fini(struct lu_ref *ref) > -{ > -} > - > -static inline struct lu_ref_link *lu_ref_add(struct lu_ref *ref, > - const char *scope, > - const void *source) > -{ > - return NULL; > -} > - > -static inline struct lu_ref_link *lu_ref_add_atomic(struct lu_ref *ref, > - const char *scope, > - const void *source) > -{ > - return NULL; > -} > - > -static inline void lu_ref_add_at(struct lu_ref *ref, > - struct lu_ref_link *link, > - const char *scope, > - const void *source) > -{ > -} > - > -static inline void lu_ref_del(struct lu_ref *ref, const char *scope, > - const void *source) > -{ > -} > - > -static inline void lu_ref_set_at(struct lu_ref *ref, struct lu_ref_link *link, > - const char *scope, const void *source0, > - const void *source1) > -{ > -} > - > -static inline void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link, > - const char *scope, const void *source) > -{ > -} > - > -static inline int lu_ref_global_init(void) > -{ > - return 0; > -} > - > -static inline void lu_ref_global_fini(void) > -{ > -} > - > -static inline void lu_ref_print(const struct lu_ref *ref) > -{ > -} > - > -static inline void lu_ref_print_all(void) > -{ > -} > - > -/** @} lu */ > - > -#endif /* __LUSTRE_LU_REF_H */ > diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h > index c561d61d1a49..6c0371ef056c 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h > +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h > @@ -49,7 +49,6 @@ > #include > #include > #include > -#include > > #include "lustre_dlm_flags.h" > > @@ -785,8 +784,6 @@ struct ldlm_lock { > struct list_head l_sl_mode; > struct list_head l_sl_policy; > > - /** Reference tracking structure to debug leaked locks. */ > - struct lu_ref l_reference; > #if LUSTRE_TRACKS_LOCK_EXP_REFS > /* Debugging stuff for bug 20498, for tracking export references. */ > /** number of export references taken */ > @@ -859,9 +856,6 @@ struct ldlm_resource { > * Associated inode, used only on client side. > */ > struct inode *lr_lvb_inode; > - > - /** List of references to this resource. For debugging. */ > - struct lu_ref lr_reference; > }; > > static inline bool ldlm_has_layout(struct ldlm_lock *lock) > @@ -1066,17 +1060,12 @@ static inline struct ldlm_lock *ldlm_handle2lock(const struct lustre_handle *h) > return __ldlm_handle2lock(h, 0); > } > > -#define LDLM_LOCK_REF_DEL(lock) \ > - lu_ref_del(&lock->l_reference, "handle", current) > - > static inline struct ldlm_lock * > ldlm_handle2lock_long(const struct lustre_handle *h, u64 flags) > { > struct ldlm_lock *lock; > > lock = __ldlm_handle2lock(h, flags); > - if (lock) > - LDLM_LOCK_REF_DEL(lock); > return lock; > } > > @@ -1107,7 +1096,6 @@ void ldlm_dump_export_locks(struct obd_export *exp); > */ > #define LDLM_LOCK_PUT(lock) \ > do { \ > - LDLM_LOCK_REF_DEL(lock); \ > /*LDLM_DEBUG((lock), "put");*/ \ > ldlm_lock_put(lock); \ > } while (0) > @@ -1198,14 +1186,6 @@ void ldlm_resource_dump(int level, struct ldlm_resource *); > int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *, > const struct ldlm_res_id *); > > -#define LDLM_RESOURCE_ADDREF(res) do { \ > - lu_ref_add_atomic(&(res)->lr_reference, __func__, current); \ > -} while (0) > - > -#define LDLM_RESOURCE_DELREF(res) do { \ > - lu_ref_del(&(res)->lr_reference, __func__, current); \ > -} while (0) > - > /* ldlm_request.c */ > /** \defgroup ldlm_local_ast Default AST handlers for local locks > * These AST handlers are typically used for server-side local locks and are > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index e09268f08e5c..f7f4db0481b2 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -40,7 +40,6 @@ > > #include > #include > -#include > #include > #include > #include > @@ -615,12 +614,6 @@ struct obd_device { > > int obd_conn_inprogress; > > - /** > - * A list of outstanding class_incref()'s against this obd. For > - * debugging. > - */ > - struct lu_ref obd_reference; > - > struct kset obd_kset; /* sysfs object collection */ > struct kobj_type obd_ktype; > struct completion obd_kobj_unregister; > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > index 6789d3bf0485..60a6ec2f7136 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > @@ -175,7 +175,6 @@ void ldlm_lock_put(struct ldlm_lock *lock) > > lprocfs_counter_decr(ldlm_res_to_ns(res)->ns_stats, > LDLM_NSS_LOCKS); > - lu_ref_del(&res->lr_reference, "lock", lock); > ldlm_resource_putref(res); > lock->l_resource = NULL; > if (lock->l_export) { > @@ -185,7 +184,6 @@ void ldlm_lock_put(struct ldlm_lock *lock) > > kfree(lock->l_lvb_data); > > - lu_ref_fini(&lock->l_reference); > OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle); > } > } > @@ -334,10 +332,8 @@ static void ldlm_lock_destroy(struct ldlm_lock *lock) > unlock_res_and_lock(lock); > > /* drop reference from hashtable only for first destroy */ > - if (first) { > - lu_ref_del(&lock->l_reference, "hash", lock); > + if (first) > LDLM_LOCK_RELEASE(lock); > - } > } > > /** > @@ -349,10 +345,8 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) > > first = ldlm_lock_destroy_internal(lock); > /* drop reference from hashtable only for first destroy */ > - if (first) { > - lu_ref_del(&lock->l_reference, "hash", lock); > + if (first) > LDLM_LOCK_RELEASE(lock); > - } > } > > /* this is called by portals_handle2object with the handle lock taken */ > @@ -392,7 +386,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) > > spin_lock_init(&lock->l_lock); > lock->l_resource = resource; > - lu_ref_add(&resource->lr_reference, "lock", lock); > > atomic_set(&lock->l_refc, 2); > INIT_LIST_HEAD(&lock->l_res_link); > @@ -412,8 +405,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) > INIT_LIST_HEAD(&lock->l_handle.h_link); > class_handle_hash(&lock->l_handle, &lock_handle_ops); > > - lu_ref_init(&lock->l_reference); > - lu_ref_add(&lock->l_reference, "hash", lock); > lock->l_callback_timeout = 0; > > #if LUSTRE_TRACKS_LOCK_EXP_REFS > @@ -457,7 +448,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, > if (IS_ERR(newres)) > return PTR_ERR(newres); > > - lu_ref_add(&newres->lr_reference, "lock", lock); > /* > * To flip the lock from the old to the new resource, lock, oldres and > * newres have to be locked. Resource spin-locks are nested within > @@ -480,7 +470,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, > unlock_res_and_lock(lock); > > /* ...and the flowers are still standing! */ > - lu_ref_del(&oldres->lr_reference, "lock", lock); > ldlm_resource_putref(oldres); > > return 0; > @@ -528,16 +517,13 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, > /* It's unlikely but possible that someone marked the lock as > * destroyed after we did handle2object on it > */ > - if (flags == 0 && !ldlm_is_destroyed(lock)) { > - lu_ref_add(&lock->l_reference, "handle", current); > + if (flags == 0 && !ldlm_is_destroyed(lock)) > return lock; > - } > > lock_res_and_lock(lock); > > LASSERT(lock->l_resource); > > - lu_ref_add_atomic(&lock->l_reference, "handle", current); > if (unlikely(ldlm_is_destroyed(lock))) { > unlock_res_and_lock(lock); > CDEBUG(D_INFO, "lock already destroyed: lock %p\n", lock); > @@ -658,16 +644,13 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock, > enum ldlm_mode mode) > { > ldlm_lock_remove_from_lru(lock); > - if (mode & (LCK_NL | LCK_CR | LCK_PR)) { > + if (mode & (LCK_NL | LCK_CR | LCK_PR)) > lock->l_readers++; > - lu_ref_add_atomic(&lock->l_reference, "reader", lock); > - } > - if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) { > + > + if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) > lock->l_writers++; > - lu_ref_add_atomic(&lock->l_reference, "writer", lock); > - } > + > LDLM_LOCK_GET(lock); > - lu_ref_add_atomic(&lock->l_reference, "user", lock); > LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]); > } > > @@ -725,16 +708,13 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock, > LDLM_DEBUG(lock, "ldlm_lock_decref(%s)", ldlm_lockname[mode]); > if (mode & (LCK_NL | LCK_CR | LCK_PR)) { > LASSERT(lock->l_readers > 0); > - lu_ref_del(&lock->l_reference, "reader", lock); > lock->l_readers--; > } > if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP | LCK_COS)) { > LASSERT(lock->l_writers > 0); > - lu_ref_del(&lock->l_reference, "writer", lock); > lock->l_writers--; > } > > - lu_ref_del(&lock->l_reference, "user", lock); > LDLM_LOCK_RELEASE(lock); /* matches the LDLM_LOCK_GET() in addref */ > } > > @@ -1285,7 +1265,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags, > return 0; > } > > - LDLM_RESOURCE_ADDREF(res); > lock_res(res); > > if (res->lr_type == LDLM_EXTENT) > @@ -1307,7 +1286,6 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, u64 flags, > } > out: > unlock_res(res); > - LDLM_RESOURCE_DELREF(res); > ldlm_resource_putref(res); > > if (lock) { > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > index b819adef2bfe..1f04a782bd89 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > @@ -1423,7 +1423,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, > > LDLM_LOCK_GET(lock); > spin_unlock(&ns->ns_lock); > - lu_ref_add(&lock->l_reference, __func__, current); > > /* Pass the lock through the policy filter and see if it > * should stay in LRU. > @@ -1441,15 +1440,11 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, > */ > result = pf(ns, lock, unused, added, count); > if (result == LDLM_POLICY_KEEP_LOCK) { > - lu_ref_del(&lock->l_reference, > - __func__, current); > LDLM_LOCK_RELEASE(lock); > spin_lock(&ns->ns_lock); > break; > } > if (result == LDLM_POLICY_SKIP_LOCK) { > - lu_ref_del(&lock->l_reference, > - __func__, current); > LDLM_LOCK_RELEASE(lock); > spin_lock(&ns->ns_lock); > continue; > @@ -1467,8 +1462,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, > * pages could be put under it. > */ > unlock_res_and_lock(lock); > - lu_ref_del(&lock->l_reference, > - __func__, current); > LDLM_LOCK_RELEASE(lock); > spin_lock(&ns->ns_lock); > continue; > @@ -1507,7 +1500,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, > LASSERT(list_empty(&lock->l_bl_ast)); > list_add(&lock->l_bl_ast, cancels); > unlock_res_and_lock(lock); > - lu_ref_del(&lock->l_reference, __func__, current); > spin_lock(&ns->ns_lock); > added++; > unused--; > @@ -1695,7 +1687,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, > return 0; > } > > - LDLM_RESOURCE_ADDREF(res); > count = ldlm_cancel_resource_local(res, &cancels, policy, mode, > 0, flags | LCF_BL_AST, opaque); > rc = ldlm_cli_cancel_list(&cancels, count, NULL, flags); > @@ -1703,7 +1694,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, > CERROR("canceling unused lock " DLDLMRES ": rc = %d\n", > PLDLMRES(res), rc); > > - LDLM_RESOURCE_DELREF(res); > ldlm_resource_putref(res); > return 0; > } > @@ -1843,9 +1833,7 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns, > if (IS_ERR(res)) > return 0; > > - LDLM_RESOURCE_ADDREF(res); > rc = ldlm_resource_foreach(res, iter, data); > - LDLM_RESOURCE_DELREF(res); > ldlm_resource_putref(res); > return rc; > } > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index ae2fddd044ea..371cc1d5e539 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -1021,7 +1021,6 @@ static struct ldlm_resource *ldlm_resource_new(enum ldlm_type ldlm_type) > > atomic_set(&res->lr_refcount, 1); > spin_lock_init(&res->lr_lock); > - lu_ref_init(&res->lr_reference); > > /* The creator of the resource must unlock the mutex after LVB > * initialization. > @@ -1084,8 +1083,6 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, > if (hnode) { > /* Someone won the race and already added the resource. */ > cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); > - /* Clean lu_ref for failed resource. */ > - lu_ref_fini(&res->lr_reference); > /* We have taken lr_lvb_mutex. Drop it. */ > mutex_unlock(&res->lr_lvb_mutex); > if (res->lr_itree) > @@ -1163,7 +1160,6 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd, > > cfs_hash_bd_del_locked(ns->ns_rs_hash, > bd, &res->lr_hash); > - lu_ref_fini(&res->lr_reference); > cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1); > if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) > ns->ns_lvbo->lvbo_free(res); > diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c > index afcaa5ec13c2..94299fc2f5e3 100644 > --- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c > +++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c > @@ -179,7 +179,6 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md) > * locked by I_NEW bit. > */ > lli->lli_clob = clob; > - lu_object_ref_add(&clob->co_lu, "inode", inode); > } else { > result = PTR_ERR(clob); > } > @@ -254,7 +253,6 @@ void cl_inode_fini(struct inode *inode) > * when its master is evicted. > */ > cl_object_kill(env, clob); > - lu_object_ref_del(&clob->co_lu, "inode", inode); > cl_object_put_last(env, clob); > lli->lli_clob = NULL; > if (emergency) > diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c > index af983ee09e8e..185d1692d79b 100644 > --- a/drivers/staging/lustre/lustre/llite/rw.c > +++ b/drivers/staging/lustre/lustre/llite/rw.c > @@ -209,7 +209,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, > goto out; > } > > - lu_ref_add(&page->cp_reference, "ra", current); > cl_page_assume(env, io, page); > vpg = cl2vvp_page(cl_object_page_slice(clob, page)); > if (!vpg->vpg_defer_uptodate && !PageUptodate(vmpage)) { > @@ -225,7 +224,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, > rc = 1; > } > > - lu_ref_del(&page->cp_reference, "ra", current); > cl_page_put(env, page); > out: > if (vmpage) { > @@ -936,8 +934,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) > page = cl_page_find(env, clob, vmpage->index, > vmpage, CPT_CACHEABLE); > if (!IS_ERR(page)) { > - lu_ref_add(&page->cp_reference, "writepage", > - current); > cl_page_assume(env, io, page); > result = cl_page_flush(env, io, page); > if (result != 0) { > @@ -954,8 +950,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) > } > cl_page_disown(env, io, page); > unlocked = true; > - lu_ref_del(&page->cp_reference, > - "writepage", current); > cl_page_put(env, page); > } else { > result = PTR_ERR(page); > diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c > index e4ce3b6f5772..9bcbc8b084e5 100644 > --- a/drivers/staging/lustre/lustre/llite/rw26.c > +++ b/drivers/staging/lustre/lustre/llite/rw26.c > @@ -482,7 +482,6 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, > } > > lcc->lcc_page = page; > - lu_ref_add(&page->cp_reference, "cl_io", io); > > cl_page_assume(env, io, page); > if (!PageUptodate(vmpage)) { > @@ -511,10 +510,8 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, > unlock_page(vmpage); > put_page(vmpage); > } > - if (!IS_ERR_OR_NULL(page)) { > - lu_ref_del(&page->cp_reference, "cl_io", io); > + if (!IS_ERR_OR_NULL(page)) > cl_page_put(env, page); > - } > if (io) > io->ci_result = result; > } else { > @@ -575,7 +572,6 @@ static int ll_write_end(struct file *file, struct address_space *mapping, > cl_page_disown(env, io, page); > > lcc->lcc_page = NULL; > - lu_ref_del(&page->cp_reference, "cl_io", io); > cl_page_put(env, page); > > /* page list is not contiguous now, commit it now */ > diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c > index c10ca6e7c606..34206166ada4 100644 > --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c > +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c > @@ -240,10 +240,9 @@ static int vvp_device_init(const struct lu_env *env, struct lu_device *d, > rc = next->ld_type->ldt_ops->ldto_device_init(env, next, > next->ld_type->ldt_name, > NULL); > - if (rc == 0) { > + if (rc == 0) > lu_device_get(next); > - lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); > - } > + > return rc; > } > > @@ -420,10 +419,9 @@ static struct cl_object *vvp_pgcache_obj(const struct lu_env *env, > struct lu_object *lu_obj; > > lu_obj = lu_object_locate(id->vpi_obj, dev->ld_type); > - if (lu_obj) { > - lu_object_ref_add(lu_obj, "dump", current); > + if (lu_obj) > return lu2cl(lu_obj); > - } > + > lu_object_put(env, lu_object_top(id->vpi_obj)); > } > return NULL; > @@ -456,7 +454,6 @@ static struct page *vvp_pgcache_current(struct vvp_seq_private *priv) > priv->vsp_id.vpi_index = vmpage->index; > return vmpage; > } > - lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current); > cl_object_put(priv->vsp_env, priv->vsp_clob); > priv->vsp_clob = NULL; > priv->vsp_id.vpi_index = 0; > @@ -527,11 +524,8 @@ static void vvp_pgcache_rewind(struct vvp_seq_private *priv) > if (priv->vsp_prev_pos) { > memset(&priv->vsp_id, 0, sizeof(priv->vsp_id)); > priv->vsp_prev_pos = 0; > - if (priv->vsp_clob) { > - lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", > - current); > + if (priv->vsp_clob) > cl_object_put(priv->vsp_env, priv->vsp_clob); > - } > priv->vsp_clob = NULL; > } > } > @@ -607,10 +601,8 @@ static int vvp_dump_pgcache_seq_release(struct inode *inode, struct file *file) > struct seq_file *seq = file->private_data; > struct vvp_seq_private *priv = seq->private; > > - if (priv->vsp_clob) { > - lu_object_ref_del(&priv->vsp_clob->co_lu, "dump", current); > + if (priv->vsp_clob) > cl_object_put(priv->vsp_env, priv->vsp_clob); > - } > > cl_env_put(priv->vsp_env, &priv->vsp_refcheck); > return seq_release_private(inode, file); > diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c > index 593b10cecf7d..62b507926c20 100644 > --- a/drivers/staging/lustre/lustre/llite/vvp_io.c > +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c > @@ -382,7 +382,6 @@ static void vvp_io_fault_fini(const struct lu_env *env, > CLOBINVRNT(env, io->ci_obj, vvp_object_invariant(io->ci_obj)); > > if (page) { > - lu_ref_del(&page->cp_reference, "fault", io); > cl_page_put(env, page); > io->u.ci_fault.ft_page = NULL; > } > @@ -824,7 +823,6 @@ static int vvp_io_commit_sync(const struct lu_env *env, struct cl_io *io, > cl_page_disown(env, io, page); > > /* held in ll_cl_init() */ > - lu_ref_del(&page->cp_reference, "cl_io", io); > cl_page_put(env, page); > } > } > @@ -843,7 +841,6 @@ static void write_commit_callback(const struct lu_env *env, struct cl_io *io, > cl_page_disown(env, io, page); > > /* held in ll_cl_init() */ > - lu_ref_del(&page->cp_reference, "cl_io", cl_io_top(io)); > cl_page_put(env, page); > } > > @@ -944,7 +941,6 @@ int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io) > cl_page_disown(env, io, page); > > /* held in ll_cl_init() */ > - lu_ref_del(&page->cp_reference, "cl_io", io); > cl_page_put(env, page); > } > cl_page_list_fini(env, queue); > @@ -1260,7 +1256,6 @@ static int vvp_io_fault_start(const struct lu_env *env, > else > fio->ft_nob = cl_page_size(obj); > > - lu_ref_add(&page->cp_reference, "fault", io); > fio->ft_page = page; > > out: > diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c > index 397ecc1dbb4c..cde8215a0b4c 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_object.c > +++ b/drivers/staging/lustre/lustre/lov/lov_object.c > @@ -149,7 +149,6 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, > subhdr->coh_parent = hdr; > spin_unlock(&subhdr->coh_attr_guard); > subhdr->coh_nesting = hdr->coh_nesting + 1; > - lu_object_ref_add(&subobj->co_lu, "lov-parent", lov); > r0->lo_sub[stripe] = cl2lovsub(subobj); > r0->lo_sub[stripe]->lso_super = lov; > r0->lo_sub[stripe]->lso_index = idx; > @@ -405,7 +404,6 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov, > > cl_object_kill(env, sub); > /* release a reference to the sub-object and ... */ > - lu_object_ref_del(&sub->co_lu, "lov-parent", lov); > cl_object_put(env, sub); > > /* ... wait until it is actually destroyed---sub-object clears its > diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c > index 69380fc6aeab..d9b044e5aca1 100644 > --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c > +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c > @@ -65,7 +65,6 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d, > } > > lu_device_get(next); > - lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); > lsd->acid_next = lu2cl_dev(next); > return rc; > } > diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c > index e0e7b00fd2be..e878bc76da8a 100644 > --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c > +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c > @@ -87,12 +87,10 @@ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid, > NULL, &res_id, 0, 0); > if (IS_ERR(res)) > return 0; > - LDLM_RESOURCE_ADDREF(res); > /* Initialize ibits lock policy. */ > policy.l_inodebits.bits = bits; > count = ldlm_cancel_resource_local(res, cancels, &policy, > mode, 0, 0, NULL); > - LDLM_RESOURCE_DELREF(res); > ldlm_resource_putref(res); > return count; > } > diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile > index 1669c24a0b03..ee63ebd3947b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/Makefile > +++ b/drivers/staging/lustre/lustre/obdclass/Makefile > @@ -7,5 +7,5 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o > obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o \ > genops.o obd_sysfs.o lprocfs_status.o lprocfs_counters.o \ > lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ > - obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \ > + obdo.o obd_config.o obd_mount.o lu_object.o \ > cl_object.o cl_page.o cl_lock.o cl_io.o kernelcomm.o > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > index 3b4aca4e4a53..9755174c2db6 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c > @@ -770,7 +770,6 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) > LASSERT(list_empty(&page->cp_batch)); > list_add_tail(&page->cp_batch, &plist->pl_pages); > ++plist->pl_nr; > - lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); > cl_page_get(page); > } > EXPORT_SYMBOL(cl_page_list_add); > @@ -787,7 +786,6 @@ void cl_page_list_del(const struct lu_env *env, struct cl_page_list *plist, > > list_del_init(&page->cp_batch); > --plist->pl_nr; > - lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); > cl_page_put(env, page); > } > EXPORT_SYMBOL(cl_page_list_del); > @@ -805,8 +803,6 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src, > list_move_tail(&page->cp_batch, &dst->pl_pages); > --src->pl_nr; > ++dst->pl_nr; > - lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue", > - src, dst); > } > EXPORT_SYMBOL(cl_page_list_move); > > @@ -823,8 +819,6 @@ void cl_page_list_move_head(struct cl_page_list *dst, struct cl_page_list *src, > list_move(&page->cp_batch, &dst->pl_pages); > --src->pl_nr; > ++dst->pl_nr; > - lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue", > - src, dst); > } > EXPORT_SYMBOL(cl_page_list_move_head); > > @@ -869,8 +863,6 @@ void cl_page_list_disown(const struct lu_env *env, > * XXX __cl_page_disown() will fail if page is not locked. > */ > __cl_page_disown(env, io, page); > - lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", > - plist); > cl_page_put(env, page); > } > } > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index b09621f0f1f8..c7cf2e736ff7 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -924,8 +924,6 @@ struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site, > rc = ldt->ldt_ops->ldto_device_init(env, d, typename, next); > if (rc == 0) { > lu_device_get(d); > - lu_ref_add(&d->ld_reference, > - "lu-stack", &lu_site_init); > } else { > ldt->ldt_ops->ldto_device_free(env, d); > CERROR("can't init device '%s', %d\n", typename, rc); > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c > index 7dcd3aff229f..a44533a063df 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c > @@ -106,9 +106,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) > if (unlikely(slice->cpl_ops->cpo_fini)) > slice->cpl_ops->cpo_fini(env, slice); > } > - lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); > cl_object_put(env, obj); > - lu_ref_fini(&page->cp_reference); > kfree(page); > } > > @@ -138,14 +136,11 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, > refcount_set(&page->cp_ref, 1); > page->cp_obj = o; > cl_object_get(o); > - lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page", > - page); > page->cp_vmpage = vmpage; > cl_page_state_set_trust(page, CPS_CACHED); > page->cp_type = type; > INIT_LIST_HEAD(&page->cp_layers); > INIT_LIST_HEAD(&page->cp_batch); > - lu_ref_init(&page->cp_reference); > cl_object_for_each(o2, o) { > if (o2->co_ops->coo_page_init) { > result = o2->co_ops->coo_page_init(env, o2, page, > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index c91704d87042..ce92c8c1dc75 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -80,7 +80,6 @@ static void obd_device_free(struct obd_device *obd) > obd, obd->obd_namespace, obd->obd_force); > LBUG(); > } > - lu_ref_fini(&obd->obd_reference); > kmem_cache_free(obd_device_cachep, obd); > } > > @@ -314,8 +313,6 @@ struct obd_device *class_newdev(const char *type_name, const char *name, > llog_group_init(&newdev->obd_olg); > /* Detach drops this */ > atomic_set(&newdev->obd_refcount, 1); > - lu_ref_init(&newdev->obd_reference); > - lu_ref_add(&newdev->obd_reference, "newdev", newdev); > > newdev->obd_conn_inprogress = 0; > > diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c > index 3e23babb329a..6a1c3bc3e9e8 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c > @@ -52,7 +52,6 @@ > #include > #include > #include > -#include > #include > > struct lu_site_bkt_data { > @@ -1018,7 +1017,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) > s->ls_top_dev = top; > top->ld_site = s; > lu_device_get(top); > - lu_ref_add(&top->ld_reference, "site-top", s); > > INIT_LIST_HEAD(&s->ls_ld_linkage); > spin_lock_init(&s->ls_ld_lock); > @@ -1047,7 +1045,6 @@ void lu_site_fini(struct lu_site *s) > > if (s->ls_top_dev) { > s->ls_top_dev->ld_site = NULL; > - lu_ref_del(&s->ls_top_dev->ld_reference, "site-top", s); > lu_device_put(s->ls_top_dev); > s->ls_top_dev = NULL; > } > @@ -1104,7 +1101,6 @@ int lu_device_init(struct lu_device *d, struct lu_device_type *t) > memset(d, 0, sizeof(*d)); > atomic_set(&d->ld_ref, 0); > d->ld_type = t; > - lu_ref_init(&d->ld_reference); > INIT_LIST_HEAD(&d->ld_linkage); > return 0; > } > @@ -1122,7 +1118,6 @@ void lu_device_fini(struct lu_device *d) > d->ld_obd = NULL; > } > > - lu_ref_fini(&d->ld_reference); > LASSERTF(atomic_read(&d->ld_ref) == 0, > "Refcount is %u\n", atomic_read(&d->ld_ref)); > LASSERT(atomic_read(&t->ldt_device_nr) > 0); > @@ -1144,7 +1139,6 @@ int lu_object_init(struct lu_object *o, struct lu_object_header *h, > o->lo_header = h; > o->lo_dev = d; > lu_device_get(d); > - lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o); > INIT_LIST_HEAD(&o->lo_linkage); > > return 0; > @@ -1161,8 +1155,6 @@ void lu_object_fini(struct lu_object *o) > LASSERT(list_empty(&o->lo_linkage)); > > if (dev) { > - lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref, > - "lu_object", o); > lu_device_put(dev); > o->lo_dev = NULL; > } > @@ -1203,7 +1195,6 @@ int lu_object_header_init(struct lu_object_header *h) > INIT_HLIST_NODE(&h->loh_hash); > INIT_LIST_HEAD(&h->loh_lru); > INIT_LIST_HEAD(&h->loh_layers); > - lu_ref_init(&h->loh_reference); > return 0; > } > EXPORT_SYMBOL(lu_object_header_init); > @@ -1216,7 +1207,6 @@ void lu_object_header_fini(struct lu_object_header *h) > LASSERT(list_empty(&h->loh_layers)); > LASSERT(list_empty(&h->loh_lru)); > LASSERT(hlist_unhashed(&h->loh_hash)); > - lu_ref_fini(&h->loh_reference); > } > EXPORT_SYMBOL(lu_object_header_fini); > > @@ -1253,7 +1243,6 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) > lu_site_purge(env, site, ~0); > for (scan = top; scan; scan = next) { > next = scan->ld_type->ldt_ops->ldto_device_fini(env, scan); > - lu_ref_del(&scan->ld_reference, "lu-stack", &lu_site_init); > lu_device_put(scan); > } > > @@ -1306,7 +1295,6 @@ int lu_context_key_register(struct lu_context_key *key) > > result = -ENFILE; > atomic_set(&key->lct_used, 1); > - lu_ref_init(&key->lct_reference); > for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { > if (lu_keys[i]) > continue; > @@ -1318,10 +1306,9 @@ int lu_context_key_register(struct lu_context_key *key) > atomic_inc(&key_set_version); > break; > } > - if (result) { > - lu_ref_fini(&key->lct_reference); > + if (result) > atomic_set(&key->lct_used, 0); > - } > + > return result; > } > EXPORT_SYMBOL(lu_context_key_register); > @@ -1335,7 +1322,6 @@ static void key_fini(struct lu_context *ctx, int index) > LASSERT(atomic_read(&key->lct_used) > 1); > > key->lct_fini(ctx, key, ctx->lc_value[index]); > - lu_ref_del(&key->lct_reference, "ctx", ctx); > if (atomic_dec_and_test(&key->lct_used)) > wake_up_var(&key->lct_used); > > @@ -1364,8 +1350,7 @@ void lu_context_key_degister(struct lu_context_key *key) > atomic_dec(&key->lct_used); > wait_var_event(&key->lct_used, atomic_read(&key->lct_used) == 0); > > - if (!WARN_ON(lu_keys[key->lct_index] == NULL)) > - lu_ref_fini(&key->lct_reference); > + WARN_ON(lu_keys[key->lct_index] == NULL); > smp_store_release(&lu_keys[key->lct_index], NULL); > } > EXPORT_SYMBOL(lu_context_key_degister); > @@ -1562,7 +1547,6 @@ static int keys_fill(struct lu_context *ctx) > break; > } > > - lu_ref_add_atomic(&key->lct_reference, "ctx", ctx); > atomic_inc(&key->lct_used); > /* > * This is the only place in the code, where an > @@ -1873,16 +1857,10 @@ int lu_global_init(void) > > CDEBUG(D_INFO, "Lustre LU module (%p).\n", &lu_keys); > > - result = lu_ref_global_init(); > - if (result != 0) > - return result; > - > LU_CONTEXT_KEY_INIT(&lu_global_key); > result = lu_context_key_register(&lu_global_key); > - if (result != 0) { > - lu_ref_global_fini(); > + if (result != 0) > return result; > - } > > /* > * At this level, we don't know what tags are needed, so allocate them > @@ -1894,7 +1872,6 @@ int lu_global_init(void) > up_write(&lu_sites_guard); > if (result != 0) { > lu_context_key_degister(&lu_global_key); > - lu_ref_global_fini(); > return result; > } > > @@ -1912,7 +1889,6 @@ int lu_global_init(void) > lu_env_fini(&lu_shrink_env); > up_write(&lu_sites_guard); > > - lu_ref_global_fini(); > return result; > } > > @@ -1934,8 +1910,6 @@ void lu_global_fini(void) > down_write(&lu_sites_guard); > lu_env_fini(&lu_shrink_env); > up_write(&lu_sites_guard); > - > - lu_ref_global_fini(); > } > > static u32 ls_stats_read(struct lprocfs_stats *stats, int idx) > diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c > deleted file mode 100644 > index f67cb89ea0ba..000000000000 > --- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c > +++ /dev/null > @@ -1,45 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0 > -/* > - * GPL HEADER START > - * > - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License version 2 only, > - * as published by the Free Software Foundation. > - * > - * This program is distributed in the hope that it will be useful, but > - * WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - * General Public License version 2 for more details (a copy is included > - * in the LICENSE file that accompanied this code). > - * > - * You should have received a copy of the GNU General Public License > - * version 2 along with this program; If not, see > - * http://www.gnu.org/licenses/gpl-2.0.html > - * > - * GPL HEADER END > - */ > -/* > - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. > - * Use is subject to license terms. > - * > - * Copyright (c) 2012, Intel Corporation. > - */ > -/* > - * This file is part of Lustre, http://www.lustre.org/ > - * Lustre is a trademark of Sun Microsystems, Inc. > - * > - * lustre/obdclass/lu_ref.c > - * > - * Lustre reference. > - * > - * Author: Nikita Danilov > - */ > - > -#define DEBUG_SUBSYSTEM S_CLASS > - > -#include > -#include > -#include > -#include > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c > index 0cdadea4e63c..45e8f03dec80 100644 > --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c > +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c > @@ -520,7 +520,6 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) > struct obd_device *class_incref(struct obd_device *obd, > const char *scope, const void *source) > { > - lu_ref_add_atomic(&obd->obd_reference, scope, source); > atomic_inc(&obd->obd_refcount); > CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd, > atomic_read(&obd->obd_refcount)); > @@ -538,7 +537,6 @@ void class_decref(struct obd_device *obd, const char *scope, const void *source) > > LASSERT(obd->obd_num_exports >= 0); > last = atomic_dec_and_test(&obd->obd_refcount); > - lu_ref_del(&obd->obd_reference, scope, source); > > if (last) { > struct obd_export *exp; > diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c > index 4359a9320f37..81af452fbd85 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_cache.c > +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c > @@ -388,8 +388,6 @@ static void osc_extent_free(struct kref *kref) > LASSERT(RB_EMPTY_NODE(&ext->oe_node)); > > if (ext->oe_dlmlock) { > - lu_ref_add(&ext->oe_dlmlock->l_reference, > - "osc_extent", ext); > LDLM_LOCK_PUT(ext->oe_dlmlock); > ext->oe_dlmlock = NULL; > } > @@ -731,7 +729,6 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env, > if (olck->ols_dlmlock) { > LASSERT(olck->ols_hold); > cur->oe_dlmlock = LDLM_LOCK_GET(olck->ols_dlmlock); > - lu_ref_add(&olck->ols_dlmlock->l_reference, "osc_extent", cur); > } > > /* grants has been allocated by caller */ > @@ -1039,7 +1036,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, > list_del_init(&oap->oap_pending_item); > > cl_page_get(page); > - lu_ref_add(&page->cp_reference, "truncate", current); > > if (cl_page_own(env, io, page) == 0) { > cl_page_discard(env, io, page); > @@ -1049,7 +1045,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, > LASSERT(0); > } > > - lu_ref_del(&page->cp_reference, "truncate", current); > cl_page_put(env, page); > > --ext->oe_nr_pages; > @@ -1386,7 +1381,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, > * released in cl_page_completion() and nothing except for the > * reference counter protects page from concurrent reclaim. > */ > - lu_ref_del(&page->cp_reference, "transfer", page); > > cl_page_completion(env, page, crt, rc); > cl_page_put(env, page); > @@ -2208,7 +2202,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) > spin_lock(&cli->cl_loi_list_lock); > while ((osc = osc_next_obj(cli)) != NULL) { > struct cl_object *obj = osc2cl(osc); > - struct lu_ref_link link; > > OSC_IO_DEBUG(osc, "%lu in flight\n", rpcs_in_flight(cli)); > > @@ -2219,7 +2212,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) > > cl_object_get(obj); > spin_unlock(&cli->cl_loi_list_lock); > - lu_object_ref_add_at(&obj->co_lu, &link, "check", current); > > /* attempt some read/write balancing by alternating between > * reads and writes in an object. The makes_rpc checks here > @@ -2256,7 +2248,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) > CERROR("Read request failed with %d\n", rc); > > osc_list_maint(cli, osc); > - lu_object_ref_del_at(&obj->co_lu, &link, "check", current); > cl_object_put(env, obj); > > spin_lock(&cli->cl_loi_list_lock); > @@ -3065,8 +3056,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, > continue; > > cl_page_get(page); > - lu_ref_add_atomic(&page->cp_reference, > - "gang_lookup", current); > pvec[j++] = ops; > } > ++idx; > @@ -3088,7 +3077,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io, > res = (*cb)(env, io, ops, cbdata); > > page = ops->ops_cl.cpl_page; > - lu_ref_del(&page->cp_reference, "gang_lookup", current); > cl_page_put(env, page); > } > if (nr < OTI_PVEC_SIZE || end_of_region) > diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c > index bfc1abb47b49..ccdbdeffd1f3 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_lock.c > +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c > @@ -239,7 +239,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *oscl, > /* lock reference taken by ldlm_handle2lock_long() is > * owned by osc_lock and released in osc_lock_detach() > */ > - lu_ref_add(&dlmlock->l_reference, "osc_lock", oscl); > oscl->ols_has_ref = 1; > > LASSERT(!oscl->ols_dlmlock); > @@ -1031,7 +1030,6 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck) > > /* release a reference taken in osc_lock_upcall(). */ > LASSERT(olck->ols_has_ref); > - lu_ref_del(&dlmlock->l_reference, "osc_lock", olck); > LDLM_LOCK_RELEASE(dlmlock); > olck->ols_has_ref = 0; > } > diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c > index ce911b82512d..3ee7f14f7c7a 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_page.c > +++ b/drivers/staging/lustre/lustre/osc/osc_page.c > @@ -61,7 +61,6 @@ static void osc_page_transfer_get(struct osc_page *opg, const char *label) > > LASSERT(!opg->ops_transfer_pinned); > cl_page_get(page); > - lu_ref_add_atomic(&page->cp_reference, label, page); > opg->ops_transfer_pinned = 1; > } > > @@ -72,7 +71,6 @@ static void osc_page_transfer_put(const struct lu_env *env, > > if (opg->ops_transfer_pinned) { > opg->ops_transfer_pinned = 0; > - lu_ref_del(&page->cp_reference, "transfer", page); > cl_page_put(env, page); > } > } > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 765b5a7b9662..6ba443be1026 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -556,10 +556,8 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, > if (IS_ERR(res)) > return 0; > > - LDLM_RESOURCE_ADDREF(res); > count = ldlm_cancel_resource_local(res, cancels, NULL, mode, > lock_flags, 0, NULL); > - LDLM_RESOURCE_DELREF(res); > ldlm_resource_putref(res); > return count; > } > > > From jsimmons at infradead.org Sun Feb 24 20:29:22 2019 From: jsimmons at infradead.org (James Simmons) Date: Sun, 24 Feb 2019 20:29:22 +0000 (GMT) Subject: [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock. In-Reply-To: <155053494552.24125.3519300273247156099.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494552.24125.3519300273247156099.stgit@noble.brown> Message-ID: > This lock is unused on the client (and on the server, > it has been changed to a mutex). Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/include/lustre_log.h | 1 - > drivers/staging/lustre/lustre/obdclass/llog.c | 1 - > 2 files changed, 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h > index a576d40f03f7..e96bd6ab0fa4 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_log.h > +++ b/drivers/staging/lustre/lustre/include/lustre_log.h > @@ -212,7 +212,6 @@ struct llog_operations { > /* In-memory descriptor for a log object or log catalog */ > struct llog_handle { > struct rw_semaphore lgh_lock; > - spinlock_t lgh_hdr_lock; /* protect lgh_hdr data */ > struct llog_logid lgh_id; /* id of this log */ > struct llog_log_hdr *lgh_hdr; > size_t lgh_hdr_size; > diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c > index 7aa459bb444e..9d161c16c2f9 100644 > --- a/drivers/staging/lustre/lustre/obdclass/llog.c > +++ b/drivers/staging/lustre/lustre/obdclass/llog.c > @@ -64,7 +64,6 @@ static struct llog_handle *llog_alloc_handle(void) > return NULL; > > init_rwsem(&loghandle->lgh_lock); > - spin_lock_init(&loghandle->lgh_hdr_lock); > INIT_LIST_HEAD(&loghandle->u.phd.phd_entry); > atomic_set(&loghandle->lgh_refcount, 1); > > > > From adilger at whamcloud.com Mon Feb 25 18:16:14 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:14 +0000 Subject: [lustre-devel] [PATCH 13/37] lustre: llog: remove lgh_hdr_lock. In-Reply-To: <155053494552.24125.3519300273247156099.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494552.24125.3519300273247156099.stgit@noble.brown> Message-ID: <9D202678-E403-4A3E-B3A1-D304B7DC7298@whamcloud.com> > On Feb 18, 2019, at 16:09, NeilBrown wrote: > > This lock is unused on the client (and on the server, > it has been changed to a mutex). > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/lustre/include/lustre_log.h | 1 - > drivers/staging/lustre/lustre/obdclass/llog.c | 1 - > 2 files changed, 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h > index a576d40f03f7..e96bd6ab0fa4 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_log.h > +++ b/drivers/staging/lustre/lustre/include/lustre_log.h > @@ -212,7 +212,6 @@ struct llog_operations { > /* In-memory descriptor for a log object or log catalog */ > struct llog_handle { > struct rw_semaphore lgh_lock; > - spinlock_t lgh_hdr_lock; /* protect lgh_hdr data */ > struct llog_logid lgh_id; /* id of this log */ > struct llog_log_hdr *lgh_hdr; > size_t lgh_hdr_size; > diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c > index 7aa459bb444e..9d161c16c2f9 100644 > --- a/drivers/staging/lustre/lustre/obdclass/llog.c > +++ b/drivers/staging/lustre/lustre/obdclass/llog.c > @@ -64,7 +64,6 @@ static struct llog_handle *llog_alloc_handle(void) > return NULL; > > init_rwsem(&loghandle->lgh_lock); > - spin_lock_init(&loghandle->lgh_hdr_lock); > INIT_LIST_HEAD(&loghandle->u.phd.phd_entry); > atomic_set(&loghandle->lgh_refcount, 1); > > > Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:18 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:18 +0000 Subject: [lustre-devel] [PATCH 15/37] lustre: llog_obd: Convert loc_refcount to refcount_t In-Reply-To: <155053494563.24125.5471194386420442456.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494563.24125.5471194386420442456.stgit@noble.brown> Message-ID: <266DFBB3-84F6-4E10-99FB-0F37636D60AE@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > Make this a refcount_t for clarity, and also > use refcount_dec_and_lock() rather than having separate > lock and dec calls. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:15 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:15 +0000 Subject: [lustre-devel] [PATCH 12/37] lustre: remove unused function in linkea. In-Reply-To: <155053494549.24125.14755296858886216830.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494549.24125.14755296858886216830.stgit@noble.brown> Message-ID: <297EF5E9-FF08-489E-AD60-BAADA85B5A02@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > Much of the linkea functionality is server-only. > Keep the parts used on the client, but remove the rest. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:19 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:19 +0000 Subject: [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock. In-Reply-To: <155053494585.24125.10207641299012244855.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494585.24125.10207641299012244855.stgit@noble.brown> Message-ID: <19970218-0088-4873-B933-4F56FED1E6CC@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > This lock is never held over code that sleeps, and is > only ever held for short periods of time. > So a simple spinlock is best. > > Signed-off-by: NeilBrown > --- > > diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > index 27d73c95403d..aed33068ff3c 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > @@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, > if ((len == 4 && !strncmp(kernbuf, "NONE", len)) || > (len == 5 && !strncmp(kernbuf, "clear", len))) { > /* empty string is special case */ > - down_write(&squash->rsi_sem); > + spin_lock(&squash->rsi_lock); > if (!list_empty(&squash->rsi_nosquash_nids)) > cfs_free_nidlist(&squash->rsi_nosquash_nids); > - up_write(&squash->rsi_sem); > + spin_unlock(&squash->rsi_lock); > > @@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, > kfree(kernbuf); > kernbuf = NULL; > > - down_write(&squash->rsi_sem); > + spin_lock(&squash->rsi_lock); > if (!list_empty(&squash->rsi_nosquash_nids)) > cfs_free_nidlist(&squash->rsi_nosquash_nids); > list_splice(&tmp, &squash->rsi_nosquash_nids); > - up_write(&squash->rsi_sem); > + spin_unlock(&squash->rsi_lock); This is held here over cds_free_nidlist(), which has calls to kfree() internally. I don't think it is acceptable to hold a spinlock over kfree() these days? Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:17 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:17 +0000 Subject: [lustre-devel] [PATCH 14/37] lustre: llog: change lgh_refcount to struct kref. In-Reply-To: <155053494558.24125.11270061933248014691.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494558.24125.11270061933248014691.stgit@noble.brown> Message-ID: <8D48D671-98EF-4137-AB0B-1239A979D5DB@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > This is a refcount that perfectly fits the > pattern for kref, so change it to a kref. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:20 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:20 +0000 Subject: [lustre-devel] [PATCH 24/37] lustre: lu_object: remove extra newline from debug printing. In-Reply-To: <155053494611.24125.2469014113532688461.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494611.24125.2469014113532688461.stgit@noble.brown> Message-ID: <267E03EA-23B6-4555-B09E-8E71630FEF6C@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > In lu_cdebug_printer(), is "complete" is true, then > key->lck_area ends with a newline, so there is no need to > include on in the format too. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:21 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:21 +0000 Subject: [lustre-devel] [PATCH 25/37] lustre: deprecate libcfs_debug_vmsg2 In-Reply-To: <155053494619.24125.5150721300459339252.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494619.24125.5150721300459339252.stgit@noble.brown> Message-ID: On Feb 18, 2019, at 16:09, NeilBrown wrote: > > Since 2.6.36, Linux' vsprintf has supported %pV > which supports "recursive sprintf" - exactly the task > that libcfs_debug_vmsg2 aims to provide. > > Instead of calling libcfs_debug_vmsg2(), we can put the fmt and > args in a 'struct va_format', and pass the address of that structure > to the "%pV" format. > > So do this to remove all users of libcfs_debug_vmsg2(). Interesting. This code was always more complex than I'd like. > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:21 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:21 +0000 Subject: [lustre-devel] [PATCH 26/37] lustre: remove libcfs_debug_vmsg2 In-Reply-To: <155053494624.24125.18162964077735119291.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494624.24125.18162964077735119291.stgit@noble.brown> Message-ID: <7CFD9DE8-8DC3-429F-BF67-96318718293A@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > Now that libcfs_debug_vmsg2 has no (external) users, we can remove it. > It is used to implement libcfs_debug_msg(), so simply move > the body of the function (suitably modified) into that one caller. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:19 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:19 +0000 Subject: [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines. In-Reply-To: <155053494593.24125.427229089746560574.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494593.24125.427229089746560574.stgit@noble.brown> Message-ID: <917ADCDD-7F94-4E95-BD80-A93CA20B036E@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > Some of these are unused. > One is used in a minimal way where it is easier to use > an explicit number. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:22 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:22 +0000 Subject: [lustre-devel] [PATCH 10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc. In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494542.24125.3526135915611952378.stgit@noble.brown> Message-ID: <87F7798E-C989-4317-9B42-94FA9D0744A5@whamcloud.com> On Feb 24, 2019, at 09:05, James Simmons wrote: > > >> Passing 0 as the gfp_t for kmalloc() is not meaningful, and >> could change behaviour. >> Use an explicit GFP_KERNEL instead. > > Why did it every do this ?????? This is a defect introduced by commit 1b254784381 "LU-1346 libcfs: replace cfs_ memory wrappers". It replaced cfs_alloc(), which internally supplied the GFP_* mask with kmalloc(), which does not. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Mon Feb 25 18:16:20 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Mon, 25 Feb 2019 18:16:20 +0000 Subject: [lustre-devel] [PATCH 23/37] lustre: prefer to use tabs for alignment. In-Reply-To: <155053494604.24125.7873412904407447511.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494604.24125.7873412904407447511.stgit@noble.brown> Message-ID: <2730AC40-FC88-4EBA-8FA2-B34EA0C9E997@whamcloud.com> On Feb 18, 2019, at 16:09, NeilBrown wrote: > > This patch changes a lot of places that use spaces for > alignment to instead use tabs - though in one case in a > comment, spaces are used in place of tabs to be more consistent. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From neilb at suse.com Mon Feb 25 22:27:34 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 26 Feb 2019 09:27:34 +1100 Subject: [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494490.24125.1514109985903155907.stgit@noble.brown> Message-ID: <874l8rv6zt.fsf@notabene.neil.brown.name> On Sun, Feb 24 2019, James Simmons wrote: > y >> llite_kobj does not benefit from being in the >> lustre_kset kset (though it does need lustre_kset >> as a parent) > > Nak. > > Yes llite does benefit from being in the kset. On large clusters you > can end up with 1000s of clients so keeping the sysfs files setting > in sync needs to be done in mass. The way Lustre does this is by > running on the MGS server 'lctl conf_param $FSNAME.llite.lazystats=1' > or with the newer 'lctl set_param -P llite.$FSNAME-*.lazystats=1' as > an example. When this is done on the MGS that new value is first > persistently stored and then transmitted to the target nodes. > > The magic behind this is with class_process_config(). In the code > path LCFG_PARAM, which handles the conf_param case' the main function > is class_modify_config() which is used by both llite and the obd > devices. This function first attempts to find the sysfs attribute > from the kobject and call lustre_attr_store() directly to set it. > If it can't find the attribute, which means its a debugfs file > most likely, then a uevent is created and sent off. The udev rule > then exexcutes some application to handle the debugfs settings. > For uevents to work the kobject (llite) must belong to a kset. > > With LCFG_SET_PARAM, which handles the 'set_param -P' case the > master function is process_param2_config(). For this case we > always send attribute changes with uevents. Besides the requirement > of the kobject belonging to the kset this function uses > kset_find_object() directly which if llite is not in the kset > will never be found. Thanks a lot for the explanation - there are definitely things I missed there. I'll drop this patch, and keep class_setup_tunables() in the later patch that removed it. Thanks, NeilBrown > >> It also does not need the class_ktype type, as dynamic_kobj_ktype >> is sufficient. >> >> So use the simple kobject_create_and_add() to initialize it. >> >> This provides flexibility for making changes to >> class_setup_tunables(). >> >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c >> index 8215296dc15d..78ec0fa65c58 100644 >> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c >> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c >> @@ -46,7 +46,7 @@ int llite_tunables_register(void) >> { >> int rc = 0; >> >> - llite_kobj = class_setup_tunables("llite"); >> + llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj); >> if (IS_ERR(llite_kobj)) >> return PTR_ERR(llite_kobj); >> > > llite_kobj->kset = kset_get(&lustre_kset); >> > > In llite_tunables_unregister() the call for kobject_put() > should really be replaced with kobject_del(). This is a bug > in my original work. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Feb 25 22:38:51 2019 From: neilb at suse.com (NeilBrown) Date: Tue, 26 Feb 2019 09:38:51 +1100 Subject: [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494490.24125.1514109985903155907.stgit@noble.brown> Message-ID: <871s3vv6h0.fsf@notabene.neil.brown.name> On Sun, Feb 24 2019, James Simmons wrote: > For some reason this patch didn't land in my mailbox but I can > see it on https://patchwork.kernel.org/patch/10819037. This patch > is mostly good since llite now uses dynamic_kobj_ktype with its own > ktype. Thus class_sysfs_release() will never be called with llite. > > What does need fixing is > > -------------------------------------------------------- > type->typ_kobj.kset = lustre_kset; > > changed to: > > type->typ_kobj.kset = kset_get(&lustre_kset); Why? Where is the kset_put() what will match this? > -------------------------------------------------------- > > Next change needed it change all the > > kobject_put(&type->typ_kobj); -> kobject_del(&type->typ_kobj); > Why? kobject_del() removed from sysfs. kobject_put() calls kobject_release() on the last put. This calls kobject_cleanup() which calls kobject_del() if needed. So why do we need to call kobject_del()? Thanks, NeilBrown > So we properly handle the kset referencing. That is currently > broken by me :-( -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From simmonsja at ornl.gov Tue Feb 26 20:41:43 2019 From: simmonsja at ornl.gov (Simmons, James A.) Date: Tue, 26 Feb 2019 20:41:43 +0000 Subject: [lustre-devel] [PATCH 03/37] lustre: embed typ_kobj if obd_type In-Reply-To: <871s3vv6h0.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494490.24125.1514109985903155907.stgit@noble.brown> <871s3vv6h0.fsf@notabene.neil.brown.name> Message-ID: On Sun, Feb 24 2019, James Simmons wrote: >> For some reason this patch didn't land in my mailbox but I can see it >> on https://patchwork.kernel.org/patch/10819037. This patch is mostly >> good since llite now uses dynamic_kobj_ktype with its own ktype. Thus >> class_sysfs_release() will never be called with llite. >> >> What does need fixing is >> >> -------------------------------------------------------- >> type->typ_kobj.kset = lustre_kset; >> >> changed to: >> >> type->typ_kobj.kset = kset_get(&lustre_kset); > >Why? Where is the kset_put() what will match this? Just an off the cuff review. I'm work on a full fledge patch. Just testing on OpenSFS branch since the server side has some unique needs. Basically in the old days the lov and osc layer were present on servers so you have a /sys/fs/lustre/osc tree on the MDS server for example. Now a new layer osp has replaced it but we need to keep the old osc tree structure around. The function part is some people test with everything on one node which can create unique conditions to handle. I'm trying to sort it out. >> -------------------------------------------------------- >> >> Next change needed it change all the >> >> kobject_put(&type->typ_kobj); -> kobject_del(&type->typ_kobj); >> > >Why? >kobject_del() removed from sysfs. kobject_put() calls kobject_release() >on the last put. This calls kobject_cleanup() which calls kobject_del() >if needed. >So why do we need to call kobject_del()? You are right. I missed that kobject_cleanup() calls kobject_del(). I noticed It latter when you pointed out. From jsimmons at infradead.org Tue Feb 26 20:55:49 2019 From: jsimmons at infradead.org (James Simmons) Date: Tue, 26 Feb 2019 20:55:49 +0000 (GMT) Subject: [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop. In-Reply-To: <155053494599.24125.1795878344125234751.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494599.24125.1795878344125234751.stgit@noble.brown> Message-ID: > These shift loops seem to be trying to avoid doing a > multiplication. > We same effect can be achieved more transparently using > rounddown_pow_of_two(). Even though there is a multiplication > in the C code, the resulting machine code just does a single shift. Be aware rounddown_pow_of_two(n) is undefined when "n == 0". > Signed-off-by: NeilBrown > --- > .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > index a179b0d6979e..637aaca96888 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c > @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, > u32 blk_size = osfs.os_bsize >> 10; > u64 result = osfs.os_blocks; > > - while (blk_size >>= 1) > - result <<= 1; > - > + result *= rounddown_pow_of_two(blk_size); > return sprintf(buf, "%llu\n", result); > } > > @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, > u32 blk_size = osfs.os_bsize >> 10; > u64 result = osfs.os_bfree; > > - while (blk_size >>= 1) > - result <<= 1; > + result *= rounddown_pow_of_two(blk_size); > > return sprintf(buf, "%llu\n", result); > } > @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, > u32 blk_size = osfs.os_bsize >> 10; > u64 result = osfs.os_bavail; > > - while (blk_size >>= 1) > - result <<= 1; > + result *= rounddown_pow_of_two(blk_size); > > return sprintf(buf, "%llu\n", result); > } > > > From jsimmons at infradead.org Tue Feb 26 22:18:21 2019 From: jsimmons at infradead.org (James Simmons) Date: Tue, 26 Feb 2019 22:18:21 +0000 (GMT) Subject: [lustre-devel] [PATCH 02/37] lustre: llite: don't use class_setup_tunables() In-Reply-To: <874l8rv6zt.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494490.24125.1514109985903155907.stgit@noble.brown> <874l8rv6zt.fsf@notabene.neil.brown.name> Message-ID: > >> llite_kobj does not benefit from being in the > >> lustre_kset kset (though it does need lustre_kset > >> as a parent) > > > > Nak. > > > > Yes llite does benefit from being in the kset. On large clusters you > > can end up with 1000s of clients so keeping the sysfs files setting > > in sync needs to be done in mass. The way Lustre does this is by > > running on the MGS server 'lctl conf_param $FSNAME.llite.lazystats=1' > > or with the newer 'lctl set_param -P llite.$FSNAME-*.lazystats=1' as > > an example. When this is done on the MGS that new value is first > > persistently stored and then transmitted to the target nodes. > > > > The magic behind this is with class_process_config(). In the code > > path LCFG_PARAM, which handles the conf_param case' the main function > > is class_modify_config() which is used by both llite and the obd > > devices. This function first attempts to find the sysfs attribute > > from the kobject and call lustre_attr_store() directly to set it. > > If it can't find the attribute, which means its a debugfs file > > most likely, then a uevent is created and sent off. The udev rule > > then exexcutes some application to handle the debugfs settings. > > For uevents to work the kobject (llite) must belong to a kset. > > > > With LCFG_SET_PARAM, which handles the 'set_param -P' case the > > master function is process_param2_config(). For this case we > > always send attribute changes with uevents. Besides the requirement > > of the kobject belonging to the kset this function uses > > kset_find_object() directly which if llite is not in the kset > > will never be found. > > Thanks a lot for the explanation - there are definitely things I missed > there. > I'll drop this patch, and keep class_setup_tunables() in the later patch > that removed it. I have a patch to replace this one. In fact I love the using the release for cleanups for ktype that I moved debugfs handling in llite into a new llite_kobj_release(). I'm looking at the next patch but that one is tricker since it impacts server code as well as I pointed out in another email. I think we can do a reasonable cleanup here. > >> It also does not need the class_ktype type, as dynamic_kobj_ktype > >> is sufficient. > >> > >> So use the simple kobject_create_and_add() to initialize it. > >> > >> This provides flexibility for making changes to > >> class_setup_tunables(). > >> > >> Signed-off-by: NeilBrown > >> --- > >> drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c > >> index 8215296dc15d..78ec0fa65c58 100644 > >> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c > >> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c > >> @@ -46,7 +46,7 @@ int llite_tunables_register(void) > >> { > >> int rc = 0; > >> > >> - llite_kobj = class_setup_tunables("llite"); > >> + llite_kobj = kobject_create_and_add("llite", &lustre_kset->kobj); > >> if (IS_ERR(llite_kobj)) > >> return PTR_ERR(llite_kobj); > >> > > > > llite_kobj->kset = kset_get(&lustre_kset); > >> > > > > In llite_tunables_unregister() the call for kobject_put() > > should really be replaced with kobject_del(). This is a bug > > in my original work. > From neilb at suse.com Tue Feb 26 23:45:45 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 27 Feb 2019 10:45:45 +1100 Subject: [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static. In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494545.24125.14664274760505145343.stgit@noble.brown> Message-ID: <87va16t8pi.fsf@notabene.neil.brown.name> On Sun, Feb 24 2019, James Simmons wrote: >> libcfs_kkuc_msg_put() is never used outside of kernelcomm.c, >> so make it static. > > In the OpenSFS branch libcfs_kkuc_msg_put() is used by the > client and server code. While this is okay now in the future > this will be reverted. So do we keep it as is so it can handle > server code or do this change and then later do what I added > below: Where is it used? Looking in the current whamcloud master Commit f7155420024e ("LU-11208 tests: add version check to sanity tests") $ git grep libcfs_kkuc_msg_put lustre/include/lustre_kernelcomm.h:int libcfs_kkuc_msg_put(struct file *fp, void *payload); lustre/obdclass/kernelcomm.c: * libcfs_kkuc_msg_put - send an message from kernel to userspace lustre/obdclass/kernelcomm.c:int libcfs_kkuc_msg_put(struct file *filp, void *payload) lustre/obdclass/kernelcomm.c:EXPORT_SYMBOL(libcfs_kkuc_msg_put); lustre/obdclass/kernelcomm.c: rc = libcfs_kkuc_msg_put(reg->kr_fp, payload); libcfs_kkuc_msg_put() is only called from libcfs_kkuc_group_put(). What am I missing? Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Tue Feb 26 23:59:33 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 27 Feb 2019 10:59:33 +1100 Subject: [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper. In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494572.24125.4002432022455040178.stgit@noble.brown> Message-ID: <87sgwat82i.fsf@notabene.neil.brown.name> On Sun, Feb 24 2019, James Simmons wrote: >> This function seems overly complex, the same functionality >> is available with much less effort. > > Actually we are in discussion about removing these functions. > The details are at: > > https://jira.whamcloud.com/browse/LU-11157 > > Since shells typically don't handle "floating point" representation > well you can see the following: > > sanity 64d with the same error message; '209.9: syntax error: invalid > arithmetic operator (error token is ".9")' > > The second issues is that the read values are not true representation > of the desired value. The same issues is with the string helpers as > well. Take for example > > test_string_get_size_one(1100, 1, "1.10 kB", "1.07 KiB"); > > Which is taken from linux/lib/test-string_helpers.c. > > If you pass 1100 to string_get_size() you can get either 1.10 kB or 1.07 > KiB. Now if do the reverse 1.10 kB you get ~1126 which is not the same as > 11000. I discussed how to handle this problem with Andreas and he agreed > the best solution is make all the sysfs / debugfs *_mb files turn any > values passed in to around up to the nearest MiB. This way we can report > the exact MiB settings to the users. We already have a patch to do this > for max_dirty_mb which I can push. The other *_mb files need to be updated > to round off. If you can wait a few days I can backport the already done > patch and push a patch for the rest. My recommendation would be to deprecate all _mb files and instead have _bytes files which report a simple integer - the number of bytes. Leave all the unit conversion to user-space. Linus once told me that he prefers sysfs files to always be in basic units, and that decimals are fine. So use "seconds" for time, even if that means 0.002 for 2 milliseconds. Use bytes for storage, etc. NeilBrown > >> Signed-off-by: NeilBrown >> --- >> .../lustre/lustre/obdclass/lprocfs_status.c | 47 +++----------------- >> 1 file changed, 7 insertions(+), 40 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> index 568e6623e0c8..bd24e48f6145 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> @@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m, >> int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, >> int mult) >> { >> - long decimal_val, frac_val; >> int prtn; >> >> if (count < 10) >> return -EINVAL; >> >> - decimal_val = val / mult; >> - prtn = snprintf(buffer, count, "%ld", decimal_val); >> - frac_val = val % mult; >> - >> - if (prtn < (count - 4) && frac_val > 0) { >> - long temp_frac; >> - int i, temp_mult = 1, frac_bits = 0; >> - >> - temp_frac = frac_val * 10; >> - buffer[prtn++] = '.'; >> - while (frac_bits < 2 && (temp_frac / mult) < 1) { >> - /* only reserved 2 bits fraction */ >> - buffer[prtn++] = '0'; >> - temp_frac *= 10; >> - frac_bits++; >> - } >> - /* >> - * Need to think these cases : >> - * 1. #echo x.00 > /sys/xxx output result : x >> - * 2. #echo x.0x > /sys/xxx output result : x.0x >> - * 3. #echo x.x0 > /sys/xxx output result : x.x >> - * 4. #echo x.xx > /sys/xxx output result : x.xx >> - * Only reserved 2 bits fraction. >> - */ >> - for (i = 0; i < (5 - prtn); i++) >> - temp_mult *= 10; >> - >> - frac_bits = min((int)count - prtn, 3 - frac_bits); >> - prtn += snprintf(buffer + prtn, frac_bits, "%ld", >> - frac_val * temp_mult / mult); >> + prtn = snprintf(buffer, count, "%ld.%02lu", >> + val / mult, >> + (val % mult) / (mult / 100)); >> >> + /* Strip trailing zeroes, and trailing '.' */ >> + while (prtn && buffer[prtn-1] == '0') >> + prtn--; >> + if (prtn && buffer[prtn-1] == '.') >> prtn--; >> - while (buffer[prtn] < '1' || buffer[prtn] > '9') { >> - prtn--; >> - if (buffer[prtn] == '.') { >> - prtn--; >> - break; >> - } >> - } >> - prtn++; >> - } >> buffer[prtn++] = '\n'; >> return prtn; >> } >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Wed Feb 27 00:22:16 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 27 Feb 2019 11:22:16 +1100 Subject: [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock. In-Reply-To: <19970218-0088-4873-B933-4F56FED1E6CC@whamcloud.com> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494585.24125.10207641299012244855.stgit@noble.brown> <19970218-0088-4873-B933-4F56FED1E6CC@whamcloud.com> Message-ID: <87pnret70n.fsf@notabene.neil.brown.name> On Mon, Feb 25 2019, Andreas Dilger wrote: > On Feb 18, 2019, at 16:09, NeilBrown wrote: >> >> This lock is never held over code that sleeps, and is >> only ever held for short periods of time. >> So a simple spinlock is best. >> >> Signed-off-by: NeilBrown >> --- >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> index 27d73c95403d..aed33068ff3c 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> @@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, >> if ((len == 4 && !strncmp(kernbuf, "NONE", len)) || >> (len == 5 && !strncmp(kernbuf, "clear", len))) { >> /* empty string is special case */ >> - down_write(&squash->rsi_sem); >> + spin_lock(&squash->rsi_lock); >> if (!list_empty(&squash->rsi_nosquash_nids)) >> cfs_free_nidlist(&squash->rsi_nosquash_nids); >> - up_write(&squash->rsi_sem); >> + spin_unlock(&squash->rsi_lock); >> > >> @@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, >> kfree(kernbuf); >> kernbuf = NULL; >> >> - down_write(&squash->rsi_sem); >> + spin_lock(&squash->rsi_lock); >> if (!list_empty(&squash->rsi_nosquash_nids)) >> cfs_free_nidlist(&squash->rsi_nosquash_nids); >> list_splice(&tmp, &squash->rsi_nosquash_nids); >> - up_write(&squash->rsi_sem); >> + spin_unlock(&squash->rsi_lock); > > > This is held here over cds_free_nidlist(), which has calls to kfree() > internally. I don't think it is acceptable to hold a spinlock over > kfree() these days? I have not heard that, and have myself called kfree inside a spinlock before. A quick look finds some examples in lib/idr.c ida_free() calls kfree() while holding a spinlock (xas_unlock_irqrestore is a wrapper around spin_unlock_irqrestore). I couldn't find any documentation which said one way or the other, and normally if a common function cannot be called under a spinlock, it will call may_sleep() to ensure errors are found quickly. NeilBrown > > Cheers, Andreas > --- > Andreas Dilger > Principal Lustre Architect > Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Wed Feb 27 00:41:49 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 27 Feb 2019 11:41:49 +1100 Subject: [lustre-devel] [PATCH 21/37] lustre: remove several MAX_STRING_SIZE defines. In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494593.24125.427229089746560574.stgit@noble.brown> Message-ID: <87mumit642.fsf@notabene.neil.brown.name> On Sun, Feb 24 2019, James Simmons wrote: >> Some of these are unused. >> One is used in a minimal way where it is easier to use >> an explicit number. > > While I dislike mystery meat type defines like MAX_STRING_SIZE I also > don't like using raw numbers. In the past using raw numbers has causes > problems when requirements changed that were not easy to track down > why the new bug appeared. Mind you the same problem exist for constants > like MAX_STRING_SIZE which provides no real meaning to why the magically > number 128 is used. > > This number seems to be a limiting factor in the naming of sysfs directory > and file naming. I kind of see why this number has no meaning. So such > a number belongs in one place, lprocfs_status.h. Now sysfs attributes > can have any naming style they want, within reason :-) As for directories > that is limited by MAX_OBD_NAME. What do you know MAX_OBD_NAME is equal > too MAX_STRING_SIZE (hint hint) :-) I've changed the 128 to MAX_OBD_NAME - seems to make sense. I've also added the patch below. Thanks, NeilBrown From: NeilBrown Subject: [PATCH] lustre: ldlm: discard varname in ldlm_pool. This allocated buffer serves no purpose. A constant string is copied into it, it is passed to some function which copies it out again, then the buffer is freed. Instead, we can pass the constant string to that function. --- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 2 -- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 16 ++++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index d8dcf8a73e4b..c907d880274d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -31,8 +31,6 @@ * Lustre is a trademark of Sun Microsystems, Inc. */ -#define MAX_STRING_SIZE 128 - extern int ldlm_srv_namespace_nr; extern int ldlm_cli_namespace_nr; extern struct mutex ldlm_srv_namespace_lock; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 5b23767faecf..adc3f3737daa 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -505,7 +505,7 @@ LUSTRE_RW_ATTR(lock_volume_factor); #define LDLM_POOL_ADD_VAR(name, var, ops) \ do { \ - snprintf(var_name, MAX_STRING_SIZE, #name); \ + pool_vars[0].name = #name; \ pool_vars[0].data = var; \ pool_vars[0].fops = ops; \ ldebugfs_add_vars(pl->pl_debugfs_entry, pool_vars, NULL);\ @@ -557,25 +557,18 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) ns_pool); struct dentry *debugfs_ns_parent; struct lprocfs_vars pool_vars[2]; - char *var_name = NULL; int rc = 0; - var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS); - if (!var_name) - return -ENOMEM; - debugfs_ns_parent = ns->ns_debugfs_entry; if (IS_ERR_OR_NULL(debugfs_ns_parent)) { CERROR("%s: debugfs entry is not initialized\n", ldlm_ns_name(ns)); rc = -EINVAL; - goto out_free_name; + goto out; } pl->pl_debugfs_entry = debugfs_create_dir("pool", debugfs_ns_parent); - var_name[MAX_STRING_SIZE] = '\0'; memset(pool_vars, 0, sizeof(pool_vars)); - pool_vars[0].name = var_name; LDLM_POOL_ADD_VAR(state, pl, &lprocfs_pool_state_fops); @@ -583,7 +576,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) LDLM_POOL_FIRST_STAT, 0); if (!pl->pl_stats) { rc = -ENOMEM; - goto out_free_name; + goto out; } lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT, @@ -622,8 +615,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) debugfs_create_file("stats", 0644, pl->pl_debugfs_entry, pl->pl_stats, &lprocfs_stats_seq_fops); -out_free_name: - kfree(var_name); +out: return rc; } -- 2.14.0.rc0.dirty -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Wed Feb 27 00:51:26 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 27 Feb 2019 11:51:26 +1100 Subject: [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop. In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494599.24125.1795878344125234751.stgit@noble.brown> Message-ID: <87k1hmt5o1.fsf@notabene.neil.brown.name> On Tue, Feb 26 2019, James Simmons wrote: >> These shift loops seem to be trying to avoid doing a >> multiplication. >> We same effect can be achieved more transparently using >> rounddown_pow_of_two(). Even though there is a multiplication >> in the C code, the resulting machine code just does a single shift. > > Be aware rounddown_pow_of_two(n) is undefined when "n == 0". Hmm... can os_bsize ever be less than 1024? I guess we still need to be careful of the possibility. The current code treats anything less than 1024 as though it were 1024, so I could achieve the same thing with result *= rounddown_pow_of_two(blk_size ?: 1); Is that too obscure? Thanks, NeilBrown > >> Signed-off-by: NeilBrown >> --- >> .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- >> 1 file changed, 3 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> index a179b0d6979e..637aaca96888 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >> @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, >> u32 blk_size = osfs.os_bsize >> 10; >> u64 result = osfs.os_blocks; >> >> - while (blk_size >>= 1) >> - result <<= 1; >> - >> + result *= rounddown_pow_of_two(blk_size); >> return sprintf(buf, "%llu\n", result); >> } >> >> @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, >> u32 blk_size = osfs.os_bsize >> 10; >> u64 result = osfs.os_bfree; >> >> - while (blk_size >>= 1) >> - result <<= 1; >> + result *= rounddown_pow_of_two(blk_size); >> >> return sprintf(buf, "%llu\n", result); >> } >> @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, >> u32 blk_size = osfs.os_bsize >> 10; >> u64 result = osfs.os_bavail; >> >> - while (blk_size >>= 1) >> - result <<= 1; >> + result *= rounddown_pow_of_two(blk_size); >> >> return sprintf(buf, "%llu\n", result); >> } >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From adilger at whamcloud.com Wed Feb 27 00:54:25 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 00:54:25 +0000 Subject: [lustre-devel] [PATCH 22/37] lustre: lprocfs: use log2.h macros instead of shift loop. In-Reply-To: <87k1hmt5o1.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494599.24125.1795878344125234751.stgit@noble.brown> <87k1hmt5o1.fsf@notabene.neil.brown.name> Message-ID: <45B15CDD-E478-4553-8F0F-C45DB7FD28FB@whamcloud.com> On Feb 26, 2019, at 17:51, NeilBrown wrote: > > On Tue, Feb 26 2019, James Simmons wrote: > >>> These shift loops seem to be trying to avoid doing a >>> multiplication. >>> We same effect can be achieved more transparently using >>> rounddown_pow_of_two(). Even though there is a multiplication >>> in the C code, the resulting machine code just does a single shift. >> >> Be aware rounddown_pow_of_two(n) is undefined when "n == 0". > > Hmm... can os_bsize ever be less than 1024? I guess we still need to be > careful of the possibility. In theory, ZFS allows a 512-byte blocksize, but we don't use that today. There is some chance the MDT will be on a byte-granular NVRAM storage at some point in the future, but even those would have an allocation unit of 16-32 bytes or so. > The current code treats anything less than 1024 as though it were 1024, > so I could achieve the same thing with > > result *= rounddown_pow_of_two(blk_size ?: 1); > > Is that too obscure? Should be fine. Cheers, Andreas > > Thanks, > NeilBrown > > >> >>> Signed-off-by: NeilBrown >>> --- >>> .../lustre/lustre/obdclass/lprocfs_status.c | 10 +++------- >>> 1 file changed, 3 insertions(+), 7 deletions(-) >>> >>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> index a179b0d6979e..637aaca96888 100644 >>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> @@ -341,9 +341,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, >>> u32 blk_size = osfs.os_bsize >> 10; >>> u64 result = osfs.os_blocks; >>> >>> - while (blk_size >>= 1) >>> - result <<= 1; >>> - >>> + result *= rounddown_pow_of_two(blk_size); >>> return sprintf(buf, "%llu\n", result); >>> } >>> >>> @@ -364,8 +362,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, >>> u32 blk_size = osfs.os_bsize >> 10; >>> u64 result = osfs.os_bfree; >>> >>> - while (blk_size >>= 1) >>> - result <<= 1; >>> + result *= rounddown_pow_of_two(blk_size); >>> >>> return sprintf(buf, "%llu\n", result); >>> } >>> @@ -387,8 +384,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, >>> u32 blk_size = osfs.os_bsize >> 10; >>> u64 result = osfs.os_bavail; >>> >>> - while (blk_size >>= 1) >>> - result <<= 1; >>> + result *= rounddown_pow_of_two(blk_size); >>> >>> return sprintf(buf, "%llu\n", result); >>> } >>> >>> >>> Cheers, Andreas --- Andreas Dilger CTO Whamcloud From adilger at whamcloud.com Wed Feb 27 01:00:59 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 01:00:59 +0000 Subject: [lustre-devel] [PATCH 20/37] lustre: convert rsi_sem to a spinlock. In-Reply-To: <87pnret70n.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494585.24125.10207641299012244855.stgit@noble.brown> <19970218-0088-4873-B933-4F56FED1E6CC@whamcloud.com> <87pnret70n.fsf@notabene.neil.brown.name> Message-ID: On Feb 26, 2019, at 17:22, NeilBrown wrote: > > On Mon, Feb 25 2019, Andreas Dilger wrote: > >> On Feb 18, 2019, at 16:09, NeilBrown wrote: >>> >>> This lock is never held over code that sleeps, and is >>> only ever held for short periods of time. >>> So a simple spinlock is best. >>> >>> Signed-off-by: NeilBrown >>> --- >>> >>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> index 27d73c95403d..aed33068ff3c 100644 >>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> @@ -1720,10 +1720,10 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, >>> if ((len == 4 && !strncmp(kernbuf, "NONE", len)) || >>> (len == 5 && !strncmp(kernbuf, "clear", len))) { >>> /* empty string is special case */ >>> - down_write(&squash->rsi_sem); >>> + spin_lock(&squash->rsi_lock); >>> if (!list_empty(&squash->rsi_nosquash_nids)) >>> cfs_free_nidlist(&squash->rsi_nosquash_nids); >>> - up_write(&squash->rsi_sem); >>> + spin_unlock(&squash->rsi_lock); >>> >> >>> @@ -1740,11 +1740,11 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, >>> kfree(kernbuf); >>> kernbuf = NULL; >>> >>> - down_write(&squash->rsi_sem); >>> + spin_lock(&squash->rsi_lock); >>> if (!list_empty(&squash->rsi_nosquash_nids)) >>> cfs_free_nidlist(&squash->rsi_nosquash_nids); >>> list_splice(&tmp, &squash->rsi_nosquash_nids); >>> - up_write(&squash->rsi_sem); >>> + spin_unlock(&squash->rsi_lock); >> >> >> This is held here over cds_free_nidlist(), which has calls to kfree() >> internally. I don't think it is acceptable to hold a spinlock over >> kfree() these days? > > I have not heard that, and have myself called kfree inside a spinlock before. > A quick look finds some examples in lib/idr.c > ida_free() calls kfree() while holding a spinlock (xas_unlock_irqrestore > is a wrapper around spin_unlock_irqrestore). > > I couldn't find any documentation which said one way or the other, and > normally if a common function cannot be called under a spinlock, it will > call may_sleep() to ensure errors are found quickly. Hmm, maybe I'm wrong. I thought there was something about freeing slab objects and eventually they spilled out of the per-CPU slab cache and might sleep, but that could be ancient news. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Wed Feb 27 01:06:47 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 01:06:47 +0000 Subject: [lustre-devel] [PATCH 17/37] lustre: simplify lprocfs_read_frac_helper. In-Reply-To: <87sgwat82i.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494572.24125.4002432022455040178.stgit@noble.brown> <87sgwat82i.fsf@notabene.neil.brown.name> Message-ID: On Feb 26, 2019, at 16:59, NeilBrown wrote: > > On Sun, Feb 24 2019, James Simmons wrote: > >>> This function seems overly complex, the same functionality >>> is available with much less effort. >> >> Actually we are in discussion about removing these functions. >> The details are at: >> >> https://jira.whamcloud.com/browse/LU-11157 >> >> Since shells typically don't handle "floating point" representation >> well you can see the following: >> >> sanity 64d with the same error message; '209.9: syntax error: invalid >> arithmetic operator (error token is ".9")' >> >> The second issues is that the read values are not true representation >> of the desired value. The same issues is with the string helpers as >> well. Take for example >> >> test_string_get_size_one(1100, 1, "1.10 kB", "1.07 KiB"); >> >> Which is taken from linux/lib/test-string_helpers.c. >> >> If you pass 1100 to string_get_size() you can get either 1.10 kB or 1.07 >> KiB. Now if do the reverse 1.10 kB you get ~1126 which is not the same as >> 11000. I discussed how to handle this problem with Andreas and he agreed >> the best solution is make all the sysfs / debugfs *_mb files turn any >> values passed in to around up to the nearest MiB. This way we can report >> the exact MiB settings to the users. We already have a patch to do this >> for max_dirty_mb which I can push. The other *_mb files need to be updated >> to round off. If you can wait a few days I can backport the already done >> patch and push a patch for the rest. > > My recommendation would be to deprecate all _mb files and instead have > _bytes files which report a simple integer - the number of bytes. That would break a lot of configurations and documentation. Also, bytes are not very convenient units for a lot of the numbers, for example you don't want to (nor could you) send 47-byte RPCs. > Leave all the unit conversion to user-space. > > Linus once told me that he prefers sysfs files to always be in basic > units, and that decimals are fine. So use "seconds" for time, even if > that means 0.002 for 2 milliseconds. Use bytes for storage, etc. That is not going to be better than allowing "max_dirty_mb=0.5", which is what we wanted to get rid of in the first place. Back in the day when a system had 4MB DIMMs it was useful to allow fractional MB for the cache size or debug log size, but I don't think that is useful today. I'm content to just round these to the nearest MB, in the rare case that someone specifies a fractional unit, but honestly I don't think that anyone does anymore. It is much more likely they will be setting the cache size to 16G per target on their 256GB RAM nodes. Cheers, Andreas >>> Signed-off-by: NeilBrown >>> --- >>> .../lustre/lustre/obdclass/lprocfs_status.c | 47 +++----------------- >>> 1 file changed, 7 insertions(+), 40 deletions(-) >>> >>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> index 568e6623e0c8..bd24e48f6145 100644 >>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c >>> @@ -205,53 +205,20 @@ static void obd_connect_data_seqprint(struct seq_file *m, >>> int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, >>> int mult) >>> { >>> - long decimal_val, frac_val; >>> int prtn; >>> >>> if (count < 10) >>> return -EINVAL; >>> >>> - decimal_val = val / mult; >>> - prtn = snprintf(buffer, count, "%ld", decimal_val); >>> - frac_val = val % mult; >>> - >>> - if (prtn < (count - 4) && frac_val > 0) { >>> - long temp_frac; >>> - int i, temp_mult = 1, frac_bits = 0; >>> - >>> - temp_frac = frac_val * 10; >>> - buffer[prtn++] = '.'; >>> - while (frac_bits < 2 && (temp_frac / mult) < 1) { >>> - /* only reserved 2 bits fraction */ >>> - buffer[prtn++] = '0'; >>> - temp_frac *= 10; >>> - frac_bits++; >>> - } >>> - /* >>> - * Need to think these cases : >>> - * 1. #echo x.00 > /sys/xxx output result : x >>> - * 2. #echo x.0x > /sys/xxx output result : x.0x >>> - * 3. #echo x.x0 > /sys/xxx output result : x.x >>> - * 4. #echo x.xx > /sys/xxx output result : x.xx >>> - * Only reserved 2 bits fraction. >>> - */ >>> - for (i = 0; i < (5 - prtn); i++) >>> - temp_mult *= 10; >>> - >>> - frac_bits = min((int)count - prtn, 3 - frac_bits); >>> - prtn += snprintf(buffer + prtn, frac_bits, "%ld", >>> - frac_val * temp_mult / mult); >>> + prtn = snprintf(buffer, count, "%ld.%02lu", >>> + val / mult, >>> + (val % mult) / (mult / 100)); >>> >>> + /* Strip trailing zeroes, and trailing '.' */ >>> + while (prtn && buffer[prtn-1] == '0') >>> + prtn--; >>> + if (prtn && buffer[prtn-1] == '.') >>> prtn--; >>> - while (buffer[prtn] < '1' || buffer[prtn] > '9') { >>> - prtn--; >>> - if (buffer[prtn] == '.') { >>> - prtn--; >>> - break; >>> - } >>> - } >>> - prtn++; >>> - } >>> buffer[prtn++] = '\n'; >>> return prtn; >>> } Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From neilb at suse.com Wed Feb 27 01:17:41 2019 From: neilb at suse.com (NeilBrown) Date: Wed, 27 Feb 2019 12:17:41 +1100 Subject: [lustre-devel] [PATCH 27/37] lustre: discard lu_ref In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494627.24125.13508435808475179343.stgit@noble.brown> Message-ID: <87h8cqt4ga.fsf@notabene.neil.brown.name> On Sun, Feb 24 2019, James Simmons wrote: >> struct lu_ref is always an empty structure, and the functions >> which manipulate it do nothing. >> So this is not being tested and so cannot be trusted. >> So remove all these calls and field declarations. > > Or we can make lu_ref really work and always test with it :-) We could ... though a lot of the code has been removed already, I was just finishing the job. How useful is this stuff? Has it actually helped to find any bugs? Does it do any run-time checks, or it is just there to help you pull apart a crash-dump? I think there is a real cost in having these extra linkages. I'd like to be clear what the benefit is. Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From adilger at whamcloud.com Wed Feb 27 05:35:42 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 05:35:42 +0000 Subject: [lustre-devel] [PATCH 27/37] lustre: discard lu_ref In-Reply-To: <87h8cqt4ga.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494627.24125.13508435808475179343.stgit@noble.brown> <87h8cqt4ga.fsf@notabene.neil.brown.name> Message-ID: <7025104E-6297-4312-8647-213D3671E6A4@whamcloud.com> > On Feb 26, 2019, at 18:17, NeilBrown wrote: > > On Sun, Feb 24 2019, James Simmons wrote: > >>> struct lu_ref is always an empty structure, and the functions >>> which manipulate it do nothing. >>> So this is not being tested and so cannot be trusted. >>> So remove all these calls and field declarations. >> >> Or we can make lu_ref really work and always test with it :-) > > We could ... though a lot of the code has been removed already, I was > just finishing the job. > > How useful is this stuff? > Has it actually helped to find any bugs? > Does it do any run-time checks, or it is just > there to help you pull apart a crash-dump? > > I think there is a real cost in having these extra linkages. I'd like > to be clear what the benefit is. I've never used it myself, though I know a few developers that did in the past. That said, most of the time they needed to use it to debug some issue they had to push a patch to fix it first... Mike, Alex, you are most likely to use this code - do you think it is still useful? Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Wed Feb 27 06:17:57 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 06:17:57 +0000 Subject: [lustre-devel] [PATCH 37/37] lustre: obd_sysfs: error-check value stored in jobid_var In-Reply-To: <155053494716.24125.12637812266850199400.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494716.24125.12637812266850199400.stgit@noble.brown> Message-ID: <4271D74A-4B36-4781-A1DA-F5512CBCAF15@whamcloud.com> On Feb 18, 2019, at 17:09, NeilBrown wrote: > > The jobid_var sysfs attribute only has 3 meaningful values. > Other values cause lustre_get_jobid() to return an error > which is uniformly ignored. > > To improve usability and resilience, check that the value > written is acceptable before storing it. > > Signed-off-by: NeilBrown This will no longer be true once https://review.whamcloud.com/31691 commit 6488c0ec57de ("LU-10698 obdclass: allow specifying complex jobids") is merged into your tree. That allows specifying more useful jobid values, similar to how coredump files can be named: Allow specifying a format string for the jobid_name variable to create a jobid for processes on the client. The jobid_name is used when jobid_var=nodelocal, if jobid_name contains "%j", or as a fallback if getting the specified jobid_var from the environment fails. The jobid_node string allows the following escape sequences: %e = executable name %g = group ID %h = hostname (system utsname) %j = jobid from jobid_var environment variable %p = process ID %u = user ID Any unknown escape sequences are dropped. Other arbitrary characters pass through unmodified, up to the maximum jobid string size of 32, though whitespace within the jobid is not copied. This allows, for example, specifying an arbitrary prefix, such as the cluster name, in addition to the traditional "procname.uid" format, to distinguish between jobs running on clients in different clusters: lctl set_param jobid_var=nodelocal jobid_name=cluster2.%e.%u or lctl set_param jobid_var=SLURM_JOB_ID jobid_name=cluster2.%j.%e To use an environment-specified JobID, if available, but fall back to a static string for all processes that do not have a valid JobID: lctl set_param jobid_var=SLURM_JOB_ID jobid_name=unknown Currently the "%j" function was removed from the kernel client, even though there is no technical reason it can't work (i.e. all of the code to implement it is available and exported). This is actually super useful for HPC cluster administrators to monitor per-job IO bandwidth and IOPS on the server, and something that I think should be restored. Cheers, Andreas > --- > drivers/staging/lustre/lustre/obdclass/obd_sysfs.c | 21 ++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c > index 57a6f2c2da1c..69ccc6a55947 100644 > --- a/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c > +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c > @@ -216,16 +216,25 @@ static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr, > const char *buffer, > size_t count) > { > + static char *valid[] = { > + JOBSTATS_DISABLE, > + JOBSTATS_PROCNAME_UID, > + JOBSTATS_NODELOCAL, > + NULL > + }; > + int i; > + > if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) > return -EINVAL; > > - memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); > - > - memcpy(obd_jobid_var, buffer, count); > + for (i = 0; valid[i]; i++) > + if (sysfs_streq(buffer, valid[i])) > + break; > + if (!valid[i]) > + return -EINVAL; > > - /* Trim the trailing '\n' if any */ > - if (obd_jobid_var[count - 1] == '\n') > - obd_jobid_var[count - 1] = 0; > + memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); > + strcpy(obd_jobid_var, valid[i]); > > return count; > } > > Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Wed Feb 27 06:32:10 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 06:32:10 +0000 Subject: [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle. In-Reply-To: <155053494654.24125.18407080080202016099.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494654.24125.18407080080202016099.stgit@noble.brown> Message-ID: On Feb 18, 2019, at 17:09, NeilBrown wrote: > > Every object with a lustre_handle has (and must have) a refcount. > The lustre_handles code needs a call-out to increment this. > To simplify things, move the refcount into the lustre_handle > and discard the call-out. > > Signed-off-by: NeilBrown This patch reduces the debugbility of refcounting on these data structures, which can be tricky to diagnose if there is a leak at some point and nothing can clean up at the end because some data structure is holding an extra reference (e.g. lock->exp->dev). > struct obd_export *class_export_get(struct obd_export *exp) > { > - refcount_inc(&exp->exp_refcount); > + refcount_inc(&exp->exp_handle.h_ref); > CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp, > - refcount_read(&exp->exp_refcount)); > + refcount_read(&exp->exp_handle.h_ref)); > return exp; > } For example, with the existing callback mechanism, class_export_get() and class_export_put() would be called for every reference added and removed to this struct obd_export (e.g. when a valid lock handle is looked up), so with D_INFO logging enabled we can trace all of the reference counting of the data structures involved. > @@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie, > const struct portals_handle_ops *ops) > > spin_lock(&h->h_lock); > if (likely(h->h_in != 0)) { > - h->h_ops->hop_addref(h); > + refcount_inc(&h->h_ref); > retval = h; > } > spin_unlock(&h->h_lock); With this change, while class_handle2object() will still reference the handle correctly, it not print anything into the logs so if there is something wrong it will be much more difficult to find. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Wed Feb 27 06:37:49 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 06:37:49 +0000 Subject: [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops In-Reply-To: <155053494646.24125.10155576042684274174.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494646.24125.10155576042684274174.stgit@noble.brown> Message-ID: On Feb 18, 2019, at 17:09, NeilBrown wrote: > > lustre_handles assigned a 64bit unique identifier (a 'cookie') to > objects of various types and stored them in a hash table, allowing > them to be accessed by the cookie. > > The is a facility for type checking by recording an 'owner' for each > object, and checking the owner on lookup. Unfortunately this is not > used - owner is always zero. > > Eahc object also contains an h_ops pointer which can be used to > reliably identify an owner. > > So discard h_owner, pass and 'ops' pointer to class_handle2object(), > and only return objects for which the h_ops matches. > > Signed-off-by: NeilBrown The h_owner is not used in the client code, but it is still used in the server code to ensure that only clients which have already opened a file handle can use the open file handle cookie to re-open the file. The h_owner in this case is an MDS-local pointer to the client export data, so just using the h_ops pointer (which is generic to the class of users, not the specific user) would not provide this functionality. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From adilger at whamcloud.com Wed Feb 27 06:52:17 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 06:52:17 +0000 Subject: [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref. In-Reply-To: <155053494637.24125.716197573687357279.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494637.24125.716197573687357279.stgit@noble.brown> Message-ID: On Feb 18, 2019, at 17:09, NeilBrown wrote: > > These arguments are no longer used, so we can discard them. > > Signed-off-by: NeilBrown Well, they are no longer used, because you've removed the users. > -struct obd_device *class_incref(struct obd_device *obd, > - const char *scope, const void *source) > +struct obd_device *class_incref(struct obd_device *obd) > { > atomic_inc(&obd->obd_refcount); > CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd, > @@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd, > } > EXPORT_SYMBOL(class_incref); > > -void class_decref(struct obd_device *obd, const char *scope, const void *source) > +void class_decref(struct obd_device *obd) > { > int last; > > - CDEBUG(D_INFO, "Decref %s (%p) now %d - %s\n", obd->obd_name, obd, > - atomic_read(&obd->obd_refcount), scope); > + CDEBUG(D_INFO, "Decref %s (%p) now %d\n", obd->obd_name, obd, > + atomic_read(&obd->obd_refcount)); In particular, the scope (object type) is printed, which allows debugging the generic incref/decref of these objects (similar to class_get_export() and class_put_export() as mentioned in my other email). If we at least can keep the scope and source, then these generic refcount functions could still be used for debugging. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From neilb at suse.com Wed Feb 27 21:41:23 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 28 Feb 2019 08:41:23 +1100 Subject: [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494646.24125.10155576042684274174.stgit@noble.brown> Message-ID: <87bm2wucxo.fsf@notabene.neil.brown.name> On Wed, Feb 27 2019, Andreas Dilger wrote: > On Feb 18, 2019, at 17:09, NeilBrown wrote: >> >> lustre_handles assigned a 64bit unique identifier (a 'cookie') to >> objects of various types and stored them in a hash table, allowing >> them to be accessed by the cookie. >> >> The is a facility for type checking by recording an 'owner' for each >> object, and checking the owner on lookup. Unfortunately this is not >> used - owner is always zero. >> >> Eahc object also contains an h_ops pointer which can be used to >> reliably identify an owner. >> >> So discard h_owner, pass and 'ops' pointer to class_handle2object(), >> and only return objects for which the h_ops matches. >> >> Signed-off-by: NeilBrown > > The h_owner is not used in the client code, but it is still used in the > server code to ensure that only clients which have already opened a file > handle can use the open file handle cookie to re-open the file. The > h_owner in this case is an MDS-local pointer to the client export data, > so just using the h_ops pointer (which is generic to the class of users, > not the specific user) would not provide this functionality. Is it possible for two different clients to be using the same cookie? The lookup code in class_handle2object() appears to allow this, but I assume it doesn't happen. If it *does*, then the 'owner' does need to be part of the lookup key, at least on the server. If it doesn't, then I think it would be better for the owner to live in struct mdt_file_data rather than in the handle. In the handle it wastes space in the thousands of instances that don't need it. Thanks, NeilBrown > > Cheers, Andreas > --- > Andreas Dilger > Principal Lustre Architect > Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Wed Feb 27 21:48:37 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 28 Feb 2019 08:48:37 +1100 Subject: [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle. In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494654.24125.18407080080202016099.stgit@noble.brown> Message-ID: <878sy0uclm.fsf@notabene.neil.brown.name> On Wed, Feb 27 2019, Andreas Dilger wrote: > On Feb 18, 2019, at 17:09, NeilBrown wrote: >> >> Every object with a lustre_handle has (and must have) a refcount. >> The lustre_handles code needs a call-out to increment this. >> To simplify things, move the refcount into the lustre_handle >> and discard the call-out. >> >> Signed-off-by: NeilBrown > > This patch reduces the debugbility of refcounting on these data > structures, which can be tricky to diagnose if there is a leak > at some point and nothing can clean up at the end because some > data structure is holding an extra reference (e.g. lock->exp->dev). > >> struct obd_export *class_export_get(struct obd_export *exp) >> { >> - refcount_inc(&exp->exp_refcount); >> + refcount_inc(&exp->exp_handle.h_ref); >> CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp, >> - refcount_read(&exp->exp_refcount)); >> + refcount_read(&exp->exp_handle.h_ref)); >> return exp; >> } > > For example, with the existing callback mechanism, class_export_get() > and class_export_put() would be called for every reference added > and removed to this struct obd_export (e.g. when a valid lock handle > is looked up), so with D_INFO logging enabled we can trace all of the > reference counting of the data structures involved. > >> @@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie, >> const struct portals_handle_ops *ops) >> >> spin_lock(&h->h_lock); >> if (likely(h->h_in != 0)) { >> - h->h_ops->hop_addref(h); >> + refcount_inc(&h->h_ref); >> retval = h; >> } >> spin_unlock(&h->h_lock); > > With this change, while class_handle2object() will still reference the > handle correctly, it not print anything into the logs so if there is > something wrong it will be much more difficult to find. To restore the debugability, would it be sufficient to add a CDEBUG(D_INFO) to class_handle2object() where it increments the ref? We could even add a type name to powers_handle_ops to make the messages easier to search for? Thanks, NeilBrown > > Cheers, Andreas > --- > Andreas Dilger > Principal Lustre Architect > Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From adilger at whamcloud.com Wed Feb 27 22:14:47 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 27 Feb 2019 22:14:47 +0000 Subject: [lustre-devel] [PATCH 30/37] lustre: handle: move refcount into the lustre_handle. In-Reply-To: <878sy0uclm.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494654.24125.18407080080202016099.stgit@noble.brown> <878sy0uclm.fsf@notabene.neil.brown.name> Message-ID: <0076CC3E-7DAF-4FEE-9EF4-B41A709D9F61@whamcloud.com> On Feb 27, 2019, at 14:48, NeilBrown wrote: > > On Wed, Feb 27 2019, Andreas Dilger wrote: > >> On Feb 18, 2019, at 17:09, NeilBrown wrote: >>> >>> Every object with a lustre_handle has (and must have) a refcount. >>> The lustre_handles code needs a call-out to increment this. >>> To simplify things, move the refcount into the lustre_handle >>> and discard the call-out. >>> >>> Signed-off-by: NeilBrown >> >> This patch reduces the debugbility of refcounting on these data >> structures, which can be tricky to diagnose if there is a leak >> at some point and nothing can clean up at the end because some >> data structure is holding an extra reference (e.g. lock->exp->dev). >> >>> struct obd_export *class_export_get(struct obd_export *exp) >>> { >>> - refcount_inc(&exp->exp_refcount); >>> + refcount_inc(&exp->exp_handle.h_ref); >>> CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp, >>> - refcount_read(&exp->exp_refcount)); >>> + refcount_read(&exp->exp_handle.h_ref)); >>> return exp; >>> } >> >> For example, with the existing callback mechanism, class_export_get() >> and class_export_put() would be called for every reference added >> and removed to this struct obd_export (e.g. when a valid lock handle >> is looked up), so with D_INFO logging enabled we can trace all of the >> reference counting of the data structures involved. >> >>> @@ -152,7 +152,7 @@ void *class_handle2object(u64 cookie, >>> const struct portals_handle_ops *ops) >>> >>> spin_lock(&h->h_lock); >>> if (likely(h->h_in != 0)) { >>> - h->h_ops->hop_addref(h); >>> + refcount_inc(&h->h_ref); >>> retval = h; >>> } >>> spin_unlock(&h->h_lock); >> >> With this change, while class_handle2object() will still reference the >> handle correctly, it not print anything into the logs so if there is >> something wrong it will be much more difficult to find. > > To restore the debugability, would it be sufficient to add a > CDEBUG(D_INFO) to class_handle2object() where it increments the ref? > We could even add a type name to powers_handle_ops to make the messages > easier to search for? That would probably work. We'd have the pointer+type from the initial reference, and if the pointer+type is logged in the increment/decrement functions then it doesn't matter that they aren't printed by the same function. Ideally the formatting of such messages would be consistent to make searching easier. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud From jsimmons at infradead.org Wed Feb 27 22:36:16 2019 From: jsimmons at infradead.org (James Simmons) Date: Wed, 27 Feb 2019 22:36:16 +0000 (GMT) Subject: [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static. In-Reply-To: <87va16t8pi.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494545.24125.14664274760505145343.stgit@noble.brown> <87va16t8pi.fsf@notabene.neil.brown.name> Message-ID: > >> libcfs_kkuc_msg_put() is never used outside of kernelcomm.c, > >> so make it static. > > > > In the OpenSFS branch libcfs_kkuc_msg_put() is used by the > > client and server code. While this is okay now in the future > > this will be reverted. So do we keep it as is so it can handle > > server code or do this change and then later do what I added > > below: > > Where is it used? > > Looking in the current whamcloud master > Commit f7155420024e ("LU-11208 tests: add version check to sanity tests") > > $ git grep libcfs_kkuc_msg_put > lustre/include/lustre_kernelcomm.h:int libcfs_kkuc_msg_put(struct file *fp, void *payload); > lustre/obdclass/kernelcomm.c: * libcfs_kkuc_msg_put - send an message from kernel to userspace > lustre/obdclass/kernelcomm.c:int libcfs_kkuc_msg_put(struct file *filp, void *payload) > lustre/obdclass/kernelcomm.c:EXPORT_SYMBOL(libcfs_kkuc_msg_put); > lustre/obdclass/kernelcomm.c: rc = libcfs_kkuc_msg_put(reg->kr_fp, payload); > > libcfs_kkuc_msg_put() is only called from libcfs_kkuc_group_put(). > What am I missing? I'm remembering older code. You are correct. Let me give it a proper review. From jsimmons at infradead.org Wed Feb 27 22:37:06 2019 From: jsimmons at infradead.org (James Simmons) Date: Wed, 27 Feb 2019 22:37:06 +0000 (GMT) Subject: [lustre-devel] [PATCH 11/37] lustre: kernelcomm: make libcfs_kkuc_msg_put static. In-Reply-To: <155053494545.24125.14664274760505145343.stgit@noble.brown> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494545.24125.14664274760505145343.stgit@noble.brown> Message-ID: > libcfs_kkuc_msg_put() is never used outside of kernelcomm.c, > so make it static. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../lustre/lustre/include/lustre_kernelcomm.h | 1 - > .../staging/lustre/lustre/obdclass/kernelcomm.c | 3 +-- > 2 files changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h > index 8e3a99057a38..1ed41840ab8f 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h > +++ b/drivers/staging/lustre/lustre/include/lustre_kernelcomm.h > @@ -46,7 +46,6 @@ typedef int (*libcfs_kkuc_cb_t)(void *data, void *cb_arg); > > /* Kernel methods */ > void libcfs_kkuc_init(void); > -int libcfs_kkuc_msg_put(struct file *fp, void *payload); > int libcfs_kkuc_group_put(unsigned int group, void *payload); > int libcfs_kkuc_group_add(struct file *fp, int uid, unsigned int group, > void *data, size_t data_len); > diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > index 09d0b1ab8d1c..27870952b1f0 100644 > --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c > @@ -49,7 +49,7 @@ > * @param payload Payload data. First field of payload is always > * struct kuc_hdr > */ > -int libcfs_kkuc_msg_put(struct file *filp, void *payload) > +static int libcfs_kkuc_msg_put(struct file *filp, void *payload) > { > struct kuc_hdr *kuch = (struct kuc_hdr *)payload; > ssize_t count = kuch->kuc_msglen; > @@ -80,7 +80,6 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload) > > return rc; > } > -EXPORT_SYMBOL(libcfs_kkuc_msg_put); > > /* > * Broadcast groups are global across all mounted filesystems; > > > From neilb at suse.com Thu Feb 28 00:39:19 2019 From: neilb at suse.com (NeilBrown) Date: Thu, 28 Feb 2019 11:39:19 +1100 Subject: [lustre-devel] [PATCH 28/37] lustre: remove scope and source from class_incref and class_decref. In-Reply-To: References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494637.24125.716197573687357279.stgit@noble.brown> Message-ID: <875zt4u4p4.fsf@notabene.neil.brown.name> On Wed, Feb 27 2019, Andreas Dilger wrote: > On Feb 18, 2019, at 17:09, NeilBrown wrote: >> >> These arguments are no longer used, so we can discard them. >> >> Signed-off-by: NeilBrown > > Well, they are no longer used, because you've removed the users. yes...... 'source' isn't used since I removed lu_ref. 'scope' is used, as you say, in a CDEBUG() message. I'll wait until there is more input on the lu_ref stuff before doing anything more about these. I won't push them for now. Thanks, NeilBrown > >> -struct obd_device *class_incref(struct obd_device *obd, >> - const char *scope, const void *source) >> +struct obd_device *class_incref(struct obd_device *obd) >> { >> atomic_inc(&obd->obd_refcount); >> CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd, >> @@ -528,12 +527,12 @@ struct obd_device *class_incref(struct obd_device *obd, >> } >> EXPORT_SYMBOL(class_incref); >> >> -void class_decref(struct obd_device *obd, const char *scope, const void *source) >> +void class_decref(struct obd_device *obd) >> { >> int last; >> >> - CDEBUG(D_INFO, "Decref %s (%p) now %d - %s\n", obd->obd_name, obd, >> - atomic_read(&obd->obd_refcount), scope); >> + CDEBUG(D_INFO, "Decref %s (%p) now %d\n", obd->obd_name, obd, >> + atomic_read(&obd->obd_refcount)); > > In particular, the scope (object type) is printed, which allows debugging the > generic incref/decref of these objects (similar to class_get_export() and > class_put_export() as mentioned in my other email). If we at least can keep > the scope and source, then these generic refcount functions could still be used > for debugging. > > Cheers, Andreas > --- > Andreas Dilger > Principal Lustre Architect > Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From adilger at whamcloud.com Thu Feb 28 06:41:34 2019 From: adilger at whamcloud.com (Andreas Dilger) Date: Thu, 28 Feb 2019 06:41:34 +0000 Subject: [lustre-devel] [PATCH 29/37] lustre: handles: discard h_owner in favour of h_ops In-Reply-To: <87bm2wucxo.fsf@notabene.neil.brown.name> References: <155053473693.24125.6976971762921761309.stgit@noble.brown> <155053494646.24125.10155576042684274174.stgit@noble.brown> <87bm2wucxo.fsf@notabene.neil.brown.name> Message-ID: On Feb 27, 2019, at 14:41, NeilBrown wrote: > > On Wed, Feb 27 2019, Andreas Dilger wrote: > >> On Feb 18, 2019, at 17:09, NeilBrown wrote: >>> >>> lustre_handles assigned a 64bit unique identifier (a 'cookie') to >>> objects of various types and stored them in a hash table, allowing >>> them to be accessed by the cookie. >>> >>> The is a facility for type checking by recording an 'owner' for each >>> object, and checking the owner on lookup. Unfortunately this is not >>> used - owner is always zero. >>> >>> Eahc object also contains an h_ops pointer which can be used to >>> reliably identify an owner. >>> >>> So discard h_owner, pass and 'ops' pointer to class_handle2object(), >>> and only return objects for which the h_ops matches. >>> >>> Signed-off-by: NeilBrown >> >> The h_owner is not used in the client code, but it is still used in the >> server code to ensure that only clients which have already opened a file >> handle can use the open file handle cookie to re-open the file. The >> h_owner in this case is an MDS-local pointer to the client export data, >> so just using the h_ops pointer (which is generic to the class of users, >> not the specific user) would not provide this functionality. > > Is it possible for two different clients to be using the same cookie? > The lookup code in class_handle2object() appears to allow this, but I > assume it doesn't happen. > > If it *does*, then the 'owner' does need to be part of the lookup key, > at least on the server. > If it doesn't, then I think it would be better for the owner to live in > struct mdt_file_data rather than in the handle. In the handle it > wastes space in the thousands of instances that don't need it. No, since the cookie is generated by the MDS in this case, it should be unique among all clients, and a single open file handle can't be used by multiple clients. The goal of class_handle2object() was to ensure that the handle was only valid for the right caller, and some other client couldn't accidentally or maliciously use the same cookie to get access to an object that they weren't allowed to. That said, it looks like the caller mdt_open_handle2mfd() could also do this check itself, to verify that the found handle actually belongs to the client using it. That would need an "owner" pointer to be stored in struct mdt_file_data to reference the export, but at least this overhead would be contained to the one place that needs it. While the MDS could also verify this by scanning the entire list of open files for that client, there could potentially be thousands of files per client that need to be checked. Cheers, Andreas --- Andreas Dilger Principal Lustre Architect Whamcloud