New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test inotify watch after drop caches #246
Conversation
The first two patches looks good to me. I do have some questions for the new testcase though. Is there a kernel commit that fixes the bug? We usually add the commit hash to the top level comment of the test so that everyone can check if the tested kernel should contain the fix or not. Also is there a pointer to original reproducer? We tend to include link to it as well. |
tst_brk(TBROK, "Failed to open drop_caches"); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have SAFE_FILE_PRINTF() exactly for this purpose, the whole function can be replaced with:
SAFE_FILE_PRINTF("proc/sys/vm/drop_caches", "2");
{ | ||
struct stat buf; | ||
|
||
fd_notify = tst_syscall(__NR_inotify_init1, O_NONBLOCK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This calls for addition of myinotify_init1() to the inotify.h.
@metan-ucw the fix commit is not yet in upstream. it is on Miklos's overlayfs-next branch, I did not get a reproducer. The reproducer was described in the post from Niklas that I referred to in the RP. |
Then something is not right, the test is passing for me on vanilla 4.14.11. Do I get it right that we should stop getting updates after we drop the dentry cache? |
That's because the bug is an overlay bug, not an inotify bug. |
Then the test has to mount the overlay in the test setup(). |
OK. will do that. |
fab253c
to
c5a5dd9
Compare
Please note that the commit in the test description is in linux-next tree, but not yet upstream |
3b4f443
to
a3183bb
Compare
Rebased to master. |
cb34158
to
d2445a2
Compare
Added another test for another issue I found. |
@metan-ucw commit 31747eda41ef that fixes test case inotify07 in now merged to kernel v4.16-rc1. |
If there is a real bug we can always push the test even if there is no upstream commit, we just have to add that information to the test top level comment and then replace it with kernel commit id once the fix is released. |
d2445a2
to
4df8894
Compare
@metan-ucw I updated fix commit of inotify08. It's not upstream yet, but on overlayfs-next branch, so will get upstream soon. |
I've pushed the first two patches along with seven more fixes for the original inotify tests on the top of that. Some of the problems I've fixed are in the new test you wrote as well. Can you please rebase the pull request and also update the two new test cases? |
4df8894
to
2139add
Compare
FYI, commit 764baba80168 from inotify08 was merged to v4.16-rc5 |
@metan-ucw ping |
2171cff
to
1b26582
Compare
@metan-ucw rebased and fixed problem with inotify07 -i 2 |
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LTP default license is GPLv2+ (the any later one) but that is very minor.
tst_brk(TBROK | TERRNO, | ||
"read(%d, buf, %zu) failed", | ||
fd_notify, EVENT_BUF_LEN); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only nit for this version is that when executed on broken kernel the failure message produced is:
BROK: read(3, buf, 32768) failed: EAGAIN/EWOULDBLOCK
Which looks much more like a broken test rather than anything else. Can we please check for the EAGAIN errno here and print a bit more user friendly TFAIL message in this case?
The same applies to the next test and apart from that the code looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. there are already meaningful TFAIL messages further down, so I only skipped TBROK for EAGAIN case
SAFE_STAT(FILE_PATH, &buf); | ||
tst_res(TINFO, FILE_PATH " ino=%lu, dev=%u:%u", buf.st_ino, | ||
major(buf.st_dev), minor(buf.st_dev)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also got a header deprecation warnings on newer systems for the minor() and major():
inotify08.c:211:13: warning: In the GNU C Library, "minor" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "minor", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"minor", you should undefine it after including <sys/types.h>.
So we should add #include <sys/sysmacros.h> to the includes here.
Add watch on an overlayfs lower directory, then copy up the directory and drop dentry and inode caches. An inotify watch pins the directory inode in cache, but not the dentry. Execute operations on directory and child and expect events to be reported on directory watch. This will fail if file system does not obtain the pinned inode to the new allocated dentry after copy up and drop caches. This is a regression test for commit 31747eda41ef ("ovl: hash directory inodes for fsnotify"). Signed-off-by: Amir Goldstein <amir73il@gmail.com>
291c24d
to
c6b6a5b
Compare
Add watch on an overlayfs lower file, then copy up the file and drop dentry and inode caches. An inotify watch pins the file inode in cache, but not the dentry. Execute operations on file and expect events to be reported on file watch. This will fail if file system does not obtain the pinned inode to the new allocated dentry after copy up and drop caches. This is a regression test for commit 764baba80168 ("ovl: hash non-dir by lower inode for fsnotify"). Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Applied, thanks! |
A test for a problem reported by Niklas Cassel for a setup of inotify watch on overlayfs:
https://marc.info/?l=linux-unionfs&m=151581833424827&w=2
Starts with a face lift to existing inotify tests