Optimise NFS readdir hack slightly.
Subsystems (3)
David Woodhouse
maintainerPATCH 1/1 Optimise NFS readdir hack slightly.
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 <[email protected]>
fs/nfsd/vfs.c +7 -4
@@ -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));
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
David Woodhouse
maintainer[JFFS2] Use d_splice_alias() not d_add() in jffs2_lookup()
Now that JFFS2 can be exported by NFS, we need to get this right.
Signed-off-by David Woodhouse <[email protected]>
fs/jffs2/dir.c +1 -3
@@ -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); }/***********************************************************************/
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation