|
|
9ae3a8 |
From 52288902dd647cbcfa470a11867163a6e5983297 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 11 Jul 2016 05:33:38 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 5/7] raw-posix: Fetch max sectors for host block device
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1468215219-30793-6-git-send-email-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 71109
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH 5/6] raw-posix: Fetch max sectors for host block device
|
|
|
9ae3a8 |
Bugzilla: 1318199
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This is sometimes a useful value we should count in.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 6f6071745bd0366221f5a0160ed7d18d0e38b9f7)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
block/raw-posix.c | 24 ++++++++++++++++++++++++
|
|
|
9ae3a8 |
1 file changed, 24 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff
|
|
|
9ae3a8 |
index 92fcb6c..ed97bd4 100644
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -587,9 +587,33 @@ static void raw_reopen_abort(BDRVReopenState *state)
|
|
|
9ae3a8 |
state->opaque = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static int hdev_get_max_transfer_length(int fd)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+#ifdef BLKSECTGET
|
|
|
9ae3a8 |
+ int max_sectors = 0;
|
|
|
9ae3a8 |
+ if (ioctl(fd, BLKSECTGET, &max_sectors) == 0) {
|
|
|
9ae3a8 |
+ return max_sectors;
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ return -errno;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+#else
|
|
|
9ae3a8 |
+ return -ENOSYS;
|
|
|
9ae3a8 |
+#endif
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BDRVRawState *s = bs->opaque;
|
|
|
9ae3a8 |
+ struct stat st;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (!fstat(s->fd, &st)) {
|
|
|
9ae3a8 |
+ if (S_ISBLK(st.st_mode)) {
|
|
|
9ae3a8 |
+ int ret = hdev_get_max_transfer_length(s->fd);
|
|
|
9ae3a8 |
+ if (ret >= 0) {
|
|
|
9ae3a8 |
+ bs->bl.max_transfer_length = ret;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
raw_probe_alignment(bs, s->fd, errp);
|
|
|
9ae3a8 |
bs->bl.opt_mem_alignment = s->buf_align;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|