Skip to content

Instantly share code, notes, and snippets.

@avagin
Created September 6, 2014 17:58
Show Gist options
  • Save avagin/617d8d45907beb43a8d5 to your computer and use it in GitHub Desktop.
Save avagin/617d8d45907beb43a8d5 to your computer and use it in GitHub Desktop.
[root@avagin-fc19-cr criu]# bash test/zdtm.sh static/inotify00
================================= CRIU CHECK =================================
Looks good.
Execute zdtm/live/static/inotify00
cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -iquote ../../lib/arch/x86/include -I../../lib inotify00.c ../../lib/libzdtmtst.a -o inotify00
./inotify00 --pidfile=inotify00.pid --outfile=inotify00.out
Dump 1097
Restore
Check results 1097
Waiting...
21:51:43.278: 1097: 4
21:51:43.278: 1097: -----
21:51:43.648: 1097: 10
21:51:43.648: 1097: 4
21:51:43.648: 1097: 20
21:51:43.649: 1097: 4
21:51:43.649: 1097: 400
21:51:43.649: 1097: FAIL: inotify00.c:90: Unexpected events (errno = 11 (Resource temporarily unavailable))
21:51:43.649: 1097: -----
21:51:43.680: 1097: 8
21:51:43.680: 1097: 400
21:51:43.680: 1097: 8000
21:51:43.680: 1097: PASS
Test: zdtm/live/static/inotify00, Result: PASS
ZDTM tests PASS.
[root@avagin-fc19-cr criu]# bash test/zdtm.sh -i 0 static/inotify00
================================= CRIU CHECK =================================
Looks good.
Execute zdtm/live/static/inotify00
./inotify00 --pidfile=inotify00.pid --outfile=inotify00.out
Check results 1190
Waiting...
21:51:52.187: 1190: 4
21:51:52.187: 1190: -----
21:51:52.204: 1190: -----
21:51:52.236: 1190: 8
21:51:52.236: 1190: 400
21:51:52.236: 1190: 8000
21:51:52.236: 1190: PASS
Test: zdtm/live/static/inotify00, Result: PASS
ZDTM tests PASS.
diff --git a/fs/dcache.c b/fs/dcache.c
index 06f6585..7f88507 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -279,13 +279,16 @@ static void dentry_iput(struct dentry * dentry)
__releases(dentry->d_inode->i_lock)
{
struct inode *inode = dentry->d_inode;
+ bool last_dentry;
+
if (inode) {
dentry->d_inode = NULL;
hlist_del_init(&dentry->d_alias);
+ last_dentry = hlist_empty(&inode->i_dentry);
spin_unlock(&dentry->d_lock);
spin_unlock(&inode->i_lock);
if (!inode->i_nlink)
- fsnotify_inoderemove(inode);
+ fsnotify_inoderemove(inode, last_dentry);
if (dentry->d_op && dentry->d_op->d_iput)
dentry->d_op->d_iput(dentry, inode);
else
@@ -304,14 +307,17 @@ static void dentry_unlink_inode(struct dentry * dentry)
__releases(dentry->d_inode->i_lock)
{
struct inode *inode = dentry->d_inode;
+ bool last_dentry;
+
__d_clear_type(dentry);
dentry->d_inode = NULL;
hlist_del_init(&dentry->d_alias);
dentry_rcuwalk_barrier(dentry);
+ last_dentry = hlist_empty(&inode->i_dentry);
spin_unlock(&dentry->d_lock);
spin_unlock(&inode->i_lock);
if (!inode->i_nlink)
- fsnotify_inoderemove(inode);
+ fsnotify_inoderemove(inode, last_dentry);
if (dentry->d_op && dentry->d_op->d_iput)
dentry->d_op->d_iput(dentry, inode);
else
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 1c804b0..63dae9d 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -144,10 +144,11 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
/*
* fsnotify_inoderemove - an inode is going away
*/
-static inline void fsnotify_inoderemove(struct inode *inode)
+static inline void fsnotify_inoderemove(struct inode *inode, bool delete)
{
fsnotify(inode, FS_DELETE_SELF, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
- __fsnotify_inode_delete(inode);
+ if (delete)
+ __fsnotify_inode_delete(inode);
}
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment