aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2008-02-07 00:27:04 -0500
committerDavid Teigland <teigland@redhat.com>2008-02-07 00:27:04 -0500
commitd292c0cc489fa642799494bddbd7c94d11f7bbc1 (patch)
tree5999df751f987dc59ff052ed07fc7715c00898cc /fs/dlm
parente5dae548b0b5397e070de793be925cfc5813ad95 (diff)
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>
Diffstat (limited to 'fs/dlm')
-rw-r--r--fs/dlm/debug_fs.c6
-rw-r--r--fs/dlm/dlm_internal.h5
-rw-r--r--fs/dlm/lock.c14
-rw-r--r--fs/dlm/memory.c2
-rw-r--r--fs/dlm/netlink.c5
-rw-r--r--fs/dlm/user.c8
6 files changed, 18 insertions, 22 deletions
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 12c3bfd5e660..52b11960a175 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -162,14 +162,12 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)
162 162
163static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) 163static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r)
164{ 164{
165 struct dlm_user_args *ua;
166 unsigned int waiting = 0; 165 unsigned int waiting = 0;
167 uint64_t xid = 0; 166 uint64_t xid = 0;
168 167
169 if (lkb->lkb_flags & DLM_IFL_USER) { 168 if (lkb->lkb_flags & DLM_IFL_USER) {
170 ua = (struct dlm_user_args *) lkb->lkb_astparam; 169 if (lkb->lkb_ua)
171 if (ua) 170 xid = lkb->lkb_ua->xid;
172 xid = ua->xid;
173 } 171 }
174 172
175 if (lkb->lkb_timestamp) 173 if (lkb->lkb_timestamp)
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index a53c237f310c..d30ea8b433a2 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -253,7 +253,10 @@ struct dlm_lkb {
253 struct dlm_lksb *lkb_lksb; /* caller's status block */ 253 struct dlm_lksb *lkb_lksb; /* caller's status block */
254 void (*lkb_astfn) (void *astparam); 254 void (*lkb_astfn) (void *astparam);
255 void (*lkb_bastfn) (void *astparam, int mode); 255 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 };
257}; 260};
258 261
259 262
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 94f8cbd3c0be..8f250ac8b928 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -4533,7 +4533,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4533 /* user can change the params on its lock when it converts it, or 4533 /* user can change the params on its lock when it converts it, or
4534 add an lvb that didn't exist before */ 4534 add an lvb that didn't exist before */
4535 4535
4536 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4536 ua = lkb->lkb_ua;
4537 4537
4538 if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) { 4538 if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) {
4539 ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); 4539 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,
4584 if (error) 4584 if (error)
4585 goto out; 4585 goto out;
4586 4586
4587 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4587 ua = lkb->lkb_ua;
4588 4588
4589 if (lvb_in && ua->lksb.sb_lvbptr) 4589 if (lvb_in && ua->lksb.sb_lvbptr)
4590 memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN); 4590 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,
4633 if (error) 4633 if (error)
4634 goto out; 4634 goto out;
4635 4635
4636 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4636 ua = lkb->lkb_ua;
4637 if (ua_tmp->castparam) 4637 if (ua_tmp->castparam)
4638 ua->castparam = ua_tmp->castparam; 4638 ua->castparam = ua_tmp->castparam;
4639 ua->user_lksb = ua_tmp->user_lksb; 4639 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)
4671 if (error) 4671 if (error)
4672 goto out; 4672 goto out;
4673 4673
4674 ua = (struct dlm_user_args *)lkb->lkb_astparam; 4674 ua = lkb->lkb_ua;
4675 4675
4676 error = set_unlock_args(flags, ua, &args); 4676 error = set_unlock_args(flags, ua, &args);
4677 if (error) 4677 if (error)
@@ -4710,7 +4710,6 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid)
4710 4710
4711static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) 4711static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4712{ 4712{
4713 struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam;
4714 struct dlm_args args; 4713 struct dlm_args args;
4715 int error; 4714 int error;
4716 4715
@@ -4719,7 +4718,7 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4719 list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans); 4718 list_add_tail(&lkb->lkb_ownqueue, &ls->ls_orphans);
4720 mutex_unlock(&ls->ls_orphans_mutex); 4719 mutex_unlock(&ls->ls_orphans_mutex);
4721 4720
4722 set_unlock_args(0, ua, &args); 4721 set_unlock_args(0, lkb->lkb_ua, &args);
4723 4722
4724 error = cancel_lock(ls, lkb, &args); 4723 error = cancel_lock(ls, lkb, &args);
4725 if (error == -DLM_ECANCEL) 4724 if (error == -DLM_ECANCEL)
@@ -4732,11 +4731,10 @@ static int orphan_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4732 4731
4733static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb) 4732static int unlock_proc_lock(struct dlm_ls *ls, struct dlm_lkb *lkb)
4734{ 4733{
4735 struct dlm_user_args *ua = (struct dlm_user_args *)lkb->lkb_astparam;
4736 struct dlm_args args; 4734 struct dlm_args args;
4737 int error; 4735 int error;
4738 4736
4739 set_unlock_args(DLM_LKF_FORCEUNLOCK, ua, &args); 4737 set_unlock_args(DLM_LKF_FORCEUNLOCK, lkb->lkb_ua, &args);
4740 4738
4741 error = unlock_lock(ls, lkb, &args); 4739 error = unlock_lock(ls, lkb, &args);
4742 if (error == -DLM_EUNLOCK) 4740 if (error == -DLM_EUNLOCK)
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index f7783867491a..65e41e5569b0 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -80,7 +80,7 @@ void dlm_free_lkb(struct dlm_lkb *lkb)
80{ 80{
81 if (lkb->lkb_flags & DLM_IFL_USER) { 81 if (lkb->lkb_flags & DLM_IFL_USER) {
82 struct dlm_user_args *ua; 82 struct dlm_user_args *ua;
83 ua = (struct dlm_user_args *)lkb->lkb_astparam; 83 ua = lkb->lkb_ua;
84 if (ua) { 84 if (ua) {
85 if (ua->lksb.sb_lvbptr) 85 if (ua->lksb.sb_lvbptr)
86 kfree(ua->lksb.sb_lvbptr); 86 kfree(ua->lksb.sb_lvbptr);
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c
index 863b87d0dc71..90374b848761 100644
--- a/fs/dlm/netlink.c
+++ b/fs/dlm/netlink.c
@@ -104,7 +104,6 @@ void dlm_netlink_exit(void)
104static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb) 104static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb)
105{ 105{
106 struct dlm_rsb *r = lkb->lkb_resource; 106 struct dlm_rsb *r = lkb->lkb_resource;
107 struct dlm_user_args *ua = (struct dlm_user_args *) lkb->lkb_astparam;
108 107
109 memset(data, 0, sizeof(struct dlm_lock_data)); 108 memset(data, 0, sizeof(struct dlm_lock_data));
110 109
@@ -117,8 +116,8 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb)
117 data->grmode = lkb->lkb_grmode; 116 data->grmode = lkb->lkb_grmode;
118 data->rqmode = lkb->lkb_rqmode; 117 data->rqmode = lkb->lkb_rqmode;
119 data->timestamp = lkb->lkb_timestamp; 118 data->timestamp = lkb->lkb_timestamp;
120 if (ua) 119 if (lkb->lkb_ua)
121 data->xid = ua->xid; 120 data->xid = lkb->lkb_ua->xid;
122 if (r) { 121 if (r) {
123 data->lockspace_id = r->res_ls->ls_global_id; 122 data->lockspace_id = r->res_ls->ls_global_id;
124 data->resource_namelen = r->res_length; 123 data->resource_namelen = r->res_length;
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index c3060458b68e..70b31b914870 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -195,8 +195,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
195 if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD)) 195 if (lkb->lkb_flags & (DLM_IFL_ORPHAN | DLM_IFL_DEAD))
196 goto out; 196 goto out;
197 197
198 DLM_ASSERT(lkb->lkb_astparam, dlm_print_lkb(lkb);); 198 DLM_ASSERT(lkb->lkb_ua, dlm_print_lkb(lkb););
199 ua = (struct dlm_user_args *)lkb->lkb_astparam; 199 ua = lkb->lkb_ua;
200 proc = ua->proc; 200 proc = ua->proc;
201 201
202 if (type == AST_BAST && ua->bastaddr == NULL) 202 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,
771{ 771{
772 struct dlm_user_proc *proc = file->private_data; 772 struct dlm_user_proc *proc = file->private_data;
773 struct dlm_lkb *lkb; 773 struct dlm_lkb *lkb;
774 struct dlm_user_args *ua;
775 DECLARE_WAITQUEUE(wait, current); 774 DECLARE_WAITQUEUE(wait, current);
776 int error, type=0, bmode=0, removed = 0; 775 int error, type=0, bmode=0, removed = 0;
777 776
@@ -842,8 +841,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
842 } 841 }
843 spin_unlock(&proc->asts_spin); 842 spin_unlock(&proc->asts_spin);
844 843
845 ua = (struct dlm_user_args *)lkb->lkb_astparam; 844 error = copy_result_to_user(lkb->lkb_ua,
846 error = copy_result_to_user(ua,
847 test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags), 845 test_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags),
848 type, bmode, buf, count); 846 type, bmode, buf, count);
849 847