linux/fs/ext4
Lukas Czerner 4234fb29a8 ext4: fix free clusters calculation in bigalloc filesystem
commit 304e220f08 upstream.

ext4_has_free_clusters() should tell us whether there is enough free
clusters to allocate, however number of free clusters in the file system
is converted to blocks using EXT4_C2B() which is not only wrong use of
the macro (we should have used EXT4_NUM_B2C) but it's also completely
wrong concept since everything else is in cluster units.

Moreover when calculating number of root clusters we should be using
macro EXT4_NUM_B2C() instead of EXT4_B2C() otherwise the result might be
off by one. However r_blocks_count should always be a multiple of the
cluster ratio so doing a plain bit shift should be enough here. We
avoid using EXT4_B2C() because it's confusing.

As a result of the first problem number of free clusters is much bigger
than it should have been and ext4_has_free_clusters() would return 1 even
if there is really not enough free clusters available.

Fix this by removing the EXT4_C2B() conversion of free clusters and
using bit shift when calculating number of root clusters. This bug
affects number of xfstests tests covering file system ENOSPC situation
handling. With this patch most of the ENOSPC problems with bigalloc file
system disappear, especially the errors caused by delayed allocation not
having enough space when the actual allocation is finally requested.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-04 06:06:42 +08:00
..
acl.c ext4: fix memory leak in ext4_xattr_set_acl()'s error path 2013-01-17 08:50:45 -08:00
acl.h fs: take the ACL checks to common code 2011-07-25 14:30:23 -04:00
balloc.c ext4: fix free clusters calculation in bigalloc filesystem 2013-03-04 06:06:42 +08:00
bitmap.c ext4: fix overhead calculation used by ext4_statfs() 2012-08-09 08:31:41 -07:00
block_validity.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
dir.c Merge branch 'for-3.4' of git://linux-nfs.org/~bfields/linux 2012-03-29 14:53:25 -07:00
ext4_extents.h ext4: add no_printk argument validation, fix fallout 2012-03-19 23:11:43 -04:00
ext4_jbd2.c jbd2: add debugging information to jbd2_journal_dirty_metadata() 2011-09-04 10:18:14 -04:00
ext4_jbd2.h ext4: expand commit callback and 2012-02-20 17:53:02 -05:00
ext4.h ext4: fix overhead calculation used by ext4_statfs() 2012-08-09 08:31:41 -07:00
extents.c ext4: fix extent tree corruption caused by hole punch 2013-01-17 08:50:52 -08:00
file.c Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 2011-11-02 10:06:20 -07:00
fsync.c ext4: fix race between sync and completed io work 2012-03-05 10:29:52 -05:00
hash.c ext4: return 32/64-bit dir name hash according to usage type 2012-03-18 22:44:40 -04:00
ialloc.c ext4: fix possible use after free with metadata csum 2013-01-17 08:50:45 -08:00
indirect.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
inode.c ext4: init pagevec in ext4_da_block_invalidatepages 2013-01-21 11:45:24 -08:00
ioctl.c ext4: fix duplicated mnt_drop_write call in EXT4_IOC_MOVE_EXT 2012-07-29 08:04:19 -07:00
Kconfig ext4: Don't ask about supporting ext2/3 in ext4 if ext4 is not configured 2009-12-21 10:54:09 -05:00
Makefile ext4: move ext4_ind_* functions from inode.c to indirect.c 2011-06-27 19:40:50 -04:00
mballoc.c ext4: fix race in ext4_mb_add_n_trim() 2013-03-04 06:06:42 +08:00
mballoc.h ext4: remove EXT4_MB_{BITMAP,BUDDY} macros 2012-02-20 17:54:06 -05:00
migrate.c ext4: using PTR_ERR() on the wrong variable in ext4_ext_migrate() 2012-02-20 17:53:06 -05:00
mmp.c ext4: Fix endianness bug when reading the MMP block 2012-02-27 01:09:03 -05:00
move_extent.c ext4: online defrag is not supported for journaled files 2012-10-13 05:38:49 +09:00
namei.c ext4: always set i_op in ext4_mknod() 2012-10-13 05:38:49 +09:00
page-io.c Revert "ext4: don't release page refs in ext4_end_bio()" 2012-03-29 17:00:56 -07:00
resize.c ext4: avoid duplicate writes of the backup bg descriptor blocks 2012-10-13 05:38:48 +09:00
super.c ext4: lock i_mutex when truncating orphan inodes 2013-01-17 08:50:53 -08:00
symlink.c ext4: symlink must be handled via filesystem specific operation 2010-05-16 02:00:00 -04:00
truncate.h ext4: move common truncate functions to header file 2011-06-27 19:16:04 -04:00
xattr_security.c Merge branch 'for_linus' into for_linus_merged 2012-01-10 11:54:07 -05:00
xattr_trusted.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
xattr_user.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
xattr.c ext4: fix xattr block allocation/release with bigalloc 2013-03-04 06:06:42 +08:00
xattr.h fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00