Skip to content

Commit d292c0c

Browse files
committed
dlm: eliminate astparam type casting
Put lkb_astparam in a union with a dlm_user_args pointer to eliminate a lot of type casting. Signed-off-by: David Teigland <teigland@redhat.com>
1 parent e5dae54 commit d292c0c

6 files changed

Lines changed: 18 additions & 22 deletions

File tree

‎fs/dlm/debug_fs.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,12 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)
162162

163163
static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r)
164164
{
165-
struct dlm_user_args *ua;
166165
unsigned int waiting = 0;
167166
uint64_t xid = 0;
168167

169168
if (lkb->lkb_flags & DLM_IFL_USER) {
170-
ua = (struct dlm_user_args *) lkb->lkb_astparam;
171-
if (ua)
172-
xid = ua->xid;
169+
if (lkb->lkb_ua)
170+
xid = lkb->lkb_ua->xid;
173171
}
174172

175173
if (lkb->lkb_timestamp)

‎fs/dlm/dlm_internal.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ struct dlm_lkb {
253253
struct dlm_lksb *lkb_lksb; /* caller's status block */
254254
void (*lkb_astfn) (void *astparam);
255255
void (*lkb_bastfn) (void *astparam, int mode);
256-
void *lkb_astparam; /* caller's ast arg */
256+
union {
257+
void *lkb_astparam; /* caller's ast arg */
258+
struct dlm_user_args *lkb_ua;
259+
};
257260
};
258261

259262

‎fs/dlm/lock.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4533,7 +4533,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
45334533
/* user can change the params on its lock when it converts it, or
45344534
add an lvb that didn't exist before */
45354535

4536-
ua = (struct dlm_user_args *)lkb->lkb_astparam;
4536+
ua = lkb->lkb_ua;
45374537

45384538
if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) {
45394539
ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL);
@@ -4584,7 +4584,7 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
45844584
if (error)
45854585
goto out;
45864586

4587-
ua = (struct dlm_user_args *)lkb->lkb_astparam;
4587+
ua = lkb->lkb_ua;
45884588

45894589
if (lvb_in && ua->lksb.sb_lvbptr)
45904590
memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN);
@@ -4633,7 +4633,7 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
46334633
if (error)
46344634
goto out;
46354635

4636-
ua = (struct dlm_user_args *)lkb->lkb_astparam;
4636+
ua = lkb->lkb_ua;
46374637
if (ua_tmp->castparam)
46384638
ua->castparam = ua_tmp->castparam;
46394639
ua->user_lksb = ua_tmp->user_lksb;
@@ -4671,7 +4671,7 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid)
46714671
if (error)
46724672
goto out;
46734673

4674-
ua = (struct dlm_user_args *)lkb->lkb_astparam;
4674+
ua = lkb->lkb_ua;
46754675

46764676
error = set_unlock_args(flags, ua, &args);
46774677
if (error)
@@ -4710,7 +4710,6 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid)
47104710

47114711
static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
47124712
{
4713-
struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam;
47144713
struct dlm_args args;
47154714
int error;
47164715

@@ -4719,7 +4718,7 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
47194718
list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans);
47204719
mutex_unlock(&ls->ls_orphans_mutex);
47214720

4722-
set_unlock_args(0, ua, &args);
4721+
set_unlock_args(0, lkb->lkb_ua, &args);
47234722

47244723
error = cancel_lock(ls, lkb, &args);
47254724
if (error == -DLM_ECANCEL)
@@ -4732,11 +4731,10 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
47324731

47334732
static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
47344733
{
4735-
struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam;
47364734
struct dlm_args args;
47374735
int error;
47384736

4739-
set_unlock_args(DLM_LKF_FORCEUNLOCK, ua, &args);
4737+
set_unlock_args(DLM_LKF_FORCEUNLOCK, lkb->lkb_ua, &args);
47404738

47414739
error = unlock_lock(ls, lkb, &args);
47424740
if (error == -DLM_EUNLOCK)

‎fs/dlm/memory.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void dlm_free_lkb(struct dlm_lkb *lkb)
8080
{
8181
if (lkb->lkb_flags & DLM_IFL_USER) {
8282
struct dlm_user_args *ua;
83-
ua = (struct dlm_user_args *)lkb->lkb_astparam;
83+
ua = lkb->lkb_ua;
8484
if (ua) {
8585
if (ua->lksb.sb_lvbptr)
8686
kfree(ua->lksb.sb_lvbptr);

‎fs/dlm/netlink.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ void dlm_netlink_exit(void)
104104
static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb)
105105
{
106106
struct dlm_rsb *r = lkb->lkb_resource;
107-
struct dlm_user_args *ua = (struct dlm_user_args *) lkb->lkb_astparam;
108107

109108
memset(data, 0, sizeof(struct dlm_lock_data));
110109

@@ -117,8 +116,8 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb)
117116
data->grmode = lkb->lkb_grmode;
118117
data->rqmode = lkb->lkb_rqmode;
119118
data->timestamp = lkb->lkb_timestamp;
120-
if (ua)
121-
data->xid = ua->xid;
119+
if (lkb->lkb_ua)
120+
data->xid = lkb->lkb_ua->xid;
122121
if (r) {
123122
data->lockspace_id = r->res_ls->ls_global_id;
124123
data->resource_namelen = r->res_length;

‎fs/dlm/user.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
195195
if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
196196
goto out;
197197

198-
DLM_ASSERT(lkb->lkb_astparam, dlm_print_lkb(lkb););
199-
ua = (struct dlm_user_args *)lkb->lkb_astparam;
198+
DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb););
199+
ua = lkb->lkb_ua;
200200
proc = ua->proc;
201201

202202
if (type == AST_BAST && ua->bastaddr == NULL)
@@ -771,7 +771,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
771771
{
772772
struct dlm_user_proc *proc = file->private_data;
773773
struct dlm_lkb *lkb;
774-
struct dlm_user_args *ua;
775774
DECLARE_WAITQUEUE(wait, current);
776775
int error, type=0, bmode=0, removed = 0;
777776

@@ -842,8 +841,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
842841
}
843842
spin_unlock(&proc->asts_spin);
844843

845-
ua = (struct dlm_user_args *)lkb->lkb_astparam;
846-
error = copy_result_to_user(ua,
844+
error = copy_result_to_user(lkb->lkb_ua,
847845
test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags),
848846
type, bmode, buf, count);
849847

0 commit comments

Comments
 (0)