[Ocfs2-commits] mfasheh commits r1529 - branches/dlm-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Sep 30 19:54:40 CDT 2004
Author: mfasheh
Date: 2004-09-30 19:54:38 -0500 (Thu, 30 Sep 2004)
New Revision: 1529
Modified:
branches/dlm-changes/src/namei.c
Log:
* make unlink always roll forward
Modified: branches/dlm-changes/src/namei.c
===================================================================
--- branches/dlm-changes/src/namei.c 2004-10-01 00:54:11 UTC (rev 1528)
+++ branches/dlm-changes/src/namei.c 2004-10-01 00:54:38 UTC (rev 1529)
@@ -790,13 +790,13 @@
if (inode == osb->root_inode) {
LOG_TRACE_STR ("Cannot delete the root directory");
status = -EPERM;
- goto bail;
+ goto leave;
}
handle = ocfs_alloc_handle(osb);
if (handle == NULL) {
LOG_ERROR_STATUS (status = -ENOMEM);
- goto bail;
+ goto leave;
}
status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
@@ -858,6 +858,7 @@
LOG_ERROR_STATUS (status = -ENOMEM);
goto leave;
}
+ ocfs_handle_set_always_commits(handle, 1);
status = ocfs_journal_access(handle, fe_bh, OCFS_JOURNAL_ACCESS_WRITE);
if (status < 0) {
@@ -873,11 +874,7 @@
inode->i_nlink = fe->i_links_count;
}
- if (S_ISDIR (inode->i_mode))
- fe->i_links_count = 0;
- else
- fe->i_links_count--;
- if (!fe->i_links_count) {
+ if (S_ISDIR(inode->i_mode) || (fe->i_links_count == 1)) {
status = ocfs_orphan_add(osb, handle, inode, fe, orphan_name,
orphan_entry_bh);
if (status < 0) {
@@ -886,14 +883,19 @@
}
}
- status = ocfs_journal_dirty(handle, fe_bh);
+ /* delete the name from the parent dir */
+ status = ocfs_delete_entry (handle, dir, dirent, dirent_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
}
- /* delete the name from the parent dir */
- status = ocfs_delete_entry (handle, dir, dirent, dirent_bh);
+ if (S_ISDIR (inode->i_mode))
+ fe->i_links_count = 0;
+ else
+ fe->i_links_count--;
+
+ status = ocfs_journal_dirty(handle, fe_bh);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto leave;
@@ -918,20 +920,15 @@
leave:
if (handle) {
- if (status < 0)
- ocfs_abort_trans(handle);
- else {
- ocfs_commit_trans(handle);
- // already checked to make sure dir has nlink==2
- if (S_ISDIR (inode->i_mode)) {
- inode->i_nlink = 0;
- dir->i_nlink--;
- } else
- inode->i_nlink--;
- }
+ ocfs_commit_trans(handle);
+ // already checked to make sure dir has nlink==2
+ if (S_ISDIR (inode->i_mode)) {
+ inode->i_nlink = 0;
+ dir->i_nlink--;
+ } else
+ inode->i_nlink--;
}
-bail:
if (status < 0 && status != -ENOTEMPTY &&
status != -EPERM && status != -EBUSY && status != -EINTR) {
LOG_ERROR_STATUS(status);
More information about the Ocfs2-commits
mailing list