Most recent kernel where this bug did not occur: N/A Distribution: this bug does not depend on distribution. Hardware Environment: x86 Software Environment: >>> # lsmod Module Size Used by bfs 14008 1 # <<< Problem Description: When deleting an inode, the BFS driver adds a free disk block even when the inode did not use any disk blocks. Steps to reproduce: 1. Mount a BFS partition. 2. Create an empty file on this partition, delete this file, repeat: >>> root@codedot:/mnt# mount | grep mnt /dev/loop0 on /mnt type bfs (rw) root@codedot:/mnt# df -B 512 | grep loop /dev/loop0 65536 81 65455 1% /mnt root@codedot:/mnt# touch file root@codedot:/mnt# rm file root@codedot:/mnt# df -B 512 | grep loop /dev/loop0 65536 80 65456 1% /mnt root@codedot:/mnt# for i in `seq 1 100`; do touch file; rm file; done root@codedot:/mnt# df -B 512 | grep loop /dev/loop0 65536 -20 65556 0% /mnt root@codedot:/mnt# <<< The number of occupied blocks reported by statfs() becomes negative if an empty file gets created and subsequently removed sufficient number of times.
The bfs_get_block() function located in `fs/bfs/file.c' does not compare the number of the physical block, which it tries to access when extending the file, against the size of the block device. Checks against the block device size need to be introduced into the filesystem driver, and -ENOSPC error should be returned every time the partition runs out of free space when writing a growing file. I am working on a fix for the BFS driver, that's why I am assigning this bug to myself now.
The patch proposed in the following LKML message http://lkml.org/lkml/2007/11/13/185 fixes the error reported in the context of this bug. What follows is a console session, which proves that the error is gone: >>> debian:~# mount -t bfs /dev/loop0 /mnt debian:~# cd /mnt/ debian:/mnt# df -B 512 | grep loop /dev/loop0 65536 81 65455 1% /mnt debian:/mnt# for i in `seq 1 100`; do touch file; rm file; done debian:/mnt# df -B 512 | grep loop /dev/loop0 65536 81 65455 1% /mnt debian:/mnt# <<<
I merged Dmitry's fix