Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3769464imm; Mon, 11 Jun 2018 01:13:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLy+ugH38Km0V4qnELEj94p8zTZIsjDeDVdfcRFeWqY9HZBV967HYtLmjnlY8V8dcPpyI7T X-Received: by 2002:a63:6142:: with SMTP id v63-v6mr13506965pgb.390.1528704814199; Mon, 11 Jun 2018 01:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528704814; cv=none; d=google.com; s=arc-20160816; b=QSHsitAw9ruEhsmF2F/W1nthT0k3LzFff25yzoj6TtqQGkDbOB9+osV6HvW5sP9d6r 02IxT+T7GQUKte0NZwYcE+uFolQO8T7o4gUmCRKTh/lLz1WAFCq9zylBPqSyaC4OtJiF 9Uit6YYIMStIyV/VyuBLNqL6xkhcQwSrcvbB73vB9OOnRNcPcN0RbybUPjqrU+RdDIBB xx7MpKobQ7/2QfSWG6xn+k2mp5bUAa83RkZ8xSBpRIjVz4nLqeGUqc2PT8KD65JRQIax Rhh0zi519TxyK2bZo/uMCbxYThk72/4ywlH+JiaZH+qzVevDCZfqhD1F21FRuu/rOu3x +1hQ== 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=4U5fA8bZ2v7pR/pTYqty+yTdhBVClsTEYlT8g5psnbQ=; b=PZV7rlX7vqmK8zhe9KUbGhnpaFqdBmga8wykJYmvop0c0mgF7Vz5IIN1HOVQF9SsnG 26jd5PCIkNLMTjDRmu8sFVwo8EEteYjrV02xjPD4x+j9rpuoArH6RaY8zbrVOKjfloEf 63TCDs8CCwywSBEbExP8xilSqJTpz14qfz7hdd4ZIJl62yh3gq37cKRBl+Xh2wXj/f+S Ch47JK2xuiJDE4cYxl60b/5NuIIhLg5zzuqSwH4u7wTghbKmx+cRaNBCumE+Bs4vpIwH Q+SP/WMmTrgh8VagsVm3pCxgCEG5kiRxqLGC5LtPpvHmmHPaOInusS39gRhVesANCnGN v8QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=B7WSfjEQ; 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 g20-v6si17338060pgv.427.2018.06.11.01.13.19; Mon, 11 Jun 2018 01:13:34 -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=B7WSfjEQ; 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 S1754123AbeFKILo (ORCPT + 99 others); Mon, 11 Jun 2018 04:11:44 -0400 Received: from mail-ot0-f196.google.com ([74.125.82.196]:33128 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754053AbeFKILn (ORCPT ); Mon, 11 Jun 2018 04:11:43 -0400 Received: by mail-ot0-f196.google.com with SMTP id h6-v6so22764339otj.0 for ; Mon, 11 Jun 2018 01:11:43 -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=4U5fA8bZ2v7pR/pTYqty+yTdhBVClsTEYlT8g5psnbQ=; b=B7WSfjEQ2KGcf/v0X6eorSNZyNEnCLMnJPGEfIXQxIEBc7JOCyi7e0uUcqN6r5QJ8s 9fO0HThMnCDe3e2AoEWJIvb+16X38Ahv79x3KCjPOlEO14ePvuX088iyhqvsgRFwaiBo gs7OhciD5q/Lih6ahq/xLOGD1TW6CAc0yXPdI= 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=4U5fA8bZ2v7pR/pTYqty+yTdhBVClsTEYlT8g5psnbQ=; b=nwhnfFyeikbWTNWDQCLNaIZs7L0KCJrXUm1nja5TAkkcjXvZ/t/i48hvP8WFjGpa5z /0g84EO3tyJpwwrEpdi2AInLW54N2mNZM32F5rPf+DoXwGfF2CX0cXM3CDokEsOEmh2N TAdAbibRS2/FuN5yn0bVvDZ5Hot4CKWaTb3JkS8n/sJrpJXbioWGasfN8y8kvPknrnrz yTIWaa/seROZ2nmbAlByYoiIvz4lTXdDWYEl02hEYCCkBGM8s22FIWmHuk+KzPKV4EZF 2CQDAW7UTbQsfeZitRbXRnS9WnnKKYY44MVEdKehqJVBL07BeTs7YqmWLpH8tXG56L1u VQHg== X-Gm-Message-State: APt69E1Js9SuWtBWWifS/8YYQCL6PzIEKIAvDqvaKP6f8m1nxE89XFHV eqvJV+fIGWvCdMDvz0QjOKCS5jcUjRnvCQLeuBOT3A== X-Received: by 2002:a9d:1bd6:: with SMTP id v22-v6mr9850946otv.85.1528704702739; Mon, 11 Jun 2018 01:11:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1123:0:0:0:0:0 with HTTP; Mon, 11 Jun 2018 01:11:42 -0700 (PDT) X-Originating-IP: [194.176.227.33] In-Reply-To: <20180610054156.GP30522@ZenIV.linux.org.uk> References: <20180529144339.16538-1-mszeredi@redhat.com> <20180529144339.16538-16-mszeredi@redhat.com> <20180610054156.GP30522@ZenIV.linux.org.uk> From: Miklos Szeredi Date: Mon, 11 Jun 2018 10:11:42 +0200 Message-ID: Subject: Re: [PATCH 15/39] ovl: add helper to return real file To: Al Viro 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 Sun, Jun 10, 2018 at 7:42 AM, Al Viro wrote: > On Tue, May 29, 2018 at 04:43:15PM +0200, Miklos Szeredi wrote: >> In the common case we can just use the real file cached in >> file->private_data. There are two exceptions: >> >> 1) File has been copied up since open: in this unlikely corner case just >> use a throwaway real file for the operation. If ever this becomes a >> perfomance problem (very unlikely, since overlayfs has been doing most fine >> without correctly handling this case at all), then we can deal with that by >> updating the cached real file. > > See the ovl_mmap() problem. FWIW, I would probably suggest something along > the lines of > ->private_data either points to struct file, or is 1 | address of > 2-element array of struct file * > odd value => mask bit 0 away, cast to struct file ** and dereference > even value and it's still in the right layer => use that > even value and it is in the wrong layer => > allocate a two-pointer array > open in the right layer > stick that into array[0] and original - into array[1] > cmpxchg array | 1 into ->private_data > if that succeeds > return array[0] > else > fput array[0], free array, then use the value returned > by cmpxchg - mask bit 0 away, cast and dereference Iff we really need that complexity, then yes, that's a nice solution. But I think we don't: see incremental posted for ->mmap() issue + for plain I/O we don't really care about this case, since it happens so rarely. Maybe later... Thanks, Miklos