aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2017-09-04 15:42:22 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2017-09-04 15:42:22 -0400
commit495e642939114478a5237a7d91661ba93b76f15a (patch)
tree99d9efa957ece9af764956d9ae2532de375351fa
parent191a3980c6161d40c32e69273e0567615be17001 (diff)
vfs: add flags to d_real()
Add a separate flags argument (in addition to the open flags) to control the behavior of d_real(). Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--Documentation/filesystems/Locking2
-rw-r--r--Documentation/filesystems/vfs.txt2
-rw-r--r--fs/open.c4
-rw-r--r--fs/overlayfs/super.c4
-rw-r--r--include/linux/dcache.h11
-rw-r--r--include/linux/fs.h2
6 files changed, 13 insertions, 12 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index fe25787ff6d4..75d2d57e2c44 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -22,7 +22,7 @@ prototypes:
22 struct vfsmount *(*d_automount)(struct path *path); 22 struct vfsmount *(*d_automount)(struct path *path);
23 int (*d_manage)(const struct path *, bool); 23 int (*d_manage)(const struct path *, bool);
24 struct dentry *(*d_real)(struct dentry *, const struct inode *, 24 struct dentry *(*d_real)(struct dentry *, const struct inode *,
25 unsigned int); 25 unsigned int, unsigned int);
26 26
27locking rules: 27locking rules:
28 rename_lock ->d_lock may block rcu-walk 28 rename_lock ->d_lock may block rcu-walk
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 73e7d91f03dc..7f20c1bdfb67 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -990,7 +990,7 @@ struct dentry_operations {
990 struct vfsmount *(*d_automount)(struct path *); 990 struct vfsmount *(*d_automount)(struct path *);
991 int (*d_manage)(const struct path *, bool); 991 int (*d_manage)(const struct path *, bool);
992 struct dentry *(*d_real)(struct dentry *, const struct inode *, 992 struct dentry *(*d_real)(struct dentry *, const struct inode *,
993 unsigned int); 993 unsigned int, unsigned int);
994}; 994};
995 995
996 d_revalidate: called when the VFS needs to revalidate a dentry. This 996 d_revalidate: called when the VFS needs to revalidate a dentry. This
diff --git a/fs/open.c b/fs/open.c
index 35bb784763a4..6d5c9a9b8c8d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -96,7 +96,7 @@ long vfs_truncate(const struct path *path, loff_t length)
96 * write access on the upper inode, not on the overlay inode. For 96 * write access on the upper inode, not on the overlay inode. For
97 * non-overlay filesystems d_real() is an identity function. 97 * non-overlay filesystems d_real() is an identity function.
98 */ 98 */
99 upperdentry = d_real(path->dentry, NULL, O_WRONLY); 99 upperdentry = d_real(path->dentry, NULL, O_WRONLY, 0);
100 error = PTR_ERR(upperdentry); 100 error = PTR_ERR(upperdentry);
101 if (IS_ERR(upperdentry)) 101 if (IS_ERR(upperdentry))
102 goto mnt_drop_write_and_out; 102 goto mnt_drop_write_and_out;
@@ -857,7 +857,7 @@ EXPORT_SYMBOL(file_path);
857int vfs_open(const struct path *path, struct file *file, 857int vfs_open(const struct path *path, struct file *file,
858 const struct cred *cred) 858 const struct cred *cred)
859{ 859{
860 struct dentry *dentry = d_real(path->dentry, NULL, file->f_flags); 860 struct dentry *dentry = d_real(path->dentry, NULL, file->f_flags, 0);
861 861
862 if (IS_ERR(dentry)) 862 if (IS_ERR(dentry))
863 return PTR_ERR(dentry); 863 return PTR_ERR(dentry);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index c0c02cca776b..19e89ce39017 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -70,7 +70,7 @@ static int ovl_check_append_only(struct inode *inode, int flag)
70 70
71static struct dentry *ovl_d_real(struct dentry *dentry, 71static struct dentry *ovl_d_real(struct dentry *dentry,
72 const struct inode *inode, 72 const struct inode *inode,
73 unsigned int open_flags) 73 unsigned int open_flags, unsigned int flags)
74{ 74{
75 struct dentry *real; 75 struct dentry *real;
76 int err; 76 int err;
@@ -102,7 +102,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
102 goto bug; 102 goto bug;
103 103
104 /* Handle recursion */ 104 /* Handle recursion */
105 real = d_real(real, inode, open_flags); 105 real = d_real(real, inode, open_flags, 0);
106 106
107 if (!inode || inode == d_inode(real)) 107 if (!inode || inode == d_inode(real))
108 return real; 108 return real;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index aae1cdb76851..fd0721e520f4 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -147,7 +147,7 @@ struct dentry_operations {
147 struct vfsmount *(*d_automount)(struct path *); 147 struct vfsmount *(*d_automount)(struct path *);
148 int (*d_manage)(const struct path *, bool); 148 int (*d_manage)(const struct path *, bool);
149 struct dentry *(*d_real)(struct dentry *, const struct inode *, 149 struct dentry *(*d_real)(struct dentry *, const struct inode *,
150 unsigned int); 150 unsigned int, unsigned int);
151} ____cacheline_aligned; 151} ____cacheline_aligned;
152 152
153/* 153/*
@@ -566,7 +566,8 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper)
566 * d_real - Return the real dentry 566 * d_real - Return the real dentry
567 * @dentry: the dentry to query 567 * @dentry: the dentry to query
568 * @inode: inode to select the dentry from multiple layers (can be NULL) 568 * @inode: inode to select the dentry from multiple layers (can be NULL)
569 * @flags: open flags to control copy-up behavior 569 * @open_flags: open flags to control copy-up behavior
570 * @flags: flags to control what is returned by this function
570 * 571 *
571 * If dentry is on a union/overlay, then return the underlying, real dentry. 572 * If dentry is on a union/overlay, then return the underlying, real dentry.
572 * Otherwise return the dentry itself. 573 * Otherwise return the dentry itself.
@@ -575,10 +576,10 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper)
575 */ 576 */
576static inline struct dentry *d_real(struct dentry *dentry, 577static inline struct dentry *d_real(struct dentry *dentry,
577 const struct inode *inode, 578 const struct inode *inode,
578 unsigned int flags) 579 unsigned int open_flags, unsigned int flags)
579{ 580{
580 if (unlikely(dentry->d_flags & DCACHE_OP_REAL)) 581 if (unlikely(dentry->d_flags & DCACHE_OP_REAL))
581 return dentry->d_op->d_real(dentry, inode, flags); 582 return dentry->d_op->d_real(dentry, inode, open_flags, flags);
582 else 583 else
583 return dentry; 584 return dentry;
584} 585}
@@ -593,7 +594,7 @@ static inline struct dentry *d_real(struct dentry *dentry,
593static inline struct inode *d_real_inode(const struct dentry *dentry) 594static inline struct inode *d_real_inode(const struct dentry *dentry)
594{ 595{
595 /* This usage of d_real() results in const dentry */ 596 /* This usage of d_real() results in const dentry */
596 return d_backing_inode(d_real((struct dentry *) dentry, NULL, 0)); 597 return d_backing_inode(d_real((struct dentry *) dentry, NULL, 0, 0));
597} 598}
598 599
599struct name_snapshot { 600struct name_snapshot {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6e1fd5d21248..ee1db83c39cb 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1233,7 +1233,7 @@ static inline struct inode *file_inode(const struct file *f)
1233 1233
1234static inline struct dentry *file_dentry(const struct file *file) 1234static inline struct dentry *file_dentry(const struct file *file)
1235{ 1235{
1236 return d_real(file->f_path.dentry, file_inode(file), 0); 1236 return d_real(file->f_path.dentry, file_inode(file), 0, 0);
1237} 1237}
1238 1238
1239static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl) 1239static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)