1. 12 4月, 2018 4 次提交
    • A
      ovl: constant st_ino for non-samefs with xino · e487d889
      Amir Goldstein 提交于
      On 64bit systems, when overlay layers are not all on the same fs, but
      all inode numbers of underlying fs are not using the high bits, use the
      high bits to partition the overlay st_ino address space.  The high bits
      hold the fsid (upper fsid is 0).  This way overlay inode numbers are unique
      and all inodes use overlay st_dev.  Inode numbers are also persistent
      for a given layer configuration.
      
      Currently, our only indication for available high ino bits is from a
      filesystem that supports file handles and uses the default encode_fh()
      operation, which encodes a 32bit inode number.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      e487d889
    • A
      ovl: allocate anon bdev per unique lower fs · 5148626b
      Amir Goldstein 提交于
      Instead of allocating an anonymous bdev per lower layer, allocate
      one anonymous bdev per every unique lower fs that is different than
      upper fs.
      
      Every unique lower fs is assigned an fsid > 0 and the number of
      unique lower fs are stored in ofs->numlowerfs.
      
      The assigned fsid is stored in the lower layer struct and will be
      used also for inode number multiplexing.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      5148626b
    • A
      ovl: factor out ovl_map_dev_ino() helper · da309e8c
      Amir Goldstein 提交于
      A helper for ovl_getattr() to map the values of st_dev and st_ino
      according to constant st_ino rules.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      da309e8c
    • A
      ovl: set i_ino to the value of st_ino for NFS export · 695b46e7
      Amir Goldstein 提交于
      Eddie Horng reported that readdir of an overlayfs directory that
      was exported via NFSv3 returns entries with d_type set to DT_UNKNOWN.
      The reason is that while preparing the response for readdirplus, nfsd
      checks inside encode_entryplus_baggage() that a child dentry's inode
      number matches the value of d_ino returns by overlayfs readdir iterator.
      
      Because the overlayfs inodes use arbitrary inode numbers that are not
      correlated with the values of st_ino/d_ino, NFSv3 falls back to not
      encoding d_type. Although this is an allowed behavior, we can fix it for
      the case of all overlayfs layers on the same underlying filesystem.
      
      When NFS export is enabled and d_ino is consistent with st_ino
      (samefs), set the same value also to i_ino in ovl_fill_inode() for all
      overlayfs inodes, nfsd readdirplus sanity checks will pass.
      ovl_fill_inode() may be called from ovl_new_inode(), before real inode
      was created with ino arg 0. In that case, i_ino will be updated to real
      upper inode i_ino on ovl_inode_init() or ovl_inode_update().
      Reported-by: NEddie Horng <eddiehorng.tw@gmail.com>
      Tested-by: NEddie Horng <eddiehorng.tw@gmail.com>
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Fixes: 8383f174 ("ovl: wire up NFS export operations")
      Cc: <stable@vger.kernel.org> #v4.16
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      695b46e7
  2. 24 1月, 2018 8 次提交
  3. 19 1月, 2018 1 次提交
    • A
      ovl: hash directory inodes for fsnotify · 31747eda
      Amir Goldstein 提交于
      fsnotify pins a watched directory inode in cache, but if directory dentry
      is released, new lookup will allocate a new dentry and a new inode.
      Directory events will be notified on the new inode, while fsnotify listener
      is watching the old pinned inode.
      
      Hash all directory inodes to reuse the pinned inode on lookup. Pure upper
      dirs are hashes by real upper inode, merge and lower dirs are hashed by
      real lower inode.
      
      The reference to lower inode was being held by the lower dentry object
      in the overlay dentry (oe->lowerstack[0]). Releasing the overlay dentry
      may drop lower inode refcount to zero. Add a refcount on behalf of the
      overlay inode to prevent that.
      
      As a by-product, hashing directory inodes also detects multiple
      redirected dirs to the same lower dir and uncovered redirected dir
      target on and returns -ESTALE on lookup.
      
      The reported issue dates back to initial version of overlayfs, but this
      patch depends on ovl_inode code that was introduced in kernel v4.13.
      
      Cc: <stable@vger.kernel.org> #v4.13
      Reported-by: NNiklas Cassel <niklas.cassel@axis.com>
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      Tested-by: NNiklas Cassel <niklas.cassel@axis.com>
      31747eda
  4. 09 11月, 2017 3 次提交
    • 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
    • A
      ovl: no direct iteration for dir with origin xattr · b79e05aa
      Amir Goldstein 提交于
      If a non-merge dir in an overlay mount has an overlay.origin xattr, it
      means it was once an upper merge dir, which may contain whiteouts and
      then the lower dir was removed under it.
      
      Do not iterate real dir directly in this case to avoid exposing whiteouts.
      
      [SzM] Set OVL_WHITEOUT for all merge directories as well.
      
      [amir] A directory that was just copied up does not have the OVL_WHITEOUTS
      flag. We need to set it to fix merge dir iteration.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      b79e05aa
  5. 05 10月, 2017 2 次提交
  6. 28 7月, 2017 1 次提交
    • M
      ovl: constant d_ino for non-merge dirs · 4edb83bb
      Miklos Szeredi 提交于
      Impure directories are ones which contain objects with origins (i.e. those
      that have been copied up).  These are relevant to readdir operation only
      because of the d_ino field, no other transformation is necessary.  Also a
      directory can become impure between two getdents(2) calls.
      
      This patch creates a cache for impure directories.  Unlike the cache for
      merged directories, this one only contains entries with origin and is not
      refcounted but has a its lifetime tied to that of the dentry.
      
      Similarly to the merged cache, the impure cache is invalidated based on a
      version number.  This version number is incremented when an entry with
      origin is added or removed from the directory.
      
      If the cache is empty, then the impure xattr is removed from the directory.
      
      This patch also fixes up handling of d_ino for the ".." entry if the parent
      directory is merged.
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      4edb83bb
  7. 20 7月, 2017 1 次提交
  8. 05 7月, 2017 15 次提交
  9. 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
  10. 19 5月, 2017 2 次提交
  11. 18 5月, 2017 1 次提交
  12. 05 5月, 2017 1 次提交
    • A
      ovl: set the ORIGIN type flag · 59548503
      Amir Goldstein 提交于
      For directory entries, non zero oe->numlower implies OVL_TYPE_MERGE.
      Define a new type flag OVL_TYPE_ORIGIN to indicate that an entry holds a
      reference to its lower copy up origin.
      
      For directory entries ORIGIN := MERGE && UPPER. For non-dir entries ORIGIN
      means that a lower type dentry has been recently copied up or that we were
      able to find the copy up origin from overlay.origin xattr.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      59548503