From: Mikulas Patocka Subject: Re: [PATCH 4/4] Support discard if at least one underlying device supports it Date: Fri, 2 Jul 2010 15:49:49 -0400 (EDT) Message-ID: References: <20100702181430.GD26916@redhat.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: dm-devel@redhat.com, Alasdair G Kergon , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org To: Mike Snitzer Return-path: Received: from mx1.redhat.com ([209.132.183.28]:7839 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756603Ab0GBTt4 (ORCPT ); Fri, 2 Jul 2010 15:49:56 -0400 In-Reply-To: <20100702181430.GD26916@redhat.com> Sender: linux-ext4-owner@vger.kernel.org List-ID: > As we discussed, we have a challenge where we need DM to avoid issuing > a barrier before the discard IFF a target doesn't support the discard > (which the barrier is paired with). > > My understanding is that blkdev_issue_discard() only cares if the > discard was supported. Barrier is used just to decorate the discard > (for correctness). So by returning -EOPNOTSUPP we're saying the discard > isn't supported; we're not making any claims about the implict barrier, > so best to avoid the barrier entirely. > > Otherwise we'll be issuing unnecessary barriers (and associated > performance loss). > > So yet another TODO item... Anyway: > > Acked-by: Mike Snitzer Unnecessary barriers are issued anyway. With each freed extent. The code must issue a "SYNCHRONIZE CACHE" to flush cache for previous writes, then "UNMAP" and then another "SYNCHRONIZE CACHE" to commit that unmap to disk. And this in loop for all extents in "release_blocks_on_commit". One idea behind "discard barriers" was to submit a discard request and not wait for it. Then the request would need a barrier so that it doesn't get reordered with further writes (that may potentially write to the same area as the discarded area). But discard isn't used this way anyway, sb_issue_discard waits for completion, so the barrier isn't needed. Even if ext4 developers wanted asynchronous discard requests, they should fire all the discards at once and then submit one zero-sized barrier. Not barrier with each discard request. This is up to ext4 developers to optimize and remove the barriers and we can't do anything with it. Just send "SYNCHRONIZE CACHE"+"UNMAP"+"SYNCHRONIZE CACHE" like the barrier specification wants... Mikulas