]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: Return raw code from background daemons
authorAndrew Deason <adeason@sinenomine.net>
Fri, 20 Dec 2013 18:16:37 +0000 (12:16 -0600)
committerStephan Wiesand <stephan.wiesand@desy.de>
Thu, 27 Feb 2014 13:26:23 +0000 (05:26 -0800)
Currently, a background daemon processing a 'store' request will
return any error code in the 'code' field in the brequest structure,
for processing by anyone that's waiting for the response. Since any
waiter will not have access to the treq for the request, they won't be
able to call afs_CheckCode on that return code, so the background
daemon calls afs_CheckCode before returning its error code.

Currently, afs_close uses the 'code' value from the background daemon
as if it were not passed through afs_CheckCode. That is, if all
background daemons are busy, we get our 'code' directly from
afs_StoreOnLastReference, and if we use a background daemon, our
'code' is tb->code. But these values are two different things: the
return value from afs_StoreOnLastReference is a raw error code, and
the code from the background daemon (tb->code) has been translated
through afs_CheckCode.

This can be confusing, in particular for the scenario where a
StoreData fails because of network errors or because of a VBUSY error.
If we get a network error when the request went through a background
daemon, afs_CheckCode will translate this to ETIMEDOUT, which is
commonly value 110, the same as VBUSY. So, an ETIMEDOUT error from the
background daemon is difficult to distinguish from a VBUSY error from
a direct afs_StoreOnLastReference call. Either case can result in a
message to the kernel like the following:

  afs: failed to store file (110)

To resolve this, have the background daemon store both the 'raw' error
code, and the error code that has been translated through
afs_CheckCode. afs_close can then use the raw error code when
reporting messages like normal, but can still use the translated error
code to return to the caller, if it has a translated error. With this
change, now afs_close will always log "network problems" for a network
error, regardless of if the error came in via a background daemon or a
direct afs_StoreOnLastReference call.

In Irix's afs_delmap, we just remove the old usage of tb->code, since
the result was not used for anything.

Reviewed-on: http://gerrit.openafs.org/10633
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 7f58e4ac454f9c06fb2d51ff0a17b8656c454efe)

Change-Id: Id5935d41b0d20000f06b39c48649cd7d0dd2fd81
Reviewed-on: http://gerrit.openafs.org/10812
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: D Brashear <shadow@your-file-system.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/afs/IRIX/osi_vnodeops.c
src/afs/VNOPS/afs_vnop_write.c
src/afs/afs.h
src/afs/afs_daemons.c
src/afs/afs_dcache.c

index 33d94e3d7ef8953c015c69c3147690ed71d86d13..70dac93f20d2892fad8e8a8ec2e17b67e67190c7 100644 (file)
@@ -983,7 +983,6 @@ OSI_VC_DECL(avc);
                tb->flags |= BUWAIT;
                afs_osi_Sleep(tb);
            }
-           code = tb->code;
            afs_BRelease(tb);
        }
     } else {
index c0672e83d993810ce493cad61395376d596ebe5e..50e0702966328b87bd4d1ac2bb49d4ba8bcfb88d 100644 (file)
@@ -681,6 +681,7 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
 #endif
 {
     afs_int32 code;
+    afs_int32 code_checkcode = 0;
     struct brequest *tb;
     struct vrequest treq;
 #ifdef AFS_SGI65_ENV
@@ -766,7 +767,8 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
                tb->flags |= BUWAIT;
                afs_osi_Sleep(tb);
            }
-           code = tb->code;
+           code = tb->code_raw;
+           code_checkcode = tb->code_checkcode;
            afs_BRelease(tb);
        }
 
@@ -787,6 +789,7 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
 #endif
            /* printf("avc->vc_error=%d\n", avc->vc_error); */
            code = avc->vc_error;
+           code_checkcode = 0;
            avc->vc_error = 0;
        }
        ReleaseWriteLock(&avc->lock);
@@ -848,7 +851,12 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
     }
     AFS_DISCON_UNLOCK();
     afs_PutFakeStat(&fakestat);
-    code = afs_CheckCode(code, &treq, 5);
+
+    if (code_checkcode) {
+       code = code_checkcode;
+    } else {
+       code = afs_CheckCode(code, &treq, 5);
+    }
     return code;
 }
 
index 76394a0f78fb0d2050036651da1eb8e4790e4d57..e77d16aa8dbb22c597905bc0c59561765826868f 100644 (file)
@@ -152,7 +152,8 @@ struct brequest {
     afs_ucred_t *cred; /* credentials to use for operation */
     afs_size_t size_parm[BPARMS];      /* random parameters */
     void *ptr_parm[BPARMS];    /* pointer parameters */
-    afs_int32 code;            /* return code */
+    afs_int32 code_raw;                /* return code from AFS routines */
+    afs_int32 code_checkcode;  /* the afs_CheckCode-translated code */
     short refCount;            /* use counter for this structure */
     char opcode;               /* what to do (store, fetch, etc) */
     char flags;                        /* free, etc */
index dd710b75650601ba7194701ae512782f427ba249..a35f2cb3b1b9a104ace8fd7c9fcfd73edf740796 100644 (file)
@@ -601,7 +601,17 @@ BStore(struct brequest *ab)
 #endif
     /* now set final return code, and wakeup anyone waiting */
     if ((ab->flags & BUVALID) == 0) {
-       ab->code = afs_CheckCode(code, &treq, 43);      /* set final code, since treq doesn't go across processes */
+
+       /* To explain code_raw/code_checkcode:
+        * Anyone that's waiting won't have our treq, so they won't be able to
+        * call afs_CheckCode themselves on the return code we provide here.
+        * But if we give back only the afs_CheckCode value, they won't know
+        * what the "raw" value was. So give back both values, so the waiter
+        * can know the "raw" value for interpreting the value internally, as
+        * well as the afs_CheckCode value to give to the OS. */
+       ab->code_raw = code;
+       ab->code_checkcode = afs_CheckCode(code, &treq, 43);
+
        ab->flags |= BUVALID;
        if (ab->flags & BUWAIT) {
            ab->flags &= ~BUWAIT;
@@ -668,7 +678,7 @@ afs_BQueue(short aopcode, struct vcache *avc,
            tb->ptr_parm[1] = apparm1;
            tb->ptr_parm[2] = apparm2;
            tb->flags = 0;
-           tb->code = 0;
+           tb->code_raw = tb->code_checkcode = 0;
            tb->ts = afs_brs_count++;
            /* if daemons are waiting for work, wake them up */
            if (afs_brsDaemons > 0) {
index 18117995dc08c6485291737236f6a9e8ab95119c..dc1e039c168c9c838e9060300db9301a4b66e2f2 100644 (file)
@@ -3045,7 +3045,7 @@ afs_wakeup(struct vcache *avc)
             * is already being handled by the higher-level code.
             */
            if ((avc->f.states & CSafeStore) == 0) {
-               tb->code = 0;
+               tb->code_raw = tb->code_checkcode = 0;
                tb->flags |= BUVALID;
                if (tb->flags & BUWAIT) {
                    tb->flags &= ~BUWAIT;