OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [fs/] [nfs/] [nfsiod.c] - Blame information for rev 1628

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1628 jcastillo
/*
2
 * linux/fs/nfs/nfsiod.c
3
 *
4
 * Async NFS RPC call support.
5
 *
6
 * When a process wants to place an asynchronous RPC call, it reserves
7
 * an nfsiod slot, fills in all necessary fields including the callback
8
 * handler field, and enqueues the request.
9
 *
10
 * This will wake up nfsiod, which calls nfs_rpc_doio to collect the
11
 * reply. It then dispatches the result to the caller via the callback
12
 * function, including result value and request pointer. It then re-inserts
13
 * itself into the free list.
14
 *
15
 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
16
 */
17
 
18
#include <linux/sched.h>
19
#include <linux/nfs_fs.h>
20
#include <linux/string.h>
21
#include <linux/errno.h>
22
#include <linux/rpcsock.h>
23
#include <linux/nfsiod.h>
24
 
25
static struct nfsiod_req *      free_list = NULL;
26
static int                      active = 0;
27
 
28
#undef DEBUG_NFSIOD
29
#ifdef DEBUG_NFSIOD
30
#define dprintk(args...)        printk(## args)
31
#else
32
#define dprintk(args...)        /* nothing */
33
#endif
34
 
35
 
36
/*
37
 * Reserve an nfsiod slot and initialize the request struct
38
 */
39
struct nfsiod_req *
40
nfsiod_reserve(struct nfs_server *server)
41
{
42
        struct nfsiod_req       *req;
43
 
44
        if (!(req = free_list)) {
45
                dprintk("BIO: nfsiod_reserve: no free nfsiods\n");
46
                return NULL;
47
        }
48
        free_list = req->rq_next;
49
        memset(&req->rq_rpcreq, 0, sizeof(struct rpc_ioreq));
50
 
51
        if (rpc_reserve(server->rsock, &req->rq_rpcreq, 1) < 0) {
52
                dprintk("BIO: nfsiod_reserve failed to reserve RPC slot\n");
53
                req->rq_next = free_list;
54
                free_list = req;
55
                return NULL;
56
        }
57
 
58
        req->rq_server = server;
59
        return req;
60
}
61
 
62
void
63
nfsiod_release(struct nfsiod_req *req)
64
{
65
        dprintk("BIO: nfsiod_release called\n");
66
        rpc_release(req->rq_server->rsock, &req->rq_rpcreq);
67
        memset(&req->rq_rpcreq, 0, sizeof(struct rpc_ioreq));
68
        req->rq_next = free_list;
69
        free_list = req;
70
}
71
 
72
/*
73
 * Transmit a request and put it on nfsiod's list of pending requests.
74
 */
75
void
76
nfsiod_enqueue(struct nfsiod_req *req)
77
{
78
        dprintk("BIO: enqueuing request %p\n", &req->rq_rpcreq);
79
        wake_up(&req->rq_wait);
80
        schedule();
81
}
82
 
83
/*
84
 * This is the main nfsiod loop.
85
 */
86
int
87
nfsiod(void)
88
{
89
        struct nfsiod_req       request, *req = &request;
90
        int                     result;
91
 
92
        dprintk("BIO: nfsiod %d starting\n", current->pid);
93
        while (1) {
94
                /* Insert request into free list */
95
                memset(req, 0, sizeof(*req));
96
                req->rq_next = free_list;
97
                free_list = req;
98
 
99
                /* Wait until user enqueues request */
100
                dprintk("BIO: before: now %d nfsiod's active\n", active);
101
                dprintk("BIO: nfsiod %d waiting\n", current->pid);
102
#ifndef MODULE
103
                current->signal = 0;
104
#endif
105
                interruptible_sleep_on(&req->rq_wait);
106
#ifdef  MODULE
107
                if (current->signal & ~current->blocked)
108
                        break;
109
#endif
110
                if (!req->rq_rpcreq.rq_slot)
111
                        continue;
112
                dprintk("BIO: nfsiod %d woken up; calling nfs_rpc_doio.\n",
113
                                current->pid);
114
                active++;
115
                dprintk("BIO: before: now %d nfsiod's active\n", active);
116
                do {
117
                        result = nfs_rpc_doio(req->rq_server,
118
                                                &req->rq_rpcreq, 1);
119
                } while (!req->rq_callback(result, req));
120
                active--;
121
        }
122
 
123
        return 0;
124
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.