aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-12-16 06:03:51 -0500
committerJan Kara <jack@suse.cz>2015-03-04 10:06:38 -0500
commit5eacb2ac029161d94969a511e0adf7dca28cda1f (patch)
treef49c47630dbd2790ae4d297f745f6ab359525ed9 /fs/quota
parent59b6ba699043e0f55d4057cf2ae79d9c1171bc58 (diff)
quota: Make ->set_info use structure with neccesary info to VFS and XFS
Change ->set_info to take new qc_info structure which contains all the necessary information both for XFS and VFS. Convert Q_SETINFO handler to use this structure. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/dquot.c27
-rw-r--r--fs/quota/quota.c21
2 files changed, 36 insertions, 12 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index cf4edd87e854..f37b74eab807 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2649,33 +2649,38 @@ int dquot_get_state(struct super_block *sb, struct qc_state *state)
2649EXPORT_SYMBOL(dquot_get_state); 2649EXPORT_SYMBOL(dquot_get_state);
2650 2650
2651/* Generic routine for setting common part of quota file information */ 2651/* Generic routine for setting common part of quota file information */
2652int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) 2652int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii)
2653{ 2653{
2654 struct mem_dqinfo *mi; 2654 struct mem_dqinfo *mi;
2655 int err = 0; 2655 int err = 0;
2656 2656
2657 if ((ii->i_fieldmask & QC_WARNS_MASK) ||
2658 (ii->i_fieldmask & QC_RT_SPC_TIMER))
2659 return -EINVAL;
2657 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); 2660 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
2658 if (!sb_has_quota_active(sb, type)) { 2661 if (!sb_has_quota_active(sb, type)) {
2659 err = -ESRCH; 2662 err = -ESRCH;
2660 goto out; 2663 goto out;
2661 } 2664 }
2662 mi = sb_dqopt(sb)->info + type; 2665 mi = sb_dqopt(sb)->info + type;
2663 if (ii->dqi_valid & IIF_FLAGS) { 2666 if (ii->i_fieldmask & QC_FLAGS) {
2664 if (ii->dqi_flags & ~DQF_SETINFO_MASK || 2667 if ((ii->i_flags & QCI_ROOT_SQUASH &&
2665 (ii->dqi_flags & DQF_ROOT_SQUASH &&
2666 mi->dqi_format->qf_fmt_id != QFMT_VFS_OLD)) { 2668 mi->dqi_format->qf_fmt_id != QFMT_VFS_OLD)) {
2667 err = -EINVAL; 2669 err = -EINVAL;
2668 goto out; 2670 goto out;
2669 } 2671 }
2670 } 2672 }
2671 spin_lock(&dq_data_lock); 2673 spin_lock(&dq_data_lock);
2672 if (ii->dqi_valid & IIF_BGRACE) 2674 if (ii->i_fieldmask & QC_SPC_TIMER)
2673 mi->dqi_bgrace = ii->dqi_bgrace; 2675 mi->dqi_bgrace = ii->i_spc_timelimit;
2674 if (ii->dqi_valid & IIF_IGRACE) 2676 if (ii->i_fieldmask & QC_INO_TIMER)
2675 mi->dqi_igrace = ii->dqi_igrace; 2677 mi->dqi_igrace = ii->i_ino_timelimit;
2676 if (ii->dqi_valid & IIF_FLAGS) 2678 if (ii->i_fieldmask & QC_FLAGS) {
2677 mi->dqi_flags = (mi->dqi_flags & ~DQF_SETINFO_MASK) | 2679 if (ii->i_flags & QCI_ROOT_SQUASH)
2678 (ii->dqi_flags & DQF_SETINFO_MASK); 2680 mi->dqi_flags |= DQF_ROOT_SQUASH;
2681 else
2682 mi->dqi_flags &= ~DQF_ROOT_SQUASH;
2683 }
2679 spin_unlock(&dq_data_lock); 2684 spin_unlock(&dq_data_lock);
2680 mark_info_dirty(sb, type); 2685 mark_info_dirty(sb, type);
2681 /* Force write to disk */ 2686 /* Force write to disk */
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 20d11cd21247..741d5a178268 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -149,12 +149,31 @@ static int quota_getinfo(struct super_block *sb, int type, void __user *addr)
149static int quota_setinfo(struct super_block *sb, int type, void __user *addr) 149static int quota_setinfo(struct super_block *sb, int type, void __user *addr)
150{ 150{
151 struct if_dqinfo info; 151 struct if_dqinfo info;
152 struct qc_info qinfo;
152 153
153 if (copy_from_user(&info, addr, sizeof(info))) 154 if (copy_from_user(&info, addr, sizeof(info)))
154 return -EFAULT; 155 return -EFAULT;
155 if (!sb->s_qcop->set_info) 156 if (!sb->s_qcop->set_info)
156 return -ENOSYS; 157 return -ENOSYS;
157 return sb->s_qcop->set_info(sb, type, &info); 158 if (info.dqi_valid & ~(IIF_FLAGS | IIF_BGRACE | IIF_IGRACE))
159 return -EINVAL;
160 memset(&qinfo, 0, sizeof(qinfo));
161 if (info.dqi_valid & IIF_FLAGS) {
162 if (info.dqi_flags & ~DQF_SETINFO_MASK)
163 return -EINVAL;
164 if (info.dqi_flags & DQF_ROOT_SQUASH)
165 qinfo.i_flags |= QCI_ROOT_SQUASH;
166 qinfo.i_fieldmask |= QC_FLAGS;
167 }
168 if (info.dqi_valid & IIF_BGRACE) {
169 qinfo.i_spc_timelimit = info.dqi_bgrace;
170 qinfo.i_fieldmask |= QC_SPC_TIMER;
171 }
172 if (info.dqi_valid & IIF_IGRACE) {
173 qinfo.i_ino_timelimit = info.dqi_igrace;
174 qinfo.i_fieldmask |= QC_INO_TIMER;
175 }
176 return sb->s_qcop->set_info(sb, type, &qinfo);
158} 177}
159 178
160static inline qsize_t qbtos(qsize_t blocks) 179static inline qsize_t qbtos(qsize_t blocks)