* a question for i_inode's i_size in ext2
@ 2008-09-19 7:21 홍신 shin hong
2008-09-19 23:32 ` Theodore Tso
2008-09-20 3:25 ` Jan Kara
0 siblings, 2 replies; 6+ messages in thread
From: 홍신 shin hong @ 2008-09-19 7:21 UTC (permalink / raw)
To: linux-ext4
Dear ext2 maintainers
I have a question of inode's i_size. I found that it is hard to find
any consistent synchronization mechanism that protects inode's i_size
field.
Is there any lock or synchronization mechanism that consistently
protects i_size fields of inode objects to avoid data race?
In inode's definition in /include/linux/fs.h, there is comment that
i_lock protects i_size but it is not clear.
Sincerely
Shin Hong
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: a question for i_inode's i_size in ext2
2008-09-19 7:21 a question for i_inode's i_size in ext2 홍신 shin hong
@ 2008-09-19 23:32 ` Theodore Tso
2008-09-20 3:25 ` Jan Kara
1 sibling, 0 replies; 6+ messages in thread
From: Theodore Tso @ 2008-09-19 23:32 UTC (permalink / raw)
To: 홍신 shin hong; +Cc: linux-ext4
On Fri, Sep 19, 2008 at 04:21:44PM +0900, 홍신 shin hong wrote:
> Dear ext2 maintainers
>
> I have a question of inode's i_size. I found that it is hard to find
> any consistent synchronization mechanism that protects inode's i_size
> field.
> Is there any lock or synchronization mechanism that consistently
> protects i_size fields of inode objects to avoid data race?
> In inode's definition in /include/linux/fs.h, there is comment that
> i_lock protects i_size but it is not clear.
Yes, there is; the i_size (as well as others) are protected via
i_mutex in ext2.
Regards,
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: a question for i_inode's i_size in ext2
2008-09-19 7:21 a question for i_inode's i_size in ext2 홍신 shin hong
2008-09-19 23:32 ` Theodore Tso
@ 2008-09-20 3:25 ` Jan Kara
2008-09-20 6:35 ` Theodore Tso
1 sibling, 1 reply; 6+ messages in thread
From: Jan Kara @ 2008-09-20 3:25 UTC (permalink / raw)
To: 홍신 shin hong; +Cc: linux-ext4
Dear Shin Hong,
> I have a question of inode's i_size. I found that it is hard to find
> any consistent synchronization mechanism that protects inode's i_size
> field.
> Is there any lock or synchronization mechanism that consistently
> protects i_size fields of inode objects to avoid data race?
> In inode's definition in /include/linux/fs.h, there is comment that
> i_lock protects i_size but it is not clear.
As Ted said, i_size changes use i_mutex to guard them (actually,
the comment you are probably refering to speaks about i_mutex - i_lock is
something different). Reading i_size is a different matter - see
i_size_read function. We use seqlock for that - essentially we use an
atomic counter which is incremented on every change of i_size and check
that it's value before we started reading i_size and after we have
finished reading it has not changed. I hope this helps.
Honza
--
Jan Kara <jack@suse.cz>
SuSE CR Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: a question for i_inode's i_size in ext2
2008-09-20 3:25 ` Jan Kara
@ 2008-09-20 6:35 ` Theodore Tso
[not found] ` <2014bcab0809252152i6fef9babx242e821c4f0d5a7b@mail.gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Theodore Tso @ 2008-09-20 6:35 UTC (permalink / raw)
To: Jan Kara; +Cc: 홍신 shin hong, linux-ext4
On Sat, Sep 20, 2008 at 05:25:22AM +0200, Jan Kara wrote:
> Reading i_size is a different matter - see
> i_size_read function. We use seqlock for that - essentially we use an
> atomic counter which is incremented on every change of i_size and check
> that it's value before we started reading i_size and after we have
> finished reading it has not changed. I hope this helps.
Just to clarify for Shin Hong's benefit: this is necessary only on SMP
(or CONFIG_PREEMPT) 32-bit platforms in order to make sure we read a
coherent 64-bit i_size value.
- Ted
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-26 14:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-19 7:21 a question for i_inode's i_size in ext2 홍신 shin hong
2008-09-19 23:32 ` Theodore Tso
2008-09-20 3:25 ` Jan Kara
2008-09-20 6:35 ` Theodore Tso
[not found] ` <2014bcab0809252152i6fef9babx242e821c4f0d5a7b@mail.gmail.com>
2008-09-26 4:53 ` 홍신 shin hong
2008-09-26 14:41 ` Theodore Tso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox