extents.c (e8b83d9303317fb068ad83d87991b610fe990ed5) extents.c (4f224b8b7be6856a3ceaf7f9d9c1860d467174ae)
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 *

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

3910 }
3911
3912 return allocated_clusters;
3913}
3914
3915static int
3916convert_initialized_extent(handle_t *handle, struct inode *inode,
3917 struct ext4_map_blocks *map,
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 *

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

3910 }
3911
3912 return allocated_clusters;
3913}
3914
3915static int
3916convert_initialized_extent(handle_t *handle, struct inode *inode,
3917 struct ext4_map_blocks *map,
3918 struct ext4_ext_path *path, int flags,
3918 struct ext4_ext_path **ppath, int flags,
3919 unsigned int allocated, ext4_fsblk_t newblock)
3920{
3919 unsigned int allocated, ext4_fsblk_t newblock)
3920{
3921 struct ext4_ext_path *path = *ppath;
3921 struct ext4_extent *ex;
3922 ext4_lblk_t ee_block;
3923 unsigned int ee_len;
3924 int depth;
3925 int err = 0;
3926
3927 /*
3928 * Make sure that the extent is no bigger than we support with

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

3941 (unsigned long long)ee_block, ee_len);
3942
3943 if (ee_block != map->m_lblk || ee_len > map->m_len) {
3944 err = ext4_split_convert_extents(handle, inode, map, path,
3945 EXT4_GET_BLOCKS_CONVERT_UNWRITTEN);
3946 if (err < 0)
3947 return err;
3948 ext4_ext_drop_refs(path);
3922 struct ext4_extent *ex;
3923 ext4_lblk_t ee_block;
3924 unsigned int ee_len;
3925 int depth;
3926 int err = 0;
3927
3928 /*
3929 * Make sure that the extent is no bigger than we support with

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

3942 (unsigned long long)ee_block, ee_len);
3943
3944 if (ee_block != map->m_lblk || ee_len > map->m_len) {
3945 err = ext4_split_convert_extents(handle, inode, map, path,
3946 EXT4_GET_BLOCKS_CONVERT_UNWRITTEN);
3947 if (err < 0)
3948 return err;
3949 ext4_ext_drop_refs(path);
3949 path = ext4_ext_find_extent(inode, map->m_lblk, &path,
3950 EXT4_EX_NOFREE_ON_ERR);
3950 path = ext4_ext_find_extent(inode, map->m_lblk, ppath, 0);
3951 if (IS_ERR(path))
3952 return PTR_ERR(path);
3953 depth = ext_depth(inode);
3954 ex = path[depth].p_ext;
3955 if (!ex) {
3956 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
3957 (unsigned long) map->m_lblk);
3958 return -EIO;

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

4320
4321 /*
4322 * If the extent is initialized check whether the
4323 * caller wants to convert it to unwritten.
4324 */
4325 if ((!ext4_ext_is_unwritten(ex)) &&
4326 (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) {
4327 allocated = convert_initialized_extent(
3951 if (IS_ERR(path))
3952 return PTR_ERR(path);
3953 depth = ext_depth(inode);
3954 ex = path[depth].p_ext;
3955 if (!ex) {
3956 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
3957 (unsigned long) map->m_lblk);
3958 return -EIO;

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

4320
4321 /*
4322 * If the extent is initialized check whether the
4323 * caller wants to convert it to unwritten.
4324 */
4325 if ((!ext4_ext_is_unwritten(ex)) &&
4326 (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) {
4327 allocated = convert_initialized_extent(
4328 handle, inode, map, path, flags,
4329 allocated, newblock);
4328 handle, inode, map, &path,
4329 flags, allocated, newblock);
4330 goto out2;
4331 } else if (!ext4_ext_is_unwritten(ex))
4332 goto out;
4333
4334 ret = ext4_ext_handle_unwritten_extents(
4335 handle, inode, map, path, flags,
4336 allocated, newblock);
4337 if (ret < 0)

--- 1372 unchanged lines hidden ---
4330 goto out2;
4331 } else if (!ext4_ext_is_unwritten(ex))
4332 goto out;
4333
4334 ret = ext4_ext_handle_unwritten_extents(
4335 handle, inode, map, path, flags,
4336 allocated, newblock);
4337 if (ret < 0)

--- 1372 unchanged lines hidden ---