All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, lczerner@redhat.com
Subject: Re: [PATCH 3/5] ext4_zero_range: fix incorect journal credits reservation
Date: Mon, 25 Aug 2014 11:19:39 +0400	[thread overview]
Message-ID: <87k35x9gtw.fsf@openvz.org> (raw)
In-Reply-To: <20140823190835.GB6236@thunk.org>

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

On Sat, 23 Aug 2014 15:08:35 -0400, "Theodore Ts'o" <tytso@mit.edu> wrote:
> On Fri, Aug 22, 2014 at 03:32:25PM +0400, Dmitry Monakhov wrote:
> > -	handle = ext4_journal_start(inode, EXT4_HT_MISC, 4);
> > +	/* In worst case we have to writeout two nonadjacent unwritten blocks */
> > +	credits = ext4_chunk_trans_blocks(inode, 1) * 2 -
> > +		EXT4_META_TRANS_BLOCKS(inode->i_sb);
> 
> This looks like it would be a massive over-estimate, since it includes
> the block group allocation bitmaps, which we wouldn't need to update,
> no?
  Oh. You right. groups metadata/quota should not be affected.
> 
> Wouldn't
> 
> 	credts = ext4_index_trans_blocks(inode, 1, 1) * 2;
Yes, but ext4_index_trans_blocks is statically defined in inode.c,
but since zero_range works only for extent based
ext4_ext_index_trans_blocks is sufficient. Also we must reserve 2 block
for data. So final calculation looks like follows:
credits =  ext4_ext_index_trans_blocks(inode, 2) + 2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ext4_zero_range-fix-incorect-journal-credits-reserva.patch --]
[-- Type: text/x-patch, Size: 975 bytes --]

>From ec7e1926e8bb99ccd0eb525efc6666cb8ea36a5e Mon Sep 17 00:00:00 2001
From: Dmitry Monakhov <dmonakhov@openvz.org>
Date: Mon, 25 Aug 2014 11:12:35 +0400
Subject: [PATCH] ext4_zero_range: fix incorect journal credits reservation v2

Currently we reserve only 4 blocks but in worst case scenario
ext4_zero_partial_blocks() may want to zeroout and convert two
non adjacent blocks.

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

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5bf718b..f09dbe7 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4740,6 +4740,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 	loff_t new_size = 0;
 	int ret = 0;
 	int flags;
+	int credits;
 	int partial;
 	loff_t start, end;
 	ext4_lblk_t lblk;
@@ -4839,8 +4840,9 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 		if (ret)
 			goto out_dio;
 	}

  reply	other threads:[~2014-08-25  7:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-22 11:32 [PATCH 0/5] i_size/i_disksize update fixes and cleanup series Dmitry Monakhov
2014-08-22 11:32 ` [PATCH 1/5] use ext4_update_i_disksize instead of opencoded ones Dmitry Monakhov
2014-08-31  3:17   ` Theodore Ts'o
2014-08-22 11:32 ` [PATCH 2/5] move i_size,i_diskzie update routines to helper function Dmitry Monakhov
2014-08-26  1:30   ` Theodore Ts'o
2014-08-22 11:32 ` [PATCH 3/5] ext4_zero_range: fix incorect journal credits reservation Dmitry Monakhov
2014-08-23 19:08   ` Theodore Ts'o
2014-08-25  7:19     ` Dmitry Monakhov [this message]
2014-08-26  1:30       ` Theodore Ts'o
2014-08-27 21:31       ` Theodore Ts'o
2014-08-22 11:32 ` [PATCH 4/5] fix transaction issues for ext4_fallocate and ext_zero_range Dmitry Monakhov
2014-08-26  1:30   ` Theodore Ts'o
2014-08-22 11:32 ` [PATCH 5/5] update i_disksize coherently with block allocation Dmitry Monakhov
2014-08-23 22:00   ` Theodore Ts'o
2014-08-25  7:59     ` Dmitry Monakhov
2014-09-14 12:38       ` Dmitry Monakhov
2014-08-26  1:13   ` Theodore Ts'o
2014-08-26  7:47     ` Dmitry Monakhov
2014-08-26 12:26       ` Theodore Ts'o

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=87k35x9gtw.fsf@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 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.