Re: Linux loop device driver bug (and fix)

Thomas Horsten (thomas@horsten.com)
Tue, 20 Oct 1998 17:23:13 +0200 (CEST)


My fix caused another bug in the loopback driver, so if you had multiple
filehandles on a loopback device (ie. if you did anything else than mount
it), the internal refcount would be wrong and it would then be impossible
to unload the loop module after releasing the loopback device.

I also noticed that the MOD_USE_COUNT is incremented both when the device
is accessed and when it's configured/unconfigured. This is really not
neccesary since the interal refcount takes care of checking open files,
where the MOD_USE_COUNT should be incremented/decremented only when a
device is actually configured/removed. I didn't change that one though,
since I want to be sure that what I've done works.

How's the procedure for adding this to the source?

Here's the fix:

*** loop.c.orig Tue Oct 20 16:06:52 1998
--- loop.c Tue Oct 20 17:04:08 1998
***************
*** 449,454 ****
--- 449,455 ----
dput(dentry);
}

+ loop_release_xfer(lo);
lo->transfer = NULL;
lo->ioctl = NULL;
lo->lo_device = 0;
***************
*** 611,619 ****
if (lo->lo_refcnt <= 0)
printk(KERN_ERR "lo_release: refcount(%d) <= 0\n", lo->lo_refcnt);
else {
! if (--lo->lo_refcnt == 0)
! err = loop_release_xfer(lo);
! MOD_DEC_USE_COUNT;
}
return err;
}
--- 612,619 ----
if (lo->lo_refcnt <= 0)
printk(KERN_ERR "lo_release: refcount(%d) <= 0\n", lo->lo_refcnt);
else {
! --lo->lo_refcnt;
! MOD_DEC_USE_COUNT;
}
return err;
}

Yours sincerely,

Thomas Horsten
Thomas@Horsten.COM

--
PGP public key available, finger thomas@horsten.com

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/