aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2015-11-06 19:31:54 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-06 20:50:42 -0500
commitda019954dd821682d6b2a8330c9c90acb943c456 (patch)
tree1a5d72c00aa1ce9e46982c521132a86735a13825
parentb22580948c39d71fb150c1d53148a381011dd109 (diff)
nilfs2: add helper functions to delete blocks from dat file
This adds delete functions for data blocks of metadata files using bitmap based allocator. nilfs_palloc_delete_entry_block() deletes an entry block (e.g. block storing dat entries), and nilfs_palloc_delete_bitmap_block() deletes a bitmap block, respectively. These helpers are intended to be used in the successive change on deallocator of block addresses ("nilfs2: free unused dat file blocks during garbage collection"). Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/nilfs2/alloc.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c
index 5b7ee36f84c7..225b79768865 100644
--- a/fs/nilfs2/alloc.c
+++ b/fs/nilfs2/alloc.c
@@ -236,6 +236,26 @@ static int nilfs_palloc_get_block(struct inode *inode, unsigned long blkoff,
236} 236}
237 237
238/** 238/**
239 * nilfs_palloc_delete_block - delete a block on the persistent allocator file
240 * @inode: inode of metadata file using this allocator
241 * @blkoff: block offset
242 * @prev: nilfs_bh_assoc struct of the last used buffer
243 * @lock: spin lock protecting @prev
244 */
245static int nilfs_palloc_delete_block(struct inode *inode, unsigned long blkoff,
246 struct nilfs_bh_assoc *prev,
247 spinlock_t *lock)
248{
249 spin_lock(lock);
250 if (prev->bh && blkoff == prev->blkoff) {
251 brelse(prev->bh);
252 prev->bh = NULL;
253 }
254 spin_unlock(lock);
255 return nilfs_mdt_delete_block(inode, blkoff);
256}
257
258/**
239 * nilfs_palloc_get_desc_block - get buffer head of a group descriptor block 259 * nilfs_palloc_get_desc_block - get buffer head of a group descriptor block
240 * @inode: inode of metadata file using this allocator 260 * @inode: inode of metadata file using this allocator
241 * @group: group number 261 * @group: group number
@@ -274,6 +294,22 @@ static int nilfs_palloc_get_bitmap_block(struct inode *inode,
274} 294}
275 295
276/** 296/**
297 * nilfs_palloc_delete_bitmap_block - delete a bitmap block
298 * @inode: inode of metadata file using this allocator
299 * @group: group number
300 */
301static int nilfs_palloc_delete_bitmap_block(struct inode *inode,
302 unsigned long group)
303{
304 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
305
306 return nilfs_palloc_delete_block(inode,
307 nilfs_palloc_bitmap_blkoff(inode,
308 group),
309 &cache->prev_bitmap, &cache->lock);
310}
311
312/**
277 * nilfs_palloc_get_entry_block - get buffer head of an entry block 313 * nilfs_palloc_get_entry_block - get buffer head of an entry block
278 * @inode: inode of metadata file using this allocator 314 * @inode: inode of metadata file using this allocator
279 * @nr: serial number of the entry (e.g. inode number) 315 * @nr: serial number of the entry (e.g. inode number)
@@ -292,6 +328,20 @@ int nilfs_palloc_get_entry_block(struct inode *inode, __u64 nr,
292} 328}
293 329
294/** 330/**
331 * nilfs_palloc_delete_entry_block - delete an entry block
332 * @inode: inode of metadata file using this allocator
333 * @nr: serial number of the entry
334 */
335static int nilfs_palloc_delete_entry_block(struct inode *inode, __u64 nr)
336{
337 struct nilfs_palloc_cache *cache = NILFS_MDT(inode)->mi_palloc_cache;
338
339 return nilfs_palloc_delete_block(inode,
340 nilfs_palloc_entry_blkoff(inode, nr),
341 &cache->prev_entry, &cache->lock);
342}
343
344/**
295 * nilfs_palloc_block_get_group_desc - get kernel address of a group descriptor 345 * nilfs_palloc_block_get_group_desc - get kernel address of a group descriptor
296 * @inode: inode of metadata file using this allocator 346 * @inode: inode of metadata file using this allocator
297 * @group: group number 347 * @group: group number