[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 9/9] scsi/scsi_bus: fix races in REPORT LUNS
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v4 9/9] scsi/scsi_bus: fix races in REPORT LUNS |
Date: |
Fri, 11 Sep 2020 16:12:08 +0100 |
On Wed, Sep 09, 2020 at 11:20:24AM +0300, Maxim Levitsky wrote:
> On Tue, 2020-09-08 at 16:27 +0100, Stefan Hajnoczi wrote:
> > On Mon, Aug 31, 2020 at 06:01:24PM +0300, Maxim Levitsky wrote:
> > > @@ -460,46 +466,36 @@ static bool
> > > scsi_target_emulate_report_luns(SCSITargetReq *r)
> > > }
> > > channel = r->req.dev->channel;
> > > id = r->req.dev->id;
> > > - found_lun0 = false;
> > > - n = 0;
> > >
> > > - rcu_read_lock();
> > >
> > > - QTAILQ_FOREACH_RCU(kid, &r->req.bus->qbus.children, sibling) {
> > > - DeviceState *qdev = kid->child;
> > > - SCSIDevice *dev = SCSI_DEVICE(qdev);
> > > + /* add size (will be updated later to correct value */
> > > + g_byte_array_append(buf, tmp, 8);
> > > + len += 8;
> >
> > Can g_byte_array_size() be used instead of keeping a len local variable?
> Glib don't seem to have this function, I checked the docs.
> Its seems that they want to convert it to GBytes which is basically immutible
> verion
> of GByteArray and it does have g_bytes_get_size.
> I decided that a local variable while ugly is still better that this.
>
>
> I haven't wrote much code that uses Glib, so I might have missed something
> though.
> I had read this reference:
> https://developer.gnome.org/glib/stable/glib-Byte-Arrays.html
Oops, you're right. GByteArray != GBytes. The local variable makes sense.
Stefan
signature.asc
Description: PGP signature