qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 1/2] raw-posix: Fetch max sectors for host block


From: Kevin Wolf
Subject: Re: [Qemu-block] [PATCH 1/2] raw-posix: Fetch max sectors for host block device from sysfs
Date: Thu, 2 Jun 2016 14:54:23 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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.
> > 
> > Signed-off-by: Fam Zheng <address@hidden>
> > ---
> >  block/raw-posix.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 47 insertions(+)
> > 
> > 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 *state)
> >      state->opaque = NULL;
> >  }
> >  
> > +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 = g_strdup_printf("/sys/dev/block/%u:%u/queue/max_sectors_kb",
> > +                           major(dev), minor(dev));
> 
> 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

Attachment: pgpUEv_jWFiRL.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]