<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/overlayfs/util.c, branch linux-4.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-04-19T06:54:09Z</updated>
<entry>
<title>ovl: set i_ino to the value of st_ino for NFS export</title>
<updated>2018-04-19T06:54:09Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-03-15T21:39:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=63437bd1ca69a6512cb3236a03e4a4f36d0329ff'/>
<id>urn:sha1:63437bd1ca69a6512cb3236a03e4a4f36d0329ff</id>
<content type='text'>
commit 695b46e76b62447e506cddc87e088236498008e5 upstream.

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: Eddie Horng &lt;eddiehorng.tw@gmail.com&gt;
Tested-by: Eddie Horng &lt;eddiehorng.tw@gmail.com&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Fixes: 8383f1748829 ("ovl: wire up NFS export operations")
Cc: &lt;stable@vger.kernel.org&gt; #v4.16
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ovl: store 'has_upper' and 'opaque' as bit flags</title>
<updated>2018-01-24T10:25:58Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-01-14T17:25:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c62520a83bceae0bb0b7b3de10c3e81205cd3823'/>
<id>urn:sha1:c62520a83bceae0bb0b7b3de10c3e81205cd3823</id>
<content type='text'>
We need to make some room in struct ovl_entry to store information
about redirected ancestors for NFS export, so cram two booleans as
bit flags.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: copy up of disconnected dentries</title>
<updated>2018-01-24T10:25:58Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-10-15T15:00:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=aa3ff3c152ff94ef045ed802db7535167f8a21ab'/>
<id>urn:sha1:aa3ff3c152ff94ef045ed802db7535167f8a21ab</id>
<content type='text'>
With NFS export, some operations on decoded file handles (e.g. open,
link, setattr, xattr_set) may call copy up with a disconnected non-dir.
In this case, we will copy up lower inode to index dir without
linking it to upper dir.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: whiteout index when union nlink drops to zero</title>
<updated>2018-01-24T10:25:56Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-10-24T14:38:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e7dd0e71348c1e3bc4b9d767c1ffbcbdee46a726'/>
<id>urn:sha1:e7dd0e71348c1e3bc4b9d767c1ffbcbdee46a726</id>
<content type='text'>
With NFS export feature enabled, when overlay inode nlink drops to
zero, instead of removing the index entry, replace it with a whiteout
index entry.

This is needed for NFS export in order to prevent future open by handle
from opening the lower file directly.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: cleanup dir index when dir nlink drops to zero</title>
<updated>2018-01-24T10:25:55Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-09-26T04:40:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=89a17556ce4d113f6e7896e118a14f79a84484e9'/>
<id>urn:sha1:89a17556ce4d113f6e7896e118a14f79a84484e9</id>
<content type='text'>
When non-dir index union nlink drops to zero the non-dir index
is cleaned. Do the same for directory type index entries when
union directory is removed.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: index directories on copy up for NFS export</title>
<updated>2018-01-24T10:25:55Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-01-11T12:01:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=016b720f5558d825bc0a4c6d2bdd6929fbe86536'/>
<id>urn:sha1:016b720f5558d825bc0a4c6d2bdd6929fbe86536</id>
<content type='text'>
With the NFS export feature enabled, all dirs are indexed on copy up.
Non-dir files are copied up directly to indexdir and then hardlinked
to upper dir.

Directories are copied up to indexdir, then an index entry is created
in indexdir with 'upper' xattr pointing to the copied up dir and then
the copied up dir is moved to upper dir.

Directory index is also used for consistency verification, like
detecting multiple redirected dirs to the same lower dir on lookup.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: index all non-dir on copy up for NFS export</title>
<updated>2018-01-24T10:25:54Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-11-21T22:08:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fbd2d2074bde2e333d9a9eeda5864cd593fbe29c'/>
<id>urn:sha1:fbd2d2074bde2e333d9a9eeda5864cd593fbe29c</id>
<content type='text'>
With the NFS export feature enabled, all non-dir are indexed on copy up.
The copy up origin inode of an indexed non-dir can be used as a unique
identifier of the overlay object.

The full index is also used for consistency verfication, like detecting
multiple non-hardlink uppers with the same 'origin' on lookup.

Directory index on copy up will be implemented by following patch.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: create ovl_need_index() helper</title>
<updated>2018-01-24T10:25:54Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-09-26T04:55:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=24b33ee104ecd5a4e1e71412f8966199d6a0bf02'/>
<id>urn:sha1:24b33ee104ecd5a4e1e71412f8966199d6a0bf02</id>
<content type='text'>
The helper determines which lower file needs to be indexed
on copy up and before nlink changes.

For index=on, the helper evaluates to true for lower hardlinks.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: add support for "nfs_export" configuration</title>
<updated>2018-01-24T10:25:37Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-01-19T09:26:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f168f1098dd9038daaf9f7be5f81cdea4985886a'/>
<id>urn:sha1:f168f1098dd9038daaf9f7be5f81cdea4985886a</id>
<content type='text'>
Introduce the "nfs_export" config, module and mount options.

The NFS export feature depends on the "index" feature and enables two
implicit overlayfs features: "index_all" and "verify_lower".
The "index_all" feature creates an index on copy up of every file and
directory. The "verify_lower" feature uses the full index to detect
overlay filesystems inconsistencies on lookup, like redirect from
multiple upper dirs to the same lower dir.

NFS export can be enabled for non-upper mount with no index. However,
because lower layer redirects cannot be verified with the index, enabling
NFS export support on an overlay with no upper layer requires turning off
redirect follow (e.g. "redirect_dir=nofollow").

The full index may incur some overhead on mount time, especially when
verifying that lower directory file handles are not stale.

NFS export support, full index and consistency verification will be
implemented by following patches.

Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: hash directory inodes for fsnotify</title>
<updated>2018-01-19T12:54:33Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-01-14T16:35:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=31747eda41ef3c30c09c5c096b380bf54013746a'/>
<id>urn:sha1:31747eda41ef3c30c09c5c096b380bf54013746a</id>
<content type='text'>
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-&gt;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: &lt;stable@vger.kernel.org&gt; #v4.13
Reported-by: Niklas Cassel &lt;niklas.cassel@axis.com&gt;
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Tested-by: Niklas Cassel &lt;niklas.cassel@axis.com&gt;
</content>
</entry>
</feed>
