Commit 267309f3 authored by Al Viro's avatar Al Viro

ufs_get_locked_page(): make sure we have buffer_heads

callers rely upon that, but find_lock_page() racing with attempt of
page eviction by memory pressure might have left us with
	* try_to_free_buffers() successfully done
	* __remove_mapping() failed, leaving the page in our mapping
	* find_lock_page() returning an uptodate page with no
buffer_heads attached.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c596961d
...@@ -243,9 +243,8 @@ ufs_set_inode_dev(struct super_block *sb, struct ufs_inode_info *ufsi, dev_t dev ...@@ -243,9 +243,8 @@ ufs_set_inode_dev(struct super_block *sb, struct ufs_inode_info *ufsi, dev_t dev
struct page *ufs_get_locked_page(struct address_space *mapping, struct page *ufs_get_locked_page(struct address_space *mapping,
pgoff_t index) pgoff_t index)
{ {
struct page *page; struct inode *inode = mapping->host;
struct page *page = find_lock_page(mapping, index);
page = find_lock_page(mapping, index);
if (!page) { if (!page) {
page = read_mapping_page(mapping, index, NULL); page = read_mapping_page(mapping, index, NULL);
...@@ -253,7 +252,7 @@ struct page *ufs_get_locked_page(struct address_space *mapping, ...@@ -253,7 +252,7 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
printk(KERN_ERR "ufs_change_blocknr: " printk(KERN_ERR "ufs_change_blocknr: "
"read_mapping_page error: ino %lu, index: %lu\n", "read_mapping_page error: ino %lu, index: %lu\n",
mapping->host->i_ino, index); mapping->host->i_ino, index);
goto out; return page;
} }
lock_page(page); lock_page(page);
...@@ -262,8 +261,7 @@ struct page *ufs_get_locked_page(struct address_space *mapping, ...@@ -262,8 +261,7 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
/* Truncate got there first */ /* Truncate got there first */
unlock_page(page); unlock_page(page);
put_page(page); put_page(page);
page = NULL; return NULL;
goto out;
} }
if (!PageUptodate(page) || PageError(page)) { if (!PageUptodate(page) || PageError(page)) {
...@@ -272,11 +270,12 @@ struct page *ufs_get_locked_page(struct address_space *mapping, ...@@ -272,11 +270,12 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
printk(KERN_ERR "ufs_change_blocknr: " printk(KERN_ERR "ufs_change_blocknr: "
"can not read page: ino %lu, index: %lu\n", "can not read page: ino %lu, index: %lu\n",
mapping->host->i_ino, index); inode->i_ino, index);
page = ERR_PTR(-EIO); return ERR_PTR(-EIO);
} }
} }
out: if (!page_has_buffers(page))
create_empty_buffers(page, 1 << inode->i_blkbits, 0);
return page; return page;
} }
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