]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: use vmalloc for messages larger than one page
authorSage Weil <sage@newdream.net>
Thu, 30 Oct 2008 18:05:25 +0000 (11:05 -0700)
committerSage Weil <sage@newdream.net>
Thu, 30 Oct 2008 18:05:25 +0000 (11:05 -0700)
src/kernel/messenger.c
src/kernel/messenger.h

index 1e1fb2852fa8efea6d1eb0a513882e37092e9d23..eed0268bd050bae2d880762150850af8dc4bf258 100644 (file)
@@ -2271,10 +2271,16 @@ struct ceph_msg *ceph_msg_new(int type, int front_len,
        m->hdr.data_off = cpu_to_le32(page_off);
        m->footer.front_crc = 0;
        m->footer.data_crc = 0;
+       m->front_is_vmalloc = false;
 
        /* front */
        if (front_len) {
-               m->front.iov_base = kmalloc(front_len, GFP_NOFS);
+               if (front_len > PAGE_CACHE_SIZE) {
+                       m->front.iov_base = vmalloc(front_len);
+                       m->front_is_vmalloc = true;
+               } else {
+                       m->front.iov_base = kmalloc(front_len, GFP_NOFS);
+               }
                if (m->front.iov_base == NULL) {
                        derr(0, "ceph_msg_new can't allocate %d bytes\n",
                             front_len);
@@ -2318,7 +2324,10 @@ void ceph_msg_put(struct ceph_msg *m)
        if (atomic_dec_and_test(&m->nref)) {
                dout(20, "ceph_msg_put last one on %p\n", m);
                WARN_ON(!list_empty(&m->list_head));
-               kfree(m->front.iov_base);
+               if (m->front_is_vmalloc)
+                       vfree(m->front.iov_base);
+               else
+                       kfree(m->front.iov_base);
                kfree(m);
        }
 }
index 12097097df44234336ee7eb4ec2d95c7365600e5..2dfbaea39f483b387e35c94dc55af80cab60b3a0 100644 (file)
@@ -115,6 +115,7 @@ struct ceph_msg {
        unsigned nr_pages;              /* size of page array */
        struct list_head list_head;
        atomic_t nref;
+       bool front_is_vmalloc;
 };
 
 struct ceph_msg_pos {