All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fernando Luis Vazquez Cao <fernando_b1@lab.ntt.co.jp>
To: Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Dave Chinner <dchinner@redhat.com>,
	Christoph Hellwig <hch@infradead.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/8] fsfreeze: emergency thaw will deadlock on s_umount
Date: Thu, 13 Sep 2012 15:23:27 +0900	[thread overview]
Message-ID: <50517BDF.1090409@lab.ntt.co.jp> (raw)
In-Reply-To: <20120713131755.GE20361@quack.suse.cz>

On 2012/07/13 22:17, Jan Kara wrote:
> On Thu 12-07-12 18:04:09, Fernando Luis Vázquez Cao wrote:
>> diff -urNp vfs-orig/fs/super.c vfs/fs/super.c
>> --- vfs-orig/fs/super.c	2012-07-04 18:57:54.000000000 +0900
>> +++ vfs/fs/super.c	2012-07-12 14:21:09.736566768 +0900
>> @@ -1221,23 +1221,25 @@ int freeze_super(struct super_block *sb)
>>   EXPORT_SYMBOL(freeze_super);
>>   
>>   /**
>> - * thaw_super -- unlock filesystem
>> + * __thaw_super -- unlock filesystem
>>    * @sb: the super to thaw
>> + * @emergency:	emergency thaw
>>    *
>>    * Unlocks the filesystem and marks it writeable again after freeze_super().
>> + * This is the unlocked version of thaw_super and has to be called with the
>> + * sb->s_umount lock held in the non-emergency thaw case.
>>    */
>> -int thaw_super(struct super_block *sb)
>> +static int __thaw_super(struct super_block *sb, int emergency)
>>   {
>> -	int error;
>> +	int error = 0;
>>   
>> -	down_write(&sb->s_umount);
>>   	if (sb->s_frozen == SB_UNFROZEN) {
>> -		up_write(&sb->s_umount);
>> -		return -EINVAL;
>> +		error = -EINVAL;
>> +		goto out;
>>   	}
>>   
>>   	if (sb->s_flags & MS_RDONLY)
>> -		goto out;
>> +		goto out_thaw;
>>   
>>   	if (sb->s_op->unfreeze_fs) {
>>   		error = sb->s_op->unfreeze_fs(sb);
>> @@ -1245,17 +1247,52 @@ int thaw_super(struct super_block *sb)
>>   			printk(KERN_ERR
>>   				"VFS:Filesystem thaw failed\n");
>>   			sb->s_frozen = SB_FREEZE_TRANS;
>> -			up_write(&sb->s_umount);
>> -			return error;
>> +			goto out;
>>   		}
>>   	}
>>   
>> -out:
>> +out_thaw:
>>   	sb->s_frozen = SB_UNFROZEN;
>>   	smp_wmb();
>>   	wake_up(&sb->s_wait_unfrozen);
>> -	deactivate_locked_super(sb);
>>   
>> -	return 0;
>> +	/*
>> +	 * When called from emergency scope, we cannot grab the s_umount lock
>> +	 * so we cannot deactivate the superblock. This may leave unbalanced
>> +	 * superblock references which could prevent unmount, but given this is
>> +	 * an emergency operation....
>> +	 */
>> +	if (!emergency)
>> +		deactivate_locked_super(sb);
>> +out:
>> +	return error;
>> +}
>    This is just wrong. deactivate_locked_super() will unlock the superblock
> for you (and may even free it). So just do this in thaw_super() instead of
> up_write(&sb->s_umount) which is bogus there. That will also allow you to
> get rid of that ugly 'emergency' argument...

I just wanted to let you know that I rewrote this patch from scratch
taking a different approach which allows me to get locking right
in the emergency thaw case too. I will be sending the updated
patch set later today.

Thanks,
Fernando
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-09-13  6:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-12  8:57 [PATCH 0/8 v2] fsfreeze: miscellaneous fixes and cleanups Fernando Luis Vázquez Cao
2012-07-12  9:02 ` [PATCH 1/8] fsfreeze: Prevent emergency thaw from looping infinitely Fernando Luis Vázquez Cao
2012-07-13 12:59   ` Jan Kara
2012-07-17  5:13     ` Fernando Luis Vazquez Cao
2012-07-12  9:04 ` [PATCH 2/8] fsfreeze: emergency thaw will deadlock on s_umount Fernando Luis Vázquez Cao
2012-07-13 13:17   ` Jan Kara
2012-08-09  6:00     ` Fernando Luis Vazquez Cao
2012-09-13  6:23     ` Fernando Luis Vazquez Cao [this message]
2012-07-12  9:05 ` [PATCH 3/8] fsfreeze: freeze_super and thaw_bdev don't play well together Fernando Luis Vázquez Cao
2012-07-13 13:45   ` Jan Kara
2012-08-09  9:00     ` Fernando Luis Vazquez Cao
2012-07-12  9:07 ` [PATCH 4/8] fsfreeze: switch to using super methods where possible Fernando Luis Vázquez Cao
2012-07-13 13:50   ` Jan Kara
2012-07-12  9:09 ` [PATCH 5/8] fsfreeze: move emergency thaw code to fs/super.c Fernando Luis Vázquez Cao
2012-07-13 13:53   ` Jan Kara
2012-07-12  9:10 ` [PATCH 6/8] fsfreeze: add vfs ioctl to check freeze state Fernando Luis Vázquez Cao
2012-07-13 13:54   ` Jan Kara
2012-07-15 22:45     ` Dave Chinner
2012-09-13  6:19       ` Fernando Luis Vazquez Cao
2012-09-13  7:18         ` Dave Chinner
2012-09-13  8:19           ` Fernando Luis Vazquez Cao
2012-09-14  0:15             ` Dave Chinner
2012-09-14  1:46               ` Fernando Luis Vazquez Cao
2012-09-14  6:28                 ` Dave Chinner
2012-09-14  8:18                   ` Fernando Luis Vazquez Cao
2012-09-13  6:11     ` Fernando Luis Vazquez Cao
2012-07-12  9:11 ` [PATCH 7/8] fsfreeze: add block device " Fernando Luis Vázquez Cao
2012-07-12  9:12 ` [PATCH 8/8] fsfreeze: update Documentation/filesystems/Locking Fernando Luis Vázquez Cao
2012-07-13 14:11   ` Jan Kara
2012-07-17  1:42     ` Fernando Luis Vazquez Cao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50517BDF.1090409@lab.ntt.co.jp \
    --to=fernando_b1@lab.ntt.co.jp \
    --cc=dchinner@redhat.com \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.