inode.c (efc33ce197e4b6aaddf1eb2ba6293f51daf3c283) | inode.c (74d553aad7926ed05e05d9d5cff516a7b31375fc) |
---|---|
1/* 2 * linux/fs/ext4/inode.c 3 * 4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card@masi.ibp.fr) 6 * Laboratoire MASI - Institut Blaise Pascal 7 * Universite Pierre et Marie Curie (Paris VI) 8 * --- 1131 unchanged lines hidden (view full) --- 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 */ | 1/* 2 * linux/fs/ext4/inode.c 3 * 4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card@masi.ibp.fr) 6 * Laboratoire MASI - Institut Blaise Pascal 7 * Universite Pierre et Marie Curie (Paris VI) 8 * --- 1131 unchanged lines hidden (view full) --- 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 */ |
1148static int ext4_ordered_write_end(struct file *file, 1149 struct address_space *mapping, 1150 loff_t pos, unsigned len, unsigned copied, 1151 struct page *page, void *fsdata) | 1148static 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 | 1152{ 1153 handle_t *handle = ext4_journal_current_handle(); 1154 struct inode *inode = mapping->host; 1155 int ret = 0, ret2; 1156 |
1157 trace_ext4_ordered_write_end(inode, pos, len, copied); 1158 ret = ext4_jbd2_file_inode(handle, inode); 1159 1160 if (ret == 0) { 1161 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, 1162 page, fsdata); 1163 copied = ret2; 1164 if (pos + len > inode->i_size && ext4_can_truncate(inode)) 1165 /* if we have allocated more blocks and copied 1166 * less. We will have blocks allocated outside 1167 * inode->i_size. So truncate them 1168 */ 1169 ext4_orphan_add(handle, inode); 1170 if (ret2 < 0) 1171 ret = ret2; 1172 } else { 1173 unlock_page(page); 1174 page_cache_release(page); | 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 } |
1175 } 1176 | 1165 } 1166 |
1177 ret2 = ext4_journal_stop(handle); 1178 if (!ret) 1179 ret = ret2; 1180 1181 if (pos + len > inode->i_size) { 1182 ext4_truncate_failed_write(inode); 1183 /* 1184 * If truncate failed early the inode might still be 1185 * on the orphan list; we need to make sure the inode 1186 * is removed from the orphan list in that case. 1187 */ 1188 if (inode->i_nlink) 1189 ext4_orphan_del(NULL, inode); 1190 } 1191 1192 1193 return ret ? ret : copied; 1194} 1195 1196static int ext4_writeback_write_end(struct file *file, 1197 struct address_space *mapping, 1198 loff_t pos, unsigned len, unsigned copied, 1199 struct page *page, void *fsdata) 1200{ 1201 handle_t *handle = ext4_journal_current_handle(); 1202 struct inode *inode = mapping->host; 1203 int ret = 0, ret2; 1204 1205 trace_ext4_writeback_write_end(inode, pos, len, copied); 1206 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, 1207 page, fsdata); 1208 copied = ret2; | 1167 copied = ext4_generic_write_end(file, mapping, pos, len, copied, 1168 page, fsdata); 1169 if (copied < 0) 1170 ret = copied; |
1209 if (pos + len > inode->i_size && ext4_can_truncate(inode)) 1210 /* if we have allocated more blocks and copied 1211 * less. We will have blocks allocated outside 1212 * inode->i_size. So truncate them 1213 */ 1214 ext4_orphan_add(handle, inode); | 1171 if (pos + len > inode->i_size && ext4_can_truncate(inode)) 1172 /* if we have allocated more blocks and copied 1173 * less. We will have blocks allocated outside 1174 * inode->i_size. So truncate them 1175 */ 1176 ext4_orphan_add(handle, inode); |
1215 1216 if (ret2 < 0) 1217 ret = ret2; 1218 | 1177errout: |
1219 ret2 = ext4_journal_stop(handle); 1220 if (!ret) 1221 ret = ret2; 1222 1223 if (pos + len > inode->i_size) { 1224 ext4_truncate_failed_write(inode); 1225 /* 1226 * If truncate failed early the inode might still be --- 1586 unchanged lines hidden (view full) --- 2813{ 2814 struct inode *inode = mapping->host; 2815 int ret = 0, ret2; 2816 handle_t *handle = ext4_journal_current_handle(); 2817 loff_t new_i_size; 2818 unsigned long start, end; 2819 int write_mode = (int)(unsigned long)fsdata; 2820 | 1178 ret2 = ext4_journal_stop(handle); 1179 if (!ret) 1180 ret = ret2; 1181 1182 if (pos + len > inode->i_size) { 1183 ext4_truncate_failed_write(inode); 1184 /* 1185 * If truncate failed early the inode might still be --- 1586 unchanged lines hidden (view full) --- 2772{ 2773 struct inode *inode = mapping->host; 2774 int ret = 0, ret2; 2775 handle_t *handle = ext4_journal_current_handle(); 2776 loff_t new_i_size; 2777 unsigned long start, end; 2778 int write_mode = (int)(unsigned long)fsdata; 2779 |
2821 if (write_mode == FALL_BACK_TO_NONDELALLOC) { 2822 switch (ext4_inode_journal_mode(inode)) { 2823 case EXT4_INODE_ORDERED_DATA_MODE: 2824 return ext4_ordered_write_end(file, mapping, pos, 2825 len, copied, page, fsdata); 2826 case EXT4_INODE_WRITEBACK_DATA_MODE: 2827 return ext4_writeback_write_end(file, mapping, pos, 2828 len, copied, page, fsdata); 2829 default: 2830 BUG(); 2831 } 2832 } | 2780 if (write_mode == FALL_BACK_TO_NONDELALLOC) 2781 return ext4_write_end(file, mapping, pos, 2782 len, copied, page, fsdata); |
2833 2834 trace_ext4_da_write_end(inode, pos, len, copied); 2835 start = pos & (PAGE_CACHE_SIZE - 1); 2836 end = start + copied - 1; 2837 2838 /* 2839 * generic_write_end() will run mark_inode_dirty() if i_size 2840 * changes. So let's piggyback the i_disksize mark_inode_dirty --- 488 unchanged lines hidden (view full) --- 3329 * is called, propagate that into the buffers appropriately. 3330 */ 3331static int ext4_journalled_set_page_dirty(struct page *page) 3332{ 3333 SetPageChecked(page); 3334 return __set_page_dirty_nobuffers(page); 3335} 3336 | 2783 2784 trace_ext4_da_write_end(inode, pos, len, copied); 2785 start = pos & (PAGE_CACHE_SIZE - 1); 2786 end = start + copied - 1; 2787 2788 /* 2789 * generic_write_end() will run mark_inode_dirty() if i_size 2790 * changes. So let's piggyback the i_disksize mark_inode_dirty --- 488 unchanged lines hidden (view full) --- 3279 * is called, propagate that into the buffers appropriately. 3280 */ 3281static int ext4_journalled_set_page_dirty(struct page *page) 3282{ 3283 SetPageChecked(page); 3284 return __set_page_dirty_nobuffers(page); 3285} 3286 |
3337static const struct address_space_operations ext4_ordered_aops = { | 3287static const struct address_space_operations ext4_aops = { |
3338 .readpage = ext4_readpage, 3339 .readpages = ext4_readpages, 3340 .writepage = ext4_writepage, 3341 .write_begin = ext4_write_begin, | 3288 .readpage = ext4_readpage, 3289 .readpages = ext4_readpages, 3290 .writepage = ext4_writepage, 3291 .write_begin = ext4_write_begin, |
3342 .write_end = ext4_ordered_write_end, | 3292 .write_end = ext4_write_end, |
3343 .bmap = ext4_bmap, 3344 .invalidatepage = ext4_invalidatepage, 3345 .releasepage = ext4_releasepage, 3346 .direct_IO = ext4_direct_IO, 3347 .migratepage = buffer_migrate_page, 3348 .is_partially_uptodate = block_is_partially_uptodate, 3349 .error_remove_page = generic_error_remove_page, 3350}; 3351 | 3293 .bmap = ext4_bmap, 3294 .invalidatepage = ext4_invalidatepage, 3295 .releasepage = ext4_releasepage, 3296 .direct_IO = ext4_direct_IO, 3297 .migratepage = buffer_migrate_page, 3298 .is_partially_uptodate = block_is_partially_uptodate, 3299 .error_remove_page = generic_error_remove_page, 3300}; 3301 |
3352static const struct address_space_operations ext4_writeback_aops = { 3353 .readpage = ext4_readpage, 3354 .readpages = ext4_readpages, 3355 .writepage = ext4_writepage, 3356 .write_begin = ext4_write_begin, 3357 .write_end = ext4_writeback_write_end, 3358 .bmap = ext4_bmap, 3359 .invalidatepage = ext4_invalidatepage, 3360 .releasepage = ext4_releasepage, 3361 .direct_IO = ext4_direct_IO, 3362 .migratepage = buffer_migrate_page, 3363 .is_partially_uptodate = block_is_partially_uptodate, 3364 .error_remove_page = generic_error_remove_page, 3365}; 3366 | |
3367static const struct address_space_operations ext4_journalled_aops = { 3368 .readpage = ext4_readpage, 3369 .readpages = ext4_readpages, 3370 .writepage = ext4_writepage, 3371 .write_begin = ext4_write_begin, 3372 .write_end = ext4_journalled_write_end, 3373 .set_page_dirty = ext4_journalled_set_page_dirty, 3374 .bmap = ext4_bmap, --- 19 unchanged lines hidden (view full) --- 3394 .is_partially_uptodate = block_is_partially_uptodate, 3395 .error_remove_page = generic_error_remove_page, 3396}; 3397 3398void ext4_set_aops(struct inode *inode) 3399{ 3400 switch (ext4_inode_journal_mode(inode)) { 3401 case EXT4_INODE_ORDERED_DATA_MODE: | 3302static const struct address_space_operations ext4_journalled_aops = { 3303 .readpage = ext4_readpage, 3304 .readpages = ext4_readpages, 3305 .writepage = ext4_writepage, 3306 .write_begin = ext4_write_begin, 3307 .write_end = ext4_journalled_write_end, 3308 .set_page_dirty = ext4_journalled_set_page_dirty, 3309 .bmap = ext4_bmap, --- 19 unchanged lines hidden (view full) --- 3329 .is_partially_uptodate = block_is_partially_uptodate, 3330 .error_remove_page = generic_error_remove_page, 3331}; 3332 3333void ext4_set_aops(struct inode *inode) 3334{ 3335 switch (ext4_inode_journal_mode(inode)) { 3336 case EXT4_INODE_ORDERED_DATA_MODE: |
3402 if (test_opt(inode->i_sb, DELALLOC)) 3403 inode->i_mapping->a_ops = &ext4_da_aops; 3404 else 3405 inode->i_mapping->a_ops = &ext4_ordered_aops; | 3337 ext4_set_inode_state(inode, EXT4_STATE_ORDERED_MODE); |
3406 break; 3407 case EXT4_INODE_WRITEBACK_DATA_MODE: | 3338 break; 3339 case EXT4_INODE_WRITEBACK_DATA_MODE: |
3408 if (test_opt(inode->i_sb, DELALLOC)) 3409 inode->i_mapping->a_ops = &ext4_da_aops; 3410 else 3411 inode->i_mapping->a_ops = &ext4_writeback_aops; | 3340 ext4_clear_inode_state(inode, EXT4_STATE_ORDERED_MODE); |
3412 break; 3413 case EXT4_INODE_JOURNAL_DATA_MODE: 3414 inode->i_mapping->a_ops = &ext4_journalled_aops; | 3341 break; 3342 case EXT4_INODE_JOURNAL_DATA_MODE: 3343 inode->i_mapping->a_ops = &ext4_journalled_aops; |
3415 break; | 3344 return; |
3416 default: 3417 BUG(); 3418 } | 3345 default: 3346 BUG(); 3347 } |
3348 if (test_opt(inode->i_sb, DELALLOC)) 3349 inode->i_mapping->a_ops = &ext4_da_aops; 3350 else 3351 inode->i_mapping->a_ops = &ext4_aops; |
|
3419} 3420 3421 3422/* 3423 * ext4_discard_partial_page_buffers() 3424 * Wrapper function for ext4_discard_partial_page_buffers_no_lock. 3425 * This function finds and locks the page containing the offset 3426 * "from" and passes it to ext4_discard_partial_page_buffers_no_lock. --- 1673 unchanged lines hidden --- | 3352} 3353 3354 3355/* 3356 * ext4_discard_partial_page_buffers() 3357 * Wrapper function for ext4_discard_partial_page_buffers_no_lock. 3358 * This function finds and locks the page containing the offset 3359 * "from" and passes it to ext4_discard_partial_page_buffers_no_lock. --- 1673 unchanged lines hidden --- |