Commit Message

From: Robin Dong <sanbai@taobao.com>
1. fix the bug reported by Eric Sandeen (http://www.spinics.net/lists/linux-ext4/msg30259.html)
2. change the argument of i_{reserved_data,reserved_meta,allocated_meta}_blocks to i_*_clusters
3. In the old logic When we try writing to a block which does not have a mapping, and bigalloc is enabled:
a) one block have been mapped, a whole cluster will be reserved.
b) While the block has not been mapped (and so the data on disk is
uninitialized) the cluster has indeed been allocated, so we don't need
to reserve any additional room for the block.
Imaging s_cluster_ratio is 4 and the clusters is: (follow the comment in fs/ext4/extent.c:4100)
[0-3], [4-7], [8-11]
The new quota-reservation logic have changed to this now:
1. delay-allocation write blocks 10&11
we reserve 1 cluster, the i_reserved_data_blocks is 1 now
2. delay-allocation write blocks 3 to 8
we reserve other 2 clusters, so 3 clusters totally, the
i_reserved_data_blocks is 3 now
3. writeout the blocks 3 to 8
claim all 3 clusters, i_reserved_data_blocks is 0 now
At this moment, we really have allocated 3 clusters, and the
remain 10&11 block would never occupy another cluster (it would
definitely go into the [8-11] cluster), so, we don't need to reserve one
more cluster quota (which is the old logic).
4. writeout the 10&11 blocks
the 10&11 blocks will be set EXT4_MAP_FROM_CLUSTER flag ( by
get_implied_cluster_alloc as the 8~9 block have been allocated), and
it will not call ext4_da_update_reserve_space any more
As this, no warning, no reserve-and-release ping pong.
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: Robin Dong <sanbai@taobao.com>
---
fs/ext4/balloc.c | 4 +-
fs/ext4/ext4.h | 6 +-
fs/ext4/extents.c | 97 +++++++++++--------------------------------
fs/ext4/file.c | 2 +-
fs/ext4/inode.c | 66 +++++++++++++++--------------
fs/ext4/super.c | 7 ++-
include/trace/events/ext4.h | 42 +++++++++---------
7 files changed, 90 insertions(+), 134 deletions(-)