linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH 2/3] quota: add the option to not fail with EDQUOT in block allocation
Date: Wed, 07 Apr 2010 16:52:28 -0500	[thread overview]
Message-ID: <4BBCFE9C.4070302@redhat.com> (raw)
In-Reply-To: <4BBCFD10.3030504@redhat.com>

To simplify metadata tracking for delalloc writes, ext4
will simply claim metadata blocks at allocation time, without
first speculatively reserving the worst case and then freeing
what was not used.

To do this, we need a mechanism to track allocations in
the quota subsystem, but potentially allow that allocation
to actually go over quota.

This patch adds a DQUOT_SPACE_NOFAIL flag and function
variants for this purpose.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8436d9b..c38b137 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1490,6 +1490,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
 	char warntype[MAXQUOTAS];
 	int warn = flags & DQUOT_SPACE_WARN;
 	int reserve = flags & DQUOT_SPACE_RESERVE;
+	int nofail = flags & DQUOT_SPACE_NOFAIL;
 
 	/*
 	 * First test before acquiring mutex - solves deadlocks when we
@@ -1510,7 +1511,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags)
 			continue;
 		ret = check_bdq(inode->i_dquot[cnt], number, !warn,
 				warntype+cnt);
-		if (ret) {
+		if (ret && !nofail) {
 			spin_unlock(&dq_data_lock);
 			goto out_flush_warn;
 		}
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index daa106f..8f858ce 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -16,6 +16,7 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb)
 
 #define DQUOT_SPACE_WARN	0x1
 #define DQUOT_SPACE_RESERVE	0x2
+#define DQUOT_SPACE_NOFAIL	0x4
 
 #if defined(CONFIG_QUOTA)
 
@@ -262,6 +263,12 @@ static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
 	return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN);
 }
 
+static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr)
+{
+	__dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL);
+	mark_inode_dirty(inode);
+}
+
 static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
 {
 	int ret;
@@ -277,6 +284,11 @@ static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr)
 	return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits);
 }
 
+static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr)
+{
+	dquot_alloc_space_nofail(inode, nr << inode->i_blkbits);
+}
+
 static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
 {
 	return dquot_alloc_space(inode, nr << inode->i_blkbits);


  parent reply	other threads:[~2010-04-07 21:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 21:45 [PATCH 0/3] ext4: don't use quota reservation for speculative metadata blocks Eric Sandeen
2010-04-07 21:49 ` [PATCH 1/3] quota: use flags interface for dquot alloc/free space Eric Sandeen
2010-04-12 13:22   ` Jan Kara
2010-05-20 22:29   ` tytso
2010-04-07 21:52 ` Eric Sandeen [this message]
2010-04-12 13:23   ` [PATCH 2/3] quota: add the option to not fail with EDQUOT in block allocation Jan Kara
2010-05-20 22:32   ` tytso
2010-04-07 21:55 ` [PATCH 3/3] ext4: don't use quota reservation for speculative metadata blocks Eric Sandeen
2010-04-12 13:36   ` Jan Kara
2010-05-20 23:10   ` tytso
2010-04-08  8:20 ` [PATCH 0/3] " Dmitry Monakhov
2010-04-08 15:28   ` Eric Sandeen
2010-04-11  9:37     ` Dmitry Monakhov
2010-04-12 13:15       ` Jan Kara
2010-04-12 13:22         ` Jan Kara
2010-04-12 13:40           ` Dmitry Monakhov
2010-04-12 13:33         ` Dmitry Monakhov
2010-04-12 13:37           ` Dmitry Monakhov
2010-04-12 13:42           ` tytso
2010-04-12 13:52             ` Dmitry Monakhov
2010-04-12 13:55           ` Jan Kara
2010-04-12 14:08             ` Dmitry Monakhov
2010-04-12 14:24               ` Jan Kara
2010-04-12 15:50                 ` Eric Sandeen
2010-04-12  2:20 ` tytso
2010-04-12 14:03   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BBCFE9C.4070302@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).