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

Commit 5dd4056d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jan Kara
Browse files

dquot: cleanup space allocation / freeing routines



Get rid of the alloc_space, free_space, reserve_space, claim_space and
release_rsv dquot operations - they are always called from the filesystem
and if a filesystem really needs their own (which none currently does)
it can just call into it's own routine directly.

Move shared logic into the common __dquot_alloc_space,
dquot_claim_space_nodirty and __dquot_free_space low-level methods,
and rationalize the wrappers around it to move as much as possible
code into the common block for CONFIG_QUOTA vs not.  Also rename
all these helpers to be named dquot_* instead of vfs_dq_*.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 49792c80
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -462,9 +462,7 @@ in sys_read() and friends.
prototypes:
prototypes:
	int (*initialize) (struct inode *, int);
	int (*initialize) (struct inode *, int);
	int (*drop) (struct inode *);
	int (*drop) (struct inode *);
	int (*alloc_space) (struct inode *, qsize_t, int);
	int (*alloc_inode) (const struct inode *, unsigned long);
	int (*alloc_inode) (const struct inode *, unsigned long);
	int (*free_space) (struct inode *, qsize_t);
	int (*free_inode) (const struct inode *, unsigned long);
	int (*free_inode) (const struct inode *, unsigned long);
	int (*transfer) (struct inode *, struct iattr *);
	int (*transfer) (struct inode *, struct iattr *);
	int (*write_dquot) (struct dquot *);
	int (*write_dquot) (struct dquot *);
@@ -481,9 +479,7 @@ What filesystem should expect from the generic quota functions:
		FS recursion	Held locks when called
		FS recursion	Held locks when called
initialize:	yes		maybe dqonoff_sem
initialize:	yes		maybe dqonoff_sem
drop:		yes		-
drop:		yes		-
alloc_space:	->mark_dirty()	-
alloc_inode:	->mark_dirty()	-
alloc_inode:	->mark_dirty()	-
free_space:	->mark_dirty()	-
free_inode:	->mark_dirty()	-
free_inode:	->mark_dirty()	-
transfer:	yes		-
transfer:	yes		-
write_dquot:	yes		dqonoff_sem or dqptr_sem
write_dquot:	yes		dqonoff_sem or dqptr_sem
@@ -495,7 +491,7 @@ write_info: yes dqonoff_sem
FS recursion means calling ->quota_read() and ->quota_write() from superblock
FS recursion means calling ->quota_read() and ->quota_write() from superblock
operations.
operations.


->alloc_space(), ->alloc_inode(), ->free_space(), ->free_inode() are called
->alloc_inode(), ->free_inode() are called
only directly by the filesystem and do not call any fs functions only
only directly by the filesystem and do not call any fs functions only
the ->mark_dirty() operation.
the ->mark_dirty() operation.


+7 −5
Original line number Original line Diff line number Diff line
@@ -570,7 +570,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long block,
error_return:
error_return:
	brelse(bitmap_bh);
	brelse(bitmap_bh);
	release_blocks(sb, freed);
	release_blocks(sb, freed);
	vfs_dq_free_block(inode, freed);
	dquot_free_block(inode, freed);
}
}


/**
/**
@@ -1236,6 +1236,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
	unsigned short windowsz = 0;
	unsigned short windowsz = 0;
	unsigned long ngroups;
	unsigned long ngroups;
	unsigned long num = *count;
	unsigned long num = *count;
	int ret;


	*errp = -ENOSPC;
	*errp = -ENOSPC;
	sb = inode->i_sb;
	sb = inode->i_sb;
@@ -1247,8 +1248,9 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
	/*
	/*
	 * Check quota for allocation of this block.
	 * Check quota for allocation of this block.
	 */
	 */
	if (vfs_dq_alloc_block(inode, num)) {
	ret = dquot_alloc_block(inode, num);
		*errp = -EDQUOT;
	if (ret) {
		*errp = ret;
		return 0;
		return 0;
	}
	}


@@ -1409,7 +1411,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,


	*errp = 0;
	*errp = 0;
	brelse(bitmap_bh);
	brelse(bitmap_bh);
	vfs_dq_free_block(inode, *count-num);
	dquot_free_block(inode, *count-num);
	*count = num;
	*count = num;
	return ret_block;
	return ret_block;


@@ -1420,7 +1422,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
	 * Undo the block allocation
	 * Undo the block allocation
	 */
	 */
	if (!performed_allocation)
	if (!performed_allocation)
		vfs_dq_free_block(inode, *count);
		dquot_free_block(inode, *count);
	brelse(bitmap_bh);
	brelse(bitmap_bh);
	return 0;
	return 0;
}
}
+5 −5
Original line number Original line Diff line number Diff line
@@ -644,8 +644,8 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
				   the inode.  */
				   the inode.  */
				ea_bdebug(new_bh, "reusing block");
				ea_bdebug(new_bh, "reusing block");


				error = -EDQUOT;
				error = dquot_alloc_block(inode, 1);
				if (vfs_dq_alloc_block(inode, 1)) {
				if (error) {
					unlock_buffer(new_bh);
					unlock_buffer(new_bh);
					goto cleanup;
					goto cleanup;
				}
				}
@@ -702,7 +702,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
		 * as if nothing happened and cleanup the unused block */
		 * as if nothing happened and cleanup the unused block */
		if (error && error != -ENOSPC) {
		if (error && error != -ENOSPC) {
			if (new_bh && new_bh != old_bh)
			if (new_bh && new_bh != old_bh)
				vfs_dq_free_block(inode, 1);
				dquot_free_block(inode, 1);
			goto cleanup;
			goto cleanup;
		}
		}
	} else
	} else
@@ -734,7 +734,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
			le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
			le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
			if (ce)
			if (ce)
				mb_cache_entry_release(ce);
				mb_cache_entry_release(ce);
			vfs_dq_free_block(inode, 1);
			dquot_free_block(inode, 1);
			mark_buffer_dirty(old_bh);
			mark_buffer_dirty(old_bh);
			ea_bdebug(old_bh, "refcount now=%d",
			ea_bdebug(old_bh, "refcount now=%d",
				le32_to_cpu(HDR(old_bh)->h_refcount));
				le32_to_cpu(HDR(old_bh)->h_refcount));
@@ -797,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode)
		mark_buffer_dirty(bh);
		mark_buffer_dirty(bh);
		if (IS_SYNC(inode))
		if (IS_SYNC(inode))
			sync_dirty_buffer(bh);
			sync_dirty_buffer(bh);
		vfs_dq_free_block(inode, 1);
		dquot_free_block(inode, 1);
	}
	}
	EXT2_I(inode)->i_file_acl = 0;
	EXT2_I(inode)->i_file_acl = 0;


+6 −5
Original line number Original line Diff line number Diff line
@@ -676,7 +676,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode,
	}
	}
	ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
	ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
	if (dquot_freed_blocks)
	if (dquot_freed_blocks)
		vfs_dq_free_block(inode, dquot_freed_blocks);
		dquot_free_block(inode, dquot_freed_blocks);
	return;
	return;
}
}


@@ -1502,8 +1502,9 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
	/*
	/*
	 * Check quota for allocation of this block.
	 * Check quota for allocation of this block.
	 */
	 */
	if (vfs_dq_alloc_block(inode, num)) {
	err = dquot_alloc_block(inode, num);
		*errp = -EDQUOT;
	if (err) {
		*errp = err;
		return 0;
		return 0;
	}
	}


@@ -1713,7 +1714,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,


	*errp = 0;
	*errp = 0;
	brelse(bitmap_bh);
	brelse(bitmap_bh);
	vfs_dq_free_block(inode, *count-num);
	dquot_free_block(inode, *count-num);
	*count = num;
	*count = num;
	return ret_block;
	return ret_block;


@@ -1728,7 +1729,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
	 * Undo the block allocation
	 * Undo the block allocation
	 */
	 */
	if (!performed_allocation)
	if (!performed_allocation)
		vfs_dq_free_block(inode, *count);
		dquot_free_block(inode, *count);
	brelse(bitmap_bh);
	brelse(bitmap_bh);
	return 0;
	return 0;
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -3336,7 +3336,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
 * i_size has been changed by generic_commit_write() and we thus need
 * i_size has been changed by generic_commit_write() and we thus need
 * to include the updated inode in the current transaction.
 * to include the updated inode in the current transaction.
 *
 *
 * Also, vfs_dq_alloc_space() will always dirty the inode when blocks
 * Also, dquot_alloc_space() will always dirty the inode when blocks
 * are allocated to the file.
 * are allocated to the file.
 *
 *
 * If the inode is marked synchronous, we don't honour that here - doing
 * If the inode is marked synchronous, we don't honour that here - doing
Loading