From patchwork Wed Jul 22 13:03:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Gr=C3=BCnbacher?= X-Patchwork-Id: 6842951 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0DB4E9F380 for ; Wed, 22 Jul 2015 13:09:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 382F2206CC for ; Wed, 22 Jul 2015 13:09:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBD46206B6 for ; Wed, 22 Jul 2015 13:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933427AbbGVNI3 (ORCPT ); Wed, 22 Jul 2015 09:08:29 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:37972 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757034AbbGVNEt (ORCPT ); Wed, 22 Jul 2015 09:04:49 -0400 Received: by wibxm9 with SMTP id xm9so101364885wib.1; Wed, 22 Jul 2015 06:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hgI9YQKW35sdUoMXQ20n/rp1VmiXJA9XUngEHlHLRKQ=; b=PKTQL4/o/ZbmjnYdGY1z0gmZycsE0orj0+48oRMnJ5PczHCA5zcOGqllAZT2OIHTm/ M/ICaGvT60cRnFB6JI+rH65xrOyOWCnhtr372+4BgRTGP1T8F/uYF1p9AAKF4YDTPu3t 9stHDpnQ0LBMuyy9MfonUcjQBY3nK/8EZHTfAhWQPOjdtzvZUufAnjyBtTKtCnEoMka0 FPhGZL3gjm4DjSbvVyxl1TikHawhc4gtrsMQKRsx7c7RSagF2PUUwDX1Y3d9eHyuW/ig HMmTMt3LPQI5/1LQVKjQemhZq0Jbp8Idy2eUs+mIEnCKkWxbVqFpej74UbMBk3qO6lNE Mkqw== X-Received: by 10.194.121.131 with SMTP id lk3mr4792359wjb.77.1437570288096; Wed, 22 Jul 2015 06:04:48 -0700 (PDT) Received: from schleppi.home.com ([149.14.88.26]) by smtp.gmail.com with ESMTPSA id u7sm21992628wif.3.2015.07.22.06.04.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 06:04:47 -0700 (PDT) From: Andreas Gruenbacher To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-api@vger.kernel.org, samba-technical@lists.samba.org, linux-security-module@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH v5 35/39] sunrpc: Add xdr_init_encode_pages Date: Wed, 22 Jul 2015 15:03:25 +0200 Message-Id: <1437570209-29832-36-git-send-email-andreas.gruenbacher@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437570209-29832-1-git-send-email-andreas.gruenbacher@gmail.com> References: <1437570209-29832-1-git-send-email-andreas.gruenbacher@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andreas Gruenbacher Initialize xdr_stream and xdr_buf from a pages array, for encoding into the pages. Signed-off-by: Andreas Gruenbacher --- include/linux/sunrpc/xdr.h | 2 ++ net/sunrpc/xdr.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 70c6b92..2c99cff 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -214,6 +214,8 @@ typedef void (*kxdreproc_t)(void *rqstp, struct xdr_stream *xdr, void *obj); typedef int (*kxdrdproc_t)(void *rqstp, struct xdr_stream *xdr, void *obj); extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); +extern void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, + struct page **pages, unsigned int len); extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes); extern void xdr_commit_encode(struct xdr_stream *xdr); extern void xdr_truncate_encode(struct xdr_stream *xdr, size_t len); diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index e6a1744..4a4437c 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -483,6 +483,31 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p) EXPORT_SYMBOL_GPL(xdr_init_encode); /** + * xdr_init_encode_pages - Initialize a struct xdr_stream for encoding into pages. + * @xdr: pointer to xdr_stream struct + * @buf: pointer to XDR buffer in which to encode data + * @pages: pages array in which to encode + * @page_len: maximum length of @buf + * + * Initialize @xdr and @buf for encoding into the @pages array. If a + * page in @pages is NULL, it will be allocated on demand. + */ +void xdr_init_encode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, + struct page **pages, unsigned int len) +{ + memset(buf, 0, sizeof(*buf)); + buf->pages = pages; + buf->page_len = len; + buf->buflen = len; + + memset(xdr, 0, sizeof(*xdr)); + xdr->buf = buf; + xdr->iov = buf->head; + xdr->page_ptr = pages - 1; +} +EXPORT_SYMBOL_GPL(xdr_init_encode_pages); + +/** * xdr_commit_encode - Ensure all data is written to buffer * @xdr: pointer to xdr_stream *