From: Lukas Czerner <lczerner@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: Lukas Czerner <lczerner@redhat.com>,
linux-ext4@vger.kernel.org, jmoyer@redhat.com,
rwheeler@redhat.com, eshishki@redhat.com, sandeen@redhat.com
Subject: Re: [PATCH 2/2] Add batched discard support for ext3
Date: Mon, 12 Jul 2010 17:58:46 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1007121735210.2733@localhost> (raw)
In-Reply-To: <20100712152825.GB19433@atrey.karlin.mff.cuni.cz>
On Mon, 12 Jul 2010, Jan Kara wrote:
> > Walk through each allocation group and trim all free extents. It can be
> > invoked through TRIM ioctl on the file system. The main idea is to
> > provide a way to trim the whole file system if needed, since some SSD's
> > may suffer from performance loss after the whole device was filled (it
> > does not mean that fs is full!).
> >
> > It search for free extents in each allocation group. When the free
> > extent is found, blocks are marked as used and then trimmed. Afterwards
> > these blocks are marked as free in per-group bitmap.
> >
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> > ---
> > fs/ext3/balloc.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++
> > fs/ext3/super.c | 1 +
> > include/linux/ext3_fs.h | 1 +
> > 3 files changed, 147 insertions(+), 0 deletions(-)
> >
> > diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
> > index a177122..bcee525 100644
> > --- a/fs/ext3/balloc.c
> > +++ b/fs/ext3/balloc.c
> ...
> > + /**
> > + * Allocate contiguous free extents by setting bits in the
> > + * block bitmap
> > + */
> > + while (next < max
> > + && !ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
> > + next, bh->b_data)) {
> > + next++;
> > + }
> This is actually wrong. You completely ignore journalling here. You can't
> just go and modify metadata buffer - other process can be modifying it as well
> and writing it to disk and thus your changes will also get written. And if
> a crash happens afterwards before the bitmap is written again, you'll get an
> inconsistent filesystem.
> Also you have to check whether the block isn't actually still used by a
> running/committing transaction - look at fs/ext3/balloc.c:claim_block() to see
> how you have to allocate free blocks.
I may be wrong, but I thought that since the trim command ensures that
every operation in queue completes before the trim proceed, I do not
need to care much about the journaling and running transaction. But I
will took at it once more..
> All-in-all won't it be good enough to just freeze the fs, do the trimming,
> and unfreeze it?
>
> Honza
>
Yes, it can be done that way. But it is king of rough solution.
Thank.
-Lukas
next prev parent reply other threads:[~2010-07-12 15:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-07 13:18 Ext3: batched discard support Lukas Czerner
2010-07-07 13:18 ` [PATCH 1/2] Add discard/nodiscard mount option for ext3 Lukas Czerner
2010-07-12 15:19 ` Jan Kara
2010-07-12 15:26 ` Lukas Czerner
2010-07-12 15:50 ` Jan Kara
2010-07-12 16:01 ` Lukas Czerner
2010-07-12 15:27 ` Ric Wheeler
2010-07-12 16:03 ` Ric Wheeler
2010-07-12 16:05 ` Lukas Czerner
2010-07-12 16:15 ` Lukas Czerner
2010-07-12 18:07 ` Eric Sandeen
2010-07-07 13:18 ` [PATCH 2/2] Add batched discard support " Lukas Czerner
2010-07-12 15:28 ` Jan Kara
2010-07-12 15:58 ` Lukas Czerner [this message]
2010-07-12 19:57 ` Jan Kara
2010-07-13 15:55 ` Lukas Czerner
2010-07-07 19:14 ` Ext3: batched discard support Greg Freemyer
2010-07-09 8:53 ` Lukas Czerner
2010-07-09 10:18 ` Ric Wheeler
2010-07-12 15:09 ` 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=alpine.LFD.2.00.1007121735210.2733@localhost \
--to=lczerner@redhat.com \
--cc=eshishki@redhat.com \
--cc=jack@suse.cz \
--cc=jmoyer@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=rwheeler@redhat.com \
--cc=sandeen@redhat.com \
/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).