From: David Woodhouse <dwmw2@infradead.org>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] Optimise NFS readdir hack slightly.
Date: Sun, 17 Aug 2008 17:21:18 +0100 [thread overview]
Message-ID: <1218990078.3184.319.camel@pmac.infradead.org> (raw)
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
next reply other threads:[~2008-08-17 16:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-17 16:21 David Woodhouse [this message]
2008-08-18 14:36 ` [JFFS2] Use d_splice_alias() not d_add() in jffs2_lookup() 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=1218990078.3184.319.camel@pmac.infradead.org \
--to=dwmw2@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).