Opened 15 years ago

Last modified 7 years ago

#4443 assigned bug

Deleting (recently mounted & unmounted) image file does not free up space

Reported by: psycho_killer Owned by: nobody
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

After having mounted and unmounted a BFS image file the space occupied by the file is not freed when the file is deleted.

To reproduce: Take note of the amount of free space on your Haiku volume.
Expand i.e. this file: http://haiku-files.org/files/blank-bfs/blank-bfs-512mb.image.zip
then mount it (doubleclick in Tracker), unmount it (through Tracker)
Delete the image file
Observe free space on volume, the 512 MB is not freed, not even after reboot.

System used: R1/alpha (Revision 32945)
On real hardware: 512 MB of memory, 640 MB swap, partition ~2.5 GB

Tested the same file in BeOS R5, space was freed up afterwards.

Attachments (6)

testbfs.zip (71.0 KB ) - added by psycho_killer 15 years ago.
bfs image file, size 3 MB
testiso.zip (65.5 KB ) - added by psycho_killer 15 years ago.
iso image file, size 460 KB
checkfs-0.png (105.0 KB ) - added by psycho_killer 15 years ago.
before reboot
checkfs-1.png (77.4 KB ) - added by psycho_killer 15 years ago.
after reboot, just checking
checkfs-2.png (84.4 KB ) - added by psycho_killer 15 years ago.
fixed, space regained
checkfs-3.png (90.2 KB ) - added by psycho_killer 15 years ago.
verify with 'checkfs -c'

Download all attachments as: .zip

Change History (15)

comment:1 by scottmc, 15 years ago

Try emptying the trash can. I had this happen to me recently and was trying to figure out why the volume's space bar didn't change when I deleted the image file. Then I deleted all of the files on my scratch partition leaving only the home folder and it still didn't move. Then I realized that the trash sits on the desktop which you can't see in tracker. Emptying the trash I then saw the volume space bar indicators empty out as expected. Try it and let us know if that was the issue.

by psycho_killer, 15 years ago

Attachment: testbfs.zip added

bfs image file, size 3 MB

by psycho_killer, 15 years ago

Attachment: testiso.zip added

iso image file, size 460 KB

comment:2 by psycho_killer, 15 years ago

Thanks for your confidence in me, scottmc. Ok, jokes aside, thank you for replying. I suspect from your answer that you couldn't reproduce, or what?

I have uploaded two small image files (one bfs and one iso) that behaves like described, not freeing up the space. Should be easier for you all to test with small files. Just have the 'Get info' box open for your volume to note the space before/after deletion.

Space is not freed up whether I delete + empty trash, use shift + Del or use 'rm' in terminal. I booted into BeOS and deleted all the content of the Haiku partition, even did a 'rm -Rf *' in the /haiku root to delete the hidden stuff. Had to reformat to free up the space.

Ok, so I did some more testing.

  • Without exception, every time I mount an image file (both bfs and iso) through the gui by double clicking it, I lose that space permanently, also after rebooting. Obviously, this is unfortunate if we're talking about 700 MB iso files.
  • Mounting with the terminal can result in either the space being freed or not. In most typical user situations the result is that the space is not released, even after reboot. In fact, the only way I've found to reliably mount an image file and have the space freed up afterwards is as follows: First mount/unmount the file through Tracker, then delete it (and lose the space in the process). Then mount the same file, with the exact same filename, through Terminal using the '-t <file system>' option. (Not specifying file system will result in an error, bug report will follow later.) Now you can unmount the volume (use Terminal) and delete the file, and the space should be regained. It almost seems to be a "bug" that allows this loophole to happen and have the space freed up--it's only the fringe case that behaves correctly.
  • It is possible to swap the image file that you use in the second step of the procedure described just above with a different one --as long as it is named exactly the same-- and not loose space occupied by the second file when mounting in terminal. Useful workaround for mounting that big iso.

To sum up, something seems to be up with the mounting of image files, not my trash can handling :-)

comment:3 by mmlr, 15 years ago

Can you please try the checkfs command on the partition in question? I suppose the file is deleted, but not freed because it is still in use. Then on reboot this gets lost (as our journal format doesn't allow to track this situation). Running checkfs should free up these blocks and show a corresponding block number being freed.

comment:4 by mmadia, 15 years ago

/dev/disk/virtual/files might be related. after using tracker to unmount and shift-delete the imagefile, this still displays

/dev/disk/virtual/files/20> ls -l
total 1
lrw-r--r-- 1 user root 32 Sep 11 23:19 raw -> /boot/home/Desktop/testbfs.image

comment:5 by mmadia, 15 years ago

note: checkfs and sync afterwards didnt help.

comment:6 by psycho_killer, 15 years ago

Yes! checkfs frees up the lost space. But only AFTER you have rebooted, mmdadia. Have a look at the attached screenshots. Thanks for the tip about /dev/disk/virtual -- that was helpful to understand what is going on.

Screenshot 0 is before reboot, checkfs can not do anything and there are several images I have mounted->unmounted->deleted that is listed in the /dev/disk/virtual folder. The others are after the reboot, first just checking (1), then fixing (2), and checking again (3). Note the space left on the volume in the info box down to the right.

I hope this is helpful and that it is possible to fix someday. As I said earlier, the typical user mounting an image will loose the space without knowing how to regain it, both through Tracker and Terminal. As you probably figure out by now the case of space actually being freed up described in my earlier comment (using Terminal after Tracker) is due to that the file in the virtual folder is reused instead of a new one being created.

A little usability side note: Have a look at screenshot checkfs-2.png and notice how the checkfs command says "33011 blocks could be freed" while the haiku info box shows that the space now has been freed. This confused me the first time I ran the procedure, and I discovered later that the space actually had been freed in that step. The solution is obviously to print "could be freed" when using the '-c' option, and print "has been freed" when successfully running the command to fix.

by psycho_killer, 15 years ago

Attachment: checkfs-0.png added

before reboot

by psycho_killer, 15 years ago

Attachment: checkfs-1.png added

after reboot, just checking

by psycho_killer, 15 years ago

Attachment: checkfs-2.png added

fixed, space regained

by psycho_killer, 15 years ago

Attachment: checkfs-3.png added

verify with 'checkfs -c'

comment:7 by anevilyak, 14 years ago

Component: File Systems/BFSSystem/Kernel
Version: R1/pre-alpha1R1/Development

This one appears to still be with us. By the looks of things the culprit is the virtual / loopback filesystem mount mechanism though, not BFS. Changing component.

comment:8 by mmadia, 14 years ago

Summary: Deleting image file does not free up spaceDeleting (recently mounted & unmounted) image file does not free up space

comment:9 by axeld, 7 years ago

Owner: changed from axeld to nobody
Status: newassigned
Note: See TracTickets for help on using tickets.