Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 174705
b: refs/heads/master
c: db38d5a
h: refs/heads/master
i:
  174703: 5ac7b26
v: v3
  • Loading branch information
Ryusuke Konishi committed Nov 20, 2009
1 parent 533b8f0 commit 2b4dbc5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 141bbdba9c2c1592d56b019277774099a5412aea
refs/heads/master: db38d5ad323362bfca118b52fe5906f97a69fb45
27 changes: 27 additions & 0 deletions trunk/fs/nilfs2/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,30 @@ int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
}
return 0;
}

void nilfs_palloc_setup_cache(struct inode *inode,
struct nilfs_palloc_cache *cache)
{
NILFS_MDT(inode)->mi_palloc_cache = cache;
spin_lock_init(&cache->lock);
}

void nilfs_palloc_clear_cache(struct inode *inode)
{
struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;

spin_lock(&cache->lock);
brelse(cache->prev_desc.bh);
brelse(cache->prev_bitmap.bh);
brelse(cache->prev_entry.bh);
cache->prev_desc.bh = NULL;
cache->prev_bitmap.bh = NULL;
cache->prev_entry.bh = NULL;
spin_unlock(&cache->lock);
}

void nilfs_palloc_destroy_cache(struct inode *inode)
{
nilfs_palloc_clear_cache(inode);
NILFS_MDT(inode)->mi_palloc_cache = NULL;
}
21 changes: 21 additions & 0 deletions trunk/fs/nilfs2/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,25 @@ int nilfs_palloc_freev(struct inode *, __u64 *, size_t);
#define nilfs_clear_bit_atomic ext2_clear_bit_atomic
#define nilfs_find_next_zero_bit ext2_find_next_zero_bit

/*
* persistent object allocator cache
*/

struct nilfs_bh_assoc {
unsigned long blkoff;
struct buffer_head *bh;
};

struct nilfs_palloc_cache {
spinlock_t lock;
struct nilfs_bh_assoc prev_desc;
struct nilfs_bh_assoc prev_bitmap;
struct nilfs_bh_assoc prev_entry;
};

void nilfs_palloc_setup_cache(struct inode *inode,
struct nilfs_palloc_cache *cache);
void nilfs_palloc_clear_cache(struct inode *inode);
void nilfs_palloc_destroy_cache(struct inode *inode);

#endif /* _NILFS_ALLOC_H */
2 changes: 2 additions & 0 deletions trunk/fs/nilfs2/mdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ void nilfs_mdt_destroy(struct inode *inode)
{
struct nilfs_mdt_info *mdi = NILFS_MDT(inode);

if (mdi->mi_palloc_cache)
nilfs_palloc_destroy_cache(inode);
nilfs_mdt_clear(inode);

kfree(mdi->mi_bgl); /* kfree(NULL) is safe */
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/nilfs2/mdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @mi_entry_size: size of an entry
* @mi_first_entry_offset: offset to the first entry
* @mi_entries_per_block: number of entries in a block
* @mi_palloc_cache: persistent object allocator cache
* @mi_blocks_per_group: number of blocks in a group
* @mi_blocks_per_desc_block: number of blocks per descriptor block
*/
Expand All @@ -46,6 +47,7 @@ struct nilfs_mdt_info {
unsigned mi_entry_size;
unsigned mi_first_entry_offset;
unsigned long mi_entries_per_block;
struct nilfs_palloc_cache *mi_palloc_cache;
unsigned long mi_blocks_per_group;
unsigned long mi_blocks_per_desc_block;
};
Expand Down

0 comments on commit 2b4dbc5

Please sign in to comment.