From 02ff03a5a93668aa3964cc53918fcce37d99b744 Mon Sep 17 00:00:00 2001 From: sageweil Date: Wed, 19 Dec 2007 18:00:48 +0000 Subject: [PATCH] readdir over multiple fragments git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2234 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/include/ceph_fs.h | 11 ++++++++++- trunk/ceph/kernel/dir.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/trunk/ceph/include/ceph_fs.h b/trunk/ceph/include/ceph_fs.h index 38d37c0e3ae5e..fa8e6091e985a 100644 --- a/trunk/ceph/include/ceph_fs.h +++ b/trunk/ceph/include/ceph_fs.h @@ -21,7 +21,7 @@ typedef __u64 ceph_tid_t; typedef __u32 ceph_epoch_t; -/** +/* * fs id */ struct ceph_fsid { @@ -54,8 +54,17 @@ struct ceph_timeval { __u32 tv_usec; }; +/* + * dir fragments + */ typedef __u32 ceph_frag_t; +static inline __u32 frag_make(__u32 b, __u32 v) { return (b << 24) | (v & (0xffffffffull >> (32-b))); } +static inline __u32 frag_bits(__u32 f) { return f >> 24; } +static inline __u32 frag_value(__u32 f) { return f & 0xffffffu; } +static inline __u32 frag_mask(__u32 f) { return 0xffffffffull >> (32-frag_bits(f)); } +static inline __u32 frag_next(__u32 f) { return (frag_bits(f) << 24) | (frag_value(f)+1); } + /* * object layout - how objects are mapped into PGs diff --git a/trunk/ceph/kernel/dir.c b/trunk/ceph/kernel/dir.c index c2a9453a327c4..549e345c40b33 100644 --- a/trunk/ceph/kernel/dir.c +++ b/trunk/ceph/kernel/dir.c @@ -31,7 +31,6 @@ static int get_dentry_path(struct dentry *dn, char *buf, struct dentry *base) struct ceph_inode_cap *ceph_open(struct inode *inode, struct file *file, int flags) { - struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc; ceph_ino_t pathbase; char path[PATH_MAX]; @@ -184,7 +183,14 @@ nextfrag: filp->f_pos++; } - // next frag? FIXME *** + /* more frags? */ + if (frag_value(frag) != frag_mask(frag)) { + frag = frag_next(frag); + off = 0; + filp->f_pos = make_fpos(frag, off); + dout(10, "dir_readdir next frag is %u\n", frag); + goto nextfrag; + } dout(20, "dir_readdir done.\n"); return 0; -- 2.39.5