Exemple #1
0
/*
 * Calculate the number of buffer credits needed to write multiple pages in
 * a single ext3 transaction. 
 *
 * Check ext3_writepage_trans_blocks() for detail
 *
 */
static int mlowerfs_ext3_credits_needed(struct inode *inode, __u64 len)
{
	struct super_block *sb = inode->i_sb;
	int _nblock = (int)(len >> sb->s_blocksize_bits); /* Any possible overflow? */
	int nblock = _nblock + 2; /* Two block or more */
	int nindirect = _nblock / EXT3_ADDR_PER_BLOCK(sb) + 2;
	int ndindirect = _nblock / (EXT3_ADDR_PER_BLOCK(sb) * EXT3_ADDR_PER_BLOCK(sb)) + 2;
	int nbitmaps = 1 + nblock + nindirect + ndindirect; /* tindirect */
	int ngdblocks = nbitmaps > EXT3_SB(sb)->s_gdb_count ? EXT3_SB(sb)->s_gdb_count : nbitmaps;
	int ngroups = nbitmaps > EXT3_SB(sb)->s_groups_count ? EXT3_SB(sb)->s_groups_count : nbitmaps;
	int needed = 2; /* inodes + superblock */
	int i = 0;

	if (mlowerfs_ext3_should_journal_data(inode)) {
		needed += nbitmaps;
	}

	needed += ngdblocks + ngroups;

#if defined(CONFIG_QUOTA)
	if (!IS_NOQUOTA(inode)) {
		for (i = 0; i < MAXQUOTAS; i++) {
			if (sb_has_quota_active(sb, i)) {
				needed += EXT3_SINGLEDATA_TRANS_BLOCKS;
			}
		}
	}
#endif
	return needed;
}
Exemple #2
0
static int ext3_block_to_path(struct inode *inode,
			long i_block, int offsets[4], int *boundary)
{
	int ptrs = EXT3_ADDR_PER_BLOCK(inode->i_sb);
	int ptrs_bits = EXT3_ADDR_PER_BLOCK_BITS(inode->i_sb);
	const long direct_blocks = EXT3_NDIR_BLOCKS,
		indirect_blocks = ptrs,
		double_blocks = (1 << (ptrs_bits * 2));
	int n = 0;
	int final = 0;

	if (i_block < 0) {
		ext3_warning (inode->i_sb, "ext3_block_to_path", "block < 0");
	} else if (i_block < direct_blocks) {
		offsets[n++] = i_block;
		final = direct_blocks;