Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235062
b: refs/heads/master
c: e4a7b7b
h: refs/heads/master
v: v3
  • Loading branch information
Benjamin Marzinski authored and Steven Whitehouse committed Mar 11, 2011
1 parent 13e504a commit eb0e61f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 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: fa1bbdea300a15ec7c1186a5e53de33a5b1672f5
refs/heads/master: e4a7b7b0c98efcdcc4c1f6eb10925dec1fbc4016
56 changes: 31 additions & 25 deletions trunk/fs/gfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,7 @@ static void empty_write_end(struct page *page, unsigned from,
{
struct gfs2_inode *ip = GFS2_I(page->mapping->host);

page_zero_new_buffers(page, from, to);
flush_dcache_page(page);
zero_user(page, from, to-from);
mark_page_accessed(page);

if (!gfs2_is_writeback(ip))
Expand All @@ -632,50 +631,57 @@ static void empty_write_end(struct page *page, unsigned from,
block_commit_write(page, from, to);
}

static int write_empty_blocks(struct page *page, unsigned from, unsigned to)
static int needs_empty_write(sector_t block, struct inode *inode)
{
unsigned start, end, next;
struct buffer_head *bh, *head;
int error;
struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };

if (!page_has_buffers(page)) {
error = __block_write_begin(page, from, to - from, gfs2_block_map);
if (unlikely(error))
return error;
bh_map.b_size = 1 << inode->i_blkbits;
error = gfs2_block_map(inode, block, &bh_map, 0);
if (unlikely(error))
return error;
return !buffer_mapped(&bh_map);
}

empty_write_end(page, from, to);
return 0;
}
static int write_empty_blocks(struct page *page, unsigned from, unsigned to)
{
struct inode *inode = page->mapping->host;
unsigned start, end, next, blksize;
sector_t block = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
int ret;

bh = head = page_buffers(page);
blksize = 1 << inode->i_blkbits;
next = end = 0;
while (next < from) {
next += bh->b_size;
bh = bh->b_this_page;
next += blksize;
block++;
}
start = next;
do {
next += bh->b_size;
if (buffer_mapped(bh)) {
next += blksize;
ret = needs_empty_write(block, inode);
if (unlikely(ret < 0))
return ret;
if (ret == 0) {
if (end) {
error = __block_write_begin(page, start, end - start,
gfs2_block_map);
if (unlikely(error))
return error;
ret = __block_write_begin(page, start, end - start,
gfs2_block_map);
if (unlikely(ret))
return ret;
empty_write_end(page, start, end);
end = 0;
}
start = next;
}
else
end = next;
bh = bh->b_this_page;
block++;
} while (next < to);

if (end) {
error = __block_write_begin(page, start, end - start, gfs2_block_map);
if (unlikely(error))
return error;
ret = __block_write_begin(page, start, end - start, gfs2_block_map);
if (unlikely(ret))
return ret;
empty_write_end(page, start, end);
}

Expand Down

0 comments on commit eb0e61f

Please sign in to comment.