From: Al Viro <viro@zeniv.linux.org.uk>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org
Subject: Re: [PATCH v2 2/4] ovl: stash upper real file in backing_file struct
Date: Mon, 7 Oct 2024 04:03:13 +0100 [thread overview]
Message-ID: <20241007030313.GH4017910@ZenIV> (raw)
In-Reply-To: <20241006210426.GG4017910@ZenIV>
On Sun, Oct 06, 2024 at 10:04:26PM +0100, Al Viro wrote:
> On Sun, Oct 06, 2024 at 10:23:57AM +0200, Amir Goldstein wrote:
> > + /*
> > + * Usually, if we operated on a stashed upperfile once, all following
> > + * operations will operate on the stashed upperfile, but there is one
> > + * exception - ovl_fsync(datasync = false) can populate the stashed
> > + * upperfile to perform fsync on upper metadata inode. In this case,
> > + * following read/write operations will not use the stashed upperfile.
> > + */
> > + if (upperfile && likely(ovl_is_real_file(upperfile, realpath))) {
> > + realfile = upperfile;
> > + goto checkflags;
> > }
> >
> > + /*
> > + * If realfile is lower and has been copied up since we'd opened it,
> > + * open the real upper file and stash it in backing_file_private().
> > + */
> > + if (unlikely(!ovl_is_real_file(realfile, realpath))) {
> > + struct file *old;
> > +
> > + /* Either stashed realfile or upperfile must match realinode */
> > + if (WARN_ON_ONCE(upperfile))
> > + return -EIO;
> > +
> > + upperfile = ovl_open_realfile(file, realpath);
> > + if (IS_ERR(upperfile))
> > + return PTR_ERR(upperfile);
> > +
> > + old = cmpxchg_release(backing_file_private_ptr(realfile), NULL,
> > + upperfile);
> > + if (old) {
> > + fput(upperfile);
> > + upperfile = old;
> > + }
> > +
> > + /* Stashed upperfile that won the race must match realinode */
> > + if (WARN_ON_ONCE(!ovl_is_real_file(upperfile, realpath)))
> > + return -EIO;
> > +
> > + realfile = upperfile;
> > + }
> > +
> > +checkflags:
>
> Hmm... That still feels awkward. Question: can we reach that code with
> * non-NULL upperfile
> * false ovl_is_real_file(upperfile, realpath)
> * true ovl_is_real_file(realfile, realpath)
> Is that really possible?
read() from metacopied file after fsync(), with the data still in lower
layer? Or am I misreading that?
next prev parent reply other threads:[~2024-10-07 3:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-06 8:23 [PATCH v2 0/4] Stash overlay real upper file in backing_file Amir Goldstein
2024-10-06 8:23 ` [PATCH v2 1/4] ovl: do not open non-data lower file for fsync Amir Goldstein
2024-10-06 8:23 ` [PATCH v2 2/4] ovl: stash upper real file in backing_file struct Amir Goldstein
2024-10-06 21:04 ` Al Viro
2024-10-07 3:03 ` Al Viro [this message]
2024-10-07 3:42 ` Al Viro
2024-10-07 6:34 ` Amir Goldstein
2024-10-06 8:23 ` [PATCH v2 3/4] ovl: convert ovl_real_fdget_path() callers to ovl_real_file_path() Amir Goldstein
2024-10-07 3:12 ` Al Viro
2024-10-07 6:36 ` Amir Goldstein
2024-10-06 8:23 ` [PATCH v2 4/4] ovl: convert ovl_real_fdget() callers to ovl_real_file() Amir Goldstein
2024-10-07 9:35 ` [PATCH v2 0/4] Stash overlay real upper file in backing_file Miklos Szeredi
2024-10-07 10:22 ` Amir Goldstein
2024-10-07 10:37 ` Miklos Szeredi
2024-10-07 11:01 ` Amir Goldstein
2024-10-07 11:15 ` Miklos Szeredi
2024-10-07 12:42 ` Amir Goldstein
2024-10-07 14:11 ` Christian Brauner
2024-10-07 14:21 ` 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=20241007030313.GH4017910@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@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).