summaryrefslogtreecommitdiffstats
path: root/fs/jffs2/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/gc.c')
-rw-r--r--fs/jffs2/gc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index 9ed0f26cf023..373b3b7c9f44 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -1165,12 +1165,13 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
1165 struct jffs2_inode_info *f, struct jffs2_full_dnode *fn, 1165 struct jffs2_inode_info *f, struct jffs2_full_dnode *fn,
1166 uint32_t start, uint32_t end) 1166 uint32_t start, uint32_t end)
1167{ 1167{
1168 struct inode *inode = OFNI_EDONI_2SFFJ(f);
1168 struct jffs2_full_dnode *new_fn; 1169 struct jffs2_full_dnode *new_fn;
1169 struct jffs2_raw_inode ri; 1170 struct jffs2_raw_inode ri;
1170 uint32_t alloclen, offset, orig_end, orig_start; 1171 uint32_t alloclen, offset, orig_end, orig_start;
1171 int ret = 0; 1172 int ret = 0;
1172 unsigned char *comprbuf = NULL, *writebuf; 1173 unsigned char *comprbuf = NULL, *writebuf;
1173 unsigned long pg; 1174 struct page *page;
1174 unsigned char *pg_ptr; 1175 unsigned char *pg_ptr;
1175 1176
1176 memset(&ri, 0, sizeof(ri)); 1177 memset(&ri, 0, sizeof(ri));
@@ -1325,15 +1326,18 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
1325 * end up here trying to GC the *same* page that jffs2_write_begin() is 1326 * end up here trying to GC the *same* page that jffs2_write_begin() is
1326 * trying to write out, read_cache_page() will not deadlock. */ 1327 * trying to write out, read_cache_page() will not deadlock. */
1327 mutex_unlock(&f->sem); 1328 mutex_unlock(&f->sem);
1328 pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg); 1329 page = read_cache_page(inode->i_mapping, start >> PAGE_SHIFT,
1329 mutex_lock(&f->sem); 1330 jffs2_do_readpage_unlock, inode);
1330 1331 if (IS_ERR(page)) {
1331 if (IS_ERR(pg_ptr)) {
1332 pr_warn("read_cache_page() returned error: %ld\n", 1332 pr_warn("read_cache_page() returned error: %ld\n",
1333 PTR_ERR(pg_ptr)); 1333 PTR_ERR(page));
1334 return PTR_ERR(pg_ptr); 1334 mutex_lock(&f->sem);
1335 return PTR_ERR(page);
1335 } 1336 }
1336 1337
1338 pg_ptr = kmap(page);
1339 mutex_lock(&f->sem);
1340
1337 offset = start; 1341 offset = start;
1338 while(offset < orig_end) { 1342 while(offset < orig_end) {
1339 uint32_t datalen; 1343 uint32_t datalen;
@@ -1396,6 +1400,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
1396 } 1400 }
1397 } 1401 }
1398 1402
1399 jffs2_gc_release_page(c, pg_ptr, &pg); 1403 kunmap(page);
1404 put_page(page);
1400 return ret; 1405 return ret;
1401} 1406}