Skip to content

Commit e5dae54

Browse files
committed
dlm: proper types for asts and basts
Use proper types for ast and bast functions, and use consistent type for ast param. Signed-off-by: David Teigland <teigland@redhat.com>
1 parent cb79f19 commit e5dae54

4 files changed

Lines changed: 44 additions & 33 deletions

File tree

‎fs/dlm/ast.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type)
3939
dlm_user_add_ast(lkb, type);
4040
return;
4141
}
42-
DLM_ASSERT(lkb->lkb_astaddr != DLM_FAKE_USER_AST, dlm_print_lkb(lkb););
4342

4443
spin_lock(&ast_queue_lock);
4544
if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) {
@@ -58,8 +57,8 @@ static void process_asts(void)
5857
struct dlm_ls *ls = NULL;
5958
struct dlm_rsb *r = NULL;
6059
struct dlm_lkb *lkb;
61-
void (*cast) (long param);
62-
void (*bast) (long param, int mode);
60+
void (*cast) (void *astparam);
61+
void (*bast) (void *astparam, int mode);
6362
int type = 0, found, bmode;
6463

6564
for (;;) {
@@ -83,8 +82,8 @@ static void process_asts(void)
8382
if (!found)
8483
break;
8584

86-
cast = lkb->lkb_astaddr;
87-
bast = lkb->lkb_bastaddr;
85+
cast = lkb->lkb_astfn;
86+
bast = lkb->lkb_bastfn;
8887
bmode = lkb->lkb_bastmode;
8988

9089
if ((type & AST_COMP) && cast)

‎fs/dlm/dlm_internal.h‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ do { \
9292
} \
9393
}
9494

95-
#define DLM_FAKE_USER_AST ERR_PTR(-EINVAL)
96-
9795

9896
struct dlm_direntry {
9997
struct list_head list;
@@ -146,9 +144,9 @@ struct dlm_recover {
146144

147145
struct dlm_args {
148146
uint32_t flags;
149-
void *astaddr;
150-
long astparam;
151-
void *bastaddr;
147+
void (*astfn) (void *astparam);
148+
void *astparam;
149+
void (*bastfn) (void *astparam, int mode);
152150
int mode;
153151
struct dlm_lksb *lksb;
154152
unsigned long timeout;
@@ -253,9 +251,9 @@ struct dlm_lkb {
253251

254252
char *lkb_lvbptr;
255253
struct dlm_lksb *lkb_lksb; /* caller's status block */
256-
void *lkb_astaddr; /* caller's ast function */
257-
void *lkb_bastaddr; /* caller's bast function */
258-
long lkb_astparam; /* caller's ast arg */
254+
void (*lkb_astfn) (void *astparam);
255+
void (*lkb_bastfn) (void *astparam, int mode);
256+
void *lkb_astparam; /* caller's ast arg */
259257
};
260258

261259

‎fs/dlm/lock.c‎

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ static void grant_pending_locks(struct dlm_rsb *r)
17811781
*/
17821782

17831783
list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) {
1784-
if (lkb->lkb_bastaddr && lock_requires_bast(lkb, high, cw)) {
1784+
if (lkb->lkb_bastfn && lock_requires_bast(lkb, high, cw)) {
17851785
if (cw && high == DLM_LOCK_PR)
17861786
queue_bast(r, lkb, DLM_LOCK_CW);
17871787
else
@@ -1811,7 +1811,7 @@ static void send_bast_queue(struct dlm_rsb *r, struct list_head *head,
18111811
struct dlm_lkb *gr;
18121812

18131813
list_for_each_entry(gr, head, lkb_statequeue) {
1814-
if (gr->lkb_bastaddr && modes_require_bast(gr, lkb)) {
1814+
if (gr->lkb_bastfn && modes_require_bast(gr, lkb)) {
18151815
queue_bast(r, gr, lkb->lkb_rqmode);
18161816
gr->lkb_highbast = lkb->lkb_rqmode;
18171817
}
@@ -1966,8 +1966,11 @@ static void confirm_master(struct dlm_rsb *r, int error)
19661966
}
19671967

19681968
static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
1969-
int namelen, unsigned long timeout_cs, void *ast,
1970-
void *astarg, void *bast, struct dlm_args *args)
1969+
int namelen, unsigned long timeout_cs,
1970+
void (*ast) (void *astparam),
1971+
void *astparam,
1972+
void (*bast) (void *astparam, int mode),
1973+
struct dlm_args *args)
19711974
{
19721975
int rv = -EINVAL;
19731976

@@ -2017,9 +2020,9 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
20172020
an active lkb cannot be modified before locking the rsb */
20182021

20192022
args->flags = flags;
2020-
args->astaddr = ast;
2021-
args->astparam = (long) astarg;
2022-
args->bastaddr = bast;
2023+
args->astfn = ast;
2024+
args->astparam = astparam;
2025+
args->bastfn = bast;
20232026
args->timeout = timeout_cs;
20242027
args->mode = mode;
20252028
args->lksb = lksb;
@@ -2038,7 +2041,7 @@ static int set_unlock_args(uint32_t flags, void *astarg, struct dlm_args *args)
20382041
return -EINVAL;
20392042

20402043
args->flags = flags;
2041-
args->astparam = (long) astarg;
2044+
args->astparam = astarg;
20422045
return 0;
20432046
}
20442047

@@ -2068,9 +2071,9 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
20682071

20692072
lkb->lkb_exflags = args->flags;
20702073
lkb->lkb_sbflags = 0;
2071-
lkb->lkb_astaddr = args->astaddr;
2074+
lkb->lkb_astfn = args->astfn;
20722075
lkb->lkb_astparam = args->astparam;
2073-
lkb->lkb_bastaddr = args->bastaddr;
2076+
lkb->lkb_bastfn = args->bastfn;
20742077
lkb->lkb_rqmode = args->mode;
20752078
lkb->lkb_lksb = args->lksb;
20762079
lkb->lkb_lvbptr = args->lksb->sb_lvbptr;
@@ -2717,9 +2720,9 @@ static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb,
27172720
/* m_result and m_bastmode are set from function args,
27182721
not from lkb fields */
27192722

2720-
if (lkb->lkb_bastaddr)
2723+
if (lkb->lkb_bastfn)
27212724
ms->m_asts |= AST_BAST;
2722-
if (lkb->lkb_astaddr)
2725+
if (lkb->lkb_astfn)
27232726
ms->m_asts |= AST_COMP;
27242727

27252728
/* compare with switch in create_message; send_remove() doesn't
@@ -3002,6 +3005,16 @@ static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb,
30023005
return 0;
30033006
}
30043007

3008+
static void fake_bastfn(void *astparam, int mode)
3009+
{
3010+
log_print("fake_bastfn should not be called");
3011+
}
3012+
3013+
static void fake_astfn(void *astparam)
3014+
{
3015+
log_print("fake_astfn should not be called");
3016+
}
3017+
30053018
static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
30063019
struct dlm_message *ms)
30073020
{
@@ -3010,8 +3023,9 @@ static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
30103023
lkb->lkb_remid = ms->m_lkid;
30113024
lkb->lkb_grmode = DLM_LOCK_IV;
30123025
lkb->lkb_rqmode = ms->m_rqmode;
3013-
lkb->lkb_bastaddr = (void *) (long) (ms->m_asts & AST_BAST);
3014-
lkb->lkb_astaddr = (void *) (long) (ms->m_asts & AST_COMP);
3026+
3027+
lkb->lkb_bastfn = (ms->m_asts & AST_BAST) ? &fake_bastfn : NULL;
3028+
lkb->lkb_astfn = (ms->m_asts & AST_COMP) ? &fake_astfn : NULL;
30153029

30163030
if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
30173031
/* lkb was just created so there won't be an lvb yet */
@@ -4291,8 +4305,8 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
42914305
lkb->lkb_grmode = rl->rl_grmode;
42924306
/* don't set lkb_status because add_lkb wants to itself */
42934307

4294-
lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST);
4295-
lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP);
4308+
lkb->lkb_bastfn = (rl->rl_asts & AST_BAST) ? &fake_bastfn : NULL;
4309+
lkb->lkb_astfn = (rl->rl_asts & AST_COMP) ? &fake_astfn : NULL;
42964310

42974311
if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
42984312
int lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) -
@@ -4466,7 +4480,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
44664480
lock and that lkb_astparam is the dlm_user_args structure. */
44674481

44684482
error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs,
4469-
DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args);
4483+
fake_astfn, ua, fake_bastfn, &args);
44704484
lkb->lkb_flags |= DLM_IFL_USER;
44714485
ua->old_mode = DLM_LOCK_IV;
44724486

@@ -4540,7 +4554,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
45404554
ua->old_mode = lkb->lkb_grmode;
45414555

45424556
error = set_lock_args(mode, &ua->lksb, flags, 0, timeout_cs,
4543-
DLM_FAKE_USER_AST, ua, DLM_FAKE_USER_AST, &args);
4557+
fake_astfn, ua, fake_bastfn, &args);
45444558
if (error)
45454559
goto out_put;
45464560

‎fs/dlm/rcom.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb,
318318
rl->rl_status = lkb->lkb_status;
319319
rl->rl_wait_type = cpu_to_le16(lkb->lkb_wait_type);
320320

321-
if (lkb->lkb_bastaddr)
321+
if (lkb->lkb_bastfn)
322322
rl->rl_asts |= AST_BAST;
323-
if (lkb->lkb_astaddr)
323+
if (lkb->lkb_astfn)
324324
rl->rl_asts |= AST_COMP;
325325

326326
rl->rl_namelen = cpu_to_le16(r->res_length);

0 commit comments

Comments
 (0)