Commit 495e6429 authored by Miklos Szeredi's avatar Miklos Szeredi

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: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 191a3980
...@@ -22,7 +22,7 @@ prototypes: ...@@ -22,7 +22,7 @@ prototypes:
struct vfsmount *(*d_automount)(struct path *path); struct vfsmount *(*d_automount)(struct path *path);
int (*d_manage)(const struct path *, bool); int (*d_manage)(const struct path *, bool);
struct dentry *(*d_real)(struct dentry *, const struct inode *, struct dentry *(*d_real)(struct dentry *, const struct inode *,
unsigned int); unsigned int, unsigned int);
locking rules: locking rules:
rename_lock ->d_lock may block rcu-walk rename_lock ->d_lock may block rcu-walk
......
...@@ -990,7 +990,7 @@ struct dentry_operations { ...@@ -990,7 +990,7 @@ struct dentry_operations {
struct vfsmount *(*d_automount)(struct path *); struct vfsmount *(*d_automount)(struct path *);
int (*d_manage)(const struct path *, bool); int (*d_manage)(const struct path *, bool);
struct dentry *(*d_real)(struct dentry *, const struct inode *, struct dentry *(*d_real)(struct dentry *, const struct inode *,
unsigned int); unsigned int, unsigned int);
}; };
d_revalidate: called when the VFS needs to revalidate a dentry. This d_revalidate: called when the VFS needs to revalidate a dentry. This
......
...@@ -96,7 +96,7 @@ long vfs_truncate(const struct path *path, loff_t length) ...@@ -96,7 +96,7 @@ long vfs_truncate(const struct path *path, loff_t length)
* write access on the upper inode, not on the overlay inode. For * write access on the upper inode, not on the overlay inode. For
* non-overlay filesystems d_real() is an identity function. * non-overlay filesystems d_real() is an identity function.
*/ */
upperdentry = d_real(path->dentry, NULL, O_WRONLY); upperdentry = d_real(path->dentry, NULL, O_WRONLY, 0);
error = PTR_ERR(upperdentry); error = PTR_ERR(upperdentry);
if (IS_ERR(upperdentry)) if (IS_ERR(upperdentry))
goto mnt_drop_write_and_out; goto mnt_drop_write_and_out;
...@@ -857,7 +857,7 @@ EXPORT_SYMBOL(file_path); ...@@ -857,7 +857,7 @@ EXPORT_SYMBOL(file_path);
int vfs_open(const struct path *path, struct file *file, int vfs_open(const struct path *path, struct file *file,
const struct cred *cred) const struct cred *cred)
{ {
struct dentry *dentry = d_real(path->dentry, NULL, file->f_flags); struct dentry *dentry = d_real(path->dentry, NULL, file->f_flags, 0);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
return PTR_ERR(dentry); return PTR_ERR(dentry);
......
...@@ -70,7 +70,7 @@ static int ovl_check_append_only(struct inode *inode, int flag) ...@@ -70,7 +70,7 @@ static int ovl_check_append_only(struct inode *inode, int flag)
static struct dentry *ovl_d_real(struct dentry *dentry, static struct dentry *ovl_d_real(struct dentry *dentry,
const struct inode *inode, const struct inode *inode,
unsigned int open_flags) unsigned int open_flags, unsigned int flags)
{ {
struct dentry *real; struct dentry *real;
int err; int err;
...@@ -102,7 +102,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry, ...@@ -102,7 +102,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
goto bug; goto bug;
/* Handle recursion */ /* Handle recursion */
real = d_real(real, inode, open_flags); real = d_real(real, inode, open_flags, 0);
if (!inode || inode == d_inode(real)) if (!inode || inode == d_inode(real))
return real; return real;
......
...@@ -147,7 +147,7 @@ struct dentry_operations { ...@@ -147,7 +147,7 @@ struct dentry_operations {
struct vfsmount *(*d_automount)(struct path *); struct vfsmount *(*d_automount)(struct path *);
int (*d_manage)(const struct path *, bool); int (*d_manage)(const struct path *, bool);
struct dentry *(*d_real)(struct dentry *, const struct inode *, struct dentry *(*d_real)(struct dentry *, const struct inode *,
unsigned int); unsigned int, unsigned int);
} ____cacheline_aligned; } ____cacheline_aligned;
/* /*
...@@ -566,7 +566,8 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper) ...@@ -566,7 +566,8 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper)
* d_real - Return the real dentry * d_real - Return the real dentry
* @dentry: the dentry to query * @dentry: the dentry to query
* @inode: inode to select the dentry from multiple layers (can be NULL) * @inode: inode to select the dentry from multiple layers (can be NULL)
* @flags: open flags to control copy-up behavior * @open_flags: open flags to control copy-up behavior
* @flags: flags to control what is returned by this function
* *
* If dentry is on a union/overlay, then return the underlying, real dentry. * If dentry is on a union/overlay, then return the underlying, real dentry.
* Otherwise return the dentry itself. * Otherwise return the dentry itself.
...@@ -575,10 +576,10 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper) ...@@ -575,10 +576,10 @@ static inline struct dentry *d_backing_dentry(struct dentry *upper)
*/ */
static inline struct dentry *d_real(struct dentry *dentry, static inline struct dentry *d_real(struct dentry *dentry,
const struct inode *inode, const struct inode *inode,
unsigned int flags) unsigned int open_flags, unsigned int flags)
{ {
if (unlikely(dentry->d_flags & DCACHE_OP_REAL)) 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, open_flags, flags);
else else
return dentry; return dentry;
} }
...@@ -593,7 +594,7 @@ static inline struct dentry *d_real(struct dentry *dentry, ...@@ -593,7 +594,7 @@ static inline struct dentry *d_real(struct dentry *dentry,
static inline struct inode *d_real_inode(const struct dentry *dentry) static inline struct inode *d_real_inode(const struct dentry *dentry)
{ {
/* This usage of d_real() results in const 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, 0, 0));
} }
struct name_snapshot { struct name_snapshot {
......
...@@ -1233,7 +1233,7 @@ static inline struct inode *file_inode(const struct file *f) ...@@ -1233,7 +1233,7 @@ static inline struct inode *file_inode(const struct file *f)
static inline struct dentry *file_dentry(const struct file *file) 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), 0, 0);
} }
static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl) static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment