Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be667377 authored by Ryusuke Konishi's avatar Ryusuke Konishi
Browse files

nilfs2: record used amount of each checkpoint in checkpoint list



This records the number of used blocks per checkpoint in each
checkpoint entry of cpfile.  Even though userland tools can get the
block count via nilfs_get_cpinfo ioctl, it was not updated by the
nilfs2 kernel code.  This fixes the issue and makes it available for
userland tools to calculate used amount per checkpoint.

Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Jiro SEKIBA <jir@unicus.jp>
parent ae191838
Loading
Loading
Loading
Loading
+0 −11
Original line number Original line Diff line number Diff line
@@ -425,17 +425,6 @@ int nilfs_bmap_test_and_clear_dirty(struct nilfs_bmap *bmap)
/*
/*
 * Internal use only
 * Internal use only
 */
 */

void nilfs_bmap_add_blocks(const struct nilfs_bmap *bmap, int n)
{
	inode_add_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n);
}

void nilfs_bmap_sub_blocks(const struct nilfs_bmap *bmap, int n)
{
	inode_sub_bytes(bmap->b_inode, (1 << bmap->b_inode->i_blkbits) * n);
}

__u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
__u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *bmap,
			      const struct buffer_head *bh)
			      const struct buffer_head *bh)
{
{
+0 −3
Original line number Original line Diff line number Diff line
@@ -240,9 +240,6 @@ __u64 nilfs_bmap_data_get_key(const struct nilfs_bmap *,
__u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *, __u64);
__u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *, __u64);
__u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *);
__u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *);


void nilfs_bmap_add_blocks(const struct nilfs_bmap *, int);
void nilfs_bmap_sub_blocks(const struct nilfs_bmap *, int);



/* Assume that bmap semaphore is locked. */
/* Assume that bmap semaphore is locked. */
static inline int nilfs_bmap_dirty(const struct nilfs_bmap *bmap)
static inline int nilfs_bmap_dirty(const struct nilfs_bmap *bmap)
+3 −3
Original line number Original line Diff line number Diff line
@@ -1174,7 +1174,7 @@ static int nilfs_btree_insert(struct nilfs_bmap *btree, __u64 key, __u64 ptr)
	if (ret < 0)
	if (ret < 0)
		goto out;
		goto out;
	nilfs_btree_commit_insert(btree, path, level, key, ptr);
	nilfs_btree_commit_insert(btree, path, level, key, ptr);
	nilfs_bmap_add_blocks(btree, stats.bs_nblocks);
	nilfs_inode_add_blocks(btree->b_inode, stats.bs_nblocks);


 out:
 out:
	nilfs_btree_free_path(path);
	nilfs_btree_free_path(path);
@@ -1511,7 +1511,7 @@ static int nilfs_btree_delete(struct nilfs_bmap *btree, __u64 key)
	if (ret < 0)
	if (ret < 0)
		goto out;
		goto out;
	nilfs_btree_commit_delete(btree, path, level, dat);
	nilfs_btree_commit_delete(btree, path, level, dat);
	nilfs_bmap_sub_blocks(btree, stats.bs_nblocks);
	nilfs_inode_sub_blocks(btree->b_inode, stats.bs_nblocks);


out:
out:
	nilfs_btree_free_path(path);
	nilfs_btree_free_path(path);
@@ -1776,7 +1776,7 @@ int nilfs_btree_convert_and_insert(struct nilfs_bmap *btree,
		return ret;
		return ret;
	nilfs_btree_commit_convert_and_insert(btree, key, ptr, keys, ptrs, n,
	nilfs_btree_commit_convert_and_insert(btree, key, ptr, keys, ptrs, n,
					      di, ni, bh);
					      di, ni, bh);
	nilfs_bmap_add_blocks(btree, stats.bs_nblocks);
	nilfs_inode_add_blocks(btree->b_inode, stats.bs_nblocks);
	return 0;
	return 0;
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -146,7 +146,7 @@ static int nilfs_direct_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr)
		if (NILFS_BMAP_USE_VBN(bmap))
		if (NILFS_BMAP_USE_VBN(bmap))
			nilfs_bmap_set_target_v(bmap, key, req.bpr_ptr);
			nilfs_bmap_set_target_v(bmap, key, req.bpr_ptr);


		nilfs_bmap_add_blocks(bmap, 1);
		nilfs_inode_add_blocks(bmap->b_inode, 1);
	}
	}
	return ret;
	return ret;
}
}
@@ -168,7 +168,7 @@ static int nilfs_direct_delete(struct nilfs_bmap *bmap, __u64 key)
	if (!ret) {
	if (!ret) {
		nilfs_bmap_commit_end_ptr(bmap, &req, dat);
		nilfs_bmap_commit_end_ptr(bmap, &req, dat);
		nilfs_direct_set_ptr(bmap, key, NILFS_BMAP_INVALID_PTR);
		nilfs_direct_set_ptr(bmap, key, NILFS_BMAP_INVALID_PTR);
		nilfs_bmap_sub_blocks(bmap, 1);
		nilfs_inode_sub_blocks(bmap->b_inode, 1);
	}
	}
	return ret;
	return ret;
}
}
+18 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,24 @@ struct nilfs_iget_args {
	int for_gc;
	int for_gc;
};
};


void nilfs_inode_add_blocks(struct inode *inode, int n)
{
	struct nilfs_root *root = NILFS_I(inode)->i_root;

	inode_add_bytes(inode, (1 << inode->i_blkbits) * n);
	if (root)
		atomic_add(n, &root->blocks_count);
}

void nilfs_inode_sub_blocks(struct inode *inode, int n)
{
	struct nilfs_root *root = NILFS_I(inode)->i_root;

	inode_sub_bytes(inode, (1 << inode->i_blkbits) * n);
	if (root)
		atomic_sub(n, &root->blocks_count);
}

/**
/**
 * nilfs_get_block() - get a file block on the filesystem (callback function)
 * nilfs_get_block() - get a file block on the filesystem (callback function)
 * @inode - inode struct of the target file
 * @inode - inode struct of the target file
Loading