From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com ([74.125.82.65]:35091 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750867AbcEQVzZ (ORCPT ); Tue, 17 May 2016 17:55:25 -0400 Received: by mail-wm0-f65.google.com with SMTP id g17so1547703wme.2 for ; Tue, 17 May 2016 14:55:24 -0700 (PDT) Date: Tue, 17 May 2016 23:55:20 +0200 From: Miklos Szeredi To: Al Viro Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Howells Subject: [PATCH 2/3] vfs: document ->d_real() Message-ID: <20160517215520.GB1589@veci.piliscsaba.szeredi.hu> References: <20160517215326.GA1589@veci.piliscsaba.szeredi.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160517215326.GA1589@veci.piliscsaba.szeredi.hu> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Add missing documentation for the d_op->d_real() method and d_real() helper. Signed-off-by: Miklos Szeredi --- Documentation/filesystems/Locking | 2 ++ Documentation/filesystems/vfs.txt | 19 +++++++++++++++++++ include/linux/dcache.h | 7 +++++++ 3 files changed, 28 insertions(+) --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -20,6 +20,7 @@ be able to use diff(1). char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); struct vfsmount *(*d_automount)(struct path *path); int (*d_manage)(struct dentry *, bool); + struct dentry *(*d_real)(struct dentry *, struct inode *, unsigned int); locking rules: rename_lock ->d_lock may block rcu-walk @@ -34,6 +35,7 @@ d_iput: no no yes no d_dname: no no no no d_automount: no no yes no d_manage: no no yes (ref-walk) maybe +d_real no no yes no --------------------------- inode_operations --------------------------- prototypes: --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -938,6 +938,7 @@ struct dentry_operations { char *(*d_dname)(struct dentry *, char *, int); struct vfsmount *(*d_automount)(struct path *); int (*d_manage)(struct dentry *, bool); + struct dentry *(*d_real)(struct dentry *, struct inode *, unsigned int); }; d_revalidate: called when the VFS needs to revalidate a dentry. This @@ -1060,6 +1061,24 @@ struct dentry_operations { This function is only used if DCACHE_MANAGE_TRANSIT is set on the 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 + 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. + + This method is never called with both non-NULL inode and non-zero flags. + Example : static char *pipefs_dname(struct dentry *dent, char *buffer, int buflen) --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -554,6 +554,13 @@ static inline struct dentry *d_backing_d return upper; } +/** + * d_real - Return the real dentry + * @dentry: The dentry to query + * + * If dentry is on an union/overlay, then return the underlying, real dentry. + * Otherwise return the dentry itself. + */ static inline struct dentry *d_real(struct dentry *dentry) { if (unlikely(dentry->d_flags & DCACHE_OP_REAL))