BACKPORT: FROMLIST: ovl: fix wrong use of impure dir cache in ovl_iterate()

Only upper dir can be impure, but if we are in the middle of
iterating a lower real dir, dir could be copied up and marked
impure. We only want the impure cache if we started iterating
a real upper dir to begin with.

Aditya Kali reported that the following reproducer hits the
WARN_ON(!cache->refcount) in ovl_get_cache():

 docker run --rm drupal:8.5.4-fpm-alpine \
    sh -c 'cd /var/www/html/vendor/symfony && \
           chown -R www-data:www-data . && ls -l .'

Reported-by: Aditya Kali <adityakali@xxxxxxxxxx>
Tested-by: Aditya Kali <adityakali@xxxxxxxxxx>
Fixes: 4edb83bb1041 ('ovl: constant d_ino for non-merge dirs')
Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>

(am from https://www.spinics.net/lists/linux-unionfs/msg05418.html)

Conflicts:
	fs/overlayfs/readdir.c
(Dropped the "xino" related comment as it is not supported in
 our kernel)

BUG=b:111060505
TEST=trybots, manual testing using repro
Change-Id: Icc1e357c636d41365f325d078913b01be2ef72e1
Reviewed-on: https://chromium-review.googlesource.com/1149330
Commit-Ready: ChromeOS CL Exonerator Bot <[email protected]>
Tested-by: Aditya Kali <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
(cherry picked from commit 0b4c9a7d4c4889a75f1dfdc3d2b15256704a8257)
Reviewed-on: https://chromium-review.googlesource.com/1162283
Commit-Queue: Aditya Kali <[email protected]>
1 file changed