inode.c (0713ed0cde76438d05849f1537d3aab46e099475) | inode.c (eb3544c6fc6642c9037817980d8a9dc9df44aa45) |
---|---|
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 * --- 3924 unchanged lines hidden (view full) --- 3933 * ext4_truncate() run will find them and release them. 3934 */ 3935void ext4_truncate(struct inode *inode) 3936{ 3937 struct ext4_inode_info *ei = EXT4_I(inode); 3938 unsigned int credits; 3939 handle_t *handle; 3940 struct address_space *mapping = inode->i_mapping; | 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 * --- 3924 unchanged lines hidden (view full) --- 3933 * ext4_truncate() run will find them and release them. 3934 */ 3935void ext4_truncate(struct inode *inode) 3936{ 3937 struct ext4_inode_info *ei = EXT4_I(inode); 3938 unsigned int credits; 3939 handle_t *handle; 3940 struct address_space *mapping = inode->i_mapping; |
3941 loff_t page_len; | |
3942 3943 /* 3944 * There is a possibility that we're either freeing the inode 3945 * or it completely new indode. In those cases we might not 3946 * have i_mutex locked because it's not necessary. 3947 */ 3948 if (!(inode->i_state & (I_NEW|I_FREEING))) 3949 WARN_ON(!mutex_is_locked(&inode->i_mutex)); --- 27 unchanged lines hidden (view full) --- 3977 credits = ext4_blocks_for_truncate(inode); 3978 3979 handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits); 3980 if (IS_ERR(handle)) { 3981 ext4_std_error(inode->i_sb, PTR_ERR(handle)); 3982 return; 3983 } 3984 | 3941 3942 /* 3943 * There is a possibility that we're either freeing the inode 3944 * or it completely new indode. In those cases we might not 3945 * have i_mutex locked because it's not necessary. 3946 */ 3947 if (!(inode->i_state & (I_NEW|I_FREEING))) 3948 WARN_ON(!mutex_is_locked(&inode->i_mutex)); --- 27 unchanged lines hidden (view full) --- 3976 credits = ext4_blocks_for_truncate(inode); 3977 3978 handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits); 3979 if (IS_ERR(handle)) { 3980 ext4_std_error(inode->i_sb, PTR_ERR(handle)); 3981 return; 3982 } 3983 |
3985 if (inode->i_size % PAGE_CACHE_SIZE != 0) { 3986 page_len = PAGE_CACHE_SIZE - 3987 (inode->i_size & (PAGE_CACHE_SIZE - 1)); | 3984 if (inode->i_size & (inode->i_sb->s_blocksize - 1)) 3985 ext4_block_truncate_page(handle, mapping, inode->i_size); |
3988 | 3986 |
3989 if (ext4_discard_partial_page_buffers(handle, 3990 mapping, inode->i_size, page_len, 0)) 3991 goto out_stop; 3992 } 3993 | |
3994 /* 3995 * We add the inode to the orphan list, so that if this 3996 * truncate spans multiple transactions, and we crash, we will 3997 * resume the truncate when the filesystem recovers. It also 3998 * marks the inode dirty, to catch the new size. 3999 * 4000 * Implication: the file must always be in a sane, consistent 4001 * truncatable state while each transaction commits. --- 1422 unchanged lines hidden --- | 3987 /* 3988 * We add the inode to the orphan list, so that if this 3989 * truncate spans multiple transactions, and we crash, we will 3990 * resume the truncate when the filesystem recovers. It also 3991 * marks the inode dirty, to catch the new size. 3992 * 3993 * Implication: the file must always be in a sane, consistent 3994 * truncatable state while each transaction commits. --- 1422 unchanged lines hidden --- |