staging: lustre: add sparse locking annotations
authorfrank zago <fzago@cray.com>
Wed, 23 Dec 2015 17:32:11 +0000 (12:32 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Feb 2016 22:16:48 +0000 (14:16 -0800)
Adds __acquires / __releases / __must_hold sparse locking annotations to
several functions.

Fixes sparse warnings such as:

libcfs/libcfs/hash.c:127:1: warning: context imbalance in 'cfs_hash_spin_lock'
        - wrong count at exit
libcfs/libcfs/hash.c:133:1: warning: context imbalance in 'cfs_hash_spin_unlock'
        - unexpected unlock
libcfs/libcfs/hash.c:141:9: warning: context imbalance in 'cfs_hash_rw_lock'
        - wrong count at exit
include/linux/rwlock_api_smp.h:221:9: warning: context imbalance in
        'cfs_hash_rw_unlock' - unexpected unlock

Signed-off-by: frank zago <fzago@cray.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5396
Reviewed-on: http://review.whamcloud.com/11295
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
drivers/staging/lustre/lustre/libcfs/libcfs_lock.c
drivers/staging/lustre/lustre/osc/osc_cache.c
drivers/staging/lustre/lustre/ptlrpc/client.c

index c7b9ccb..176c79b 100644 (file)
@@ -750,8 +750,7 @@ kiblnd_setup_rd_kiov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
 
 static int
 kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
-       __releases(conn->ibc_lock)
-       __acquires(conn->ibc_lock)
+       __must_hold(&conn->ibc_lock)
 {
        kib_msg_t *msg = tx->tx_msg;
        kib_peer_t *peer = conn->ibc_peer;
index 477b385..a0955d2 100644 (file)
@@ -2336,6 +2336,7 @@ ksocknal_flush_stale_txs(ksock_peer_t *peer)
 
 static int
 ksocknal_send_keepalive_locked(ksock_peer_t *peer)
+       __must_hold(&ksocknal_data.ksnd_global_lock)
 {
        ksock_sched_t *sched;
        ksock_conn_t *conn;
index 15782d9..32db788 100644 (file)
@@ -90,6 +90,7 @@ EXPORT_SYMBOL(cfs_percpt_lock_alloc);
  */
 void
 cfs_percpt_lock(struct cfs_percpt_lock *pcl, int index)
+       __acquires(pcl->pcl_locks)
 {
        int     ncpt = cfs_cpt_number(pcl->pcl_cptab);
        int     i;
@@ -124,6 +125,7 @@ EXPORT_SYMBOL(cfs_percpt_lock);
 /** unlock a CPU partition */
 void
 cfs_percpt_unlock(struct cfs_percpt_lock *pcl, int index)
+       __releases(pcl->pcl_locks)
 {
        int     ncpt = cfs_cpt_number(pcl->pcl_cptab);
        int     i;
index 2229419..6b5f8d0 100644 (file)
@@ -1938,6 +1938,7 @@ static int get_write_extents(struct osc_object *obj, struct list_head *rpclist)
 static int
 osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
                   struct osc_object *osc)
+       __must_hold(osc)
 {
        LIST_HEAD(rpclist);
        struct osc_extent *ext;
@@ -2010,6 +2011,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli,
 static int
 osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli,
                  struct osc_object *osc)
+       __must_hold(osc)
 {
        struct osc_extent *ext;
        struct osc_extent *next;
@@ -2083,6 +2085,7 @@ static struct osc_object *osc_next_obj(struct client_obd *cli)
 
 /* called with the loi list lock held */
 static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli)
+       __must_hold(&cli->cl_loi_list_lock)
 {
        struct osc_object *osc;
        int rc = 0;
index efdda09..8f3c26f 100644 (file)
@@ -353,6 +353,7 @@ static int unpack_reply(struct ptlrpc_request *req)
  * If anything goes wrong just ignore it - same as if it never happened
  */
 static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req)
+       __must_hold(&req->rq_lock)
 {
        struct ptlrpc_request *early_req;
        time64_t olddl;