1. 24 1月, 2018 10 次提交
    • A
      ovl: cleanup temp index entries · 9ee60ce2
      Amir Goldstein 提交于
      A previous failed attempt to create or whiteout a directory index may
      leave index entries named '#%x' in the index dir. Cleanup those temp
      entries on mount instead of failing the mount.
      
      In the future, we may drop 'work' dir and use 'index' dir instead.
      This change is enough for cleaning up copy up leftovers 'from the future',
      but it is not enough for cleaning up rmdir leftovers 'from the future'
      (i.e. temp dir containing whiteouts).
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      9ee60ce2
    • A
      ovl: verify directory index entries on mount · e8f9e5b7
      Amir Goldstein 提交于
      Directory index entries should have 'upper' xattr pointing to the real
      upper dir. Verifying that the upper dir file handle is not stale is
      expensive, so only verify stale directory index entries on mount if
      NFS export feature is enabled.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      e8f9e5b7
    • A
      ovl: verify whiteout index entries on mount · 7db25d36
      Amir Goldstein 提交于
      Whiteout index entries are used as an indication that an exported
      overlay file handle should be treated as stale (i.e. after unlink
      of the overlay inode).
      
      Check on mount that whiteout index entries have a name that looks like
      a valid file handle and cleanup invalid index entries.
      
      For whiteout index entries, do not check that they also have valid
      origin fh and nlink xattr, because those xattr do not exist for a
      whiteout index entry.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      7db25d36
    • A
      ovl: use directory index entries for consistency verification · ad1d615c
      Amir Goldstein 提交于
      A directory index is a directory type entry in index dir with a
      "trusted.overlay.upper" xattr containing an encoded ovl_fh of the merge
      directory upper dir inode.
      
      On lookup of non-dir files, lower file is followed by origin file handle.
      On lookup of dir entries, lower dir is found by name and then compared
      to origin file handle. We only trust dir index if we verified that lower
      dir matches origin file handle, otherwise index may be inconsistent and
      we ignore it.
      
      If we find an indexed non-upper dir or an indexed merged dir, whose
      index 'upper' xattr points to a different upper dir, that means that the
      lower directory may be also referenced by another upper dir via redirect,
      so we fail the lookup on inconsistency error.
      
      To be consistent with directory index entries format, the association of
      index dir to upper root dir, that was stored by older kernels in
      "trusted.overlay.origin" xattr is now stored in "trusted.overlay.upper"
      xattr. This also serves as an indication that overlay was mounted with a
      kernel that support index directory entries. For backward compatibility,
      if an 'origin' xattr exists on the index dir we also verify it on mount.
      
      Directory index entries are going to be used for NFS export.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      ad1d615c
    • A
      ovl: verify stored origin fh matches lower dir · 37b12916
      Amir Goldstein 提交于
      When the NFS export feature is enabled, overlayfs implicitly enables the
      feature "verify_lower". When the "verify_lower" feature is enabled, a
      directory inode found in lower layer by name or by redirect_dir is
      verified against the file handle of the copy up origin that is stored in
      the upper layer.
      
      This introduces a change of behavior for the case of lower layer
      modification while overlay is offline. A lower directory created or
      moved offline under an exisitng upper directory, will not be merged with
      that upper directory.
      
      The NFS export feature should not be used after copying layers, because
      the new lower directory inodes would fail verification and won't be
      merged with upper directories.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      37b12916
    • A
      ovl: generalize ovl_verify_origin() and helpers · 05122443
      Amir Goldstein 提交于
      Remove the "origin" language from the functions that handle set, get
      and verify of "origin" xattr and pass the xattr name as an argument.
      
      The same helpers are going to be used for NFS export to get, get and
      verify the "upper" xattr for directory index entries.
      
      ovl_verify_origin() is now a helper used only to verify non upper
      file handle stored in "origin" xattr of upper inode.
      
      The upper root dir file handle is still stored in "origin" xattr on
      the index dir for backward compatibility. This is going to be changed
      by the patch that adds directory index entries support.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      05122443
    • A
      ovl: simplify arguments to ovl_check_origin_fh() · 1eff1a1d
      Amir Goldstein 提交于
      Pass the fs instance with lower_layers array instead of the dentry
      lowerstack array to ovl_check_origin_fh(), because the dentry members
      of lowerstack play no role in this helper.
      
      This change simplifies the argument list of ovl_check_origin(),
      ovl_cleanup_index() and ovl_verify_index().
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      1eff1a1d
    • A
      ovl: factor out ovl_check_origin_fh() · 2e1a5328
      Amir Goldstein 提交于
      Re-factor ovl_check_origin() and ovl_get_origin(), so origin fh xattr is
      read from upper inode only once during lookup with multiple lower layers
      and only once when verifying index entry origin.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      2e1a5328
    • A
      ovl: store layer index in ovl_layer · d583ed7d
      Amir Goldstein 提交于
      Store the fs root layer index inside ovl_layer struct, so we can
      get the root fs layer index from merge dir lower layer instead of
      find it with ovl_find_layer() helper.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      d583ed7d
    • A
      ovl: fix inconsistent d_ino for legacy merge dir · 9678e630
      Amir Goldstein 提交于
      For a merge dir that was copied up before v4.12 or that was hand crafted
      offline (e.g. mkdir {upper/lower}/dir), upper dir does not contain the
      'trusted.overlay.origin' xattr.  In that case, stat(2) on the merge dir
      returns the lower dir st_ino, but getdents(2) returns the upper dir d_ino.
      
      After this change, on merge dir lookup, missing origin xattr on upper
      dir will be fixed and 'impure' xattr will be fixed on parent of the legacy
      merge dir.
      Suggested-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      9678e630
  2. 20 1月, 2018 2 次提交
    • A
      ovl: fix another overlay: warning prefix · f8167817
      Amir Goldstein 提交于
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      f8167817
    • A
      ovl: take lower dir inode mutex outside upper sb_writers lock · 6d0a8a90
      Amir Goldstein 提交于
      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: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      6d0a8a90
  3. 11 12月, 2017 2 次提交
  4. 10 11月, 2017 2 次提交
  5. 09 11月, 2017 2 次提交
    • C
      ovl: re-structure overlay lower layers in-memory · b9343632
      Chandan Rajendra 提交于
      Define new structures to represent overlay instance lower layers and
      overlay merge dir lower layers to make room for storing more per layer
      information in-memory.
      
      Instead of keeping the fs instance lower layers in an array of struct
      vfsmount, keep them in an array of new struct ovl_layer, that has a
      pointer to struct vfsmount.
      
      Instead of keeping the dentry lower layers in an array of struct path,
      keep them in an array of new struct ovl_path, that has a pointer to
      struct dentry and to struct ovl_layer.
      
      Add a small helper to find the fs layer id that correspopnds to a lower
      struct ovl_path and use it in ovl_lookup().
      
      [amir: split re-structure from anonymous bdev patch]
      Signed-off-by: NChandan Rajendra <chandan@linux.vnet.ibm.com>
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      b9343632
    • A
      ovl: move include of ovl_entry.h into overlayfs.h · ee023c30
      Amir Goldstein 提交于
      Most overlayfs c files already explicitly include ovl_entry.h
      to use overlay entry struct definitions and upcoming changes
      are going to require even more c files to include this header.
      
      All overlayfs c files include overlayfs.h and overlayfs.h itself
      refers to some structs defined in ovl_entry.h, so it seems more
      logic to include ovl_entry.h from overlayfs.h than from c files.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      ee023c30
  6. 24 10月, 2017 3 次提交
    • A
      ovl: do not cleanup unsupported index entries · fa0096e3
      Amir Goldstein 提交于
      With index=on, ovl_indexdir_cleanup() tries to cleanup invalid index
      entries (e.g. bad index name). This behavior could result in cleaning of
      entries created by newer kernels and is therefore undesirable.
      Instead, abort mount if such entries are encountered. We still cleanup
      'stale' entries and 'orphan' entries, both those cases can be a result
      of offline changes to lower and upper dirs.
      
      When encoutering an index entry of type directory or whiteout, kernel
      was supposed to fallback to read-only mount, but the fill_super()
      operation returns EROFS in this case instead of returning success with
      read-only mount flag, so mount fails when encoutering directory or
      whiteout index entries. Bless this behavior by returning -EINVAL on
      directory and whiteout index entries as we do for all unsupported index
      entries.
      
      Fixes: 61b67471 ("ovl: do not cleanup directory and whiteout index..")
      Cc: <stable@vger.kernel.org> # v4.13
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      fa0096e3
    • A
      ovl: handle ENOENT on index lookup · 7937a56f
      Amir Goldstein 提交于
      Treat ENOENT from index entry lookup the same way as treating a returned
      negative dentry. Apparently, either could be returned if file is not
      found, depending on the underlying file system.
      
      Fixes: 359f392c ("ovl: lookup index entry for copy up origin")
      Cc: <stable@vger.kernel.org> # v4.13
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      7937a56f
    • A
      ovl: fix EIO from lookup of non-indexed upper · 6eaf0111
      Amir Goldstein 提交于
      Commit fbaf94ee ("ovl: don't set origin on broken lower hardlink")
      attempt to avoid the condition of non-indexed upper inode with lower
      hardlink as origin. If this condition is found, lookup returns EIO.
      
      The protection of commit mentioned above does not cover the case of lower
      that is not a hardlink when it is copied up (with either index=off/on)
      and then lower is hardlinked while overlay is offline.
      
      Changes to lower layer while overlayfs is offline should not result in
      unexpected behavior, so a permanent EIO error after creating a link in
      lower layer should not be considered as correct behavior.
      
      This fix replaces EIO error with success in cases where upper has origin
      but no index is found, or index is found that does not match upper
      inode. In those cases, lookup will not fail and the returned overlay inode
      will be hashed by upper inode instead of by lower origin inode.
      
      Fixes: 359f392c ("ovl: lookup index entry for copy up origin")
      Cc: <stable@vger.kernel.org> # v4.13
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      6eaf0111
  7. 19 10月, 2017 1 次提交
  8. 05 10月, 2017 1 次提交
  9. 14 9月, 2017 1 次提交
    • M
      mm: treewide: remove GFP_TEMPORARY allocation flag · 0ee931c4
      Michal Hocko 提交于
      GFP_TEMPORARY was introduced by commit e12ba74d ("Group short-lived
      and reclaimable kernel allocations") along with __GFP_RECLAIMABLE.  It's
      primary motivation was to allow users to tell that an allocation is
      short lived and so the allocator can try to place such allocations close
      together and prevent long term fragmentation.  As much as this sounds
      like a reasonable semantic it becomes much less clear when to use the
      highlevel GFP_TEMPORARY allocation flag.  How long is temporary? Can the
      context holding that memory sleep? Can it take locks? It seems there is
      no good answer for those questions.
      
      The current implementation of GFP_TEMPORARY is basically GFP_KERNEL |
      __GFP_RECLAIMABLE which in itself is tricky because basically none of
      the existing caller provide a way to reclaim the allocated memory.  So
      this is rather misleading and hard to evaluate for any benefits.
      
      I have checked some random users and none of them has added the flag
      with a specific justification.  I suspect most of them just copied from
      other existing users and others just thought it might be a good idea to
      use without any measuring.  This suggests that GFP_TEMPORARY just
      motivates for cargo cult usage without any reasoning.
      
      I believe that our gfp flags are quite complex already and especially
      those with highlevel semantic should be clearly defined to prevent from
      confusion and abuse.  Therefore I propose dropping GFP_TEMPORARY and
      replace all existing users to simply use GFP_KERNEL.  Please note that
      SLAB users with shrinkers will still get __GFP_RECLAIMABLE heuristic and
      so they will be placed properly for memory fragmentation prevention.
      
      I can see reasons we might want some gfp flag to reflect shorterm
      allocations but I propose starting from a clear semantic definition and
      only then add users with proper justification.
      
      This was been brought up before LSF this year by Matthew [1] and it
      turned out that GFP_TEMPORARY really doesn't have a clear semantic.  It
      seems to be a heuristic without any measured advantage for most (if not
      all) its current users.  The follow up discussion has revealed that
      opinions on what might be temporary allocation differ a lot between
      developers.  So rather than trying to tweak existing users into a
      semantic which they haven't expected I propose to simply remove the flag
      and start from scratch if we really need a semantic for short term
      allocations.
      
      [1] http://lkml.kernel.org/r/20170118054945.GD18349@bombadil.infradead.org
      
      [akpm@linux-foundation.org: fix typo]
      [akpm@linux-foundation.org: coding-style fixes]
      [sfr@canb.auug.org.au: drm/i915: fix up]
        Link: http://lkml.kernel.org/r/20170816144703.378d4f4d@canb.auug.org.au
      Link: http://lkml.kernel.org/r/20170728091904.14627-1-mhocko@kernel.orgSigned-off-by: NMichal Hocko <mhocko@suse.com>
      Signed-off-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Acked-by: NMel Gorman <mgorman@suse.de>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Neil Brown <neilb@suse.de>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0ee931c4
  10. 20 7月, 2017 2 次提交
  11. 05 7月, 2017 12 次提交
  12. 05 6月, 2017 1 次提交
  13. 29 5月, 2017 1 次提交
    • A
      ovl: mark upper merge dir with type origin entries "impure" · f3a15685
      Amir Goldstein 提交于
      An upper dir is marked "impure" to let ovl_iterate() know that this
      directory may contain non pure upper entries whose d_ino may need to be
      read from the origin inode.
      
      We already mark a non-merge dir "impure" when moving a non-pure child
      entry inside it, to let ovl_iterate() know not to iterate the non-merge
      dir directly.
      
      Mark also a merge dir "impure" when moving a non-pure child entry inside
      it and when copying up a child entry inside it.
      
      This can be used to optimize ovl_iterate() to perform a "pure merge" of
      upper and lower directories, merging the content of the directories,
      without having to read d_ino from origin inodes.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      f3a15685