[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFyb7TPkOXmOiNQojnW-Fb-uunbqdMgiF13hE-o1t5rmcQ@mail.gmail.com>
Date: Wed, 30 Apr 2014 17:18:23 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Miklos Szeredi <miklos@...redi.hu>,
Dave Chinner <david@...morbit.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: dcache shrink list corruption?
On Wed, Apr 30, 2014 at 4:43 PM, Al Viro <viro@...iv.linux.org.uk> wrote:
>
> OK, done and force-pushed. Should propagate in a few...
That made it more obvious how the DCACHE_MAY_FREE case ends up
working. And in particular, mind rewriting this:
if (dentry->d_flags & DCACHE_MAY_FREE) {
spin_unlock(&dentry->d_lock);
dentry_free(dentry);
} else {
spin_unlock(&dentry->d_lock);
}
return parent;
as just
bool free = dentry->d_flags & DCACHE_MAY_FREE;
spin_unlock(&dentry->d_lock);
if (free)
dentry_free(dentry);
return parent;
instead? In fact, I get the feeling that the other case later on
really fits the same model:
spin_lock(&dentry->d_lock);
if (dentry->d_flags & DCACHE_SHRINK_LIST) {
dentry->d_flags |= DCACHE_MAY_FREE;
spin_unlock(&dentry->d_lock);
} else {
spin_unlock(&dentry->d_lock);
dentry_free(dentry);
}
ends up really being better as
spin_lock(&dentry->d_lock);
free = 1;
if (dentry->d_flags & DCACHE_SHRINK_LIST) {
dentry->d_flags |= DCACHE_MAY_FREE;
free = 0;
}
spin_unlock(&dentry->d_lock);
if (free)
dentry_free(dentry);
return parent;
and then suddenly it looks like we have a common exit sequence from
that dentry_kill() function, no?
(The earlier "unlock_on_failure" exit case is altogether a different case).
I dunno. Maybe not a big deal, but one reason I prefer doing that
"free" flag is because I really tend to prefer the simple case of
lock-unlock pairing cleanly at the same level. NOT the pattern where
you have one lock at one indentation level, paired with multiple
unlocks for all the different cases.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists