From: Oleg Drokin <green@linuxhacker.ru>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH 02/15] lustre: simplify the living hell out of ksocknal_lib_recv_kiov()
Date: Sat, 23 Jul 2016 02:36:59 -0400 [thread overview]
Message-ID: <1469255832-746785-3-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1469255832-746785-1-git-send-email-green@linuxhacker.ru>
From: Al Viro <viro@zeniv.linux.org.uk>
... by using ITER_BVEC recvmsg
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
.../staging/lustre/lnet/klnds/socklnd/socklnd.h | 6 +-
.../lustre/lnet/klnds/socklnd/socklnd_lib.c | 98 ++--------------------
2 files changed, 12 insertions(+), 92 deletions(-)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index a56632b..d5efb42 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -86,8 +86,10 @@ struct ksock_sched { /* per scheduler state */
int kss_nconns; /* # connections assigned to
* this scheduler */
struct ksock_sched_info *kss_info; /* owner of it */
- struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
- struct kvec kss_scratch_iov[LNET_MAX_IOV];
+ union {
+ struct bio_vec kss_scratch_bvec[LNET_MAX_IOV];
+ struct kvec kss_scratch_iov[LNET_MAX_IOV];
+ };
};
struct ksock_sched_info {
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index 6a17757..8479b53 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -259,67 +259,11 @@ ksocknal_lib_recv_iov(struct ksock_conn *conn)
return rc;
}
-static void
-ksocknal_lib_kiov_vunmap(void *addr)
-{
- if (!addr)
- return;
-
- vunmap(addr);
-}
-
-static void *
-ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
- struct kvec *iov, struct page **pages)
-{
- void *addr;
- int nob;
- int i;
-
- if (!*ksocknal_tunables.ksnd_zc_recv || !pages)
- return NULL;
-
- LASSERT(niov <= LNET_MAX_IOV);
-
- if (niov < 2 ||
- niov < *ksocknal_tunables.ksnd_zc_recv_min_nfrags)
- return NULL;
-
- for (nob = i = 0; i < niov; i++) {
- if ((kiov[i].kiov_offset && i > 0) ||
- (kiov[i].kiov_offset + kiov[i].kiov_len != PAGE_SIZE && i < niov - 1))
- return NULL;
-
- pages[i] = kiov[i].kiov_page;
- nob += kiov[i].kiov_len;
- }
-
- addr = vmap(pages, niov, VM_MAP, PAGE_KERNEL);
- if (!addr)
- return NULL;
-
- iov->iov_base = addr + kiov[0].kiov_offset;
- iov->iov_len = nob;
-
- return addr;
-}
-
int
ksocknal_lib_recv_kiov(struct ksock_conn *conn)
{
-#if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK
- struct kvec scratch;
- struct kvec *scratchiov = &scratch;
- struct page **pages = NULL;
- unsigned int niov = 1;
-#else
-#ifdef CONFIG_HIGHMEM
-#warning "XXX risk of kmap deadlock on multiple frags..."
-#endif
- struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- struct page **pages = conn->ksnc_scheduler->kss_rx_scratch_pgs;
+ struct bio_vec *bv = conn->ksnc_scheduler->kss_scratch_bvec;
unsigned int niov = conn->ksnc_rx_nkiov;
-#endif
lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
struct msghdr msg = {
.msg_flags = 0
@@ -328,44 +272,26 @@ ksocknal_lib_recv_kiov(struct ksock_conn *conn)
int i;
int rc;
void *base;
- void *addr;
int sum;
int fragnob;
int n;
- /*
- * NB we can't trust socket ops to either consume our iovs
- * or leave them alone.
- */
- addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages);
- if (addr) {
- nob = scratchiov[0].iov_len;
- n = 1;
-
- } else {
- for (nob = i = 0; i < niov; i++) {
- nob += scratchiov[i].iov_len = kiov[i].kiov_len;
- scratchiov[i].iov_base = kmap(kiov[i].kiov_page) +
- kiov[i].kiov_offset;
- }
- n = niov;
+ for (nob = i = 0; i < niov; i++) {
+ nob += bv[i].bv_len = kiov[i].kiov_len;
+ bv[i].bv_page = kiov[i].kiov_page;
+ bv[i].bv_offset = kiov[i].kiov_offset;
}
+ n = niov;
LASSERT(nob <= conn->ksnc_rx_nob_wanted);
- rc = kernel_recvmsg(conn->ksnc_sock, &msg, (struct kvec *)scratchiov,
- n, nob, MSG_DONTWAIT);
+ iov_iter_bvec(&msg.msg_iter, READ | ITER_BVEC, bv, n, nob);
+ rc = sock_recvmsg(conn->ksnc_sock, &msg, MSG_DONTWAIT);
if (conn->ksnc_msg.ksm_csum) {
for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
LASSERT(i < niov);
- /*
- * Dang! have to kmap again because I have nowhere to
- * stash the mapped address. But by doing it while the
- * page is still mapped, the kernel just bumps the map
- * count and returns me the address it stashed.
- */
base = kmap(kiov[i].kiov_page) + kiov[i].kiov_offset;
fragnob = kiov[i].kiov_len;
if (fragnob > sum)
@@ -377,14 +303,6 @@ ksocknal_lib_recv_kiov(struct ksock_conn *conn)
kunmap(kiov[i].kiov_page);
}
}
-
- if (addr) {
- ksocknal_lib_kiov_vunmap(addr);
- } else {
- for (i = 0; i < niov; i++)
- kunmap(kiov[i].kiov_page);
- }
-
return rc;
}
--
2.7.4
next prev parent reply other threads:[~2016-07-23 6:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-23 6:36 [PATCH 00/15] Lustre cleanups Oleg Drokin
2016-07-23 6:36 ` [PATCH 01/15] lustre: switch lnet_sock_write() to sock_sendmsg() Oleg Drokin
2016-07-23 6:36 ` Oleg Drokin [this message]
2016-07-23 6:37 ` [PATCH 03/15] lustre: don't reinvent struct bio_vec Oleg Drokin
2016-07-23 6:37 ` [PATCH 04/15] ksocknal_lib_recv_iov(): recvmsg doesn't bugger iovec anymore Oleg Drokin
2016-07-23 6:37 ` [PATCH 05/15] ksocknal_lib_send_iov(): sendmsg doesn't bugger iovec Oleg Drokin
2016-07-23 6:37 ` [PATCH 06/15] ksocknal_lib_send_kiov(): " Oleg Drokin
2016-07-23 6:37 ` [PATCH 07/15] lustre: ->kss_scratch... are unused now Oleg Drokin
2016-08-15 16:55 ` Greg Kroah-Hartman
2016-07-23 6:37 ` [PATCH 08/15] lustre: constify lib-move.c stuff Oleg Drokin
2016-07-23 6:37 ` [PATCH 09/15] lustre: pass iov_iter to ->lnd_recv() Oleg Drokin
2016-07-23 6:37 ` [PATCH 10/15] lustre: introduce lnet_copy_{k,}iov2iter(), kill lnet_copy_{k,}iov2{k,}iov() Oleg Drokin
2016-07-23 6:37 ` [PATCH 11/15] staging/lustre: Always return EEXIST on mkdir for existing names Oleg Drokin
2016-07-23 6:37 ` [PATCH 12/15] staging/lustre: Add spaces preferred around that '{+,-,*,/,|,<<,>>,&}' Oleg Drokin
2016-07-23 17:31 ` Joe Perches
2016-07-23 18:01 ` Oleg Drokin
2016-07-26 1:47 ` Joe Perches
2016-07-23 6:37 ` [PATCH 13/15] staging/lustre: Fix unnecessary parentheses around variables Oleg Drokin
2016-07-23 6:37 ` [PATCH 14/15] staging/lustre: Make alignment match open parenthesis Oleg Drokin
2016-07-23 6:37 ` [PATCH 15/15] staging/lustre: Remove unused cp_error from struct cl_page Oleg Drokin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469255832-746785-3-git-send-email-green@linuxhacker.ru \
--to=green@linuxhacker.ru \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox