Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
21de0a95
Commit
21de0a95
authored
Jul 17, 2011
by
Trond Myklebust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SUNRPC: Clean up the slot table allocation
Signed-off-by:
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
parent
8d9266ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
29 deletions
+37
-29
include/linux/sunrpc/xprt.h
include/linux/sunrpc/xprt.h
+0
-2
net/sunrpc/xprt.c
net/sunrpc/xprt.c
+37
-27
No files found.
include/linux/sunrpc/xprt.h
View file @
21de0a95
...
...
@@ -168,7 +168,6 @@ struct rpc_xprt {
struct
rpc_wait_queue
pending
;
/* requests in flight */
struct
rpc_wait_queue
backlog
;
/* waiting for slot */
struct
list_head
free
;
/* free slots */
struct
rpc_rqst
*
slot
;
/* slot table storage */
unsigned
int
max_reqs
;
/* total slots */
unsigned
long
state
;
/* transport state */
unsigned
char
shutdown
:
1
,
/* being shut down */
...
...
@@ -321,7 +320,6 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie);
#define XPRT_CLOSING (6)
#define XPRT_CONNECTION_ABORT (7)
#define XPRT_CONNECTION_CLOSE (8)
#define XPRT_INITIALIZED (9)
static
inline
void
xprt_set_connected
(
struct
rpc_xprt
*
xprt
)
{
...
...
net/sunrpc/xprt.c
View file @
21de0a95
...
...
@@ -62,6 +62,7 @@
/*
* Local functions
*/
static
void
xprt_init
(
struct
rpc_xprt
*
xprt
,
struct
net
*
net
);
static
void
xprt_request_init
(
struct
rpc_task
*
,
struct
rpc_xprt
*
);
static
void
xprt_connect_status
(
struct
rpc_task
*
task
);
static
int
__xprt_get_cong
(
struct
rpc_xprt
*
,
struct
rpc_task
*
);
...
...
@@ -961,25 +962,42 @@ static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
spin_unlock
(
&
xprt
->
reserve_lock
);
}
struct
rpc_xprt
*
xprt_alloc
(
struct
net
*
net
,
int
size
,
int
max_req
)
static
void
xprt_free_all_slots
(
struct
rpc_xprt
*
xprt
)
{
struct
rpc_rqst
*
req
;
while
(
!
list_empty
(
&
xprt
->
free
))
{
req
=
list_first_entry
(
&
xprt
->
free
,
struct
rpc_rqst
,
rq_list
);
list_del
(
&
req
->
rq_list
);
kfree
(
req
);
}
}
struct
rpc_xprt
*
xprt_alloc
(
struct
net
*
net
,
int
size
,
int
num_prealloc
)
{
struct
rpc_xprt
*
xprt
;
struct
rpc_rqst
*
req
;
int
i
;
xprt
=
kzalloc
(
size
,
GFP_KERNEL
);
if
(
xprt
==
NULL
)
goto
out
;
atomic_set
(
&
xprt
->
count
,
1
);
xprt
->
max_reqs
=
max_req
;
xprt
->
slot
=
kcalloc
(
max_req
,
sizeof
(
struct
rpc_rqst
),
GFP_KERNEL
);
if
(
xprt
->
slot
==
NULL
)
xprt_init
(
xprt
,
net
);
for
(
i
=
0
;
i
<
num_prealloc
;
i
++
)
{
req
=
kzalloc
(
sizeof
(
struct
rpc_rqst
),
GFP_KERNEL
);
if
(
!
req
)
break
;
list_add
(
&
req
->
rq_list
,
&
xprt
->
free
);
}
if
(
i
<
num_prealloc
)
goto
out_free
;
xprt
->
max_reqs
=
num_prealloc
;
xprt
->
xprt_net
=
get_net
(
net
);
return
xprt
;
out_free:
k
free
(
xprt
);
xprt_
free
(
xprt
);
out:
return
NULL
;
}
...
...
@@ -988,7 +1006,7 @@ EXPORT_SYMBOL_GPL(xprt_alloc);
void
xprt_free
(
struct
rpc_xprt
*
xprt
)
{
put_net
(
xprt
->
xprt_net
);
kfree
(
xprt
->
slo
t
);
xprt_free_all_slots
(
xpr
t
);
kfree
(
xprt
);
}
EXPORT_SYMBOL_GPL
(
xprt_free
);
...
...
@@ -1091,9 +1109,9 @@ void xprt_release(struct rpc_task *task)
xprt_free_bc_request
(
req
);
}
static
void
xprt_init
(
struct
rpc_xprt
*
xprt
)
static
void
xprt_init
(
struct
rpc_xprt
*
xprt
,
struct
net
*
net
)
{
struct
rpc_rqst
*
req
;
atomic_set
(
&
xprt
->
count
,
1
)
;
spin_lock_init
(
&
xprt
->
transport_lock
);
spin_lock_init
(
&
xprt
->
reserve_lock
);
...
...
@@ -1105,12 +1123,6 @@ static void xprt_init(struct rpc_xprt *xprt)
INIT_LIST_HEAD
(
&
xprt
->
bc_pa_list
);
#endif
/* CONFIG_SUNRPC_BACKCHANNEL */
INIT_WORK
(
&
xprt
->
task_cleanup
,
xprt_autoclose
);
if
(
xprt_has_timer
(
xprt
))
setup_timer
(
&
xprt
->
timer
,
xprt_init_autodisconnect
,
(
unsigned
long
)
xprt
);
else
init_timer
(
&
xprt
->
timer
);
xprt
->
last_used
=
jiffies
;
xprt
->
cwnd
=
RPC_INITCWND
;
xprt
->
bind_index
=
0
;
...
...
@@ -1121,12 +1133,9 @@ static void xprt_init(struct rpc_xprt *xprt)
rpc_init_wait_queue
(
&
xprt
->
resend
,
"xprt_resend"
);
rpc_init_priority_wait_queue
(
&
xprt
->
backlog
,
"xprt_backlog"
);
/* initialize free list */
for
(
req
=
&
xprt
->
slot
[
xprt
->
max_reqs
-
1
];
req
>=
&
xprt
->
slot
[
0
];
req
--
)
list_add
(
&
req
->
rq_list
,
&
xprt
->
free
);
xprt_init_xid
(
xprt
);
xprt
->
xprt_net
=
get_net
(
net
);
}
/**
...
...
@@ -1155,16 +1164,17 @@ struct rpc_xprt *xprt_create_transport(struct xprt_create *args)
if
(
IS_ERR
(
xprt
))
{
dprintk
(
"RPC: xprt_create_transport: failed, %ld
\n
"
,
-
PTR_ERR
(
xprt
));
return
xpr
t
;
goto
ou
t
;
}
if
(
test_and_set_bit
(
XPRT_INITIALIZED
,
&
xprt
->
state
))
/* ->setup returned a pre-initialized xprt: */
return
xprt
;
xprt_init
(
xprt
);
INIT_WORK
(
&
xprt
->
task_cleanup
,
xprt_autoclose
);
if
(
xprt_has_timer
(
xprt
))
setup_timer
(
&
xprt
->
timer
,
xprt_init_autodisconnect
,
(
unsigned
long
)
xprt
);
else
init_timer
(
&
xprt
->
timer
);
dprintk
(
"RPC: created transport %p with %u slots
\n
"
,
xprt
,
xprt
->
max_reqs
);
out:
return
xprt
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment