From a4e95cc51221475e80b0780a4823cc945491f48e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 13 Mar 2008 13:20:32 -0700 Subject: [PATCH] client: cleanup --- src/kernel/dir.c | 20 ++++++------- src/kernel/inode.c | 26 ++++++++++------- src/kernel/mds_client.h | 38 +++++++++++++++---------- src/script/strip_trailing_whitespace.sh | 1 + 4 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/kernel/dir.c b/src/kernel/dir.c index a0d9b12a9bd05..3b323c41cb0e4 100644 --- a/src/kernel/dir.c +++ b/src/kernel/dir.c @@ -46,8 +46,8 @@ retry: } else { strncpy(path + pos, temp->d_name.name, temp->d_name.len); - dout(30, "build_path_dentry path+%d: '%s'\n", - pos, path + pos); + dout(30, "build_path_dentry path+%d: '%.*s'\n", + pos, temp->d_name.len, path + pos); if (pos) path[--pos] = '/'; } @@ -69,8 +69,8 @@ retry: goto retry; } - dout(10, "build_path_dentry on %p build '%s' len %d\n", - dentry, path, len); + dout(10, "build_path_dentry on %p build '%.*s'\n", + dentry, len, path); *plen = len; return path; } @@ -107,8 +107,8 @@ static int prepopulate_dir(struct dentry *parent, dname.hash = full_name_hash(dname.name, dname.len); dn = d_lookup(parent, &dname); - dout(30, "calling d_lookup on parent=%p name=%s" - " returned %p\n", parent, dname.name, dn); + dout(30, "calling d_lookup on parent=%p name=%.*s" + " returned %p\n", parent, dname.len, dname.name, dn); if (!dn) { dn = d_alloc(parent, &dname); @@ -304,8 +304,8 @@ static struct dentry *ceph_dir_lookup(struct inode *dir, struct dentry *dentry, { int err; - dout(5, "dir_lookup in dir %p dentry %p '%s'\n", - dir, dentry, dentry->d_name.name); + dout(5, "dir_lookup in dir %p dentry %p '%.*s'\n", + dir, dentry, dentry->d_name.len, dentry->d_name.name); /* open(|create) intent? */ /* @@ -496,8 +496,8 @@ ceph_dir_create(struct inode *dir, struct dentry *dentry, int mode, struct ceph_mds_request_head *rhead; int err; - dout(5, "create in dir %p dentry %p name '%s' flags %d\n", - dir, dentry, dentry->d_name.name, mode); + dout(5, "create in dir %p dentry %p name '%.*s' flags %d\n", + dir, dentry, dentry->d_name.len, dentry->d_name.name, mode); pathbase = ceph_ino(dir->i_sb->s_root->d_inode); path = ceph_build_dentry_path(dentry, &pathlen); if (IS_ERR(path)) diff --git a/src/kernel/inode.c b/src/kernel/inode.c index 7f96172a074d7..fff2c141fe314 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -161,6 +161,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) struct dentry *dn = sb->s_root; struct dentry *parent = NULL; struct inode *in; + struct ceph_mds_reply_inode *ininfo; int i = 0; if (rinfo->trace_nr == 0) { @@ -172,8 +173,9 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) in = dn->d_inode; } else { /* first reply (i.e. mount) */ - BUG_ON(i); - err = ceph_get_inode(sb, le64_to_cpu(rinfo->trace_in[0].in->ino), &in); + err = ceph_get_inode(sb, + le64_to_cpu(rinfo->trace_in[0].in->ino), + &in); if (err < 0) return err; dn = d_alloc_root(in); @@ -192,19 +194,21 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) dget(dn); for (i = 1; i < rinfo->trace_nr; i++) { - dout(10, "fill_trace i=%d/%d dn %p in %p dname '%s'\n", i, rinfo->trace_nr, + dout(10, "fill_trace i=%d/%d dn %p in %p dname '%s'\n", + i, rinfo->trace_nr, dn, dn->d_inode, rinfo->trace_dname[i]); parent = dn; dname.name = rinfo->trace_dname[i]; dname.len = rinfo->trace_dname_len[i]; dname.hash = full_name_hash(dname.name, dname.len); - dout(10, "fill_trace calling d_lookup on '%s'\n", dname.name); + dout(10, "fill_trace calling d_lookup on '%.*s'\n", + (int)dname.len, dname.name); dn = d_lookup(parent, &dname); if (!dn) { if (req->r_last_dentry && req->r_last_dentry->d_parent == parent) { - dout(10, "fill_trace using dentry provided in req\n"); + dout(10, "fill_trace using provided dentry\n"); dn = req->r_last_dentry; req->r_last_dentry = NULL; } else { @@ -217,7 +221,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) } } } - if (!rinfo->trace_in[i].in) { + ininfo = rinfo->trace_in[i].in; + if (!ininfo) { dout(10, "fill_trace has dentry but no inode\n"); err = -ENOENT; d_add(dn, NULL); @@ -226,7 +231,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) } if ((!dn->d_inode) || - (ceph_ino(dn->d_inode) != rinfo->trace_in[i].in->ino)) { + (ceph_ino(dn->d_inode) != ininfo->ino)) { dout(10, "fill_trace new_inode\n"); in = new_inode(parent->d_sb); if (in == NULL) { @@ -236,7 +241,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) dn = NULL; break; } - if ((err = ceph_fill_inode(in, rinfo->trace_in[i].in)) < 0) { + if ((err = ceph_fill_inode(in, ininfo)) < 0) { dout(30, "ceph_fill_inode badness\n"); iput(in); d_delete(dn); @@ -246,11 +251,12 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) ceph_touch_dentry(dn); dout(10, "fill_trace d_add\n"); d_add(dn, in); - dout(10, "ceph_fill_trace added dentry %p inode %llx %d/%d\n", + dout(10, "ceph_fill_trace added dentry %p" + " inode %llx %d/%d\n", dn, ceph_ino(in), i, rinfo->trace_nr); } else { in = dn->d_inode; - if ((err = ceph_fill_inode(in, rinfo->trace_in[i].in)) < 0) { + if ((err = ceph_fill_inode(in, ininfo)) < 0) { dout(30, "ceph_fill_inode badness\n"); break; } diff --git a/src/kernel/mds_client.h b/src/kernel/mds_client.h index 6a63abebf5c1b..83ba746cd4d18 100644 --- a/src/kernel/mds_client.h +++ b/src/kernel/mds_client.h @@ -72,9 +72,7 @@ struct ceph_mds_request { struct ceph_inode_cap * r_cap; struct ceph_mds_session * r_session; struct ceph_mds_session * r_mds[2]; - - //__u32 r_mds[2]; /* set of mds's with whom request may be outstanding */ - 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 */ @@ -88,12 +86,12 @@ struct ceph_mds_request { * mds client state */ struct ceph_mds_client { - spinlock_t lock; /* protects all nested structures */ + spinlock_t lock; /* all nested structures */ struct ceph_client *client; struct ceph_mdsmap *mdsmap; struct ceph_mds_session **sessions; /* NULL if no session */ - int max_sessions; /* size of s_mds_sessions array */ - __u64 last_tid; /* id of most recent mds request */ + int max_sessions; /* len of s_mds_sessions */ + __u64 last_tid; /* most recent mds request */ struct radix_tree_root request_tree; /* pending mds requests */ __u64 last_requested_map; struct completion map_waiters, session_close_waiters; @@ -106,20 +104,30 @@ struct ceph_mds_client { extern const char* ceph_mds_op_name(int op); -extern void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client); +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, 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, struct ceph_msg *msg); -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, struct ceph_msg *msg); +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, + struct ceph_msg *msg); +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, + 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_ino_t ino2, const char *path2); -extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, struct ceph_mds_request *req); +extern struct ceph_mds_request * +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); extern void ceph_mdsc_put_request(struct ceph_mds_request *req); #endif diff --git a/src/script/strip_trailing_whitespace.sh b/src/script/strip_trailing_whitespace.sh index 2d24dcfea862e..11a99f71bf935 100755 --- a/src/script/strip_trailing_whitespace.sh +++ b/src/script/strip_trailing_whitespace.sh @@ -1,3 +1,4 @@ #!/bin/sh sed -i 's/[ \t]*$//' $1 +sed -i 's/ /\t/s' $1 -- 2.39.5