inode.c (d67d1218344009970ba0deb7eb15a3984518ddd0) inode.c (0562e0bad483d10e9651fbb8f21dc3d0bad57374)
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 *

--- 959 unchanged lines hidden (view full) ---

968 Indirect *partial;
969 ext4_fsblk_t goal;
970 int indirect_blks;
971 int blocks_to_boundary = 0;
972 int depth;
973 int count = 0;
974 ext4_fsblk_t first_block = 0;
975
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 *

--- 959 unchanged lines hidden (view full) ---

968 Indirect *partial;
969 ext4_fsblk_t goal;
970 int indirect_blks;
971 int blocks_to_boundary = 0;
972 int depth;
973 int count = 0;
974 ext4_fsblk_t first_block = 0;
975
976 trace_ext4_ind_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);
976 J_ASSERT(!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)));
977 J_ASSERT(handle != NULL || (flags & EXT4_GET_BLOCKS_CREATE) == 0);
978 depth = ext4_block_to_path(inode, map->m_lblk, offsets,
979 &blocks_to_boundary);
980
981 if (depth == 0)
982 goto out;
983

--- 69 unchanged lines hidden (view full) ---

1053 partial = chain + depth - 1; /* the whole chain */
1054cleanup:
1055 while (partial > chain) {
1056 BUFFER_TRACE(partial->bh, "call brelse");
1057 brelse(partial->bh);
1058 partial--;
1059 }
1060out:
977 J_ASSERT(!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)));
978 J_ASSERT(handle != NULL || (flags & EXT4_GET_BLOCKS_CREATE) == 0);
979 depth = ext4_block_to_path(inode, map->m_lblk, offsets,
980 &blocks_to_boundary);
981
982 if (depth == 0)
983 goto out;
984

--- 69 unchanged lines hidden (view full) ---

1054 partial = chain + depth - 1; /* the whole chain */
1055cleanup:
1056 while (partial > chain) {
1057 BUFFER_TRACE(partial->bh, "call brelse");
1058 brelse(partial->bh);
1059 partial--;
1060 }
1061out:
1062 trace_ext4_ind_map_blocks_exit(inode, map->m_lblk,
1063 map->m_pblk, map->m_len, err);
1061 return err;
1062}
1063
1064#ifdef CONFIG_QUOTA
1065qsize_t *ext4_get_reserved_space(struct inode *inode)
1066{
1067 return &EXT4_I(inode)->i_reserved_quota;
1068}

--- 2305 unchanged lines hidden (view full) ---

3374 return 0;
3375 }
3376
3377 return generic_block_bmap(mapping, block, ext4_get_block);
3378}
3379
3380static int ext4_readpage(struct file *file, struct page *page)
3381{
1064 return err;
1065}
1066
1067#ifdef CONFIG_QUOTA
1068qsize_t *ext4_get_reserved_space(struct inode *inode)
1069{
1070 return &EXT4_I(inode)->i_reserved_quota;
1071}

--- 2305 unchanged lines hidden (view full) ---

3377 return 0;
3378 }
3379
3380 return generic_block_bmap(mapping, block, ext4_get_block);
3381}
3382
3383static int ext4_readpage(struct file *file, struct page *page)
3384{
3385 trace_ext4_readpage(page);
3382 return mpage_readpage(page, ext4_get_block);
3383}
3384
3385static int
3386ext4_readpages(struct file *file, struct address_space *mapping,
3387 struct list_head *pages, unsigned nr_pages)
3388{
3389 return mpage_readpages(mapping, pages, nr_pages, ext4_get_block);

--- 18 unchanged lines hidden (view full) ---

3408 bh = bh->b_this_page;
3409 } while (bh != head);
3410}
3411
3412static void ext4_invalidatepage(struct page *page, unsigned long offset)
3413{
3414 journal_t *journal = EXT4_JOURNAL(page->mapping->host);
3415
3386 return mpage_readpage(page, ext4_get_block);
3387}
3388
3389static int
3390ext4_readpages(struct file *file, struct address_space *mapping,
3391 struct list_head *pages, unsigned nr_pages)
3392{
3393 return mpage_readpages(mapping, pages, nr_pages, ext4_get_block);

--- 18 unchanged lines hidden (view full) ---

3412 bh = bh->b_this_page;
3413 } while (bh != head);
3414}
3415
3416static void ext4_invalidatepage(struct page *page, unsigned long offset)
3417{
3418 journal_t *journal = EXT4_JOURNAL(page->mapping->host);
3419
3420 trace_ext4_invalidatepage(page, offset);
3421
3416 /*
3417 * free any io_end structure allocated for buffers to be discarded
3418 */
3419 if (ext4_should_dioread_nolock(page->mapping->host))
3420 ext4_invalidatepage_free_endio(page, offset);
3421 /*
3422 * If it's a full truncate we just forget about the pending dirtying
3423 */

--- 5 unchanged lines hidden (view full) ---

3429 else
3430 block_invalidatepage(page, offset);
3431}
3432
3433static int ext4_releasepage(struct page *page, gfp_t wait)
3434{
3435 journal_t *journal = EXT4_JOURNAL(page->mapping->host);
3436
3422 /*
3423 * free any io_end structure allocated for buffers to be discarded
3424 */
3425 if (ext4_should_dioread_nolock(page->mapping->host))
3426 ext4_invalidatepage_free_endio(page, offset);
3427 /*
3428 * If it's a full truncate we just forget about the pending dirtying
3429 */

--- 5 unchanged lines hidden (view full) ---

3435 else
3436 block_invalidatepage(page, offset);
3437}
3438
3439static int ext4_releasepage(struct page *page, gfp_t wait)
3440{
3441 journal_t *journal = EXT4_JOURNAL(page->mapping->host);
3442
3443 trace_ext4_releasepage(page);
3444
3437 WARN_ON(PageChecked(page));
3438 if (!page_has_buffers(page))
3439 return 0;
3440 if (journal)
3441 return jbd2_journal_try_to_free_buffers(journal, page, wait);
3442 else
3443 return try_to_free_buffers(page);
3444}

--- 342 unchanged lines hidden (view full) ---

3787}
3788
3789static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
3790 const struct iovec *iov, loff_t offset,
3791 unsigned long nr_segs)
3792{
3793 struct file *file = iocb->ki_filp;
3794 struct inode *inode = file->f_mapping->host;
3445 WARN_ON(PageChecked(page));
3446 if (!page_has_buffers(page))
3447 return 0;
3448 if (journal)
3449 return jbd2_journal_try_to_free_buffers(journal, page, wait);
3450 else
3451 return try_to_free_buffers(page);
3452}

--- 342 unchanged lines hidden (view full) ---

3795}
3796
3797static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
3798 const struct iovec *iov, loff_t offset,
3799 unsigned long nr_segs)
3800{
3801 struct file *file = iocb->ki_filp;
3802 struct inode *inode = file->f_mapping->host;
3803 ssize_t ret;
3795
3804
3805 trace_ext4_direct_IO_enter(inode, offset, iov_length(iov, nr_segs), rw);
3796 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
3806 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
3797 return ext4_ext_direct_IO(rw, iocb, iov, offset, nr_segs);
3798
3799 return ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);
3807 ret = ext4_ext_direct_IO(rw, iocb, iov, offset, nr_segs);
3808 else
3809 ret = ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);
3810 trace_ext4_direct_IO_exit(inode, offset,
3811 iov_length(iov, nr_segs), rw, ret);
3812 return ret;
3800}
3801
3802/*
3803 * Pages can be marked dirty completely asynchronously from ext4's journalling
3804 * activity. By filemap_sync_pte(), try_to_unmap_one(), etc. We cannot do
3805 * much here because ->set_page_dirty is called under VFS locks. The page is
3806 * not necessarily locked.
3807 *

--- 612 unchanged lines hidden (view full) ---

4420 ext4_lblk_t offsets[4];
4421 Indirect chain[4];
4422 Indirect *partial;
4423 __le32 nr = 0;
4424 int n;
4425 ext4_lblk_t last_block;
4426 unsigned blocksize = inode->i_sb->s_blocksize;
4427
3813}
3814
3815/*
3816 * Pages can be marked dirty completely asynchronously from ext4's journalling
3817 * activity. By filemap_sync_pte(), try_to_unmap_one(), etc. We cannot do
3818 * much here because ->set_page_dirty is called under VFS locks. The page is
3819 * not necessarily locked.
3820 *

--- 612 unchanged lines hidden (view full) ---

4433 ext4_lblk_t offsets[4];
4434 Indirect chain[4];
4435 Indirect *partial;
4436 __le32 nr = 0;
4437 int n;
4438 ext4_lblk_t last_block;
4439 unsigned blocksize = inode->i_sb->s_blocksize;
4440
4441 trace_ext4_truncate_enter(inode);
4442
4428 if (!ext4_can_truncate(inode))
4429 return;
4430
4431 ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4432
4433 if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
4434 ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
4435
4436 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
4437 ext4_ext_truncate(inode);
4443 if (!ext4_can_truncate(inode))
4444 return;
4445
4446 ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
4447
4448 if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
4449 ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
4450
4451 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
4452 ext4_ext_truncate(inode);
4453 trace_ext4_truncate_exit(inode);
4438 return;
4439 }
4440
4441 handle = start_transaction(inode);
4442 if (IS_ERR(handle))
4443 return; /* AKPM: return what? */
4444
4445 last_block = (inode->i_size + blocksize-1)

--- 113 unchanged lines hidden (view full) ---

4559 * However, if this was a real unlink then we were called by
4560 * ext4_delete_inode(), and we allow that function to clean up the
4561 * orphan info for us.
4562 */
4563 if (inode->i_nlink)
4564 ext4_orphan_del(handle, inode);
4565
4566 ext4_journal_stop(handle);
4454 return;
4455 }
4456
4457 handle = start_transaction(inode);
4458 if (IS_ERR(handle))
4459 return; /* AKPM: return what? */
4460
4461 last_block = (inode->i_size + blocksize-1)

--- 113 unchanged lines hidden (view full) ---

4575 * However, if this was a real unlink then we were called by
4576 * ext4_delete_inode(), and we allow that function to clean up the
4577 * orphan info for us.
4578 */
4579 if (inode->i_nlink)
4580 ext4_orphan_del(handle, inode);
4581
4582 ext4_journal_stop(handle);
4583 trace_ext4_truncate_exit(inode);
4567}
4568
4569/*
4570 * ext4_get_inode_loc returns with an extra refcount against the inode's
4571 * underlying buffer_head on success. If 'in_mem' is true, we have all
4572 * data in memory that is needed to recreate the on-disk version of this
4573 * inode.
4574 */

--- 115 unchanged lines hidden (view full) ---

4690 sb_breadahead(sb, b++);
4691 }
4692
4693 /*
4694 * There are other valid inodes in the buffer, this inode
4695 * has in-inode xattrs, or we don't have this inode in memory.
4696 * Read the block from disk.
4697 */
4584}
4585
4586/*
4587 * ext4_get_inode_loc returns with an extra refcount against the inode's
4588 * underlying buffer_head on success. If 'in_mem' is true, we have all
4589 * data in memory that is needed to recreate the on-disk version of this
4590 * inode.
4591 */

--- 115 unchanged lines hidden (view full) ---

4707 sb_breadahead(sb, b++);
4708 }
4709
4710 /*
4711 * There are other valid inodes in the buffer, this inode
4712 * has in-inode xattrs, or we don't have this inode in memory.
4713 * Read the block from disk.
4714 */
4715 trace_ext4_load_inode(inode);
4698 get_bh(bh);
4699 bh->b_end_io = end_buffer_read_sync;
4700 submit_bh(READ_META, bh);
4701 wait_on_buffer(bh);
4702 if (!buffer_uptodate(bh)) {
4703 EXT4_ERROR_INODE_BLOCK(inode, block,
4704 "unable to read itable block");
4705 brelse(bh);

--- 1129 unchanged lines hidden ---
4716 get_bh(bh);
4717 bh->b_end_io = end_buffer_read_sync;
4718 submit_bh(READ_META, bh);
4719 wait_on_buffer(bh);
4720 if (!buffer_uptodate(bh)) {
4721 EXT4_ERROR_INODE_BLOCK(inode, block,
4722 "unable to read itable block");
4723 brelse(bh);

--- 1129 unchanged lines hidden ---