* [Ocfs2-devel] [PATCH] quota: Allow negative usage of space and inodes
@ 2008-10-20 17:23 Jan Kara
0 siblings, 0 replies; only message in thread
From: Jan Kara @ 2008-10-20 17:23 UTC (permalink / raw)
To: ocfs2-devel
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>
---
fs/dquot.c | 6 ++++--
include/linux/quota.h | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/dquot.c b/fs/dquot.c
index 904bd67..f4258fe 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -845,7 +845,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)
{
- 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;
else
dquot->dq_dqb.dqb_curinodes = 0;
@@ -856,7 +857,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)
{
- 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;
else
dquot->dq_dqb.dqb_curspace = 0;
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 3dca22c..597e8e9 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -170,7 +170,7 @@ enum {
#include <asm/atomic.h>
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 __s64 qsize_t; /* Type in which we store sizes */
extern spinlock_t dq_data_lock;
@@ -341,6 +341,7 @@ enum {
* responsible for setting
* 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)
{
--
1.5.2.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-10-20 17:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-20 17:23 [Ocfs2-devel] [PATCH] quota: Allow negative usage of space and inodes Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.