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

Commit 907f4554 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jan Kara
Browse files

dquot: move dquot initialization responsibility into the filesystem



Currently various places in the VFS call vfs_dq_init directly.  This means
we tie the quota code into the VFS.  Get rid of that and make the
filesystem responsible for the initialization.   For most metadata operations
this is a straight forward move into the methods, but for truncate and
open it's a bit more complicated.

For truncate we currently only call vfs_dq_init for the sys_truncate case
because open already takes care of it for ftruncate and open(O_TRUNC) - the
new code causes an additional vfs_dq_init for those which is harmless.

For open the initialization is moved from do_filp_open into the open method,
which means it happens slightly earlier now, and only for regular files.
The latter is fine because we don't need to initialize it for operations
on special files, and we already do it as part of the namespace operations
for directories.

Add a dquot_file_open helper that filesystems that support generic quotas
can use to fill in ->open.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 9f754758
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ const struct file_operations ext2_file_operations = {
	.compat_ioctl	= ext2_compat_ioctl,
#endif
	.mmap		= generic_file_mmap,
	.open		= generic_file_open,
	.open		= dquot_file_open,
	.release	= ext2_release_file,
	.fsync		= ext2_fsync,
	.splice_read	= generic_file_splice_read,
@@ -87,7 +87,7 @@ const struct file_operations ext2_xip_file_operations = {
	.compat_ioctl	= ext2_compat_ioctl,
#endif
	.mmap		= xip_file_mmap,
	.open		= generic_file_open,
	.open		= dquot_file_open,
	.release	= ext2_release_file,
	.fsync		= ext2_fsync,
};
+5 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ static inline int ext2_inode_is_fast_symlink(struct inode *inode)
 */
void ext2_delete_inode (struct inode * inode)
{
	if (!is_bad_inode(inode))
		vfs_dq_init(inode);
	truncate_inode_pages(&inode->i_data, 0);

	if (is_bad_inode(inode))
@@ -1457,6 +1459,9 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
	error = inode_change_ok(inode, iattr);
	if (error)
		return error;

	if (iattr->ia_valid & ATTR_SIZE)
		vfs_dq_init(inode);
	if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
	    (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
		error = dquot_transfer(inode, iattr);
+34 −17
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
 */

#include <linux/pagemap.h>
#include <linux/quotaops.h>
#include "ext2.h"
#include "xattr.h"
#include "acl.h"
@@ -99,9 +100,14 @@ struct dentry *ext2_get_parent(struct dentry *child)
 */
static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd)
{
	struct inode * inode = ext2_new_inode (dir, mode);
	int err = PTR_ERR(inode);
	if (!IS_ERR(inode)) {
	struct inode *inode;

	vfs_dq_init(dir);

	inode = ext2_new_inode(dir, mode);
	if (IS_ERR(inode))
		return PTR_ERR(inode);

	inode->i_op = &ext2_file_inode_operations;
	if (ext2_use_xip(inode->i_sb)) {
		inode->i_mapping->a_ops = &ext2_aops_xip;
@@ -114,9 +120,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, st
		inode->i_fop = &ext2_file_operations;
	}
	mark_inode_dirty(inode);
		err = ext2_add_nondir(dentry, inode);
	}
	return err;
	return ext2_add_nondir(dentry, inode);
}

static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
@@ -127,6 +131,8 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_
	if (!new_valid_dev(rdev))
		return -EINVAL;

	vfs_dq_init(dir);

	inode = ext2_new_inode (dir, mode);
	err = PTR_ERR(inode);
	if (!IS_ERR(inode)) {
@@ -151,6 +157,8 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,
	if (l > sb->s_blocksize)
		goto out;

	vfs_dq_init(dir);

	inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
	err = PTR_ERR(inode);
	if (IS_ERR(inode))
@@ -194,6 +202,8 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
	if (inode->i_nlink >= EXT2_LINK_MAX)
		return -EMLINK;

	vfs_dq_init(dir);

	inode->i_ctime = CURRENT_TIME_SEC;
	inode_inc_link_count(inode);
	atomic_inc(&inode->i_count);
@@ -216,6 +226,8 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
	if (dir->i_nlink >= EXT2_LINK_MAX)
		goto out;

	vfs_dq_init(dir);

	inode_inc_link_count(dir);

	inode = ext2_new_inode (dir, S_IFDIR | mode);
@@ -262,6 +274,8 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
	struct page * page;
	int err = -ENOENT;

	vfs_dq_init(dir);

	de = ext2_find_entry (dir, &dentry->d_name, &page);
	if (!de)
		goto out;
@@ -304,6 +318,9 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
	struct ext2_dir_entry_2 * old_de;
	int err = -ENOENT;

	vfs_dq_init(old_dir);
	vfs_dq_init(new_dir);

	old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page);
	if (!old_de)
		goto out;
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ const struct file_operations ext3_file_operations = {
	.compat_ioctl	= ext3_compat_ioctl,
#endif
	.mmap		= generic_file_mmap,
	.open		= generic_file_open,
	.open		= dquot_file_open,
	.release	= ext3_release_file,
	.fsync		= ext3_sync_file,
	.splice_read	= generic_file_splice_read,
+5 −0
Original line number Diff line number Diff line
@@ -196,6 +196,9 @@ void ext3_delete_inode (struct inode * inode)
{
	handle_t *handle;

	if (!is_bad_inode(inode))
		vfs_dq_init(inode);

	truncate_inode_pages(&inode->i_data, 0);

	if (is_bad_inode(inode))
@@ -3148,6 +3151,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
	if (error)
		return error;

	if (ia_valid & ATTR_SIZE)
		vfs_dq_init(inode);
	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
		handle_t *handle;
Loading