[Devel] [PATCH 2/2] e4defrag2: Fix donor file lookup for IAF defragmentation
Dmitry Monakhov
dmonakhov at openvz.org
Wed Sep 30 01:19:23 PDT 2015
Currently dircache per-group bucket explicitly initialized only if IEF candidates
are found for a group, but dircache is also required for IAF files. Let's initialize
all popilated groups.
https://jira.sw.ru/browse/PSBM-40027
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
misc/e4defrag2.c | 33 +++++++++++++++++++++------------
1 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/misc/e4defrag2.c b/misc/e4defrag2.c
index 7be14a8..f217a40 100644
--- a/misc/e4defrag2.c
+++ b/misc/e4defrag2.c
@@ -864,6 +864,21 @@ static int do_iaf_defrag_one(struct defrag_context *dfx, int dirfd, const char *
typedef int proc_inode_t (struct defrag_context *dfx, int fd, struct stat64 *st,
int dirfd, const char *name);
+
+static int group_info_init(struct defrag_context *dfx, dgrp_t group)
+{
+ struct group_info *gi;
+
+ dfx->group[group] = malloc(sizeof(struct group_info) +
+ dfx->root_fhp->handle_bytes * GROUP_DIR_CACHE_SZ);
+ if (!dfx->group[group]) {
+ fprintf(stderr, "%s: Can not allocate memory errno:%d\n", __func__, errno);
+ return 0;
+ }
+ memset(dfx->group[group], 0, sizeof(struct group_info));
+ dfx->group[group]->fh_root = RB_ROOT;
+ return 1;
+}
/* Add ief candidate for later processing */
static int group_add_ief_candidate(struct defrag_context *dfx, int dirfd, const char* name,
dgrp_t group, __u64 pblock,
@@ -878,16 +893,8 @@ static int group_add_ief_candidate(struct defrag_context *dfx, int dirfd, const
assert(flags & SP_FL_IEF_RELOC);
- if (!dfx->group[group]) {
- dfx->group[group] = malloc(sizeof(struct group_info) +
- dfx->root_fhp->handle_bytes * GROUP_DIR_CACHE_SZ);
- if (!dfx->group[group]) {
- fprintf(stderr, "%s: Can not allocate memory errno:%d\n", __func__, errno);
- return -1;
- }
- memset(dfx->group[group], 0, sizeof(struct group_info));
- dfx->group[group]->fh_root = RB_ROOT;
- }
+ if (!dfx->group[group] && !group_info_init(dfx, group))
+ return -1;
fhp = malloc(sizeof(struct file_handle) + dfx->root_fhp->handle_bytes);
if (!fhp) {
@@ -1051,8 +1058,10 @@ static void group_add_dircache(struct defrag_context *dfx, int dirfd, struct sta
struct file_handle *fhp = NULL;
dgrp_t grp = e4d_group_of_ino(dfx, stat->st_ino);
- if (!dfx->group[grp] ||
- dfx->group[grp]->dir_cached == GROUP_DIR_CACHE_SZ)
+ if (!dfx->group[grp] && !group_info_init(dfx, grp))
+ return;
+
+ if (dfx->group[grp]->dir_cached == GROUP_DIR_CACHE_SZ)
return;
for (i = 0; i < dfx->group[grp]->dir_cached; i++) {
--
1.7.1
More information about the Devel
mailing list