[PATCH 1/3] nfs: add lock annotations to squelch sparse warnings

From: Ramkumar Ramachandra
Date: Sat Jul 06 2013 - 08:16:19 EST


sparse, being a static analyzer, emits the following warnings:

context imbalance in 'nfs_server_list_start' - wrong count at exit
context imbalance in 'nfs_server_list_start' - unexpected unlock
context imbalance in 'nfs_volume_list_start' - wrong count at exit
context imbalance in 'nfs_volume_list_start' - unexpected unlock

Help it by annotating the pairs of functions with __acquires and
__releases.

Cc: David Howells <dhowells@xxxxxxxxxx>
Cc: Trond Myklebust <Trond.Myklebust@xxxxxxxxxx>
Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
fs/nfs/client.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index c513b0c..2a32ac8 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1253,6 +1253,7 @@ static int nfs_server_list_open(struct inode *inode, struct file *file)
* set up the iterator to start reading from the server list and return the first item
*/
static void *nfs_server_list_start(struct seq_file *m, loff_t *_pos)
+ __acquires(&nn->nfs_client_lock)
{
struct nfs_net *nn = net_generic(m->private, nfs_net_id);

@@ -1275,6 +1276,7 @@ static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos)
* clean up after reading from the transports list
*/
static void nfs_server_list_stop(struct seq_file *p, void *v)
+ __releases(&nn->nfs_client_lock)
{
struct nfs_net *nn = net_generic(p->private, nfs_net_id);

@@ -1338,6 +1340,7 @@ static int nfs_volume_list_open(struct inode *inode, struct file *file)
* set up the iterator to start reading from the volume list and return the first item
*/
static void *nfs_volume_list_start(struct seq_file *m, loff_t *_pos)
+ __acquires(&nn->nfs_client_lock)
{
struct nfs_net *nn = net_generic(m->private, nfs_net_id);

@@ -1360,6 +1363,7 @@ static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos)
* clean up after reading from the transports list
*/
static void nfs_volume_list_stop(struct seq_file *p, void *v)
+ __releases(&nn->nfs_client_lock)
{
struct nfs_net *nn = net_generic(p->private, nfs_net_id);

--
1.8.3.2.733.gf8abaeb

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/