aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2008-10-01 12:21:39 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:40:21 -0500
commitdb49d2df489f727096438706a5428115e84a3f0d (patch)
tree4ba9837a5371bb4a84dc27614eaeb4e4772e3eb8
parente3d4d56b9715e40ded2a84d0d4fa7f3b6c58983c (diff)
quota: Allow negative usage of space and inodes
For clustered filesystems, it can happen that space / inode usage goes negative temporarily (because some node is allocating another node is freeing and they are not completely in sync). So let quota code allow this and change qsize_t so a signed type so that we don't underflow the variables. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r--fs/dquot.c6
-rw-r--r--include/linux/quota.h3
2 files changed, 6 insertions, 3 deletions
diff --git a/fs/dquot.c b/fs/dquot.c
index 74185c34a4f0..9c78ffe1aad2 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -847,7 +847,8 @@ static inline void dquot_incr_space(struct dquot *dquot, qsize_t number)
847 847
848static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number) 848static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
849{ 849{
850 if (dquot->dq_dqb.dqb_curinodes > number) 850 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
851 dquot->dq_dqb.dqb_curinodes >= number)
851 dquot->dq_dqb.dqb_curinodes -= number; 852 dquot->dq_dqb.dqb_curinodes -= number;
852 else 853 else
853 dquot->dq_dqb.dqb_curinodes = 0; 854 dquot->dq_dqb.dqb_curinodes = 0;
@@ -858,7 +859,8 @@ static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
858 859
859static inline void dquot_decr_space(struct dquot *dquot, qsize_t number) 860static inline void dquot_decr_space(struct dquot *dquot, qsize_t number)
860{ 861{
861 if (dquot->dq_dqb.dqb_curspace > number) 862 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
863 dquot->dq_dqb.dqb_curspace >= number)
862 dquot->dq_dqb.dqb_curspace -= number; 864 dquot->dq_dqb.dqb_curspace -= number;
863 else 865 else
864 dquot->dq_dqb.dqb_curspace = 0; 866 dquot->dq_dqb.dqb_curspace = 0;
diff --git a/include/linux/quota.h b/include/linux/quota.h
index e51dfdc0aef0..75bf761caef2 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -168,7 +168,7 @@ enum {
168#include <asm/atomic.h> 168#include <asm/atomic.h>
169 169
170typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */ 170typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
171typedef __u64 qsize_t; /* Type in which we store sizes */ 171typedef long long qsize_t; /* Type in which we store sizes */
172 172
173extern spinlock_t dq_data_lock; 173extern spinlock_t dq_data_lock;
174 174
@@ -336,6 +336,7 @@ enum {
336 * responsible for setting 336 * responsible for setting
337 * S_NOQUOTA, S_NOATIME flags 337 * S_NOQUOTA, S_NOATIME flags
338 */ 338 */
339#define DQUOT_NEGATIVE_USAGE (1 << 7) /* Allow negative quota usage */
339 340
340static inline unsigned int dquot_state_flag(unsigned int flags, int type) 341static inline unsigned int dquot_state_flag(unsigned int flags, int type)
341{ 342{