[Ocfs2-commits] mfasheh commits r1536 - branches/dlm-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Oct 1 16:09:50 CDT 2004
Author: mfasheh
Date: 2004-10-01 16:09:48 -0500 (Fri, 01 Oct 2004)
New Revision: 1536
Modified:
branches/dlm-changes/src/namei.c
Log:
* make rename roll-forward.
Modified: branches/dlm-changes/src/namei.c
===================================================================
--- branches/dlm-changes/src/namei.c 2004-10-01 20:06:21 UTC (rev 1535)
+++ branches/dlm-changes/src/namei.c 2004-10-01 21:09:48 UTC (rev 1536)
@@ -1105,7 +1105,7 @@
&new_dir_bh, new_dir);
if (status < 0) {
LOG_ERROR_STATUS(status);
- goto finally;
+ goto bail;
}
/* make sure both dirs have bhs
@@ -1117,7 +1117,7 @@
} else {
LOG_ERROR_STR("no old_dir_bh!");
status = -EIO;
- goto finally;
+ goto bail;
}
}
@@ -1134,7 +1134,7 @@
}
if (status < 0) {
LOG_ERROR_STATUS(status);
- goto finally;
+ goto bail;
}
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE,
FLAG_RELEASE_DENTRY|FLAG_FILE_RENAME,
@@ -1144,23 +1144,23 @@
status = -EIO;
old_inode_de_bh = ocfs_bread (old_inode, 0, &status, 0);
if (!old_inode_de_bh)
- goto finally;
+ goto bail;
status = -EIO;
if (le64_to_cpu(PARENT_INO(old_inode_de_bh->b_data)) !=
OCFS_I(old_dir)->ip_blkno)
- goto finally;
+ goto bail;
status = -EMLINK;
if (!new_inode && new_dir!=old_dir &&
new_dir->i_nlink >= OCFS2_LINK_MAX)
- goto finally;
+ goto bail;
} else {
/* Ah, the simple case - we're a file so just send a
* message. */
status = ocfs_notify_on_rename(osb, old_inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
- goto finally;
+ goto bail;
}
}
@@ -1169,7 +1169,7 @@
old_dentry->d_name.len,
old_dir, &old_de);
if (!old_de_bh)
- goto finally;
+ goto bail;
/*
* Check for inode number is _not_ due to possible IO errors.
@@ -1178,7 +1178,7 @@
* same name. Goodbye sticky bit ;-<
*/
if (le64_to_cpu(old_de->inode) != OCFS_I(old_inode)->ip_blkno)
- goto finally;
+ goto bail;
/* check if the target already exists (in which case we need
* to delete it */
@@ -1192,7 +1192,7 @@
/* If we cannot find the file specified we should just */
/* return the error... */
LOG_ERROR_STATUS (status);
- goto finally;
+ goto bail;
}
if (!new_de && new_inode)
@@ -1213,7 +1213,7 @@
new_inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
- goto finally;
+ goto bail;
}
ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE,
FLAG_RELEASE_DENTRY, new_inode);
@@ -1221,11 +1221,6 @@
newfe = (ocfs2_dinode *) newfe_bh->b_data;
- /* if our caching is working right, then after the
- * verify_update_inode, newfe->i_nlink ==
- * new_inode->i_nlink */
- status = ocfs_refresh_inode (new_inode, newfe);
-
LOG_TRACE_ARGS("aha rename over existing... new_de=%p "
"new_blkno=%llu newfebh=%p bhblocknr=%llu\n",
new_de, newfe_blkno, newfe_bh, newfe_bh ?
@@ -1238,7 +1233,7 @@
&orphan_entry_bh);
if (status < 0) {
LOG_ERROR_STATUS (status);
- goto finally;
+ goto bail;
}
}
} else {
@@ -1249,7 +1244,7 @@
&insert_entry_bh);
if (status < 0) {
LOG_ERROR_STATUS (status);
- goto finally;
+ goto bail;
}
}
@@ -1258,49 +1253,38 @@
LOG_ERROR_STATUS(status = -ENOMEM);
goto bail;
}
+ ocfs_handle_set_always_commits(handle, 1);
if (new_de) {
+ if (S_ISDIR (new_inode->i_mode)) {
+ if (!ocfs_empty_dir(new_inode) || new_inode->i_nlink != 2) {
+ status = -ENOTEMPTY;
+ goto bail;
+ }
+ }
status = ocfs_journal_access(handle, newfe_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS (status);
- goto finally;
+ goto bail;
}
- if (S_ISDIR (new_inode->i_mode)) {
- if (!ocfs_empty_dir(new_inode) || new_inode->i_nlink != 2) {
- status = -ENOTEMPTY;
- goto finally;
- }
- }
-
- if (S_ISDIR (new_inode->i_mode))
- newfe->i_links_count = 0;
- else
- newfe->i_links_count--;
-
- if (!newfe->i_links_count) {
+ if (S_ISDIR(new_inode->i_mode) || (newfe->i_links_count == 1)){
status = ocfs_orphan_add(osb, handle, new_inode,
newfe, orphan_name,
orphan_entry_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
- goto finally;
+ goto bail;
}
}
- status = ocfs_journal_dirty(handle, newfe_bh);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
/* change the dirent to point to the correct inode */
status = ocfs_journal_access(handle, new_de_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
LOG_ERROR_STATUS (status);
- goto finally;
+ goto bail;
}
new_de->inode =
le64_to_cpu(OCFS_I(old_inode)->ip_blkno);
@@ -1309,8 +1293,19 @@
status = ocfs_journal_dirty(handle, new_de_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
- goto finally;
+ goto bail;
}
+
+ if (S_ISDIR (new_inode->i_mode))
+ newfe->i_links_count = 0;
+ else
+ newfe->i_links_count--;
+
+ status = ocfs_journal_dirty(handle, newfe_bh);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ goto bail;
+ }
} else {
/* if the name was not found in new_dir, add it now */
status = ocfs_add_entry (handle, new_dentry, old_inode,
@@ -1318,12 +1313,6 @@
new_dir_bh, insert_entry_bh);
}
-finally:
- if (status < 0) {
- ocfs_abort_trans(handle);
- goto bail;
- }
-
old_inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(old_inode);
@@ -1342,19 +1331,9 @@
if (old_inode_de_bh) {
status = ocfs_journal_access(handle, old_inode_de_bh,
OCFS_JOURNAL_ACCESS_WRITE);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- // BAD
- goto bail;
- }
PARENT_INO(old_inode_de_bh->b_data) =
le64_to_cpu(OCFS_I(new_dir)->ip_blkno);
status = ocfs_journal_dirty(handle, old_inode_de_bh);
- if (status < 0) {
- LOG_ERROR_STATUS(status);
- // BAD
- goto bail;
- }
old_dir->i_nlink--;
if (new_inode) {
new_inode->i_nlink--;
@@ -1396,16 +1375,14 @@
}
}
- /* commit_trans */
- ocfs_commit_trans(handle);
+ status = 0;
+bail:
+ if (handle)
+ ocfs_commit_trans(handle);
if (new_inode)
sync_mapping_buffers(old_inode->i_mapping);
- status = 0;
-
-bail:
-
if (new_inode)
iput(new_inode);
if (newfe_bh)
@@ -2169,14 +2146,6 @@
goto leave;
}
- status = __ocfs_add_entry(handle, orphan_dir_inode, name, namelen,
- inode, OCFS_I(inode)->ip_blkno,
- orphan_dir_bh, de_bh);
- if (status < 0) {
- LOG_ERROR_STATUS(status);
- goto leave;
- }
-
status = ocfs_journal_access(handle, orphan_dir_bh,
OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
@@ -2197,6 +2166,14 @@
goto leave;
}
+ status = __ocfs_add_entry(handle, orphan_dir_inode, name, namelen,
+ inode, OCFS_I(inode)->ip_blkno,
+ orphan_dir_bh, de_bh);
+ if (status < 0) {
+ LOG_ERROR_STATUS(status);
+ goto leave;
+ }
+
fe->i_flags |= OCFS2_ORPHANED_FL;
leave:
if (orphan_dir_inode)
More information about the Ocfs2-commits
mailing list