From 88a4efbfa3dbf497a96ad4d8b8ab2cd68351ffbf Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Thu, 19 Dec 2013 09:49:33 -0500 Subject: [PATCH] dafs: avoid asserting on dafs VSALVAGING error code DAFS introduced the VSALVAGING error code which is returned when a vnode cannot be put and a volume has been scheduled to be salvaged. Update the afsfileprocs to not assert on VSALVAGING, as well as the VSALVAGE error code. For example, VPutVnode() and VVnodeWriteToRead() may call VRequestSalvage_r() which will set the error code to VSALVAGING when a salvage is requested. This was noticed during a code inspection. Change-Id: I6cacfe92347bc5af57defef17b8a2f98c5302f93 Reviewed-on: http://gerrit.openafs.org/10611 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/viced/afsfileprocs.c | 55 ++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index c8025948c..8209ab679 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -151,6 +151,13 @@ pthread_mutex_t fileproc_glock_mutex; #define CREATE_SGUID_ADMIN_ONLY 1 + +/** + * Abort the fileserver on fatal errors returned from vnode operations. + */ +#define assert_vnode_success_or_salvaging(code) \ + opr_Assert((code) == 0 || (code) == VSALVAGE || (code) == VSALVAGING) + extern struct afsconf_dir *confDir; extern afs_int32 dataVersionHigh; @@ -651,7 +658,7 @@ CheckVnodeWithCall(AFSFid * fid, Volume ** volptr, struct VCallByVol *cbv, return (errorCode); if ((*vptr)->disk.uniquifier != fid->Unique) { VPutVnode(&fileCode, *vptr); - opr_Assert(fileCode == 0); + assert_vnode_success_or_salvaging(fileCode); *vptr = 0; return (VNOVNODE); /* return the right error code, at least */ } @@ -953,15 +960,15 @@ PutVolumePackageWithCall(struct rx_call *acall, Vnode * rx_KeepAliveOff(acall); if (parentwhentargetnotdir) { VPutVnode(&fileCode, parentwhentargetnotdir); - opr_Assert(!fileCode || (fileCode == VSALVAGE)); + assert_vnode_success_or_salvaging(fileCode); } if (targetptr) { VPutVnode(&fileCode, targetptr); - opr_Assert(!fileCode || (fileCode == VSALVAGE)); + assert_vnode_success_or_salvaging(fileCode); } if (parentptr) { VPutVnode(&fileCode, parentptr); - opr_Assert(!fileCode || (fileCode == VSALVAGE)); + assert_vnode_success_or_salvaging(fileCode); } if (volptr) { VPutVolumeWithCall(volptr, cbv); @@ -2332,7 +2339,7 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, if (parentwhentargetnotdir != NULL) { tparentwhentargetnotdir = *parentwhentargetnotdir; VPutVnode(&fileCode, parentwhentargetnotdir); - opr_Assert(!fileCode || (fileCode == VSALVAGE)); + assert_vnode_success_or_salvaging(fileCode); parentwhentargetnotdir = NULL; } @@ -2967,7 +2974,7 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid, rx_KeepAliveOff(acall); VPutVnode(&fileCode, parentwhentargetnotdir); rx_KeepAliveOn(acall); - opr_Assert(!fileCode || (fileCode == VSALVAGE)); + assert_vnode_success_or_salvaging(fileCode); parentwhentargetnotdir = NULL; } @@ -3111,7 +3118,7 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); rx_KeepAliveOn(acall); @@ -3205,7 +3212,7 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); /* Break call backs on Fid */ BreakCallBack(client->z.host, Fid, 0); @@ -3331,14 +3338,14 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name, DeleteFileCallBacks(&fileFid); /* convert the parent lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); } else { /* convert the parent lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); /* convert the target lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); /* tell all the file has changed */ BreakCallBack(client->z.host, &fileFid, 1); } @@ -3472,7 +3479,7 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); /* break call back on parent dir */ BreakCallBack(client->z.host, DirFid, 0); @@ -3799,7 +3806,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, } if (testnode == 1) top = 1; testvptr = VGetVnode(&errorCode, volptr, testnode, READ_LOCK); - opr_Assert(errorCode == 0); + assert_vnode_success_or_salvaging(errorCode); testnode = testvptr->disk.parent; VPutVnode(&errorCode, testvptr); if ((top == 1) && (testnode != 0)) { @@ -3810,7 +3817,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, errorCode = EIO; goto Bad_Rename; } - opr_Assert(errorCode == 0); + assert_vnode_success_or_salvaging(errorCode); } } @@ -3942,15 +3949,15 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, /* convert the write locks to a read locks before breaking callbacks */ VVnodeWriteToRead(&errorCode, newvptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); if (oldvptr != newvptr) { VVnodeWriteToRead(&errorCode, oldvptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); } if (newfileptr && !doDelete) { /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, newfileptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); } rx_KeepAliveOn(acall); @@ -3983,7 +3990,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, if (newfileptr) { rx_KeepAliveOff(acall); VPutVnode(&fileCode, newfileptr); - opr_Assert(fileCode == 0); + assert_vnode_success_or_salvaging(fileCode); } (void)PutVolumePackage(acall, fileptr, (newvptr && newvptr != oldvptr ? newvptr : 0), oldvptr, volptr, &client); @@ -4155,7 +4162,7 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); rx_KeepAliveOn(acall); @@ -4331,9 +4338,9 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write locks to read locks before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); VVnodeWriteToRead(&errorCode, parentptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); rx_KeepAliveOn(acall); @@ -4502,7 +4509,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); rx_KeepAliveOn(acall); @@ -4638,7 +4645,7 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); rx_KeepAliveOn(acall); @@ -4942,7 +4949,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid, rx_KeepAliveOn(acall); /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - opr_Assert(!errorCode || errorCode == VSALVAGE); + assert_vnode_success_or_salvaging(errorCode); BreakCallBack(client->z.host, Fid, 0); } -- 2.39.5