Linux ocfs2 filesystem development
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] Question about commit cf1b5ea1c5cd
Date: Tue, 14 Apr 2015 04:40:10 +0100	[thread overview]
Message-ID: <20150414034009.GV889@ZenIV.linux.org.uk> (raw)
In-Reply-To: <552C8440.2000106@huawei.com>

On Tue, Apr 14, 2015 at 11:06:40AM +0800, Joseph Qi wrote:
> Hi Viro,
> I have questions about your commit cf1b5ea1c5cd
> ("[regression] ocfs2: do *not* increment ->ki_pos twice").
> Yes, ->ki_pos is increased in generic_file_direct_write(). But
> *ppos doesn't. So I increase it here for further use in
> generic_perform_write.
> After this, ->ki_pos and *ppos are equal.

They are equal all along, for a very simple reason: ppos *points* *to*
iocb->ki_pos.  So yes, you do increase it twice, once via one alias,
once via another.

Check and you'll see - ppos is initialized with &iocb->ki_pos and never
reassigned.  What happens is an equivalent of

int x = 0;
int *p = &x;

x += 10;
*p += 10;

which obviously ends with x increased by 20, not by 10...

  reply	other threads:[~2015-04-14  3:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14  3:06 [Ocfs2-devel] Question about commit cf1b5ea1c5cd Joseph Qi
2015-04-14  3:40 ` Al Viro [this message]
2015-04-14  3:52   ` Joseph Qi

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=20150414034009.GV889@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=ocfs2-devel@oss.oracle.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