[Top] [All Lists]

Re: [PATCH 2/2] xfs: don't truncate prealloc from frequently accessed in

To: Alex Elder <aelder@xxxxxxx>
Subject: Re: [PATCH 2/2] xfs: don't truncate prealloc from frequently accessed inodes
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 15 Oct 2010 08:28:41 +1100
Cc: xfs@xxxxxxxxxxx
In-reply-to: <1287076970.2362.521.camel@doink>
References: <1286187236-16682-1-git-send-email-david@xxxxxxxxxxxxx> <1286187236-16682-3-git-send-email-david@xxxxxxxxxxxxx> <1287076970.2362.521.camel@doink>
User-agent: Mutt/1.5.20 (2009-06-14)
On Thu, Oct 14, 2010 at 12:22:50PM -0500, Alex Elder wrote:
> On Mon, 2010-10-04 at 21:13 +1100, Dave Chinner wrote:
> > diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
> > index b7bdc43..0c8eeba 100644
> > --- a/fs/xfs/xfs_vnodeops.c
> > +++ b/fs/xfs/xfs_vnodeops.c
> OK, this comment is unrelated to your exact change.  But just above
> the next hunk there's a big nasty condition, which appears to
> be *almost* duplicated in xfs_inactive() (twice!).  It would be
> very nice if, while you're at modifying this nearby code, you
> could encapsulate that condition in a macro that has a meaningful
> name.

I've looked at doing this factoring before, but the conditions are
subtly different and hence cannot be factored into a single macro.
The xfs_inactive case can be cleaned up (i've got old patches around
that do half the job, IIRC), but the tests in the two functions are
not the same.

> > @@ -979,14 +979,27 @@ xfs_release(
> >                      * chance to drop them once the last reference to
> >                      * the inode is dropped, so we'll never leak blocks
> >                      * permanently.
> I'm curious what the effect is if we simply don't do the truncate
> *except* when the inode becomes inactive.  It means we hang onto
> the stuff for a while longer, and maybe it makes things messier
> in the event of a crash.

It doesn't change a thing in the event of a crash - speculative
preallocation is entirely in-memory state.

> Can you tell me why we do the truncate
> here as well as in xfs_inactive() (or what the problem is of
> *not* doing it here)?

the truncation in ->release is not guaranteed to succeed - it uses
trylock semantics to avoid blocking unnecessarily. It can do this
because we know that when xfs_inactive() is called, the truncation
will happen for real.

Dave Chinner

<Prev in Thread] Current Thread [Next in Thread>