From 384ce4f4e094e0e5ffb5762b933a285d30f347db Mon Sep 17 00:00:00 2001 From: Jeffrey Hutzelman Date: Mon, 13 Dec 2004 19:41:10 +0000 Subject: [PATCH] STABLE14-STABLE12-implement-vpeek-for-listvol-20041211 FIXES 16765 All of AFSVolListOneVolume, AFSVolXListOneVolume, AFSVolListVolumes, AFSVolXListVolumes currrently attach each volume to be listed with V_READONLY. This makes the fileserver update and sync the volume header before releasing the volume to the volserver. The result is that volume list operations are slow, and generate lots of fileserver load, as Jimmy pointed out during his talk this afternoon. The attached patch introduces a new attach mode, V_PEEK, which is like a cross between V_READONLY and V_SECRETLY. It can be used for read-only operations on the volume header, where it is not necessary to inform the fileserver that the volume is being accessed. The patch also changes the above-named RPC's to use the new mode. --- src/vol/volume.c | 7 ++++--- src/vol/volume.h | 5 +++++ src/volser/volprocs.c | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/vol/volume.c b/src/vol/volume.c index 4b677664f..a6d5a1690 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -635,7 +635,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) } DiskToVolumeHeader(&iheader, &diskHeader); - if (programType == volumeUtility && mode != V_SECRETLY) { + if (programType == volumeUtility && mode != V_SECRETLY && mode != V_PEEK) { if (FSYNC_askfs(iheader.id, partition, FSYNC_NEEDVOLUME, mode) == FSYNC_DENIED) { Log("VAttachVolume: attach of volume %u apparently denied by file server\n", iheader.id); @@ -650,7 +650,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) * takes the volume offline or not. If the volume isn't * offline, we must not return it when we detach the volume, * or the server will abort */ - if (mode == V_READONLY + if (mode == V_READONLY || mode == V_PEEK || (!VolumeWriteable(vp) && (mode == V_CLONE || mode == V_DUMP))) vp->needsPutBack = 0; else @@ -667,7 +667,8 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) * for all of that to happen, but if it does, probably the right * fix is for the server to allow the return of readonly volumes * that it doesn't think are really checked out. */ - if (programType == volumeUtility && vp == NULL && mode != V_SECRETLY) { + if (programType == volumeUtility && vp == NULL && + mode != V_SECRETLY && mode != V_PEEK) { FSYNC_askfs(iheader.id, partition, FSYNC_ON, 0); } else if (programType == fileServer && vp) { V_needsCallback(vp) = 0; diff --git a/src/vol/volume.h b/src/vol/volume.h index c737f2b4f..779e9b4c0 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -492,6 +492,11 @@ extern void VTakeOffline(register Volume * vp); * never knows about more than one copy of the same volume--when * a volume is moved from one partition to another on a single * server */ +#define V_PEEK 6 /* "Peek" at the volume without telling the fileserver. This is + * similar to V_SECRETLY, but read-only. It is used in cases where + * not impacting fileserver performance is more important than + * getting the most recent data. */ + #if defined(NEARINODE_HINT) #define V_pref(vp,nearInode) nearInodeHash(V_id(vp),(nearInode)); (nearInode) %= V_partition(vp)->f_files diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index 95796aafb..9499360dc 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -1790,7 +1790,7 @@ VolListOneVolume(struct rx_call *acid, afs_int32 partid, afs_int32 pntr->volid = volid; goto drop; } - tv = VAttachVolumeByName(&error, pname, volname, V_READONLY); + tv = VAttachVolumeByName(&error, pname, volname, V_PEEK); if (error) { pntr->status = 0; /*things are messed up */ strcpy(pntr->name, volname); @@ -2004,7 +2004,7 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID, /* * Attach the volume, give up on the volume if we can't. */ - tv = VAttachVolumeByName(&error, pname, volname, V_READONLY); + tv = VAttachVolumeByName(&error, pname, volname, V_PEEK); if (error) { xInfoP->status = 0; /*things are messed up */ strcpy(xInfoP->name, volname); @@ -2171,7 +2171,7 @@ VolListVolumes(struct rx_call *acid, afs_int32 partid, afs_int32 flags, pntr->volid = volid; goto drop; } - tv = VAttachVolumeByName(&error, pname, volname, V_READONLY); + tv = VAttachVolumeByName(&error, pname, volname, V_PEEK); if (error) { pntr->status = 0; /*things are messed up */ strcpy(pntr->name, volname); @@ -2413,7 +2413,7 @@ VolXListVolumes(struct rx_call *a_rxCidP, afs_int32 a_partID, /* * Attach the volume, give up on this volume if we can't. */ - tv = VAttachVolumeByName(&error, pname, volname, V_READONLY); + tv = VAttachVolumeByName(&error, pname, volname, V_PEEK); if (error) { xInfoP->status = 0; /*things are messed up */ strcpy(xInfoP->name, volname); -- 2.39.5