]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ocfs2: Add ->get_osb() dlmglue locking operation
authorMark Fasheh <mark.fasheh@oracle.com>
Wed, 13 Sep 2006 04:49:13 +0000 (21:49 -0700)
committerMark Fasheh <mark.fasheh@oracle.com>
Sun, 24 Sep 2006 20:50:46 +0000 (13:50 -0700)
Will be used to find the ocfs2_super structure from a given lockres.

Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
fs/ocfs2/dlmglue.c

index 7532f80b87bc224d8b89d47f447bf8281f97d59e..2e4d43a54652cff35c1ec0d2e9509b4a4cd02f0f 100644 (file)
@@ -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)
 {