0015-fsck.ocfs2-prompt-before-truncating-an-invalid-dir-i.patch

0016-tunefs.ocfs2-move-o2ne_add_tailers-into-libocfs2ne.c.patch
   0018-mkfs.ocfs2-create-root-and-orphan-directories-as-ind.patch
   0019-libocfs2-fix-flag-check-in-ocfs2_init_dir.patch
   0020-libocfs2-fix-ocfs2_init_dir-to-retain-indexed-flag.patch
   0021-fsck.ocfs2-verify-dirent-dx-entry-linkages.patch

OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/ocfs2-tools?expand=0&rev=15
This commit is contained in:
Coly Li
2010-06-30 08:38:13 +00:00
committed by Git OBS Bridge
parent 015da54f10
commit 91c883dbb5
7 changed files with 7 additions and 1496 deletions

View File

@@ -1,48 +0,0 @@
From ed44744701bd4eeaf5ee0fcce9190cdf36b5b21c Mon Sep 17 00:00:00 2001
From: Mark Fasheh <mfasheh@suse.com>
Date: Mon, 19 Apr 2010 16:25:48 -0700
Subject: [PATCH 15/30] fsck.ocfs2: prompt before truncating an invalid dir index
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
fsck.ocfs2/fsck.ocfs2.checks.8.in | 6 ++++++
fsck.ocfs2/pass2.c | 6 +++++-
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/fsck.ocfs2/fsck.ocfs2.checks.8.in b/fsck.ocfs2/fsck.ocfs2.checks.8.in
index 05561ae..5cda023 100644
--- a/fsck.ocfs2/fsck.ocfs2.checks.8.in
+++ b/fsck.ocfs2/fsck.ocfs2.checks.8.in
@@ -1055,6 +1055,12 @@ but fsck has already found quota limits for this user / group.
Answering yes will use new values of limits for the user / group.
+.SS "IV_DX_TREE"
+A directory index was found on an inode but that feature is not enabled on the
+file system.
+
+Answering yes will truncate the invalid index.
+
.SH "SEE ALSO"
.BR fsck.ocfs2(8)
diff --git a/fsck.ocfs2/pass2.c b/fsck.ocfs2/pass2.c
index 58efcd4..b999761 100644
--- a/fsck.ocfs2/pass2.c
+++ b/fsck.ocfs2/pass2.c
@@ -874,7 +874,11 @@ next:
if ((!ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super)))&&
di->i_dyn_features & OCFS2_INDEXED_DIR_FL ) {
/* ignore the return value */
- ocfs2_dx_dir_truncate(dd->fs, dbe->e_ino);
+ if (prompt(dd->ost, PY, PR_IV_DX_TREE, "A directory index was "
+ "found on inode %"PRIu64" but the indexing feature "
+ "is not set on the fs. Truncate the invalid index?",
+ dbe->e_ino))
+ ocfs2_dx_dir_truncate(dd->fs, dbe->e_ino);
}
out:
--
1.7.0.2

File diff suppressed because it is too large Load Diff

View File

@@ -1,137 +0,0 @@
From 88d139c22a91b17ff451a50e37d002d8714748f3 Mon Sep 17 00:00:00 2001
From: Mark Fasheh <mfasheh@suse.com>
Date: Mon, 19 Apr 2010 22:26:47 -0700
Subject: [PATCH 18/30] mkfs.ocfs2: create root and orphan directories as indexed
If the indexed dirs feature is enabled but the inline directories feature is
for some reason disabled, we'll create sub-optimal (non-indexed) root and
orphan directories. It's easy however at the end of mkfs.ocfs2 to simply
index these.
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
mkfs.ocfs2/mkfs.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++----
mkfs.ocfs2/mkfs.h | 1 +
2 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index b43a9ba..5507872 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -82,6 +82,7 @@ static AllocGroup * initialize_alloc_group(State *s, const char *name,
uint64_t blkno,
uint16_t chain, uint16_t cpg,
uint16_t bpc);
+static void index_system_dirs(State *s, ocfs2_filesys *fs);
static void create_lost_found_dir(State *s, ocfs2_filesys *fs);
static void format_journals(State *s, ocfs2_filesys *fs);
static void format_slotmap(State *s, ocfs2_filesys *fs);
@@ -436,12 +437,6 @@ static void finish_normal_format(State *s)
printf("done\n");
if (!s->quiet)
- printf("Writing lost+found: ");
- create_lost_found_dir(s, fs);
- if (!s->quiet)
- printf("done\n");
-
- if (!s->quiet)
printf("Formatting quota files: ");
format_quota_files(s, fs);
@@ -449,6 +444,24 @@ static void finish_normal_format(State *s)
if (!s->quiet)
printf("done\n");
+ if (s->dx_dirs && !s->inline_data) {
+ /*
+ * We want to do this after quota, but before adding
+ * any new entries to directories.
+ */
+ if (!s->quiet)
+ printf("Indexing system directories: ");
+ index_system_dirs(s, fs);
+ if (!s->quiet)
+ printf("done\n");
+ }
+
+ if (!s->quiet)
+ printf("Writing lost+found: ");
+ create_lost_found_dir(s, fs);
+ if (!s->quiet)
+ printf("done\n");
+
ocfs2_close(fs);
}
@@ -1085,6 +1098,10 @@ get_state(int argc, char **argv)
s->no_backup_super = 0;
else
s->no_backup_super = 1;
+ if (s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS)
+ s->dx_dirs = 1;
+ else
+ s->dx_dirs = 0;
/* Here if the user set these flags explicitly, we will use them and
@@ -2751,6 +2768,44 @@ clear_both_ends(State *s)
return ;
}
+static void index_system_dirs(State *s, ocfs2_filesys *fs)
+{
+ errcode_t ret;
+ int i, num_slots = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
+ uint64_t orphan_dir_blkno;
+
+
+ /* Start with the root directory */
+ ret = ocfs2_dx_dir_build(fs, fs->fs_root_blkno);
+ if (ret) {
+ com_err(s->progname, ret, "while indexing root directory");
+ goto bail;
+ }
+
+ for (i = 0; i < num_slots; i++) {
+ ret = ocfs2_lookup_system_inode(fs, ORPHAN_DIR_SYSTEM_INODE,
+ i, &orphan_dir_blkno);
+ if (ret) {
+ com_err(s->progname, ret,
+ "while looking up orphan dir %d for indexing",
+ i);
+ goto bail;
+ }
+
+ ret = ocfs2_dx_dir_build(fs, orphan_dir_blkno);
+ if (ret) {
+ com_err(s->progname, ret, "while indexing root directory");
+ goto bail;
+ }
+ }
+
+ return;
+
+bail:
+ clear_both_ends(s);
+ exit(1);
+}
+
static void create_lost_found_dir(State *s, ocfs2_filesys *fs)
{
errcode_t ret;
diff --git a/mkfs.ocfs2/mkfs.h b/mkfs.ocfs2/mkfs.h
index b702f00..c3aecd6 100644
--- a/mkfs.ocfs2/mkfs.h
+++ b/mkfs.ocfs2/mkfs.h
@@ -188,6 +188,7 @@ struct _State {
int mount;
int no_backup_super;
int inline_data;
+ int dx_dirs;
int dry_run;
uint32_t blocksize;
--
1.7.0.2

View File

@@ -1,26 +0,0 @@
From 912f3e698ed20eb14daad38ef79b106a30d39a02 Mon Sep 17 00:00:00 2001
From: Mark Fasheh <mfasheh@suse.com>
Date: Tue, 20 Apr 2010 10:19:54 -0700
Subject: [PATCH 19/30] libocfs2: fix flag check in ocfs2_init_dir()
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
libocfs2/expanddir.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libocfs2/expanddir.c b/libocfs2/expanddir.c
index ec05b74..eb18260 100644
--- a/libocfs2/expanddir.c
+++ b/libocfs2/expanddir.c
@@ -238,7 +238,7 @@ errcode_t ocfs2_init_dir(ocfs2_filesys *fs,
* directory to extent in ocfs2_expand_dir()
*/
if (ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(fs->fs_super)) &&
- (!cinode->ci_inode->i_dyn_features & OCFS2_INLINE_DATA_FL)) {
+ !(cinode->ci_inode->i_dyn_features & OCFS2_INLINE_DATA_FL)) {
ret = ocfs2_dx_dir_build(fs, dir);
if (ret)
goto bail;
--
1.7.0.2

View File

@@ -1,40 +0,0 @@
From 30a19b42c6da181fa3f96123041fb20e69d065d9 Mon Sep 17 00:00:00 2001
From: Mark Fasheh <mfasheh@suse.com>
Date: Tue, 20 Apr 2010 10:20:24 -0700
Subject: [PATCH 20/30] libocfs2: fix ocfs2_init_dir() to retain indexed flag
We were re-using the out of date 'cached inode' later in the function after
ocfs2_dx_dir_build() (which updates and writes out the inode internally).
As a result, ocfs2_init_dir() was accidentally clearing
OCFS2_INDEXED_DIR_FL. Fix this by refreshing the cache after the call to
ocfs2_dx_dir_build().
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
libocfs2/expanddir.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/libocfs2/expanddir.c b/libocfs2/expanddir.c
index eb18260..a81cfbe 100644
--- a/libocfs2/expanddir.c
+++ b/libocfs2/expanddir.c
@@ -242,6 +242,15 @@ errcode_t ocfs2_init_dir(ocfs2_filesys *fs,
ret = ocfs2_dx_dir_build(fs, dir);
if (ret)
goto bail;
+
+ /*
+ * Re-read the 'cached inode' as ocfs2_dx_dir_build()
+ * may have written out changes which won't be
+ * reflected in our copy.
+ */
+ ret = ocfs2_read_cached_inode(fs, dir, &cinode);
+ if (ret)
+ goto bail;
}
/* set link count of the parent */
--
1.7.0.2

View File

@@ -1,92 +0,0 @@
From 4c1cf61779ee71c828134d956f5779e272a3195e Mon Sep 17 00:00:00 2001
From: Mark Fasheh <mfasheh@suse.com>
Date: Fri, 23 Apr 2010 23:09:05 -0700
Subject: [PATCH 21/30] fsck.ocfs2: verify dirent -> dx entry linkages
During pass2 we can trivially do a lookup on dirents while walking the
directory tree. This will help us make sure that an index entry exists for
each dirent. If an entry is not found, the users is prompted and the parent
directory will be marked for an index rebuild.
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
fsck.ocfs2/fsck.ocfs2.checks.8.in | 7 +++++++
fsck.ocfs2/pass2.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/fsck.ocfs2/fsck.ocfs2.checks.8.in b/fsck.ocfs2/fsck.ocfs2.checks.8.in
index 5cda023..cfbb12e 100644
--- a/fsck.ocfs2/fsck.ocfs2.checks.8.in
+++ b/fsck.ocfs2/fsck.ocfs2.checks.8.in
@@ -1061,6 +1061,13 @@ file system.
Answering yes will truncate the invalid index.
+.SS "DX_LOOKUP_FAILED"
+A directory entry is missing an entry in the directory index. Not
+found in directory index. The missing index entry will cause lookups
+on this name to fail.
+
+Answering yes will rebuild the directory index, restoring the missing entry.
+
.SH "SEE ALSO"
.BR fsck.ocfs2(8)
diff --git a/fsck.ocfs2/pass2.c b/fsck.ocfs2/pass2.c
index b999761..e03bd4e 100644
--- a/fsck.ocfs2/pass2.c
+++ b/fsck.ocfs2/pass2.c
@@ -648,6 +648,39 @@ out:
return ret;
}
+static errcode_t fix_dirent_index(o2fsck_dirblock_entry *dbe,
+ struct dirblock_data *dd,
+ struct ocfs2_dir_entry *dirent,
+ unsigned int *flags)
+{
+ errcode_t ret = 0;
+ struct ocfs2_dinode *di = (struct ocfs2_dinode *)dd->inoblock_buf;
+ uint64_t ino;
+
+ if (!ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super)))
+ goto out;
+
+ if (di->i_dyn_features & OCFS2_INDEXED_DIR_FL) {
+ ret = ocfs2_lookup(dd->fs, dbe->e_ino, dirent->name,
+ dirent->name_len, NULL, &ino);
+ if (ret) {
+ if (ret != OCFS2_ET_FILE_NOT_FOUND)
+ goto out;
+ ret = 0;
+
+ if (prompt(dd->ost, PY, PR_DX_LOOKUP_FAILED,
+ "Directory inode %"PRIu64" is missing "
+ "an index entry for child inode %"PRIu64
+ "\n. Repair this by rebuilding the "
+ "directory index?", dbe->e_ino, ino))
+ *flags |= OCFS2_DIRENT_CHANGED;
+ goto out;
+ }
+ }
+out:
+ return ret;
+}
+
static int corrupt_dirent_lengths(struct ocfs2_dir_entry *dirent, int left)
{
if ((dirent->rec_len >= OCFS2_DIR_REC_LEN(1)) &&
@@ -805,6 +838,10 @@ static unsigned pass2_dir_block_iterate(o2fsck_dirblock_entry *dbe,
if (dirent->inode == 0)
goto next;
+ ret = fix_dirent_index(dbe, dd, dirent, &ret_flags);
+ if (ret)
+ goto out;
+
verbosef("dirent %.*s refs ino %"PRIu64"\n", dirent->name_len,
dirent->name, (uint64_t)dirent->inode);
o2fsck_icount_delta(dd->ost->ost_icount_refs, dirent->inode, 1);
--
1.7.0.2

View File

@@ -1,5 +1,5 @@
-------------------------------------------------------------------
Wed Jun 30 05:59:19 UTC 2010 - i@coly.li
Wed Jun 30 08:51:06 UTC 2010 - i@coly.li
- remove bug-585080-handle-symbolic-link.patch since it's upstream now.
- remove version-1.4.3.patch, update to ocfs2-tools 1.6.0
@@ -18,7 +18,13 @@ Wed Jun 30 05:59:19 UTC 2010 - i@coly.li
0012-dx_dirs-fix-return-value-of-walk_dirblock-when-enabl.patch
0013-dx_dirs-try-to-install-dir-trailers-when-enable-inde.patch
0014-dx_dirs-add-an-initial-man-page-entry-for-indexed-di.patch
0015-fsck.ocfs2-prompt-before-truncating-an-invalid-dir-i.patch
0016-tunefs.ocfs2-move-o2ne_add_tailers-into-libocfs2ne.c.patch
0017-dx_dirs-add-check-for-invalid-slot-in-ocfs2_new_dx_r.patch
0018-mkfs.ocfs2-create-root-and-orphan-directories-as-ind.patch
0019-libocfs2-fix-flag-check-in-ocfs2_init_dir.patch
0020-libocfs2-fix-ocfs2_init_dir-to-retain-indexed-flag.patch
0021-fsck.ocfs2-verify-dirent-dx-entry-linkages.patch
0022-dx_dirs-stop-iterate-dir-entries-for-I-O-error.patch
0023-dx_dirs-check-callback-iter-dx_func-return-value-in-.patch
0024-dx_dirs-remove-unncessary-return-value-assignment.patch