On Thu, Oct 10, 2019 at 10:02:39AM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.w...@oracle.com> > > Currently, if the loop device receives a WRITE_ZEROES request, it asks > the underlying filesystem to punch out the range. This behavior is > correct if unmapping is allowed. However, a NOUNMAP request means that > the caller forbids us from freeing the storage backing the range, so > punching out the range is incorrect behavior.
It doesn't really forbid, as most protocols don't have a way for forbid deallocation. It requests not to. Otherwise this looks fine, although I would have implemented it slightly differently: > case REQ_OP_FLUSH: > return lo_req_flush(lo, rq); > case REQ_OP_DISCARD: > - case REQ_OP_WRITE_ZEROES: > return lo_discard(lo, rq, pos); > + case REQ_OP_WRITE_ZEROES: > + return lo_zeroout(lo, rq, pos); This could just become: case REQ_OP_WRITE_ZEROES: if (rq->cmd_flags & REQ_NOUNMAP)) return lo_zeroout(lo, rq, pos); /*FALLTHRU*/ case REQ_OP_DISCARD: return lo_discard(lo, rq, pos);