From patchwork Tue Dec 14 14:55:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 409991 X-Patchwork-Delegate: Trond.Myklebust@netapp.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBEEstRs007667 for ; Tue, 14 Dec 2010 14:55:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757597Ab0LNOze (ORCPT ); Tue, 14 Dec 2010 09:55:34 -0500 Received: from mail-gw0-f42.google.com ([74.125.83.42]:64762 "EHLO mail-gw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757549Ab0LNOzd (ORCPT ); Tue, 14 Dec 2010 09:55:33 -0500 Received: by mail-gw0-f42.google.com with SMTP id 20so538996gwb.1 for ; Tue, 14 Dec 2010 06:55:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:subject:to:cc :date:message-id:in-reply-to:references:user-agent:mime-version :content-type:content-transfer-encoding; bh=zOHDD9S+q3eBg23MsC/LLeeUEENfy6YOriaJBDGj6j4=; b=YtUKwoYf86iAM4v8DhHlOI+q1sigQ5O589Yqi547AjGwwKOacL8aP4VaOcCjK7/M3/ sH4FoQ3VbYaJy7r+Bi/NNRF1jG5sj9yul+bPVCq2nLL9d/HjeJU09LwqNwzv8xUIrXvY hDp5YRHJ5CMMp0qAoHRDzCWBQxQ9BAKgcts88= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; b=Z4dY2Lmn3yqTWz3/esJo4U1pMpdVx9L3Qr0VzXWBKXFB+6fduFs5jSljyfrkgqgGVu n4Ob3aKONmmOIQjAd1bj6Upd2SCZDfVlfEvEuWLnxic9SgmoWIZK1GAAkRZFblfN31IF pliJNLr+r4AGzwRQOZY3+1ZHmOcvVx++zxnfY= Received: by 10.42.177.74 with SMTP id bh10mr4330815icb.51.1292338533032; Tue, 14 Dec 2010 06:55:33 -0800 (PST) Received: from matisse.1015granger.net ([99.26.161.222]) by mx.google.com with ESMTPS id y3sm13503icw.11.2010.12.14.06.55.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 14 Dec 2010 06:55:32 -0800 (PST) From: Chuck Lever Subject: [PATCH 07/31] NFS: Move and update xdr_decode_foo() functions that we're keeping To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org Date: Tue, 14 Dec 2010 09:55:30 -0500 Message-ID: <20101214145530.2293.83224.stgit@matisse.1015granger.net> In-Reply-To: <20101214144747.2293.68070.stgit@matisse.1015granger.net> References: <20101214144747.2293.68070.stgit@matisse.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 14 Dec 2010 14:55:36 +0000 (UTC) diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index ae75116..70df08a 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c @@ -89,46 +89,6 @@ static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) /* - * Common NFS XDR functions as inlines - */ -static inline __be32* -xdr_decode_time(__be32 *p, struct timespec *timep) -{ - timep->tv_sec = ntohl(*p++); - /* Convert microseconds into nanoseconds */ - timep->tv_nsec = ntohl(*p++) * 1000; - return p; -} - -static __be32 * -xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) -{ - u32 rdev, type; - type = ntohl(*p++); - fattr->mode = ntohl(*p++); - fattr->nlink = ntohl(*p++); - fattr->uid = ntohl(*p++); - fattr->gid = ntohl(*p++); - fattr->size = ntohl(*p++); - fattr->du.nfs2.blocksize = ntohl(*p++); - rdev = ntohl(*p++); - fattr->du.nfs2.blocks = ntohl(*p++); - fattr->fsid.major = ntohl(*p++); - fattr->fsid.minor = 0; - fattr->fileid = ntohl(*p++); - p = xdr_decode_time(p, &fattr->atime); - p = xdr_decode_time(p, &fattr->mtime); - p = xdr_decode_time(p, &fattr->ctime); - fattr->valid |= NFS_ATTR_FATTR_V2; - fattr->rdev = new_decode_dev(rdev); - if (type == NFCHR && rdev == NFS2_FIFO_DEV) { - fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO; - fattr->rdev = 0; - } - return p; -} - -/* * Encode/decode NFSv2 basic data types * * Basic NFSv2 data types are defined in section 2.3 of RFC 1094: @@ -208,6 +168,27 @@ out_overflow: } /* + * 2.3.2. ftype + * + * enum ftype { + * NFNON = 0, + * NFREG = 1, + * NFDIR = 2, + * NFBLK = 3, + * NFCHR = 4, + * NFLNK = 5 + * }; + * + */ +static __be32 *xdr_decode_ftype(__be32 *p, u32 *type) +{ + *type = be32_to_cpup(p++); + if (unlikely(*type > NF2FIFO)) + *type = NFBAD; + return p; +} + +/* * 2.3.3. fhandle * * typedef opaque fhandle[FHSIZE]; @@ -269,6 +250,13 @@ static __be32 *xdr_encode_current_server_time(__be32 *p, return p; } +static __be32 *xdr_decode_time(__be32 *p, struct timespec *timep) +{ + timep->tv_sec = be32_to_cpup(p++); + timep->tv_nsec = be32_to_cpup(p++) * NSEC_PER_USEC; + return p; +} + /* * 2.3.5. fattr * @@ -292,12 +280,39 @@ static __be32 *xdr_encode_current_server_time(__be32 *p, */ static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) { + u32 rdev, type; __be32 *p; p = xdr_inline_decode(xdr, NFS_fattr_sz << 2); if (unlikely(p == NULL)) goto out_overflow; - xdr_decode_fattr(p, fattr); + + fattr->valid |= NFS_ATTR_FATTR_V2; + + p = xdr_decode_ftype(p, &type); + + fattr->mode = be32_to_cpup(p++); + fattr->nlink = be32_to_cpup(p++); + fattr->uid = be32_to_cpup(p++); + fattr->gid = be32_to_cpup(p++); + fattr->size = be32_to_cpup(p++); + fattr->du.nfs2.blocksize = be32_to_cpup(p++); + + rdev = be32_to_cpup(p++); + fattr->rdev = new_decode_dev(rdev); + if (type == (u32)NFCHR && rdev == (u32)NFS2_FIFO_DEV) { + fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO; + fattr->rdev = 0; + } + + fattr->du.nfs2.blocks = be32_to_cpup(p++); + fattr->fsid.major = be32_to_cpup(p++); + fattr->fsid.minor = 0; + fattr->fileid = be32_to_cpup(p++); + + p = xdr_decode_time(p, &fattr->atime); + p = xdr_decode_time(p, &fattr->mtime); + xdr_decode_time(p, &fattr->ctime); return 0; out_overflow: print_overflow_msg(__func__, xdr);