Skip to contentSkip to conversation

Optimise NFS readdir hack slightly.

PATCH In review David Woodhouse 1 participant 2 messages Aug 17, 2008 – Aug 18, 2008

Subsystems (3)
lore
Share & tools
lore

David Woodhouse

author maintainer
#0 lore raw

PATCH 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.

fs/nfsd/vfs.c +7 -4
index d789fb8..7631bd1 100644
@@ -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
author maintainer
#1 lore raw

[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.

fs/jffs2/dir.c +1 -3
index cd219ef..d4d9f32 100644
@@ -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