Skip to content

Commit c0e4133

Browse files
author
Joel Becker
committed
ocfs2: Attach the connection to the lksb
We're going to want it in the ast functions, so we convert union ocfs2_dlm_lksb to struct ocfs2_dlm_lksb and let it carry the connection. Signed-off-by: Joel Becker <joel.becker@oracle.com>
1 parent a796d28 commit c0e4133

6 files changed

Lines changed: 56 additions & 47 deletions

File tree

‎fs/ocfs2/dlmglue.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres)
297297
lockres->l_type == OCFS2_LOCK_TYPE_OPEN;
298298
}
299299

300-
static inline struct ocfs2_lock_res *ocfs2_lksb_to_lock_res(union ocfs2_dlm_lksb *lksb)
300+
static inline struct ocfs2_lock_res *ocfs2_lksb_to_lock_res(struct ocfs2_dlm_lksb *lksb)
301301
{
302302
return container_of(lksb, struct ocfs2_lock_res, l_lksb);
303303
}
@@ -1046,7 +1046,7 @@ static unsigned int lockres_set_pending(struct ocfs2_lock_res *lockres)
10461046
}
10471047

10481048

1049-
static void ocfs2_blocking_ast(union ocfs2_dlm_lksb *lksb, int level)
1049+
static void ocfs2_blocking_ast(struct ocfs2_dlm_lksb *lksb, int level)
10501050
{
10511051
struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb);
10521052
struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
@@ -1077,7 +1077,7 @@ static void ocfs2_blocking_ast(union ocfs2_dlm_lksb *lksb, int level)
10771077
ocfs2_wake_downconvert_thread(osb);
10781078
}
10791079

1080-
static void ocfs2_locking_ast(union ocfs2_dlm_lksb *lksb)
1080+
static void ocfs2_locking_ast(struct ocfs2_dlm_lksb *lksb)
10811081
{
10821082
struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb);
10831083
struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
@@ -3058,7 +3058,7 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
30583058
mlog_exit_void();
30593059
}
30603060

3061-
static void ocfs2_unlock_ast(union ocfs2_dlm_lksb *lksb, int error)
3061+
static void ocfs2_unlock_ast(struct ocfs2_dlm_lksb *lksb, int error)
30623062
{
30633063
struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb);
30643064
unsigned long flags;

‎fs/ocfs2/ocfs2.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ struct ocfs2_lock_res {
159159
int l_level;
160160
unsigned int l_ro_holders;
161161
unsigned int l_ex_holders;
162-
union ocfs2_dlm_lksb l_lksb;
162+
struct ocfs2_dlm_lksb l_lksb;
163163

164164
/* used from AST/BAST funcs. */
165165
enum ocfs2_ast_action l_action;

‎fs/ocfs2/stack_o2cb.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int dlm_status_to_errno(enum dlm_status status)
161161

162162
static void o2dlm_lock_ast_wrapper(void *astarg)
163163
{
164-
union ocfs2_dlm_lksb *lksb = astarg;
164+
struct ocfs2_dlm_lksb *lksb = astarg;
165165

166166
BUG_ON(o2cb_stack.sp_proto == NULL);
167167

@@ -170,7 +170,7 @@ static void o2dlm_lock_ast_wrapper(void *astarg)
170170

171171
static void o2dlm_blocking_ast_wrapper(void *astarg, int level)
172172
{
173-
union ocfs2_dlm_lksb *lksb = astarg;
173+
struct ocfs2_dlm_lksb *lksb = astarg;
174174

175175
BUG_ON(o2cb_stack.sp_proto == NULL);
176176

@@ -179,7 +179,7 @@ static void o2dlm_blocking_ast_wrapper(void *astarg, int level)
179179

180180
static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
181181
{
182-
union ocfs2_dlm_lksb *lksb = astarg;
182+
struct ocfs2_dlm_lksb *lksb = astarg;
183183

184184
int error = dlm_status_to_errno(status);
185185

@@ -204,7 +204,7 @@ static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
204204

205205
static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,
206206
int mode,
207-
union ocfs2_dlm_lksb *lksb,
207+
struct ocfs2_dlm_lksb *lksb,
208208
u32 flags,
209209
void *name,
210210
unsigned int namelen)
@@ -223,7 +223,7 @@ static int o2cb_dlm_lock(struct ocfs2_cluster_connection *conn,
223223
}
224224

225225
static int o2cb_dlm_unlock(struct ocfs2_cluster_connection *conn,
226-
union ocfs2_dlm_lksb *lksb,
226+
struct ocfs2_dlm_lksb *lksb,
227227
u32 flags)
228228
{
229229
enum dlm_status status;
@@ -236,7 +236,7 @@ static int o2cb_dlm_unlock(struct ocfs2_cluster_connection *conn,
236236
return ret;
237237
}
238238

239-
static int o2cb_dlm_lock_status(union ocfs2_dlm_lksb *lksb)
239+
static int o2cb_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
240240
{
241241
return dlm_status_to_errno(lksb->lksb_o2dlm.status);
242242
}
@@ -246,17 +246,17 @@ static int o2cb_dlm_lock_status(union ocfs2_dlm_lksb *lksb)
246246
* contents, it will zero out the LVB. Thus the caller can always trust
247247
* the contents.
248248
*/
249-
static int o2cb_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb)
249+
static int o2cb_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb)
250250
{
251251
return 1;
252252
}
253253

254-
static void *o2cb_dlm_lvb(union ocfs2_dlm_lksb *lksb)
254+
static void *o2cb_dlm_lvb(struct ocfs2_dlm_lksb *lksb)
255255
{
256256
return (void *)(lksb->lksb_o2dlm.lvb);
257257
}
258258

259-
static void o2cb_dump_lksb(union ocfs2_dlm_lksb *lksb)
259+
static void o2cb_dump_lksb(struct ocfs2_dlm_lksb *lksb)
260260
{
261261
dlm_print_one_lock(lksb->lksb_o2dlm.lockid);
262262
}

‎fs/ocfs2/stack_user.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ static void ocfs2_control_exit(void)
665665

666666
static void fsdlm_lock_ast_wrapper(void *astarg)
667667
{
668-
union ocfs2_dlm_lksb *lksb = astarg;
668+
struct ocfs2_dlm_lksb *lksb = astarg;
669669
int status = lksb->lksb_fsdlm.sb_status;
670670

671671
BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
@@ -688,7 +688,7 @@ static void fsdlm_lock_ast_wrapper(void *astarg)
688688

689689
static void fsdlm_blocking_ast_wrapper(void *astarg, int level)
690690
{
691-
union ocfs2_dlm_lksb *lksb = astarg;
691+
struct ocfs2_dlm_lksb *lksb = astarg;
692692

693693
BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
694694

@@ -697,7 +697,7 @@ static void fsdlm_blocking_ast_wrapper(void *astarg, int level)
697697

698698
static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
699699
int mode,
700-
union ocfs2_dlm_lksb *lksb,
700+
struct ocfs2_dlm_lksb *lksb,
701701
u32 flags,
702702
void *name,
703703
unsigned int namelen)
@@ -716,7 +716,7 @@ static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
716716
}
717717

718718
static int user_dlm_unlock(struct ocfs2_cluster_connection *conn,
719-
union ocfs2_dlm_lksb *lksb,
719+
struct ocfs2_dlm_lksb *lksb,
720720
u32 flags)
721721
{
722722
int ret;
@@ -726,27 +726,27 @@ static int user_dlm_unlock(struct ocfs2_cluster_connection *conn,
726726
return ret;
727727
}
728728

729-
static int user_dlm_lock_status(union ocfs2_dlm_lksb *lksb)
729+
static int user_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
730730
{
731731
return lksb->lksb_fsdlm.sb_status;
732732
}
733733

734-
static int user_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb)
734+
static int user_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb)
735735
{
736736
int invalid = lksb->lksb_fsdlm.sb_flags & DLM_SBF_VALNOTVALID;
737737

738738
return !invalid;
739739
}
740740

741-
static void *user_dlm_lvb(union ocfs2_dlm_lksb *lksb)
741+
static void *user_dlm_lvb(struct ocfs2_dlm_lksb *lksb)
742742
{
743743
if (!lksb->lksb_fsdlm.sb_lvbptr)
744744
lksb->lksb_fsdlm.sb_lvbptr = (char *)lksb +
745745
sizeof(struct dlm_lksb);
746746
return (void *)(lksb->lksb_fsdlm.sb_lvbptr);
747747
}
748748

749-
static void user_dlm_dump_lksb(union ocfs2_dlm_lksb *lksb)
749+
static void user_dlm_dump_lksb(struct ocfs2_dlm_lksb *lksb)
750750
{
751751
}
752752

‎fs/ocfs2/stackglue.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,47 +240,52 @@ EXPORT_SYMBOL_GPL(ocfs2_stack_glue_set_locking_protocol);
240240
*/
241241
int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
242242
int mode,
243-
union ocfs2_dlm_lksb *lksb,
243+
struct ocfs2_dlm_lksb *lksb,
244244
u32 flags,
245245
void *name,
246246
unsigned int namelen)
247247
{
248248
BUG_ON(lproto == NULL);
249249

250+
if (!lksb->lksb_conn)
251+
lksb->lksb_conn = conn;
252+
else
253+
BUG_ON(lksb->lksb_conn != conn);
250254
return active_stack->sp_ops->dlm_lock(conn, mode, lksb, flags,
251255
name, namelen);
252256
}
253257
EXPORT_SYMBOL_GPL(ocfs2_dlm_lock);
254258

255259
int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
256-
union ocfs2_dlm_lksb *lksb,
260+
struct ocfs2_dlm_lksb *lksb,
257261
u32 flags)
258262
{
259263
BUG_ON(lproto == NULL);
264+
BUG_ON(lksb->lksb_conn == NULL);
260265

261266
return active_stack->sp_ops->dlm_unlock(conn, lksb, flags);
262267
}
263268
EXPORT_SYMBOL_GPL(ocfs2_dlm_unlock);
264269

265-
int ocfs2_dlm_lock_status(union ocfs2_dlm_lksb *lksb)
270+
int ocfs2_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
266271
{
267272
return active_stack->sp_ops->lock_status(lksb);
268273
}
269274
EXPORT_SYMBOL_GPL(ocfs2_dlm_lock_status);
270275

271-
int ocfs2_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb)
276+
int ocfs2_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb)
272277
{
273278
return active_stack->sp_ops->lvb_valid(lksb);
274279
}
275280
EXPORT_SYMBOL_GPL(ocfs2_dlm_lvb_valid);
276281

277-
void *ocfs2_dlm_lvb(union ocfs2_dlm_lksb *lksb)
282+
void *ocfs2_dlm_lvb(struct ocfs2_dlm_lksb *lksb)
278283
{
279284
return active_stack->sp_ops->lock_lvb(lksb);
280285
}
281286
EXPORT_SYMBOL_GPL(ocfs2_dlm_lvb);
282287

283-
void ocfs2_dlm_dump_lksb(union ocfs2_dlm_lksb *lksb)
288+
void ocfs2_dlm_dump_lksb(struct ocfs2_dlm_lksb *lksb)
284289
{
285290
active_stack->sp_ops->dump_lksb(lksb);
286291
}

‎fs/ocfs2/stackglue.h‎

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,24 @@ struct fsdlm_lksb_plus_lvb {
7070
* size of the union is known. Lock status structures are embedded in
7171
* ocfs2 inodes.
7272
*/
73-
union ocfs2_dlm_lksb {
74-
struct dlm_lockstatus lksb_o2dlm;
75-
struct dlm_lksb lksb_fsdlm;
76-
struct fsdlm_lksb_plus_lvb padding;
73+
struct ocfs2_cluster_connection;
74+
struct ocfs2_dlm_lksb {
75+
union {
76+
struct dlm_lockstatus lksb_o2dlm;
77+
struct dlm_lksb lksb_fsdlm;
78+
struct fsdlm_lksb_plus_lvb padding;
79+
};
80+
struct ocfs2_cluster_connection *lksb_conn;
7781
};
7882

7983
/*
8084
* The ocfs2_locking_protocol defines the handlers called on ocfs2's behalf.
8185
*/
8286
struct ocfs2_locking_protocol {
8387
struct ocfs2_protocol_version lp_max_version;
84-
void (*lp_lock_ast)(union ocfs2_dlm_lksb *lksb);
85-
void (*lp_blocking_ast)(union ocfs2_dlm_lksb *lksb, int level);
86-
void (*lp_unlock_ast)(union ocfs2_dlm_lksb *lksb, int error);
88+
void (*lp_lock_ast)(struct ocfs2_dlm_lksb *lksb);
89+
void (*lp_blocking_ast)(struct ocfs2_dlm_lksb *lksb, int level);
90+
void (*lp_unlock_ast)(struct ocfs2_dlm_lksb *lksb, int error);
8791
};
8892

8993

@@ -161,7 +165,7 @@ struct ocfs2_stack_operations {
161165
*/
162166
int (*dlm_lock)(struct ocfs2_cluster_connection *conn,
163167
int mode,
164-
union ocfs2_dlm_lksb *lksb,
168+
struct ocfs2_dlm_lksb *lksb,
165169
u32 flags,
166170
void *name,
167171
unsigned int namelen);
@@ -176,7 +180,7 @@ struct ocfs2_stack_operations {
176180
* function. The caller can use this to find their object.
177181
*/
178182
int (*dlm_unlock)(struct ocfs2_cluster_connection *conn,
179-
union ocfs2_dlm_lksb *lksb,
183+
struct ocfs2_dlm_lksb *lksb,
180184
u32 flags);
181185

182186
/*
@@ -185,17 +189,17 @@ struct ocfs2_stack_operations {
185189
* callback pulls out the stack-specific lksb, converts the status
186190
* to a proper errno, and returns it.
187191
*/
188-
int (*lock_status)(union ocfs2_dlm_lksb *lksb);
192+
int (*lock_status)(struct ocfs2_dlm_lksb *lksb);
189193

190194
/*
191195
* Return non-zero if the LVB is valid.
192196
*/
193-
int (*lvb_valid)(union ocfs2_dlm_lksb *lksb);
197+
int (*lvb_valid)(struct ocfs2_dlm_lksb *lksb);
194198

195199
/*
196200
* Pull the lvb pointer off of the stack-specific lksb.
197201
*/
198-
void *(*lock_lvb)(union ocfs2_dlm_lksb *lksb);
202+
void *(*lock_lvb)(struct ocfs2_dlm_lksb *lksb);
199203

200204
/*
201205
* Cluster-aware posix locks
@@ -212,7 +216,7 @@ struct ocfs2_stack_operations {
212216
* This is an optoinal debugging hook. If provided, the
213217
* stack can dump debugging information about this lock.
214218
*/
215-
void (*dump_lksb)(union ocfs2_dlm_lksb *lksb);
219+
void (*dump_lksb)(struct ocfs2_dlm_lksb *lksb);
216220
};
217221

218222
/*
@@ -248,18 +252,18 @@ int ocfs2_cluster_this_node(unsigned int *node);
248252
struct ocfs2_lock_res;
249253
int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
250254
int mode,
251-
union ocfs2_dlm_lksb *lksb,
255+
struct ocfs2_dlm_lksb *lksb,
252256
u32 flags,
253257
void *name,
254258
unsigned int namelen);
255259
int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
256-
union ocfs2_dlm_lksb *lksb,
260+
struct ocfs2_dlm_lksb *lksb,
257261
u32 flags);
258262

259-
int ocfs2_dlm_lock_status(union ocfs2_dlm_lksb *lksb);
260-
int ocfs2_dlm_lvb_valid(union ocfs2_dlm_lksb *lksb);
261-
void *ocfs2_dlm_lvb(union ocfs2_dlm_lksb *lksb);
262-
void ocfs2_dlm_dump_lksb(union ocfs2_dlm_lksb *lksb);
263+
int ocfs2_dlm_lock_status(struct ocfs2_dlm_lksb *lksb);
264+
int ocfs2_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb);
265+
void *ocfs2_dlm_lvb(struct ocfs2_dlm_lksb *lksb);
266+
void ocfs2_dlm_dump_lksb(struct ocfs2_dlm_lksb *lksb);
263267

264268
int ocfs2_stack_supports_plocks(void);
265269
int ocfs2_plock(struct ocfs2_cluster_connection *conn, u64 ino,

0 commit comments

Comments
 (0)