@@ -38,6 +38,7 @@
#include <linux/libcfs/libcfs_cpu.h>
#include <linux/delay.h>
#include <linux/random.h>
+#include <linux/vmalloc.h>
#include <obd_support.h>
#include <obd_class.h>
@@ -529,7 +530,10 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
list_del(&req->rq_list);
LASSERT(req->rq_reqbuf);
LASSERT(req->rq_reqbuf_len == pool->prp_rq_size);
- kvfree(req->rq_reqbuf);
+ if (is_vmalloc_addr(req->rq_reqbuf))
+ vfree_atomic(req->rq_reqbuf);
+ else
+ kfree(req->rq_reqbuf);
ptlrpc_request_cache_free(req);
}
kfree(pool);
@@ -42,6 +42,7 @@
#include <linux/cred.h>
#include <linux/key.h>
#include <linux/sched/task.h>
+#include <linux/vmalloc.h>
#include <obd.h>
#include <obd_class.h>
@@ -474,7 +475,10 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req,
req->rq_flvr = old_flvr;
}
- kvfree(reqmsg);
+ if (is_vmalloc_addr(reqmsg))
+ vfree_atomic(reqmsg);
+ else
+ kfree(reqmsg);
}
return rc;
}
@@ -836,7 +840,10 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req)
if (req->rq_pool || !req->rq_reqbuf)
return;
- kvfree(req->rq_reqbuf);
+ if (is_vmalloc_addr(req->rq_reqbuf))
+ vfree_atomic(req->rq_reqbuf);
+ else
+ kfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
@@ -1133,7 +1140,10 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
err_ctx:
sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
err_buf:
- kvfree(early_buf);
+ if (is_vmalloc_addr(early_buf))
+ vfree_atomic(early_buf);
+ else
+ kfree(early_buf);
err_req:
ptlrpc_request_cache_free(early_req);
return rc;
@@ -1151,7 +1161,10 @@ void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req)
LASSERT(early_req->rq_repmsg);
sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1);
- kvfree(early_req->rq_repbuf);
+ if (is_vmalloc_addr(early_req->rq_repbuf))
+ vfree_atomic(early_req->rq_repbuf);
+ else
+ kfree(early_req->rq_repbuf);
ptlrpc_request_cache_free(early_req);
}
@@ -37,6 +37,7 @@
#define DEBUG_SUBSYSTEM S_SEC
+#include <linux/vmalloc.h>
#include <linux/libcfs/libcfs.h>
#include <obd.h>
@@ -380,7 +381,10 @@ static inline void enc_pools_free(void)
LASSERT(page_pools.epp_max_pools);
LASSERT(page_pools.epp_pools);
- kvfree(page_pools.epp_pools);
+ if (is_vmalloc_addr(page_pools.epp_pools))
+ vfree_atomic(page_pools.epp_pools);
+ else
+ kfree(page_pools.epp_pools);
}
static struct shrinker pools_shrinker = {
@@ -37,6 +37,7 @@
#define DEBUG_SUBSYSTEM S_SEC
+#include <linux/vmalloc.h>
#include <obd_support.h>
#include <obd_cksum.h>
#include <obd_class.h>
@@ -180,7 +181,10 @@ void null_free_reqbuf(struct ptlrpc_sec *sec,
"req %p: reqlen %d should smaller than buflen %d\n",
req, req->rq_reqlen, req->rq_reqbuf_len);
- kvfree(req->rq_reqbuf);
+ if (is_vmalloc_addr(req->rq_reqbuf))
+ vfree_atomic(req->rq_reqbuf);
+ else
+ kfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
@@ -210,7 +214,10 @@ void null_free_repbuf(struct ptlrpc_sec *sec,
{
LASSERT(req->rq_repbuf);
- kvfree(req->rq_repbuf);
+ if (is_vmalloc_addr(req->rq_repbuf))
+ vfree_atomic(req->rq_repbuf);
+ else
+ kfree(req->rq_repbuf);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
}
@@ -257,7 +264,10 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
spin_lock(&req->rq_import->imp_lock);
memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);
- kvfree(req->rq_reqbuf);
+ if (is_vmalloc_addr(req->rq_reqbuf))
+ vfree_atomic(req->rq_reqbuf);
+ else
+ kfree(req->rq_reqbuf);
req->rq_reqbuf = newbuf;
req->rq_reqmsg = newbuf;
req->rq_reqbuf_len = alloc_size;
@@ -337,8 +347,12 @@ void null_free_rs(struct ptlrpc_reply_state *rs)
LASSERT_ATOMIC_GT(&rs->rs_svc_ctx->sc_refcount, 1);
atomic_dec(&rs->rs_svc_ctx->sc_refcount);
- if (!rs->rs_prealloc)
- kvfree(rs);
+ if (!rs->rs_prealloc) {
+ if (is_vmalloc_addr(rs))
+ vfree_atomic(rs);
+ else
+ kfree(rs);
+ }
}
static
@@ -38,6 +38,7 @@
#define DEBUG_SUBSYSTEM S_SEC
#include <linux/highmem.h>
+#include <linux/vmalloc.h>
#include <obd_support.h>
#include <obd_cksum.h>
#include <obd_class.h>
@@ -582,7 +583,10 @@ void plain_free_reqbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req)
{
if (!req->rq_pool) {
- kvfree(req->rq_reqbuf);
+ if (is_vmalloc_addr(req->rq_reqbuf))
+ vfree_atomic(req->rq_reqbuf);
+ else
+ kfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
@@ -623,7 +627,10 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec,
void plain_free_repbuf(struct ptlrpc_sec *sec,
struct ptlrpc_request *req)
{
- kvfree(req->rq_repbuf);
+ if (is_vmalloc_addr(req->rq_repbuf))
+ vfree_atomic(req->rq_repbuf);
+ else
+ kfree(req->rq_repbuf);
req->rq_repbuf = NULL;
req->rq_repbuf_len = 0;
}
@@ -678,7 +685,10 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
- kvfree(req->rq_reqbuf);
+ if (is_vmalloc_addr(req->rq_reqbuf))
+ vfree_atomic(req->rq_reqbuf);
+ else
+ kfree(req->rq_reqbuf);
req->rq_reqbuf = newbuf;
req->rq_reqbuf_len = newbuf_size;
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf,
@@ -823,8 +833,12 @@ void plain_free_rs(struct ptlrpc_reply_state *rs)
LASSERT(atomic_read(&rs->rs_svc_ctx->sc_refcount) > 1);
atomic_dec(&rs->rs_svc_ctx->sc_refcount);
- if (!rs->rs_prealloc)
- kvfree(rs);
+ if (!rs->rs_prealloc) {
+ if (is_vmalloc_addr(rs))
+ vfree_atomic(rs);
+ else
+ kfree(rs);
+ }
}
static
@@ -36,6 +36,7 @@
#include <linux/kthread.h>
#include <linux/ratelimit.h>
#include <linux/fs_struct.h>
+#include <linux/vmalloc.h>
#include <obd_support.h>
#include <obd_class.h>
@@ -118,7 +119,10 @@ static void ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
svcpt->scp_nrqbds_total--;
spin_unlock(&svcpt->scp_lock);
- kvfree(rqbd->rqbd_buffer);
+ if (is_vmalloc_addr(rqbd->rqbd_buffer))
+ vfree_atomic(rqbd->rqbd_buffer);
+ else
+ kfree(rqbd->rqbd_buffer);
kfree(rqbd);
}
@@ -838,7 +842,10 @@ static void ptlrpc_server_drop_request(struct ptlrpc_request *req)
test_req_buffer_pressure) {
/* like in ptlrpc_free_rqbd() */
svcpt->scp_nrqbds_total--;
- kvfree(rqbd->rqbd_buffer);
+ if (is_vmalloc_addr(rqbd->rqbd_buffer))
+ vfree_atomic(rqbd->rqbd_buffer);
+ else
+ kfree(rqbd->rqbd_buffer);
kfree(rqbd);
} else {
list_add_tail(&rqbd->rqbd_list,
@@ -1197,7 +1204,10 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req)
class_export_put(reqcopy->rq_export);
out:
sptlrpc_svc_ctx_decref(reqcopy);
- kvfree(reqmsg);
+ if (is_vmalloc_addr(reqmsg))
+ vfree_atomic(reqmsg);
+ else
+ kfree(reqmsg);
out_free:
ptlrpc_request_cache_free(reqcopy);
return rc;
@@ -2938,7 +2948,10 @@ static void ptlrpc_wait_replies(struct ptlrpc_service_part *svcpt)
struct ptlrpc_reply_state,
rs_list)) != NULL) {
list_del(&rs->rs_list);
- kvfree(rs);
+ if (is_vmalloc_addr(rs))
+ vfree_atomic(rs);
+ else
+ kfree(rs);
}
}
}
@@ -2355,6 +2355,7 @@ void vfree_atomic(const void *addr)
return;
__vfree_deferred(addr);
}
+EXPORT_SYMBOL(vfree_atomic);
static void __vfree(const void *addr)
{