[Ocfs-tools-commits]
manish commits r32 - in trunk/libocfs: Common Common/inc Linux
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed May 19 16:12:09 CDT 2004
Author: manish
Date: 2004-05-19 15:12:06 -0500 (Wed, 19 May 2004)
New Revision: 32
Modified:
trunk/libocfs/Common/inc/ocfsconst.h
trunk/libocfs/Common/inc/ocfsdef.h
trunk/libocfs/Common/inc/ocfsdisk.h
trunk/libocfs/Common/inc/ocfsgencreate.h
trunk/libocfs/Common/inc/ocfsgendirnode.h
trunk/libocfs/Common/inc/ocfsgenmisc.h
trunk/libocfs/Common/inc/ocfsgennm.h
trunk/libocfs/Common/inc/ocfsheartbeat.h
trunk/libocfs/Common/inc/ocfsvol.h
trunk/libocfs/Common/ocfsgenalloc.c
trunk/libocfs/Common/ocfsgencreate.c
trunk/libocfs/Common/ocfsgendirnode.c
trunk/libocfs/Common/ocfsgendlm.c
trunk/libocfs/Common/ocfsgenmisc.c
trunk/libocfs/Common/ocfsgennm.c
trunk/libocfs/Common/ocfsheartbeat.c
trunk/libocfs/Linux/ocfsdlm.c
trunk/libocfs/Linux/ocfsmount.c
trunk/libocfs/Linux/ocfsport.c
Log:
Sync with current ocfsv1 sources
Modified: trunk/libocfs/Common/inc/ocfsconst.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsconst.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsconst.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -35,7 +35,8 @@
#define ONE_MILLI_SEC (10 * 1000) /* 100 nanosec unit */
#define ONE_MEGA_BYTE (1 * 1024 * 1024) /* in bytes */
-#define MISS_COUNT_VALUE 20
+#define MISS_COUNT_VALUE 40
+#define MIN_MISS_COUNT_VALUE 5
#define OCFS_DEFAULT_DIR_NODE_SIZE (1024 * 128)
#define OCFS_DEFAULT_FILE_NODE_SIZE (512)
@@ -242,6 +243,7 @@
#define OCFS_NM_HEARTBEAT_TIME 500 /* in ms */
#define OCFS_HEARTBEAT_INIT 10 /* number of NM iterations to stabilize the publish map */
+#define OCFS_HB_TIMEOUT 30000 /* in ms */
#ifndef O_DIRECT
#define O_DIRECT 040000
Modified: trunk/libocfs/Common/inc/ocfsdef.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsdef.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsdef.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -52,6 +52,9 @@
#define IS_VALID_OSB(_osb) ((_osb)->obj_id.type == OCFS_TYPE_OSB)
+#define IS_VALID_DISKHB(_hb) ((_hb) >= 500 && (_hb) <= 5000)
+#define IS_VALID_HBTIMEO(_to) ((_to) >= 10000 && (_to) <= 60000)
+
#define OCFS_GET_EXTENT(vbo, extent, k) \
do { \
for ((k) = 0; (k) < OCFS_MAX_DATA_EXTENTS; (k)++) { \
@@ -335,6 +338,7 @@
__u32 num_cfg_nodes;
__u32 node_num;
bool reclaim_id; /* reclaim the original node number*/
+ __u32 max_miss_cnt;
__u8 hbm;
unsigned long hbt;
__u64 log_disk_off;
@@ -475,7 +479,6 @@
__u32 dlm_msg_size;
__u16 version;
bool init;
- bool re_init;
struct socket *send_sock;
struct socket *recv_sock;
struct completion complete;
Modified: trunk/libocfs/Common/inc/ocfsdisk.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsdisk.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsdisk.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -200,6 +200,8 @@
__u32 prot_bits;
__u32 uid;
__u32 gid;
+ __u32 disk_hb;
+ __u32 hb_timeo;
}
ocfs_vol_layout;
Modified: trunk/libocfs/Common/inc/ocfsgencreate.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsgencreate.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsgencreate.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -64,7 +64,7 @@
__u64 file_size, __u64 * file_off, struct iattr *attr);
int ocfs_get_dirnode(ocfs_super *osb, ocfs_dir_node *lockn, __u64 lockn_off,
- ocfs_dir_node *dirn);
+ ocfs_dir_node *dirn, bool *invalid_dirnode);
int ocfs_create_directory (ocfs_super * osb, __u64 parent_off, ocfs_file_entry * fe);
Modified: trunk/libocfs/Common/inc/ocfsgendirnode.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsgendirnode.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsgendirnode.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -77,9 +77,36 @@
int ocfs_del_file_entry (ocfs_super * osb,
ocfs_file_entry * EntryToDel, ocfs_dir_node * LockNode);
-int ocfs_insert_file (ocfs_super * osb,
- ocfs_dir_node * DirNode,
- ocfs_file_entry * InsertEntry,
- ocfs_dir_node * LockNode, ocfs_lock_res * LockResource);
+int ocfs_insert_file (ocfs_super * osb, ocfs_dir_node * DirNode,
+ ocfs_file_entry * InsertEntry, ocfs_dir_node * LockNode,
+ ocfs_lock_res * LockResource, bool invalid_dirnode);
+int ocfs_validate_dir_index (ocfs_super *osb, ocfs_dir_node *dirnode);
+
+int ocfs_validate_num_del (ocfs_super *osb, ocfs_dir_node *dirnode);
+
+static inline int ocfs_validate_dirnode (ocfs_super *osb, ocfs_dir_node *dirn)
+{
+ int ret = 0;
+
+ if (!IS_VALID_DIR_NODE (dirn))
+ ret = -EFAIL;
+
+ if (ret == 0)
+ ret = ocfs_validate_dir_index (osb, dirn);
+ if (ret == 0)
+ ret = ocfs_validate_num_del (osb, dirn);
+
+ return ret;
+}
+
+static inline void ocfs_update_hden (ocfs_dir_node *lockn, ocfs_dir_node *dirn,
+ __u64 off)
+{
+ if (lockn->node_disk_off != dirn->node_disk_off)
+ lockn->head_del_ent_node = off;
+ else
+ dirn->head_del_ent_node = off;
+}
+
#endif /* _OCFSGENDIRNODE_H_ */
Modified: trunk/libocfs/Common/inc/ocfsgenmisc.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsgenmisc.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsgenmisc.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -39,7 +39,7 @@
void ocfs_delete_all_extent_maps (ocfs_inode * oin);
-void ocfs_release_oin (ocfs_inode * oin, bool FreeMemory);
+void ocfs_release_oin (ocfs_inode * oin, bool need_lock);
int ocfs_initialize_osb (ocfs_super * osb,
ocfs_vol_disk_hdr * VolDiskHdr,
@@ -55,6 +55,7 @@
int ocfs_commit_cache (ocfs_super * osb, bool Flag);
+int ocfs_is_dir_empty (ocfs_super * osb, ocfs_dir_node * dirnode, bool * empty);
/* sorry about all the macros, but file and line are important */
Modified: trunk/libocfs/Common/inc/ocfsgennm.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsgennm.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsgennm.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -27,6 +27,16 @@
#ifndef _OCFSGENNM_H_
#define _OCFSGENNM_H_
+static inline int ocfs_validate_lockid (ocfs_super *osb, __u64 lockid) {
+ if (!lockid)
+ return -1;
+ if (osb->vol_layout.size < lockid)
+ return -1;
+ if (lockid % OCFS_SECTOR_SIZE)
+ return -1;
+ return 0;
+}
+
int ocfs_flush_data (ocfs_inode * oin);
int ocfs_disk_update_resource (ocfs_super * osb, ocfs_lock_res * lockres,
Modified: trunk/libocfs/Common/inc/ocfsheartbeat.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsheartbeat.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsheartbeat.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -27,10 +27,23 @@
#ifndef _OCFSHEARTBEAT_H_
#define _OCFSHEARTBEAT_H_
+typedef struct _ocfs_sched_vote
+{
+ ocfs_super * osb;
+ __u32 node_num;
+ struct tq_struct sv_tq;
+ __u8 publish_sect[OCFS_SECTOR_SIZE];
+}
+ocfs_sched_vote;
+
void ocfs_update_publish_map (ocfs_super * osb, void *buffer, bool first_time);
int ocfs_nm_thread (ocfs_super * mount_osb);
int ocfs_nm_heart_beat (ocfs_super * osb, __u32 flag, bool read_publish);
+int ocfs_schedule_vote (ocfs_super * osb, ocfs_publish * publish, __u32 node_num);
+
+void ocfs_process_vote_worker (void * val);
+
#endif /* _OCFSHEARTBEAT_H_ */
Modified: trunk/libocfs/Common/inc/ocfsvol.h
===================================================================
--- trunk/libocfs/Common/inc/ocfsvol.h 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/inc/ocfsvol.h 2004-05-19 20:12:06 UTC (rev 32)
@@ -84,6 +84,10 @@
__u32 uid; // UID
__u32 gid; // GID
__s32 excl_mount; // NODENUM
+ /* disk heartbeat time in ms */
+ __u32 disk_hb; // NUMBER RANGE(0, ULONG_MAX)
+ /* node timeout in ms */
+ __u32 hb_timeo; // NUMBER RANGE(0, ULONG_MAX)
}
ocfs_vol_disk_hdr; // END CLASS
Modified: trunk/libocfs/Common/ocfsgenalloc.c
===================================================================
--- trunk/libocfs/Common/ocfsgenalloc.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/ocfsgenalloc.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -2057,7 +2057,7 @@
/* special case: just one byte - also happens to be the *only*
* way in which this func is currently called */
if (ByteCount == 1) {
- status = -EFAIL;
+ status = -ESPIPE;
/* return the blocknum directly, no need to alloc ioruns */
if (ocfs_lookup_extent_map_entry (osb, &oin->map, Vbo, Lbo,
&length, &Runs)) {
@@ -2099,10 +2099,11 @@
}
if (Vbo >= (__s64) FileEntry->alloc_size) {
- LOG_ERROR_ARGS ("fe=%u.%u, vbo=%u.%u, fe->alloc_sz=%u.%u, oin->alloc_size=%u.%u",
+ LOG_TRACE_ARGS ("fe=%u.%u, vbo=%u.%u, fe->alloc_sz=%u.%u, "
+ "oin->alloc_size=%u.%u\n",
HILO (FileEntry->this_sector), HILO (Vbo),
HILO (FileEntry->alloc_size), HILO (oin->alloc_size));
- status = -EFAIL;
+ status = -ESPIPE;
goto finally;
}
@@ -2149,7 +2150,7 @@
"oin->alloc_size=%u.%u, thisext=%u.%u",
HILO(localVbo), HILO(oin->alloc_size),
HILO(OcfsExtent->this_ext));
- status = -EFAIL;
+ status = -ESPIPE;
goto finally;
}
@@ -2167,7 +2168,7 @@
}
if (ByteCount == 1) {
- status = -EFAIL;
+ status = -ESPIPE;
if (ocfs_lookup_extent_map_entry (osb, &oin->map, Vbo, Lbo,
&length, &Runs)) {
status = 0;
@@ -2189,7 +2190,7 @@
*(Lbo) = IoRuns[0].disk_off;
}
-no_iorun_exit:
+no_iorun_exit:
/* Should send a null for IoRuns in case of onl 1 extent */
LOG_TRACE_ARGS ("Num of Runs is: %d\n", Runs);
Modified: trunk/libocfs/Common/ocfsgencreate.c
===================================================================
--- trunk/libocfs/Common/ocfsgencreate.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/ocfsgencreate.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -70,7 +70,7 @@
/* Add checks as needed */
if (IS_FE_DELETED(fe->sync_flags) ||
(!(fe->sync_flags & OCFS_SYNC_FLAG_VALID))) {
- LOG_TRACE_ARGS ("Invalid file: %*s, syncflg=0x%X",
+ LOG_TRACE_ARGS ("Invalid file: %*s, syncflg=0x%X\n",
fe->filename_len, fe->filename,
fe->sync_flags);
OCFS_SET_FLAG (oin->oin_flags, OCFS_OIN_INVALID);
@@ -82,7 +82,7 @@
disk_len = strlen(fe->filename);
inode = oin->inode;
if (inode == NULL) {
- LOG_TRACE_ARGS ("oin has no matching inode: %*s",
+ LOG_TRACE_ARGS ("oin has no matching inode: %*s\n",
fe->filename_len, fe->filename);
OCFS_SET_FLAG (oin->oin_flags, OCFS_OIN_INVALID);
status = -ENOENT;
@@ -101,7 +101,7 @@
}
}
if (status < 0) {
- LOG_TRACE_ARGS ("name did not match inode: %*s, %d",
+ LOG_TRACE_ARGS ("name did not match inode: %*s\n",
fe->filename_len, fe->filename);
OCFS_SET_FLAG (oin->oin_flags, OCFS_OIN_INVALID);
goto leave;
@@ -984,6 +984,7 @@
ocfs_log_record *pOcfsLogRec;
__u64 lockId = 0;
__u32 log_node_num = OCFS_INVALID_NODE_NUM;
+ bool empty = false;
LOG_ENTRY_ARGS ("(osb=0x%p, poff=%u.%u, fl=%u, foff=%u.%u)\n",
osb, HILO(parent_off), flags, HILO(file_off));
@@ -1010,7 +1011,7 @@
status = ocfs_acquire_lock (osb, lockId, OCFS_DLM_EXCLUSIVE_LOCK,
lockFlags, &pLockResource, (ocfs_file_entry *) pLockNode);
if (status < 0) {
- if (status != -EINTR)
+ if (status != -EINTR && status != -EBUSY)
LOG_ERROR_STATUS (status);
goto leave;
}
@@ -1054,7 +1055,13 @@
/* Ask for a lock on the file to ensure there are no open oin's */
/* on the file on any node */
if (fe->attribs & OCFS_ATTRIB_DIRECTORY) {
- if ((pLockNode->num_ent_used > 0) && !(flags & FLAG_DEL_NAME)) {
+ status = ocfs_is_dir_empty (osb, pLockNode, &empty);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto leave;
+ }
+
+ if ((!empty) && !(flags & FLAG_DEL_NAME)) {
status = -ENOTEMPTY;
goto leave;
}
@@ -1417,16 +1424,20 @@
*
*/
int ocfs_get_dirnode(ocfs_super *osb, ocfs_dir_node *lockn, __u64 lockn_off,
- ocfs_dir_node *dirn)
+ ocfs_dir_node *dirn, bool *invalid_dirnode)
{
int status = 0;
__u64 node_off;
+ bool hden = false;
LOG_ENTRY_ARGS ("(lockn_off=%u.%u)\n", HILO (lockn_off));
- if (lockn->head_del_ent_node != INVALID_NODE_POINTER)
+ *invalid_dirnode = false;
+
+ if (lockn->head_del_ent_node != INVALID_NODE_POINTER) {
node_off = lockn->head_del_ent_node;
- else {
+ hden = true;
+ } else {
if (lockn->free_node_ptr == INVALID_NODE_POINTER)
node_off = lockn_off;
else
@@ -1439,36 +1450,54 @@
goto leave;
}
- if (dirn->node_disk_off != lockn->head_del_ent_node)
- goto leave;
+ status = ocfs_validate_dirnode (osb, dirn);
+ if (status >= 0) {
+ if (dirn->node_disk_off != lockn->head_del_ent_node)
+ goto leave;
- if (dirn->num_ent_used < osb->max_dir_node_ent)
+ if (dirn->num_ent_used < osb->max_dir_node_ent)
+ goto leave;
+ } else if (status != -EBADSLT) {
+ LOG_ERROR_STATUS (status);
goto leave;
+ } else {
+ *invalid_dirnode = true;
+ status = 0;
+ }
/* dirn with no free slots and pointed to by head_del_ent_node */
node_off = lockn_off;
while (1) {
+ *invalid_dirnode = false;
+
status = ocfs_read_dir_node (osb, dirn, node_off);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
}
- if (dirn->num_ent_used < osb->max_dir_node_ent) {
- if (lockn->node_disk_off != dirn->node_disk_off)
- lockn->head_del_ent_node = dirn->node_disk_off;
- else
- dirn->head_del_ent_node = dirn->node_disk_off;
+ status = ocfs_validate_dirnode (osb, dirn);
+ if (status >= 0) {
+ if (dirn->num_ent_used < osb->max_dir_node_ent) {
+ if (hden)
+ ocfs_update_hden (lockn, dirn,
+ dirn->node_disk_off);
+ goto leave;
+ }
+ } else if (status != -EBADSLT) {
+ LOG_ERROR_STATUS (status);
goto leave;
+ } else {
+ *invalid_dirnode = true;
+ status = 0;
}
node_off = dirn->next_node_ptr;
if (node_off == INVALID_NODE_POINTER) {
- if (lockn->node_disk_off != dirn->node_disk_off)
- lockn->head_del_ent_node = INVALID_NODE_POINTER;
- else
- dirn->head_del_ent_node = INVALID_NODE_POINTER;
+ if (hden && !*invalid_dirnode)
+ ocfs_update_hden (lockn, dirn,
+ INVALID_NODE_POINTER);
goto leave;
}
}
@@ -1497,6 +1526,7 @@
ocfs_lock_res *pLockResource = NULL;
__u32 lockFlags = 0;
bool bAcquiredLock = false;
+ bool invalid_dirnode = false;
LOG_ENTRY ();
@@ -1583,7 +1613,8 @@
}
}
- status = ocfs_get_dirnode(osb, pLockNode, parent_off, PDirNode);
+ status = ocfs_get_dirnode(osb, pLockNode, parent_off, PDirNode,
+ &invalid_dirnode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -1599,7 +1630,7 @@
DISK_LOCK_READER_NODE (fileEntry) = osb->node_num;
status = ocfs_insert_file (osb, PDirNode, fileEntry, pLockNode,
- pLockResource);
+ pLockResource, invalid_dirnode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -1636,6 +1667,7 @@
ocfs_lock_res *pLockResource = NULL;
__u32 lockFlags = 0;
bool bAcquiredLock = false;
+ bool invalid_dirnode = false;
LOG_ENTRY_ARGS ("(osb=0x%p, poff=%u.%u, fe=0x%p)\n", osb,
HILO(parent_off), fe);
@@ -1672,7 +1704,8 @@
goto leave;
}
- status = ocfs_get_dirnode(osb, pLockNode, parent_off, PDirNode);
+ status = ocfs_get_dirnode(osb, pLockNode, parent_off, PDirNode,
+ &invalid_dirnode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -1684,8 +1717,10 @@
DISK_LOCK_WRITER_NODE (fileEntry) = osb->node_num;
DISK_LOCK_READER_NODE (fileEntry) = osb->node_num;
+ fileEntry->next_del = INVALID_DIR_NODE_INDEX;
+
status = ocfs_insert_file (osb, PDirNode, fileEntry, pLockNode,
- pLockResource);
+ pLockResource, invalid_dirnode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -1748,7 +1783,8 @@
case FLAG_FILE_DELETE:
status = ocfs_del_file (osb, parent_off, 0, *file_off);
if (status < 0) {
- if (status != -EINTR && status != -ENOTEMPTY)
+ if (status != -EINTR && status != -ENOTEMPTY &&
+ status != -EBUSY)
LOG_ERROR_STATUS (status);
goto leave;
}
@@ -2022,8 +2058,7 @@
DISK_LOCK_READER_NODE (fe) = OCFS_INVALID_NODE_NUM;
DISK_LOCK_WRITER_NODE (fe) = OCFS_INVALID_NODE_NUM;
- OcfsQuerySystemTime (&fe->modify_time);
-
+ fe->modify_time = CURRENT_TIME;
fe->create_time = fe->modify_time;
status = ocfs_create_modify_file (osb, parent_off, NULL,
@@ -2084,8 +2119,7 @@
DISK_LOCK_READER_NODE (fe) = OCFS_INVALID_NODE_NUM;
DISK_LOCK_WRITER_NODE (fe) = OCFS_INVALID_NODE_NUM;
- OcfsQuerySystemTime (&fe->modify_time);
-
+ fe->modify_time = CURRENT_TIME;
fe->create_time = fe->modify_time;
status = ocfs_create_modify_file (osb, parent_off, NULL, NULL,
@@ -2661,6 +2695,7 @@
__u32 lockFlags = 0;
bool bAcquiredLock = false;
__u8 *buffer = NULL;
+ bool invalid_dirnode = false;
LOG_ENTRY ();
@@ -2736,7 +2771,8 @@
goto leave;
}
- status = ocfs_get_dirnode(osb, pLockNode, parent_off, PDirNode);
+ status = ocfs_get_dirnode(osb, pLockNode, parent_off, PDirNode,
+ &invalid_dirnode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -2748,7 +2784,7 @@
DISK_LOCK_READER_NODE (fileEntry) = osb->node_num;
status = ocfs_insert_file (osb, PDirNode, fileEntry, pLockNode,
- pLockResource);
+ pLockResource, invalid_dirnode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
@@ -2860,7 +2896,7 @@
DISK_LOCK_SEQNUM (fe) = changeSeqNum;
SET_VALID_BIT (fe->sync_flags);
fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
- OcfsQuerySystemTime (&fe->modify_time);
+ fe->modify_time = CURRENT_TIME;
status = ocfs_write_file_entry (osb, fe, fe->this_sector);
if (status < 0) {
Modified: trunk/libocfs/Common/ocfsgendirnode.c
===================================================================
--- trunk/libocfs/Common/ocfsgendirnode.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/ocfsgendirnode.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -833,6 +833,7 @@
if (status < 0) {
LOG_ERROR_STATUS (status);
}
+#if 0
if (!bCacheWrite) {
status =
ocfs_write_disk (osb, buffer, size, offset);
@@ -840,6 +841,7 @@
LOG_ERROR_STATUS (status);
}
}
+#endif
} else {
status = ocfs_write_disk (osb, buffer, size, offset);
if (status < 0) {
@@ -1376,6 +1378,7 @@
ocfs_lock_res *dir_lres = NULL;
__u64 dir_off;
bool lock_acq = false;
+ bool lock_rls = false;
int index = 0;
int length = 0;
@@ -1447,6 +1450,20 @@
PDirNode->head_del_ent_node = PDirNode->node_disk_off;
}
+ /* clear the lock on disk */
+ if (DISK_LOCK_FILE_LOCK (PDirNode) != OCFS_DLM_ENABLE_CACHE_LOCK) {
+ ocfs_acquire_lockres (dir_lres);
+ dir_lres->lock_type = OCFS_DLM_NO_LOCK;
+ ocfs_release_lockres (dir_lres);
+
+ lock_rls = true;
+
+ if (LockNode->node_disk_off == PDirNode->node_disk_off)
+ DISK_LOCK_FILE_LOCK (PDirNode) = OCFS_DLM_NO_LOCK;
+ else
+ DISK_LOCK_FILE_LOCK (LockNode) = OCFS_DLM_NO_LOCK;
+ }
+
status = ocfs_write_dir_node (osb, PDirNode, offset);
if (status < 0) {
LOG_ERROR_STATUS (status);
@@ -1475,6 +1492,8 @@
goto leave;
}
}
+ if (lock_rls)
+ lock_acq = false;
goto leave;
}
}
@@ -1487,6 +1506,7 @@
LOG_ERROR_STATUS (tmpstat);
}
+ ocfs_put_lockres (dir_lres);
ocfs_release_dirnode (PDirNode);
LOG_EXIT_STATUS (status);
return status;
@@ -1498,7 +1518,7 @@
*/
int ocfs_insert_file (ocfs_super * osb, ocfs_dir_node * DirNode,
ocfs_file_entry * InsertEntry, ocfs_dir_node * LockNode,
- ocfs_lock_res * LockResource)
+ ocfs_lock_res * LockResource, bool invalid_dirnode)
{
int status = 0;
__u64 bitmapOffset = 0;
@@ -1519,7 +1539,7 @@
/* and insert in that. */
/* We should not find this entry already inserted */
- if (DirNode->num_ent_used < osb->max_dir_node_ent) {
+ if (!invalid_dirnode && DirNode->num_ent_used < osb->max_dir_node_ent) {
status = ocfs_insert_dir_node (osb, DirNode, InsertEntry, LockNode,
&indexOffset);
if (status < 0) {
@@ -1582,7 +1602,6 @@
/* Insert in this dirnode and setup the pointers */
DirNode->next_node_ptr = pNewDirNode->node_disk_off;
- /* Create the btree now... */
status = ocfs_write_dir_node (osb, pNewDirNode, indexOffset);
if (status < 0) {
LOG_ERROR_STATUS (status);
@@ -1591,17 +1610,22 @@
indexOffset = -1;
}
- if (DISK_LOCK_FILE_LOCK (DirNode) != OCFS_DLM_ENABLE_CACHE_LOCK) {
- /* This is an optimization... */
- ocfs_acquire_lockres (LockResource);
- LockResource->lock_type = OCFS_DLM_NO_LOCK;
- ocfs_release_lockres (LockResource);
-
- if (LockNode->node_disk_off == DirNode->node_disk_off)
+ if (LockNode->node_disk_off == DirNode->node_disk_off) {
+ if (DISK_LOCK_FILE_LOCK (DirNode) != OCFS_DLM_ENABLE_CACHE_LOCK) {
+ ocfs_acquire_lockres (LockResource);
+ LockResource->lock_type = OCFS_DLM_NO_LOCK;
+ ocfs_release_lockres (LockResource);
/* Reset the lock on the disk */
DISK_LOCK_FILE_LOCK (DirNode) = OCFS_DLM_NO_LOCK;
- else
+ }
+ } else {
+ if (DISK_LOCK_FILE_LOCK (LockNode) != OCFS_DLM_ENABLE_CACHE_LOCK) {
+ ocfs_acquire_lockres (LockResource);
+ LockResource->lock_type = OCFS_DLM_NO_LOCK;
+ ocfs_release_lockres (LockResource);
+ /* Reset the lock on the disk */
DISK_LOCK_FILE_LOCK (LockNode) = OCFS_DLM_NO_LOCK;
+ }
}
status = ocfs_write_dir_node (osb, DirNode, indexOffset);
@@ -1633,3 +1657,133 @@
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_insert_file */
+
+
+/*
+ * ocfs_validate_dir_index()
+ *
+ */
+int ocfs_validate_dir_index (ocfs_super *osb, ocfs_dir_node *dirnode)
+{
+ ocfs_file_entry *fe = NULL;
+ int status = 0;
+ __u8 i;
+ __u8 offset;
+ __u8 *ind = NULL;
+
+ LOG_ENTRY_ARGS ("(osb=0x%p, dn=0x%p)\n", osb, dirnode);
+
+ if ((ind = (__u8 *)ocfs_malloc (256)) == NULL) {
+ LOG_ERROR_STATUS (status = -ENOMEM);
+ goto bail;
+ }
+
+ memset(ind, 0, 256);
+
+ for (i = 0; i < dirnode->num_ent_used; ++i) {
+ offset = dirnode->index[i];
+ if (offset > 253 || ind[offset]) {
+ status = -EBADSLT;
+ break;
+ } else
+ ind[offset] = 1;
+
+ fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+ (offset * OCFS_SECTOR_SIZE));
+
+ if (!fe->sync_flags) {
+ status = -EBADSLT;
+ break;
+ }
+ }
+
+ if (status == -EBADSLT)
+ LOG_ERROR_ARGS ("corrupted index in dirnode=%u.%u",
+ HILO(dirnode->node_disk_off));
+
+bail:
+ ocfs_safefree (ind);
+ LOG_EXIT_STATUS (status);
+ return status;
+} /* ocfs_validate_dir_index */
+
+
+/*
+ * ocfs_validate_num_del()
+ *
+ */
+int ocfs_validate_num_del (ocfs_super *osb, ocfs_dir_node *dirnode)
+{
+ ocfs_file_entry *fe = NULL;
+ int i;
+ int j;
+ int status = 0;
+ __u8 offset;
+ __u8 *ind = NULL;
+ char tmpstr[3];
+ __u64 tmpoff;
+
+ LOG_ENTRY_ARGS ("(osb=0x%p, dn=0x%p)\n", osb, dirnode);
+
+ if (!dirnode->num_del)
+ goto bail;
+
+ if ((ind = (__u8 *)ocfs_malloc (256)) == NULL) {
+ LOG_ERROR_STATUS (status = -ENOMEM);
+ goto bail;
+ }
+
+ memset(ind, 0, 256);
+
+ offset = dirnode->first_del;
+ for (i = 0; i < dirnode->num_del; ++i) {
+ if (offset > 253) {
+ status = -EBADSLT;
+ break;
+ }
+
+ /* check if offset is in index and hence invalid */
+ for (j = 0; j < dirnode->num_ent_used; ++j) {
+ if (dirnode->index[j] == offset) {
+ status = -EBADSLT;
+ break;
+ }
+ }
+
+ /* check for circular list */
+ if (ind[offset]) {
+ status = -EBADSLT;
+ break;
+ } else
+ ind[offset] = 1;
+
+ fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+ (offset * OCFS_SECTOR_SIZE));
+
+ /* file has to be deleted to be in the list */
+ if (fe->sync_flags) {
+ status = -EBADSLT;
+ break;
+ }
+
+ offset = (__u8)fe->next_del;
+ }
+
+ if (status == -EBADSLT) {
+ if (i) {
+ strncpy (tmpstr, "fe", sizeof(tmpstr));
+ tmpoff = fe->this_sector;
+ } else {
+ strncpy (tmpstr, "dn", sizeof(tmpstr));
+ tmpoff = dirnode->node_disk_off;
+ }
+
+ LOG_ERROR_ARGS ("bad offset=%u in %s=%u.%u", offset, tmpstr,
+ HILO(tmpoff));
+ }
+
+bail:
+ ocfs_safefree (ind);
+ LOG_EXIT_STATUS (status);
+ return status;
+} /* ocfs_validate_num_del */
Modified: trunk/libocfs/Common/ocfsgendlm.c
===================================================================
--- trunk/libocfs/Common/ocfsgendlm.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/ocfsgendlm.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -31,7 +31,6 @@
#include <libocfs.h>
#endif
-
#define WAIT_FOR_VOTE_INCREMENT 200
/* Tracing */
@@ -158,6 +157,7 @@
__u8 *p;
__u32 wait;
bool publish_flag = false;
+ __u32 disk_hb = osb->vol_layout.disk_hb;
LOG_ENTRY_ARGS ("(osb=0x%p, id=%u.%u, ty=%u, fl=%u, vm=0x%08x)\n", osb,
HI(lock_id), LO(lock_id), lock_type, flags, LO(vote_map));
@@ -195,7 +195,7 @@
} else {
get_random_bytes(&wait, sizeof(wait));
wait %= 200;
- wait += OCFS_NM_HEARTBEAT_TIME;
+ wait += disk_hb;
LOG_TRACE_ARGS ("wait: %d\n", wait);
ocfs_sleep (wait);
}
@@ -564,21 +564,18 @@
__u64 gotvotemap = 0;
__u64 fileopenmap = 0;
- LOG_ENTRY_ARGS ("(osb=0x%p, id=%u.%u, ty=%u, fl=%u, vm=0x%08x, "
- "sq:%u.%u)\n", osb, HI (lock_id), LO (lock_id), lock_type,
- flags, LO (vote_map), HI(lock_seq_num), LO(lock_seq_num));
+ LOG_ENTRY_ARGS ("(osb=0x%p, id=%u.%u, type=%u, flg=%u, map=0x%x, "
+ "seq=%u.%u)\n", osb, HILO (lock_id), lock_type,
+ flags, LO (vote_map), HILO (lock_seq_num));
while (time_to_wait > timewaited) {
ocfs_sleep (WAIT_FOR_VOTE_INCREMENT);
if (!atomic_read (&osb->node_req_vote)) {
- LOG_TRACE_ARGS ("wait EAGAIN\n");
status = -EAGAIN;
goto bail;
}
- gotvotemap |= (1 << osb->node_num);
-
status = ocfs_get_vote_on_disk (osb, lock_id, lock_type, flags,
&gotvotemap, vote_map, lock_seq_num, &fileopenmap);
if (status < 0) {
@@ -587,12 +584,6 @@
goto bail;
}
- if (!(gotvotemap & (1 << osb->node_num))) {
- status = -EAGAIN;
- goto bail;
- }
-
- vote_map |= (1 << osb->node_num);
if (vote_map == gotvotemap) {
if ((flags & FLAG_FILE_EXTEND) || (flags & FLAG_FILE_UPDATE))
lockres->oin_openmap = fileopenmap;
@@ -608,10 +599,11 @@
ocfs_compute_dlm_stats ((timewaited >= time_to_wait ? -ETIMEDOUT : 0),
status, &(osb->dsk_reqst_stats));
- LOG_TRACE_ARGS ("disk vote id=%u.%u, seq=%u.%u, map=0x%08x, "
- "flags=0x%08x, type=0x%08x, status=%d\n",
+ LOG_TRACE_ARGS ("disk vote id=%u.%u, seq=%u.%u, map=0x%x, "
+ "flags=0x%x, type=0x%x, status=%d, timeo=%d\n",
HILO(lock_id), HILO(lock_seq_num), LO(vote_map),
- flags, lock_type, status);
+ flags, lock_type, status,
+ (timewaited >= time_to_wait ? -ETIMEDOUT : 0));
LOG_EXIT_STATUS (status);
return status;
@@ -721,7 +713,7 @@
ocfs_send_bcast (osb, vote_map, dlm_msg);
status = ocfs_wait (lockres->voted_event,
- atomic_read (&lockres->voted_event_woken), 1000);
+ atomic_read (&lockres->voted_event_woken), 3000);
atomic_set (&lockres->voted_event_woken, 0);
if (status == -ETIMEDOUT) {
@@ -997,6 +989,23 @@
return status;
} /* ocfs_update_disk_lock */
+
+#define ACQUIRE_WITH_FLAG(lock, flag) \
+ do { \
+ if (!(flag)) { \
+ ocfs_acquire_lockres(lock); \
+ (flag) = true; \
+ } \
+ } while (0)
+
+#define RELEASE_WITH_FLAG(lock, flag) \
+ do { \
+ if (flag) { \
+ ocfs_release_lockres(lock); \
+ (flag) = false; \
+ } \
+ } while (0)
+
/*
* ocfs_update_master_on_open()
*
@@ -1005,25 +1014,26 @@
{
int status = -EAGAIN;
bool disk_vote = false;
+ bool lock_acq = false;
LOG_ENTRY ();
+ ocfs_get_lockres(lockres);
+
while (status == -EAGAIN) {
if (!IS_NODE_ALIVE (osb->publ_map, lockres->master_node_num,
OCFS_MAXIMUM_NODES)) {
LOG_TRACE_ARGS ("Master (%u) dead, lockid %u.%u\n",
- lockres->master_node_num,
- HI (lockres->sector_num), LO (lockres->sector_num));
+ lockres->master_node_num, HILO (lockres->sector_num));
status = 0;
goto bail;
}
- ocfs_acquire_lockres (lockres);
+ ACQUIRE_WITH_FLAG(lockres, lock_acq);
if (lockres->master_node_num == osb->node_num) {
LOG_TRACE_ARGS ("Added node to map 0x%08x, lockid %u.%u\n",
- LO (lockres->oin_openmap), HI (lockres->sector_num),
- LO (lockres->sector_num));
+ LO (lockres->oin_openmap), HILO (lockres->sector_num));
lockres->oin_openmap |= (1 << osb->node_num);
status = ocfs_update_disk_lock (osb, lockres,
@@ -1032,14 +1042,13 @@
LOG_ERROR_STATUS (status);
goto bail;
}
- ocfs_release_lockres (lockres);
} else {
status = ocfs_update_lock_state (osb, lockres,
FLAG_ADD_OIN_MAP, &disk_vote);
if (status < 0) {
if (status != -EAGAIN)
LOG_ERROR_STATUS (status);
- ocfs_release_lockres (lockres);
+ RELEASE_WITH_FLAG(lockres, lock_acq);
if (status == -EAGAIN) {
ocfs_sleep (500);
if (ocfs_task_interruptible (osb)) {
@@ -1053,11 +1062,12 @@
}
goto bail;
}
- ocfs_release_lockres (lockres);
}
}
bail:
+ RELEASE_WITH_FLAG(lockres, lock_acq);
+ ocfs_put_lockres(lockres);
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_update_master_on_open */
@@ -1274,7 +1284,8 @@
continue;
} else {
ocfs_release_lockres (lockres);
- LOG_ERROR_STATUS (status);
+ if (status != -EBUSY)
+ LOG_ERROR_STATUS (status);
goto finally;
}
}
@@ -1284,22 +1295,7 @@
return status;
} /* ocfs_get_x_for_del */
-#define ACQUIRE_WITH_FLAG(lock, flag) \
- do { \
- if (!(flag)) { \
- ocfs_acquire_lockres(lock); \
- (flag) = true; \
- } \
- } while (0)
-#define RELEASE_WITH_FLAG(lock, flag) \
- do { \
- if (flag) { \
- ocfs_release_lockres(lock); \
- (flag) = false; \
- } \
- } while (0)
-
/*
* ocfs_try_exclusive_lock()
*
@@ -1483,7 +1479,7 @@
flags, lockres, fe);
RELEASE_WITH_FLAG(lockres, lockres_acq);
if (status < 0) {
- if (status != -EINTR)
+ if (status != -EINTR && status != -EBUSY)
LOG_ERROR_STATUS (status);
}
goto finally;
@@ -1635,7 +1631,7 @@
updated, disklock, lock_id,
lock_type);
if (status < 0) {
- if (status != -EINTR)
+ if (status != -EINTR && status != -EBUSY)
LOG_ERROR_STATUS (status);
goto finally;
}
@@ -1929,7 +1925,6 @@
LOG_ENTRY ();
OcfsIpcCtxt.init = false;
- OcfsIpcCtxt.re_init = false;
LOG_EXIT_STATUS (0);
return 0;
Modified: trunk/libocfs/Common/ocfsgenmisc.c
===================================================================
--- trunk/libocfs/Common/ocfsgenmisc.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/ocfsgenmisc.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -30,6 +30,7 @@
#include <libocfs.h>
#endif
+__u32 disk_timeo = 0;
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_MISC
@@ -38,6 +39,8 @@
__u32 OcfsErrorLogSequence = 0;
+extern spinlock_t ocfs_inode_lock;
+
/*
* ocfs_create_meta_log_files()
*
@@ -480,18 +483,18 @@
* ocfs_release_oin()
*
*/
-void ocfs_release_oin (ocfs_inode * oin, bool FreeMemory)
+void ocfs_release_oin (ocfs_inode * oin, bool need_lock)
{
ocfs_lock_res *lockres = NULL;
- ocfs_super *osb = NULL;
struct inode *inode;
+ __u64 savedOffset = 0;
- LOG_ENTRY_ARGS ("oin = %p, free = %s\n", oin, FreeMemory? "yes" : "no");
+ LOG_ENTRY_ARGS ("oin=%p, lock=%s\n", oin, need_lock? "yes" : "no");
if (!oin || !oin->osb)
goto bail;
- osb = oin->osb;
+ OCFS_ASSERT(IS_VALID_OIN(oin));
lockres = oin->lock_res;
@@ -506,15 +509,25 @@
inode = (struct inode *) oin->inode;
if (inode) {
- __u64 savedOffset = oin->file_disk_off;
-
+ savedOffset = oin->file_disk_off;
SET_INODE_OIN (inode, NULL);
SET_INODE_OFFSET (inode, savedOffset);
LOG_TRACE_ARGS ("inode oin cleared / flags: %d / offset: %u.%u\n",
inode->i_flags, savedOffset);
}
+ if (inode) {
+ if (need_lock)
+ spin_lock (&ocfs_inode_lock);
+ oin->inode = NULL;
+ if (atomic_read(&inode->i_count) > 1)
+ atomic_dec(&inode->i_count);
+ if (need_lock)
+ spin_unlock (&ocfs_inode_lock);
+ }
+
ocfs_extent_map_destroy (&oin->map);
+ ocfs_extent_map_init (&oin->map);
/* Delete the ocfs_sem objects */
if (oin->oin_flags & OCFS_INITIALIZED_MAIN_RESOURCE) {
@@ -527,15 +540,14 @@
OCFS_INITIALIZED_PAGING_IO_RESOURCE);
}
- if (FreeMemory) {
+ memset (oin, 0, sizeof(ocfs_inode));
#ifdef OCFS_MEM_DBG
- ocfs_dbg_slab_free (OcfsGlobalCtxt.oin_cache, oin);
+ ocfs_dbg_slab_free (OcfsGlobalCtxt.oin_cache, oin);
#else
- kmem_cache_free (OcfsGlobalCtxt.oin_cache, oin);
+ kmem_cache_free (OcfsGlobalCtxt.oin_cache, oin);
#endif
- oin = NULL;
- ocfs_put_lockres (lockres);
- }
+ oin = NULL;
+ ocfs_put_lockres (lockres);
ocfs_put_lockres (lockres);
bail:
@@ -576,16 +588,6 @@
snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
-#ifdef __LP64__
-#define HASHBITS 11
-#else
-#define HASHBITS 12
-#endif
- if (!ocfs_hash_create (&(osb->root_sect_node), HASHBITS)) {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto bail;
- }
-
ocfs_init_sem (&(osb->osb_res));
ocfs_init_sem (&(osb->map_lock));
ocfs_init_sem (&(osb->log_lock));
@@ -600,14 +602,22 @@
init_MUTEX (&(osb->comm_lock));
init_MUTEX (&(osb->trans_lock));
+#ifdef __LP64__
+#define HASHBITS 11
+#else
+#define HASHBITS 12
+#endif
+ if (!ocfs_hash_create (&(osb->root_sect_node), HASHBITS)) {
+ LOG_ERROR_STATUS (status = -ENOMEM);
+ goto bail;
+ }
+
osb->node_recovering = OCFS_INVALID_NODE_NUM;
-
osb->needs_flush = false;
osb->commit_cache_exec = false;
osb->log_disk_off = 0;
osb->log_meta_disk_off = 0;
osb->trans_in_progress = false;
-
osb->last_disk_seq = ULONGLONG_MAX;
init_MUTEX (&(osb->publish_lock));
@@ -649,6 +659,22 @@
vol_layout->uid = vdh->uid;
vol_layout->gid = vdh->gid;
+ if (disk_timeo) {
+ vol_layout->disk_hb = vdh->disk_hb;
+ vol_layout->hb_timeo = vdh->hb_timeo;
+ }
+
+ if (!IS_VALID_DISKHB(vol_layout->disk_hb))
+ vol_layout->disk_hb = OCFS_NM_HEARTBEAT_TIME;
+
+ if (!IS_VALID_HBTIMEO(vol_layout->hb_timeo))
+ vol_layout->hb_timeo = OCFS_HB_TIMEOUT;
+
+ if (disk_timeo)
+ osb->max_miss_cnt = (vdh->hb_timeo / vdh->disk_hb) + 1;
+ else
+ osb->max_miss_cnt = MISS_COUNT_VALUE;
+
memcpy (vol_layout->vol_id, vol_label->vol_id, MAX_VOL_ID_LENGTH);
if (vol_layout->dir_node_size == 0)
@@ -990,3 +1016,58 @@
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_commit_cache */
+
+/*
+ * ocfs_is_dir_empty()
+ *
+ */
+int ocfs_is_dir_empty (ocfs_super * osb, ocfs_dir_node * dirnode, bool * empty)
+{
+ ocfs_dir_node *dn = NULL;
+ __u64 offset;
+ int status = 0;
+
+ LOG_ENTRY ();
+
+ *empty = true;
+
+ if (dirnode->num_ent_used != 0) {
+ *empty = false;
+ goto bail;
+ }
+
+ offset = dirnode->next_node_ptr;
+ if (offset == INVALID_NODE_POINTER)
+ goto bail;
+
+ dn = ocfs_malloc (OCFS_SECTOR_SIZE);
+ if (dn == NULL) {
+ LOG_ERROR_STATUS (status = -ENOMEM);
+ goto bail;
+ }
+
+ while (1) {
+ status = ocfs_read_sector (osb, dn, offset);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto bail;
+ }
+
+ if (dn->num_ent_used != 0) {
+ *empty = false;
+ goto bail;
+ }
+
+ offset = dn->next_node_ptr;
+ if (offset == INVALID_NODE_POINTER)
+ goto bail;
+ }
+
+bail:
+ LOG_TRACE_ARGS("status=%d, dir=%u.%u is %s\n", status,
+ HILO(dirnode->node_disk_off),
+ (*empty ? "empty" : "not empty"));
+ ocfs_safefree (dn);
+ LOG_EXIT_STATUS (status);
+ return status;
+} /* ocfs _is_dir_empty */
Modified: trunk/libocfs/Common/ocfsgennm.c
===================================================================
--- trunk/libocfs/Common/ocfsgennm.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/ocfsgennm.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -217,13 +217,7 @@
goto finally;
}
- if (lock_id != (*lockres)->sector_num) {
- LOG_ERROR_ARGS ("lockid=%u.%u != secnum=%u.%u\n",
- HILO(lock_id),
- HILO((*lockres)->sector_num));
- status = -EFAIL;
- goto finally;
- }
+ OCFS_ASSERT (lock_id == (*lockres)->sector_num);
status = ocfs_check_for_stale_lock(osb, *lockres, fe, lock_id);
if (status < 0) {
@@ -248,13 +242,7 @@
}
}
- if (lock_id != (*lockres)->sector_num) {
- LOG_ERROR_ARGS ("lockid=%u.%u != secnum=%u.%u",
- HILO(lock_id),
- HILO((*lockres)->sector_num));
- status = -EFAIL;
- goto finally;
- }
+ OCFS_ASSERT (lock_id == (*lockres)->sector_num);
if ((*lockres)->master_node_num != osb->node_num) {
status = ocfs_disk_update_resource (osb, *lockres, fe, timeout);
@@ -335,7 +323,9 @@
(find_inode_t) ocfs_find_inode,
(void *) (&args));
if (inode != NULL && is_bad_inode (inode)) {
+#ifndef USERSPACE_TOOL
iput (inode);
+#endif
inode = NULL;
}
ocfs_release_file_entry (fe);
@@ -416,9 +406,8 @@
LOG_ENTRY_ARGS ("(0x%p, 0x%p, %u)\n", osb, publish, node_num);
- LOG_TRACE_ARGS ("node=%u, id=%u.%u, seq=%u.%u\n", node_num,
- HI(publish->dir_ent), LO(publish->dir_ent),
- HI(publish->publ_seq_num), LO(publish->publ_seq_num));
+ LOG_TRACE_ARGS ("pv node=%u, id=%u.%u, seq=%u.%u\n", node_num,
+ HILO (publish->dir_ent), HILO (publish->publ_seq_num));
num_nodes = OCFS_MAXIMUM_NODES;
flags = publish->vote_type;
@@ -431,9 +420,16 @@
goto finito;
}
+ /* if invalid lockid */
+ if (ocfs_validate_lockid (osb, publish->dir_ent)) {
+ vote->vote[node_num] = FLAG_VOTE_UPDATE_RETRY;
+ vote->open_handle = false;
+ goto finito;
+ }
+
/* Exclusive vote for */
status = ocfs_find_update_res (osb, publish->dir_ent, &lockres, NULL,
- NULL, (OCFS_NM_HEARTBEAT_TIME/2));
+ NULL, (OCFS_NM_HEARTBEAT_TIME));
if (status < 0) {
if (status == -ETIMEDOUT)
goto finito;
@@ -452,7 +448,7 @@
goto finito;
}
- status = ocfs_acquire_lockres_ex (lockres, (OCFS_NM_HEARTBEAT_TIME/2));
+ status = ocfs_acquire_lockres_ex (lockres, (OCFS_NM_HEARTBEAT_TIME));
if (status < 0) {
LOG_TRACE_ARGS ("Timedout locking lockres for id: %u.%u\n",
HILO (lockres->sector_num));
@@ -707,14 +703,19 @@
__u32 retry_cnt = 0;
bool acq_oin = false;
ocfs_file_entry *fe = NULL;
- bool rls_oin = true;
ocfs_inode *oin = NULL;
ocfs_sem *oin_sem = NULL;
+ struct inode *inode = NULL;
LOG_ENTRY ();
+/* The macro below takes into account the pre RELEASE/ACQUIRE_LOCK flag days */
+/* Allows for rolling upgrade */
+#define IS_RELEASE_LOCK(_f) (((_f) & FLAG_FILE_RELEASE_LOCK) || \
+ !((_f) & (FLAG_FILE_ACQUIRE_LOCK | FLAG_FILE_RELEASE_LOCK)))
+
oin = (*lockres)->oin;
- if (oin) {
+ if (oin && !IS_RELEASE_LOCK(flags)) {
ocfs_down_sem (&oin->main_res, true);
oin->needs_verification = true;
status = ocfs_verify_update_oin(osb, oin);
@@ -752,11 +753,6 @@
}
}
-/* The macro below takes into account the pre RELEASE/ACQUIRE_LOCK flag days */
-/* Allows for rolling upgrade */
-#define IS_RELEASE_LOCK(_f) (((_f) & FLAG_FILE_RELEASE_LOCK) || \
- !((_f) & (FLAG_FILE_ACQUIRE_LOCK | FLAG_FILE_RELEASE_LOCK)))
-
if (((*lockres)->oin->open_hndl_cnt == 0) &&
(!(oin->oin_flags & OCFS_OIN_IN_USE))) {
if (!(oin->oin_flags & OCFS_OIN_IN_TEARDOWN) &&
@@ -766,8 +762,6 @@
acq_oin = false;
}
- rls_oin = false;
-
if (!acq_oin) {
ocfs_down_sem (oin_sem, true);
acq_oin = true;
@@ -784,28 +778,19 @@
ocfs_release_lockres (*lockres);
if (oin && oin->inode) {
- struct inode *inode = oin->inode;
+ inode = oin->inode;
+ if (inode) {
+ oin->inode = NULL;
+#ifndef USERSPACE_TOOL
+ iput(inode);
+#endif
+ }
+ ocfs_down_sem (&(oin->paging_io_res), true);
+ ocfs_purge_cache_section (oin, NULL, 0);
+ ocfs_up_sem (&(oin->paging_io_res));
inode->i_nlink = 0;
d_prune_aliases (inode);
}
-
- if (rls_oin) {
- ocfs_release_cached_oin (osb, oin);
- ocfs_release_oin (oin, true);
- } else {
- ocfs_down_sem (&(oin->paging_io_res),
- true);
- ocfs_purge_cache_section (oin, NULL, 0);
- ocfs_up_sem (&(oin->paging_io_res));
- }
-
- if (oin && oin->inode) {
-#ifndef USERSPACE_TOOL
- iput (oin->inode);
-#endif
- oin->inode = NULL;
- }
- *lockres = NULL;
}
*vote = FLAG_VOTE_NODE;
goto finito;
@@ -815,7 +800,6 @@
}
} else {
#ifndef USERSPACE_TOOL
- struct inode *inode = NULL;
if (flags & FLAG_FILE_DELETE && IS_RELEASE_LOCK(flags)) {
inode = ocfs_get_inode_from_offset(osb, lock_id);
if (inode) {
Modified: trunk/libocfs/Common/ocfsheartbeat.c
===================================================================
--- trunk/libocfs/Common/ocfsheartbeat.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Common/ocfsheartbeat.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -246,8 +246,13 @@
if (publish->vote)
publish->vote = 0;
+#if defined(DISK_VOTE_INLINE) || defined(USERSPACE_TOOL)
ocfs_process_vote (osb, publish_to_vote, vote_node);
osb->last_disk_seq = curr_publ_seq;
+#else
+ if (!ocfs_schedule_vote (osb, publish_to_vote, vote_node))
+ osb->last_disk_seq = curr_publ_seq;
+#endif
}
osb->hbt = 50 + jiffies;
@@ -318,11 +323,11 @@
if (node_map->time[i] == publish->time) {
if (IS_NODE_ALIVE(osb->publ_map, i, num_nodes)) {
if (atomic_read (&(node_map->dismount[i]))) {
- node_map->miss_cnt[i] = MISS_COUNT_VALUE;
+ node_map->miss_cnt[i] = osb->max_miss_cnt /*MISS_COUNT_VALUE*/;
atomic_set (&(node_map->dismount[i]), 0);
} else
(node_map->miss_cnt[i])++;
- if (node_map->miss_cnt[i] > MISS_COUNT_VALUE) {
+ if (node_map->miss_cnt[i] > osb->max_miss_cnt /*MISS_COUNT_VALUE*/) {
#if !defined(USERSPACE_TOOL)
printk ("ocfs: Removing %s (node %d) "
"from clustered device (%s)\n",
@@ -370,3 +375,65 @@
LOG_EXIT ();
return;
} /* ocfs_update_publish_map */
+
+
+#ifndef USERSPACE_TOOL
+/*
+ * ocfs_schedule_vote()
+ *
+ */
+int ocfs_schedule_vote (ocfs_super * osb, ocfs_publish * publish, __u32 node_num)
+{
+ ocfs_sched_vote *sv = NULL;
+ int status = 0;
+
+ LOG_ENTRY ();
+
+ sv = ocfs_malloc (sizeof (ocfs_sched_vote));
+ if (sv == NULL) {
+ LOG_ERROR_STATUS (status = -ENOMEM);
+ goto bail;
+ }
+ memset (sv, 0, sizeof (ocfs_sched_vote));
+
+ sv->osb = osb;
+ sv->node_num = node_num;
+ memcpy (&sv->publish_sect, publish, OCFS_SECTOR_SIZE);
+
+ INIT_TQUEUE (&sv->sv_tq, ocfs_process_vote_worker, sv);
+
+ schedule_task (&sv->sv_tq);
+
+bail:
+ if (status < 0)
+ ocfs_safefree (sv);
+
+ LOG_EXIT_STATUS (status);
+ return status;
+} /* ocfs_schedule_vote */
+
+
+/*
+ * ocfs_process_vote_worker()
+ *
+ */
+void ocfs_process_vote_worker (void * val)
+{
+ ocfs_sched_vote *sv = (ocfs_sched_vote *)val;
+ ocfs_publish *publish = NULL;
+
+ LOG_ENTRY ();
+
+ if (sv) {
+ publish = (ocfs_publish *) &sv->publish_sect;
+ if (!IS_VALID_OSB (sv->osb) || !publish)
+ goto bail;
+ ocfs_process_vote (sv->osb, publish, sv->node_num);
+ ocfs_safefree (sv);
+ }
+
+bail:
+ LOG_EXIT ();
+ return ;
+} /* ocfs_process_vote_worker */
+#endif
Modified: trunk/libocfs/Linux/ocfsdlm.c
===================================================================
--- trunk/libocfs/Linux/ocfsdlm.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Linux/ocfsdlm.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -31,7 +31,6 @@
#include <libocfs.h>
#endif
-
/* Tracing */
#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_NM
@@ -175,6 +174,7 @@
char proc[16];
int status = 0;
int flush_counter = 0;
+ __u32 disk_hb = 0;
LOG_ENTRY ();
@@ -189,6 +189,8 @@
osb->dlm_task = current;
#endif
+ disk_hb = osb->vol_layout.disk_hb;
+
/* The delay changes based on multiplier */
while (!(OcfsGlobalCtxt.flags & OCFS_FLAG_SHUTDOWN_VOL_THREAD) &&
!(osb->osb_flags & OCFS_OSB_FLAGS_BEING_DISMOUNTED)) {
@@ -196,7 +198,7 @@
if (OcfsGlobalCtxt.hbm == 0)
OcfsGlobalCtxt.hbm = DISK_HBEAT_NO_COMM;
- ocfs_sleep (OCFS_NM_HEARTBEAT_TIME);
+ ocfs_sleep (disk_hb);
if ((OcfsGlobalCtxt.flags & OCFS_FLAG_SHUTDOWN_VOL_THREAD) ||
(osb->osb_flags & OCFS_OSB_FLAGS_BEING_DISMOUNTED))
Modified: trunk/libocfs/Linux/ocfsmount.c
===================================================================
--- trunk/libocfs/Linux/ocfsmount.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Linux/ocfsmount.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -411,6 +411,7 @@
__u32 nodemap;
__u32 tempmap;
int i;
+ bool nm_killed = false;
LOG_ENTRY_ARGS ("(0x%p)\n", sb);
@@ -467,6 +468,7 @@
wait_for_completion (&(osb->complete));
#endif
osb->dlm_task = NULL;
+ nm_killed = true;
}
/* create map of all active nodes except self */
@@ -476,23 +478,27 @@
#ifndef USERSPACE_TOOL
/* send dismount msg to all */
- status = ocfs_send_dismount_msg (osb, (__u64)nodemap);
- if (status < 0)
- LOG_ERROR_STATUS (status);
+ if (nm_killed && OcfsIpcCtxt.task) {
+ status = ocfs_send_dismount_msg (osb, (__u64)nodemap);
+ if (status < 0)
+ LOG_ERROR_STATUS (status);
+ }
/* decrement mount count */
- spin_lock (&mount_cnt_lock);
- mount_cnt--;
- if (mount_cnt == 0) {
- /* Shutdown ocfslsnr */
- if (OcfsIpcCtxt.task) {
- LOG_TRACE_STR ("Waiting for ocfslsnr to exit....");
- send_sig (SIGINT, OcfsIpcCtxt.task, 0);
- wait_for_completion (&(OcfsIpcCtxt.complete));
- OcfsIpcCtxt.task = NULL;
+ if (nm_killed) {
+ spin_lock (&mount_cnt_lock);
+ mount_cnt--;
+ if (mount_cnt == 0) {
+ /* Shutdown ocfslsnr */
+ if (OcfsIpcCtxt.task) {
+ LOG_TRACE_STR ("Waiting for ocfslsnr to exit....");
+ send_sig (SIGINT, OcfsIpcCtxt.task, 0);
+ wait_for_completion (&(OcfsIpcCtxt.complete));
+ OcfsIpcCtxt.task = NULL;
+ }
}
+ spin_unlock (&mount_cnt_lock);
}
- spin_unlock (&mount_cnt_lock);
#endif
ocfs_down_sem (&(OcfsGlobalCtxt.res), true);
@@ -505,8 +511,11 @@
AcquiredOSB = false;
}
- printk ("ocfs: Unmounting device (%s) on %s (node %d)\n", osb->dev_str,
- osb->node_cfg_info[osb->node_num]->node_name, osb->node_num);
+ if (nm_killed && osb->node_num != OCFS_INVALID_NODE_NUM)
+ printk ("ocfs: Unmounting device (%s) on %s (node %d)\n",
+ osb->dev_str,
+ osb->node_cfg_info[osb->node_num]->node_name,
+ osb->node_num);
/* Free all nodecfgs */
for (i = 0; i < OCFS_MAXIMUM_NODES; ++i) {
Modified: trunk/libocfs/Linux/ocfsport.c
===================================================================
--- trunk/libocfs/Linux/ocfsport.c 2004-05-12 19:01:28 UTC (rev 31)
+++ trunk/libocfs/Linux/ocfsport.c 2004-05-19 20:12:06 UTC (rev 32)
@@ -223,13 +223,15 @@
#ifdef HAVE_NPTL
spin_lock_irq (¤t->sighand->siglock);
tmpsig = current->blocked;
- siginitsetinv (¤t->blocked, SHUTDOWN_SIGS);
+// siginitsetinv (¤t->blocked, SHUTDOWN_SIGS);
+ siginitsetinv (¤t->blocked, sigmask(SIGINT));
recalc_sigpending ();
spin_unlock_irq (¤t->sighand->siglock);
#else
spin_lock_irq (¤t->sigmask_lock);
tmpsig = current->blocked;
- siginitsetinv (¤t->blocked, SHUTDOWN_SIGS);
+// siginitsetinv (¤t->blocked, SHUTDOWN_SIGS);
+ siginitsetinv (¤t->blocked, sigmask(SIGINT));
recalc_sigpending (current);
spin_unlock_irq (¤t->sigmask_lock);
#endif
@@ -434,12 +436,10 @@
if (inode_data_is_oin (inode)) {
ocfs_inode *f = ((ocfs_inode *)inode->u.generic_ip);
- if (f == NULL) {
- LOG_ERROR_STR ("bad inode oin");
+ if (!f || !IS_VALID_OIN(f)) {
*off = -1;
return false;
} else {
- OCFS_ASSERT(IS_VALID_OIN(f));
if (oin != NULL)
*oin = f;
if (S_ISDIR (inode->i_mode))
@@ -558,7 +558,6 @@
if (map->initialized) {
spin_lock(&(map->lock));
- #warning RACE! need to retest map->initialized here!
map->capacity = 0;
map->count = 0;
ocfs_safefree (map->buf);
@@ -582,7 +581,6 @@
LOG_ENTRY ();
OCFS_ASSERT (map != NULL);
- #warning this locking almost has to be a bug
spin_lock(&(map->lock));
ret = map->count;
spin_unlock(&(map->lock));
@@ -650,10 +648,7 @@
LOG_ENTRY ();
- if (!map->initialized) {
- LOG_ERROR_STR ("ExtentMap is not initialized");
- goto bail;
- }
+ OCFS_ASSERT(map != NULL && map->initialized == true);
/* attempt to coalesce this into an existing entry */
@@ -779,12 +774,8 @@
LOG_ENTRY ();
- OCFS_ASSERT (map != NULL);
+ OCFS_ASSERT(map != NULL && map->initialized == true);
- if (!map->initialized) {
- LOG_ERROR_STATUS (-EFAIL);
- goto bail;
- }
spin_lock(&(map->lock));
if ((ret =
@@ -828,7 +819,6 @@
release_spinlock:
spin_unlock(&(map->lock));
-bail:
LOG_EXIT_ULONG (ret);
return ret;
} /* ocfs_extent_map_add */
@@ -898,12 +888,8 @@
LOG_ENTRY ();
- OCFS_ASSERT (map != NULL);
+ OCFS_ASSERT(map != NULL && map->initialized == true);
- if (!map->initialized) {
- LOG_ERROR_STR ("BUG! Uninitialized ExtentMap!");
- goto bail;
- }
spin_lock(&(map->lock));
for (idx = 0; idx < map->count; idx++) {
@@ -925,7 +911,6 @@
}
spin_unlock(&(map->lock));
-bail:
*index = idx;
LOG_EXIT_ULONG (ret);
@@ -944,10 +929,8 @@
LOG_ENTRY ();
- OCFS_ASSERT (map != NULL);
+ OCFS_ASSERT(map != NULL && map->initialized == true);
- if (!map->initialized)
- goto bail;
spin_lock(&(map->lock));
if (runindex >= map->count)
goto release_spinlock;
@@ -959,7 +942,6 @@
release_spinlock:
spin_unlock(&(map->lock));
-bail:
LOG_EXIT_ULONG (ret);
return ret;
More information about the Ocfs-tools-commits
mailing list