* [PATCH 1/2] fs: export d_exchange for the fs with FS_RENAME_DOSE_D_MOVE
@ 2015-09-03 9:12 xuw2015
2015-09-03 9:12 ` [PATCH 2/2] ovl: ovl_rename2 should do d_move by itself xuw2015
0 siblings, 1 reply; 2+ messages in thread
From: xuw2015 @ 2015-09-03 9:12 UTC (permalink / raw)
To: linux-unionfs, linux-fsdevel; +Cc: Geroge Wang
From: Geroge Wang <xuw2015@gmail.com>
d_move is exported for specified file systems, we should export
d_exchange also.
Signed-off-by: George Wang <xuw2015@gmail.com>
---
fs/dcache.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/dcache.c b/fs/dcache.c
index 9b5fe50..a6de9b0 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2694,6 +2694,7 @@ void d_exchange(struct dentry *dentry1, struct dentry *dentry2)
write_sequnlock(&rename_lock);
}
+EXPORT_SYMBOL(d_exchange);
/**
* d_ancestor - search for an ancestor
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] ovl: ovl_rename2 should do d_move by itself
2015-09-03 9:12 [PATCH 1/2] fs: export d_exchange for the fs with FS_RENAME_DOSE_D_MOVE xuw2015
@ 2015-09-03 9:12 ` xuw2015
0 siblings, 0 replies; 2+ messages in thread
From: xuw2015 @ 2015-09-03 9:12 UTC (permalink / raw)
To: linux-unionfs, linux-fsdevel; +Cc: George Wang
From: George Wang <xuw2015@gmail.com>
ovl always creates new inode regardless of the fact that upper hardlink
shares same inode. If we do rename with dentries shared inode, there is
no real opertions, but vfs_rename will do the d_move after that.
And an intersting result will appear. The following step will explain
it:
echo 1234 > src
link src tgt
rename(src, tgt)
rm -f src
rm -f tgt
In upper level, src(upper) and tgt(upper) shares same inode; in ovl
level, src(ovl) and tgt(ovl) uses different inode. vfs_rename did
d_move, and dentry src(ovl) is renamed tgt, and dentry tgt(ovl) is
released. When unlink src, a new dentry src(ovl) is created, and is
removed, src(upper) is also removed; and then unlink tgt, renamed dentry
src(ovl) is removed, src(upper) is also removed(but for upper fs, the
src has already be removed).
ovl should call d_move/d_exchange by itself, then it can control wether
or not does it.
Signed-off-by: George Wang <xuw2015@gmail.com>
---
fs/overlayfs/dir.c | 10 ++++++++++
fs/overlayfs/super.c | 1 +
2 files changed, 11 insertions(+)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 692ceda..1b02688 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -915,6 +915,16 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old,
ovl_dentry_version_inc(old->d_parent);
ovl_dentry_version_inc(new->d_parent);
+ /*
+ *FS_RENAME_DOES_D_MOVE is set in fs_flags, we need to do d_move/d_exchange
+ *by ourselves. overwrite means no RENAME_EXCHANGE in flags, just do d_move;
+ *d_exchange otherwise.
+ */
+ if (overwrite)
+ d_move(old, new);
+ else
+ d_exchange(old, new);
+
out_dput:
dput(newdentry);
out_unlock:
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 7466ff3..0395653 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1097,6 +1097,7 @@ static struct file_system_type ovl_fs_type = {
.name = "overlay",
.mount = ovl_mount,
.kill_sb = kill_anon_super,
+ .fs_flags = FS_RENAME_DOES_D_MOVE,
};
MODULE_ALIAS_FS("overlay");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-03 9:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-03 9:12 [PATCH 1/2] fs: export d_exchange for the fs with FS_RENAME_DOSE_D_MOVE xuw2015
2015-09-03 9:12 ` [PATCH 2/2] ovl: ovl_rename2 should do d_move by itself xuw2015
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).