Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
09d8b586
Commit
09d8b586
authored
Jul 04, 2017
by
Miklos Szeredi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ovl: move __upperdentry to ovl_inode
Signed-off-by:
Miklos Szeredi
<
mszeredi@redhat.com
>
parent
9020df37
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
94 deletions
+79
-94
fs/overlayfs/copy_up.c
fs/overlayfs/copy_up.c
+1
-2
fs/overlayfs/dir.c
fs/overlayfs/dir.c
+4
-4
fs/overlayfs/inode.c
fs/overlayfs/inode.c
+17
-9
fs/overlayfs/namei.c
fs/overlayfs/namei.c
+3
-4
fs/overlayfs/overlayfs.h
fs/overlayfs/overlayfs.h
+7
-5
fs/overlayfs/ovl_entry.h
fs/overlayfs/ovl_entry.h
+6
-7
fs/overlayfs/super.c
fs/overlayfs/super.c
+9
-6
fs/overlayfs/util.c
fs/overlayfs/util.c
+32
-57
No files found.
fs/overlayfs/copy_up.c
View file @
09d8b586
...
@@ -417,8 +417,7 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
...
@@ -417,8 +417,7 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
goto
out_cleanup
;
goto
out_cleanup
;
newdentry
=
dget
(
tmpfile
?
upper
:
temp
);
newdentry
=
dget
(
tmpfile
?
upper
:
temp
);
ovl_dentry_update
(
dentry
,
newdentry
);
ovl_inode_update
(
d_inode
(
dentry
),
newdentry
);
ovl_inode_update
(
d_inode
(
dentry
),
d_inode
(
newdentry
));
/* Restore timestamps on parent (best effort) */
/* Restore timestamps on parent (best effort) */
ovl_set_timestamps
(
upperdir
,
pstat
);
ovl_set_timestamps
(
upperdir
,
pstat
);
...
...
fs/overlayfs/dir.c
View file @
09d8b586
...
@@ -154,12 +154,12 @@ static void ovl_instantiate(struct dentry *dentry, struct inode *inode,
...
@@ -154,12 +154,12 @@ static void ovl_instantiate(struct dentry *dentry, struct inode *inode,
struct
dentry
*
newdentry
,
bool
hardlink
)
struct
dentry
*
newdentry
,
bool
hardlink
)
{
{
ovl_dentry_version_inc
(
dentry
->
d_parent
);
ovl_dentry_version_inc
(
dentry
->
d_parent
);
ovl_dentry_update
(
dentry
,
newdentry
);
if
(
!
hardlink
)
{
if
(
!
hardlink
)
{
ovl_inode_update
(
inode
,
d_inode
(
newdentry
)
);
ovl_inode_update
(
inode
,
newdentry
);
ovl_copyattr
(
newdentry
->
d_inode
,
inode
);
ovl_copyattr
(
newdentry
->
d_inode
,
inode
);
}
else
{
}
else
{
WARN_ON
(
ovl_inode_real
(
inode
,
NULL
)
!=
d_inode
(
newdentry
));
WARN_ON
(
ovl_inode_real
(
inode
)
!=
d_inode
(
newdentry
));
dput
(
newdentry
);
inc_nlink
(
inode
);
inc_nlink
(
inode
);
}
}
d_instantiate
(
dentry
,
inode
);
d_instantiate
(
dentry
,
inode
);
...
@@ -1003,7 +1003,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
...
@@ -1003,7 +1003,7 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
new_opaque
=
ovl_dentry_is_opaque
(
new
);
new_opaque
=
ovl_dentry_is_opaque
(
new
);
err
=
-
ESTALE
;
err
=
-
ESTALE
;
if
(
ovl_dentry_upper
(
new
))
{
if
(
d_inode
(
new
)
&&
ovl_dentry_upper
(
new
))
{
if
(
opaquedir
)
{
if
(
opaquedir
)
{
if
(
newdentry
!=
opaquedir
)
if
(
newdentry
!=
opaquedir
)
goto
out_dput
;
goto
out_dput
;
...
...
fs/overlayfs/inode.c
View file @
09d8b586
...
@@ -134,8 +134,8 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
...
@@ -134,8 +134,8 @@ int ovl_getattr(const struct path *path, struct kstat *stat,
int
ovl_permission
(
struct
inode
*
inode
,
int
mask
)
int
ovl_permission
(
struct
inode
*
inode
,
int
mask
)
{
{
bool
is_upper
;
struct
inode
*
upperinode
=
ovl_inode_upper
(
inode
)
;
struct
inode
*
realinode
=
ovl_inode_real
(
inode
,
&
is_upper
);
struct
inode
*
realinode
=
upperinode
?:
ovl_inode_lower
(
inode
);
const
struct
cred
*
old_cred
;
const
struct
cred
*
old_cred
;
int
err
;
int
err
;
...
@@ -154,7 +154,8 @@ int ovl_permission(struct inode *inode, int mask)
...
@@ -154,7 +154,8 @@ int ovl_permission(struct inode *inode, int mask)
return
err
;
return
err
;
old_cred
=
ovl_override_creds
(
inode
->
i_sb
);
old_cred
=
ovl_override_creds
(
inode
->
i_sb
);
if
(
!
is_upper
&&
!
special_file
(
realinode
->
i_mode
)
&&
mask
&
MAY_WRITE
)
{
if
(
!
upperinode
&&
!
special_file
(
realinode
->
i_mode
)
&&
mask
&
MAY_WRITE
)
{
mask
&=
~
(
MAY_WRITE
|
MAY_APPEND
);
mask
&=
~
(
MAY_WRITE
|
MAY_APPEND
);
/* Make sure mounter can read file for copy up later */
/* Make sure mounter can read file for copy up later */
mask
|=
MAY_READ
;
mask
|=
MAY_READ
;
...
@@ -286,7 +287,7 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
...
@@ -286,7 +287,7 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
struct
posix_acl
*
ovl_get_acl
(
struct
inode
*
inode
,
int
type
)
struct
posix_acl
*
ovl_get_acl
(
struct
inode
*
inode
,
int
type
)
{
{
struct
inode
*
realinode
=
ovl_inode_real
(
inode
,
NULL
);
struct
inode
*
realinode
=
ovl_inode_real
(
inode
);
const
struct
cred
*
old_cred
;
const
struct
cred
*
old_cred
;
struct
posix_acl
*
acl
;
struct
posix_acl
*
acl
;
...
@@ -462,17 +463,24 @@ static int ovl_inode_set(struct inode *inode, void *data)
...
@@ -462,17 +463,24 @@ static int ovl_inode_set(struct inode *inode, void *data)
return
0
;
return
0
;
}
}
struct
inode
*
ovl_get_inode
(
struct
dentry
*
dentry
)
struct
inode
*
ovl_get_inode
(
struct
dentry
*
dentry
,
struct
dentry
*
upperdentry
)
{
{
struct
dentry
*
upperdentry
=
ovl_dentry_upp
er
(
dentry
);
struct
dentry
*
lowerdentry
=
ovl_dentry_low
er
(
dentry
);
struct
inode
*
realinode
=
d_inode
(
ovl_dentry_real
(
dentry
))
;
struct
inode
*
realinode
=
upperdentry
?
d_inode
(
upperdentry
)
:
NULL
;
struct
inode
*
inode
;
struct
inode
*
inode
;
if
(
!
realinode
)
realinode
=
d_inode
(
lowerdentry
);
if
(
upperdentry
&&
!
d_is_dir
(
upperdentry
))
{
if
(
upperdentry
&&
!
d_is_dir
(
upperdentry
))
{
inode
=
iget5_locked
(
dentry
->
d_sb
,
(
unsigned
long
)
realinode
,
inode
=
iget5_locked
(
dentry
->
d_sb
,
(
unsigned
long
)
realinode
,
ovl_inode_test
,
ovl_inode_set
,
realinode
);
ovl_inode_test
,
ovl_inode_set
,
realinode
);
if
(
!
inode
||
!
(
inode
->
i_state
&
I_NEW
)
)
if
(
!
inode
)
goto
out
;
goto
out
;
if
(
!
(
inode
->
i_state
&
I_NEW
))
{
dput
(
upperdentry
);
goto
out
;
}
set_nlink
(
inode
,
realinode
->
i_nlink
);
set_nlink
(
inode
,
realinode
->
i_nlink
);
}
else
{
}
else
{
...
@@ -481,7 +489,7 @@ struct inode *ovl_get_inode(struct dentry *dentry)
...
@@ -481,7 +489,7 @@ struct inode *ovl_get_inode(struct dentry *dentry)
goto
out
;
goto
out
;
}
}
ovl_fill_inode
(
inode
,
realinode
->
i_mode
,
realinode
->
i_rdev
);
ovl_fill_inode
(
inode
,
realinode
->
i_mode
,
realinode
->
i_rdev
);
ovl_inode_init
(
inode
,
dentry
);
ovl_inode_init
(
inode
,
upperdentry
,
lower
dentry
);
if
(
inode
->
i_state
&
I_NEW
)
if
(
inode
->
i_state
&
I_NEW
)
unlock_new_inode
(
inode
);
unlock_new_inode
(
inode
);
out:
out:
...
...
fs/overlayfs/namei.c
View file @
09d8b586
...
@@ -359,7 +359,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
...
@@ -359,7 +359,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
return
ERR_PTR
(
-
ENAMETOOLONG
);
return
ERR_PTR
(
-
ENAMETOOLONG
);
old_cred
=
ovl_override_creds
(
dentry
->
d_sb
);
old_cred
=
ovl_override_creds
(
dentry
->
d_sb
);
upperdir
=
ovl_
upperdentry_dereference
(
poe
);
upperdir
=
ovl_
dentry_upper
(
dentry
->
d_parent
);
if
(
upperdir
)
{
if
(
upperdir
)
{
err
=
ovl_lookup_layer
(
upperdir
,
&
d
,
&
upperdentry
);
err
=
ovl_lookup_layer
(
upperdir
,
&
d
,
&
upperdentry
);
if
(
err
)
if
(
err
)
...
@@ -436,13 +436,12 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
...
@@ -436,13 +436,12 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
oe
->
opaque
=
upperopaque
;
oe
->
opaque
=
upperopaque
;
oe
->
impure
=
upperimpure
;
oe
->
impure
=
upperimpure
;
oe
->
redirect
=
upperredirect
;
oe
->
redirect
=
upperredirect
;
oe
->
__upperdentry
=
upperdentry
;
memcpy
(
oe
->
lowerstack
,
stack
,
sizeof
(
struct
path
)
*
ctr
);
memcpy
(
oe
->
lowerstack
,
stack
,
sizeof
(
struct
path
)
*
ctr
);
dentry
->
d_fsdata
=
oe
;
dentry
->
d_fsdata
=
oe
;
if
(
upperdentry
||
ctr
)
{
if
(
upperdentry
||
ctr
)
{
err
=
-
ENOMEM
;
err
=
-
ENOMEM
;
inode
=
ovl_get_inode
(
dentry
);
inode
=
ovl_get_inode
(
dentry
,
upperdentry
);
if
(
!
inode
)
if
(
!
inode
)
goto
out_free_oe
;
goto
out_free_oe
;
}
}
...
@@ -487,7 +486,7 @@ bool ovl_lower_positive(struct dentry *dentry)
...
@@ -487,7 +486,7 @@ bool ovl_lower_positive(struct dentry *dentry)
return
oe
->
opaque
;
return
oe
->
opaque
;
/* Negative upper -> positive lower */
/* Negative upper -> positive lower */
if
(
!
o
e
->
__upperdentry
)
if
(
!
o
vl_dentry_upper
(
dentry
)
)
return
true
;
return
true
;
/* Positive upper -> have to look up lower to see whether it exists */
/* Positive upper -> have to look up lower to see whether it exists */
...
...
fs/overlayfs/overlayfs.h
View file @
09d8b586
...
@@ -189,7 +189,9 @@ enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path);
...
@@ -189,7 +189,9 @@ enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path);
struct
dentry
*
ovl_dentry_upper
(
struct
dentry
*
dentry
);
struct
dentry
*
ovl_dentry_upper
(
struct
dentry
*
dentry
);
struct
dentry
*
ovl_dentry_lower
(
struct
dentry
*
dentry
);
struct
dentry
*
ovl_dentry_lower
(
struct
dentry
*
dentry
);
struct
dentry
*
ovl_dentry_real
(
struct
dentry
*
dentry
);
struct
dentry
*
ovl_dentry_real
(
struct
dentry
*
dentry
);
struct
inode
*
ovl_inode_real
(
struct
inode
*
inode
,
bool
*
is_upper
);
struct
inode
*
ovl_inode_upper
(
struct
inode
*
inode
);
struct
inode
*
ovl_inode_lower
(
struct
inode
*
inode
);
struct
inode
*
ovl_inode_real
(
struct
inode
*
inode
);
struct
ovl_dir_cache
*
ovl_dir_cache
(
struct
dentry
*
dentry
);
struct
ovl_dir_cache
*
ovl_dir_cache
(
struct
dentry
*
dentry
);
void
ovl_set_dir_cache
(
struct
dentry
*
dentry
,
struct
ovl_dir_cache
*
cache
);
void
ovl_set_dir_cache
(
struct
dentry
*
dentry
,
struct
ovl_dir_cache
*
cache
);
bool
ovl_dentry_is_opaque
(
struct
dentry
*
dentry
);
bool
ovl_dentry_is_opaque
(
struct
dentry
*
dentry
);
...
@@ -199,9 +201,9 @@ void ovl_dentry_set_opaque(struct dentry *dentry);
...
@@ -199,9 +201,9 @@ void ovl_dentry_set_opaque(struct dentry *dentry);
bool
ovl_redirect_dir
(
struct
super_block
*
sb
);
bool
ovl_redirect_dir
(
struct
super_block
*
sb
);
const
char
*
ovl_dentry_get_redirect
(
struct
dentry
*
dentry
);
const
char
*
ovl_dentry_get_redirect
(
struct
dentry
*
dentry
);
void
ovl_dentry_set_redirect
(
struct
dentry
*
dentry
,
const
char
*
redirect
);
void
ovl_dentry_set_redirect
(
struct
dentry
*
dentry
,
const
char
*
redirect
);
void
ovl_
dentry_update
(
struct
dentry
*
dentry
,
struct
dentry
*
upperdentry
);
void
ovl_
inode_init
(
struct
inode
*
inode
,
struct
dentry
*
upperdentry
,
void
ovl_inode_init
(
struct
inode
*
inode
,
struct
dentry
*
dentry
);
struct
dentry
*
lower
dentry
);
void
ovl_inode_update
(
struct
inode
*
inode
,
struct
inode
*
upperinode
);
void
ovl_inode_update
(
struct
inode
*
inode
,
struct
dentry
*
upperdentry
);
void
ovl_dentry_version_inc
(
struct
dentry
*
dentry
);
void
ovl_dentry_version_inc
(
struct
dentry
*
dentry
);
u64
ovl_dentry_version_get
(
struct
dentry
*
dentry
);
u64
ovl_dentry_version_get
(
struct
dentry
*
dentry
);
bool
ovl_is_whiteout
(
struct
dentry
*
dentry
);
bool
ovl_is_whiteout
(
struct
dentry
*
dentry
);
...
@@ -250,7 +252,7 @@ int ovl_update_time(struct inode *inode, struct timespec *ts, int flags);
...
@@ -250,7 +252,7 @@ int ovl_update_time(struct inode *inode, struct timespec *ts, int flags);
bool
ovl_is_private_xattr
(
const
char
*
name
);
bool
ovl_is_private_xattr
(
const
char
*
name
);
struct
inode
*
ovl_new_inode
(
struct
super_block
*
sb
,
umode_t
mode
,
dev_t
rdev
);
struct
inode
*
ovl_new_inode
(
struct
super_block
*
sb
,
umode_t
mode
,
dev_t
rdev
);
struct
inode
*
ovl_get_inode
(
struct
dentry
*
dentry
);
struct
inode
*
ovl_get_inode
(
struct
dentry
*
dentry
,
struct
dentry
*
upperdentry
);
static
inline
void
ovl_copyattr
(
struct
inode
*
from
,
struct
inode
*
to
)
static
inline
void
ovl_copyattr
(
struct
inode
*
from
,
struct
inode
*
to
)
{
{
to
->
i_uid
=
from
->
i_uid
;
to
->
i_uid
=
from
->
i_uid
;
...
...
fs/overlayfs/ovl_entry.h
View file @
09d8b586
...
@@ -36,7 +36,6 @@ struct ovl_fs {
...
@@ -36,7 +36,6 @@ struct ovl_fs {
/* private information held for every overlayfs dentry */
/* private information held for every overlayfs dentry */
struct
ovl_entry
{
struct
ovl_entry
{
struct
dentry
*
__upperdentry
;
struct
ovl_dir_cache
*
cache
;
struct
ovl_dir_cache
*
cache
;
union
{
union
{
struct
{
struct
{
...
@@ -54,14 +53,9 @@ struct ovl_entry {
...
@@ -54,14 +53,9 @@ struct ovl_entry {
struct
ovl_entry
*
ovl_alloc_entry
(
unsigned
int
numlower
);
struct
ovl_entry
*
ovl_alloc_entry
(
unsigned
int
numlower
);
static
inline
struct
dentry
*
ovl_upperdentry_dereference
(
struct
ovl_entry
*
oe
)
{
return
lockless_dereference
(
oe
->
__upperdentry
);
}
struct
ovl_inode
{
struct
ovl_inode
{
struct
inode
vfs_inode
;
struct
inode
vfs_inode
;
struct
inode
*
upper
;
struct
dentry
*
__upperdentry
;
struct
inode
*
lower
;
struct
inode
*
lower
;
};
};
...
@@ -69,3 +63,8 @@ static inline struct ovl_inode *OVL_I(struct inode *inode)
...
@@ -69,3 +63,8 @@ static inline struct ovl_inode *OVL_I(struct inode *inode)
{
{
return
container_of
(
inode
,
struct
ovl_inode
,
vfs_inode
);
return
container_of
(
inode
,
struct
ovl_inode
,
vfs_inode
);
}
}
static
inline
struct
dentry
*
ovl_upperdentry_dereference
(
struct
ovl_inode
*
oi
)
{
return
lockless_dereference
(
oi
->
__upperdentry
);
}
fs/overlayfs/super.c
View file @
09d8b586
...
@@ -41,7 +41,6 @@ static void ovl_dentry_release(struct dentry *dentry)
...
@@ -41,7 +41,6 @@ static void ovl_dentry_release(struct dentry *dentry)
if
(
oe
)
{
if
(
oe
)
{
unsigned
int
i
;
unsigned
int
i
;
dput
(
oe
->
__upperdentry
);
kfree
(
oe
->
redirect
);
kfree
(
oe
->
redirect
);
for
(
i
=
0
;
i
<
oe
->
numlower
;
i
++
)
for
(
i
=
0
;
i
<
oe
->
numlower
;
i
++
)
dput
(
oe
->
lowerstack
[
i
].
dentry
);
dput
(
oe
->
lowerstack
[
i
].
dentry
);
...
@@ -171,7 +170,7 @@ static struct inode *ovl_alloc_inode(struct super_block *sb)
...
@@ -171,7 +170,7 @@ static struct inode *ovl_alloc_inode(struct super_block *sb)
{
{
struct
ovl_inode
*
oi
=
kmem_cache_alloc
(
ovl_inode_cachep
,
GFP_KERNEL
);
struct
ovl_inode
*
oi
=
kmem_cache_alloc
(
ovl_inode_cachep
,
GFP_KERNEL
);
oi
->
upper
=
NULL
;
oi
->
__upperdentry
=
NULL
;
oi
->
lower
=
NULL
;
oi
->
lower
=
NULL
;
return
&
oi
->
vfs_inode
;
return
&
oi
->
vfs_inode
;
...
@@ -186,6 +185,10 @@ static void ovl_i_callback(struct rcu_head *head)
...
@@ -186,6 +185,10 @@ static void ovl_i_callback(struct rcu_head *head)
static
void
ovl_destroy_inode
(
struct
inode
*
inode
)
static
void
ovl_destroy_inode
(
struct
inode
*
inode
)
{
{
struct
ovl_inode
*
oi
=
OVL_I
(
inode
);
dput
(
oi
->
__upperdentry
);
call_rcu
(
&
inode
->
i_rcu
,
ovl_i_callback
);
call_rcu
(
&
inode
->
i_rcu
,
ovl_i_callback
);
}
}
...
@@ -636,7 +639,7 @@ ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
...
@@ -636,7 +639,7 @@ ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
size_t
size
,
int
flags
)
size_t
size
,
int
flags
)
{
{
struct
dentry
*
workdir
=
ovl_workdir
(
dentry
);
struct
dentry
*
workdir
=
ovl_workdir
(
dentry
);
struct
inode
*
realinode
=
ovl_inode_real
(
inode
,
NULL
);
struct
inode
*
realinode
=
ovl_inode_real
(
inode
);
struct
posix_acl
*
acl
=
NULL
;
struct
posix_acl
*
acl
=
NULL
;
int
err
;
int
err
;
...
@@ -678,7 +681,7 @@ ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
...
@@ -678,7 +681,7 @@ ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
err
=
ovl_xattr_set
(
dentry
,
handler
->
name
,
value
,
size
,
flags
);
err
=
ovl_xattr_set
(
dentry
,
handler
->
name
,
value
,
size
,
flags
);
if
(
!
err
)
if
(
!
err
)
ovl_copyattr
(
ovl_inode_real
(
inode
,
NULL
),
inode
);
ovl_copyattr
(
ovl_inode_real
(
inode
),
inode
);
return
err
;
return
err
;
...
@@ -1000,7 +1003,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -1000,7 +1003,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
kfree
(
lowertmp
);
kfree
(
lowertmp
);
if
(
upperpath
.
dentry
)
{
if
(
upperpath
.
dentry
)
{
oe
->
__upperdentry
=
upperpath
.
dentry
;
oe
->
impure
=
ovl_is_impuredir
(
upperpath
.
dentry
);
oe
->
impure
=
ovl_is_impuredir
(
upperpath
.
dentry
);
}
}
for
(
i
=
0
;
i
<
numlower
;
i
++
)
{
for
(
i
=
0
;
i
<
numlower
;
i
++
)
{
...
@@ -1011,7 +1013,8 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
...
@@ -1011,7 +1013,8 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
root_dentry
->
d_fsdata
=
oe
;
root_dentry
->
d_fsdata
=
oe
;
ovl_inode_init
(
d_inode
(
root_dentry
),
root_dentry
);
ovl_inode_init
(
d_inode
(
root_dentry
),
upperpath
.
dentry
,
ovl_dentry_lower
(
root_dentry
));
sb
->
s_root
=
root_dentry
;
sb
->
s_root
=
root_dentry
;
...
...
fs/overlayfs/util.c
View file @
09d8b586
...
@@ -78,7 +78,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
...
@@ -78,7 +78,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
enum
ovl_path_type
type
=
0
;
enum
ovl_path_type
type
=
0
;
if
(
o
e
->
__upperdentry
)
{
if
(
o
vl_dentry_upper
(
dentry
)
)
{
type
=
__OVL_PATH_UPPER
;
type
=
__OVL_PATH_UPPER
;
/*
/*
...
@@ -99,10 +99,9 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
...
@@ -99,10 +99,9 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
void
ovl_path_upper
(
struct
dentry
*
dentry
,
struct
path
*
path
)
void
ovl_path_upper
(
struct
dentry
*
dentry
,
struct
path
*
path
)
{
{
struct
ovl_fs
*
ofs
=
dentry
->
d_sb
->
s_fs_info
;
struct
ovl_fs
*
ofs
=
dentry
->
d_sb
->
s_fs_info
;
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
path
->
mnt
=
ofs
->
upper_mnt
;
path
->
mnt
=
ofs
->
upper_mnt
;
path
->
dentry
=
ovl_
upperdentry_dereference
(
oe
);
path
->
dentry
=
ovl_
dentry_upper
(
dentry
);
}
}
void
ovl_path_lower
(
struct
dentry
*
dentry
,
struct
path
*
path
)
void
ovl_path_lower
(
struct
dentry
*
dentry
,
struct
path
*
path
)
...
@@ -126,51 +125,39 @@ enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
...
@@ -126,51 +125,39 @@ enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
struct
dentry
*
ovl_dentry_upper
(
struct
dentry
*
dentry
)
struct
dentry
*
ovl_dentry_upper
(
struct
dentry
*
dentry
)
{
{
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
return
ovl_upperdentry_dereference
(
OVL_I
(
d_inode
(
dentry
)));
return
ovl_upperdentry_dereference
(
oe
);
}
static
struct
dentry
*
__ovl_dentry_lower
(
struct
ovl_entry
*
oe
)
{
return
oe
->
numlower
?
oe
->
lowerstack
[
0
].
dentry
:
NULL
;
}
}
struct
dentry
*
ovl_dentry_lower
(
struct
dentry
*
dentry
)
struct
dentry
*
ovl_dentry_lower
(
struct
dentry
*
dentry
)
{
{
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
return
__ovl_dentry_lower
(
oe
)
;
return
oe
->
numlower
?
oe
->
lowerstack
[
0
].
dentry
:
NULL
;
}
}
struct
dentry
*
ovl_dentry_real
(
struct
dentry
*
dentry
)
struct
dentry
*
ovl_dentry_real
(
struct
dentry
*
dentry
)
{
{
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
return
ovl_dentry_upper
(
dentry
)
?:
ovl_dentry_lower
(
dentry
);
struct
dentry
*
realdentry
;
realdentry
=
ovl_upperdentry_dereference
(
oe
);
if
(
!
realdentry
)
realdentry
=
__ovl_dentry_lower
(
oe
);
return
realdentry
;
}
}
struct
inode
*
ovl_inode_
real
(
struct
inode
*
inode
,
bool
*
is_upper
)
struct
inode
*
ovl_inode_
upper
(
struct
inode
*
inode
)
{
{
struct
inode
*
realinode
=
lockless_dereference
(
OVL_I
(
inode
)
->
upper
);
struct
dentry
*
upperdentry
=
ovl_upperdentry_dereference
(
OVL_I
(
inode
));
bool
isup
=
false
;
if
(
!
realinode
)
return
upperdentry
?
d_inode
(
upperdentry
)
:
NULL
;
realinode
=
OVL_I
(
inode
)
->
lower
;
}
else
isup
=
true
;
if
(
is_upper
)
struct
inode
*
ovl_inode_lower
(
struct
inode
*
inode
)
*
is_upper
=
isup
;
{
return
OVL_I
(
inode
)
->
lower
;
}
return
realinode
;
struct
inode
*
ovl_inode_real
(
struct
inode
*
inode
)
{
return
ovl_inode_upper
(
inode
)
?:
ovl_inode_lower
(
inode
);
}
}
struct
ovl_dir_cache
*
ovl_dir_cache
(
struct
dentry
*
dentry
)
struct
ovl_dir_cache
*
ovl_dir_cache
(
struct
dentry
*
dentry
)
{
{
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
...
@@ -232,42 +219,30 @@ void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect)
...
@@ -232,42 +219,30 @@ void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect)
oe
->
redirect
=
redirect
;
oe
->
redirect
=
redirect
;
}
}
void
ovl_dentry_update
(
struct
dentry
*
dentry
,
struct
dentry
*
upperdentry
)
void
ovl_inode_init
(
struct
inode
*
inode
,
struct
dentry
*
upperdentry
,
struct
dentry
*
lowerdentry
)
{
{
struct
ovl_entry
*
oe
=
dentry
->
d_fsdata
;
if
(
upperdentry
)
OVL_I
(
inode
)
->
__upperdentry
=
upperdentry
;
if
(
lowerdentry
)
OVL_I
(
inode
)
->
lower
=
d_inode
(
lowerdentry
);
WARN_ON
(
!
inode_is_locked
(
upperdentry
->
d_parent
->
d_inode
));
ovl_copyattr
(
d_inode
(
upperdentry
?:
lowerdentry
),
inode
);
WARN_ON
(
oe
->
__upperdentry
);
/*
* Make sure upperdentry is consistent before making it visible to
* ovl_upperdentry_dereference().
*/
smp_wmb
();
oe
->
__upperdentry
=
upperdentry
;
}
}
void
ovl_inode_
init
(
struct
inode
*
inode
,
struct
dentry
*
dentry
)
void
ovl_inode_
update
(
struct
inode
*
inode
,
struct
dentry
*
upper
dentry
)
{
{
struct
inode
*
realinode
=
d_inode
(
ovl_dentry_real
(
dentry
)
);
struct
inode
*
upperinode
=
d_inode
(
upperdentry
);
if
(
ovl_dentry_upper
(
dentry
))
OVL_I
(
inode
)
->
upper
=
realinode
;
else
OVL_I
(
inode
)
->
lower
=
realinode
;
ovl_copyattr
(
realinode
,
inode
);
}
void
ovl_inode_update
(
struct
inode
*
inode
,
struct
inode
*
upperinode
)
{
WARN_ON
(
!
upperinode
);
WARN_ON
(
!
inode_unhashed
(
inode
));
WARN_ON
(
!
inode_unhashed
(
inode
));
WARN_ON
(
!
inode_is_locked
(
upperdentry
->
d_parent
->
d_inode
));
WARN_ON
(
OVL_I
(
inode
)
->
__upperdentry
);
/*
/*
* Make sure upperinode is consistent before making it visible to
* Make sure upperdentry is consistent before making it visible
* ovl_inode_real();
*/
*/
smp_wmb
();
smp_wmb
();
OVL_I
(
inode
)
->
upper
=
upperinode
;
OVL_I
(
inode
)
->
__upperdentry
=
upperdentry
;
if
(
!
S_ISDIR
(
upperinode
->
i_mode
))
{
if
(
!
S_ISDIR
(
upperinode
->
i_mode
))
{
inode
->
i_private
=
upperinode
;
inode
->
i_private
=
upperinode
;
__insert_inode_hash
(
inode
,
(
unsigned
long
)
upperinode
);
__insert_inode_hash
(
inode
,
(
unsigned
long
)
upperinode
);
...
@@ -311,7 +286,7 @@ int ovl_copy_up_start(struct dentry *dentry)
...
@@ -311,7 +286,7 @@ int ovl_copy_up_start(struct dentry *dentry)
spin_lock
(
&
ofs
->
copyup_wq
.
lock
);
spin_lock
(
&
ofs
->
copyup_wq
.
lock
);
err
=
wait_event_interruptible_locked
(
ofs
->
copyup_wq
,
!
oe
->
copying
);
err
=
wait_event_interruptible_locked
(
ofs
->
copyup_wq
,
!
oe
->
copying
);
if
(
!
err
)
{
if
(
!
err
)
{
if
(
o
e
->
__upperdentry
)
if
(
o
vl_dentry_upper
(
dentry
)
)
err
=
1
;
/* Already copied up */
err
=
1
;
/* Already copied up */
else
else
oe
->
copying
=
true
;
oe
->
copying
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment