Re: [PATCH][RFC] %pd - for printing dentry name

From: Al Viro
Date: Mon Feb 01 2010 - 17:34:16 EST


On Mon, Feb 01, 2010 at 10:25:11PM +0000, Al Viro wrote:
> There's a lot of places doing printks with ->d_name of various
> dentries. Unfortunately, as often as not they are b0rken due to races
> with rename().
>
> I propose to add a new format - %pd. It would print dentry name.
> However, unlike everything else in vsnprintf, it would NOT be locking-agnostic.
> It would grab and release dentry->d_lock. And yes, I hate that as much as
> anyone. I don't see any sane alternative.
>
> Patch below implements it and fixes some obvious races in ocfs2
> and ubifs by switch to that sucker. There are many more places of
> that kind and a _lot_ of those are racy. Adding ->d_lock in every caller
> is not a good solution, IMO...
>
> Rules are:
> * don't use %pd under dentry->d_lock, use dentry->d_name.name instead; in
> that case it *is* safe. Incidentally, ->d_lock isn't held a lot.
> * if we don't hold dentry->d_lock, feel free to use %pd....,dentry
>
> Comments?

PS: if it ends up going in, the usual S-o-b applies
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/