2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-16 17:23:55 +08:00

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
parent 71d509280f
commit c9f00fdb9a

View File

@ -274,11 +274,11 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
return 0;
}
static inline int ovl_dir_read_merged(struct path *upperpath,
struct path *lowerpath,
struct list_head *list)
static int ovl_dir_read_merged(struct dentry *dentry, struct list_head *list)
{
int err;
struct path lowerpath;
struct path upperpath;
struct ovl_readdir_data rdd = {
.ctx.actor = ovl_fill_merge,
.list = list,
@ -286,25 +286,28 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
.is_merge = false,
};
if (upperpath->dentry) {
err = ovl_dir_read(upperpath, &rdd);
ovl_path_lower(dentry, &lowerpath);
ovl_path_upper(dentry, &upperpath);
if (upperpath.dentry) {
err = ovl_dir_read(&upperpath, &rdd);
if (err)
goto out;
if (lowerpath->dentry) {
err = ovl_dir_mark_whiteouts(upperpath->dentry, &rdd);
if (lowerpath.dentry) {
err = ovl_dir_mark_whiteouts(upperpath.dentry, &rdd);
if (err)
goto out;
}
}
if (lowerpath->dentry) {
if (lowerpath.dentry) {
/*
* Insert lowerpath entries before upperpath ones, this allows
* offsets to be reasonably constant
*/
list_add(&rdd.middle, rdd.list);
rdd.is_merge = true;
err = ovl_dir_read(lowerpath, &rdd);
err = ovl_dir_read(&lowerpath, &rdd);
list_del(&rdd.middle);
}
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)
{
int res;
struct path lowerpath;
struct path upperpath;
struct ovl_dir_cache *cache;
cache = ovl_dir_cache(dentry);
@ -347,10 +348,7 @@ static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
cache->refcount = 1;
INIT_LIST_HEAD(&cache->entries);
ovl_path_lower(dentry, &lowerpath);
ovl_path_upper(dentry, &upperpath);
res = ovl_dir_read_merged(&upperpath, &lowerpath, &cache->entries);
res = ovl_dir_read_merged(dentry, &cache->entries);
if (res) {
ovl_cache_free(&cache->entries);
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 err;
struct path lowerpath;
struct path upperpath;
struct ovl_cache_entry *p;
ovl_path_upper(dentry, &upperpath);
ovl_path_lower(dentry, &lowerpath);
err = ovl_dir_read_merged(&upperpath, &lowerpath, list);
err = ovl_dir_read_merged(dentry, list);
if (err)
return err;