2009-11-17 21:49:06

by Eric Sandeen

[permalink] [raw]
Subject: [PATCH] e2fsprogs: open device writable for trim/discard

Sorry about that, the discard ioctl doesn't actually work
unless you open the file with write capabilities...

Signed-off-by: Eric Sandeen <[email protected]>
---

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 94b4c81..0aa31d8 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1877,7 +1877,7 @@ static void mke2fs_discard_blocks(ext2_filsys fs)
range[0] = 0;
range[1] = blocks * blocksize;

- fd = open64(fs->device_name, O_RDONLY);
+ fd = open64(fs->device_name, O_RDWR);

/*
* We don't care about whether the ioctl succeeds; it's only an



2009-11-25 12:05:55

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] e2fsprogs: open device writable for trim/discard

On Tue, Nov 17, 2009 at 03:49:03PM -0600, Eric Sandeen wrote:
> Sorry about that, the discard ioctl doesn't actually work
> unless you open the file with write capabilities...

Applied, thanks.

- Ted