Re: Loopback mount and free space...

Matthias Urlichs (smurf@smurf.noris.de)
Thu, 4 Apr 1996 15:35:21 +0100


Somebody _does_ forget to free an inode. Unmounting closes the loopback
device, but closing the device doesn't disassociate the device from the
underlying file. This is bad. IMHO it is an error for umount to depend =
on
_anything_, including a correct /etc/mtab.

# ./looptest
+ df .
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda1 29727 18455 11272 62% /
+ gzip -d </boot/disk.81 >disk
+ df .
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda1 29727 20966 8761 71% /
+ mount -o loop disk /mnt
+ rm disk
+ umount /mnt
+ df .
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda1 29727 20967 8760 71% /
+ exit 0

The following fix is untested but should work, assuming that mount moun=
ts
the device before closing /dev/loop#:

--- /pub/src/linux/kernel/linux-1.3.83/drivers/block/loop.c Fri Mar 29 =
11:52:28 1996
+++ /usr/src/kernel/linux-test/drivers/block/loop.c Thu Apr 4 15:13:48=
1996
@@ -450,6 +450,8 @@
printk("lo_release: refcount(%d) <=3D 0\n", lo->lo_refcnt);
else {
lo->lo_refcnt--;
+ if(lo->lo_refcnt =3D=3D 0)
+ loop_clr_fd(lo, inode->i_rdev);
MOD_DEC_USE_COUNT;
}
}

Grumble. Of course mount _does_ close the device before mounting. The
following patch would break mount after 250 loopback-mounts from one mo=
unt
program, which IMHO can be tolerated. ;-)

--- /usr/src/sbin/mount-2.5g/lomount.c.old Thu Apr 4 15:27:29 1996
+++ /usr/src/sbin/mount-2.5g/lomount.c Thu Apr 4 15:27:54 1996
@@ -185,7 +185,7 @@
perror ("ioctl: LOOP_SET_STATUS");
return 1;
}
- close (fd);
+ /* close (fd); -- auto-remove on close!? */
close (ffd);
return 0;
}

--=20
Dog Pound: A used cur lot.
--=20
Matthias Urlichs \ XLink-POP N=FCrnberg | EMail: urlichs@smurf.=
noris.de
Schleiermacherstra=DFe 12 \ Unix+Linux+Mac | Phone: ...please use =
email.
90491 N=FCrnberg (Germany) \ Consulting+Networking+Programming+etc'i=
ng 42
PGP: 1B 89 E2 1C 43 EA 80 44 15 D2 29 CF C6 C7 E0 DE=20
Click <A HREF=3D"http://smurf.noris.de/~smurf/finger">here</A>.