Re: [PATCH] loop: fix no-unmap write-zeroes request behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 10, 2019 at 10:02:39AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> 
> 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);



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux