Use NFS V2/V3 file handles instead of mount results.
authorRainer Orth <ro@techfak.uni-bielefeld.de>
Thu, 2 Oct 2003 16:29:27 +0000 (16:29 +0000)
committerRainer Orth <ro@techfak.uni-bielefeld.de>
Thu, 2 Oct 2003 16:29:27 +0000 (16:29 +0000)
* 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.

ChangeLog
amd/amfs_host.c
amd/autil.c
amd/ops_nfs.c
hlfsd/hlfsd.c
include/am_utils.h
libamu/mount_fs.c

index 94cb9ad2e92e2305d9025447ff5be357c1a62de6..b87cd9b0f8f22fba94fdebe96c9cd652abb0f54a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2003-10-02  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       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  <ro@TechFak.Uni-Bielefeld.DE>
 
        * amd/clock.c (CID_ALLOC): Remove unused argument.
index 393a81647ac44bfbb0fe65f0ef3e82f5360c7674..010f93cda2df8c2ad9eb5db4a0bfe3920579457e 100644 (file)
@@ -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 */
index cc7153c62b6cc8449b0e9a1566df3ffe3b136898..61f5eb2a773f157cb7168d488bcd6569bbcfa425 100644 (file)
@@ -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,
index 656699083f84633593341c5dc7249bb25dd25644..652bfe77f12f6bcdb8c14dced58dc0b93a7c8eab 100644 (file)
@@ -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) {
index 7046b178915cdc02dfe1dde8f77b0367e7189a0e..b920d260855d1c4782f27d20ecf895ee4b3200e3 100644 (file)
@@ -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 <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
@@ -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,
index 7de05f907a6a2d641ace97c8e6346decce1e4726..73160bf1fe2cf6cb4ccbc30d7fac264ef5239a29 100644 (file)
@@ -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;
 
index 1c6e766aaa67948ee18b19a3193f8ea738d81515..3d2dcc345da0e6d9d9cf59806455e78f0c0c125d 100644 (file)
@@ -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;