scoutfs: update filerw cursor use

The conversion of the filerw item callers of the btree cursor wasn't
updated to consistently release the cursors.  This was causing block
refcounting problems that could scribble on freed and realloced memory.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2016-04-13 09:49:13 -07:00
parent affee9da7c
commit 0234abf098
+6 -2
View File
@@ -81,7 +81,7 @@ static bool map_data_region(struct data_region *dr, u64 pos, struct page *page)
static int scoutfs_readpage(struct file *file, struct page *page)
{
struct inode *inode = file->f_mapping->host;
struct scoutfs_btree_cursor curs = {NULL,};
DECLARE_SCOUTFS_BTREE_CURSOR(curs);
struct super_block *sb = inode->i_sb;
struct scoutfs_key key;
struct data_region dr;
@@ -93,6 +93,7 @@ static int scoutfs_readpage(struct file *file, struct page *page)
scoutfs_set_key(&key, scoutfs_ino(inode), SCOUTFS_DATA_KEY,
dr.item_key);
scoutfs_btree_release(&curs);
ret = scoutfs_btree_lookup(sb, &key, &curs);
if (ret == -ENOENT) {
addr = kmap_atomic(page);
@@ -108,6 +109,8 @@ static int scoutfs_readpage(struct file *file, struct page *page)
kunmap_atomic(addr);
}
scoutfs_btree_release(&curs);
if (!ret)
SetPageUptodate(page);
unlock_page(page);
@@ -125,7 +128,7 @@ static int scoutfs_readpage(struct file *file, struct page *page)
static int scoutfs_writepage(struct page *page, struct writeback_control *wbc)
{
struct inode *inode = page->mapping->host;
struct scoutfs_btree_cursor curs = {NULL,};
DECLARE_SCOUTFS_BTREE_CURSOR(curs);
struct super_block *sb = inode->i_sb;
struct scoutfs_key key;
struct data_region dr;
@@ -140,6 +143,7 @@ static int scoutfs_writepage(struct page *page, struct writeback_control *wbc)
dr.item_key);
/* XXX dirty */
scoutfs_btree_release(&curs);
ret = scoutfs_btree_insert(sb, &key, SCOUTFS_MAX_ITEM_LEN,
&curs);
if (ret)