[Ocfs2-devel] [PATCH 6/7] vfs: Set special lockdep map for dirs only if not set by fs

Peter Zijlstra peterz at infradead.org
Thu Feb 26 12:27:22 PST 2009


On Thu, 2009-02-26 at 21:15 +0100, Jan Kara wrote:
> Some filesystems need to set lockdep map for i_mutex differently for
> different directories. For a filesystem it is naturaly done when the
> inode is read but we have to modify unlock_new_inode() not to overwrite
> the lockdep map filesystem has set.

This sounds very dubious.. are you really saying there are distinctly
different locking rules for different directories within a single
filesystem?

That's insane..

As to the patch, I'd rather you introduce a helper,
lockdep_match_class() or somesuch, if you can convince VFS folks that
what you're wanting to do is sane.

> CC: peterz at infradead.org
> CC: mingo at redhat.com
> Signed-off-by: Jan Kara <jack at suse.cz>
> ---
>  fs/inode.c |   16 ++++++++++------
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index 913ab2d..c8c36cf 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -640,12 +640,16 @@ void unlock_new_inode(struct inode *inode)
>  	if (inode->i_mode & S_IFDIR) {
>  		struct file_system_type *type = inode->i_sb->s_type;
>  
> -		/*
> -		 * ensure nobody is actually holding i_mutex
> -		 */
> -		mutex_destroy(&inode->i_mutex);
> -		mutex_init(&inode->i_mutex);
> -		lockdep_set_class(&inode->i_mutex, &type->i_mutex_dir_key);
> +		/* Set new key only if filesystem haven't already changed it */
> +		if (inode->i_mutex.dep_map.key != &type->i_mutex_key) {
> +			/*
> +			 * ensure nobody is actually holding i_mutex
> +			 */
> +			mutex_destroy(&inode->i_mutex);
> +			mutex_init(&inode->i_mutex);
> +			lockdep_set_class(&inode->i_mutex,
> +					  &type->i_mutex_dir_key);
> +		}
>  	}
>  #endif
>  	/*




More information about the Ocfs2-devel mailing list