From: William Lee Irwin III <wli@holomorphy.com>
To: linux-kernel@vger.kernel.org
Cc: davem@davemloft.net
Subject: [sunrpc] remove xdr_kmap()
Date: Tue, 28 Dec 2004 15:04:16 -0800 [thread overview]
Message-ID: <20041228230416.GM771@holomorphy.com> (raw)
I was auditing nfs for missing flush_dcache_page() calls. They appear
to be done almost nowhere in nfs and so likely nowhere near enough, and
that makes nfs one of the primary suspects for breaking various machines
I have.
In this process, I stumbled over a blatant kmap() deadlock in
xdr_kmap(), which fortunately is never called.
This patch removes these dangerous nowhere-called functions.
vs. 2.6.10-bk1
-- wli
Index: wli-2.6.10-bk1/include/linux/sunrpc/xdr.h
===================================================================
--- wli-2.6.10-bk1.orig/include/linux/sunrpc/xdr.h 2004-08-13 22:38:10.000000000 -0700
+++ wli-2.6.10-bk1/include/linux/sunrpc/xdr.h 2004-12-28 14:27:16.000000000 -0800
@@ -145,8 +145,6 @@
/*
* XDR buffer helper functions
*/
-extern int xdr_kmap(struct kvec *, struct xdr_buf *, size_t);
-extern void xdr_kunmap(struct xdr_buf *, size_t);
extern void xdr_shift_buf(struct xdr_buf *, size_t);
extern void _copy_from_pages(char *, struct page **, size_t, size_t);
extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *);
Index: wli-2.6.10-bk1/net/sunrpc/xdr.c
===================================================================
--- wli-2.6.10-bk1.orig/net/sunrpc/xdr.c 2004-08-13 22:37:26.000000000 -0700
+++ wli-2.6.10-bk1/net/sunrpc/xdr.c 2004-12-28 14:27:16.000000000 -0800
@@ -216,93 +216,6 @@
}
}
-/*
- * Map a struct xdr_buf into an kvec array.
- */
-int xdr_kmap(struct kvec *iov_base, struct xdr_buf *xdr, size_t base)
-{
- struct kvec *iov = iov_base;
- struct page **ppage = xdr->pages;
- unsigned int len, pglen = xdr->page_len;
-
- len = xdr->head[0].iov_len;
- if (base < len) {
- iov->iov_len = len - base;
- iov->iov_base = (char *)xdr->head[0].iov_base + base;
- iov++;
- base = 0;
- } else
- base -= len;
-
- if (pglen == 0)
- goto map_tail;
- if (base >= pglen) {
- base -= pglen;
- goto map_tail;
- }
- if (base || xdr->page_base) {
- pglen -= base;
- base += xdr->page_base;
- ppage += base >> PAGE_CACHE_SHIFT;
- base &= ~PAGE_CACHE_MASK;
- }
- do {
- len = PAGE_CACHE_SIZE;
- iov->iov_base = kmap(*ppage);
- if (base) {
- iov->iov_base += base;
- len -= base;
- base = 0;
- }
- if (pglen < len)
- len = pglen;
- iov->iov_len = len;
- iov++;
- ppage++;
- } while ((pglen -= len) != 0);
-map_tail:
- if (xdr->tail[0].iov_len) {
- iov->iov_len = xdr->tail[0].iov_len - base;
- iov->iov_base = (char *)xdr->tail[0].iov_base + base;
- iov++;
- }
- return (iov - iov_base);
-}
-
-void xdr_kunmap(struct xdr_buf *xdr, size_t base)
-{
- struct page **ppage = xdr->pages;
- unsigned int pglen = xdr->page_len;
-
- if (!pglen)
- return;
- if (base > xdr->head[0].iov_len)
- base -= xdr->head[0].iov_len;
- else
- base = 0;
-
- if (base >= pglen)
- return;
- if (base || xdr->page_base) {
- pglen -= base;
- base += xdr->page_base;
- ppage += base >> PAGE_CACHE_SHIFT;
- /* Note: The offset means that the length of the first
- * page is really (PAGE_CACHE_SIZE - (base & ~PAGE_CACHE_MASK)).
- * In order to avoid an extra test inside the loop,
- * we bump pglen here, and just subtract PAGE_CACHE_SIZE... */
- pglen += base & ~PAGE_CACHE_MASK;
- }
- for (;;) {
- flush_dcache_page(*ppage);
- kunmap(*ppage);
- if (pglen <= PAGE_CACHE_SIZE)
- break;
- pglen -= PAGE_CACHE_SIZE;
- ppage++;
- }
-}
-
void
xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base,
skb_reader_t *desc,
next reply other threads:[~2004-12-28 23:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-28 23:04 William Lee Irwin III [this message]
2004-12-29 1:12 ` [sunrpc] remove xdr_kmap() David S. Miller
2004-12-29 2:09 ` William Lee Irwin III
2004-12-29 3:49 ` David S. Miller
2004-12-29 5:57 ` Trond Myklebust
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=20041228230416.GM771@holomorphy.com \
--to=wli@holomorphy.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
/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