Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3487497imm; Tue, 29 May 2018 08:05:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqY+jv+/SSwyzWWkFZ45IUsVoKWJmN9ZqTLmPe072KOH0h3OaKYgxYzUnUiykGHVNmE7YIr X-Received: by 2002:a17:902:8c81:: with SMTP id t1-v6mr17741841plo.310.1527606309117; Tue, 29 May 2018 08:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527606309; cv=none; d=google.com; s=arc-20160816; b=g8gTFNZ5n1HZ3KEhnwyTaIUd8Jj1qTpBmzo3JgH1dn2Caj2vxbKTKleKeKwI1xepRV Upru9XwyUroE9DDx1XjQo8ZW/m+fx2sCBan7MPIyBs/GU+20Hyb6jyvEMGKgaN0SEyKH tnZtcdtZLc/SoUUsvQHFtU+d1ah58m+tm7SNaurPspW1T91HbIsmliduqlGj3iQdCbVc Eb9vzmPxpTzLlsryU4Rm3iGs/evq3Gh+ix1r4BEyhp4kpKqDYf7SC++fVfBjbmBAVLAU IZeSEwKaTJGAcNKVv9RRjKtXZKU7F3Je021R2zcq8pR1XTWLyXQ3zkmxFLOnjx8z9OKt lYxg== 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=K+evSNrcR+hzMlH67HiBtRanECSTnzt9P3myjMjxm5A=; b=FePX2HljC3SKi5vyMPl/92bKjfZdNoenXEizTrw3zJS7Jiu0PATpzu5WjVFySg6tSg 0Lh+PDmUAvpZsAjJZqx88vfQGrsmlWnvgFYYOJGStDWAHhqD+8wCpSgFArzsT9+Hvhsl B0h1dV8Oe1DCMm9F3fRL4wPzmRvkFHcC8XwgGrzY712rqdc2xY2FJjazqEZykQ3NJFVa LJ+Mr4ZuJSA1wHMB96LNlyqss2Oi7p6wvqEF+wcvgSFtjqkvL9mbfsP0txXlMYT3lQrm 6Zuk9W+jFK12Iy341CWm3KCUtp++pZz3NNLldHVhGMralBBo5bFJJsS+R/q3olihPDwf 3JtQ== 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 u70-v6si12619471pgc.376.2018.05.29.08.04.55; Tue, 29 May 2018 08:05:09 -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 S935744AbeE2PEH (ORCPT + 99 others); Tue, 29 May 2018 11:04:07 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36155 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935368AbeE2Oob (ORCPT ); Tue, 29 May 2018 10:44:31 -0400 Received: by mail-wm0-f68.google.com with SMTP id v131-v6so22136496wma.1 for ; Tue, 29 May 2018 07:44:30 -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=K+evSNrcR+hzMlH67HiBtRanECSTnzt9P3myjMjxm5A=; b=tParvlOejYTJkrPfSiADLmNDOjNDHBMKGe3AGHIqR+zUcTBpxx9r3K7T529e1He42u gDMBvx/tcXVQybinsD/ig1lisbAKtFqLTHkZ5Zlkp6NKDW8y/MMGUUuW+oZZ572xbL8x sgnh2P0hGSsXj8qRPzTtBqGJ2UM7xUpuplAWhgwDrKZMvTjjOtFyFCnfCGIN3eq3ytGh RyWeG8XApFaLksCcPcHJe7wHauxes4lNsAlzeeVGAH262AaR0if2QzbgneETFedETVkb MjtvvAFrl5ABOb3iLCi+yQvsGex0RwTlaWJPazwVtJNszhSX97kRXiBoqnk1dhjAesQf rLAg== X-Gm-Message-State: ALKqPwfyxF0e4NH8sTg8Jt5qM68cEZQZjJujrIgBEZZ/qujZYaE569Hw hpiN/YaQxYRC7iVnqaU/YVoc9w== X-Received: by 2002:a1c:f407:: with SMTP id z7-v6mr3807756wma.143.1527605069776; Tue, 29 May 2018 07:44:29 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id t198-v6sm18834422wmt.23.2018.05.29.07.44.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:44:29 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 39/39] vfs: remove open_flags from d_real() Date: Tue, 29 May 2018 16:43:39 +0200 Message-Id: <20180529144339.16538-40-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144339.16538-1-mszeredi@redhat.com> References: <20180529144339.16538-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 d7df69e5b674..cd5c82f105d6 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 8fe4efa94af6..78cea80423a3 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; /* @@ -568,7 +567,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. @@ -576,11 +574,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; } @@ -595,7 +592,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 7471a4208fdc..eb4c189d34ba 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