[Ocfs2-commits]
jlbec commits r1125 - in branches/format-changes: . src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jun 17 00:30:29 CDT 2004
Author: jlbec
Date: 2004-06-16 23:30:27 -0500 (Wed, 16 Jun 2004)
New Revision: 1125
Removed:
branches/format-changes/src/hash.c
branches/format-changes/src/hash.h
Modified:
branches/format-changes/TODO
branches/format-changes/src/Makefile
branches/format-changes/src/alloc.c
branches/format-changes/src/bitmap.c
branches/format-changes/src/buffer_head_io.c
branches/format-changes/src/dir.c
branches/format-changes/src/dlm.c
branches/format-changes/src/file.c
branches/format-changes/src/heartbeat.c
branches/format-changes/src/inode.c
branches/format-changes/src/journal.c
branches/format-changes/src/lockres.c
branches/format-changes/src/namei.c
branches/format-changes/src/nm.c
branches/format-changes/src/ocfs.h
branches/format-changes/src/ocfs_buffer_head.h
branches/format-changes/src/super.c
branches/format-changes/src/sysfile.c
branches/format-changes/src/volcfg.c
Log:
o Merge 1115 from trunk:
- [1115] Remove the bh sem hash. YAY!
Modified: branches/format-changes/TODO
===================================================================
--- branches/format-changes/TODO 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/TODO 2004-06-17 04:30:27 UTC (rev 1125)
@@ -31,9 +31,6 @@
find_space_from_local where we take the main bitmap lock a bit early... We
can probably eliminate that and just let it get taken later...
-* Remove ocfs_ugly_hack. This can be totally removed after we've gotten rid
- of the bh_sem_hash.
-
* Local alloc code can be slightly revamped to not use the commit_bits on
the journal handle any more. Also, investigate whether we can use the
"undo" access flag on that bitmap.
@@ -56,6 +53,4 @@
* change the dirent->inode to block number... it's in bytes currently
-* finish the work of removing the bh sem hash
-
* turn priv_sem into a spinlock
Modified: branches/format-changes/src/Makefile
===================================================================
--- branches/format-changes/src/Makefile 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/Makefile 2004-06-17 04:30:27 UTC (rev 1125)
@@ -56,13 +56,6 @@
GLOBAL_DEFINES += -DVERBOSE_BH_SEQNUM_TRACE
GLOBAL_DEFINES += -DVERBOSE_PROCESS_VOTE
-#off by default -- these generate ALOT of output
-#GLOBAL_DEFINES += -DVERBOSE_BH_SEM
-#GLOBAL_DEFINES += -DBH_SEM_DEBUG
-
-#off by default as it's expensive
-#GLOBAL_DEFINES += -DBH_SEM_LEAK_CHECKING
-
ifneq ($(OCFS_PROCESSOR),ia64)
#GLOBAL_DEFINES += -DOCFS_DBG_TIMING
endif
@@ -131,7 +124,6 @@
dlm.c \
extmap.c \
file.c \
- hash.c \
heartbeat.c \
inode.c \
ioctl.c \
@@ -163,7 +155,6 @@
dlm.h \
extmap.h \
file.h \
- hash.h \
heartbeat.h \
inode.h \
ioctl.h \
Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/alloc.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -40,7 +40,6 @@
#include "bitmap.h"
#include "dlm.h"
#include "extmap.h"
-#include "hash.h"
#include "inode.h"
#include "util.h"
#include "sysfile.h"
@@ -55,27 +54,6 @@
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_ALLOC
-/* Remove this after the bh_sem hash is removed. */
-static inline int ocfs_ugly_hack(ocfs_journal_handle *handle,
- struct buffer_head *bh)
-{
- int status = 0;
- status = ocfs_journal_access(handle, bh, OCFS_JOURNAL_ACCESS_WRITE);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- return(status);
- }
- OCFS_BH_GET_DATA_WRITE(bh);
- OCFS_BH_PUT_DATA(bh);
- status = ocfs_journal_dirty(handle, bh);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- return(status);
- }
-
- return(status);
-}
-
static int ocfs_kill_this_tree(ocfs_super *osb,
struct buffer_head *extent_grp_bh,
ocfs_journal_handle *handle,
@@ -255,7 +233,6 @@
int credits = 33; /* one for each potential sysfile fe. This
* goes away when ocfs_ugly_hack goes
* away. */
- struct buffer_head *ugly_hack_bh = NULL;
LOG_ENTRY_ARGS ("(0x%p, 0x%p)\n", osb, free_log);
@@ -362,7 +339,7 @@
status = ocfs_acquire_lock (osb,
OCFS_DLM_EXCLUSIVE_LOCK,
FLAG_FILE_CREATE,
- &ugly_hack_bh,
+ NULL,
extnode_inode[i]);
if (status < 0) {
up_write(&OCFS_I(extnode_inode[i])->ip_io_sem);
@@ -372,10 +349,6 @@
LOG_ERROR_STATUS (status);
goto abort;
}
-
- ocfs_ugly_hack(handle, ugly_hack_bh);
- brelse(ugly_hack_bh);
- ugly_hack_bh = NULL;
}
}
@@ -400,7 +373,6 @@
LOG_ERROR_STATUS (status);
goto abort;
}
- ocfs_ugly_hack(handle, globalbh);
}
@@ -3227,12 +3199,6 @@
FLAG_FILE_CREATE,
bh, inode, 1);
- status = ocfs_ugly_hack(handle, bh);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
-
numBits = ((bytes_wanted + (blockSize-1)) >> blockSizeBits);
numBytes = (u64)numBits << blockSizeBits;
Modified: branches/format-changes/src/bitmap.c
===================================================================
--- branches/format-changes/src/bitmap.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/bitmap.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -38,7 +38,6 @@
#include "alloc.h"
#include "bitmap.h"
-#include "hash.h"
#include "util.h"
#include "ocfs_journal.h"
Modified: branches/format-changes/src/buffer_head_io.c
===================================================================
--- branches/format-changes/src/buffer_head_io.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/buffer_head_io.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -37,7 +37,6 @@
#include "ocfs.h"
#include "alloc.h"
-#include "hash.h"
#include "util.h"
#include "ocfs_journal.h"
@@ -125,23 +124,6 @@
if (flags & OCFS_BH_CONCURRENT_WRITE)
goto skip_modified_check;
- /* Make sure the buffer is locked for modify, and
- * we're the ones with the write lock on this
- * buffer. */
- if (!buffer_modified(bh)) {
- printk("ocfs2: modified bit is NOT set on buffer "
- "(bh->b_blocknr = %llu)!\n",
- (unsigned long long)bh->b_blocknr);
- BUG();
- }
- if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY){
- printk("ocfs2: someone else owns this buffer"
- "(bh->b_blocknr = %llu)!\n",
- (unsigned long long)bh->b_blocknr);
- BUG();
- }
- ocfs_bh_sem_unlock(bh);
-
skip_modified_check:
if (!(flags & OCFS_BH_IGNORE_JBD) && buffer_jbd(bh)) {
#ifdef VERBOSE_BH_JBD_TRACE
@@ -181,10 +163,6 @@
SET_BH_SEQNUM(inode, bh);
else
CLEAR_BH_SEQNUM(bh);
-
- if (!(flags & OCFS_BH_CONCURRENT_WRITE)
- && (!buffer_jbd(bh) || (flags & OCFS_BH_IGNORE_JBD)))
- ocfs_clear_buffer_modified(bh);
}
bail:
Modified: branches/format-changes/src/dir.c
===================================================================
--- branches/format-changes/src/dir.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/dir.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -51,7 +51,6 @@
#include "dir.h"
#include "dlm.h"
-#include "hash.h"
#include "inode.h"
#include "namei.h"
#include "util.h"
Modified: branches/format-changes/src/dlm.c
===================================================================
--- branches/format-changes/src/dlm.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/dlm.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -40,7 +40,6 @@
#include "alloc.h"
#include "dcache.h"
#include "dlm.h"
-#include "hash.h"
#include "lockres.h"
#include "nm.h"
#include "util.h"
@@ -1164,11 +1163,9 @@
}
finito:
- if (tmpbh) {
- if (clear_tmp)
- ocfs_clear_buffer_modified(tmpbh);
+ if (tmpbh)
brelse(tmpbh);
- }
+
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_disk_release_lock */
@@ -1180,7 +1177,6 @@
int ocfs_release_lock (ocfs_super * osb, __u32 lock_type, __u32 flags, struct buffer_head *bh, struct inode *inode)
{
int status = 0;
- int tries = 0;
ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);
__u64 lock_id;
@@ -1194,24 +1190,8 @@
flags |= FLAG_RELEASE_LOCK;
-again:
ocfs_acquire_lockres (lockres, 0); // ocfs_release_lock
- if (bh) {
- /* always get the write lock on the bh */
- /* make sure to do this AFTER the lockres acquire */
- if (OCFS_BH_GET_DATA_WRITE_TRYLOCK(bh) == NULL) {
- tries++;
- ocfs_release_lockres(lockres); // ocfs_release_lock
- LOG_ERROR_ARGS("failed to get bh sem (%llu), attempt %d, trying again\n",
- (unsigned long long)bh->b_blocknr, tries);
- ocfs_sleep(100);
- goto again;
- }
- OCFS_BH_PUT_DATA(bh);
- }
-
-
if ((lockres->lock_type == OCFS_DLM_ENABLE_CACHE_LOCK) &&
(lockres->master_node_num == osb->node_num) &&
!(flags & FLAG_FILE_DELETE) && !(flags & FLAG_FILE_EXTEND)
@@ -1241,8 +1221,6 @@
}
finally:
- if (bh)
- ocfs_clear_buffer_modified(bh);
lockres->lock_holders--;
LOG_TRACE_ARGS("lockres->lock_holders = %u\n", lockres->lock_holders);
ocfs_release_lockres (lockres); // ocfs_release_lock
Modified: branches/format-changes/src/file.c
===================================================================
--- branches/format-changes/src/file.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/file.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -41,7 +41,6 @@
#include "extmap.h"
#include "file.h"
#include "sysfile.h"
-#include "hash.h"
#include "inode.h"
#include "util.h"
@@ -325,9 +324,6 @@
ret = 0;
}
- if (ret < 0)
- ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
LOG_TRACE_ARGS
("exiting file_open: file=%p dentry=%p inode=%p kiovec=%d\n",
file, file->f_dentry, file->f_dentry->d_inode, err);
@@ -408,8 +404,6 @@
}
bail:
-// ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
if (dec)
iput(inode);
@@ -855,12 +849,6 @@
OCFS_CLEAR_FLAG(OCFS_I(inode)->oin_flags, OCFS_OIN_OPEN_FOR_WRITE);
}
-
-#ifndef BH_SEM_LEAK_CHECKING
- if (ret < 0)
-#endif
- ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
LOG_EXIT_INT (ret);
return ret;
} /* ocfs_file_write */
@@ -1509,11 +1497,6 @@
bail:
up_write(&OCFS_I(inode)->ip_io_sem);
-#ifndef BH_SEM_LEAK_CHECKING
- if (error < 0)
-#endif
- ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
LOG_EXIT_INT (error);
return error;
} /* ocfs_setattr */
Deleted: branches/format-changes/src/hash.c
===================================================================
--- branches/format-changes/src/hash.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/hash.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -1,648 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * hash.c
- *
- * lockid hash, bh sem hash, inode hash
- *
- * Copyright (C) 2002, 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
- * Manish Singh, Neeraj Goyal, Suchit Kaura
- */
-
-#include "ocfs_compat.h"
-
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/blkdev.h>
-#include <linux/highmem.h>
-#include <linux/random.h>
-
-#include "ocfs_log.h"
-#include "ocfs.h"
-
-#include "hash.h"
-#include "util.h"
-
-#include "ocfs_buffer_head.h"
-
-
-/* Tracing */
-#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_HASH
-
-
-#ifndef ATOMIC_DEC_AND_LOCK
-extern int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
-#endif
-
-
-/*
- *
- * BH SEM HASH
- *
- */
-
-
-static ocfs_bh_sem *ocfs_bh_sem_alloc(void)
-{
- return kmem_cache_alloc(OcfsGlobalCtxt.bh_sem_cache, GFP_NOFS);
-}
-
-static void ocfs_bh_sem_free(ocfs_bh_sem *sem)
-{
- kmem_cache_free(OcfsGlobalCtxt.bh_sem_cache, sem);
-}
-
-static void ocfs_bh_sem_get(ocfs_bh_sem *sem)
-{
- atomic_inc(&sem->s_refcnt);
-}
-
-static void ocfs_bh_sem_put(ocfs_bh_sem *sem)
-{
- if (atomic_dec_and_lock(&sem->s_refcnt, &OcfsGlobalCtxt.bh_sem_hash_lock)) {
- if (buffer_modified(sem->s_bh)) {
- LOG_ERROR_ARGS("putting last refcount of a modified buffer! block %llu\n",
- (unsigned long long)sem->s_bh->b_blocknr);
- }
- put_bh(sem->s_bh);
- sem->s_bh = NULL;
- spin_unlock(&OcfsGlobalCtxt.bh_sem_hash_lock);
- }
-}
-
-static void ocfs_bh_sem_down(ocfs_bh_sem *sem)
-{
- down(&sem->s_sem);
-}
-
-static void ocfs_bh_sem_up(ocfs_bh_sem *sem)
-{
- up(&sem->s_sem);
-}
-
-/* ripped right out of inode.c */
-#define ocfs_bh_hash_shift (OcfsGlobalCtxt.bh_sem_hash_sz-1)
-#define _hashfn(dev,block) \
- ((((dev)<<(ocfs_bh_hash_shift - 6)) ^ ((dev)<<(ocfs_bh_hash_shift - 9))) ^ \
- (((block)<<(ocfs_bh_hash_shift - 6)) ^ ((block) >> 13) ^ \
- ((block) << (ocfs_bh_hash_shift - 12))))
-#define ocfs_bh_sem_hash_fn(_b) \
- (_hashfn((unsigned int)BH_GET_DEVICE((_b)), (_b)->b_blocknr) & ocfs_bh_hash_shift)
-
-int ocfs_bh_sem_hash_init()
-{
- int i, ret;
-
- spin_lock_init (&OcfsGlobalCtxt.bh_sem_hash_lock);
- OcfsGlobalCtxt.bh_sem_hash = (struct list_head *)__get_free_pages(GFP_KERNEL, 2);
- if (!OcfsGlobalCtxt.bh_sem_hash) {
- LOG_ERROR_STR("ENOMEM allocating ocfs_bh_sem_hash");
- ret = -ENOMEM;
- goto bail;
- }
- OcfsGlobalCtxt.bh_sem_hash_sz = (PAGE_SIZE * 4) / sizeof(struct list_head);
-
- for (i=OcfsGlobalCtxt.bh_sem_hash_sz-1; i>=0; i--)
- INIT_LIST_HEAD(&OcfsGlobalCtxt.bh_sem_hash[i]);
-
- atomic_set(&OcfsGlobalCtxt.bh_sem_hash_target_bucket, -1);
- atomic_set(&OcfsGlobalCtxt.bh_sem_hash_num_iters, 0);
- ret = 0;
-bail:
- return ret;
-}
-
-int ocfs_bh_sem_hash_destroy()
-{
- int missed;
-
- while (1) {
- missed = ocfs_bh_sem_hash_prune_all();
- if (missed == 0)
- break;
- LOG_TRACE_ARGS("still have %d entries in use in hashtable\n", missed);
- }
-
- spin_lock (&OcfsGlobalCtxt.bh_sem_hash_lock);
- free_pages((unsigned long)OcfsGlobalCtxt.bh_sem_hash, 2);
- OcfsGlobalCtxt.bh_sem_hash = NULL;
-
- return 0;
-}
-
-
-static ocfs_bh_sem * ocfs_bh_sem_lookup(struct buffer_head *bh)
-{
- int depth, bucket;
- struct list_head *head, *iter = NULL;
- ocfs_bh_sem *sem = NULL, *newsem = NULL;
-
- bucket = ocfs_bh_sem_hash_fn(bh);
- head = &OcfsGlobalCtxt.bh_sem_hash[bucket];
-again:
- depth = 0;
- spin_lock (&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- list_for_each(iter, head) {
- if (++depth > OCFS_BH_SEM_HASH_PRUNE_TRIGGER) {
- /* Grandma, what a long list you have? */
- atomic_set(&OcfsGlobalCtxt.bh_sem_hash_target_bucket, bucket);
- }
- sem = list_entry (iter, ocfs_bh_sem, s_list);
- if (sem->s_blocknr == bh->b_blocknr &&
- sem->s_dev == BH_GET_DEVICE(bh)) {
- if (atomic_read(&sem->s_refcnt)==0) {
- if (sem->s_bh) {
- LOG_ERROR_STR("refcount was zero but s_bh not NULL!");
- BUG();
- }
- get_bh(bh);
- sem->s_bh = bh;
- }
- if (sem->s_bh != bh) {
- LOG_ERROR_ARGS("bad bh_sem->bh: sem(%p,%llu,%lu), new(%p,%llu)\n",
- sem->s_bh, sem->s_bh ?
- (unsigned long long)sem->s_bh->b_blocknr : 0ULL,
- sem->s_blocknr, bh,
- (unsigned long long)bh->b_blocknr);
- BUG();
- }
- break;
- }
- sem = NULL;
- }
-
- if (newsem && !sem) {
- /* second pass, we are first to insert */
- sem = newsem;
- list_add(&sem->s_list, head);
- get_bh(bh);
- sem->s_bh = bh;
- }
-
- if (sem) {
- /* found something on first or second pass */
- ocfs_bh_sem_get(sem);
- if (newsem != sem) {
- /* if not just added, mru to front */
- list_del(&sem->s_list);
- list_add(&sem->s_list, head);
- }
- //LOG_TRACE_ARGS("found bh_sem for %d, modified=%s, pid=%d\n",
- // sem->s_bh->b_blocknr,
- // buffer_modified(sem->s_bh) ? "true" : "false",
- // sem->s_pid);
-
- if (buffer_modified(sem->s_bh) && sem->s_pid == 0) {
- LOG_ERROR_ARGS("found a%s sem with a modified bh but no pid!!! (block=%llu)\n",
- newsem != sem ? "n old" : " new",
- (unsigned long long)sem->s_bh->b_blocknr);
- }
- } else {
- /* first pass. not found. do alloc */
- spin_unlock (&OcfsGlobalCtxt.bh_sem_hash_lock);
- newsem = ocfs_bh_sem_alloc();
- if (newsem) {
- newsem->s_bh = NULL;
- atomic_set(&newsem->s_refcnt, 0);
- newsem->s_blocknr = bh->b_blocknr;
- newsem->s_dev = BH_GET_DEVICE(bh);
- init_MUTEX (&newsem->s_sem);
- init_waitqueue_head(&newsem->s_wait);
- newsem->s_pid = 0;
-#ifdef BH_SEM_DEBUG
- memset(&newsem->s_modifier[0], 0, 40);
-#endif
- goto again;
- }
- sem = NULL;
- goto bail;
- }
-
- spin_unlock (&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- if (newsem && newsem != sem) {
- /* another thread inserted while we were sleeping */
- ocfs_bh_sem_free(newsem);
- }
-
-bail:
- return sem;
-}
-
-
-/* look up the semaphore for this blocknum, and lock it too */
-/* this can obviously block if someone else already has the bh */
-int ocfs_bh_sem_lock(struct buffer_head *bh)
-{
- ocfs_bh_sem *sem;
- int ret;
-
- sem = ocfs_bh_sem_lookup(bh);
- if (!sem)
- BUG();
-
- ocfs_bh_sem_down(sem);
- if (buffer_modified(bh) && sem->s_pid != current->pid) {
-#ifdef VERBOSE_BH_SEM
- LOG_TRACE_ARGS("need to wait... modified and pid is %d\n", sem->s_pid);
-#endif
- LOG_ERROR_ARGS("Uhoh, read lock wanted on modified buffer! (pid=%d, block=%llu)\n", sem->s_pid, (unsigned long long)bh->b_blocknr);
- ret = OCFS_BH_SEM_WAIT_ON_MODIFY;
- } else {
-#ifdef VERBOSE_BH_SEM
- LOG_TRACE_ARGS("got the lock\n");
-#endif
- ret = OCFS_BH_SEM_GOT_LOCK;
- }
-
- return ret;
-}
-
-#ifdef BH_SEM_DEBUG
-int __ocfs_bh_sem_lock_modify(struct buffer_head *bh, const char *func,
- const char *file, int line)
-{
- ocfs_bh_sem *sem;
- int ret;
-
- sem = ocfs_bh_sem_lookup(bh);
- if (!sem)
- BUG();
-
- ocfs_bh_sem_down(sem);
- ret = OCFS_BH_SEM_GOT_LOCK;
- if (buffer_modified(bh)) {
- if (sem->s_pid == 0) {
- sem->s_pid = current->pid;
-
- snprintf(sem->s_modifier, 40, "%s:%s:%d",
- func, file, line);
-
- ocfs_bh_sem_get(sem);
- } else if (sem->s_pid != current->pid) {
- ret = OCFS_BH_SEM_WAIT_ON_MODIFY;
- }
- } else {
- if (sem->s_pid != 0)
- printk("first to modify, but pid is NOT 0!\n");
- sem->s_pid = current->pid;
-
- snprintf(sem->s_modifier, 40, "%s:%s:%d",
- func, file, line);
-
- ocfs_bh_sem_get(sem);
-
- set_buffer_modified(bh);
- }
-
- return ret;
-}
-#else
-int ocfs_bh_sem_lock_modify(struct buffer_head *bh)
-{
- ocfs_bh_sem *sem;
- int ret;
-
- sem = ocfs_bh_sem_lookup(bh);
- if (!sem)
- BUG();
-
- ocfs_bh_sem_down(sem);
- ret = OCFS_BH_SEM_GOT_LOCK;
- if (buffer_modified(bh)) {
- //LOG_TRACE_ARGS("buffer modified\n");
- if (sem->s_pid == 0) {
- LOG_ERROR_ARGS("modified, but pid is 0!\n");
- // BUG();
- sem->s_pid = current->pid;
-
- /* this should really be a bug, but for now, up the */
- /* refcount as if it weren't modified */
- ocfs_bh_sem_get(sem);
- } else if (sem->s_pid != current->pid) {
-// LOG_TRACE_ARGS("need to wait... modified and pid is %d\n", sem->s_pid);
- ret = OCFS_BH_SEM_WAIT_ON_MODIFY;
- LOG_ERROR_ARGS("Uhoh, write lock wanted on modified buffer! (pid=%d, block=%llu)\n", sem->s_pid, (unsigned long long)bh->b_blocknr);
- }
- } else {
- //LOG_TRACE_ARGS("buffer NOT modified\n");
- /* this is the first call to modify it */
- if (sem->s_pid != 0)
- LOG_ERROR_ARGS("first to modify, but pid is NOT 0!\n");
- sem->s_pid = current->pid;
-
- /* extra refcount for the modified bh */
- ocfs_bh_sem_get(sem);
-
- set_buffer_modified(bh);
- }
-
- return ret;
-}
-#endif
-
-
-
-int ocfs_bh_sem_unlock(struct buffer_head *bh)
-{
- ocfs_bh_sem *sem;
-
- sem = ocfs_bh_sem_lookup(bh);
- if (!sem)
- BUG();
-
- /* take away one ref from this lookup */
- ocfs_bh_sem_put(sem);
-
- ocfs_bh_sem_up(sem);
-
- /* take away another ref from the lock lookup */
- ocfs_bh_sem_put(sem);
-
- return 0;
-}
-
-
-/* returns number of pruned entries */
-int ocfs_bh_sem_hash_prune()
-{
- unsigned int bucket;
- int pruned = 0, mandatory=0;
- struct list_head *head, *iter = NULL, *tmpiter = NULL;
- ocfs_bh_sem *sem = NULL;
- LIST_HEAD(tmp);
-
- atomic_inc(&OcfsGlobalCtxt.bh_sem_hash_num_iters);
- if (atomic_read(&OcfsGlobalCtxt.bh_sem_hash_num_iters) > 10) {
- mandatory = 1;
- atomic_sub(10, &OcfsGlobalCtxt.bh_sem_hash_num_iters);
- }
-
- /* The better to prune you with, my dear! */
- bucket = atomic_read(&OcfsGlobalCtxt.bh_sem_hash_target_bucket);
- if (bucket == -1) {
- if (mandatory) {
- get_random_bytes(&bucket, sizeof(bucket));
- bucket %= OcfsGlobalCtxt.bh_sem_hash_sz;
- } else {
- pruned = 0;
- goto bail;
- }
- }
-
- spin_lock(&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- bucket = atomic_read(&OcfsGlobalCtxt.bh_sem_hash_target_bucket);
- if (bucket == -1) {
- spin_unlock (&OcfsGlobalCtxt.bh_sem_hash_lock);
- pruned = 0;
- goto bail;
- }
-
- head = &OcfsGlobalCtxt.bh_sem_hash[bucket];
- pruned = 0;
-
- /* run in lru order */
- list_for_each_prev_safe(iter, tmpiter, head) {
- sem = list_entry (iter, ocfs_bh_sem, s_list);
- if (atomic_read(&sem->s_refcnt) < 1) {
- list_del(&sem->s_list);
- list_add(&sem->s_list, &tmp);
- pruned++;
- }
- if (pruned >= OCFS_BH_SEM_HASH_PRUNE_MAX)
- break;
- }
- atomic_set(&OcfsGlobalCtxt.bh_sem_hash_target_bucket, -1);
-
- spin_unlock (&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- list_for_each_safe(iter, tmpiter, &tmp) {
- sem = list_entry (iter, ocfs_bh_sem, s_list);
- if (sem->s_bh) {
- LOG_ERROR_STR("s_bh is NOT NULL");
- BUG();
- }
- list_del(&sem->s_list);
- ocfs_bh_sem_free(sem);
- }
-bail:
- return pruned;
-}
-
-/*
- * ocfs_bh_sem_hash_cleanup_pid()
- *
- * Yes, this function is evil.
- */
-int ocfs_bh_sem_hash_cleanup_pid(pid_t pid)
-{
- int bucket, found = 0;
- struct list_head *head, *iter = NULL;
- ocfs_bh_sem *sem = NULL;
-
- bucket = 0;
-again:
- spin_lock(&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- head = &OcfsGlobalCtxt.bh_sem_hash[bucket];
-
- list_for_each(iter, head) {
- sem = list_entry (iter, ocfs_bh_sem, s_list);
-
- if (sem->s_bh &&
- buffer_modified(sem->s_bh) &&
- sem->s_pid == pid) {
- found++;
- ocfs_bh_sem_get(sem);
-
- /* only do one buffer at a time. */
- spin_unlock(&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- LOG_ERROR_ARGS("blocknr = %llu, pid = %d\n",
- (unsigned long long)sem->s_bh->b_blocknr,
- pid);
- ocfs_clear_buffer_modified(sem->s_bh);
- ocfs_bh_sem_put(sem);
- goto again;
- }
- }
-
- spin_unlock (&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- if (++bucket < OcfsGlobalCtxt.bh_sem_hash_sz)
- goto again;
-
- if (found) {
- LOG_ERROR_ARGS("Found %d modified buffers!\n", found);
-#ifdef BH_SEM_LEAK_CHECKING
- BUG();
-#endif
- }
- return found;
-} /* ocfs_bh_sem_hash_cleanup_pid() */
-
-/* returns number of missed entries */
-int ocfs_bh_sem_hash_prune_all()
-{
- int bucket, missed;
- struct list_head *head, *iter = NULL, *tmpiter = NULL;
- ocfs_bh_sem *sem = NULL;
- LIST_HEAD(tmp);
-
- missed = 0;
- bucket = 0;
- spin_lock(&OcfsGlobalCtxt.bh_sem_hash_lock);
- atomic_set(&OcfsGlobalCtxt.bh_sem_hash_target_bucket, -1);
-again:
- head = &OcfsGlobalCtxt.bh_sem_hash[bucket];
-
- /* run in lru order */
- list_for_each_prev_safe(iter, tmpiter, head) {
- sem = list_entry (iter, ocfs_bh_sem, s_list);
- if (atomic_read(&sem->s_refcnt) < 1) {
- if (sem->s_bh) {
- LOG_ERROR_ARGS("killing off bh_sem with bh still attached! block=%llu, count=%d\n",
- (unsigned long long)sem->s_bh->b_blocknr,
- atomic_read(&sem->s_bh->b_count));
- }
- list_del(&sem->s_list);
- list_add(&sem->s_list, &tmp);
- } else {
- missed++;
- LOG_TRACE_ARGS("missed block %lu, refcount %u, "
- "pid = %u\n",
- sem->s_blocknr,
- atomic_read(&sem->s_refcnt),
- sem->s_pid);
- }
- }
-
- if (++bucket < OcfsGlobalCtxt.bh_sem_hash_sz)
- goto again;
-
- LOG_TRACE_ARGS("finished pruning, missed %d entries\n", missed);
-
- spin_unlock (&OcfsGlobalCtxt.bh_sem_hash_lock);
-
- list_for_each_safe(iter, tmpiter, &tmp) {
- sem = list_entry (iter, ocfs_bh_sem, s_list);
- if (sem->s_bh) {
- LOG_ERROR_STR("s_bh is NOT NULL");
- BUG();
- }
- list_del(&sem->s_list);
- ocfs_bh_sem_free(sem);
- }
-
- return missed;
-}
-
-#define BUFFER_MODIFIED_TIMEOUT (10*HZ)
-
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-static inline void ocfs_kick_disk(struct buffer_head *bh)
-{
- struct block_device *bd;
-
- smp_mb();
- bd = bh->b_bdev;
- if (bd)
- blk_run_address_space(bd->bd_inode->i_mapping);
-}
-#else
-static inline void ocfs_kick_disk(struct buffer_head *bh)
-{
- run_task_queue(&tq_disk);
-}
-#endif
-
-void wait_on_buffer_modified(struct buffer_head * bh)
-{
- int do_timeout = 1;
- ocfs_bh_sem *sem = ocfs_bh_sem_lookup(bh);
- struct task_struct *tsk = current;
- DECLARE_WAITQUEUE(wait, tsk);
-
- LOG_ENTRY_ARGS("(block=%llu, sem->s_pid=%d)\n",
- (unsigned long long)bh->b_blocknr, sem->s_pid);
-
- add_wait_queue(&sem->s_wait, &wait);
- do {
- if (!buffer_modified(bh) ||
- sem->s_pid == current->pid)
- break;
- ocfs_kick_disk(bh);
- if (!do_timeout) {
- set_task_state(tsk, TASK_UNINTERRUPTIBLE);
- io_schedule();
- } else {
- do_timeout = 0;
- set_task_state(tsk, TASK_INTERRUPTIBLE);
- schedule_timeout(BUFFER_MODIFIED_TIMEOUT);
- if (buffer_modified(bh) &&
- sem->s_pid != current->pid && sem->s_pid != 0) {
-#ifdef BH_SEM_DEBUG
- LOG_ERROR_ARGS("possible deadlock: block=%lu, owner=%d, this=%d, modifier='%s'\n",
- bh->b_blocknr, sem->s_pid, current->pid, sem->s_modifier);
-#else
- LOG_ERROR_ARGS("possible deadlock: block=%llu, owner=%d, this=%d\n",
- (unsigned long long)bh->b_blocknr, sem->s_pid, current->pid);
-#endif
- }
- }
- } while (buffer_modified(bh) && sem->s_pid != current->pid);
- set_task_state(tsk, TASK_RUNNING);
- remove_wait_queue(&sem->s_wait, &wait);
- ocfs_bh_sem_put(sem);
-
- LOG_EXIT();
-}
-
-void ocfs_clear_buffer_modified(struct buffer_head *bh)
-{
- ocfs_bh_sem *sem = NULL;
-
- LOG_ENTRY();
- if (buffer_modified(bh)) {
- sem = ocfs_bh_sem_lookup(bh);
- if (ocfs_bh_sem_lock_modify(bh) != OCFS_BH_SEM_GOT_LOCK) {
- printk("ocfs2: sem->s_pid=%d, my pid=%d\n", sem->s_pid, current->pid);
- BUG();
- }
- clear_buffer_modified(bh);
- sem->s_pid = 0;
-#ifdef BH_SEM_DEBUG
- memset(&sem->s_modifier[0], 0, 40);
-#endif
- ocfs_bh_sem_unlock(bh);
- if (waitqueue_active(&sem->s_wait))
- wake_up(&sem->s_wait);
- /* remove ref from lookup above */
- ocfs_bh_sem_put(sem);
-
- /* remove additional ref from ocfs_bh_sem_lock_modify */
- ocfs_bh_sem_put(sem);
- }
- LOG_EXIT();
-}
Deleted: branches/format-changes/src/hash.h
===================================================================
--- branches/format-changes/src/hash.h 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/hash.h 2004-06-17 04:30:27 UTC (rev 1125)
@@ -1,52 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * hash.h
- *
- * Function prototypes
- *
- * Copyright (C) 2002, 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
- * Manish Singh, Neeraj Goyal, Suchit Kaura
- */
-
-#ifndef OCFS2_HASH_H
-#define OCFS2_HASH_H
-
-int ocfs_bh_sem_hash_cleanup_pid(pid_t pid);
-int ocfs_bh_sem_hash_destroy(void);
-int ocfs_bh_sem_hash_init(void);
-int ocfs_bh_sem_hash_prune(void);
-int ocfs_bh_sem_hash_prune_all(void);
-int ocfs_bh_sem_lock(struct buffer_head *bh);
-int ocfs_bh_sem_unlock(struct buffer_head *bh);
-void ocfs_clear_buffer_modified(struct buffer_head *bh);
-void wait_on_buffer_modified(struct buffer_head *bh);
-
-#ifdef BH_SEM_DEBUG
-#define ocfs_bh_sem_lock_modify(bh) \
- __ocfs_bh_sem_lock_modify((bh), __FUNCTION__, __FILE__, __LINE__)
-
-int __ocfs_bh_sem_lock_modify(struct buffer_head *bh, const char *func,
- const char *file, int line);
-#else
-int ocfs_bh_sem_lock_modify(struct buffer_head *bh);
-#endif
-
-#endif /* OCFS2_HASH_H */
Modified: branches/format-changes/src/heartbeat.c
===================================================================
--- branches/format-changes/src/heartbeat.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/heartbeat.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -37,7 +37,6 @@
#include "ocfs.h"
#include "alloc.h"
-#include "hash.h"
#include "heartbeat.h"
#include "util.h"
#include "vote.h"
Modified: branches/format-changes/src/inode.c
===================================================================
--- branches/format-changes/src/inode.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/inode.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -45,7 +45,6 @@
#include "dlm.h"
#include "extmap.h"
#include "file.h"
-#include "hash.h"
#include "inode.h"
#include "ioctl.h"
#include "lockres.h"
Modified: branches/format-changes/src/journal.c
===================================================================
--- branches/format-changes/src/journal.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/journal.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -39,7 +39,6 @@
#include "alloc.h"
#include "dlm.h"
#include "extmap.h"
-#include "hash.h"
#include "inode.h"
#include "journal.h"
#include "nm.h"
@@ -407,10 +406,6 @@
else
kern_handle->h_sync = 0;
- /* Ok, we're done changing these buffers now... */
- for(i = 0; i < handle->num_buffs; i++)
- ocfs_clear_buffer_modified(handle->buffs[i]);
-
/* release inode semaphores we took during this transaction */
ocfs_handle_unlock_inodes(handle);
if (handle->flags & OCFS_HANDLE_LOCAL_ALLOC)
@@ -578,15 +573,10 @@
OCFS_BH_PUT_DATA(bh);
/* we no longer need the buffer in this case. */
- if (!dirtied) {
- ocfs_clear_buffer_modified(bh);
+ if (!dirtied)
brelse(bh);
- }
}
- for(i = 0; i < handle->num_buffs; i++)
- ocfs_clear_buffer_modified(handle->buffs[i]);
-
/* release inode semaphores we took during this transaction */
ocfs_handle_unlock_inodes(handle);
if (handle->flags & OCFS_HANDLE_LOCAL_ALLOC)
Modified: branches/format-changes/src/lockres.c
===================================================================
--- branches/format-changes/src/lockres.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/lockres.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -37,7 +37,6 @@
#include "ocfs.h"
#include "dlm.h"
-#include "hash.h"
#include "lockres.h"
#include "util.h"
#include "vote.h"
Modified: branches/format-changes/src/namei.c
===================================================================
--- branches/format-changes/src/namei.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/namei.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -55,7 +55,6 @@
#include "dlm.h"
#include "file.h"
#include "sysfile.h"
-#include "hash.h"
#include "inode.h"
#include "lockres.h"
#include "namei.h"
@@ -344,11 +343,6 @@
if ((status < 0) && inode)
iput(inode);
-#ifndef BH_SEM_LEAK_CHECKING
- if (status < 0)
-#endif
- ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
LOG_EXIT_STATUS(status);
return(status);
} /* ocfs_mknod */
@@ -761,13 +755,6 @@
if (parent_node_bh)
brelse(parent_node_bh);
-
-#ifndef BH_SEM_LEAK_CHECKING
- if (retval < 0)
-#endif
- ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
-
LOG_EXIT_INT (retval);
return retval;
} /* ocfs_unlink */
@@ -1249,11 +1236,6 @@
if (old_inode_de_bh)
brelse(old_inode_de_bh);
-#ifndef BH_SEM_LEAK_CHECKING
- if (status < 0)
-#endif
- ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
LOG_EXIT_STATUS(status);
return status;
} /* ocfs_rename */
@@ -1389,6 +1371,7 @@
bail:
up_write(&OCFS_I(dir)->ip_io_sem);
+ /* can we race with the nm threads iget() here? */
if (status >= 0) {
insert_inode_hash (inode);
d_instantiate (dentry, inode);
@@ -1402,11 +1385,6 @@
if (parent_fe_bh)
brelse(parent_fe_bh);
-#ifndef BH_SEM_LEAK_CHECKING
- if (status < 0)
-#endif
- ocfs_bh_sem_hash_cleanup_pid(current->pid);
-
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_symlink */
Modified: branches/format-changes/src/nm.c
===================================================================
--- branches/format-changes/src/nm.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/nm.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -40,7 +40,6 @@
#include "alloc.h"
#include "dlm.h"
-#include "hash.h"
#include "heartbeat.h"
#include "inode.h"
#include "lockres.h"
@@ -261,8 +260,6 @@
return(status);
} /* ocfs_schedule_process_vote */
-//#define OCFS_BH_SEM_PRUNE_LIMIT 60 // prune everything each 30 seconds
-#define OCFS_BH_SEM_PRUNE_LIMIT 60000 // 8 hours :)
/* half a second timeout */
#define OCFS_HEARTBEAT_JIFFIES (HZ >> 1)
@@ -286,7 +283,7 @@
__u32 vote_node;
ocfs_node_config_hdr *node_cfg_hdr = NULL;
__u64 cfg_seq_num;
- int which, pruned, prune_iters = 0;
+ int which;
struct buffer_head *bh = NULL;
siginfo_t info;
@@ -312,18 +309,6 @@
if (!time_after (jiffies, (unsigned long) (osb->hbt)))
goto finally;
- /* try to prune some bh_sem hash entries if list is too long */
- if (prune_iters++ == OCFS_BH_SEM_PRUNE_LIMIT) {
- int missed;
- prune_iters = 0;
- missed = ocfs_bh_sem_hash_prune_all();
- //LOG_TRACE_ARGS("missed %d entries pruning everything from nm thread\n", missed);
- printk("missed %d entries pruning everything from nm thread\n", missed);
- } else {
- pruned = ocfs_bh_sem_hash_prune();
- LOG_TRACE_ARGS("pruned %d entries from nm thread\n", pruned);
- }
-
/* lock publish to prevent overwrites from vote_req and vote_reset */
down (&(osb->publish_lock));
@@ -1144,10 +1129,7 @@
}
else // CHANGE_MASTER
lockres->master_node_num = node_num;
- } else {
- /* we didn't actually modify it. */
- ocfs_clear_buffer_modified(fe_bh);
- }
+ }
brelse(fe_bh);
vote_response = FLAG_VOTE_NODE;
inc_inode_seq = 1;
Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/ocfs.h 2004-06-17 04:30:27 UTC (rev 1125)
@@ -289,11 +289,6 @@
#define OCFS_NM_HEARTBEAT_TIME 500 /* in ms */
#define OCFS_HEARTBEAT_INIT 10 /* number of NM iterations to stabilize the publish map */
-
-
-#define OCFS_BH_SEM_HASH_PRUNE_TRIGGER 50 /* trigger nm to prune the hash when list size is > this */
-#define OCFS_BH_SEM_HASH_PRUNE_MAX 100 /* nm will prune at most this many in one cycle */
-
#ifndef O_DIRECT
#warning this depends on the architecture!
@@ -434,26 +429,6 @@
/* =========================================================== */
-enum {
- OCFS_BH_SEM_GOT_LOCK,
- OCFS_BH_SEM_WAIT_ON_MODIFY,
-};
-
-typedef struct _ocfs_bh_sem
-{
- struct semaphore s_sem;
- struct list_head s_list;
- unsigned long s_blocknr;
- dev_t s_dev;
- atomic_t s_refcnt;
- struct buffer_head *s_bh;
- wait_queue_head_t s_wait;
- pid_t s_pid;
-#ifdef BH_SEM_DEBUG
- char s_modifier[40];
-#endif
-} ocfs_bh_sem;
-
#include "ocfs2_fs.h"
typedef struct _ocfs_vol_disk_hdr // CLASS
@@ -879,7 +854,6 @@
struct list_head osb_next; /* List of all volumes */
kmem_cache_t *inode_cache;
kmem_cache_t *extent_cache;
- kmem_cache_t *bh_sem_cache;
__u32 flags;
__u32 pref_node_num; /* preferred... osb has the real one */
ocfs_guid guid; /* uniquely identifies a node */
@@ -889,11 +863,6 @@
int comm_info_read; /* ipc info loaded from config file */
spinlock_t comm_seq_lock; /* protects comm_seq_num */
__u64 comm_seq_num; /* local node seq num used in ipcdlm */
- struct list_head *bh_sem_hash;
- spinlock_t bh_sem_hash_lock;
- int bh_sem_hash_sz;
- atomic_t bh_sem_hash_target_bucket;
- atomic_t bh_sem_hash_num_iters;
ocfs_dlm_stats net_reqst_stats; /* stats of netdlm vote requests */
ocfs_dlm_stats net_reply_stats; /* stats of netdlm vote reponses */
ocfs_dlm_stats dsk_reqst_stats; /* stats of diskdlm vote requests */
Modified: branches/format-changes/src/ocfs_buffer_head.h
===================================================================
--- branches/format-changes/src/ocfs_buffer_head.h 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/ocfs_buffer_head.h 2004-06-17 04:30:27 UTC (rev 1125)
@@ -71,15 +71,7 @@
#define BH_Modified 18
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-/*
- * BUFFER_FNS is the new marcro magic intruduced in 2.5.x kernel for defining
- * set_buffer_XXX, clear_buffer_XXX, and buffer_XXX functions
- */
-BUFFER_FNS(Modified, modified)
-
-#else /* 2.4.x kernel */
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
/*
* Copied right out of the 2.6.2 kernel's buffer_head.h:
* macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
@@ -102,147 +94,16 @@
#undef buffer_uptodate
#undef buffer_dirty
BUFFER_FNS(Uptodate, uptodate)
-BUFFER_FNS(Modified, modified)
BUFFER_FNS(Dirty, dirty)
#endif /* 2.4.x kernel */
-static inline void * OCFS_BH_GET_DATA_READ(struct buffer_head *bh)
-{
- unsigned char *kaddr;
-
- OCFS_ASSERT(bh);
+#define OCFS_BH_GET_DATA(bh) ((void *) ((bh)->b_data))
+#define OCFS_BH_GET_DATA_READ(bh) OCFS_BH_GET_DATA(bh)
+#define OCFS_BH_GET_DATA_WRITE(bh) OCFS_BH_GET_DATA(bh)
+#define OCFS_BH_GET_DATA_WRITE_TRYLOCK(bh) OCFS_BH_GET_DATA(bh)
+#define OCFS_BH_PUT_DATA(bh) do { } while(0)
- if (!bh->b_blocknr) {
- printk("%d: warning trying to OCFS_BH_GET_DATA_READ block zero!\n", current->pid);
- ocfs_show_stack(NULL);
- }
-
- while (1) {
- if (ocfs_bh_sem_lock(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) {
- BUG();
-
- ocfs_bh_sem_unlock(bh);
- wait_on_buffer_modified(bh);
- } else {
- break;
- }
- }
-
- kaddr = kmap(bh->b_page);
- kaddr += ((unsigned long)bh->b_data & ~PAGE_MASK);
-
- return kaddr;
-}
-
-
-/* BH_SEM_DEBUG needs these to be macros to get at __LINE__ and such */
-
-#ifdef BH_SEM_DEBUG
-#define OCFS_BH_GET_DATA_WRITE(bh) ({ \
- unsigned char *kaddr; \
- while (1) { \
- if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) { \
- ocfs_bh_sem_unlock(bh); \
- wait_on_buffer_modified(bh); \
- } else \
- break; \
- } \
- kaddr = (kmap((bh)->b_page)) + ((unsigned long)(bh)->b_data & ~PAGE_MASK); \
- (void *)kaddr; \
-})
-
-#define OCFS_BH_GET_DATA_WRITE_TRYLOCK(bh) \
-({ \
- unsigned char *kaddr; \
- if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) { \
- ocfs_bh_sem_unlock(bh); \
- return NULL; \
- } \
- kaddr = kmap((bh)->b_page); \
- kaddr += ((unsigned long)(bh)->b_data & ~PAGE_MASK); \
- (void *)kaddr; \
-})
-#else
-static inline void * OCFS_BH_GET_DATA_WRITE(struct buffer_head *bh)
-{
- unsigned char *kaddr;
-
- OCFS_ASSERT(bh);
-
- if (!bh->b_blocknr) {
- printk("%d: trying to OCFS_BH_GET_DATA_WRITE block zero!\n", current->pid);
- BUG();
- }
-
- while (1) {
- if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) {
-#ifdef VERBOSE_BH_SEM
- printk("ocfs2: called getdata for write but "
- "this process is not the lock "
- "holder!\n");
-#endif
- BUG();
- ocfs_bh_sem_unlock(bh);
- wait_on_buffer_modified(bh);
- } else {
- break;
- }
- }
-
- kaddr = kmap(bh->b_page);
- kaddr += ((unsigned long)bh->b_data & ~PAGE_MASK);
-
- return kaddr;
-}
-
-static inline void * OCFS_BH_GET_DATA_WRITE_TRYLOCK(struct buffer_head *bh)
-{
- unsigned char *kaddr;
-
- OCFS_ASSERT(bh);
-
- if (!bh->b_blocknr) {
- printk("%d: trying to OCFS_BH_GET_DATA_WRITE_TRYLOCK block zero!\n", current->pid);
- BUG();
- }
-
- if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) {
-#ifdef VERBOSE_BH_SEM
- printk("ocfs2: called getdata for write but "
- "this process is not the lock "
- "holder!\n");
-#endif
- LOG_ERROR_STR("Trylock about to BUG()");
- BUG();
- ocfs_bh_sem_unlock(bh);
- return NULL;
- }
-
- kaddr = kmap(bh->b_page);
- kaddr += ((unsigned long)bh->b_data & ~PAGE_MASK);
-
- return kaddr;
-}
-
-#endif
-
-
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define BH_GET_DEVICE(bh) ((bh->b_bdev)->bd_dev)
-#else
-#define BH_GET_DEVICE(bh) (bh->b_dev)
-#endif
-
-static inline void OCFS_BH_PUT_DATA(struct buffer_head *bh)
-{
- OCFS_ASSERT(bh);
-
- kunmap(bh->b_page);
- ocfs_bh_sem_unlock(bh);
-}
-
#define STATE_BH_BITS 8
#define USED_BH_BITS 23 /* Number of BH bits used up through JBD */
Modified: branches/format-changes/src/super.c
===================================================================
--- branches/format-changes/src/super.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/super.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -52,7 +52,6 @@
#include "alloc.h"
#include "bitmap.h"
-#include "hash.h"
#include "heartbeat.h"
#include "inode.h"
#include "journal.h"
@@ -553,12 +552,6 @@
goto leave;
}
- status = ocfs_bh_sem_hash_init();
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
-
spin_lock_init (&osb_id_lock);
spin_lock (&osb_id_lock);
osb_id = 0;
@@ -583,9 +576,6 @@
leave:
if (status < 0) {
- if (OcfsGlobalCtxt.bh_sem_hash && ocfs_bh_sem_hash_destroy() < 0)
- LOG_ERROR_STR("failed to destroy bh_sem hashtable");
-
/* Free up lookaside lists */
if (OcfsGlobalCtxt.flags & OCFS_FLAG_MEM_LISTS_INITIALIZED)
ocfs_free_mem_lists ();
@@ -697,9 +687,6 @@
down (&(OcfsGlobalCtxt.global_res));
OCFS_SET_FLAG (OcfsGlobalCtxt.flags, OCFS_FLAG_SHUTDOWN_VOL_THREAD);
- if (ocfs_bh_sem_hash_destroy() < 0)
- LOG_ERROR_STR("failed to destroy bh_sem hashtable");
-
if (OcfsGlobalCtxt.flags & OCFS_FLAG_MEM_LISTS_INITIALIZED)
ocfs_free_mem_lists ();
@@ -829,10 +816,6 @@
sizeof(ocfs_extent) + OCFS_POINTER_SIZE, 0, SLAB_NO_REAP | SLAB_HWCACHE_ALIGN,
NULL, NULL);
- OcfsGlobalCtxt.bh_sem_cache = kmem_cache_create ("ocfs2_bh_sem",
- sizeof(ocfs_bh_sem), 0, SLAB_NO_REAP | SLAB_HWCACHE_ALIGN,
- NULL, NULL);
-
OCFS_SET_FLAG (OcfsGlobalCtxt.flags, OCFS_FLAG_MEM_LISTS_INITIALIZED);
return 0;
@@ -846,7 +829,6 @@
{
kmem_cache_destroy (OcfsGlobalCtxt.inode_cache);
kmem_cache_destroy (OcfsGlobalCtxt.extent_cache);
- kmem_cache_destroy (OcfsGlobalCtxt.bh_sem_cache);
OCFS_CLEAR_FLAG (OcfsGlobalCtxt.flags, OCFS_FLAG_MEM_LISTS_INITIALIZED);
} /* ocfs_free_mem_lists */
Modified: branches/format-changes/src/sysfile.c
===================================================================
--- branches/format-changes/src/sysfile.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/sysfile.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -38,7 +38,6 @@
#include "alloc.h"
#include "dir.h"
-#include "hash.h"
#include "inode.h"
#include "sysfile.h"
#include "util.h"
Modified: branches/format-changes/src/volcfg.c
===================================================================
--- branches/format-changes/src/volcfg.c 2004-06-17 03:37:52 UTC (rev 1124)
+++ branches/format-changes/src/volcfg.c 2004-06-17 04:30:27 UTC (rev 1125)
@@ -36,7 +36,6 @@
#include "ocfs_log.h"
#include "ocfs.h"
-#include "hash.h"
#include "util.h"
#include "volcfg.h"
More information about the Ocfs2-commits
mailing list