All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ovl: support ltp/testcase/bin/inotify04 on overlayfs
@ 2016-07-21 10:19 ` zhangaihua1
  0 siblings, 0 replies; 3+ messages in thread
From: zhangaihua1 @ 2016-07-21 10:19 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel, linux-unionfs; +Cc: Aihua Zhang

From: Aihua Zhang <zhangaihua1@huawei.com>

after patch:
[root@localhost bin]# ./inotify04
inotify04    1  TPASS  :  got event: wd=1 mask=400 cookie=0 len=0 name=""
inotify04    2  TPASS  :  got event: wd=1 mask=8000 cookie=0 len=0 name=""
inotify04    3  TPASS  :  got event: wd=2 mask=4 cookie=0 len=0 name=""
inotify04    4  TPASS  :  got event: wd=2 mask=400 cookie=0 len=0 name=""
inotify04    5  TPASS  :  got event: wd=2 mask=8000 cookie=0 len=0 name=""

Signed-off-by: Aihua Zhang <zhangaihua1@huawei.com>
---
 fs/dcache.c          |    8 ++++++--
 fs/overlayfs/inode.c |    2 +-
 include/linux/fs.h   |    1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 7654509..0db095d 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -313,7 +313,9 @@ static void dentry_iput(struct dentry * dentry)
 		hlist_del_init(&dentry->d_u.d_alias);
 		spin_unlock(&dentry->d_lock);
 		spin_unlock(&inode->i_lock);
-		if (!inode->i_nlink)
+		if ((!inode->i_nlink) ||
+			((inode->i_flags & S_SPECIAL_OVL) &&
+			(1 == inode->i_nlink)))
 			fsnotify_inoderemove(inode);
 		if (dentry->d_op && dentry->d_op->d_iput)
 			dentry->d_op->d_iput(dentry, inode);
@@ -339,7 +341,9 @@ static void dentry_unlink_inode(struct dentry * dentry)
 	dentry_rcuwalk_barrier(dentry);
 	spin_unlock(&dentry->d_lock);
 	spin_unlock(&inode->i_lock);
-	if (!inode->i_nlink)
+	if ((!inode->i_nlink) ||
+		((inode->i_flags & S_SPECIAL_OVL) &&
+		(1 == inode->i_nlink)))
 		fsnotify_inoderemove(inode);
 	if (dentry->d_op && dentry->d_op->d_iput)
 		dentry->d_op->d_iput(dentry, inode);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index e696ba3..eb57b96 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -399,7 +399,7 @@ struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
 
 	inode->i_ino = get_next_ino();
 	inode->i_mode = mode;
-	inode->i_flags |= S_NOATIME | S_NOCMTIME;
+	inode->i_flags |= S_NOATIME | S_NOCMTIME | S_SPECIAL_OVL;
 
 	switch (mode) {
 	case S_IFDIR:
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2a41353..6e763d7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1610,6 +1610,7 @@ struct super_operations {
 #define S_IMA		1024	/* Inode has an associated IMA struct */
 #define S_AUTOMOUNT	2048	/* Automount/referral quasi-directory */
 #define S_NOSEC		4096	/* no suid or xattr security attributes */
+#define S_SPECIAL_OVL   8192    /* special inode means ovlerlayfs */
 
 /*
  * Note that nosuid etc flags are inode-specific: setting some file-system
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] ovl: support ltp/testcase/bin/inotify04 on overlayfs
@ 2016-07-21 10:19 ` zhangaihua1
  0 siblings, 0 replies; 3+ messages in thread
From: zhangaihua1 @ 2016-07-21 10:19 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel, linux-unionfs; +Cc: Aihua Zhang

From: Aihua Zhang <zhangaihua1@huawei.com>

after patch:
[root@localhost bin]# ./inotify04
inotify04    1  TPASS  :  got event: wd=1 mask=400 cookie=0 len=0 name=""
inotify04    2  TPASS  :  got event: wd=1 mask=8000 cookie=0 len=0 name=""
inotify04    3  TPASS  :  got event: wd=2 mask=4 cookie=0 len=0 name=""
inotify04    4  TPASS  :  got event: wd=2 mask=400 cookie=0 len=0 name=""
inotify04    5  TPASS  :  got event: wd=2 mask=8000 cookie=0 len=0 name=""

Signed-off-by: Aihua Zhang <zhangaihua1@huawei.com>
---
 fs/dcache.c          |    8 ++++++--
 fs/overlayfs/inode.c |    2 +-
 include/linux/fs.h   |    1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 7654509..0db095d 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -313,7 +313,9 @@ static void dentry_iput(struct dentry * dentry)
 		hlist_del_init(&dentry->d_u.d_alias);
 		spin_unlock(&dentry->d_lock);
 		spin_unlock(&inode->i_lock);
-		if (!inode->i_nlink)
+		if ((!inode->i_nlink) ||
+			((inode->i_flags & S_SPECIAL_OVL) &&
+			(1 == inode->i_nlink)))
 			fsnotify_inoderemove(inode);
 		if (dentry->d_op && dentry->d_op->d_iput)
 			dentry->d_op->d_iput(dentry, inode);
@@ -339,7 +341,9 @@ static void dentry_unlink_inode(struct dentry * dentry)
 	dentry_rcuwalk_barrier(dentry);
 	spin_unlock(&dentry->d_lock);
 	spin_unlock(&inode->i_lock);
-	if (!inode->i_nlink)
+	if ((!inode->i_nlink) ||
+		((inode->i_flags & S_SPECIAL_OVL) &&
+		(1 == inode->i_nlink)))
 		fsnotify_inoderemove(inode);
 	if (dentry->d_op && dentry->d_op->d_iput)
 		dentry->d_op->d_iput(dentry, inode);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index e696ba3..eb57b96 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -399,7 +399,7 @@ struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
 
 	inode->i_ino = get_next_ino();
 	inode->i_mode = mode;
-	inode->i_flags |= S_NOATIME | S_NOCMTIME;
+	inode->i_flags |= S_NOATIME | S_NOCMTIME | S_SPECIAL_OVL;
 
 	switch (mode) {
 	case S_IFDIR:
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2a41353..6e763d7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1610,6 +1610,7 @@ struct super_operations {
 #define S_IMA		1024	/* Inode has an associated IMA struct */
 #define S_AUTOMOUNT	2048	/* Automount/referral quasi-directory */
 #define S_NOSEC		4096	/* no suid or xattr security attributes */
+#define S_SPECIAL_OVL   8192    /* special inode means ovlerlayfs */
 
 /*
  * Note that nosuid etc flags are inode-specific: setting some file-system
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ovl: support ltp/testcase/bin/inotify04 on overlayfs
  2016-07-21 10:19 ` zhangaihua1
  (?)
@ 2016-07-21 10:34 ` Miklos Szeredi
  -1 siblings, 0 replies; 3+ messages in thread
From: Miklos Szeredi @ 2016-07-21 10:34 UTC (permalink / raw)
  To: Zhang AiHua; +Cc: linux-fsdevel, linux-kernel, linux-unionfs

On Thu, Jul 21, 2016 at 12:19 PM,  <zhangaihua1@huawei.com> wrote:
> From: Aihua Zhang <zhangaihua1@huawei.com>
>
> after patch:
> [root@localhost bin]# ./inotify04
> inotify04    1  TPASS  :  got event: wd=1 mask=400 cookie=0 len=0 name=""
> inotify04    2  TPASS  :  got event: wd=1 mask=8000 cookie=0 len=0 name=""
> inotify04    3  TPASS  :  got event: wd=2 mask=4 cookie=0 len=0 name=""
> inotify04    4  TPASS  :  got event: wd=2 mask=400 cookie=0 len=0 name=""
> inotify04    5  TPASS  :  got event: wd=2 mask=8000 cookie=0 len=0 name=""
>
> Signed-off-by: Aihua Zhang <zhangaihua1@huawei.com>
> ---
>  fs/dcache.c          |    8 ++++++--
>  fs/overlayfs/inode.c |    2 +-
>  include/linux/fs.h   |    1 +
>  3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 7654509..0db095d 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -313,7 +313,9 @@ static void dentry_iput(struct dentry * dentry)
>                 hlist_del_init(&dentry->d_u.d_alias);
>                 spin_unlock(&dentry->d_lock);
>                 spin_unlock(&inode->i_lock);
> -               if (!inode->i_nlink)
> +               if ((!inode->i_nlink) ||
> +                       ((inode->i_flags & S_SPECIAL_OVL) &&
> +                       (1 == inode->i_nlink)))


No such horrible hackery is needed if overlay code would correctly
reset i_nlink on rmdir.

See a50128d4524a ("ovl: clear nlink on rmdir") in the overlayfs-next branch of

  git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-21 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-21 10:19 [PATCH] ovl: support ltp/testcase/bin/inotify04 on overlayfs zhangaihua1
2016-07-21 10:19 ` zhangaihua1
2016-07-21 10:34 ` Miklos Szeredi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.