From: Dmitry Monakhov <dmonakhov@openvz.org>
To: Lukas Czerner <lczerner@redhat.com>
Cc: eshishki@redhat.com, jmoyer@redhat.com, rwheeler@redhat.com,
linux-ext4@vger.kernel.org, sandeen@redhat.com
Subject: Re: [PATCH 2/2] Add batched discard support for ext4
Date: Wed, 14 Jul 2010 12:33:00 +0400 [thread overview]
Message-ID: <87tyo2a2f7.fsf@dmon-lap.sw.ru> (raw)
In-Reply-To: <1278489212-12110-3-git-send-email-lczerner@redhat.com> (Lukas Czerner's message of "Wed, 7 Jul 2010 09:53:32 +0200")
[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]
Lukas Czerner <lczerner@redhat.com> writes:
> 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 fro 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.
Looks ok, except two small notes:
1) trim_fs is a time consuming operation and we have to add
condresced, and signal_pending checks to allow user to interrupt
cmd if necessery. See patch attached.
2) IMHO runtime trim support is useful sometimes, for example when
user really care about data security i.e. unlinked file should be
trimmed ASAP. I think we have to provide 'secdel' mount option
similar to secdeletion flag for inode, but this is another story
not directly connected with the patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ext4-Add-interrupt-points-to-batched-discard.patch --]
[-- Type: text/x-diff, Size: 2230 bytes --]
>From 54ca2add544f88ac9ca8c647ae7b093be9ac2872 Mon Sep 17 00:00:00 2001
From: Dmitry Monakhov <dmonakhov@openvz.org>
Date: Wed, 14 Jul 2010 12:16:50 +0400
Subject: [PATCH] ext4: Add interrupt points to batched discard
Since fstrim is a long operation it will be good to have an
ability to interrupt it by a signal.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ext4/mballoc.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 48abd3d..0948408 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3959,7 +3959,7 @@ static void ext4_trim_extent(struct super_block *sb, int start, int count,
(unsigned long long)discard_block,
count);
sb_issue_discard(sb, discard_block, count);
-
+ cond_resched();
ext4_lock_group(sb, group);
mb_free_blocks(NULL, e4b, start, ex.fe_len);
}
@@ -3995,7 +3995,10 @@ ext4_grpblk_t ext4_trim_all_free(struct super_block *sb, struct ext4_buddy *e4b,
next - start, group, e4b);
}
start = next + 1;
-
+ if (signal_pending(current)) {
+ count = -ERESTARTSYS;
+ break;
+ }
if ((e4b->bd_info->bb_free - count) < minblocks)
break;
}
@@ -4013,7 +4016,8 @@ int ext4_trim_fs(unsigned int minlen, struct super_block *sb)
struct ext4_buddy e4b;
ext4_group_t group;
ext4_group_t ngroups = ext4_get_groups_count(sb);
- ext4_grpblk_t minblocks;
+ ext4_grpblk_t minblocks, cnt;
+ int ret = 0;
if (!test_opt(sb, DISCARD))
return 0;
@@ -4023,22 +4027,25 @@ int ext4_trim_fs(unsigned int minlen, struct super_block *sb)
return -EINVAL;
for (group = 0; group < ngroups; group++) {
- int err;
-
- err = ext4_mb_load_buddy(sb, group, &e4b);
- if (err) {
+ ret = ext4_mb_load_buddy(sb, group, &e4b);
+ if (ret) {
ext4_error(sb, "Error in loading buddy "
"information for %u", group);
- continue;
+ break;
}
if (e4b.bd_info->bb_free >= minblocks) {
- ext4_trim_all_free(sb, &e4b, minblocks);
+ cnt = ext4_trim_all_free(sb, &e4b, minblocks);
+ if (cnt < 0) {
+ ret = cnt;
+ ext4_mb_unload_buddy(&e4b);
+ break;
+ }
}
ext4_mb_unload_buddy(&e4b);
}
- return 0;
+ return ret;
}
/*
--
1.6.6.1
next prev parent reply other threads:[~2010-07-14 8:33 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-07 7:53 Ext4: batched discard support - simplified version Lukas Czerner
2010-07-07 7:53 ` [PATCH 1/2] Add ioctl FITRIM Lukas Czerner
2010-07-07 7:53 ` [PATCH 2/2] Add batched discard support for ext4 Lukas Czerner
2010-07-14 8:33 ` Dmitry Monakhov [this message]
2010-07-14 9:40 ` Lukas Czerner
2010-07-14 10:03 ` Dmitry Monakhov
2010-07-14 11:43 ` Lukas Czerner
2010-07-23 14:36 ` Ext4: batched discard support - simplified version Ted Ts'o
2010-07-23 15:13 ` Jeff Moyer
2010-07-23 15:19 ` Ted Ts'o
2010-07-23 15:40 ` Jeff Moyer
2010-07-23 17:00 ` Ted Ts'o
2010-07-24 16:31 ` Ric Wheeler
2010-07-23 15:30 ` Greg Freemyer
2010-07-26 10:30 ` Lukas Czerner
-- strict thread matches above, loose matches on Subject: below --
2010-04-19 10:55 Ext4: batched discard support Lukas Czerner
2010-04-19 10:55 ` [PATCH 1/2] Add ioctl FITRIM Lukas Czerner
2010-04-19 10:55 ` [PATCH 2/2] Add batched discard support for ext4 Lukas Czerner
2010-04-20 21:21 ` Greg Freemyer
2010-04-21 2:26 ` Mark Lord
2010-04-21 2:45 ` Eric Sandeen
2010-04-21 18:59 ` Greg Freemyer
2010-04-21 19:04 ` Ric Wheeler
2010-04-21 19:22 ` Jeff Moyer
2010-04-21 20:44 ` Greg Freemyer
2010-04-21 20:53 ` Greg Freemyer
2010-04-21 21:01 ` Eric Sandeen
2010-04-21 21:03 ` Ric Wheeler
2010-04-21 21:47 ` Greg Freemyer
2010-04-21 21:56 ` James Bottomley
2010-04-21 21:59 ` Mark Lord
2010-04-23 8:23 ` Lukas Czerner
2010-04-24 13:24 ` Greg Freemyer
2010-04-24 13:48 ` Ric Wheeler
2010-04-24 14:30 ` Greg Freemyer
2010-04-24 14:43 ` Eric Sandeen
2010-04-24 15:03 ` Greg Freemyer
2010-04-24 17:04 ` Ric Wheeler
2010-04-24 18:30 ` Greg Freemyer
2010-04-24 18:41 ` Ric Wheeler
2010-04-26 14:00 ` Mark Lord
2010-04-26 14:42 ` Martin K. Petersen
2010-04-26 15:27 ` Greg Freemyer
2010-04-26 15:51 ` Lukas Czerner
2010-04-28 1:25 ` Mark Lord
2010-04-26 15:48 ` Ric Wheeler
2010-04-24 19:06 ` Martin K. Petersen
2010-04-26 14:03 ` Mark Lord
2010-04-24 18:39 ` Martin K. Petersen
2010-04-26 16:55 ` Jan Kara
2010-04-26 17:46 ` Lukas Czerner
2010-04-26 17:52 ` Ric Wheeler
2010-04-26 18:14 ` Lukas Czerner
2010-04-26 18:28 ` Jeff Moyer
2010-04-21 20:52 ` Greg Freemyer
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=87tyo2a2f7.fsf@dmon-lap.sw.ru \
--to=dmonakhov@openvz.org \
--cc=eshishki@redhat.com \
--cc=jmoyer@redhat.com \
--cc=lczerner@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 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.