remarkable-linux/fs/ext4
Aneesh Kumar K.V c364b22c95 ext4: Fix mmap/truncate race when blocksize < pagesize && delayed allocation
It is possible to see buffer_heads which are not mapped in the
writepage callback in the following scneario (where the fs blocksize
is 1k and the page size is 4k):

1) truncate(f, 1024)
2) mmap(f, 0, 4096)
3) a[0] = 'a'
4) truncate(f, 4096)
5) writepage(...)

Now if we get a writepage callback immediately after (4) and before an
attempt to write at any other offset via mmap address (which implies we
are yet to get a pagefault and do a get_block) what we would have is the
page which is dirty have first block allocated and the other three
buffer_heads unmapped.

In the above case the writepage should go ahead and try to write the
first blocks and clear the page_dirty flag. Further attempts to write
to the page will again create a fault and result in allocating blocks
and marking page dirty.  If we don't write any other offset via mmap
address we would still have written the first block to the disk and
rest of the space will be considered as a hole.

So to address this, we change all of the places where we look for
delayed, unmapped, or unwritten buffer heads, and only check for
delayed or unwritten buffer heads instead.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-14 17:57:10 -04:00
..
acl.c helpers for acl caching + switch to those 2009-06-24 08:17:07 -04:00
acl.h switch ext4 to inode->i_acl 2009-06-24 08:17:04 -04:00
balloc.c ext4: Convert ext4_lock_group to use sb_bgl_lock 2009-05-02 20:35:09 -04:00
bitmap.c
block_validity.c ext4: Add a comprehensive block validity check to ext4_get_blocks() 2009-05-17 15:38:01 -04:00
dir.c ext4: Define a new set of flags for ext4_get_blocks() 2009-05-14 00:58:52 -04:00
ext4.h ext4: naturally align struct ext4_allocation_request 2009-07-13 10:24:17 -04:00
ext4_extents.h ext4: online defrag -- Add EXT4_IOC_MOVE_EXT ioctl 2009-06-17 19:24:03 -04:00
ext4_jbd2.c
ext4_jbd2.h ext4: fix no journal corruption with locale-gen 2009-07-08 17:11:24 -04:00
extents.c ext4: Calculate required journal credits for inserting an extent properly 2009-07-05 23:12:04 -04:00
file.c ext4: update the s_last_mounted field in the superblock 2009-06-13 10:09:48 -04:00
fsync.c ext4: convert instrumentation from markers to tracepoints 2009-06-17 11:48:11 -04:00
hash.c
ialloc.c ext4: Fix goal inum check in the inode allocator 2009-07-05 23:45:11 -04:00
inode.c ext4: Fix mmap/truncate race when blocksize < pagesize && delayed allocation 2009-06-14 17:57:10 -04:00
ioctl.c ext4: online defrag -- Add EXT4_IOC_MOVE_EXT ioctl 2009-06-17 19:24:03 -04:00
Kconfig trivial: fix typos/grammar errors in Kconfig texts 2009-03-30 15:22:01 +02:00
Makefile ext4: online defrag -- Add EXT4_IOC_MOVE_EXT ioctl 2009-06-17 19:24:03 -04:00
mballoc.c ext4: Use rcu_barrier() on module unload. 2009-07-05 22:29:27 -04:00
mballoc.h ext4: Move fs/ext4/group.h into ext4.h 2009-05-01 19:44:44 -04:00
migrate.c ext4: teach the inode allocator to use a goal inode number 2009-06-13 11:45:35 -04:00
move_extent.c ext4: online defrag -- Add EXT4_IOC_MOVE_EXT ioctl 2009-06-17 19:24:03 -04:00
namei.c ext4: teach the inode allocator to use a goal inode number 2009-06-13 11:45:35 -04:00
resize.c block: rename CONFIG_LBD to CONFIG_LBDAF 2009-06-19 08:08:50 +02:00
super.c switch ext4 to inode->i_acl 2009-06-24 08:17:04 -04:00
symlink.c
xattr.c ext4: Use lowercase names of quota functions 2009-03-26 02:18:36 +01:00
xattr.h
xattr_security.c
xattr_trusted.c
xattr_user.c