Re: [RFC][PATCH] f2fs: Avoid print false deadlock messages.
From: Libo Chen
Date: Wed May 15 2013 - 03:22:32 EST
On 2013/5/15 14:58, majianpeng wrote:
> By adding some messages, i found this problem because the gcc
> optimizing. For those codes:
>> > for (i = 0; i < NR_GLOBAL_LOCKS; i++)
>> > mutex_init(&sbi->fs_lock[i]);
> The defination of mutex_init is:
>> > #define mutex_init(mutex)
>> >do {
>> >
>> > static struct lock_class_key __key;
>> >
>> >
>> > __mutex_init((mutex), #mutex, &__key);
>> >
>> >} while (0)
> Because the optimizing of gcc, there are only one __key rather than
> NR_GLOBAL_LOCKS times.
>
> Add there is other problems about lockname.Using 'for()' the lockname is
> the same which is '&sbi->fs_lock[i]'.If it met problem about
> mutex-operation, it can't find which one.
>
> Although my patch can work,i think it's not best.Because if
> NR_GLOBAL_LOCKS changed, we may leak to change this.
>
> BTY, if who know how to avoid optimize, please tell me. Thanks!
>
> Signed-off-by: Jianpeng Ma <majianpeng@xxxxxxxxx>
> ---
> fs/f2fs/super.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 8555f7d..ce08b96 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -520,7 +520,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
> struct buffer_head *raw_super_buf;
> struct inode *root;
> long err = -EINVAL;
> - int i;
>
> /* allocate memory for f2fs-specific super block info */
> sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
> @@ -578,8 +577,16 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
> mutex_init(&sbi->gc_mutex);
> mutex_init(&sbi->writepages);
> mutex_init(&sbi->cp_mutex);
> - for (i = 0; i < NR_GLOBAL_LOCKS; i++)
> - mutex_init(&sbi->fs_lock[i]);
> +
you can try barrier() or mb() to avoid compile optimization.
--
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/