Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci-2.6.23
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci-2.6.23
Commits
34f52e35
Commit
34f52e35
authored
Jun 14, 2007
by
Trond Myklebust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SUNRPC: Convert rpc_clnt->cl_users to a kref
Signed-off-by:
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
parent
c44fe705
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
44 deletions
+35
-44
fs/lockd/host.c
fs/lockd/host.c
+3
-9
include/linux/sunrpc/clnt.h
include/linux/sunrpc/clnt.h
+1
-1
net/sunrpc/clnt.c
net/sunrpc/clnt.c
+28
-29
net/sunrpc/rpc_pipe.c
net/sunrpc/rpc_pipe.c
+1
-1
net/sunrpc/sched.c
net/sunrpc/sched.c
+2
-4
No files found.
fs/lockd/host.c
View file @
34f52e35
...
@@ -161,15 +161,9 @@ nlm_destroy_host(struct nlm_host *host)
...
@@ -161,15 +161,9 @@ nlm_destroy_host(struct nlm_host *host)
*/
*/
nsm_unmonitor
(
host
);
nsm_unmonitor
(
host
);
if
((
clnt
=
host
->
h_rpcclnt
)
!=
NULL
)
{
clnt
=
host
->
h_rpcclnt
;
if
(
atomic_read
(
&
clnt
->
cl_users
))
{
if
(
clnt
!=
NULL
)
printk
(
KERN_WARNING
rpc_shutdown_client
(
clnt
);
"lockd: active RPC handle
\n
"
);
clnt
->
cl_dead
=
1
;
}
else
{
rpc_destroy_client
(
host
->
h_rpcclnt
);
}
}
kfree
(
host
);
kfree
(
host
);
}
}
...
...
include/linux/sunrpc/clnt.h
View file @
34f52e35
...
@@ -24,8 +24,8 @@ struct rpc_inode;
...
@@ -24,8 +24,8 @@ struct rpc_inode;
* The high-level client handle
* The high-level client handle
*/
*/
struct
rpc_clnt
{
struct
rpc_clnt
{
struct
kref
cl_kref
;
/* Number of references */
atomic_t
cl_count
;
/* Number of clones */
atomic_t
cl_count
;
/* Number of clones */
atomic_t
cl_users
;
/* number of references */
struct
list_head
cl_clients
;
/* Global list of clients */
struct
list_head
cl_clients
;
/* Global list of clients */
struct
list_head
cl_tasks
;
/* List of tasks */
struct
list_head
cl_tasks
;
/* List of tasks */
spinlock_t
cl_lock
;
/* spinlock */
spinlock_t
cl_lock
;
/* spinlock */
...
...
net/sunrpc/clnt.c
View file @
34f52e35
...
@@ -121,7 +121,6 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
...
@@ -121,7 +121,6 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
clnt
=
kzalloc
(
sizeof
(
*
clnt
),
GFP_KERNEL
);
clnt
=
kzalloc
(
sizeof
(
*
clnt
),
GFP_KERNEL
);
if
(
!
clnt
)
if
(
!
clnt
)
goto
out_err
;
goto
out_err
;
atomic_set
(
&
clnt
->
cl_users
,
0
);
atomic_set
(
&
clnt
->
cl_count
,
1
);
atomic_set
(
&
clnt
->
cl_count
,
1
);
clnt
->
cl_parent
=
clnt
;
clnt
->
cl_parent
=
clnt
;
...
@@ -157,6 +156,8 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
...
@@ -157,6 +156,8 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
clnt
->
cl_rtt
=
&
clnt
->
cl_rtt_default
;
clnt
->
cl_rtt
=
&
clnt
->
cl_rtt_default
;
rpc_init_rtt
(
&
clnt
->
cl_rtt_default
,
xprt
->
timeout
.
to_initval
);
rpc_init_rtt
(
&
clnt
->
cl_rtt_default
,
xprt
->
timeout
.
to_initval
);
kref_init
(
&
clnt
->
cl_kref
);
err
=
rpc_setup_pipedir
(
clnt
,
program
->
pipe_dir_name
);
err
=
rpc_setup_pipedir
(
clnt
,
program
->
pipe_dir_name
);
if
(
err
<
0
)
if
(
err
<
0
)
goto
out_no_path
;
goto
out_no_path
;
...
@@ -272,10 +273,10 @@ rpc_clone_client(struct rpc_clnt *clnt)
...
@@ -272,10 +273,10 @@ rpc_clone_client(struct rpc_clnt *clnt)
if
(
!
new
)
if
(
!
new
)
goto
out_no_clnt
;
goto
out_no_clnt
;
atomic_set
(
&
new
->
cl_count
,
1
);
atomic_set
(
&
new
->
cl_count
,
1
);
atomic_set
(
&
new
->
cl_users
,
0
);
new
->
cl_metrics
=
rpc_alloc_iostats
(
clnt
);
new
->
cl_metrics
=
rpc_alloc_iostats
(
clnt
);
if
(
new
->
cl_metrics
==
NULL
)
if
(
new
->
cl_metrics
==
NULL
)
goto
out_no_stats
;
goto
out_no_stats
;
kref_init
(
&
new
->
cl_kref
);
err
=
rpc_setup_pipedir
(
new
,
clnt
->
cl_program
->
pipe_dir_name
);
err
=
rpc_setup_pipedir
(
new
,
clnt
->
cl_program
->
pipe_dir_name
);
if
(
err
!=
0
)
if
(
err
!=
0
)
goto
out_no_path
;
goto
out_no_path
;
...
@@ -311,40 +312,28 @@ out_no_clnt:
...
@@ -311,40 +312,28 @@ out_no_clnt:
int
int
rpc_shutdown_client
(
struct
rpc_clnt
*
clnt
)
rpc_shutdown_client
(
struct
rpc_clnt
*
clnt
)
{
{
dprintk
(
"RPC: shutting down %s client for %s, tasks=%d
\n
"
,
dprintk
(
"RPC: shutting down %s client for %s
\n
"
,
clnt
->
cl_protname
,
clnt
->
cl_server
,
clnt
->
cl_protname
,
clnt
->
cl_server
);
atomic_read
(
&
clnt
->
cl_users
));
while
(
atomic_read
(
&
clnt
->
cl_users
)
>
0
)
{
while
(
!
list_empty
(
&
clnt
->
cl_tasks
)
)
{
/* Don't let rpc_release_client destroy us */
/* Don't let rpc_release_client destroy us */
clnt
->
cl_oneshot
=
0
;
clnt
->
cl_oneshot
=
0
;
clnt
->
cl_dead
=
0
;
clnt
->
cl_dead
=
0
;
rpc_killall_tasks
(
clnt
);
rpc_killall_tasks
(
clnt
);
wait_event_timeout
(
destroy_wait
,
wait_event_timeout
(
destroy_wait
,
!
atomic_read
(
&
clnt
->
cl_users
),
1
*
HZ
);
list_empty
(
&
clnt
->
cl_tasks
),
1
*
HZ
);
}
if
(
atomic_read
(
&
clnt
->
cl_users
)
<
0
)
{
printk
(
KERN_ERR
"RPC: rpc_shutdown_client clnt %p tasks=%d
\n
"
,
clnt
,
atomic_read
(
&
clnt
->
cl_users
));
#ifdef RPC_DEBUG
rpc_show_tasks
();
#endif
BUG
();
}
}
return
rpc_destroy_client
(
clnt
);
return
rpc_destroy_client
(
clnt
);
}
}
/*
/*
*
Delet
e an RPC client
*
Fre
e an RPC client
*/
*/
int
static
void
rpc_
destroy_client
(
struct
rpc_clnt
*
clnt
)
rpc_
free_client
(
struct
kref
*
kref
)
{
{
if
(
!
atomic_dec_and_test
(
&
clnt
->
cl_count
))
struct
rpc_clnt
*
clnt
=
container_of
(
kref
,
struct
rpc_clnt
,
cl_kref
);
return
1
;
BUG_ON
(
atomic_read
(
&
clnt
->
cl_users
)
!=
0
);
dprintk
(
"RPC: destroying %s client for %s
\n
"
,
dprintk
(
"RPC: destroying %s client for %s
\n
"
,
clnt
->
cl_protname
,
clnt
->
cl_server
);
clnt
->
cl_protname
,
clnt
->
cl_server
);
...
@@ -368,23 +357,33 @@ out_free:
...
@@ -368,23 +357,33 @@ out_free:
clnt
->
cl_metrics
=
NULL
;
clnt
->
cl_metrics
=
NULL
;
xprt_put
(
clnt
->
cl_xprt
);
xprt_put
(
clnt
->
cl_xprt
);
kfree
(
clnt
);
kfree
(
clnt
);
return
0
;
}
}
/*
/*
* Release
an
RPC client
* Release
reference to the
RPC client
*/
*/
void
void
rpc_release_client
(
struct
rpc_clnt
*
clnt
)
rpc_release_client
(
struct
rpc_clnt
*
clnt
)
{
{
dprintk
(
"RPC: rpc_release_client(%p, %d)
\n
"
,
dprintk
(
"RPC: rpc_release_client(%p)
\n
"
,
clnt
);
clnt
,
atomic_read
(
&
clnt
->
cl_users
));
if
(
!
atomic_dec_and_test
(
&
clnt
->
cl_users
))
if
(
list_empty
(
&
clnt
->
cl_tasks
))
return
;
wake_up
(
&
destroy_wait
);
wake_up
(
&
destroy_wait
);
if
(
clnt
->
cl_oneshot
||
clnt
->
cl_dead
)
if
(
clnt
->
cl_oneshot
||
clnt
->
cl_dead
)
rpc_destroy_client
(
clnt
);
rpc_destroy_client
(
clnt
);
kref_put
(
&
clnt
->
cl_kref
,
rpc_free_client
);
}
/*
* Delete an RPC client
*/
int
rpc_destroy_client
(
struct
rpc_clnt
*
clnt
)
{
if
(
!
atomic_dec_and_test
(
&
clnt
->
cl_count
))
return
1
;
kref_put
(
&
clnt
->
cl_kref
,
rpc_free_client
);
return
0
;
}
}
/**
/**
...
...
net/sunrpc/rpc_pipe.c
View file @
34f52e35
...
@@ -344,7 +344,7 @@ rpc_info_open(struct inode *inode, struct file *file)
...
@@ -344,7 +344,7 @@ rpc_info_open(struct inode *inode, struct file *file)
mutex_lock
(
&
inode
->
i_mutex
);
mutex_lock
(
&
inode
->
i_mutex
);
clnt
=
RPC_I
(
inode
)
->
private
;
clnt
=
RPC_I
(
inode
)
->
private
;
if
(
clnt
)
{
if
(
clnt
)
{
atomic_inc
(
&
clnt
->
cl_users
);
kref_get
(
&
clnt
->
cl_kref
);
m
->
private
=
clnt
;
m
->
private
=
clnt
;
}
else
{
}
else
{
single_release
(
inode
,
file
);
single_release
(
inode
,
file
);
...
...
net/sunrpc/sched.c
View file @
34f52e35
...
@@ -846,7 +846,7 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, cons
...
@@ -846,7 +846,7 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, cons
task
->
tk_workqueue
=
rpciod_workqueue
;
task
->
tk_workqueue
=
rpciod_workqueue
;
if
(
clnt
)
{
if
(
clnt
)
{
atomic_inc
(
&
clnt
->
cl_users
);
kref_get
(
&
clnt
->
cl_kref
);
if
(
clnt
->
cl_softrtry
)
if
(
clnt
->
cl_softrtry
)
task
->
tk_flags
|=
RPC_TASK_SOFT
;
task
->
tk_flags
|=
RPC_TASK_SOFT
;
if
(
!
clnt
->
cl_intr
)
if
(
!
clnt
->
cl_intr
)
...
@@ -898,9 +898,7 @@ out:
...
@@ -898,9 +898,7 @@ out:
cleanup:
cleanup:
/* Check whether to release the client */
/* Check whether to release the client */
if
(
clnt
)
{
if
(
clnt
)
{
printk
(
"rpc_new_task: failed, users=%d, oneshot=%d
\n
"
,
kref_get
(
&
clnt
->
cl_kref
);
/* pretend we were used ... */
atomic_read
(
&
clnt
->
cl_users
),
clnt
->
cl_oneshot
);
atomic_inc
(
&
clnt
->
cl_users
);
/* pretend we were used ... */
rpc_release_client
(
clnt
);
rpc_release_client
(
clnt
);
}
}
goto
out
;
goto
out
;
...
...
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