From: Rainer Orth Date: Thu, 2 Oct 2003 16:29:27 +0000 (+0000) Subject: Use NFS V2/V3 file handles instead of mount results. X-Git-Tag: before-retrans-udp-tcp-split~81 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=60b405bc4620b54863c8dae0732ddf38b1d2f8e6;p=am-utils-6.2.git Use NFS V2/V3 file handles instead of mount results. * include/am_utils.h (am_nfs_fhandle): Use NFS V2/V3 file handles only, not MOUNTPROC_MNT results. * amd/amfs_host.c (fetch_fhandle): Use local variables to store MOUNTPROC_MNT results. * amd/autil.c (amfs_mount): Use new am_nfs_fhandle_t. * amd/ops_nfs.c (struct fh_cache): New member fh_status. (got_nfs_fh): Use local variables to store MOUNTPROC_MNT results. Store MOUNTPROC_MNT errors in fh_status. (prime_nfs_fhandle_cache): Get fh_error from fh_status. * hlfsd/hlfsd.c (main): Use new am_nfs_fhandle_t. * libamu/mount_fs.c (compute_nfs_args): Copy NFS V2/V3 file handles straight from new am_nfs_fhandle_t. --- diff --git a/ChangeLog b/ChangeLog index 94cb9ad2..b87cd9b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2003-10-02 Rainer Orth + + Use NFS V2/V3 file handles instead of mount results. + + * include/am_utils.h (am_nfs_fhandle): Use NFS V2/V3 file handles + only, not MOUNTPROC_MNT results. + * amd/amfs_host.c (fetch_fhandle): Use local variables to store + MOUNTPROC_MNT results. + * amd/autil.c (amfs_mount): Use new am_nfs_fhandle_t. + * amd/ops_nfs.c (struct fh_cache): New member fh_status. + (got_nfs_fh): Use local variables to store MOUNTPROC_MNT results. + Store MOUNTPROC_MNT errors in fh_status. + (prime_nfs_fhandle_cache): Get fh_error from fh_status. + * hlfsd/hlfsd.c (main): Use new am_nfs_fhandle_t. + * libamu/mount_fs.c (compute_nfs_args): Copy NFS V2/V3 file + handles straight from new am_nfs_fhandle_t. + 2003-10-02 Rainer Orth * amd/clock.c (CID_ALLOC): Remove unused argument. diff --git a/amd/amfs_host.c b/amd/amfs_host.c index 393a8164..010f93cd 100644 --- a/amd/amfs_host.c +++ b/amd/amfs_host.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: amfs_host.c,v 1.23 2003/09/13 23:07:56 ib42 Exp $ + * $Id: amfs_host.c,v 1.24 2003/10/02 16:29:28 ro Exp $ * */ @@ -207,6 +207,10 @@ fetch_fhandle(CLIENT *client, char *dir, am_nfs_handle_t *fhp, u_long nfs_versio { struct timeval tv; enum clnt_stat clnt_stat; + struct fhstatus res; +#ifdef HAVE_FS_NFS3 + struct mountres3 res3; +#endif /* HAVE_FS_NFS3 */ /* * Pick a number, any number... @@ -224,23 +228,28 @@ fetch_fhandle(CLIENT *client, char *dir, am_nfs_handle_t *fhp, u_long nfs_versio plog(XLOG_INFO, "fetch_fhandle: NFS version %d", (int) nfs_version); #ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) { - memset((char *) &fhp->v3, 0, sizeof(fhp->v3)); + memset((char *) &res3, 0, sizeof(res3)); clnt_stat = clnt_call(client, MOUNTPROC_MNT, (XDRPROC_T_TYPE) xdr_dirpath, (SVC_IN_ARG_TYPE) &dir, (XDRPROC_T_TYPE) xdr_mountres3, - (SVC_IN_ARG_TYPE) &fhp->v3, + (SVC_IN_ARG_TYPE) &res3, tv); if (clnt_stat != RPC_SUCCESS) { plog(XLOG_ERROR, "mountd rpc failed: %s", clnt_sperrno(clnt_stat)); return EIO; } /* Check the status of the filehandle */ - if ((errno = fhp->v3.fhs_status)) { + if ((errno = res3.fhs_status)) { dlog("fhandle fetch for mount version 3 failed: %m"); return errno; } + memset((voidp) &fhp->v3, 0, sizeof(am_nfs_fh3)); + fhp->v3.fh3_length = res3.mountres3_u.mountinfo.fhandle.fhandle3_len; + memmove(fhp->v3.fh3_u.data, + res3.mountres3_u.mountinfo.fhandle.fhandle3_val, + fhp->v3.fh3_length); } else { /* not NFS_VERSION3 mount */ #endif /* HAVE_FS_NFS3 */ clnt_stat = clnt_call(client, @@ -248,18 +257,19 @@ fetch_fhandle(CLIENT *client, char *dir, am_nfs_handle_t *fhp, u_long nfs_versio (XDRPROC_T_TYPE) xdr_dirpath, (SVC_IN_ARG_TYPE) &dir, (XDRPROC_T_TYPE) xdr_fhstatus, - (SVC_IN_ARG_TYPE) &fhp->v2, + (SVC_IN_ARG_TYPE) &res, tv); if (clnt_stat != RPC_SUCCESS) { plog(XLOG_ERROR, "mountd rpc failed: %s", clnt_sperrno(clnt_stat)); return EIO; } /* Check status of filehandle */ - if (fhp->v2.fhs_status) { - errno = fhp->v2.fhs_status; + if (res.fhs_status) { + errno = res.fhs_status; dlog("fhandle fetch for mount version 1 failed: %m"); return errno; } + memmove(&fhp->v2, &res.fhs_fh, NFS_FHSIZE); #ifdef HAVE_FS_NFS3 } /* end of "if (nfs_version == NFS_VERSION3)" statement */ #endif /* HAVE_FS_NFS3 */ diff --git a/amd/autil.c b/amd/autil.c index cc7153c6..61f5eb2a 100644 --- a/amd/autil.c +++ b/amd/autil.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: autil.c,v 1.40 2003/09/20 01:09:04 ib42 Exp $ + * $Id: autil.c,v 1.41 2003/10/02 16:29:28 ro Exp $ * */ @@ -572,7 +572,7 @@ amfs_mount(am_node *mp, mntfs *mf, char *opts) #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* setup the many fields and flags within nfs_args */ - memmove(&anh.v2.fhs_fh, fhp, sizeof(*fhp)); + memmove(&anh.v2, fhp, sizeof(*fhp)); #ifdef HAVE_TRANSPORT_TYPE_TLI compute_nfs_args(&nfs_args, &mnt, diff --git a/amd/ops_nfs.c b/amd/ops_nfs.c index 65669908..652bfe77 100644 --- a/amd/ops_nfs.c +++ b/amd/ops_nfs.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: ops_nfs.c,v 1.32 2003/10/02 16:03:46 ro Exp $ + * $Id: ops_nfs.c,v 1.33 2003/10/02 16:29:28 ro Exp $ * */ @@ -97,6 +97,7 @@ struct fh_cache { int fh_cid; /* Callout id */ u_long fh_nfs_version; /* highest NFS version on host */ am_nfs_handle_t fh_nfs_handle; /* Handle on filesystem */ + int fh_status; /* Status of last rpc */ struct sockaddr_in fh_sin; /* Address of mountd */ fserver *fh_fs; /* Server holding filesystem */ char *fh_path; /* Filesystem on host */ @@ -175,6 +176,10 @@ static void got_nfs_fh(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, opaque_t arg, int done) { fh_cache *fp; + struct fhstatus res; +#ifdef HAVE_FS_NFS3 + struct mountres3 res3; +#endif /* HAVE_FS_NFS3 */ fp = find_nfs_fhandle_cache(arg, done); if (!fp) @@ -185,13 +190,26 @@ got_nfs_fh(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, o * NFS protocol version. */ #ifdef HAVE_FS_NFS3 - if (fp->fh_nfs_version == NFS_VERSION3) - fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &fp->fh_nfs_handle.v3, + if (fp->fh_nfs_version == NFS_VERSION3) { + memset(&res3, 0, sizeof(res3)); + fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &res3, (XDRPROC_T_TYPE) xdr_mountres3); - else + fp->fh_status = unx_error(res3.fhs_status); + memset(&fp->fh_nfs_handle.v3, 0, sizeof(am_nfs_fh3)); + fp->fh_nfs_handle.v3.fh3_length = res3.mountres3_u.mountinfo.fhandle.fhandle3_len; + memmove(fp->fh_nfs_handle.v3.fh3_u.data, + res3.mountres3_u.mountinfo.fhandle.fhandle3_val, + fp->fh_nfs_handle.v3.fh3_length); + } else { #endif /* HAVE_FS_NFS3 */ - fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &fp->fh_nfs_handle.v2, + memset(&res, 0, sizeof(res)); + fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &res, (XDRPROC_T_TYPE) xdr_fhstatus); + fp->fh_status = unx_error(res.fhs_status); + memmove(&fp->fh_nfs_handle.v2, &res.fhs_fh, NFS_FHSIZE); +#ifdef HAVE_FS_NFS3 + } +#endif /* HAVE_FS_NFS3 */ if (!fp->fh_error) { dlog("got filehandle for %s:%s", fp->fh_fs->fs_host, fp->fh_path); @@ -266,12 +284,7 @@ prime_nfs_fhandle_cache(char *path, fserver *fs, am_nfs_handle_t *fhbuf, mntfs * case 0: plog(XLOG_INFO, "prime_nfs_fhandle_cache: NFS version %d", (int) fp->fh_nfs_version); -#ifdef HAVE_FS_NFS3 - if (fp->fh_nfs_version == NFS_VERSION3) - error = fp->fh_error = unx_error(fp->fh_nfs_handle.v3.fhs_status); - else -#endif /* HAVE_FS_NFS3 */ - error = fp->fh_error = unx_error(fp->fh_nfs_handle.v2.fhs_status); + error = fp->fh_error = fp->fh_status; if (error == 0) { if (mf->mf_flags & MFF_NFS_SCALEDOWN) { diff --git a/hlfsd/hlfsd.c b/hlfsd/hlfsd.c index 7046b178..b920d260 100644 --- a/hlfsd/hlfsd.c +++ b/hlfsd/hlfsd.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: hlfsd.c,v 1.24 2003/07/30 06:56:13 ib42 Exp $ + * $Id: hlfsd.c,v 1.25 2003/10/02 16:29:28 ro Exp $ * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok and Alexander Dupuy @@ -522,7 +522,7 @@ main(int argc, char *argv[]) if (retry <= 0) retry = 1; /* XXX */ - memmove(&anh.v2.fhs_fh, root_fhp, sizeof(*root_fhp)); + memmove(&anh.v2, root_fhp, sizeof(*root_fhp)); #ifdef HAVE_TRANSPORT_TYPE_TLI compute_nfs_args(&nfs_args, &mnt, diff --git a/include/am_utils.h b/include/am_utils.h index 7de05f90..73160bf1 100644 --- a/include/am_utils.h +++ b/include/am_utils.h @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: am_utils.h,v 1.52 2003/07/30 06:56:14 ib42 Exp $ + * $Id: am_utils.h,v 1.53 2003/10/02 16:29:29 ro Exp $ * */ @@ -209,9 +209,9 @@ typedef enum { union am_nfs_handle { /* placeholder for V4 file handle */ #ifdef HAVE_FS_NFS3 - struct mountres3 v3; /* NFS version 3 handle */ + am_nfs_fh3 v3; /* NFS version 3 handle */ #endif /* HAVE_FS_NFS3 */ - struct fhstatus v2; /* NFS version 2 handle */ + am_nfs_fh v2; /* NFS version 2 handle */ }; typedef union am_nfs_handle am_nfs_handle_t; diff --git a/libamu/mount_fs.c b/libamu/mount_fs.c index 1c6e766a..3d2dcc34 100644 --- a/libamu/mount_fs.c +++ b/libamu/mount_fs.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: mount_fs.c,v 1.36 2003/10/01 01:47:40 ib42 Exp $ + * $Id: mount_fs.c,v 1.37 2003/10/02 16:29:29 ro Exp $ * */ @@ -341,9 +341,6 @@ void compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct netconfig *nfsncp, struct sockaddr_in *ip_addr, u_long nfs_version, char *nfs_proto, am_nfs_handle_t *fhp, char *host_name, char *fs_name) { int acval = 0; -#ifdef HAVE_FS_NFS3 - static am_nfs_fh3 fh3; /* static, b/c gcc on aix corrupts stack */ -#endif /* HAVE_FS_NFS3 */ /* initialize just in case */ memset((voidp) nap, 0, sizeof(nfs_args_t)); @@ -353,12 +350,6 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct netconfig /************************************************************************/ #ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) { - memset((voidp) &fh3, 0, sizeof(am_nfs_fh3)); - fh3.fh3_length = fhp->v3.mountres3_u.mountinfo.fhandle.fhandle3_len; - memmove(fh3.fh3_u.data, - fhp->v3.mountres3_u.mountinfo.fhandle.fhandle3_val, - fh3.fh3_length); - # if defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) /* * Some systems (Irix/bsdi3) have a separate field in nfs_args for @@ -366,9 +357,9 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct netconfig * the file handle set in nfs_args be plain bytes, and not * include the length field. */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &(fh3.fh3_u.data)); + NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3.fh3_u.data); # else /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &fh3); + NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3); # endif /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */ # ifdef MNT2_NFS_OPT_NFSV3 nap->flags |= MNT2_NFS_OPT_NFSV3; @@ -378,12 +369,12 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct netconfig # endif /* MNT2_NFS_OPT_VER3 */ } else #endif /* HAVE_FS_NFS3 */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &(fhp->v2.fhs_fh)); + NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v2); #ifdef HAVE_NFS_ARGS_T_FHSIZE # ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) - nap->fhsize = fh3.fh3_length; + nap->fhsize = fhp->v3.fh3_length; else # endif /* HAVE_FS_NFS3 */ nap->fhsize = FHSIZE;