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:42:02 +0100 [thread overview]
Message-ID: <20241007034202.GJ4017910@ZenIV> (raw)
In-Reply-To: <20241007030313.GH4017910@ZenIV>
On Mon, Oct 07, 2024 at 04:03:13AM +0100, Al Viro wrote:
> > 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?
Unless I'm misreading that thing, the logics would be
If what we are asked for is where the data used to be at open time
just use what we'd opened back then and be done with that.
Either we'd been copied up since open, or it's a metadata fsync of
a metacopied file; it doesn't matter which, since the upper layer
file will be the same either way.
If it hadn't been opened and stashed into the backing_file, do so.
If we end up using the reference stashed by somebody else (either
by finding it there in the first place, or by having cmpxchg tell
us we'd lost the race), verify that it _is_ in the right place;
it really should be, short of an equivalent of fs corruption
(== somebody fucking around with the upper layer under us).
Is that what's going on there? If so, I think your current version is
correct, but I'd probably put it in a different way:
if (!ovl_is_real_file(realfile, realpath) {
/*
* the place we want is not where the data used to be at
* open time; either we'd been copied up, or it's an fsync
* of metacopied file. Should be the same location either
* way...
*/
struct file *upperfile = backing_file_private(realfile);
struct file *old;
if (!upperfile) { /* nobody opened it yet */
upperfile = ovl_open_realfile(file, realpath);
if (IS_ERR(upperfile))
return upperfile;
old = cmpxchg_release(backing_file_private_ptr(realfile),
NULL, upperfile);
if (old) { /* but they did while we were opening it */
fput(upperfile);
upperfile = old;
}
}
/*
* stashed file must have been from the right place, unless
* someone's been corrupting the upper layer.
*/
if (WARN_ON_ONCE(!ovl_is_real_file(upperfile, realpath)))
return ERR_PTR(-EIO);
realfile = upperfile;
}
next prev parent reply other threads:[~2024-10-07 3:42 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
2024-10-07 3:42 ` Al Viro [this message]
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=20241007034202.GJ4017910@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).