infra: use new mapfree dirtifying

This commit is contained in:
Thomas Schoebel-Theuer 2017-12-10 11:30:21 +01:00
parent 7d64386a21
commit b2cf8686de
3 changed files with 11 additions and 39 deletions

View File

@ -373,47 +373,21 @@ void mf_remove_dirty(struct mapfree_info *mf, struct dirty_info *di)
}
EXPORT_SYMBOL_GPL(mf_remove_dirty);
void mf_get_dirty(struct mapfree_info *mf, loff_t *min, loff_t *max, int min_stage, int max_stage)
{
struct list_head *tmp;
if (unlikely(!mf))
goto done;
down_read(&mf->mf_mutex);
for (tmp = mf->mf_dirty_anchor.next; tmp != &mf->mf_dirty_anchor; tmp = tmp->next) {
struct dirty_info *di = container_of(tmp, struct dirty_info, dirty_head);
struct mref_object *mref = di->dirty_mref;
if (unlikely(!mref)) {
continue;
}
if (di->dirty_stage < min_stage || di->dirty_stage > max_stage) {
continue;
}
if (mref->ref_pos < *min) {
*min = mref->ref_pos;
}
if (mref->ref_pos + mref->ref_len > *max) {
*max = mref->ref_pos + mref->ref_len;
}
}
up_read(&mf->mf_mutex);
done:;
}
EXPORT_SYMBOL_GPL(mf_get_dirty);
void mf_get_any_dirty(const char *filename, loff_t *min, loff_t *max, int min_stage, int max_stage)
loff_t mf_get_any_dirty(const char *filename, int stage)
{
loff_t res = -1;
struct list_head *tmp;
down_read(&mapfree_mutex);
for (tmp = mapfree_list.next; tmp != &mapfree_list; tmp = tmp->next) {
struct mapfree_info *mf = container_of(tmp, struct mapfree_info, mf_head);
if (!strcmp(mf->mf_name, filename)) {
mf_get_dirty(mf, min, max, min_stage, max_stage);
res = mf_dirty_length(mf, stage);
break;
}
}
up_read(&mapfree_mutex);
return res;
}
EXPORT_SYMBOL_GPL(mf_get_any_dirty);

View File

@ -99,8 +99,7 @@ loff_t mf_dirty_length(struct mapfree_info *mf, enum dirty_stage stage);
void mf_insert_dirty(struct mapfree_info *mf, struct dirty_info *di);
void mf_remove_dirty(struct mapfree_info *mf, struct dirty_info *di);
void mf_get_dirty(struct mapfree_info *mf, loff_t *min, loff_t *max, int min_stage, int max_stage);
void mf_get_any_dirty(const char *filename, loff_t *min, loff_t *max, int min_stage, int max_stage);
loff_t mf_get_any_dirty(const char *filename, int stage);
////////////////// module init stuff /////////////////////////

View File

@ -1079,19 +1079,18 @@ int get_inode(char *newpath, struct mars_dent *dent)
}
path_put(&path);
} else if (S_ISREG(dent->new_stat.mode) && dent->d_name && !strncmp(dent->d_name, "log-", 4)) {
loff_t min = dent->new_stat.size;
loff_t max = 0;
loff_t min;
dent->d_corr_A = 0;
dent->d_corr_B = 0;
mf_get_any_dirty(newpath, &min, &max, 0, 2);
min = mf_get_any_dirty(newpath, DIRTY_COMPLETED);
if (min < dent->new_stat.size) {
MARS_DBG("file '%s' A size=%lld min=%lld max=%lld\n", newpath, dent->new_stat.size, min, max);
MARS_DBG("file '%s' A size=%lld min=%lld\n", newpath, dent->new_stat.size, min);
dent->d_corr_A = min;
}
mf_get_any_dirty(newpath, &min, &max, 0, 3);
min = mf_get_any_dirty(newpath, DIRTY_FINISHED);
if (min < dent->new_stat.size) {
MARS_DBG("file '%s' B size=%lld min=%lld max=%lld\n", newpath, dent->new_stat.size, min, max);
MARS_DBG("file '%s' B size=%lld min=%lld\n", newpath, dent->new_stat.size, min);
dent->d_corr_B = min;
}
}