Revision 21c0e7f3
b/xseg/peers/user/cached.c | ||
---|---|---|
217 | 217 |
//FIXME: Which of those for srcport? |
218 | 218 |
//xport srcport = peer->portno_start; |
219 | 219 |
//FIXME: pr->portnumber |
220 |
xport srcport = req_old->src_portno;
|
|
220 |
xport srcport = pr->portno;
|
|
221 | 221 |
xport dstport = cached->bportno; |
222 | 222 |
xport p; |
223 | 223 |
char *req_target; |
224 | 224 |
int r; |
225 |
uint32_t i; |
|
225 | 226 |
|
226 | 227 |
req = xseg_get_request(xseg, srcport, dstport, X_ALLOC); |
227 | 228 |
if (!req) { |
... | ... | |
244 | 245 |
|
245 | 246 |
//Paste target name |
246 | 247 |
req_target = xseg_get_target(xseg, req); |
247 |
strncpy(req_target, (char *)req_old->target, XSEG_MAX_TARGETLEN); |
|
248 |
char *req_old_target = xseg_get_target(xseg, req_old); |
|
249 |
strncpy(req_target, req_old_target, XSEG_MAX_TARGETLEN); |
|
248 | 250 |
|
249 | 251 |
if (req->op == X_WRITE) { |
250 | 252 |
/* |
... | ... | |
252 | 254 |
* req_data = xseg_get_data(xseg, req); |
253 | 255 |
* memcpy(req_data, req_old->data, size); |
254 | 256 |
*/ |
257 |
} else { |
|
258 |
for (i=start; i<=end; i++){ |
|
259 |
ce->status[i] = LOADING; |
|
260 |
} |
|
255 | 261 |
} |
256 | 262 |
|
257 | 263 |
/* |
... | ... | |
301 | 307 |
int on_init(void *c, void *e) |
302 | 308 |
{ |
303 | 309 |
uint32_t i; |
304 |
struct cached *cached = (struct cached *)c; |
|
310 |
struct peerd *peer = (struct peerd *)c; |
|
311 |
struct cached *cached = peer->priv; |
|
305 | 312 |
struct ce *ce = (struct ce *)e; |
306 | 313 |
ce->flags = 0; |
307 | 314 |
memset(ce->data, 0, cached->object_size); |
... | ... | |
314 | 321 |
|
315 | 322 |
void on_put(void *c, void *e) |
316 | 323 |
{ |
317 |
struct cached *cached = (struct cached *)c; |
|
324 |
struct peerd *peer = (struct peerd *)c; |
|
325 |
struct cached *cached = peer->priv; |
|
318 | 326 |
struct ce *ce = (struct ce *)e; |
319 | 327 |
//since we are the last referrer to the cache entry |
320 | 328 |
//no lock is needed. |
... | ... | |
468 | 476 |
|
469 | 477 |
uint32_t pending_buckets = 0; |
470 | 478 |
|
479 |
XSEGLOG2(&lc, E, "Handle read started for %p (ce: %p)", pr, ce ); |
|
471 | 480 |
if (cio->state == CIO_FAILED) |
472 | 481 |
goto out; |
473 | 482 |
|
... | ... | |
475 | 484 |
limit = __get_bucket(cached, req->offset + req->size); |
476 | 485 |
//assert limit < cached->object_size |
477 | 486 |
|
478 |
for (i = b; i < limit; i++) { |
|
487 |
for (i = b; i <= limit; i++) {
|
|
479 | 488 |
if (bucket_readable(ce->status[i])) |
480 | 489 |
continue; |
481 | 490 |
if (ce->status[i] != LOADING){ |
... | ... | |
562 | 571 |
int r = -1; |
563 | 572 |
struct ce *ce; |
564 | 573 |
struct cached *cached = __get_cached(peer); |
574 |
struct cache_io *cio = __get_cache_io(pr); |
|
565 | 575 |
char name[XSEG_MAX_TARGETLEN + 1]; |
566 | 576 |
struct xseg_request *req = pr->req; |
567 | 577 |
char *target = xseg_get_target(peer->xseg, req); |
... | ... | |
570 | 580 |
XSEGLOG2(&lc, D, "In handle readwrite"); |
571 | 581 |
|
572 | 582 |
strncpy(name, target, req->targetlen); |
573 |
name[XSEG_MAX_TARGETLEN] = 0;
|
|
583 |
name[req->targetlen] = 0;
|
|
574 | 584 |
XSEGLOG2(&lc, D, "All good till here1. Name: %s\n", name); |
575 | 585 |
|
576 | 586 |
h = xcache_lookup(cached->cache, name); |
... | ... | |
590 | 600 |
r = -1; |
591 | 601 |
goto out; |
592 | 602 |
} |
593 |
|
|
594 |
complete(peer, pr); |
|
595 |
return 0; |
|
603 |
cio->h = h; |
|
596 | 604 |
|
597 | 605 |
if (req->op == X_WRITE) |
598 | 606 |
r = xworkq_enqueue(&ce->workq, handle_write, (void *)pr); |
... | ... | |
647 | 655 |
//assert ((req->offset+req->serviced) % cached->bucket_size) == 0; |
648 | 656 |
start = __get_bucket(cached, req->offset); |
649 | 657 |
end = __get_bucket(cached, req->offset + req->serviced); |
650 |
for (i = start; i < end; i++) { |
|
658 |
for (i = start; i <= end; i++) {
|
|
651 | 659 |
if (ce->status[i] == LOADING){ |
652 | 660 |
if (success){ |
653 | 661 |
memcpy(ce->data+(i*cached->bucket_size), data, |
... | ... | |
656 | 664 |
} |
657 | 665 |
else { |
658 | 666 |
//reset status |
667 |
XSEGLOG2(&lc, E, "Before ce %p, i %lu, ce->status[i] %u", ce, i, ce->status[i]); |
|
659 | 668 |
ce->status[i] = INVALID; |
669 |
XSEGLOG2(&lc, E, "After ce %p, i %lu, ce->status[i] %u", ce, i, ce->status[i]); |
|
660 | 670 |
} |
661 | 671 |
xwaitq_signal(&ce->waitq[i]); |
662 | 672 |
} |
... | ... | |
787 | 797 |
break; |
788 | 798 |
case dispatch_receive: |
789 | 799 |
XSEGLOG2(&lc, D, "In dispatch receive"); |
790 |
complete(peer, pr);
|
|
800 |
handle_receive(peer, pr, req);
|
|
791 | 801 |
break; |
792 | 802 |
case dispatch_internal: |
793 | 803 |
default: |
Also available in: Unified diff