From de0c72bf7c7d284f4d15d99c79b39e0c97f1a122 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 8 Apr 2011 13:00:15 -0500 Subject: [PATCH] DAFS: Request salvage on detach for volser 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 Reviewed-by: Derrick Brashear --- src/vol/volume.c | 10 ++++++++-- src/volser/dumpstuff.c | 5 +++++ src/volser/volprocs.c | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/vol/volume.c b/src/vol/volume.c index a6560f4c6..2f54b8763 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -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 */ diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index 11e07450b..1d48936c0 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -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); diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index 21e595803..1ada96959 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -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; -- 2.39.5