diff options
author | Li Xi <pkuelelixi@gmail.com> | 2015-03-18 15:04:53 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2015-03-18 16:55:08 -0400 |
commit | 847aac644e92e5624f2c153bab409bf713d5ff9a (patch) | |
tree | 457739cbd1ca419d9d179a07e341bb81942885f7 /fs/quota/dquot.c | |
parent | 5ce1aca814354c5942cdb5604e142a49be7033eb (diff) |
vfs: Add general support to enforce project quota limits
This patch adds support for a new quota type PRJQUOTA for project quota
enforcement. Also a new method get_projid() is added into dquot_operations
structure.
Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r-- | fs/quota/dquot.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 327a58448592..ecc25cf0ee6e 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -1163,8 +1163,8 @@ static int need_print_warning(struct dquot_warn *warn) | |||
1163 | return uid_eq(current_fsuid(), warn->w_dq_id.uid); | 1163 | return uid_eq(current_fsuid(), warn->w_dq_id.uid); |
1164 | case GRPQUOTA: | 1164 | case GRPQUOTA: |
1165 | return in_group_p(warn->w_dq_id.gid); | 1165 | return in_group_p(warn->w_dq_id.gid); |
1166 | case PRJQUOTA: /* Never taken... Just make gcc happy */ | 1166 | case PRJQUOTA: |
1167 | return 0; | 1167 | return 1; |
1168 | } | 1168 | } |
1169 | return 0; | 1169 | return 0; |
1170 | } | 1170 | } |
@@ -1405,6 +1405,9 @@ static void __dquot_initialize(struct inode *inode, int type) | |||
1405 | /* First get references to structures we might need. */ | 1405 | /* First get references to structures we might need. */ |
1406 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1406 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1407 | struct kqid qid; | 1407 | struct kqid qid; |
1408 | kprojid_t projid; | ||
1409 | int rc; | ||
1410 | |||
1408 | got[cnt] = NULL; | 1411 | got[cnt] = NULL; |
1409 | if (type != -1 && cnt != type) | 1412 | if (type != -1 && cnt != type) |
1410 | continue; | 1413 | continue; |
@@ -1415,6 +1418,10 @@ static void __dquot_initialize(struct inode *inode, int type) | |||
1415 | */ | 1418 | */ |
1416 | if (dquots[cnt]) | 1419 | if (dquots[cnt]) |
1417 | continue; | 1420 | continue; |
1421 | |||
1422 | if (!sb_has_quota_active(sb, cnt)) | ||
1423 | continue; | ||
1424 | |||
1418 | init_needed = 1; | 1425 | init_needed = 1; |
1419 | 1426 | ||
1420 | switch (cnt) { | 1427 | switch (cnt) { |
@@ -1424,6 +1431,12 @@ static void __dquot_initialize(struct inode *inode, int type) | |||
1424 | case GRPQUOTA: | 1431 | case GRPQUOTA: |
1425 | qid = make_kqid_gid(inode->i_gid); | 1432 | qid = make_kqid_gid(inode->i_gid); |
1426 | break; | 1433 | break; |
1434 | case PRJQUOTA: | ||
1435 | rc = inode->i_sb->dq_op->get_projid(inode, &projid); | ||
1436 | if (rc) | ||
1437 | continue; | ||
1438 | qid = make_kqid_projid(projid); | ||
1439 | break; | ||
1427 | } | 1440 | } |
1428 | got[cnt] = dqget(sb, qid); | 1441 | got[cnt] = dqget(sb, qid); |
1429 | } | 1442 | } |
@@ -2176,7 +2189,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id, | |||
2176 | error = -EROFS; | 2189 | error = -EROFS; |
2177 | goto out_fmt; | 2190 | goto out_fmt; |
2178 | } | 2191 | } |
2179 | if (!sb->s_op->quota_write || !sb->s_op->quota_read) { | 2192 | if (!sb->s_op->quota_write || !sb->s_op->quota_read || |
2193 | (type == PRJQUOTA && sb->dq_op->get_projid == NULL)) { | ||
2180 | error = -EINVAL; | 2194 | error = -EINVAL; |
2181 | goto out_fmt; | 2195 | goto out_fmt; |
2182 | } | 2196 | } |