tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Finding an available fss device
On Sat, Aug 11, 2018 at 10:52:42AM +0700, Robert Elz wrote:
> I doubt that your new proposed ioctl() is a very good
> interface
Indeed, the following change is enough to find a free fss without a
hang, and it does not introduce a new ioctl. It is quite close to
your proposal, except I lock before testing FSS_ACTIVE. Why would
test then lock?
Index: sys/dev/fss.c
===================================================================
RCS file: /cvsroot/src/sys/dev/fss.c,v
retrieving revision 1.98.2.2
diff -U4 -r1.98.2.2 fss.c
--- sys/dev/fss.c 13 Jan 2018 05:38:54 -0000 1.98.2.2
+++ sys/dev/fss.c 12 Aug 2018 08:00:52 -0000
@@ -336,9 +336,13 @@
fss->fss_csize = fss50->fss_csize;
fss->fss_flags = 0;
/* Fall through */
case FSSIOCSET:
- mutex_enter(&sc->sc_lock);
+ if (mutex_tryenter(&sc->sc_lock) == 0) {
+ error = EBUSY;
+ break;
+ }
+
if ((flag & FWRITE) == 0)
error = EPERM;
else if ((sc->sc_flags & FSS_ACTIVE) != 0)
error = EBUSY;
--
Emmanuel Dreyfus
manu%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index