From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8S8x-00021k-VG for qemu-devel@nongnu.org; Thu, 02 Jun 2016 08:54:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8S8w-0003ck-2S for qemu-devel@nongnu.org; Thu, 02 Jun 2016 08:54:34 -0400 Date: Thu, 2 Jun 2016 14:54:23 +0200 From: Kevin Wolf Message-ID: <20160602125423.GG6867@noname.redhat.com> References: <1464243305-10661-1-git-send-email-famz@redhat.com> <1464243305-10661-2-git-send-email-famz@redhat.com> <3290affb-9e0e-3bfe-49d8-56726bf04339@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bKyqfOwhbdpXa4YI" Content-Disposition: inline In-Reply-To: <3290affb-9e0e-3bfe-49d8-56726bf04339@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] raw-posix: Fetch max sectors for host block device from sysfs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Fam Zheng , qemu-devel@nongnu.org, Paolo Bonzini , qemu-block@nongnu.org --bKyqfOwhbdpXa4YI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 02.06.2016 um 14:30 hat Max Reitz geschrieben: > On 26.05.2016 08:15, Fam Zheng wrote: > > This is sometimes a useful value we should count in. > >=20 > > Signed-off-by: Fam Zheng > > --- > > block/raw-posix.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 47 insertions(+) > >=20 > > diff --git a/block/raw-posix.c b/block/raw-posix.c > > index a4f5a1b..d3796ad 100644 > > --- a/block/raw-posix.c > > +++ b/block/raw-posix.c > > @@ -729,9 +729,56 @@ static void raw_reopen_abort(BDRVReopenState *stat= e) > > state->opaque =3D NULL; > > } > > =20 > > +static int hdev_get_max_transfer_length(dev_t dev) > > +{ > > + int ret; > > + int fd; > > + char *path; > > + const char *end; > > + char buf[32]; > > + long len; > > + > > + path =3D g_strdup_printf("/sys/dev/block/%u:%u/queue/max_sectors_k= b", > > + major(dev), minor(dev)); >=20 > I can't say I like this very much, but well, it won't do any harm on any > systems that do not offer this path (i.e. any non-Linux system, I > suppose). So I'm fine with it. Haven't looked at the patch in detail yet, so I didn't want to send a comment yet, but I think this should be #ifdef-ed out for non-Linux. Also a quick search on the internet suggests that the BLKSECTGET ioctl is what we're looking for, so hopefully using sysfs is unnecessary anyway. Kevin --bKyqfOwhbdpXa4YI Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJXUCx/AAoJEH8JsnLIjy/WXqUP+wU9HePLsB5/y+23q34JNKQq WWjPWSN2Ej1hjGW2SdDND/HNl8XI/nWD7hcAqXOq5IN+NYqzUdSYepujMiAaM+2c +EN3a6xlVJh3/vR2fMP9fc8pbUqAnWTAZSeyalfO5wuM3aTZCaUHbwKPzZwQ7MBN 2IIArRIm5NSWIFYbuOxT46OxSg1isWljPeS+DB4mXxu0ljvmIwNBw0vTDj9iBFum mbFYCB29CXXX8+4ax26wgFDtoXDP91eJHws1i+Oke6Nqn8okeHTzMNa38JaYjfn8 KtC4fLIEasGyUZCLKeqlobvGRDXFJZLEJUxQ9XlfcRgSU2IZ9oxQbwSYWrhlxIOW YXbbw1TkvuqGK1+YWcYMg+bnO8Iygx4Gw1Fv7OLZKAYSON9hpf8wLT+ht+s6Y/jQ hZg0ob6GKtEQ3ilNN3NtDrA1+3G1gXN6Pwqw89/av9YO0Q65WOvD5leNTBrlMh9D fBCI0D3ErI8hxrJseUlknI0HZz2SEtJH7GOCJOX0FmhmO02yZpYZfhcd/xoVCO4y KnoNZesmK8350ADI6Ja8H28Urxjv9PYsh1FpUCO4QEYRRNpIVQYv31VzQvZtWktQ /a3XKG8D8nXW2JS39FyjAqq3kr3V2Buh2ma0+pxlXlktn2gqQMitTK8nyUHFNBz7 iZ2l7LlpvIUtpXH1dhOj =50pY -----END PGP SIGNATURE----- --bKyqfOwhbdpXa4YI--