Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163687
b: refs/heads/master
c: c40ce3c
h: refs/heads/master
i:
  163685: ebe440d
  163683: 95ecc1e
  163679: 697e03b
v: v3
  • Loading branch information
Akira Fujita authored and Theodore Ts'o committed Sep 16, 2009
1 parent f7044ad commit 455800f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 347fa6f1c7cb5df2b38d3c9167cfe242ce0cd1da
refs/heads/master: c40ce3c9ea97425a12d7e44031a98fe50add6fc1
46 changes: 37 additions & 9 deletions trunk/fs/ext4/move_extent.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,10 @@ mext_leaf_block(handle_t *handle, struct inode *orig_inode,
* @orig_off: block offset of original inode
* @donor_off: block offset of donor inode
* @max_count: the maximun length of extents
*
* Return 0 on success, or a negative error value on failure.
*/
static void
static int
mext_calc_swap_extents(struct ext4_extent *tmp_dext,
struct ext4_extent *tmp_oext,
ext4_lblk_t orig_off, ext4_lblk_t donor_off,
Expand All @@ -607,6 +609,19 @@ mext_calc_swap_extents(struct ext4_extent *tmp_dext,
ext4_lblk_t diff, orig_diff;
struct ext4_extent dext_old, oext_old;

BUG_ON(orig_off != donor_off);

/* original and donor extents have to cover the same block offset */
if (orig_off < le32_to_cpu(tmp_oext->ee_block) ||
le32_to_cpu(tmp_oext->ee_block) +
ext4_ext_get_actual_len(tmp_oext) - 1 < orig_off)
return -ENODATA;

if (orig_off < le32_to_cpu(tmp_dext->ee_block) ||
le32_to_cpu(tmp_dext->ee_block) +
ext4_ext_get_actual_len(tmp_dext) - 1 < orig_off)
return -ENODATA;

dext_old = *tmp_dext;
oext_old = *tmp_oext;

Expand Down Expand Up @@ -634,6 +649,8 @@ mext_calc_swap_extents(struct ext4_extent *tmp_dext,

copy_extent_status(&oext_old, tmp_dext);
copy_extent_status(&dext_old, tmp_oext);

return 0;
}

/**
Expand Down Expand Up @@ -690,8 +707,10 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,
dext = donor_path[depth].p_ext;
tmp_dext = *dext;

mext_calc_swap_extents(&tmp_dext, &tmp_oext, orig_off,
err = mext_calc_swap_extents(&tmp_dext, &tmp_oext, orig_off,
donor_off, count);
if (err)
goto out;

/* Loop for the donor extents */
while (1) {
Expand Down Expand Up @@ -760,9 +779,10 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,
}
tmp_dext = *dext;

mext_calc_swap_extents(&tmp_dext, &tmp_oext, orig_off,
donor_off,
count - replaced_count);
err = mext_calc_swap_extents(&tmp_dext, &tmp_oext, orig_off,
donor_off, count - replaced_count);
if (err)
goto out;
}

out:
Expand Down Expand Up @@ -1243,11 +1263,15 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
ext_cur = holecheck_path[depth].p_ext;

/*
* Get proper extent whose ee_block is beyond block_start
* if block_start was within the hole.
* Get proper starting location of block replacement if block_start was
* within the hole.
*/
if (le32_to_cpu(ext_cur->ee_block) +
ext4_ext_get_actual_len(ext_cur) - 1 < block_start) {
/*
* The hole exists between extents or the tail of
* original file.
*/
last_extent = mext_next_extent(orig_inode,
holecheck_path, &ext_cur);
if (last_extent < 0) {
Expand All @@ -1260,8 +1284,12 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
ret1 = last_extent;
goto out;
}
}
seq_start = block_start;
seq_start = le32_to_cpu(ext_cur->ee_block);
} else if (le32_to_cpu(ext_cur->ee_block) > block_start)
/* The hole exists at the beginning of original file. */
seq_start = le32_to_cpu(ext_cur->ee_block);
else
seq_start = block_start;

/* No blocks within the specified range. */
if (le32_to_cpu(ext_cur->ee_block) > block_end) {
Expand Down

0 comments on commit 455800f

Please sign in to comment.