linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Batched discard support
@ 2010-08-06 11:31 Lukas Czerner
  2010-08-06 11:31 ` [PATCH 1/3] Add ioctl FITRIM Lukas Czerner
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Lukas Czerner @ 2010-08-06 11:31 UTC (permalink / raw)
  To: linux-ext4
  Cc: dmonakhov, jmoyer, rwheeler, eshishki, sandeen, jack, tytso,
	lczerner

Hi, all

because people were worried about possibly long stalls appearing
when FITRIM ioctl is working, I have changed the FITRIM interface
as Dimitry suggested. Now you can choose whether to trim whole
file system or just a part of it, resp. you can specify the range
of Bytes to trim.

To be specific you can create something like this:

int main(int argc, char **argv)
{
	int fd;
	uint64_t range[3];

	range[0] = 40960;
	range[1] = 134217728;
	range[2] = 4096;

	fd = open(argv[1], O_RDONLY);
	if (fd < 0) {
		perror("open");
		return 1;
	}

	if (ioctl(fd, FITRIM, range)) {
		if (errno == EOPNOTSUPP)
			fprintf(stderr, "FITRIM not supported\n");
		else
			perror("FITRIM");
		return 1;
	}

	return 0;
}

Range items have following meaning:

range[0] - (start) first Byte to trim
range[1] - (len) number of Bytes to trim from start
range[2] - (minlen) minimum extent length to trim, free extents shorter
than this number of Bytes will be ignored. This number will be rounded
up to the block size.

So in my example it will trim all free extents from block 10 of first
alloc. group to block 10 of second alloc. group, assuming we have
block_size = 4096.

Also, when you want to trim the whole fs, you can simply pass NULL
instead of range into the ioctl, or you can specify the range correctly
to cover the whole fs.

Regards
-Lukas

[PATCH 1/3] Add ioctl FITRIM.
[PATCH 2/3] Add batched discard support for ext3
[PATCH 3/3] Add batched discard support for ext4

 fs/ext3/balloc.c        |  249 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext3/super.c         |    1 +
 fs/ext4/ext4.h          |    2 +
 fs/ext4/mballoc.c       |  194 ++++++++++++++++++++++++++++++++++++
 fs/ext4/super.c         |    1 +
 fs/ioctl.c              |   34 +++++++
 include/linux/ext3_fs.h |    1 +
 include/linux/fs.h      |    2 +
 8 files changed, 484 insertions(+), 0 deletions(-)

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

end of thread, other threads:[~2010-08-10 11:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06 11:31 [PATCH 0/3] Batched discard support Lukas Czerner
2010-08-06 11:31 ` [PATCH 1/3] Add ioctl FITRIM Lukas Czerner
2010-08-06 11:31 ` [PATCH 2/3] Add batched discard support for ext3 Lukas Czerner
2010-08-06 11:31 ` [PATCH 3/3] Add batched discard support for ext4 Lukas Czerner
2010-08-06 13:03   ` Dmitry Monakhov
2010-08-06 13:23     ` Lukas Czerner
2010-08-07 22:25   ` Jan Kara
2010-08-10 11:32     ` Lukas Czerner
2010-08-06 13:05 ` [PATCH 0/3] Batched discard support Dmitry Monakhov
2010-08-06 13:49   ` Lukas Czerner
2010-08-06 14:24     ` Dmitry Monakhov
2010-08-06 14:32     ` Lukas Czerner
2010-08-06 15:02       ` Dmitry Monakhov
2010-08-10 11:31         ` Lukas Czerner

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