[Ocfs2-commits] khackel commits r1207 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Jun 23 21:25:45 CDT 2004
Author: khackel
Date: 2004-06-23 20:25:44 -0500 (Wed, 23 Jun 2004)
New Revision: 1207
Modified:
trunk/src/heartbeat.c
trunk/src/inode.c
trunk/src/inode.h
trunk/src/namei.c
trunk/src/ocfs.h
trunk/src/util.c
trunk/src/util.h
Log:
* made node ejection due to heartbeat timeout a 3 stage thing with a few warnings
* added in a better ocfs_wait that is not a macro
* take a return value from possible errors in ocfs_populate_inode and sanely handle
making bad inodes and returning these up the call stack
Modified: trunk/src/heartbeat.c
===================================================================
--- trunk/src/heartbeat.c 2004-06-24 01:10:55 UTC (rev 1206)
+++ trunk/src/heartbeat.c 2004-06-24 01:25:44 UTC (rev 1207)
@@ -178,22 +178,32 @@
/* and memory timestamp values */
if (node_map[i].time == publish->time) {
if (ocfs_node_is_alive(&osb->publ_map, i)) {
+ char *err_msg = NULL;
if (atomic_read (&(node_map[i].dismount))) {
- node_map[i].miss_cnt = MISS_COUNT_VALUE;
+ node_map[i].miss_cnt = MISS_COUNT_NODE_DEAD;
atomic_set (&(node_map[i].dismount), 0);
ocfs_publish_map_clear(&osb->publ_map, i);
- } else
+ err_msg = "Received dismount message. Removing %s "
+ "(node %d) from clustered device (%u,%u).\n";
+ } else {
(node_map[i].miss_cnt)++;
- if (node_map[i].miss_cnt > MISS_COUNT_VALUE) {
-#if !defined(USERSPACE_TOOL)
- printk ("ocfs2: Removing %s (node %d) "
- "from clustered device (%u,%u)\n",
- osb->node_cfg_info[i]->node_name, i,
- MAJOR(osb->sb->s_dev),
- MINOR(osb->sb->s_dev));
-#endif
+ if (node_map[i].miss_cnt == MISS_COUNT_WARNING)
+ err_msg = "warning: %s (node %d) may be ejected from cluster "
+ "on device (%u.%u)... %d misses so far\n";
+ else if (node_map[i].miss_cnt == MISS_COUNT_EMERGENCY)
+ err_msg = "warning: %s (node %d) WILL BE EJECTED from cluster "
+ "on device (%u.%u)... %d misses so far\n";
+ else if (node_map[i].miss_cnt >= MISS_COUNT_NODE_DEAD)
+ err_msg = "Removing %s (node %d) from clustered device "
+ "(%u,%u) after %d misses\n";
+ }
+ if (err_msg)
+ LOG_ERROR_ARGS(err_msg, osb->node_cfg_info[i]->node_name, i,
+ MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev),
+ node_map[i].miss_cnt);
+ if (node_map[i].miss_cnt >= MISS_COUNT_NODE_DEAD) {
ocfs_recovery_map_set(osb, i);
ocfs_publish_map_clear(&osb->publ_map, i);
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-06-24 01:10:55 UTC (rev 1206)
+++ trunk/src/inode.c 2004-06-24 01:25:44 UTC (rev 1207)
@@ -85,7 +85,7 @@
static int ocfs_get_block (struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create);
static int ocfs_symlink_get_block (struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create);
-static void ocfs_read_locked_inode(struct inode *inode, ocfs_find_inode_args *args);
+static int ocfs_read_locked_inode(struct inode *inode, ocfs_find_inode_args *args);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
static sector_t ocfs_bmap(struct address_space *mapping, sector_t block);
static int ocfs_writepage (struct page *page, struct writeback_control *wbc);
@@ -174,12 +174,16 @@
if (inode->i_state & I_NEW) {
LOG_TRACE_STR("Inode was not in inode cache, reading "
"it.");
- ocfs_read_locked_inode(inode, &args);
- unlock_new_inode(inode);
+ if (ocfs_read_locked_inode(inode, &args) < 0) {
+ LOG_ERROR_ARGS("bad inode: i_ino=%lu\n", inode->i_ino);
+ make_bad_inode(inode);
+ iput(inode);
+ inode = NULL;
+ } else
+ unlock_new_inode(inode);
}
#endif
}
-
LOG_EXIT_PTR(inode);
return(inode);
@@ -275,7 +279,10 @@
void ocfs_read_inode2(struct inode *inode, void *opaque)
{
LOG_SET_CONTEXT(READ_INODE2);
- ocfs_read_locked_inode(inode, opaque);
+ if (ocfs_read_locked_inode(inode, opaque) < 0) {
+ LOG_ERROR_ARGS("bad inode: i_ino=%lu\n", inode->i_ino);
+ make_bad_inode(inode);
+ }
LOG_CLEAR_CONTEXT();
}
@@ -335,11 +342,12 @@
* ocfs_populate_inode()
*
*/
-void ocfs_populate_inode(struct inode *inode, ocfs2_dinode *fe,
+int ocfs_populate_inode(struct inode *inode, ocfs2_dinode *fe,
int create_ino)
{
struct super_block *sb;
ocfs_super *osb;
+ int status = -EINVAL;
LOG_ENTRY_ARGS ("(0x%p, size:%llu)\n", inode, fe->i_size);
@@ -349,8 +357,9 @@
// this means that read_inode cannot create a superblock
// inode today. change if needed.
if (!IS_VALID_FILE_ENTRY(fe)) {
- printk("ocfs2: invalid file entry!\n");
- BUG();
+ LOG_ERROR_ARGS("invalid file entry! i_ino=%lu, fe->i_blkno=%llu\n",
+ inode->i_ino, fe->i_blkno);
+ goto bail;
}
if (!inode->u.generic_ip && ocfs_inode_init_private(inode)) {
@@ -441,12 +450,13 @@
break;
}
+ status = 0;
bail:
- LOG_EXIT ();
- return;
+ LOG_EXIT_STATUS (status);
+ return status;
} /* ocfs_populate_inode */
-static void ocfs_read_locked_inode(struct inode *inode, ocfs_find_inode_args *args)
+static int ocfs_read_locked_inode(struct inode *inode, ocfs_find_inode_args *args)
{
struct super_block *sb;
ocfs_super *osb;
@@ -457,6 +467,7 @@
LOG_ENTRY_ARGS ("(0x%p, 0x%p)\n", inode, args);
+ status = -EINVAL;
if (inode == NULL || inode->i_sb == NULL) {
LOG_ERROR_STR ("bad inode");
goto bail;
@@ -487,7 +498,13 @@
if (S_ISCHR(fe->i_mode) || S_ISBLK(fe->i_mode))
inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
- ocfs_populate_inode(inode, fe, 0);
+ status = -EINVAL;
+ if (ocfs_populate_inode (inode, fe, 0) < 0) {
+ LOG_ERROR_ARGS("populate inode failed! i_blkno=%llu, i_ino=%lu\n",
+ fe->i_blkno, inode->i_ino);
+ make_bad_inode (inode);
+ goto bail;
+ }
/* eventually this case has to GO!
* -- is this comment valid anymore? -- joel */
@@ -498,13 +515,14 @@
OCFS_SET_FLAG(OCFS_I(inode)->ip_flags, OCFS_INODE_SYSTEM_FILE);
ocfs_init_lockres (osb, inode);
+ status = 0;
bail:
if (args && bh)
brelse(bh);
- LOG_EXIT ();
- return;
+ LOG_EXIT_STATUS (status);
+ return status;
}
/*
Modified: trunk/src/inode.h
===================================================================
--- trunk/src/inode.h 2004-06-24 01:10:55 UTC (rev 1206)
+++ trunk/src/inode.h 2004-06-24 01:25:44 UTC (rev 1207)
@@ -37,7 +37,7 @@
struct inode *ocfs_iget(ocfs_super *osb, __u64 feoff);
int ocfs_inode_init_private(struct inode *inode);
int ocfs_inode_revalidate(struct dentry *dentry);
-void ocfs_populate_inode(struct inode *inode, ocfs2_dinode *fe,
+int ocfs_populate_inode(struct inode *inode, ocfs2_dinode *fe,
int create_ino);
void ocfs_put_inode(struct inode *inode);
void ocfs_read_inode(struct inode *inode);
Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c 2004-06-24 01:10:55 UTC (rev 1206)
+++ trunk/src/namei.c 2004-06-24 01:25:44 UTC (rev 1207)
@@ -253,7 +253,11 @@
fe = (ocfs2_dinode *)new_fe_bh->b_data;
- ocfs_populate_inode(inode, fe, 1);
+ if (ocfs_populate_inode(inode, fe, 1) < 0) {
+ LOG_ERROR_ARGS("populate inode failed! bh->b_blocknr=%lu, i_blkno=%llu, i_ino=%lu\n",
+ new_fe_bh->b_blocknr, fe->i_blkno, inode->i_ino);
+ BUG();
+ }
file_off = fe->i_blkno << dir->i_sb->s_blocksize_bits;
handle->new_file_lockid = file_off;
@@ -1561,8 +1565,13 @@
}
fe = (ocfs2_dinode *) new_fe_bh->b_data;
+
+ if (ocfs_populate_inode (inode, fe, 1) < 0) {
+ LOG_ERROR_ARGS("populate inode failed! bh->b_blocknr=%lu, i_blkno=%llu, i_ino=%lu\n",
+ new_fe_bh->b_blocknr, fe->i_blkno, inode->i_ino);
+ BUG();
+ }
- ocfs_populate_inode(inode, fe, 1);
ocfs_init_lockres(osb, inode);
status = ocfs_extend_file(osb, newsize, handle, inode, NULL, 0,
@@ -1576,7 +1585,6 @@
goto abort_trans;
}
inode->i_rdev = OCFS_NODEV;
-
inode->i_size = newsize;
inode->i_blocks = (newsize + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
Modified: trunk/src/ocfs.h
===================================================================
--- trunk/src/ocfs.h 2004-06-24 01:10:55 UTC (rev 1206)
+++ trunk/src/ocfs.h 2004-06-24 01:25:44 UTC (rev 1207)
@@ -111,7 +111,9 @@
#define OCFS_SET_INODE_TIME(i, x, y) (ocfs_get_seconds(i->x) = (y))
-#define MISS_COUNT_VALUE 30
+#define MISS_COUNT_WARNING 30
+#define MISS_COUNT_EMERGENCY 200
+#define MISS_COUNT_NODE_DEAD 300
/*
** The following flag values reflect the operation to be performed
@@ -968,8 +970,18 @@
__ret; \
})
+#include "util.h"
+/* exits when var == val, or on timeout */
+static inline int ocfs_wait_atomic_eq(wait_queue_head_t *wq, atomic_t *var, int val, int timeout)
+{
+ int ret = 0;
+ if (atomic_read(var) != val)
+ ret = __ocfs_wait_atomic_eq(wq, var, val, timeout);
+ return ret;
+}
+
static inline unsigned long ino_from_blkno(struct super_block *sb,
u64 blkno)
{
Modified: trunk/src/util.c
===================================================================
--- trunk/src/util.c 2004-06-24 01:10:55 UTC (rev 1206)
+++ trunk/src/util.c 2004-06-24 01:25:44 UTC (rev 1207)
@@ -266,3 +266,47 @@
}
+
+int __ocfs_wait_atomic_eq(wait_queue_head_t *wq, atomic_t *var, int val, int ms)
+{
+ int ret;
+ ocfs_timeout timeout;
+ DECLARE_WAITQUEUE(wait, current);
+ DECLARE_WAITQUEUE(to_wait, current);
+
+ ocfs_init_timeout(&timeout);
+
+ if (ms) {
+ ocfs_set_timeout(&timeout, ms);
+ if (timeout.timed_out) {
+ ocfs_clear_timeout(&timeout);
+ }
+ }
+ add_wait_queue(wq, &wait);
+ add_wait_queue(&timeout.wait, &to_wait);
+ do {
+ ret = 0;
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (atomic_read(var)==val)
+ break;
+ ret = -ETIMEDOUT;
+ if (timeout.timed_out)
+ break;
+ schedule();
+ if (signal_pending(current)) {
+ ret = -EINTR;
+ break;
+ }
+ } while (1);
+
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(wq, &wait);
+ remove_wait_queue(&timeout.wait, &to_wait);
+
+ if (ms)
+ ocfs_clear_timeout(&timeout);
+
+ return ret;
+}
+
+
Modified: trunk/src/util.h
===================================================================
--- trunk/src/util.h 2004-06-24 01:10:55 UTC (rev 1206)
+++ trunk/src/util.h 2004-06-24 01:25:44 UTC (rev 1207)
@@ -38,5 +38,6 @@
void ocfs_show_trace(unsigned long *stack);
int ocfs_sleep(__u32 ms);
void ocfs_truncate_inode_pages(struct inode *inode, loff_t off);
+int __ocfs_wait_atomic_eq(wait_queue_head_t *wq, atomic_t *var, int val, int ms);
#endif /* OCFS2_UTIL_H */
More information about the Ocfs2-commits
mailing list