From 3138356e9379baaa0983e51f11705a3c2dbae43f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 21 Jul 2009 09:53:33 -0700 Subject: [PATCH] kclient: some dir.c cleanup --- src/TODO | 20 ++++++++++++++------ src/kernel/dir.c | 34 +++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/TODO b/src/TODO index dc2933433dd96..1ccc80dab96a4 100644 --- a/src/TODO +++ b/src/TODO @@ -31,12 +31,20 @@ v0.10 /- improved monitor read model - osd bugfixes -kclient review -- andi -/ - server-specified max file size -/ - pr_debug -/ - top of file comments -- test nfs export +v0.11 +(andi) +/- server-specified max file size +/- simplified pr_debug macro +/- more comments +/- added a few missing '__attribute__ ((packed))' +/- kcalloc throughout (chris wright) +/- simplified export.c (jbfields) +/- cleaned up mount code +/- kmem_cache for dentry_info +/- EBADF on bad caps +/- fixed stray unaligned access +/- respond to control-c on slow/hung mount + bugs - premature filejournal trimming? diff --git a/src/kernel/dir.c b/src/kernel/dir.c index e1ea029743c01..205f834a60981 100644 --- a/src/kernel/dir.c +++ b/src/kernel/dir.c @@ -6,6 +6,10 @@ #include "ceph_debug.h" #include "super.h" +/* + * Directory operations: lookup, create, link, unlink, rename, etc. + */ + /* * Ceph MDS operations are specified in terms of a base ino and * relative path. Thus, the client can specify an operation on a @@ -25,8 +29,8 @@ struct dentry_operations ceph_dentry_ops; static int ceph_dentry_revalidate(struct dentry *dentry, struct nameidata *nd); /* - * for readdir, encoding the directory frag and offset within that frag - * into f_pos. + * for readdir, we encode the directory frag and offset within that + * frag into f_pos. */ static unsigned fpos_frag(loff_t p) { @@ -38,14 +42,15 @@ static unsigned fpos_off(loff_t p) } /* - * Satisfy a readdir by peeking at the dcache. We make this work by - * carefully ordering dentryes on d_u.d_child when we initially get - * results back from the MDS, and falling back to a "normal" sync - * readdir if any dentries in the dir are dropped. + * When possible, we try to satisfy a readdir by peeking at the + * dcache. We make this work by carefully ordering dentries on + * d_u.d_child when we initially get results back from the MDS, and + * falling back to a "normal" sync readdir if any dentries in the dir + * are dropped. * - * I_COMPLETE tells indicates we have all dirs. It is defined IFF we - * hold the CEPH_CAP_FILE_SHARED (which will be revoked by the MDS - * if/when the directory is modified). + * I_COMPLETE tells indicates we have all dentries in the dir. It is + * defined IFF we hold CEPH_CAP_FILE_SHARED (which will be revoked by + * the MDS if/when the directory is modified). */ static int __dcache_readdir(struct file *filp, void *dirent, filldir_t filldir) @@ -59,13 +64,16 @@ static int __dcache_readdir(struct file *filp, struct ceph_dentry_info *di; int err = 0; + /* claim ref on last dentry we returned */ last = fi->dentry; fi->dentry = NULL; + dout("__dcache_readdir %p at %llu (last %p)\n", dir, filp->f_pos, last); spin_lock(&dcache_lock); + /* start at beginning? */ if (filp->f_pos == 2 || (last && filp->f_pos < ceph_dentry(last)->offset)) { if (list_empty(&parent->d_subdirs)) @@ -111,15 +119,15 @@ more: dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode); filp->f_pos = di->offset; err = filldir(dirent, dentry->d_name.name, - dentry->d_name.len, di->offset, - dentry->d_inode->i_ino, - dentry->d_inode->i_mode >> 12); + dentry->d_name.len, di->offset, + dentry->d_inode->i_ino, + dentry->d_inode->i_mode >> 12); spin_lock(&inode->i_lock); spin_lock(&dcache_lock); if (err < 0) { - fi->dentry = dentry; + fi->dentry = dentry; /* remember our position */ goto out_unlock; } -- 2.39.5