On Thu, Feb 25, 2021 at 07:51:05AM +0000, Christoph Hellwig wrote: > As a quick fix this looks good: > > Reviewed-by: Christoph Hellwig <hch@xxxxxx> > > That beeing said we really need to go back and look into this, > especially due to discards. For SSDs it is generlly much better to > quickly reuse freed blocks rather than discarding them later. > Ok, that's an interesting point. I'm not sure online discard is a super critical use case, but I agree that there's a tangible advantage to optimizing out pending discards in that configuration. That also raises a caveat with the alternative implementation I was mulling over. The current implementation simply skips over extents that are busy and already under discard. If we were to find a prospective reusable busy block (not under discard), allocate it, and then commit to reusing it, we'd have to deal with the fact that we could find it under discard at that point. We can't easily skip it because we've already performed an allocation in the transaction by that point. I suspect the simplest solution is just wait for the discard to complete since we already have somewhat of a mechanism to do that, but hopefully it wouldn't be a frequent occurence. Brian