Commit 55702c2a authored by Hans Reiser's avatar Hans Reiser Committed by Linus Torvalds

[PATCH] 06-kmalloc_cleanup.diff

   Convert all the code to use reiserfs_{kmalloc,kfree}. Remove all extra
   reiserfs_{kmalloc,kfree} overhead if CONFIG_REISERFS_CHECK is not set.
parent e79e5fce
......@@ -115,13 +115,13 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
if (d_reclen <= 32) {
local_buf = small_buf ;
} else {
local_buf = kmalloc(d_reclen, GFP_NOFS) ;
local_buf = reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb) ;
if (!local_buf) {
pathrelse (&path_to_entry);
return -ENOMEM ;
}
if (item_moved (&tmp_ih, &path_to_entry)) {
kfree(local_buf) ;
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
goto research;
}
}
......@@ -133,12 +133,12 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
if (filldir (dirent, local_buf, d_reclen, d_off, d_ino,
DT_UNKNOWN) < 0) {
if (local_buf != small_buf) {
kfree(local_buf) ;
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
}
goto end;
}
if (local_buf != small_buf) {
kfree(local_buf) ;
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
}
// next entry should be looked for with such offset
......
......@@ -1979,7 +1979,7 @@ static int get_neighbors(
return CARRY_ON;
}
#ifdef CONFIG_REISERFS_CHECK
void * reiserfs_kmalloc (size_t size, int flags, struct super_block * s)
{
void * vp;
......@@ -2007,6 +2007,7 @@ void reiserfs_kfree (const void * vp, size_t size, struct super_block * s)
reiserfs_warning ("vs-8302: reiserfs_kfree: allocated memory %d\n", s->u.reiserfs_sb.s_kmallocs);
}
#endif
static int get_virtual_node_size (struct super_block * sb, struct buffer_head * bh)
......
......@@ -118,13 +118,13 @@ allocate_bitmap_node(struct super_block *p_s_sb) {
struct reiserfs_bitmap_node *bn ;
static int id = 0 ;
bn = kmalloc(sizeof(struct reiserfs_bitmap_node), GFP_NOFS) ;
bn = reiserfs_kmalloc(sizeof(struct reiserfs_bitmap_node), GFP_NOFS, p_s_sb) ;
if (!bn) {
return NULL ;
}
bn->data = kmalloc(p_s_sb->s_blocksize, GFP_NOFS) ;
bn->data = reiserfs_kmalloc(p_s_sb->s_blocksize, GFP_NOFS, p_s_sb) ;
if (!bn->data) {
kfree(bn) ;
reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
return NULL ;
}
bn->id = id++ ;
......@@ -159,8 +159,8 @@ static inline void free_bitmap_node(struct super_block *p_s_sb,
struct reiserfs_bitmap_node *bn) {
SB_JOURNAL(p_s_sb)->j_used_bitmap_nodes-- ;
if (SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) {
kfree(bn->data) ;
kfree(bn) ;
reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb) ;
reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
} else {
list_add(&bn->list, &SB_JOURNAL(p_s_sb)->j_bitmap_nodes) ;
SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes++ ;
......@@ -228,8 +228,8 @@ static int free_bitmap_nodes(struct super_block *p_s_sb) {
while(next != &SB_JOURNAL(p_s_sb)->j_bitmap_nodes) {
bn = list_entry(next, struct reiserfs_bitmap_node, list) ;
list_del(next) ;
kfree(bn->data) ;
kfree(bn) ;
reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb) ;
reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
next = SB_JOURNAL(p_s_sb)->j_bitmap_nodes.next ;
SB_JOURNAL(p_s_sb)->j_free_bitmap_nodes-- ;
}
......@@ -1507,13 +1507,13 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
}
trans_id = le32_to_cpu(desc->j_trans_id) ;
/* now we know we've got a good transaction, and it was inside the valid time ranges */
log_blocks = kmalloc(le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), GFP_NOFS) ;
real_blocks = kmalloc(le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), GFP_NOFS) ;
log_blocks = reiserfs_kmalloc(le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), GFP_NOFS, p_s_sb) ;
real_blocks = reiserfs_kmalloc(le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), GFP_NOFS, p_s_sb) ;
if (!log_blocks || !real_blocks) {
brelse(c_bh) ;
brelse(d_bh) ;
kfree(log_blocks) ;
kfree(real_blocks) ;
reiserfs_kfree(log_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
reiserfs_kfree(real_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
reiserfs_warning("journal-1169: kmalloc failed, unable to mount FS\n") ;
return -1 ;
}
......@@ -1532,8 +1532,8 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
brelse_array(real_blocks, i) ;
brelse(c_bh) ;
brelse(d_bh) ;
kfree(log_blocks) ;
kfree(real_blocks) ;
reiserfs_kfree(log_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
reiserfs_kfree(real_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
return -1 ;
}
}
......@@ -1547,8 +1547,8 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
brelse_array(real_blocks, le32_to_cpu(desc->j_len)) ;
brelse(c_bh) ;
brelse(d_bh) ;
kfree(log_blocks) ;
kfree(real_blocks) ;
reiserfs_kfree(log_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
reiserfs_kfree(real_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
return -1 ;
}
memcpy(real_blocks[i]->b_data, log_blocks[i]->b_data, real_blocks[i]->b_size) ;
......@@ -1567,8 +1567,8 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
brelse_array(real_blocks + i, le32_to_cpu(desc->j_len) - i) ;
brelse(c_bh) ;
brelse(d_bh) ;
kfree(log_blocks) ;
kfree(real_blocks) ;
reiserfs_kfree(log_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
reiserfs_kfree(real_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
return -1 ;
}
brelse(real_blocks[i]) ;
......@@ -1584,8 +1584,8 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
SB_JOURNAL(p_s_sb)->j_trans_id = trans_id + 1;
brelse(c_bh) ;
brelse(d_bh) ;
kfree(log_blocks) ;
kfree(real_blocks) ;
reiserfs_kfree(log_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
reiserfs_kfree(real_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
return 0 ;
}
......@@ -1785,7 +1785,7 @@ static void reiserfs_journal_commit_task_func(struct reiserfs_journal_commit_tas
atomic_read(&(jl->j_commit_left)) == 0) {
kupdate_one_transaction(ct->p_s_sb, jl) ;
}
kfree(ct->self) ;
reiserfs_kfree(ct->self, sizeof(struct reiserfs_journal_commit_task), ct->p_s_sb) ;
}
static void setup_commit_task_arg(struct reiserfs_journal_commit_task *ct,
......@@ -1809,7 +1809,7 @@ static void commit_flush_async(struct super_block *p_s_sb, int jindex) {
/* using GFP_NOFS, GFP_KERNEL could try to flush inodes, which will try
** to start/join a transaction, which will deadlock
*/
ct = kmalloc(sizeof(struct reiserfs_journal_commit_task), GFP_NOFS) ;
ct = reiserfs_kmalloc(sizeof(struct reiserfs_journal_commit_task), GFP_NOFS, p_s_sb) ;
if (ct) {
setup_commit_task_arg(ct, p_s_sb, jindex) ;
queue_task(&(ct->task), &reiserfs_commit_thread_tq);
......
......@@ -895,7 +895,7 @@ static int reiserfs_symlink (struct inode * dir, struct dentry * dentry, const c
return -ENAMETOOLONG;
}
name = kmalloc (item_len, GFP_NOFS);
name = reiserfs_kmalloc (item_len, GFP_NOFS, dir->i_sb);
if (!name) {
iput(inode) ;
return -ENOMEM;
......@@ -908,7 +908,7 @@ static int reiserfs_symlink (struct inode * dir, struct dentry * dentry, const c
inode = reiserfs_new_inode (&th, dir, S_IFLNK | S_IRWXUGO, name, strlen (symname), dentry,
inode, &retval);
kfree (name);
reiserfs_kfree (name, item_len, dir->i_sb);
if (inode == 0) { /* reiserfs_new_inode iputs for us */
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
......
......@@ -1927,8 +1927,14 @@ void wait_buffer_until_released (const struct buffer_head * bh);
struct buffer_head * reiserfs_bread (struct super_block *super, int n_block);
/* fix_nodes.c */
#ifdef CONFIG_REISERFS_CHECK
void * reiserfs_kmalloc (size_t size, int flags, struct super_block * s);
void reiserfs_kfree (const void * vp, size_t size, struct super_block * s);
#else
#define reiserfs_kmalloc(x, y, z) kmalloc(x, y)
#define reiserfs_kfree(x, y, z) kfree(x)
#endif
int fix_nodes (int n_op_mode, struct tree_balance * p_s_tb,
struct item_head * p_s_ins_ih, const void *);
void unfix_nodes (struct tree_balance *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment