From patchwork Tue Oct 1 21:09:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomoki Sekiyama X-Patchwork-Id: 279584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 326582C0090 for ; Wed, 2 Oct 2013 07:10:34 +1000 (EST) Received: from localhost ([::1]:32788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR7DD-0007aK-D0 for incoming@patchwork.ozlabs.org; Tue, 01 Oct 2013 17:10:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR7Co-0007Xw-Tl for qemu-devel@nongnu.org; Tue, 01 Oct 2013 17:10:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VR7Cj-0007xe-58 for qemu-devel@nongnu.org; Tue, 01 Oct 2013 17:10:06 -0400 Received: from usindpps05.hds.com ([207.126.252.18]:48401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR7Ci-0007xP-TP for qemu-devel@nongnu.org; Tue, 01 Oct 2013 17:10:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hds.com; h=subject : to : from : cc : date : message-id : mime-version : content-type : content-transfer-encoding; s=mail1; bh=Ew9NtwSEtJ2C3afqSn2n5uknr9YoKYApjy18TUSOW04=; b=Kd3X6BT3Z+xENBR7NGYISDzwSUPl2FfBfiKC6APg5Tqr5DAN6dZpQbboWyTwl2I7Xpsr CV0uYj8udwtxjCvK8NeFYMgdwG9cPY5XoIEs8LLDpl4Wt/Qbjh1eozA9HCjlp0eEkPL0 5iJfOqJ/s34suTaTxdQn9FEFeIaEmY2mJCeacONSt+DeB0r9j3YNLrwtlzYTaTjRib2R NqHMKnI4vdh7i7rTfq0ggOHGpT5tyuzBF7ZGPp2XUq8Ws/pTNP/ozPiw3+AMVHf5677r UOzMyj/An4/ZQWh5oU5huD6bn24lF5q+T3i7iFpmZyMEw3+Hd3hEIUQR9UXy2Sc1L83o HQ== Received: from usindmail01.hds.com (usindmail03 [207.126.252.22]) by usindpps05.hds.com (8.14.5/8.14.5) with ESMTP id r91L9tZl026785; Tue, 1 Oct 2013 17:09:55 -0400 Received: from localhost.localdomain (usindnetf5d-vlan47float.corp.hds.com [10.74.73.11]) by usindmail01.hds.com (8.14.1/8.14.1) with ESMTP id r91L9ruL044759; Tue, 1 Oct 2013 17:09:54 -0400 (EDT) To: qemu-devel@nongnu.org From: Tomoki Sekiyama Date: Tue, 01 Oct 2013 17:09:53 -0400 Message-ID: <20131001210953.23207.28945.stgit@localhost.localdomain> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 mx ip4:207.126.244.0/26 ip4:207.126.252.0/25 include:mktomail.com include:cloud.hds.com ~all X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794, 1.0.431, 0.0.0000 definitions=2013-10-01_07:2013-10-01, 2013-10-01, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=outbound_policy score=0 spamscore=0 suspectscore=13 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1305240000 definitions=main-1310010109 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 207.126.252.18 Cc: seiji.aguchi@hds.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] qemu-ga: execute fsfreeze-freeze in reverse order of mounts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently, fsfreeze-freeze may cause deadlock if a guest has loopback mounts of image files in its disk; e.g.: # mount | grep ^/ /dev/vda1 / type ext4 (rw,noatime,seclabel,data=ordered) /tmp/disk.img on /mnt type ext4 (rw,relatime,seclabel) To avoid the deadlock, this freeze filesystems in reverse order of mounts. Signed-off-by: Tomoki Sekiyama Reviewed-by: Eric Blake --- qga/commands-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index e199738..f453132 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -566,7 +566,7 @@ typedef struct FsMount { QTAILQ_ENTRY(FsMount) next; } FsMount; -typedef QTAILQ_HEAD(, FsMount) FsMountList; +typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList; static void free_fs_mount_list(FsMountList *mounts) { @@ -728,7 +728,7 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err) /* cannot risk guest agent blocking itself on a write in this state */ ga_set_frozen(ga_state); - QTAILQ_FOREACH(mount, &mounts, next) { + QTAILQ_FOREACH_REVERSE(mount, &mounts, FsMountList, next) { fd = qemu_open(mount->dirname, O_RDONLY); if (fd == -1) { error_setg_errno(err, errno, "failed to open %s", mount->dirname);