]> git.karo-electronics.de Git - karo-tx-linux.git/commit
fs/direct-io.c: salcuate fs_count correctly in get_more_blocks()
authorTao Ma <boyu.mt@taobao.com>
Mon, 24 Oct 2011 15:00:17 +0000 (02:00 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 2 Nov 2011 04:59:29 +0000 (15:59 +1100)
commit4c1bff87213d726d61e06a1eb52b60a0b2f556ad
tree687c8c355f527250f94e62ecfa1d4364cebe29c3
parentb47a30f8b1f6d8e6da3eb64646c527ddb66f6301
fs/direct-io.c: salcuate fs_count correctly in get_more_blocks()

In get_more_blocks(), we use dio_count to calcuate fs_count and do some
tricky things to increase fs_count if dio_count isn't aligned.  But
actually it still has some corner cases that can't be coverd.  See the
following example:

dio_write foo -s 1024 -w 4096

(direct write 4096 bytes at offset 1024).  The same goes if the offset
isn't aligned to fs_blocksize.

In this case, the old calculation counts fs_count to be 1, but actually we
will write into 2 different blocks (if fs_blocksize=4096).  The old code
just works, since it will call get_block twice (and may have to allocate
and create extents twice for filesystems like ext4).  So we'd better call
get_block just once with the proper fs_count.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/direct-io.c