diff options
author | Mark Fasheh <mark.fasheh@oracle.com> | 2006-09-13 00:49:13 -0400 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2006-09-24 16:50:46 -0400 |
commit | 54a7e7552e484c08db221e49c4519ccdeb8882d0 (patch) | |
tree | 9787fd07933105339ec5f2310888166d63cbc4b0 /fs/ocfs2 | |
parent | 2a45f2d13e1dd91bc110801f5818379f2699509c (diff) |
ocfs2: Add ->get_osb() dlmglue locking operation
Will be used to find the ocfs2_super structure from a given lockres.
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/dlmglue.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 7532f80b87b..2e4d43a5465 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); |
76 | static void ocfs2_rename_bast_func(void *opaque, | 76 | static void ocfs2_rename_bast_func(void *opaque, |
77 | int level); | 77 | int level); |
78 | static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres); | ||
79 | static 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 | */ |
118 | struct ocfs2_lock_res_ops { | 120 | struct 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 | ||
146 | static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { | 153 | static 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 | ||
152 | static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = { | 160 | static 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 | ||
158 | static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = { | 167 | static 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 | ||
176 | static struct ocfs2_lock_res_ops ocfs2_dentry_lops = { | 186 | static 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 | ||
233 | static 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 | |||
222 | static int ocfs2_lock_create(struct ocfs2_super *osb, | 241 | static 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 | ||
374 | static 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 | |||
355 | static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) | 381 | static __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 | ||
391 | static 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 | |||
365 | void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl, | 398 | void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl, |
366 | u64 parent, struct inode *inode) | 399 | u64 parent, struct inode *inode) |
367 | { | 400 | { |