Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2680261imm; Sat, 9 Jun 2018 22:43:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK32yOUUUcn3idGPv2p/7Dvn9nWqASo0U4hpTgXWWUxxIIlE9l8A4ZosB7Ag8haqhLH4iIC X-Received: by 2002:a63:a553:: with SMTP id r19-v6mr10655212pgu.147.1528609397136; Sat, 09 Jun 2018 22:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528609397; cv=none; d=google.com; s=arc-20160816; b=EVJRteUwo89ZqRF7FDNzpVxyvp3BZ7+clFoCbti7SBAQBD30JxTBSM1ccBPCmxUps+ bGZ1f4Rie4KMuLM6kbwJSgsvsLc+3pd0OQM/D0tF2v8QpFmhz2of+bCm5sNS0soCq1pQ tdBoxHmp9dVpBaGBG0wDutflIoDKLVwfkaqr1hXV96VaEOIqwWnl+OpHaGQby0iRKGKj WeO9IqzDEoOEGlZF1HofR+SnLXRULUi7+UD0pUe328meFZPFrz2my5ZGtNS7p21GADGj 6zqU9RxuinkaqTdL9dSJsYocckxKVPblSnp8HFmyL8qVo+xEDZNveWRspi3e0PILb/bv 2BpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=FJEVrMdTUhKEDf7f0jEYJPw0KkVrcpw6lfcw6cLBRVQ=; b=ZPG8QZCzX5IGTHZAFzUf1xY/TEUnY+FgkRlo+YJfGuq/l4hCJdFsJ3URxHqycOeEqG 0A6huXWDaP04ijmNVQ2Dbj1cQVTPLHebKuHJ7Jk7wKkOq3pjpPVL0E9DRy754IXf4fC0 a9Dq96tgcVXh5dErEEx1gn3Mzx7h7CnzFEUt3I3sbZe0Qtx/DHPyaNS+7i2JgAInjIkH wG6ncgr42SWT0/8gsUo3WWdpfRDSssHSXcryFBEF+XrJ5tN9eCqOtVvlD0qwSlv2ECzD SAsZa8nxPrxsHsS0X4gStS7JlWpWb4umLenlRreg3ciS+uiDo7WCIFHDBQceOtoLDv8j Ok8Q== ARC-Authentication-Results: i=1; mx.google.com; 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 6-v6si14827173pfb.204.2018.06.09.22.43.03; Sat, 09 Jun 2018 22:43:17 -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; 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 S1753751AbeFJFmg (ORCPT + 99 others); Sun, 10 Jun 2018 01:42:36 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:54310 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751518AbeFJFmf (ORCPT ); Sun, 10 Jun 2018 01:42:35 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fRt76-0003wX-78; Sun, 10 Jun 2018 05:42:10 +0000 Date: Sun, 10 Jun 2018 06:42:04 +0100 From: Al Viro To: Miklos Szeredi Cc: linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 15/39] ovl: add helper to return real file Message-ID: <20180610054156.GP30522@ZenIV.linux.org.uk> References: <20180529144339.16538-1-mszeredi@redhat.com> <20180529144339.16538-16-mszeredi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180529144339.16538-16-mszeredi@redhat.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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