mirror of
https://git.openafs.org/openafs.git
synced 2025-02-01 05:57:43 +00:00
Linux: bypass: consolidate copy_page macros into a single function
The copy_page(s) macros are very similar; combine them into a single function that can be used for all cases. This will make it easier to add some pre-processor logic around the kmap_atomic calls to adapt to Linux API changes. Reviewed-on: http://gerrit.openafs.org/7980 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementix.org> (cherry picked from commit 0a8256a26fafb490b454f2a857b0c15d859572c5) Change-Id: I6835a024428b26a8cd8d073f6304d0d0b3042b24 Reviewed-on: http://gerrit.openafs.org/8077 Reviewed-by: Derrick Brashear <shadow@your-file-system.com> Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com> Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
parent
191df3d057
commit
54db9af1a8
@ -270,49 +270,12 @@ done:
|
||||
#ifdef UKERNEL
|
||||
typedef void * bypass_page_t;
|
||||
|
||||
#define copy_page(pp, pageoff, rxiov, iovno, iovoff, auio, curiov) \
|
||||
do { \
|
||||
int dolen = auio->uio_iov[curiov].iov_len - pageoff; \
|
||||
memcpy(((char *)pp) + pageoff, \
|
||||
((char *)rxiov[iovno].iov_base) + iovoff, dolen); \
|
||||
auio->uio_resid -= dolen; \
|
||||
} while(0)
|
||||
|
||||
#define copy_pages(pp, pageoff, rxiov, iovno, iovoff, auio, curiov) \
|
||||
do { \
|
||||
int dolen = rxiov[iovno].iov_len - iovoff; \
|
||||
memcpy(((char *)pp) + pageoff, \
|
||||
((char *)rxiov[iovno].iov_base) + iovoff, dolen); \
|
||||
auio->uio_resid -= dolen; \
|
||||
} while(0)
|
||||
|
||||
#define unlock_and_release_pages(auio)
|
||||
#define release_full_page(pp, pageoff)
|
||||
|
||||
#else
|
||||
typedef struct page * bypass_page_t;
|
||||
|
||||
#define copy_page(pp, pageoff, rxiov, iovno, iovoff, auio, curiov) \
|
||||
do { \
|
||||
char *address; \
|
||||
int dolen = auio->uio_iov[curiov].iov_len - pageoff; \
|
||||
address = kmap_atomic(pp, KM_USER0); \
|
||||
memcpy(address + pageoff, \
|
||||
(char *)(rxiov[iovno].iov_base) + iovoff, dolen); \
|
||||
kunmap_atomic(address, KM_USER0); \
|
||||
} while(0)
|
||||
|
||||
#define copy_pages(pp, pageoff, rxiov, iovno, iovoff, auio, curiov) \
|
||||
do { \
|
||||
char *address; \
|
||||
int dolen = rxiov[iovno].iov_len - iovoff; \
|
||||
address = kmap_atomic(pp, KM_USER0); \
|
||||
memcpy(address + pageoff, \
|
||||
(char *)(rxiov[iovno].iov_base) + iovoff, dolen); \
|
||||
kunmap_atomic(address, KM_USER0); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define unlock_and_release_pages(auio) \
|
||||
do { \
|
||||
struct iovec *ciov; \
|
||||
@ -347,9 +310,31 @@ typedef struct page * bypass_page_t;
|
||||
afs_warn("afs_NoCacheFetchProc: page not locked!\n"); \
|
||||
put_page(pp); /* decrement refcount */ \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
afs_bypass_copy_page(bypass_page_t pp, int pageoff, struct iovec *rxiov,
|
||||
int iovno, int iovoff, struct uio *auio, int curiov, int partial)
|
||||
{
|
||||
char *address;
|
||||
int dolen;
|
||||
|
||||
if (partial)
|
||||
dolen = rxiov[iovno].iov_len - iovoff;
|
||||
else
|
||||
dolen = auio->uio_iov[curiov].iov_len - pageoff;
|
||||
|
||||
#if !defined(UKERNEL)
|
||||
address = kmap_atomic(pp, KM_USER0);
|
||||
#else
|
||||
address = pp;
|
||||
#endif
|
||||
memcpy(address + pageoff, (char *)(rxiov[iovno].iov_base) + iovoff, dolen);
|
||||
#if !defined(UKERNEL)
|
||||
kunmap_atomic(address, KM_USER0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* no-cache prefetch routine */
|
||||
static afs_int32
|
||||
afs_NoCacheFetchProc(struct rx_call *acall,
|
||||
@ -447,7 +432,7 @@ afs_NoCacheFetchProc(struct rx_call *acall,
|
||||
if (pageoff + (rxiov[iovno].iov_len - iovoff) <= auio->uio_iov[curpage].iov_len) {
|
||||
/* Copy entire (or rest of) current iovec into current page */
|
||||
if (pp)
|
||||
copy_pages(pp, pageoff, rxiov, iovno, iovoff, auio, curpage);
|
||||
afs_bypass_copy_page(pp, pageoff, rxiov, iovno, iovoff, auio, curpage, 0);
|
||||
length -= (rxiov[iovno].iov_len - iovoff);
|
||||
pageoff += rxiov[iovno].iov_len - iovoff;
|
||||
iovno++;
|
||||
@ -455,7 +440,7 @@ afs_NoCacheFetchProc(struct rx_call *acall,
|
||||
} else {
|
||||
/* Copy only what's needed to fill current page */
|
||||
if (pp)
|
||||
copy_page(pp, pageoff, rxiov, iovno, iovoff, auio, curpage);
|
||||
afs_bypass_copy_page(pp, pageoff, rxiov, iovno, iovoff, auio, curpage, 1);
|
||||
length -= (auio->uio_iov[curpage].iov_len - pageoff);
|
||||
iovoff += auio->uio_iov[curpage].iov_len - pageoff;
|
||||
pageoff = auio->uio_iov[curpage].iov_len;
|
||||
|
Loading…
x
Reference in New Issue
Block a user