Re: [PATCH] ovl: fix dir cache leak for ovl_cache_get

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 8, 2017 at 12:54 PM, Rock Lee <rockdotlee@xxxxxxxxx> wrote:

>
> One more question, only ctx->pos == 0 in ovl_iterate would cause
> ovl_dir_reset and rebuild dir cache which means in some scenarios, dir
> cache may be not up to date. Consider this code:
>
>     DIR *dirp = opendir("foo");
>     readdir(dirp);                /* make sure ctx->pos != 0 in the
> blow readir() */
>     creat("foo/bar" ,0600);  /* ovl_dentry_version_inc() */
>     while ((entry = readdir(dirp)) != NULL) {
>         printf("name %s\n", entry->d_name);
>     }
>
> In this case, "foo/bar" will not be shown in the output because
> readdir will not rebuild dir cache. Could we just ovl_dir_reset()
> everytime regardless of ctx->pos in ovl_iterate() ? Once files
> created/removed/renamed in a directory, ovl_iterate will rebuild dir
> cache and keep the dir cache up to date?
>

We can't because:

1. After rebuilding the cache, you have no guaranty that ctx->pos is
pointing AFTER all the entries that you already read BEFORE rebuilding
the cache, so the result list can be a total disaster.

2. Even if we have a way to use persistent iterator position somehow,
rebuilding the cache on every iteration for a large dir is expensive.

Anyway, the situation you described - skipping an entry that was created
AFTER dir iteration has started can happen on any file system, so it's not
even a bug what you suggest to fix.

Amir.
--
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



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux