is_wh_entry = 1;
}
- found = find_filldir_node(buf->rdstate, name, namelen);
-
- if (found)
+ found = find_filldir_node(buf->rdstate, name, namelen, is_wh_entry);
+
+ if (found) {
+ /*
+ * If we had non-whiteout entry in dir cache, then mark it
+ * as a whiteout and but leave it in the dir cache.
+ */
+ if (is_wh_entry && !found->whiteout)
+ found->whiteout = is_wh_entry;
goto out;
+ }
/* if 'name' isn't a whiteout, filldir it. */
if (!is_wh_entry) {
whiteout = 1;
}
- found = find_filldir_node(buf->rdstate, name, namelen);
+ found = find_filldir_node(buf->rdstate, name, namelen, whiteout);
/* If it was found in the table there was a previous whiteout. */
if (found)
goto out;
}
struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
- const char *name, int namelen)
+ const char *name, int namelen,
+ int is_whiteout)
{
int index;
unsigned int hash;
found = 1;
/*
- * if the duplicate is in this branch, then the file
- * system is corrupted.
+ * if a duplicate is found in this branch, and is
+ * not due to the caller looking for an entry to
+ * whiteout, then the file system may be corrupted.
*/
- if (unlikely(cursor->bindex == rdstate->bindex))
+ if (unlikely(!is_whiteout &&
+ cursor->bindex == rdstate->bindex))
printk(KERN_ERR "unionfs: filldir: possible "
"I/O error: a file is duplicated "
"in the same branch %d: %s\n",
const char *name, int namelen, int bindex,
int whiteout);
extern struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
- const char *name, int namelen);
+ const char *name, int namelen,
+ int is_whiteout);
extern struct dentry **alloc_new_dentries(int objs);
extern struct unionfs_data *alloc_new_data(int objs);