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
nexedi
linux
Commits
04806257
Commit
04806257
authored
Apr 22, 2004
by
Christoph Hellwig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[XFS] use kmem_alloc for noaddr buffers
SGI Modid: xfs-linux:xfs-kern:167609a
parent
347f6162
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
43 deletions
+47
-43
fs/xfs/linux/xfs_buf.c
fs/xfs/linux/xfs_buf.c
+47
-43
No files found.
fs/xfs/linux/xfs_buf.c
View file @
04806257
...
...
@@ -334,10 +334,14 @@ pagebuf_free(
if
(
pb
->
pb_flags
&
_PBF_MEM_ALLOCATED
)
{
if
(
pb
->
pb_pages
)
{
/* release the pages in the address list */
if
((
pb
->
pb_pages
[
0
])
&&
(
pb
->
pb_flags
&
_PBF_MEM_SLAB
))
{
kfree
(
pb
->
pb_addr
);
if
(
pb
->
pb_flags
&
_PBF_MEM_SLAB
)
{
/*
* XXX: bp->pb_count_desired might be incorrect
* (see pagebuf_associate_memory for details),
* but fortunately the Linux version of
* kmem_free ignores the len argument..
*/
kmem_free
(
pb
->
pb_addr
,
pb
->
pb_count_desired
);
}
else
{
_pagebuf_freepages
(
pb
);
}
...
...
@@ -843,54 +847,54 @@ pagebuf_associate_memory(
return
0
;
}
page
_buf_t
*
xfs
_buf_t
*
pagebuf_get_no_daddr
(
size_t
len
,
pb_target
_t
*
target
)
xfs_buftarg
_t
*
target
)
{
int
rval
;
void
*
rmem
=
NULL
;
page_buf_flags_t
flags
=
PBF_FORCEIO
;
page_buf_t
*
pb
;
size_t
tlen
=
0
;
size_t
malloc_len
=
len
;
xfs_buf_t
*
bp
;
void
*
data
;
int
error
;
if
(
unlikely
(
len
>
0x20000
))
return
NULL
;
pb
=
pagebuf_allocate
(
flags
);
if
(
!
pb
)
return
NULL
;
_pagebuf_initialize
(
pb
,
target
,
0
,
len
,
flags
);
do
{
if
(
tlen
==
0
)
{
tlen
=
len
;
/* first time */
}
else
{
kfree
(
rmem
);
/* free the mem from the previous try */
tlen
<<=
1
;
/* double the size and try again */
}
if
((
rmem
=
kmalloc
(
tlen
,
GFP_KERNEL
))
==
0
)
{
pagebuf_free
(
pb
);
return
NULL
;
}
}
while
((
size_t
)
rmem
!=
((
size_t
)
rmem
&
~
target
->
pbr_smask
));
if
((
rval
=
pagebuf_associate_memory
(
pb
,
rmem
,
len
))
!=
0
)
{
kfree
(
rmem
);
pagebuf_free
(
pb
);
return
NULL
;
goto
fail
;
bp
=
pagebuf_allocate
(
0
);
if
(
unlikely
(
bp
==
NULL
))
goto
fail
;
_pagebuf_initialize
(
bp
,
target
,
0
,
len
,
PBF_FORCEIO
);
try_again:
data
=
kmem_alloc
(
malloc_len
,
KM_SLEEP
);
if
(
unlikely
(
data
==
NULL
))
goto
fail_free_buf
;
/* check whether alignment matches.. */
if
((
__psunsigned_t
)
data
!=
((
__psunsigned_t
)
data
&
~
target
->
pbr_smask
))
{
/* .. else double the size and try again */
kmem_free
(
data
,
malloc_len
);
malloc_len
<<=
1
;
goto
try_again
;
}
/* otherwise pagebuf_free just ignores it */
pb
->
pb_flags
|=
(
_PBF_MEM_ALLOCATED
|
_PBF_MEM_SLAB
);
PB_CLEAR_OWNER
(
pb
);
up
(
&
pb
->
pb_sema
);
/* Return unlocked pagebuf */
PB_TRACE
(
pb
,
"no_daddr"
,
rmem
);
error
=
pagebuf_associate_memory
(
bp
,
data
,
len
);
if
(
error
)
goto
fail_free_mem
;
bp
->
pb_flags
|=
(
_PBF_MEM_ALLOCATED
|
_PBF_MEM_SLAB
);
return
pb
;
}
pagebuf_unlock
(
bp
);
PB_TRACE
(
bp
,
"no_daddr"
,
data
);
return
bp
;
fail_free_mem:
kmem_free
(
data
,
malloc_len
);
fail_free_buf:
pagebuf_free
(
bp
);
fail:
return
NULL
;
}
/*
* pagebuf_hold
...
...
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