DAFS: Preattach, not attach, in FSYNC_Drop
authorAndrew Deason <adeason@sinenomine.net>
Thu, 31 May 2012 21:41:15 +0000 (16:41 -0500)
committerDerrick Brashear <shadow@dementix.org>
Mon, 11 Jun 2012 22:26:00 +0000 (15:26 -0700)
FSYNC_Drop currently attaches volumes that were checked out by the
dropped fssync handler, but not checked back in, in order to make the
volume available again. For DAFS, however, a full attachment is
unnecessary; just preattach instead.

Change-Id: I2c9d0b8cf0ddc7f4182347706b2c26d86f69725e
Reviewed-on: http://gerrit.openafs.org/7515
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/vol/fssync-server.c

index 14d2247..c90d86e 100644 (file)
@@ -1986,21 +1986,32 @@ FSYNC_Drop(osi_socket fd)
     struct offlineInfo *p;
     int i;
     Error error;
+#ifndef AFS_DEMAND_ATTACH_FS
     char tvolName[VMAXPATHLEN];
+#endif
 
     VOL_LOCK;
     p = OfflineVolumes[FindHandler(fd)];
     for (i = 0; i < MAXOFFLINEVOLUMES; i++) {
        if (p[i].volumeID) {
-
            Volume *vp;
 
+#ifdef AFS_DEMAND_ATTACH_FS
+           vp = VPreAttachVolumeById_r(&error, p[i].partName, p[i].volumeID);
+           if (vp) {
+               VCreateReservation_r(vp);
+               VWaitExclusiveState_r(vp);
+               VDeregisterVolOp_r(vp);
+               VCancelReservation_r(vp);
+           }
+#else
            tvolName[0] = OS_DIRSEPC;
            sprintf(&tvolName[1], VFORMAT, afs_printable_uint32_lu(p[i].volumeID));
            vp = VAttachVolumeByName_r(&error, p[i].partName, tvolName,
                                       V_VOLUPD);
            if (vp)
                VPutVolume_r(vp);
+#endif /* !AFS_DEMAND_ATTACH_FS */
            p[i].volumeID = 0;
        }
     }