From: Al Viro <viro@ZenIV.linux.org.uk>
To: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Cc: Vitaly Chernooky <vitalii.chernookyi@globallogic.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
David Vrabel <david.vrabel@citrix.com>,
Iurii Konovalenko <iurii.konovalenko@globallogic.com>,
Ian Campbell <ian.campbell@citrix.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Andrii Anisov <andrii.anisov@globallogic.com>,
Artem Mygaiev <artem.mygaiev@globallogic.com>
Subject: Re: [PATCH] [RFC] Fix deadlock on regular nonseekable files
Date: Fri, 20 Mar 2015 19:35:06 +0000 [thread overview]
Message-ID: <20150320193504.GD29656@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20150320190052.GF2321@mail-itl>
On Fri, Mar 20, 2015 at 08:00:52PM +0100, Marek Marczykowski-Górecki wrote:
> > What the devil does that have to do with seeks, anyway? Exact
> > same problem will happen for blocking read() vs. another read() attempts
> > on the same descriptor. With perfectly accepted lseek() (which will also
> > have to block, as per 2.9.7).
>
> Yes, the problem here is because this particular file (/proc/xen/xenbus)
> blocks the read() operation waiting for new events. Because of said
> commit, now it also blocks write() operation used to send some request
> (which would result in some response, so unblocking read() call). It
> shouldn't be a normal file in the first place...
Aha. OK, so you have something that looks a whole lot like a FIFO in
that respect, and this semantics simply isn't compatible with read()
being atomic wrt write().
So just have that flag explicitly knocked out in your ->open(), preferably
with a comment explaining why is that done. Having lseek() is a red herring
in that respect - the same problem would exist if that file *did* have
something done on lseek().
That's actually what I'm objecting against - "uses nonseekable_open()" is
used a weird proxy for "can't have read(), write(), etc. atomic wrt each
other". It's not true in either direction - there's a lot of e.g. procfs
files that are just fine with current exclusion and there can very well
be files _not_ using nonseekable_open() that would break the same way
and for the same reasons as /proc/xen/xenbus does.
It's trivial to fix - either by explicit filp->f_mode &= ~FMODE_ATOMIC_POS;
in xenbus_file_open(), or by adding
static inline void no_atomic_pos(struct file *f)
{
f->f_mode &= ~FMODE_ATOMIC_POS;
}
somewhere in include/linux/fs.h and having it called in the same
xenbus_file_open(). Either way, it ought to come with something
along the lines of
/*
* we can't live with read() vs. write() atomicity, since we use
* write() as source of events returned by read() and write()
* called after another thread has blocked in read() waiting for
* events cannot be required to wait for that read() to finish.
*/
next to this removal of FMODE_ATOMIC_POS, whichever way we express it...
Objections?
prev parent reply other threads:[~2015-03-20 19:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-20 13:17 Vitaly Chernooky
2015-03-20 13:42 ` Al Viro
2015-03-20 14:22 ` Vitaly Chernooky
2015-03-20 14:46 ` Al Viro
2015-03-20 17:37 ` Vitaly Chernooky
2015-03-20 17:55 ` Al Viro
2015-03-20 19:00 ` Marek Marczykowski-Górecki
2015-03-20 19:35 ` Al Viro [this message]
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=20150320193504.GD29656@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=andrii.anisov@globallogic.com \
--cc=artem.mygaiev@globallogic.com \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=iurii.konovalenko@globallogic.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marmarek@invisiblethingslab.com \
--cc=torvalds@linux-foundation.org \
--cc=vitalii.chernookyi@globallogic.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
Powered by JetHome