[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/31] raw-posix: Fetch max sectors for host block de
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 22/31] raw-posix: Fetch max sectors for host block device |
Date: |
Wed, 8 Jun 2016 11:16:48 +0200 |
From: Fam Zheng <address@hidden>
This is sometimes a useful value we should count in.
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/raw-posix.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index ce1cf14..ce2e20f 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;
--
1.8.3.1
- [Qemu-devel] [PULL 12/31] blkreplay: Convert to bdrv_co_pwrite_zeroes(), (continued)
- [Qemu-devel] [PULL 12/31] blkreplay: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 16/31] raw_bsd: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 14/31] qed: Convert to bdrv_co_pwrite_zeroes(), Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 28/31] qemu-img bench: Sequential writes, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 23/31] qcow2: avoid extra flushes in qcow2, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 27/31] qemu-img bench, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 24/31] block: Fix bdrv_all_delete_snapshot() error handling, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 25/31] blockdev: clean up error handling in do_open_tray, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 20/31] migration/block: Convert saving to BlockBackend, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 29/31] qemu-img bench: Make start offset configurable, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 22/31] raw-posix: Fetch max sectors for host block device,
Kevin Wolf <=
- [Qemu-devel] [PULL 26/31] block: Don't emulate natively supported pwritev flags, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 31/31] qemu-img bench: Add --flush-interval, Kevin Wolf, 2016/06/08
- [Qemu-devel] [PULL 30/31] qemu-img bench: Implement -S (step size), Kevin Wolf, 2016/06/08
- Re: [Qemu-devel] [PULL 00/31] Block layer patches, Peter Maydell, 2016/06/08