]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kernel module compiles on 2.6.18
authorYehuda Sadeh-Weinraub <yehuda@yehuda.infit.com>
Mon, 10 Mar 2008 09:06:16 +0000 (11:06 +0200)
committerYehuda Sadeh-Weinraub <yehuda@yehuda.infit.com>
Mon, 10 Mar 2008 09:06:16 +0000 (11:06 +0200)
src/kernel/client.c
src/kernel/inode.c
src/kernel/mds_client.c
src/kernel/messenger.c
src/kernel/osd_client.c

index 2ead328615e21910dd019a176e86752084bd4e22..ea67a0dd04869f72be72cab425f3deb985a26751 100644 (file)
@@ -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;
index ce82e67687614ff0f30dca21242f0e3f6fa9a758..e6b36e66df8a7b62fdf08fed68f370d6fcd7cfde 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/uaccess.h>
 #include <linux/kernel.h>
 #include <linux/ceph_fs.h>
+#include <linux/namei.h>
 
 int ceph_inode_debug = 50;
 #define DOUT_VAR ceph_inode_debug
index ba01491f10078e45182adf6e97178e4048afc371..0b78db51e83efaf13ebe81db22b069f602a6e0d2 100644 (file)
@@ -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);
 }
 
index 5f2f3dce8869d142350ec64054047e0d4bff4e42..aa9e7cec2c03e12bc09babd2bc6c5b07ebdd1f2d 100644 (file)
@@ -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);
index eca06a1dc6ba2002e85a5c5dc72dd9ef2cfbf989..810e96f9b2f4a2ba02c2465be63a42b42ed3966d 100644 (file)
@@ -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);