From: Joseph Qi <joseph.qi@huawei.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 3/3] fsck.ocfs2: support append direct io ro compat feature
Date: Mon, 2 Feb 2015 10:59:57 +0800 [thread overview]
Message-ID: <54CEE82D.5040609@huawei.com> (raw)
Support to truncate direct io orphan entry in fsck.ocfs2.
Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
---
fsck.ocfs2/pass4.c | 9 +++++++++
libocfs2/truncate.c | 12 ++++++++++++
2 files changed, 21 insertions(+)
diff --git a/fsck.ocfs2/pass4.c b/fsck.ocfs2/pass4.c
index 7737cc9..de3f672 100644
--- a/fsck.ocfs2/pass4.c
+++ b/fsck.ocfs2/pass4.c
@@ -100,6 +100,9 @@ out:
return;
}
+#define OCFS2_DIO_ORPHAN_PREFIX "dio-"
+#define OCFS2_DIO_ORPHAN_PREFIX_LEN 4
+
static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent,
uint64_t blocknr,
int offset,
@@ -138,6 +141,11 @@ static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent,
goto out;
}
+ /* do not delete inode in case of dio orphan entry */
+ if (!strncmp(dirent->name, OCFS2_DIO_ORPHAN_PREFIX,
+ OCFS2_DIO_ORPHAN_PREFIX_LEN))
+ goto out_check;
+
ret = ocfs2_delete_inode(ost->ost_fs, dirent->inode);
if (ret) {
com_err(whoami, ret, "while deleting orphan inode %"PRIu64
@@ -148,6 +156,7 @@ static int replay_orphan_iterate(struct ocfs2_dir_entry *dirent,
ost->ost_orphan_deleted_count++;
+out_check:
/* Only calculate icount in force check. */
if (ost->ost_force) {
/*
diff --git a/libocfs2/truncate.c b/libocfs2/truncate.c
index 7327253..451db28 100644
--- a/libocfs2/truncate.c
+++ b/libocfs2/truncate.c
@@ -33,6 +33,7 @@
#include <assert.h>
#include <errno.h>
#include "ocfs2/ocfs2.h"
+#include "ocfs2/byteorder.h"
struct truncate_ctxt {
uint64_t ino;
@@ -356,6 +357,16 @@ errcode_t ocfs2_truncate_full(ocfs2_filesys *fs, uint64_t ino,
if (ret)
goto out;
+ /* in case of dio crashed, force do trucate since blocks may already
+ * be allocated
+ */
+ if (ci->ci_inode->i_flags & cpu_to_le32(OCFS2_DIO_ORPHANED_FL)) {
+ ci->ci_inode->i_flags &= ~cpu_to_le32(OCFS2_DIO_ORPHANED_FL);
+ ci->ci_inode->i_dio_orphaned_slot = 0;
+ new_i_size = ci->ci_inode->i_size;
+ goto truncate;
+ }
+
if (ci->ci_inode->i_size == new_i_size)
goto out;
@@ -364,6 +375,7 @@ errcode_t ocfs2_truncate_full(ocfs2_filesys *fs, uint64_t ino,
goto out;
}
+truncate:
if ((S_ISLNK(ci->ci_inode->i_mode) && !ci->ci_inode->i_clusters) ||
(ci->ci_inode->i_dyn_features & OCFS2_INLINE_DATA_FL))
ret = ocfs2_truncate_inline(fs, ino, new_i_size);
--
1.8.4.3
reply other threads:[~2015-02-02 2:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54CEE82D.5040609@huawei.com \
--to=joseph.qi@huawei.com \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.