From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm4Wy-0005wr-5p for qemu-devel@nongnu.org; Wed, 27 Jul 2011 09:52:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qm4Wt-0006Da-Sl for qemu-devel@nongnu.org; Wed, 27 Jul 2011 09:52:12 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:50469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm4Wt-0006DS-Nm for qemu-devel@nongnu.org; Wed, 27 Jul 2011 09:52:07 -0400 Received: by gyg8 with SMTP id 8so1255571gyg.4 for ; Wed, 27 Jul 2011 06:52:07 -0700 (PDT) Message-ID: <4E301804.40209@codemonkey.ws> Date: Wed, 27 Jul 2011 08:52:04 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <20110727113000.25109.16204.sendpatchset@skannery> <20110727113045.25109.54866.sendpatchset@skannery> <4E3015EC.7070004@msgid.tls.msk.ru> In-Reply-To: <4E3015EC.7070004@msgid.tls.msk.ru> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [V5 Patch 3/4]Qemu: Command "block_set" for dynamic block params change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: Kevin Wolf , Supriya Kannery , Christoph Hellwig , qemu-devel@nongnu.org, Stefan Hajnoczi On 07/27/2011 08:43 AM, Michael Tokarev wrote: >> Index: qemu/block.c >> =================================================================== >> --- qemu.orig/block.c >> +++ qemu/block.c >> @@ -651,6 +651,34 @@ unlink_and_fail: >> return ret; >> } >> >> +int bdrv_reopen(BlockDriverState *bs, int bdrv_flags) >> +{ >> + BlockDriver *drv = bs->drv; >> + int ret = 0, open_flags; >> + >> + /* Quiesce IO for the given block device */ >> + qemu_aio_flush(); >> + if (bdrv_flush(bs)) { >> + qerror_report(QERR_DATA_SYNC_FAILED, bs->device_name); >> + return ret; >> + } >> + open_flags = bs->open_flags; >> + bdrv_close(bs); >> + >> + ret = bdrv_open(bs, bs->filename, bdrv_flags, drv); >> + if (ret< 0) { >> + /* Reopen failed. Try to open with original flags */ >> + qerror_report(QERR_REOPEN_FILE_FAILED, bs->filename); >> + ret = bdrv_open(bs, bs->filename, open_flags, drv); >> + if (ret< 0) { >> + /* Reopen failed with orig and modified flags */ >> + abort(); >> + } > > Can we please avoid this stuff completely? Just keep the > old device open still, until you're sure new one is ok. I may be misremembering, but I thought Christoph had mentioned wanting to write a kernel patch to toggle O_DIRECT through fcntl(). This seems like the only way to make this not racy to me. Regards, Anthony Liguori