aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c205
1 files changed, 103 insertions, 102 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0afc8c1d8cf3..a0ab3754d0d6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -221,6 +221,7 @@ void ext4_delete_inode(struct inode *inode)
221 "couldn't extend journal (err %d)", err); 221 "couldn't extend journal (err %d)", err);
222 stop_handle: 222 stop_handle:
223 ext4_journal_stop(handle); 223 ext4_journal_stop(handle);
224 ext4_orphan_del(NULL, inode);
224 goto no_delete; 225 goto no_delete;
225 } 226 }
226 } 227 }
@@ -337,9 +338,11 @@ static int ext4_block_to_path(struct inode *inode,
337 return n; 338 return n;
338} 339}
339 340
340static int __ext4_check_blockref(const char *function, struct inode *inode, 341static int __ext4_check_blockref(const char *function, unsigned int line,
342 struct inode *inode,
341 __le32 *p, unsigned int max) 343 __le32 *p, unsigned int max)
342{ 344{
345 struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
343 __le32 *bref = p; 346 __le32 *bref = p;
344 unsigned int blk; 347 unsigned int blk;
345 348
@@ -348,8 +351,9 @@ static int __ext4_check_blockref(const char *function, struct inode *inode,
348 if (blk && 351 if (blk &&
349 unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb), 352 unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
350 blk, 1))) { 353 blk, 1))) {
351 ext4_error_inode(function, inode, 354 es->s_last_error_block = cpu_to_le64(blk);
352 "invalid block reference %u", blk); 355 ext4_error_inode(inode, function, line, blk,
356 "invalid block");
353 return -EIO; 357 return -EIO;
354 } 358 }
355 } 359 }
@@ -358,11 +362,13 @@ static int __ext4_check_blockref(const char *function, struct inode *inode,
358 362
359 363
360#define ext4_check_indirect_blockref(inode, bh) \ 364#define ext4_check_indirect_blockref(inode, bh) \
361 __ext4_check_blockref(__func__, inode, (__le32 *)(bh)->b_data, \ 365 __ext4_check_blockref(__func__, __LINE__, inode, \
366 (__le32 *)(bh)->b_data, \
362 EXT4_ADDR_PER_BLOCK((inode)->i_sb)) 367 EXT4_ADDR_PER_BLOCK((inode)->i_sb))
363 368
364#define ext4_check_inode_blockref(inode) \ 369#define ext4_check_inode_blockref(inode) \
365 __ext4_check_blockref(__func__, inode, EXT4_I(inode)->i_data, \ 370 __ext4_check_blockref(__func__, __LINE__, inode, \
371 EXT4_I(inode)->i_data, \
366 EXT4_NDIR_BLOCKS) 372 EXT4_NDIR_BLOCKS)
367 373
368/** 374/**
@@ -1128,20 +1134,24 @@ void ext4_da_update_reserve_space(struct inode *inode,
1128 ext4_discard_preallocations(inode); 1134 ext4_discard_preallocations(inode);
1129} 1135}
1130 1136
1131static int check_block_validity(struct inode *inode, const char *func, 1137static int __check_block_validity(struct inode *inode, const char *func,
1138 unsigned int line,
1132 struct ext4_map_blocks *map) 1139 struct ext4_map_blocks *map)
1133{ 1140{
1134 if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk, 1141 if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk,
1135 map->m_len)) { 1142 map->m_len)) {
1136 ext4_error_inode(func, inode, 1143 ext4_error_inode(inode, func, line, map->m_pblk,
1137 "lblock %lu mapped to illegal pblock %llu " 1144 "lblock %lu mapped to illegal pblock "
1138 "(length %d)", (unsigned long) map->m_lblk, 1145 "(length %d)", (unsigned long) map->m_lblk,
1139 map->m_pblk, map->m_len); 1146 map->m_len);
1140 return -EIO; 1147 return -EIO;
1141 } 1148 }
1142 return 0; 1149 return 0;
1143} 1150}
1144 1151
1152#define check_block_validity(inode, map) \
1153 __check_block_validity((inode), __func__, __LINE__, (map))
1154
1145/* 1155/*
1146 * Return the number of contiguous dirty pages in a given inode 1156 * Return the number of contiguous dirty pages in a given inode
1147 * starting at page frame idx. 1157 * starting at page frame idx.
@@ -1244,7 +1254,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
1244 up_read((&EXT4_I(inode)->i_data_sem)); 1254 up_read((&EXT4_I(inode)->i_data_sem));
1245 1255
1246 if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { 1256 if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
1247 int ret = check_block_validity(inode, __func__, map); 1257 int ret = check_block_validity(inode, map);
1248 if (ret != 0) 1258 if (ret != 0)
1249 return ret; 1259 return ret;
1250 } 1260 }
@@ -1324,9 +1334,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
1324 1334
1325 up_write((&EXT4_I(inode)->i_data_sem)); 1335 up_write((&EXT4_I(inode)->i_data_sem));
1326 if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { 1336 if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
1327 int ret = check_block_validity(inode, 1337 int ret = check_block_validity(inode, map);
1328 "ext4_map_blocks_after_alloc",
1329 map);
1330 if (ret != 0) 1338 if (ret != 0)
1331 return ret; 1339 return ret;
1332 } 1340 }
@@ -1519,9 +1527,25 @@ static int walk_page_buffers(handle_t *handle,
1519static int do_journal_get_write_access(handle_t *handle, 1527static int do_journal_get_write_access(handle_t *handle,
1520 struct buffer_head *bh) 1528 struct buffer_head *bh)
1521{ 1529{
1530 int dirty = buffer_dirty(bh);
1531 int ret;
1532
1522 if (!buffer_mapped(bh) || buffer_freed(bh)) 1533 if (!buffer_mapped(bh) || buffer_freed(bh))
1523 return 0; 1534 return 0;
1524 return ext4_journal_get_write_access(handle, bh); 1535 /*
1536 * __block_prepare_write() could have dirtied some buffers. Clean
1537 * the dirty bit as jbd2_journal_get_write_access() could complain
1538 * otherwise about fs integrity issues. Setting of the dirty bit
1539 * by __block_prepare_write() isn't a real problem here as we clear
1540 * the bit before releasing a page lock and thus writeback cannot
1541 * ever write the buffer.
1542 */
1543 if (dirty)
1544 clear_buffer_dirty(bh);
1545 ret = ext4_journal_get_write_access(handle, bh);
1546 if (!ret && dirty)
1547 ret = ext4_handle_dirty_metadata(handle, NULL, bh);
1548 return ret;
1525} 1549}
1526 1550
1527/* 1551/*
@@ -2194,7 +2218,7 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd)
2194 BUG_ON(!handle); 2218 BUG_ON(!handle);
2195 2219
2196 /* 2220 /*
2197 * Call ext4_get_blocks() to allocate any delayed allocation 2221 * Call ext4_map_blocks() to allocate any delayed allocation
2198 * blocks, or to convert an uninitialized extent to be 2222 * blocks, or to convert an uninitialized extent to be
2199 * initialized (in the case where we have written into 2223 * initialized (in the case where we have written into
2200 * one or more preallocated blocks). 2224 * one or more preallocated blocks).
@@ -2203,7 +2227,7 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd)
2203 * indicate that we are on the delayed allocation path. This 2227 * indicate that we are on the delayed allocation path. This
2204 * affects functions in many different parts of the allocation 2228 * affects functions in many different parts of the allocation
2205 * call path. This flag exists primarily because we don't 2229 * call path. This flag exists primarily because we don't
2206 * want to change *many* call functions, so ext4_get_blocks() 2230 * want to change *many* call functions, so ext4_map_blocks()
2207 * will set the magic i_delalloc_reserved_flag once the 2231 * will set the magic i_delalloc_reserved_flag once the
2208 * inode's allocation semaphore is taken. 2232 * inode's allocation semaphore is taken.
2209 * 2233 *
@@ -2221,6 +2245,8 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd)
2221 2245
2222 blks = ext4_map_blocks(handle, mpd->inode, &map, get_blocks_flags); 2246 blks = ext4_map_blocks(handle, mpd->inode, &map, get_blocks_flags);
2223 if (blks < 0) { 2247 if (blks < 0) {
2248 struct super_block *sb = mpd->inode->i_sb;
2249
2224 err = blks; 2250 err = blks;
2225 /* 2251 /*
2226 * If get block returns with error we simply 2252 * If get block returns with error we simply
@@ -2231,7 +2257,7 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd)
2231 return 0; 2257 return 0;
2232 2258
2233 if (err == -ENOSPC && 2259 if (err == -ENOSPC &&
2234 ext4_count_free_blocks(mpd->inode->i_sb)) { 2260 ext4_count_free_blocks(sb)) {
2235 mpd->retval = err; 2261 mpd->retval = err;
2236 return 0; 2262 return 0;
2237 } 2263 }
@@ -2243,16 +2269,17 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd)
2243 * writepage and writepages will again try to write 2269 * writepage and writepages will again try to write
2244 * the same. 2270 * the same.
2245 */ 2271 */
2246 ext4_msg(mpd->inode->i_sb, KERN_CRIT, 2272 if (!(EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)) {
2247 "delayed block allocation failed for inode %lu at " 2273 ext4_msg(sb, KERN_CRIT,
2248 "logical offset %llu with max blocks %zd with " 2274 "delayed block allocation failed for inode %lu "
2249 "error %d", mpd->inode->i_ino, 2275 "at logical offset %llu with max blocks %zd "
2250 (unsigned long long) next, 2276 "with error %d", mpd->inode->i_ino,
2251 mpd->b_size >> mpd->inode->i_blkbits, err); 2277 (unsigned long long) next,
2252 printk(KERN_CRIT "This should not happen!! " 2278 mpd->b_size >> mpd->inode->i_blkbits, err);
2253 "Data will be lost\n"); 2279 ext4_msg(sb, KERN_CRIT,
2254 if (err == -ENOSPC) { 2280 "This should not happen!! Data will be lost\n");
2255 ext4_print_free_blocks(mpd->inode); 2281 if (err == -ENOSPC)
2282 ext4_print_free_blocks(mpd->inode);
2256 } 2283 }
2257 /* invalidate all the pages */ 2284 /* invalidate all the pages */
2258 ext4_da_block_invalidatepages(mpd, next, 2285 ext4_da_block_invalidatepages(mpd, next,
@@ -2320,7 +2347,7 @@ static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
2320 * XXX Don't go larger than mballoc is willing to allocate 2347 * XXX Don't go larger than mballoc is willing to allocate
2321 * This is a stopgap solution. We eventually need to fold 2348 * This is a stopgap solution. We eventually need to fold
2322 * mpage_da_submit_io() into this function and then call 2349 * mpage_da_submit_io() into this function and then call
2323 * ext4_get_blocks() multiple times in a loop 2350 * ext4_map_blocks() multiple times in a loop
2324 */ 2351 */
2325 if (nrblocks >= 8*1024*1024/mpd->inode->i_sb->s_blocksize) 2352 if (nrblocks >= 8*1024*1024/mpd->inode->i_sb->s_blocksize)
2326 goto flush_it; 2353 goto flush_it;
@@ -2553,18 +2580,16 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
2553/* 2580/*
2554 * This function is used as a standard get_block_t calback function 2581 * This function is used as a standard get_block_t calback function
2555 * when there is no desire to allocate any blocks. It is used as a 2582 * when there is no desire to allocate any blocks. It is used as a
2556 * callback function for block_prepare_write(), nobh_writepage(), and 2583 * callback function for block_prepare_write() and block_write_full_page().
2557 * block_write_full_page(). These functions should only try to map a 2584 * These functions should only try to map a single block at a time.
2558 * single block at a time.
2559 * 2585 *
2560 * Since this function doesn't do block allocations even if the caller 2586 * Since this function doesn't do block allocations even if the caller
2561 * requests it by passing in create=1, it is critically important that 2587 * requests it by passing in create=1, it is critically important that
2562 * any caller checks to make sure that any buffer heads are returned 2588 * any caller checks to make sure that any buffer heads are returned
2563 * by this function are either all already mapped or marked for 2589 * by this function are either all already mapped or marked for
2564 * delayed allocation before calling nobh_writepage() or 2590 * delayed allocation before calling block_write_full_page(). Otherwise,
2565 * block_write_full_page(). Otherwise, b_blocknr could be left 2591 * b_blocknr could be left unitialized, and the page write functions will
2566 * unitialized, and the page write functions will be taken by 2592 * be taken by surprise.
2567 * surprise.
2568 */ 2593 */
2569static int noalloc_get_block_write(struct inode *inode, sector_t iblock, 2594static int noalloc_get_block_write(struct inode *inode, sector_t iblock,
2570 struct buffer_head *bh_result, int create) 2595 struct buffer_head *bh_result, int create)
@@ -2749,9 +2774,7 @@ static int ext4_writepage(struct page *page,
2749 return __ext4_journalled_writepage(page, len); 2774 return __ext4_journalled_writepage(page, len);
2750 } 2775 }
2751 2776
2752 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) 2777 if (page_bufs && buffer_uninit(page_bufs)) {
2753 ret = nobh_writepage(page, noalloc_get_block_write, wbc);
2754 else if (page_bufs && buffer_uninit(page_bufs)) {
2755 ext4_set_bh_endio(page_bufs, inode); 2778 ext4_set_bh_endio(page_bufs, inode);
2756 ret = block_write_full_page_endio(page, noalloc_get_block_write, 2779 ret = block_write_full_page_endio(page, noalloc_get_block_write,
2757 wbc, ext4_end_io_buffer_write); 2780 wbc, ext4_end_io_buffer_write);
@@ -3146,13 +3169,10 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
3146 int ret, retries = 0; 3169 int ret, retries = 0;
3147 struct page *page; 3170 struct page *page;
3148 pgoff_t index; 3171 pgoff_t index;
3149 unsigned from, to;
3150 struct inode *inode = mapping->host; 3172 struct inode *inode = mapping->host;
3151 handle_t *handle; 3173 handle_t *handle;
3152 3174
3153 index = pos >> PAGE_CACHE_SHIFT; 3175 index = pos >> PAGE_CACHE_SHIFT;
3154 from = pos & (PAGE_CACHE_SIZE - 1);
3155 to = from + len;
3156 3176
3157 if (ext4_nonda_switch(inode->i_sb)) { 3177 if (ext4_nonda_switch(inode->i_sb)) {
3158 *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; 3178 *fsdata = (void *)FALL_BACK_TO_NONDELALLOC;
@@ -3668,6 +3688,8 @@ static int ext4_end_io_nolock(ext4_io_end_t *io)
3668 return ret; 3688 return ret;
3669 } 3689 }
3670 3690
3691 if (io->iocb)
3692 aio_complete(io->iocb, io->result, 0);
3671 /* clear the DIO AIO unwritten flag */ 3693 /* clear the DIO AIO unwritten flag */
3672 io->flag = 0; 3694 io->flag = 0;
3673 return ret; 3695 return ret;
@@ -3767,6 +3789,8 @@ static ext4_io_end_t *ext4_init_io_end (struct inode *inode, gfp_t flags)
3767 io->offset = 0; 3789 io->offset = 0;
3768 io->size = 0; 3790 io->size = 0;
3769 io->page = NULL; 3791 io->page = NULL;
3792 io->iocb = NULL;
3793 io->result = 0;
3770 INIT_WORK(&io->work, ext4_end_io_work); 3794 INIT_WORK(&io->work, ext4_end_io_work);
3771 INIT_LIST_HEAD(&io->list); 3795 INIT_LIST_HEAD(&io->list);
3772 } 3796 }
@@ -3796,12 +3820,18 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
3796 if (io_end->flag != EXT4_IO_UNWRITTEN){ 3820 if (io_end->flag != EXT4_IO_UNWRITTEN){
3797 ext4_free_io_end(io_end); 3821 ext4_free_io_end(io_end);
3798 iocb->private = NULL; 3822 iocb->private = NULL;
3799 goto out; 3823out:
3824 if (is_async)
3825 aio_complete(iocb, ret, 0);
3826 return;
3800 } 3827 }
3801 3828
3802 io_end->offset = offset; 3829 io_end->offset = offset;
3803 io_end->size = size; 3830 io_end->size = size;
3804 io_end->flag = EXT4_IO_UNWRITTEN; 3831 if (is_async) {
3832 io_end->iocb = iocb;
3833 io_end->result = ret;
3834 }
3805 wq = EXT4_SB(io_end->inode->i_sb)->dio_unwritten_wq; 3835 wq = EXT4_SB(io_end->inode->i_sb)->dio_unwritten_wq;
3806 3836
3807 /* queue the work to convert unwritten extents to written */ 3837 /* queue the work to convert unwritten extents to written */
@@ -3813,9 +3843,6 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
3813 list_add_tail(&io_end->list, &ei->i_completed_io_list); 3843 list_add_tail(&io_end->list, &ei->i_completed_io_list);
3814 spin_unlock_irqrestore(&ei->i_completed_io_lock, flags); 3844 spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);
3815 iocb->private = NULL; 3845 iocb->private = NULL;
3816out:
3817 if (is_async)
3818 aio_complete(iocb, ret, 0);
3819} 3846}
3820 3847
3821static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate) 3848static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate)
@@ -3941,7 +3968,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3941 return -ENOMEM; 3968 return -ENOMEM;
3942 /* 3969 /*
3943 * we save the io structure for current async 3970 * we save the io structure for current async
3944 * direct IO, so that later ext4_get_blocks() 3971 * direct IO, so that later ext4_map_blocks()
3945 * could flag the io structure whether there 3972 * could flag the io structure whether there
3946 * is a unwritten extents needs to be converted 3973 * is a unwritten extents needs to be converted
3947 * when IO is completed. 3974 * when IO is completed.
@@ -4132,17 +4159,6 @@ int ext4_block_truncate_page(handle_t *handle,
4132 length = blocksize - (offset & (blocksize - 1)); 4159 length = blocksize - (offset & (blocksize - 1));
4133 iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); 4160 iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
4134 4161
4135 /*
4136 * For "nobh" option, we can only work if we don't need to
4137 * read-in the page - otherwise we create buffers to do the IO.
4138 */
4139 if (!page_has_buffers(page) && test_opt(inode->i_sb, NOBH) &&
4140 ext4_should_writeback_data(inode) && PageUptodate(page)) {
4141 zero_user(page, offset, length);
4142 set_page_dirty(page);
4143 goto unlock;
4144 }
4145
4146 if (!page_has_buffers(page)) 4162 if (!page_has_buffers(page))
4147 create_empty_buffers(page, blocksize, 0); 4163 create_empty_buffers(page, blocksize, 0);
4148 4164
@@ -4492,9 +4508,8 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
4492 * (should be rare). 4508 * (should be rare).
4493 */ 4509 */
4494 if (!bh) { 4510 if (!bh) {
4495 EXT4_ERROR_INODE(inode, 4511 EXT4_ERROR_INODE_BLOCK(inode, nr,
4496 "Read failure block=%llu", 4512 "Read failure");
4497 (unsigned long long) nr);
4498 continue; 4513 continue;
4499 } 4514 }
4500 4515
@@ -4506,27 +4521,6 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
4506 depth); 4521 depth);
4507 4522
4508 /* 4523 /*
4509 * We've probably journalled the indirect block several
4510 * times during the truncate. But it's no longer
4511 * needed and we now drop it from the transaction via
4512 * jbd2_journal_revoke().
4513 *
4514 * That's easy if it's exclusively part of this
4515 * transaction. But if it's part of the committing
4516 * transaction then jbd2_journal_forget() will simply
4517 * brelse() it. That means that if the underlying
4518 * block is reallocated in ext4_get_block(),
4519 * unmap_underlying_metadata() will find this block
4520 * and will try to get rid of it. damn, damn.
4521 *
4522 * If this block has already been committed to the
4523 * journal, a revoke record will be written. And
4524 * revoke records must be emitted *before* clearing
4525 * this block's bit in the bitmaps.
4526 */
4527 ext4_forget(handle, 1, inode, bh, bh->b_blocknr);
4528
4529 /*
4530 * Everything below this this pointer has been 4524 * Everything below this this pointer has been
4531 * released. Now let this top-of-subtree go. 4525 * released. Now let this top-of-subtree go.
4532 * 4526 *
@@ -4550,8 +4544,20 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
4550 blocks_for_truncate(inode)); 4544 blocks_for_truncate(inode));
4551 } 4545 }
4552 4546
4547 /*
4548 * The forget flag here is critical because if
4549 * we are journaling (and not doing data
4550 * journaling), we have to make sure a revoke
4551 * record is written to prevent the journal
4552 * replay from overwriting the (former)
4553 * indirect block if it gets reallocated as a
4554 * data block. This must happen in the same
4555 * transaction where the data blocks are
4556 * actually freed.
4557 */
4553 ext4_free_blocks(handle, inode, 0, nr, 1, 4558 ext4_free_blocks(handle, inode, 0, nr, 1,
4554 EXT4_FREE_BLOCKS_METADATA); 4559 EXT4_FREE_BLOCKS_METADATA|
4560 EXT4_FREE_BLOCKS_FORGET);
4555 4561
4556 if (parent_bh) { 4562 if (parent_bh) {
4557 /* 4563 /*
@@ -4809,8 +4815,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
4809 4815
4810 bh = sb_getblk(sb, block); 4816 bh = sb_getblk(sb, block);
4811 if (!bh) { 4817 if (!bh) {
4812 EXT4_ERROR_INODE(inode, "unable to read inode block - " 4818 EXT4_ERROR_INODE_BLOCK(inode, block,
4813 "block %llu", block); 4819 "unable to read itable block");
4814 return -EIO; 4820 return -EIO;
4815 } 4821 }
4816 if (!buffer_uptodate(bh)) { 4822 if (!buffer_uptodate(bh)) {
@@ -4908,8 +4914,8 @@ make_io:
4908 submit_bh(READ_META, bh); 4914 submit_bh(READ_META, bh);
4909 wait_on_buffer(bh); 4915 wait_on_buffer(bh);
4910 if (!buffer_uptodate(bh)) { 4916 if (!buffer_uptodate(bh)) {
4911 EXT4_ERROR_INODE(inode, "unable to read inode " 4917 EXT4_ERROR_INODE_BLOCK(inode, block,
4912 "block %llu", block); 4918 "unable to read itable block");
4913 brelse(bh); 4919 brelse(bh);
4914 return -EIO; 4920 return -EIO;
4915 } 4921 }
@@ -4980,7 +4986,7 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
4980 /* we are using combined 48 bit field */ 4986 /* we are using combined 48 bit field */
4981 i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 | 4987 i_blocks = ((u64)le16_to_cpu(raw_inode->i_blocks_high)) << 32 |
4982 le32_to_cpu(raw_inode->i_blocks_lo); 4988 le32_to_cpu(raw_inode->i_blocks_lo);
4983 if (ei->i_flags & EXT4_HUGE_FILE_FL) { 4989 if (ext4_test_inode_flag(inode, EXT4_INODE_HUGE_FILE)) {
4984 /* i_blocks represent file system block size */ 4990 /* i_blocks represent file system block size */
4985 return i_blocks << (inode->i_blkbits - 9); 4991 return i_blocks << (inode->i_blkbits - 9);
4986 } else { 4992 } else {
@@ -5076,7 +5082,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
5076 transaction_t *transaction; 5082 transaction_t *transaction;
5077 tid_t tid; 5083 tid_t tid;
5078 5084
5079 spin_lock(&journal->j_state_lock); 5085 read_lock(&journal->j_state_lock);
5080 if (journal->j_running_transaction) 5086 if (journal->j_running_transaction)
5081 transaction = journal->j_running_transaction; 5087 transaction = journal->j_running_transaction;
5082 else 5088 else
@@ -5085,7 +5091,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
5085 tid = transaction->t_tid; 5091 tid = transaction->t_tid;
5086 else 5092 else
5087 tid = journal->j_commit_sequence; 5093 tid = journal->j_commit_sequence;
5088 spin_unlock(&journal->j_state_lock); 5094 read_unlock(&journal->j_state_lock);
5089 ei->i_sync_tid = tid; 5095 ei->i_sync_tid = tid;
5090 ei->i_datasync_tid = tid; 5096 ei->i_datasync_tid = tid;
5091 } 5097 }
@@ -5130,7 +5136,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
5130 ei->i_file_acl); 5136 ei->i_file_acl);
5131 ret = -EIO; 5137 ret = -EIO;
5132 goto bad_inode; 5138 goto bad_inode;
5133 } else if (ei->i_flags & EXT4_EXTENTS_FL) { 5139 } else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
5134 if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 5140 if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
5135 (S_ISLNK(inode->i_mode) && 5141 (S_ISLNK(inode->i_mode) &&
5136 !ext4_inode_is_fast_symlink(inode))) 5142 !ext4_inode_is_fast_symlink(inode)))
@@ -5410,9 +5416,8 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
5410 if (wbc->sync_mode == WB_SYNC_ALL) 5416 if (wbc->sync_mode == WB_SYNC_ALL)
5411 sync_dirty_buffer(iloc.bh); 5417 sync_dirty_buffer(iloc.bh);
5412 if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { 5418 if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
5413 EXT4_ERROR_INODE(inode, 5419 EXT4_ERROR_INODE_BLOCK(inode, iloc.bh->b_blocknr,
5414 "IO error syncing inode (block=%llu)", 5420 "IO error syncing inode");
5415 (unsigned long long) iloc.bh->b_blocknr);
5416 err = -EIO; 5421 err = -EIO;
5417 } 5422 }
5418 brelse(iloc.bh); 5423 brelse(iloc.bh);
@@ -5487,10 +5492,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
5487 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { 5492 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
5488 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 5493 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
5489 5494
5490 if (attr->ia_size > sbi->s_bitmap_maxbytes) { 5495 if (attr->ia_size > sbi->s_bitmap_maxbytes)
5491 error = -EFBIG; 5496 return -EFBIG;
5492 goto err_out;
5493 }
5494 } 5497 }
5495 } 5498 }
5496 5499
@@ -5692,7 +5695,7 @@ int ext4_writepage_trans_blocks(struct inode *inode)
5692 * Calculate the journal credits for a chunk of data modification. 5695 * Calculate the journal credits for a chunk of data modification.
5693 * 5696 *
5694 * This is called from DIO, fallocate or whoever calling 5697 * This is called from DIO, fallocate or whoever calling
5695 * ext4_get_blocks() to map/allocate a chunk of contiguous disk blocks. 5698 * ext4_map_blocks() to map/allocate a chunk of contiguous disk blocks.
5696 * 5699 *
5697 * journal buffers for data blocks are not included here, as DIO 5700 * journal buffers for data blocks are not included here, as DIO
5698 * and fallocate do no need to journal data buffers. 5701 * and fallocate do no need to journal data buffers.
@@ -5758,7 +5761,6 @@ static int ext4_expand_extra_isize(struct inode *inode,
5758{ 5761{
5759 struct ext4_inode *raw_inode; 5762 struct ext4_inode *raw_inode;
5760 struct ext4_xattr_ibody_header *header; 5763 struct ext4_xattr_ibody_header *header;
5761 struct ext4_xattr_entry *entry;
5762 5764
5763 if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) 5765 if (EXT4_I(inode)->i_extra_isize >= new_extra_isize)
5764 return 0; 5766 return 0;
@@ -5766,7 +5768,6 @@ static int ext4_expand_extra_isize(struct inode *inode,
5766 raw_inode = ext4_raw_inode(&iloc); 5768 raw_inode = ext4_raw_inode(&iloc);
5767 5769
5768 header = IHDR(inode, raw_inode); 5770 header = IHDR(inode, raw_inode);
5769 entry = IFIRST(header);
5770 5771
5771 /* No extended attributes present */ 5772 /* No extended attributes present */
5772 if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) || 5773 if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) ||