Re: [PATCH 1/3] ovl: cleanup non-empty directories in ovl_indexdir_cleanup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 10, 2020 at 10:25 AM Amir Goldstein <amir73il@xxxxxxxxx> wrote:
>
> Teach ovl_indexdir_cleanup() to remove temp directories containing
> whiteouts to prepare for using index dir instead of work dir for
> removing merge directories.
>
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> ---
>  fs/overlayfs/overlayfs.h |  4 ++--
>  fs/overlayfs/readdir.c   | 13 +++++++------
>  2 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index e6f3670146ed..e00b1ff6dea9 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -394,8 +394,8 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list);
>  void ovl_cache_free(struct list_head *list);
>  void ovl_dir_cache_free(struct inode *inode);
>  int ovl_check_d_type_supported(struct path *realpath);
> -void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
> -                        struct dentry *dentry, int level);
> +int ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
> +                       struct dentry *dentry, int level);
>  int ovl_indexdir_cleanup(struct ovl_fs *ofs);
>
>  /* inode.c */
> diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
> index e452ff7d583d..d6b601caf122 100644
> --- a/fs/overlayfs/readdir.c
> +++ b/fs/overlayfs/readdir.c
> @@ -1071,14 +1071,13 @@ static void ovl_workdir_cleanup_recurse(struct path *path, int level)
>         ovl_cache_free(&list);
>  }
>
> -void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
> +int ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
>                          struct dentry *dentry, int level)
>  {
>         int err;
>
>         if (!d_is_dir(dentry) || level > 1) {
> -               ovl_cleanup(dir, dentry);
> -               return;
> +               return ovl_cleanup(dir, dentry);
>         }
>
>         err = ovl_do_rmdir(dir, dentry);
> @@ -1088,8 +1087,10 @@ void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
>                 inode_unlock(dir);
>                 ovl_workdir_cleanup_recurse(&path, level + 1);
>                 inode_lock_nested(dir, I_MUTEX_PARENT);
> -               ovl_cleanup(dir, dentry);
> +               err = ovl_cleanup(dir, dentry);
>         }
> +
> +       return err;
>  }
>
>  int ovl_indexdir_cleanup(struct ovl_fs *ofs)
> @@ -1132,8 +1133,8 @@ int ovl_indexdir_cleanup(struct ovl_fs *ofs)
>                 if (!err) {
>                         goto next;
>                 } else if (err == -ESTALE) {
> -                       /* Cleanup stale index entries */
> -                       err = ovl_cleanup(dir, index);
> +                       /* Cleanup stale index entries and leftover whiteouts */
> +                       err = ovl_workdir_cleanup(dir, path.mnt, index, 1);

I'd much prefer if cleanup of temp files were handled separately from
stale index entries.  I.e. only call ovl_verify_index() on things that
might actually be index files.


>                 } else if (err != -ENOENT) {
>                         /*
>                          * Abort mount to avoid corrupting the index if
> --
> 2.17.1
>



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux