linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lukáš Czerner" <lczerner@redhat.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: "Lukáš Czerner" <lczerner@redhat.com>,
	"Ext4 Developers List" <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 5/7] ext4: refactor truncate code
Date: Wed, 27 Mar 2013 14:31:48 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.2.00.1303271426420.18375@localhost> (raw)
In-Reply-To: <20130327123651.GG5861@thunk.org>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2384 bytes --]

On Wed, 27 Mar 2013, Theodore Ts'o wrote:

> Date: Wed, 27 Mar 2013 08:36:51 -0400
> From: Theodore Ts'o <tytso@mit.edu>
> To: Lukáš Czerner <lczerner@redhat.com>
> Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>
> Subject: Re: [PATCH 5/7] ext4: refactor truncate code
> 
> On Wed, Mar 27, 2013 at 11:53:42AM +0100, Lukáš Czerner wrote:
> > > +	up_write(&ei->i_data_sem);
> > 
> > In ext_truncate we used to unlock it after the ext4_handle_sync(),
> > however in ind_truncate we used to unlock it before the
> > ext4_handle_sync(). Which one is correct ? I guess it does not have
> > to be done under the i_data_sem, so maybe we can move it outside the
> > semaphore in the punch_hole code as well ?
> 
> Yes, we can move this outside of the semaphore protected code.  Given
> that ext4_handle_sync() an inline function which sets a single memory
> location, my guess is that it didn't make a huge amount of difference,
> but it's better to keep the critical section as small as possible.
> I'll make that change.
> 
> 
> Hmm.... one thing I'm not sure about, now that I'm looking at this
> code.  We call ext4_discard_preallocations() twice; once before we
> remove the extent, and once afterwards.  I'm not sure why we're doing
> that.  It doesn't look to me like ext4_free_blocks() ever releases
> blocks back to the preallocation space.  Am I missing something, or
> could we eliminate one of the calls to ext4_discard_preallocations()?

I was wondering about that as well. There is a possibility of
allocation occurring in ext4_ext_remove_space() however it is only
metadata allocation and as such there should be no preallocation so
it seems to me that the second ext4_discard_preallocations() is
unnecessary. Note that it has been there from the introduction of
punch hole.

However let's take it one step further. What about the first call of
ext4_discard_preallocations() is this entirely necessary for a punch
hole ? I am wondering whether we can optimize things by dropping the
preallocation only within the hole we're punching, or possibly only
when we punch a hole at the end, or past the end of the file.

-Lukas

> 
>       	 	       	      	       - Ted
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2013-03-27 13:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25  0:06 [PATCH 0/7] ext4 code simplification and clean ups Theodore Ts'o
2013-03-25  0:06 ` [PATCH 1/7] ext4: collapse handling of data=ordered and data=writeback codepaths Theodore Ts'o
2013-03-27 12:57   ` Lukáš Czerner
2013-03-25  0:06 ` [PATCH 2/7] ext4: fold ext4_generic_write_end() into ext4_write_end() Theodore Ts'o
2013-03-27 12:58   ` Lukáš Czerner
2013-03-27 15:35   ` Jan Kara
2013-03-25  0:06 ` [PATCH 3/7] ext4: fold ext4_alloc_blocks() in ext4_alloc_branch() Theodore Ts'o
2013-03-27 17:01   ` Jan Kara
2013-03-25  0:06 ` [PATCH 4/7] ext4: refactor punch hole code Theodore Ts'o
     [not found]   ` <alpine.LFD.2.00.1303261334060.2455@(none)>
2013-03-27  2:38     ` Theodore Ts'o
2013-03-27 10:49       ` Lukáš Czerner
2013-03-25  0:06 ` [PATCH 5/7] ext4: refactor truncate code Theodore Ts'o
     [not found]   ` <alpine.LFD.2.00.1303271128480.2455@(none)>
2013-03-27 12:36     ` Theodore Ts'o
2013-03-27 13:31       ` Lukáš Czerner [this message]
2013-03-25  0:06 ` [PATCH 6/7] ext4: add mutex_is_locked() assertion to ext4_truncate() Theodore Ts'o
2013-03-26  9:31   ` Lukáš Czerner
2013-03-27  2:29     ` Theodore Ts'o
2013-03-25  0:06 ` [PATCH 7/7] ext4: add might_sleep() annotations Theodore Ts'o
2013-03-26  9:48   ` Lukáš Czerner
2013-03-26  9:49     ` Lukáš Czerner

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=alpine.LFD.2.00.1303271426420.18375@localhost \
    --to=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 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).