[openib-general] [PATCH] support kernel-level sockets in sdp
Michael S. Tsirkin
mst at mellanox.co.il
Thu Nov 3 06:00:12 PST 2005
Hi!
I plan to commit the following. Comments?
---
The following patch adds support for kernel-level sockets in SDP Zcopy
(currently used with AIO).
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>
Index: drivers/infiniband/ulp/sdp/sdp_iocb.c
===================================================================
--- drivers/infiniband/ulp/sdp/sdp_iocb.c (revision 3958)
+++ drivers/infiniband/ulp/sdp/sdp_iocb.c (working copy)
@@ -176,30 +176,40 @@
if (!iocb->page_array)
goto err_page;
- down_read(¤t->mm->mmap_sem);
-
- result = get_user_pages(current, current->mm,
- iocb->addr, iocb->page_count,
- !!(iocb->flags & SDP_IOCB_F_RECV), 0,
- iocb->page_array, NULL);
+ if (segment_eq(get_fs(), get_ds())) {
+ /* Kernel request */
+ for (i = 0; i< iocb->page_count; ++i) {
+ iocb->page_array[i] = virt_to_page(addr);
+ iocb->addr_array[i] = page_to_phys(iocb->page_array[i]);
+ addr += PAGE_SIZE;
+ }
+ } else {
+ /* User-level request */
+ down_read(¤t->mm->mmap_sem);
- up_read(¤t->mm->mmap_sem);
+ result = get_user_pages(current, current->mm,
+ iocb->addr, iocb->page_count,
+ !!(iocb->flags & SDP_IOCB_F_RECV), 0,
+ iocb->page_array, NULL);
- if (result != iocb->page_count) {
- sdp_dbg_err("unable to lock <%lx:%Zu> error <%d> <%d>",
- iocb->addr, iocb->size, result, iocb->page_count);
- goto err_get;
+ up_read(¤t->mm->mmap_sem);
+
+ if (result != iocb->page_count) {
+ sdp_dbg_err("unable to lock <%lx:%Zu> error <%d> <%d>",
+ iocb->addr, iocb->size, result,
+ iocb->page_count);
+ goto err_get;
+ }
+
+ iocb->flags |= SDP_IOCB_F_LOCKED;
+ iocb->mm = current->mm;
+ iocb->tsk = current;
+
+
+ for (i = 0; i< iocb->page_count; ++i) {
+ iocb->addr_array[i] = page_to_phys(iocb->page_array[i]);
+ }
}
-
- iocb->flags |= SDP_IOCB_F_LOCKED;
- iocb->mm = current->mm;
- iocb->tsk = current;
-
-
- for (i = 0; i< iocb->page_count; ++i) {
- iocb->addr_array[i] = page_to_phys(iocb->page_array[i]);
- }
-
return 0;
err_get:
--
MST
More information about the general
mailing list