diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2008-04-29 08:11:12 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-04-29 08:11:12 -0400 |
commit | e067ba0078cd6f00eb6c4052fec630b78ebe59de (patch) | |
tree | 58c5f6d1e86ac03257cde1714fb09437d408043c /fs/ext4 | |
parent | fd28784adc079afa905df56204b1298ddb4d0bfe (diff) | |
download | op-kernel-dev-e067ba0078cd6f00eb6c4052fec630b78ebe59de.zip op-kernel-dev-e067ba0078cd6f00eb6c4052fec630b78ebe59de.tar.gz |
ext4: make ext4_ext_get_blocks always return <= max_blocks
ext4_ext_get_blocks() returns number of blocks allocated with buffer
heads unmapped for a read from prealloc space. This is needed so that
delayed allocation doesn't do block reservation for prealloc space since
the blocks are already resevred on disk. Fix ext4_ext_get_blocks to not
return greater than max_blocks, since some of the code paths cannot
handle such a return value.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/extents.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index c2b004e..f4ef0b7 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2570,8 +2570,18 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, } if (create == EXT4_CREATE_UNINITIALIZED_EXT) goto out; - if (!create) + if (!create) { + /* + * We have blocks reserved already. We + * return allocated blocks so that delalloc + * won't do block reservation for us. But + * the buffer head will be unmapped so that + * a read from the block returns 0s. + */ + if (allocated > max_blocks) + allocated = max_blocks; goto out2; + } ret = ext4_ext_convert_to_initialized(handle, inode, path, iblock, |