ext4: move ext4_update_i_disksize() into mpage_map_and_submit_extent()
authorTheodore Ts'o <tytso@mit.edu>
Fri, 11 Apr 2014 14:35:17 +0000 (10:35 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 6 May 2014 14:59:37 +0000 (07:59 -0700)
commitde65d2a2221ab864583fee719b8a3f9e045a385b
tree5948b0b142893a1457439a62d31dab1fd9393b72
parent58b9dc7b5d9d84783ea2d317b5fe29efbe4c9c83
ext4: move ext4_update_i_disksize() into mpage_map_and_submit_extent()

commit 622cad1325e404598fe3b148c3fa640dbaabc235 upstream.

The function ext4_update_i_disksize() is used in only one place, in
the function mpage_map_and_submit_extent().  Move its code to simplify
the code paths, and also move the call to ext4_mark_inode_dirty() into
the i_data_sem's critical region, to be consistent with all of the
other places where we update i_disksize.  That way, we also keep the
raw_inode's i_disksize protected, to avoid the following race:

      CPU #1                                 CPU #2

   down_write(&i_data_sem)
   Modify i_disk_size
   up_write(&i_data_sem)
                                        down_write(&i_data_sem)
                                        Modify i_disk_size
                                        Copy i_disk_size to on-disk inode
                                        up_write(&i_data_sem)
   Copy i_disk_size to on-disk inode

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/ext4.h
fs/ext4/inode.c