All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <mason@suse.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, akpm@osdl.org
Subject: Re: [PATCH RFC] O_DIRECT reads and writes without i_sem
Date: Mon, 01 Nov 2004 11:56:49 -0500	[thread overview]
Message-ID: <1099328209.23475.98.camel@watt.suse.com> (raw)
In-Reply-To: <20041101160844.GA29251@infradead.org>

On Mon, 2004-11-01 at 16:08 +0000, Christoph Hellwig wrote:
> On Mon, Nov 01, 2004 at 10:32:07AM -0500, Chris Mason wrote:

> > Right now, O_DIRECT reads and writes on regular files have to take i_sem
> > while reading file metadata in order to make sure we don't race with
> > hole filling.
[ ... ]
> This gets too complicated for it's own sake.  What about going down the
> XFS route and making i_sem a r/w semaphore that's taken only shared
> during read and write I/O, but exclusive while setting up write I/O
> outside of i_size?  Alternatively just move the I/O locking into the
> filesytem.
> 

Nod, it is too complex, this is why I posted early ;)  The only place in
the FS specific code for the locking I added to fs/direct-io.c would be
in each filesystem get_blocks call.  I went for direct-io.c because
that's where all the other locking already was.  shrug.

If we do down_read(i_rw_sem) for all cases except growing the file, then
we still have no locking for O_DIRECT while we are filling holes in the
file.  The filesystem write function could do this:

	down_read(i_rw_sem)
	read fs metadata
	if (filling hole) {
		up_read(i_rw_sem)
		down_write(i_rw_sem)
		goto retry
	}

But it also gets nasty in a hurry.  The second alternative is just to
make O_DIRECT lock pages (or stub pages if they aren't in cache) in the
filesystem address space, but this might add significant overhead in
radix tree operations during O_DIRECT.

-chris



  reply	other threads:[~2004-11-01 16:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-01 15:32 [PATCH RFC] O_DIRECT reads and writes without i_sem Chris Mason
2004-11-01 16:08 ` Christoph Hellwig
2004-11-01 16:56   ` Chris Mason [this message]
2004-11-05 18:06   ` Chris Mason

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=1099328209.23475.98.camel@watt.suse.com \
    --to=mason@suse.com \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@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 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.