1. 05 2月, 2018 1 次提交
  2. 24 1月, 2018 13 次提交
    • A
      ovl: lookup indexed ancestor of lower dir · 06170154
      Amir Goldstein 提交于
      ovl_lookup_real() in lower layer walks back lower parents to find the
      topmost indexed parent. If an indexed ancestor is found before reaching
      lower layer root, ovl_lookup_real() is called recursively with upper
      layer to walk back from indexed upper to the topmost connected/hashed
      upper parent (or up to root).
      
      ovl_lookup_real() in upper layer then walks forward to connect the topmost
      upper overlay dir dentry and ovl_lookup_real() in lower layer continues to
      walk forward to connect the decoded lower overlay dir dentry.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      06170154
    • A
      ovl: lookup connected ancestor of dir in inode cache · 4b91c30a
      Amir Goldstein 提交于
      Decoding a dir file handle requires walking backward up to layer root and
      for lower dir also checking the index to see if any of the parents have
      been copied up.
      
      Lookup overlay ancestor dentry in inode/dentry cache by decoded real
      parents to shortcut looking up all the way back to layer root.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      4b91c30a
    • A
      ovl: decode pure lower dir file handles · 98892516
      Amir Goldstein 提交于
      Similar to decoding a pure upper dir file handle, decoding a pure lower
      dir file handle is implemented by looking an overlay dentry of the same
      path as the pure lower path and verifying that the overlay dentry's
      real lower matches the decoded real lower file handle.
      
      Unlike the case of upper dir file handle, the lookup of overlay path by
      lower real path can fail or find a mismatched overlay dentry if any of
      the lower parents have been copied up and renamed. To address this case
      we will need to check if any of the lower parents are indexed.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      98892516
    • A
      ovl: decode indexed dir file handles · 3b0bfc6e
      Amir Goldstein 提交于
      Decoding an indexed dir file handle is done by looking up the file handle
      in index dir by name and then decoding the upper dir from the index origin
      file handle. The decoded upper path is used to lookup an overlay dentry of
      the same path.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      3b0bfc6e
    • A
      ovl: decode lower file handles of unlinked but open files · 9436a1a3
      Amir Goldstein 提交于
      Lookup overlay inode in cache by origin inode, so we can decode a file
      handle of an open file even if the index has a whiteout index entry to
      mark this overlay inode was unlinked.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      9436a1a3
    • A
      ovl: decode indexed non-dir file handles · f71bd9cf
      Amir Goldstein 提交于
      Decoding an indexed non-dir file handle is similar to decoding a lower
      non-dir file handle, but additionally, we lookup the file handle in index
      dir by name to find the real upper inode.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      f71bd9cf
    • A
      ovl: decode lower non-dir file handles · f941866f
      Amir Goldstein 提交于
      Decoding a lower non-dir file handle is done by decoding the lower dentry
      from underlying lower fs, finding or allocating an overlay inode that is
      hashed by the real lower inode and instantiating an overlay dentry with
      that inode.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      f941866f
    • A
      ovl: encode lower file handles · 03e1c584
      Amir Goldstein 提交于
      For indexed or lower non-dir, encode a non-connectable lower file handle
      from origin inode. For indexed or lower dir, when ofs->numlower == 1,
      encode a lower file handle from lower dir.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      03e1c584
    • A
      ovl: copy up before encoding non-connectable dir file handle · 05e1f118
      Amir Goldstein 提交于
      Decoding a merge dir, whose origin's parent is under a redirected
      lower dir is not always possible. As a simple aproximation, we do
      not encode lower dir file handles when overlay has multiple lower
      layers and origin is below the topmost lower layer.
      
      We should later relax this condition and copy up only the parent
      that is under a redirected lower.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      05e1f118
    • A
      ovl: encode non-indexed upper file handles · b305e844
      Amir Goldstein 提交于
      We only need to encode origin if there is a chance that the same object was
      encoded pre copy up and then we need to stay consistent with the same
      encoding also after copy up.
      
      In case a non-pure upper is not indexed, then it was copied up before NFS
      export support was enabled. In that case, we don't need to worry about
      staying consistent with pre copy up encoding and we encode an upper file
      handle.
      
      This mitigates the problem that with no index, we cannot find an upper
      inode from origin inode, so we cannot decode a non-indexed upper from
      origin file handle.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      b305e844
    • A
      ovl: decode connected upper dir file handles · 3985b70a
      Amir Goldstein 提交于
      Until this change, we decoded upper file handles by instantiating an
      overlay dentry from the real upper dentry. This is sufficient to handle
      pure upper files, but insufficient to handle merge/impure dirs.
      
      To that end, if decoded real upper dir is connected and hashed, we
      lookup an overlay dentry with the same path as the real upper dir.
      If decoded real upper is non-dir, we instantiate a disconnected overlay
      dentry as before this change.
      
      Because ovl_fh_to_dentry() returns a connected overlay dir dentry,
      exportfs never needs to call get_parent() and get_name() to reconnect an
      upper overlay dir. Because connectable non-dir file handles are not
      supported, exportfs will not be able to use fh_to_parent() and get_name()
      methods to reconnect a disconnected non-dir to its parent. Therefore, the
      methods get_parent() and get_name() are implemented just to print out a
      sanity warning and the method fh_to_parent() is implemented to warn the
      user that using the 'subtree_check' exportfs option is not supported.
      
      An alternative approach could have been to implement instantiating of
      an overlay directory inode from origin/index and implement get_parent()
      and get_name() by calling into underlying fs operations and them
      instantiating the overlay parent dir.
      
      The reasons for not choosing the get_parent() approach were:
      - Obtaining a disconnected overlay dir dentry would requires a
        delicate re-factoring of ovl_lookup() to get a dentry with overlay
        parent info. It was preferred to avoid doing that re-factoring unless
        it was proven worthy.
      - Going down the path of disconnected dir would mean that the (non
        trivial) code path of d_splice_alias() could be traveled and that
        meant writing more tests and introduces race cases that are very hard
        to hit on purpose. Taking the path of connecting overlay dentry by
        forward lookup is therefore the safe and boring way to avoid surprises.
      
      The culprits of the chosen "connected overlay dentry" approach:
      - We need to take special care to rename of ancestors while connecting
        the overlay dentry by real dentry path. These subtleties are usually
        handled by generic exportfs and VFS code.
      - In a hypothetical workload, we could end up in a loop trying to connect,
        interrupted by rename and restarting connect forever.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      3985b70a
    • A
      ovl: decode pure upper file handles · 8556a420
      Amir Goldstein 提交于
      Decoding an upper file handle is done by decoding the upper dentry from
      underlying upper fs, finding or allocating an overlay inode that is
      hashed by the real upper inode and instantiating an overlay dentry with
      that inode.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      8556a420
    • A
      ovl: encode pure upper file handles · 8ed5eec9
      Amir Goldstein 提交于
      Encode overlay file handles as struct ovl_fh containing the file handle
      encoding of the real upper inode.
      Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      8ed5eec9