1. 24 Jan, 2018 35 commits
  2. 19 Jan, 2018 5 commits
    • Amir Goldstein's avatar
      ovl: take mnt_want_write() for removing impure xattr · a5a927a7
      Amir Goldstein authored
      The optimization in ovl_cache_get_impure() that tries to remove an
      unneeded "impure" xattr needs to take mnt_want_write() on upper fs.
      
      Fixes: 4edb83bb ("ovl: constant d_ino for non-merge dirs")
      Cc: <stable@vger.kernel.org> #v4.14
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      a5a927a7
    • Amir Goldstein's avatar
      ovl: take mnt_want_write() for work/index dir setup · 2ba9d57e
      Amir Goldstein authored
      There are several write operations on upper fs not covered by
      mnt_want_write():
      
      - test set/remove OPAQUE xattr
      - test create O_TMPFILE
      - set ORIGIN xattr in ovl_verify_origin()
      - cleanup of index entries in ovl_indexdir_cleanup()
      
      Some of these go way back, but this patch only applies over the
      v4.14 re-factoring of ovl_fill_super().
      
      Cc: <stable@vger.kernel.org> #v4.14
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      2ba9d57e
    • Amir Goldstein's avatar
      f8167817
    • Amir Goldstein's avatar
      ovl: take lower dir inode mutex outside upper sb_writers lock · 6d0a8a90
      Amir Goldstein authored
      The functions ovl_lower_positive() and ovl_check_empty_dir() both take
      inode mutex on the real lower dir under ovl_want_write() which takes
      the upper_mnt sb_writers lock.
      
      While this is not a clear locking order or layering violation, it creates
      an undesired lock dependency between two unrelated layers for no good
      reason.
      
      This lock dependency materializes to a false(?) positive lockdep warning
      when calling rmdir() on a nested overlayfs, where both nested and
      underlying overlayfs both use the same fs type as upper layer.
      
      rmdir() on the nested overlayfs creates the lock chain:
        sb_writers of upper_mnt (e.g. tmpfs) in ovl_do_remove()
        ovl_i_mutex_dir_key[] of lower overlay dir in ovl_lower_positive()
      
      rmdir() on the underlying overlayfs creates the lock chain in
      reverse order:
        ovl_i_mutex_dir_key[] of lower overlay dir in vfs_rmdir()
        sb_writers of nested upper_mnt (e.g. tmpfs) in ovl_do_remove()
      
      To rid of the unneeded locking dependency, move both ovl_lower_positive()
      and ovl_check_empty_dir() to before ovl_want_write() in rmdir() and
      rename() implementation.
      
      This change spreads the pieces of ovl_check_empty_and_clear() directly
      inside the rmdir()/rename() implementations so the helper is no longer
      needed and removed.
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      6d0a8a90
    • Amir Goldstein's avatar
      ovl: fix failure to fsync lower dir · d796e77f
      Amir Goldstein authored
      As a writable mount, it is not expected for overlayfs to return
      EINVAL/EROFS for fsync, even if dir/file is not changed.
      
      This commit fixes the case of fsync of directory, which is easier to
      address, because overlayfs already implements fsync file operation for
      directories.
      
      The problem reported by Raphael is that new PostgreSQL 10.0 with a
      database in overlayfs where lower layer in squashfs fails to start.
      The failure is due to fsync error, when PostgreSQL does fsync on all
      existing db directories on startup and a specific directory exists
      lower layer with no changes.
      Reported-by: default avatarRaphael Hertzog <raphael@ouaza.com>
      Cc: <stable@vger.kernel.org> # v3.18
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Tested-by: default avatarRaphaël Hertzog <hertzog@debian.org>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      d796e77f