Skip to content

Commit 4d59bce

Browse files
jankaraMark Fasheh
authored andcommitted
quota: Keep which entries were set by SETQUOTA quotactl
Quota in a clustered environment needs to synchronize quota information among cluster nodes. This means we have to occasionally update some information in dquot from disk / network. On the other hand we have to be careful not to overwrite changes administrator did via SETQUOTA. So indicate in dquot->dq_flags which entries have been set by SETQUOTA and quota format can clear these flags when it properly propagated the changes. Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Mark Fasheh <[email protected]>
1 parent db49d2d commit 4d59bce

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

fs/dquot.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,25 +2010,33 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
20102010
if (di->dqb_valid & QIF_SPACE) {
20112011
dm->dqb_curspace = di->dqb_curspace;
20122012
check_blim = 1;
2013+
__set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
20132014
}
20142015
if (di->dqb_valid & QIF_BLIMITS) {
20152016
dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
20162017
dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
20172018
check_blim = 1;
2019+
__set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
20182020
}
20192021
if (di->dqb_valid & QIF_INODES) {
20202022
dm->dqb_curinodes = di->dqb_curinodes;
20212023
check_ilim = 1;
2024+
__set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
20222025
}
20232026
if (di->dqb_valid & QIF_ILIMITS) {
20242027
dm->dqb_isoftlimit = di->dqb_isoftlimit;
20252028
dm->dqb_ihardlimit = di->dqb_ihardlimit;
20262029
check_ilim = 1;
2030+
__set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
20272031
}
2028-
if (di->dqb_valid & QIF_BTIME)
2032+
if (di->dqb_valid & QIF_BTIME) {
20292033
dm->dqb_btime = di->dqb_btime;
2030-
if (di->dqb_valid & QIF_ITIME)
2034+
__set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
2035+
}
2036+
if (di->dqb_valid & QIF_ITIME) {
20312037
dm->dqb_itime = di->dqb_itime;
2038+
__set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
2039+
}
20322040

20332041
if (check_blim) {
20342042
if (!dm->dqb_bsoftlimit || dm->dqb_curspace < dm->dqb_bsoftlimit) {

include/linux/quota.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,21 @@
8080
* Quota structure used for communication with userspace via quotactl
8181
* Following flags are used to specify which fields are valid
8282
*/
83-
#define QIF_BLIMITS 1
84-
#define QIF_SPACE 2
85-
#define QIF_ILIMITS 4
86-
#define QIF_INODES 8
87-
#define QIF_BTIME 16
88-
#define QIF_ITIME 32
83+
enum {
84+
QIF_BLIMITS_B = 0,
85+
QIF_SPACE_B,
86+
QIF_ILIMITS_B,
87+
QIF_INODES_B,
88+
QIF_BTIME_B,
89+
QIF_ITIME_B,
90+
};
91+
92+
#define QIF_BLIMITS (1 << QIF_BLIMITS_B)
93+
#define QIF_SPACE (1 << QIF_SPACE_B)
94+
#define QIF_ILIMITS (1 << QIF_ILIMITS_B)
95+
#define QIF_INODES (1 << QIF_INODES_B)
96+
#define QIF_BTIME (1 << QIF_BTIME_B)
97+
#define QIF_ITIME (1 << QIF_ITIME_B)
8998
#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
9099
#define QIF_USAGE (QIF_SPACE | QIF_INODES)
91100
#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
@@ -242,6 +251,11 @@ extern struct dqstats dqstats;
242251
#define DQ_FAKE_B 3 /* no limits only usage */
243252
#define DQ_READ_B 4 /* dquot was read into memory */
244253
#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */
254+
#define DQ_LASTSET_B 6 /* Following 6 bits (see QIF_) are reserved\
255+
* for the mask of entries set via SETQUOTA\
256+
* quotactl. They are set under dq_data_lock\
257+
* and the quota format handling dquot can\
258+
* clear them when it sees fit. */
245259

246260
struct dquot {
247261
struct hlist_node dq_hash; /* Hash list in memory */

0 commit comments

Comments
 (0)