From 0bddd655c9fff2386ef605c03546beca038d2bf4 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 30 Sep 2010 11:34:59 -0500 Subject: [PATCH] volser: Do not FSYNC_VOL_DONE temporary volumes Currently, the volserver just looks at the destroyMe field in a volume header to see if it should tell the fileserver a volume has been deleted (FSYNC_VOL_DONE opcode). However, temporary volumes created by the volserver (such as new volumes or clones) have destroyMe set, but are obviously not deleted, and so the fileserver should just be told FSYNC_VOL_LEAVE_OFF about these volumes instead. With commit bb9caf9822a53ad07cd3a5d6cea7f6b7eeeedd59, FSYNC_VOL_DONE and FSYNC_VOL_LEAVE_OFF actually do different things, so this does make a difference. Note that this commit slightly changes the meaning of the vp->needsPutBack field. Now it must be set to VOL_PUTBACK_DELETE to tell the fileserver that the volume has been deleted, and set to VOL_PUTBACK if it just needs to be given back to the fileserver. Reviewed-on: http://gerrit.openafs.org/2872 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit 5988923898e15cb50d550e54119869b38cb5bc5b) Change-Id: I1cbc48537a0b038838a8bc102842b05195d685c3 Reviewed-on: http://gerrit.openafs.org/3481 --- src/vol/volume.c | 12 +++++++++--- src/vol/volume.h | 11 ++++++++--- src/volser/volprocs.c | 5 ++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/vol/volume.c b/src/vol/volume.c index fe541a3e8..1916a651b 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -2413,7 +2413,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) if (mode == V_PEEK) { vp->needsPutBack = 0; } else { - vp->needsPutBack = 1; + vp->needsPutBack = VOL_PUTBACK; } #else /* !AFS_DEMAND_ATTACH_FS */ /* duplicate computation in fssync.c about whether the server @@ -2424,7 +2424,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) || (!VolumeWriteable(vp) && (mode == V_CLONE || mode == V_DUMP))) vp->needsPutBack = 0; else - vp->needsPutBack = 1; + vp->needsPutBack = VOL_PUTBACK; #endif /* !AFS_DEMAND_ATTACH_FS */ } #ifdef FSSYNC_BUILD_CLIENT @@ -4175,7 +4175,7 @@ VDetachVolume_r(Error * ec, Volume * vp) if (VCanUseFSSYNC()) { notifyServer = vp->needsPutBack; if (V_destroyMe(vp) == DESTROY_ME) - useDone = FSYNC_VOL_DONE; + useDone = FSYNC_VOL_LEAVE_OFF; #ifdef AFS_DEMAND_ATTACH_FS else if (!V_blessed(vp) || !V_inService(vp)) useDone = FSYNC_VOL_LEAVE_OFF; @@ -4201,6 +4201,12 @@ VDetachVolume_r(Error * ec, Volume * vp) */ #ifdef FSSYNC_BUILD_CLIENT if (VCanUseFSSYNC() && notifyServer) { + if (notifyServer == VOL_PUTBACK_DELETE) { + /* Only send FSYNC_VOL_DONE if the volume was actually deleted. + * volserver code will set needsPutBack to VOL_PUTBACK_DELETE + * to signify a deleted volume. */ + useDone = FSYNC_VOL_DONE; + } /* * Note: The server is not notified in the case of a bogus volume * explicitly to make it possible to create a volume, do a partial diff --git a/src/vol/volume.h b/src/vol/volume.h index 998bb86aa..b6a54c9a4 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -653,10 +653,15 @@ typedef struct Volume { bit32 cacheCheck; /* Online sequence number to be used to invalidate vnode cache entries * that stayed around while a volume was offline */ short nUsers; /* Number of users of this volume header */ - byte needsPutBack; /* For a volume utility, this flag is set if we need - * to give the volume back when we detach it. The server has +#define VOL_PUTBACK 1 +#define VOL_PUTBACK_DELETE 2 + byte needsPutBack; /* For a volume utility, this flag is set to VOL_PUTBACK if we + * need to give the volume back when we detach it. The server has * certain modes where it doesn't detach the volume, and - * if we give it back spuriously, the server aborts. This field + * if we give it back spuriously, the server aborts. If set to + * VOL_PUTBACK_DELETE, it indicates that we need to tell the + * fileserver that the volume is gone entirely, instead of just + * giving the volume back to the fileserver. This field * is meaningless on the file server */ byte specialStatus; /* An error code to return on VGetVolume: the * volume is unavailable for the reason quoted, diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index ce09cbf58..858ac63cc 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -636,7 +636,10 @@ VolDeleteVolume(struct rx_call *acid, afs_int32 atrans) Log("%s is executing Delete Volume %u\n", caller, tt->volid); TSetRxCall(tt, acid, "DeleteVolume"); VPurgeVolume(&error, tt->volume); /* don't check error code, it is not set! */ - V_destroyMe(tt->volume) = DESTROY_ME; /* so endtrans does the right fssync opcode */ + V_destroyMe(tt->volume) = DESTROY_ME; + if (tt->volume->needsPutBack) { + tt->volume->needsPutBack = VOL_PUTBACK_DELETE; /* so endtrans does the right fssync opcode */ + } VTRANS_OBJ_LOCK(tt); tt->vflags |= VTDeleted; /* so we know not to do anything else to it */ TClearRxCall_r(tt); -- 2.39.5