ext4: journal credit fix for the delayed allocation's writepages() function
authorMingming Cao <cmm@us.ibm.com>
Wed, 20 Aug 2008 02:15:58 +0000 (22:15 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 20 Aug 2008 02:15:58 +0000 (22:15 -0400)
commit525f4ed8dcb72c71b306a78ecbf06f41d08fe441
treed4d74dc7b109c5d74fa955970a8528ec90e20b06
parenta1d6cc563bfdf1bf2829d3e6ce4d8b774251796b
ext4: journal credit fix for the delayed allocation's writepages() function

Previous delalloc writepages implementation started a new transaction
outside of a loop which called get_block() to do the block allocation.
Since we didn't know exactly how many blocks would need to be allocated,
the estimated journal credits required was very conservative and caused
many issues.

With the reworked delayed allocation, a new transaction is created for
each get_block(), thus we don't need to guess how many credits for the
multiple chunk of allocation.  We start every transaction with enough
credits for inserting a single exent.  When estimate the credits for
indirect blocks to allocate a chunk of blocks, we need to know the
number of data blocks to allocate.  We use the total number of reserved
delalloc datablocks; if that is too big, for non-extent files, we need
to limit the number of blocks to EXT4_MAX_TRANS_BLOCKS.

Code cleanup from Aneesh.

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Reviewed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/extents.c
fs/ext4/inode.c