From: Al Viro <viro@ZenIV.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Trond Myklebust <trond.myklebust@primarydata.com>,
Christoph Hellwig <hch@infradead.org>,
Dave Chinner <david@fromorbit.com>, Theodore Ts'o <tytso@mit.edu>,
Miklos Szeredi <miklos@szeredi.hu>,
Oleg Drokin <oleg.drokin@intel.com>,
Joseph Qi <joseph.qi@huawei.com>,
Joel Becker <jlbec@evilplan.org>, Mark Fasheh <mfasheh@suse.com>
Subject: Re: [RFC] write(2) semantics wrt return values and current position
Date: Wed, 8 Apr 2015 20:24:50 +0100 [thread overview]
Message-ID: <20150408192450.GQ889@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20150406153641.GL889@ZenIV.linux.org.uk>
On Mon, Apr 06, 2015 at 05:02:31PM +0100, Al Viro wrote:
7) commit 3a83b342c87e6d21290de8dc76ec20a67821261d
Author: Joseph Qi <joseph.qi@huawei.com>
Date: Mon Feb 16 16:00:09 2015 -0800
ocfs2: complete the rest request through buffer io
appears to be very odd. Look:
written = generic_file_direct_write(iocb, from, *ppos);
- if (written < 0) {
+ if (written < 0 || written == count) {
ret = written;
goto out_dio;
}
+
+ /*
+ * for completing the rest of the request.
+ */
+ *ppos += written;
ppos here is &iocb->ki_pos. Now, take a look at the end of
generic_file_direct_write():
if (written > 0) {
pos += written;
iov_iter_advance(from, written);
if (pos > i_size_read(inode) && !S_ISBLK(inode->i_mode)) {
i_size_write(inode, pos);
mark_inode_dirty(inode);
}
iocb->ki_pos = pos;
}
out:
return written;
In other words, after short write done by ->direct_IO(), we end up incrementing
position by *twice* the amount written by it. And if it's short, but not
empty, we appear to be buggered...
Unless I hear "Al, you idiot, it's doing the right thing, here's what you've
missed: ...", I'm going to take that increment in ocfs2_file_write_iter()
out, and send it to Linus for 4.0 - it's post-3.19 regression.
next prev parent reply other threads:[~2015-04-08 19:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-06 16:02 [RFC] write(2) semantics wrt return values and current position Al Viro
2015-04-06 18:13 ` Linus Torvalds
2015-04-06 19:29 ` Al Viro
2015-04-06 19:50 ` Al Viro
2015-04-06 20:04 ` Drokin, Oleg
2015-04-06 20:09 ` Al Viro
2015-04-06 20:39 ` Drokin, Oleg
2015-04-07 15:25 ` Christoph Hellwig
2015-04-08 19:24 ` Al Viro [this message]
2015-04-08 20:57 ` Al Viro
2015-04-08 21:20 ` Al Viro
2015-04-09 4:48 ` Junxiao Bi
2015-04-09 11:23 ` Al Viro
2015-04-09 11:42 ` Al Viro
2015-04-10 14:31 ` Junxiao Bi
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=20150408192450.GQ889@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mfasheh@suse.com \
--cc=miklos@szeredi.hu \
--cc=oleg.drokin@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=trond.myklebust@primarydata.com \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.