From: Christoph Hellwig <hch@infradead.org>
To: Lachlan McIlroy <lachlan@sgi.com>
Cc: Christoph Hellwig <hch@infradead.org>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [Fwd: [PATCH] Fix race in xfs_write() between direct and buffered I/O with DMAPI]
Date: Tue, 9 Dec 2008 04:22:40 -0500 [thread overview]
Message-ID: <20081209092240.GA23915@infradead.org> (raw)
In-Reply-To: <493DFDBD.7060909@sgi.com>
On Tue, Dec 09, 2008 at 04:10:21PM +1100, Lachlan McIlroy wrote:
> Thanks for looking at this Christoph.
>
> I'm not sure what you mean by duplicating the checks. I assume you
> mean this check:
>
> if (!need_i_mutex && (mapping->nrpages || pos > xip->i_size)) {
> xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
> iolock = XFS_IOLOCK_EXCL;
> need_i_mutex = 1;
> mutex_lock(&inode->i_mutex);
> xfs_ilock(xip, XFS_ILOCK_EXCL|iolock);
> goto start;
> }
Yes.
> This check is there because the default case for direct I/O is to
> acquire the iolock in shared mode. If we have work to do which
> requires the iolock to be held exclusive then drop the lock and get
> it again. Since we dropped the lock then restart.
>
> In the dmapi post-write event it doesn't matter if we have the
> iolock shared or exclusive - it will be dropped regardless so I
> don't see how checking the state of the iolock will allow us to
> avoid a restart.
All very true, but it doesn't matter :) When you do the goto start
after the dmapi post event you will run through the above check anyway,
and take the lock exclusive even if you don't need it. By doing
the check right after the dmapi even you only run through the sequence
of checks leading to the above one guaranteed once, instead of
potentially twice (in addition to the initial once or twice before the
dmapi event). Alternatively you could also have a flag that sais don't
bother with taking the lock exclusive that gets set after the dmapi
nospace even code.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2008-12-09 9:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-04 6:33 [Fwd: [PATCH] Fix race in xfs_write() between direct and buffered I/O with DMAPI] Lachlan McIlroy
2008-12-08 22:51 ` Christoph Hellwig
2008-12-09 5:10 ` Lachlan McIlroy
2008-12-09 9:22 ` Christoph Hellwig [this message]
2008-12-22 8:53 ` Christoph Hellwig
2008-12-23 0:40 ` Lachlan McIlroy
2008-12-23 8:40 ` Christoph Hellwig
2008-12-24 1:10 ` Lachlan McIlroy
2008-12-24 2:10 ` Niv Sardi
2008-12-24 2:23 ` Lachlan McIlroy
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=20081209092240.GA23915@infradead.org \
--to=hch@infradead.org \
--cc=lachlan@sgi.com \
--cc=xfs@oss.sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox