Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4618500imm; Wed, 30 May 2018 08:49:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJGRyQ0lfobM1BKNxK1AHm0Smn0SgC2nWmZ4T3DmZlcXSgxMG8UNjz3sXWZsXgfccMetJg X-Received: by 2002:a63:744a:: with SMTP id e10-v6mr2640983pgn.275.1527695355582; Wed, 30 May 2018 08:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527695355; cv=none; d=google.com; s=arc-20160816; b=NqmoI4VcaclNA1NXFAzp4AllwElqSGOnF/3BxuqWN3DReLMvQ8bw3UQ0bbDtOH/Aff uu0l6XtvSShoJGPXyTRs+TwOQ8wI7zzXcCGzB9UmkbjAiiGfvGt/eLGl2iRCi5LaHWay Rs6NUBKqjIcQAXLt+oiOs8A9QHr826snrlx6JdW/5VC2U3ULv10o7q1HU+XxHridz0fs x8vZUPrDHkayLS4IzCQ2Pqqhz8F7xj2XuJBG/YCgw5V06+lWpDQevOdRAkJTZI2jOVQ8 CF1IMyp/yyYc+MmPr2mJcL4h3oGDCei3RzGyQlef8IGBIyZ3zfCauqC1qKYJFEwm/sIC V56A== 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=57BFN6Y5Z/T3oHiih8+7TZqA9sxsdR7xx1LpPaAFzBE=; b=IM7+gkJ4jIvkmrEZd5ObpG2CxDqKKJAq9+d/ulW/2FN8mK9BiMwM1fxMZ+lIXT3krZ HwpV29JECYDtlWGA6lDsTpap2mJ2bGByjIBl0P/drC44SV8mQFW7gj4H/Z+XSNhZTRXU TCBi896SiDhBJ5s3JcOXSIXYQ3E0YdWffMD035K/AzJbGDJPiH5H7w+7mRQYFH8iAF3e cJV9nuVhMPMuanexf9Gn6fwdIk8LaIKiqTHM5lDtH3Pwo6JlEqhYqqEmTLauT3uJTGU9 TsIV/AihzMgSabSS9LTCFxxVHsRJ5XD+VaciKUfOnU2JosneSQGF5rxDSyBPO6wIPt6e fc1Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12-v6si27171814pgu.115.2018.05.30.08.49.01; Wed, 30 May 2018 08:49:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932078AbeE3Psb (ORCPT + 99 others); Wed, 30 May 2018 11:48:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42212 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753561AbeE3Ps2 (ORCPT ); Wed, 30 May 2018 11:48:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92D6781663CC; Wed, 30 May 2018 15:48:27 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FE7C7D55C; Wed, 30 May 2018 15:48:27 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id D50432239B4; Wed, 30 May 2018 11:48:26 -0400 (EDT) Date: Wed, 30 May 2018 11:48:26 -0400 From: Vivek Goyal To: Miklos Szeredi Cc: Miklos Szeredi , overlayfs , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 15/28] ovl: Open file with data except for the case of fsync Message-ID: <20180530154826.GC2717@redhat.com> References: <20180529144612.16675-1-mszeredi@redhat.com> <20180529144612.16675-16-mszeredi@redhat.com> <20180530143044.GB2717@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 30 May 2018 15:48:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 30 May 2018 15:48:27 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vgoyal@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 30, 2018 at 05:12:16PM +0200, Miklos Szeredi wrote: > >> From: Vivek Goyal > >> > >> ovl_open() should open file which contains data and not open metacopy > >> inode. With the introduction of metacopy inodes, with current > >> implementaion we will end up opening metacopy inode as well. > >> > >> But there can be certain circumstances like ovl_fsync() where we want to > >> allow opening a metacopy inode instead. > >> > >> Hence, change ovl_open_realfile() and add _ovl_open_real() and add extra > >> parameter which specifies whether to allow opening metacopy inode or not. > >> If this parameter is false, we look for data inode and open that. > >> > >> This should allow covering both the cases. > >> > >> Signed-off-by: Vivek Goyal > >> Reviewed-by: Amir Goldstein > >> Signed-off-by: Miklos Szeredi > >> --- > >> fs/overlayfs/file.c | 39 ++++++++++++++++++++++++++++++--------- > >> 1 file changed, 30 insertions(+), 9 deletions(-) > >> > >> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c > >> index 266692ce9a9a..c7738ef492c8 100644 > >> --- a/fs/overlayfs/file.c > >> +++ b/fs/overlayfs/file.c > >> @@ -14,11 +14,20 @@ > >> #include > >> #include "overlayfs.h" > >> > >> -static struct file *ovl_open_realfile(const struct file *file) > >> +static char ovl_whatisit(struct inode *inode, struct inode *realinode) > >> +{ > >> + if (realinode != ovl_inode_upper(inode)) > >> + return 'l'; > >> + if (ovl_has_upperdata(inode)) > >> + return 'u'; > >> + else > >> + return 'm'; > >> +} > >> + > >> +static struct file *ovl_open_realfile(const struct file *file, > >> + struct inode *realinode) > >> { > >> 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; > >> > >> @@ -28,7 +37,7 @@ static struct file *ovl_open_realfile(const struct file *file) > >> revert_creds(old_cred); > >> > >> pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n", > >> - file, file, upperinode ? 'u' : 'l', file->f_flags, > >> + file, file, ovl_whatisit(inode, realinode), file->f_flags, > >> realfile, IS_ERR(realfile) ? 0 : realfile->f_flags); > >> > >> return realfile; > >> @@ -72,17 +81,24 @@ static int ovl_change_flags(struct file *file, unsigned int flags) > >> return 0; > >> } > >> > >> -static int ovl_real_fdget(const struct file *file, struct fd *real) > >> +static int ovl_real_fdget_meta(const struct file *file, struct fd *real, > >> + bool allow_meta) > >> { > >> struct inode *inode = file_inode(file); > >> + struct inode *realinode; > >> > >> real->flags = 0; > >> real->file = file->private_data; > >> > >> + if (allow_meta) > >> + realinode = ovl_inode_real(inode); > >> + else > >> + realinode = ovl_inode_realdata(inode); > >> + > >> /* Has it been copied up since we'd opened it? */ > >> - if (unlikely(file_inode(real->file) != ovl_inode_real(inode))) { > >> + if (unlikely(file_inode(real->file) != realinode)) { > >> real->flags = FDPUT_FPUT; > >> - real->file = ovl_open_realfile(file); > >> + real->file = ovl_open_realfile(file, realinode); > >> > >> return PTR_ERR_OR_ZERO(real->file); > >> } > >> @@ -94,6 +110,11 @@ static int ovl_real_fdget(const struct file *file, struct fd *real) > >> return 0; > >> } > >> > >> +static int ovl_real_fdget(const struct file *file, struct fd *real) > >> +{ > >> + return ovl_real_fdget_meta(file, real, false); > >> +} > >> + > >> static int ovl_open(struct inode *inode, struct file *file) > >> { > >> struct dentry *dentry = file_dentry(file); > >> @@ -107,7 +128,7 @@ static int ovl_open(struct inode *inode, struct file *file) > >> /* No longer need these flags, so don't pass them on to underlying fs */ > >> file->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); > >> > >> - realfile = ovl_open_realfile(file); > >> + realfile = ovl_open_realfile(file, ovl_inode_real(file_inode(file))); > > That was meant to be > > + realfile = ovl_open_realfile(file, ovl_inode_realdata(file_inode(file))); > > Is that correct? Yes, that's correct. While we are at it, can we also update patch changelog. I see that _ovl_open_real() is not there anymore. Thanks Vivek