Skip to content

Commit 8ea2876

Browse files
amir73ilMiklos Szeredi
authored andcommitted
ovl: do not reconnect upper index records in ovl_indexdir_cleanup()
ovl_indexdir_cleanup() is called on mount of overayfs with nfs_export feature to cleanup stale index records for lower and upper files that have been deleted while overlayfs was offline. This has the side effect (good or bad) of pre populating inode cache with all the copied up upper inodes, while verifying the index entries. For copied up directories, the upper file handles are decoded to conncted upper dentries. This has the even bigger side effect of reading the content of all the parent upper directories which may take significantly more time and IO than just reading the upper inodes. Do not request connceted upper dentries for verifying upper directory index entries, because we have no use for the connected dentry. Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent cdf5c9d commit 8ea2876

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

fs/overlayfs/export.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static struct dentry *ovl_lookup_real_inode(struct super_block *sb,
463463

464464
/* Get connected upper overlay dir from index */
465465
if (index) {
466-
struct dentry *upper = ovl_index_upper(ofs, index);
466+
struct dentry *upper = ovl_index_upper(ofs, index, true);
467467

468468
dput(index);
469469
if (IS_ERR_OR_NULL(upper))
@@ -739,7 +739,7 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
739739

740740
/* Then try to get a connected upper dir by index */
741741
if (index && d_is_dir(index)) {
742-
struct dentry *upper = ovl_index_upper(ofs, index);
742+
struct dentry *upper = ovl_index_upper(ofs, index, true);
743743

744744
err = PTR_ERR(upper);
745745
if (IS_ERR_OR_NULL(upper))

fs/overlayfs/namei.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry,
487487
}
488488

489489
/* Get upper dentry from index */
490-
struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
490+
struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index,
491+
bool connected)
491492
{
492493
struct ovl_fh *fh;
493494
struct dentry *upper;
@@ -499,7 +500,7 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
499500
if (IS_ERR_OR_NULL(fh))
500501
return ERR_CAST(fh);
501502

502-
upper = ovl_decode_real_fh(ofs, fh, ovl_upper_mnt(ofs), true);
503+
upper = ovl_decode_real_fh(ofs, fh, ovl_upper_mnt(ofs), connected);
503504
kfree(fh);
504505

505506
if (IS_ERR_OR_NULL(upper))
@@ -572,7 +573,7 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
572573
* directly from the index dentry, but for dir index we first need to
573574
* decode the upper directory.
574575
*/
575-
upper = ovl_index_upper(ofs, index);
576+
upper = ovl_index_upper(ofs, index, false);
576577
if (IS_ERR_OR_NULL(upper)) {
577578
err = PTR_ERR(upper);
578579
/*

fs/overlayfs/overlayfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
525525
int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry,
526526
enum ovl_xattr ox, struct dentry *real, bool is_upper,
527527
bool set);
528-
struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index);
528+
struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index,
529+
bool connected);
529530
int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index);
530531
int ovl_get_index_name(struct ovl_fs *ofs, struct dentry *origin,
531532
struct qstr *name);

0 commit comments

Comments
 (0)