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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6DFDAC4CEC9 for ; Tue, 17 Sep 2019 04:55:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45B18216C8 for ; Tue, 17 Sep 2019 04:55:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730349AbfIQEzu (ORCPT ); Tue, 17 Sep 2019 00:55:50 -0400 Received: from james.kirk.hungrycats.org ([174.142.39.145]:35356 "EHLO james.kirk.hungrycats.org" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727234AbfIQEzu (ORCPT ); Tue, 17 Sep 2019 00:55:50 -0400 Received: by james.kirk.hungrycats.org (Postfix, from userid 1002) id ECBAE42C9A1; Tue, 17 Sep 2019 00:55:48 -0400 (EDT) Date: Tue, 17 Sep 2019 00:55:48 -0400 From: Zygo Blaxell To: Chris Murphy Cc: General Zed , Btrfs BTRFS Subject: Re: Feature requests: online backup - defrag - change RAID level Message-ID: <20190917045548.GF24379@hungrycats.org> References: <20190912202604.Horde.2Cvnicewbvpdb39q5eBASP7@server53.web-hosting.com> <20190913031242.GF22121@hungrycats.org> <20190913010552.Horde.cUL303XsYbqREB5g0iiCDKd@server53.web-hosting.com> <20190914005655.GH22121@hungrycats.org> <20190913215038.Horde.gsxNyK9aSRLm6Qsl5sUNhf0@server53.web-hosting.com> <20190914044219.GL22121@hungrycats.org> <20190915135407.Horde.qqs07Bais-BPrjIVxyrrIfo@server53.web-hosting.com> <20190916225126.GB24379@hungrycats.org> <20190916210317.Horde.CLwHiAXP00_WIX7YMxFiew3@server53.web-hosting.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Mon, Sep 16, 2019 at 07:44:31PM -0600, Chris Murphy wrote: > Reflinks are like a file based snapshot, they're a file with its own > inode and other metadata you expect for a file, but points to the same > extents as another file. Off hand I'm not sure other than age if > there's any difference between the structure of the original file and > a reflink of that file. Find out. Make a reflink, dump tree. Delete > the original file. Dump tree. Ehhhh...not really. The clone-file ioctl is a wrapper around clone-file-range that fills in 0 as the offset and the size of the file as the length when creating reflinks. clone-file-range copies all the extent reference items from the src range to the dst range, replacing any extent reference items that were present before. It's O(n) in the number of source range extent refs, and it doesn't have snapshot-style atomicity. The offset for src and dst can both be non-zero, and src and dst inode can be the same. Src and dst cannot overlap, but they can be logically adjacent, creating a logical-neighbor loop for physical extents.