From 5bd05894dd14bdbf845aa3f384f9d8dcac1286aa Mon Sep 17 00:00:00 2001 From: Hartmut Reuter Date: Thu, 18 Oct 2012 07:07:21 -0400 Subject: [PATCH] libafs: add partial background store add a bop that does a partial store Change-Id: I5971d2cda705a11c7fba7c0cfa54a3fa2d90f392 Reviewed-on: http://gerrit.openafs.org/8249 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/afs.h | 1 + src/afs/afs_daemons.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/afs/afs.h b/src/afs/afs.h index 6a24cc0bb..f3acdb79c 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -135,6 +135,7 @@ struct sysname_info { #ifdef AFS_DARWIN_ENV #define BOP_MOVE 5 /* ptr1 afs_uspc_param ptr2 sname ptr3 dname */ #endif +#define BOP_PARTIAL_STORE 6 /* parm1 is chunk to store */ #define B_DONTWAIT 1 /* On failure return; don't wait */ diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index 05e428720..7d875ed31 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -611,6 +611,43 @@ BStore(struct brequest *ab) } } +static void +BPartialStore(struct brequest *ab) +{ + struct vcache *tvc; + afs_int32 code; + struct vrequest treq; + int locked, shared_locked = 0; + + AFS_STATCNT(BStore); + if ((code = afs_InitReq(&treq, ab->cred))) + return; + code = 0; + tvc = ab->vc; + locked = tvc->lock.excl_locked? 1:0; + if (!locked) + ObtainWriteLock(&tvc->lock, 1209); + else if (!(tvc->lock.excl_locked & WRITE_LOCK)) { + shared_locked = 1; + ConvertSToRLock(&tvc->lock); + } + code = afs_StoreAllSegments(tvc, &treq, AFS_ASYNC); + if (!locked) + ReleaseWriteLock(&tvc->lock); + else if (shared_locked) + ConvertSToRLock(&tvc->lock); + /* now set final return code, and wakeup anyone waiting */ + if ((ab->flags & BUVALID) == 0) { + /* set final code, since treq doesn't go across processes */ + ab->code = afs_CheckCode(code, &treq, 43); + ab->flags |= BUVALID; + if (ab->flags & BUWAIT) { + ab->flags &= ~BUWAIT; + afs_osi_Wakeup(ab); + } + } +} + /* release a held request buffer */ void afs_BRelease(struct brequest *ab) @@ -1104,6 +1141,8 @@ afs_BackgroundDaemon(void) return 0; } #endif + else if (tb->opcode == BOP_PARTIAL_STORE) + BPartialStore(tb); else panic("background bop"); brequest_release(tb); -- 2.39.5