Commit b145333f authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: iovec cleanups - sunrpc, nfs and nfsd

sunrpc, nfs and nfsd switched to use of kvec and kernel_...msg()
parent 8af0afb2
......@@ -231,7 +231,7 @@ nfs_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args)
static int
nfs_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res)
{
struct iovec *iov = req->rq_rcv_buf.head;
struct kvec *iov = req->rq_rcv_buf.head;
int status, count, recvd, hdrlen;
if ((status = ntohl(*p++)))
......@@ -375,7 +375,7 @@ static int
nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy)
{
struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
struct iovec *iov = rcvbuf->head;
struct kvec *iov = rcvbuf->head;
struct page **page;
int hdrlen, recvd;
int status, nr;
......@@ -530,7 +530,7 @@ static int
nfs_xdr_readlinkres(struct rpc_rqst *req, u32 *p, void *dummy)
{
struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
struct iovec *iov = rcvbuf->head;
struct kvec *iov = rcvbuf->head;
unsigned int hdrlen;
u32 *strlen, len;
char *string;
......
......@@ -484,7 +484,7 @@ static int
nfs3_xdr_readdirres(struct rpc_rqst *req, u32 *p, struct nfs3_readdirres *res)
{
struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
struct iovec *iov = rcvbuf->head;
struct kvec *iov = rcvbuf->head;
struct page **page;
int hdrlen, recvd;
int status, nr;
......@@ -721,7 +721,7 @@ static int
nfs3_xdr_readlinkres(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
{
struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
struct iovec *iov = rcvbuf->head;
struct kvec *iov = rcvbuf->head;
unsigned int hdrlen;
u32 *strlen, len;
char *string;
......@@ -761,7 +761,7 @@ nfs3_xdr_readlinkres(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
static int
nfs3_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res)
{
struct iovec *iov = req->rq_rcv_buf.head;
struct kvec *iov = req->rq_rcv_buf.head;
int status, count, ocount, recvd, hdrlen;
status = ntohl(*p++);
......
......@@ -933,7 +933,7 @@ static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
WRITE32(FATTR4_WORD0_FILEID);
WRITE32(0);
/* set up reply iovec
/* set up reply kvec
* toplevel_status + taglen + rescount + OP_PUTFH + status
* + OP_READDIR + status + verifer(2) = 9
*/
......@@ -954,7 +954,7 @@ static int encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *r
RESERVE_SPACE(4);
WRITE32(OP_READLINK);
/* set up reply iovec
/* set up reply kvec
* toplevel_status + taglen + rescount + OP_PUTFH + status
* + OP_READLINK + status = 7
*/
......@@ -1501,7 +1501,7 @@ static int nfs4_xdr_enc_read(struct rpc_rqst *req, uint32_t *p, struct nfs_reada
if (status)
goto out;
/* set up reply iovec
/* set up reply kvec
* toplevel status + taglen=0 + rescount + OP_PUTFH + status
* + OP_READ + status + eof + datalen = 9
*/
......@@ -2785,7 +2785,7 @@ static int decode_putrootfh(struct xdr_stream *xdr)
static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res)
{
struct iovec *iov = req->rq_rcv_buf.head;
struct kvec *iov = req->rq_rcv_buf.head;
uint32_t *p;
uint32_t count, eof, recvd, hdrlen;
int status;
......@@ -2814,7 +2814,7 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
{
struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
struct page *page = *rcvbuf->pages;
struct iovec *iov = rcvbuf->head;
struct kvec *iov = rcvbuf->head;
unsigned int nr, pglen = rcvbuf->page_len;
uint32_t *end, *entry, *p, *kaddr;
uint32_t len, attrlen, word;
......@@ -2897,7 +2897,7 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
{
struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
struct iovec *iov = rcvbuf->head;
struct kvec *iov = rcvbuf->head;
uint32_t *strlen;
unsigned int hdrlen, len;
char *string;
......
......@@ -340,7 +340,7 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, u32 *p,
if (len > NFSSVC_MAXBLKSIZE)
len = NFSSVC_MAXBLKSIZE;
/* set up the iovec */
/* set up the kvec */
v=0;
while (len > 0) {
pn = rqstp->rq_resused;
......@@ -430,7 +430,7 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, u32 *p,
int len;
int avail;
char *old, *new;
struct iovec *vec;
struct kvec *vec;
if (!(p = decode_fh(p, &args->ffh))
|| !(p = decode_filename(p, &args->fname, &args->flen))
......
......@@ -2519,7 +2519,7 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, u32 *p, struct nfsd4_compound
/*
* All that remains is to write the tag and operation count...
*/
struct iovec *iov;
struct kvec *iov;
p = resp->tagp;
*p++ = htonl(resp->taglen);
memcpy(p, resp->tag, resp->taglen);
......
......@@ -41,7 +41,7 @@ static struct svc_cacherep * lru_tail;
static struct svc_cacherep * nfscache;
static int cache_disabled = 1;
static int nfsd_cache_append(struct svc_rqst *rqstp, struct iovec *vec);
static int nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *vec);
/*
* locking for the reply cache:
......@@ -308,7 +308,7 @@ void
nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, u32 *statp)
{
struct svc_cacherep *rp;
struct iovec *resv = &rqstp->rq_res.head[0], *cachv;
struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
int len;
if (!(rp = rqstp->rq_cacherep) || cache_disabled)
......@@ -358,9 +358,9 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, u32 *statp)
* keep a refcount....
*/
static int
nfsd_cache_append(struct svc_rqst *rqstp, struct iovec *data)
nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *data)
{
struct iovec *vec = &rqstp->rq_res.head[0];
struct kvec *vec = &rqstp->rq_res.head[0];
if (vec->iov_len + data->iov_len > PAGE_SIZE) {
printk(KERN_WARNING "nfsd: cached reply too large (%Zd).\n",
......
......@@ -641,7 +641,7 @@ nfsd_read_actor(read_descriptor_t *desc, struct page *page, unsigned long offset
*/
int
nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
struct iovec *vec, int vlen, unsigned long *count)
struct kvec *vec, int vlen, unsigned long *count)
{
struct raparms *ra;
mm_segment_t oldfs;
......@@ -673,7 +673,7 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
} else {
oldfs = get_fs();
set_fs(KERNEL_DS);
err = vfs_readv(&file, vec, vlen, &offset);
err = vfs_readv(&file, (struct iovec __user *)vec, vlen, &offset);
set_fs(oldfs);
}
......@@ -704,7 +704,7 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
*/
int
nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
struct iovec *vec, int vlen,
struct kvec *vec, int vlen,
unsigned long cnt, int *stablep)
{
struct svc_export *exp;
......@@ -753,7 +753,7 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
/* Write the data. */
oldfs = get_fs(); set_fs(KERNEL_DS);
err = vfs_writev(&file, vec, vlen, &offset);
err = vfs_writev(&file, (struct iovec __user *)vec, vlen, &offset);
set_fs(oldfs);
if (err >= 0) {
nfsdstats.io_write += cnt;
......
......@@ -33,7 +33,7 @@ struct svc_cacherep {
u32 c_vers;
unsigned long c_timestamp;
union {
struct iovec u_vec;
struct kvec u_vec;
u32 u_status;
} c_u;
};
......
......@@ -92,9 +92,9 @@ int nfsd_open(struct svc_rqst *, struct svc_fh *, int,
int, struct file *);
void nfsd_close(struct file *);
int nfsd_read(struct svc_rqst *, struct svc_fh *,
loff_t, struct iovec *,int, unsigned long *);
loff_t, struct kvec *,int, unsigned long *);
int nfsd_write(struct svc_rqst *, struct svc_fh *,
loff_t, struct iovec *,int, unsigned long, int *);
loff_t, struct kvec *,int, unsigned long, int *);
int nfsd_readlink(struct svc_rqst *, struct svc_fh *,
char *, int *);
int nfsd_symlink(struct svc_rqst *, struct svc_fh *,
......
......@@ -30,7 +30,7 @@ struct nfsd_readargs {
struct svc_fh fh;
__u32 offset;
__u32 count;
struct iovec vec[RPCSVC_MAXPAGES];
struct kvec vec[RPCSVC_MAXPAGES];
int vlen;
};
......@@ -38,7 +38,7 @@ struct nfsd_writeargs {
svc_fh fh;
__u32 offset;
int len;
struct iovec vec[RPCSVC_MAXPAGES];
struct kvec vec[RPCSVC_MAXPAGES];
int vlen;
};
......
......@@ -33,7 +33,7 @@ struct nfsd3_readargs {
struct svc_fh fh;
__u64 offset;
__u32 count;
struct iovec vec[RPCSVC_MAXPAGES];
struct kvec vec[RPCSVC_MAXPAGES];
int vlen;
};
......@@ -43,7 +43,7 @@ struct nfsd3_writeargs {
__u32 count;
int stable;
int len;
struct iovec vec[RPCSVC_MAXPAGES];
struct kvec vec[RPCSVC_MAXPAGES];
int vlen;
};
......
......@@ -241,7 +241,7 @@ struct nfsd4_read {
stateid_t rd_stateid; /* request */
u64 rd_offset; /* request */
u32 rd_length; /* request */
struct iovec rd_iov[RPCSVC_MAXPAGES];
struct kvec rd_iov[RPCSVC_MAXPAGES];
int rd_vlen;
struct svc_rqst *rd_rqstp; /* response */
......@@ -324,7 +324,7 @@ struct nfsd4_write {
u64 wr_offset; /* request */
u32 wr_stable_how; /* request */
u32 wr_buflen; /* request */
struct iovec wr_vec[RPCSVC_MAXPAGES]; /* request */
struct kvec wr_vec[RPCSVC_MAXPAGES]; /* request */
int wr_vlen;
u32 wr_bytes_written; /* response */
......
......@@ -67,7 +67,7 @@ struct svc_serv {
* read responses (that have a header, and some data pages, and possibly
* a tail) and means we can share some client side routines.
*
* The xdr_buf.head iovec always points to the first page in the rq_*pages
* The xdr_buf.head kvec always points to the first page in the rq_*pages
* list. The xdr_buf.pages pointer points to the second page on that
* list. xdr_buf.tail points to the end of the first page.
* This assumes that the non-page part of an rpc reply will fit
......@@ -78,7 +78,7 @@ struct svc_serv {
*/
#define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 2)
static inline u32 svc_getu32(struct iovec *iov)
static inline u32 svc_getu32(struct kvec *iov)
{
u32 val, *vp;
vp = iov->iov_base;
......@@ -87,7 +87,7 @@ static inline u32 svc_getu32(struct iovec *iov)
iov->iov_len -= sizeof(u32);
return val;
}
static inline void svc_putu32(struct iovec *iov, u32 val)
static inline void svc_putu32(struct kvec *iov, u32 val)
{
u32 *vp = iov->iov_base + iov->iov_len;
*vp = val;
......@@ -162,14 +162,14 @@ static inline int
xdr_argsize_check(struct svc_rqst *rqstp, u32 *p)
{
char *cp = (char *)p;
struct iovec *vec = &rqstp->rq_arg.head[0];
struct kvec *vec = &rqstp->rq_arg.head[0];
return cp - (char*)vec->iov_base <= vec->iov_len;
}
static inline int
xdr_ressize_check(struct svc_rqst *rqstp, u32 *p)
{
struct iovec *vec = &rqstp->rq_res.head[0];
struct kvec *vec = &rqstp->rq_res.head[0];
char *cp = (char*)p;
vec->iov_len = cp - (char*)vec->iov_base;
......
......@@ -48,7 +48,7 @@ typedef int (*kxdrproc_t)(void *rqstp, u32 *data, void *obj);
* operations and/or has a need for scatter/gather involving pages.
*/
struct xdr_buf {
struct iovec head[1], /* RPC header + non-page data */
struct kvec head[1], /* RPC header + non-page data */
tail[1]; /* Appended after page data */
struct page ** pages; /* Array of contiguous pages */
......@@ -127,15 +127,15 @@ xdr_decode_hyper(u32 *p, __u64 *valp)
}
/*
* Adjust iovec to reflect end of xdr'ed data (RPC client XDR)
* Adjust kvec to reflect end of xdr'ed data (RPC client XDR)
*/
static inline int
xdr_adjust_iovec(struct iovec *iov, u32 *p)
xdr_adjust_iovec(struct kvec *iov, u32 *p)
{
return iov->iov_len = ((u8 *) p - (u8 *) iov->iov_base);
}
void xdr_shift_iovec(struct iovec *, int, size_t);
void xdr_shift_iovec(struct kvec *, int, size_t);
/*
* Maximum number of iov's we use.
......@@ -145,11 +145,11 @@ void xdr_shift_iovec(struct iovec *, int, size_t);
/*
* XDR buffer helper functions
*/
extern int xdr_kmap(struct iovec *, struct xdr_buf *, size_t);
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 iovec *, struct xdr_buf *);
extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *);
extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, int, int);
extern int xdr_buf_read_netobj(struct xdr_buf *, struct xdr_netobj *, int);
extern int read_bytes_from_xdr_buf(struct xdr_buf *buf, int base, void *obj, int len);
......@@ -182,7 +182,7 @@ struct xdr_stream {
struct xdr_buf *buf; /* XDR buffer to read/write */
uint32_t *end; /* end of available buffer space */
struct iovec *iov; /* pointer to the current iovec */
struct kvec *iov; /* pointer to the current kvec */
};
extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p);
......
......@@ -417,7 +417,7 @@ gss_upcall(struct rpc_clnt *clnt, struct rpc_task *task, struct rpc_cred *cred)
static ssize_t
gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
char *dst, size_t buflen)
char __user *dst, size_t buflen)
{
char *data = (char *)msg->data + msg->copied;
ssize_t mlen = msg->len;
......@@ -439,7 +439,7 @@ gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,
#define MSG_BUF_MAXSIZE 1024
static ssize_t
gss_pipe_downcall(struct file *filp, const char *src, size_t mlen)
gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
{
struct xdr_netobj obj = {
.len = mlen,
......@@ -697,7 +697,7 @@ gss_marshal(struct rpc_task *task, u32 *p, int ruid)
struct rpc_rqst *req = task->tk_rqstp;
u32 maj_stat = 0;
struct xdr_netobj mic;
struct iovec iov;
struct kvec iov;
struct xdr_buf verf_buf;
u32 service;
......@@ -774,7 +774,7 @@ gss_validate(struct rpc_task *task, u32 *p)
gc_base);
struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred);
u32 seq, qop_state;
struct iovec iov;
struct kvec iov;
struct xdr_buf verf_buf;
struct xdr_netobj mic;
u32 flav,len;
......@@ -830,7 +830,7 @@ gss_wrap_req_integ(struct gss_cl_ctx *ctx,
u32 *integ_len = NULL;
struct xdr_netobj mic;
u32 offset, *q;
struct iovec *iov;
struct kvec *iov;
u32 maj_stat = 0;
int status = -EIO;
......
......@@ -503,7 +503,7 @@ static inline u32 round_up_to_quad(u32 i)
}
static inline int
svc_safe_getnetobj(struct iovec *argv, struct xdr_netobj *o)
svc_safe_getnetobj(struct kvec *argv, struct xdr_netobj *o)
{
int l;
......@@ -520,7 +520,7 @@ svc_safe_getnetobj(struct iovec *argv, struct xdr_netobj *o)
}
static inline int
svc_safe_putnetobj(struct iovec *resv, struct xdr_netobj *o)
svc_safe_putnetobj(struct kvec *resv, struct xdr_netobj *o)
{
u32 *p;
......@@ -548,8 +548,8 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
struct xdr_buf rpchdr;
struct xdr_netobj checksum;
u32 flavor = 0;
struct iovec *argv = &rqstp->rq_arg.head[0];
struct iovec iov;
struct kvec *argv = &rqstp->rq_arg.head[0];
struct kvec iov;
/* data to compute the checksum over: */
iov.iov_base = rpcstart;
......@@ -595,7 +595,7 @@ gss_write_verf(struct svc_rqst *rqstp, struct gss_ctx *ctx_id, u32 seq)
struct xdr_buf verf_data;
struct xdr_netobj mic;
u32 *p;
struct iovec iov;
struct kvec iov;
svc_putu32(rqstp->rq_res.head, htonl(RPC_AUTH_GSS));
xdr_seq = htonl(seq);
......@@ -743,8 +743,8 @@ struct gss_svc_data {
static int
svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
{
struct iovec *argv = &rqstp->rq_arg.head[0];
struct iovec *resv = &rqstp->rq_res.head[0];
struct kvec *argv = &rqstp->rq_arg.head[0];
struct kvec *resv = &rqstp->rq_res.head[0];
u32 crlen;
struct xdr_netobj tmpobj;
struct gss_svc_data *svcdata = rqstp->rq_auth_data;
......@@ -952,7 +952,7 @@ svcauth_gss_release(struct svc_rqst *rqstp)
struct xdr_buf *resbuf = &rqstp->rq_res;
struct xdr_buf integ_buf;
struct xdr_netobj mic;
struct iovec *resv;
struct kvec *resv;
u32 *p;
int integ_offset, integ_len;
int stat = -EINVAL;
......
......@@ -257,8 +257,8 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
struct svc_program *progp;
struct svc_version *versp = NULL; /* compiler food */
struct svc_procedure *procp = NULL;
struct iovec * argv = &rqstp->rq_arg.head[0];
struct iovec * resv = &rqstp->rq_res.head[0];
struct kvec * argv = &rqstp->rq_arg.head[0];
struct kvec * resv = &rqstp->rq_res.head[0];
kxdrproc_t xdr;
u32 *statp;
u32 dir, prog, vers, proc,
......
......@@ -338,8 +338,8 @@ void svcauth_unix_purge(void)
static int
svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp)
{
struct iovec *argv = &rqstp->rq_arg.head[0];
struct iovec *resv = &rqstp->rq_res.head[0];
struct kvec *argv = &rqstp->rq_arg.head[0];
struct kvec *resv = &rqstp->rq_res.head[0];
int rv=0;
struct ip_map key, *ipm;
......@@ -422,8 +422,8 @@ struct auth_ops svcauth_null = {
int
svcauth_unix_accept(struct svc_rqst *rqstp, u32 *authp)
{
struct iovec *argv = &rqstp->rq_arg.head[0];
struct iovec *resv = &rqstp->rq_res.head[0];
struct kvec *argv = &rqstp->rq_arg.head[0];
struct kvec *resv = &rqstp->rq_res.head[0];
struct svc_cred *cred = &rqstp->rq_cred;
u32 slen, i;
int len = argv->iov_len;
......
......@@ -450,9 +450,8 @@ svc_recv_available(struct svc_sock *svsk)
* Generic recvfrom routine.
*/
static int
svc_recvfrom(struct svc_rqst *rqstp, struct iovec *iov, int nr, int buflen)
svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen)
{
mm_segment_t oldfs;
struct msghdr msg;
struct socket *sock;
int len, alen;
......@@ -462,16 +461,12 @@ svc_recvfrom(struct svc_rqst *rqstp, struct iovec *iov, int nr, int buflen)
msg.msg_name = &rqstp->rq_addr;
msg.msg_namelen = sizeof(rqstp->rq_addr);
msg.msg_iov = iov;
msg.msg_iovlen = nr;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT;
oldfs = get_fs(); set_fs(KERNEL_DS);
len = sock_recvmsg(sock, &msg, buflen, MSG_DONTWAIT);
set_fs(oldfs);
len = kernel_recvmsg(sock, &msg, iov, nr, buflen, MSG_DONTWAIT);
/* sock_recvmsg doesn't fill in the name/namelen, so we must..
* possibly we should cache this in the svc_sock structure
......@@ -898,7 +893,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
struct svc_sock *svsk = rqstp->rq_sock;
struct svc_serv *serv = svsk->sk_server;
int len;
struct iovec vec[RPCSVC_MAXPAGES];
struct kvec vec[RPCSVC_MAXPAGES];
int pnum, vlen;
dprintk("svc: tcp_recv %p data %d conn %d close %d\n",
......@@ -942,7 +937,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
*/
if (svsk->sk_tcplen < 4) {
unsigned long want = 4 - svsk->sk_tcplen;
struct iovec iov;
struct kvec iov;
iov.iov_base = ((char *) &svsk->sk_reclen) + svsk->sk_tcplen;
iov.iov_len = want;
......@@ -1056,8 +1051,8 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
int sent;
u32 reclen;
/* Set up the first element of the reply iovec.
* Any other iovecs that may be in use have been taken
/* Set up the first element of the reply kvec.
* Any other kvecs that may be in use have been taken
* care of by the server implementation itself.
*/
reclen = htonl(0x80000000|((xbufp->len ) - 4));
......
......@@ -141,7 +141,7 @@ void
xdr_encode_pages(struct xdr_buf *xdr, struct page **pages, unsigned int base,
unsigned int len)
{
struct iovec *tail = xdr->tail;
struct kvec *tail = xdr->tail;
u32 *p;
xdr->pages = pages;
......@@ -168,8 +168,8 @@ void
xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset,
struct page **pages, unsigned int base, unsigned int len)
{
struct iovec *head = xdr->head;
struct iovec *tail = xdr->tail;
struct kvec *head = xdr->head;
struct kvec *tail = xdr->tail;
char *buf = (char *)head->iov_base;
unsigned int buflen = head->iov_len;
......@@ -186,19 +186,19 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset,
}
/*
* Realign the iovec if the server missed out some reply elements
* Realign the kvec if the server missed out some reply elements
* (such as post-op attributes,...)
* Note: This is a simple implementation that assumes that
* len <= iov->iov_len !!!
* The RPC header (assumed to be the 1st element in the iov array)
* is not shifted.
*/
void xdr_shift_iovec(struct iovec *iov, int nr, size_t len)
void xdr_shift_iovec(struct kvec *iov, int nr, size_t len)
{
struct iovec *pvec;
struct kvec *pvec;
for (pvec = iov + nr - 1; nr > 1; nr--, pvec--) {
struct iovec *svec = pvec - 1;
struct kvec *svec = pvec - 1;
if (len > pvec->iov_len) {
printk(KERN_DEBUG "RPC: Urk! Large shift of short iovec.\n");
......@@ -217,11 +217,11 @@ void xdr_shift_iovec(struct iovec *iov, int nr, size_t len)
}
/*
* Map a struct xdr_buf into an iovec array.
* Map a struct xdr_buf into an kvec array.
*/
int xdr_kmap(struct iovec *iov_base, struct xdr_buf *xdr, size_t base)
int xdr_kmap(struct kvec *iov_base, struct xdr_buf *xdr, size_t base)
{
struct iovec *iov = iov_base;
struct kvec *iov = iov_base;
struct page **ppage = xdr->pages;
unsigned int len, pglen = xdr->page_len;
......@@ -371,11 +371,10 @@ xdr_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
unsigned int len, pglen = xdr->page_len;
int err, ret = 0;
ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
mm_segment_t oldfs;
len = xdr->head[0].iov_len;
if (base < len || (addr != NULL && base == 0)) {
struct iovec iov = {
struct kvec iov = {
.iov_base = xdr->head[0].iov_base + base,
.iov_len = len - base,
};
......@@ -384,16 +383,13 @@ xdr_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
.msg_namelen = addrlen,
.msg_flags = msgflags,
};
if (iov.iov_len != 0) {
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
}
if (xdr->len > len)
msg.msg_flags |= MSG_MORE;
oldfs = get_fs(); set_fs(get_ds());
err = sock_sendmsg(sock, &msg, iov.iov_len);
set_fs(oldfs);
if (iov.iov_len != 0)
err = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
else
err = kernel_sendmsg(sock, &msg, NULL, 0, 0);
if (ret == 0)
ret = err;
else if (err > 0)
......@@ -446,18 +442,14 @@ xdr_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
copy_tail:
len = xdr->tail[0].iov_len;
if (base < len) {
struct iovec iov = {
struct kvec iov = {
.iov_base = xdr->tail[0].iov_base + base,
.iov_len = len - base,
};
struct msghdr msg = {
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_flags = msgflags,
};
oldfs = get_fs(); set_fs(get_ds());
err = sock_sendmsg(sock, &msg, iov.iov_len);
set_fs(oldfs);
err = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
if (ret == 0)
ret = err;
else if (err > 0)
......@@ -614,14 +606,14 @@ _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len)
* @buf: xdr_buf
* @len: bytes to remove from buf->head[0]
*
* Shrinks XDR buffer's header iovec buf->head[0] by
* Shrinks XDR buffer's header kvec buf->head[0] by
* 'len' bytes. The extra data is not lost, but is instead
* moved into the inlined pages and/or the tail.
*/
void
xdr_shrink_bufhead(struct xdr_buf *buf, size_t len)
{
struct iovec *head, *tail;
struct kvec *head, *tail;
size_t copy, offs;
unsigned int pglen = buf->page_len;
......@@ -694,7 +686,7 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len)
void
xdr_shrink_pagelen(struct xdr_buf *buf, size_t len)
{
struct iovec *tail;
struct kvec *tail;
size_t copy;
char *p;
unsigned int pglen = buf->page_len;
......@@ -738,15 +730,15 @@ xdr_shift_buf(struct xdr_buf *buf, size_t len)
* @p: current pointer inside XDR buffer
*
* Note: at the moment the RPC client only passes the length of our
* scratch buffer in the xdr_buf's header iovec. Previously this
* scratch buffer in the xdr_buf's header kvec. Previously this
* meant we needed to call xdr_adjust_iovec() after encoding the
* data. With the new scheme, the xdr_stream manages the details
* of the buffer length, and takes care of adjusting the iovec
* of the buffer length, and takes care of adjusting the kvec
* length for us.
*/
void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p)
{
struct iovec *iov = buf->head;
struct kvec *iov = buf->head;
xdr->buf = buf;
xdr->iov = iov;
......@@ -763,7 +755,7 @@ EXPORT_SYMBOL(xdr_init_encode);
*
* Checks that we have enough buffer space to encode 'nbytes' more
* bytes of data. If so, update the total xdr_buf length, and
* adjust the length of the current iovec.
* adjust the length of the current kvec.
*/
uint32_t * xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes)
{
......@@ -795,7 +787,7 @@ void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, unsigned int b
unsigned int len)
{
struct xdr_buf *buf = xdr->buf;
struct iovec *iov = buf->tail;
struct kvec *iov = buf->tail;
buf->pages = pages;
buf->page_base = base;
buf->page_len = len;
......@@ -826,7 +818,7 @@ EXPORT_SYMBOL(xdr_write_pages);
*/
void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p)
{
struct iovec *iov = buf->head;
struct kvec *iov = buf->head;
unsigned int len = iov->iov_len;
if (len > buf->len)
......@@ -873,7 +865,7 @@ EXPORT_SYMBOL(xdr_inline_decode);
void xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
{
struct xdr_buf *buf = xdr->buf;
struct iovec *iov;
struct kvec *iov;
ssize_t shift;
unsigned int end;
int padding;
......@@ -905,10 +897,10 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
}
EXPORT_SYMBOL(xdr_read_pages);
static struct iovec empty_iov = {.iov_base = NULL, .iov_len = 0};
static struct kvec empty_iov = {.iov_base = NULL, .iov_len = 0};
void
xdr_buf_from_iov(struct iovec *iov, struct xdr_buf *buf)
xdr_buf_from_iov(struct kvec *iov, struct xdr_buf *buf)
{
buf->head[0] = *iov;
buf->tail[0] = empty_iov;
......@@ -921,7 +913,7 @@ xdr_buf_from_iov(struct iovec *iov, struct xdr_buf *buf)
* length of subiov to zero. Decrements len by length of subiov, sets base
* to zero (or decrements it by length of iov if subiov is empty). */
static void
iov_subsegment(struct iovec *iov, struct iovec *subiov, int *base, int *len)
iov_subsegment(struct kvec *iov, struct kvec *subiov, int *base, int *len)
{
if (*base > iov->iov_len) {
subiov->iov_base = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment