diff options
author | Theodore Ts'o <tytso@mit.edu> | 2014-04-11 10:35:17 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-04-11 10:35:17 -0400 |
commit | 622cad1325e404598fe3b148c3fa640dbaabc235 (patch) | |
tree | 45f8f60ba6246b9f7276146635c15fb44195f763 /fs/ext4/ext4.h | |
parent | c57ab39b9658315a742b6e61fdc86bb4d20cf566 (diff) |
ext4: move ext4_update_i_disksize() into mpage_map_and_submit_extent()
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>
Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index f1c65dc7cc0a..66946aa62127 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -2466,23 +2466,6 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize) | |||
2466 | up_write(&EXT4_I(inode)->i_data_sem); | 2466 | up_write(&EXT4_I(inode)->i_data_sem); |
2467 | } | 2467 | } |
2468 | 2468 | ||
2469 | /* | ||
2470 | * Update i_disksize after writeback has been started. Races with truncate | ||
2471 | * are avoided by checking i_size under i_data_sem. | ||
2472 | */ | ||
2473 | static inline void ext4_wb_update_i_disksize(struct inode *inode, loff_t newsize) | ||
2474 | { | ||
2475 | loff_t i_size; | ||
2476 | |||
2477 | down_write(&EXT4_I(inode)->i_data_sem); | ||
2478 | i_size = i_size_read(inode); | ||
2479 | if (newsize > i_size) | ||
2480 | newsize = i_size; | ||
2481 | if (newsize > EXT4_I(inode)->i_disksize) | ||
2482 | EXT4_I(inode)->i_disksize = newsize; | ||
2483 | up_write(&EXT4_I(inode)->i_data_sem); | ||
2484 | } | ||
2485 | |||
2486 | struct ext4_group_info { | 2469 | struct ext4_group_info { |
2487 | unsigned long bb_state; | 2470 | unsigned long bb_state; |
2488 | struct rb_root bb_free_root; | 2471 | struct rb_root bb_free_root; |