| File: | afs/afs_fetchstore.c |
| Location: | line 532, column 2 |
| Description: | Value stored to 'stored' is never read |
| 1 | /* |
| 2 | * Copyright 2000, International Business Machines Corporation and others. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This software has been released under the terms of the IBM Public |
| 6 | * License. For details, see the LICENSE file in the top-level source |
| 7 | * directory or online at http://www.openafs.org/dl/license10.html |
| 8 | */ |
| 9 | |
| 10 | #include <afsconfig.h> |
| 11 | #include "afs/param.h" |
| 12 | |
| 13 | #include "afs/sysincludes.h" /* Standard vendor system headers */ |
| 14 | #ifndef AFS_LINUX22_ENV |
| 15 | #include "rpc/types.h" |
| 16 | #endif |
| 17 | #ifdef AFS_ALPHA_ENV |
| 18 | #undef kmem_alloc |
| 19 | #undef kmem_free |
| 20 | #undef mem_alloc |
| 21 | #undef mem_free |
| 22 | #endif /* AFS_ALPHA_ENV */ |
| 23 | #include "afsincludes.h" /* Afs-based standard headers */ |
| 24 | #include "afs/afs_stats.h" /* statistics */ |
| 25 | #include "afs_prototypes.h" |
| 26 | |
| 27 | extern int cacheDiskType; |
| 28 | |
| 29 | #ifndef AFS_NOSTATS |
| 30 | void |
| 31 | FillStoreStats(int code, int idx, osi_timeval_t *xferStartTime, |
| 32 | afs_size_t bytesToXfer, afs_size_t bytesXferred) |
| 33 | { |
| 34 | struct afs_stats_xferData *xferP; |
| 35 | osi_timeval_t xferStopTime; |
| 36 | osi_timeval_t elapsedTime; |
| 37 | |
| 38 | xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[idx]); |
| 39 | osi_GetuTime(&xferStopTime)osi_GetTime(&xferStopTime); |
| 40 | (xferP->numXfers)++; |
| 41 | if (!code) { |
| 42 | (xferP->numSuccesses)++; |
| 43 | afs_stats_XferSumBytes[idx] += bytesXferred; |
| 44 | (xferP->sumBytes) += (afs_stats_XferSumBytes[idx] >> 10); |
| 45 | afs_stats_XferSumBytes[idx] &= 0x3FF; |
| 46 | if (bytesXferred < xferP->minBytes) |
| 47 | xferP->minBytes = bytesXferred; |
| 48 | if (bytesXferred > xferP->maxBytes) |
| 49 | xferP->maxBytes = bytesXferred; |
| 50 | |
| 51 | /* |
| 52 | * Tally the size of the object. Note: we tally the actual size, |
| 53 | * NOT the number of bytes that made it out over the wire. |
| 54 | */ |
| 55 | if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0128) (xferP->count[0])++; |
| 56 | else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET11024) (xferP->count[1])++; |
| 57 | else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET28192) (xferP->count[2])++; |
| 58 | else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET316384) (xferP->count[3])++; |
| 59 | else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET432768) (xferP->count[4])++; |
| 60 | else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5131072) (xferP->count[5])++; |
| 61 | else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6524288) (xferP->count[6])++; |
| 62 | else if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET71048576) (xferP->count[7])++; |
| 63 | else |
| 64 | (xferP->count[8])++; |
| 65 | |
| 66 | afs_stats_GetDiff(elapsedTime, (*xferStartTime), xferStopTime){ if (xferStopTime.tv_usec < (*xferStartTime).tv_usec) { xferStopTime .tv_usec += 1000000; xferStopTime.tv_sec -= 1; } elapsedTime. tv_sec = xferStopTime.tv_sec - (*xferStartTime).tv_sec; elapsedTime .tv_usec = xferStopTime.tv_usec - (*xferStartTime).tv_usec; }; |
| 67 | afs_stats_AddTo((xferP->sumTime), elapsedTime){ (xferP->sumTime).tv_sec += elapsedTime.tv_sec; (xferP-> sumTime).tv_usec += elapsedTime.tv_usec; if ((xferP->sumTime ).tv_usec > 1000000) { (xferP->sumTime).tv_usec -= 1000000 ; (xferP->sumTime).tv_sec++; } }; |
| 68 | afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime){ if(elapsedTime.tv_sec > 0 ) { (xferP->sqrTime).tv_sec += elapsedTime.tv_sec * elapsedTime.tv_sec + 2 * elapsedTime .tv_sec * elapsedTime.tv_usec /1000000; (xferP->sqrTime).tv_usec += (2 * elapsedTime.tv_sec * elapsedTime.tv_usec) % 1000000 + (elapsedTime.tv_usec / 1000)*(elapsedTime.tv_usec / 1000) + 2 * (elapsedTime.tv_usec / 1000) * (elapsedTime.tv_usec % 1000 ) / 1000 + (((elapsedTime.tv_usec % 1000) > 707) ? 1 : 0); } else { (xferP->sqrTime).tv_usec += (elapsedTime.tv_usec / 1000)*(elapsedTime.tv_usec / 1000) + 2 * (elapsedTime.tv_usec / 1000) * (elapsedTime.tv_usec % 1000) / 1000 + (((elapsedTime .tv_usec % 1000) > 707) ? 1 : 0); } if ((xferP->sqrTime ).tv_usec > 1000000) { (xferP->sqrTime).tv_usec -= 1000000 ; (xferP->sqrTime).tv_sec++; } }; |
| 69 | if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))((elapsedTime.tv_sec < (xferP->minTime).tv_sec) ? 1 : ( elapsedTime.tv_sec > (xferP->minTime).tv_sec) ? 0 : (elapsedTime .tv_usec < (xferP->minTime).tv_usec) ? 1 : 0)) { |
| 70 | afs_stats_TimeAssign((xferP->minTime), elapsedTime){ (xferP->minTime).tv_sec = elapsedTime.tv_sec; (xferP-> minTime).tv_usec = elapsedTime.tv_usec; }; |
| 71 | } |
| 72 | if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))((elapsedTime.tv_sec > (xferP->maxTime).tv_sec) ? 1 : ( elapsedTime.tv_sec < (xferP->maxTime).tv_sec) ? 0 : (elapsedTime .tv_usec > (xferP->maxTime).tv_usec) ? 1 : 0)) { |
| 73 | afs_stats_TimeAssign((xferP->maxTime), elapsedTime){ (xferP->maxTime).tv_sec = elapsedTime.tv_sec; (xferP-> maxTime).tv_usec = elapsedTime.tv_usec; }; |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | #endif /* AFS_NOSTATS */ |
| 78 | |
| 79 | /* rock and operations for RX_FILESERVER */ |
| 80 | |
| 81 | |
| 82 | |
| 83 | afs_int32 |
| 84 | rxfs_storeUfsPrepare(void *r, afs_uint32 size, afs_uint32 *tlen) |
| 85 | { |
| 86 | *tlen = (size > AFS_LRALLOCSIZ4096 ? AFS_LRALLOCSIZ4096 : size); |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | afs_int32 |
| 91 | rxfs_storeMemPrepare(void *r, afs_uint32 size, afs_uint32 *tlen) |
| 92 | { |
| 93 | afs_int32 code; |
| 94 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *) r; |
| 95 | |
| 96 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 96);}while(0); } while(0); |
| 97 | code = rx_WritevAlloc(v->call, v->tiov, &v->tnio, RX_MAXIOVECS16, size); |
| 98 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 98);}while(0); afs_global_owner = pthread_self(); } while(0 ); |
| 99 | if (code <= 0) { |
| 100 | code = rx_Error(v->call)((v->call)->error); |
| 101 | if (!code) |
| 102 | code = -33; |
| 103 | } |
| 104 | else { |
| 105 | *tlen = code; |
| 106 | code = 0; |
| 107 | } |
| 108 | return code; |
| 109 | } |
| 110 | |
| 111 | afs_int32 |
| 112 | rxfs_storeUfsRead(void *r, struct osi_file *tfile, afs_uint32 offset, |
| 113 | afs_uint32 tlen, afs_uint32 *bytesread) |
| 114 | { |
| 115 | afs_int32 code; |
| 116 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r; |
| 117 | |
| 118 | *bytesread = 0; |
| 119 | code = afs_osi_Read(tfile, -1, v->tbuffer, tlen); |
| 120 | if (code < 0) |
| 121 | return EIO5; |
| 122 | *bytesread = code; |
| 123 | if (code == tlen) |
| 124 | return 0; |
| 125 | #if defined(KERNEL_HAVE_UERROR) |
| 126 | if (getuerror()get_user_struct()->u_error) |
| 127 | return EIO5; |
| 128 | #endif |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | afs_int32 |
| 133 | rxfs_storeMemRead(void *r, struct osi_file *tfile, afs_uint32 offset, |
| 134 | afs_uint32 tlen, afs_uint32 *bytesread) |
| 135 | { |
| 136 | afs_int32 code; |
| 137 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r; |
| 138 | struct memCacheEntry *mceP = (struct memCacheEntry *)tfile; |
| 139 | |
| 140 | *bytesread = 0; |
| 141 | code = afs_MemReadvBlk(mceP, offset, v->tiov, v->tnio, tlen); |
| 142 | if (code != tlen) |
| 143 | return -33; |
| 144 | *bytesread = code; |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | afs_int32 |
| 149 | rxfs_storeMemWrite(void *r, afs_uint32 l, afs_uint32 *byteswritten) |
| 150 | { |
| 151 | afs_int32 code; |
| 152 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r; |
| 153 | |
| 154 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 154);}while(0); } while(0); |
| 155 | code = rx_Writev(v->call, v->tiov, v->tnio, l)rx_WritevProc(v->call, v->tiov, v->tnio, l); |
| 156 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 156);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 157 | if (code != l) { |
| 158 | code = rx_Error(v->call)((v->call)->error); |
| 159 | return (code ? code : -33); |
| 160 | } |
| 161 | *byteswritten = code; |
| 162 | return 0; |
| 163 | } |
| 164 | |
| 165 | afs_int32 |
| 166 | rxfs_storeUfsWrite(void *r, afs_uint32 l, afs_uint32 *byteswritten) |
| 167 | { |
| 168 | afs_int32 code; |
| 169 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r; |
| 170 | |
| 171 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 171);}while(0); } while(0); |
| 172 | code = rx_Write(v->call, v->tbuffer, l)rx_WriteProc(v->call, v->tbuffer, l); |
| 173 | /* writing 0 bytes will |
| 174 | * push a short packet. Is that really what we want, just because the |
| 175 | * data didn't come back from the disk yet? Let's try it and see. */ |
| 176 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 176);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 177 | if (code != l) { |
| 178 | code = rx_Error(v->call)((v->call)->error); |
| 179 | return (code ? code : -33); |
| 180 | } |
| 181 | *byteswritten = code; |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | afs_int32 |
| 186 | rxfs_storePadd(void *rock, afs_uint32 size) |
| 187 | { |
| 188 | afs_int32 code = 0; |
| 189 | afs_uint32 tlen; |
| 190 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)rock; |
| 191 | |
| 192 | if (!v->tbuffer) |
| 193 | v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ4096); |
| 194 | memset(v->tbuffer, 0, AFS_LRALLOCSIZ4096); |
| 195 | |
| 196 | while (size) { |
| 197 | tlen = (size > AFS_LRALLOCSIZ4096 ? AFS_LRALLOCSIZ4096 : size); |
| 198 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 198);}while(0); } while(0); |
| 199 | code = rx_Write(v->call, v->tbuffer, tlen)rx_WriteProc(v->call, v->tbuffer, tlen); |
| 200 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 200);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 201 | |
| 202 | if (code != tlen) |
| 203 | return -33; /* XXX */ |
| 204 | size -= tlen; |
| 205 | } |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | afs_int32 |
| 210 | rxfs_storeStatus(void *rock) |
| 211 | { |
| 212 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)rock; |
| 213 | |
| 214 | if (rx_GetRemoteStatus(v->call)((v->call)->remoteStatus) & 1) |
| 215 | return 0; |
| 216 | return 1; |
| 217 | } |
| 218 | |
| 219 | afs_int32 |
| 220 | rxfs_storeClose(void *r, struct AFSFetchStatus *OutStatus, int *doProcessFS) |
| 221 | { |
| 222 | afs_int32 code; |
| 223 | struct AFSVolSync tsync; |
| 224 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)r; |
| 225 | |
| 226 | if (!v->call) |
| 227 | return -1; |
| 228 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 228);}while(0); } while(0); |
| 229 | #ifdef AFS_64BIT_CLIENT |
| 230 | if (!v->hasNo64bit) |
| 231 | code = EndRXAFS_StoreData64(v->call, OutStatus, &tsync); |
| 232 | else |
| 233 | #endif |
| 234 | code = EndRXAFS_StoreData(v->call, OutStatus, &tsync); |
| 235 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 235);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 236 | if (!code) |
| 237 | *doProcessFS = 1; /* Flag to run afs_ProcessFS() later on */ |
| 238 | |
| 239 | return code; |
| 240 | } |
| 241 | |
| 242 | afs_int32 |
| 243 | rxfs_storeDestroy(void **r, afs_int32 error) |
| 244 | { |
| 245 | afs_int32 code = error; |
| 246 | struct rxfs_storeVariables *v = (struct rxfs_storeVariables *)*r; |
| 247 | |
| 248 | *r = NULL((void *)0); |
| 249 | if (v->call) { |
| 250 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 250);}while(0); } while(0); |
| 251 | code = rx_EndCall(v->call, error); |
| 252 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 252);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 253 | if (!code && error) |
| 254 | code = error; |
| 255 | } |
| 256 | if (v->tbuffer) |
| 257 | osi_FreeLargeSpace(v->tbuffer); |
| 258 | if (v->tiov) |
| 259 | osi_FreeSmallSpace(v->tiov); |
| 260 | osi_FreeSmallSpace(v); |
| 261 | return code; |
| 262 | } |
| 263 | |
| 264 | afs_int32 |
| 265 | afs_GenericStoreProc(struct storeOps *ops, void *rock, |
| 266 | struct dcache *tdc, int *shouldwake, |
| 267 | afs_size_t *bytesXferred) |
| 268 | { |
| 269 | struct rxfs_storeVariables *svar = rock; |
| 270 | afs_uint32 tlen, bytesread, byteswritten; |
| 271 | afs_int32 code = 0; |
| 272 | int offset = 0; |
| 273 | afs_size_t size; |
| 274 | struct osi_file *tfile; |
| 275 | |
| 276 | size = tdc->f.chunkBytes; |
| 277 | |
| 278 | tfile = afs_CFileOpen(&tdc->f.inode)(void *)(*(afs_cacheType->open))(&tdc->f.usr_inode); |
| 279 | |
| 280 | while ( size > 0 ) { |
| 281 | code = (*ops->prepare)(rock, size, &tlen); |
| 282 | if ( code ) |
| 283 | break; |
| 284 | |
| 285 | code = (*ops->read)(rock, tfile, offset, tlen, &bytesread); |
| 286 | if (code) |
| 287 | break; |
| 288 | |
| 289 | tlen = bytesread; |
| 290 | code = (*ops->write)(rock, tlen, &byteswritten); |
| 291 | if (code) |
| 292 | break; |
| 293 | #ifndef AFS_NOSTATS |
| 294 | *bytesXferred += byteswritten; |
| 295 | #endif /* AFS_NOSTATS */ |
| 296 | |
| 297 | offset += tlen; |
| 298 | size -= tlen; |
| 299 | /* |
| 300 | * if file has been locked on server, can allow |
| 301 | * store to continue |
| 302 | */ |
| 303 | if (shouldwake && *shouldwake && ((*ops->status)(rock) == 0)) { |
| 304 | *shouldwake = 0; /* only do this once */ |
| 305 | afs_wakeup(svar->vcache); |
| 306 | } |
| 307 | } |
| 308 | afs_CFileClose(tfile)(*(afs_cacheType->close))(tfile); |
| 309 | |
| 310 | return code; |
| 311 | } |
| 312 | |
| 313 | static |
| 314 | struct storeOps rxfs_storeUfsOps = { |
| 315 | #ifndef HAVE_STRUCT_LABEL_SUPPORT1 |
| 316 | rxfs_storeUfsPrepare, |
| 317 | rxfs_storeUfsRead, |
| 318 | rxfs_storeUfsWrite, |
| 319 | rxfs_storeStatus, |
| 320 | rxfs_storePadd, |
| 321 | rxfs_storeClose, |
| 322 | rxfs_storeDestroy, |
| 323 | afs_GenericStoreProc |
| 324 | #else |
| 325 | .prepare = rxfs_storeUfsPrepare, |
| 326 | .read = rxfs_storeUfsRead, |
| 327 | .write = rxfs_storeUfsWrite, |
| 328 | .status = rxfs_storeStatus, |
| 329 | .padd = rxfs_storePadd, |
| 330 | .close = rxfs_storeClose, |
| 331 | .destroy = rxfs_storeDestroy, |
| 332 | #ifdef AFS_LINUX26_ENV |
| 333 | .storeproc = afs_linux_storeproc |
| 334 | #else |
| 335 | .storeproc = afs_GenericStoreProc |
| 336 | #endif |
| 337 | #endif |
| 338 | }; |
| 339 | |
| 340 | static |
| 341 | struct storeOps rxfs_storeMemOps = { |
| 342 | #ifndef HAVE_STRUCT_LABEL_SUPPORT1 |
| 343 | rxfs_storeMemPrepare, |
| 344 | rxfs_storeMemRead, |
| 345 | rxfs_storeMemWrite, |
| 346 | rxfs_storeStatus, |
| 347 | rxfs_storePadd, |
| 348 | rxfs_storeClose, |
| 349 | rxfs_storeDestroy, |
| 350 | afs_GenericStoreProc |
| 351 | #else |
| 352 | .prepare = rxfs_storeMemPrepare, |
| 353 | .read = rxfs_storeMemRead, |
| 354 | .write = rxfs_storeMemWrite, |
| 355 | .status = rxfs_storeStatus, |
| 356 | .padd = rxfs_storePadd, |
| 357 | .close = rxfs_storeClose, |
| 358 | .destroy = rxfs_storeDestroy, |
| 359 | .storeproc = afs_GenericStoreProc |
| 360 | #endif |
| 361 | }; |
| 362 | |
| 363 | afs_int32 |
| 364 | rxfs_storeInit(struct vcache *avc, struct afs_conn *tc, |
| 365 | struct rx_connection *rxconn, afs_size_t base, |
| 366 | afs_size_t bytes, afs_size_t length, |
| 367 | int sync, struct storeOps **ops, void **rock) |
| 368 | { |
| 369 | afs_int32 code; |
| 370 | struct rxfs_storeVariables *v; |
| 371 | |
| 372 | if ( !tc ) |
| 373 | return -1; |
| 374 | |
| 375 | v = (struct rxfs_storeVariables *) osi_AllocSmallSpace(sizeof(struct rxfs_storeVariables)); |
| 376 | if (!v) |
| 377 | osi_Panic("rxfs_storeInit: osi_AllocSmallSpace returned NULL\n"); |
| 378 | memset(v, 0, sizeof(struct rxfs_storeVariables)); |
| 379 | |
| 380 | v->InStatus.ClientModTime = avc->f.m.Date; |
| 381 | v->InStatus.Mask = AFS_SETMODTIME1; |
| 382 | v->vcache = avc; |
| 383 | if (sync & AFS_SYNC1) |
| 384 | v->InStatus.Mask |= AFS_FSYNC1024; |
| 385 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 385);}while(0); } while(0); |
| 386 | v->call = rx_NewCall(rxconn); |
| 387 | if (v->call) { |
| 388 | #ifdef AFS_64BIT_CLIENT |
| 389 | if (!afs_serverHasNo64Bit(tc)(((struct sa_conn_vector*)(tc)->parent)->srvr->server ->flags & 0x200)) |
| 390 | code = StartRXAFS_StoreData64( |
| 391 | v->call, (struct AFSFid*)&avc->f.fidusr_fid.Fid, |
| 392 | &v->InStatus, base, bytes, length); |
| 393 | else |
| 394 | if (length > 0xFFFFFFFF) |
| 395 | code = EFBIG27; |
| 396 | else { |
| 397 | afs_int32 t1 = base, t2 = bytes, t3 = length; |
| 398 | code = StartRXAFS_StoreData(v->call, |
| 399 | (struct AFSFid *) &avc->f.fidusr_fid.Fid, |
| 400 | &v->InStatus, t1, t2, t3); |
| 401 | } |
| 402 | #else /* AFS_64BIT_CLIENT */ |
| 403 | code = StartRXAFS_StoreData(v->call, (struct AFSFid *)&avc->f.fidusr_fid.Fid, |
| 404 | &v->InStatus, base, bytes, length); |
| 405 | #endif /* AFS_64BIT_CLIENT */ |
| 406 | } else |
| 407 | code = -1; |
| 408 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 408);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 409 | if (code) { |
| 410 | osi_FreeSmallSpace(v); |
| 411 | return code; |
| 412 | } |
| 413 | if (cacheDiskType == AFS_FCACHE_TYPE_UFS0x0) { |
| 414 | v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ4096); |
| 415 | if (!v->tbuffer) |
| 416 | osi_Panic |
| 417 | ("rxfs_storeInit: osi_AllocLargeSpace for iovecs returned NULL\n"); |
| 418 | *ops = (struct storeOps *) &rxfs_storeUfsOps; |
| 419 | } else { |
| 420 | v->tiov = osi_AllocSmallSpace(sizeof(struct iovec) * RX_MAXIOVECS16); |
| 421 | if (!v->tiov) |
| 422 | osi_Panic |
| 423 | ("rxfs_storeInit: osi_AllocSmallSpace for iovecs returned NULL\n"); |
| 424 | *ops = (struct storeOps *) &rxfs_storeMemOps; |
| 425 | #ifdef notdef |
| 426 | /* do this at a higher level now -- it's a parameter */ |
| 427 | /* for now, only do 'continue from close' code if file fits in one |
| 428 | * chunk. Could clearly do better: if only one modified chunk |
| 429 | * then can still do this. can do this on *last* modified chunk */ |
| 430 | length = avc->f.m.Length - 1; /* byte position of last byte we'll store */ |
| 431 | if (shouldWake) { |
| 432 | if (AFS_CHUNK(length)((length < afs_FirstCSize) ? 0 : (((length - afs_FirstCSize ) >> afs_LogChunk) + 1)) != 0) |
| 433 | *shouldWake = 0; |
| 434 | else |
| 435 | *shouldWake = 1; |
| 436 | } |
| 437 | #endif /* notdef */ |
| 438 | } |
| 439 | |
| 440 | *rock = (void *)v; |
| 441 | return 0; |
| 442 | } |
| 443 | unsigned int storeallmissing = 0; |
| 444 | /*! |
| 445 | * Called for each chunk upon store. |
| 446 | * |
| 447 | * \param avc Ptr to the vcache entry of the file being stored. |
| 448 | * \param dclist pointer to the list of dcaches |
| 449 | * \param bytes total number of bytes for the current operation |
| 450 | * \param anewDV Ptr to the dataversion after store |
| 451 | * \param doProcessFS pointer to the "do process FetchStatus" flag |
| 452 | * \param OutStatus pointer to the FetchStatus as returned by the fileserver |
| 453 | * \param nchunks number of dcaches to consider |
| 454 | * \param nomore copy of the "no more data" flag |
| 455 | * \param ops pointer to the block of storeOps to be used for this operation |
| 456 | * \param rock pointer to the opaque protocol-specific data of this operation |
| 457 | */ |
| 458 | afs_int32 |
| 459 | afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist, |
| 460 | afs_size_t bytes, afs_hyper_t *anewDV, int *doProcessFS, |
| 461 | struct AFSFetchStatus *OutStatus, afs_uint32 nchunks, |
| 462 | int nomore, struct storeOps *ops, void *rock) |
| 463 | { |
| 464 | int *shouldwake = NULL((void *)0); |
| 465 | unsigned int i; |
| 466 | afs_int32 code = 0; |
| 467 | afs_size_t bytesXferred; |
| 468 | |
| 469 | #ifndef AFS_NOSTATS |
| 470 | osi_timeval_t xferStartTime; /*FS xfer start time */ |
| 471 | afs_size_t bytesToXfer = 10000; /* # bytes to xfer */ |
| 472 | #endif /* AFS_NOSTATS */ |
| 473 | XSTATS_DECLSstruct afs_stats_opTimingData *opP = ((void *)0); osi_timeval_t opStartTime = { 0, 0}, opStopTime, elapsedTime; |
| 474 | |
| 475 | for (i = 0; i < nchunks && !code; i++) { |
| 476 | int stored = 0; |
| 477 | struct dcache *tdc = dclist[i]; |
| 478 | afs_int32 size = tdc->f.chunkBytes; |
| 479 | if (!tdc) { |
| 480 | afs_warn("afs: missing dcache!\n"); |
| 481 | storeallmissing++; |
| 482 | continue; /* panic? */ |
| 483 | } |
| 484 | afs_Trace4(afs_iclSetp, CM_TRACE_STOREALL2, ICL_TYPE_POINTER, avc,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087878L), (1<<24)+((2) <<18)+((7)<<12)+((7)<<6)+(7), (long)(avc), ( long)(tdc->f.chunk), (long)(tdc->index), (long)(afs_inode2trace (&tdc->f.usr_inode))) : 0) |
| 485 | ICL_TYPE_INT32, tdc->f.chunk, ICL_TYPE_INT32, tdc->index,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087878L), (1<<24)+((2) <<18)+((7)<<12)+((7)<<6)+(7), (long)(avc), ( long)(tdc->f.chunk), (long)(tdc->index), (long)(afs_inode2trace (&tdc->f.usr_inode))) : 0) |
| 486 | ICL_TYPE_INT32, afs_inode2trace(&tdc->f.inode))(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087878L), (1<<24)+((2) <<18)+((7)<<12)+((7)<<6)+(7), (long)(avc), ( long)(tdc->f.chunk), (long)(tdc->index), (long)(afs_inode2trace (&tdc->f.usr_inode))) : 0); |
| 487 | shouldwake = 0; |
| 488 | if (nomore) { |
| 489 | if (avc->asynchrony == -1) { |
| 490 | if (afs_defaultAsynchrony > (bytes - stored)) |
| 491 | shouldwake = &nomore; |
| 492 | } |
| 493 | else if ((afs_uint32) avc->asynchrony >= (bytes - stored)) |
| 494 | shouldwake = &nomore; |
| 495 | } |
| 496 | |
| 497 | afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087757L), (1<<24)+((2) <<18)+((5)<<12)+((8)<<6)+(7), (long)(avc), ( long)(&(avc->f.usr_fid)), (long)((avc->f.m.Length)) , (long)(size)) : 0) |
| 498 | ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087757L), (1<<24)+((2) <<18)+((5)<<12)+((8)<<6)+(7), (long)(avc), ( long)(&(avc->f.usr_fid)), (long)((avc->f.m.Length)) , (long)(size)) : 0) |
| 499 | ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, size)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087757L), (1<<24)+((2) <<18)+((5)<<12)+((8)<<6)+(7), (long)(avc), ( long)(&(avc->f.usr_fid)), (long)((avc->f.m.Length)) , (long)(size)) : 0); |
| 500 | |
| 501 | AFS_STATCNT(CacheStoreProc)((afs_cmstats.callInfo.C_CacheStoreProc)++); |
| 502 | |
| 503 | XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREDATA)opP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[3]); osi_GetTime (&opStartTime);; |
| 504 | avc->f.truncPos = AFS_NOTRUNC0x7fffffff; |
| 505 | #ifndef AFS_NOSTATS |
| 506 | /* |
| 507 | * In this case, size is *always* the amount of data we'll be trying |
| 508 | * to ship here. |
| 509 | */ |
| 510 | bytesToXfer = size; |
| 511 | |
| 512 | osi_GetuTime(&xferStartTime)osi_GetTime(&xferStartTime); |
| 513 | #endif /* AFS_NOSTATS */ |
| 514 | bytesXferred = 0; |
| 515 | |
| 516 | code = (*ops->storeproc)(ops, rock, tdc, shouldwake, |
| 517 | &bytesXferred); |
| 518 | |
| 519 | afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087757L), (1<<24)+((2) <<18)+((5)<<12)+((8)<<6)+(7), (long)(avc), ( long)(&(avc->f.usr_fid)), (long)((avc->f.m.Length)) , (long)(size)) : 0) |
| 520 | ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087757L), (1<<24)+((2) <<18)+((5)<<12)+((8)<<6)+(7), (long)(avc), ( long)(&(avc->f.usr_fid)), (long)((avc->f.m.Length)) , (long)(size)) : 0) |
| 521 | ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, size)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087757L), (1<<24)+((2) <<18)+((5)<<12)+((8)<<6)+(7), (long)(avc), ( long)(&(avc->f.usr_fid)), (long)((avc->f.m.Length)) , (long)(size)) : 0); |
| 522 | |
| 523 | #ifndef AFS_NOSTATS |
| 524 | FillStoreStats(code, AFS_STATS_FS_XFERIDX_STOREDATA1, |
| 525 | &xferStartTime, bytesToXfer, bytesXferred); |
| 526 | #endif /* AFS_NOSTATS */ |
| 527 | |
| 528 | if ((tdc->f.chunkBytes < afs_OtherCSize) |
| 529 | && (i < (nchunks - 1)) && code == 0) { |
| 530 | code = (*ops->padd)(rock, afs_OtherCSize - tdc->f.chunkBytes); |
| 531 | } |
| 532 | stored += tdc->f.chunkBytes; |
Value stored to 'stored' is never read | |
| 533 | /* ideally, I'd like to unlock the dcache and turn |
| 534 | * off the writing bit here, but that would |
| 535 | * require being able to retry StoreAllSegments in |
| 536 | * the event of a failure. It only really matters |
| 537 | * if user can't read from a 'locked' dcache or |
| 538 | * one which has the writing bit turned on. */ |
| 539 | } |
| 540 | |
| 541 | if (!code) { |
| 542 | code = (*ops->close)(rock, OutStatus, doProcessFS); |
| 543 | if (*doProcessFS) { |
| 544 | hadd32(*anewDV, 1)((void)((((*anewDV).low ^ (int)(1)) & 0x80000000) ? ((((( *anewDV).low + (int)(1)) & 0x80000000) == 0) && ( *anewDV).high++) : (((*anewDV).low & (int)(1) & 0x80000000 ) && (*anewDV).high++)), (*anewDV).low += (int)(1)); |
| 545 | } |
| 546 | XSTATS_END_TIMEosi_GetTime(&opStopTime); (opP->numOps)++; if (!code) { (opP->numSuccesses)++; { if (opStopTime.tv_usec < opStartTime .tv_usec) { opStopTime.tv_usec += 1000000; opStopTime.tv_sec -= 1; } elapsedTime.tv_sec = opStopTime.tv_sec - opStartTime.tv_sec ; elapsedTime.tv_usec = opStopTime.tv_usec - opStartTime.tv_usec ; }; { (opP->sumTime).tv_sec += elapsedTime.tv_sec; (opP-> sumTime).tv_usec += elapsedTime.tv_usec; if ((opP->sumTime ).tv_usec > 1000000) { (opP->sumTime).tv_usec -= 1000000 ; (opP->sumTime).tv_sec++; } }; { if(elapsedTime.tv_sec > 0 ) { (opP->sqrTime).tv_sec += elapsedTime.tv_sec * elapsedTime .tv_sec + 2 * elapsedTime.tv_sec * elapsedTime.tv_usec /1000000 ; (opP->sqrTime).tv_usec += (2 * elapsedTime.tv_sec * elapsedTime .tv_usec) % 1000000 + (elapsedTime.tv_usec / 1000)*(elapsedTime .tv_usec / 1000) + 2 * (elapsedTime.tv_usec / 1000) * (elapsedTime .tv_usec % 1000) / 1000 + (((elapsedTime.tv_usec % 1000) > 707) ? 1 : 0); } else { (opP->sqrTime).tv_usec += (elapsedTime .tv_usec / 1000)*(elapsedTime.tv_usec / 1000) + 2 * (elapsedTime .tv_usec / 1000) * (elapsedTime.tv_usec % 1000) / 1000 + (((elapsedTime .tv_usec % 1000) > 707) ? 1 : 0); } if ((opP->sqrTime). tv_usec > 1000000) { (opP->sqrTime).tv_usec -= 1000000; (opP->sqrTime).tv_sec++; } }; if (((elapsedTime.tv_sec < (opP->minTime).tv_sec) ? 1 : (elapsedTime.tv_sec > (opP ->minTime).tv_sec) ? 0 : (elapsedTime.tv_usec < (opP-> minTime).tv_usec) ? 1 : 0)) { { (opP->minTime).tv_sec = elapsedTime .tv_sec; (opP->minTime).tv_usec = elapsedTime.tv_usec; }; } if (((elapsedTime.tv_sec > (opP->maxTime).tv_sec) ? 1 : (elapsedTime.tv_sec < (opP->maxTime).tv_sec) ? 0 : (elapsedTime .tv_usec > (opP->maxTime).tv_usec) ? 1 : 0)) { { (opP-> maxTime).tv_sec = elapsedTime.tv_sec; (opP->maxTime).tv_usec = elapsedTime.tv_usec; }; } }; |
| 547 | } |
| 548 | if (ops) |
| 549 | code = (*ops->destroy)(&rock, code); |
| 550 | return code; |
| 551 | } |
| 552 | |
| 553 | #define lmin(a,b)(((a) < (b)) ? (a) : (b)) (((a) < (b)) ? (a) : (b)) |
| 554 | /*! |
| 555 | * Called upon store. |
| 556 | * |
| 557 | * \param dclist pointer to the list of dcaches |
| 558 | * \param avc Ptr to the vcache entry. |
| 559 | * \param areq Ptr to the request structure |
| 560 | * \param sync sync flag |
| 561 | * \param minj the chunk offset for this call |
| 562 | * \param high index of last dcache to store |
| 563 | * \param moredata the moredata flag |
| 564 | * \param anewDV Ptr to the dataversion after store |
| 565 | * \param amaxStoredLength Ptr to the amount of that is actually stored |
| 566 | * |
| 567 | * \note Environment: Nothing interesting. |
| 568 | */ |
| 569 | int |
| 570 | afs_CacheStoreVCache(struct dcache **dcList, struct vcache *avc, |
| 571 | struct vrequest *areq, int sync, unsigned int minj, |
| 572 | unsigned int high, unsigned int moredata, |
| 573 | afs_hyper_t *anewDV, afs_size_t *amaxStoredLength) |
| 574 | { |
| 575 | afs_int32 code = 0; |
| 576 | struct storeOps *ops; |
| 577 | void * rock = NULL((void *)0); |
| 578 | unsigned int i, j; |
| 579 | |
| 580 | struct AFSFetchStatus OutStatus; |
| 581 | int doProcessFS = 0; |
| 582 | afs_size_t base, bytes, length; |
| 583 | int nomore; |
| 584 | unsigned int first = 0; |
| 585 | struct afs_conn *tc; |
| 586 | struct rx_connection *rxconn; |
| 587 | |
| 588 | for (bytes = 0, j = 0; !code && j <= high; j++) { |
| 589 | if (dcList[j]) { |
| 590 | ObtainSharedLock(&(dcList[j]->lock), 629)do { ; if (!(&(dcList[j]->lock))->excl_locked) (& (dcList[j]->lock)) -> excl_locked = 4; else Afs_Lock_Obtain (&(dcList[j]->lock), 4); (&(dcList[j]->lock))-> pid_writer = (get_user_struct()->u_procp->p_pid ); (& (dcList[j]->lock))->src_indicator = 629; } while (0); |
| 591 | if (!bytes) |
| 592 | first = j; |
| 593 | bytes += dcList[j]->f.chunkBytes; |
| 594 | if ((dcList[j]->f.chunkBytes < afs_OtherCSize) |
| 595 | && (dcList[j]->f.chunk - minj < high) |
| 596 | && dcList[j + 1]) { |
| 597 | int sbytes = afs_OtherCSize - dcList[j]->f.chunkBytes; |
| 598 | bytes += sbytes; |
| 599 | } |
| 600 | } |
| 601 | if (bytes && (j == high || !dcList[j + 1])) { |
| 602 | afs_uint32 nchunks; |
| 603 | struct dcache **dclist = &dcList[first]; |
| 604 | /* base = AFS_CHUNKTOBASE(dcList[first]->f.chunk); */ |
| 605 | base = AFS_CHUNKTOBASE(first + minj)((first + minj == 0) ? 0 : ((afs_size_t) afs_FirstCSize + ((afs_size_t ) (first + minj - 1) << afs_LogChunk))); |
| 606 | /* |
| 607 | * |
| 608 | * take a list of dcache structs and send them all off to the server |
| 609 | * the list must be in order, and the chunks contiguous. |
| 610 | * Note - there is no locking done by this code currently. For |
| 611 | * safety's sake, xdcache could be locked over the entire call. |
| 612 | * However, that pretty well ties up all the threads. Meantime, all |
| 613 | * the chunks _MUST_ have their refcounts bumped. |
| 614 | * The writes done before a store back will clear setuid-ness |
| 615 | * in cache file. |
| 616 | * We can permit CacheStoreProc to wake up the user process IFF we |
| 617 | * are doing the last RPC for this close, ie, storing back the last |
| 618 | * set of contiguous chunks of a file. |
| 619 | */ |
| 620 | |
| 621 | nchunks = 1 + j - first; |
| 622 | nomore = !(moredata || (j != high)); |
| 623 | length = lmin(avc->f.m.Length, avc->f.truncPos)(((avc->f.m.Length) < (avc->f.truncPos)) ? (avc-> f.m.Length) : (avc->f.truncPos)); |
| 624 | afs_Trace4(afs_iclSetp, CM_TRACE_STOREDATA64,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087881L), (1<<24)+((5) <<18)+((8)<<12)+((8)<<6)+(8), (long)(&avc ->f.usr_fid.Fid), (long)((base)), (long)((bytes)), (long)( (length))) : 0) |
| 625 | ICL_TYPE_FID, &avc->f.fid.Fid, ICL_TYPE_OFFSET,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087881L), (1<<24)+((5) <<18)+((8)<<12)+((8)<<6)+(8), (long)(&avc ->f.usr_fid.Fid), (long)((base)), (long)((bytes)), (long)( (length))) : 0) |
| 626 | ICL_HANDLE_OFFSET(base), ICL_TYPE_OFFSET,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087881L), (1<<24)+((5) <<18)+((8)<<12)+((8)<<6)+(8), (long)(&avc ->f.usr_fid.Fid), (long)((base)), (long)((bytes)), (long)( (length))) : 0) |
| 627 | ICL_HANDLE_OFFSET(bytes), ICL_TYPE_OFFSET,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087881L), (1<<24)+((5) <<18)+((8)<<12)+((8)<<6)+(8), (long)(&avc ->f.usr_fid.Fid), (long)((base)), (long)((bytes)), (long)( (length))) : 0) |
| 628 | ICL_HANDLE_OFFSET(length))(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087881L), (1<<24)+((5) <<18)+((8)<<12)+((8)<<6)+(8), (long)(&avc ->f.usr_fid.Fid), (long)((base)), (long)((bytes)), (long)( (length))) : 0); |
| 629 | |
| 630 | do { |
| 631 | tc = afs_Conn(&avc->f.fidusr_fid, areq, 0, &rxconn); |
| 632 | |
| 633 | #ifdef AFS_64BIT_CLIENT |
| 634 | restart: |
| 635 | #endif |
| 636 | code = rxfs_storeInit(avc, tc, rxconn, base, bytes, length, |
| 637 | sync, &ops, &rock); |
| 638 | if ( !code ) { |
| 639 | code = afs_CacheStoreDCaches(avc, dclist, bytes, anewDV, |
| 640 | &doProcessFS, &OutStatus, |
| 641 | nchunks, nomore, ops, rock); |
| 642 | } |
| 643 | |
| 644 | #ifdef AFS_64BIT_CLIENT |
| 645 | if (code == RXGEN_OPCODE-455 && !afs_serverHasNo64Bit(tc)(((struct sa_conn_vector*)(tc)->parent)->srvr->server ->flags & 0x200)) { |
| 646 | afs_serverSetNo64Bit(tc)(((struct sa_conn_vector*)(tc)->parent)->srvr->server ->flags |= 0x200); |
| 647 | goto restart; |
| 648 | } |
| 649 | #endif /* AFS_64BIT_CLIENT */ |
| 650 | } while (afs_Analyze |
| 651 | (tc, rxconn, code, &avc->f.fidusr_fid, areq, |
| 652 | AFS_STATS_FS_RPCIDX_STOREDATA3, SHARED_LOCK4, |
| 653 | NULL((void *)0))); |
| 654 | |
| 655 | /* put back all remaining locked dcache entries */ |
| 656 | for (i = 0; i < nchunks; i++) { |
| 657 | struct dcache *tdc = dclist[i]; |
| 658 | if (!code) { |
| 659 | if (afs_indexFlags[tdc->index] & IFDataMod4) { |
| 660 | /* |
| 661 | * LOCKXXX -- should hold afs_xdcache(W) when |
| 662 | * modifying afs_indexFlags. |
| 663 | */ |
| 664 | afs_indexFlags[tdc->index] &= ~IFDataMod4; |
| 665 | afs_stats_cmperf.cacheCurrDirtyChunks--; |
| 666 | afs_indexFlags[tdc->index] &= ~IFDirtyPages16; |
| 667 | if (sync & AFS_VMSYNC_INVAL2) { |
| 668 | /* since we have invalidated all the pages of this |
| 669 | ** vnode by calling osi_VM_TryToSmush, we can |
| 670 | ** safely mark this dcache entry as not having |
| 671 | ** any pages. This vnode now becomes eligible for |
| 672 | ** reclamation by getDownD. |
| 673 | */ |
| 674 | afs_indexFlags[tdc->index] &= ~IFAnyPages32; |
| 675 | } |
| 676 | } |
| 677 | } |
| 678 | UpgradeSToWLock(&tdc->lock, 628)do { ; if (!(&tdc->lock)->readers_reading) (&tdc ->lock)->excl_locked = 2; else Afs_Lock_Obtain(&tdc ->lock, 6); (&tdc->lock)->pid_writer = (get_user_struct ()->u_procp->p_pid ); (&tdc->lock)->src_indicator = 628; } while (0); |
| 679 | tdc->f.states &= ~DWriting8; /* correct? */ |
| 680 | tdc->dflags |= DFEntryMod0x02; |
| 681 | ReleaseWriteLock(&tdc->lock)do { ; (&tdc->lock)->excl_locked &= ~2; if ((& tdc->lock)->wait_states) Afs_Lock_ReleaseR(&tdc-> lock); (&tdc->lock)->pid_writer=0; } while (0); |
| 682 | afs_PutDCache(tdc); |
| 683 | /* Mark the entry as released */ |
| 684 | dclist[i] = NULL((void *)0); |
| 685 | } |
| 686 | |
| 687 | if (doProcessFS) { |
| 688 | /* Now copy out return params */ |
| 689 | UpgradeSToWLock(&avc->lock, 28)do { ; if (!(&avc->lock)->readers_reading) (&avc ->lock)->excl_locked = 2; else Afs_Lock_Obtain(&avc ->lock, 6); (&avc->lock)->pid_writer = (get_user_struct ()->u_procp->p_pid ); (&avc->lock)->src_indicator = 28; } while (0); /* keep out others for a while */ |
| 690 | afs_ProcessFS(avc, &OutStatus, areq); |
| 691 | /* Keep last (max) size of file on server to see if |
| 692 | * we need to call afs_StoreMini to extend the file. |
| 693 | */ |
| 694 | if (!moredata) |
| 695 | *amaxStoredLength = OutStatus.Length; |
| 696 | ConvertWToSLock(&avc->lock)do { ; (&avc->lock)->excl_locked = 4; if((&avc-> lock)->wait_states) Afs_Lock_ReleaseR(&avc->lock); } while (0); |
| 697 | doProcessFS = 0; |
| 698 | } |
| 699 | |
| 700 | if (code) { |
| 701 | for (j++; j <= high; j++) { |
| 702 | if (dcList[j]) { |
| 703 | ReleaseSharedLock(&(dcList[j]->lock))do { ; (&(dcList[j]->lock))->excl_locked &= ~(4 | 2); if ((&(dcList[j]->lock))->wait_states) Afs_Lock_ReleaseR (&(dcList[j]->lock)); (&(dcList[j]->lock))-> pid_writer=0; } while (0); |
| 704 | afs_PutDCache(dcList[j]); |
| 705 | /* Releasing entry */ |
| 706 | dcList[j] = NULL((void *)0); |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | afs_Trace2(afs_iclSetp, CM_TRACE_STOREALLDCDONE,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event2(afs_iclSetp, (701087841L), (1<<24)+((2) <<18)+((7)<<12), (long)(avc), (long)(code)) : 0) |
| 712 | ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event2(afs_iclSetp, (701087841L), (1<<24)+((2) <<18)+((7)<<12), (long)(avc), (long)(code)) : 0); |
| 713 | bytes = 0; |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | return code; |
| 718 | } |
| 719 | |
| 720 | /* rock and operations for RX_FILESERVER */ |
| 721 | |
| 722 | struct rxfs_fetchVariables { |
| 723 | struct rx_call *call; |
| 724 | char *tbuffer; |
| 725 | struct iovec *iov; |
| 726 | afs_int32 nio; |
| 727 | afs_int32 hasNo64bit; |
| 728 | afs_int32 iovno; |
| 729 | afs_int32 iovmax; |
| 730 | }; |
| 731 | |
| 732 | afs_int32 |
| 733 | rxfs_fetchUfsRead(void *r, afs_uint32 size, afs_uint32 *bytesread) |
| 734 | { |
| 735 | afs_int32 code; |
| 736 | afs_uint32 tlen; |
| 737 | struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r; |
| 738 | |
| 739 | *bytesread = 0; |
| 740 | tlen = (size > AFS_LRALLOCSIZ4096 ? AFS_LRALLOCSIZ4096 : size); |
| 741 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 741);}while(0); } while(0); |
| 742 | code = rx_Read(v->call, v->tbuffer, tlen)rx_ReadProc(v->call, v->tbuffer, tlen); |
| 743 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 743);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 744 | if (code <= 0) |
| 745 | return -34; |
| 746 | *bytesread = code; |
| 747 | return 0; |
| 748 | } |
| 749 | |
| 750 | afs_int32 |
| 751 | rxfs_fetchMemRead(void *r, afs_uint32 tlen, afs_uint32 *bytesread) |
| 752 | { |
| 753 | afs_int32 code; |
| 754 | struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r; |
| 755 | |
| 756 | *bytesread = 0; |
| 757 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 757);}while(0); } while(0); |
| 758 | code = rx_Readv(v->call, v->iov, &v->nio, RX_MAXIOVECS, tlen)rx_ReadvProc(v->call, v->iov, &v->nio, 16, tlen); |
| 759 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 759);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 760 | if (code <= 0) |
| 761 | return -34; |
| 762 | *bytesread = code; |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | |
| 767 | afs_int32 |
| 768 | rxfs_fetchMemWrite(void *r, struct osi_file *fP, afs_uint32 offset, |
| 769 | afs_uint32 tlen, afs_uint32 *byteswritten) |
| 770 | { |
| 771 | afs_int32 code; |
| 772 | struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r; |
| 773 | struct memCacheEntry *mceP = (struct memCacheEntry *)fP; |
| 774 | |
| 775 | code = afs_MemWritevBlk(mceP, offset, v->iov, v->nio, tlen); |
| 776 | if (code != tlen) { |
| 777 | return EIO5; |
| 778 | } |
| 779 | *byteswritten = code; |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | afs_int32 |
| 784 | rxfs_fetchUfsWrite(void *r, struct osi_file *fP, afs_uint32 offset, |
| 785 | afs_uint32 tlen, afs_uint32 *byteswritten) |
| 786 | { |
| 787 | afs_int32 code; |
| 788 | struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r; |
| 789 | |
| 790 | code = afs_osi_Write(fP, -1, v->tbuffer, tlen); |
| 791 | if (code != tlen) { |
| 792 | return EIO5; |
| 793 | } |
| 794 | *byteswritten = code; |
| 795 | return 0; |
| 796 | } |
| 797 | |
| 798 | |
| 799 | afs_int32 |
| 800 | rxfs_fetchClose(void *r, struct vcache *avc, struct dcache * adc, |
| 801 | struct afs_FetchOutput *o) |
| 802 | { |
| 803 | afs_int32 code, code1 = 0; |
| 804 | struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r; |
| 805 | |
| 806 | if (!v->call) |
| 807 | return -1; |
| 808 | |
| 809 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 809);}while(0); } while(0); |
| 810 | #ifdef AFS_64BIT_CLIENT |
| 811 | if (!v->hasNo64bit) |
| 812 | code = EndRXAFS_FetchData64(v->call, &o->OutStatus, &o->CallBack, |
| 813 | &o->tsync); |
| 814 | else |
| 815 | #endif |
| 816 | code = EndRXAFS_FetchData(v->call, &o->OutStatus, &o->CallBack, |
| 817 | &o->tsync); |
| 818 | code1 = rx_EndCall(v->call, code); |
| 819 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 819);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 820 | if (!code && code1) |
| 821 | code = code1; |
| 822 | |
| 823 | v->call = NULL((void *)0); |
| 824 | |
| 825 | return code; |
| 826 | } |
| 827 | |
| 828 | afs_int32 |
| 829 | rxfs_fetchDestroy(void **r, afs_int32 error) |
| 830 | { |
| 831 | afs_int32 code = error; |
| 832 | struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)*r; |
| 833 | |
| 834 | *r = NULL((void *)0); |
| 835 | if (v->call) { |
| 836 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 836);}while(0); } while(0); |
| 837 | code = rx_EndCall(v->call, error); |
| 838 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 838);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 839 | if (error) |
| 840 | code = error; |
| 841 | } |
| 842 | if (v->tbuffer) |
| 843 | osi_FreeLargeSpace(v->tbuffer); |
| 844 | if (v->iov) |
| 845 | osi_FreeSmallSpace(v->iov); |
| 846 | osi_FreeSmallSpace(v); |
| 847 | return code; |
| 848 | } |
| 849 | |
| 850 | afs_int32 |
| 851 | rxfs_fetchMore(void *r, afs_int32 *length, afs_uint32 *moredata) |
| 852 | { |
| 853 | afs_int32 code; |
| 854 | struct rxfs_fetchVariables *v = (struct rxfs_fetchVariables *)r; |
| 855 | |
| 856 | /* |
| 857 | * The fetch protocol is extended for the AFS/DFS translator |
| 858 | * to allow multiple blocks of data, each with its own length, |
| 859 | * to be returned. As long as the top bit is set, there are more |
| 860 | * blocks expected. |
| 861 | * |
| 862 | * We do not do this for AFS file servers because they sometimes |
| 863 | * return large negative numbers as the transfer size. |
| 864 | */ |
| 865 | if (*moredata) { |
| 866 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 866);}while(0); } while(0); |
| 867 | code = rx_Read(v->call, (void *)length, sizeof(afs_int32))rx_ReadProc(v->call, (void *)length, sizeof(afs_int32)); |
| 868 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 868);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 869 | *length = ntohl(*length)(__builtin_constant_p(*length) ? ((((__uint32_t)(*length)) >> 24) | ((((__uint32_t)(*length)) & (0xff << 16)) >> 8) | ((((__uint32_t)(*length)) & (0xff << 8)) << 8) | (((__uint32_t)(*length)) << 24)) : __bswap32_var( *length)); |
| 870 | if (code != sizeof(afs_int32)) { |
| 871 | code = rx_Error(v->call)((v->call)->error); |
| 872 | *moredata = 0; |
| 873 | return (code ? code : -1); /* try to return code, not -1 */ |
| 874 | } |
| 875 | } |
| 876 | *moredata = *length & 0x80000000; |
| 877 | *length &= ~0x80000000; |
| 878 | return 0; |
| 879 | } |
| 880 | |
| 881 | static |
| 882 | struct fetchOps rxfs_fetchUfsOps = { |
| 883 | rxfs_fetchMore, |
| 884 | rxfs_fetchUfsRead, |
| 885 | rxfs_fetchUfsWrite, |
| 886 | rxfs_fetchClose, |
| 887 | rxfs_fetchDestroy |
| 888 | }; |
| 889 | |
| 890 | static |
| 891 | struct fetchOps rxfs_fetchMemOps = { |
| 892 | rxfs_fetchMore, |
| 893 | rxfs_fetchMemRead, |
| 894 | rxfs_fetchMemWrite, |
| 895 | rxfs_fetchClose, |
| 896 | rxfs_fetchDestroy |
| 897 | }; |
| 898 | |
| 899 | afs_int32 |
| 900 | rxfs_fetchInit(struct afs_conn *tc, struct rx_connection *rxconn, |
| 901 | struct vcache *avc, afs_offs_t base, |
| 902 | afs_uint32 size, afs_int32 *alength, struct dcache *adc, |
| 903 | struct osi_file *fP, struct fetchOps **ops, void **rock) |
| 904 | { |
| 905 | struct rxfs_fetchVariables *v; |
| 906 | int code = 0, code1 = 0; |
| 907 | #ifdef AFS_64BIT_CLIENT |
| 908 | afs_uint32 length_hi = 0; |
| 909 | #endif |
| 910 | afs_uint32 length, bytes; |
| 911 | |
| 912 | v = (struct rxfs_fetchVariables *) |
| 913 | osi_AllocSmallSpace(sizeof(struct rxfs_fetchVariables)); |
| 914 | if (!v) |
| 915 | osi_Panic("rxfs_fetchInit: osi_AllocSmallSpace returned NULL\n"); |
| 916 | memset(v, 0, sizeof(struct rxfs_fetchVariables)); |
| 917 | |
| 918 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 918);}while(0); } while(0); |
| 919 | v->call = rx_NewCall(rxconn); |
| 920 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 920);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 921 | if (v->call) { |
| 922 | #ifdef AFS_64BIT_CLIENT |
| 923 | afs_size_t length64; /* as returned from server */ |
| 924 | if (!afs_serverHasNo64Bit(tc)(((struct sa_conn_vector*)(tc)->parent)->srvr->server ->flags & 0x200)) { |
| 925 | afs_uint64 llbytes = size; |
| 926 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 926);}while(0); } while(0); |
| 927 | code = StartRXAFS_FetchData64(v->call, |
| 928 | (struct AFSFid *) &avc->f.fidusr_fid.Fid, |
| 929 | base, llbytes); |
| 930 | if (code != 0) { |
| 931 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 931);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 932 | afs_Trace2(afs_iclSetp, CM_TRACE_FETCH64CODE,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event2(afs_iclSetp, (701087865L), (1<<24)+((2) <<18)+((7)<<12), (long)(avc), (long)(code)) : 0) |
| 933 | ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event2(afs_iclSetp, (701087865L), (1<<24)+((2) <<18)+((7)<<12), (long)(avc), (long)(code)) : 0); |
| 934 | } else { |
| 935 | bytes = rx_Read(v->call, (char *)&length_hi, sizeof(afs_int32))rx_ReadProc(v->call, (char *)&length_hi, sizeof(afs_int32 )); |
| 936 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 936);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 937 | if (bytes == sizeof(afs_int32)) { |
| 938 | length_hi = ntohl(length_hi)(__builtin_constant_p(length_hi) ? ((((__uint32_t)(length_hi) ) >> 24) | ((((__uint32_t)(length_hi)) & (0xff << 16)) >> 8) | ((((__uint32_t)(length_hi)) & (0xff << 8)) << 8) | (((__uint32_t)(length_hi)) << 24)) : __bswap32_var(length_hi)); |
| 939 | } else { |
| 940 | code = rx_Error(v->call)((v->call)->error); |
| 941 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 941);}while(0); } while(0); |
| 942 | code1 = rx_EndCall(v->call, code); |
| 943 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 943);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 944 | v->call = NULL((void *)0); |
| 945 | } |
| 946 | } |
| 947 | } |
| 948 | if (code == RXGEN_OPCODE-455 || afs_serverHasNo64Bit(tc)(((struct sa_conn_vector*)(tc)->parent)->srvr->server ->flags & 0x200)) { |
| 949 | if (base > 0x7FFFFFFF) { |
| 950 | code = EFBIG27; |
| 951 | } else { |
| 952 | afs_uint32 pos; |
| 953 | pos = base; |
| 954 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 954);}while(0); } while(0); |
| 955 | if (!v->call) |
| 956 | v->call = rx_NewCall(rxconn); |
| 957 | code = |
| 958 | StartRXAFS_FetchData( |
| 959 | v->call, (struct AFSFid*)&avc->f.fidusr_fid.Fid, |
| 960 | pos, size); |
| 961 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 961);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 962 | } |
| 963 | afs_serverSetNo64Bit(tc)(((struct sa_conn_vector*)(tc)->parent)->srvr->server ->flags |= 0x200); |
| 964 | } |
| 965 | if (!code) { |
| 966 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 966);}while(0); } while(0); |
| 967 | bytes = rx_Read(v->call, (char *)&length, sizeof(afs_int32))rx_ReadProc(v->call, (char *)&length, sizeof(afs_int32 )); |
| 968 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 968);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 969 | if (bytes == sizeof(afs_int32)) |
| 970 | length = ntohl(length)(__builtin_constant_p(length) ? ((((__uint32_t)(length)) >> 24) | ((((__uint32_t)(length)) & (0xff << 16)) >> 8) | ((((__uint32_t)(length)) & (0xff << 8)) << 8) | (((__uint32_t)(length)) << 24)) : __bswap32_var(length )); |
| 971 | else { |
| 972 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 972);}while(0); } while(0); |
| 973 | code = rx_Error(v->call)((v->call)->error); |
| 974 | code1 = rx_EndCall(v->call, code); |
| 975 | v->call = NULL((void *)0); |
| 976 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 976);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 977 | } |
| 978 | } |
| 979 | FillInt64(length64, length_hi, length)(length64) = ((afs_int64)(length_hi) << 32) | (length);; |
| 980 | afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64LENG,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event3(afs_iclSetp, (701087866L), (1<<24)+((2) <<18)+((7)<<12)+((8)<<6), (long)(avc), (long )(code), (long)((length64))) : 0) |
| 981 | ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event3(afs_iclSetp, (701087866L), (1<<24)+((2) <<18)+((7)<<12)+((8)<<6), (long)(avc), (long )(code), (long)((length64))) : 0) |
| 982 | ICL_TYPE_OFFSET,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event3(afs_iclSetp, (701087866L), (1<<24)+((2) <<18)+((7)<<12)+((8)<<6), (long)(avc), (long )(code), (long)((length64))) : 0) |
| 983 | ICL_HANDLE_OFFSET(length64))(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event3(afs_iclSetp, (701087866L), (1<<24)+((2) <<18)+((7)<<12)+((8)<<6), (long)(avc), (long )(code), (long)((length64))) : 0); |
| 984 | *alength = length; |
| 985 | #else /* AFS_64BIT_CLIENT */ |
| 986 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 986);}while(0); } while(0); |
| 987 | code = StartRXAFS_FetchData(v->call, (struct AFSFid *)&avc->f.fidusr_fid.Fid, |
| 988 | base, size); |
| 989 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 989);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 990 | if (code == 0) { |
| 991 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 991);}while(0); } while(0); |
| 992 | bytes = |
| 993 | rx_Read(v->call, (char *)&length, sizeof(afs_int32))rx_ReadProc(v->call, (char *)&length, sizeof(afs_int32 )); |
| 994 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 994);}while(0); afs_global_owner = pthread_self(); } while( 0); |
| 995 | if (bytes == sizeof(afs_int32)) { |
| 996 | *alength = ntohl(length)(__builtin_constant_p(length) ? ((((__uint32_t)(length)) >> 24) | ((((__uint32_t)(length)) & (0xff << 16)) >> 8) | ((((__uint32_t)(length)) & (0xff << 8)) << 8) | (((__uint32_t)(length)) << 24)) : __bswap32_var(length )); |
| 997 | } else { |
| 998 | code = rx_Error(v->call)((v->call)->error); |
| 999 | code1 = rx_EndCall(v->call, code); |
| 1000 | v->call = NULL((void *)0); |
| 1001 | } |
| 1002 | } |
| 1003 | #endif /* AFS_64BIT_CLIENT */ |
| 1004 | } else |
| 1005 | code = -1; |
| 1006 | |
| 1007 | /* We need to cast here, in order to avoid issues if *alength is |
| 1008 | * negative. Some, older, fileservers can return a negative length, |
| 1009 | * which the rest of the code deals correctly with. */ |
| 1010 | if (code == 0 && *alength > (afs_int32) size) { |
| 1011 | /* The fileserver told us it is going to send more data than we |
| 1012 | * requested. It shouldn't do that, and accepting that much data |
| 1013 | * can make us take up more cache space than we're supposed to, |
| 1014 | * so error. */ |
| 1015 | code = rx_Error(v->call)((v->call)->error); |
| 1016 | RX_AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 1016);}while(0); } while(0); |
| 1017 | code1 = rx_EndCall(v->call, code); |
| 1018 | RX_AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_fetchstore.c" , 1018);}while(0); afs_global_owner = pthread_self(); } while (0); |
| 1019 | v->call = NULL((void *)0); |
| 1020 | code = EIO5; |
| 1021 | } |
| 1022 | |
| 1023 | if (!code && code1) |
| 1024 | code = code1; |
| 1025 | |
| 1026 | if (code) { |
| 1027 | osi_FreeSmallSpace(v); |
| 1028 | return code; |
| 1029 | } |
| 1030 | if (cacheDiskType == AFS_FCACHE_TYPE_UFS0x0) { |
| 1031 | v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ4096); |
| 1032 | if (!v->tbuffer) |
| 1033 | osi_Panic("rxfs_fetchInit: osi_AllocLargeSpace for iovecs returned NULL\n"); |
| 1034 | osi_Assert(WriteLocked(&adc->lock))(void)((((&adc->lock)->excl_locked & 2)) || (osi_AssertFailK ( "WriteLocked(&adc->lock)" , "/home/wollman/openafs/src/afs/afs_fetchstore.c" , 1034), 0)); |
| 1035 | fP->offset = 0; |
| 1036 | *ops = (struct fetchOps *) &rxfs_fetchUfsOps; |
| 1037 | } |
| 1038 | else { |
| 1039 | afs_Trace4(afs_iclSetp, CM_TRACE_MEMFETCH, ICL_TYPE_POINTER, avc,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087876L), (1<<24)+((2) <<18)+((2)<<12)+((8)<<6)+(7), (long)(avc), ( long)(fP), (long)((base)), (long)(length)) : 0) |
| 1040 | ICL_TYPE_POINTER, fP, ICL_TYPE_OFFSET,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087876L), (1<<24)+((2) <<18)+((2)<<12)+((8)<<6)+(7), (long)(avc), ( long)(fP), (long)((base)), (long)(length)) : 0) |
| 1041 | ICL_HANDLE_OFFSET(base), ICL_TYPE_INT32, length)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087876L), (1<<24)+((2) <<18)+((2)<<12)+((8)<<6)+(7), (long)(avc), ( long)(fP), (long)((base)), (long)(length)) : 0); |
| 1042 | /* |
| 1043 | * We need to alloc the iovecs on the heap so that they are "pinned" |
| 1044 | * rather than declare them on the stack - defect 11272 |
| 1045 | */ |
| 1046 | v->iov = osi_AllocSmallSpace(sizeof(struct iovec) * RX_MAXIOVECS16); |
| 1047 | if (!v->iov) |
| 1048 | osi_Panic("rxfs_fetchInit: osi_AllocSmallSpace for iovecs returned NULL\n"); |
| 1049 | *ops = (struct fetchOps *) &rxfs_fetchMemOps; |
| 1050 | } |
| 1051 | *rock = (void *)v; |
| 1052 | return 0; |
| 1053 | } |
| 1054 | |
| 1055 | |
| 1056 | /*! |
| 1057 | * Routine called on fetch; also tells people waiting for data |
| 1058 | * that more has arrived. |
| 1059 | * |
| 1060 | * \param tc Ptr to the AFS connection structure. |
| 1061 | * \param rxconn Ptr to the Rx connection structure. |
| 1062 | * \param fP File descriptor for the cache file. |
| 1063 | * \param base Base offset to fetch. |
| 1064 | * \param adc Ptr to the dcache entry for the file, write-locked. |
| 1065 | * \param avc Ptr to the vcache entry for the file. |
| 1066 | * \param size Amount of data that should be fetched. |
| 1067 | * \param tsmall Ptr to the afs_FetchOutput structure. |
| 1068 | * |
| 1069 | * \note Environment: Nothing interesting. |
| 1070 | */ |
| 1071 | int |
| 1072 | afs_CacheFetchProc(struct afs_conn *tc, struct rx_connection *rxconn, |
| 1073 | struct osi_file *fP, afs_size_t base, |
| 1074 | struct dcache *adc, struct vcache *avc, afs_int32 size, |
| 1075 | struct afs_FetchOutput *tsmall) |
| 1076 | { |
| 1077 | afs_int32 code; |
| 1078 | afs_int32 length; |
| 1079 | afs_uint32 bytesread, byteswritten; |
| 1080 | struct fetchOps *ops = NULL((void *)0); |
| 1081 | void *rock = NULL((void *)0); |
| 1082 | afs_uint32 moredata = 0; |
| 1083 | int offset = 0; |
| 1084 | |
| 1085 | XSTATS_DECLSstruct afs_stats_opTimingData *opP = ((void *)0); osi_timeval_t opStartTime = { 0, 0}, opStopTime, elapsedTime; |
| 1086 | #ifndef AFS_NOSTATS |
| 1087 | osi_timeval_t xferStartTime; /*FS xfer start time */ |
| 1088 | afs_size_t bytesToXfer = 0, bytesXferred = 0; |
| 1089 | #endif |
| 1090 | |
| 1091 | AFS_STATCNT(CacheFetchProc)((afs_cmstats.callInfo.C_CacheFetchProc)++); |
| 1092 | |
| 1093 | XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHDATA)opP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[0]); osi_GetTime (&opStartTime);; |
| 1094 | |
| 1095 | /* |
| 1096 | * Locks held: |
| 1097 | * avc->lock(R) if setLocks && !slowPass |
| 1098 | * avc->lock(W) if !setLocks || slowPass |
| 1099 | * adc->lock(W) |
| 1100 | */ |
| 1101 | code = rxfs_fetchInit( |
| 1102 | tc, rxconn, avc, base, size, &length, adc, fP, &ops, &rock); |
| 1103 | |
| 1104 | #ifndef AFS_NOSTATS |
| 1105 | osi_GetuTime(&xferStartTime)osi_GetTime(&xferStartTime); |
| 1106 | #endif /* AFS_NOSTATS */ |
| 1107 | |
| 1108 | if (adc) { |
| 1109 | adc->validPos = base; |
| 1110 | } |
| 1111 | |
| 1112 | if ( !code ) do { |
| 1113 | if (avc->f.states & CForeign0x00002000) { |
| 1114 | code = (*ops->more)(rock, &length, &moredata); |
| 1115 | if ( code ) |
| 1116 | break; |
| 1117 | } |
| 1118 | #ifndef AFS_NOSTATS |
| 1119 | bytesToXfer += length; |
| 1120 | #endif /* AFS_NOSTATS */ |
| 1121 | while (length > 0) { |
| 1122 | #ifdef RX_KERNEL_TRACE |
| 1123 | afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event1(afs_iclSetp, (701087896L), (1<<24)+((4) <<18), (long)("before rx_Read")) : 0) |
| 1124 | "before rx_Read")(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event1(afs_iclSetp, (701087896L), (1<<24)+((4) <<18), (long)("before rx_Read")) : 0); |
| 1125 | #endif |
| 1126 | code = (*ops->read)(rock, length, &bytesread); |
| 1127 | #ifdef RX_KERNEL_TRACE |
| 1128 | afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event1(afs_iclSetp, (701087896L), (1<<24)+((4) <<18), (long)("after rx_Read")) : 0) |
| 1129 | "after rx_Read")(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event1(afs_iclSetp, (701087896L), (1<<24)+((4) <<18), (long)("after rx_Read")) : 0); |
| 1130 | #endif |
| 1131 | #ifndef AFS_NOSTATS |
| 1132 | bytesXferred += bytesread; |
| 1133 | #endif /* AFS_NOSTATS */ |
| 1134 | if ( code ) { |
| 1135 | afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64READ,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event3(afs_iclSetp, (701087867L), (1<<24)+((2) <<18)+((7)<<12)+((7)<<6), (long)(avc), (long )(code), (long)(length)) : 0) |
| 1136 | ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event3(afs_iclSetp, (701087867L), (1<<24)+((2) <<18)+((7)<<12)+((7)<<6), (long)(avc), (long )(code), (long)(length)) : 0) |
| 1137 | ICL_TYPE_INT32, length)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event3(afs_iclSetp, (701087867L), (1<<24)+((2) <<18)+((7)<<12)+((7)<<6), (long)(avc), (long )(code), (long)(length)) : 0); |
| 1138 | code = -34; |
| 1139 | break; |
| 1140 | } |
| 1141 | code = (*ops->write)(rock, fP, offset, bytesread, &byteswritten); |
| 1142 | if ( code ) |
| 1143 | break; |
| 1144 | offset += bytesread; |
| 1145 | base += bytesread; |
| 1146 | length -= bytesread; |
| 1147 | adc->validPos = base; |
| 1148 | if (afs_osi_Wakeup(&adc->validPos) == 0) |
| 1149 | afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, ICL_TYPE_STRING,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087894L), (1<<24)+((4) <<18)+((7)<<12)+((2)<<6)+(7), (long)("/home/wollman/openafs/src/afs/afs_fetchstore.c" ), (long)(1150), (long)(adc), (long)(adc->dflags)) : 0) |
| 1150 | __FILE__, ICL_TYPE_INT32, __LINE__,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087894L), (1<<24)+((4) <<18)+((7)<<12)+((2)<<6)+(7), (long)("/home/wollman/openafs/src/afs/afs_fetchstore.c" ), (long)(1150), (long)(adc), (long)(adc->dflags)) : 0) |
| 1151 | ICL_TYPE_POINTER, adc, ICL_TYPE_INT32,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087894L), (1<<24)+((4) <<18)+((7)<<12)+((2)<<6)+(7), (long)("/home/wollman/openafs/src/afs/afs_fetchstore.c" ), (long)(1150), (long)(adc), (long)(adc->dflags)) : 0) |
| 1152 | adc->dflags)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ? afs_icl_Event4(afs_iclSetp, (701087894L), (1<<24)+((4) <<18)+((7)<<12)+((2)<<6)+(7), (long)("/home/wollman/openafs/src/afs/afs_fetchstore.c" ), (long)(1150), (long)(adc), (long)(adc->dflags)) : 0); |
| 1153 | } |
| 1154 | code = 0; |
| 1155 | } while (moredata); |
| 1156 | if (!code) |
| 1157 | code = (*ops->close)(rock, avc, adc, tsmall); |
| 1158 | if (ops) |
| 1159 | (*ops->destroy)(&rock, code); |
| 1160 | |
| 1161 | #ifndef AFS_NOSTATS |
| 1162 | FillStoreStats(code, AFS_STATS_FS_XFERIDX_FETCHDATA0, &xferStartTime, |
| 1163 | bytesToXfer, bytesXferred); |
| 1164 | #endif |
| 1165 | XSTATS_END_TIMEosi_GetTime(&opStopTime); (opP->numOps)++; if (!code) { (opP->numSuccesses)++; { if (opStopTime.tv_usec < opStartTime .tv_usec) { opStopTime.tv_usec += 1000000; opStopTime.tv_sec -= 1; } elapsedTime.tv_sec = opStopTime.tv_sec - opStartTime.tv_sec ; elapsedTime.tv_usec = opStopTime.tv_usec - opStartTime.tv_usec ; }; { (opP->sumTime).tv_sec += elapsedTime.tv_sec; (opP-> sumTime).tv_usec += elapsedTime.tv_usec; if ((opP->sumTime ).tv_usec > 1000000) { (opP->sumTime).tv_usec -= 1000000 ; (opP->sumTime).tv_sec++; } }; { if(elapsedTime.tv_sec > 0 ) { (opP->sqrTime).tv_sec += elapsedTime.tv_sec * elapsedTime .tv_sec + 2 * elapsedTime.tv_sec * elapsedTime.tv_usec /1000000 ; (opP->sqrTime).tv_usec += (2 * elapsedTime.tv_sec * elapsedTime .tv_usec) % 1000000 + (elapsedTime.tv_usec / 1000)*(elapsedTime .tv_usec / 1000) + 2 * (elapsedTime.tv_usec / 1000) * (elapsedTime .tv_usec % 1000) / 1000 + (((elapsedTime.tv_usec % 1000) > 707) ? 1 : 0); } else { (opP->sqrTime).tv_usec += (elapsedTime .tv_usec / 1000)*(elapsedTime.tv_usec / 1000) + 2 * (elapsedTime .tv_usec / 1000) * (elapsedTime.tv_usec % 1000) / 1000 + (((elapsedTime .tv_usec % 1000) > 707) ? 1 : 0); } if ((opP->sqrTime). tv_usec > 1000000) { (opP->sqrTime).tv_usec -= 1000000; (opP->sqrTime).tv_sec++; } }; if (((elapsedTime.tv_sec < (opP->minTime).tv_sec) ? 1 : (elapsedTime.tv_sec > (opP ->minTime).tv_sec) ? 0 : (elapsedTime.tv_usec < (opP-> minTime).tv_usec) ? 1 : 0)) { { (opP->minTime).tv_sec = elapsedTime .tv_sec; (opP->minTime).tv_usec = elapsedTime.tv_usec; }; } if (((elapsedTime.tv_sec > (opP->maxTime).tv_sec) ? 1 : (elapsedTime.tv_sec < (opP->maxTime).tv_sec) ? 0 : (elapsedTime .tv_usec > (opP->maxTime).tv_usec) ? 1 : 0)) { { (opP-> maxTime).tv_sec = elapsedTime.tv_sec; (opP->maxTime).tv_usec = elapsedTime.tv_usec; }; } }; |
| 1166 | return code; |
| 1167 | } |