Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1485488

Re: [PATCH 04/12] fsnotify: support overlayfs

From Amir Goldstein <amir73il@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 04/12] fsnotify: support overlayfs
Date 2016-09-17 08:30 +0200
Message-ID <sihip-7p1-1@gated-at.bofh.it> (permalink)
References <si0hz-4BJ-1@gated-at.bofh.it> <si0rg-4Fp-59@gated-at.bofh.it> <si6Gm-rc-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Sep 16, 2016 at 7:38 PM, Jan Kara <jack@suse.cz> wrote:
> On Fri 16-09-16 14:19:23, Miklos Szeredi wrote:
>> From: Aihua Zhang <zhangaihua1@huawei.com>
>>
>> When an event occurs direct it to the overlay inode instead of the real
>> underlying inode.
>>
>> This will work even if the file was first on the lower layer and then
>> copied up, while the watch is there.  This is because the watch is on the
>> overlay inode, which stays the same through the copy-up.
>>
>> For filesystems other than overlayfs this is a no-op, except for the
>> performance impact of an extra pointer dereferece.
>>
>> Verified to work correctly with the inotify/fanotify tests in LTP.
>>
>> Signed-off-by: Aihua Zhang <zhangaihua1@huawei.com>
>> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
>> Cc: Jan Kara <jack@suse.cz>
>> Cc: Eric Paris <eparis@redhat.com>
>> ---
>>  include/linux/fsnotify.h | 14 +++++++++-----
>>  1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
>> index eed9e853a06f..b8bcc058e031 100644
>> --- a/include/linux/fsnotify.h
>> +++ b/include/linux/fsnotify.h
>> @@ -29,7 +29,11 @@ static inline int fsnotify_parent(struct path *path, struct dentry *dentry, __u3
>>  static inline int fsnotify_perm(struct file *file, int mask)
>>  {
>>       struct path *path = &file->f_path;
>> -     struct inode *inode = file_inode(file);
>> +     /*
>> +      * Do not use file_inode() here or anywhere in this file to get the
>> +      * inode.  That would break *notity on overlayfs.
>> +      */
>> +     struct inode *inode = path->dentry->d_inode;
>
> So shouldn't we rather have d_backing_inode(path->dentry) here and
> everywhere else?

d_backing_inode()'s intention is quite the opposite
it's documented as "Get upper or lower inode we should be using"

So there is no helper to return this "unreal" inode.
In fact, it seems that was the intention of d_inode() helper,
but it won't work for overlayfs.

Miklos just submitted a new helper locks_inode() for 4.9, which does
exactly that.
I suppose it's either another similar helper fsnotify_inode() or find
a better and generic
name for this creature.

IMO, the helper file_dentry(), that Miklos introduced in commit d101a1259
should be renamed to file_backing_dentry() and a new helper file_dentry()
should be used here. i.e. inode = d_inode(file_dentry(file));

Also in this case, I think that an explicit name for the helper to get
the "unreal" dentry
would serve better then a generic name, but I can't think of a better name...

Cheers,
Amir.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/12] misc filesystem patches for 4.9 Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:20 +0200
  [PATCH 10/12] posix_acl: don't ignore return value of posix_acl_create_masq() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
    Re: [PATCH 10/12] posix_acl: don't ignore return value of posix_acl_create_masq() Andreas Grünbacher <andreas.gruenbacher@gmail.com> - 2016-09-16 14:50 +0200
  [PATCH 01/12] ima: use file_dentry() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 12/12] vfat: don't use ->d_time Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 05/12] locks: fix file locking on overlayfs Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 08/12] btrfs: use filemap_check_errors() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 11/12] cifs: don't use ->d_time Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 07/12] vfs: do get_write_access() on upper layer of overlayfs Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 02/12] vfs: move permission checking into notify_change() for utimes(NULL) Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 09/12] f2fs: use filemap_check_errors() Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 03/12] vfs: update ovl inode before relatime check Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
  [PATCH 04/12] fsnotify: support overlayfs Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200
    Re: [PATCH 04/12] fsnotify: support overlayfs Jan Kara <jack@suse.cz> - 2016-09-16 21:10 +0200
      Re: [PATCH 04/12] fsnotify: support overlayfs Amir Goldstein <amir73il@gmail.com> - 2016-09-17 08:30 +0200
  [PATCH 06/12] vfs: make argument of d_real_inode() const Miklos Szeredi <mszeredi@redhat.com> - 2016-09-16 14:30 +0200

csiph-web