Re: [PATCH 2/2] block: create ioctl to discard-or-zeroout a range of blocks

4 messages, 4 authors, 2016-03-03 · open the first message on its own page

Re: [PATCH 2/2] block: create ioctl to discard-or-zeroout a range of blocks

From: Martin K. Petersen <hidden>
Date: 2016-03-03 18:05:39

quoted
quoted
quoted
quoted
"Linus" == Linus Torvalds [off-list ref] writes:
Linus> .. but the flag doesn't even set that. Even if you avoid TRIM,
Linus> there is absolutely zero guarantees that WRITE_SAME would do
Linus> "real storage blocks full of zeroes backing the LBAs they just
Linus> wrote out".

That's not entirely true. Writing the blocks may cause them to be
allocated on the storage device (depending on which flags we feed it in
WRITE SAME).

The filesystems people were wanted the following semantics:

 - deallocate, don't care about contents for future reads (discard)
 - deallocate, guarantee zeroes on future reads (zeroout)
 - (re)allocate, guarantee zeroes on future reads (zeroout)

Maybe we just need a better naming scheme...

-- 
Martin K. Petersen	Oracle Linux Engineering

Re: [PATCH 2/2] block: create ioctl to discard-or-zeroout a range of blocks

From: Christoph Hellwig <hch@infradead.org>
Date: 2016-03-03 18:09:26

On Thu, Mar 03, 2016 at 01:01:11PM -0500, Martin K. Petersen wrote:
That's not entirely true. Writing the blocks may cause them to be
allocated on the storage device (depending on which flags we feed it in
WRITE SAME).

The filesystems people were wanted the following semantics:

 - deallocate, don't care about contents for future reads (discard)
 - deallocate, guarantee zeroes on future reads (zeroout)
 - (re)allocate, guarantee zeroes on future reads (zeroout)

Maybe we just need a better naming scheme...
In filesystem terms we have two and three:

 - FALLOC_FL_PUNCH_HOLE assures zeroes are returned, but space is
   deallocated as much as possible
 - FALLOC_FL_ZERO_RANGE assures zeroes are returned, AND blocks are
   actually allocated

Returning stale blocks in a file system is a nasty security risk, so
we don't do that, and so shouldn't storage that offers any kind
of multi tenancy, and if it's just VMs using multiple partitions on it.

Re: [PATCH 2/2] block: create ioctl to discard-or-zeroout a range of blocks

From: Darrick J. Wong <hidden>
Date: 2016-03-03 18:12:40

On Thu, Mar 03, 2016 at 10:09:24AM -0800, Christoph Hellwig wrote:
On Thu, Mar 03, 2016 at 01:01:11PM -0500, Martin K. Petersen wrote:
quoted
That's not entirely true. Writing the blocks may cause them to be
allocated on the storage device (depending on which flags we feed it in
WRITE SAME).

The filesystems people were wanted the following semantics:

 - deallocate, don't care about contents for future reads (discard)
 - deallocate, guarantee zeroes on future reads (zeroout)
 - (re)allocate, guarantee zeroes on future reads (zeroout)

Maybe we just need a better naming scheme...
In filesystem terms we have two and three:

 - FALLOC_FL_PUNCH_HOLE assures zeroes are returned, but space is
   deallocated as much as possible
 - FALLOC_FL_ZERO_RANGE assures zeroes are returned, AND blocks are
   actually allocated

Returning stale blocks in a file system is a nasty security risk, so
we don't do that, and so shouldn't storage that offers any kind
of multi tenancy, and if it's just VMs using multiple partitions on it.
Any particular reason why we can't just implement those two fallocate
flags for block devices?

--D

Re: [PATCH 2/2] block: create ioctl to discard-or-zeroout a range of blocks

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-03-03 18:14:17

On Thu, Mar 3, 2016 at 10:01 AM, Martin K. Petersen
[off-list ref] wrote:
quoted
quoted
quoted
quoted
quoted
"Linus" == Linus Torvalds [off-list ref] writes:
Linus> .. but the flag doesn't even set that. Even if you avoid TRIM,
Linus> there is absolutely zero guarantees that WRITE_SAME would do
Linus> "real storage blocks full of zeroes backing the LBAs they just
Linus> wrote out".

That's not entirely true. Writing the blocks may cause them to be
allocated on the storage device (depending on which flags we feed it in
WRITE SAME).
Ok, so now we're getting somewhere, with actual _reasons_ why somebody
would want to use one interface over another.
The filesystems people were wanted the following semantics:

 - deallocate, don't care about contents for future reads (discard)
 - deallocate, guarantee zeroes on future reads (zeroout)
 - (re)allocate, guarantee zeroes on future reads (zeroout)

Maybe we just need a better naming scheme...
Yes.

And this does make me think that Christoph is right: this would be so
much better if the block layer just supported fallocate() instead,
which already has those operations.

Right now we have

        if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
                return -ENODEV;

so right now the vfs_fallocate() code expliitly disallows block
devices, but that would be easy to expand.

Would people be happy with that kind of patch instead? It would
certainly make all my objections go away..

             Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help