<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/overlayfs/inode.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 lower layer st_dev only if setting lower st_ino</title>
<updated>2018-04-19T06:54:09Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-04-11T17:09:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f2924419f27812d2cd2e2c0d6a8bf96feaac13e7'/>
<id>urn:sha1:f2924419f27812d2cd2e2c0d6a8bf96feaac13e7</id>
<content type='text'>
commit 9f99e50d460ac7fd5f6c9b97aad0088c28c8656d upstream.

For broken hardlinks, we do not return lower st_ino, so we should
also not return lower pseudo st_dev.

Fixes: a0c5ad307ac0 ("ovl: relax same fs constraint for constant st_ino")
Cc: &lt;stable@vger.kernel.org&gt; #v4.15
Signed-off-by: Amir Goldstein &lt;amir73il@gmail.com&gt;
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: 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: hash non-dir by lower inode for fsnotify</title>
<updated>2018-02-16T14:53:20Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-02-04T13:35:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=764baba80168ad3adafb521d2ab483ccbc49e344'/>
<id>urn:sha1:764baba80168ad3adafb521d2ab483ccbc49e344</id>
<content type='text'>
Commit 31747eda41ef ("ovl: hash directory inodes for fsnotify")
fixed an issue of inotify watch on directory that stops getting
events after dropping dentry caches.

A similar issue exists for non-dir non-upper files, for example:

$ mkdir -p lower upper work merged
$ touch lower/foo
$ mount -t overlay -o
lowerdir=lower,workdir=work,upperdir=upper none merged
$ inotifywait merged/foo &amp;
$ echo 2 &gt; /proc/sys/vm/drop_caches
$ cat merged/foo

inotifywait doesn't get the OPEN event, because ovl_lookup() called
from 'cat' allocates a new overlay inode and does not reuse the
watched inode.

Fix this by hashing non-dir overlay inodes by lower real inode in
the following cases that were not hashed before this change:
 - A non-upper overlay mount
 - A lower non-hardlink when index=off

A helper ovl_hash_bylower() was added to put all the logic and
documentation about which real inode an overlay inode is hashed by
into one place.

The 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
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: lookup connected ancestor of dir in inode cache</title>
<updated>2018-01-24T10:26:05Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2018-01-18T14:39:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b91c30a5a19332e8dd10b601d05b72caf657730'/>
<id>urn:sha1:4b91c30a5a19332e8dd10b601d05b72caf657730</id>
<content type='text'>
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: Amir Goldstein &lt;amir73il@gmail.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
</content>
</entry>
<entry>
<title>ovl: hash non-indexed dir by upper inode for NFS export</title>
<updated>2018-01-24T10:26:04Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-07-10T12:55:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7a9dadef9684aaf738e7ce7e2a9284cc5e165ebc'/>
<id>urn:sha1:7a9dadef9684aaf738e7ce7e2a9284cc5e165ebc</id>
<content type='text'>
Non-indexed upper dirs are encoded as upper file handles. When NFS export
is enabled, hash non-indexed directory inodes by upper inode, so we can
find them in inode cache using the decoded upper inode.

When NFS export is disabled, directories are not indexed on copy up, so
hash non-indexed directory inodes by origin inode, the same hash key
that is used before copy up.

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: decode lower file handles of unlinked but open files</title>
<updated>2018-01-24T10:26:03Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-12-24T16:28:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9436a1a339fae84698aaa0b66d7a822018388348'/>
<id>urn:sha1:9436a1a339fae84698aaa0b66d7a822018388348</id>
<content type='text'>
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: 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: do not pass overlay dentry to ovl_get_inode()</title>
<updated>2018-01-24T10:25:57Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-12-12T21:43:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0aceb53e73befee4441c9e68d23cb4f682382171'/>
<id>urn:sha1:0aceb53e73befee4441c9e68d23cb4f682382171</id>
<content type='text'>
This is needed for using ovl_get_inode() for decoding file handles
for NFS export.

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: unbless lower st_ino of unverified origin</title>
<updated>2018-01-24T10:25:52Z</updated>
<author>
<name>Amir Goldstein</name>
</author>
<published>2017-11-21T11:55:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=86eaa13046d5e814484c89f635a95b0342b765ad'/>
<id>urn:sha1:86eaa13046d5e814484c89f635a95b0342b765ad</id>
<content type='text'>
On a malformed overlay, several redirected dirs can point to the same
dir on a lower layer. This presents a similar challenge as broken
hardlinks, because different objects in the overlay can return the same
st_ino/st_dev pair from stat(2).

For broken hardlinks, we do not provide constant st_ino on copy up to
avoid this inconsistency. When NFS export feature is enabled, apply
the same logic to files and directories with unverified lower origin.

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>
