Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332501
b: refs/heads/master
c: 35075bb
h: refs/heads/master
i:
  332499: b7c110c
v: v3
  • Loading branch information
Alexander Block authored and Chris Mason committed Oct 1, 2012
1 parent f527419 commit 669c2dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 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: ee849c0472a9fe1dc09fe8390965d993b9c4e979
refs/heads/master: 35075bb046cc91f42a0e5336bdc07f3279061add
29 changes: 18 additions & 11 deletions trunk/fs/btrfs/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ static int find_extent_clone(struct send_ctx *sctx,
u64 extent_item_pos;
struct btrfs_file_extent_item *fi;
struct extent_buffer *eb = path->nodes[0];
struct backref_ctx backref_ctx;
struct backref_ctx *backref_ctx = NULL;
struct clone_root *cur_clone_root;
struct btrfs_key found_key;
struct btrfs_path *tmp_path;
Expand All @@ -1159,6 +1159,12 @@ static int find_extent_clone(struct send_ctx *sctx,
if (!tmp_path)
return -ENOMEM;

backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_NOFS);
if (!backref_ctx) {
ret = -ENOMEM;
goto out;
}

if (data_offset >= ino_size) {
/*
* There may be extents that lie behind the file's size.
Expand Down Expand Up @@ -1206,32 +1212,32 @@ static int find_extent_clone(struct send_ctx *sctx,
cur_clone_root->found_refs = 0;
}

backref_ctx.sctx = sctx;
backref_ctx.found = 0;
backref_ctx.cur_objectid = ino;
backref_ctx.cur_offset = data_offset;
backref_ctx.found_itself = 0;
backref_ctx.extent_len = num_bytes;
backref_ctx->sctx = sctx;
backref_ctx->found = 0;
backref_ctx->cur_objectid = ino;
backref_ctx->cur_offset = data_offset;
backref_ctx->found_itself = 0;
backref_ctx->extent_len = num_bytes;

/*
* The last extent of a file may be too large due to page alignment.
* We need to adjust extent_len in this case so that the checks in
* __iterate_backrefs work.
*/
if (data_offset + num_bytes >= ino_size)
backref_ctx.extent_len = ino_size - data_offset;
backref_ctx->extent_len = ino_size - data_offset;

/*
* Now collect all backrefs.
*/
extent_item_pos = logical - found_key.objectid;
ret = iterate_extent_inodes(sctx->send_root->fs_info,
found_key.objectid, extent_item_pos, 1,
__iterate_backrefs, &backref_ctx);
__iterate_backrefs, backref_ctx);
if (ret < 0)
goto out;

if (!backref_ctx.found_itself) {
if (!backref_ctx->found_itself) {
/* found a bug in backref code? */
ret = -EIO;
printk(KERN_ERR "btrfs: ERROR did not find backref in "
Expand All @@ -1246,7 +1252,7 @@ verbose_printk(KERN_DEBUG "btrfs: find_extent_clone: data_offset=%llu, "
"num_bytes=%llu, logical=%llu\n",
data_offset, ino, num_bytes, logical);

if (!backref_ctx.found)
if (!backref_ctx->found)
verbose_printk("btrfs: no clones found\n");

cur_clone_root = NULL;
Expand All @@ -1271,6 +1277,7 @@ verbose_printk(KERN_DEBUG "btrfs: find_extent_clone: data_offset=%llu, "

out:
btrfs_free_path(tmp_path);
kfree(backref_ctx);
return ret;
}

Expand Down

0 comments on commit 669c2dd

Please sign in to comment.