Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -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,
				 pgoff_t index)
{
	struct page *page;

	page = find_lock_page(mapping, index);
	struct inode *inode = mapping->host;
	struct page *page = find_lock_page(mapping, index);
	if (!page) {
		page = read_mapping_page(mapping, index, NULL);

@@ -253,7 +252,7 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
			printk(KERN_ERR "ufs_change_blocknr: "
			       "read_mapping_page error: ino %lu, index: %lu\n",
			       mapping->host->i_ino, index);
			goto out;
			return page;
		}

		lock_page(page);
@@ -262,8 +261,7 @@ struct page *ufs_get_locked_page(struct address_space *mapping,
			/* Truncate got there first */
			unlock_page(page);
			put_page(page);
			page = NULL;
			goto out;
			return NULL;
		}

		if (!PageUptodate(page) || PageError(page)) {
@@ -272,11 +270,12 @@ struct page *ufs_get_locked_page(struct address_space *mapping,

			printk(KERN_ERR "ufs_change_blocknr: "
			       "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;
}