Skip to contentSkip to conversation

Readpages using Read-While-Load feature

PATCH In review Amul Kumar Saha 2 participants 2 messages Jan 19, 2010 – Feb 2, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Readpages using Read-While-Load feature

JFFS2-Readpages patch makes use of the Read-While-Load support present on OneNAND variant devices. There is an increase in the read-speed by ~13% upon usage of the readpages patch.

---
 file.c     |   89 ++++++++++++++++
 nodelist.h |    9 +
 read.c     |  333 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 431 insertions(+)
fs/jffs2/file.c +89 -0
index b7b74e2..eef28af 100644
@@ -17,6 +17,7 @@
 #include <linux/highmem.h>
 #include <linux/crc32.h>
 #include <linux/jffs2.h>
+#include <linux/pagevec.h>
 #include "nodelist.h"
 
 static int jffs2_write_end(struct file *filp, struct address_space *mapping,
@@ -26,6 +27,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
 			loff_t pos, unsigned len, unsigned flags,
 			struct page **pagep, void **fsdata);
 static int jffs2_readpage (struct file *filp, struct page *pg);
+static int jffs2_readpages(struct file *file, struct address_space *mapping,
+			struct list_head *pages, unsigned nr_pages);
 
 int jffs2_fsync(struct file *filp, struct dentry *dentry, int datasync)
 {
@@ -66,6 +69,7 @@ const struct inode_operations jffs2_file_inode_operations =
 
 const struct address_space_operations jffs2_file_address_operations =
 {
+	.readpages =	jffs2_readpages,
 	.readpage =	jffs2_readpage,
 	.write_begin =	jffs2_write_begin,
 	.write_end =	jffs2_write_end,
@@ -109,6 +113,91 @@ int jffs2_do_readpage_unlock(struct inode *inode, struct page *pg)
 	return ret;
 }
 
+static int jffs2_readpages(struct file *file, struct address_space *mapping,
+			   struct list_head *pages, unsigned nr_pages)
+{
+	struct pagevec lru_pvec;
+	struct page *page;
+	loff_t offset;
+	unsigned int readSize, i;
+	int readCnt = 0, pageaddfailed = 0;
+	unsigned contigPages;
+	unsigned long expectedIndex;
+
+	struct jffs2_inode_info *f = JFFS2_INODE_INFO(mapping->host);
+	struct jffs2_sb_info *c = JFFS2_SB_INFO(mapping->host->i_sb);
+
+	pagevec_init(&lru_pvec, 0);
+	mutex_lock(&f->sem);
+
+	f->inocache = jffs2_get_ino_cache(c, mapping->host->i_ino);
+	if (unlikely(!f->inocache)) {
+		mutex_unlock(&f->sem);
+		return readCnt;
+	}
+
+	for (i = 0; i < nr_pages; i += contigPages) {
+		if (list_empty(pages))
+			break;
+		expectedIndex = (loff_t)(list_entry(pages->prev, struct page,
+				lru))->index;
+		offset = expectedIndex << PAGE_CACHE_SHIFT;
+
+		contigPages = 0;
+		list_for_each_entry_reverse(page, pages, lru) {
+			if (page->index != expectedIndex)
+				break;
+			if (add_to_page_cache(page, mapping, page->index,
+			GFP_KERNEL)) {
+				printk(KERN_CRIT "%s: Add page cache failed\n",
+					__func__);
+				pageaddfailed = 1;
+				break;
+			}
+			BUG_ON(!PageLocked(page));
+			contigPages++;
+			expectedIndex++;
+		}
+
+		readSize = contigPages * PAGE_CACHE_SIZE;
+		readCnt = jffs2_read_multiple_inode_range(c, f, pages, offset,
+			readSize) & PAGE_CACHE_MASK;
+
+		while (readSize) {
+			page = list_entry(pages->prev, struct page, lru);
+			list_del(&page->lru);
+
+			if (readCnt > 0) {
+				SetPageUptodate(page);
+				ClearPageError(page);
+				readCnt -= PAGE_CACHE_SIZE;
+			} else {
+				ClearPageUptodate(page);
+				SetPageError(page);
+			}
+			flush_dcache_page(page);
+			unlock_page(page);
+			if (!pagevec_add(&lru_pvec, page))
+				pagevec_lru_add_file(&lru_pvec);
+
+			readSize -= PAGE_CACHE_SIZE;
+		}
+
+		if (pageaddfailed) {
+			page = list_entry(pages->prev, struct page, lru);
+			list_del(&page->lru);
+			page_cache_release(page);
+			i++;
+			pageaddfailed = 0;
+		}
+
+	}
+
+	mutex_unlock(&f->sem);
+	pagevec_lru_add_file(&lru_pvec);
+	return readCnt;
+}
+
 
 static int jffs2_readpage (struct file *filp, struct page *pg)
 {
fs/jffs2/nodelist.h +9 -0
index 507ed6e..6564b81 100644
@@ -451,6 +451,15 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
 		     int ofs, int len);
 int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
 			   unsigned char *buf, uint32_t offset, uint32_t len);
+int jffs2_read_multiple_inode_range(struct jffs2_sb_info *c,
+		struct jffs2_inode_info *f, struct list_head *pages,
+		uint32_t startofs, uint32_t lentoread);
+int jffs2_read_multiple_dnodes(struct jffs2_sb_info *c,
+		struct jffs2_inode_info *f, struct jffs2_node_frag *frag,
+		struct list_head *pages, uint32_t tobuf, uint32_t startofs,
+		int conlen);
+char *mmemcpy(struct list_head *pages, uint32_t offset, char *src,
+		uint32_t len);
 char *jffs2_getlink(struct jffs2_sb_info *c, struct jffs2_inode_info *f);
 
 /* scan.c */
fs/jffs2/read.c +333 -0

336 lines not on this page · raw message

#1 lore raw
Quoted 11 lines · Amul Kumar Saha

JFFS2-Readpages patch makes use of the Read-While-Load support present on OneNAND variant devices. There is an increase in the read-speed by ~13% upon usage of the readpages patch.

---
 file.c     |   89 ++++++++++++++++
 nodelist.h |    9 +
 read.c     |  333 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 431 insertions(+)

Pushed your patch to my l2-mtd-2.6.git / dunno

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)