Revision 24e4e9d5 xseg/peers/user/cached.c
b/xseg/peers/user/cached.c | ||
---|---|---|
587 | 587 |
|
588 | 588 |
static int handle_readwrite(struct peerd *peer, struct peer_req *pr) |
589 | 589 |
{ |
590 |
int r = -1; |
|
591 | 590 |
struct ce *ce; |
592 | 591 |
struct cached *cached = __get_cached(peer); |
593 | 592 |
struct cache_io *cio = __get_cache_io(pr); |
594 |
char name[XSEG_MAX_TARGETLEN + 1]; |
|
595 | 593 |
struct xseg_request *req = pr->req; |
596 |
char *target = xseg_get_target(peer->xseg, req); |
|
597 |
|
|
594 |
char name[XSEG_MAX_TARGETLEN + 1]; |
|
595 |
char *target; |
|
596 |
int r = -1; |
|
598 | 597 |
xcache_handler h = NoEntry; |
599 |
XSEGLOG2(&lc, D, "In handle readwrite"); |
|
600 | 598 |
|
599 |
XSEGLOG2(&lc, I, "Started\n"); |
|
600 |
|
|
601 |
/*Get name of target object*/ |
|
602 |
target = xseg_get_target(peer->xseg, req); |
|
601 | 603 |
strncpy(name, target, req->targetlen); |
602 | 604 |
name[req->targetlen] = 0; |
603 |
XSEGLOG2(&lc, D, "All good till here1. Name: %s\n", name);
|
|
605 |
XSEGLOG2(&lc, D, "Target is %s\n", name);
|
|
604 | 606 |
|
607 |
/*Look if an associated handler exists in xcache*/ |
|
605 | 608 |
h = xcache_lookup(cached->cache, name); |
606 | 609 |
if (h == NoEntry){ |
610 |
/*If there is no handler, allocate a new one*/ |
|
607 | 611 |
h = xcache_alloc_init(cached->cache, name); |
608 | 612 |
if (h == NoEntry){ |
609 | 613 |
goto out; |
610 | 614 |
} |
615 |
/*Insert handler in xcache*/ |
|
611 | 616 |
r = xcache_insert(cached->cache, h); |
612 | 617 |
if (r < 0){ |
613 | 618 |
goto out; |
614 | 619 |
} |
615 | 620 |
} |
616 | 621 |
|
622 |
/*Get cache entry of the inserted handler*/ |
|
617 | 623 |
ce = (struct ce *)get_cache_entry(cached->cache, h); |
618 | 624 |
if (!ce){ |
619 | 625 |
r = -1; |
620 | 626 |
goto out; |
621 | 627 |
} |
628 |
/*Assosicate cio with the handler*/ |
|
622 | 629 |
cio->h = h; |
623 | 630 |
|
624 | 631 |
if (req->op == X_WRITE) |
... | ... | |
816 | 823 |
case dispatch_accept: |
817 | 824 |
XSEGLOG2(&lc, D, "In dispatch accept"); |
818 | 825 |
if (req->op == X_READ || req->op == X_WRITE) { |
826 |
/*We cache only read/write requests*/ |
|
819 | 827 |
cio->state = CIO_ACCEPTED; |
820 | 828 |
handle_readwrite(peer, pr); |
821 | 829 |
} else { |
830 |
/*Other requests should be forwarded to blocker*/ |
|
822 | 831 |
fail(peer, pr); |
823 | 832 |
} |
824 | 833 |
break; |
Also available in: Unified diff