]> bbs.cooldavid.org Git - net-next-2.6.git/commit - fs/ocfs2/file.c
Ocfs2: Optimize punching-hole code.
authorTristan Ye <tristan.ye@oracle.com>
Tue, 11 May 2010 09:54:45 +0000 (17:54 +0800)
committerJoel Becker <joel.becker@oracle.com>
Tue, 18 May 2010 19:31:05 +0000 (12:31 -0700)
commitc1631d4a484fbb498e35d661f1aebd64c86b66bf
tree06e951cfebbd616dbaa0017d1c030a3f6e0d8d88
parentee149a7c6cbaee0e3a1a7d9e9f92711228ef5236
Ocfs2: Optimize punching-hole code.

This patch simplifies the logic of handling existing holes and
skipping extent blocks and removes some confusing comments.

The patch survived the fill_verify_holes testcase in ocfs2-test.
It also passed my manual sanity check and stress tests with enormous
extent records.

Currently punching a hole on a file with 3+ extent tree depth was
really a performance disaster.  It can even take several hours,
though we may not hit this in real life with such a huge extent
number.

One simple way to improve the performance is quite straightforward.
From the logic of truncate, we can punch the hole from hole_end to
hole_start, which reduces the overhead of btree operations in a
significant way, such as tree rotation and moving.

Following is the testing result when punching hole from 0 to file end
in bytes, on a 1G file, 1G file consists of 256k extent records, each record
cover 4k data(just one cluster, clustersize is 4k):

===========================================================================
 * Original punching-hole mechanism:
===========================================================================

   I waited 1 hour for its completion, unfortunately it's still ongoing.

===========================================================================
 * Patched punching-hode mechanism:
===========================================================================

   real 0m2.518s
   user 0m0.000s
   sys  0m2.445s

That means we've gained up to 1000 times improvement on performance in this
case, whee! It's fairly cool. and it looks like that performance gain will
be raising when extent records grow.

The patch was based on my former 2 patches, which were about truncating
codes optimization and fixup to handle CoW on punching hole.

Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
Acked-by: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
fs/ocfs2/file.c