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 X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CD3AC2BA15 for ; Sun, 5 Apr 2020 14:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC1CB20659 for ; Sun, 5 Apr 2020 14:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726898AbgDEOvb (ORCPT ); Sun, 5 Apr 2020 10:51:31 -0400 Received: from freki.datenkhaos.de ([81.7.17.101]:58248 "EHLO freki.datenkhaos.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbgDEOva (ORCPT ); Sun, 5 Apr 2020 10:51:30 -0400 Received: from localhost (localhost [127.0.0.1]) by freki.datenkhaos.de (Postfix) with ESMTP id 2B89226E05E3; Sun, 5 Apr 2020 16:51:28 +0200 (CEST) Received: from freki.datenkhaos.de ([127.0.0.1]) by localhost (freki.datenkhaos.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g1zko7_PMvce; Sun, 5 Apr 2020 16:51:25 +0200 (CEST) Received: from latitude (x4e373139.dyn.telefonica.de [78.55.49.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by freki.datenkhaos.de (Postfix) with ESMTPSA; Sun, 5 Apr 2020 16:51:25 +0200 (CEST) Date: Sun, 5 Apr 2020 16:51:21 +0200 From: Johannes Hirte To: Filipe Manana Cc: linux-btrfs Subject: Re: unexpected truncated files Message-ID: <20200405145121.GA952734@latitude> References: <20200404193846.GA432065@latitude> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2020 Apr 04, Filipe Manana wrote: > On Sat, Apr 4, 2020 at 8:52 PM Johannes Hirte > wrote: > > > > While testing with the current 5.7 development kernel, I've encountered > > some strange behaviour. I'm using Gentoo linux, and during updating the > > system I got some unexpected errors. It looked like some files were > > missing. Some investigations showed me, that files from shortly > > installed packages were truncated to zero. So for example the config > > files for apache webserver were affected. I've reinstalled apache, > > verified that the config was ok and continued the system update with the > > next package. After this, the apache config files were truncated again. > > I've found several files from different packages that were affed too, > > but only text files (configs, cmake-files, headers). Files which were > > writen, are truncated by some other write operation to the filesystem. > > > > I'm not sure, if this is really caused by btrfs, but it's the most > > obvious candidate. After switching back to 5.6-kernel, the truncation > > stopped und I was able to (re-)install the packages without any trouble. > > > > Has anyone ideas what could cause this behaviour? > > It's likely due to file cloning. > > I found this out yesterday but hadn't sent a patch yet, was waiting > for monday morning. > I've just sent the patch to the list: > https://patchwork.kernel.org/patch/11474453/ > > Since you are only getting this with small files, it's likely the > cloning of inline extents causing it, due to some changes in 5.7 that > changed the file size update logic. > > Can you try it? > > Thanks. Yes, this was it. Installing the second package for triggering the truncation was a coincidence. Installing the first package (appache here) and rebooting triggered the error reliable. With portage (the package manager from Gentoo) everything is compiled and installed to a a location on /tmp. After this, the content is copied to the target location and seems to be done with cloning. With your patch the problem doesn't occur anymore. -- Regards, Johannes Hirte