From: Dave Chinner <david@fromorbit.com>
To: Daniel Walker <dwalker@mvista.com>
Cc: xfs@oss.sgi.com, linux-kernel@vger.kernel.org, matthew@wil.cx
Subject: Re: [PATCH 4/6] Replace inode flush semaphore with a completion
Date: Thu, 14 Aug 2008 10:19:38 +1000 [thread overview]
Message-ID: <20080814001938.GC6119@disturbed> (raw)
In-Reply-To: <1218641641.6166.32.camel@dhcp32.mvista.com>
On Wed, Aug 13, 2008 at 08:34:01AM -0700, Daniel Walker wrote:
> On Wed, 2008-08-13 at 17:50 +1000, Dave Chinner wrote:
>
> > Right now we have the case where no matter what type of flush
> > is done, the caller does not have to worry about unlocking
> > the flush lock - it will be done as part of the flush. You're
> > suggestion makes that conditional based on whether we did a
> > sync flush or not.
> >
> > So, what happenѕ when you call:
> >
> > xfs_iflush(ip, XFS_IFLUSH_DELWRI_ELSE_SYNC);
> >
> > i.e. xfs_iflush() may do an delayed flush or a sync flush depending
> > on the current state of the inode. The caller has no idea what type
> > of flush was done, so will have no idea whether to unlock or not.
>
> You wouldn't base the unlock on what iflush does, you would
> unconditionally unlock.
It's not really a flush lock at that point - it's a state lock.
We've already got one of those, and a set of state flags that it
protects.
Basically you're suggesting that we keep external state to the
completion that tracks whether a completion is in progress
or not. You can't use a mutex like you suggested to protect
state because you can't hold it while doing a wait_for_completion()
and then use it to clear the state flag before calling complete().
We can use the internal inode state flags and lock to keep
track of this. i.e:
xfs_iflock(
xfs_inode_t *ip)
{
xfs_iflags_set(ip, XFS_IFLUSH_INPROGRESS);
wait_for_completion(ip->i_flush_wq);
}
xfs_iflock_nowait(
xfs_inode_t *ip)
{
if (xfs_iflags_test(ip, XFS_IFLUSH_INPROGRESS))
return 1;
xfs_iflags_set(ip, XFS_IFLUSH_INPROGRESS);
wait_for_completion(ip->i_flush_wq);
return 0;
}
xfs_ifunlock(
xfs_inode_t *ip)
{
xfs_iflags_clear(ip, XFS_IFLUSH_INPROGRESS);
complete(ip->i_flush_wq);
}
*However*, given that we already have this exact state in the
completion itself, I see little reason for adding the additional
locking overhead and the complexity of race conditions of keeping
this state coherent with the completion. Modifying the completion
API slightly to export this state is the simplest, easiest solution
to the problem....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2008-08-14 0:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-27 8:44 [PATCH 0/6] Remove most users of semaphores from XFS V2 Dave Chinner
2008-06-27 8:44 ` [PATCH 1/6] Clean up stale references to semaphores Dave Chinner
2008-06-27 8:44 ` [PATCH 2/6] Replace the XFS buf iodone semaphore with a completion Dave Chinner
2008-06-27 8:44 ` [PATCH 3/6] Extend completions to provide XFS object flush requirements Dave Chinner
2008-06-27 8:44 ` [PATCH 4/6] Replace inode flush semaphore with a completion Dave Chinner
2008-08-13 3:11 ` Daniel Walker
2008-08-13 7:50 ` Dave Chinner
2008-08-13 15:34 ` Daniel Walker
2008-08-14 0:19 ` Dave Chinner [this message]
2008-08-14 1:34 ` Daniel Walker
2008-08-14 2:30 ` Dave Chinner
2008-06-27 8:44 ` [PATCH 5/6] Replace dquot " Dave Chinner
2008-06-27 8:44 ` [PATCH 6/6] Remove the sema_t from XFS Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
2008-07-11 1:13 [RESEND, PATCH 0/6] Remove most users of semaphores " Dave Chinner
2008-07-11 1:13 ` [PATCH 4/6] Replace inode flush semaphore with a completion Dave Chinner
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=20080814001938.GC6119@disturbed \
--to=david@fromorbit.com \
--cc=dwalker@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--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