Commit db49d2df authored by Jan Kara's avatar Jan Kara Committed by Mark Fasheh

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: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent e3d4d56b
...@@ -847,7 +847,8 @@ static inline void dquot_incr_space(struct dquot *dquot, qsize_t number) ...@@ -847,7 +847,8 @@ static inline void dquot_incr_space(struct dquot *dquot, qsize_t number)
static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number) static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
{ {
if (dquot->dq_dqb.dqb_curinodes > number) if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
dquot->dq_dqb.dqb_curinodes >= number)
dquot->dq_dqb.dqb_curinodes -= number; dquot->dq_dqb.dqb_curinodes -= number;
else else
dquot->dq_dqb.dqb_curinodes = 0; dquot->dq_dqb.dqb_curinodes = 0;
...@@ -858,7 +859,8 @@ static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number) ...@@ -858,7 +859,8 @@ static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
static inline void dquot_decr_space(struct dquot *dquot, qsize_t number) static inline void dquot_decr_space(struct dquot *dquot, qsize_t number)
{ {
if (dquot->dq_dqb.dqb_curspace > number) if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
dquot->dq_dqb.dqb_curspace >= number)
dquot->dq_dqb.dqb_curspace -= number; dquot->dq_dqb.dqb_curspace -= number;
else else
dquot->dq_dqb.dqb_curspace = 0; dquot->dq_dqb.dqb_curspace = 0;
......
...@@ -168,7 +168,7 @@ enum { ...@@ -168,7 +168,7 @@ enum {
#include <asm/atomic.h> #include <asm/atomic.h>
typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */ typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
typedef __u64 qsize_t; /* Type in which we store sizes */ typedef long long qsize_t; /* Type in which we store sizes */
extern spinlock_t dq_data_lock; extern spinlock_t dq_data_lock;
...@@ -336,6 +336,7 @@ enum { ...@@ -336,6 +336,7 @@ enum {
* responsible for setting * responsible for setting
* S_NOQUOTA, S_NOATIME flags * S_NOQUOTA, S_NOATIME flags
*/ */
#define DQUOT_NEGATIVE_USAGE (1 << 7) /* Allow negative quota usage */
static inline unsigned int dquot_state_flag(unsigned int flags, int type) static inline unsigned int dquot_state_flag(unsigned int flags, int type)
{ {
......
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