Commit 5c4e9e03 authored by Steven Whitehouse's avatar Steven Whitehouse Committed by Steven Whitehouse

[GFS2] Fix a case where we didn't get unstuffing right

There was a bug in the unstuffing logic which caused a crash
under certain circumstances. This is now fixed.
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 61a30dcb
...@@ -220,14 +220,14 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) ...@@ -220,14 +220,14 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
if (error) if (error)
return error; return error;
kaddr = kmap(page); kaddr = kmap_atomic(page, KM_USER0);
memcpy((char *)kaddr, memcpy((char *)kaddr,
dibh->b_data + sizeof(struct gfs2_dinode), dibh->b_data + sizeof(struct gfs2_dinode),
ip->i_di.di_size); ip->i_di.di_size);
memset((char *)kaddr + ip->i_di.di_size, memset((char *)kaddr + ip->i_di.di_size,
0, 0,
PAGE_CACHE_SIZE - ip->i_di.di_size); PAGE_CACHE_SIZE - ip->i_di.di_size);
kunmap(page); kunmap_atomic(page, KM_USER0);
brelse(dibh); brelse(dibh);
...@@ -240,9 +240,9 @@ static int zero_readpage(struct page *page) ...@@ -240,9 +240,9 @@ static int zero_readpage(struct page *page)
{ {
void *kaddr; void *kaddr;
kaddr = kmap(page); kaddr = kmap_atomic(page, KM_USER0);
memset(kaddr, 0, PAGE_CACHE_SIZE); memset(kaddr, 0, PAGE_CACHE_SIZE);
kunmap(page); kunmap_atomic(page, KM_USER0);
SetPageUptodate(page); SetPageUptodate(page);
unlock_page(page); unlock_page(page);
...@@ -364,14 +364,14 @@ static int gfs2_prepare_write(struct file *file, struct page *page, ...@@ -364,14 +364,14 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
if (gfs2_is_stuffed(ip)) { if (gfs2_is_stuffed(ip)) {
if (end > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) { if (end > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
error = gfs2_unstuff_dinode(ip, gfs2_unstuffer_page, page); error = gfs2_unstuff_dinode(ip, gfs2_unstuffer_page, page);
if (error) if (error == 0)
goto out; goto prepare_write;
} else if (!PageUptodate(page)) { } else if (!PageUptodate(page))
error = stuffed_readpage(ip, page); error = stuffed_readpage(ip, page);
goto out; goto out;
}
} }
prepare_write:
error = block_prepare_write(page, from, to, gfs2_get_block); error = block_prepare_write(page, from, to, gfs2_get_block);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment