[Ocfs2-commits] manish commits r2284 - in trunk: . fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu May 19 02:00:38 CDT 2005
Author: manish
Signed-off-by: mfasheh
Date: 2005-05-19 02:00:36 -0500 (Thu, 19 May 2005)
New Revision: 2284
Modified:
trunk/README
trunk/fs/ocfs2/journal.c
trunk/fs/ocfs2/ocfs.h
trunk/fs/ocfs2/super.c
Log:
Add barrier support
Signed-off-by: mfasheh
Modified: trunk/README
===================================================================
--- trunk/README 2005-05-19 02:16:54 UTC (rev 2283)
+++ trunk/README 2005-05-19 07:00:36 UTC (rev 2284)
@@ -23,4 +23,9 @@
Mount options
=============
-None that should be manually specified by the user right now.
+
+OCFS2 supports the following mount options:
+(*) == default
+
+barrier=1 This enables/disables barriers. barrier=0 disables it,
+ barrier=1 enables it.
Modified: trunk/fs/ocfs2/journal.c
===================================================================
--- trunk/fs/ocfs2/journal.c 2005-05-19 02:16:54 UTC (rev 2283)
+++ trunk/fs/ocfs2/journal.c 2005-05-19 07:00:36 UTC (rev 2284)
@@ -56,7 +56,7 @@
static int ocfs_recover_node(ocfs_super *osb,
int node_num);
static int __ocfs_recovery_thread(void *arg);
-static int ocfs_commit_cache (ocfs_super * osb);
+static int ocfs_commit_cache(ocfs_super *osb);
static int ocfs_wait_on_mount(ocfs_super *osb);
static void ocfs_handle_cleanup_locks(ocfs_journal *journal,
ocfs_journal_handle *handle,
@@ -78,7 +78,7 @@
int status = 0;
unsigned int flushed;
unsigned long old_id;
- ocfs_journal * journal = NULL;
+ ocfs_journal *journal = NULL;
mlog_entry_void();
@@ -114,13 +114,13 @@
ocfs2_kick_vote_thread(osb);
wake_up(&journal->j_checkpointed);
finally:
- mlog_exit (status);
+ mlog_exit(status);
return status;
} /* ocfs_commit_cache */
-ocfs_journal_handle * ocfs_alloc_handle(ocfs_super *osb)
+ocfs_journal_handle *ocfs_alloc_handle(ocfs_super *osb)
{
- ocfs_journal_handle * retval = NULL;
+ ocfs_journal_handle *retval = NULL;
retval = kmalloc(sizeof(*retval), GFP_KERNEL);
if (!retval) {
@@ -134,8 +134,8 @@
retval->num_locks = 0;
retval->k_handle = NULL;
- INIT_LIST_HEAD(&(retval->locks));
- INIT_LIST_HEAD(&(retval->inode_list));
+ INIT_LIST_HEAD(&retval->locks);
+ INIT_LIST_HEAD(&retval->inode_list);
retval->journal = osb->journal;
return retval;
@@ -144,13 +144,13 @@
/* pass it NULL and it will allocate a new handle object for you. If
* you pass it a handle however, it may still return NULL, in which
* case it has free'd the passed handle for you. */
-ocfs_journal_handle * ocfs_start_trans(ocfs_super *osb,
+ocfs_journal_handle *ocfs_start_trans(ocfs_super *osb,
ocfs_journal_handle *handle,
int max_buffs)
{
- journal_t * journal = osb->journal->j_journal;
+ journal_t *journal = osb->journal->j_journal;
- mlog_entry ("(max_buffs = %d)\n", max_buffs);
+ mlog_entry("(max_buffs = %d)\n", max_buffs);
if (!osb || !osb->journal->j_journal)
BUG();
@@ -260,7 +260,7 @@
/*
* ocfs_commit_trans
*/
-void ocfs_commit_trans(ocfs_journal_handle * handle)
+void ocfs_commit_trans(ocfs_journal_handle *handle)
{
handle_t *jbd_handle;
int retval;
@@ -376,12 +376,12 @@
OCFS_ASSERT(bh);
OCFS_ASSERT((handle->flags & OCFS_HANDLE_STARTED));
- mlog_entry("(bh->b_blocknr=%llu, type=%d (\"%s\"), "
- "bh->b_size = %hu)\n",
- (unsigned long long)bh->b_blocknr, type,
- (type == OCFS_JOURNAL_ACCESS_CREATE) ?
- "OCFS_JOURNAL_ACCESS_CREATE" :
- "OCFS_JOURNAL_ACCESS_WRITE", bh->b_size);
+ mlog_entry("(bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %hu)\n",
+ (unsigned long long)bh->b_blocknr, type,
+ (type == OCFS_JOURNAL_ACCESS_CREATE) ?
+ "OCFS_JOURNAL_ACCESS_CREATE" :
+ "OCFS_JOURNAL_ACCESS_WRITE",
+ bh->b_size);
/* we can safely remove this assertion after testing. */
if (!buffer_uptodate(bh)) {
@@ -411,6 +411,7 @@
if (status < 0)
mlog(ML_ERROR, "Error %d getting %d access to buffer!\n",
status, type);
+
mlog_exit(status);
return status;
} /* ocfs_journal_access */
@@ -427,7 +428,7 @@
OCFS_ASSERT((handle->flags & OCFS_HANDLE_STARTED));
mlog_entry("(bh->b_blocknr=%llu)\n",
- (unsigned long long)bh->b_blocknr);
+ (unsigned long long)bh->b_blocknr);
status = journal_dirty_metadata(handle->k_handle, bh);
if (status < 0)
@@ -447,6 +448,7 @@
ocfs_journal_lock *lock;
OCFS_ASSERT(inode);
+
lock = kmem_cache_alloc(ocfs2_lock_cache, GFP_NOFS);
if (!lock) {
status = -ENOMEM;
@@ -485,8 +487,9 @@
ocfs_set_inode_lock_trans(journal, inode);
ocfs2_meta_unlock(inode, 1);
if (atomic_read(&inode->i_count) == 1)
- mlog(ML_ERROR, "Inode %"MLFu64", I'm doing a last iput "
- "for!", OCFS_I(inode)->ip_blkno);
+ mlog(ML_ERROR,
+ "Inode %"MLFu64", I'm doing a last iput for!",
+ OCFS_I(inode)->ip_blkno);
iput(inode);
kmem_cache_free(ocfs2_lock_cache, lock);
}
@@ -501,7 +504,7 @@
{
int status = -1;
struct inode *inode = NULL; /* the journal inode */
- journal_t * j_journal = NULL;
+ journal_t *j_journal = NULL;
ocfs2_dinode *fe = NULL;
struct buffer_head *bh = NULL;
ocfs_super *osb;
@@ -520,9 +523,9 @@
mlog_errno(status);
goto done;
}
- if (is_bad_inode (inode)) {
+ if (is_bad_inode(inode)) {
mlog(ML_ERROR, "access error (bad inode)\n");
- iput (inode);
+ iput(inode);
inode = NULL;
status = -EACCES;
goto done;
@@ -536,7 +539,7 @@
mlog(ML_ERROR, "Could not get lock on journal!\n");
goto done;
}
- fe = (ocfs2_dinode *) bh->b_data;
+ fe = (ocfs2_dinode *)bh->b_data;
if (fe->i_size < OCFS2_MIN_JOURNAL_SIZE) {
mlog(ML_ERROR, "Journal file size (%"MLFu64") is too small!",
@@ -554,8 +557,8 @@
mlog(ML_ERROR, "inode and fe alloc sizes differ! (%u != %u",
OCFS_I(inode)->ip_clusters, fe->i_clusters);
if (inode->i_size != fe->i_size)
- mlog(ML_ERROR, "inode and fe i_size's differ! "
- "(%lld != %"MLFu64")",
+ mlog(ML_ERROR,
+ "inode and fe i_size's differ! (%lld != %"MLFu64")",
inode->i_size, fe->i_size);
OCFS_I(inode)->ip_open_cnt++;
@@ -572,6 +575,13 @@
mlog(0, "j_journal->j_maxlen = %u\n", j_journal->j_maxlen);
j_journal->j_commit_interval = OCFS_DEFAULT_COMMIT_INTERVAL;
+ spin_lock(&j_journal->j_state_lock);
+ if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER)
+ j_journal->j_flags |= JFS_BARRIER;
+ else
+ j_journal->j_flags &= ~JFS_BARRIER;
+ spin_unlock(&j_journal->j_state_lock);
+
*dirty = (le32_to_cpu(fe->id1.journal1.ij_flags) &
OCFS2_JOURNAL_DIRTY_FL);
@@ -602,13 +612,13 @@
{
int status;
unsigned int flags;
- ocfs_journal * journal = osb->journal;
+ ocfs_journal *journal = osb->journal;
struct buffer_head *bh = journal->j_bh;
ocfs2_dinode *fe;
mlog_entry_void();
- fe = (ocfs2_dinode *) bh->b_data;
+ fe = (ocfs2_dinode *)bh->b_data;
OCFS2_BUG_ON_INVALID_DINODE(fe);
flags = le32_to_cpu(fe->id1.journal1.ij_flags);
@@ -631,9 +641,9 @@
*/
void ocfs_journal_shutdown(ocfs_super *osb)
{
- ocfs_journal * journal = NULL;
+ ocfs_journal *journal = NULL;
int status = 0;
- struct inode * inode = NULL;
+ struct inode *inode = NULL;
int num_running_trans = 0;
mlog_entry_void();
@@ -656,8 +666,9 @@
num_running_trans = atomic_read(&(osb->journal->j_num_trans));
if (num_running_trans > 0)
- mlog(0, "Shutting down journal: must wait on %d"
- " running transactions!\n", num_running_trans);
+ mlog(0, "Shutting down journal: must wait on %d "
+ "running transactions!\n",
+ num_running_trans);
/* Do a commit_cache here. It will flush our journal, *and*
* release any locks that are still held.
@@ -689,7 +700,7 @@
/* unlock our journal */
ocfs2_meta_unlock(inode, 1);
- brelse (journal->j_bh);
+ brelse(journal->j_bh);
journal->j_bh = NULL;
journal->j_state = OCFS_JOURNAL_FREE;
@@ -734,7 +745,7 @@
}
/* Launch the commit thread */
- osb->commit_task = kthread_run(ocfs_commit_thread, osb, "ocfs2cmt-%d",
+ osb->commit_task =kthread_run(ocfs_commit_thread, osb, "ocfs2cmt-%d",
osb->osb_id);
if (IS_ERR(osb->commit_task)) {
status = PTR_ERR(osb->commit_task);
@@ -1006,9 +1017,10 @@
status = ocfs_recover_node(osb, node_num);
if (status < 0) {
- mlog(ML_ERROR, "Error %d recovering node %d on device "
- "(%u,%u)!\n", status, node_num,
- MAJOR(osb->sb->s_dev),MINOR(osb->sb->s_dev));
+ mlog(ML_ERROR,
+ "Error %d recovering node %d on device (%u,%u)!\n",
+ status, node_num,
+ MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
mlog(ML_ERROR, "Volume requires unmount.\n");
continue;
}
@@ -1047,7 +1059,7 @@
void ocfs_recovery_thread(ocfs_super *osb, int node_num)
{
mlog_entry("(node_num=%d, osb->node_num = %d)\n",
- node_num, osb->node_num);
+ node_num, osb->node_num);
down(&osb->recovery_lock);
if (osb->disable_recovery)
@@ -1096,9 +1108,9 @@
mlog_errno(status);
goto done;
}
- if (is_bad_inode (inode)) {
+ if (is_bad_inode(inode)) {
status = -EACCES;
- iput (inode);
+ iput(inode);
inode = NULL;
mlog_errno(status);
goto done;
@@ -1125,8 +1137,8 @@
}
mlog(ML_NOTICE, "Recovering node %d from slot %d on device (%u,%u)\n",
- node_num, slot_num, MAJOR(osb->sb->s_dev),
- MINOR(osb->sb->s_dev));
+ node_num, slot_num,
+ MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
OCFS_I(inode)->ip_clusters = fe->i_clusters;
@@ -1213,7 +1225,7 @@
ocfs2_dinode *tl_copy = NULL;
mlog_entry("(node_num=%d, osb->node_num = %d)\n",
- node_num, osb->node_num);
+ node_num, osb->node_num);
mlog(0, "checking node %d\n", node_num);
@@ -1285,9 +1297,9 @@
status = -EACCES;
goto bail;
}
- if (is_bad_inode (inode)) {
+ if (is_bad_inode(inode)) {
mlog(ML_ERROR, "access error (bad inode)\n");
- iput (inode);
+ iput(inode);
inode = NULL;
status = -EACCES;
goto bail;
@@ -1414,7 +1426,7 @@
up(&orphan_dir_inode->i_sem);
status = -EINVAL;
mlog_errno(status);
- brelse (bh);
+ brelse(bh);
goto bail;
}
@@ -1425,11 +1437,12 @@
if (!le64_to_cpu(de->inode))
continue;
if (de->file_type > OCFS2_FT_MAX) {
- mlog(ML_ERROR, "block %llu contains invalid "
- "de: inode = %"MLFu64", rec_len = %u, "
+ mlog(ML_ERROR,
+ "block %llu contains invalid de: "
+ "inode = %"MLFu64", rec_len = %u, "
"name_len = %u, file_type = %u, "
"name='%.*s'\n",
- (unsigned long long) bh->b_blocknr,
+ (unsigned long long)bh->b_blocknr,
le64_to_cpu(de->inode),
le16_to_cpu(de->rec_len),
de->name_len,
@@ -1529,8 +1542,9 @@
mlog_errno(status);
if (kthread_should_stop() && atomic_read(&journal->j_num_trans)){
- mlog(ML_KTHREAD, "commit_thread: %u transactions "
- "pending on shutdown\n",
+ mlog(ML_KTHREAD,
+ "commit_thread: %u transactions pending on "
+ "shutdown\n",
atomic_read(&journal->j_num_trans));
}
}
Modified: trunk/fs/ocfs2/ocfs.h
===================================================================
--- trunk/fs/ocfs2/ocfs.h 2005-05-19 02:16:54 UTC (rev 2283)
+++ trunk/fs/ocfs2/ocfs.h 2005-05-19 07:00:36 UTC (rev 2284)
@@ -292,6 +292,12 @@
OCFS2_LA_DISABLED
};
+enum ocfs2_mount_options
+{
+ OCFS2_MOUNT_HB_OK = 1 << 0, /* Heartbeat started */
+ OCFS2_MOUNT_BARRIER = 1 << 1 /* Use block barriers */
+};
+
struct _ocfs_journal;
struct _ocfs2_slot_info;
@@ -334,6 +340,8 @@
spinlock_t s_next_gen_lock;
u32 s_next_generation;
+ unsigned long s_mount_opt;
+
u16 max_nodes;
u16 num_nodes;
s16 node_num;
Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c 2005-05-19 02:16:54 UTC (rev 2283)
+++ trunk/fs/ocfs2/super.c 2005-05-19 07:00:36 UTC (rev 2284)
@@ -36,6 +36,7 @@
#include <linux/blkdev.h>
#include <linux/socket.h>
#include <linux/inet.h>
+#include <linux/parser.h>
#include <cluster/nodemanager.h>
@@ -78,8 +79,9 @@
MODULE_AUTHOR("Oracle");
MODULE_LICENSE("GPL");
+static int ocfs2_parse_options(char *options, unsigned long *mount_opt);
static void ocfs_put_super(struct super_block *sb);
-static int ocfs_mount_volume(struct super_block *sb);
+static int ocfs_mount_volume(struct super_block *sb, unsigned long mount_opt);
static void ocfs_dismount_volume(struct super_block *sb, int mnt_err);
static int ocfs_initialize_mem_caches(void);
static void ocfs_free_mem_caches(void);
@@ -117,6 +119,18 @@
.get_parent = ocfs_get_parent,
};
+enum {
+ Opt_hbok,
+ Opt_barrier,
+ Opt_err,
+};
+
+static match_table_t tokens = {
+ {Opt_hbok, OCFS2_HB_OK},
+ {Opt_barrier, "barrier=%u"},
+ {Opt_err, NULL}
+};
+
/*
* write_super and sync_fs ripped right out of ext3.
*/
@@ -292,6 +306,7 @@
int status;
struct inode *inode = NULL;
ocfs_super *osb = NULL;
+ unsigned long mount_opt = 0;
mlog_entry("%p, %p, %i", sb, data, silent);
@@ -302,21 +317,25 @@
goto read_super_error;
}
- /* Stopgap check to ensure that mount.ocfs2 mounted the volume */
- if (!data || strcmp(data, OCFS2_HB_OK)) {
+ if (!ocfs2_parse_options(data, &mount_opt)) {
status = -EINVAL;
- if (data)
- mlog(ML_ERROR, "Invalid options: %s\n", (char *)data);
goto read_super_error;
}
+ /* Stopgap check to ensure that mount.ocfs2 mounted the volume */
+ if (!(mount_opt & OCFS2_MOUNT_HB_OK)) {
+ mlog(ML_ERROR, "No heartbeat for device (%s)\n", sb->s_id);
+ status = -EINVAL;
+ goto read_super_error;
+ }
+
sb->s_magic = OCFS2_SUPER_MAGIC;
sb->s_op = &ocfs_sops;
sb->s_export_op = &ocfs_export_ops;
sb->s_flags |= MS_NOATIME;
sb->s_fs_info = NULL;
- status = ocfs_mount_volume(sb);
+ status = ocfs_mount_volume(sb, mount_opt);
/* ocfs_mount_volume may set osb even on error so we want to
* pull it off for proper cleanup. */
osb = OCFS2_SB(sb);
@@ -392,6 +411,56 @@
.next = NULL
};
+static int ocfs2_parse_options(char *options, unsigned long *mount_opt)
+{
+ int status;
+ char *p;
+
+ mlog_entry("options: \"%s\"\n", options ? options : "(none)");
+
+ if (!options) {
+ status = 1;
+ goto bail;
+ }
+
+ while ((p = strsep(&options, ",")) != NULL) {
+ int token, option;
+ substring_t args[MAX_OPT_ARGS];
+
+ if (!*p)
+ continue;
+
+ token = match_token(p, tokens, args);
+ switch (token) {
+ case Opt_hbok:
+ *mount_opt |= OCFS2_MOUNT_HB_OK;
+ break;
+ case Opt_barrier:
+ if (match_int(&args[0], &option)) {
+ status = 0;
+ goto bail;
+ }
+ if (option)
+ *mount_opt |= OCFS2_MOUNT_BARRIER;
+ else
+ *mount_opt &= ~OCFS2_MOUNT_BARRIER;
+ break;
+ default:
+ mlog(ML_ERROR,
+ "Unrecognized mount option \"%s\" "
+ "or missing value\n", p);
+ status = 0;
+ goto bail;
+ }
+ }
+
+ status = 1;
+
+bail:
+ mlog_exit(status);
+ return status;
+}
+
static int __init ocfs2_init(void)
{
int status;
@@ -688,7 +757,7 @@
* ocfs_mount_volume()
*
*/
-static int ocfs_mount_volume(struct super_block *sb)
+static int ocfs_mount_volume(struct super_block *sb, unsigned long mount_opt)
{
int status, sector_size;
int unlock_super = 0;
@@ -714,6 +783,8 @@
sb->s_fs_info = osb;
osb->sb = sb;
+ osb->s_mount_opt = mount_opt;
+
/* Save off for ocfs_rw_direct */
osb->s_sectsize_bits = blksize_bits(sector_size);
if (!osb->s_sectsize_bits)
More information about the Ocfs2-commits
mailing list