Subject: bug#47940: tests/tail-2/inotify-dir-recreate.sh FAILs for remote filesystems that passes is_local_dir_

From: Carl Dong <[email-masked]>
Date: Wed, 21 Apr 2021 16:05:02 -0400

Hi all,

I am debugging a reproducible test failure in tests/tail-2/inotify-dir-recreate.sh for coreutils 8.32.

Logs: https://gist.githubusercontent.com/dongcarl/d24bfe853cc5bd9402bba82c36513c07/raw/19b9a15c4b12edf601dd1504cdf4ec0ee0d9344c/inotify-dir-recreate.log

Looking at the non-‘+’ lines, and the final compare diff, we can see that the “out” file only contained the string “inotify” and nothing else.

From my understanding, it has to do with the fact that I’m running this test in a directory which is on overlayfs, which is considered “remote” by tail (see `fremote(int, const char*)`). The filesystem being “remote” should ordinarily trigger one of the 2 SKIP checks in this test, however, neither check triggered a SKIP.

Check 1: is_local_dir_

At the top of inotify-dir-recreate.sh, we invoke is_local_dir_ to make sure that we’re in a “local” filesystem. However, is_local_dir_ invokes `df --local`, which does not use “‌fremote” to determine filesystem locality, but rather “read_file_system_list” from gnulib. The “me_remote” field of the returned “mount_entry" struct is then used to filter out entries which are non-local. However, in the case of overlayfs, the “me_remote” field will be false, and it will be considered “local” by `df --local`

TL;DR: is_local_dir_ = “is possibly local”, but we really want to check if “is possibly remote”

Check 2: Grepping for 'inotify (resources exhausted|cannot be used)'

Here, we expect that if inotify cannot be used, tail will print an indication to stderr and we can skip this test. However, this message is not printed when inotify is disabled in the fast-failing codepath: https://github.com/coreutils/coreutils/blob/v8.32/src/tail.c#L2490-L2512

I think the easiest fix might be to have tail output ‘inotify cannot be used’ to stderr in the fast-failing disable case: https://github.com/coreutils/coreutils/blob/v8.32/src/tail.c#L2490-L2496.

It seems like this bug has been encountered by others as well:
1. https://dnsglk.github.io/lfs/2018/06/28/lfs-coreutils-test-issue.html#inotify-dir-recreate
2. https://github.com/containers/podman/issues/5493#issuecomment-598851397

Carl Dong
[email-masked]
"I fight for the users”

P.S. I believe the comment line for ‌`is_local_fs_type` in the generated `src/fs-is-local.h` needs to be fixed.