Skip to content

Commit a8449f2

Browse files
Alexander Aringteigland
authored andcommitted
dlm: add __CHECKER__ for false positives
This patch will adds #ifndef __CHECKER__ for false positives warnings about an imbalance lock/unlock srcu handling. Which are shown by running sparse checks: fs/dlm/midcomms.c:1065:20: warning: context imbalance in 'dlm_midcomms_get_mhandle' - wrong count at exit Using __CHECKER__ will tell sparse to ignore these sections. Those imbalances are false positive because from upper layer it is always required to call a function in sequence, e.g. if dlm_midcomms_get_mhandle() is successful there must be a dlm_midcomms_commit_mhandle() call afterwards. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 314a554 commit a8449f2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

fs/dlm/lowcomms.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,10 @@ static struct dlm_msg *dlm_lowcomms_new_msg_con(struct connection *con, int len,
13031303
return msg;
13041304
}
13051305

1306+
/* avoid false positive for nodes_srcu, unlock happens in
1307+
* dlm_lowcomms_commit_msg which is a must call if success
1308+
*/
1309+
#ifndef __CHECKER__
13061310
struct dlm_msg *dlm_lowcomms_new_msg(int nodeid, int len, gfp_t allocation,
13071311
char **ppc, void (*cb)(void *data),
13081312
void *data)
@@ -1336,6 +1340,7 @@ struct dlm_msg *dlm_lowcomms_new_msg(int nodeid, int len, gfp_t allocation,
13361340
msg->idx = idx;
13371341
return msg;
13381342
}
1343+
#endif
13391344

13401345
static void _dlm_lowcomms_commit_msg(struct dlm_msg *msg)
13411346
{
@@ -1362,11 +1367,16 @@ static void _dlm_lowcomms_commit_msg(struct dlm_msg *msg)
13621367
return;
13631368
}
13641369

1370+
/* avoid false positive for nodes_srcu, lock was happen in
1371+
* dlm_lowcomms_new_msg
1372+
*/
1373+
#ifndef __CHECKER__
13651374
void dlm_lowcomms_commit_msg(struct dlm_msg *msg)
13661375
{
13671376
_dlm_lowcomms_commit_msg(msg);
13681377
srcu_read_unlock(&connections_srcu, msg->idx);
13691378
}
1379+
#endif
13701380

13711381
void dlm_lowcomms_put_msg(struct dlm_msg *msg)
13721382
{

fs/dlm/midcomms.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,10 @@ static struct dlm_msg *dlm_midcomms_get_msg_3_2(struct dlm_mhandle *mh, int node
10621062
return msg;
10631063
}
10641064

1065+
/* avoid false positive for nodes_srcu, unlock happens in
1066+
* dlm_midcomms_commit_mhandle which is a must call if success
1067+
*/
1068+
#ifndef __CHECKER__
10651069
struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
10661070
gfp_t allocation, char **ppc)
10671071
{
@@ -1127,6 +1131,7 @@ struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
11271131
srcu_read_unlock(&nodes_srcu, idx);
11281132
return NULL;
11291133
}
1134+
#endif
11301135

11311136
static void dlm_midcomms_commit_msg_3_2(struct dlm_mhandle *mh)
11321137
{
@@ -1136,6 +1141,10 @@ static void dlm_midcomms_commit_msg_3_2(struct dlm_mhandle *mh)
11361141
dlm_lowcomms_commit_msg(mh->msg);
11371142
}
11381143

1144+
/* avoid false positive for nodes_srcu, lock was happen in
1145+
* dlm_midcomms_get_mhandle
1146+
*/
1147+
#ifndef __CHECKER__
11391148
void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh)
11401149
{
11411150
switch (mh->node->version) {
@@ -1157,6 +1166,7 @@ void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh)
11571166
break;
11581167
}
11591168
}
1169+
#endif
11601170

11611171
int dlm_midcomms_start(void)
11621172
{

0 commit comments

Comments
 (0)