Skip to content

Commit 495e642

Browse files
author
Miklos Szeredi
committed
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 <[email protected]>
1 parent 191a398 commit 495e642

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

Documentation/filesystems/Locking

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ prototypes:
2222
struct vfsmount *(*d_automount)(struct path *path);
2323
int (*d_manage)(const struct path *, bool);
2424
struct dentry *(*d_real)(struct dentry *, const struct inode *,
25-
unsigned int);
25+
unsigned int, unsigned int);
2626

2727
locking rules:
2828
rename_lock ->d_lock may block rcu-walk

Documentation/filesystems/vfs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ struct dentry_operations {
990990
struct vfsmount *(*d_automount)(struct path *);
991991
int (*d_manage)(const struct path *, bool);
992992
struct dentry *(*d_real)(struct dentry *, const struct inode *,
993-
unsigned int);
993+
unsigned int, unsigned int);
994994
};
995995

996996
d_revalidate: called when the VFS needs to revalidate a dentry. This

fs/open.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ long vfs_truncate(const struct path *path, loff_t length)
9696
* write access on the upper inode, not on the overlay inode. For
9797
* non-overlay filesystems d_real() is an identity function.
9898
*/
99-
upperdentry = d_real(path->dentry, NULL, O_WRONLY);
99+
upperdentry = d_real(path->dentry, NULL, O_WRONLY, 0);
100100
error = PTR_ERR(upperdentry);
101101
if (IS_ERR(upperdentry))
102102
goto mnt_drop_write_and_out;
@@ -857,7 +857,7 @@ EXPORT_SYMBOL(file_path);
857857
int vfs_open(const struct path *path, struct file *file,
858858
const struct cred *cred)
859859
{
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);
861861

862862
if (IS_ERR(dentry))
863863
return PTR_ERR(dentry);

fs/overlayfs/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int ovl_check_append_only(struct inode *inode, int flag)
7070

7171
static struct dentry *ovl_d_real(struct dentry *dentry,
7272
const struct inode *inode,
73-
unsigned int open_flags)
73+
unsigned int open_flags, unsigned int flags)
7474
{
7575
struct dentry *real;
7676
int err;
@@ -102,7 +102,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
102102
goto bug;
103103

104104
/* Handle recursion */
105-
real = d_real(real, inode, open_flags);
105+
real = d_real(real, inode, open_flags, 0);
106106

107107
if (!inode || inode == d_inode(real))
108108
return real;

include/linux/dcache.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct dentry_operations {
147147
struct vfsmount *(*d_automount)(struct path *);
148148
int (*d_manage)(const struct path *, bool);
149149
struct dentry *(*d_real)(struct dentry *, const struct inode *,
150-
unsigned int);
150+
unsigned int, unsigned int);
151151
} ____cacheline_aligned;
152152

153153
/*
@@ -566,7 +566,8 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper)
566566
* d_real - Return the real dentry
567567
* @dentry: the dentry to query
568568
* @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
570571
*
571572
* If dentry is on a union/overlay, then return the underlying, real dentry.
572573
* Otherwise return the dentry itself.
@@ -575,10 +576,10 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper)
575576
*/
576577
static inline struct dentry *d_real(struct dentry *dentry,
577578
const struct inode *inode,
578-
unsigned int flags)
579+
unsigned int open_flags, unsigned int flags)
579580
{
580581
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);
582583
else
583584
return dentry;
584585
}
@@ -593,7 +594,7 @@ static inline struct dentry *d_real(struct dentry *dentry,
593594
static inline struct inode *d_real_inode(const struct dentry *dentry)
594595
{
595596
/* 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));
597598
}
598599

599600
struct name_snapshot {

include/linux/fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ static inline struct inode *file_inode(const struct file *f)
12331233

12341234
static inline struct dentry *file_dentry(const struct file *file)
12351235
{
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);
12371237
}
12381238

12391239
static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)

0 commit comments

Comments
 (0)