public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Caching of reads
@ 2001-11-16 15:37 Ian Campbell
  2001-11-16 15:48 ` David Woodhouse
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Campbell @ 2001-11-16 15:37 UTC (permalink / raw)
  To: Linux MTD Mailing List

Good afternoon,

I've checked the documentation and list archives and I can't find
anything which refers to my problem...

It seems as if reads from a JFFS2 file system are not being cached as we
would expect, for instance this small script:

while true ; do
sleep 1
done

causes a read from the flash every time the sleep is executed. This is
true even if the fs is mounted read only.

This is with a 2.4.14 kernel (and the JFFS2 therein), does anyone have
any clue as to what might be going on?

Thanks IA,
Ian.

-- 
Ian Campbell
Design Engineer

Arcom Control Systems Ltd,
Clifton Road,
Cambridge CB1 7EA
United Kingdom

Tel: +44 (0)1223 411200 ext. 3204
E-Mail: icampbell@arcom.co.uk
Web: http://www.arcomcontrols.com


_____________________________________________________________________
The message in this transmission is sent in confidence for the attention of the addressee only and should not be disclosed to any other party. Unauthorised recipients are requested to preserve this confidentiality. Please advise the sender if the addressee is not resident at the receiving end.

This message has been checked for all viruses by MessageLabs Virus Control Centre. 

Company registered in England No. 1608562.
Registered Office: Unit 8, Clifton Road, Cambridge, CB1 7EA, United Kingdom, Tel: 01223 411200.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Caching of reads
  2001-11-16 15:37 Caching of reads Ian Campbell
@ 2001-11-16 15:48 ` David Woodhouse
  2001-11-21 15:10   ` Ian Campbell
  0 siblings, 1 reply; 6+ messages in thread
From: David Woodhouse @ 2001-11-16 15:48 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Linux MTD Mailing List


icampbell@arcom.co.uk said:
>  It seems as if reads from a JFFS2 file system are not being cached as
> we would expect, for instance this small script:

> while true ; do sleep 1; done

> causes a read from the flash every time the sleep is executed. This is
> true even if the fs is mounted read only. 

Strange. JFFS2 doesn't do caching - that's supposed to be handle by the 
Linux VFS/VM. But set CONFIG_JFFS2_FS_DEBUG=1 and 
echo 9 > /proc/sys/kernel/printk, then see what it's actually being asked 
to read each time.

--
dwmw2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Caching of reads
  2001-11-16 15:48 ` David Woodhouse
@ 2001-11-21 15:10   ` Ian Campbell
  2001-11-21 15:46     ` David Woodhouse
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Campbell @ 2001-11-21 15:10 UTC (permalink / raw)
  To: Linux MTD Mailing List

> Strange. JFFS2 doesn't do caching - that's supposed to be handle by the 
> Linux VFS/VM. But set CONFIG_JFFS2_FS_DEBUG=1 and 
> echo 9 > /proc/sys/kernel/printk, then see what it's actually being asked 
> to read each time.

Hi,

I've instrumented my kernel a bit and found that the reads are being
caused by calls to jffs2_follow_link (in order to resolve the sym links
for the libraries needed to load sleep)... 

It's been pointed out to me that the jffs list might be a better place
so I'll take this there... 

Thanks,
Ian.
 
-- 
Ian Campbell
Design Engineer

Arcom Control Systems Ltd,
Clifton Road,
Cambridge CB1 7EA
United Kingdom

Tel: +44 (0)1223 411200 ext. 3204
E-Mail: icampbell@arcom.co.uk
Web: http://www.arcomcontrols.com


_____________________________________________________________________
The message in this transmission is sent in confidence for the attention of the addressee only and should not be disclosed to any other party. Unauthorised recipients are requested to preserve this confidentiality. Please advise the sender if the addressee is not resident at the receiving end.

This message has been checked for all viruses by MessageLabs Virus Control Centre. 

Company registered in England No. 1608562.
Registered Office: Unit 8, Clifton Road, Cambridge, CB1 7EA, United Kingdom, Tel: 01223 411200.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Caching of reads
  2001-11-21 15:10   ` Ian Campbell
@ 2001-11-21 15:46     ` David Woodhouse
  2001-11-21 16:33       ` Ian Campbell
  0 siblings, 1 reply; 6+ messages in thread
From: David Woodhouse @ 2001-11-21 15:46 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Linux MTD Mailing List, jffs-dev

icampbell@arcom.co.uk said:
>  I've instrumented my kernel a bit and found that the reads are being
> caused by calls to jffs2_follow_link (in order to resolve the sym
> links for the libraries needed to load sleep)... 

> It's been pointed out to me that the jffs list might be a better place
> so I'll take this there... 

Try this.

Index: include/linux/jffs2_fs_i.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/jffs2_fs_i.h,v
retrieving revision 1.8
diff -u -r1.8 jffs2_fs_i.h
--- include/linux/jffs2_fs_i.h	2001/04/18 13:05:28	1.8
+++ include/linux/jffs2_fs_i.h	2001/11/21 15:45:43
@@ -44,6 +44,7 @@
 	/* Some stuff we just have to keep in-core at all times, for each inode. */
 	struct jffs2_inode_cache *inocache;
 
+	unsigned char *symlink_target;
 	/* Keep a pointer to the last physical node in the list. We don't 
 	   use the doubly-linked lists because we don't want to increase
 	   the memory usage that much. This is simpler */
Index: fs/jffs2/readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/readinode.c,v
retrieving revision 1.56
diff -u -r1.56 readinode.c
--- fs/jffs2/readinode.c	2001/07/26 20:32:39	1.56
+++ fs/jffs2/readinode.c	2001/11/21 15:45:44
@@ -458,6 +458,9 @@
 
 	D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode));
 
+	if (f->symlink_target)
+		kfree(f->symlink_target);
+
 	frags = f->fraglist;
 	fds = f->dents;
 	if (f->metadata) {
Index: fs/jffs2/symlink.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/symlink.c,v
retrieving revision 1.5
diff -u -r1.5 symlink.c
--- fs/jffs2/symlink.c	2001/03/15 15:38:24	1.5
+++ fs/jffs2/symlink.c	2001/11/21 15:45:44
@@ -52,7 +52,7 @@
 	setattr:	jffs2_setattr
 };
 
-static char *jffs2_getlink(struct dentry *dentry)
+static int jffs2_get_link_target(struct dentry *dentry)
 {
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode);
 	char *buf;
@@ -60,46 +60,45 @@
 
 	if (!f->metadata) {
 		printk(KERN_NOTICE "No metadata for symlink inode #%lu\n", dentry->d_inode->i_ino);
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
 	}
 	buf = kmalloc(f->metadata->size+1, GFP_USER);
 	if (!buf)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 	buf[f->metadata->size]=0;
 
 	ret = jffs2_read_dnode(JFFS2_SB_INFO(dentry->d_inode->i_sb), f->metadata, buf, 0, f->metadata->size);
 	if (ret) {
 		kfree(buf);
-		return ERR_PTR(ret);
+		return ret;
 	}
-	return buf;
+	f->symlink_target = buf;
 
+	return 0;
 }
+
 int jffs2_readlink(struct dentry *dentry, char *buffer, int buflen)
 {
-	unsigned char *kbuf;
-	int ret;
+	struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode);
+
+	if (!f->symlink_target) {
+		int ret = jffs2_get_link_target(dentry);
+		if (ret)
+			return ret;
+	}
 
-	kbuf = jffs2_getlink(dentry);
-	if (IS_ERR(kbuf))
-		return PTR_ERR(kbuf);
-
-	ret = vfs_readlink(dentry, buffer, buflen, kbuf);
-	kfree(kbuf);
-	return ret;
+	return vfs_readlink(dentry, buffer, buflen, f->symlink_target);
 }
 
 int jffs2_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-	unsigned char *buf;
-	int ret;
-
-	buf = jffs2_getlink(dentry);
+	struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode);
 
-	if (IS_ERR(buf))
-		return PTR_ERR(buf);
+	if (!f->symlink_target) {
+		int ret = jffs2_get_link_target(dentry);
+		if (ret)
+			return ret;
+	}
 
-	ret = vfs_follow_link(nd, buf);
-	kfree(buf);
-	return ret;
+	return vfs_follow_link(nd, f->symlink_target);
 }



--
dwmw2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Caching of reads
  2001-11-21 15:46     ` David Woodhouse
@ 2001-11-21 16:33       ` Ian Campbell
  2001-11-29  9:08         ` David Woodhouse
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Campbell @ 2001-11-21 16:33 UTC (permalink / raw)
  To: David Woodhouse; +Cc: Linux MTD Mailing List, JFFS dev Mailing List

> Try this.

It seems to do the trick!

Thanks very much for the exceedingly quick response!

Ian.
 
-- 
Ian Campbell
Design Engineer

Arcom Control Systems Ltd,
Clifton Road,
Cambridge CB1 7EA
United Kingdom

Tel: +44 (0)1223 411200 ext. 3204
E-Mail: icampbell@arcom.co.uk
Web: http://www.arcomcontrols.com


_____________________________________________________________________
The message in this transmission is sent in confidence for the attention of the addressee only and should not be disclosed to any other party. Unauthorised recipients are requested to preserve this confidentiality. Please advise the sender if the addressee is not resident at the receiving end.

This message has been checked for all viruses by MessageLabs Virus Control Centre. 

Company registered in England No. 1608562.
Registered Office: Unit 8, Clifton Road, Cambridge, CB1 7EA, United Kingdom, Tel: 01223 411200.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Caching of reads
  2001-11-21 16:33       ` Ian Campbell
@ 2001-11-29  9:08         ` David Woodhouse
  0 siblings, 0 replies; 6+ messages in thread
From: David Woodhouse @ 2001-11-29  9:08 UTC (permalink / raw)
  To: Ian Campbell; +Cc: Linux MTD Mailing List, JFFS dev Mailing List

icampbell@arcom.co.uk said:
>  It seems to do the trick!
> Thanks very much for the exceedingly quick response! 

I'm not committing it. We want to do it the way ext2 does, with 
page_symlink_inode_operations and a readpage(). That way, we can drop the 
cached symlink target from memory when we can't just drop the whole inode.

--
dwmw2

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-11-29  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-16 15:37 Caching of reads Ian Campbell
2001-11-16 15:48 ` David Woodhouse
2001-11-21 15:10   ` Ian Campbell
2001-11-21 15:46     ` David Woodhouse
2001-11-21 16:33       ` Ian Campbell
2001-11-29  9:08         ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox