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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham 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 82566C43381 for ; Thu, 28 Mar 2019 20:07:37 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CF6B20811 for ; Thu, 28 Mar 2019 20:07:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CF6B20811 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vt.edu Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1h9bIw-0003ca-Pl; Thu, 28 Mar 2019 16:07:14 -0400 Received: from omr2.cc.ipv6.vt.edu ([2607:b400:92:8400:0:33:fb76:806e] helo=omr2.cc.vt.edu) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1h9bIv-0003cU-3G for kernelnewbies@kernelnewbies.org; Thu, 28 Mar 2019 16:07:13 -0400 Received: from mr6.cc.vt.edu (mr6.cc.ipv6.vt.edu [IPv6:2607:b400:92:8500:0:af:2d00:4488]) by omr2.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x2SK7AcT003932 for ; Thu, 28 Mar 2019 16:07:11 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mr6.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x2SK74qF015642 for ; Thu, 28 Mar 2019 16:07:10 -0400 Received: by mail-qt1-f198.google.com with SMTP id i3so7930qtc.7 for ; Thu, 28 Mar 2019 13:07:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :mime-version:date:message-id; bh=9wDX7af+RIOHy/zMwUV6LtTzSR1hK6UCL1lnK0I+uSE=; b=Yr1yxUjGtlRaM9WgpkpiL9r0qsiBoVSec6HOESmS991zxwhFjql4VeJe6Y52tjvChf FpwPjgfpbLDYpRPoR5YWYBXea/vMj8rTFVL2lPJlktYaeHRa5rq2xTi49p9mWWGKsUk8 i7L6rDvSfUTIZM3LuTuDc0+ZgRTSrSK29fhZYqsnPLy9aPKSU3vAqgqkozGin634jZmv S0jB/+aVEoN6PpbcVoBkUfOeN1CCxfaOkl6lQL1CGxRuA0D6eADy7CXKksfzvVGDMGvg qk2OiXVgar+gQMxqbDAdoVX7Uv0aLwmeLSLmYuB4VHxh7sb5UsfXdKUVgvRJCyOhtJ1l 6zrA== X-Gm-Message-State: APjAAAXv6+tYCCBO+KWxkIB1p6t3qHfFr0BuoZcWOj0T0Qu46+QE3L6I OQfeHBUrUcJXf18Chn2fd2COTnHV/7DGexGVpqCRfPjNw/IgOCxUL5PsNH9Sc9F+WrM2u5wubcy 9zBGgMvXD7Hp5POb+OHQ6ewD5rGnqgBnWVEoyjYo= X-Received: by 2002:ac8:2427:: with SMTP id c36mr37821089qtc.124.1553803624637; Thu, 28 Mar 2019 13:07:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIez8u6JYZ5X0TMhQ1CUAAxcRCYeaffMZz4mNOj7hKRcVoHjxNdASnXL0Rm5nCWh2BWPTv+Q== X-Received: by 2002:ac8:2427:: with SMTP id c36mr37821069qtc.124.1553803624474; Thu, 28 Mar 2019 13:07:04 -0700 (PDT) Received: from turing-police ([2601:5c0:c001:4341::208]) by smtp.gmail.com with ESMTPSA id d17sm13831431qtl.43.2019.03.28.13.07.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Mar 2019 13:07:03 -0700 (PDT) From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Google-Original-From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7+dev To: Bharath Vedartham Subject: Re: Overwriting copy functionality in filesystem In-reply-to: <20190328183017.GA3568@bharath12345-Inspiron-5559> References: <20190323165945.GA13199@bharath12345-Inspiron-5559> <13539.1553367716@turing-police> <20190324131808.GA24735@bharath12345-Inspiron-5559> <10332.1553436396@turing-police> <20190328183017.GA3568@bharath12345-Inspiron-5559> Mime-Version: 1.0 Date: Thu, 28 Mar 2019 16:07:02 -0400 Message-ID: <24069.1553803622@turing-police> Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Fri, 29 Mar 2019 00:00:17 +0530, Bharath Vedartham said: > I was thinking of a use case where we are copying a huge file (say 100 > GB), if we do copy-on-write we can speed up /bin/cp for such files i > feel. Any comments on this? Hmm.. wait a minute. What definition of "copy on write" are you using? Hint - if you're copying an *entire* 100GB file, the *fastest* way is to simply make a second hard link to the file. If you're determined to make an entire second copy, you're going to be reading 100GB and writing 100GB, and the exact details aren't going to matter all that much. Now, where you can get clever is if you create your 100GB file, and then somebody only changes 8K of the file. There's no need to copy all 100GB into a new file if you are able to record "oh, and this 8K got changed". You only need to write the 8K of changes, and some metadata. (Similar tricks are used for shared libraries and pre-zero'ed storage. Everybody gets a reference to the same copy of the page(s) in memory - until somebody scribbles on a page. So say you have a 30MB shared object in memory, with 5 users. That's 5 references to the same data. Now one user writes to it. The system catches that write (usually via a page fault), copies just the one page to a new page, and then lets the write to the new page complete. Now we have 5 users that all have references to the same (30M-4K) of data, 4 users that have a reference to the old copy of that 4K, and one user that has a reference to the modified copy of that 4K. https://en.wikipedia.org/wiki/Copy-on-write _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies