From 61f6ce6b3beb79a27b145d32a11303b36e847c8c Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 13 Nov 2007 20:29:25 +0000 Subject: [PATCH] super cleanup, fixed some misc compile errors git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2062 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/kernel/client.h | 8 ++++-- trunk/ceph/kernel/ktcp.c | 2 +- trunk/ceph/kernel/mds_client.c | 16 ++++++++--- trunk/ceph/kernel/messenger.c | 20 ++++++++------ trunk/ceph/kernel/mon_client.h | 2 ++ trunk/ceph/kernel/osd_client.h | 2 +- trunk/ceph/kernel/super.c | 50 ++++++++++++++++++---------------- 7 files changed, 58 insertions(+), 42 deletions(-) diff --git a/trunk/ceph/kernel/client.h b/trunk/ceph/kernel/client.h index 60253c63ec008..40a850b43b914 100644 --- a/trunk/ceph/kernel/client.h +++ b/trunk/ceph/kernel/client.h @@ -9,7 +9,8 @@ * different relative server paths) */ -#include +#include +#include #include "messenger.h" #include "monmap.h" @@ -35,10 +36,11 @@ enum { */ struct ceph_client { __u32 whoami; /* my client number */ + struct ceph_fsid fsid; atomic_t nref; atomic_t mounting; - struct wait_queue mount_wq; + wait_queue_t mount_wq; struct ceph_messenger *msgr; /* messenger instance */ struct ceph_mon_client monc; @@ -51,7 +53,7 @@ struct ceph_client { struct list_head sb_list; }; -extern struct ceph_client *ceph_get_client(ceph_mount_args *args); +extern struct ceph_client *ceph_get_client(struct ceph_mount_args *args); extern void ceph_put_client(struct ceph_client *cl); #endif diff --git a/trunk/ceph/kernel/ktcp.c b/trunk/ceph/kernel/ktcp.c index bcf25d2274941..2fbec52c17247 100644 --- a/trunk/ceph/kernel/ktcp.c +++ b/trunk/ceph/kernel/ktcp.c @@ -2,7 +2,7 @@ #include #include #include -#include "kmsg.h" +#include "messenger.h" #include "ktcp.h" diff --git a/trunk/ceph/kernel/mds_client.c b/trunk/ceph/kernel/mds_client.c index 6e39706a0166e..a6cc8255fe508 100644 --- a/trunk/ceph/kernel/mds_client.c +++ b/trunk/ceph/kernel/mds_client.c @@ -108,7 +108,7 @@ static void open_session(struct ceph_mds_client *mdsc, struct ceph_mds_session * /* connect */ if (ceph_mdsmap_get_state(mdsc->mdsmap, mds) < CEPH_MDS_STATE_ACTIVE) { - ceph_monc_request_mdsmap(&mdsc->client->mon_client, mdsc->mdsmap->m_epoch); /* race fixme */ + ceph_monc_request_mdsmap(&mdsc->client->monc, mdsc->mdsmap->m_epoch); /* race fixme */ return; } @@ -123,7 +123,7 @@ static void open_session(struct ceph_mds_client *mdsc, struct ceph_mds_session * static void wait_for_new_map(struct ceph_mds_client *mdsc) { if (mdsc->last_requested_map < mdsc->mdsmap->m_epoch) - ceph_monc_request_mdsmap(&mdsc->client->mon_client, mdsc->mdsmap->m_epoch); + ceph_monc_request_mdsmap(&mdsc->client->monc, mdsc->mdsmap->m_epoch); wait_for_completion(&mdsc->map_waiters); } @@ -284,10 +284,13 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_bufferlist_iterator bli; __u64 epoch; __u32 left; + int err; ceph_bl_iterator_init(&bli); - epoch = ceph_bl_decode_u64(&msg->payload, &bli); - left = ceph_bl_decode_u32(&msg->payload, &bli); + if ((err = ceph_bl_decode_64(&msg->payload, &bli, &epoch)) != 0) + goto bad; + if ((err = ceph_bl_decode_32(&msg->payload, &bli, &left)) != 0) + goto bad; dout(2, "ceph_mdsc_handle_map epoch %llu\n", epoch); @@ -300,5 +303,10 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, spin_unlock(&mdsc->lock); } +out: ceph_put_msg(msg); + return; +bad: + dout(1, "corrupt map\n"); + goto out; } diff --git a/trunk/ceph/kernel/messenger.c b/trunk/ceph/kernel/messenger.c index 2766efca5b64d..bb9e7c892927b 100644 --- a/trunk/ceph/kernel/messenger.c +++ b/trunk/ceph/kernel/messenger.c @@ -31,8 +31,9 @@ static struct ceph_connection *new_connection(struct ceph_messenger *msgr) { struct ceph_connection *con; con = kmalloc(sizeof(struct ceph_connection), GFP_KERNEL); - if (con == NULL) return 0; - memset(&con, 0, sizeof(con)); + if (con == NULL) + return NULL; + memset(con, 0, sizeof(*con)); con->msgr = msgr; @@ -408,7 +409,7 @@ static void prepare_read_message(struct ceph_connection *con) con->in_tag = CEPH_MSGR_TAG_MSG; con->in_base_pos = 0; con->in_partial = kmalloc(sizeof(struct ceph_message), GFP_KERNEL); - if (!con->in_partial) { + if (con->in_partial == NULL) { /* TBD: we don't check for error in caller, handle error */ printk(KERN_INFO "malloc failure\n"); goto done; @@ -625,9 +626,10 @@ struct ceph_connection *new_listener(struct ceph_messenger *msgr) struct sockaddr saddr; memset(&saddr, 0, sizeof(saddr)); - con = kmalloc(sizeof(struct ceph_connection), GFP_KERNEL); - if (con == NULL) return NULL; - memset(&con, 0, sizeof(con)); + con = kmalloc(sizeof(*con), GFP_KERNEL); + if (con == NULL) + return NULL; + memset(con, 0, sizeof(*con)); /* create listener connection */ spin_lock_init(&con->con_lock); @@ -650,10 +652,10 @@ static struct ceph_messenger *new_messenger(void) struct ceph_messenger *msgr; struct ceph_connection *listener; - msgr = kmalloc(sizeof(struct ceph_messenger), GFP_KERNEL); + msgr = kmalloc(sizeof(*msgr), GFP_KERNEL); if (msgr == NULL) goto done; - memset(&msgr, 0, sizeof(msgr)); + memset(msgr, 0, sizeof(*msgr)); spin_lock_init(&msgr->con_lock); INIT_LIST_HEAD(&msgr->poll_list); @@ -687,7 +689,7 @@ struct ceph_message *ceph_new_message(int type, int size) if (m == NULL) return ERR_PTR(-ENOMEM); memset(m, 0, sizeof(*m)); - m.hdr.type = type; + m->hdr.type = type; if (size) { BUG_ON(size); /* implement me */ diff --git a/trunk/ceph/kernel/mon_client.h b/trunk/ceph/kernel/mon_client.h index 1bf30c094d196..38815e12f0029 100644 --- a/trunk/ceph/kernel/mon_client.h +++ b/trunk/ceph/kernel/mon_client.h @@ -1,6 +1,8 @@ #ifndef _FS_CEPH_MON_CLIENT_H #define _FS_CEPH_MON_CLIENT_H +#include "monmap.h" + struct ceph_mount_args; struct ceph_mon_client { diff --git a/trunk/ceph/kernel/osd_client.h b/trunk/ceph/kernel/osd_client.h index 6d8cef636f1a3..ef99ba2c0a39c 100644 --- a/trunk/ceph/kernel/osd_client.h +++ b/trunk/ceph/kernel/osd_client.h @@ -14,7 +14,7 @@ struct ceph_osd_client { }; -extern void ceph_osdc_init(struct ceph_osdc_init *osdc); +extern void ceph_osdc_init(struct ceph_osd_client *osdc); extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, struct ceph_message *msg); extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_message *msg); diff --git a/trunk/ceph/kernel/super.c b/trunk/ceph/kernel/super.c index 748df7c5d1946..bbe68821dcbeb 100644 --- a/trunk/ceph/kernel/super.c +++ b/trunk/ceph/kernel/super.c @@ -1,5 +1,9 @@ #include +#include +#include +#include +#include #include "super.h" @@ -16,8 +20,6 @@ static void ceph_read_inode(struct inode * inode) static int ceph_write_inode(struct inode * inode, int unused) { - lock_kernel(); - unlock_kernel(); return 0; } @@ -26,7 +28,7 @@ static void ceph_delete_inode(struct inode * inode) return; } -static void ceph_clear_inode(struct inode * inode, int unused) +static void ceph_clear_inode(struct inode * inode) { } @@ -58,13 +60,13 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt) struct ceph_mount_args *args = &sbinfo->mount_args; if (ceph_debug != 0) - seq_printf(",debug=%d", ceph_debug); + seq_printf(m, ",debug=%d", ceph_debug); if (args->flags & CEPH_MOUNT_FSID) - seq_printf(",fsidmajor=%ld,fsidminor%ld", + seq_printf(m, ",fsidmajor=%llu,fsidminor%llu", args->fsid.major, args->fsid.minor); if (args->flags & CEPH_MOUNT_NOSHARE) - seq_puts(",noshare"); - seq_printf(",monport=%d", args->mon_port); + seq_puts(m, ",noshare"); + seq_printf(m, ",monport=%d", args->mon_port); return 0; } @@ -88,22 +90,19 @@ static void ceph_destroy_inode(struct inode *inode) kmem_cache_free(ceph_inode_cachep, CEPH_I(inode)); } -static void ceph_icache_init_once(void *foo, struct kmem_cache *cachep, unsigned long flags) +static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags) { - struct ceph_inode_info *ci = (struct ceph_inode_info *) foo; - - if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == - SLAB_CTOR_CONSTRUCTOR) - inode_init_once(&ci->vfs_inode); + struct ceph_inode_info *ci = foo; + inode_init_once(&ci->vfs_inode); } - -static int init_inodecache(void) + +static int init_inodecache(void *foo, struct kmem_cache *cachep, unsigned long flags) { ceph_inode_cachep = kmem_cache_create("ceph_inode_cache", sizeof(struct ceph_inode_info), 0, (SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), - ceph_icache_init_once, NULL); + init_once); if (ceph_inode_cachep == NULL) return -ENOMEM; return 0; @@ -131,6 +130,7 @@ static int ceph_set_super(struct super_block *s, void *data) { struct ceph_mount_args *args = data; struct ceph_super_info *sbinfo; + int ret; s->s_flags = args->mntflags; @@ -140,7 +140,7 @@ static int ceph_set_super(struct super_block *s, void *data) memset(sbinfo, 0, sizeof(*sbinfo)); s->s_fs_info = sbinfo; - memcpy(sbinfo->mount_args, args, sizeof(*args)); + memcpy(&sbinfo->mount_args, args, sizeof(*args)); ret = set_anon_super(s, 0); /* what is the second arg for? */ if (ret != 0) @@ -164,11 +164,12 @@ static int ceph_compare_super(struct super_block *sb, void *data) /* either compare fsid, or specified mon_hostname */ if (args->flags & CEPH_MOUNT_FSID) { - if (!ceph_fsid_equal(&args->fsid, other->sb_client->fsid)) + if (!ceph_fsid_equal(&args->fsid, &other->sb_client->fsid)) return 1; } else { - if (strcmp(args->mon_hostname, other->mount_args.mon_hostname) != 0) + /*if (strcmp(args->mon_hostname, other->mount_args.mon_hostname) != 0) return 1; + */ } if (strcmp(args->path, other->mount_args.path) != 0) return 1; @@ -179,7 +180,8 @@ static int ceph_compare_super(struct super_block *sb, void *data) enum { - Opt_fsid, + Opt_fsidmajor, + Opt_fsidminor, Opt_debug, Opt_monport }; @@ -196,7 +198,7 @@ static int parse_mount_args(int flags, char *options, char *dev_name, struct cep { char *c; int len; - substring_t args[MAX_OPT_ARGS]; + substring_t argstr[MAX_OPT_ARGS]; dout(1, "parse_mount_args dev_name %s\n", dev_name); @@ -206,7 +208,7 @@ static int parse_mount_args(int flags, char *options, char *dev_name, struct cep args->mon_port = CEPH_MON_PORT; /* get mon hostname, relative path */ - c = strchr(dev_name, ":"); + c = strchr(dev_name, ':'); if (c == NULL) return -EINVAL; len = c - dev_name; @@ -228,8 +230,8 @@ static int parse_mount_args(int flags, char *options, char *dev_name, struct cep int ret; if (!*p) continue; - token = match_token(p, arg_tokens, args); - ret = match_int(&args[0], &intval); + token = match_token(p, arg_tokens, argstr); + ret = match_int(&argstr[0], &intval); if (ret < 0) { dout(0, "bad mount arg\n"); continue; -- 2.39.5