linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ext4: Allow quota file use root reservation
@ 2011-10-19 10:16 Dmitry Monakhov
  2011-10-19 10:16 ` [PATCH 2/2] ext3: " Dmitry Monakhov
  2011-10-21  0:11 ` [PATCH 1/2] ext4: " Ted Ts'o
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Monakhov @ 2011-10-19 10:16 UTC (permalink / raw)
  To: jack, linux-ext4; +Cc: Dmitry Monakhov

Quota file is fs's metadata, so it is reasonable  to permit use
root resevation if necessary. This patch fix 265'th xfstest failure

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext4/mballoc.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 17a5a57..5a7b3b4 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4256,6 +4256,10 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 
 	trace_ext4_request_blocks(ar);
 
+	/* Allow to use superuser reservation for quota file */
+	if (IS_NOQUOTA(ar->inode))
+		ar->flags |= EXT4_MB_USE_ROOT_BLOCKS;
+
 	/*
 	 * For delayed allocation, we could skip the ENOSPC and
 	 * EDQUOT check, as blocks and quotas have been already
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ext3: Allow quota file use root reservation
  2011-10-19 10:16 [PATCH 1/2] ext4: Allow quota file use root reservation Dmitry Monakhov
@ 2011-10-19 10:16 ` Dmitry Monakhov
  2011-10-20 23:36   ` Jan Kara
  2011-10-21  0:11 ` [PATCH 1/2] ext4: " Ted Ts'o
  1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Monakhov @ 2011-10-19 10:16 UTC (permalink / raw)
  To: jack, linux-ext4; +Cc: Dmitry Monakhov

Quota file is fs's metadata, so it is reasonable  to permit use
root resevation if necessary. This patch fix 265'th xfstest failure

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext3/balloc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 6386d76..5430559 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -1440,14 +1440,14 @@ out:
  *
  * Check if filesystem has at least 1 free block available for allocation.
  */
-static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
+static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
 {
 	ext3_fsblk_t free_blocks, root_blocks;
 
 	free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
 	root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
 	if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
-		sbi->s_resuid != current_fsuid() &&
+		!use_reservation && sbi->s_resuid != current_fsuid() &&
 		(sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
 		return 0;
 	}
@@ -1468,7 +1468,7 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
  */
 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
 {
-	if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
+	if (!ext3_has_free_blocks(EXT3_SB(sb), 0) || (*retries)++ > 3)
 		return 0;
 
 	jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
@@ -1546,7 +1546,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
 	if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
 		my_rsv = &block_i->rsv_window_node;
 
-	if (!ext3_has_free_blocks(sbi)) {
+	if (!ext3_has_free_blocks(sbi, IS_NOQUOTA(inode))) {
 		*errp = -ENOSPC;
 		goto out;
 	}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] ext3: Allow quota file use root reservation
  2011-10-19 10:16 ` [PATCH 2/2] ext3: " Dmitry Monakhov
@ 2011-10-20 23:36   ` Jan Kara
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2011-10-20 23:36 UTC (permalink / raw)
  To: Dmitry Monakhov; +Cc: jack, linux-ext4

On Wed 19-10-11 14:16:23, Dmitry Monakhov wrote:
> Quota file is fs's metadata, so it is reasonable  to permit use
> root resevation if necessary. This patch fix 265'th xfstest failure
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
>  fs/ext3/balloc.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
> index 6386d76..5430559 100644
> --- a/fs/ext3/balloc.c
> +++ b/fs/ext3/balloc.c
...
> @@ -1546,7 +1546,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
>  	if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
>  		my_rsv = &block_i->rsv_window_node;
>  
> -	if (!ext3_has_free_blocks(sbi)) {
> +	if (!ext3_has_free_blocks(sbi, IS_NOQUOTA(inode))) {
>  		*errp = -ENOSPC;
>  		goto out;
>  	}
  Hmph, using IS_NOQUOTA() for a detection of quota files is a hack. But if
we look at it like "if a file is extempted from quota, it can be as well
allowed to use reserved blocks" then it makes some sense. So I'll take the
patch. Thanks.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ext4: Allow quota file use root reservation
  2011-10-19 10:16 [PATCH 1/2] ext4: Allow quota file use root reservation Dmitry Monakhov
  2011-10-19 10:16 ` [PATCH 2/2] ext3: " Dmitry Monakhov
@ 2011-10-21  0:11 ` Ted Ts'o
  1 sibling, 0 replies; 4+ messages in thread
From: Ted Ts'o @ 2011-10-21  0:11 UTC (permalink / raw)
  To: Dmitry Monakhov; +Cc: jack, linux-ext4

On Wed, Oct 19, 2011 at 02:16:22PM +0400, Dmitry Monakhov wrote:
> Quota file is fs's metadata, so it is reasonable  to permit use
> root resevation if necessary. This patch fix 265'th xfstest failure
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>

Applied to the ext4 tree, thanks.  I'll leave the ext3 patch to Jan.

					- Ted

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-21  1:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-19 10:16 [PATCH 1/2] ext4: Allow quota file use root reservation Dmitry Monakhov
2011-10-19 10:16 ` [PATCH 2/2] ext3: " Dmitry Monakhov
2011-10-20 23:36   ` Jan Kara
2011-10-21  0:11 ` [PATCH 1/2] ext4: " Ted Ts'o

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).