From 0234abf098edc1bbef8c9d73af1d65242c0275b1 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 13 Apr 2016 09:49:13 -0700 Subject: [PATCH] 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 --- kmod/src/filerw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kmod/src/filerw.c b/kmod/src/filerw.c index 074204df..7b7cb532 100644 --- a/kmod/src/filerw.c +++ b/kmod/src/filerw.c @@ -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)