[Ocfs2-commits] mfasheh commits r1238 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Jul 2 19:52:31 CDT 2004
Author: mfasheh
Date: 2004-07-02 18:52:30 -0500 (Fri, 02 Jul 2004)
New Revision: 1238
Modified:
trunk/src/journal.c
trunk/src/nm.c
trunk/src/ocfs.h
trunk/src/ocfs_journal.h
trunk/src/super.c
Log:
* some journal cleanups -- paving the way for a better lock release
scheme.
Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c 2004-07-02 22:17:58 UTC (rev 1237)
+++ trunk/src/journal.c 2004-07-02 23:52:30 UTC (rev 1238)
@@ -131,27 +131,24 @@
/* now we can run an unlock against any pending handles and
* release them. */
- down(&journal->commit_sem);
- down(&commit->c_lock);
+ spin_lock(&journal->cmt_lock);
- /* Once we've got commit_sem, we can let transactions start
+ /* Once we've got cmt_lock, we can let transactions start
* again -- it should protect us against people mucking with
- * the commited list... */
+ * the committed list... */
journal_unlock_updates(journal->k_journal);
- /* we want to take everything off the commited list and
+ /* we want to take everything off the committed list and
* process it independently, so we can drop the trans_lock
* earlier. */
- if (!list_empty(&journal->commited)) {
- list_splice(&journal->commited , &commit->c_list);
- INIT_LIST_HEAD(&journal->commited);
+ if (!list_empty(&journal->committed)) {
+ list_splice(&journal->committed , &commit->c_list);
+ INIT_LIST_HEAD(&journal->committed);
}
- up(&commit->c_lock);
- up(&journal->commit_sem);
+ spin_unlock(&journal->cmt_lock);
osb->needs_flush = 0;
- down(&commit->c_lock);
list_for_each_safe(p, n, &commit->c_list) {
handle = list_entry(p, ocfs_journal_handle, h_list);
tmpstat = ocfs_handle_release_locks(handle, TRANS_CACHE);
@@ -162,7 +159,6 @@
atomic_dec(&journal->num_trans);
}
- up(&commit->c_lock);
flush_data:
/* flush data buffers if asked. */
@@ -309,7 +305,6 @@
}
memset(retval->co_buffs, 0, sizeof(ocfs_journal_copyout) * max_buffs);
- spin_lock_init(&(retval->list_lock));
INIT_LIST_HEAD(&(retval->h_list));
INIT_LIST_HEAD(&(retval->locks));
INIT_LIST_HEAD(&(retval->inode_list));
@@ -413,7 +408,7 @@
}
/* This does no locking of the handle. If the handle is on
- * journal->commited, then you want to be holding the commit_sem
+ * journal->committed, then you want to be holding the cmt_lock
* before calling this. */
static int ocfs_handle_release_locks(ocfs_journal_handle *handle,
release_locks_action action)
@@ -484,15 +479,15 @@
LOG_ENTRY_ARGS("(%llu)\n", lockid);
journal = osb->journal;
- down(&journal->commit_sem);
- list_for_each(p1, &(journal->commited)) {
+ spin_lock(&journal->cmt_lock);
+ list_for_each(p1, &(journal->committed)) {
handle = list_entry(p1, ocfs_journal_handle, h_list);
if (handle->new_file_lockid == lockid) {
status = 0;
break;
}
}
- up(&journal->commit_sem);
+ spin_unlock(&journal->cmt_lock);
LOG_EXIT_STATUS(status);
return status;
@@ -555,7 +550,7 @@
ocfs_handle_unlock_inodes(handle);
/* actually stop the transaction. if we've set h_sync,
- * it'll have been commited when we return */
+ * it'll have been committed when we return */
retval = journal_stop(kern_handle);
if (retval < 0) {
LOG_ERROR_STATUS(retval);
@@ -610,10 +605,10 @@
/* If we're not going to checkpoint the handle on
* commit then we need to add it to our journals list
* so it can be done later */
- down(&journal->commit_sem);
- list_add_tail(&(handle->h_list), &(journal->commited));
+ spin_lock(&journal->cmt_lock);
+ list_add_tail(&(handle->h_list), &(journal->committed));
osb->needs_flush = 1;
- up(&journal->commit_sem);
+ spin_unlock(&journal->cmt_lock);
/* Ok, any references to the handle after this are
* unsafe as it might be processed (and free'd from
* memory) by the commit thread! */
@@ -948,13 +943,10 @@
} /* ocfs_journal_dirty */
-/* We are expecting to be run on the current running transaction, so
- * we use the spin_lock here. You really shouldn't be calling this on
- * other transactions anyway...
- *
+/*
* If you've passed the inode to the handle already (via
* ocfs_handle_add_inode), then req_io_sem should be true.
-*/
+ */
void ocfs_handle_add_lock(ocfs_journal_handle *handle, __u32 type,
__u32 flags, struct buffer_head *bh,
struct inode *inode, int req_io_sem)
@@ -983,10 +975,8 @@
atomic_inc(&inode->i_count);
- spin_lock(&handle->list_lock);
list_add_tail(&(lock->lock_list), &(handle->locks));
handle->num_locks++;
- spin_unlock(&handle->list_lock);
LOG_EXIT();
return;
@@ -1010,8 +1000,8 @@
if (!osb)
BUG();
- INIT_LIST_HEAD(&(osb->journal->commited));
- init_MUTEX(&(osb->journal->commit_sem));
+ INIT_LIST_HEAD(&(osb->journal->committed));
+ spin_lock_init(&(osb->journal->cmt_lock));
/* already have the inode for our journal */
inode = ocfs_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE, osb->node_num);
Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c 2004-07-02 22:17:58 UTC (rev 1237)
+++ trunk/src/nm.c 2004-07-02 23:52:30 UTC (rev 1238)
@@ -60,7 +60,7 @@
struct semaphore recovery_list_sem;
static inline int get_process_vote_action(ocfs_super * osb, ocfs_lock_res *lockres, __u32 node_num, __u32 flags, int status, int *master_alive, struct inode *inode);
-static int ocfs_search_commited(ocfs_super *osb, struct inode *inode);
+static int ocfs_search_committed(ocfs_super *osb, struct inode *inode);
static int ocfs_schedule_process_vote(ocfs_super *osb, struct buffer_head *bh, int vote_node);
static int _ocfs_drop_readonly_cache_lock(void *arg);
@@ -654,8 +654,8 @@
/* Search the journals committed transactions list for a given
* inode. If it's in there, return true, zero otherwise and -1 on
- * error. Must hold the journal->commit_sem before going here! */
-static int ocfs_search_commited(ocfs_super *osb, struct inode *inode)
+ * error. Must hold the journal->cmt_lock before going here! */
+static int ocfs_search_committed(ocfs_super *osb, struct inode *inode)
{
struct list_head *handle_p;
struct list_head *lock_p;
@@ -668,7 +668,7 @@
journal = osb->journal;
- list_for_each(handle_p, &journal->commited) {
+ list_for_each(handle_p, &journal->committed) {
handle = list_entry(handle_p, ocfs_journal_handle, h_list);
list_for_each(lock_p, &(handle->locks)) {
@@ -1014,13 +1014,13 @@
LOG_TRACE_ARGS("Lock id (%llu) has %u holders\n",
OCFS_I(inode)->ip_blkno << inode->i_sb->s_blocksize_bits,
lockres->lock_holders);
- down(&(osb->journal->commit_sem));
- if (ocfs_search_commited(osb, inode)) {
+ spin_lock(&(osb->journal->cmt_lock));
+ if (ocfs_search_committed(osb, inode)) {
// kick the commit thread
atomic_set(&osb->flush_event_woken, 1);
wake_up(&osb->flush_event);
}
- up(&(osb->journal->commit_sem));
+ spin_unlock(&(osb->journal->cmt_lock));
vote_response = FLAG_VOTE_UPDATE_RETRY;
status = 0;
break;
Modified: trunk/src/ocfs.h
===================================================================
--- trunk/src/ocfs.h 2004-07-02 22:17:58 UTC (rev 1237)
+++ trunk/src/ocfs.h 2004-07-02 23:52:30 UTC (rev 1238)
@@ -512,7 +512,6 @@
{
struct completion c_complete;
struct task_struct *c_task;
- struct semaphore c_lock;
struct list_head c_list;
} ocfs_commit_task;
Modified: trunk/src/ocfs_journal.h
===================================================================
--- trunk/src/ocfs_journal.h 2004-07-02 22:17:58 UTC (rev 1237)
+++ trunk/src/ocfs_journal.h 2004-07-02 23:52:30 UTC (rev 1238)
@@ -71,14 +71,10 @@
to access file entry */
atomic_t num_trans; /* Number of transactions
* currently in the system. */
- /* locking order: trans_lock -> commit_sem -> journal.curr.list_lock */
- struct semaphore commit_sem; /* protects *everything*
- * in the commited list
- * and also protects
- * 'curr' from
- * removal/creation. */
- struct list_head commited; /* doubly linked list of all
- * commited handles awaiting
+ /* locking order: trans_lock -> cmt_lock */
+ spinlock_t cmt_lock; /* protects the committed list */
+ struct list_head committed; /* doubly linked list of all
+ * committed handles awaiting
* checkpointing. */
struct rw_semaphore trans_barrier;
};
@@ -116,14 +112,7 @@
int num_buffs;
struct buffer_head **buffs;
- /* The following three fields are for ocfs_handle_add_lock */
- spinlock_t list_lock; /* Used to protect the 'locks'
- * list. Only used if the
- * handle is the same as
- * journal->curr. otherwise, we
- * should be in the commited
- * list in which case we're
- * protected by commit_sem */
+ /* The following two fields are for ocfs_handle_add_lock */
int num_locks;
struct list_head locks; /* A bunch of locks to
* release on commit/abort. This
@@ -211,7 +200,7 @@
* ocfs_journal_load - Load the given journal off disk. Replay it if
* there's transactions still in there.
* ocfs_journal_shutdown - Shutdown a journal, this will flush all
- * uncommited, uncheckpointed transactions.
+ * uncommitted, uncheckpointed transactions.
* ocfs_journal_wipe - Wipe transactions from a journal. Optionally
* zero out each block.
* ocfs_recovery_thread - Perform recovery on a node. osb is our own osb.
@@ -258,7 +247,7 @@
*
* Write access is for when we read a block off disk and are going to
* modify it. This way the journalling layer knows it may need to make
- * a copy of that block (if it's part of another, uncommited
+ * a copy of that block (if it's part of another, uncommitted
* transaction) before we do so.
*/
#define OCFS_JOURNAL_ACCESS_CREATE 0
Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c 2004-07-02 22:17:58 UTC (rev 1237)
+++ trunk/src/super.c 2004-07-02 23:52:30 UTC (rev 1238)
@@ -1021,7 +1021,6 @@
goto leave;
}
memset(osb->commit, 0, sizeof(ocfs_commit_task));
- init_MUTEX(&osb->commit->c_lock);
INIT_LIST_HEAD(&osb->commit->c_list);
child_pid = kernel_thread (ocfs_commit_thread, osb,
CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
More information about the Ocfs2-commits
mailing list