From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWkNJ-0004C2-E2 for qemu-devel@nongnu.org; Mon, 08 Aug 2016 09:13:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWkNH-0005iM-HF for qemu-devel@nongnu.org; Mon, 08 Aug 2016 09:13:48 -0400 From: Fam Zheng Date: Mon, 8 Aug 2016 21:13:14 +0800 Message-Id: <1470662013-19785-2-git-send-email-famz@redhat.com> In-Reply-To: <1470662013-19785-1-git-send-email-famz@redhat.com> References: <1470662013-19785-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v7 01/20] block: Add flag bits for image locking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, rjones@redhat.com, John Snow , Jeff Cody , Markus Armbruster , Max Reitz , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, berrange@redhat.com Later the block layer will automatically lock the images to avoid unexpected concurrent accesses to the same image, which will easily corrupt the metadata or user data, unless in some very special cases, like migration. The exceptional cases like shared storage migration and testing should set BDRV_O_SHARED_LOCK or BDRV_O_NO_LOCK to advise an appropriate locking mode. Signed-off-by: Fam Zheng Reviewed-by: Max Reitz --- include/block/block.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index 11c162d..4f8450b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -97,6 +97,8 @@ typedef struct HDGeometry { select an appropriate protocol driver, ignoring the format layer */ #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ +#define BDRV_O_NO_LOCK 0x20000 /* don't lock image file */ +#define BDRV_O_SHARED_LOCK 0x40000 /* lock the image file in shared mode */ #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) -- 2.7.4