Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
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
Commits
dd26d857
Commit
dd26d857
authored
Dec 05, 2009
by
Sage Weil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ceph: use kref for ceph_buffer
Signed-off-by:
Sage Weil
<
sage@newdream.net
>
parent
2f2ffd35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
fs/ceph/buffer.c
fs/ceph/buffer.c
+13
-1
fs/ceph/buffer.h
fs/ceph/buffer.h
+7
-11
No files found.
fs/ceph/buffer.c
View file @
dd26d857
...
...
@@ -9,13 +9,25 @@ struct ceph_buffer *ceph_buffer_new(gfp_t gfp)
b
=
kmalloc
(
sizeof
(
*
b
),
gfp
);
if
(
!
b
)
return
NULL
;
atomic_set
(
&
b
->
nref
,
1
);
kref_init
(
&
b
->
kref
);
b
->
vec
.
iov_base
=
NULL
;
b
->
vec
.
iov_len
=
0
;
b
->
alloc_len
=
0
;
return
b
;
}
void
ceph_buffer_release
(
struct
kref
*
kref
)
{
struct
ceph_buffer
*
b
=
container_of
(
kref
,
struct
ceph_buffer
,
kref
);
if
(
b
->
vec
.
iov_base
)
{
if
(
b
->
is_vmalloc
)
vfree
(
b
->
vec
.
iov_base
);
else
kfree
(
b
->
vec
.
iov_base
);
}
kfree
(
b
);
}
int
ceph_buffer_alloc
(
struct
ceph_buffer
*
b
,
int
len
,
gfp_t
gfp
)
{
b
->
vec
.
iov_base
=
kmalloc
(
len
,
gfp
|
__GFP_NOWARN
);
...
...
fs/ceph/buffer.h
View file @
dd26d857
#ifndef __FS_CEPH_BUFFER_H
#define __FS_CEPH_BUFFER_H
#include <linux/kref.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/types.h>
...
...
@@ -13,7 +14,7 @@
* sizes.
*/
struct
ceph_buffer
{
atomic_t
n
ref
;
struct
kref
k
ref
;
struct
kvec
vec
;
size_t
alloc_len
;
bool
is_vmalloc
;
...
...
@@ -24,21 +25,16 @@ int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp);
static
inline
struct
ceph_buffer
*
ceph_buffer_get
(
struct
ceph_buffer
*
b
)
{
atomic_inc
(
&
b
->
n
ref
);
kref_get
(
&
b
->
k
ref
);
return
b
;
}
void
ceph_buffer_release
(
struct
kref
*
kref
);
static
inline
void
ceph_buffer_put
(
struct
ceph_buffer
*
b
)
{
if
(
b
&&
atomic_dec_and_test
(
&
b
->
nref
))
{
if
(
b
->
vec
.
iov_base
)
{
if
(
b
->
is_vmalloc
)
vfree
(
b
->
vec
.
iov_base
);
else
kfree
(
b
->
vec
.
iov_base
);
}
kfree
(
b
);
}
if
(
b
)
kref_put
(
&
b
->
kref
,
ceph_buffer_release
);
}
static
inline
struct
ceph_buffer
*
ceph_buffer_new_alloc
(
int
len
,
gfp_t
gfp
)
...
...
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