DAFS: Request salvage on detach for volser
authorAndrew Deason <adeason@sinenomine.net>
Fri, 8 Apr 2011 18:00:15 +0000 (13:00 -0500)
committerDerrick Brashear <shadow@dementia.org>
Mon, 11 Apr 2011 03:50:40 +0000 (20:50 -0700)
When the volserver notices that a volume needs salvaging, mark
V_needsSalvaged. So when we VDetachVolume the volume, we can then just
request the salvage in the volume package.

Fix the VolClone salvaging code to do this as well, instead of using
the vol-private VRequestSalvage_r interface.

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

src/vol/volume.c
src/volser/dumpstuff.c
src/volser/volprocs.c

index a6560f4..2f54b87 100644 (file)
@@ -4613,11 +4613,17 @@ VDetachVolume_r(Error * ec, Volume * vp)
        notifyServer = vp->needsPutBack;
        if (V_destroyMe(vp) == DESTROY_ME)
            useDone = FSYNC_VOL_LEAVE_OFF;
-#ifdef AFS_DEMAND_ATTACH_FS
+# ifdef AFS_DEMAND_ATTACH_FS
        else if (!V_blessed(vp) || !V_inService(vp))
            useDone = FSYNC_VOL_LEAVE_OFF;
-#endif
+# endif
+    }
+# ifdef AFS_DEMAND_ATTACH_FS
+    if (V_needsSalvaged(vp)) {
+       notifyServer = 0;
+       VRequestSalvage_r(ec, vp, SALVSYNC_NEEDED, 0);
     }
+# endif
     tpartp = vp->partition;
     volume = V_id(vp);
 #endif /* FSSYNC_BUILD_CLIENT */
index 11e0745..1d48936 100644 (file)
@@ -1400,6 +1400,7 @@ ReadVnodes(struct iod *iodp, Volume * vp, int incremental,
                    if (!VALID_INO(ino)) {
                        Log("1 Volser: ReadVnodes: IH_CREATE: %s - restore aborted\n",
                             afs_error_message(errno));
+                       V_needsSalvaged(vp) = 1;
                        return VOLSERREAD_DUMPERROR;
                    }
                    nearInode = ino;
@@ -1410,6 +1411,7 @@ ReadVnodes(struct iod *iodp, Volume * vp, int incremental,
                        Log("1 Volser: ReadVnodes: IH_OPEN: %s - restore aborted\n",
                             afs_error_message(errno));
                        IH_RELEASE(tmpH);
+                       V_needsSalvaged(vp) = 1;
                        return VOLSERREAD_DUMPERROR;
                    }
                    vnodeLength =
@@ -1421,6 +1423,7 @@ ReadVnodes(struct iod *iodp, Volume * vp, int incremental,
                        Log("1 Volser: ReadVnodes: IDEC inode %llu\n",
                            (afs_uintmax_t) ino);
                        IH_DEC(V_linkHandle(vp), ino, V_parentId(vp));
+                       V_needsSalvaged(vp) = 1;
                        return VOLSERREAD_DUMPERROR;
                    }
                    break;
@@ -1454,6 +1457,7 @@ ReadVnodes(struct iod *iodp, Volume * vp, int incremental,
            if (fdP == NULL) {
                Log("1 Volser: ReadVnodes: Error opening vnode index: %s; restore aborted\n",
                    afs_error_message(errno));
+               V_needsSalvaged(vp) = 1;
                return VOLSERREAD_DUMPERROR;
            }
            if (FDH_PREAD(fdP, &oldvnode, sizeof(oldvnode), vnodeIndexOffset(vcp, vnodeNumber)) ==
@@ -1468,6 +1472,7 @@ ReadVnodes(struct iod *iodp, Volume * vp, int incremental,
                Log("1 Volser: ReadVnodes: Error writing vnode index: %s; restore aborted\n",
                    afs_error_message(errno));
                FDH_REALLYCLOSE(fdP);
+               V_needsSalvaged(vp) = 1;
                return VOLSERREAD_DUMPERROR;
            }
            FDH_CLOSE(fdP);
index 21e5958..1ada969 100644 (file)
@@ -571,6 +571,7 @@ VolCreateVolume(struct rx_call *acid, afs_int32 apart, char *aname,
            Log("1 Volser: CreateVolume: Unable to create volume root dir; "
                "error code %u\n", (unsigned)error);
            DeleteTrans(tt, 1);
+           V_needsSalvaged(vp) = 1;
            VDetachVolume(&junk, vp);
            return EIO;
        }
@@ -848,8 +849,7 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
        DeleteTrans(ttc, 1);
 #ifdef AFS_DEMAND_ATTACH_FS
     if (salv_vp && error != VVOLEXISTS && error != EXDEV) {
-       Error salv_error;
-       VRequestSalvage_r(&salv_error, salv_vp, FSYNC_SALVAGE, 0);
+       V_needsSalvaged(salv_vp) = 1;
     }
 #endif /* AFS_DEMAND_ATTACH_FS */
     return error;