extents.c (d895cb1af15c04c522a25c79cc429076987c089b) | extents.c (357b66fdc8ad4cea6e6336956a70742f961f0a4d) |
---|---|
1/* 2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com 3 * Written by Alex Tomas <alex@clusterfs.com> 4 * 5 * Architecture independence: 6 * Copyright (c) 2005, Bull S.A. 7 * Written by Pierre Peiffer <pierre.peiffer@bull.net> 8 * --- 2929 unchanged lines hidden (view full) --- 2938 2939 depth = ext_depth(inode); 2940 ex = path[depth].p_ext; 2941 ee_block = le32_to_cpu(ex->ee_block); 2942 ee_len = ext4_ext_get_actual_len(ex); 2943 newblock = split - ee_block + ext4_ext_pblock(ex); 2944 2945 BUG_ON(split < ee_block || split >= (ee_block + ee_len)); | 1/* 2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com 3 * Written by Alex Tomas <alex@clusterfs.com> 4 * 5 * Architecture independence: 6 * Copyright (c) 2005, Bull S.A. 7 * Written by Pierre Peiffer <pierre.peiffer@bull.net> 8 * --- 2929 unchanged lines hidden (view full) --- 2938 2939 depth = ext_depth(inode); 2940 ex = path[depth].p_ext; 2941 ee_block = le32_to_cpu(ex->ee_block); 2942 ee_len = ext4_ext_get_actual_len(ex); 2943 newblock = split - ee_block + ext4_ext_pblock(ex); 2944 2945 BUG_ON(split < ee_block || split >= (ee_block + ee_len)); |
2946 BUG_ON(!ext4_ext_is_uninitialized(ex) && 2947 split_flag & (EXT4_EXT_MAY_ZEROOUT | 2948 EXT4_EXT_MARK_UNINIT1 | 2949 EXT4_EXT_MARK_UNINIT2)); |
|
2946 2947 err = ext4_ext_get_access(handle, inode, path + depth); 2948 if (err) 2949 goto out; 2950 2951 if (split == ee_block) { 2952 /* 2953 * case b: block @split is the block that the extent begins with --- 102 unchanged lines hidden (view full) --- 3056 EXT4_EXT_MARK_UNINIT2; 3057 if (split_flag & EXT4_EXT_DATA_VALID2) 3058 split_flag1 |= EXT4_EXT_DATA_VALID1; 3059 err = ext4_split_extent_at(handle, inode, path, 3060 map->m_lblk + map->m_len, split_flag1, flags1); 3061 if (err) 3062 goto out; 3063 } | 2950 2951 err = ext4_ext_get_access(handle, inode, path + depth); 2952 if (err) 2953 goto out; 2954 2955 if (split == ee_block) { 2956 /* 2957 * case b: block @split is the block that the extent begins with --- 102 unchanged lines hidden (view full) --- 3060 EXT4_EXT_MARK_UNINIT2; 3061 if (split_flag & EXT4_EXT_DATA_VALID2) 3062 split_flag1 |= EXT4_EXT_DATA_VALID1; 3063 err = ext4_split_extent_at(handle, inode, path, 3064 map->m_lblk + map->m_len, split_flag1, flags1); 3065 if (err) 3066 goto out; 3067 } |
3064 | 3068 /* 3069 * Update path is required because previous ext4_split_extent_at() may 3070 * result in split of original leaf or extent zeroout. 3071 */ |
3065 ext4_ext_drop_refs(path); 3066 path = ext4_ext_find_extent(inode, map->m_lblk, path); 3067 if (IS_ERR(path)) 3068 return PTR_ERR(path); | 3072 ext4_ext_drop_refs(path); 3073 path = ext4_ext_find_extent(inode, map->m_lblk, path); 3074 if (IS_ERR(path)) 3075 return PTR_ERR(path); |
3076 depth = ext_depth(inode); 3077 ex = path[depth].p_ext; 3078 uninitialized = ext4_ext_is_uninitialized(ex); 3079 split_flag1 = 0; |
|
3069 3070 if (map->m_lblk >= ee_block) { | 3080 3081 if (map->m_lblk >= ee_block) { |
3071 split_flag1 = split_flag & (EXT4_EXT_MAY_ZEROOUT | 3072 EXT4_EXT_DATA_VALID2); 3073 if (uninitialized) | 3082 split_flag1 = split_flag & EXT4_EXT_DATA_VALID2; 3083 if (uninitialized) { |
3074 split_flag1 |= EXT4_EXT_MARK_UNINIT1; | 3084 split_flag1 |= EXT4_EXT_MARK_UNINIT1; |
3075 if (split_flag & EXT4_EXT_MARK_UNINIT2) 3076 split_flag1 |= EXT4_EXT_MARK_UNINIT2; | 3085 split_flag1 |= split_flag & (EXT4_EXT_MAY_ZEROOUT | 3086 EXT4_EXT_MARK_UNINIT2); 3087 } |
3077 err = ext4_split_extent_at(handle, inode, path, 3078 map->m_lblk, split_flag1, flags); 3079 if (err) 3080 goto out; 3081 } 3082 3083 ext4_ext_show_leaf(inode, path); 3084out: --- 1219 unchanged lines hidden (view full) --- 4304 * preallocate space for a file. This implements ext4's fallocate file 4305 * operation, which gets called from sys_fallocate system call. 4306 * For block-mapped files, posix_fallocate should fall back to the method 4307 * of writing zeroes to the required new blocks (the same behavior which is 4308 * expected for file systems which do not support fallocate() system call). 4309 */ 4310long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 4311{ | 3088 err = ext4_split_extent_at(handle, inode, path, 3089 map->m_lblk, split_flag1, flags); 3090 if (err) 3091 goto out; 3092 } 3093 3094 ext4_ext_show_leaf(inode, path); 3095out: --- 1219 unchanged lines hidden (view full) --- 4315 * preallocate space for a file. This implements ext4's fallocate file 4316 * operation, which gets called from sys_fallocate system call. 4317 * For block-mapped files, posix_fallocate should fall back to the method 4318 * of writing zeroes to the required new blocks (the same behavior which is 4319 * expected for file systems which do not support fallocate() system call). 4320 */ 4321long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) 4322{ |
4312 struct inode *inode = file_inode(file); | 4323 struct inode *inode = file->f_path.dentry->d_inode; |
4313 handle_t *handle; 4314 loff_t new_size; 4315 unsigned int max_blocks; 4316 int ret = 0; 4317 int ret2 = 0; 4318 int retries = 0; 4319 int flags; 4320 struct ext4_map_blocks map; --- 245 unchanged lines hidden (view full) --- 4566 * @inode: The inode of the file to punch a hole in 4567 * @offset: The starting byte offset of the hole 4568 * @length: The length of the hole 4569 * 4570 * Returns the number of blocks removed or negative on err 4571 */ 4572int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) 4573{ | 4324 handle_t *handle; 4325 loff_t new_size; 4326 unsigned int max_blocks; 4327 int ret = 0; 4328 int ret2 = 0; 4329 int retries = 0; 4330 int flags; 4331 struct ext4_map_blocks map; --- 245 unchanged lines hidden (view full) --- 4577 * @inode: The inode of the file to punch a hole in 4578 * @offset: The starting byte offset of the hole 4579 * @length: The length of the hole 4580 * 4581 * Returns the number of blocks removed or negative on err 4582 */ 4583int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) 4584{ |
4574 struct inode *inode = file_inode(file); | 4585 struct inode *inode = file->f_path.dentry->d_inode; |
4575 struct super_block *sb = inode->i_sb; 4576 ext4_lblk_t first_block, stop_block; 4577 struct address_space *mapping = inode->i_mapping; 4578 handle_t *handle; 4579 loff_t first_page, last_page, page_len; 4580 loff_t first_page_offset, last_page_offset; 4581 int credits, err = 0; 4582 --- 203 unchanged lines hidden --- | 4586 struct super_block *sb = inode->i_sb; 4587 ext4_lblk_t first_block, stop_block; 4588 struct address_space *mapping = inode->i_mapping; 4589 handle_t *handle; 4590 loff_t first_page, last_page, page_len; 4591 loff_t first_page_offset, last_page_offset; 4592 int credits, err = 0; 4593 --- 203 unchanged lines hidden --- |