[Ocfs2-commits] mfasheh commits r1668 - branches/dlm-glue/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Nov 23 15:10:24 CST 2004
Author: mfasheh
Date: 2004-11-23 15:10:22 -0600 (Tue, 23 Nov 2004)
New Revision: 1668
Modified:
branches/dlm-glue/src/dlmglue.c
branches/dlm-glue/src/dlmglue.h
branches/dlm-glue/src/inode.c
branches/dlm-glue/src/ocfs.h
branches/dlm-glue/src/super.c
branches/dlm-glue/src/vote.c
Log:
* genericize things more, clean some stuff up. Adding new lock types
should be very easy now...
Modified: branches/dlm-glue/src/dlmglue.c
===================================================================
--- branches/dlm-glue/src/dlmglue.c 2004-11-23 18:39:29 UTC (rev 1667)
+++ branches/dlm-glue/src/dlmglue.c 2004-11-23 21:10:22 UTC (rev 1668)
@@ -35,7 +35,6 @@
#include <dlmhb.h>
#include <dlmnm.h>
#include <dlmtcp.h>
-//#include <dlmnet.h>
#include <dlmmod.h>
#include "ocfs_log.h"
@@ -81,19 +80,53 @@
static void ocfs2_super_ast_func(void *opaque);
static void ocfs2_super_bast_func(void *opaque, int level);
/* so far, all locks have gotten along with the same unlock ast */
-static void ocfs2_unlock_ast_func(void *opaque, dlm_status status);
+static void ocfs2_unlock_ast_func(void *opaque,
+ dlm_status status);
+static int ocfs2_do_unblock_meta(struct inode *inode,
+ int *requeue);
+static int ocfs2_unblock_meta(ocfs2_lock_res *lockres,
+ int *requeue);
+static int ocfs2_unblock_data(ocfs2_lock_res *lockres,
+ int *requeue);
+static int ocfs2_unblock_super(ocfs2_lock_res *lockres,
+ int *requeue);
+typedef void (ocfs2_convert_worker_t)(ocfs2_lock_res *, int);
+static int ocfs2_generic_unblock_lock(ocfs_super *osb,
+ ocfs2_lock_res *lockres,
+ int *requeue,
+ ocfs2_convert_worker_t *worker);
-static dlm_astlockfunc_t *ocfs2_lock_type_asts[OCFS_NUM_LOCK_TYPES] = {
- [OCFS_TYPE_META] ocfs2_inode_ast_func,
- [OCFS_TYPE_DATA] ocfs2_inode_ast_func,
- [OCFS_TYPE_SUPER] ocfs2_super_ast_func
+struct ocfs2_lock_res_ops {
+ void (*ast)(void *);
+ void (*bast)(void *, int);
+ void (*unlock_ast)(void *, dlm_status);
+ int (*unblock)(ocfs2_lock_res *, int *);
};
-static dlm_bastlockfunc_t *ocfs2_lock_type_basts[OCFS_NUM_LOCK_TYPES] = {
- [OCFS_TYPE_META] ocfs2_inode_bast_func,
- [OCFS_TYPE_DATA] ocfs2_inode_bast_func,
- [OCFS_TYPE_SUPER] ocfs2_super_bast_func
+
+struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = {
+ .ast = ocfs2_inode_ast_func,
+ .bast = ocfs2_inode_bast_func,
+ .unlock_ast = ocfs2_unlock_ast_func,
+ .unblock = ocfs2_unblock_meta,
};
+static void ocfs2_data_convert_worker(ocfs2_lock_res *lockres,
+ int blocking);
+
+struct ocfs2_lock_res_ops ocfs2_inode_data_lops = {
+ .ast = ocfs2_inode_ast_func,
+ .bast = ocfs2_inode_bast_func,
+ .unlock_ast = ocfs2_unlock_ast_func,
+ .unblock = ocfs2_unblock_data,
+};
+
+struct ocfs2_lock_res_ops ocfs2_super_lops = {
+ .ast = ocfs2_super_ast_func,
+ .bast = ocfs2_super_bast_func,
+ .unlock_ast = ocfs2_unlock_ast_func,
+ .unblock = ocfs2_unblock_super,
+};
+
static inline int ocfs2_is_inode_lock(ocfs2_lock_res *lockres)
{
return lockres->l_type == OCFS_TYPE_META ||
@@ -119,6 +152,9 @@
return (struct inode *) lockres->l_priv;
}
+static void ocfs2_lock_res_init_common(ocfs2_lock_res *res,
+ enum ocfs2_lock_type type,
+ void *priv);
static int ocfs2_lock_create(ocfs_super *osb,
ocfs2_lock_res *lockres,
int level,
@@ -129,13 +165,21 @@
ocfs2_lock_res *lockres,
int level,
int lkm_flags);
-void ocfs2_cluster_unlock(ocfs_super *osb,
- ocfs2_lock_res *lockres,
- int level);
+static void ocfs2_cluster_unlock(ocfs_super *osb,
+ ocfs2_lock_res *lockres,
+ int level);
+static inline void ocfs2_generic_handle_downconvert_action(ocfs2_lock_res *lockres);
+static inline void ocfs2_generic_handle_convert_action(ocfs2_lock_res *lockres);
+static inline void ocfs2_generic_handle_attach_action(ocfs2_lock_res *lockres);
+static void ocfs2_generic_handle_bast(ocfs2_lock_res *lockres, int level);
+static inline void ocfs2_handle_meta_convert_action(struct inode *inode,
+ ocfs2_lock_res *lockres);
static void ocfs2_inc_inode_seq(ocfs_super *osb,
struct inode *inode);
-static void ocfs2_schedule_blocked_inode(struct inode *inode);
-static void ocfs2_schedule_blocked_super(ocfs_super *osb);
+static void ocfs2_schedule_blocked_lock(ocfs_super *osb,
+ ocfs2_lock_res *lockres);
+static void ocfs2_schedule_blocked_inode_lock(struct inode *inode,
+ ocfs2_lock_res *lockres);
static inline void ocfs2_recover_from_dlm_error(ocfs2_lock_res *lockres,
int convert);
static void ocfs2_vote_on_unlock(ocfs_super *osb,
@@ -163,10 +207,6 @@
static inline int ocfs2_can_downconvert_meta_lock(struct inode *inode,
ocfs2_lock_res *lockres,
int new_level);
-static int ocfs2_process_blocked_meta(struct inode *inode,
- int *requeue);
-static int ocfs2_process_blocked_data(struct inode *inode,
- int *requeue);
static inline int ocfs2_lvb_is_trustable(ocfs2_lock_res *lockres)
{
@@ -243,6 +283,19 @@
return (len);
}
+static void ocfs2_lock_res_init_common(ocfs2_lock_res *res,
+ enum ocfs2_lock_type type,
+ void *priv)
+{
+ memset(res, 0, sizeof(ocfs2_lock_res));
+ spin_lock_init(&res->l_lock);
+ init_waitqueue_head(&res->l_event);
+ res->l_type = type;
+ res->l_level = LKM_IVMODE;
+ INIT_LIST_HEAD(&res->l_blocked_list);
+ res->l_priv = priv;
+}
+
int ocfs2_inode_lock_res_init(ocfs2_lock_res *res,
enum ocfs2_lock_type type,
struct inode *inode)
@@ -254,13 +307,13 @@
OCFS_ASSERT(type == OCFS_TYPE_META ||
type == OCFS_TYPE_DATA);
- memset(res, 0, sizeof(ocfs2_lock_res));
- spin_lock_init(&res->l_lock);
- init_waitqueue_head(&res->l_event);
- res->l_type = type;
- res->l_level = LKM_IVMODE;
+ ocfs2_lock_res_init_common(res, type, inode);
- res->l_priv = inode;
+ if (type == OCFS_TYPE_META)
+ res->l_ops = &ocfs2_inode_meta_lops;
+ else
+ res->l_ops = &ocfs2_inode_data_lops;
+
status = ocfs2_build_lock_name(type,
OCFS_I(inode)->ip_blkno,
inode->i_generation,
@@ -283,15 +336,12 @@
LOG_ENTRY();
- memset(res, 0, sizeof(ocfs2_lock_res));
- spin_lock_init(&res->l_lock);
- init_waitqueue_head(&res->l_event);
- res->l_type = type;
- res->l_level = LKM_IVMODE;
+ ocfs2_lock_res_init_common(res, type, osb);
- res->l_priv = osb;
+ res->l_ops = &ocfs2_super_lops;
+
status = ocfs2_build_lock_name(type,
- 0ULL,
+ OCFS2_SUPER_BLOCK_BLKNO,
0,
&res->l_name);
if (status < 0) {
@@ -498,7 +548,7 @@
#endif
ocfs2_generic_handle_bast(lockres, level);
- ocfs2_schedule_blocked_inode(inode);
+ ocfs2_schedule_blocked_inode_lock(inode, lockres);
ocfs2_kick_vote_thread(osb);
}
@@ -551,7 +601,7 @@
#endif
ocfs2_generic_handle_bast(lockres, level);
- ocfs2_schedule_blocked_super(osb);
+ ocfs2_schedule_blocked_lock(osb, lockres);
ocfs2_kick_vote_thread(osb);
}
@@ -573,7 +623,6 @@
int flags)
{
int ret = 0;
- enum ocfs2_lock_type type = lockres->l_type;
dlm_status status;
LOG_ENTRY();
@@ -594,9 +643,9 @@
&lockres->l_lksb,
flags,
lockres->l_name,
- ocfs2_lock_type_asts[type],
+ lockres->l_ops->ast,
lockres,
- ocfs2_lock_type_basts[type]);
+ lockres->l_ops->bast);
if (status != DLM_NORMAL) {
LOG_ERROR_ARGS("Dlm returns %d\n", status);
ret = -ENOENT;
@@ -658,7 +707,6 @@
int lkm_flags)
{
int ret;
- enum ocfs2_lock_type type = lockres->l_type;
dlm_status status;
LOG_ENTRY();
@@ -715,9 +763,9 @@
&lockres->l_lksb,
lkm_flags|LKM_CONVERT|LKM_VALBLK,
lockres->l_name,
- ocfs2_lock_type_asts[type],
+ lockres->l_ops->ast,
lockres,
- ocfs2_lock_type_basts[type]);
+ lockres->l_ops->bast);
if (status != DLM_NORMAL) {
if ((lkm_flags & LKM_NOQUEUE) &&
(status == DLM_NOTQUEUED))
@@ -745,9 +793,9 @@
return ret;
}
-void ocfs2_cluster_unlock(ocfs_super *osb,
- ocfs2_lock_res *lockres,
- int level)
+static void ocfs2_cluster_unlock(ocfs_super *osb,
+ ocfs2_lock_res *lockres,
+ int level)
{
spin_lock(&lockres->l_lock);
ocfs2_dec_holders(lockres, level);
@@ -1339,7 +1387,7 @@
status = dlmunlock(osb->dlm,
&lockres->l_lksb,
LKM_VALBLK,
- ocfs2_unlock_ast_func,
+ lockres->l_ops->unlock_ast,
lockres);
if (status != DLM_NORMAL) {
LOG_ERROR_ARGS("Dlm returns %d\n", status);
@@ -1424,7 +1472,6 @@
int lvb)
{
int status, flags = LKM_CONVERT;
- enum ocfs2_lock_type type = lockres->l_type;
OCFS_ASSERT(lockres->l_blocking > LKM_NLMODE);
OCFS_ASSERT(lockres->l_level > new_level);
@@ -1441,9 +1488,9 @@
&lockres->l_lksb,
flags,
lockres->l_name,
- ocfs2_lock_type_asts[type],
+ lockres->l_ops->ast,
lockres,
- ocfs2_lock_type_basts[type]);
+ lockres->l_ops->bast);
if (status != DLM_NORMAL) {
LOG_ERROR_ARGS("Dlm returns %d\n", status);
status = -ENOENT;
@@ -1472,7 +1519,7 @@
status = dlmunlock(osb->dlm,
&lockres->l_lksb,
LKM_CANCEL,
- ocfs2_unlock_ast_func,
+ lockres->l_ops->unlock_ast,
lockres);
if (status == DLM_NORMAL)
status = 0;
@@ -1510,8 +1557,8 @@
return ret;
}
-static int ocfs2_process_blocked_meta(struct inode *inode,
- int *requeue)
+static int ocfs2_do_unblock_meta(struct inode *inode,
+ int *requeue)
{
int new_level;
int set_lvb = 0;
@@ -1560,16 +1607,18 @@
return 0;
}
-static int ocfs2_process_blocked_data(struct inode *inode,
- int *requeue)
+static int ocfs2_generic_unblock_lock(ocfs_super *osb,
+ ocfs2_lock_res *lockres,
+ int *requeue,
+ ocfs2_convert_worker_t *worker)
{
- ocfs2_lock_res *lockres = &OCFS_I(inode)->ip_data_lockres;
int blocking;
int new_level;
spin_lock(&lockres->l_lock);
if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) {
spin_unlock(&lockres->l_lock);
+ *requeue = 0;
return 0;
}
@@ -1577,7 +1626,7 @@
recheck:
if (lockres->l_flags & OCFS2_LOCK_BUSY) {
- *requeue++;
+ *requeue = 1;
if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
/* If we're already trying to cancel a lock conversion
* then just drop the spinlock and requeue ourselves
@@ -1586,41 +1635,41 @@
return 0;
}
- return __ocfs2_cancel_convert(OCFS2_SB(inode->i_sb),
- lockres);
+ return __ocfs2_cancel_convert(osb, lockres);
}
- /* if we're blocking an exclusive and we have *anyone* in I/O,
+ /* if we're blocking an exclusive and we have *any* holders,
* then requeue. */
if ((lockres->l_blocking == LKM_EXMODE)
&& (lockres->l_ex_holders || lockres->l_ro_holders)) {
spin_unlock(&lockres->l_lock);
- *requeue++;
+ *requeue = 1;
return 0;
}
/* If it's a PR we're blocking, then only
- * requeue if we've got anyone doing write (ex) I/O */
+ * requeue if we've got any EX holders */
if (lockres->l_blocking == LKM_PRMODE &&
lockres->l_ex_holders) {
spin_unlock(&lockres->l_lock);
- *requeue++;
+ *requeue = 1;
return 0;
}
- /* if we get here, then we know that anyone doing incompatible
- * I/O is currently blocked. Save off a copy of what we're
- * blocking as it may change while we're not holding the spin
- * lock. */
+ /* If we get here, then we know that there are no more
+ * incompatible holders (and anyone asking for an incompatible
+ * lock is blocked). We can now downconvert the lock */
+ if (!worker)
+ goto downconvert;
+
+ /* Some lockres types want to do a bit of work before
+ * downconverting a lock. Allow that here. The worker function
+ * may sleep, so we save off a copy of what we're blocking as
+ * it may change while we're not holding the spin lock. */
blocking = lockres->l_blocking;
spin_unlock(&lockres->l_lock);
- /* 3 cases: EX blocking EX
- * EX blocking RO
- * RO blocking EX */
- sync_mapping_buffers(inode->i_mapping);
- if (blocking == LKM_EXMODE)
- ocfs_truncate_inode_pages(inode, 0);
+ worker(lockres, blocking);
spin_lock(&lockres->l_lock);
if (blocking != lockres->l_blocking) {
@@ -1629,113 +1678,120 @@
goto recheck;
}
+downconvert:
+ *requeue = 0;
new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking);
- return __ocfs2_downconvert_lock(OCFS2_SB(inode->i_sb), lockres,
- new_level, 0);
+ return __ocfs2_downconvert_lock(osb, lockres, new_level, 0);
}
-/* TODO: This is very generic, and looks much like
- * ocfs2_process_blocked_data. Lets try to find a way to combine these
- * two. */
-void ocfs2_process_blocked_super(ocfs_super *osb)
+static void ocfs2_data_convert_worker(ocfs2_lock_res *lockres,
+ int blocking)
{
- int status = 0;
- int new_level;
- ocfs2_lock_res *lockres = &osb->super_lockres;
+ struct inode *inode = ocfs2_lock_res_inode(lockres);
- spin_lock(&lockres->l_lock);
- if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) {
- spin_unlock(&lockres->l_lock);
- return;
- }
+ sync_mapping_buffers(inode->i_mapping);
+ if (blocking == LKM_EXMODE)
+ ocfs_truncate_inode_pages(inode, 0);
+}
- if (lockres->l_flags & OCFS2_LOCK_BUSY) {
- if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
- /* If we're already trying to cancel a lock conversion
- * then just drop the spinlock and requeue ourselves
- * to check again later. */
- spin_unlock(&lockres->l_lock);
- } else
- status = __ocfs2_cancel_convert(osb,
- lockres);
- if (status < 0)
- LOG_ERROR_STATUS(status);
- goto requeue;
- }
+int ocfs2_unblock_data(ocfs2_lock_res *lockres,
+ int *requeue)
+{
+ int status;
+ struct inode *inode = ocfs2_lock_res_inode(lockres);
+ ocfs_super *osb = OCFS2_SB(inode->i_sb);
- /* if we're blocking an exclusive and we have *any* holders,
- * then requeue. */
- if ((lockres->l_blocking == LKM_EXMODE)
- && (lockres->l_ex_holders || lockres->l_ro_holders)) {
- spin_unlock(&lockres->l_lock);
- goto requeue;
- }
+ status = ocfs2_generic_unblock_lock(osb,
+ lockres,
+ requeue,
+ ocfs2_data_convert_worker);
+ if (status < 0)
+ LOG_ERROR_STATUS(status);
- /* If it's a PR we're blocking, then only
- * requeue if we've got anyone holding an EX */
- if (lockres->l_blocking == LKM_PRMODE &&
- lockres->l_ex_holders) {
- spin_unlock(&lockres->l_lock);
- goto requeue;
- }
+ /* because of inode ref counting, we never want to propagate
+ * up requeue requests for inode locks. Instead we do it
+ * ourselves here, and lose the extra ref we got from queueing
+ * when we came in. */
+ if (*requeue)
+ ocfs2_schedule_blocked_inode_lock(inode, lockres);
- /* if we get here, then we know that we have no incompatible
- * holders, and since we're marked, anyone asking for an
- * incompatible lock will block. We can safely downconvert
- * now. */
- new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking);
- spin_unlock(&lockres->l_lock);
+ iput(inode);
+ *requeue = 0;
- status = __ocfs2_downconvert_lock(osb, lockres, new_level, 0);
- if (status < 0) {
+ return status;
+}
+
+int ocfs2_unblock_meta(ocfs2_lock_res *lockres,
+ int *requeue)
+{
+ int status;
+ struct inode *inode = ocfs2_lock_res_inode(lockres);
+
+ status = ocfs2_do_unblock_meta(inode, requeue);
+ if (status < 0)
LOG_ERROR_STATUS(status);
- goto requeue;
- }
- return;
-requeue:
- ocfs2_schedule_blocked_super(osb);
+ /* if you're confused by this, see the comment in
+ * ocfs2_unblock_data */
+ if (*requeue)
+ ocfs2_schedule_blocked_inode_lock(inode, lockres);
+
+ iput(inode);
+ *requeue = 0;
+
+ return status;
}
-void ocfs2_process_blocked_inode(struct inode *inode)
+static int ocfs2_unblock_super(ocfs2_lock_res *lockres,
+ int *requeue)
{
int status;
- int requeue = 0;
+ ocfs_super *osb = ocfs2_lock_res_super(lockres);
- /* At this point, we've been taken off the blocked_list */
- status = ocfs2_process_blocked_meta(inode, &requeue);
+ status = ocfs2_generic_unblock_lock(osb,
+ lockres,
+ requeue,
+ NULL);
if (status < 0)
LOG_ERROR_STATUS(status);
- status = ocfs2_process_blocked_data(inode, &requeue);
+ return status;
+}
+
+void ocfs2_process_blocked_lock(ocfs_super *osb,
+ ocfs2_lock_res *lockres)
+{
+ int status;
+ int requeue = 0;
+
+ status = lockres->l_ops->unblock(lockres, &requeue);
if (status < 0)
LOG_ERROR_STATUS(status);
if (requeue)
- ocfs2_schedule_blocked_inode(inode);
+ ocfs2_schedule_blocked_lock(osb, lockres);
}
-static void ocfs2_schedule_blocked_super(ocfs_super *osb)
+static void ocfs2_schedule_blocked_lock(ocfs_super *osb,
+ ocfs2_lock_res *lockres)
{
spin_lock(&osb->vote_task_lock);
- osb->blocked_super_count++;
+ if (list_empty(&lockres->l_blocked_list))
+ list_add_tail(&osb->blocked_lock_list,
+ &lockres->l_blocked_list);
+ osb->blocked_lock_count++;
spin_unlock(&osb->vote_task_lock);
}
-static void ocfs2_schedule_blocked_inode(struct inode *inode)
+/* needed for inodes as we have to take a reference on them.. */
+static void ocfs2_schedule_blocked_inode_lock(struct inode *inode,
+ ocfs2_lock_res *lockres)
{
- ocfs_super *osb = OCFS2_SB(inode->i_sb);
-
if (!igrab(inode)) {
LOG_ERROR_ARGS("Inode %llu asked to be scheduled during "
"clear_inode!\n", OCFS_I(inode)->ip_blkno);
return;
}
- spin_lock(&osb->vote_task_lock);
- if (list_empty(&(OCFS_I(inode)->ip_blocked_list)))
- list_add_tail(&osb->blocked_inode_list,
- &(OCFS_I(inode)->ip_blocked_list));
- osb->blocked_inode_count++;
- spin_unlock(&osb->vote_task_lock);
+ ocfs2_schedule_blocked_lock(OCFS2_SB(inode->i_sb), lockres);
}
Modified: branches/dlm-glue/src/dlmglue.h
===================================================================
--- branches/dlm-glue/src/dlmglue.h 2004-11-23 18:39:29 UTC (rev 1667)
+++ branches/dlm-glue/src/dlmglue.h 2004-11-23 21:10:22 UTC (rev 1668)
@@ -109,10 +109,9 @@
int ex);
void ocfs2_super_unlock(ocfs_super *osb,
int ex);
-
/* for the vote thread */
-void ocfs2_process_blocked_inode(struct inode *inode);
-void ocfs2_process_blocked_super(ocfs_super *osb);
+void ocfs2_process_blocked_lock(ocfs_super *osb,
+ ocfs2_lock_res *lockres);
static inline void ocfs2_lvb_set_trunc_clusters(struct inode *inode,
unsigned int trunc_clusters)
Modified: branches/dlm-glue/src/inode.c
===================================================================
--- branches/dlm-glue/src/inode.c 2004-11-23 18:39:29 UTC (rev 1667)
+++ branches/dlm-glue/src/inode.c 2004-11-23 21:10:22 UTC (rev 1668)
@@ -304,7 +304,6 @@
memset(i, 0, sizeof(ocfs_inode_private));
i->ip_flags = 0;
- INIT_LIST_HEAD(&i->ip_blocked_list);
atomic_set(&i->ip_clean_buffer_seq, 0);
i->ip_open_cnt = 0;
spin_lock_init(&i->ip_lock);
Modified: branches/dlm-glue/src/ocfs.h
===================================================================
--- branches/dlm-glue/src/ocfs.h 2004-11-23 18:39:29 UTC (rev 1667)
+++ branches/dlm-glue/src/ocfs.h 2004-11-23 21:10:22 UTC (rev 1668)
@@ -166,10 +166,15 @@
#define OCFS2_LOCK_NEEDS_REFRESH (0x00000010)
#define OCFS2_LOCK_REFRESHING (0x00000020)
+struct ocfs2_lock_res_ops;
+
typedef struct _ocfs2_lock_res {
void *l_priv;
+ struct ocfs2_lock_res_ops *l_ops;
spinlock_t l_lock;
+ struct list_head l_blocked_list;
+
enum ocfs2_lock_type l_type;
int l_flags;
char *l_name;
@@ -199,7 +204,6 @@
ocfs2_lock_res ip_meta_lockres;
ocfs2_lock_res ip_data_lockres;
- struct list_head ip_blocked_list;
/* protects allocation changes on this inode. */
struct rw_semaphore ip_alloc_sem;
@@ -391,11 +395,13 @@
wait_queue_head_t vote_event;
atomic_t wake_vote_task;
int vote_exit;
- int blocked_super_count;
- struct list_head blocked_inode_list;
- int blocked_inode_count;
+
+ struct list_head blocked_lock_list;
+ int blocked_lock_count;
+
struct list_head vote_list;
int vote_count;
+
struct completion vote_event_complete;
struct completion vote_event_init;
Modified: branches/dlm-glue/src/super.c
===================================================================
--- branches/dlm-glue/src/super.c 2004-11-23 18:39:29 UTC (rev 1667)
+++ branches/dlm-glue/src/super.c 2004-11-23 21:10:22 UTC (rev 1668)
@@ -1150,8 +1150,8 @@
atomic_set(&osb->wake_vote_task, 0);
spin_lock_init(&osb->vote_task_lock);
init_waitqueue_head(&osb->vote_event);
- INIT_LIST_HEAD(&osb->blocked_inode_list);
- osb->blocked_inode_count = 0;
+ INIT_LIST_HEAD(&osb->blocked_lock_list);
+ osb->blocked_lock_count = 0;
INIT_LIST_HEAD(&osb->vote_list);
spin_lock_init(&osb->s_next_gen_lock);
get_random_bytes(&osb->s_next_generation, sizeof(u32));
Modified: branches/dlm-glue/src/vote.c
===================================================================
--- branches/dlm-glue/src/vote.c 2004-11-23 18:39:29 UTC (rev 1667)
+++ branches/dlm-glue/src/vote.c 2004-11-23 21:10:22 UTC (rev 1668)
@@ -295,39 +295,25 @@
static void ocfs2_vote_thread_do_work(ocfs_super *osb)
{
- struct inode *inode = NULL;
- ocfs_inode_private *ip;
int processed;
+ ocfs2_lock_res *lockres;
ocfs2_vote_work *work;
spin_lock(&osb->vote_task_lock);
- if (osb->blocked_super_count) {
- OCFS_ASSERT(osb->blocked_super_count == 1);
- osb->blocked_super_count = 0;
- spin_unlock(&osb->vote_task_lock);
-
- ocfs2_process_blocked_super(osb);
-
- spin_lock(&osb->vote_task_lock);
- }
-
- processed = osb->blocked_inode_count;
+ processed = osb->blocked_lock_count;
while (processed) {
- OCFS_ASSERT(!list_empty(&osb->blocked_inode_list));
+ OCFS_ASSERT(!list_empty(&osb->blocked_lock_list));
- ip = list_entry(&osb->blocked_inode_list.next,
- ocfs_inode_private, ip_blocked_list);
- list_del_init(&ip->ip_blocked_list);
- osb->blocked_inode_count--;
+ lockres = list_entry(&osb->blocked_lock_list.next,
+ ocfs2_lock_res, l_blocked_list);
+ list_del_init(&lockres->l_blocked_list);
+ osb->blocked_lock_count--;
spin_unlock(&osb->vote_task_lock);
- inode = ip->ip_inode;
processed--;
- ocfs2_process_blocked_inode(inode);
+ ocfs2_process_blocked_lock(osb, lockres);
- iput(inode);
-
spin_lock(&osb->vote_task_lock);
}
@@ -349,9 +335,8 @@
static inline int ocfs2_vote_thread_has_work(ocfs_super *osb)
{
- if (list_empty(&osb->blocked_inode_list) &&
- list_empty(&osb->vote_list) &&
- !osb->blocked_super_count)
+ if (list_empty(&osb->blocked_lock_list) &&
+ list_empty(&osb->vote_list))
return 0;
return 1;
More information about the Ocfs2-commits
mailing list