All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junxiao Bi <junxiao.bi@oracle.com>
To: Al Viro <viro@ZenIV.linux.org.uk>, 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: Thu, 09 Apr 2015 12:48:44 +0800	[thread overview]
Message-ID: <552604AC.8030704@oracle.com> (raw)
In-Reply-To: <20150408212026.GS889@ZenIV.linux.org.uk>

On 04/09/2015 05:20 AM, Al Viro wrote:
> On Wed, Apr 08, 2015 at 09:57:37PM +0100, Al Viro wrote:
>> ... and having looked through old mail, there's _another_ breakage that
>> might have inspired that one; this one is mine - "ocfs2 syncs the wrong range".
>> It was syncing the wrong range with O_APPEND, all right, but after that
>> patch it was syncing the wrong range in _all_ cases.  What it should've
>> been doing instead is
>>                 ret = filemap_fdatawrite_range(file->f_mapping,
>> 					       iocb->ki_pos - written,
>>                                                iocb->ki_pos - 1);
>> ...
>>                         ret = filemap_fdatawait_range(file->f_mapping,
>> 						      iocb->ki_pos - written,
>>                                                       iocb->ki_pos - 1);

Looks like if generic_file_direct_write() return -EIOCBQUEUED and
IS_SYNC(inode) is true, the sync range is also wrong.


2385         if (direct_io) {
2386                 loff_t endbyte;
2387                 ssize_t written_buffered;
2388                 written = generic_file_direct_write(iocb, from, *ppos);
2389                 if (written < 0 || written == count) {
2390                         ret = written;
2391                         goto out_dio;
2392                 }

2443         if (((file->f_flags & O_DSYNC) && !direct_io) ||
IS_SYNC(inode) ||
2444             ((file->f_flags & O_DIRECT) && !direct_io)) {

The other two patches looks good.


Thanks,
Junxiao.
>>
>> Joseph, my apologies for missing your mail back in January - you are absolutely
>> correct, *ppos (aka iocb->ki_pos) _is_ changed.  Unlike pos, it can be used
>> to get the right range reliably (as above; pos, back when it existed,
>> hadn't been affected by generic_write_checks() call in what used to be
>> ocfs2_file_aio_write()), but the actual calculation had been completely
>> wrong.
>>
>> If that had contributed to confusion, my deep apologies...
> 
> Folks, could you please take a look through vfs.git#for-linus (the last
> three commits in there) and see if you are OK with those?
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  reply	other threads:[~2015-04-09  4:52 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
2015-04-08 20:57   ` Al Viro
2015-04-08 21:20     ` Al Viro
2015-04-09  4:48       ` Junxiao Bi [this message]
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=552604AC.8030704@oracle.com \
    --to=junxiao.bi@oracle.com \
    --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 \
    --cc=viro@ZenIV.linux.org.uk \
    /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.