From 8b795e1e07a347530b716446d1da8ca0a8c287ca Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh-Weinraub Date: Mon, 10 Mar 2008 11:06:16 +0200 Subject: [PATCH] kernel module compiles on 2.6.18 --- src/kernel/client.c | 2 +- src/kernel/inode.c | 1 + src/kernel/mds_client.c | 19 +++++++++++++++++- src/kernel/messenger.c | 43 +++++++++++++++++++++++++++++++++++++---- src/kernel/osd_client.c | 6 ++++++ 5 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/kernel/client.c b/src/kernel/client.c index 2ead328615e21..ea67a0dd04869 100644 --- a/src/kernel/client.c +++ b/src/kernel/client.c @@ -61,7 +61,7 @@ static struct dentry *open_root_dentry(struct ceph_client *client, struct ceph_m req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_OPEN, 1, args->path, 0, 0); if (IS_ERR(req)) return ERR_PTR(PTR_ERR(req)); - req->r_expects_cap = true; + req->r_expects_cap = 1; reqhead = req->r_request->front.iov_base; reqhead->args.open.flags = O_DIRECTORY; reqhead->args.open.mode = 0; diff --git a/src/kernel/inode.c b/src/kernel/inode.c index ce82e67687614..e6b36e66df8a7 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -6,6 +6,7 @@ #include #include #include +#include int ceph_inode_debug = 50; #define DOUT_VAR ceph_inode_debug diff --git a/src/kernel/mds_client.c b/src/kernel/mds_client.c index ba01491f10078..0b78db51e83ef 100644 --- a/src/kernel/mds_client.c +++ b/src/kernel/mds_client.c @@ -360,7 +360,7 @@ static struct ceph_mds_request *new_request(struct ceph_msg *msg) req->r_reply = 0; req->r_last_inode = 0; req->r_last_dentry = 0; - req->r_expects_cap = false; + req->r_expects_cap = 0; req->r_cap = 0; req->r_session = 0; req->r_num_mds = 0; @@ -1289,10 +1289,18 @@ void schedule_delayed(struct ceph_mds_client *mdsc) schedule_delayed_work(&mdsc->delayed_work, hz); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) void delayed_work(struct work_struct *work) +#else +void delayed_work(void *arg) +#endif { int i; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) struct ceph_mds_client *mdsc = container_of(work, struct ceph_mds_client, delayed_work.work); +#else + struct ceph_mds_client *mdsc = arg; +#endif dout(10, "delayed_work on %p\n", mdsc); @@ -1324,7 +1332,11 @@ void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client) mdsc->last_requested_map = 0; init_completion(&mdsc->map_waiters); init_completion(&mdsc->session_close_waiters); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) INIT_DELAYED_WORK(&mdsc->delayed_work, delayed_work); +#else + INIT_WORK(&mdsc->delayed_work, delayed_work, mdsc); +#endif } void ceph_mdsc_stop(struct ceph_mds_client *mdsc) @@ -1354,7 +1366,12 @@ void ceph_mdsc_stop(struct ceph_mds_client *mdsc) spin_lock(&mdsc->lock); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) cancel_delayed_work_sync(&mdsc->delayed_work); /* cancel timer */ +#else + cancel_delayed_work(&mdsc->delayed_work); /* cancel timer */ + flush_scheduled_work(); +#endif spin_unlock(&mdsc->lock); } diff --git a/src/kernel/messenger.c b/src/kernel/messenger.c index 5f2f3dce8869d..aa9e7cec2c03e 100644 --- a/src/kernel/messenger.c +++ b/src/kernel/messenger.c @@ -22,11 +22,13 @@ static char tag_ack = CEPH_MSGR_TAG_ACK; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) static void try_read(struct work_struct *); +static void try_write(struct work_struct *); +static void try_accept(struct work_struct *); #else static void try_read(void *); +static void try_write(void *); +static void try_accept(void *); #endif -static void try_write(struct work_struct *); -static void try_accept(struct work_struct *); @@ -58,10 +60,11 @@ static struct ceph_connection *new_connection(struct ceph_messenger *msgr) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) INIT_WORK(&con->rwork, try_read); + INIT_DELAYED_WORK(&con->swork, try_write); #else INIT_WORK(&con->rwork, try_read, con); + INIT_WORK(&con->swork, try_write, con); #endif - INIT_DELAYED_WORK(&con->swork, try_write); return con; } @@ -190,13 +193,21 @@ static void __remove_connection(struct ceph_messenger *msgr, struct ceph_connect radix_tree_delete(&msgr->con_open, key); } else { slot = radix_tree_lookup_slot(&msgr->con_open, key); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) val = radix_tree_deref_slot(slot); +#else + val = *slot; +#endif dout(20, "__remove_connection %p from bucket %lu head %p\n", con, key, val); if (val == &con->list_bucket) { dout(20, "__remove_connection adjusting bucket ptr" " for %lu to next item, %p\n", key, con->list_bucket.next); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) radix_tree_replace_slot(slot, con->list_bucket.next); +#else + *slot = con->list_bucket.next; +#endif } list_del(&con->list_bucket); } @@ -236,7 +247,11 @@ void ceph_queue_write(struct ceph_connection *con) { dout(40, "ceph_queue_write %p\n", con); atomic_inc(&con->nref); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) if (!queue_work(send_wq, &con->swork.work)) { +#else + if (!queue_work(send_wq, &con->swork)) { +#endif dout(40, "ceph_queue_write %p - already queued\n", con); put_connection(con); } @@ -460,10 +475,18 @@ static void prepare_write_accept_reply(struct ceph_connection *con, char *ptag) /* * worker function when socket is writeable */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) static void try_write(struct work_struct *work) +#else +static void try_write(void *arg) +#endif { struct ceph_connection *con = +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) container_of(work, struct ceph_connection, swork.work); +#else + arg; +#endif struct ceph_messenger *msgr = con->msgr; int ret = 1; @@ -1011,12 +1034,20 @@ out: /* * worker function when listener receives a connect */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) static void try_accept(struct work_struct *work) +#else +static void try_accept(void *arg) +#endif { - struct ceph_connection *new_con = NULL; + struct ceph_connection *new_con = NULL; struct ceph_messenger *msgr; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) msgr = container_of(work, struct ceph_messenger, awork); +#else + msgr = arg; +#endif dout(5, "Entered try_accept\n"); @@ -1060,7 +1091,11 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr) msgr = kzalloc(sizeof(*msgr), GFP_KERNEL); if (msgr == NULL) return ERR_PTR(-ENOMEM); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) INIT_WORK(&msgr->awork, try_accept); +#else + INIT_WORK(&msgr->awork, try_accept, msgr); +#endif spin_lock_init(&msgr->con_lock); INIT_LIST_HEAD(&msgr->con_all); INIT_LIST_HEAD(&msgr->con_accepting); diff --git a/src/kernel/osd_client.c b/src/kernel/osd_client.c index eca06a1dc6ba2..810e96f9b2f4a 100644 --- a/src/kernel/osd_client.c +++ b/src/kernel/osd_client.c @@ -207,6 +207,8 @@ static void send_request(struct ceph_osd_client *osdc, struct ceph_osd_request * break; default: BUG_ON(1); + + return; /* remove compilation warning */ } nr_osds = crush_do_rule(osdc->osdmap->crush, rule, req->r_pgid.pg.ps, osds, 10, @@ -424,7 +426,11 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, calc_file_object_mapping(layout, &off, &len, &reqhead->oid, &reqhead->offset, &reqhead->length); BUG_ON(len != 0); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) nr_pages = DIV_ROUND_UP(reqhead->length, PAGE_SIZE); +#else + nr_pages = (reqhead->length + PAGE_SIZE - 1) / PAGE_SIZE; +#endif calc_object_layout(&reqhead->layout, &reqhead->oid, layout, osdc->osdmap); dout(10, "readpage object block %u %llu~%llu\n", reqhead->oid.bno, reqhead->offset, reqhead->length); -- 2.39.5