linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Vivek Goyal <vgoyal@redhat.com>,
	overlayfs <linux-unionfs@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v3 3/4] ovl: create helper ovl_create_temp()
Date: Wed, 16 May 2018 14:15:23 +0300	[thread overview]
Message-ID: <CAOQ4uxgOvzFRb1RYSiCEE2Q4dbCCTaywi8b+kRmJOp7gUeB2-w@mail.gmail.com> (raw)
In-Reply-To: <CAJfpegsP-GrgenqRcc9-YrHHxWrtq1ApswD=FimUid4-8hXhBg@mail.gmail.com>

On Wed, May 16, 2018 at 1:41 PM, Miklos Szeredi <miklos@szeredi.hu> wrote:
> On Tue, May 15, 2018 at 12:26 PM, Amir Goldstein <amir73il@gmail.com> wrote:
>> Al Viro suggested to simplify callers of ovl_create_real() by
>> returning the created dentry (or ERR_PTR) from ovl_create_real().
>> This is a spin off of his suggestion, which is cleaner in my opinion.
>>
>> Also created a wrapper ovl_create_temp_dir() and used it in
>> ovl_create_index() instead of calling ovl_do_mkdir(), so now all callers
>> of ovl_do_mkdir() are routed through ovl_create_real(), which paves the
>> way for Al's fix for non-hashed result from vfs_mkdir().
>>
>> Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
>> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>> ---
>>  fs/overlayfs/copy_up.c   | 27 +++++++--------------------
>>  fs/overlayfs/dir.c       | 47 +++++++++++++++++++++++++++++------------------
>>  fs/overlayfs/overlayfs.h |  9 ++++++++-
>>  3 files changed, 44 insertions(+), 39 deletions(-)
>>
>> diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
>> index 8bede0742619..4ba16cbeaec2 100644
>> --- a/fs/overlayfs/copy_up.c
>> +++ b/fs/overlayfs/copy_up.c
>> @@ -365,14 +365,10 @@ static int ovl_create_index(struct dentry *dentry, struct dentry *origin,
>>         if (err)
>>                 return err;
>>
>> -       temp = ovl_lookup_temp(indexdir);
>> +       temp = ovl_create_temp_dir(indexdir);
>
> #define OVL_DIR_CATTR(m) (&(struct cattr) { .mode = S_IFDIR | (m) })
>         temp = ovl_create_temp(indexdir, OVL_DIR_CATTR(0), NULL);
>

OK.

>>         if (IS_ERR(temp))
>>                 goto temp_err;
>>
>> -       err = ovl_do_mkdir(dir, temp, S_IFDIR, true);
>> -       if (err)
>> -               goto out;
>> -
>>         err = ovl_set_upper_fh(upper, temp);
>>         if (err)
>>                 goto out_cleanup;
>> @@ -501,22 +497,13 @@ static int ovl_get_tmpfile(struct ovl_copy_up_ctx *c, struct dentry **tempp)
>>         if (new_creds)
>>                 old_creds = override_creds(new_creds);
>>
>> -       if (c->tmpfile) {
>> +       if (c->tmpfile)
>>                 temp = ovl_do_tmpfile(c->workdir, c->stat.mode);
>> -               if (IS_ERR(temp))
>> -                       goto temp_err;
>> -       } else {
>> -               temp = ovl_lookup_temp(c->workdir);
>> -               if (IS_ERR(temp))
>> -                       goto temp_err;
>> -
>> -               err = ovl_create_real(d_inode(c->workdir), temp, &cattr,
>> -                                     NULL, true);
>> -               if (err) {
>> -                       dput(temp);
>> -                       goto out;
>> -               }
>> -       }
>> +       else
>> +               temp = ovl_create_temp(c->workdir, &cattr, NULL);
>> +       if (IS_ERR(temp))
>> +               goto temp_err;
>> +
>>         err = 0;
>>         *tempp = temp;
>>  out:
>> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
>> index 25b339278684..45f5f9232e71 100644
>> --- a/fs/overlayfs/dir.c
>> +++ b/fs/overlayfs/dir.c
>> @@ -160,6 +160,26 @@ int ovl_create_real(struct inode *dir, struct dentry *newdentry,
>>         return err;
>>  }
>>
>> +struct dentry *ovl_create_temp(struct dentry *workdir, struct cattr *attr,
>> +                              struct dentry *hardlink)
>
> Talking of cleanups, can we put hardlink into cattr as well?  (separate patch)
>

OK. If you don't mind, I'll use this opportunity to also namespace
it to ovl_cattr.

>> +{
>> +       struct inode *wdir = workdir->d_inode;
>> +       struct dentry *temp;
>> +       int err;
>> +
>> +       temp = ovl_lookup_temp(workdir);
>> +       if (IS_ERR(temp))
>> +               return temp;
>
> What's wrong with viro's version of  dentry in ovl_create_real()?
> Turns this whole function into:
>
>         return ovl_create_real(d_inode(workdir),
> ovl_lookup_temp(workdir), attr, hardlink, true);

Nothing. A matter of taste. If you like Al's version better,
I'll add it back in the next patch.

>
>> +
>> +       err = ovl_create_real(wdir, temp, attr, hardlink, true);
>> +       if (err) {
>> +               dput(temp);
>> +               return ERR_PTR(err);
>> +       }
>> +
>> +       return temp;
>> +}
>> +
>>  static int ovl_set_opaque_xerr(struct dentry *dentry, struct dentry *upper,
>>                                int xerr)
>>  {
>> @@ -292,15 +312,11 @@ static struct dentry *ovl_clear_empty(struct dentry *dentry,
>>         if (upper->d_parent->d_inode != udir)
>>                 goto out_unlock;
>>
>> -       opaquedir = ovl_lookup_temp(workdir);
>> +       opaquedir = ovl_create_temp_dir(workdir);
>
> Where has the mode gone?

OOPS. I'll get it back.

Thanks,
Amir.

  reply	other threads:[~2018-05-16 11:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 10:26 [PATCH v3 0/4] Overlayfs mkdir related fixes Amir Goldstein
2018-05-15 10:26 ` [PATCH v3 1/4] ovl: use insert_inode_locked4() to hash a newly created inode Amir Goldstein
2018-05-15 13:23   ` Vivek Goyal
2018-05-15 13:37     ` Amir Goldstein
2018-05-16  8:34       ` Miklos Szeredi
2018-05-16  9:51         ` Amir Goldstein
2018-05-16 10:14           ` Miklos Szeredi
2018-05-16 11:03             ` Amir Goldstein
2018-05-17  6:03       ` Amir Goldstein
2018-05-17  8:10         ` Miklos Szeredi
2018-05-17  8:45           ` Amir Goldstein
2018-05-17  8:53           ` Miklos Szeredi
2018-05-17  8:58             ` Amir Goldstein
2018-05-17  9:07               ` Miklos Szeredi
2018-05-17 16:14                 ` Amir Goldstein
2018-05-15 10:26 ` [PATCH v3 2/4] ovl: relax WARN_ON() real inode attributes mismatch Amir Goldstein
2018-05-15 12:48   ` Vivek Goyal
2018-05-15 12:55     ` Amir Goldstein
2018-05-16 10:29   ` Miklos Szeredi
2018-05-16 11:06     ` Amir Goldstein
2018-05-16 11:18       ` Miklos Szeredi
2018-05-16 13:46         ` Amir Goldstein
2018-05-15 10:26 ` [PATCH v3 3/4] ovl: create helper ovl_create_temp() Amir Goldstein
2018-05-16 10:41   ` Miklos Szeredi
2018-05-16 11:15     ` Amir Goldstein [this message]
2018-05-16 11:37       ` Miklos Szeredi
2018-05-15 10:26 ` [PATCH v3 4/4] ovl: make ovl_create_real() cope with vfs_mkdir() safely Amir Goldstein

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=CAOQ4uxgOvzFRb1RYSiCEE2Q4dbCCTaywi8b+kRmJOp7gUeB2-w@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=vgoyal@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).