[PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>, Alexander Viro <viro@...>, Christoph Hellwig <hch@...>, Roman Zippel <zippel@...>, Mikulas Patocka <mikulas@...>, David Woodhouse <dwmw2@...>, Dave Kleikamp <shaggy@...>, Anton Altaparmakov <aia21@...>, Evgeniy Dushistov <dushistov@...>
Cc: <linux-kernel@...>, <linux-fsdevel@...>, <reiserfs-dev@...>
Date: Wednesday, April 11, 2007 - 10:49 pm

Replace jffs2_gc_fetch_page() and jffs2_gc_release_page() using the
read_cache_page() and put_kmapped_page() calls, and update the call site
accordingly.  Explicit calls to kmap()/kunmap() make the code more clear.

Signed-off-by: Nate Diller <nate.diller@gmail.com>

---

diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/jffs2/fs.c linux-2.6.21-rc5-mm4-test/fs/jffs2/fs.c
--- linux-2.6.21-rc5-mm4/fs/jffs2/fs.c	2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/jffs2/fs.c	2007-04-06 01:59:19.000000000 -0700
@@ -621,33 +621,6 @@ struct jffs2_inode_info *jffs2_gc_fetch_
 	return JFFS2_INODE_INFO(inode);
 }
 
-unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
-				   struct jffs2_inode_info *f,
-				   unsigned long offset,
-				   unsigned long *priv)
-{
-	struct inode *inode = OFNI_EDONI_2SFFJ(f);
-	struct page *pg;
-
-	pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT,
-			     (void *)jffs2_do_readpage_unlock, inode);
-	if (IS_ERR(pg))
-		return (void *)pg;
-
-	*priv = (unsigned long)pg;
-	return kmap(pg);
-}
-
-void jffs2_gc_release_page(struct jffs2_sb_info *c,
-			   unsigned char *ptr,
-			   unsigned long *priv)
-{
-	struct page *pg = (void *)*priv;
-
-	kunmap(pg);
-	page_cache_release(pg);
-}
-
 static int jffs2_flash_setup(struct jffs2_sb_info *c) {
 	int ret = 0;
 
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/jffs2/gc.c linux-2.6.21-rc5-mm4-test/fs/jffs2/gc.c
--- linux-2.6.21-rc5-mm4/fs/jffs2/gc.c	2007-04-05 17:13:10.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/jffs2/gc.c	2007-04-06 01:59:19.000000000 -0700
@@ -1078,7 +1078,7 @@ static int jffs2_garbage_collect_dnode(s
 	uint32_t alloclen, offset, orig_end, orig_start;
 	int ret = 0;
 	unsigned char *comprbuf = NULL, *writebuf;
-	unsigned long pg;
+	struct page *page;
 	unsigned char *pg_ptr;
 
 	memset(&ri, 0, sizeof(ri));
@@ -1219,12 +1219,16 @@ static int jffs2_garbage_collect_dnode(s
 	 *    page OK. We'll actually write it out again in commit_write, which is a little
 	 *    suboptimal, but at least we're correct.
 	 */
-	pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg);
+	page = read_cache_page(OFNI_EDONI_2SFFJ(f)->i_mapping,
+				start >> PAGE_CACHE_SHIFT,
+				(void *)jffs2_do_readpage_unlock,
+				OFNI_EDONI_2SFFJ(f));
 
-	if (IS_ERR(pg_ptr)) {
+	if (IS_ERR(page)) {
 		printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr));
-		return PTR_ERR(pg_ptr);
+		return PTR_ERR(page);
 	}
+	pg_ptr = kmap(page);
 
 	offset = start;
 	while(offset < orig_end) {
@@ -1287,6 +1291,7 @@ static int jffs2_garbage_collect_dnode(s
 		}
 	}
 
-	jffs2_gc_release_page(c, pg_ptr, &pg);
+	kunmap(page);
+	page_cache_release(page);
 	return ret;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 10/17] mtd: convert page_read to read_kmap_page, Nate Diller, (Wed Apr 11, 10:49 pm)
[PATCH 8/17] jfs: use locking read_mapping_page, Nate Diller, (Wed Apr 11, 10:49 pm)
[PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cach..., Nate Diller, (Wed Apr 11, 10:49 pm)
[PATCH 1/17] cramfs: use read_mapping_page, Nate Diller, (Wed Apr 11, 10:49 pm)
Re: [PATCH 1/17] cramfs: use read_mapping_page, Christoph Hellwig, (Thu Apr 12, 5:54 am)
Re: [PATCH 1/17] cramfs: use read_mapping_page, Roman Zippel, (Thu Apr 12, 7:26 am)
Re: [PATCH 1/17] cramfs: use read_mapping_page, Nate Diller, (Thu Apr 12, 2:36 pm)