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

(Dropped the "xino" related comment as it is not supported in
 our kernel)

TEST=trybots, manual testing using repro
Change-Id: Icc1e357c636d41365f325d078913b01be2ef72e1
Commit-Ready: ChromeOS CL Exonerator Bot <>
Tested-by: Aditya Kali <>
Reviewed-by: Guenter Roeck <>
(cherry picked from commit 0b4c9a7d4c4889a75f1dfdc3d2b15256704a8257)
Commit-Queue: Aditya Kali <>
1 file changed