All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] Question about commit cf1b5ea1c5cd
@ 2015-04-14  3:06 Joseph Qi
  2015-04-14  3:40 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Qi @ 2015-04-14  3:06 UTC (permalink / raw)
  To: ocfs2-devel

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. Then after buffer write, I
only get written_buffered increased into ->ki_pos, so ->ki_pos is *not*
increased twice.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Ocfs2-devel] Question about commit cf1b5ea1c5cd
  2015-04-14  3:06 [Ocfs2-devel] Question about commit cf1b5ea1c5cd Joseph Qi
@ 2015-04-14  3:40 ` Al Viro
  2015-04-14  3:52   ` Joseph Qi
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2015-04-14  3:40 UTC (permalink / raw)
  To: ocfs2-devel

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...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Ocfs2-devel] Question about commit cf1b5ea1c5cd
  2015-04-14  3:40 ` Al Viro
@ 2015-04-14  3:52   ` Joseph Qi
  0 siblings, 0 replies; 3+ messages in thread
From: Joseph Qi @ 2015-04-14  3:52 UTC (permalink / raw)
  To: ocfs2-devel

On 2015/4/14 11:40, Al Viro wrote:
> 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...
> 
> 
I see. My mistake of ignoring this.
Thanks very much for spotting it out.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-14  3:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14  3:06 [Ocfs2-devel] Question about commit cf1b5ea1c5cd Joseph Qi
2015-04-14  3:40 ` Al Viro
2015-04-14  3:52   ` Joseph Qi

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.