[Ocfs2-commits] jlbec commits r970 - in trunk/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Jun 2 12:16:36 CDT 2004
Author: jlbec
Date: 2004-06-02 11:16:34 -0500 (Wed, 02 Jun 2004)
New Revision: 970
Added:
trunk/src/buffer_head_io.c
trunk/src/inc/ocfs_buffer_head.h
Removed:
trunk/src/inc/io.h
trunk/src/io.c
Modified:
trunk/src/Makefile
trunk/src/alloc.c
trunk/src/bitmap.c
trunk/src/dcache.c
trunk/src/dir.c
trunk/src/dlm.c
trunk/src/extmap.c
trunk/src/file.c
trunk/src/hash.c
trunk/src/heartbeat.c
trunk/src/inc/ocfs.h
trunk/src/inc/ocfs_compat.h
trunk/src/inc/ocfs_journal.h
trunk/src/inc/ocfs_log.h
trunk/src/inode.c
trunk/src/ioctl.c
trunk/src/journal.c
trunk/src/lockres.c
trunk/src/namei.c
trunk/src/nm.c
trunk/src/proc.c
trunk/src/super.c
trunk/src/symlink.c
trunk/src/sysfile.c
trunk/src/util.c
trunk/src/ver.c
trunk/src/volcfg.c
trunk/src/vote.c
Log:
o Remove OCFS_MEM_DBG junk.
o Move io.h to ocfs_buffer_head.h - that's what it is anyway.
o Move io.c to buffer_head_io.c - same reason.
o Remove every #include from ocfs.h that doesn't belong there.
o Fixup all the files to #include what they need.
o Drop many silly abstractions (eg, get_publish_time(), ocfs_getpid()).
o Drop ocfs_free() and ocfs_vfree().
o Move all inline funcs to the bottom of ocfs.h, below the structure
declarations.
Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/Makefile 2004-06-02 16:16:34 UTC (rev 970)
@@ -119,30 +119,30 @@
DEFINES += $(BASE_DEFINES) $(GLOBAL_DEFINES)
-CFILES = \
- alloc.c \
- bitmap.c \
- dcache.c \
- dir.c \
- dlm.c \
- extmap.c \
- file.c \
- hash.c \
- heartbeat.c \
- inode.c \
- io.c \
- ioctl.c \
- journal.c \
- lockres.c \
- namei.c \
- nm.c \
- proc.c \
- super.c \
- symlink.c \
- sysfile.c \
- util.c \
- ver.c \
- volcfg.c \
+CFILES = \
+ alloc.c \
+ bitmap.c \
+ dcache.c \
+ dir.c \
+ dlm.c \
+ extmap.c \
+ file.c \
+ hash.c \
+ heartbeat.c \
+ inode.c \
+ buffer_head_io.c \
+ ioctl.c \
+ journal.c \
+ lockres.c \
+ namei.c \
+ nm.c \
+ proc.c \
+ super.c \
+ symlink.c \
+ sysfile.c \
+ util.c \
+ ver.c \
+ volcfg.c \
vote.c
HFILES = \
@@ -150,7 +150,7 @@
inc/ocfs_log.h \
inc/ocfs_compat.h \
inc/ocfs_journal.h \
- inc/io.h \
+ inc/ocfs_buffer_head.h \
inc/proto.h
OBJS = $(subst .c,.o,$(CFILES))
Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/alloc.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,12 +26,15 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
#ifndef USERSPACE_TOOL
@@ -820,7 +823,7 @@
for (i = 0; i < numSectorsAlloc; i++)
if (header_bhs[i])
brelse(header_bhs[i]);
- ocfs_free(header_bhs);
+ kfree(header_bhs);
}
LOG_EXIT_STATUS (status);
return status;
@@ -1634,7 +1637,7 @@
goto bail;
}
/* Pop one off the stack */
- ocfs_free(stack[tos]);
+ kfree(stack[tos]);
stack[tos] = NULL;
cur_extent = NULL;
tos--;
@@ -1644,7 +1647,7 @@
bail:
for(i = 0; i < OCFS_TREE_STACK_SIZE; i++)
if (stack[i])
- ocfs_free(stack[i]);
+ kfree(stack[i]);
LOG_EXIT_STATUS (status);
return(status);
Modified: trunk/src/bitmap.c
===================================================================
--- trunk/src/bitmap.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/bitmap.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,12 +26,15 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_BITMAP
@@ -73,7 +76,7 @@
if (bitmap->chunk[i])
brelse(bitmap->chunk[i]);
- ocfs_free(bitmap->chunk);
+ kfree(bitmap->chunk);
bitmap->chunk = NULL;
bitmap->numbh = 0;
bitmap->validbits = 0;
@@ -114,7 +117,7 @@
memcpy(newchunk, bitmap->chunk, (bitmap->numbh * sizeof(struct buffer_head *)));
- ocfs_free(bitmap->chunk);
+ kfree(bitmap->chunk);
bitmap->numbh = newnumbh;
bitmap->chunk = newchunk;
Copied: trunk/src/buffer_head_io.c (from rev 968, trunk/src/io.c)
===================================================================
--- trunk/src/io.c 2004-06-02 01:55:02 UTC (rev 968)
+++ trunk/src/buffer_head_io.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -0,0 +1,346 @@
+/*
+ * io.c
+ *
+ * Buffer cache handling
+ *
+ * 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 "inc/ocfs_compat.h"
+
+#include <linux/fs.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/highmem.h>
+
+#include "inc/ocfs_log.h"
+#include "inc/ocfs.h"
+#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
+
+#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_IO
+
+static void ocfs_end_buffer_io_sync(struct buffer_head *bh,
+ int uptodate)
+{
+// LOG_ENTRY_ARGS("(bh->b_blocknr = %u, uptodate = %d)\n", bh->b_blocknr,
+// uptodate);
+
+ if (!uptodate)
+ LOG_ERROR_STATUS(-EIO);
+
+ if (uptodate)
+ set_buffer_uptodate(bh);
+ else
+ clear_buffer_uptodate(bh);
+ unlock_buffer(bh);
+
+// LOG_EXIT();
+ return;
+}
+
+
+int ocfs_write_bhs (ocfs_super * osb, struct buffer_head *bhs[],
+ int nr, int flags, struct inode *inode)
+{
+ int status = 0;
+ int i;
+ struct super_block *sb;
+ ocfs_blockdev dev;
+ struct buffer_head *bh;
+
+#ifdef OCFS_DBG_TIMING
+ my_timing_t begin, end;
+#endif
+
+ LOG_ENTRY_ARGS("(bh[0]->b_blocknr = %lu, nr=%d, flags=%u, inode=%p)\n",
+ bhs[0]->b_blocknr, nr, flags, inode);
+#ifdef OCFS_DBG_TIMING
+ rdtsc (begin.lohi[0], begin.lohi[1]);
+#endif
+
+ if (osb == NULL || osb->sb == NULL || bhs == NULL) {
+ LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == "
+ "NULL");
+ status = -EINVAL;
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
+ if (nr > 256)
+ LOG_TRACE_ARGS ("Getting write for %d blocks\n", nr);
+
+ sb = osb->sb;
+ dev = OCFS_GET_BLOCKDEV(sb);
+
+ /* we don't ever want cached writes -- those should go to the
+ * journal so we can control when they actually hit disk and
+ * so we can make sure they never get overwritten by a
+ * subsequent read. */
+ if ((flags & OCFS_BH_CACHED) || (flags & OCFS_BH_COND_CACHED)) {
+ LOG_TRACE_STR("asking for a cached write!");
+ status = -EINVAL;
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
+ for (i = 0 ; i < nr ; i++) {
+ bh = bhs[i];
+ if (bh == NULL) {
+ LOG_TRACE_STR("bh == NULL");
+ status = -EIO;
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
+ if (check_block_zero_write(bh) < 0) {
+ status = -EIO;
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
+ 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 = %lu)!\n", 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 = %lu)!\n", 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
+ LOG_TRACE_ARGS("trying to write a jbd managed bh "
+ "(blocknr = %lu), nr=%d\n",
+ bh->b_blocknr, nr);
+#endif
+ continue;
+ }
+
+ lock_buffer(bh);
+
+ set_buffer_uptodate(bh);
+ /* remove from dirty list before I/O. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ /*
+ * mark_buffer_clean() doesn't exist in 2.6.x kernels.
+ * Not many places actually used mark_buffer_clean, but
+ * at least reiserfs uses clear_buffer_dirty() as
+ * a replacment.
+ */
+ clear_buffer_dirty(bh);
+#else
+ mark_buffer_clean(bh);
+#endif
+
+ bh->b_end_io = ocfs_end_buffer_io_sync;
+ submit_bh(WRITE, bh);
+ }
+
+ for (i = (nr-1) ; i >= 0; i--) {
+ bh = bhs[i];
+
+ wait_on_buffer(bh);
+
+ if (inode)
+ 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:
+
+#ifdef OCFS_DBG_TIMING
+ IO_FUNC_TIMING_PRINT("ocfs_write_bhs", status);
+#endif
+
+ LOG_EXIT_STATUS(status);
+ return status;
+}
+
+/*
+ * ocfs_read_bhs()
+ *
+ */
+int ocfs_read_bhs (ocfs_super * osb, __u64 off, __u64 len,
+ struct buffer_head *bhs[], int flags,
+ struct inode *inode)
+{
+ int status = 0;
+ struct super_block *sb;
+ int nr, i, ignore_cache = 0;
+ __u64 blocknum;
+ ocfs_blockdev dev;
+ struct buffer_head *bh;
+
+#ifdef OCFS_DBG_TIMING
+ my_timing_t begin, end;
+#endif
+ LOG_ENTRY_ARGS("(off=(%llu), len=(%llu), flags=%d, inode=%p)\n", off,
+ len, flags, inode);
+#ifdef OCFS_DBG_TIMING
+ rdtsc (begin.lohi[0], begin.lohi[1]);
+#endif
+
+ if (len % 512) {
+ LOG_TRACE_ARGS("len %% 512 (len=%llu)\n", len);
+ status = -EINVAL;
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
+ if (osb == NULL || osb->sb == NULL || bhs == NULL) {
+ LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == NULL "
+ "|| num == NULL");
+ status = -EINVAL;
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
+ if ((flags & OCFS_BH_COND_CACHED) &&
+ (off >= osb->vol_layout.bitmap_off))
+ flags |= OCFS_BH_CACHED;
+
+ if (OCFS_NONCACHED(osb, off)) {
+ if (flags & OCFS_BH_CACHED)
+ LOG_TRACE_STR("hey bozo you are trying to write "
+ "a system thingy cached!");
+ flags &= ~OCFS_BH_CACHED;
+ }
+
+ sb = osb->sb;
+ dev = OCFS_GET_BLOCKDEV(sb);
+ blocknum = off >> sb->s_blocksize_bits;
+
+ nr = (len + 511) >> 9;
+ if (nr == 0) {
+ LOG_TRACE_STR("No buffers will be read!!!");
+ LOG_TRACE_ARGS("Len=%llu Off=%llu numbuffers=%u "
+ "blocknum=%llu\n", len, off,
+ nr, blocknum);
+ status = 0;
+ goto bail;
+ }
+
+ for (i = 0 ; i < nr ; i++) {
+ if (bhs[i] == NULL) {
+ bhs[i] = getblk (dev, blocknum++, sb->s_blocksize);
+ if (bhs[i] == NULL) {
+ LOG_TRACE_STR("bh == NULL");
+ status = -EIO;
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+ }
+ bh = bhs[i];
+ ignore_cache = 0;
+
+ /* Lock everyone else out of this bh */
+ OCFS_BH_GET_DATA_READ(bh);
+
+ if (flags & OCFS_BH_CACHED && inode &&
+ !TEST_BH_SEQNUM(inode, bh)) {
+#ifdef VERBOSE_BH_SEQNUM_TRACE
+ LOG_TRACE_ARGS("(read) bh (%lu) seqnum (%lu) does not "
+ "match inode (%u)\n", bh->b_blocknr,
+ (bh->b_state & STATE_BIT_MASK) >> 19,
+ atomic_read(GET_INODE_CLEAN_SEQ(inode)));
+#endif
+ ignore_cache = 1;
+ }
+
+ if ((flags & OCFS_BH_CACHED) && (!buffer_uptodate(bh)))
+ ignore_cache = 1;
+
+ if (buffer_jbd(bh)) {
+#ifdef VERBOSE_BH_JBD_TRACE
+ if (!(flags & OCFS_BH_CACHED) || ignore_cache)
+ LOG_TRACE_ARGS("trying to sync read a jbd "
+ "managed bh (blocknr = %lu)\n",
+ bh->b_blocknr);
+#endif
+ continue;
+ }
+
+ if (!(flags & OCFS_BH_CACHED) || ignore_cache) {
+ if (buffer_dirty(bh)) {
+ /* This should probably be a BUG, or
+ * at least return an error. */
+ LOG_TRACE_ARGS("asking me to sync read a "
+ "dirty buffer! (blocknr = %lu)\n",
+ bh->b_blocknr);
+ continue;
+ }
+
+ lock_buffer(bh);
+ clear_buffer_uptodate(bh);
+ bh->b_end_io = ocfs_end_buffer_io_sync;
+ if (flags & OCFS_BH_READAHEAD)
+ submit_bh(READA, bh);
+ else
+ submit_bh(READ, bh);
+ continue;
+ }
+ }
+
+ status = 0;
+
+ for (i = (nr-1); i >= 0; i--) {
+ bh = bhs[i];
+
+ wait_on_buffer(bh);
+
+ if (inode)
+ SET_BH_SEQNUM(inode, bh);
+ else
+ CLEAR_BH_SEQNUM(bh);
+
+ OCFS_BH_PUT_DATA(bh);
+ }
+ LOG_TRACE_ARGS("off=(%llu), len=(%llu), cached=%s\n", off, len,
+ (!(flags & OCFS_BH_CACHED) || ignore_cache) ? "no" : "yes");
+
+bail:
+
+#ifdef OCFS_DBG_TIMING
+ IO_FUNC_TIMING_PRINT("ocfs_read_bhs", status);
+#endif
+
+ LOG_EXIT_STATUS(status);
+ return status;
+}
+
+
+
Modified: trunk/src/dcache.c
===================================================================
--- trunk/src/dcache.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/dcache.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,8 +26,12 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include <linux/namei.h>
+#endif
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
Modified: trunk/src/dir.c
===================================================================
--- trunk/src/dir.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/dir.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,11 +26,14 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
+#include "inc/ocfs_buffer_head.h"
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_DIR
Modified: trunk/src/dlm.c
===================================================================
--- trunk/src/dlm.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/dlm.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,12 +26,16 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
+#include <linux/random.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
extern __u32 comm_voting;
Modified: trunk/src/extmap.c
===================================================================
--- trunk/src/extmap.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/extmap.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,6 +26,7 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/file.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,12 +26,15 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_FILE
@@ -324,7 +327,7 @@
}
if (ret < 0)
- ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+ ocfs_bh_sem_hash_cleanup_pid(current->pid);
LOG_TRACE_ARGS
("exiting file_open: file=%p dentry=%p inode=%p kiovec=%d\n",
@@ -409,7 +412,7 @@
}
bail:
-// ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+// ocfs_bh_sem_hash_cleanup_pid(current->pid());
LOG_EXIT_INT (0);
return 0;
@@ -866,7 +869,7 @@
#ifndef BH_SEM_LEAK_CHECKING
if (ret < 0)
#endif
- ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+ ocfs_bh_sem_hash_cleanup_pid(current->pid);
LOG_EXIT_INT (ret);
return ret;
@@ -1476,7 +1479,7 @@
#ifndef BH_SEM_LEAK_CHECKING
if (error < 0)
#endif
- ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+ ocfs_bh_sem_hash_cleanup_pid(current->pid);
LOG_EXIT_INT (error);
return error;
Modified: trunk/src/hash.c
===================================================================
--- trunk/src/hash.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/hash.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,11 +26,16 @@
#include "inc/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 "inc/ocfs_log.h"
#include "inc/ocfs.h"
+#include "inc/ocfs_buffer_head.h"
/* Tracing */
Modified: trunk/src/heartbeat.c
===================================================================
--- trunk/src/heartbeat.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/heartbeat.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,12 +26,15 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_HEARTBEAT
@@ -78,7 +81,10 @@
publish->dirty = 0;
}
/* Write the current time in local node's publish sector */
- publish->time = ocfs_get_publish_time();
+ publish->time = jiffies;
+ /* Dissallow 0 */
+ if (!publish->time)
+ publish->time = 1;
publish->hbm[osb->node_num] = osb->hbm;
spin_lock (&OcfsGlobalCtxt.comm_seq_lock);
publish->comm_seq_num = OcfsGlobalCtxt.comm_seq_num;
Deleted: trunk/src/inc/io.h
===================================================================
--- trunk/src/inc/io.h 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/inc/io.h 2004-06-02 16:16:34 UTC (rev 970)
@@ -1,364 +0,0 @@
-/*
- * io.h
- *
- * Buffer cache handling functions defined
- *
- * 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
- */
-
-#ifndef OCFSIO_H
-#define OCFSIO_H
-
-#include <linux/fs.h>
-#include <linux/compiler.h>
-
-/* Yosh made me do it. */
-static inline int ocfs_write_bh (ocfs_super *osb,
- struct buffer_head *bh,
- int flags,
- struct inode *inode);
-static inline int ocfs_read_bh (ocfs_super *osb,
- __u64 off,
- struct buffer_head **bh,
- int flags,
- struct inode *inode);
-
-int ocfs_write_bhs (ocfs_super *osb,
- struct buffer_head *bh[],
- int nr,
- int flags,
- struct inode *inode);
-int ocfs_read_bhs (ocfs_super *osb,
- __u64 off,
- __u64 len,
- struct buffer_head *bhs[],
- int flags,
- struct inode *inode);
-
-
-#define OCFS_BH_CACHED 1
-#define OCFS_BH_COND_CACHED 2
-#define OCFS_BH_CONCURRENT_WRITE 4 /* This should only be used by ocfs_worker */
-#define OCFS_BH_IGNORE_JBD 8 /* This should only be used by ocfs_checkpoint_handle! */
-#define OCFS_BH_READAHEAD 16 /* use this to pass READA down to submit_bh */
-
-
-#define OCFS_NONCACHED(osb,off) ((off) < (osb)->vol_layout.data_start_off)
-
-#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 */
-
-/*
- * Copied right out of the 2.6.2 kernel's buffer_head.h:
- * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
- * and buffer_foo() functions.
- */
-#define BUFFER_FNS(bit, name) \
-static inline void set_buffer_##name(struct buffer_head *bh) \
-{ \
- set_bit(BH_##bit, &(bh)->b_state); \
-} \
-static inline void clear_buffer_##name(struct buffer_head *bh) \
-{ \
- clear_bit(BH_##bit, &(bh)->b_state); \
-} \
-static inline int buffer_##name(struct buffer_head *bh) \
-{ \
- return test_bit(BH_##bit, &(bh)->b_state); \
-}
-
-#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);
-
- 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) {
- 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); \
- 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); \
- 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
- 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
- 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 */
-
-#define STATE_BIT_MAX (1 << STATE_BH_BITS)
-#define STATE_BIT_MAX_MASK ((1 << STATE_BH_BITS)-1)
-#define STATE_BIT_MASK ((~0UL) << USED_BH_BITS)
-
-
-static inline void CLEAR_BH_SEQNUM(struct buffer_head *bh)
-{
- unsigned int prev = bh->b_state & STATE_BIT_MASK;
- bh->b_state &= ~prev;
-}
-
-static inline void SET_BH_SEQNUM(struct inode *inode, struct buffer_head *bh)
-{
- unsigned int seq = (atomic_read(GET_INODE_CLEAN_SEQ(inode)) &
- STATE_BIT_MAX_MASK) << USED_BH_BITS;
-
- CLEAR_BH_SEQNUM(bh);
- bh->b_state |= seq;
-}
-
-static inline int TEST_BH_SEQNUM(struct inode *inode, struct buffer_head *bh)
-{
- int ret;
- unsigned int seq =
- (bh->b_state & STATE_BIT_MASK) >> USED_BH_BITS;
-
- ret = (seq == atomic_read(GET_INODE_CLEAN_SEQ(inode)));
- return ret;
-}
-
-static inline int check_block_zero_write(struct buffer_head *bh)
-{
- if (unlikely(bh->b_blocknr == 0)) {
- ocfs_vol_disk_hdr *hdr = OCFS_BH_GET_DATA_READ(bh);
-
- if (hdr == NULL) {
- printk ("ocfs2: failed to map bh page!!!\n");
- return -EIO;
- }
-
- if (memcmp(hdr->signature,
- OCFS_VOLUME_SIGNATURE,
- strlen(OCFS_VOLUME_SIGNATURE)) != 0) {
- printk("ocfs2: WARNING! attempting to write non "
- "volume header to block 0\n");
- OCFS_BH_PUT_DATA(bh);
- return -EIO;
- }
-
- OCFS_BH_PUT_DATA(bh);
- }
-
- return 0;
-}
-
-#define OCFS_PRINT_FE_SIZE(bh) \
-do { \
- if (bh) { \
- ocfs_file_entry *__fe = bh->b_data; \
- if (IS_VALID_FILE_ENTRY(__fe)) { \
- printk("ocfs2: %s:%d fe_check: file_size = (%llu), " \
- "this_sector = (%llu)\n", \
- __FUNCTION__, __LINE__, \
- __fe->file_size, \
- __fe->this_sector); \
- } \
- } \
-} while(0)
-
-/* check the 1st five bytes. */
-static inline int ocfs_poison(struct buffer_head *bh)
-{
- int i;
- for(i = 0; i < 512; i++)
- if ((bh)->b_data[i] != 'P')
- return(0);
- return(1);
-}
-
-#define OCFS_DO_HEX_DUMP(bh) \
-do { \
- printk("bh->b_blocknr = %lu, bh->b_data:\n", bh->b_blocknr); \
- for(i = 0; i < 512; i++) { \
- printk("%03x ", bh->b_data[i]); \
- if ( ((i+1) % 16) == 0 ) \
- printk("\n"); \
- } \
- printk("\n"); \
-} while (0)
-
-static inline int ocfs_write_bh (ocfs_super * osb, struct buffer_head *bh,
- int flags, struct inode *inode)
-{
- int status;
-
- IO_FUNC_TIMING_DECL
-
- status = ocfs_write_bhs (osb, &bh, 1, flags, inode);
-
- IO_FUNC_TIMING_PRINT("ocfs_write_bh", status);
-
- return status;
-}
-
-static inline int ocfs_read_bh (ocfs_super * osb, __u64 off,
- struct buffer_head **bh, int flags,
- struct inode *inode)
-{
- int status = 0;
-
- IO_FUNC_TIMING_DECL
-
- if (bh == NULL) {
- printk("ocfs2: bh == NULL\n");
- status = -EINVAL;
- goto bail;
- }
-
- status = ocfs_read_bhs(osb, off, 512, bh, flags, inode);
-
-bail:
- IO_FUNC_TIMING_PRINT("ocfs_read_bh", status);
-
- return status;
-}
-
-#endif /* OCFSIO_H */
Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/inc/ocfs.h 2004-06-02 16:16:34 UTC (rev 970)
@@ -32,51 +32,17 @@
*/
#define __KERNEL_SYSCALLS__
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-#else /* 2.4 kernel */
-#include <asm/processor.h>
-#endif /* 2.6 kernel */
-
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/list.h>
-#include <linux/fs.h>
-#include <linux/pagemap.h>
-#include <linux/random.h>
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+#include <linux/list.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/writeback.h>
+# include <linux/workqueue.h>
#else
-#include <linux/locks.h>
+# include <linux/tqueue.h>
#endif
-#include <linux/hdreg.h>
-#include <linux/file.h>
-#include <linux/unistd.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/workqueue.h>
-#else
-#include <linux/tqueue.h>
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/blkdev.h>
-#include <linux/in.h>
-#include <linux/buffer_head.h>
-#include <linux/namei.h>
-#endif
-#include <linux/smp_lock.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-#include <linux/iobuf.h>
-#endif /* for 2.5 - no more kiovec, kiobuf structures - vfs handles
- * this for us (direct i/o) */
-#include <linux/sysctl.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/moduleparam.h>
-#endif
-
-
#define OCFS_BITMAP_CHUNK (512) /* size of a chunk, in bytes */
#define OCFS_BITS_IN_CHUNK (OCFS_BITMAP_CHUNK * 8)
/* Lovely convenience macros. If we move to a scheme where
@@ -159,17 +125,10 @@
#define ocfs_safefree(x) \
do { \
if (x) \
- ocfs_free(x); \
+ kfree(x); \
(x) = NULL; \
} while (0)
-#define ocfs_safevfree(x) \
-do { \
- if (x) \
- vfree(x); \
- (x) = NULL; \
-} while (0)
-
#define OCFS_ASSERT(x) do { if (!(x)) BUG(); } while (0)
@@ -179,11 +138,6 @@
- (((x)>>3)&0x11111111))
-#ifdef USERSPACE_TOOL
-#define list_for_each_safe(pos, n, head) \
- for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next)
-#endif
-
#ifndef list_for_each_prev_safe
#define list_for_each_prev_safe(pos, n, head) \
for (pos = (head)->prev, n = pos->prev; pos != (head); \
@@ -191,28 +145,7 @@
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define OCFS_CURRENT_TIME (CURRENT_TIME.tv_sec)
-#define OCFS_SET_INODE_TIME(i, x, y) (i->x.tv_sec = (y))
-#else
-#define OCFS_CURRENT_TIME (CURRENT_TIME)
-#define OCFS_SET_INODE_TIME(i, x, y) i->x = (y)
-#endif
-static inline __u64 ocfs_get_publish_time(void)
-{
- unsigned long ret = jiffies;
- return (ret != 0 ? ret : 1);
-}
-
-#ifdef __KERNEL__
-#define ocfs_getpid() current->pid
-#else
-#define ocfs_getpid() getpid()
-#endif
-
-
-
#define ONE_MEGA_BYTE (1 * 1024 * 1024) /* in bytes */
#define MISS_COUNT_VALUE 30
@@ -589,55 +522,20 @@
#define TEST_NODE_IN_RECOVERY(osb, num) ((osb->recovery_map) & (0x1 << (num)))
-#if defined(OCFS_LINUX_MEM_DEBUG)
-void *ocfs_linux_dbg_alloc (int Size, char *file, int line);
-void ocfs_linux_dbg_free (const void *Buffer);
-# define ocfs_malloc(_s) \
-({ \
- void *m = ocfs_linux_dbg_alloc(_s, __FILE__, __LINE__); \
- if (debug_level & OCFS_DEBUG_LEVEL_MALLOC) \
- printk("malloc(%s,%d) = %p\n", __FILE__, \
- __LINE__, m); \
- m; \
-})
-
-# define ocfs_free(x)\
-do { \
- if (debug_level & OCFS_DEBUG_LEVEL_MALLOC) \
- printk("free(%s,%d) = %p\n", __FILE__, \
- __LINE__, x); \
- ocfs_linux_dbg_free(x); \
-} while (0)
-
-# define ocfs_vmalloc(size) \
-({ \
- void *p = vmalloc(size); \
- if (!p) \
- printk("ERROR: unable to allocate %u bytes of memory\n", \
- (size)); \
- else \
- memset(p, 0, size); \
- p; \
-})
-# define ocfs_vfree vfree
-#elif !defined(OCFS_LINUX_MEM_DEBUG)
-# define ocfs_malloc(size) \
+#define ocfs_malloc(size) \
({ \
void *__ptr = kmalloc((size_t)(size), GFP_KERNEL); \
if (__ptr) \
memset(__ptr, 0, size); \
__ptr; \
})
-# define ocfs_free kfree
-# define ocfs_vmalloc(size) \
+#define ocfs_vmalloc(size) \
({ \
void *__ptr = vmalloc((size_t)(size)); \
if (__ptr) \
memset(__ptr, 0, size); \
__ptr; \
})
-# define ocfs_vfree vfree
-#endif /* ! defined(OCFS_MEM_DBG) */
@@ -667,43 +565,13 @@
__ret; \
})
-/* sorry about all the macros, but file and line are important */
-
-/* lockres macros */
-#ifdef OCFS_MEM_DBG
-#define ocfs_allocate_extent_entry() (ocfs_extent *)ocfs_dbg_slab_alloc( \
- OcfsGlobalCtxt.extent_cache, \
- __FILE__, __LINE__)
-#define ocfs_free_extent_entry(ext) ocfs_dbg_slab_free( \
- OcfsGlobalCtxt.extent_cache, ext)
-#else /* !OCFS_MEM_DBG */
-
#define ocfs_allocate_extent_entry() (ocfs_extent *)kmem_cache_alloc ( \
OcfsGlobalCtxt.extent_cache, GFP_NOFS)
#define ocfs_free_extent_entry(ext) kmem_cache_free(OcfsGlobalCtxt.extent_cache, ext)
-#endif
-
-/* file entry macros */
-#ifdef OCFS_MEM_DBG
#define ocfs_allocate_file_entry() ((ocfs_file_entry *)({ \
ocfs_file_entry *FileEntry = NULL; \
- FileEntry = ocfs_dbg_slab_alloc (OcfsGlobalCtxt.fe_cache, __FILE__, __LINE__); \
- if (FileEntry != NULL) \
- memset (FileEntry, 0, OCFS_SECTOR_SIZE); \
- FileEntry; }))
-
-#define ocfs_release_file_entry(fe) \
- do { \
- if (fe) { \
- ocfs_dbg_slab_free (OcfsGlobalCtxt.fe_cache, fe); \
- fe = NULL; \
- } \
- } while (0)
-#else /* !OCFS_MEM_DBG */
-#define ocfs_allocate_file_entry() ((ocfs_file_entry *)({ \
- ocfs_file_entry *FileEntry = NULL; \
FileEntry = kmem_cache_alloc (OcfsGlobalCtxt.fe_cache, GFP_NOFS); \
if (FileEntry != NULL) \
memset (FileEntry, 0, OCFS_SECTOR_SIZE); \
@@ -716,7 +584,6 @@
fe = NULL; \
} \
} while (0)
-#endif
#define OCFS_NAME "OCFS"
@@ -735,11 +602,6 @@
})
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,18)
-#define free_kiovec_sz(nr, buf, bh) free_kiovec(nr, buf)
-#define alloc_kiovec_sz(nr, buf, bh) alloc_kiovec(nr, buf)
-#endif
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
typedef struct block_device * ocfs_blockdev;
typedef dev_t ocfs_dev;
@@ -758,11 +620,6 @@
#define getblk(dev, blk, sz) __getblk(dev, blk, sz)
#endif /* >= 2.6.0 */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define OCFS_GENERIC_SB_MEMBER(sb) ((sb)->s_fs_info)
-#else
-#define OCFS_GENERIC_SB_MEMBER(sb) ((sb)->u.generic_sbp)
-#endif
#define OCFS_SB(sb) ((ocfs_super *)OCFS_GENERIC_SB_MEMBER(sb))
@@ -786,6 +643,7 @@
DLOCK_FLAG_LAST_UPDATE)
+#define DISK_LOCK(x) ((ocfs_disk_lock *)(x))
#define DISK_LOCK_CURRENT_MASTER(x) ( ((ocfs_disk_lock *)x)->curr_master )
#define DISK_LOCK_OIN_MAP(x) ( ((ocfs_disk_lock *)x)->oin_node_map )
#define DISK_LOCK_FILE_LOCK(x) ( ((ocfs_disk_lock *)x)->file_lock )
@@ -895,6 +753,7 @@
{
__u32 curr_master; // NODENUM
__u8 file_lock; // LOCKLEVEL
+ __u8 odl_pad[3]; // UNUSED
__u64 last_write_time; // NUMBER RANGE(0,ULONG_LONG_MAX
__u64 last_read_time; // NUMBER RANGE(0,ULONG_LONG_MAX
__u32 writer_node_num; // NODENUM
@@ -903,6 +762,7 @@
__u64 dlock_seq_num; // NUMBER RANGE(0,ULONG_LONG_MAX)
}
ocfs_disk_lock; // END CLASS
+
typedef struct _ocfs_vol_label // CLASS
{
ocfs_disk_lock disk_lock; // DISKLOCK
@@ -1119,9 +979,10 @@
/* is this a system file? */
#define OCFS_INODE_SYSTEM_FILE 0x00000008
+#define OCFS_I(i) ((ocfs_inode_private *)(i->u.generic_ip))
+
#define GET_INODE_CLEAN_SEQ(i) (atomic_t *)(&(OCFS_I(i)->i_clean_buffer_seq))
-#define OCFS_I(i) ((ocfs_inode_private *)(i->u.generic_ip))
#define INODE_DELETED(i) (OCFS_I(i)->flags & OCFS_INODE_DELETED)
#define SET_INODE_DELETED(i) (OCFS_I(i)->flags |= OCFS_INODE_DELETED)
@@ -1138,19 +999,7 @@
#define GET_INODE_FEOFF(i) OCFS_I(i)->feoff
-static inline unsigned long ino_from_fe_off(struct inode *inode)
-{
- return (unsigned long)((GET_INODE_FEOFF(inode) >>
- inode->i_sb->s_blocksize_bits) & (__u64)ULONG_MAX);
-}
-static inline unsigned long ino_from_off(struct super_block *sb, __u64 off)
-{
- return (unsigned long)((off >> sb->s_blocksize_bits) & (__u64)ULONG_MAX);
-}
-
-
-
#warning take this out when all the lockres stuff checks out
#define GET_INODE_LOCKRES(i) ({ if (i==NULL) BUG(); (&(OCFS_I(i)->i_lockres)); })
@@ -1392,9 +1241,6 @@
__u8 hbm;
spinlock_t comm_seq_lock; /* protects comm_seq_num */
__u64 comm_seq_num; /* local node seq num used in ipcdlm */
-#ifdef OCFS_LINUX_MEM_DEBUG
- struct list_head item_list;
-#endif
struct list_head *bh_sem_hash;
spinlock_t bh_sem_hash_lock;
int bh_sem_hash_sz;
@@ -1740,143 +1586,7 @@
}
ocfs_bitmap_free_head;
-static inline ocfs_bitmap_free_head * ocfs_alloc_bitmap_free_head(void)
-{
- struct _ocfs_bitmap_free_head *f;
- f = ocfs_malloc(sizeof(ocfs_bitmap_free_head));
- if (f) {
- f->num_logs = 0;
- f->tail = NULL;
- INIT_LIST_HEAD(&(f->free_logs));
- }
- return(f);
-}
-
-static inline void ocfs_free_bitmap_free_head(ocfs_bitmap_free_head *f)
-{
- ocfs_free_rec *log;
- struct list_head *p, *n;
-
- if ((f) && ((f)->num_logs)) {
- list_for_each_safe(p, n, &((f)->free_logs)) {
- log = list_entry(p, ocfs_free_rec, log_list);
- list_del(&(log->log_list));
- ocfs_free(log);
- }
- }
- ocfs_safefree((f));
- return;
-}
-
-static inline unsigned int ocfs_clusters_for_bytes(struct super_block *sb,
- __u64 bytes)
-{
- int cl_bits = OCFS_SB(sb)->cluster_size_bits;
- unsigned int clusters;
-
- bytes += OCFS_SB(sb)->vol_layout.cluster_size - 1;
- /* OCFS2 just cannot have enough clusters to overflow this */
- clusters = (unsigned int)(bytes >> cl_bits);
-
- return clusters;
-}
-
-static inline __u64 ocfs_align_bytes_to_clusters(struct super_block *sb,
- __u64 bytes)
-{
- int cl_bits = OCFS_SB(sb)->cluster_size_bits;
- unsigned int clusters;
-
- clusters = ocfs_clusters_for_bytes(sb, bytes);
- return (__u64)clusters << cl_bits;
-}
-
-static inline int ocfs_inc_icount(struct inode *inode)
-{
- struct dentry *dentry = NULL;
- struct list_head *iter;
-
- if (atomic_read(&inode->i_count) >= 1 &&
- !(inode->i_state & I_CLEAR)) {
- atomic_inc(&inode->i_count);
- return 0;
- }
-
- list_for_each (iter, &(inode->i_dentry)) {
- dentry = list_entry (iter, struct dentry, d_alias);
- // what the heck, take the first one ;-)
- break;
- }
-
- if (dentry)
- LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
- atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
- dentry->d_name.len, dentry->d_name.name);
- else
- LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
- atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
-
- LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n",
- GET_INODE_FEOFF(inode),
- INODE_DELETED(inode));
- return -EINVAL;
-}
-
-#define ocfs_check_inode(inode) __ocfs_check_inode(inode, __LINE__)
-
-/* call this right before an atomic_dec or iput. */
-static inline void __ocfs_check_inode(struct inode *inode, unsigned int line)
-{
- struct dentry *dentry = NULL;
- struct list_head *iter;
- int max_cnt = 1; /* one for the inode hash */
- ocfs_super *osb = NULL;
- int is_root = 0;
-
- if (!inode)
- return;
-
- osb = OCFS_SB(inode->i_sb);
- if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
- is_root = 1;
-
- if (INODE_DELETED(inode))
- max_cnt--;
-
- list_for_each (iter, &(inode->i_dentry)) {
- dentry = list_entry (iter, struct dentry, d_alias);
- // what the heck, take the first one ;-)
- break;
- }
-
- /* add one for the dentrys ref... */
- if (dentry)
- max_cnt++;
-
- /* +1 for the ref you're about to remove. */
- if (atomic_read(&inode->i_count) >= (max_cnt+1))
- return;
-
-
- LOG_ERROR_ARGS("max_cnt = %d, line = %u, root=%u\n", max_cnt, line,
- is_root);
- if (dentry)
- LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
- atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
- dentry->d_name.len, dentry->d_name.name);
- else
- LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
- atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
-
- LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n",
- GET_INODE_FEOFF(inode),
- INODE_DELETED(inode));
-
- BUG();
-}
-
-
struct ocfs_ioc
{
char name[255]; /* "OCFS" */
@@ -1931,20 +1641,14 @@
[S_IFLNK >> S_SHIFT] OCFS_FT_SYMLINK,
};
-static inline void ocfs_set_de_type(struct super_block *sb, struct ocfs2_dir_entry *de, umode_t mode) {
- de->file_type = ocfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
-}
-
-
typedef struct _ocfs_find_inode_args
{
__u64 feoff;
struct buffer_head *fe_bh;
unsigned long ino;
__u32 flags;
-}
-ocfs_find_inode_args;
+} ocfs_find_inode_args;
#define OCFS_FIND_INODE_FLAG_SYSFILE 0x00000002
@@ -1953,8 +1657,7 @@
struct timer_list timer;
int timed_out;
wait_queue_head_t wait;
-}
-ocfs_timeout;
+} ocfs_timeout;
#define NAMEI_RA_CHUNKS 2
#define NAMEI_RA_BLOCKS 4
@@ -2026,7 +1729,166 @@
__ret; \
})
+static inline unsigned long ino_from_fe_off(struct inode *inode)
+{
+ __u64 block_off = GET_INODE_FEOFF(inode) >> inode->i_sb->s_blocksize_bits;
+ return (unsigned long)(block_off & (__u64)ULONG_MAX);
+}
+
+static inline unsigned long ino_from_off(struct super_block *sb,
+ __u64 off)
+{
+ __u64 block_off = off >> sb->s_blocksize_bits;
+
+ return (unsigned long)(block_off & (__u64)ULONG_MAX);
+}
+
+static inline void ocfs_set_de_type(struct super_block *sb,
+ struct ocfs2_dir_entry *de,
+ umode_t mode)
+{
+ de->file_type = ocfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
+}
+
+static inline ocfs_bitmap_free_head * ocfs_alloc_bitmap_free_head(void)
+{
+ struct _ocfs_bitmap_free_head *f;
+
+ f = ocfs_malloc(sizeof(ocfs_bitmap_free_head));
+ if (f) {
+ f->num_logs = 0;
+ f->tail = NULL;
+ INIT_LIST_HEAD(&(f->free_logs));
+ }
+ return(f);
+}
+
+static inline void ocfs_free_bitmap_free_head(ocfs_bitmap_free_head *f)
+{
+ ocfs_free_rec *log;
+ struct list_head *p, *n;
+
+ if ((f) && ((f)->num_logs)) {
+ list_for_each_safe(p, n, &((f)->free_logs)) {
+ log = list_entry(p, ocfs_free_rec, log_list);
+ list_del(&(log->log_list));
+ kfree(log);
+ }
+ }
+ ocfs_safefree((f));
+ return;
+}
+
+static inline unsigned int ocfs_clusters_for_bytes(struct super_block *sb,
+ __u64 bytes)
+{
+ int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+ unsigned int clusters;
+
+ bytes += OCFS_SB(sb)->vol_layout.cluster_size - 1;
+ /* OCFS2 just cannot have enough clusters to overflow this */
+ clusters = (unsigned int)(bytes >> cl_bits);
+
+ return clusters;
+}
+
+static inline __u64 ocfs_align_bytes_to_clusters(struct super_block *sb,
+ __u64 bytes)
+{
+ int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+ unsigned int clusters;
+
+ clusters = ocfs_clusters_for_bytes(sb, bytes);
+ return (__u64)clusters << cl_bits;
+}
+
+static inline int ocfs_inc_icount(struct inode *inode)
+{
+ struct dentry *dentry = NULL;
+ struct list_head *iter;
+
+ if (atomic_read(&inode->i_count) >= 1 &&
+ !(inode->i_state & I_CLEAR)) {
+ atomic_inc(&inode->i_count);
+ return 0;
+ }
+
+ list_for_each (iter, &(inode->i_dentry)) {
+ dentry = list_entry (iter, struct dentry, d_alias);
+#warning This cant be right in the land of hardlinks, can it?
+ // what the heck, take the first one ;-)
+ break;
+ }
+
+ if (dentry)
+ LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
+ atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
+ dentry->d_name.len, dentry->d_name.name);
+ else
+ LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
+ atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
+
+ LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n",
+ GET_INODE_FEOFF(inode),
+ INODE_DELETED(inode));
+ return -EINVAL;
+}
+
+#define ocfs_check_inode(inode) __ocfs_check_inode(inode, __LINE__)
+
+/* call this right before an atomic_dec or iput. */
+static inline void __ocfs_check_inode(struct inode *inode, unsigned int line)
+{
+ struct dentry *dentry = NULL;
+ struct list_head *iter;
+ int max_cnt = 1; /* one for the inode hash */
+ ocfs_super *osb = NULL;
+ int is_root = 0;
+
+ if (!inode)
+ return;
+
+ osb = OCFS_SB(inode->i_sb);
+ if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
+ is_root = 1;
+
+ if (INODE_DELETED(inode))
+ max_cnt--;
+
+ list_for_each (iter, &(inode->i_dentry)) {
+ dentry = list_entry (iter, struct dentry, d_alias);
+ // what the heck, take the first one ;-)
+ break;
+ }
+
+ /* add one for the dentrys ref... */
+ if (dentry)
+ max_cnt++;
+
+ /* +1 for the ref you're about to remove. */
+ if (atomic_read(&inode->i_count) >= (max_cnt+1))
+ return;
+
+
+ LOG_ERROR_ARGS("max_cnt = %d, line = %u, root=%u\n", max_cnt, line,
+ is_root);
+ if (dentry)
+ LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
+ atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
+ dentry->d_name.len, dentry->d_name.name);
+ else
+ LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
+ atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
+
+ LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n",
+ GET_INODE_FEOFF(inode),
+ INODE_DELETED(inode));
+
+ BUG();
+}
+
+
static inline int ocfs_is_local_cache_lock(ocfs_super *osb, struct inode *inode)
{
ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);
@@ -2070,6 +1932,5 @@
typedef struct _ocfs_journal_handle ocfs_journal_handle;
#include "proto.h"
-#include "io.h"
#endif /* !OCFS_H */
Copied: trunk/src/inc/ocfs_buffer_head.h (from rev 968, trunk/src/inc/io.h)
===================================================================
--- trunk/src/inc/io.h 2004-06-02 01:55:02 UTC (rev 968)
+++ trunk/src/inc/ocfs_buffer_head.h 2004-06-02 16:16:34 UTC (rev 970)
@@ -0,0 +1,370 @@
+/*
+ * ocfs_buffer_head.h
+ *
+ * Buffer cache handling functions defined
+ *
+ * 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
+ */
+
+#ifndef OCFSIO_H
+#define OCFSIO_H
+
+#include <linux/compiler.h>
+
+/* UGLY place to put it, but it is for the best */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+# include <linux/locks.h>
+#else
+# include <linux/buffer_head.h>
+#endif
+
+/* Yosh made me do it. */
+static inline int ocfs_write_bh (ocfs_super *osb,
+ struct buffer_head *bh,
+ int flags,
+ struct inode *inode);
+static inline int ocfs_read_bh (ocfs_super *osb,
+ __u64 off,
+ struct buffer_head **bh,
+ int flags,
+ struct inode *inode);
+
+int ocfs_write_bhs (ocfs_super *osb,
+ struct buffer_head *bh[],
+ int nr,
+ int flags,
+ struct inode *inode);
+int ocfs_read_bhs (ocfs_super *osb,
+ __u64 off,
+ __u64 len,
+ struct buffer_head *bhs[],
+ int flags,
+ struct inode *inode);
+
+
+#define OCFS_BH_CACHED 1
+#define OCFS_BH_COND_CACHED 2
+#define OCFS_BH_CONCURRENT_WRITE 4 /* This should only be used by ocfs_worker */
+#define OCFS_BH_IGNORE_JBD 8 /* This should only be used by ocfs_checkpoint_handle! */
+#define OCFS_BH_READAHEAD 16 /* use this to pass READA down to submit_bh */
+
+
+#define OCFS_NONCACHED(osb,off) ((off) < (osb)->vol_layout.data_start_off)
+
+#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 */
+
+/*
+ * Copied right out of the 2.6.2 kernel's buffer_head.h:
+ * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
+ * and buffer_foo() functions.
+ */
+#define BUFFER_FNS(bit, name) \
+static inline void set_buffer_##name(struct buffer_head *bh) \
+{ \
+ set_bit(BH_##bit, &(bh)->b_state); \
+} \
+static inline void clear_buffer_##name(struct buffer_head *bh) \
+{ \
+ clear_bit(BH_##bit, &(bh)->b_state); \
+} \
+static inline int buffer_##name(struct buffer_head *bh) \
+{ \
+ return test_bit(BH_##bit, &(bh)->b_state); \
+}
+
+#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);
+
+ 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) {
+ 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); \
+ 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); \
+ 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
+ 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
+ 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 */
+
+#define STATE_BIT_MAX (1 << STATE_BH_BITS)
+#define STATE_BIT_MAX_MASK ((1 << STATE_BH_BITS)-1)
+#define STATE_BIT_MASK ((~0UL) << USED_BH_BITS)
+
+
+static inline void CLEAR_BH_SEQNUM(struct buffer_head *bh)
+{
+ unsigned int prev = bh->b_state & STATE_BIT_MASK;
+ bh->b_state &= ~prev;
+}
+
+static inline void SET_BH_SEQNUM(struct inode *inode, struct buffer_head *bh)
+{
+ unsigned int seq = (atomic_read(GET_INODE_CLEAN_SEQ(inode)) &
+ STATE_BIT_MAX_MASK) << USED_BH_BITS;
+
+ CLEAR_BH_SEQNUM(bh);
+ bh->b_state |= seq;
+}
+
+static inline int TEST_BH_SEQNUM(struct inode *inode, struct buffer_head *bh)
+{
+ int ret;
+ unsigned int seq =
+ (bh->b_state & STATE_BIT_MASK) >> USED_BH_BITS;
+
+ ret = (seq == atomic_read(GET_INODE_CLEAN_SEQ(inode)));
+ return ret;
+}
+
+static inline int check_block_zero_write(struct buffer_head *bh)
+{
+ if (unlikely(bh->b_blocknr == 0)) {
+ ocfs_vol_disk_hdr *hdr = OCFS_BH_GET_DATA_READ(bh);
+
+ if (hdr == NULL) {
+ printk ("ocfs2: failed to map bh page!!!\n");
+ return -EIO;
+ }
+
+ if (memcmp(hdr->signature,
+ OCFS_VOLUME_SIGNATURE,
+ strlen(OCFS_VOLUME_SIGNATURE)) != 0) {
+ printk("ocfs2: WARNING! attempting to write non "
+ "volume header to block 0\n");
+ OCFS_BH_PUT_DATA(bh);
+ return -EIO;
+ }
+
+ OCFS_BH_PUT_DATA(bh);
+ }
+
+ return 0;
+}
+
+#define OCFS_PRINT_FE_SIZE(bh) \
+do { \
+ if (bh) { \
+ ocfs_file_entry *__fe = bh->b_data; \
+ if (IS_VALID_FILE_ENTRY(__fe)) { \
+ printk("ocfs2: %s:%d fe_check: file_size = (%llu), " \
+ "this_sector = (%llu)\n", \
+ __FUNCTION__, __LINE__, \
+ __fe->file_size, \
+ __fe->this_sector); \
+ } \
+ } \
+} while(0)
+
+/* check the 1st five bytes. */
+static inline int ocfs_poison(struct buffer_head *bh)
+{
+ int i;
+ for(i = 0; i < 512; i++)
+ if ((bh)->b_data[i] != 'P')
+ return(0);
+ return(1);
+}
+
+#define OCFS_DO_HEX_DUMP(bh) \
+do { \
+ printk("bh->b_blocknr = %lu, bh->b_data:\n", bh->b_blocknr); \
+ for(i = 0; i < 512; i++) { \
+ printk("%03x ", bh->b_data[i]); \
+ if ( ((i+1) % 16) == 0 ) \
+ printk("\n"); \
+ } \
+ printk("\n"); \
+} while (0)
+
+static inline int ocfs_write_bh (ocfs_super * osb, struct buffer_head *bh,
+ int flags, struct inode *inode)
+{
+ int status;
+
+ IO_FUNC_TIMING_DECL
+
+ status = ocfs_write_bhs (osb, &bh, 1, flags, inode);
+
+ IO_FUNC_TIMING_PRINT("ocfs_write_bh", status);
+
+ return status;
+}
+
+static inline int ocfs_read_bh (ocfs_super * osb, __u64 off,
+ struct buffer_head **bh, int flags,
+ struct inode *inode)
+{
+ int status = 0;
+
+ IO_FUNC_TIMING_DECL
+
+ if (bh == NULL) {
+ printk("ocfs2: bh == NULL\n");
+ status = -EINVAL;
+ goto bail;
+ }
+
+ status = ocfs_read_bhs(osb, off, 512, bh, flags, inode);
+
+bail:
+ IO_FUNC_TIMING_PRINT("ocfs_read_bh", status);
+
+ return status;
+}
+
+#endif /* OCFSIO_H */
Modified: trunk/src/inc/ocfs_compat.h
===================================================================
--- trunk/src/inc/ocfs_compat.h 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/inc/ocfs_compat.h 2004-06-02 16:16:34 UTC (rev 970)
@@ -44,7 +44,19 @@
struct mem_dqinfo;
extern inline void mark_info_dirty(struct mem_dqinfo *info);
-#endif /* LINUX_VERSION_CODE */
+#define OCFS_GENERIC_SB_MEMBER(sb) ((sb)->u.generic_sbp)
+#define OCFS_CURRENT_TIME (CURRENT_TIME)
+#define OCFS_SET_INODE_TIME(i, x, y) i->x = (y)
+
+#else /* LINUX_VERSION_CODE < 2.6 */
+
+#define OCFS_GENERIC_SB_MEMBER(sb) ((sb)->s_fs_info)
+
+#define OCFS_CURRENT_TIME (CURRENT_TIME.tv_sec)
+#define OCFS_SET_INODE_TIME(i, x, y) (i->x.tv_sec = (y))
+
+#endif /* LINUX_VERSION_CODE < 2.6 */
+
#endif /* OCFS_COMPAT_H */
Modified: trunk/src/inc/ocfs_journal.h
===================================================================
--- trunk/src/inc/ocfs_journal.h 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/inc/ocfs_journal.h 2004-06-02 16:16:34 UTC (rev 970)
@@ -166,9 +166,9 @@
while (handle->num_co) {
handle->num_co--;
if (handle->co_buffs[handle->num_co].data)
- ocfs_free(handle->co_buffs[handle->num_co].data);
+ kfree(handle->co_buffs[handle->num_co].data);
}
- ocfs_free(handle->co_buffs);
+ kfree(handle->co_buffs);
handle->co_buffs = NULL;
}
Modified: trunk/src/inc/ocfs_log.h
===================================================================
--- trunk/src/inc/ocfs_log.h 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/inc/ocfs_log.h 2004-06-02 16:16:34 UTC (rev 970)
@@ -89,7 +89,7 @@
rdtsc (end.lohi[0], end.lohi[1]); \
IF_LEVEL_NO_CONTEXT(OCFS_DEBUG_LEVEL_TIMING) \
printk("(%d) EXIT : %s() = %d => [%llu]\n", \
- ocfs_getpid(), _fn, _ret, \
+ current->pid, _fn, _ret, \
end.q-begin.q); \
} while(0)
#else
@@ -102,12 +102,12 @@
#define DECL_U8_ARRAY(__t, __s)
#define INIT_U8_ARRAY(__s)
#define PRINT_STRING(__t) printk("\n");
-#define PRINT_ENTRY(__t) printk("(%d) ENTRY: %s", ocfs_getpid (), __FUNCTION__)
+#define PRINT_ENTRY(__t) printk("(%d) ENTRY: %s", current->pid, __FUNCTION__)
#else
#define DECL_U8_ARRAY(__t, __s) __u8 (__t)[(__s)]
#define INIT_U8_ARRAY(__s) *(__s) = '\0'
#define PRINT_STRING(__t) printk("%s\n", (__t))
-#define PRINT_ENTRY(__t) printk("(%d) %sENTRY: %s", ocfs_getpid (), (__t), __FUNCTION__)
+#define PRINT_ENTRY(__t) printk("(%d) %sENTRY: %s", current->pid, (__t), __FUNCTION__)
#endif
@@ -127,9 +127,9 @@
/* privately used macros */
# define IF_LEVEL(level) \
if ((debug_context & OCFS_DEBUG_CONTEXT) && (debug_level & level) && \
- ocfs_getpid()!=debug_exclude)
+ current->pid!=debug_exclude)
# define IF_LEVEL_NO_CONTEXT(level) \
- if ((debug_level & level) && ocfs_getpid()!=debug_exclude)
+ if ((debug_level & level) && current->pid!=debug_exclude)
#ifndef OCFS_DBG_TIMING
# define ENTRY_TIMING_DECLS
@@ -164,7 +164,7 @@
#define IF_LEVEL_PID() \
if ((debug_level & OCFS_DEBUG_LEVEL_PRINTK) && \
- (ocfs_getpid()!=debug_exclude))
+ (current->pid!=debug_exclude))
static inline void eat_value_int(int val)
{
@@ -218,7 +218,7 @@
#define LOG_PID_PRINTK(fmt, arg...) \
do { \
IF_LEVEL_PID() { \
- printk("(%d) %s(): ", ocfs_getpid(), \
+ printk("(%d) %s(): ", current->pid, \
__FUNCTION__); \
printk(fmt, ## arg); \
} \
@@ -259,7 +259,7 @@
INIT_U8_ARRAY(_t); \
GET_TIMING(_t, _HI, _LO); \
printk("(%d) EXIT : %s() %s", \
- ocfs_getpid (), __FUNCTION__, \
+ current->pid, __FUNCTION__, \
(*fmt == '\n' ? "" : "= ")); \
if (*fmt != '\n') \
printk(fmt, ## arg); \
@@ -284,7 +284,7 @@
#define LOG_TRACE_ARGS(fmt, arg...) \
do { \
IF_LEVEL(OCFS_DEBUG_LEVEL_TRACE) { \
- printk("(%d) TRACE: %s() ", ocfs_getpid (), \
+ printk("(%d) TRACE: %s() ", current->pid, \
__FUNCTION__); \
printk(fmt, ## arg); \
} \
@@ -304,7 +304,7 @@
*/
#define LOG_ERROR_ARGS(fmt, arg...) \
do { \
- printk(KERN_ERR "(%d) ERROR at %s, %d: ", ocfs_getpid (), __FILE__, __LINE__); \
+ printk(KERN_ERR "(%d) ERROR at %s, %d: ", current->pid, __FILE__, __LINE__); \
printk(fmt, ## arg); \
} while (0)
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/inode.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,15 +26,29 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
+#include <linux/pagemap.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_INODE
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+# include <linux/iobuf.h>
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,18)
+# define free_kiovec_sz(nr, buf, bh) free_kiovec(nr, buf)
+# define alloc_kiovec_sz(nr, buf, bh) alloc_kiovec(nr, buf)
+# endif
+#endif /* for 2.6 - no more kiovec, kiobuf structures - vfs handles
+ * this for us (direct i/o) */
+
+
extern struct semaphore recovery_list_sem;
static int ocfs_readpage (struct file *file, struct page *page);
Deleted: trunk/src/io.c
===================================================================
--- trunk/src/io.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/io.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -1,343 +0,0 @@
-/*
- * io.c
- *
- * Buffer cache handling
- *
- * 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 "inc/ocfs_compat.h"
-
-#include <linux/types.h>
-#include <linux/slab.h>
-
-#include "inc/ocfs_log.h"
-#include "inc/ocfs.h"
-#include "inc/ocfs_journal.h"
-
-#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_IO
-
-static void ocfs_end_buffer_io_sync(struct buffer_head *bh,
- int uptodate)
-{
-// LOG_ENTRY_ARGS("(bh->b_blocknr = %u, uptodate = %d)\n", bh->b_blocknr,
-// uptodate);
-
- if (!uptodate)
- LOG_ERROR_STATUS(-EIO);
-
- if (uptodate)
- set_buffer_uptodate(bh);
- else
- clear_buffer_uptodate(bh);
- unlock_buffer(bh);
-
-// LOG_EXIT();
- return;
-}
-
-
-int ocfs_write_bhs (ocfs_super * osb, struct buffer_head *bhs[],
- int nr, int flags, struct inode *inode)
-{
- int status = 0;
- int i;
- struct super_block *sb;
- ocfs_blockdev dev;
- struct buffer_head *bh;
-
-#ifdef OCFS_DBG_TIMING
- my_timing_t begin, end;
-#endif
-
- LOG_ENTRY_ARGS("(bh[0]->b_blocknr = %lu, nr=%d, flags=%u, inode=%p)\n",
- bhs[0]->b_blocknr, nr, flags, inode);
-#ifdef OCFS_DBG_TIMING
- rdtsc (begin.lohi[0], begin.lohi[1]);
-#endif
-
- if (osb == NULL || osb->sb == NULL || bhs == NULL) {
- LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == "
- "NULL");
- status = -EINVAL;
- LOG_ERROR_STATUS(status);
- goto bail;
- }
-
- if (nr > 256)
- LOG_TRACE_ARGS ("Getting write for %d blocks\n", nr);
-
- sb = osb->sb;
- dev = OCFS_GET_BLOCKDEV(sb);
-
- /* we don't ever want cached writes -- those should go to the
- * journal so we can control when they actually hit disk and
- * so we can make sure they never get overwritten by a
- * subsequent read. */
- if ((flags & OCFS_BH_CACHED) || (flags & OCFS_BH_COND_CACHED)) {
- LOG_TRACE_STR("asking for a cached write!");
- status = -EINVAL;
- LOG_ERROR_STATUS(status);
- goto bail;
- }
-
- for (i = 0 ; i < nr ; i++) {
- bh = bhs[i];
- if (bh == NULL) {
- LOG_TRACE_STR("bh == NULL");
- status = -EIO;
- LOG_ERROR_STATUS(status);
- goto bail;
- }
-
- if (check_block_zero_write(bh) < 0) {
- status = -EIO;
- LOG_ERROR_STATUS(status);
- goto bail;
- }
-
- 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 = %lu)!\n", 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 = %lu)!\n", 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
- LOG_TRACE_ARGS("trying to write a jbd managed bh "
- "(blocknr = %lu), nr=%d\n",
- bh->b_blocknr, nr);
-#endif
- continue;
- }
-
- lock_buffer(bh);
-
- set_buffer_uptodate(bh);
- /* remove from dirty list before I/O. */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
- /*
- * mark_buffer_clean() doesn't exist in 2.6.x kernels.
- * Not many places actually used mark_buffer_clean, but
- * at least reiserfs uses clear_buffer_dirty() as
- * a replacment.
- */
- clear_buffer_dirty(bh);
-#else
- mark_buffer_clean(bh);
-#endif
-
- bh->b_end_io = ocfs_end_buffer_io_sync;
- submit_bh(WRITE, bh);
- }
-
- for (i = (nr-1) ; i >= 0; i--) {
- bh = bhs[i];
-
- wait_on_buffer(bh);
-
- if (inode)
- 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:
-
-#ifdef OCFS_DBG_TIMING
- IO_FUNC_TIMING_PRINT("ocfs_write_bhs", status);
-#endif
-
- LOG_EXIT_STATUS(status);
- return status;
-}
-
-/*
- * ocfs_read_bhs()
- *
- */
-int ocfs_read_bhs (ocfs_super * osb, __u64 off, __u64 len,
- struct buffer_head *bhs[], int flags,
- struct inode *inode)
-{
- int status = 0;
- struct super_block *sb;
- int nr, i, ignore_cache = 0;
- __u64 blocknum;
- ocfs_blockdev dev;
- struct buffer_head *bh;
-
-#ifdef OCFS_DBG_TIMING
- my_timing_t begin, end;
-#endif
- LOG_ENTRY_ARGS("(off=(%llu), len=(%llu), flags=%d, inode=%p)\n", off,
- len, flags, inode);
-#ifdef OCFS_DBG_TIMING
- rdtsc (begin.lohi[0], begin.lohi[1]);
-#endif
-
- if (len % 512) {
- LOG_TRACE_ARGS("len %% 512 (len=%llu)\n", len);
- status = -EINVAL;
- LOG_ERROR_STATUS(status);
- goto bail;
- }
-
- if (osb == NULL || osb->sb == NULL || bhs == NULL) {
- LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == NULL "
- "|| num == NULL");
- status = -EINVAL;
- LOG_ERROR_STATUS(status);
- goto bail;
- }
-
- if ((flags & OCFS_BH_COND_CACHED) &&
- (off >= osb->vol_layout.bitmap_off))
- flags |= OCFS_BH_CACHED;
-
- if (OCFS_NONCACHED(osb, off)) {
- if (flags & OCFS_BH_CACHED)
- LOG_TRACE_STR("hey bozo you are trying to write "
- "a system thingy cached!");
- flags &= ~OCFS_BH_CACHED;
- }
-
- sb = osb->sb;
- dev = OCFS_GET_BLOCKDEV(sb);
- blocknum = off >> sb->s_blocksize_bits;
-
- nr = (len + 511) >> 9;
- if (nr == 0) {
- LOG_TRACE_STR("No buffers will be read!!!");
- LOG_TRACE_ARGS("Len=%llu Off=%llu numbuffers=%u "
- "blocknum=%llu\n", len, off,
- nr, blocknum);
- status = 0;
- goto bail;
- }
-
- for (i = 0 ; i < nr ; i++) {
- if (bhs[i] == NULL) {
- bhs[i] = getblk (dev, blocknum++, sb->s_blocksize);
- if (bhs[i] == NULL) {
- LOG_TRACE_STR("bh == NULL");
- status = -EIO;
- LOG_ERROR_STATUS(status);
- goto bail;
- }
- }
- bh = bhs[i];
- ignore_cache = 0;
-
- /* Lock everyone else out of this bh */
- OCFS_BH_GET_DATA_READ(bh);
-
- if (flags & OCFS_BH_CACHED && inode &&
- !TEST_BH_SEQNUM(inode, bh)) {
-#ifdef VERBOSE_BH_SEQNUM_TRACE
- LOG_TRACE_ARGS("(read) bh (%lu) seqnum (%lu) does not "
- "match inode (%u)\n", bh->b_blocknr,
- (bh->b_state & STATE_BIT_MASK) >> 19,
- atomic_read(GET_INODE_CLEAN_SEQ(inode)));
-#endif
- ignore_cache = 1;
- }
-
- if ((flags & OCFS_BH_CACHED) && (!buffer_uptodate(bh)))
- ignore_cache = 1;
-
- if (buffer_jbd(bh)) {
-#ifdef VERBOSE_BH_JBD_TRACE
- if (!(flags & OCFS_BH_CACHED) || ignore_cache)
- LOG_TRACE_ARGS("trying to sync read a jbd "
- "managed bh (blocknr = %lu)\n",
- bh->b_blocknr);
-#endif
- continue;
- }
-
- if (!(flags & OCFS_BH_CACHED) || ignore_cache) {
- if (buffer_dirty(bh)) {
- /* This should probably be a BUG, or
- * at least return an error. */
- LOG_TRACE_ARGS("asking me to sync read a "
- "dirty buffer! (blocknr = %lu)\n",
- bh->b_blocknr);
- continue;
- }
-
- lock_buffer(bh);
- clear_buffer_uptodate(bh);
- bh->b_end_io = ocfs_end_buffer_io_sync;
- if (flags & OCFS_BH_READAHEAD)
- submit_bh(READA, bh);
- else
- submit_bh(READ, bh);
- continue;
- }
- }
-
- status = 0;
-
- for (i = (nr-1); i >= 0; i--) {
- bh = bhs[i];
-
- wait_on_buffer(bh);
-
- if (inode)
- SET_BH_SEQNUM(inode, bh);
- else
- CLEAR_BH_SEQNUM(bh);
-
- OCFS_BH_PUT_DATA(bh);
- }
- LOG_TRACE_ARGS("off=(%llu), len=(%llu), cached=%s\n", off, len,
- (!(flags & OCFS_BH_CACHED) || ignore_cache) ? "no" : "yes");
-
-bail:
-
-#ifdef OCFS_DBG_TIMING
- IO_FUNC_TIMING_PRINT("ocfs_read_bhs", status);
-#endif
-
- LOG_EXIT_STATUS(status);
- return status;
-}
-
-
-
Modified: trunk/src/ioctl.c
===================================================================
--- trunk/src/ioctl.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/ioctl.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,6 +26,7 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/journal.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,12 +26,15 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_JOURNAL
@@ -343,7 +346,7 @@
iput(lock->inode);
list_del(&(lock->lock_list));
handle->num_locks--;
- ocfs_free(lock);
+ kfree(lock);
}
LOG_EXIT_STATUS(status);
@@ -501,7 +504,7 @@
/* we don't free the kernel handle because jbd has freed it. */
if (handle->buffs) {
- ocfs_free(handle->buffs);
+ kfree(handle->buffs);
handle->buffs = NULL;
}
@@ -525,7 +528,7 @@
ocfs_free_bitmap_free_head(commit_head);
if (checkpoint)
- ocfs_free(handle);
+ kfree(handle);
LOG_EXIT();
@@ -681,8 +684,8 @@
ocfs_free_bitmap_free_head(handle->commit_bits);
if (handle->buffs)
- ocfs_free(handle->buffs);
- ocfs_free(handle);
+ kfree(handle->buffs);
+ kfree(handle);
LOG_EXIT();
return;
@@ -1079,7 +1082,7 @@
send_sig (SIGINT, osb->commit->c_task, 0);
wait_for_completion(&osb->commit->c_complete);
osb->commit->c_task = NULL;
- ocfs_free(osb->commit);
+ kfree(osb->commit);
}
/* Shutdown the kernel journal system */
@@ -1245,7 +1248,7 @@
for(i = 0; i < totalblks; i++)
if (bhs[i])
brelse(bhs[i]);
- ocfs_free(bhs);
+ kfree(bhs);
}
LOG_EXIT_STATUS(status);
return(status);
@@ -1287,7 +1290,7 @@
LOG_EXIT_STATUS(status);
- ocfs_free(arg);
+ kfree(arg);
return status;
}
@@ -1734,7 +1737,7 @@
if (tmpstat < 0)
LOG_ERROR_STATUS((status = tmpstat));
list_del(&(handle->h_list));
- ocfs_free(handle);
+ kfree(handle);
}
up(&commit->c_lock);
Modified: trunk/src/lockres.c
===================================================================
--- trunk/src/lockres.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/lockres.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,11 +26,14 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
+#include "inc/ocfs_buffer_head.h"
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_LOCKRES
@@ -139,7 +142,7 @@
OCFS_ASSERT(lockres);
- mypid = ocfs_getpid ();
+ mypid = current->pid;
if (timeout)
jif = jiffies + (timeout * HZ / 1000);
Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/namei.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,12 +26,15 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_NAMEI
@@ -298,7 +301,7 @@
#ifndef BH_SEM_LEAK_CHECKING
if (status < 0)
#endif
- ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+ ocfs_bh_sem_hash_cleanup_pid(current->pid);
LOG_EXIT_STATUS(status);
return(status);
@@ -743,7 +746,7 @@
#ifndef BH_SEM_LEAK_CHECKING
if (retval < 0)
#endif
- ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+ ocfs_bh_sem_hash_cleanup_pid(current->pid);
LOG_EXIT_INT (retval);
@@ -1265,7 +1268,7 @@
#ifndef BH_SEM_LEAK_CHECKING
if (status < 0)
#endif
- ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+ ocfs_bh_sem_hash_cleanup_pid(current->pid);
LOG_EXIT_STATUS(status);
return status;
@@ -1412,7 +1415,7 @@
#ifndef BH_SEM_LEAK_CHECKING
if (status < 0)
#endif
- ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
+ ocfs_bh_sem_hash_cleanup_pid(current->pid);
LOG_EXIT_STATUS (status);
return status;
Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/nm.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,14 +26,17 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include <linux/bitops.h>
#include <linux/net.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_NM
@@ -169,7 +172,7 @@
ocfs_process_vote(osb, &(sv->ctxt));
/* we should free this when done. */
- ocfs_free(sv);
+ kfree(sv);
LOG_EXIT();
return;
@@ -231,8 +234,8 @@
/* if no error, then the workqueue should clear it? */
if ((status < 0) && ctxt) {
if (ctxt->u.publish)
- ocfs_free(ctxt->u.publish);
- ocfs_free(ctxt);
+ kfree(ctxt->u.publish);
+ kfree(ctxt);
}
LOG_EXIT_STATUS(status);
@@ -724,7 +727,7 @@
status, &master_alive, inode);
#ifdef VERBOSE_PROCESS_VOTE
- printk("(%u) ocfs_process_vote: %s request for lockid: %llu, action: (%u) %s, type: %s\n", ocfs_getpid(),
+ printk("(%u) ocfs_process_vote: %s request for lockid: %llu, action: (%u) %s, type: %s\n", current->pid,
flags & FLAG_RELEASE_LOCK ? "RELEASE" :
(flags & FLAG_ACQUIRE_LOCK ? "ACQUIRE" : "MODIFY"), lock_id,
vote_type, process_vote_strings[vote_type], disk_vote ? "disk vote" : "net vote" );
@@ -1206,7 +1209,7 @@
}
#ifdef VERBOSE_PROCESS_VOTE
- printk("(%u) vote: lockid=%llu, node=%d, seqnum=%llu, response=%d, open_handle=%s\n",ocfs_getpid(), lock_id, node_num, seq_num, vote_response, open_handle?"yes":"no");
+ printk("(%u) vote: lockid=%llu, node=%d, seqnum=%llu, response=%d, open_handle=%s\n",current->pid, lock_id, node_num, seq_num, vote_response, open_handle?"yes":"no");
#endif
if (status < 0)
Modified: trunk/src/proc.c
===================================================================
--- trunk/src/proc.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/proc.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -28,6 +28,7 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
@@ -51,9 +52,6 @@
static int ocfs_proc_device (char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_nodes (char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_net_vote_obj (char *page, char **start, off_t off, int count, int *eof, void *data);
-#ifdef OCFS_LINUX_MEM_DEBUG
-static int ocfs_proc_memallocs (char *page, char **start, off_t off, int count, int *eof, void *data);
-#endif
static int ocfs_proc_alloc_stat(char *page, char **start, off_t off,
int count, int *eof, void *data);
@@ -75,9 +73,6 @@
{ OCFS2_PROC_BASENAME "/nodename", NULL, ocfs_proc_nodename },
{ OCFS2_PROC_BASENAME "/globalctxt", NULL, ocfs_proc_globalctxt },
{ OCFS2_PROC_BASENAME "/lockstat", NULL, ocfs_proc_dlm_stats },
-#ifdef OCFS_LINUX_MEM_DEBUG
- { OCFS2_PROC_BASENAME "/memallocs", NULL, ocfs_proc_memallocs },
-#endif
{ NULL, }
};
@@ -105,9 +100,6 @@
remove_proc_entry (OCFS2_PROC_BASENAME "/nodename", NULL);
remove_proc_entry (OCFS2_PROC_BASENAME "/globalctxt", NULL);
remove_proc_entry (OCFS2_PROC_BASENAME "/lockstat", NULL);
-#ifdef OCFS_LINUX_MEM_DEBUG
- remove_proc_entry (OCFS2_PROC_BASENAME "/memallocs", NULL);
-#endif
remove_proc_entry (OCFS2_PROC_BASENAME, NULL);
LOG_EXIT ();
@@ -140,89 +132,7 @@
return len;
} /* ocfs_proc_calc_metrics */
-#ifdef OCFS_LINUX_MEM_DEBUG
-/*
- * ocfs_proc_memallocs()
- *
- */
-static int ocfs_proc_memallocs (char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int ret = 0;
- int proc_overflow = 0;
- struct list_head *iter;
- struct list_head *temp_iter;
- alloc_item *item;
- int len = 0;
- char *slabname;
- char *tmpstr = NULL;
- LOG_ENTRY ();
-
-#define MEMDBG_LEN 255
- tmpstr = ocfs_malloc(MEMDBG_LEN);
- if (!tmpstr) {
- LOG_ERROR_STATUS (-ENOMEM);
- goto bail;
- }
-
- sprintf (tmpstr, "%-8s %-9s %s\n", "Pointer", "Size/Slab", "Line:File");
- printk("%s", tmpstr);
- ret = sprintf ((char *) (page + len), "%s", tmpstr);
- len += ret;
-
- list_for_each_safe (iter, temp_iter, &OcfsGlobalCtxt.item_list) {
- if (len >= 4096)
- proc_overflow = 1;
- item = list_entry (iter, alloc_item, list);
- switch (item->type) {
- case SLAB_ITEM:
- if (item->u.slab == OcfsGlobalCtxt.fe_cache)
- slabname = "fe";
- else
- slabname = "unknown";
-
- sprintf(tmpstr, "%08x %9s %-40s\n", item->address,
- slabname, item->tag);
-
- printk("%s", tmpstr);
- if (!proc_overflow) {
- ret = snprintf ((char *) (page + len),
- (4096 - len), "%s", tmpstr);
- len += ret;
- }
- break;
- case KMALLOC_ITEM:
- case VMALLOC_ITEM:
- default:
- sprintf(tmpstr, "%08x %9d %s\n", item->address,
- item->u.length, item->tag);
- printk("%s", tmpstr);
- if (!proc_overflow) {
- ret = snprintf ((char *) (page + len),
- (4096 - len), "%s", tmpstr);
- len += ret;
- }
-
- break;
- }
- if (ret < 0)
- proc_overflow = 1;
- }
-
-
- if (proc_overflow)
- LOG_ERROR_STR ("proc output truncated");
-
- ret = ocfs_proc_calc_metrics (page, start, off, count, eof, len);
-
-bail:
- ocfs_safefree (tmpstr);
- LOG_EXIT_LONG (ret);
- return ret;
-} /* ocfs_proc_memallocs */
-#endif
-
/*
* ocfs_proc_globalctxt()
*
Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/super.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,15 +26,23 @@
#include "inc/ocfs_compat.h"
-#include <linux/utsname.h>
#include <linux/module.h>
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
+#include <linux/utsname.h>
#include <linux/init.h>
+#include <linux/sysctl.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include <linux/statfs.h>
+#include <linux/moduleparam.h>
+#endif
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_SUPER
@@ -484,9 +492,6 @@
memset (&OcfsGlobalCtxt, 0, sizeof (ocfs_global_ctxt));
memset (&OcfsIpcCtxt, 0, sizeof (ocfs_ipc_ctxt));
-#ifdef OCFS_LINUX_MEM_DEBUG
- INIT_LIST_HEAD (&(OcfsGlobalCtxt.item_list));
-#endif
INIT_LIST_HEAD (&(OcfsGlobalCtxt.osb_next));
INIT_LIST_HEAD (&(OcfsGlobalCtxt.osb_next));
@@ -636,49 +641,7 @@
} /* ocfs_read_params */
-#ifdef OCFS_LINUX_MEM_DEBUG
/*
- * ocfs_memcheck()
- *
- */
-static void ocfs_memcheck (void)
-{
- struct list_head *iter;
- struct list_head *temp_iter;
- alloc_item *item;
- char *memtype;
- char sizeinfo[20];
-
- list_for_each_safe (iter, temp_iter, &OcfsGlobalCtxt.item_list) {
- item = list_entry (iter, alloc_item, list);
- switch (item->type)
- {
- case SLAB_ITEM:
- /* TODO: use the actual slab name */
- memtype = "SLAB";
- snprintf(sizeinfo, 20, "slab=%p", item->u.slab);
- break;
- case KMALLOC_ITEM:
- memtype = "KMALLOC";
- snprintf(sizeinfo, 20, "size=%d", item->u.length);
- break;
- case VMALLOC_ITEM:
- memtype = "VMALLOC";
- snprintf(sizeinfo, 20, "size=%d", item->u.length);
- break;
- default:
- memtype = "UNKNOWN";
- snprintf(sizeinfo, 20, "size=%d", item->u.length);
- break;
- }
- LOG_ERROR_ARGS ("unfreed %s mem %x: %s tag='%s'", memtype,
- item->address, sizeinfo, item->tag);
- }
-} /* ocfs_memcheck */
-
-#endif /* OCFS_LINUX_MEM_DEBUG */
-
-/*
* ocfs_driver_exit()
*
* Called on rmmod
@@ -708,10 +671,6 @@
unregister_filesystem (&ocfs_fs_type);
-#ifdef OCFS_LINUX_MEM_DEBUG
- ocfs_memcheck ();
-#endif
-
printk("Unloaded OCFS Driver module\n");
LOG_EXIT ();
return;
@@ -1525,7 +1484,14 @@
}
publish = (ocfs_publish *) OCFS_BH_GET_DATA_WRITE(publish_bh); /* write */
- publish->time = ocfs_get_publish_time();
+ /*
+ * FIXME: This really ought to be something exported by the
+ * identical code in heartbeat.c
+ */
+ publish->time = jiffies;
+ /* Disallow 0 */
+ if (!publish->time)
+ publish->time = 1;
OCFS_BH_PUT_DATA(publish_bh);
publish = NULL;
Modified: trunk/src/symlink.c
===================================================================
--- trunk/src/symlink.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/symlink.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -32,8 +32,10 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/pagemap.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
Modified: trunk/src/sysfile.c
===================================================================
--- trunk/src/sysfile.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/sysfile.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,14 +26,17 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#warning dont vmalloc
#include <linux/vmalloc.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
#include "inc/ocfs_journal.h"
+#include "inc/ocfs_buffer_head.h"
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_SYSFILE
@@ -323,7 +326,7 @@
status = ocfs_read_bhs(osb, actualDiskOffset,
actualLength, bhs, 0, NULL);
if (status < 0) {
- ocfs_free(bhs);
+ kfree(bhs);
LOG_ERROR_STATUS(status);
goto leave;
}
@@ -337,7 +340,7 @@
status = ocfs_write_bhs(osb, bhs, numbhs, 0, NULL);
for(i = 0; i < numbhs; i++)
brelse(bhs[i]);
- ocfs_free(bhs);
+ kfree(bhs);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
Modified: trunk/src/util.c
===================================================================
--- trunk/src/util.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/util.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,7 +26,9 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
+#include <linux/mm.h>
#include <linux/slab.h>
#include "inc/ocfs_log.h"
@@ -118,10 +120,6 @@
return 0;
} /* ocfs_sleep */
-#ifdef OCFS_LINUX_MEM_DEBUG
-#define SUPER_VERBOSE_MEM_DEBUG 1
-#endif
-
/*
* ocfs_dbg_slab_alloc()
*
@@ -130,23 +128,10 @@
{
void *m;
m = kmem_cache_alloc(slab, GFP_NOFS);
-#ifdef OCFS_LINUX_MEM_DEBUG
- if (m == NULL) {
+#if 0 /* FIXME: Should we check? */
+ if (m == NULL)
LOG_ERROR_ARGS("failed to alloc from slab = %p", slab);
- } else {
- alloc_item *new;
- new = kmalloc (sizeof (alloc_item), GFP_NOFS);
- new->type = SLAB_ITEM;
- new->address = m;
- new->u.slab = slab;
- snprintf (new->tag, 30, "%d:%s", line, file);
- new->tag[29] = '\0';
- list_add (&new->list, &OcfsGlobalCtxt.item_list);
-#ifdef SUPER_VERBOSE_MEM_DEBUG
- LOG_TRACE_ARGS (" + %x (%p, '%s')\n", m, slab, new->tag);
#endif
- }
-#endif
return m;
} /* ocfs_dbg_slab_alloc */
@@ -156,105 +141,10 @@
*/
void ocfs_dbg_slab_free (kmem_cache_t *slab, void *m)
{
-
-#ifdef OCFS_LINUX_MEM_DEBUG
- struct list_head *iter, *tmpiter;
- alloc_item *item = NULL;
- int do_free = 0;
-
- list_for_each_safe (iter, tmpiter, &OcfsGlobalCtxt.item_list) {
- item = list_entry (iter, alloc_item, list);
-
- if (item->address == m && item->type == SLAB_ITEM) {
-#ifdef SUPER_VERBOSE_MEM_DEBUG
- LOG_TRACE_ARGS (" - %x (%p, '%s')\n", m, item->u.slab, item->tag);
-#endif
- list_del (&item->list);
- do_free = 1;
- break;
- }
- }
-
- if (do_free) {
- kmem_cache_free(slab, m);
- kfree (item);
- return;
- }
- LOG_ERROR_ARGS ("tried to free mem never allocated: %x", m);
-#endif
-#ifndef OCFS_LINUX_MEM_DEBUG
kmem_cache_free(slab, m);
-#endif
} /* ocfs_dbg_slab_free */
-
-/*
- * ocfs_linux_dbg_alloc()
- *
- */
-void *ocfs_linux_dbg_alloc (int Size, char *file, int line)
-{
- void *m;
-
- m = kmalloc (Size, GFP_NOFS);
-#ifdef OCFS_LINUX_MEM_DEBUG
- if (m == NULL) {
- LOG_ERROR_ARGS ("failed! (size=%d)", Size);
- } else {
- alloc_item *new;
- new = kmalloc (sizeof (alloc_item), GFP_NOFS);
- new->type = KMALLOC_ITEM;
- new->address = m;
- new->u.length = Size;
- snprintf (new->tag, 30, "%d:%s", line, file);
- new->tag[29] = '\0';
- list_add (&new->list, &OcfsGlobalCtxt.item_list);
-#ifdef SUPER_VERBOSE_MEM_DEBUG
- LOG_TRACE_ARGS (" + %x (%d, '%s')\n", m, Size, new->tag);
-#endif
- }
-#endif
- return m;
-} /* ocfs_linux_dbg_alloc */
-
-/*
- * ocfs_linux_dbg_free()
- *
- */
-void ocfs_linux_dbg_free (const void *Buffer)
-{
-
-#ifdef OCFS_LINUX_MEM_DEBUG
- struct list_head *iter, *tmpiter;
- alloc_item *item = NULL;
- int do_free = 0;
-
- list_for_each_safe (iter, tmpiter, &OcfsGlobalCtxt.item_list) {
- item = list_entry (iter, alloc_item, list);
-
- if (item->address == Buffer && item->type == KMALLOC_ITEM) {
-#ifdef SUPER_VERBOSE_MEM_DEBUG
- LOG_TRACE_ARGS (" - %x (%d, '%s')\n", Buffer,
- item->u.length, item->tag);
-#endif
- list_del (&item->list);
- do_free = 1;
- break;
- }
- }
- if (do_free) {
- kfree (Buffer);
- kfree (item);
- return;
- }
- LOG_ERROR_ARGS ("tried to free mem never allocated: %x", Buffer);
-#endif
-#ifndef OCFS_LINUX_MEM_DEBUG
- kfree (Buffer);
-#endif
-} /* ocfs_linux_dbg_free */
-
/* prefetch has been declared to allow to build in debug mode */
#ifdef DEBUG
#ifndef ARCH_HAS_PREFETCH
Modified: trunk/src/ver.c
===================================================================
--- trunk/src/ver.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/ver.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -27,6 +27,7 @@
#include "inc/ocfs_compat.h"
#include <linux/module.h>
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/kernel.h>
Modified: trunk/src/volcfg.c
===================================================================
--- trunk/src/volcfg.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/volcfg.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -26,11 +26,14 @@
#include "inc/ocfs_compat.h"
+#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
+#include <linux/highmem.h>
#include "inc/ocfs_log.h"
#include "inc/ocfs.h"
+#include "inc/ocfs_buffer_head.h"
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_VOLCFG
Modified: trunk/src/vote.c
===================================================================
--- trunk/src/vote.c 2004-06-02 06:07:23 UTC (rev 969)
+++ trunk/src/vote.c 2004-06-02 16:16:34 UTC (rev 970)
@@ -31,9 +31,8 @@
#include <linux/slab.h>
#include <linux/inet.h>
#include <linux/net.h>
+#include <linux/in.h>
-#include <net/sock.h>
-
#include <asm/uaccess.h>
#include "inc/ocfs_log.h"
@@ -793,7 +792,7 @@
obj->seq_num = 0ULL;
obj->req_lock_type = reqlock;
obj->vote_status = 0;
- obj->pid = ocfs_getpid();
+ obj->pid = current->pid;
return obj;
}
More information about the Ocfs2-commits
mailing list