public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: "홍신 shin hong" <hongshin@gmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: a question for i_inode's i_size in ext2
Date: Sat, 20 Sep 2008 05:25:22 +0200	[thread overview]
Message-ID: <20080920032522.GB9633@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <2014bcab0809190021qbca7bect601c891c2db197cf@mail.gmail.com>

  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

  parent reply	other threads:[~2008-09-20  3:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20080920032522.GB9633@atrey.karlin.mff.cuni.cz \
    --to=jack@suse.cz \
    --cc=hongshin@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    /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