]> git.hungrycats.org Git - linux/commitdiff
NFS: Now that file handle comparison ignores the unused parts of the
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Mon, 23 Aug 2004 14:16:26 +0000 (10:16 -0400)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Mon, 23 Aug 2004 14:16:26 +0000 (10:16 -0400)
   file handle container, there is no longer any need to clear the
   file handle container before copying in a file handle.  This
   allows us to remove a 128 byte memset() from several hot paths.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@fys.uio.no>
fs/nfs/inode.c
fs/nfs/mount_clnt.c
fs/nfs/nfs2xdr.c
fs/nfs/nfs3xdr.c
fs/nfs/nfsroot.c
include/linux/nfs.h

index 919776250e8cc6dc317b53a70ecc3b5ee3f94357..daaa0680d737ab4942700a7d4ea5cc4c160d6666 100644 (file)
@@ -607,11 +607,10 @@ static int
 nfs_init_locked(struct inode *inode, void *opaque)
 {
        struct nfs_find_desc    *desc = (struct nfs_find_desc *)opaque;
-       struct nfs_fh           *fh = desc->fh;
        struct nfs_fattr        *fattr = desc->fattr;
 
        NFS_FILEID(inode) = fattr->fileid;
-       memcpy(NFS_FH(inode), fh, sizeof(struct nfs_fh));
+       nfs_copy_fh(NFS_FH(inode), desc->fh);
        return 0;
 }
 
@@ -1284,9 +1283,7 @@ static struct super_block *nfs_get_sb(struct file_system_type *fs_type,
        init_nfsv4_state(server);
 
        root = &server->fh;
-       memcpy(root, &data->root, sizeof(*root));
-       if (root->size < sizeof(root->data))
-               memset(root->data+root->size, 0, sizeof(root->data)-root->size);
+       nfs_copy_fh(root, (struct nfs_fh *) &data->root);
 
        if (data->version != NFS_MOUNT_VERSION) {
                printk("nfs warning: mount version %s than kernel\n",
@@ -1297,7 +1294,6 @@ static struct super_block *nfs_get_sb(struct file_system_type *fs_type,
                        data->bsize  = 0;
                if (data->version < 4) {
                        data->flags &= ~NFS_MOUNT_VER3;
-                       memset(root, 0, sizeof(*root));
                        root->size = NFS2_FHSIZE;
                        memcpy(root->data, data->old_root.data, NFS2_FHSIZE);
                }
index a2ddc6c5e2afc740bfc668b4f9600b829fa140cc..857e3ea4c40b2a199f314621e1243dad339cfe1e 100644 (file)
@@ -108,7 +108,6 @@ xdr_decode_fhstatus(struct rpc_rqst *req, u32 *p, struct mnt_fhstatus *res)
 {
        struct nfs_fh *fh = res->fh;
 
-       memset((void *)fh, 0, sizeof(*fh));
        if ((res->status = ntohl(*p++)) == 0) {
                fh->size = NFS2_FHSIZE;
                memcpy(fh->data, p, NFS2_FHSIZE);
@@ -121,7 +120,6 @@ xdr_decode_fhstatus3(struct rpc_rqst *req, u32 *p, struct mnt_fhstatus *res)
 {
        struct nfs_fh *fh = res->fh;
 
-       memset((void *)fh, 0, sizeof(*fh));
        if ((res->status = ntohl(*p++)) == 0) {
                int size = ntohl(*p++);
                if (size <= NFS3_FHSIZE) {
index 01aebbf13cc89b3de6ef484d1edc6f6312034aab..aa62e01b97e56a0336adc9290fac03f4002dc40a 100644 (file)
@@ -77,8 +77,6 @@ xdr_encode_fhandle(u32 *p, struct nfs_fh *fhandle)
 static inline u32 *
 xdr_decode_fhandle(u32 *p, struct nfs_fh *fhandle)
 {
-       /* Zero handle first to allow comparisons */
-       memset(fhandle, 0, sizeof(*fhandle));
        /* NFSv2 handles have a fixed length */
        fhandle->size = NFS2_FHSIZE;
        memcpy(fhandle->data, p, NFS2_FHSIZE);
index 415fa5bbb8c3f6b39310f843d6d432c8f77b569d..ba3ff20a643fc86b4de4dd26d816756d0b690127 100644 (file)
@@ -109,10 +109,6 @@ xdr_encode_fhandle(u32 *p, struct nfs_fh *fh)
 static inline u32 *
 xdr_decode_fhandle(u32 *p, struct nfs_fh *fh)
 {
-       /*
-        * Zero all nonused bytes
-        */
-       memset((u8 *)fh, 0, sizeof(*fh));
        if ((fh->size = ntohl(*p++)) <= NFS3_FHSIZE) {
                memcpy(fh->data, p, fh->size);
                return p + XDR_QUADLEN(fh->size);
index 86461591686259894e7e38cd1ff8f8b2e054c69e..fe679026da7dbf4d7b9f5c8725a1e2d332ae48e5 100644 (file)
@@ -495,10 +495,8 @@ static int __init root_nfs_get_handle(void)
        if (status < 0)
                printk(KERN_ERR "Root-NFS: Server returned error %d "
                                "while mounting %s\n", status, nfs_path);
-       else {
-               nfs_data.root.size = fh.size;
-               memcpy(nfs_data.root.data, fh.data, fh.size);
-       }
+       else
+               nfs_copy_fh(nfs_data.root, fh);
 
        return status;
 }
index 11a05d8a1f24a2aeafef3cc51f2d29f807bd44e8..ca2ffa6ae1d5ef0da33d8d265c1ac6579217fa3b 100644 (file)
@@ -148,6 +148,12 @@ static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b)
        return a->size != b->size || memcmp(a->data, b->data, a->size) != 0;
 }
 
+static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source)
+{
+       target->size = source->size;
+       memcpy(target->data, source->data, source->size);
+}
+
 
 /*
  * This is really a general kernel constant, but since nothing like