Received: by 10.192.165.148 with SMTP id m20csp2826812imm; Mon, 7 May 2018 01:44:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQr/UDJwtztSBIwGxZAy+fLZBW1BTBbcDZ3Y7ACz7ABe/KlQ5SOT4Y3pcMwvZFoyjGnsiq X-Received: by 10.98.18.17 with SMTP id a17mr36217267pfj.104.1525682640036; Mon, 07 May 2018 01:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525682639; cv=none; d=google.com; s=arc-20160816; b=vQF7jurXYIyoQ8wuGEw0cv1BJ+1wAdJNo2TtbAba9WaccRs1PHh6rUORfdw+sufYZg VGXKX8Oxzhry1f151yiH+sd/dYePqW5GM/VDa1+zWFBhH5+MO2SHHe1mC0MqFBzj1Mwl BQKRL6r+0EHxntXQg1C0tM4wUnMavJonJrP+GawwFr5QHdDMI1jE/lHKCJojWQy7CZvh yffyPJBxOd/bmaqC24H1hFF0sqap259els7P4VO8qfUMl8ARRQtKrBNjdoOJmdw3UbYW hAukBooeJ5IZsSV3POyVMkBdWES+vs9WXEZ4cEy/osq4RF16liSUZc98hAReyt304aBO 8iig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=BElHOwQsLXNFeh3Ppd/NjLrFUQEEkh1inZAwNkRGtwE=; b=vW9qb5b7Fg4wIzAytJg2PrGYIO/4Nd+JxvHtqerx59lCHIf5DhJZnqT6LeGl3pasE4 VdHfpVfaGvQLOMQnEPOH3CVKH7xZrRuQLX4bsy759nZWTd1uiXNggtl2BTDgP+Qdm+RY GWt8lTwTrScaYctNHUSgclA+aDgdz/28dexgrr2uU5JCgQmGb/gJJ61Z4iJTzNZmjcRe kQ0+hgbsQAA2EQbHsgoDyNSYIMtpl0DeaMpfxWYegv5Zeghrp6R3KlqGvMkom3UthjsJ nhMvP4/YbEFAl+4Cbs2jq9IU3tMoIIB+NUhR7RLPGR18CDTSMyigbJLJuy3POXoWm59U kaJQ== 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 o3-v6si3524366pls.64.2018.05.07.01.43.45; Mon, 07 May 2018 01:43:59 -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 S1752221AbeEGIkx (ORCPT + 99 others); Mon, 7 May 2018 04:40:53 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42203 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752264AbeEGIiw (ORCPT ); Mon, 7 May 2018 04:38:52 -0400 Received: by mail-wr0-f196.google.com with SMTP id v5-v6so27853090wrf.9 for ; Mon, 07 May 2018 01:38:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BElHOwQsLXNFeh3Ppd/NjLrFUQEEkh1inZAwNkRGtwE=; b=igWUFXkNRXnrcrEmdINcbmiODvhShGXBEGVHpYSql1HhUPcwIpxyTEgDLTC3KouT1Z U3wWR1zqf7nfjyT1tqT8YuzozU7hxzeieDQ7d7aYwaHnAsJrBulcs55Vk875IYYFDZ4T JyHv81W59etxbJPd2rJyvmZkm5KHmm34hlh2vPW51IqfrRsAxIZmF47l5U+Rd5a6rT0W NU46jNCVUdvWIfPtvzlcKZ2cmdG6JccGwr1Cmg84pny1AAU9IB/xphMikKRxy7PzFBfU a1HFtnO2jh3myuqsgTLAvMaynA1MfaHmnY8UmwYXhBSLcn/Cf5pca3LUZTXPmEYn23Wt +QPQ== X-Gm-Message-State: ALQs6tAKbMNEjwIUUleoXNzFkojLITx/77p+FQvcHFwGT+b3uFU+dqN5 yg6YTKiRDIcJD6uadExhW50N7w== X-Received: by 2002:adf:9d0d:: with SMTP id k13-v6mr30538034wre.179.1525682331095; Mon, 07 May 2018 01:38:51 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id h8-v6sm5908050wmc.16.2018.05.07.01.38.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 01:38:50 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH v2 34/35] vfs: remove open_flags from d_real() Date: Mon, 7 May 2018 10:38:06 +0200 Message-Id: <20180507083807.28792-35-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180507083807.28792-1-mszeredi@redhat.com> References: <20180507083807.28792-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Opening regular files on overlayfs is now handled via ovl_open(). Remove the now unused "open_flags" argument from d_op->d_real() and the d_real() helper. Signed-off-by: Miklos Szeredi --- Documentation/filesystems/Locking | 3 +-- Documentation/filesystems/vfs.txt | 16 ++++------------ fs/overlayfs/super.c | 36 +++--------------------------------- include/linux/dcache.h | 11 ++++------- include/linux/fs.h | 2 +- 5 files changed, 13 insertions(+), 55 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index a4afe96f0112..e1d7e43d302c 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -21,8 +21,7 @@ prototypes: char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); struct vfsmount *(*d_automount)(struct path *path); int (*d_manage)(const struct path *, bool); - struct dentry *(*d_real)(struct dentry *, const struct inode *, - unsigned int); + struct dentry *(*d_real)(struct dentry *, const struct inode *); locking rules: rename_lock ->d_lock may block rcu-walk diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index af54d3651ff8..8b03c5e675bf 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -990,8 +990,7 @@ struct dentry_operations { char *(*d_dname)(struct dentry *, char *, int); struct vfsmount *(*d_automount)(struct path *); int (*d_manage)(const struct path *, bool); - struct dentry *(*d_real)(struct dentry *, const struct inode *, - unsigned int); + struct dentry *(*d_real)(struct dentry *, const struct inode *); }; d_revalidate: called when the VFS needs to revalidate a dentry. This @@ -1125,22 +1124,15 @@ struct dentry_operations { dentry being transited from. d_real: overlay/union type filesystems implement this method to return one of - the underlying dentries hidden by the overlay. It is used in three + the underlying dentries hidden by the overlay. It is used in two different modes: - Called from open it may need to copy-up the file depending on the - supplied open flags. This mode is selected with a non-zero flags - argument. In this mode the d_real method can return an error. - Called from file_dentry() it returns the real dentry matching the inode argument. The real dentry may be from a lower layer already copied up, but still referenced from the file. This mode is selected with a - non-NULL inode argument. This will always succeed. - - With NULL inode and zero flags the topmost real underlying dentry is - returned. This will always succeed. + non-NULL inode argument. - This method is never called with both non-NULL inode and non-zero flags. + With NULL inode the topmost real underlying dentry is returned. Each dentry has a pointer to its parent dentry, as well as a hash list of child dentries. Child dentries are basically like files in a diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index f2a83fabe2eb..492d534058ae 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -80,28 +80,10 @@ static void ovl_dentry_release(struct dentry *dentry) } } -static int ovl_check_append_only(struct inode *inode, int flag) -{ - /* - * This test was moot in vfs may_open() because overlay inode does - * not have the S_APPEND flag, so re-check on real upper inode - */ - if (IS_APPEND(inode)) { - if ((flag & O_ACCMODE) != O_RDONLY && !(flag & O_APPEND)) - return -EPERM; - if (flag & O_TRUNC) - return -EPERM; - } - - return 0; -} - static struct dentry *ovl_d_real(struct dentry *dentry, - const struct inode *inode, - unsigned int open_flags) + const struct inode *inode) { struct dentry *real; - int err; /* It's an overlay file */ if (inode && d_inode(dentry) == inode) @@ -113,28 +95,16 @@ static struct dentry *ovl_d_real(struct dentry *dentry, goto bug; } - if (open_flags) { - err = ovl_open_maybe_copy_up(dentry, open_flags); - if (err) - return ERR_PTR(err); - } - real = ovl_dentry_upper(dentry); - if (real && (!inode || inode == d_inode(real))) { - if (!inode) { - err = ovl_check_append_only(d_inode(real), open_flags); - if (err) - return ERR_PTR(err); - } + if (real && (!inode || inode == d_inode(real))) return real; - } real = ovl_dentry_lower(dentry); if (!real) goto bug; /* Handle recursion */ - real = d_real(real, inode, open_flags); + real = d_real(real, inode); if (!inode || inode == d_inode(real)) return real; diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 58fcc66ddccd..2458b18b9356 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -145,8 +145,7 @@ struct dentry_operations { char *(*d_dname)(struct dentry *, char *, int); struct vfsmount *(*d_automount)(struct path *); int (*d_manage)(const struct path *, bool); - struct dentry *(*d_real)(struct dentry *, const struct inode *, - unsigned int); + struct dentry *(*d_real)(struct dentry *, const struct inode *); } ____cacheline_aligned; /* @@ -567,7 +566,6 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper) * d_real - Return the real dentry * @dentry: the dentry to query * @inode: inode to select the dentry from multiple layers (can be NULL) - * @flags: open flags to control copy-up behavior * * If dentry is on a union/overlay, then return the underlying, real dentry. * Otherwise return the dentry itself. @@ -575,11 +573,10 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper) * See also: Documentation/filesystems/vfs.txt */ static inline struct dentry *d_real(struct dentry *dentry, - const struct inode *inode, - unsigned int flags) + const struct inode *inode) { if (unlikely(dentry->d_flags & DCACHE_OP_REAL)) - return dentry->d_op->d_real(dentry, inode, flags); + return dentry->d_op->d_real(dentry, inode); else return dentry; } @@ -594,7 +591,7 @@ static inline struct dentry *d_real(struct dentry *dentry, static inline struct inode *d_real_inode(const struct dentry *dentry) { /* This usage of d_real() results in const dentry */ - return d_backing_inode(d_real((struct dentry *) dentry, NULL, 0)); + return d_backing_inode(d_real((struct dentry *) dentry, NULL)); } struct name_snapshot { diff --git a/include/linux/fs.h b/include/linux/fs.h index 417e692a606a..8b8d793b3774 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1234,7 +1234,7 @@ static inline struct inode *file_inode(const struct file *f) static inline struct dentry *file_dentry(const struct file *file) { - return d_real(file->f_path.dentry, file_inode(file), 0); + return d_real(file->f_path.dentry, file_inode(file)); } static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl) -- 2.14.3