Re: [RFC PATCH] discarding swap

David Woodhouse
2008-09-12T14:09:40Z

On Fri, 2008-09-12 at 13:10 +0100, Hugh Dickins wrote:
> So long as the I/O schedulers guarantee that a WRITE bio submitted
> to an area already covered by a DISCARD_NOBARRIER bio cannot pass that
> DISCARD_NOBARRIER - ...

> That seems a reasonable guarantee to me, and perhaps it's trivially
> obvious to those who know their I/O schedulers; but I don't, so I'd
> like to hear such assurance given.

No, that's the point. the I/O schedulers _don't_ give you that guarantee
at all. They can treat DISCARD_NOBARRIER just like a write. That's all
it is, really -- a special kind of WRITE request without any data.

But -- and this came as a bit of a shock to me -- they don't guarantee
that writes don't cross writes on their queue. If you issue two WRITE
requests to the same sector, you have to make sure for _yourself_ that
there is some kind of barrier between them to keep them in the right
order.

Does swap do that, when a page on the disk is deallocated and then used
for something else?

--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation