From: Valerie Aurora Subject: [RFC PATCH 0/3] VFS: Fix s_umount thaw/write deadlock Date: Mon, 12 Sep 2011 19:53:03 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=0016364d27f10b5eb904acc9be53 To: linux-fsdevel@vger.kernel.org, Jan Kara , Dave Chinner , Masayoshi MIZUMA , Greg Freemyer , linux Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:43304 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753070Ab1IMCxF (ORCPT ); Mon, 12 Sep 2011 22:53:05 -0400 Sender: linux-ext4-owner@vger.kernel.org List-ID: --0016364d27f10b5eb904acc9be53 Content-Type: text/plain; charset=ISO-8859-1 I've been working on some patches to fix the following problem: File system freeze/thaw require the superblock's s_umount lock. However, we write to the file system while holding the s_umount lock in several places (e.g., writeback and quotas). Any of these can block on a frozen file system while holding s_umount, preventing any later thaw from occurring, since thaw requires s_umount. The solution is to add a check, vfs_is_frozen(), to all code paths that write while holding sb->s_umount and return without writing if it is true. Attached is an audit of each use of ->s_umount and whether it could result in a deadlock with freeze/thaw. Some of this has gone into the code comments. Patches against some random post 3.0.0 pull to follow. A patch to xfstests is coming. Basically, we need to test for mmaped writes concurrent with file system freeze. Probably test 068 can be extended. (If anyone is interested in doing this, it is relatively simple work.) Thanks, Jan Kara and Dave Chinner for their kind suggestions for fixes and review of patches offline. -VAL --0016364d27f10b5eb904acc9be53 Content-Type: text/plain; charset=US-ASCII; name="audit.txt" Content-Disposition: attachment; filename="audit.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gsiacmhn0 QWN0dWFsIHBsYWNlcyBzX3Vtb3VudCBpcyBncmFiYmVkCgpmcy9mcy13cml0ZWJhY2suYwogLSBn cmFiYmVkIGJ5IHdyaXRlYmFja19pbm9kZXNfc2JfaWZfaWRsZSgpCiAgIFlFUzogZnMgaXMgbW91 bnRlZCwgY2FuIGJlIGZyb3plbiwgd2U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