Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp788760imm; Tue, 5 Jun 2018 04:37:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIlxY6OgsCFLABRMr1pjp2MyrdfyggK+ikSYR6nssq4vHINo2bl6Ski4YABVSg9RyH0YJC6 X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr20264671pgu.266.1528198661573; Tue, 05 Jun 2018 04:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528198661; cv=none; d=google.com; s=arc-20160816; b=zU70b++qlcmweMSHT93jKCe1s2VpQ6TONf+9Q6H4dtO44wNQ9sGb37XdSn3/3HzzhM FlEdEC6dlV0fPu7ha589BVWiwUrSsVMi274qfxHB9bDwNL1Cgm9Fd1L2WZxOB8IHzJC8 WZ21cIR1d6ffceIDqz6jBiPtAFdXJ+TBJxRsKvjcY6ctbywmLhhgOfc8nMu98Rmf9DHq kS3QxdZAWeKM/KL9J15Lyzd2NrYS/dRntRH5NH66bu+bEZBGl9KgCyCRMVT2gxtNR8+G 9iE1v0DLPIOqUXTRBv38A5kS8yvMNdYPplNRBiNIUEXuJp8k5dSPkbbF9/BR/N7O1FYk DXHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=9zvPDaalaXBzJ69MSyAmLmk4HuMJ6jKk43E5b5uQi4k=; b=anXsZN9C8tNEfEVx58ulgXa+WnN8BM9GIcplRu5aXPoyWyaWUb/hBAJhk6U0bsj1kC 7wqSelxFDMv6losTRseBsw+AsBP83HknbFqESuo4BQTW79+oX8hm1eZcjKCigmpXcxZg jqavffmNvyqlk6u9Np7oe+VzHe8418yZJjylcyYde9+1TD9czSa5Mqm61XSAKbV0B1eC tTe3Oj5MD70YHRJkJO685q+cldw1q0pMGL2R5yPUeXvUoFGFFJAkbC0OEGV30qvzwh3V jrVV6STvsRJuHl3J3tGMt91J+Qgpsq/H2V3Wz0lROSCNmOQayDIujt7QZPKqZOs10GSt 2YCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=VQJNIyCr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16-v6si10045249pfj.55.2018.06.05.04.37.27; Tue, 05 Jun 2018 04:37:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=VQJNIyCr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751845AbeFELgJ (ORCPT + 99 others); Tue, 5 Jun 2018 07:36:09 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:46675 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbeFELgG (ORCPT ); Tue, 5 Jun 2018 07:36:06 -0400 Received: by mail-oi0-f68.google.com with SMTP id h79-v6so1703201oig.13 for ; Tue, 05 Jun 2018 04:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9zvPDaalaXBzJ69MSyAmLmk4HuMJ6jKk43E5b5uQi4k=; b=VQJNIyCrnirL+X5pi4Zqf66wa4OUXHyI5vc4jrcplkhhmeDsfzsmZr+lLN5Ln61dY5 6pPeKJXV75D/KZPyDkmUheDMH5DMl6nSAj0lLiiLQA3sZieyRKixcac7kfJGMckik5Iv g1vhawu/wLRYqnInltu/Ab8EUQ3fV/fbjmXrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9zvPDaalaXBzJ69MSyAmLmk4HuMJ6jKk43E5b5uQi4k=; b=Yc7uIlXtbWlq6kxa73OUHc7C5Qn5Ej5VBQnfhqxV+7Rueh1JxzgeGHqckDn4as/G2s X3cNFXxbAu6uFEYqABb68U8o7rfqfUoYvIRId9bPpdNZINZON5F75cUga/1qYKonwRgc TSQUheulPUTvddniLokVJLiLw81iF4KXSkEzG2DAdbT/mswb/p9WHOvTVqe0W4ScKSVV Cm8MT2O5rYbdSuoy5XEo+azsbvbuXGisMsB9AfdjXA5dZG4pEOuH0MZ8et1ofLXc0GUK wOTGF/Rmr5VXWiHg40m27Y8qAEi2KfF9mA0GGPtp/YXtzoC1bNlVEgi7RFY7VbMWH37U i+bQ== X-Gm-Message-State: ALKqPwf/rK9KUQOdFLQj/B0LF2/DgdEMZ5Ie3w1jxRwA6aPEXBPVesSI 8bDy7ksj+E3fOOlvueABKOxa4Y0Zu7mjm/WMnfKnOw== X-Received: by 2002:aca:f388:: with SMTP id r130-v6mr13473501oih.17.1528198565630; Tue, 05 Jun 2018 04:36:05 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1123:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 04:36:04 -0700 (PDT) X-Originating-IP: [194.176.227.33] In-Reply-To: <20180604084827.GE11333@infradead.org> References: <20180529144339.16538-1-mszeredi@redhat.com> <20180529144339.16538-7-mszeredi@redhat.com> <20180604084827.GE11333@infradead.org> From: Miklos Szeredi Date: Tue, 5 Jun 2018 13:36:04 +0200 Message-ID: Subject: Re: [PATCH 06/39] vfs: add f_op->pre_mmap() To: Christoph Hellwig Cc: Miklos Szeredi , overlayfs , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 4, 2018 at 10:48 AM, Christoph Hellwig wrote: > On Tue, May 29, 2018 at 04:43:06PM +0200, Miklos Szeredi wrote: >> This is needed by overlayfs to be able to copy up a file from a read-only >> lower layer to a writable layer when being mapped shared. When copying up, >> overlayfs takes VFS locks that would violate locking order when nested >> inside mmap_sem. >> >> Add a new f_op->pre_mmap method, which is called before taking mmap_sem. > > NAK. We really should not add multiple methods for mmap, and everytime > this came up we found a better way to solve the problem instead. Most > recent example was the socket zero copy receive code. Okay, I'll drop this. Not sure if it's better, but I have an idea for solving this without pre_mmap(): - Private maps of lower files continue to use the underlying fs' mapping. This keeps the nice page sharing properties of overlays for shared libraries, executables and most read-only uses. - Shared maps of lower file and all maps of upper files go to overlayfs's own page cache. In these cases we can't have shared mappings, so it basically doesn't matter if the cache resides in the underlying inode or the overlay inode. The implementation is certainly going to be more complex, since we'll have to add address space ops to overlayfs. . The advantage will be that we won't actually have to do the copy up when a lower file is mapped with MAP_SHARED. Thanks, Miklos