* [Qemu-devel] [PATCH v2] raw-posix: Fetch max sectors for host block device
@ 2016-06-03 2:07 Fam Zheng
2016-06-03 2:42 ` Eric Blake
2016-06-03 8:27 ` Kevin Wolf
0 siblings, 2 replies; 4+ messages in thread
From: Fam Zheng @ 2016-06-03 2:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Max Reitz, qemu-block
This is sometimes a useful value we should count in.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
block/raw-posix.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index a4f5a1b..32f9596 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -729,9 +729,33 @@ static void raw_reopen_abort(BDRVReopenState *state)
state->opaque = NULL;
}
+static int hdev_get_max_transfer_length(int fd)
+{
+#ifdef BLKSECTGET
+ int max_sectors = 0;
+ if (ioctl(fd, BLKSECTGET, &max_sectors) == 0) {
+ return max_sectors;
+ } else {
+ return -errno;
+ }
+#else
+ return -ENOSYS;
+#endif
+}
+
static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
{
BDRVRawState *s = bs->opaque;
+ struct stat st;
+
+ if (!fstat(s->fd, &st)) {
+ if (S_ISBLK(st.st_mode)) {
+ int ret = hdev_get_max_transfer_length(s->fd);
+ if (ret >= 0) {
+ bs->bl.max_transfer_length = ret;
+ }
+ }
+ }
raw_probe_alignment(bs, s->fd, errp);
bs->bl.min_mem_alignment = s->buf_align;
--
2.8.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] raw-posix: Fetch max sectors for host block device
2016-06-03 2:07 [Qemu-devel] [PATCH v2] raw-posix: Fetch max sectors for host block device Fam Zheng
@ 2016-06-03 2:42 ` Eric Blake
2016-06-03 2:51 ` Fam Zheng
2016-06-03 8:27 ` Kevin Wolf
1 sibling, 1 reply; 4+ messages in thread
From: Eric Blake @ 2016-06-03 2:42 UTC (permalink / raw)
To: Fam Zheng, qemu-devel; +Cc: Kevin Wolf, qemu-block, Max Reitz
[-- Attachment #1: Type: text/plain, Size: 590 bytes --]
On 06/02/2016 08:07 PM, Fam Zheng wrote:
> This is sometimes a useful value we should count in.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> block/raw-posix.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
Will conflict with patches I'm about to post to rework BlockLimits to be
byte-based, rather than a mix of byte- and sector values. First one in
gets to watch the other rebase :)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] raw-posix: Fetch max sectors for host block device
2016-06-03 2:42 ` Eric Blake
@ 2016-06-03 2:51 ` Fam Zheng
0 siblings, 0 replies; 4+ messages in thread
From: Fam Zheng @ 2016-06-03 2:51 UTC (permalink / raw)
To: Eric Blake; +Cc: qemu-devel, Kevin Wolf, qemu-block, Max Reitz
On Thu, 06/02 20:42, Eric Blake wrote:
> On 06/02/2016 08:07 PM, Fam Zheng wrote:
> > This is sometimes a useful value we should count in.
> >
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> > block/raw-posix.c | 24 ++++++++++++++++++++++++
> > 1 file changed, 24 insertions(+)
> >
>
> Will conflict with patches I'm about to post to rework BlockLimits to be
> byte-based, rather than a mix of byte- and sector values. First one in
> gets to watch the other rebase :)
Thanks! I'm looking forward to a byte based BlockLimits!
Fam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] raw-posix: Fetch max sectors for host block device
2016-06-03 2:07 [Qemu-devel] [PATCH v2] raw-posix: Fetch max sectors for host block device Fam Zheng
2016-06-03 2:42 ` Eric Blake
@ 2016-06-03 8:27 ` Kevin Wolf
1 sibling, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2016-06-03 8:27 UTC (permalink / raw)
To: Fam Zheng; +Cc: qemu-devel, Max Reitz, qemu-block
Am 03.06.2016 um 04:07 hat Fam Zheng geschrieben:
> This is sometimes a useful value we should count in.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-03 8:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-03 2:07 [Qemu-devel] [PATCH v2] raw-posix: Fetch max sectors for host block device Fam Zheng
2016-06-03 2:42 ` Eric Blake
2016-06-03 2:51 ` Fam Zheng
2016-06-03 8:27 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).