projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
file: fix potential buffer overrun in get_fs_free_counts()
[fio.git]
/
smalloc.c
diff --git
a/smalloc.c
b/smalloc.c
index b0173739b49c18254e5a425d58d09e9369a0792e..c8f1642eb54cfc7863182286be03d03599dd4dae 100644
(file)
--- a/
smalloc.c
+++ b/
smalloc.c
@@
-16,6
+16,7
@@
#include "mutex.h"
#include "arch/arch.h"
#include "os/os.h"
#include "mutex.h"
#include "arch/arch.h"
#include "os/os.h"
+#include "smalloc.h"
#define SMALLOC_REDZONE /* define to detect memory corruption */
#define SMALLOC_REDZONE /* define to detect memory corruption */
@@
-30,7
+31,7
@@
#define SMALLOC_POST_RED 0x5aa55aa5U
unsigned int smalloc_pool_size = INITIAL_SIZE;
#define SMALLOC_POST_RED 0x5aa55aa5U
unsigned int smalloc_pool_size = INITIAL_SIZE;
-const int int_mask = sizeof(int) - 1;
+
static
const int int_mask = sizeof(int) - 1;
struct pool {
struct fio_mutex *lock; /* protects this pool */
struct pool {
struct fio_mutex *lock; /* protects this pool */
@@
-52,7
+53,7
@@
struct block_hdr {
static struct pool mp[MAX_POOLS];
static unsigned int nr_pools;
static unsigned int last_pool;
static struct pool mp[MAX_POOLS];
static unsigned int nr_pools;
static unsigned int last_pool;
-static struct fio_
mutex
*lock;
+static struct fio_
rwlock
*lock;
static inline void pool_lock(struct pool *pool)
{
static inline void pool_lock(struct pool *pool)
{
@@
-66,22
+67,22
@@
static inline void pool_unlock(struct pool *pool)
static inline void global_read_lock(void)
{
static inline void global_read_lock(void)
{
- fio_
mutex_down
_read(lock);
+ fio_
rwlock
_read(lock);
}
static inline void global_read_unlock(void)
{
}
static inline void global_read_unlock(void)
{
- fio_
mutex_up_read
(lock);
+ fio_
rwlock_unlock
(lock);
}
static inline void global_write_lock(void)
{
}
static inline void global_write_lock(void)
{
- fio_
mutex_down
_write(lock);
+ fio_
rwlock
_write(lock);
}
static inline void global_write_unlock(void)
{
}
static inline void global_write_unlock(void)
{
- fio_
mutex_up_write
(lock);
+ fio_
rwlock_unlock
(lock);
}
static inline int ptr_valid(struct pool *pool, void *ptr)
}
static inline int ptr_valid(struct pool *pool, void *ptr)
@@
-223,7
+224,7
@@
void sinit(void)
{
int ret;
{
int ret;
- lock = fio_
mutex_rw
_init();
+ lock = fio_
rwlock
_init();
ret = add_pool(&mp[0], INITIAL_SIZE);
assert(!ret);
}
ret = add_pool(&mp[0], INITIAL_SIZE);
assert(!ret);
}
@@
-248,7
+249,7
@@
void scleanup(void)
cleanup_pool(&mp[i]);
if (lock)
cleanup_pool(&mp[i]);
if (lock)
- fio_
mutex
_remove(lock);
+ fio_
rwlock
_remove(lock);
}
#ifdef SMALLOC_REDZONE
}
#ifdef SMALLOC_REDZONE