From: Christian Schoenebeck via Qemu-devel <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org
Cc: "Christian Schoenebeck" <qemu_oss@crudebyte.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Greg Kurz" <groug@kaod.org>,
"Antonios Motakis" <antonios.motakis@huawei.com>
Subject: Re: [Qemu-devel] [PATCH v4 3/5] 9p: Added virtfs option "remap_inodes"
Date: Fri, 28 Jun 2019 15:47:52 +0200 [thread overview]
Message-ID: <4068711.1y5nem0Q7a@silver> (raw)
In-Reply-To: <20190628120931.2d31f741@bahia.lan>
On Freitag, 28. Juni 2019 12:09:31 CEST Greg Kurz wrote:
> On Wed, 26 Jun 2019 20:42:13 +0200
>
> Christian Schoenebeck via Qemu-devel <qemu-devel@nongnu.org> wrote:
> > To support multiple devices on the 9p share, and avoid
> > qid path collisions we take the device id as input
> > to generate a unique QID path. The lowest 48 bits of
> > the path will be set equal to the file inode, and the
> > top bits will be uniquely assigned based on the top
> > 16 bits of the inode and the device id.
> >
> > Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
>
> Same remark about changes to the original patch.
ack_once(); :)
> BTW, I had a concern with the way v9fs_do_readdir() open-codes QID
> generation without calling stat_to_qid().
>
> See discussion here:
>
> https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02724.html
>
> I guess you should ensure in a preliminary patch that QIDs only
> come out of stat_to_qid().
Mja, actually I first omitted your suggestion consciously, because I first
thought it was an overkill pure visibility issue lmited to the default case
remap_inodes==false, but now that I look at it again, it is actually an issue
even when remap_inodes==true since dirent would expose wrong inode numbers on
guest as well.
I will see what to do about it. However about your other concern here, quote:
"Also, if we hit a collision while reading the directory, I'm
afraid the remaining entries won't be read at all. I'm not
sure this is really what we want."
That's however still a concern here that I would consider overkill to address.
I mean if a user gets into that situation then because of a configuration error
that must be corrected by user; the point of this patch set is to prevent
undefined behaviour and to make the user aware about the root cause of the
overall issue; the purpose is not to address all possible issues while there
is still a configuration error.
> > +static int qid_path_prefixmap(V9fsPDU *pdu, const struct stat *stbuf,
> > + uint64_t *path)
> > +{
> > + QppEntry lookup = {
> > + .dev = stbuf->st_dev,
> > + .ino_prefix = (uint16_t) (stbuf->st_ino >> 48)
> > + }, *val;
> > + uint32_t hash = qpp_hash(lookup);
> > +
> > + val = qht_lookup(&pdu->s->qpp_table, &lookup, hash);
> > +
> > + if (!val) {
> > + if (pdu->s->qp_prefix_next == 0) {
> > + /* we ran out of prefixes */
>
> And we won't ever be able to allocate a new one. Maybe worth
> adding an error_report_once() to inform the user ?
Yeah, I thought about that as well. Will do.
> > static int stat_to_qid(V9fsPDU *pdu, const struct stat *stbuf, V9fsQID
> > *qidp) {
> >
> > - size_t size;
> > + int err;
> >
> > - if (pdu->s->dev_id == 0) {
> > - pdu->s->dev_id = stbuf->st_dev;
> > - } else if (pdu->s->dev_id != stbuf->st_dev) {
> > - error_report_once(
> > - "9p: Multiple devices detected in same VirtFS export. "
> > - "You must use a separate export for each device."
> > - );
> > - return -ENOSYS;
> > + if (pdu->s->ctx.export_flags & V9FS_REMAP_INODES) {
> > + /* map inode+device to qid path (fast path) */
> > + err = qid_path_prefixmap(pdu, stbuf, &qidp->path);
> > + if (err) {
> > + return err;
> > + }
> > + } else {
> > + if (pdu->s->dev_id == 0) {
> > + pdu->s->dev_id = stbuf->st_dev;
> > + } else if (pdu->s->dev_id != stbuf->st_dev) {
> > + error_report_once(
> > + "9p: Multiple devices detected in same VirtFS export. "
> > + "You must either use a separate export for each device "
> > + "shared from host or enable virtfs option
> > 'remap_inodes'."
> > + );
> > + return -ENOSYS;
> > + }
> > + size_t size;
>
> From CODING_STYLE:
>
> 5. Declarations
>
> Mixed declarations (interleaving statements and declarations within
> blocks) are generally not allowed; declarations should be at the beginning
> of blocks.
>
> Please do so for "size" and add an extra blank line.
Ok.
> > +#define QPATH_INO_MASK (((unsigned long)1 << 48) - 1)
>
> This won't give the expected result on a 32-bit host. Since this
> is a mask for 64-bit entities, it should rather be:
>
> #define QPATH_INO_MASK ((1ULL << 48) - 1)
Correct, will fix it.
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index 0d8beb4afd..e7ea136da1 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -1334,7 +1334,7 @@ ETEXI
> >
> > DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
> >
> > "-virtfs
> > local,path=path,mount_tag=tag,security_model=mapped-xattr|mapped-fil
> > e|passthrough|none\n">
> > - "
> > [,id=id][,writeout=immediate][,readonly][,fmode=fmode][,dmode=dmode]\n" +
> > "
> > [,id=id][,writeout=immediate][,readonly][,fmode=fmode][,dmode=dmode][,rem
> > ap_inodes]\n"
> This feature applies to all backends IIUC. We don't really care for the
> synth backend since it generates non-colliding inode numbers by design,
> but the proxy backend has the same issue as local. So...
Yeah, I was not sure about these, because I did not even know what these two
were for exactly. :) [ lazyness disclaimer end]
Will do for the other manual locations you mentioned as well.
Best regards,
Christian Schoenebeck
next prev parent reply other threads:[~2019-06-28 15:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 18:57 [Qemu-devel] [PATCH v4 0/5] 9p: Fix file ID collisions Christian Schoenebeck via Qemu-devel
2019-06-26 18:25 ` [Qemu-devel] [PATCH v4 1/5] 9p: unsigned type for type, version, path Christian Schoenebeck via Qemu-devel
2019-06-27 16:12 ` Greg Kurz
2019-06-28 11:42 ` Christian Schoenebeck via Qemu-devel
2019-06-28 12:06 ` Greg Kurz
2019-06-26 18:30 ` [Qemu-devel] [PATCH v4 2/5] 9p: Treat multiple devices on one export as an error Christian Schoenebeck via Qemu-devel
2019-06-27 17:26 ` Greg Kurz
2019-06-28 12:36 ` Christian Schoenebeck via Qemu-devel
2019-06-28 12:47 ` Greg Kurz
2019-06-26 18:42 ` [Qemu-devel] [PATCH v4 3/5] 9p: Added virtfs option "remap_inodes" Christian Schoenebeck via Qemu-devel
2019-06-28 10:09 ` Greg Kurz
2019-06-28 13:47 ` Christian Schoenebeck via Qemu-devel [this message]
2019-06-28 14:23 ` Greg Kurz
2019-06-29 10:20 ` Christian Schoenebeck via Qemu-devel
2019-07-02 8:01 ` Greg Kurz
2019-06-26 18:46 ` [Qemu-devel] [PATCH v4 4/5] 9p: stat_to_qid: implement slow path Christian Schoenebeck via Qemu-devel
2019-06-28 10:21 ` Greg Kurz
2019-06-28 14:03 ` Christian Schoenebeck via Qemu-devel
2019-06-26 18:52 ` [Qemu-devel] [PATCH v4 5/5] 9p: Use variable length suffixes for inode remapping Christian Schoenebeck via Qemu-devel
2019-06-28 11:50 ` Greg Kurz
2019-06-28 14:56 ` Christian Schoenebeck via Qemu-devel
2019-06-29 11:01 ` Christian Schoenebeck via Qemu-devel
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=4068711.1y5nem0Q7a@silver \
--to=qemu-devel@nongnu.org \
--cc=antonios.motakis@huawei.com \
--cc=berrange@redhat.com \
--cc=groug@kaod.org \
--cc=qemu_oss@crudebyte.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 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).