Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 251745
b: refs/heads/master
c: b221349
h: refs/heads/master
i:
  251743: 0f143c6
v: v3
  • Loading branch information
Yongqiang Yang authored and Theodore Ts'o committed May 24, 2011
1 parent a579a29 commit 3dd2332
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 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: 072bd7ea74d4b60149a33967d29666bbd84e7709
refs/heads/master: b221349fa8b45d13c3650089f0514df7d1eb36c3
49 changes: 35 additions & 14 deletions trunk/fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -3688,6 +3688,7 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
pgoff_t last_offset;
pgoff_t offset;
pgoff_t index;
pgoff_t start_index = 0;
struct page **pages = NULL;
struct buffer_head *bh = NULL;
struct buffer_head *head = NULL;
Expand All @@ -3714,39 +3715,57 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
kfree(pages);
return EXT_CONTINUE;
}
index = 0;

next_page:
/* Try to find the 1st mapped buffer. */
end = ((__u64)pages[0]->index << PAGE_SHIFT) >>
end = ((__u64)pages[index]->index << PAGE_SHIFT) >>
blksize_bits;
if (!page_has_buffers(pages[0]))
if (!page_has_buffers(pages[index]))
goto out;
head = page_buffers(pages[0]);
head = page_buffers(pages[index]);
if (!head)
goto out;

index++;
bh = head;
do {
if (buffer_mapped(bh)) {
if (end >= newex->ec_block +
newex->ec_len)
/* The buffer is out of
* the request range.
*/
goto out;

if (buffer_mapped(bh) &&
end >= newex->ec_block) {
start_index = index - 1;
/* get the 1st mapped buffer. */
if (end > newex->ec_block +
newex->ec_len)
/* The buffer is out of
* the request range.
*/
goto out;
goto found_mapped_buffer;
}

bh = bh->b_this_page;
end++;
} while (bh != head);

/* No mapped buffer found. */
goto out;
/* No mapped buffer in the range found in this page,
* We need to look up next page.
*/
if (index >= ret) {
/* There is no page left, but we need to limit
* newex->ec_len.
*/
newex->ec_len = end - newex->ec_block;
goto out;
}
goto next_page;
} else {
/*Find contiguous delayed buffers. */
if (ret > 0 && pages[0]->index == last_offset)
head = page_buffers(pages[0]);
bh = head;
index = 1;
start_index = 0;
}

found_mapped_buffer:
Expand All @@ -3769,7 +3788,7 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
end++;
} while (bh != head);

for (index = 1; index < ret; index++) {
for (; index < ret; index++) {
if (!page_has_buffers(pages[index])) {
bh = NULL;
break;
Expand All @@ -3779,8 +3798,10 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
bh = NULL;
break;
}

if (pages[index]->index !=
pages[0]->index + index) {
pages[start_index]->index + index
- start_index) {
/* Blocks are not contiguous. */
bh = NULL;
break;
Expand Down

0 comments on commit 3dd2332

Please sign in to comment.