On 2017/5/4 17:03, Amir Goldstein wrote: > On Thu, May 4, 2017 at 11:36 AM, zhangyi (F) <yi.zhang@xxxxxxxxxx> wrote: >> >> 2. Can we read underlying dir entry and get rid of whiteout every time for >> the 'impure' dircetory, not execute the merged flow ? It will save >> memory usage. >> > Did not understand this questions. > Sorry, I didn't make it clear. I mean if we set is_real = !OVL_TYPE_COPYUP() or is_real = !OVL_TYPE_MERGE() && !ovl_dir_impure() (with optimization), it will create ovl_dir_cache and ovl_cache_entry when we read COPYUP directory or 'impure' dircetory in ovl_iterate() flow (as merged dir does). This will cause bloated memory usage and some performance overhead, because this dir is only exist in one layer(not merged), so I think it's don't need ovl_dir_cache. (cost too much ?) Can we find a way to avoid cache use, I find two ways(maybe too complex): 1. Make a wapper ovl_iterate_dir_impure(), it read the underlaying dir entry and get rid of whiteout entry, and use this function to deal the COPYUP or or 'impure' branch in ovl_iterate() like follow example: static int ovl_iterate(struct file *file, struct dir_context *ctx) if (od->is_real) return iterate_dir(od->realfile, ctx); + else if (!OVL_TYPE_MERGE && COPYUP) + return ovl_iterate_dir_impure(od->realfile, ctx); 2. Add a flag in struct dir_context, let underlying filesystem to return what we want to read, like follow example: #define DIR_CONTEXT_HIDE_WHITEOUT (1 << 0) struct dir_context { const filldir_t actor; + unsigned int flag; loff_t pos; }; static int ovl_iterate(struct file *file, struct dir_context *ctx) if (od->is_real) /* is_real = !OVL_TYPE_MERGE() */ return iterate_dir(od->realfile, ctx); And then let underlying filesystem deal with DIR_CONTEXT_HIDE_WHITEOUT flag. If take on this solution, we can cover all cases, OVL_TYPE_COPYUP and pure check are also not required. It changes too greate, but has a good expansibility (flag can be used by other demand in the future). Thanks, ZhangYi. -- To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html