diff options
author | Mark Fasheh <mark.fasheh@oracle.com> | 2006-09-12 21:49:13 -0700 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2006-09-24 13:50:46 -0700 |
commit | 54a7e7552e484c08db221e49c4519ccdeb8882d0 (patch) | |
tree | 9787fd07933105339ec5f2310888166d63cbc4b0 | |
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>
-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 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, int level); static void ocfs2_rename_bast_func(void *opaque, int level); +static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres); +static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres); /* * Return value from ocfs2_convert_worker_t functions. @@ -116,6 +118,11 @@ static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb, * These fine tune the behavior of the generic dlmglue locking infrastructure. */ struct ocfs2_lock_res_ops { + /* + * Translate an ocfs2_lock_res * into an ocfs2_super *. Define + * this callback if ->l_priv is not an ocfs2_super pointer + */ + struct ocfs2_super * (*get_osb)(struct ocfs2_lock_res *); void (*bast)(void *, int); int (*unblock)(struct ocfs2_lock_res *, struct ocfs2_unblock_ctl *); void (*post_unlock)(struct ocfs2_super *, struct ocfs2_lock_res *); @@ -144,18 +151,21 @@ static int ocfs2_generic_unblock_lock(struct ocfs2_super *osb, ocfs2_convert_worker_t *worker); static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { + .get_osb = ocfs2_get_inode_osb, .bast = ocfs2_inode_bast_func, .unblock = ocfs2_unblock_inode_lock, .flags = 0, }; static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = { + .get_osb = ocfs2_get_inode_osb, .bast = ocfs2_inode_bast_func, .unblock = ocfs2_unblock_meta, .flags = LOCK_TYPE_REQUIRES_REFRESH, }; static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = { + .get_osb = ocfs2_get_inode_osb, .bast = ocfs2_inode_bast_func, .unblock = ocfs2_unblock_data, .flags = 0, @@ -174,6 +184,7 @@ static struct ocfs2_lock_res_ops ocfs2_rename_lops = { }; static struct ocfs2_lock_res_ops ocfs2_dentry_lops = { + .get_osb = ocfs2_get_dentry_osb, .bast = ocfs2_dentry_bast_func, .unblock = ocfs2_unblock_dentry_lock, .post_unlock = ocfs2_dentry_post_unlock, @@ -219,6 +230,14 @@ static inline struct ocfs2_dentry_lock *ocfs2_lock_res_dl(struct ocfs2_lock_res return (struct ocfs2_dentry_lock *)lockres->l_priv; } +static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *lockres) +{ + if (lockres->l_ops->get_osb) + return lockres->l_ops->get_osb(lockres); + + return (struct ocfs2_super *)lockres->l_priv; +} + static int ocfs2_lock_create(struct ocfs2_super *osb, struct ocfs2_lock_res *lockres, int level, @@ -352,6 +371,13 @@ void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res, ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), res, type, ops, inode); } +static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres) +{ + struct inode *inode = ocfs2_lock_res_inode(lockres); + + return OCFS2_SB(inode->i_sb); +} + static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) { __be64 inode_blkno_be; @@ -362,6 +388,13 @@ static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) return be64_to_cpu(inode_blkno_be); } +static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres) +{ + struct ocfs2_dentry_lock *dl = lockres->l_priv; + + return OCFS2_SB(dl->dl_inode->i_sb); +} + void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl, u64 parent, struct inode *inode) { |