Re: [PATCH 0/2] sg: fix races during device removal (v2)

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

 



I wrote:
> You can do a little trick here and combine this flag with the counter t:
> Simply say t = 1 for "this device is open and has no outstanding
> transactions yet".  Then increment and decrement for requests and
> responses.  Also do t-- once on close().  Then t == 0 means "closed and
> all transactions completed".  And any t != 0 means of course "there are
> t - 1 transactions pending".  You could also shift it all by one and say
> "t == -1 means device closed and 0 transactions pending" but the former
> way allows you to use the kref API.  (However, if you ever need to know
> whether the device is open or closed, independently whether there are
> transactions pending or not, then you can't fold this "open?" flag into
> the transaction counter t.)

Also, of course you can't use the kref API for this counter t if you
want to read the number of pending transactions somewhere.  Use an
atomic_t then, or an int whose accessors are serialized by a lock.
-- 
Stefan Richter
-=====-==--= ---= -====
http://arcgraph.de/sr/
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux