From: Kazuya Mio Subject: Re: [PATCH] wake up s_wait_unfrozen when ->freeze_fs fails Date: Mon, 12 Dec 2011 09:42:16 +0900 Message-ID: <4EE54DE8.4020802@sx.jp.nec.com> References: <4ED731EB.2040104@sx.jp.nec.com> <20111206152031.GA15613@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from TYO201.gate.nec.co.jp ([202.32.8.193]:40294 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752544Ab1LLAnG (ORCPT ); Sun, 11 Dec 2011 19:43:06 -0500 In-Reply-To: <20111206152031.GA15613@infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 2011/12/07 0:20, Christoph Hellwig wrote: > On Thu, Dec 01, 2011 at 04:51:07PM +0900, Kazuya Mio wrote: >> dd slept infinitely when fsfeeze failed because of EIO. >> To fix this problem, if ->freeze_fs fails, freeze_super() wakes up >> the tasks waiting for the filesystem to become unfrozen. >> >> When s_frozen isn't SB_UNFROZEN in __generic_file_aio_write(), >> the function sleeps until FITHAW ioctl wakes up s_wait_unfrozen. >> >> However, if ->freeze_fs fails, s_frozen is set to SB_UNFROZEN and then >> freeze_super() returns an error number. In this case, FITHAW ioctl returns >> EINVAL because s_frozen is already SB_UNFROZEN. There is no way to wake up >> s_wait_unfrozen, so __generic_file_aio_write() sleeps infinitely. > > Looks good, > > Reviewed-by: Christoph Hellwig > > You don't happen to have testcase (e.g. by using dm-fauly or XFS error > injection) that we could add to xfstests for this? The problem can be reproduced by the following steps: 1. make faulty md device with mdadm # mdadm -B /dev/md1000 -l faulty -n 1 -R 2. mkfs and mount filesystem # mkfs.ext4 /dev/md1000 # mount /dev/md1000 3. run 1000 dd commands in the background to create one 10MB file # for NO in {1..1000} ; do dd if=/dev/zero of=/testfile \ bs=1M count=10 ;done 4. sleep three seconds for the adjustment with the time of fault injection # sleep 3 5. inject the md device with fault in the background # mdadm -G /dev/md1000 -l faulty -p wp1 & 6. freeze filesystem with fsfreeze (and it fails because of EIO) # freeze -f As a result, dd executed in step 3 sleeps forever. Regards, Kazuya Mio