aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlmglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/dlmglue.c')
-rw-r--r--fs/ocfs2/dlmglue.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 7532f80b87bc..2e4d43a54652 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -75,6 +75,8 @@ static void ocfs2_super_bast_func(void *opaque,
75 int level); 75 int level);
76static void ocfs2_rename_bast_func(void *opaque, 76static void ocfs2_rename_bast_func(void *opaque,
77 int level); 77 int level);
78static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres);
79static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres);
78 80
79/* 81/*
80 * Return value from ocfs2_convert_worker_t functions. 82 * Return value from ocfs2_convert_worker_t functions.
@@ -116,6 +118,11 @@ static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
116 * These fine tune the behavior of the generic dlmglue locking infrastructure. 118 * These fine tune the behavior of the generic dlmglue locking infrastructure.
117 */ 119 */
118struct ocfs2_lock_res_ops { 120struct ocfs2_lock_res_ops {
121 /*
122 * Translate an ocfs2_lock_res * into an ocfs2_super *. Define
123 * this callback if ->l_priv is not an ocfs2_super pointer
124 */
125 struct ocfs2_super * (*get_osb)(struct ocfs2_lock_res *);
119 void (*bast)(void *, int); 126 void (*bast)(void *, int);
120 int (*unblock)(struct ocfs2_lock_res *, struct ocfs2_unblock_ctl *); 127 int (*unblock)(struct ocfs2_lock_res *, struct ocfs2_unblock_ctl *);
121 void (*post_unlock)(struct ocfs2_super *, struct ocfs2_lock_res *); 128 void (*post_unlock)(struct ocfs2_super *, struct ocfs2_lock_res *);
@@ -144,18 +151,21 @@ static int ocfs2_generic_unblock_lock(struct ocfs2_super *osb,
144 ocfs2_convert_worker_t *worker); 151 ocfs2_convert_worker_t *worker);
145 152
146static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { 153static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = {
154 .get_osb = ocfs2_get_inode_osb,
147 .bast = ocfs2_inode_bast_func, 155 .bast = ocfs2_inode_bast_func,
148 .unblock = ocfs2_unblock_inode_lock, 156 .unblock = ocfs2_unblock_inode_lock,
149 .flags = 0, 157 .flags = 0,
150}; 158};
151 159
152static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = { 160static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = {
161 .get_osb = ocfs2_get_inode_osb,
153 .bast = ocfs2_inode_bast_func, 162 .bast = ocfs2_inode_bast_func,
154 .unblock = ocfs2_unblock_meta, 163 .unblock = ocfs2_unblock_meta,
155 .flags = LOCK_TYPE_REQUIRES_REFRESH, 164 .flags = LOCK_TYPE_REQUIRES_REFRESH,
156}; 165};
157 166
158static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = { 167static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = {
168 .get_osb = ocfs2_get_inode_osb,
159 .bast = ocfs2_inode_bast_func, 169 .bast = ocfs2_inode_bast_func,
160 .unblock = ocfs2_unblock_data, 170 .unblock = ocfs2_unblock_data,
161 .flags = 0, 171 .flags = 0,
@@ -174,6 +184,7 @@ static struct ocfs2_lock_res_ops ocfs2_rename_lops = {
174}; 184};
175 185
176static struct ocfs2_lock_res_ops ocfs2_dentry_lops = { 186static struct ocfs2_lock_res_ops ocfs2_dentry_lops = {
187 .get_osb = ocfs2_get_dentry_osb,
177 .bast = ocfs2_dentry_bast_func, 188 .bast = ocfs2_dentry_bast_func,
178 .unblock = ocfs2_unblock_dentry_lock, 189 .unblock = ocfs2_unblock_dentry_lock,
179 .post_unlock = ocfs2_dentry_post_unlock, 190 .post_unlock = ocfs2_dentry_post_unlock,
@@ -219,6 +230,14 @@ static inline struct ocfs2_dentry_lock *ocfs2_lock_res_dl(struct ocfs2_lock_res
219 return (struct ocfs2_dentry_lock *)lockres->l_priv; 230 return (struct ocfs2_dentry_lock *)lockres->l_priv;
220} 231}
221 232
233static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *lockres)
234{
235 if (lockres->l_ops->get_osb)
236 return lockres->l_ops->get_osb(lockres);
237
238 return (struct ocfs2_super *)lockres->l_priv;
239}
240
222static int ocfs2_lock_create(struct ocfs2_super *osb, 241static int ocfs2_lock_create(struct ocfs2_super *osb,
223 struct ocfs2_lock_res *lockres, 242 struct ocfs2_lock_res *lockres,
224 int level, 243 int level,
@@ -352,6 +371,13 @@ void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
352 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), res, type, ops, inode); 371 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), res, type, ops, inode);
353} 372}
354 373
374static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres)
375{
376 struct inode *inode = ocfs2_lock_res_inode(lockres);
377
378 return OCFS2_SB(inode->i_sb);
379}
380
355static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) 381static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres)
356{ 382{
357 __be64 inode_blkno_be; 383 __be64 inode_blkno_be;
@@ -362,6 +388,13 @@ static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres)
362 return be64_to_cpu(inode_blkno_be); 388 return be64_to_cpu(inode_blkno_be);
363} 389}
364 390
391static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres)
392{
393 struct ocfs2_dentry_lock *dl = lockres->l_priv;
394
395 return OCFS2_SB(dl->dl_inode->i_sb);
396}
397
365void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl, 398void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl,
366 u64 parent, struct inode *inode) 399 u64 parent, struct inode *inode)
367{ 400{