diff --git a/kmod/src/buddy.c b/kmod/src/buddy.c index 52ff738f..f2edb18b 100644 --- a/kmod/src/buddy.c +++ b/kmod/src/buddy.c @@ -594,89 +594,6 @@ int scoutfs_buddy_alloc(struct super_block *sb, u64 *blkno, int order) return alloc_region(sb, blkno, order, 0, REGION_BUDDY); } -static int bitmap_dirty(struct super_block *sb, u64 blkno) -{ - struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); - struct buffer_head *bh; - - /* mkfs should have ensured that there's bitmap blocks */ - /* XXX corruption */ - if (sbi->super.buddy_bm_ref.blkno == 0) - return -EIO; - - /* dirty the bitmap block */ - bh = scoutfs_block_dirty_ref(sb, &sbi->super.buddy_bm_ref); - if (IS_ERR(bh)) - return PTR_ERR(bh); - - scoutfs_block_put(bh); - return 0; -} - -static int buddy_dirty(struct super_block *sb, u64 blkno, int order) -{ - struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); - struct scoutfs_super_block *super = &sbi->super; - struct scoutfs_buddy_indirect *ind; - struct buffer_head *ind_bh = NULL; - struct buffer_head *bh = NULL; - int ret; - int sl; - - mutex_lock(&sbi->buddy_mutex); - - /* mkfs should have ensured that there's indirect blocks */ - if (sbi->super.buddy_ind_ref.blkno == 0) { - ret = -EIO; - goto out; - } - - /* get the dirty indirect block */ - ind_bh = scoutfs_block_dirty_ref(sb, &sbi->super.buddy_ind_ref); - if (IS_ERR(ind_bh)) { - ret = PTR_ERR(ind_bh); - goto out; - } - ind = bh_data(ind_bh); - - sl = indirect_slot(super, blkno); - bh = dirty_buddy_block(sb, sl, &ind->slots[sl]); - if (IS_ERR(bh)) - ret = PTR_ERR(bh); - else - ret = 0; -out: - mutex_unlock(&sbi->buddy_mutex); - scoutfs_block_put(ind_bh); - scoutfs_block_put(bh); - - return ret; -} - - -/* - * Create dirty cow copies of the bitmap, indirect, and buddy blocks - * so that a free of the given extent in the current transaction is - * guaranteed to succeed. - * - * This is only meant for buddy allocators who are complicated enough - * to need help avoiding error conditions. - */ -int scoutfs_buddy_dirty(struct super_block *sb, u64 blkno, int order) -{ - struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); - struct scoutfs_super_block *super = &sbi->super; - - switch(blkno_region(super, blkno)) { - case REGION_BM: - return bitmap_dirty(sb, blkno); - case REGION_BUDDY: - return buddy_dirty(sb, blkno, order); - } - - return 0; -} - /* * The block layer allocates from the same region as an existing blkno * when it's allocating for cow. diff --git a/kmod/src/buddy.h b/kmod/src/buddy.h index 8397aa12..b4e5b2f6 100644 --- a/kmod/src/buddy.h +++ b/kmod/src/buddy.h @@ -4,7 +4,6 @@ int scoutfs_buddy_alloc(struct super_block *sb, u64 *blkno, int order); int scoutfs_buddy_alloc_same(struct super_block *sb, u64 *blkno, int order, u64 existing); -int scoutfs_buddy_dirty(struct super_block *sb, u64 blkno, int order); int scoutfs_buddy_free(struct super_block *sb, u64 blkno, int order); #endif