From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14FF3C61DA4 for ; Thu, 16 Feb 2023 18:49:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229762AbjBPSt2 (ORCPT ); Thu, 16 Feb 2023 13:49:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjBPSt1 (ORCPT ); Thu, 16 Feb 2023 13:49:27 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7AE83B222 for ; Thu, 16 Feb 2023 10:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ijl42fP8RYVvoifRh+kGXlsg2j+7VgEORZxdms5nVJQ=; b=GkLVazNOFx43ecetbPqBQz5zfQ 61WL2jv6bzKdzNZsH5jTHLlZ8Lh/t4yCYAh3bILLujpsDT4A2LXE9ABG5+ClnSWtZ2SXGHd+8bMQM sQpp157dtOjiGIvp/VUHhyu238SlzKiUrMDO2N9V1qhwu6PcQHCVeswUfJWmRTFjplrEsf9Ml/j9Q csWrd2dSwDtSSU8F1ovWSPEkGxCbpeGAO7jcHjhRAzbKVURW4SED9CKtWC1tpUl9MIuJXxo1J8S47 X9bgXDgZBuBwnmGoOtrS7Boy3aTQ6IdAeSMpOtgWwySdUSsxqz+L7jFSSBuOKLW+oQ1oNP/0pzyj3 /0zqSppQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSjJo-00BZr8-DB; Thu, 16 Feb 2023 18:49:20 +0000 Date: Thu, 16 Feb 2023 10:49:20 -0800 From: Christoph Hellwig To: Filipe Manana Cc: Boris Burkov , Chris Murphy , Btrfs BTRFS Subject: Re: LMDB mdb_copy produces a corrupt database on btrfs, but not on ext4 Message-ID: References: <124a916c-786b-42ec-bc9d-db97bb081881@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Thu, Feb 16, 2023 at 06:00:08PM +0000, Filipe Manana wrote: > Ok, so the problem is btrfs_dio_iomap_end() detects the submitted > amount is less than expected, so it marks the ordered extents as not > up to date, setting the BTRFS_ORDERED_IOERR bit on it. > That results in having an unexpected hole for the range [8192, 65535], > and no error returned to btrfs_direct_write(). > > My initial thought was to truncate the ordered extent at > btrfs_dio_iomap_end(), similar to what we do at > btrfs_invalidate_folio(). > I think that should work, however we would end up with a bookend > extent (but so does your proposed fix), but I don't see an easy way to > get around that. Wouldn't a better way to handle this be to cache the ordered_extent in the btrfs_dio_data, and just reuse it on the next iteration if present and covering the range?