From: David Woodhouse <dwmw2@infradead.org>
To: Ian Campbell <icampbell@arcom.co.uk>
Cc: Linux MTD Mailing List <linux-mtd@lists.infradead.org>,
jffs-dev@axis.com
Subject: Re: Caching of reads
Date: Wed, 21 Nov 2001 15:46:40 +0000 [thread overview]
Message-ID: <15923.1006357600@redhat.com> (raw)
In-Reply-To: <1006355430.17354.8.camel@LinuxDev>
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
next prev parent reply other threads:[~2001-11-21 15:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2001-11-21 16:33 ` Ian Campbell
2001-11-29 9:08 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15923.1006357600@redhat.com \
--to=dwmw2@infradead.org \
--cc=icampbell@arcom.co.uk \
--cc=jffs-dev@axis.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox