All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 5/5] drive_open: Add invalidate option for block devices
Date: Tue, 04 Jan 2011 20:23:11 +0100	[thread overview]
Message-ID: <m38vz0scbk.fsf@trasno.org> (raw)
In-Reply-To: <AANLkTi=hXxgsjn4DOumRoQS-kt+p+wmnuPY0tbNoNoJz@mail.gmail.com> (Blue Swirl's message of "Tue, 4 Jan 2011 19:06:54 +0000")

Blue Swirl <blauwirbel@gmail.com> wrote:
> On Tue, Jan 4, 2011 at 2:33 PM, Juan Quintela <quintela@redhat.com> wrote:
>> Linux allows to invalidate block devices.  This is needed for the incoming
>> migration part.
>>
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  block.h           |    2 ++
>>  block/raw-posix.c |   24 ++++++++++++++++++++++++
>>  blockdev.c        |    9 +++++----
>>  3 files changed, 31 insertions(+), 4 deletions(-)
>>
>> diff --git a/block.h b/block.h
>> index f923add..5ac96a5 100644
>> --- a/block.h
>> +++ b/block.h
>> @@ -34,6 +34,8 @@ typedef struct QEMUSnapshotInfo {
>>  #define BDRV_O_NATIVE_AIO  0x0080 /* use native AIO instead of the thread pool */
>>  #define BDRV_O_NO_BACKING  0x0100 /* don't open the backing file */
>>  #define BDRV_O_NO_FLUSH    0x0200 /* disable flushing on this disk */
>> +#define BDRV_O_INVALIDATE  0x0400 /* invalidate buffer cache for this device.
>> +                                     re-read things from server */
>>
>>  #define BDRV_O_CACHE_MASK  (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH)
>>
>> diff --git a/block/raw-posix.c b/block/raw-posix.c
>> index 6b72470..9439cf1 100644
>> --- a/block/raw-posix.c
>> +++ b/block/raw-posix.c
>> @@ -51,6 +51,7 @@
>>  #include <sys/param.h>
>>  #include <linux/cdrom.h>
>>  #include <linux/fd.h>
>> +#include <linux/fs.h>
>>  #endif
>>  #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
>>  #include <signal.h>
>> @@ -168,6 +169,29 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
>>     s->fd = fd;
>>     s->aligned_buf = NULL;
>>
>> +#ifdef __linux__
>> +    if ((bdrv_flags & BDRV_O_INVALIDATE)) {
>> +        struct stat buf;
>> +        int res;
>> +
>> +        res = fstat(fd, &buf);
>> +
>> +        if (res < 0) {
>> +            return -errno;
>> +        }
>> +
>> +        if (S_ISBLK(buf.st_mode)) {
>> +            printf("we are in a block device: %s\n", filename);
>
> Leftover debugging?

ouch, yes.

thanks for the spotting.

Later, Juan.

  reply	other threads:[~2011-01-04 19:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-04 14:33 [Qemu-devel] [PATCH 0/5] Fix migration with NFS & iscsi/Fiber channel Juan Quintela
2011-01-04 14:33 ` [Qemu-devel] [PATCH 1/5] migration: exit with error code Juan Quintela
2011-01-04 14:33 ` [Qemu-devel] [PATCH 2/5] blockdev: don't leak id on removal Juan Quintela
2011-01-04 14:33 ` [Qemu-devel] [PATCH 3/5] blockdev: release resources in the error case Juan Quintela
2011-01-04 14:33 ` [Qemu-devel] [PATCH 4/5] Reopen files after migration Juan Quintela
2011-01-04 19:05   ` Blue Swirl
2011-01-05 15:52   ` Markus Armbruster
2011-01-04 14:33 ` [Qemu-devel] [PATCH 5/5] drive_open: Add invalidate option for block devices Juan Quintela
2011-01-04 19:06   ` Blue Swirl
2011-01-04 19:23     ` Juan Quintela [this message]
2011-01-07  8:38   ` Christoph Hellwig
2011-01-10 10:15 ` [Qemu-devel] Re: [PATCH 0/5] Fix migration with NFS & iscsi/Fiber channel Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m38vz0scbk.fsf@trasno.org \
    --to=quintela@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.