Commit be6257b2 authored by Jan Kara's avatar Jan Kara

quota: Add support for ->get_nextdqblk() for VFS quota

Add infrastructure for supporting get_nextdqblk() callback for VFS
quotas. Translate the operation into a callback to appropriate
filesystem and consequently to quota format callback.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 484a10f4
...@@ -1132,6 +1132,7 @@ static const struct dquot_operations ext4_quota_operations = { ...@@ -1132,6 +1132,7 @@ static const struct dquot_operations ext4_quota_operations = {
.alloc_dquot = dquot_alloc, .alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy, .destroy_dquot = dquot_destroy,
.get_projid = ext4_get_projid, .get_projid = ext4_get_projid,
.get_next_id = dquot_get_next_id,
}; };
static const struct quotactl_ops ext4_qctl_operations = { static const struct quotactl_ops ext4_qctl_operations = {
......
...@@ -2031,6 +2031,21 @@ int dquot_commit_info(struct super_block *sb, int type) ...@@ -2031,6 +2031,21 @@ int dquot_commit_info(struct super_block *sb, int type)
} }
EXPORT_SYMBOL(dquot_commit_info); EXPORT_SYMBOL(dquot_commit_info);
int dquot_get_next_id(struct super_block *sb, struct kqid *qid)
{
struct quota_info *dqopt = sb_dqopt(sb);
int err;
if (!dqopt->ops[qid->type]->get_next_id)
return -ENOSYS;
mutex_lock(&dqopt->dqio_mutex);
err = dqopt->ops[qid->type]->get_next_id(sb, qid);
mutex_unlock(&dqopt->dqio_mutex);
return err;
}
EXPORT_SYMBOL(dquot_get_next_id);
/* /*
* Definitions of diskquota operations. * Definitions of diskquota operations.
*/ */
...@@ -2042,6 +2057,7 @@ const struct dquot_operations dquot_operations = { ...@@ -2042,6 +2057,7 @@ const struct dquot_operations dquot_operations = {
.write_info = dquot_commit_info, .write_info = dquot_commit_info,
.alloc_dquot = dquot_alloc, .alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy, .destroy_dquot = dquot_destroy,
.get_next_id = dquot_get_next_id,
}; };
EXPORT_SYMBOL(dquot_operations); EXPORT_SYMBOL(dquot_operations);
...@@ -2565,6 +2581,27 @@ int dquot_get_dqblk(struct super_block *sb, struct kqid qid, ...@@ -2565,6 +2581,27 @@ int dquot_get_dqblk(struct super_block *sb, struct kqid qid,
} }
EXPORT_SYMBOL(dquot_get_dqblk); EXPORT_SYMBOL(dquot_get_dqblk);
int dquot_get_next_dqblk(struct super_block *sb, struct kqid *qid,
struct qc_dqblk *di)
{
struct dquot *dquot;
int err;
if (!sb->dq_op->get_next_id)
return -ENOSYS;
err = sb->dq_op->get_next_id(sb, qid);
if (err < 0)
return err;
dquot = dqget(sb, *qid);
if (IS_ERR(dquot))
return PTR_ERR(dquot);
do_get_dqblk(dquot, di);
dqput(dquot);
return 0;
}
EXPORT_SYMBOL(dquot_get_next_dqblk);
#define VFS_QC_MASK \ #define VFS_QC_MASK \
(QC_SPACE | QC_SPC_SOFT | QC_SPC_HARD | \ (QC_SPACE | QC_SPC_SOFT | QC_SPC_HARD | \
QC_INO_COUNT | QC_INO_SOFT | QC_INO_HARD | \ QC_INO_COUNT | QC_INO_SOFT | QC_INO_HARD | \
...@@ -2765,6 +2802,7 @@ const struct quotactl_ops dquot_quotactl_ops = { ...@@ -2765,6 +2802,7 @@ const struct quotactl_ops dquot_quotactl_ops = {
.get_state = dquot_get_state, .get_state = dquot_get_state,
.set_info = dquot_set_dqinfo, .set_info = dquot_set_dqinfo,
.get_dqblk = dquot_get_dqblk, .get_dqblk = dquot_get_dqblk,
.get_nextdqblk = dquot_get_next_dqblk,
.set_dqblk = dquot_set_dqblk .set_dqblk = dquot_set_dqblk
}; };
EXPORT_SYMBOL(dquot_quotactl_ops); EXPORT_SYMBOL(dquot_quotactl_ops);
...@@ -2776,6 +2814,7 @@ const struct quotactl_ops dquot_quotactl_sysfile_ops = { ...@@ -2776,6 +2814,7 @@ const struct quotactl_ops dquot_quotactl_sysfile_ops = {
.get_state = dquot_get_state, .get_state = dquot_get_state,
.set_info = dquot_set_dqinfo, .set_info = dquot_set_dqinfo,
.get_dqblk = dquot_get_dqblk, .get_dqblk = dquot_get_dqblk,
.get_nextdqblk = dquot_get_next_dqblk,
.set_dqblk = dquot_set_dqblk .set_dqblk = dquot_set_dqblk
}; };
EXPORT_SYMBOL(dquot_quotactl_sysfile_ops); EXPORT_SYMBOL(dquot_quotactl_sysfile_ops);
......
...@@ -802,6 +802,7 @@ static const struct dquot_operations reiserfs_quota_operations = { ...@@ -802,6 +802,7 @@ static const struct dquot_operations reiserfs_quota_operations = {
.write_info = reiserfs_write_info, .write_info = reiserfs_write_info,
.alloc_dquot = dquot_alloc, .alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy, .destroy_dquot = dquot_destroy,
.get_next_id = dquot_get_next_id,
}; };
static const struct quotactl_ops reiserfs_qctl_operations = { static const struct quotactl_ops reiserfs_qctl_operations = {
......
...@@ -306,6 +306,7 @@ struct quota_format_ops { ...@@ -306,6 +306,7 @@ struct quota_format_ops {
int (*read_dqblk)(struct dquot *dquot); /* Read structure for one user */ int (*read_dqblk)(struct dquot *dquot); /* Read structure for one user */
int (*commit_dqblk)(struct dquot *dquot); /* Write structure for one user */ int (*commit_dqblk)(struct dquot *dquot); /* Write structure for one user */
int (*release_dqblk)(struct dquot *dquot); /* Called when last reference to dquot is being dropped */ int (*release_dqblk)(struct dquot *dquot); /* Called when last reference to dquot is being dropped */
int (*get_next_id)(struct super_block *sb, struct kqid *qid); /* Get next ID with existing structure in the quota file */
}; };
/* Operations working with dquots */ /* Operations working with dquots */
...@@ -321,6 +322,8 @@ struct dquot_operations { ...@@ -321,6 +322,8 @@ struct dquot_operations {
* quota code only */ * quota code only */
qsize_t *(*get_reserved_space) (struct inode *); qsize_t *(*get_reserved_space) (struct inode *);
int (*get_projid) (struct inode *, kprojid_t *);/* Get project ID */ int (*get_projid) (struct inode *, kprojid_t *);/* Get project ID */
/* Get next ID with active quota structure */
int (*get_next_id) (struct super_block *sb, struct kqid *qid);
}; };
struct path; struct path;
......
...@@ -82,6 +82,7 @@ int dquot_commit(struct dquot *dquot); ...@@ -82,6 +82,7 @@ int dquot_commit(struct dquot *dquot);
int dquot_acquire(struct dquot *dquot); int dquot_acquire(struct dquot *dquot);
int dquot_release(struct dquot *dquot); int dquot_release(struct dquot *dquot);
int dquot_commit_info(struct super_block *sb, int type); int dquot_commit_info(struct super_block *sb, int type);
int dquot_get_next_id(struct super_block *sb, struct kqid *qid);
int dquot_mark_dquot_dirty(struct dquot *dquot); int dquot_mark_dquot_dirty(struct dquot *dquot);
int dquot_file_open(struct inode *inode, struct file *file); int dquot_file_open(struct inode *inode, struct file *file);
...@@ -99,6 +100,8 @@ int dquot_get_state(struct super_block *sb, struct qc_state *state); ...@@ -99,6 +100,8 @@ int dquot_get_state(struct super_block *sb, struct qc_state *state);
int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii); int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii);
int dquot_get_dqblk(struct super_block *sb, struct kqid id, int dquot_get_dqblk(struct super_block *sb, struct kqid id,
struct qc_dqblk *di); struct qc_dqblk *di);
int dquot_get_next_dqblk(struct super_block *sb, struct kqid *id,
struct qc_dqblk *di);
int dquot_set_dqblk(struct super_block *sb, struct kqid id, int dquot_set_dqblk(struct super_block *sb, struct kqid id,
struct qc_dqblk *di); struct qc_dqblk *di);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment