Re: [PATCH v2 3/3] doc: Add alternate trim/zero limits
- To: Eric Blake <eblake@redhat.com>
- Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, nbd@other.debian.org, edgar.kaziakhmedov@virtuozzo.com
- Subject: Re: [PATCH v2 3/3] doc: Add alternate trim/zero limits
- From: Wouter Verhelst <w@uter.be>
- Date: Sun, 1 Apr 2018 15:22:49 +0200
- Message-id: <[🔎] 20180401132249.GB9921@grep.be>
- In-reply-to: <b658b698-7475-f53a-fccf-63876f8c9720@redhat.com>
- References: <20180314211622.784604-1-eblake@redhat.com> <20180314211622.784604-4-eblake@redhat.com> <76a2eae1-c20e-51e5-bea6-27869f8e4284@virtuozzo.com> <b8d2ba7b-7679-192c-320a-d54e73179317@redhat.com> <20180329155240.GB18293@grep.be> <b658b698-7475-f53a-fccf-63876f8c9720@redhat.com>
On Thu, Mar 29, 2018 at 01:40:35PM -0500, Eric Blake wrote:
> On 03/29/2018 10:52 AM, Wouter Verhelst wrote:
> > On Wed, Mar 28, 2018 at 02:35:02PM -0500, Eric Blake wrote:
> > > We may also want to consider an extension where a server can advertise
> > > whether a successful TRIM guarantees a reads-as-zero effect (this behavior
> > > is not required of a generic server, but may be useful to exploit when a
> > > client knows that a specific server supports it).
> >
> > Isn't that why we specified WRITE_ZEROES in a way that it could
> > optionally also have the effect that TRIM was meant for?
>
> Indeed, we specified WRITE_ZEROES to be permitted to take advantage of TRIM
> semantics unless the user passes a flag that requests explicit allocation
> rather than punching a hole; although that's also relatively weak (the
> client can choose whether to avoid a trim, but cannot guarantee a trim, as
> it is optional whether the server translates a write zeroes into a trim
> based on guarantees about trim behavior). At any rate, without a specific
> use case of where KNOWING what trim can do and why it is different from what
> WRITE_ZEROES is permitted to do, I'm not going to propose an extension at
> this time.
I'm seeing WRITE_ZEROES and TRIM as two related commands:
- WRITE_ZEROES MUST read back as zeroes, MAY drop the allocation (unless
the request specified otherwise with the relevant flag)
- TRIM MAY read back as zeroes, MUST drop the allocation where supported
If someone wants a guarantee that something reads back as zeroes and
that allocation has been removed where supported, there's nothing
stopping them from issueing a WRITE_ZEROES (with trim allowed) followed
by a TRIM. That should be reasonably cheap in all but unusual cases[1], and
would ensure the TRIM in the unusual case, too.
[1] An implementation might support TRIM but not want to do it because
actually writing zeroes is cheaper than trimming, and therefore its
WRITE_ZEROES does not actually trim anything. In this
implementation, doing a TRIM before a WRITE_ZEROES might reallocate
things though, so hence the ordering.
In other cases, a TRIM of a region that has already been zeroed with
"may trim" should be an almost no-op, so issuing a WRITE_ZEROES
followed (after completion of that command) by a TRIM should not
have any measurable effect.
--
Could you people please use IRC like normal people?!?
-- Amaya Rodrigo Sastre, trying to quiet down the buzz in the DebConf 2008
Hacklab
Reply to: