Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3722173imm; Mon, 11 Jun 2018 00:09:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKHjyzt6D3xuhyJTEO+fpSRR+pS54yKamhQgRgKE+Rna34k0Er9ruywmPPQHXbsHHpEJZmy X-Received: by 2002:a62:4282:: with SMTP id h2-v6mr16303054pfd.242.1528700990963; Mon, 11 Jun 2018 00:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528700990; cv=none; d=google.com; s=arc-20160816; b=TFE78oS/N3Ahu7ezmtBCpun6OAwdmiCsmiHbtZgSoBxg9si2yb/kQPX7HzKwDptkDo KRC865xnA77XjXI7HFPhKbJjDwAcShXUr5C5eboGisxST2/bIvQXnLnLYzq3WwnXwkdG XduRMXF87SAwq6RRWUbIbsRGIeDqbG8x3o0kGKcuT4C2shNxT8spFtfOOJkVMEnwLsY8 0Gq5zDteU88/3nhA9GYUwpaGtu7iaLhVLZ0Dx01+gJsBL8ohnR2m3he9+WsQwMpvQ2lJ 6uO0bz3Tk7eWflmN+N8CH5xpUJqmVRl5TxnJwkpk9zvF3Bj5u93+xo2f4deI+mrNQTcZ Z6VA== 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=EbE77kF6+OynJ/bbplasKtmMn1oidHGDxdyMxsprOQg=; b=aoKwW8l0VJ7vTEXqN/3/PWx43cwqoNb5kyT8QhDbOH886TH2C+WJrrt7vhRtkiZPjB MSKikIBqkG1H5aEWTcWGX6PoGvldOR+twZa35mLoELqSz4JT3svR4TvvRWCm6vwRyglZ hk+PKDvGW6ri3T3uftE6drZEA7DO3RrtK4uiDfUUJF5JKA26zAt1w+gPYj4kc4HFF77l gugSd9agcf5xQPtf534RrXjH7PgLVsBAbw+Rdr+oNsGD93Hlrkcr8VExi6CQUMi2a5/Z /4Qrpj8LtL403vyuzi5DhXzIh0ACIolJBeJ4Vpt+AvhSYXYJZsl9OalqReTEG7ECgSre iWhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=MeaLhXvX; 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 j84-v6si28682927pfj.79.2018.06.11.00.09.36; Mon, 11 Jun 2018 00:09:50 -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=MeaLhXvX; 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 S932433AbeFKHJH (ORCPT + 99 others); Mon, 11 Jun 2018 03:09:07 -0400 Received: from mail-ot0-f194.google.com ([74.125.82.194]:38151 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932109AbeFKHJF (ORCPT ); Mon, 11 Jun 2018 03:09:05 -0400 Received: by mail-ot0-f194.google.com with SMTP id n3-v6so22575075ota.5 for ; Mon, 11 Jun 2018 00:09:05 -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=EbE77kF6+OynJ/bbplasKtmMn1oidHGDxdyMxsprOQg=; b=MeaLhXvXkCJp4r3oEAZBcabo5yT+D4oZrf89mZZiOyMnNVItio+Uybd0FgTv7J1Y33 k5E+JNP1d1SsAo434qGLk1ewAN8eEoY5y7pgChj5UqEyiu/tVWozS5wW6j+RqLxpndIx hFNDHxVjxU+5Ew3f+pMh7RcuQEDVGyLsmJsGw= 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=EbE77kF6+OynJ/bbplasKtmMn1oidHGDxdyMxsprOQg=; b=QCW+jiyIRyZS55WnBH3WmXFdnDN7AnMatzkoUER8DPHkjeVidcIZ3ecKvS6AXt1am3 FPnpSU4GXa/e2V9jBLGXDuxWgvJQUXKF7uJa3HL390R5tCUOOOkTSpJhCP9XTPOL5O1X 0TayYwl/MLSYMfHB1e7UmGht1D2mtISRCkOlHXo4Jf9wx+S1eQh2AREKNxLcz03R1qX8 7Aib3MZkJk6mUtFdsm4rRRuUh0lV6+TN7dZAWlr9ADwIxc699EXpuoVq3Oruxt8wD77A eYur4u2dlVAK7spUxu1MEVM8ex0cTw+YlqtFaDdLg1eoY8oqglyGigM/5vaJf+ElhH9q Sr/w== X-Gm-Message-State: APt69E0KGlsdEBPU8NRRcYdfgztlARC2KgGnGC+YbgJwSoMgjzFbj/r5 maz+MyzSPW6vnqhZ3mCT2fCVmcqR4dVtbWgYFMkPEw== X-Received: by 2002:a9d:19e8:: with SMTP id k95-v6mr8651302otk.368.1528700945150; Mon, 11 Jun 2018 00:09:05 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1123:0:0:0:0:0 with HTTP; Mon, 11 Jun 2018 00:09:04 -0700 (PDT) X-Originating-IP: [194.176.227.33] In-Reply-To: <20180610041243.GJ30522@ZenIV.linux.org.uk> References: <20180529144339.16538-1-mszeredi@redhat.com> <20180529144339.16538-15-mszeredi@redhat.com> <20180610041243.GJ30522@ZenIV.linux.org.uk> From: Miklos Szeredi Date: Mon, 11 Jun 2018 09:09:04 +0200 Message-ID: Subject: Re: [PATCH 14/39] ovl: stack file ops 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 6:13 AM, Al Viro wrote: > On Tue, May 29, 2018 at 04:43:14PM +0200, Miklos Szeredi wrote: >> Implement file operations on a regular overlay file. The underlying file >> is opened separately and cached in ->private_data. >> >> It might be worth making an exception for such files when accounting in >> nr_file to confirm to userspace expectations. We are only adding a small >> overhead (248bytes for the struct file) since the real inode and dentry are >> pinned by overlayfs anyway. >> >> This patch doesn't have any effect, since the vfs will use d_real() to find >> the real underlying file to open. The patch at the end of the series will >> actually enable this functionality. > >> +static struct file *ovl_open_realfile(const struct file *file) >> +{ >> + struct inode *inode = file_inode(file); >> + struct inode *upperinode = ovl_inode_upper(inode); >> + struct inode *realinode = upperinode ?: ovl_inode_lower(inode); >> + struct file *realfile; >> + const struct cred *old_cred; >> + >> + old_cred = ovl_override_creds(inode->i_sb); >> + realfile = path_open(&file->f_path, file->f_flags | O_NOATIME, >> + realinode, current_cred(), false); >> + revert_creds(old_cred); >> + >> + pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n", >> + file, file, upperinode ? 'u' : 'l', file->f_flags, >> + realfile, IS_ERR(realfile) ? 0 : realfile->f_flags); >> + >> + return realfile; >> +} > > IDGI. OK, you open a file in the layer you want; good, but why the hell do you > *not* use the dentry/vfsmount from the same layer? > > IOW, why does your path_open() get an explicit inode argument at all? With the > rest of the work done in that series it looks like you should be able to use > vfs_open() instead... Sure, for ovlfs file you want ->f_path on overlayfs and > not in a layer, but why do the same for those? I'd really like to get there some time but... List of basic requirements: - Private mmap of overlay file shares page cache with lower file (and hence with all other overlays using the same lower file). - /proc/PID/maps shows correct path. Thought about setting f_mapping/i_mapping of overlay file to that of underlying file. But that breaks when doing a copy-up. We can't just go and change those mapping pointers, assumption is that those remain constant (we'd need READ_ONCE() for all cases where we use the mapping more than once). It's probably doable, but it's a large and fragile change. Thanks, Miklos