diff options
author | Zheng Liu <wenqing.lz@taobao.com> | 2013-04-03 12:41:17 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-04-03 12:41:17 -0400 |
commit | eed4333f087b45e325d5b9ab29665d82ae9cab88 (patch) | |
tree | 55ff1f894d7e0fd9b4f154d3a93e0391c39560ad /fs/ext4/inode.c | |
parent | 74d553aad7926ed05e05d9d5cff516a7b31375fc (diff) |
ext4: fold ext4_generic_write_end() into ext4_write_end()
After collapsing the handling of data ordered and data writeback
codepath, ext4_generic_write_end() has only one caller,
ext4_write_end(). So we fold it into ext4_write_end().
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4ee69270a48a..a4ffb470fbf3 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -1087,14 +1087,32 @@ static int write_end_fn(handle_t *handle, struct buffer_head *bh) | |||
1087 | return ext4_handle_dirty_metadata(handle, NULL, bh); | 1087 | return ext4_handle_dirty_metadata(handle, NULL, bh); |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | static int ext4_generic_write_end(struct file *file, | 1090 | /* |
1091 | struct address_space *mapping, | 1091 | * We need to pick up the new inode size which generic_commit_write gave us |
1092 | loff_t pos, unsigned len, unsigned copied, | 1092 | * `file' can be NULL - eg, when called from page_symlink(). |
1093 | struct page *page, void *fsdata) | 1093 | * |
1094 | * ext4 never places buffers on inode->i_mapping->private_list. metadata | ||
1095 | * buffers are managed internally. | ||
1096 | */ | ||
1097 | static int ext4_write_end(struct file *file, | ||
1098 | struct address_space *mapping, | ||
1099 | loff_t pos, unsigned len, unsigned copied, | ||
1100 | struct page *page, void *fsdata) | ||
1094 | { | 1101 | { |
1095 | int i_size_changed = 0; | ||
1096 | struct inode *inode = mapping->host; | ||
1097 | handle_t *handle = ext4_journal_current_handle(); | 1102 | handle_t *handle = ext4_journal_current_handle(); |
1103 | struct inode *inode = mapping->host; | ||
1104 | int ret = 0, ret2; | ||
1105 | int i_size_changed = 0; | ||
1106 | |||
1107 | trace_ext4_write_end(inode, pos, len, copied); | ||
1108 | if (ext4_test_inode_state(inode, EXT4_STATE_ORDERED_MODE)) { | ||
1109 | ret = ext4_jbd2_file_inode(handle, inode); | ||
1110 | if (ret) { | ||
1111 | unlock_page(page); | ||
1112 | page_cache_release(page); | ||
1113 | goto errout; | ||
1114 | } | ||
1115 | } | ||
1098 | 1116 | ||
1099 | if (ext4_has_inline_data(inode)) | 1117 | if (ext4_has_inline_data(inode)) |
1100 | copied = ext4_write_inline_data_end(inode, pos, len, | 1118 | copied = ext4_write_inline_data_end(inode, pos, len, |
@@ -1105,7 +1123,7 @@ static int ext4_generic_write_end(struct file *file, | |||
1105 | 1123 | ||
1106 | /* | 1124 | /* |
1107 | * No need to use i_size_read() here, the i_size | 1125 | * No need to use i_size_read() here, the i_size |
1108 | * cannot change under us because we hold i_mutex. | 1126 | * cannot change under us because we hole i_mutex. |
1109 | * | 1127 | * |
1110 | * But it's important to update i_size while still holding page lock: | 1128 | * But it's important to update i_size while still holding page lock: |
1111 | * page writeout could otherwise come in and zero beyond i_size. | 1129 | * page writeout could otherwise come in and zero beyond i_size. |
@@ -1115,10 +1133,10 @@ static int ext4_generic_write_end(struct file *file, | |||
1115 | i_size_changed = 1; | 1133 | i_size_changed = 1; |
1116 | } | 1134 | } |
1117 | 1135 | ||
1118 | if (pos + copied > EXT4_I(inode)->i_disksize) { | 1136 | if (pos + copied > EXT4_I(inode)->i_disksize) { |
1119 | /* We need to mark inode dirty even if | 1137 | /* We need to mark inode dirty even if |
1120 | * new_i_size is less that inode->i_size | 1138 | * new_i_size is less that inode->i_size |
1121 | * bu greater than i_disksize.(hint delalloc) | 1139 | * but greater than i_disksize. (hint delalloc) |
1122 | */ | 1140 | */ |
1123 | ext4_update_i_disksize(inode, (pos + copied)); | 1141 | ext4_update_i_disksize(inode, (pos + copied)); |
1124 | i_size_changed = 1; | 1142 | i_size_changed = 1; |
@@ -1135,37 +1153,6 @@ static int ext4_generic_write_end(struct file *file, | |||
1135 | if (i_size_changed) | 1153 | if (i_size_changed) |
1136 | ext4_mark_inode_dirty(handle, inode); | 1154 | ext4_mark_inode_dirty(handle, inode); |
1137 | 1155 | ||
1138 | return copied; | ||
1139 | } | ||
1140 | |||
1141 | /* | ||
1142 | * We need to pick up the new inode size which generic_commit_write gave us | ||
1143 | * `file' can be NULL - eg, when called from page_symlink(). | ||
1144 | * | ||
1145 | * ext4 never places buffers on inode->i_mapping->private_list. metadata | ||
1146 | * buffers are managed internally. | ||
1147 | */ | ||
1148 | static int ext4_write_end(struct file *file, | ||
1149 | struct address_space *mapping, | ||
1150 | loff_t pos, unsigned len, unsigned copied, | ||
1151 | struct page *page, void *fsdata) | ||
1152 | { | ||
1153 | handle_t *handle = ext4_journal_current_handle(); | ||
1154 | struct inode *inode = mapping->host; | ||
1155 | int ret = 0, ret2; | ||
1156 | |||
1157 | trace_ext4_write_end(inode, pos, len, copied); | ||
1158 | if (ext4_test_inode_state(inode, EXT4_STATE_ORDERED_MODE)) { | ||
1159 | ret = ext4_jbd2_file_inode(handle, inode); | ||
1160 | if (ret) { | ||
1161 | unlock_page(page); | ||
1162 | page_cache_release(page); | ||
1163 | goto errout; | ||
1164 | } | ||
1165 | } | ||
1166 | |||
1167 | copied = ext4_generic_write_end(file, mapping, pos, len, copied, | ||
1168 | page, fsdata); | ||
1169 | if (copied < 0) | 1156 | if (copied < 0) |
1170 | ret = copied; | 1157 | ret = copied; |
1171 | if (pos + len > inode->i_size && ext4_can_truncate(inode)) | 1158 | if (pos + len > inode->i_size && ext4_can_truncate(inode)) |