linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Optimise NFS readdir hack slightly.
@ 2008-08-17 16:21 David Woodhouse
  2008-08-18 14:36 ` [JFFS2] Use d_splice_alias() not d_add() in jffs2_lookup() David Woodhouse
  0 siblings, 1 reply; 2+ messages in thread
From: David Woodhouse @ 2008-08-17 16:21 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel

Avoid calling the underlying ->readdir() again when we reached the end
already; keep going round the loop only if we stopped due to our own
buffer being full.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index d789fb8..7631bd1 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1832,6 +1832,7 @@ struct buffered_dirent {
 struct readdir_data {
 	char		*dirent;
 	size_t		used;
+	int		full;
 };
 
 static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
@@ -1842,8 +1843,10 @@ static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
 	unsigned int reclen;
 
 	reclen = ALIGN(sizeof(struct buffered_dirent) + namlen, sizeof(u64));
-	if (buf->used + reclen > PAGE_SIZE)
+	if (buf->used + reclen > PAGE_SIZE) {
+		buf->full = 1;
 		return -EINVAL;
+	}
 
 	de->namlen = namlen;
 	de->offset = offset;
@@ -1871,11 +1874,11 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
 	offset = *offsetp;
 	cdp->err = nfserr_eof; /* will be cleared on successful read */
 
-	while (1) {
+	do {
 		unsigned int reclen;
 
 		buf.used = 0;
-
+		buf.full = 0;
 		host_err = vfs_readdir(file, nfsd_buffered_filldir, &buf);
 		if (host_err)
 			break;
@@ -1903,7 +1906,7 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
 			de = (struct buffered_dirent *)((char *)de + reclen);
 		}
 		offset = vfs_llseek(file, 0, 1);
-	}
+	} while (buf.full);
 
  done:
 	free_page((unsigned long)(buf.dirent));

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




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

* [JFFS2] Use d_splice_alias() not d_add() in jffs2_lookup()
  2008-08-17 16:21 [PATCH] Optimise NFS readdir hack slightly David Woodhouse
@ 2008-08-18 14:36 ` David Woodhouse
  0 siblings, 0 replies; 2+ messages in thread
From: David Woodhouse @ 2008-08-18 14:36 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel

Now that JFFS2 can be exported by NFS, we need to get this right.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index cd219ef..d4d9f32 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -108,9 +108,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
 		}
 	}
 
-	d_add(target, inode);
-
-	return NULL;
+	return d_splice_alias(inode, target);
 }
 
 /***********************************************************************/

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




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

end of thread, other threads:[~2008-08-18 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-17 16:21 [PATCH] Optimise NFS readdir hack slightly David Woodhouse
2008-08-18 14:36 ` [JFFS2] Use d_splice_alias() not d_add() in jffs2_lookup() David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).