ovl: pass dentry into ovl_dir_read_merged()

Pass dentry into ovl_dir_read_merged() insted of upperpath and lowerpath.
This cleans up callers and paves the way for multi-layer directory reads.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
This commit is contained in:
Miklos Szeredi 2014-11-20 16:40:01 +01:00
Родитель 71d509280f
Коммит c9f00fdb9a
1 изменённых файлов: 14 добавлений и 21 удалений

Просмотреть файл

@ -274,11 +274,11 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
return 0; return 0;
} }
static inline int ovl_dir_read_merged(struct path *upperpath, static int ovl_dir_read_merged(struct dentry *dentry, struct list_head *list)
struct path *lowerpath,
struct list_head *list)
{ {
int err; int err;
struct path lowerpath;
struct path upperpath;
struct ovl_readdir_data rdd = { struct ovl_readdir_data rdd = {
.ctx.actor = ovl_fill_merge, .ctx.actor = ovl_fill_merge,
.list = list, .list = list,
@ -286,25 +286,28 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
.is_merge = false, .is_merge = false,
}; };
if (upperpath->dentry) { ovl_path_lower(dentry, &lowerpath);
err = ovl_dir_read(upperpath, &rdd); ovl_path_upper(dentry, &upperpath);
if (upperpath.dentry) {
err = ovl_dir_read(&upperpath, &rdd);
if (err) if (err)
goto out; goto out;
if (lowerpath->dentry) { if (lowerpath.dentry) {
err = ovl_dir_mark_whiteouts(upperpath->dentry, &rdd); err = ovl_dir_mark_whiteouts(upperpath.dentry, &rdd);
if (err) if (err)
goto out; goto out;
} }
} }
if (lowerpath->dentry) { if (lowerpath.dentry) {
/* /*
* Insert lowerpath entries before upperpath ones, this allows * Insert lowerpath entries before upperpath ones, this allows
* offsets to be reasonably constant * offsets to be reasonably constant
*/ */
list_add(&rdd.middle, rdd.list); list_add(&rdd.middle, rdd.list);
rdd.is_merge = true; rdd.is_merge = true;
err = ovl_dir_read(lowerpath, &rdd); err = ovl_dir_read(&lowerpath, &rdd);
list_del(&rdd.middle); list_del(&rdd.middle);
} }
out: out:
@ -329,8 +332,6 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry) static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
{ {
int res; int res;
struct path lowerpath;
struct path upperpath;
struct ovl_dir_cache *cache; struct ovl_dir_cache *cache;
cache = ovl_dir_cache(dentry); cache = ovl_dir_cache(dentry);
@ -347,10 +348,7 @@ static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
cache->refcount = 1; cache->refcount = 1;
INIT_LIST_HEAD(&cache->entries); INIT_LIST_HEAD(&cache->entries);
ovl_path_lower(dentry, &lowerpath); res = ovl_dir_read_merged(dentry, &cache->entries);
ovl_path_upper(dentry, &upperpath);
res = ovl_dir_read_merged(&upperpath, &lowerpath, &cache->entries);
if (res) { if (res) {
ovl_cache_free(&cache->entries); ovl_cache_free(&cache->entries);
kfree(cache); kfree(cache);
@ -538,14 +536,9 @@ const struct file_operations ovl_dir_operations = {
int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list) int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
{ {
int err; int err;
struct path lowerpath;
struct path upperpath;
struct ovl_cache_entry *p; struct ovl_cache_entry *p;
ovl_path_upper(dentry, &upperpath); err = ovl_dir_read_merged(dentry, list);
ovl_path_lower(dentry, &lowerpath);
err = ovl_dir_read_merged(&upperpath, &lowerpath, list);
if (err) if (err)
return err; return err;