All of lore.kernel.org
 help / color / mirror / Atom feed
From: "zhangyi (F)" <yi.zhang@huawei.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: overlayfs <linux-unionfs@vger.kernel.org>,
	Miklos Szeredi <miklos@szeredi.hu>, Miao Xie <miaoxie@huawei.com>,
	yangerkun <yangerkun@huawei.com>
Subject: Re: [RFC PATCH v2 5/9] ovl: add redirect dir feature when set redirect xattr to dir
Date: Fri, 3 Aug 2018 19:52:46 +0800	[thread overview]
Message-ID: <3d2b993b-6046-784a-765a-c5fd65adcc10@huawei.com> (raw)
In-Reply-To: <CAOQ4uxgwUnna5zs1n2S9UkHKv4wH1n0QA-96kSsTJ+iDiah8gQ@mail.gmail.com>

On 2018/8/1 19:03, Amir Goldstein Wrote:
> On Tue, Jul 31, 2018 at 12:37 PM, zhangyi (F) <yi.zhang@huawei.com> wrote:
>> Redirect dir feature is backward incompatible because old kernel (which
>> not support this feature) may corrupt the merge relationship between
>> directories when change the directory which have redirect xattr.
>>
>> This patch check and set the upper layer's redirect dir feature when
>> kernel set redirect xattr to directory in the upper layer.
>>
>> Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
>> ---
>>  fs/overlayfs/dir.c       | 11 +++++++++++
>>  fs/overlayfs/overlayfs.h |  5 ++++-
>>  2 files changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
>> index f480b1a2cd2e..238999e5f47b 100644
>> --- a/fs/overlayfs/dir.c
>> +++ b/fs/overlayfs/dir.c
>> @@ -969,6 +969,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
>>         bool is_dir = d_is_dir(old);
>>         bool new_is_dir = d_is_dir(new);
>>         bool samedir = olddir == newdir;
>> +       struct ovl_fs* ofs = old->d_sb->s_fs_info;
>>         struct dentry *opaquedir = NULL;
>>         const struct cred *old_cred = NULL;
>>         LIST_HEAD(list);
>> @@ -1061,6 +1062,16 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
>>                 }
>>         }
>>
>> +       if ((is_dir && ovl_type_merge_or_lower(old)) ||
>> +           (!overwrite && new_is_dir && ovl_type_merge_or_lower(new))) {
>> +               /*
>> +                * Set redirect dir feature to the upper root dir if this
>> +                * feature doesn't exist.
>> +                */
>> +               if (!ovl_has_feature_redirect_dir(ofs->upper_layer))
>> +                       err = ovl_set_feature_redirect_dir(ofs);
>> +       }
>> +
> 
> Please just place a call to  ovl_set_feature_redirect_dir(ofs)
> inside ovl_set_redirect(). There is no need to check all those
> conditions.
> Also, there is no need to check ovl_has_feature_redirect_dir()
> as ovl_set_feature() already checks for existing bit.
>

I understand check those condition is not perfect, but place it
to ovl_set_redirect() will lead to inode AA dead lock if the
parent dir of the renamed dir is the upper root dir, because
lock_rename() and vfs_setxattr() will get the same inode lock.

ovl_rename()
  ->lock_rename(upperdir)   //get the upper root inode lock
  ->ovl_set_redirect()
    ->ovl_set_feature_redirect_dir()
      ->vfs_setxattr(upperdir)  //dead lock in inode_lock()

Thanks,
Yi.


  reply	other threads:[~2018-08-03 13:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31  9:37 [RFC PATCH v2 0/9] ovl: add feature set support zhangyi (F)
2018-07-31  9:37 ` [RFC PATCH v2 1/9] ovl: store ovl upper root path in ovl_fs zhangyi (F)
2018-08-01  6:48   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 2/9] ovl: read feature set from each layer's root dir zhangyi (F)
2018-08-01  7:44   ` Amir Goldstein
2018-08-03 12:11     ` zhangyi (F)
2018-07-31  9:37 ` [RFC PATCH v2 3/9] ovl: check file system features can be mounted properly zhangyi (F)
2018-08-01  8:06   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 4/9] ovl: add helper funcs to set upper layer feature set zhangyi (F)
2018-08-01  8:51   ` Amir Goldstein
2018-08-01 11:04     ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 5/9] ovl: add redirect dir feature when set redirect xattr to dir zhangyi (F)
2018-08-01 11:03   ` Amir Goldstein
2018-08-03 11:52     ` zhangyi (F) [this message]
2018-08-03 20:38       ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 6/9] ovl: add index feature if index dir exists zhangyi (F)
2018-08-01 11:15   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 7/9] ovl: add nfs_export feature when nfs_export is enabled zhangyi (F)
2018-08-01 11:20   ` Amir Goldstein
2018-07-31  9:37 ` [RFC PATCH v2 8/9] ovl: force mount underlying layers which have feature sets zhangyi (F)
     [not found]   ` <CAOQ4uxgZcwxENyf5STfNgL6juLoHvOBnWkORpifp0pv04oi8Ww@mail.gmail.com>
2018-08-03 11:25     ` zhangyi (F)
     [not found]       ` <CAOQ4uxjxY1Urjy2fUEkV24ZfxbDjAu1vkJcERNc_7uZVmJ+2YA@mail.gmail.com>
2018-08-06  1:15         ` zhangyi (F)
2018-07-31  9:37 ` [RFC PATCH v2 9/9] ovl: check redirect_dir feature when detect redirect xattr on dir zhangyi (F)
2018-08-01 11:30   ` Amir Goldstein
2018-08-01 11:35     ` Amir Goldstein
2018-08-02 12:30       ` Vivek Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d2b993b-6046-784a-765a-c5fd65adcc10@huawei.com \
    --to=yi.zhang@huawei.com \
    --cc=amir73il@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=miklos@szeredi.hu \
    --cc=yangerkun@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.