[Ocfs2-commits] mfasheh commits r1471 - branches/dlm-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Sep 13 19:26:21 CDT 2004
Author: mfasheh
Date: 2004-09-13 19:26:20 -0500 (Mon, 13 Sep 2004)
New Revision: 1471
Modified:
branches/dlm-changes/src/alloc.c
branches/dlm-changes/src/dir.c
branches/dlm-changes/src/dir.h
branches/dlm-changes/src/dlm.c
branches/dlm-changes/src/file.c
branches/dlm-changes/src/journal.c
branches/dlm-changes/src/namei.c
Log:
* move io_sem from around all acquire_lock calls to only protect the
one read in there, and the transaction afterwards.
* rename empty_dir -> ocfs_empty_dir.
* remove a useless call to ocfs_empty_dir
* get rid of some sTudLY CaPs
Modified: branches/dlm-changes/src/alloc.c
===================================================================
--- branches/dlm-changes/src/alloc.c 2004-09-14 00:04:43 UTC (rev 1470)
+++ branches/dlm-changes/src/alloc.c 2004-09-14 00:26:20 UTC (rev 1471)
@@ -3148,9 +3148,9 @@
LOG_ERROR_STATUS (status);
goto leave;
}
-
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE,
0, inode);
+ ocfs_handle_add_inode(handle, inode);
numBits = ((bytes_wanted + (blockSize-1)) >> blockSizeBits);
numBytes = (u64)numBits << blockSizeBits;
Modified: branches/dlm-changes/src/dir.c
===================================================================
--- branches/dlm-changes/src/dir.c 2004-09-14 00:04:43 UTC (rev 1470)
+++ branches/dlm-changes/src/dir.c 2004-09-14 00:26:20 UTC (rev 1471)
@@ -79,6 +79,7 @@
struct super_block * sb = inode->i_sb;
int have_disk_lock = 0;
ocfs_super *osb = OCFS_SB(sb);
+ int have_sem = 0;
LOG_SET_CONTEXT(READDIR);
@@ -87,11 +88,6 @@
stored = 0;
bh = NULL;
- /* NOTE: We only take a write lock here because of the
- * acquire_lock call. We should investigate whether taking a
- * read lock is such a bad idea in this case... */
- down_write(&OCFS_I(inode)->ip_io_sem);
-
error = ocfs_acquire_lock_ro(osb, inode);
if (error < 0) {
if (error != -EINTR)
@@ -101,6 +97,8 @@
goto bail;
}
have_disk_lock = 1;
+ down_read(&OCFS_I(inode)->ip_io_sem);
+ have_sem = 1;
offset = filp->f_pos & (sb->s_blocksize - 1);
@@ -198,6 +196,8 @@
stored = 0;
bail:
+ if (have_sem)
+ up_read(&OCFS_I(inode)->ip_io_sem);
if (have_disk_lock) {
error = ocfs_release_lock_ro (osb, inode);
@@ -205,8 +205,6 @@
LOG_ERROR_STATUS (error);
}
- up_write(&OCFS_I(inode)->ip_io_sem);
-
LOG_EXIT_STATUS(stored);
LOG_CLEAR_CONTEXT();
return stored;
@@ -239,6 +237,7 @@
LOG_ERROR_STATUS (status);
goto leave;
}
+ down_read(&OCFS_I(inode)->ip_io_sem);
lock_acq = 1;
}
@@ -255,6 +254,7 @@
if (take_lock && lock_acq)
{
+ up_read(&OCFS_I(inode)->ip_io_sem);
tmpstat = ocfs_release_lock_ro (osb, inode);
if (tmpstat < 0) {
LOG_ERROR_STATUS (tmpstat);
@@ -278,7 +278,7 @@
/*
* routine to check that the specified directory is empty (for rmdir)
*/
-int empty_dir(struct inode *inode)
+int ocfs_empty_dir(struct inode *inode)
{
unsigned long offset;
struct buffer_head * bh;
Modified: branches/dlm-changes/src/dir.h
===================================================================
--- branches/dlm-changes/src/dir.h 2004-09-14 00:04:43 UTC (rev 1470)
+++ branches/dlm-changes/src/dir.h 2004-09-14 00:26:20 UTC (rev 1471)
@@ -29,7 +29,7 @@
#ifndef OCFS2_DIR_H
#define OCFS2_DIR_H
-int empty_dir(struct inode *inode); /* FIXME: to namei.c */
+int ocfs_empty_dir(struct inode *inode); /* FIXME: to namei.c */
int ocfs_find_files_on_disk(ocfs_super *osb, const char *name,
int namelen, u64 *blkno,
struct inode *inode, int take_lock,
Modified: branches/dlm-changes/src/dlm.c
===================================================================
--- branches/dlm-changes/src/dlm.c 2004-09-14 00:04:43 UTC (rev 1470)
+++ branches/dlm-changes/src/dlm.c 2004-09-14 00:26:20 UTC (rev 1471)
@@ -222,23 +222,31 @@
}
updated = 0;
+again:
+ /* yay, lock ordering. at least we don't hold io sem across
+ * the whole thing now. */
+ down_read(&OCFS_I(inode)->ip_io_sem);
ocfs_acquire_lockres_write (inode);
-again:
LOG_TRACE_ARGS("attempting to get lock, pass: %d\n", ++k);
+ /* if updated = 1 then we've read a valid bh so skip the
+ * update_lockres if we can trust it. */
+ if (updated && (lockres->master_node_num != osb->node_num))
+ updated = 0;
+
if (!updated) {
status = ocfs_update_lockres(osb, *bh, inode, 1);
if (status < 0) {
+ up_read(&OCFS_I(inode)->ip_io_sem);
ocfs_release_lockres_write (inode);
LOG_ERROR_STATUS (status);
goto finally;
}
+ updated = 1;
}
+ up_read(&OCFS_I(inode)->ip_io_sem);
- /* alright, if we own it then no more updates are necessary. */
- if (lockres->master_node_num == osb->node_num)
- updated = 1;
reevaluate:
no_owner = (lockres->master_node_num == OCFS_INVALID_NODE_NUM);
@@ -383,11 +391,6 @@
OCFS_I(inode)->ip_blkno,
lock_id);
ocfs_sleep (50);
- ocfs_acquire_lockres_write(inode);
- /* if we're going to jump back up, we want to update
- * if we're not the master... */
- if (lockres->master_node_num != osb->node_num)
- updated = 0;
goto again;
}
goto finally;
Modified: branches/dlm-changes/src/file.c
===================================================================
--- branches/dlm-changes/src/file.c 2004-09-14 00:04:43 UTC (rev 1470)
+++ branches/dlm-changes/src/file.c 2004-09-14 00:26:20 UTC (rev 1471)
@@ -416,7 +416,7 @@
struct inode *inode)
{
int status = 0;
- ocfs2_dinode *fileEntry = NULL;
+ ocfs2_dinode *fe = NULL;
struct buffer_head *bh = NULL;
ocfs_journal_handle *handle = NULL;
@@ -440,9 +440,9 @@
LOG_ERROR_STATUS (status);
goto leave;
}
-
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, FLAG_FILE_UPDATE_OIN,
inode);
+ ocfs_handle_add_inode(handle, inode);
/* Start a transaction - need a minimal amount of block credits (1) */
handle = ocfs_start_trans(osb, handle, 1);
@@ -451,9 +451,9 @@
goto leave;
}
- fileEntry = (ocfs2_dinode *) bh->b_data;
+ fe = (ocfs2_dinode *) bh->b_data;
- if (!IS_VALID_FILE_ENTRY(fileEntry)) {
+ if (!IS_VALID_FILE_ENTRY(fe)) {
LOG_ERROR_ARGS("Invalid fe at blkno %llu",
OCFS_I(inode)->ip_blkno);
status = -EFAIL;
@@ -466,11 +466,11 @@
goto leave;
}
- fileEntry = (ocfs2_dinode *) bh->b_data;
+ fe = (ocfs2_dinode *) bh->b_data;
- fileEntry->i_mtime = OCFS_CURRENT_TIME;
+ fe->i_mtime = OCFS_CURRENT_TIME;
- ocfs_fe_set_attributes(fileEntry, attr);
+ ocfs_fe_set_attributes(fe, attr);
status = ocfs_journal_dirty(handle, bh);
if (status < 0) {
@@ -639,10 +639,8 @@
LOG_TRACE_ARGS
("Writing at EOF, will need more allocation: have=%llu, "
"need=%llu\n", OCFS_I(inode)->ip_alloc_size, newsize);
- down_write(&OCFS_I(inode)->ip_io_sem);
status = ocfs_extend_file(osb, newsize,
NULL, inode, NULL, 0, NULL);
- up_write(&OCFS_I(inode)->ip_io_sem);
if (status < 0) {
if (status != -EINTR && status != -ENOSPC) {
LOG_ERROR_STATUS (status);
@@ -933,6 +931,8 @@
/* if we updated correctly then we can update the alloc_size */
OCFS_I(inode)->ip_alloc_size = new_alloc_size;
OCFS_I(inode)->ip_mmu_private = fe->i_size;
+ ocfs_extent_map_destroy(&OCFS_I(inode)->ip_ext_map);
+ ocfs_extent_map_init (&OCFS_I(inode)->ip_ext_map);
up (&(OCFS_I(inode)->ip_sem));
leave:
@@ -1012,7 +1012,6 @@
struct buffer_head *bh = NULL;
ocfs_journal_handle *handle = NULL;
int credits;
- struct inode *ext_alloc_inode = NULL;
LOG_ENTRY_ARGS("(file_size=%llu, system=%s)\n",
file_size, system_file?"yes":"no");
@@ -1048,6 +1047,7 @@
OCFS_LKM_EXMODE,
FLAG_FILE_EXTEND|FLAG_FILE_UPDATE_OIN,
inode);
+ ocfs_handle_add_inode(handle, inode);
} else {
handle = passed_handle;
/* fe_bh is optional if you already have a transaction open. */
@@ -1200,14 +1200,7 @@
kfree(bhs);
}
- ext_alloc_inode = ocfs_get_system_file_inode(osb, EXTENT_ALLOC_BITMAP_SYSTEM_INODE, osb->node_num);
- if (!ext_alloc_inode) {
- status = -EFAIL;
- LOG_ERROR_STATUS(status);
- goto leave;
- }
-
- ocfs_handle_add_inode(handle, ext_alloc_inode);
+// ocfs_handle_add_inode(handle, ext_alloc_inode);
status = ocfs_allocate_extent(osb, bh, handle, block_off,
numClustersAlloc, inode);
if (status < 0) {
@@ -1269,9 +1262,6 @@
if (bh != NULL && fe_bh == NULL)
brelse(bh);
- if (ext_alloc_inode)
- iput(ext_alloc_inode);
-
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_extend_file */
@@ -1303,8 +1293,6 @@
}
#endif
- down_write(&OCFS_I(inode)->ip_io_sem);
-
if (!dentry->d_parent || !dentry->d_parent->d_inode) {
LOG_ERROR_STR ("bad inode or root inode");
goto bail;
@@ -1338,7 +1326,9 @@
if (attr->ia_valid & ATTR_SIZE) {
if (atomic_read(&OCFS_I(inode)->ip_needs_verification)) {
LOG_TRACE_STR ("OIN_NEEDS_VERIFICATION");
+ down_read(&OCFS_I(inode)->ip_io_sem);
status = ocfs_verify_update_inode (osb, inode);
+ up_read(&OCFS_I(inode)->ip_io_sem);
if (status < 0) {
LOG_ERROR_STATUS (status);
LOG_TRACE_STR ("TODO: disable volume");
@@ -1365,10 +1355,6 @@
}
down (&(OCFS_I(inode)->ip_sem));
- if (inode->i_size > newsize) {
- ocfs_extent_map_destroy(&OCFS_I(inode)->ip_ext_map);
- ocfs_extent_map_init (&OCFS_I(inode)->ip_ext_map);
- }
inode->i_size = newsize;
inode->i_blocks = (newsize + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
if (OCFS_I(inode)->ip_open_flags &
@@ -1377,9 +1363,7 @@
OCFS_I(inode)->ip_mmu_private = inode->i_size;
}
up (&(OCFS_I(inode)->ip_sem));
- up_write(&OCFS_I(inode)->ip_io_sem);
status = ocfs2_zero_extend(inode);
- down_write(&OCFS_I(inode)->ip_io_sem);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto bail;
@@ -1399,8 +1383,6 @@
error = inode_setattr (inode, attr);
bail:
- up_write(&OCFS_I(inode)->ip_io_sem);
-
LOG_EXIT_INT (error);
LOG_CLEAR_CONTEXT();
Modified: branches/dlm-changes/src/journal.c
===================================================================
--- branches/dlm-changes/src/journal.c 2004-09-14 00:04:43 UTC (rev 1470)
+++ branches/dlm-changes/src/journal.c 2004-09-14 00:26:20 UTC (rev 1471)
@@ -492,7 +492,6 @@
{
OCFS_ASSERT(handle);
OCFS_ASSERT(inode);
- OCFS_ASSERT((handle->flags & OCFS_HANDLE_STARTED));
if (OCFS_I(inode)->ip_handle == handle) {
/* sanity check */
@@ -504,6 +503,11 @@
* system file in the same transaction */
LOG_TRACE_ARGS("Inode %lu already added to transaction!\n",
inode->i_ino);
+
+ /* lets not allow recursive locking for regular
+ * files. it sucks enough that we have to do it for
+ * system files. */
+ OCFS_ASSERT(OCFS_I(inode)->ip_flags & OCFS_INODE_SYSTEM_FILE);
return;
}
@@ -571,9 +575,10 @@
OCFS_ASSERT(!handle->num_co);
OCFS_ASSERT(!handle->num_buffs);
- osb = handle->osb;
+ ocfs_handle_unlock_inodes(handle);
/* You are allowed to add journal locks before the transaction
* has started. */
+ osb = handle->osb;
ocfs_handle_move_locks(osb->journal, handle);
spin_lock(&osb->journal->cmt_lock);
osb->needs_flush = 1;
@@ -1097,15 +1102,11 @@
goto done;
}
- down_write(&OCFS_I(inode)->ip_io_sem);
-
SET_INODE_JOURNAL(inode);
status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE,
0, &bh, inode);
if (status < 0) {
- up_write(&OCFS_I(inode)->ip_io_sem);
-
if (status != -EINTR)
LOG_ERROR_STR("Could not get lock on journal!");
goto done;
@@ -1118,9 +1119,6 @@
"You must run tuneocfs to add a journal for this node.\n",
fe->i_size, OCFS_JOURNAL_DEFAULT_SIZE);
status = -EINVAL;
- fe = NULL;
- up_write(&OCFS_I(inode)->ip_io_sem);
-
goto done;
}
@@ -1141,8 +1139,6 @@
OCFS_I(inode)->ip_open_cnt++;
- up_write(&OCFS_I(inode)->ip_io_sem);
-
/* call the kernels journal init function now */
k_journal = journal_init_inode(inode);
if (k_journal == NULL) {
@@ -1525,8 +1521,6 @@
goto done;
}
- down_write(&OCFS_I(inode)->ip_io_sem);
-
SET_INODE_JOURNAL(inode);
/* Should not ever be called to recover ourselves -- in that
@@ -1537,7 +1531,6 @@
status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, FLAG_FILE_RECOVERY,
&bh, inode);
- up_write(&OCFS_I(inode)->ip_io_sem);
if (status < 0) {
LOG_TRACE_ARGS("status returned from acquire_lock=%d\n",
status);
@@ -1684,7 +1677,6 @@
goto bail;
}
- down_write(&OCFS_I(orphan_dir_inode)->ip_io_sem);
status = ocfs_acquire_lock_ro(osb, orphan_dir_inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
@@ -1694,6 +1686,7 @@
offset = 0;
iter = NULL;
+ down_read(&OCFS_I(orphan_dir_inode)->ip_io_sem);
while(offset < orphan_dir_inode->i_size) {
blk = offset >> sb->s_blocksize_bits;
@@ -1701,6 +1694,7 @@
if (!bh)
status = -EINVAL;
if (status < 0) {
+ up_read(&OCFS_I(orphan_dir_inode)->ip_io_sem);
if (bh)
brelse(bh);
LOG_ERROR_STATUS(status);
@@ -1714,6 +1708,7 @@
if (!ocfs_check_dir_entry(orphan_dir_inode,
de, bh, local)) {
+ up_read(&OCFS_I(orphan_dir_inode)->ip_io_sem);
status = -EINVAL;
LOG_ERROR_STATUS(status);
brelse (bh);
@@ -1754,6 +1749,7 @@
}
brelse(bh);
}
+ up_read(&OCFS_I(orphan_dir_inode)->ip_io_sem);
status = ocfs_release_lock_ro(osb, orphan_dir_inode);
have_disk_lock = 0;
@@ -1762,7 +1758,6 @@
goto bail;
}
- up_write(&OCFS_I(orphan_dir_inode)->ip_io_sem);
iput(orphan_dir_inode);
orphan_dir_inode = NULL;
@@ -1781,10 +1776,9 @@
LOG_ERROR_STATUS(tmpstat);
}
- if (orphan_dir_inode) {
- up_write(&OCFS_I(orphan_dir_inode)->ip_io_sem);
+ if (orphan_dir_inode)
iput(orphan_dir_inode);
- }
+
return(status);
}
Modified: branches/dlm-changes/src/namei.c
===================================================================
--- branches/dlm-changes/src/namei.c 2004-09-14 00:04:43 UTC (rev 1470)
+++ branches/dlm-changes/src/namei.c 2004-09-14 00:26:20 UTC (rev 1471)
@@ -148,11 +148,9 @@
LOG_TRACE_ARGS("about to call find_files_on_disk with inode=%p\n",
dir);
- down_write(&OCFS_I(dir)->ip_io_sem);
status = ocfs_find_files_on_disk(osb, dentry->d_name.name,
dentry->d_name.len, &blkno,
dir, 1, &dirent_bh, &dirent);
- up_write(&OCFS_I(dir)->ip_io_sem);
if (status < 0)
goto bail_add;
@@ -204,8 +202,6 @@
}
#endif
- down_write(&OCFS_I(dir)->ip_io_sem);
-
/* get our super block */
osb = OCFS_SB(dir->i_sb);
if (osb->osb_flags & OCFS_OSB_FLAGS_SHUTDOWN) {
@@ -245,9 +241,8 @@
LOG_ERROR_STATUS (status);
goto leave;
}
-
- /* Ok, we got the lock -- we'd better add it to our transaction */
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
+ ocfs_handle_add_inode(handle, dir);
dirfe = (ocfs2_dinode *) parent_fe_bh->b_data;
if (!dirfe->i_links_count) {
@@ -352,8 +347,6 @@
if ((status < 0) && handle)
ocfs_abort_trans(handle);
- up_write(&OCFS_I(dir)->ip_io_sem);
-
if (status == -ENOSPC)
LOG_TRACE_STR ("Disk is full");
else if (status < 0 && status != -EINTR)
@@ -392,7 +385,6 @@
__u64 disk_off = 0;
u64 fe_blkno = 0;
__u64 fileOffset = 0;
- struct inode *inode_alloc_inode = NULL;
LOG_ENTRY_ARGS ("(0x%p, 0x%p, %d, %lu, '%*s')\n", dir, dentry, mode,
(unsigned long)dev, dentry->d_name.len, dentry->d_name.name);
@@ -400,14 +392,6 @@
OCFS_ASSERT(new_fe_bh);
*new_fe_bh = NULL;
- inode_alloc_inode = ocfs_get_system_file_inode(osb, INODE_ALLOC_BITMAP_SYSTEM_INODE, osb->node_num);
- if (!inode_alloc_inode) {
- status = -EFAIL;
- LOG_ERROR_STATUS(status);
- goto leave;
- }
-
- ocfs_handle_add_inode(handle, inode_alloc_inode);
status = ocfs_alloc_node_block(osb, osb->sb->s_blocksize,
&disk_off, &fileOffset,
osb->node_num, DISK_ALLOC_INODE,
@@ -508,8 +492,6 @@
brelse(*new_fe_bh);
*new_fe_bh = NULL;
}
- if (inode_alloc_inode)
- iput(inode_alloc_inode);
LOG_EXIT_STATUS (status);
return status;
@@ -563,7 +545,6 @@
ocfs_journal_handle *handle = NULL;
struct inode *inode = old_dentry->d_inode;
int err;
- int drop_dir_sem = 0, drop_inode_sem = 0;
struct buffer_head *fe_bh = NULL;
struct buffer_head *parent_fe_bh = NULL;
ocfs2_dinode *fe = NULL;
@@ -592,8 +573,6 @@
goto bail;
}
- down_write(&OCFS_I(dir)->ip_io_sem);
- drop_dir_sem = 1;
/* lock the parent directory */
err = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0,
&parent_fe_bh, dir);
@@ -603,9 +582,8 @@
goto bail;
}
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
+ ocfs_handle_add_inode(handle, dir);
- down_write(&OCFS_I(inode)->ip_io_sem);
- drop_inode_sem = 1;
err = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0, &fe_bh, inode);
if (err < 0) {
if (err != -EINTR)
@@ -614,6 +592,7 @@
}
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, FLAG_FILE_UPDATE_OIN,
inode);
+ ocfs_handle_add_inode(handle, inode);
fe = (ocfs2_dinode *) fe_bh->b_data;
if (fe->i_links_count >= OCFS2_LINK_MAX) {
@@ -663,11 +642,6 @@
if (handle)
ocfs_commit_trans(handle);
- if (drop_dir_sem)
- up_write(&OCFS_I(dir)->ip_io_sem);
- if (drop_inode_sem)
- up_write(&OCFS_I(inode)->ip_io_sem);
-
if (fe_bh)
brelse(fe_bh);
if (parent_fe_bh)
@@ -690,7 +664,6 @@
int retval = -EBUSY;
ocfs_super *osb = OCFS_SB(dir->i_sb);
u64 blkno;
- struct inode *parentInode = dentry->d_parent->d_inode;
ocfs2_dinode *fe = NULL;
struct buffer_head *fe_bh = NULL;
struct buffer_head *parent_node_bh = NULL; /* parent locknode */
@@ -703,6 +676,8 @@
LOG_ENTRY_ARGS ("(0x%p, 0x%p, '%*s')\n", dir, dentry,
dentry->d_name.len, dentry->d_name.name);
+ OCFS_ASSERT((dentry->d_parent->d_inode == dir));
+
LOG_TRACE_ARGS("ino = %llu\n", OCFS_I(inode)->ip_blkno);
status = -EBUSY;
@@ -719,22 +694,20 @@
goto bail;
}
- down_write(&OCFS_I(dir)->ip_io_sem);
- down_write(&OCFS_I(inode)->ip_io_sem);
-
status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
- &parent_node_bh, parentInode);
+ &parent_node_bh, dir);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
}
- ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, parentInode);
+ ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
+ ocfs_handle_add_inode(handle, dir);
/* this will re-read the directory now with the EXCLUSIVE */
/* lock already held; it will also return the blkno to us */
status = ocfs_find_files_on_disk(osb, dentry->d_name.name,
dentry->d_name.len, &blkno,
- parentInode, 0, &dirent_bh,
+ dir, 0, &dirent_bh,
&dirent);
if (status < 0) {
LOG_ERROR_STATUS(status);
@@ -753,9 +726,10 @@
}
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, FLAG_RELEASE_DENTRY,
inode);
+ ocfs_handle_add_inode(handle, inode);
if (S_ISDIR (inode->i_mode)) {
- if (!empty_dir(inode)) {
+ if (!ocfs_empty_dir(inode)) {
status = -ENOTEMPTY;
goto leave;
} else if (inode->i_nlink != 2) {
@@ -803,7 +777,7 @@
}
/* delete the name from the parent dir */
- status = ocfs_delete_entry (handle, parentInode, dirent, dirent_bh);
+ status = ocfs_delete_entry (handle, dir, dirent, dirent_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
@@ -841,8 +815,6 @@
}
}
- up_write(&OCFS_I(inode)->ip_io_sem);
- up_write(&OCFS_I(dir)->ip_io_sem);
bail:
if (status < 0 && status != -ENOTEMPTY &&
status != -EPERM && status != -EBUSY && status != -EINTR) {
@@ -933,6 +905,7 @@
goto bail;
}
ocfs_handle_add_lock(handle, type2, flags2, inode2);
+ ocfs_handle_add_inode(handle, inode2);
}
/* lock id1 */
status = ocfs_acquire_lock(osb, type1, flags1,
@@ -942,34 +915,12 @@
goto bail;
}
ocfs_handle_add_lock(handle, type1, flags1, inode1);
-
+ ocfs_handle_add_inode(handle, inode1);
bail:
-
LOG_EXIT_STATUS(status);
return(status);
} /* ocfs_double_lock */
-static inline void double_down_write(struct rw_semaphore *s1,
- struct rw_semaphore *s2)
-{
- if (s1 != s2) {
- if ((unsigned long) s1 < (unsigned long) s2) {
- struct rw_semaphore *tmp = s2;
- s2 = s1; s1 = tmp;
- }
- down_write(s1);
- }
- down_write(s2);
-}
-
-static inline void double_up_write(struct rw_semaphore *s1,
- struct rw_semaphore *s2)
-{
- up_write(s1);
- if (s1 != s2)
- up_write(s2);
-}
-
#define PARENT_INO(buffer) \
((struct ocfs2_dir_entry *) ((char *) buffer + \
le16_to_cpu(((struct ocfs2_dir_entry *) buffer)->rec_len)))->inode
@@ -1006,14 +957,9 @@
osb = OCFS_SB(old_dir->i_sb);
- double_down_write(&OCFS_I(old_dir)->ip_io_sem,
- &OCFS_I(new_dir)->ip_io_sem);
- down_write(&OCFS_I(old_inode)->ip_io_sem);
-
if (new_inode) {
if (ocfs_inc_icount(new_inode) < 0)
BUG();
- down_write(&OCFS_I(new_inode)->ip_io_sem);
}
if (atomic_read (&old_dentry->d_count) > 2) {
@@ -1024,13 +970,6 @@
}
}
- if (new_inode && S_ISDIR (old_inode->i_mode) &&
- !empty_dir (new_inode)) {
- status = -ENOTEMPTY;
- LOG_TRACE_STR ("New (directory) dentry NOT empty!");
- goto bail;
- }
-
handle = ocfs_alloc_handle(osb);
if (handle == NULL) {
LOG_ERROR_STATUS(status = -ENOMEM);
@@ -1078,10 +1017,10 @@
LOG_ERROR_STATUS(status);
goto finally;
}
-
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE,
FLAG_RELEASE_DENTRY|FLAG_FILE_RENAME,
old_inode);
+ ocfs_handle_add_inode(handle, old_inode);
status = -EIO;
old_inode_de_bh = ocfs_bread (handle, old_inode, 0, 0, &status, 0);
@@ -1157,9 +1096,9 @@
LOG_ERROR_STATUS(status);
goto finally;
}
-
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE,
FLAG_RELEASE_DENTRY, new_inode);
+ ocfs_handle_add_inode(handle, new_inode);
newfe = (ocfs2_dinode *) newfe_bh->b_data;
@@ -1189,7 +1128,7 @@
}
if (S_ISDIR (new_inode->i_mode)) {
- if (!empty_dir(new_inode) || new_inode->i_nlink != 2) {
+ if (!ocfs_empty_dir(new_inode) || new_inode->i_nlink != 2) {
status = -ENOTEMPTY;
goto finally;
}
@@ -1326,15 +1265,8 @@
bail:
- double_up_write(&OCFS_I(old_dir)->ip_io_sem,
- &OCFS_I(new_dir)->ip_io_sem);
- up_write(&OCFS_I(old_inode)->ip_io_sem);
-
- if (new_inode) {
- up_write(&OCFS_I(new_inode)->ip_io_sem);
+ if (new_inode)
iput(new_inode);
- }
-
if (newfe_bh)
brelse(newfe_bh);
if (old_dir_bh)
@@ -1494,8 +1426,6 @@
sb = dir->i_sb;
osb = OCFS_SB(sb);
- down_write(&OCFS_I(dir)->ip_io_sem);
-
inode = new_inode (sb);
if (IS_ERR (inode)) {
status = PTR_ERR(inode);
@@ -1530,8 +1460,8 @@
LOG_ERROR_STATUS (status);
goto abort_trans;
}
-
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
+ ocfs_handle_add_inode(handle, dir);
dirfe = (ocfs2_dinode *) parent_fe_bh->b_data;
if (!dirfe->i_links_count) {
@@ -1606,10 +1536,8 @@
}
bail:
- up_write(&OCFS_I(dir)->ip_io_sem);
- if (new_fe_bh) {
+ if (new_fe_bh)
brelse(new_fe_bh);
- }
if (parent_fe_bh)
brelse(parent_fe_bh);
More information about the Ocfs2-commits
mailing list