Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22b970495
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22b970495
Commits
1dddda86
Commit
1dddda86
authored
9 years ago
by
Trond Myklebust
Browse files
Options
Downloads
Patches
Plain Diff
SUNRPC: Clean up allocation and freeing of back channel requests
Signed-off-by:
Trond Myklebust
<
trond.myklebust@primarydata.com
>
parent
0f419791
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
net/sunrpc/backchannel_rqst.c
+55
-40
55 additions, 40 deletions
net/sunrpc/backchannel_rqst.c
with
55 additions
and
40 deletions
net/sunrpc/backchannel_rqst.c
+
55
−
40
View file @
1dddda86
...
...
@@ -67,6 +67,55 @@ static void xprt_free_allocation(struct rpc_rqst *req)
kfree
(
req
);
}
static
int
xprt_alloc_xdr_buf
(
struct
xdr_buf
*
buf
,
gfp_t
gfp_flags
)
{
struct
page
*
page
;
/* Preallocate one XDR receive buffer */
page
=
alloc_page
(
gfp_flags
);
if
(
page
==
NULL
)
return
-
ENOMEM
;
buf
->
head
[
0
].
iov_base
=
page_address
(
page
);
buf
->
head
[
0
].
iov_len
=
PAGE_SIZE
;
buf
->
tail
[
0
].
iov_base
=
NULL
;
buf
->
tail
[
0
].
iov_len
=
0
;
buf
->
page_len
=
0
;
buf
->
len
=
0
;
buf
->
buflen
=
PAGE_SIZE
;
return
0
;
}
static
struct
rpc_rqst
*
xprt_alloc_bc_req
(
struct
rpc_xprt
*
xprt
,
gfp_t
gfp_flags
)
{
struct
rpc_rqst
*
req
;
/* Pre-allocate one backchannel rpc_rqst */
req
=
kzalloc
(
sizeof
(
*
req
),
gfp_flags
);
if
(
req
==
NULL
)
return
NULL
;
req
->
rq_xprt
=
xprt
;
INIT_LIST_HEAD
(
&
req
->
rq_list
);
INIT_LIST_HEAD
(
&
req
->
rq_bc_list
);
/* Preallocate one XDR receive buffer */
if
(
xprt_alloc_xdr_buf
(
&
req
->
rq_rcv_buf
,
gfp_flags
)
<
0
)
{
printk
(
KERN_ERR
"Failed to create bc receive xbuf
\n
"
);
goto
out_free
;
}
req
->
rq_rcv_buf
.
len
=
PAGE_SIZE
;
/* Preallocate one XDR send buffer */
if
(
xprt_alloc_xdr_buf
(
&
req
->
rq_snd_buf
,
gfp_flags
)
<
0
)
{
printk
(
KERN_ERR
"Failed to create bc snd xbuf
\n
"
);
goto
out_free
;
}
return
req
;
out_free:
xprt_free_allocation
(
req
);
return
NULL
;
}
/*
* Preallocate up to min_reqs structures and related buffers for use
* by the backchannel. This function can be called multiple times
...
...
@@ -87,9 +136,7 @@ static void xprt_free_allocation(struct rpc_rqst *req)
*/
int
xprt_setup_backchannel
(
struct
rpc_xprt
*
xprt
,
unsigned
int
min_reqs
)
{
struct
page
*
page_rcv
=
NULL
,
*
page_snd
=
NULL
;
struct
xdr_buf
*
xbufp
=
NULL
;
struct
rpc_rqst
*
req
,
*
tmp
;
struct
rpc_rqst
*
req
;
struct
list_head
tmp_list
;
int
i
;
...
...
@@ -106,7 +153,7 @@ int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
INIT_LIST_HEAD
(
&
tmp_list
);
for
(
i
=
0
;
i
<
min_reqs
;
i
++
)
{
/* Pre-allocate one backchannel rpc_rqst */
req
=
kzalloc
(
sizeof
(
struct
rpc_rqst
)
,
GFP_KERNEL
);
req
=
xprt_alloc_bc_req
(
xprt
,
GFP_KERNEL
);
if
(
req
==
NULL
)
{
printk
(
KERN_ERR
"Failed to create bc rpc_rqst
\n
"
);
goto
out_free
;
...
...
@@ -115,41 +162,6 @@ int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
/* Add the allocated buffer to the tmp list */
dprintk
(
"RPC: adding req= %p
\n
"
,
req
);
list_add
(
&
req
->
rq_bc_pa_list
,
&
tmp_list
);
req
->
rq_xprt
=
xprt
;
INIT_LIST_HEAD
(
&
req
->
rq_list
);
INIT_LIST_HEAD
(
&
req
->
rq_bc_list
);
/* Preallocate one XDR receive buffer */
page_rcv
=
alloc_page
(
GFP_KERNEL
);
if
(
page_rcv
==
NULL
)
{
printk
(
KERN_ERR
"Failed to create bc receive xbuf
\n
"
);
goto
out_free
;
}
xbufp
=
&
req
->
rq_rcv_buf
;
xbufp
->
head
[
0
].
iov_base
=
page_address
(
page_rcv
);
xbufp
->
head
[
0
].
iov_len
=
PAGE_SIZE
;
xbufp
->
tail
[
0
].
iov_base
=
NULL
;
xbufp
->
tail
[
0
].
iov_len
=
0
;
xbufp
->
page_len
=
0
;
xbufp
->
len
=
PAGE_SIZE
;
xbufp
->
buflen
=
PAGE_SIZE
;
/* Preallocate one XDR send buffer */
page_snd
=
alloc_page
(
GFP_KERNEL
);
if
(
page_snd
==
NULL
)
{
printk
(
KERN_ERR
"Failed to create bc snd xbuf
\n
"
);
goto
out_free
;
}
xbufp
=
&
req
->
rq_snd_buf
;
xbufp
->
head
[
0
].
iov_base
=
page_address
(
page_snd
);
xbufp
->
head
[
0
].
iov_len
=
0
;
xbufp
->
tail
[
0
].
iov_base
=
NULL
;
xbufp
->
tail
[
0
].
iov_len
=
0
;
xbufp
->
page_len
=
0
;
xbufp
->
len
=
0
;
xbufp
->
buflen
=
PAGE_SIZE
;
}
/*
...
...
@@ -167,7 +179,10 @@ int xprt_setup_backchannel(struct rpc_xprt *xprt, unsigned int min_reqs)
/*
* Memory allocation failed, free the temporary list
*/
list_for_each_entry_safe
(
req
,
tmp
,
&
tmp_list
,
rq_bc_pa_list
)
{
while
(
!
list_empty
(
&
tmp_list
))
{
req
=
list_first_entry
(
&
tmp_list
,
struct
rpc_rqst
,
rq_bc_pa_list
);
list_del
(
&
req
->
rq_bc_pa_list
);
xprt_free_allocation
(
req
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment