Skip to content

Commit 09adc80

Browse files
committed
ceph: preserve I_COMPLETE across rename
d_move puts the renamed dentry at the end of d_subdirs, screwing with our cached dentry directory offsets. We were just clearing I_COMPLETE to avoid any possibility of trouble. However, assigning the renamed dentry an offset at the end of the directory (to match it's new d_subdirs position) is sufficient to maintain correct behavior and hold onto I_COMPLETE. This is especially important for workloads like rsync, which renames files into place. Before, we would lose I_COMPLETE and do MDS lookups for each file. With this patch we only talk to the MDS on create and rename. Signed-off-by: Sage Weil <sage@newdream.net>
1 parent b09734b commit 09adc80

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎fs/ceph/inode.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
10301030
dout("fill_trace doing d_move %p -> %p\n",
10311031
req->r_old_dentry, dn);
10321032

1033-
/* d_move screws up d_subdirs order */
1034-
ceph_i_clear(dir, CEPH_I_COMPLETE);
1035-
10361033
d_move(req->r_old_dentry, dn);
10371034
dout(" src %p '%.*s' dst %p '%.*s'\n",
10381035
req->r_old_dentry,
@@ -1044,12 +1041,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
10441041
rehashing bug in vfs_rename_dir */
10451042
ceph_invalidate_dentry_lease(dn);
10461043

1047-
/* take overwritten dentry's readdir offset */
1048-
dout("dn %p gets %p offset %lld (old offset %lld)\n",
1049-
req->r_old_dentry, dn, ceph_dentry(dn)->offset,
1044+
/*
1045+
* d_move() puts the renamed dentry at the end of
1046+
* d_subdirs. We need to assign it an appropriate
1047+
* directory offset so we can behave when holding
1048+
* I_COMPLETE.
1049+
*/
1050+
ceph_set_dentry_offset(req->r_old_dentry);
1051+
dout("dn %p gets new offset %lld\n", req->r_old_dentry,
10501052
ceph_dentry(req->r_old_dentry)->offset);
1051-
ceph_dentry(req->r_old_dentry)->offset =
1052-
ceph_dentry(dn)->offset;
10531053

10541054
dn = req->r_old_dentry; /* use old_dentry */
10551055
in = dn->d_inode;

0 commit comments

Comments
 (0)