From dad9ae8ec3246525c395a97abf2b4b1f07b7ea37 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 13 Mar 2008 13:35:02 -0700 Subject: [PATCH] client: touch vs init dentry --- src/kernel/dir.c | 16 ++++++---------- src/kernel/inode.c | 3 ++- src/kernel/mds_client.h | 24 ++++++++++++------------ src/kernel/super.h | 13 +++++++++++-- src/script/strip_trailing_whitespace.sh | 2 +- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/kernel/dir.c b/src/kernel/dir.c index 3b323c41cb0e4..2234dbba61d3d 100644 --- a/src/kernel/dir.c +++ b/src/kernel/dir.c @@ -116,6 +116,7 @@ static int prepopulate_dir(struct dentry *parent, dout(30, "d_alloc badness\n"); return -1; } + ceph_init_dentry(dn); } if (dn->d_inode == NULL) { @@ -261,7 +262,7 @@ const struct file_operations ceph_dir_fops = { }; -int ceph_request_lookup(struct super_block *sb, struct dentry *dentry) +int ceph_do_lookup(struct super_block *sb, struct dentry *dentry) { struct ceph_client *client = ceph_sb_to_client(sb); struct ceph_mds_client *mdsc = &client->mdsc; @@ -270,7 +271,7 @@ int ceph_request_lookup(struct super_block *sb, struct dentry *dentry) struct ceph_mds_request *req; int err; - dout(10, "request_lookup %p\n", dentry); + dout(10, "do_lookup %p\n", dentry); path = ceph_build_dentry_path(dentry, &pathlen); if (IS_ERR(path)) return PTR_ERR(path); @@ -285,20 +286,15 @@ int ceph_request_lookup(struct super_block *sb, struct dentry *dentry) err = ceph_mdsc_do_request(mdsc, req); ceph_mdsc_put_request(req); /* will dput(dentry) */ if (err == -ENOENT) { + ceph_init_dentry(dentry); ceph_touch_dentry(dentry); d_add(dentry, NULL); err = 0; } - dout(20, "request_lookup result=%d\n", err); + dout(20, "do_lookup result=%d\n", err); return err; } -void ceph_touch_dentry(struct dentry *dentry) -{ - dentry->d_time = jiffies; - dentry->d_op = &ceph_dentry_ops; -} - static struct dentry *ceph_dir_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) { @@ -315,7 +311,7 @@ static struct dentry *ceph_dir_lookup(struct inode *dir, struct dentry *dentry, } */ - err = ceph_request_lookup(dir->i_sb, dentry); + err = ceph_do_lookup(dir->i_sb, dentry); if (err == -ENOENT) d_add(dentry, NULL); else if (err < 0) diff --git a/src/kernel/inode.c b/src/kernel/inode.c index fff2c141fe314..31d4ff22aa7cf 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -220,6 +220,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) break; } } + ceph_init_dentry(dn); } ininfo = rinfo->trace_in[i].in; if (!ininfo) { @@ -719,7 +720,7 @@ int ceph_inode_revalidate(struct dentry *dentry) return 0; } dout(10, "revalidate %p is old\n", dentry); - return ceph_request_lookup(dentry->d_inode->i_sb, dentry); + return ceph_do_lookup(dentry->d_inode->i_sb, dentry); } int ceph_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) diff --git a/src/kernel/mds_client.h b/src/kernel/mds_client.h index 83ba746cd4d18..266512ee37547 100644 --- a/src/kernel/mds_client.h +++ b/src/kernel/mds_client.h @@ -23,7 +23,7 @@ struct ceph_mds_reply_info_in { struct ceph_mds_reply_info { struct ceph_mds_reply_head *head; - int trace_nr; + int trace_nr; struct ceph_mds_reply_info_in *trace_in; struct ceph_mds_reply_dirfrag **trace_dir; char **trace_dname; @@ -64,7 +64,7 @@ struct ceph_mds_session { struct ceph_mds_request { __u64 r_tid; struct ceph_msg * r_request; /* original request */ - struct ceph_msg * r_reply; + struct ceph_msg * r_reply; struct ceph_mds_reply_info r_reply_info; struct inode * r_last_inode; struct dentry * r_last_dentry; @@ -72,17 +72,17 @@ struct ceph_mds_request { struct ceph_inode_cap * r_cap; struct ceph_mds_session * r_session; struct ceph_mds_session * r_mds[2]; - int r_num_mds; /* items in r_mds */ + int r_num_mds; /* items in r_mds */ int r_attempts; /* resend attempts */ int r_num_fwd; /* number of forward attempts */ - int r_resend_mds; /* mds to resend to next, if any*/ + int r_resend_mds; /* mds to resend to next, if any*/ atomic_t r_ref; struct completion r_completion; }; -/* +/* * mds client state */ struct ceph_mds_client { @@ -104,27 +104,27 @@ struct ceph_mds_client { extern const char* ceph_mds_op_name(int op); -extern void ceph_mdsc_init(struct ceph_mds_client *mdsc, +extern void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client); extern void ceph_mdsc_stop(struct ceph_mds_client *mdsc); -extern void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, +extern void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg); extern void ceph_mdsc_handle_session(struct ceph_mds_client *mdsc, struct ceph_msg *msg); -extern void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, +extern void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg); -extern void ceph_mdsc_handle_forward(struct ceph_mds_client *mdsc, +extern void ceph_mdsc_handle_forward(struct ceph_mds_client *mdsc, struct ceph_msg *msg); -extern void ceph_mdsc_handle_filecaps(struct ceph_mds_client *mdsc, +extern void ceph_mdsc_handle_filecaps(struct ceph_mds_client *mdsc, struct ceph_msg *msg); struct ceph_inode_info; extern int ceph_mdsc_update_cap_wanted(struct ceph_inode_info *ci, int wanted); extern struct ceph_mds_request * -ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, - ceph_ino_t ino1, const char *path1, +ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, + ceph_ino_t ino1, const char *path1, ceph_ino_t ino2, const char *path2); extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, struct ceph_mds_request *req); diff --git a/src/kernel/super.h b/src/kernel/super.h index 11c158cd2078f..0bee76ebccc55 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -346,10 +346,19 @@ extern int ceph_inode_revalidate(struct dentry *dentry); /* dir.c */ extern const struct inode_operations ceph_dir_iops; extern const struct file_operations ceph_dir_fops; +extern struct dentry_operations ceph_dentry_ops; + extern char *ceph_build_dentry_path(struct dentry *dentry, int *len); extern int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req); -extern int ceph_request_lookup(struct super_block *sb, struct dentry *dentry); -extern void ceph_touch_dentry(struct dentry *dentry); +extern int ceph_do_lookup(struct super_block *sb, struct dentry *dentry); + +static inline void ceph_init_dentry(struct dentry *dentry) { + dentry->d_op = &ceph_dentry_ops; +} +static inline void ceph_touch_dentry(struct dentry *dentry) { + dentry->d_time = jiffies; + BUG_ON(dentry->d_op != &ceph_dentry_ops); +} /* proc.c */ extern void ceph_fs_proc_init(void); diff --git a/src/script/strip_trailing_whitespace.sh b/src/script/strip_trailing_whitespace.sh index 11a99f71bf935..7fa8060a6ef72 100755 --- a/src/script/strip_trailing_whitespace.sh +++ b/src/script/strip_trailing_whitespace.sh @@ -1,4 +1,4 @@ #!/bin/sh sed -i 's/[ \t]*$//' $1 -sed -i 's/ /\t/s' $1 +sed -i 's/^ /\t/' $1 -- 2.39.5