[Ocfs2-commits] mfasheh commits r911 - in trunk/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon May 10 21:12:07 CDT 2004
Author: mfasheh
Date: 2004-05-10 20:12:05 -0500 (Mon, 10 May 2004)
New Revision: 911
Modified:
trunk/src/alloc.c
trunk/src/dcache.c
trunk/src/dir.c
trunk/src/dlm.c
trunk/src/file.c
trunk/src/hash.c
trunk/src/inc/ocfs.h
trunk/src/inc/proto.h
trunk/src/inode.c
trunk/src/io.c
trunk/src/journal.c
trunk/src/lockres.c
trunk/src/namei.c
trunk/src/nm.c
trunk/src/oin.c
trunk/src/super.c
trunk/src/vote.c
Log:
* Fix a bug in get_process_vote_action where we weren't figuring out
the relase lock case of delete/rename.
* fix a deadlock with acquire_lockres when verify_update_inode -->
update_lockres is called from process_vote
* fix a bug in ocfs_process_vote where we were deferencing a null
pointer.
* And now the big one... We no longer vote based on dirnode
offset. All voting is done on file entries, via file entry offset. The
voteoff/feoff distinction is no more. All the code which had to make a
distinction between the two has been cleaned up.
Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/alloc.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -297,8 +297,7 @@
osb->vol_layout.root_int_off;
for (i = 0; i < OCFS_MAXIMUM_NODES; i++, lock_id += osb->sect_size) {
if (free_dir_node[i] != NULL) {
- dirnode_inode[i] = ocfs_iget(osb, lock_id, lock_id,
- NULL);
+ dirnode_inode[i] = ocfs_iget(osb, lock_id, NULL);
if (!dirnode_inode[i]) {
status = -EINVAL;
LOG_ERROR_STATUS (status);
@@ -320,8 +319,7 @@
osb->vol_layout.root_int_off;
for (i = 0; i < OCFS_MAXIMUM_NODES; i++, lock_id += osb->sect_size) {
if (free_ext_node[i] != NULL) {
- extnode_inode[i] = ocfs_iget(osb, lock_id, lock_id,
- NULL);
+ extnode_inode[i] = ocfs_iget(osb, lock_id, NULL);
if (!extnode_inode[i]) {
status = -EINVAL;
LOG_ERROR_STATUS (status);
@@ -340,7 +338,7 @@
}
if (free_vol_bits != NULL) {
- vol_inode = ocfs_iget(osb, OCFS_BITMAP_LOCK_OFFSET, 0, NULL);
+ vol_inode = ocfs_iget(osb, OCFS_BITMAP_LOCK_OFFSET, NULL);
if (!vol_inode) {
status = -EINVAL;
LOG_ERROR_STATUS (status);
@@ -2736,7 +2734,7 @@
down (&(osb->vol_alloc_sem));
if (!bitmap_inode) {
- bitmap_inode = ocfs_iget(osb, OCFS_BITMAP_LOCK_OFFSET, 0, NULL);
+ bitmap_inode = ocfs_iget(osb, OCFS_BITMAP_LOCK_OFFSET, NULL);
if (!bitmap_inode) {
status = -EINVAL;
LOG_ERROR_STR("Could not get bitmap inode!");
@@ -2960,7 +2958,7 @@
OCFS_ASSERT (blockSize);
lockId = (bm_file * osb->sect_size) + osb->vol_layout.root_int_off;
- inode = ocfs_iget(osb, lockId, lockId, NULL);
+ inode = ocfs_iget(osb, lockId, NULL);
if (!inode) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
@@ -3229,11 +3227,10 @@
LOG_ENTRY ();
+ offset = GET_INODE_FEOFF(inode);
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
- if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
- offset = fe->u.child_dirnode;
- else
- offset = fe->this_sector;
+ if (offset != fe->this_sector)
+ BUG();
OCFS_BH_PUT_DATA(fe_bh);
if (inode)
@@ -3428,7 +3425,7 @@
atomic_inc(&bm_inode->i_count);
local_inode = bm_inode;
} else {
- local_inode = ocfs_iget(osb, OCFS_BITMAP_LOCK_OFFSET, 0, NULL);
+ local_inode = ocfs_iget(osb, OCFS_BITMAP_LOCK_OFFSET, NULL);
if (!local_inode) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
@@ -3744,7 +3741,7 @@
if (!main_bm_inode)
main_bm_inode = ocfs_iget(osb, OCFS_BITMAP_LOCK_OFFSET,
- 0, NULL);
+ NULL);
if (!main_bm_inode) {
up (&(osb->vol_alloc_sem));
Modified: trunk/src/dcache.c
===================================================================
--- trunk/src/dcache.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/dcache.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -68,7 +68,7 @@
if (INODE_DELETED(inode)) {
LOG_TRACE_ARGS("dentry_revalidate: inode %lu (%llu) deleted, "
"returning false\n", inode->i_ino,
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
goto bail;
}
@@ -90,7 +90,7 @@
/* TODO: optimize */
down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->needs_verification = 1;
- tmpstat = ocfs_verify_update_inode(osb, inode, &needs_trunc);
+ tmpstat = ocfs_verify_update_inode(osb, inode, &needs_trunc, 0);
if (tmpstat < 0)
LOG_ERROR_STATUS (tmpstat);
up (&(OCFS_I(inode)->priv_sem));
Modified: trunk/src/dir.c
===================================================================
--- trunk/src/dir.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/dir.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -49,7 +49,6 @@
ocfs_file *ofile;
struct buffer_head *entry_bh = NULL;
ocfs_file_entry *entry = NULL;
- __u64 rootOff;
int ret = 0;
struct inode *inode = filp->f_dentry->d_inode;
@@ -65,8 +64,6 @@
goto bail;
}
- rootOff = GET_INODE_VOTEOFF(inode);
-
if (!S_ISDIR (inode->i_mode)) {
LOG_TRACE_STR ("Not a dir");
ret = -ENOTDIR;
@@ -119,13 +116,13 @@
if (r < 0)
LOG_ERROR_STR("filldir failed");
} else {
- r = ocfs_find_files_on_disk (osb, rootOff, NULL, &entry_bh,
+ r = ocfs_find_files_on_disk (osb, NULL, &entry_bh,
ofile, inode, 1);
if (r < 0)
break;
entry = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(entry_bh); /* read */
- voteoff = (entry->attribs & OCFS_ATTRIB_DIRECTORY) ? entry->u.child_dirnode : entry->this_sector;
+ voteoff = entry->this_sector;
ino = ocfs_inode_hash_lookup_ino(osb, voteoff);
r=filldir (dirent, entry->filename, strlen (entry->filename), filp->f_pos, ino, DT_UNKNOWN);
if (r < 0) {
@@ -160,7 +157,8 @@
/* ocfs_find_files_on_disk()
* NOTE: this should always be called with inode->i_sem taken!
*/
-int ocfs_find_files_on_disk (ocfs_super * osb, __u64 parent_off, struct qstr * file_name, struct buffer_head ** fe_bh, ocfs_file * ofile, struct inode *inode, int take_lock)
+/* parent off changed to file entry offset of parent! */
+int ocfs_find_files_on_disk (ocfs_super * osb, struct qstr * file_name, struct buffer_head ** fe_bh, ocfs_file * ofile, struct inode *inode, int take_lock)
{
int status = -ENOENT;
__u64 thisDirNode;
@@ -172,13 +170,14 @@
struct buffer_head **bhs = NULL;
int bufsz, nbhs, i;
__u32 lock_type = OCFS_DLM_ENABLE_CACHE_LOCK;
+ __u64 parent_off = GET_INODE_FEOFF(inode);
LOG_ENTRY_ARGS ("(osb=%p, parent=%llu, fname=%p, fe_bh=%p, ofile=%p, inode=%p)\n", osb, parent_off, file_name, fe_bh, ofile, inode);
nbhs = osb->vol_layout.dir_node_size >> osb->sect_size_bits;
bufsz = nbhs * (sizeof(struct buffer_head *));
- thisDirNode = parent_off;
+ thisDirNode = OCFS_I(inode)->u.child_dirnode;
if (ofile == NULL) {
temp_bhs = 1;
bhs = ocfs_malloc (bufsz);
@@ -862,6 +861,9 @@
/* briefly grab LockNode and get useful bits of info. */
LockNode = (ocfs_dir_node *) OCFS_BH_GET_DATA_READ(lockbh); /* read */
+ if (!IS_VALID_DIR_NODE(LockNode))
+ BUG();
+
lock_off = LockNode->node_disk_off;
head_del = LockNode->head_del_ent_node;
OCFS_BH_PUT_DATA(lockbh);
@@ -981,7 +983,7 @@
* ocfs_insert_file()
*
*/
-int ocfs_insert_file (ocfs_super * osb, ocfs_file_entry * InsertEntry, struct buffer_head *lock_bh, struct buffer_head **insert_bh, ocfs_journal_handle * handle, struct inode *dir_inode, struct inode *file_inode)
+int ocfs_insert_file (ocfs_super * osb, ocfs_file_entry * InsertEntry, struct buffer_head **insert_bh, ocfs_journal_handle * handle, struct inode *dir_inode, struct inode *file_inode)
{
int status = 0;
__u64 bitmapOffset = 0;
@@ -1001,6 +1003,7 @@
__u64 locknode_head_del;
__u8 dir_num_ent_used;
unsigned long blk;
+ struct buffer_head *lock_bh = NULL;
LOG_ENTRY ();
@@ -1013,6 +1016,14 @@
* since we brelse it here, then again when the
* ocfs_release_lock happens. */
+ dir_off = OCFS_I(dir_inode)->u.child_dirnode;
+ status = ocfs_read_bh(osb, dir_off, &lock_bh, OCFS_BH_CACHED,
+ dir_inode);
+ if (status < 0) {
+ LOG_ERROR_STATUS(status);
+ goto leave;
+ }
+
/* alloc bhs */
bhs = (struct buffer_head **)ocfs_malloc(length);
if (bhs == NULL) {
@@ -1037,6 +1048,12 @@
/* route the new file entry to the proper dir_off */
LockNode = (ocfs_dir_node *)OCFS_BH_GET_DATA_READ(lock_bh); /* read */
+ if (!IS_VALID_DIR_NODE(LockNode)) {
+ LOG_ERROR_STR ("Invalid dir node");
+ status = -EFAIL;
+ goto leave;
+ }
+
locknode_off = LockNode->node_disk_off;
locknode_head_del = LockNode->head_del_ent_node;
@@ -1301,6 +1318,9 @@
ocfs_safefree(bhs);
}
+ if (lock_bh)
+ brelse(lock_bh);
+
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_insert_file */
Modified: trunk/src/dlm.c
===================================================================
--- trunk/src/dlm.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/dlm.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -61,13 +61,11 @@
__u32 wait;
int publish_flag = 0;
struct buffer_head **bhs = NULL;
- __u64 feoff;
LOG_ENTRY_ARGS ("(osb=0x%p, id=%llu, ty=%u, fl=%u, vm=0x%08x)\n",
osb, lock_id, lock_type, flags,
(__u32)(*vote_map & 0xFFFFFFFFULL));
- feoff = inode ? GET_INODE_FEOFF(inode) : 0ULL;
*vote_map &= ~(1 << osb->node_num);
pubmap = osb->publ_map;
@@ -134,13 +132,12 @@
pubsect->vote_map = *vote_map;
pubsect->vote_type = flags;
pubsect->dir_ent = lock_id;
- pubsect->fe_off = feoff;
OCFS_BH_PUT_DATA(bhs[osb->node_num]);
#ifdef VERBOSE_LOCKING_TRACE
- printk("ocfs_disk_request_vote: lockid = %llu, "
- "fe_off=%llu\n", lock_id, feoff);
+ printk("ocfs_disk_request_vote: lockid = %llu\n",lock_id);
#endif
+
pub_off = osb->vol_layout.publ_sect_off + (osb->node_num * osb->sect_size);
status = ocfs_write_bh (osb, bhs[osb->node_num], 0, NULL);
@@ -407,8 +404,8 @@
finally:
if (lockres && status >= 0)
- status = ocfs_update_lockres (osb, GET_INODE_VOTEOFF(inode), &bh,
- NULL, 0, inode, 0);
+ status = ocfs_update_lockres (osb, GET_INODE_FEOFF(inode), &bh,
+ NULL, 0, inode, 0, 0);
if (bh)
brelse(bh);
@@ -621,7 +618,7 @@
LOG_ENTRY ();
- offset = GET_INODE_VOTEOFF(inode);
+ offset = GET_INODE_FEOFF(inode);
status = ocfs_read_bh (osb, offset, bh, 0, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
@@ -728,7 +725,7 @@
OCFS_MAXIMUM_NODES)) {
LOG_TRACE_ARGS ("Master (%u) dead, lockid %llu\n",
lockres->master_node_num,
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
status = 0;
goto bail;
}
@@ -738,7 +735,7 @@
if (lockres->master_node_num == osb->node_num) {
LOG_TRACE_ARGS ("Added node to map 0x%08x, lockid %llu\n",
(__u32)(lockres->oin_openmap & 0xFFFFFFFFULL),
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
lockres->oin_openmap |= (1 << osb->node_num);
status = ocfs_update_disk_lock (osb, DLOCK_FLAG_OPEN_MAP,
@@ -762,7 +759,7 @@
ocfs_sleep (500);
if (ocfs_task_interruptible (osb)) {
LOG_TRACE_ARGS("interrupted... lockid=%llu\n",
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
status = -EINTR;
goto bail;
}
@@ -826,6 +823,7 @@
OCFS_ASSERT(lock_type != OCFS_DLM_NO_LOCK);
OCFS_ASSERT(lock_type != OCFS_DLM_SHARED_LOCK);
OCFS_ASSERT(inode);
+ OCFS_ASSERT(GET_INODE_FEOFF(inode) == lock_id);
if (bh != NULL)
b = bh;
@@ -834,7 +832,8 @@
flags |= FLAG_ACQUIRE_LOCK;
- status = ocfs_update_lockres (osb, lock_id, b, &updated, 0, inode, 1);
+ status = ocfs_update_lockres (osb, lock_id, b, &updated, 0, inode,
+ 1, 0);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto bail;
@@ -857,6 +856,9 @@
}
disklock = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(*b); /* read */
+ if (!IS_VALID_FILE_ENTRY(disklock))
+ BUG();
+
if (lockres->master_node_num != osb->node_num ||
lockres->master_node_num != DISK_LOCK_CURRENT_MASTER (disklock)) {
lockres->master_node_num = DISK_LOCK_CURRENT_MASTER (disklock);
@@ -874,7 +876,7 @@
if (unlikely(lockres->master_node_num >= OCFS_MAXIMUM_NODES && !no_owner)) {
LOG_ERROR_ARGS("lockres: master_node=%d, owner=%s, lockid=%llu\n",
lockres->master_node_num, no_owner?"no":"yes",
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
LOG_ERROR_STATUS (status = -EINVAL);
ocfs_release_lockres (lockres); // ocfs_acquire_lock
goto finally;
@@ -967,7 +969,7 @@
#ifdef VERBOSE_LOCKING_TRACE
printk("lockres: lockid=%llu, this=%d, master=%d, locktype=%d, flags=%08x, ronode=%d, romap=%08x\n",
- GET_INODE_VOTEOFF(inode), osb->node_num, lockres->master_node_num, lockres->lock_type,
+ GET_INODE_FEOFF(inode), osb->node_num, lockres->master_node_num, lockres->lock_type,
flags|extra_lock_flags, lockres->readonly_node, (__u32)(lockres->readonly_map & 0xFFFFFFFFULL));
#endif
if (wait_on_recovery && !((flags|extra_lock_flags) & FLAG_FILE_RECOVERY)) {
@@ -990,7 +992,7 @@
ocfs_sleep (500);
if (ocfs_task_interruptible (osb)) {
LOG_TRACE_ARGS("interrupted... lockid=%llu\n",
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
status = -EINTR;
goto finally;
}
@@ -1307,7 +1309,7 @@
LOG_ENTRY ();
- lock_id = GET_INODE_VOTEOFF(inode);
+ lock_id = GET_INODE_FEOFF(inode);
if (flags & FLAG_READDIR) {
if (flags & (FLAG_CHANGE_MASTER | FLAG_REMASTER)) {
@@ -1463,7 +1465,7 @@
if (status == -EAGAIN) {
if (ocfs_task_interruptible (osb)) {
LOG_TRACE_ARGS("interrupted.... lockid=%llu\n",
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
status = -EINTR;
}
}
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/file.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -30,7 +30,7 @@
extern struct semaphore recovery_list_sem;
extern spinlock_t oin_num_ext_lock;
-static int ocfs_change_file_attrib (ocfs_super * osb, __u64 parent_off, __u64 file_size, __u64 file_off, struct iattr *attr, struct inode *inode);
+static int ocfs_change_file_attrib (ocfs_super * osb, __u64 file_off, struct iattr *attr, struct inode *inode);
static int ocfs_truncate_file (ocfs_super * osb, __u64 file_off, __u64 file_size, struct inode *inode);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
@@ -163,7 +163,8 @@
}
if (OCFS_I(inode)->needs_verification) {
- status = ocfs_verify_update_inode (osb, inode, &truncate_pages);
+ status = ocfs_verify_update_inode (osb, inode, &truncate_pages,
+ 0);
if (status < 0) {
/* disable VOLUME TODO */
LOG_ERROR_STATUS (status);
@@ -406,12 +407,11 @@
/* ocfs_change_file_attrib()
*
*/
-static int ocfs_change_file_attrib (ocfs_super * osb, __u64 parent_off, __u64 file_size, __u64 file_off, struct iattr *attr, struct inode *inode)
+static int ocfs_change_file_attrib (ocfs_super * osb, __u64 file_off, struct iattr *attr, struct inode *inode)
{
int status = 0;
int tmpstat;
ocfs_file_entry *fileEntry = NULL;
- __u64 dirOffset = 0;
int bAcquiredLock = 0;
__u64 lockId = 0;
__u32 lockFlags = 0, locktype = 0;
@@ -490,8 +490,6 @@
SET_VALID_BIT (fileEntry->sync_flags);
fileEntry->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
- dirOffset = fileEntry->this_sector;
-
flags = OCFS_FE_CACHE_FLAGS(osb, fileEntry);
OCFS_BH_PUT_DATA(bh);
@@ -610,7 +608,8 @@
if (OCFS_I(inode)->needs_verification) {
LOG_TRACE_STR ("OIN_NEEDS_VERIFICATION");
down (&(OCFS_I(inode)->priv_sem));
- status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
+ status = ocfs_verify_update_inode (osb, inode, &needs_trunc,
+ 0);
up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
@@ -736,7 +735,8 @@
if (OCFS_I(inode)->needs_verification) {
down (&(OCFS_I(inode)->priv_sem));
- status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
+ status = ocfs_verify_update_inode (osb, inode, &needs_trunc,
+ 0);
up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
@@ -1191,7 +1191,7 @@
__u64 newsize;
int status;
ocfs_super *osb = NULL;
- __u64 parentOff, fileOff;
+ __u64 fileOff;
struct super_block *sb = inode->i_sb;
int extended = 0;
int needs_trunc = 0;
@@ -1245,14 +1245,14 @@
goto bail;
/* get the file and parent offsets, and the file oin if present */
- fileOff = GET_INODE_VOTEOFF(inode);
- parentOff = GET_INODE_VOTEOFF(parentInode);
+ fileOff = GET_INODE_FEOFF(inode);
if (attr->ia_valid & ATTR_SIZE) {
down (&(OCFS_I(inode)->priv_sem));
if (OCFS_I(inode)->needs_verification) {
LOG_TRACE_STR ("OIN_NEEDS_VERIFICATION");
- status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
+ status = ocfs_verify_update_inode (osb, inode,
+ &needs_trunc, 0);
if (status < 0) {
LOG_ERROR_STATUS (status);
LOG_TRACE_STR ("TODO: disable volume");
@@ -1289,14 +1289,9 @@
up (&(OCFS_I(inode)->priv_sem));
}
- /* if directory, put FILE_ENTRY ptr into fileOff */
- if (S_ISDIR (inode->i_mode))
- fileOff = GET_INODE_FEOFF(inode);
-
status = -EFAIL;
if ((fileOff != -1) && !extended) {
- status = ocfs_change_file_attrib(osb, parentOff, newsize,
- fileOff, attr, inode);
+ status = ocfs_change_file_attrib(osb, fileOff, attr, inode);
if (status < 0) {
if (status != -EINTR)
LOG_ERROR_STATUS (status);
@@ -1385,7 +1380,7 @@
goto bail;
down (&(OCFS_I(inode)->priv_sem));
- status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
+ status = ocfs_verify_update_inode (osb, inode, &needs_trunc, 0);
up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
Modified: trunk/src/hash.c
===================================================================
--- trunk/src/hash.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/hash.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -591,7 +591,7 @@
INIT_LIST_HEAD(&inum->i_list);
inum->i_state = INUM_UNBOUND;
inum->i_inode = NULL;
- inum->i_voteoff = inum->i_feoff = 0;
+ inum->i_feoff = 0;
bail:
return(inum);
@@ -681,11 +681,9 @@
/* this log_error_args is mainly for debugging */
if (atomic_read(&inum->i_inode->i_count) > 1)
LOG_ERROR_ARGS("inode (%lu) with i_count = %u "
- "left in system, (voteoff = "
- "%llu, fileoff = %llu)\n",
+ "left in system, fileoff = %llu)\n",
inum->i_inode->i_ino,
atomic_read(&inum->i_inode->i_count),
- inum->i_voteoff,
inum->i_feoff);
iput(inum->i_inode);
@@ -746,7 +744,7 @@
list_for_each(iter, head) {
inum = list_entry(iter, ocfs_inode_num, i_list);
- if (inum->i_voteoff == off)
+ if (inum->i_feoff == off)
break;
inum = NULL;
}
@@ -755,6 +753,7 @@
return(inum);
} /* __ocfs_inode_hash_lookup */
+#if 0
static ocfs_inode_num * __ocfs_inode_hash_feoff_lookup(ocfs_inode_hash *h,
__u64 feoff)
{
@@ -783,36 +782,32 @@
return(inum);
} /* __ocfs_inode_hash_feoff_lookup */
+#endif
/*
+ * ocfs_inode_hash_lookup()
*
- * reverse means we're not sure if the voteoff is really the voteoff
- * or the fe_off, so double check the hash.
*/
struct inode *ocfs_inode_hash_lookup(ocfs_super *osb,
- __u64 voteoff,
- int reverse)
+ __u64 offset)
{
ocfs_inode_num *inum = NULL;
ocfs_inode_hash *h = &osb->inode_hash;
struct inode * inode = NULL;
-// LOG_ENTRY_ARGS("(voteoff=%llu, reverse = %s)\n", voteoff,
+// LOG_ENTRY_ARGS("(offset=%llu, reverse = %s)\n", offset,
// reverse ? "true" : "false");
search:
spin_lock(&h->lock);
- inum = __ocfs_inode_hash_lookup(h, voteoff);
- if (!inum && reverse) {
- inum = __ocfs_inode_hash_feoff_lookup(h, voteoff);
- }
+ inum = __ocfs_inode_hash_lookup(h, offset);
if (inum) {
if (inum->i_state == INUM_UNBOUND) {
spin_unlock(&h->lock);
LOG_TRACE_ARGS("waiting for inum (%lu, %llu) to be "
- "bound\n", inum->i_ino, voteoff);
+ "bound\n", inum->i_ino, offset);
yield();
goto search;
@@ -831,17 +826,17 @@
/* used for filldir. We don't want the whole inode just i_ino if it
* exists, otherwise we return an unused inode number */
-ino_t ocfs_inode_hash_lookup_ino(ocfs_super *osb, __u64 voteoff)
+ino_t ocfs_inode_hash_lookup_ino(ocfs_super *osb, __u64 off)
{
ocfs_inode_num *inum = NULL;
ocfs_inode_hash *h = &osb->inode_hash;
ino_t ino = OCFS_UNUSED_INODE_NUMBER;
- LOG_ENTRY_ARGS("(voteoff=%llu)\n", voteoff);
+ LOG_ENTRY_ARGS("(off=%llu)\n", off);
spin_lock(&h->lock);
- inum = __ocfs_inode_hash_lookup(h, voteoff);
+ inum = __ocfs_inode_hash_lookup(h, off);
if (inum)
ino = inum->i_ino;
@@ -862,7 +857,6 @@
printk(" i_state = %s\n", (inum->i_state == INUM_BOUND)
? "INUM_BOUND" : "INUM_UNBOUND");
printk(" i_ino = %lu\n", inum->i_ino);
- printk(" i_voteoff = %llu\n", inum->i_voteoff);
printk(" i_feoff = %llu\n", inum->i_feoff);
printk(" i_inode = 0x%p\n", inum->i_inode);
}
@@ -876,7 +870,6 @@
printk("ocfs: inode info\n");
printk(" inode = 0x%p\n", inode);
printk(" i_ino = %lu\n", inode->i_ino);
- printk(" voteoff = %llu\n", OCFS_I(inode)->voteoff);
printk(" feoff = %llu\n", OCFS_I(inode)->feoff);
printk(" i_count = %u\n", atomic_read(&inode->i_count));
printk(" deleted = %s\n", INODE_DELETED(inode) ? "yes" : "no");
@@ -891,8 +884,7 @@
* number passed in.
*/
unsigned long ocfs_inode_hash_insert(ocfs_super *osb,
- __u64 offset,
- __u64 fe_off)
+ __u64 offset)
{
ocfs_inode_hash *h = &osb->inode_hash;
ocfs_inode_num *inum = NULL;
@@ -902,8 +894,7 @@
unsigned long ino = 0;
struct super_block *sb = osb->sb;
- LOG_ENTRY_ARGS("(offset = %llu, fe_off = %llu)\n",
- offset, fe_off);
+ LOG_ENTRY_ARGS("(offset = %llu)\n)", offset);
again:
spin_lock(&h->lock);
@@ -911,17 +902,10 @@
inum = __ocfs_inode_hash_lookup(h, offset);
/* whoa, offset better be the same! */
- if (inum && (inum->i_voteoff != offset)) {
- LOG_ERROR_ARGS("inum=%p, i_voteoff=%llu, offset=%llu)\n",
- inum, inum ? inum->i_voteoff : 0ULL,
- offset);
- BUG();
- }
-
- if (inum && (inum->i_feoff != fe_off)) {
+ if (inum && (inum->i_feoff != offset)) {
LOG_ERROR_ARGS("inum=%p, i_feoff=%llu, fe_off=%llu)\n",
inum, inum ? inum->i_feoff : 0ULL,
- fe_off);
+ offset);
BUG();
}
@@ -942,13 +926,12 @@
new_inum = ocfs_create_inode_num();
/* root inode always has the same inode number. */
- if (offset == osb->vol_layout.root_start_off)
+ if (offset == OCFS_ROOT_INODE_FE_OFF)
ino = OCFS_ROOT_INODE_NUMBER;
else
ino = iunique(sb, OCFS_ROOT_INODE_NUMBER);
new_inum->i_ino = ino;
- new_inum->i_voteoff = offset;
- new_inum->i_feoff = fe_off;
+ new_inum->i_feoff = offset;
goto again;
}
@@ -975,31 +958,31 @@
/*
* bind an inode to an inum.
*/
-void ocfs_inode_hash_bind(ocfs_super *osb, __u64 voteoff, struct inode *inode)
+void ocfs_inode_hash_bind(ocfs_super *osb, __u64 feoff, struct inode *inode)
{
ocfs_inode_hash *h = &osb->inode_hash;
ocfs_inode_num *inum = NULL;
- LOG_ENTRY_ARGS("(voteoff=%llu, inode->i_ino = %lu)\n",
- voteoff, inode->i_ino);
+ LOG_ENTRY_ARGS("(feoff=%llu, inode->i_ino = %lu)\n",
+ feoff, inode->i_ino);
spin_lock(&h->lock);
- inum = __ocfs_inode_hash_lookup(h, voteoff);
+ inum = __ocfs_inode_hash_lookup(h, feoff);
if (!inum) {
- printk("ocfs2: lost inum (voteoff = %llu)! AIEEEE!\n",
- voteoff);
+ printk("ocfs2: lost inum (feoff = %llu)! AIEEEE!\n",
+ feoff);
ocfs_debug_print_inum(inum, inode);
BUG();
}
- if ((inum->i_voteoff != voteoff)
- || (GET_INODE_VOTEOFF(inode) != voteoff)) {
+ if ((inum->i_feoff != feoff)
+ || (GET_INODE_FEOFF(inode) != feoff)) {
LOG_ERROR_ARGS("passed=%llu, on inode=%llu, "
- "(inum voteoff = %llu, feoff = %llu)\n",
- voteoff, GET_INODE_VOTEOFF(inode),
- inum->i_voteoff, inum->i_feoff);
+ "(inum feoff = %llu)\n",
+ feoff, GET_INODE_FEOFF(inode),
+ inum->i_feoff);
BUG();
}
@@ -1008,9 +991,9 @@
"(inum=%lu, inode=%lu)\n",
inum->i_ino, inode->i_ino);
LOG_ERROR_ARGS("passed=%llu, on inode=%llu, "
- "(inum voteoff = %llu, feoff = %llu)\n",
- voteoff, GET_INODE_VOTEOFF(inode),
- inum->i_voteoff, inum->i_feoff);
+ "(inum feoff = %llu)\n",
+ feoff, GET_INODE_FEOFF(inode),
+ inum->i_feoff);
BUG();
}
@@ -1020,13 +1003,12 @@
if (ocfs_inc_icount(inode) < 0)
BUG();
- LOG_TRACE_ARGS("bound to ino %lu, voteoff=%llu, "
- "feoff=%llu\n", inode->i_ino,
- inum->i_voteoff, inum->i_feoff);
+ LOG_TRACE_ARGS("bound to ino %lu, feoff=%llu)\n",
+ inode->i_ino, inum->i_feoff);
} else if (inum->i_inode != inode) {
LOG_ERROR_ARGS("Inum is bound to a different inode! "
"(%llu) (%lu) (%lu) (deleted = %u)\n",
- voteoff, inode->i_ino,
+ feoff, inode->i_ino,
inum->i_inode->i_ino,
INODE_DELETED(inum->i_inode));
ocfs_debug_print_inum(inum, inode);
@@ -1080,9 +1062,8 @@
if (!inum->i_inode || inum->i_state == INUM_UNBOUND)
LOG_ERROR_ARGS("deleting inum in unbound state! (state = %d, "
- "voteoff = %llu, feoff = %llu, i_ino = %lu\n",
- inum->i_state, inum->i_voteoff,
- inum->i_feoff, inum->i_ino);
+ "feoff = %llu, i_ino = %lu\n",
+ inum->i_state, inum->i_feoff, inum->i_ino);
if (inum->i_inode)
iput(inum->i_inode);
@@ -1104,8 +1085,7 @@
*/
int ocfs_inode_rehash(ocfs_inode_hash *h,
__u64 oldoff,
- __u64 newoff,
- __u64 new_fe_off)
+ __u64 newoff)
{
int status = 0;
ocfs_inode_num *inum = NULL;
@@ -1113,9 +1093,7 @@
struct list_head *head;
int bucket;
- LOG_ENTRY_ARGS("(oldoff = %llu, newoff = %llu, "
- "new_fe_off = %llu)\n",
- oldoff, newoff, new_fe_off);
+ LOG_ENTRY_ARGS("(oldoff = %llu, newoff = %llu)\n", oldoff, newoff);
spin_lock(&h->lock);
@@ -1140,8 +1118,7 @@
list_del(&inum->i_list);
- inum->i_voteoff = newoff;
- inum->i_feoff = new_fe_off;
+ inum->i_feoff = newoff;
bucket = OCFS_INODE_HASH(h, newoff);
head = &h->hash[bucket];
@@ -1153,23 +1130,4 @@
return status;
} /* ocfs_inode_rehash */
-#if 0
-/* NOTE: After a put, you can't trust 'inum', as it may have been
- * freed. Returns true if we freed it from memory. */
-static inline int __put_inum(ocfs_inode_hash *h, ocfs_inode_num *inum)
-{
- int free = 0;
- free = atomic_dec_and_lock(&inum->i_refcnt, &h->lock);
-
- if (free) {
- list_del(&inum->i_list);
- h->num_ents--;
- spin_unlock(&h->lock);
- ocfs_free_inode_num(inum);
- }
-
- return(free);
-}
-#endif
-
Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/inc/ocfs.h 2004-05-11 01:12:05 UTC (rev 911)
@@ -1595,7 +1595,6 @@
/* always valid, just a simple back pointer. */
struct inode *inode;
- __u64 voteoff;
__u64 feoff;
/* These fields are protected by priv_sem */
@@ -1616,6 +1615,16 @@
atomic_t i_clean_buffer_seq;
__u32 flags; /* see below */
+ /* stolen right off of ocfs_file_entry */
+ union {
+ __u64 fe_private;
+ __u64 child_dirnode;
+ struct _ip_bitinfo {
+ __u32 used_bits;
+ __u32 total_bits;
+ } ip_bitinfo;
+ } u;
+
ocfs_lock_res i_lockres;
} ocfs_inode_private;
@@ -1650,13 +1659,6 @@
#define SET_INODE_JOURNAL(i) (OCFS_I(i)->flags |= OCFS_INODE_JOURNAL)
#define CLEAR_INODE_JOURNAL(i) (OCFS_I(i)->flags &= (~OCFS_INODE_JOURNAL))
-#define SET_INODE_VOTEOFF(i,o) \
-do { \
- OCFS_I(i)->voteoff = o; \
-} while (0)
-
-#define GET_INODE_VOTEOFF(i) OCFS_I(i)->voteoff
-
#define SET_INODE_FEOFF(i,o) \
do { \
OCFS_I(i)->feoff = o; \
@@ -1743,8 +1745,6 @@
} i_state;
struct list_head i_list;
unsigned long i_ino;
- __u64 i_voteoff;/* fe->this_sector OR
- * fe->child_dirnode */
__u64 i_feoff; /* used only for directory inodes,
* points to parent fe of
* dirnode. for files i_voteoff == i_feoff,
@@ -2159,7 +2159,6 @@
__u32 flags;
__u64 lock_seq_num;
__u8 open_handle;
- __u64 fe_off;
}
OCFS_GCC_ATTR_PACKALGN
ocfs_dlm_msg_hdr;
@@ -2398,8 +2397,7 @@
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("voteoff=%llu, feoff=%llu, deleted=%u\n",
- GET_INODE_VOTEOFF(inode),
+ LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n",
GET_INODE_FEOFF(inode),
INODE_DELETED(inode));
return -EINVAL;
@@ -2451,8 +2449,7 @@
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("voteoff=%llu, feoff=%llu, deleted=%u\n",
- GET_INODE_VOTEOFF(inode),
+ LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n",
GET_INODE_FEOFF(inode),
INODE_DELETED(inode));
@@ -2473,10 +2470,8 @@
typedef struct _ocfs_find_inode_args
{
- __u64 voteoff;
__u64 feoff;
struct buffer_head *fe_bh;
- int skip_bind;
unsigned long ino;
__u32 flags;
}
Modified: trunk/src/inc/proto.h
===================================================================
--- trunk/src/inc/proto.h 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/inc/proto.h 2004-05-11 01:12:05 UTC (rev 911)
@@ -41,7 +41,7 @@
int ocfs_lookup_vote_request_obj (ocfs_super *osb, ocfs_vote_obj_lookup_data *data);
-int ocfs_update_lockres (ocfs_super * osb, __u64 lock_id, struct buffer_head **bh, __u32 * updated, __u32 timeout, struct inode *inode,int reread);
+int ocfs_update_lockres (ocfs_super * osb, __u64 lock_id, struct buffer_head **bh, __u32 * updated, __u32 timeout, struct inode *inode, int reread, int locked);
int ocfs_acquire_lockres (ocfs_lock_res * lockres, __u32 timeout);
void ocfs_release_lockres (ocfs_lock_res * lockres);
void ocfs_init_lockres (ocfs_super * osb, struct inode *inode);
@@ -149,7 +149,7 @@
void ocfs_linux_dbg_free (const void *Buffer);
-int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode, int *needs_trunc);
+int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode, int *needs_trunc, int lockres_locked);
int ocfs_inode_fill_ext_map(ocfs_super * osb, struct buffer_head * fe_bh, struct inode *inode);
int ocfs_inode_open(ocfs_super *osb, struct buffer_head *fe_bh,
ocfs_journal_handle *handle, struct inode *inode);
@@ -233,9 +233,9 @@
int ocfs_rename (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry);
int ocfs_symlink (struct inode *dir, struct dentry *dentry, const char *symname);
-int ocfs_find_files_on_disk (ocfs_super * osb, __u64 parent_off, struct qstr * file_name, struct buffer_head ** fe_bh, ocfs_file * ofile, struct inode *inode,int take_lock);
+int ocfs_find_files_on_disk (ocfs_super * osb, struct qstr * file_name, struct buffer_head ** fe_bh, ocfs_file * ofile, struct inode *inode, int take_lock);
int ocfs_write_force_dir_node (ocfs_super * osb, struct buffer_head *bhs[], __s32 idx);
-int ocfs_insert_file (ocfs_super * osb, ocfs_file_entry * InsertEntry, struct buffer_head *lock_bh, struct buffer_head **insert_bh, ocfs_journal_handle * handle, struct inode *dir_inode, struct inode *file_inode);
+int ocfs_insert_file (ocfs_super * osb, ocfs_file_entry * InsertEntry, struct buffer_head **insert_bh, ocfs_journal_handle * handle, struct inode *dir_inode, struct inode *file_inode);
int ocfs_reindex_dir_node (ocfs_super * osb, __u64 DirNodeOffset, struct buffer_head *bhs[], ocfs_journal_handle *handle, struct inode *dir_inode);
int ocfs_recover_dir_node (ocfs_super * osb, __u64 OrigDirNodeOffset, __u64 SavedDirNodeOffset);
int ocfs_remove_file (ocfs_super * osb, struct buffer_head *febh, struct buffer_head *lockbh, ocfs_journal_handle *handle, struct inode *dir_inode, struct inode *file_inode);
@@ -263,20 +263,17 @@
int ocfs_inode_hash_init(ocfs_super *osb);
void ocfs_inode_hash_destroy(ocfs_inode_hash *h);
unsigned long ocfs_inode_hash_insert(ocfs_super *osb,
- __u64 offset,
- __u64 fe_off);
-void ocfs_inode_hash_bind(ocfs_super *osb, __u64 voteoff, struct inode *inode);
+ __u64 offset);
+void ocfs_inode_hash_bind(ocfs_super *osb, __u64 feoff, struct inode *inode);
void ocfs_inode_hash_remove(ocfs_inode_hash *h, __u64 off);
int ocfs_inode_rehash(ocfs_inode_hash *h,
__u64 oldoff,
- __u64 newoff,
- __u64 new_fe_off);
-struct inode *ocfs_iget(ocfs_super *osb, __u64 voteoff, __u64 feoff,
+ __u64 newoff);
+struct inode *ocfs_iget(ocfs_super *osb, __u64 feoff,
struct buffer_head *fe_bh);
struct inode *ocfs_inode_hash_lookup(ocfs_super *osb,
- __u64 voteoff,
- int reverse);
-ino_t ocfs_inode_hash_lookup_ino(ocfs_super *osb, __u64 voteoff);
+ __u64 offset);
+ino_t ocfs_inode_hash_lookup_ino(ocfs_super *osb, __u64 off);
void ocfs_init_timeout(ocfs_timeout *to);
void ocfs_set_timeout(ocfs_timeout *to, __u32 timeout);
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/inode.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -140,7 +140,7 @@
*
* If you give me both, I'll prefer fe_bh.
*/
-struct inode *ocfs_iget(ocfs_super *osb, __u64 voteoff, __u64 feoff,
+struct inode *ocfs_iget(ocfs_super *osb, __u64 feoff,
struct buffer_head *fe_bh)
{
struct inode *inode = NULL;
@@ -149,12 +149,11 @@
ocfs_find_inode_args args;
__u32 flags = 0;
- LOG_ENTRY_ARGS("(voteoff = %llu, feoff = %llu, fe_bh = %p)\n",
- voteoff, feoff, fe_bh);
+ LOG_ENTRY_ARGS("(feoff = %llu, fe_bh = %p)\n", feoff, fe_bh);
/* Shortcut: if they ask for the root dirnode, just return
* it. */
- if (voteoff == osb->vol_layout.root_start_off) {
+ if (feoff == OCFS_ROOT_INODE_FE_OFF) {
LOG_TRACE_ARGS("Asked for root dirnode (%llu)\n",
feoff);
@@ -176,7 +175,7 @@
/* This shouldn't happen anymore. */
if (osb->vol_layout.root_start_off == 0) {
LOG_ERROR_ARGS("root_start_off = 0! Skipping inode create for "
- "%llu, %llu\n", voteoff, feoff);
+ "%llu\n", feoff);
goto bail;
}
@@ -193,47 +192,34 @@
goto bail;
}
feoff = fe->this_sector;
- /* need voteoff too. */
- if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
- voteoff = fe->u.child_dirnode;
- else
- voteoff = fe->this_sector;
OCFS_BH_PUT_DATA(fe_bh);
}
/* Ok. By now we've either got the offsets passed to us by the
* caller, or we just pulled them off the bh. Lets do some
* sanity checks to make sure they're OK. */
- if (voteoff == 0) {
+ if (feoff == 0) {
LOG_ERROR_STATUS(-EINVAL);
goto bail;
}
- /* feoff = 0 is only valid for root inode and other system files. */
- if ((feoff == 0) && (voteoff > osb->vol_layout.root_start_off)) {
- LOG_ERROR_STATUS(-EINVAL);
- goto bail;
- }
-
/* try to detect whether this is a system file. */
if (feoff < osb->vol_layout.root_start_off)
flags |= OCFS_FIND_INODE_FLAG_SYSFILE;
- inode = ocfs_inode_hash_lookup(osb, voteoff, 0);
+ inode = ocfs_inode_hash_lookup(osb, feoff);
if (!inode) {
/* we should put this guy in the hash now... */
LOG_TRACE_STR("calling iget4");
args.feoff = feoff;
- args.voteoff = voteoff;
args.fe_bh = fe_bh;
- args.skip_bind = 0;
args.flags = flags;
/* alright, allocate a new inode number for this guy
* and insert it into the hash. It's not bound yet --
* read_inode2 binds the actual inode to it. */
- args.ino = ocfs_inode_hash_insert(osb, voteoff, feoff);
+ args.ino = ocfs_inode_hash_insert(osb, feoff);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
inode = iget5_locked (sb, args.ino, ocfs_find_actor,
ocfs_init_locked_inode, &args);
@@ -307,8 +293,7 @@
if (ino != inode->i_ino)
goto bail;
- if ((GET_INODE_FEOFF(inode) != args->feoff)
- || (GET_INODE_VOTEOFF(inode) != args->feoff)) {
+ if (GET_INODE_FEOFF(inode) != args->feoff) {
LOG_ERROR_STATUS(-EINVAL);
goto bail;
}
@@ -352,7 +337,6 @@
/* These should be set in read_inode2. */
i->alloc_size = 0ULL;
- i->voteoff = 0ULL;
i->feoff = 0ULL;
OCFS_SET_FLAG (i->flags, OCFS_INODE_INITIALIZED);
@@ -367,15 +351,14 @@
{
struct super_block *sb;
ocfs_super *osb;
- __u64 offset, fe_off;
+ __u64 offset;
unsigned long uniq_ino;
LOG_ENTRY_ARGS ("(0x%p, %u, size:%llu)\n", inode, mode, fe->file_size);
sb = inode->i_sb;
osb = OCFS_GENERIC_SB_P(sb);
- fe_off = fe->this_sector;
- offset = S_ISDIR (mode) ? fe->u.child_dirnode : fe->this_sector;
+ offset = fe->this_sector;
if (!IS_VALID_FILE_ENTRY(fe)) {
printk("ocfs2: invalid file entry!\n");
@@ -404,17 +387,18 @@
OCFS_SET_INODE_TIME(inode, i_mtime, fe->modify_time);
OCFS_SET_INODE_TIME(inode, i_ctime, fe->create_time);
- SET_INODE_VOTEOFF(inode, offset);
- SET_INODE_FEOFF(inode, fe_off);
+ SET_INODE_FEOFF(inode, offset);
OCFS_I(inode)->alloc_size = fe->alloc_size;
OCFS_I(inode)->inode = inode;
OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
+ OCFS_I(inode)->u.fe_private = fe->u.fe_private;
+
if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
OCFS_I(inode)->oin_flags |= OCFS_OIN_DIRECTORY;
if (create_ino) {
- uniq_ino = ocfs_inode_hash_insert(osb, offset, fe_off);
+ uniq_ino = ocfs_inode_hash_insert(osb, offset);
inode->i_ino = uniq_ino;
/* caller needs to know to call inode_hash_bind! */
}
@@ -493,11 +477,11 @@
struct super_block *sb;
ocfs_super *osb;
umode_t mode;
- __u64 voteoff = 0ULL;
+ __u64 feoff = 0ULL;
ocfs_file_entry *fe = NULL;
struct buffer_head *bh = NULL;
int status;
- int sysfile = 0, skip_bind = 0;
+ int sysfile = 0;
LOG_ENTRY_ARGS ("(0x%p, 0x%p)\n", inode, args);
@@ -514,9 +498,8 @@
goto bail;
}
- voteoff = args->voteoff;
+ feoff = args->feoff;
sysfile = (args->flags & OCFS_FIND_INODE_FLAG_SYSFILE);
- skip_bind = args->skip_bind;
/* Uhoh, they didn't give us a buffer. Read the FE off
* disk. This is safe because the kernel only does one
@@ -565,17 +548,14 @@
ocfs_populate_inode (inode, fe, mode, 0);
/* eventually this case has to GO! */
- voteoff = S_ISDIR (mode) ? fe->u.child_dirnode : fe->this_sector;
-
- if (voteoff != args->voteoff)
+ if (feoff != fe->this_sector)
BUG();
if (sysfile)
OCFS_SET_FLAG(OCFS_I(inode)->flags, OCFS_INODE_SYSFILE);
- if (!skip_bind)
- ocfs_inode_hash_bind(osb, voteoff, inode);
-
+ ocfs_inode_hash_bind(osb, feoff, inode);
+
ocfs_init_lockres (osb, inode);
bail:
@@ -619,8 +599,7 @@
goto bail;
}
- if ((GET_INODE_FEOFF(inode) != args->feoff)
- || (GET_INODE_VOTEOFF(inode) != args->voteoff)) {
+ if (GET_INODE_FEOFF(inode) != args->feoff) {
LOG_ERROR_STATUS(-EINVAL);
goto bail;
}
@@ -677,7 +656,7 @@
if (ocfs_inc_icount(inode) < 0)
BUG();
ocfs_inode_hash_remove(&osb->inode_hash,
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
atomic_dec(&inode->i_count);
}
@@ -709,9 +688,7 @@
if (!inode)
goto bail;
- LOG_TRACE_ARGS("Clearing inode %lu (voteoff: %llu, "
- "feoff: %llu)\n", inode->i_ino,
- GET_INODE_VOTEOFF(inode),
+ LOG_TRACE_ARGS("Clearing inode %lu feoff: %llu)\n", inode->i_ino,
GET_INODE_FEOFF(inode));
/* we should not really be using osb in this context. */
@@ -724,7 +701,7 @@
OCFS_CLEAR_FLAG (OCFS_I(inode)->flags, OCFS_INODE_INITIALIZED);
- offset = GET_INODE_VOTEOFF(inode);
+ offset = GET_INODE_FEOFF(inode);
if (offset == -1)
BUG();
@@ -870,7 +847,7 @@
goto bail;
}
- entryOffset = GET_INODE_VOTEOFF(inode);
+ entryOffset = GET_INODE_FEOFF(inode);
status = ocfs_read_bh (osb, entryOffset, &bh, OCFS_BH_CACHED, inode);
if (status < 0) {
@@ -1165,7 +1142,8 @@
/* make sure we're up to date... */
if (OCFS_I(inode)->needs_verification) {
LOG_TRACE_STR ("ocfs_direct_IO_get_blocks: verify oin.");
- status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
+ status = ocfs_verify_update_inode (osb, inode, &needs_trunc,
+ 0);
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
if (status < 0) {
Modified: trunk/src/io.c
===================================================================
--- trunk/src/io.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/io.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -71,7 +71,7 @@
break;
default:
/* this will iget() the inode if non-NULL */
- retval = ocfs_inode_hash_lookup(osb, (top+idx) << 9, 1);
+ retval = ocfs_inode_hash_lookup(osb, (top+idx) << 9);
break;
}
return retval;
Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/journal.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -239,14 +239,15 @@
|| (lock->inode && !INODE_DELETED(lock->inode))) {
tmpstat = ocfs_release_lock(osb,
- GET_INODE_VOTEOFF(lock->inode),
+ GET_INODE_FEOFF(lock->inode),
lock->type,
lock->flags,
(abort ? NULL : lock->bh),
lock->inode);
if (tmpstat < 0) {
LOG_ERROR_ARGS("Could not release lock: "
- "%llu\n", GET_INODE_VOTEOFF(lock->inode));
+ "%llu\n",
+ GET_INODE_FEOFF(lock->inode));
LOG_ERROR_STATUS(tmpstat);
status = tmpstat;
}
@@ -839,7 +840,7 @@
osb->vol_layout.root_int_off;
/* Ok, look up the inode for our journal */
- inode = ocfs_iget(osb, lock_id, lock_id, NULL);
+ inode = ocfs_iget(osb, lock_id, NULL);
if (inode == NULL) {
LOG_ERROR_STR("access error");
status = -EACCES;
@@ -1403,7 +1404,7 @@
+ osb->vol_layout.root_int_off;
/* Ok, look up the inode for our journal */
- inode = ocfs_iget(osb, lock_id, lock_id, NULL);
+ inode = ocfs_iget(osb, lock_id, NULL);
if (inode == NULL) {
LOG_ERROR_STR("access error");
status = -EACCES;
Modified: trunk/src/lockres.c
===================================================================
--- trunk/src/lockres.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/lockres.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -43,13 +43,13 @@
*
* Returns 0 if success, < 0 if error.
*/
-int ocfs_update_lockres (ocfs_super * osb, __u64 lock_id, struct buffer_head **bh, __u32 * updated, __u32 timeout, struct inode *inode, int reread)
+int ocfs_update_lockres (ocfs_super * osb, __u64 lock_id, struct buffer_head **bh, __u32 * updated, __u32 timeout, struct inode *inode, int reread, int locked)
{
int status = 0;
struct buffer_head *tmpbh = NULL, **b = NULL;
ocfs_file_entry *fe;
int flags;
- ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);
+ ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);;
LOG_ENTRY_ARGS ("(0x%p, %llu, 0x%p, 0x%p, 0x%p)\n", osb,
lock_id, lockres, bh, updated);
@@ -68,14 +68,18 @@
}
if (lockres->master_node_num != osb->node_num || !reread) {
- status = ocfs_acquire_lockres (lockres, timeout); // ocfs_file_open ocfs_symlink ocfs_acquire_lock ocfs_process_vote ocfs_dentry_revalidate ocfs_file_write ocfs_file_read ocfs_setattr ocfs_getattr ocfs_direct_IO_get_blocks ocfs_rename
+ if (!locked)
+ status = ocfs_acquire_lockres (lockres, timeout); // ocfs_file_open ocfs_symlink ocfs_acquire_lock ocfs_process_vote ocfs_dentry_revalidate ocfs_file_write ocfs_file_read ocfs_setattr ocfs_getattr ocfs_direct_IO_get_blocks ocfs_rename
if (status < 0) {
LOG_TRACE_ARGS ("Timedout locking lockres for id: %llu\n",
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
goto finally;
}
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(*b); /* read */
+ if (!IS_VALID_FILE_ENTRY(fe))
+ BUG();
+
lockres->lock_type = DISK_LOCK_FILE_LOCK (fe);
lockres->master_node_num = DISK_LOCK_CURRENT_MASTER (fe);
lockres->oin_openmap = DISK_LOCK_OIN_MAP (fe);
@@ -84,13 +88,14 @@
lockres->readonly_node != lockres->master_node_num) {
LOG_ERROR_ARGS("no longer readonly! ronode=%d, master=%d, lockid=%llu\n",
lockres->readonly_node, lockres->master_node_num,
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
lockres->readonly_node = OCFS_INVALID_NODE_NUM;
}
OCFS_BH_PUT_DATA(*b);
- ocfs_release_lockres (lockres); // ocfs_file_open ocfs_symlink ocfs_acquire_lock ocfs_process_vote ocfs_dentry_revalidate ocfs_file_write ocfs_file_read ocfs_setattr ocfs_getattr ocfs_direct_IO_get_blocks ocfs_rename
+ if (!locked)
+ ocfs_release_lockres (lockres); // ocfs_file_open ocfs_symlink ocfs_acquire_lock ocfs_process_vote ocfs_dentry_revalidate ocfs_file_write ocfs_file_read ocfs_setattr ocfs_getattr ocfs_direct_IO_get_blocks ocfs_rename
if (updated)
*updated = 1;
@@ -126,6 +131,8 @@
LOG_ENTRY_ARGS ("(0x%p, %u)\n", lockres, timeout);
+ OCFS_ASSERT(lockres);
+
mypid = ocfs_getpid ();
if (timeout)
@@ -180,6 +187,8 @@
{
LOG_ENTRY_ARGS ("(0x%p)\n", lockres);
+ OCFS_ASSERT(lockres);
+
spin_lock (&lockres->lock_mutex);
if (lockres->in_use == 0) {
LOG_ERROR_ARGS("Releasing lockres with inuse 0: 0x%p\n", lockres);
Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/namei.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -30,11 +30,12 @@
extern spinlock_t oin_num_ext_lock;
-static int ocfs_fe_smash (ocfs_super * osb, __u64 lock_node_off, __u32 flags, __u64 file_off, ocfs_journal_handle *passed_handle, struct dentry *dentry, struct inode *parent_inode);
-static int ocfs_rename_file (ocfs_super * osb, ocfs_journal_handle *handle, __u64 parent_off, struct dentry *dentry, __u64 file_off, struct inode *dir_inode);
+static int ocfs_fe_smash (ocfs_super * osb, __u32 flags, ocfs_journal_handle *passed_handle, struct dentry *dentry, struct inode *parent_inode);
+static int ocfs_rename_file (ocfs_super * osb, ocfs_journal_handle *handle,
+struct dentry *dentry, __u64 file_off, struct inode *dir_inode);
static int ocfs_mknod_locked(ocfs_super *osb, struct inode *dir,
struct dentry *dentry, int mode,
- ocfs_dev dev, struct buffer_head *lock_bh,
+ ocfs_dev dev,
struct buffer_head **new_fe_bh,
ocfs_journal_handle *handle,
struct inode *inode);
@@ -67,7 +68,6 @@
int status;
ocfs_file_entry *fe = NULL;
struct buffer_head *fe_bh = NULL;
- __u64 parentOffset;
struct inode *inode = NULL;
struct super_block *sb = dir->i_sb;
struct dentry *ret;
@@ -82,11 +82,10 @@
goto bail;
}
- parentOffset = GET_INODE_VOTEOFF(dir);
+ LOG_TRACE_ARGS("about to call find_files_on_disk with inode=%p\n",
+ dir);
- LOG_TRACE_ARGS("about to call find_files_on_disk with inode=%p\n", dir);
-
- status = ocfs_find_files_on_disk (osb, parentOffset, &(dentry->d_name),
+ status = ocfs_find_files_on_disk (osb, &(dentry->d_name),
&fe_bh, NULL, dir, 1);
if (status < 0)
goto bail_add;
@@ -94,12 +93,13 @@
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
if (!IS_VALID_FILE_ENTRY(fe)) {
printk("ocfs2: invalid file entry! parent=%llu, name='%*s'\n",
- parentOffset, dentry->d_name.len, dentry->d_name.name);
+ GET_INODE_FEOFF(dir), dentry->d_name.len,
+ dentry->d_name.name);
BUG();
}
OCFS_BH_PUT_DATA(fe_bh);
- inode = ocfs_iget(osb, 0, 0, fe_bh);
+ inode = ocfs_iget(osb, 0, fe_bh);
if (!inode) {
LOG_ERROR_STR("Could not create inode!");
ret = ERR_PTR (-EACCES);
@@ -123,10 +123,9 @@
ocfs_dev dev)
{
int status = 0;
- struct buffer_head *lock_bh = NULL;
+ struct buffer_head *parent_fe_bh = NULL;
__u64 parent_off;
__u64 file_off = 0;
- __u64 dirnode_off;
ocfs_journal_handle *handle = NULL;
ocfs_super *osb;
ocfs_file_entry *fe = NULL;
@@ -157,7 +156,7 @@
}
/* need the offset of our parent directory to lock it */
- parent_off = GET_INODE_VOTEOFF(dir);
+ parent_off = GET_INODE_FEOFF(dir);
/* start the transaction */
handle = ocfs_start_trans(osb, OCFS_MKNOD_CREDITS);
@@ -173,7 +172,7 @@
status = ocfs_acquire_lock (osb, parent_off,
OCFS_DLM_ENABLE_CACHE_LOCK,
FLAG_FILE_CREATE | FLAG_DIR,
- &lock_bh, dir);
+ &parent_fe_bh, dir);
if (status < 0) {
if (status != -EINTR)
LOG_ERROR_STATUS (status);
@@ -182,10 +181,10 @@
/* Ok, we got the lock -- we'd better add it to our transaction */
ocfs_journal_add_lock(handle, OCFS_DLM_ENABLE_CACHE_LOCK,
- FLAG_FILE_CREATE | FLAG_DIR, lock_bh, dir);
+ FLAG_FILE_CREATE | FLAG_DIR, parent_fe_bh, dir);
/* do the real work now. */
- status = ocfs_mknod_locked(osb, dir, dentry, mode, dev, lock_bh,
+ status = ocfs_mknod_locked(osb, dir, dentry, mode, dev,
&new_fe_bh, handle, inode);
if (status < 0) {
if (status != -EINTR)
@@ -196,13 +195,10 @@
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(new_fe_bh); /* read */
file_off = fe->this_sector;
- dirnode_off = fe->u.child_dirnode;
- parent_off = GET_INODE_VOTEOFF(dir);
-
ocfs_populate_inode (inode, fe, mode, 1);
insert_inode_hash (inode);
- ocfs_inode_hash_bind(osb, GET_INODE_VOTEOFF(inode), inode);
+ ocfs_inode_hash_bind(osb, GET_INODE_FEOFF(inode), inode);
handle->new_file_lockid = fe->this_sector;
OCFS_BH_PUT_DATA(new_fe_bh);
@@ -210,8 +206,9 @@
ocfs_init_lockres (osb, inode);
- status = ocfs_update_lockres (osb, GET_INODE_VOTEOFF(inode), &new_fe_bh,
- NULL, 0, inode, 0);
+ status = ocfs_update_lockres (osb, GET_INODE_FEOFF(inode),
+ &new_fe_bh, NULL, 0, inode, 0, 0);
+
d_instantiate (dentry, inode);
ocfs_commit_trans(handle);
@@ -231,8 +228,8 @@
brelse(new_fe_bh);
}
- if (lock_bh != NULL)
- brelse(lock_bh);
+ if (parent_fe_bh != NULL)
+ brelse(parent_fe_bh);
if ((status < 0) && inode)
iput(inode);
@@ -252,17 +249,15 @@
*/
static int ocfs_mknod_locked(ocfs_super *osb, struct inode *dir,
struct dentry *dentry, int mode,
- ocfs_dev dev, struct buffer_head *lock_bh,
+ ocfs_dev dev,
struct buffer_head **new_fe_bh,
ocfs_journal_handle *handle,
struct inode *inode)
{
int status = 0;
ocfs_file_entry *fe = NULL;
- ocfs_dir_node *pLockNode = NULL;
__u64 t;
struct buffer_head *fe_bh = NULL;
- int cache_lock;
int i;
unsigned long blk;
@@ -330,10 +325,6 @@
fe->create_time = fe->modify_time = OCFS_CURRENT_TIME;
- pLockNode = (ocfs_dir_node *)OCFS_BH_GET_DATA_READ(lock_bh); /* read */
- cache_lock = (DISK_LOCK_FILE_LOCK (pLockNode) == OCFS_DLM_ENABLE_CACHE_LOCK);
- OCFS_BH_PUT_DATA(lock_bh);
-
if (S_ISDIR (mode)) {
__u64 bitmapOffset;
__u64 fileOffset = 0;
@@ -358,7 +349,7 @@
up(&osb->node_alloc_sem);
if (status < 0) {
ocfs_safefree (dirbhs);
- OCFS_BH_PUT_DATA(lock_bh);
+// OCFS_BH_PUT_DATA(lock_bh);
LOG_ERROR_STATUS (status);
goto leave;
}
@@ -415,8 +406,7 @@
ocfs_safefree (dirbhs);
}
-
- status = ocfs_insert_file (osb, fe, lock_bh, &fe_bh, handle, dir, inode);
+ status = ocfs_insert_file (osb, fe, &fe_bh, handle, dir, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -493,7 +483,7 @@
struct inode *inode;
int retval = -EBUSY;
ocfs_super *osb = NULL;
- __u64 parentOff, fileOff;
+ __u64 fileOff;
int do_release = 0;
struct inode *parentInode = dentry->d_parent->d_inode;
@@ -503,8 +493,6 @@
inode = dentry->d_inode;
osb = OCFS_GENERIC_SB_P(dir->i_sb);
- parentOff = GET_INODE_VOTEOFF(dir);
-
fileOff = GET_INODE_FEOFF(inode);
if (fileOff == -1)
BUG();
@@ -545,8 +533,7 @@
OCFS_SET_FLAG (OCFS_I(inode)->oin_flags, OCFS_OIN_DELETE_ON_CLOSE);
up (&(OCFS_I(inode)->priv_sem));
- status = ocfs_fe_smash (osb, parentOff, 0, fileOff,
- NULL, dentry, parentInode);
+ status = ocfs_fe_smash (osb, 0, NULL, dentry, parentInode);
if (status < 0) {
if (status != -ENOTEMPTY && status != -EPERM &&
@@ -842,19 +829,13 @@
osb = OCFS_GENERIC_SB_P(old_dir->i_sb);
/* old parent dir offset */
- oldDirOff = GET_INODE_VOTEOFF(old_dir);
+ oldDirOff = GET_INODE_FEOFF(old_dir);
/* old file offset */
- oldOffset = GET_INODE_VOTEOFF(old_inode);
+ oldOffset = GET_INODE_FEOFF(old_inode);
- if (S_ISDIR (old_inode->i_mode)) {
- /* overwrite oldOffset to get ptr to OCFS_FILE_ENTRY
- * not DIR_NODE */
- oldOffset = GET_INODE_FEOFF(old_inode);
- }
-
/* new parent dir offset */
- newDirOff = GET_INODE_VOTEOFF (new_dir);
+ newDirOff = GET_INODE_FEOFF(new_dir);
if (new_inode) {
if (ocfs_inc_icount(new_inode) < 0)
@@ -895,7 +876,8 @@
if (!(OCFS_I(new_inode)->oin_flags & OCFS_OIN_DELETE_ON_CLOSE)) {
/* OIN exists and it's not marked for deletion! */
down (&(OCFS_I(new_inode)->priv_sem));
- status = ocfs_verify_update_inode (osb, new_inode, &needs_trunc);
+ status = ocfs_verify_update_inode (osb, new_inode,
+ &needs_trunc, 0);
up (&(OCFS_I(new_inode)->priv_sem));
delete_target_oin = 1;
if (needs_trunc)
@@ -929,23 +911,10 @@
goto finally;
}
- status = ocfs_read_bh(osb, oldOffset, &oldfe_bh, OCFS_BH_CACHED, old_inode);
- if (status < 0) {
- LOG_ERROR_STATUS(status);
- goto finally;
- }
- /* lock old_fe. we read it ourselves instead of letting
- * acquire_lock do it because if it's a directory, we lock the
- * dirnode instead. */
- oldfe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(oldfe_bh); /* read */
- if (oldfe->attribs & OCFS_ATTRIB_DIRECTORY) {
- oldfe_lockid = oldfe->u.child_dirnode;
+ if (S_ISDIR(old_inode->i_mode))
oldfe_flags = FLAG_DIR;
- } else
- oldfe_lockid = oldfe->this_sector;
+ oldfe_lockid = GET_INODE_FEOFF(old_inode);
- OCFS_BH_PUT_DATA(oldfe_bh);
- oldfe = NULL;
if (old_dir != new_dir)
oldfe_flags |= FLAG_FILE_DELETE;
else
@@ -961,7 +930,7 @@
/* check if the target already exists (in which case we need
* to delete it */
- status = ocfs_find_files_on_disk(osb, newDirOff, &(new_dentry->d_name),
+ status = ocfs_find_files_on_disk(osb, &(new_dentry->d_name),
&newfe_bh, NULL, new_dir, 0);
/* The only error we allow here is -ENOENT because the new
@@ -980,15 +949,11 @@
* away first */
if (kill_newfe) {
newfe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(newfe_bh); /* read */
- if (newfe->attribs & OCFS_ATTRIB_DIRECTORY) {
- newfe_lockid = newfe->u.child_dirnode;
+ if (newfe->attribs & OCFS_ATTRIB_DIRECTORY)
newfe_flags = FLAG_DIR;
- } else
- newfe_lockid = newfe->this_sector;
newfe_flags |= FLAG_FILE_DELETE;
+ newfe_lockid = newfe->this_sector;
- tmpoff = newfe->this_sector;
-
OCFS_BH_PUT_DATA(newfe_bh);
brelse(newfe_bh);
newfe_bh = NULL;
@@ -1004,8 +969,7 @@
}
got_newlock = 1;
- status = ocfs_fe_smash (osb, newDirOff, 0,
- tmpoff, handle, new_dentry,
+ status = ocfs_fe_smash (osb, 0, handle, new_dentry,
new_dir);
if (status < 0) {
LOG_ERROR_STATUS (status);
@@ -1021,10 +985,8 @@
/* Delete the file Entry only on the source directory */
LOG_TRACE_STR ("Source & Target Directories are different");
- status = ocfs_fe_smash (osb, oldDirOff,
- FLAG_DEL_NAME | FLAG_DEL_INODE,
- oldOffset, handle, old_dentry,
- old_dir);
+ status = ocfs_fe_smash (osb, FLAG_DEL_NAME | FLAG_DEL_INODE,
+ handle, old_dentry, old_dir);
if (status < 0) {
if (status != -ENOTEMPTY && status != -EINTR &&
status != -EBUSY)
@@ -1042,6 +1004,13 @@
goto finally;
}
+ status = ocfs_read_bh(osb, oldOffset, &oldfe_bh,
+ OCFS_BH_CACHED, old_inode);
+ if (status < 0) {
+ LOG_ERROR_STATUS(status);
+ goto finally;
+ }
+
oldfe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(oldfe_bh); /* read */
memcpy(tmpfe, oldfe, sizeof(ocfs_file_entry));
OCFS_BH_PUT_DATA(oldfe_bh);
@@ -1062,10 +1031,7 @@
DISK_LOCK_OIN_MAP(tmpfe) = (1 << osb->node_num);
tmpfe->modify_time = OCFS_CURRENT_TIME;
- if (tmpfe->attribs & OCFS_ATTRIB_DIRECTORY)
- tmpoff = tmpfe->u.child_dirnode;
- else
- tmpoff = tmpfe->this_sector;
+ tmpoff = tmpfe->this_sector;
down(&old_inode->i_sem);
/* we take oin->priv_sem because we want to lock out
@@ -1073,8 +1039,8 @@
* inode, but doesn't always have i_sem. */
down(&OCFS_I(old_inode)->priv_sem);
- status = ocfs_insert_file(osb, tmpfe, new_dir_bh, &insert_bh,
- handle, old_dir, old_inode);
+ status = ocfs_insert_file(osb, tmpfe, &insert_bh,
+ handle, new_dir, old_inode);
if (status < 0) {
up(&OCFS_I(old_inode)->priv_sem);
up(&old_inode->i_sem);
@@ -1105,21 +1071,10 @@
}
SET_INODE_FEOFF(old_inode, tmpfe->this_sector);
- if (S_ISDIR(old_inode->i_mode)) {
- /* the vote offset doesn't actually change for
- * a directory, but the fe offset does... */
- ocfs_inode_rehash(&osb->inode_hash,
- tmpoff,
- tmpfe->u.child_dirnode,
- tmpfe->this_sector);
- } else {
- SET_INODE_VOTEOFF(old_inode,
- tmpfe->this_sector);
- ocfs_inode_rehash(&osb->inode_hash,
- tmpoff,
- tmpfe->this_sector,
- tmpfe->this_sector);
- }
+ OCFS_I(old_inode)->u.fe_private = tmpfe->u.fe_private;
+ ocfs_inode_rehash(&osb->inode_hash, tmpoff,
+ tmpfe->this_sector);
+
up(&OCFS_I(old_inode)->priv_sem);
up(&old_inode->i_sem);
} else {
@@ -1128,8 +1083,8 @@
* fe. */
/* Write the new file name to disk */
LOG_TRACE_STR ("Source & Target Directories are same");
- status = ocfs_rename_file(osb, handle, oldDirOff,
- new_dentry, oldOffset, new_dir);
+ status = ocfs_rename_file(osb, handle, new_dentry, oldOffset,
+ new_dir);
if (status < 0)
LOG_ERROR_STATUS (status);
}
@@ -1222,24 +1177,25 @@
int ocfs_symlink (struct inode *dir, struct dentry *dentry, const char *symname)
{
ocfs_super *osb = NULL;
- struct inode *inode = NULL, *parentInode = NULL;
+ struct inode *inode = NULL;
__u64 file_off, parent_off;
__u64 newsize;
int status;
struct super_block *sb;
int l;
struct buffer_head *new_fe_bh = NULL;
- struct buffer_head *lock_bh = NULL;
ocfs_file_entry *fe = NULL;
ocfs_journal_handle *handle = NULL;
int got_lock = 0;
-
LOG_ENTRY_ARGS ("(0x%p, 0x%p, symname='%s' actual='%*s')\n", dir,
dentry, symname, dentry->d_name.len,
dentry->d_name.name);
- inode = new_inode (dir->i_sb);
+ sb = dir->i_sb;
+ osb = OCFS_GENERIC_SB_P(sb);
+
+ inode = new_inode (sb);
if (IS_ERR (inode)) {
status = PTR_ERR(inode);
LOG_ERROR_STR("new_inode failed!");
@@ -1251,19 +1207,9 @@
goto bail;
}
- //atomic_set(GET_INODE_CLEAN_SEQ(inode), atomic_read(&osb->clean_buffer_seq));
-
- parentInode = dentry->d_parent->d_inode;
- sb = parentInode->i_sb;
-
l = strlen (symname) + 1;
newsize = l - 1;
- osb = OCFS_GENERIC_SB_P(dir->i_sb);
-
- /* need the offset of our parent directory to lock it */
- parent_off = GET_INODE_VOTEOFF(parentInode);
-
/* start the transaction */
handle = ocfs_start_trans(osb, OCFS_SYMLINK_CREDITS);
if (handle == NULL) {
@@ -1272,10 +1218,11 @@
}
/* lock the parent directory */
+ parent_off = GET_INODE_FEOFF(dir);
status = ocfs_acquire_lock (osb, parent_off,
OCFS_DLM_ENABLE_CACHE_LOCK,
FLAG_FILE_CREATE | FLAG_DIR,
- &lock_bh, dir);
+ NULL, dir);
if (status < 0) {
if (status != -EINTR)
LOG_ERROR_STATUS (status);
@@ -1284,7 +1231,7 @@
got_lock = 1;
status = ocfs_mknod_locked(osb, dir, dentry,
- S_IFLNK | S_IRWXUGO, OCFS_NODEV, lock_bh,
+ S_IFLNK | S_IRWXUGO, OCFS_NODEV,
&new_fe_bh, handle, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
@@ -1329,7 +1276,7 @@
}
insert_inode_hash (inode);
- ocfs_inode_hash_bind(osb, GET_INODE_VOTEOFF(inode), inode);
+ ocfs_inode_hash_bind(osb, GET_INODE_FEOFF(inode), inode);
d_instantiate (dentry, inode);
abort_trans:
@@ -1344,8 +1291,10 @@
if (got_lock) {
int tmpstat;
- tmpstat = ocfs_release_lock (osb, parent_off, OCFS_DLM_ENABLE_CACHE_LOCK,
- FLAG_FILE_CREATE | FLAG_DIR, lock_bh, dir);
+ tmpstat = ocfs_release_lock (osb, parent_off,
+ OCFS_DLM_ENABLE_CACHE_LOCK,
+ FLAG_FILE_CREATE | FLAG_DIR,
+ NULL, dir);
if (tmpstat < 0)
LOG_ERROR_STATUS (tmpstat);
}
@@ -1356,13 +1305,12 @@
OCFS_BH_PUT_DATA(new_fe_bh);
brelse(new_fe_bh);
}
-
+
#ifndef BH_SEM_LEAK_CHECKING
if (status < 0)
#endif
ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
-
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_symlink */
@@ -1371,15 +1319,13 @@
/* ocfs_rename_file()
*
*/
-static int ocfs_rename_file (ocfs_super * osb, ocfs_journal_handle *handle, __u64 parent_off, struct dentry *dentry, __u64 file_off, struct inode *dir_inode)
+static int ocfs_rename_file (ocfs_super * osb, ocfs_journal_handle *handle, struct dentry *dentry, __u64 file_off, struct inode *dir_inode)
{
int status = 0;
ocfs_dir_node *pLockNode = NULL;
ocfs_file_entry *fe = NULL;
- __u32 lockFlags = 0;
- __u64 lockId = 0;
__u32 index;
- struct buffer_head *fe_bh = NULL, *lockbh = NULL, *dirbh = NULL;
+ struct buffer_head *fe_bh = NULL, *dirbh = NULL;
int cache_lock = 0, needs_reindex = 0;
__u64 dir_node_ptr = 0;
int flags = 0;
@@ -1395,32 +1341,10 @@
goto leave;
}
- /* lock file ent for a dir is out in the 1st extent, this_sector
- for file */
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
+ if (!IS_VALID_FILE_ENTRY(fe))
+ BUG();
dir_node_ptr = fe->dir_node_ptr;
- if (fe->attribs & OCFS_ATTRIB_DIRECTORY) {
- lockId = fe->u.child_dirnode;
- lockFlags = (FLAG_DIR | FLAG_FILE_RENAME);
-
- status = ocfs_read_bh(osb, lockId, &lockbh, OCFS_BH_CACHED,
- inode);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
-
- status = ocfs_journal_access(handle, lockbh,
- OCFS_JOURNAL_ACCESS_WRITE);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
- } else {
- lockId = fe->this_sector;
- lockFlags = FLAG_FILE_RENAME;
- lockbh = fe_bh;
- }
OCFS_BH_PUT_DATA(fe_bh);
fe = NULL;
@@ -1446,6 +1370,9 @@
pLockNode = (ocfs_dir_node *)OCFS_BH_GET_DATA_WRITE(dirbh); /* write */
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
+ if (!IS_VALID_DIR_NODE(pLockNode))
+ BUG();
+
/* Change the actual name now */
fe->filename[0] = '\0';
strncpy (fe->filename, file_name->name, file_name->len);
@@ -1503,8 +1430,6 @@
if (fe != NULL)
OCFS_BH_PUT_DATA(fe_bh);
- if (lockbh != fe_bh)
- brelse(lockbh);
if (fe_bh)
brelse(fe_bh);
if (dirbh)
@@ -1514,6 +1439,46 @@
return status;
} /* ocfs_rename_file */
+/* This is broken as it only checks the 1st dir node, and doesn't even
+ * check the right field. Also, it will change with the new directory
+ * structures. Return a negative value on error, 0 on empty or a positive
+ * value on not empty. */
+static int ocfs_is_dir_empty(ocfs_super *osb, struct inode *dir_inode, __u64 dir_node_off)
+{
+ int status;
+ struct buffer_head *dir_node_bh = NULL;
+ __u8 numused;
+ ocfs_dir_node *dirnode;
+
+ LOG_ENTRY_ARGS("(dir_node_off == %llu)\n", dir_node_off);
+
+ status = ocfs_read_bh(osb, dir_node_off, &dir_node_bh, OCFS_BH_CACHED,
+ dir_inode);
+ if (status < 0) {
+ LOG_ERROR_STATUS(status);
+ goto bail;
+ }
+
+ dirnode = (ocfs_dir_node *)OCFS_BH_GET_DATA_READ(dir_node_bh);/* read */
+ if (!IS_VALID_DIR_NODE(dirnode)) {
+ OCFS_BH_PUT_DATA(dir_node_bh);
+ status = -EIO;
+ LOG_TRACE_STR("Uhoh, invalid dirnode found!");
+ goto bail;
+ }
+
+ numused = dirnode->num_ent_used;
+ OCFS_BH_PUT_DATA(dir_node_bh);
+
+ status = (int) numused;
+bail:
+ if (dir_node_bh)
+ brelse(dir_node_bh);
+
+ LOG_EXIT_STATUS(status);
+ return(status);
+}
+
/* ocfs_fe_smash()
*
* Flags for 'flags' field (no flags means do everything)
@@ -1535,30 +1500,24 @@
* to pass back a bitmap_free_head (if it's not passed as NULL)
*
*/
-static int ocfs_fe_smash (ocfs_super * osb, __u64 lock_node_off, __u32 flags, __u64 file_off, ocfs_journal_handle *passed_handle, struct dentry *dentry, struct inode *parent_inode)
+static int ocfs_fe_smash (ocfs_super * osb, __u32 flags, ocfs_journal_handle *passed_handle, struct dentry *dentry, struct inode *parent_inode)
{
int status = 0;
int tmpstat;
ocfs_file_entry *fe = NULL;
__u32 lockFlags = 0;
int local_handle = 0, is_dir;
- __u64 lock_id = 0;
- struct buffer_head *fe_bh = NULL, *lock_bh = NULL;
- struct buffer_head *lock_node_bh = NULL; /* parent locknode */
+ struct buffer_head *fe_bh = NULL;
+ struct buffer_head *parent_node_bh = NULL; /* parent locknode */
ocfs_journal_handle *handle = NULL;
struct inode *inode = dentry->d_inode;
int got_parent = 0, got_file = 0;
+ __u64 file_off = GET_INODE_FEOFF(inode);
+ __u64 parent_off = GET_INODE_FEOFF(parent_inode);
+ __u64 parent_dirnode_off = OCFS_I(parent_inode)->u.child_dirnode;
LOG_ENTRY ();
- status = ocfs_read_bh(osb, lock_node_off, &lock_node_bh,
- OCFS_BH_CACHED, parent_inode);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto leave;
- }
-
-
if (passed_handle) {
status = ocfs_read_bh (osb, file_off, &fe_bh, OCFS_BH_CACHED, inode);
if (status < 0) {
@@ -1566,25 +1525,6 @@
goto leave;
}
handle = passed_handle;
- /* ok, we're going to skip the locking, but there's
- * one problem: what if this is a directory that we're
- * deleting? in that case, we also need to read the
- * head of it's first dirnode which would have been
- * done implicitely by locking it. */
- fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
- if (fe->attribs & OCFS_ATTRIB_DIRECTORY) {
- status = ocfs_read_bh(osb, fe->u.child_dirnode,
- &lock_bh, OCFS_BH_CACHED, inode);
- if (status < 0) {
- LOG_ERROR_STATUS(status);
- OCFS_BH_PUT_DATA(fe_bh);
- goto leave;
- }
- } else /* we don't really need this but just in case... */
- lock_bh = fe_bh;
-
- OCFS_BH_PUT_DATA(fe_bh);
-
goto skip_lock;
}
@@ -1597,9 +1537,9 @@
/* lock parent directory, yes we use FLAG_FILE_CREATE even
* though we're deleting ;) */
- status = ocfs_acquire_lock(osb, lock_node_off, OCFS_DLM_EXCLUSIVE_LOCK,
- FLAG_FILE_CREATE|FLAG_DIR,
- &lock_node_bh, parent_inode);
+ status = ocfs_acquire_lock(osb, parent_off, OCFS_DLM_EXCLUSIVE_LOCK,
+ FLAG_FILE_CREATE|FLAG_DIR, NULL,
+ parent_inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
@@ -1608,28 +1548,20 @@
/* this will re-read the directory now with the EXCLUSIVE */
/* lock already held; it will also return the fe_bh to us */
- status = ocfs_find_files_on_disk (osb, lock_node_off, &(dentry->d_name),
- &fe_bh, NULL, parent_inode, 0);
+ status = ocfs_find_files_on_disk (osb, &(dentry->d_name), &fe_bh, NULL,
+ parent_inode, 0);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
}
- /* lock the file entry */
- fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
-
- if (fe->attribs & OCFS_ATTRIB_DIRECTORY) {
- lock_id = fe->u.child_dirnode;
+ if (S_ISDIR (inode->i_mode))
lockFlags = (FLAG_FILE_DELETE | FLAG_DIR);
- } else {
- lock_id = fe->this_sector;
+ else
lockFlags = (FLAG_FILE_DELETE);
- lock_bh = fe_bh;
- }
- OCFS_BH_PUT_DATA(fe_bh);
- status = ocfs_acquire_lock (osb, lock_id, OCFS_DLM_EXCLUSIVE_LOCK,
- lockFlags, &lock_bh, inode);
+ status = ocfs_acquire_lock (osb, file_off, OCFS_DLM_EXCLUSIVE_LOCK,
+ lockFlags, &fe_bh, inode);
if (status < 0) {
if (status != -EINTR)
LOG_ERROR_STATUS (status);
@@ -1648,37 +1580,38 @@
* the dirnode sector first. it won't get passed to
* journal_dirty until ocfs_remove_file so clean up the write
* lock on errors before that */
- OCFS_BH_GET_DATA_WRITE(lock_node_bh);
- OCFS_BH_PUT_DATA(lock_node_bh);
+ status = ocfs_read_bh(osb, parent_dirnode_off, &parent_node_bh,
+ OCFS_BH_CACHED, parent_inode);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto leave;
+ }
+ OCFS_BH_GET_DATA_WRITE(parent_node_bh);
+ OCFS_BH_PUT_DATA(parent_node_bh);
/* we call ocfs_clear_buffer_modified in several error cases
* here if we set the modify bit on this buffer, but haven't
* journal_dirtied it yet. Otherwise, it'll stay modified even
* after the abort_trans. */
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
- is_dir = fe->attribs & OCFS_ATTRIB_DIRECTORY;
- if (is_dir) {
- __u8 numused;
- ocfs_dir_node *pLockNode;
+ is_dir = S_ISDIR (inode->i_mode);
- pLockNode = (ocfs_dir_node *)OCFS_BH_GET_DATA_READ(lock_bh);/* read */
- if (!IS_VALID_DIR_NODE(pLockNode)) {
- OCFS_BH_PUT_DATA(lock_bh);
- OCFS_BH_PUT_DATA(fe_bh);
- ocfs_clear_buffer_modified(lock_node_bh);
- status = -EIO;
- LOG_TRACE_STR("Uhoh, invalid dirnode found!");
- goto leave;
- }
+ if (fe->attribs & OCFS_ATTRIB_DIRECTORY && !is_dir)
+ BUG();
- numused = pLockNode->num_ent_used;
- OCFS_BH_PUT_DATA(lock_bh);
+ if (is_dir && !(flags & FLAG_DEL_NAME)) {
+ int numused;
- if (numused && !(flags & FLAG_DEL_NAME)) {
+ numused = ocfs_is_dir_empty(osb, inode, fe->u.child_dirnode);
+ if (numused) {
+ if (numused > 0)
+ status = -ENOTEMPTY;
+ else {
+ status = numused;
+ LOG_ERROR_STATUS(status);
+ }
OCFS_BH_PUT_DATA(fe_bh);
- ocfs_clear_buffer_modified(lock_node_bh);
- status = -ENOTEMPTY;
- LOG_TRACE_ARGS("-ENOTEMPY, numused = %u\n", numused);
+ ocfs_clear_buffer_modified(parent_node_bh);
goto leave;
}
}
@@ -1688,7 +1621,7 @@
* doing a rename so skip the 1st part of this function. */
status = 0;
OCFS_BH_PUT_DATA(fe_bh);
- ocfs_clear_buffer_modified(lock_node_bh);
+ ocfs_clear_buffer_modified(parent_node_bh);
goto delete_entry;
}
@@ -1711,7 +1644,7 @@
OCFS_BH_PUT_DATA(fe_bh);
if (status < 0) {
OCFS_BH_PUT_DATA(fe_bh);
- ocfs_clear_buffer_modified(lock_node_bh);
+ ocfs_clear_buffer_modified(parent_node_bh);
LOG_ERROR_STATUS (status);
goto leave;
}
@@ -1721,7 +1654,7 @@
status = ocfs_free_file_extents (osb, fe_bh, handle, inode);
if (status < 0) {
ocfs_clear_buffer_modified(fe_bh);
- ocfs_clear_buffer_modified(lock_node_bh);
+ ocfs_clear_buffer_modified(parent_node_bh);
LOG_ERROR_STATUS (status);
goto leave;
}
@@ -1729,7 +1662,7 @@
delete_entry:
/* remove the fe from the dirnode.*/
- status = ocfs_remove_file(osb, fe_bh, lock_node_bh, handle,
+ status = ocfs_remove_file(osb, fe_bh, parent_node_bh, handle,
parent_inode, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
@@ -1750,7 +1683,7 @@
// GET_INODE_FEOFF(inode),
// atomic_read(&inode->i_count));
ocfs_inode_hash_remove(&osb->inode_hash,
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
}
if (local_handle && handle && (status < 0))
@@ -1762,32 +1695,29 @@
/* need this to alert dentry-owners on other nodes */
/* Release the file lock if we acquired it */
if (got_file) {
- tmpstat = ocfs_release_lock(osb, lock_id,
+ tmpstat = ocfs_release_lock(osb, file_off,
OCFS_DLM_EXCLUSIVE_LOCK,
- lockFlags, lock_bh, inode);
+ lockFlags, fe_bh, inode);
if (tmpstat < 0)
LOG_ERROR_STATUS(tmpstat);
}
if (got_parent) {
- tmpstat = ocfs_release_lock(osb, lock_node_off,
+ tmpstat = ocfs_release_lock(osb, parent_off,
OCFS_DLM_EXCLUSIVE_LOCK,
FLAG_FILE_CREATE|FLAG_DIR,
- lock_node_bh, parent_inode);
+ NULL, parent_inode);
if (tmpstat < 0)
LOG_ERROR_STATUS(tmpstat);
}
- if (lock_bh != NULL && lock_bh != fe_bh)
- brelse(lock_bh);
-
- if (fe_bh != NULL)
+ if (fe_bh)
brelse(fe_bh);
- if (lock_node_bh != NULL)
- brelse(lock_node_bh);
+ if (parent_node_bh)
+ brelse(parent_node_bh);
LOG_EXIT_STATUS (status);
return status;
Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/nm.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -488,13 +488,17 @@
{
int vote_type = INVALID_REQUEST;
int my_node_wins = 0;
- __u64 lockid = GET_INODE_VOTEOFF(inode);
+ __u64 lockid = 0;
ocfs_vote_obj_lookup_data data;
LOG_ENTRY_ARGS("(status=%d, lockid=%llu, node_num=%d, flags=%08x)\n", status,
lockid, node_num, flags);
+ if (inode)
+ lockid = GET_INODE_FEOFF(inode);
+
*master_alive = 1;
+
if (status < 0) {
if (status == -ETIMEDOUT) {
LOG_TRACE_STR("(INVALID_REQUEST) status == -ETIMEDOUT");
@@ -529,7 +533,7 @@
if (flags & (FLAG_FILE_DELETE | FLAG_FILE_RENAME)) {
if (flags & FLAG_RELEASE_LOCK)
vote_type = DELETE_RENAME_RELEASE;
- else if (flags & FLAG_RELEASE_LOCK)
+ else if (flags & FLAG_ACQUIRE_LOCK)
vote_type = DELETE_RENAME_ACQUIRE;
else
vote_type = INVALID_REQUEST;
@@ -628,7 +632,7 @@
ocfs_publish *publish = (disk_vote ? ctxt->u.publish : NULL);
ocfs_dlm_msg *dlm_msg = (comm_vote ? ctxt->u.dlm_msg : NULL);
__u32 node_num = ctxt->node_num;
- __u64 lock_id, seq_num, fe_off;
+ __u64 lock_id, seq_num;
int needs_trunc = 0;
LOG_ENTRY_ARGS ("(0x%p, 0x%p)\n", osb, ctxt);
@@ -648,59 +652,60 @@
flags = publish->vote_type;
lock_id = publish->dir_ent;
seq_num = publish->publ_seq_num;
- fe_off = publish->fe_off;
} else {
ocfs_dlm_req_master *req_master = (ocfs_dlm_req_master *)dlm_msg->msg_buf;
flags = req_master->flags;
lock_id = req_master->lock_id;
seq_num = req_master->lock_seq_num;
- fe_off = req_master->fe_off;
}
lockflags = (lock_id >= osb->vol_layout.bitmap_off ? OCFS_BH_CACHED : 0);
LOG_TRACE_ARGS ("node=%u, id=%llu, seq=%llu\n", node_num,
lock_id, seq_num);
+ if (disk_vote) {
+ offset = osb->vol_layout.vote_sect_off + (osb->node_num * osb->sect_size);
+ status = ocfs_read_bh(osb, offset, &vote_bh, 0, NULL);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto leave;
+ }
+ }
+
/* delete / rename is slightly different -- we don't want to
* look up the inode in the release case -- it should already
* be gone. Eventually what we'll really want to do is get it
* via the old offsets and set the new ones. */
if ((flags & (FLAG_FILE_DELETE | FLAG_FILE_RENAME)) && (flags & FLAG_RELEASE_LOCK))
inode = NULL;
- else
- inode = ocfs_iget(osb, lock_id, fe_off, NULL);
+ else {
+ inode = ocfs_iget(osb, lock_id, NULL);
+ if (!inode) {
+ status = -EFAIL;
+ LOG_ERROR_ARGS("Could not find inode: lock_id = %llu, "
+ "node=%u, seq=%llu, flags=0x%x\n",
+ lock_id, node_num, seq_num, flags);
+ LOG_ERROR_STATUS(status);
+ goto leave;
+ }
- if (inode) {
- /* we only need i_sem for some of the operations
- * below, but due to lock ordering, we want to take it
- * before we acquire_lockres. */
down(&inode->i_sem);
have_i_sem = 1;
- }
- if (disk_vote) {
- offset = osb->vol_layout.vote_sect_off + (osb->node_num * osb->sect_size);
- status = ocfs_read_bh(osb, offset, &vote_bh, 0, NULL);
+ lockres = GET_INODE_LOCKRES(inode);
+ status = ocfs_update_lockres (osb, lock_id, NULL, NULL,
+ (OCFS_NM_HEARTBEAT_TIME/2),
+ inode, 1, 0);
if (status < 0) {
- LOG_ERROR_STATUS (status);
+ if (status != -ETIMEDOUT)
+ LOG_ERROR_STATUS (status);
goto leave;
}
- }
- if (inode) {
- lockres = GET_INODE_LOCKRES(inode);
- status = ocfs_update_lockres (osb, lock_id, NULL, NULL,
- (OCFS_NM_HEARTBEAT_TIME/2), inode, 1);
- }
- if (status < 0) {
- if (status == -ETIMEDOUT)
- goto leave;
- LOG_ERROR_STATUS (status);
- } else {
status = ocfs_acquire_lockres (lockres, (OCFS_NM_HEARTBEAT_TIME/2)); // ocfs_process_vote
if (status < 0) {
LOG_TRACE_ARGS ("Timedout locking lockres for id: %llu\n",
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
goto leave;
}
}
@@ -710,10 +715,13 @@
status, &master_alive, inode);
#ifdef VERBOSE_PROCESS_VOTE
- printk("(%u) ocfs_process_vote: %s request for lockid: %llu, fe_off: %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", ocfs_getpid(),
flags & FLAG_RELEASE_LOCK ? "RELEASE" :
- (flags & FLAG_ACQUIRE_LOCK ? "ACQUIRE" : "MODIFY"), lock_id, fe_off,
- vote_type, process_vote_strings[vote_type], disk_vote ? "disk vote" : "net vote" );
+ (flags & FLAG_ACQUIRE_LOCK ? "ACQUIRE" : "MODIFY"), lock_id,
+ vote_type, process_vote_strings[vote_type], disk_vote ? "disk vote" : "net vote" );
+ if (vote_type == INVALID_REQUEST)
+ printk("Invalid request! flags = 0x%x\n", flags);
+
#endif
/* get_process_vote_action will only allow CHANGE_MASTER, RELEASE_CACHE, and
* ADD_OIN_MAP on a CACHE lock held by this node. the CHANGE_MASTER/RELEASE_CACHE
@@ -750,7 +758,8 @@
LOG_TRACE_STR("UPDATE_OIN_INODE");
down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->needs_verification = 1;
- tmpstat = ocfs_verify_update_inode(osb, inode, &needs_trunc);
+ tmpstat = ocfs_verify_update_inode(osb, inode,
+ &needs_trunc, 1);
if (tmpstat < 0)
LOG_ERROR_STATUS (tmpstat);
up (&(OCFS_I(inode)->priv_sem));
@@ -778,7 +787,9 @@
oin_sem = 1;
down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->needs_verification = 1;
- tmpstat = ocfs_verify_update_inode(osb, inode, &needs_trunc);
+ tmpstat = ocfs_verify_update_inode(osb, inode,
+ &needs_trunc,
+ 1);
if (tmpstat < 0)
LOG_ERROR_STATUS (tmpstat);
@@ -818,7 +829,7 @@
if (inode && vote_response == FLAG_VOTE_NODE) {
SET_INODE_DELETED(inode);
ocfs_inode_hash_remove(&osb->inode_hash,
- GET_INODE_VOTEOFF(inode));
+ GET_INODE_FEOFF(inode));
}
if (!lockres) {
@@ -916,7 +927,7 @@
/* requestor will need to retry if anyone is using the lockres */
if (lockres->lock_holders > 0) {
LOG_TRACE_ARGS("Lock id (%llu) has %u holders\n",
- GET_INODE_VOTEOFF(inode), lockres->lock_holders);
+ GET_INODE_FEOFF(inode), lockres->lock_holders);
down(&(osb->journal.commit_sem));
if (ocfs_search_commited(osb, inode)) {
// kick the commit thread
Modified: trunk/src/oin.c
===================================================================
--- trunk/src/oin.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/oin.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -33,7 +33,7 @@
/*
* ocfs_verify_update_inode()
*/
-int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode, int *needs_trunc)
+int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode, int *needs_trunc, int lockres_locked)
{
int status = 0;
struct buffer_head *fe_bh = NULL;
@@ -217,8 +217,9 @@
OCFS_BH_PUT_DATA(fe_bh);
fe = NULL;
- status = ocfs_update_lockres (osb, GET_INODE_VOTEOFF(inode), &fe_bh,
- NULL, 0, inode, 0);
+ status = ocfs_update_lockres (osb, GET_INODE_FEOFF(inode), &fe_bh,
+ NULL, 0, inode, 0, lockres_locked);
+
status = 0;
leave:
if (status == 0)
@@ -278,7 +279,7 @@
/* this will update the lock info from disk while also
* ensuring that the lock level drops to something
* compatible with a first-open of the file */
- status = ocfs_wait_for_lock_release (osb, GET_INODE_VOTEOFF(inode),
+ status = ocfs_wait_for_lock_release (osb, GET_INODE_FEOFF(inode),
30000, (S_ISDIR (inode->i_mode) ?
OCFS_DLM_EXCLUSIVE_LOCK :
OCFS_DLM_NO_LOCK), inode);
Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/super.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -196,7 +196,7 @@
/* the vol bitmap */
sys_off = OCFS_BITMAP_LOCK_OFFSET;
- new = ocfs_iget(osb, sys_off, sys_off, NULL);
+ new = ocfs_iget(osb, sys_off, NULL);
if (!new) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
@@ -208,7 +208,7 @@
sys_off = osb->vol_layout.root_int_off +
((OCFS_FILE_FILE_ALLOC_BITMAP + osb->node_num)
* osb->sect_size);
- new = ocfs_iget(osb, sys_off, sys_off, NULL);
+ new = ocfs_iget(osb, sys_off, NULL);
if (!new) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
@@ -220,7 +220,7 @@
sys_off = osb->vol_layout.root_int_off +
((OCFS_FILE_DIR_ALLOC_BITMAP + osb->node_num)
* osb->sect_size);
- new = ocfs_iget(osb, sys_off, sys_off, NULL);
+ new = ocfs_iget(osb, sys_off, NULL);
if (!new) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
@@ -231,7 +231,7 @@
/* journal file */
sys_off = osb->vol_layout.root_int_off +
((OCFS_JOURNAL_FILE + osb->node_num) * osb->sect_size);
- new = ocfs_iget(osb, sys_off, sys_off, NULL);
+ new = ocfs_iget(osb, sys_off, NULL);
if (!new) {
status = -EINVAL;
LOG_ERROR_STATUS(status);
@@ -1005,8 +1005,7 @@
osb->vol_state = VOLUME_ENABLED;
up (&(osb->osb_res));
- inode = ocfs_iget(osb, osb->vol_layout.root_start_off,
- OCFS_ROOT_INODE_FE_OFF, NULL);
+ inode = ocfs_iget(osb, OCFS_ROOT_INODE_FE_OFF, NULL);
if (!inode) {
status = -EIO;
LOG_ERROR_STATUS (status);
Modified: trunk/src/vote.c
===================================================================
--- trunk/src/vote.c 2004-05-11 00:09:49 UTC (rev 910)
+++ trunk/src/vote.c 2004-05-11 01:12:05 UTC (rev 911)
@@ -821,14 +821,10 @@
req->lock_id = lock_id;
req->flags = flags;
- if (inode)
- req->fe_off = GET_INODE_FEOFF(inode);
- else
- req->fe_off = 0;
#ifdef VERBOSE_LOCKING_TRACE
- printk("ocfs_send_dlm_request_msg: inode=%p, lockid = %llu, "
- "fe_off=%llu\n", inode, lock_id, req->fe_off);
+ printk("ocfs_send_dlm_request_msg: inode=%p, lockid = %llu\n",
+ inode, lock_id);
#endif
spin_lock(&osb->vote_obj_queue_lock);
More information about the Ocfs2-commits
mailing list