From: Theodore Tso <tytso@mit.edu>
To: Jamie Lokier <jamie@shareable.org>
Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>,
Hisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>,
akpm@linux-foundation.org, linux-ext4@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] ext2/3/4: change i_mutex usage on lseek
Date: Thu, 15 Jan 2009 08:35:30 -0500 [thread overview]
Message-ID: <20090115133530.GA30522@mit.edu> (raw)
In-Reply-To: <20090115130154.GA32368@shareable.org>
On Thu, Jan 15, 2009 at 01:01:54PM +0000, Jamie Lokier wrote:
> Dave Kleikamp wrote:
> > Is there any reason you couldn't have just changed generic_file_llseek()
> > to do this rather than making identical changes to the individual file
> > systems. I would think this optimization would be safe for any file
> > system.
>
> Is it safe on 32-bit systems where 64-bit updates are not atomic?
Protection of 64-bit updates of i_size where 32-bit systems do not
have atomic 64-bit updates is done via i_size_seqcount, which is done
automatically as long as the code in question uses i_size_write(), an
inline function defined in include/linux/fs.h.
> You may say that doing multiple parallel lseek() calls is undefined
> behaviour, so it's ok to end up with file position that none of the
> individual lseek() calls asked for.
>
> But if it's undefined behaviour, no programs should be doing parallel
> lseek() calls on the same open file, so why optimise it at all?
i_mutex gets used for a lot more than protecting i_size updates for
lseek(), so removing the need for i_mutex could very well be helpful
for non-micro-benchmark tests. As Hirashi-san mentioned in his patch,
this could avoid contention between lseek() and write() (possibly via
a different file descriptor, so it wouldn't be an undefined race
condition) and fsync().
I do agree this is an optimization that should be done in
generic_file_llseek(), though.
Regards,
- Ted
prev parent reply other threads:[~2009-01-15 13:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-15 0:32 [PATCH] ext2/3/4: change i_mutex usage on lseek Hisashi Hifumi
2009-01-15 4:32 ` Dave Kleikamp
2009-01-15 4:40 ` Hisashi Hifumi
2009-01-15 13:01 ` Jamie Lokier
2009-01-15 13:35 ` Theodore Tso [this message]
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=20090115133530.GA30522@mit.edu \
--to=tytso@mit.edu \
--cc=akpm@linux-foundation.org \
--cc=hifumi.hisashi@oss.ntt.co.jp \
--cc=jamie@shareable.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=shaggy@linux.vnet.ibm.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 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.