From patchwork Tue Aug 4 11:53:34 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: 6937001 Return-Path: X-Original-To: patchwork-cifs-client@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 C8A479F38B for ; Tue, 4 Aug 2015 11:58:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF2362037E for ; Tue, 4 Aug 2015 11:58:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 110AA2035D for ; Tue, 4 Aug 2015 11:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933921AbbHDL5c (ORCPT ); Tue, 4 Aug 2015 07:57:32 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:35825 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933761AbbHDLzt (ORCPT ); Tue, 4 Aug 2015 07:55:49 -0400 Received: by wibxm9 with SMTP id xm9so162785452wib.0; Tue, 04 Aug 2015 04:55:47 -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=5bwQQFmoU5PKG061gHYCX3bsRKEOy8oPOj6NBNr+K3U=; b=0kN10qzocEltEULzFtSsCZeLecrURv6AKgBNgqHAYzprE3gNFNJziGxZTGSJP4N/fV HDUHE+kN0dPASR+Q7ORr8GhwRGON52+1y1hIpiRdNzdAjAMnUGCxjm1ngHDsry3CPUfG k7Hiaej23wr3eh7a3DX0f4Bk05Rnly6S+3uEw5+wvgu0qPKVd0lKbDQzVNk/h91EQiRV 9yTkE0cBz0xKfQMqjaKYpqeANcEkiE1+Ak6rmEiOd22CkCLVhkIz5VpSt4wsmpDG1+8F +tsh6jhYAU24UX5pSuicqV3etTD1R87J1Gty1etoFnJVlCBX9Q/B/Gbys6Uv8cz1UsBA j8Jw== X-Received: by 10.180.73.237 with SMTP id o13mr46713524wiv.55.1438689347460; Tue, 04 Aug 2015 04:55:47 -0700 (PDT) Received: from schleppi.home.com (p54980F84.dip0.t-ipconnect.de. [84.152.15.132]) by smtp.gmail.com with ESMTPSA id u7sm2018458wif.3.2015.08.04.04.55.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 04:55:47 -0700 (PDT) From: Andreas Gruenbacher X-Google-Original-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, linux-cifs@vger.kernel.org, linux-security-module@vger.kernel.org, Andreas Gruenbacher Subject: [RFC v6 36/40] sunrpc: Add xdr_init_encode_pages Date: Tue, 4 Aug 2015 13:53:34 +0200 Message-Id: <1438689218-6921-37-git-send-email-agruenba@redhat.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438689218-6921-1-git-send-email-agruenba@redhat.com> References: <1438689218-6921-1-git-send-email-agruenba@redhat.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SUSPICIOUS_RECIPS, 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 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 63c1c36..f97b96b 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 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 + * @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 *