From: Vivek Goyal <vgoyal@redhat.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Bernd Schubert <bschubert@ddn.com>,
Dharmendra Hans <dharamhans87@gmail.com>,
linux-fsdevel@vger.kernel.org,
fuse-devel <fuse-devel@lists.sourceforge.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/3] FUSE: Implement atomic lookup + open/create
Date: Wed, 11 May 2022 15:30:09 -0400 [thread overview]
Message-ID: <YnwOwS/bmUkbazeL@redhat.com> (raw)
In-Reply-To: <YnvwiZ+s+y3VDUMW@redhat.com>
On Wed, May 11, 2022 at 01:21:13PM -0400, Vivek Goyal wrote:
> On Wed, May 11, 2022 at 11:40:59AM +0200, Miklos Szeredi wrote:
> > On Thu, 5 May 2022 at 21:59, Vivek Goyal <vgoyal@redhat.com> wrote:
> >
> > > Oh, I have no issues with the intent. I will like to see cut in network
> > > traffic too (if we can do this without introducing problems). My primary
> > > interest is that this kind of change should benefit virtiofs as well.
> >
> > One issue with that appears to be checking permissions. AFAIU this
> > patchset only enables the optimization if default_permissions is
> > turned off (i.e. all permission checking is done by the server). But
> > virtiofs uses the default_permissions model.
>
> IIUC, only 3rd patch mentions that default_permission should be turned
> off. IOW, first patch where lookup + create + open is a single operation
> and second patch which does "lookup + open" in a single operation does
> not seem to require that default_permissions are not in effect.
>
> So if first two patches work fine, I think virtiofs should benefit too.
> (IMHO, 3rd patch is too hacky anyway)
>
> W.r.t permission checks, looks like may_open() will finally be called
> after ->atomic_open(). So even if we open the file, we should still be
> able to check whether we have permissions to open the file or not
> after the fact.
>
> fs/namei.c
>
> path_openat()
> {
> open_last_lookups() <--- This calls ->atomic_open()
> do_open() <--- This calls may_open()
> }
Actually I am not sure about it. I was playing with
open(foo.txt, O_CREAT | O_RDWR, O_IRUSR)
This succeeds if file is newly created but if file already existed, this
fails with -EACCESS
So man 2 open says following. Thanks to Andy Price for pointing me to it.
Note that mode applies only to future accesses of the newly cre‐
ated file; the open() call that creates a read-only file may
well return a read/write file descriptor.
Now I am wondering how will it look like with first patch. Assume file
already exists on the server (But there is no negative dentry present)
and I do following. And assume file only has read permission for user
and I am trying to open it read-write.
open(foo.txt, O_CREAT | O_RDWR, O_IRUSR)
In normal circumstances, user will expect -EACCESS as file is read-only
and user is trying to open it read-write.
I am wondering how will it look like with this first patch.
Current fuse ->atomic_open() looks up the dentry and does not open
the file if dentry is positive.
New implementation will skip lookup and open the file anyway and
set file->f_mode |= FMODE_CREATED; (First patch in series)
So first of all this seems wrong. I thought FMODE_CREATED should be
set only if file was newly created. Is that a correct understanding.
And I am looking at do_open() code. It does bunch of things based
on FMODE_CREATED flag. One of the things it does is reset acc_mode =0
if (file->f_mode & FMODE_CREATED) {
/* Don't check for write permission, don't truncate */
open_flag &= ~O_TRUNC;
acc_mode = 0;
}
error = may_open(mnt_userns, &nd->path, acc_mode, open_flag);
I suspect this is the code which allows opening a newly created read-only
file as O_RDWR. (Though I am not 100% sure).
I suspect with first patch this will be broken. We will set FMODE_CREATED
even if file already existed and VFS will assume a new file has been
created and do bunch of things which is wrong.
So looks like fuse ->atomic_open() should set FMODE_CREATED only if
it really created the file.
Thanks
Vivek
next prev parent reply other threads:[~2022-05-11 19:31 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 10:25 [PATCH v4 0/3] FUSE: Implement atomic lookup + open/create Dharmendra Singh
2022-05-02 10:25 ` [PATCH v4 1/3] FUSE: Implement atomic lookup + create Dharmendra Singh
2022-05-03 12:43 ` Vivek Goyal
2022-05-03 14:13 ` Vivek Goyal
2022-05-03 19:53 ` Vivek Goyal
2022-05-03 20:48 ` Bernd Schubert
2022-05-04 4:26 ` Dharmendra Hans
2022-05-04 14:47 ` Vivek Goyal
2022-05-04 15:46 ` Bernd Schubert
2022-05-04 17:31 ` Vivek Goyal
2022-05-05 4:51 ` Dharmendra Hans
2022-05-05 14:26 ` Vivek Goyal
2022-05-06 5:34 ` Dharmendra Hans
2022-05-06 14:12 ` Vivek Goyal
2022-05-06 16:41 ` Bernd Schubert
2022-05-06 17:07 ` Vivek Goyal
2022-05-06 18:45 ` Bernd Schubert
2022-05-07 10:42 ` Jean-Pierre André
2022-05-11 10:08 ` Bernd Schubert
2022-05-02 10:25 ` [PATCH v4 2/3] FUSE: Implement atomic lookup + open Dharmendra Singh
2022-05-04 18:20 ` Vivek Goyal
2022-05-05 6:39 ` Dharmendra Hans
2022-05-02 10:25 ` [PATCH v4 3/3] FUSE: Avoid lookup in d_revalidate() Dharmendra Singh
2022-05-04 20:39 ` Vivek Goyal
2022-05-04 21:05 ` Bernd Schubert
2022-05-05 5:49 ` Dharmendra Hans
2022-05-04 19:18 ` [PATCH v4 0/3] FUSE: Implement atomic lookup + open/create Vivek Goyal
2022-05-05 6:12 ` Dharmendra Hans
2022-05-05 12:54 ` Vivek Goyal
2022-05-05 15:13 ` Bernd Schubert
2022-05-05 19:59 ` Vivek Goyal
2022-05-11 9:40 ` Miklos Szeredi
2022-05-11 9:59 ` Bernd Schubert
2022-05-11 17:21 ` Vivek Goyal
2022-05-11 19:30 ` Vivek Goyal [this message]
2022-05-12 8:16 ` Dharmendra Hans
2022-05-12 15:24 ` 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=YnwOwS/bmUkbazeL@redhat.com \
--to=vgoyal@redhat.com \
--cc=bschubert@ddn.com \
--cc=dharamhans87@gmail.com \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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).