<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/nfs/dir.c, branch linux-3.14.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2016-07-27T16:55:49Z</updated>
<entry>
<title>make nfs_atomic_open() call d_drop() on all -&gt;open_context() errors.</title>
<updated>2016-07-27T16:55:49Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2016-06-20T17:14:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b149020bae2c1b0e3644df1d7f6e5d72cffcf9c2'/>
<id>urn:sha1:b149020bae2c1b0e3644df1d7f6e5d72cffcf9c2</id>
<content type='text'>
commit d20cb71dbf3487f24549ede1a8e2d67579b4632e upstream.

In "NFSv4: Move dentry instantiation into the NFSv4-specific atomic open code"
unconditional d_drop() after the -&gt;open_context() had been removed.  It had
been correct for success cases (there -&gt;open_context() itself had been doing
dcache manipulations), but not for error ones.  Only one of those (ENOENT)
got a compensatory d_drop() added in that commit, but in fact it should've
been done for all errors.  As it is, the case of O_CREAT non-exclusive open
on a hashed negative dentry racing with e.g. symlink creation from another
client ended up with -&gt;open_context() getting an error and proceeding to
call nfs_lookup().  On a hashed dentry, which would've instantly triggered
BUG_ON() in d_materialise_unique() (or, these days, its equivalent in
d_splice_alias()).

Tested-by: Oleg Drokin &lt;green@linuxhacker.ru&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm: fix page leak at nfs_symlink()</title>
<updated>2014-02-11T00:01:42Z</updated>
<author>
<name>Rafael Aquini</name>
</author>
<published>2014-02-10T22:25:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a0b54adda3fe4b4cc6d28f2a9217cd35d1aa888c'/>
<id>urn:sha1:a0b54adda3fe4b4cc6d28f2a9217cd35d1aa888c</id>
<content type='text'>
Changes in commit a0b8cab3b9b2 ("mm: remove lru parameter from
__pagevec_lru_add and remove parts of pagevec API") have introduced a
call to add_to_page_cache_lru() which causes a leak in nfs_symlink() as
now the page gets an extra refcount that is not dropped.

Jan Stancek observed and reported the leak effect while running test8
from Connectathon Testsuite.  After several iterations over the test
case, which creates several symlinks on a NFS mountpoint, the test
system was quickly getting into an out-of-memory scenario.

This patch fixes the page leak by dropping that extra refcount
add_to_page_cache_lru() is grabbing.

Signed-off-by: Jan Stancek &lt;jstancek@redhat.com&gt;
Signed-off-by: Rafael Aquini &lt;aquini@redhat.com&gt;
Acked-by: Mel Gorman &lt;mgorman@suse.de&gt;
Acked-by: Rik van Riel &lt;riel@redhat.com&gt;
Cc: Jeff Layton &lt;jlayton@redhat.com&gt;
Cc: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;	[3.11.x+]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>nfs: add memory barriers around NFS_INO_INVALID_DATA and NFS_INO_INVALIDATING</title>
<updated>2014-01-28T19:48:18Z</updated>
<author>
<name>Jeff Layton</name>
</author>
<published>2014-01-28T18:47:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4db72b40fdbc706f8957e9773ae73b1574b8c694'/>
<id>urn:sha1:4db72b40fdbc706f8957e9773ae73b1574b8c694</id>
<content type='text'>
If the setting of NFS_INO_INVALIDATING gets reordered to before the
clearing of NFS_INO_INVALID_DATA, then another task may hit a race
window where both appear to be clear, even though the inode's pages are
still in need of invalidation. Fix this by adding the appropriate memory
barriers.

Signed-off-by: Jeff Layton &lt;jlayton@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
</content>
</entry>
<entry>
<title>NFS: fix the handling of NFS_INO_INVALID_DATA flag in nfs_revalidate_mapping</title>
<updated>2014-01-27T20:35:56Z</updated>
<author>
<name>Jeff Layton</name>
</author>
<published>2014-01-27T18:46:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d529ef83c355f97027ff85298a9709fe06216a66'/>
<id>urn:sha1:d529ef83c355f97027ff85298a9709fe06216a66</id>
<content type='text'>
There is a possible race in how the nfs_invalidate_mapping function is
handled.  Currently, we go and invalidate the pages in the file and then
clear NFS_INO_INVALID_DATA.

The problem is that it's possible for a stale page to creep into the
mapping after the page was invalidated (i.e., via readahead). If another
writer comes along and sets the flag after that happens but before
invalidate_inode_pages2 returns then we could clear the flag
without the cache having been properly invalidated.

So, we must clear the flag first and then invalidate the pages. Doing
this however, opens another race:

It's possible to have two concurrent read() calls that end up in
nfs_revalidate_mapping at the same time. The first one clears the
NFS_INO_INVALID_DATA flag and then goes to call nfs_invalidate_mapping.

Just before calling that though, the other task races in, checks the
flag and finds it cleared. At that point, it trusts that the mapping is
good and gets the lock on the page, allowing the read() to be satisfied
from the cache even though the data is no longer valid.

These effects are easily manifested by running diotest3 from the LTP
test suite on NFS. That program does a series of DIO writes and buffered
reads. The operations are serialized and page-aligned but the existing
code fails the test since it occasionally allows a read to come out of
the cache incorrectly. While mixing direct and buffered I/O isn't
recommended, I believe it's possible to hit this in other ways that just
use buffered I/O, though that situation is much harder to reproduce.

The problem is that the checking/clearing of that flag and the
invalidation of the mapping really need to be atomic. Fix this by
serializing concurrent invalidations with a bitlock.

At the same time, we also need to allow other places that check
NFS_INO_INVALID_DATA to check whether we might be in the middle of
invalidating the file, so fix up a couple of places that do that
to look for the new NFS_INO_INVALIDATING flag.

Doing this requires us to be careful not to set the bitlock
unnecessarily, so this code only does that if it believes it will
be doing an invalidation.

Signed-off-by: Jeff Layton &lt;jlayton@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
</content>
</entry>
<entry>
<title>NFS: dprintk() should not print negative fileids and inode numbers</title>
<updated>2014-01-05T20:51:23Z</updated>
<author>
<name>Niels de Vos</name>
</author>
<published>2013-12-17T17:20:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1e8968c5b0582392d5f132422f581e3ebc24e627'/>
<id>urn:sha1:1e8968c5b0582392d5f132422f581e3ebc24e627</id>
<content type='text'>
A fileid in NFS is a uint64. There are some occurrences where dprintk()
outputs a signed fileid. This leads to confusion and more difficult to
read debugging (negative fileids matching positive inode numbers).

Signed-off-by: Niels de Vos &lt;ndevos@redhat.com&gt;
CC: Santosh Pradhan &lt;spradhan@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs</title>
<updated>2013-11-13T06:34:18Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2013-11-13T06:34:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9bc9ccd7db1c9f043f75380b5a5b94912046a60e'/>
<id>urn:sha1:9bc9ccd7db1c9f043f75380b5a5b94912046a60e</id>
<content type='text'>
Pull vfs updates from Al Viro:
 "All kinds of stuff this time around; some more notable parts:

   - RCU'd vfsmounts handling
   - new primitives for coredump handling
   - files_lock is gone
   - Bruce's delegations handling series
   - exportfs fixes

  plus misc stuff all over the place"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (101 commits)
  ecryptfs: -&gt;f_op is never NULL
  locks: break delegations on any attribute modification
  locks: break delegations on link
  locks: break delegations on rename
  locks: helper functions for delegation breaking
  locks: break delegations on unlink
  namei: minor vfs_unlink cleanup
  locks: implement delegations
  locks: introduce new FL_DELEG lock flag
  vfs: take i_mutex on renamed file
  vfs: rename I_MUTEX_QUOTA now that it's not used for quotas
  vfs: don't use PARENT/CHILD lock classes for non-directories
  vfs: pull ext4's double-i_mutex-locking into common code
  exportfs: fix quadratic behavior in filehandle lookup
  exportfs: better variable name
  exportfs: move most of reconnect_path to helper function
  exportfs: eliminate unused "noprogress" counter
  exportfs: stop retrying once we race with rename/remove
  exportfs: clear DISCONNECTED on all parents sooner
  exportfs: more detailed comment for path_reconnect
  ...
</content>
</entry>
<entry>
<title>Merge branch 'fscache' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs into linux-next</title>
<updated>2013-10-28T23:36:46Z</updated>
<author>
<name>Trond Myklebust</name>
</author>
<published>2013-10-28T23:33:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c698dbf9fecae54e5dc159cee76939228c533a25'/>
<id>urn:sha1:c698dbf9fecae54e5dc159cee76939228c533a25</id>
<content type='text'>
Pull fs-cache fixes from David Howells:

Can you pull these commits to fix an issue with NFS whereby caching can be
enabled on a file that is open for writing by subsequently opening it for
reading.  This can be made to crash by opening it for writing again if you're
quick enough.

The gist of the patchset is that the cookie should be acquired at inode
creation only and subsequently enabled and disabled as appropriate (which
dispenses with the backing objects when they're not needed).

The extra synchronisation that NFS does can then be dispensed with as it is
thenceforth managed by FS-Cache.

Could you send these on to Linus?

This likely will need fixing also in CIFS and 9P also once the FS-Cache
changes are upstream.  AFS and Ceph are probably safe.

* 'fscache' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
  NFS: Use i_writecount to control whether to get an fscache cookie in nfs_open()
  FS-Cache: Provide the ability to enable/disable cookies
  FS-Cache: Add use/unuse/wake cookie wrappers
</content>
</entry>
<entry>
<title>nfs: use IS_ROOT not DCACHE_DISCONNECTED</title>
<updated>2013-10-28T23:19:19Z</updated>
<author>
<name>J. Bruce Fields</name>
</author>
<published>2013-10-15T21:03:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a3f432bfd06a4ec3b812e32d3266e0d1ad75d008'/>
<id>urn:sha1:a3f432bfd06a4ec3b812e32d3266e0d1ad75d008</id>
<content type='text'>
This check was added by Al Viro with
d9e80b7de91db05c1c4d2e5ebbfd70b3b3ba0e0f "nfs d_revalidate() is too
trigger-happy with d_drop()", with the explanation that we don't want to
remove the root of a disconnected tree, which will still be included on
the s_anon list.

But DCACHE_DISCONNECTED does *not* actually identify dentries that are
disconnected from the dentry tree or hashed on s_anon.  IS_ROOT() is the
way to do that.

Also add a comment from Al's commit to remind us why this check is
there.

Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Trond Myklebust &lt;Trond.Myklebust@netapp.com&gt;
</content>
</entry>
<entry>
<title>nfs: use %p[dD] instead of open-coded (and often racy) equivalents</title>
<updated>2013-10-25T03:34:50Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2013-09-16T14:53:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6de1472f1a4a3bd912f515f29d3cf52a65a4c718'/>
<id>urn:sha1:6de1472f1a4a3bd912f515f29d3cf52a65a4c718</id>
<content type='text'>
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>NFS: Use i_writecount to control whether to get an fscache cookie in nfs_open()</title>
<updated>2013-09-27T17:40:25Z</updated>
<author>
<name>David Howells</name>
</author>
<published>2013-09-27T10:20:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f1fe29b4a02d0805aa7d0ff6b73410a9f9316d69'/>
<id>urn:sha1:f1fe29b4a02d0805aa7d0ff6b73410a9f9316d69</id>
<content type='text'>
Use i_writecount to control whether to get an fscache cookie in nfs_open() as
NFS does not do write caching yet.  I *think* this is the cause of a problem
encountered by Mark Moseley whereby __fscache_uncache_page() gets a NULL
pointer dereference because cookie-&gt;def is NULL:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
IP: [&lt;ffffffff812a1903&gt;] __fscache_uncache_page+0x23/0x160
PGD 0
Thread overran stack, or stack corrupted
Oops: 0000 [#1] SMP
Modules linked in: ...
CPU: 7 PID: 18993 Comm: php Not tainted 3.11.1 #1
Hardware name: Dell Inc. PowerEdge R420/072XWF, BIOS 1.3.5 08/21/2012
task: ffff8804203460c0 ti: ffff880420346640
RIP: 0010:[&lt;ffffffff812a1903&gt;] __fscache_uncache_page+0x23/0x160
RSP: 0018:ffff8801053af878 EFLAGS: 00210286
RAX: 0000000000000000 RBX: ffff8800be2f8780 RCX: ffff88022ffae5e8
RDX: 0000000000004c66 RSI: ffffea00055ff440 RDI: ffff8800be2f8780
RBP: ffff8801053af898 R08: 0000000000000001 R09: 0000000000000003
R10: 0000000000000000 R11: 0000000000000000 R12: ffffea00055ff440
R13: 0000000000001000 R14: ffff8800c50be538 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff88042fc60000(0063) knlGS:00000000e439c700
CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
CR2: 0000000000000010 CR3: 0000000001d8f000 CR4: 00000000000607f0
Stack:
...
Call Trace:
[&lt;ffffffff81365a72&gt;] __nfs_fscache_invalidate_page+0x42/0x70
[&lt;ffffffff813553d5&gt;] nfs_invalidate_page+0x75/0x90
[&lt;ffffffff811b8f5e&gt;] truncate_inode_page+0x8e/0x90
[&lt;ffffffff811b90ad&gt;] truncate_inode_pages_range.part.12+0x14d/0x620
[&lt;ffffffff81d6387d&gt;] ? __mutex_lock_slowpath+0x1fd/0x2e0
[&lt;ffffffff811b95d3&gt;] truncate_inode_pages_range+0x53/0x70
[&lt;ffffffff811b969d&gt;] truncate_inode_pages+0x2d/0x40
[&lt;ffffffff811b96ff&gt;] truncate_pagecache+0x4f/0x70
[&lt;ffffffff81356840&gt;] nfs_setattr_update_inode+0xa0/0x120
[&lt;ffffffff81368de4&gt;] nfs3_proc_setattr+0xc4/0xe0
[&lt;ffffffff81357f78&gt;] nfs_setattr+0xc8/0x150
[&lt;ffffffff8122d95b&gt;] notify_change+0x1cb/0x390
[&lt;ffffffff8120a55b&gt;] do_truncate+0x7b/0xc0
[&lt;ffffffff8121f96c&gt;] do_last+0xa4c/0xfd0
[&lt;ffffffff8121ffbc&gt;] path_openat+0xcc/0x670
[&lt;ffffffff81220a0e&gt;] do_filp_open+0x4e/0xb0
[&lt;ffffffff8120ba1f&gt;] do_sys_open+0x13f/0x2b0
[&lt;ffffffff8126aaf6&gt;] compat_SyS_open+0x36/0x50
[&lt;ffffffff81d7204c&gt;] sysenter_dispatch+0x7/0x24

The code at the instruction pointer was disassembled:

&gt; (gdb) disas __fscache_uncache_page
&gt; Dump of assembler code for function __fscache_uncache_page:
&gt; ...
&gt; 0xffffffff812a18ff &lt;+31&gt;: mov 0x48(%rbx),%rax
&gt; 0xffffffff812a1903 &lt;+35&gt;: cmpb $0x0,0x10(%rax)
&gt; 0xffffffff812a1907 &lt;+39&gt;: je 0xffffffff812a19cd &lt;__fscache_uncache_page+237&gt;

These instructions make up:

	ASSERTCMP(cookie-&gt;def-&gt;type, !=, FSCACHE_COOKIE_TYPE_INDEX);

That cmpb is the faulting instruction (%rax is 0).  So cookie-&gt;def is NULL -
which presumably means that the cookie has already been at least partway
through __fscache_relinquish_cookie().

What I think may be happening is something like a three-way race on the same
file:

	PROCESS 1	PROCESS 2	PROCESS 3
	===============	===============	===============
	open(O_TRUNC|O_WRONLY)
			open(O_RDONLY)
					open(O_WRONLY)
	--&gt;nfs_open()
	--&gt;nfs_fscache_set_inode_cookie()
	nfs_fscache_inode_lock()
	nfs_fscache_disable_inode_cookie()
	__fscache_relinquish_cookie()
	nfs_inode-&gt;fscache = NULL
	&lt;--nfs_fscache_set_inode_cookie()

			--&gt;nfs_open()
			--&gt;nfs_fscache_set_inode_cookie()
			nfs_fscache_inode_lock()
			nfs_fscache_enable_inode_cookie()
			__fscache_acquire_cookie()
			nfs_inode-&gt;fscache = cookie
			&lt;--nfs_fscache_set_inode_cookie()
	&lt;--nfs_open()
	--&gt;nfs_setattr()
	...
	...
	--&gt;nfs_invalidate_page()
	--&gt;__nfs_fscache_invalidate_page()
	cookie = nfsi-&gt;fscache
					--&gt;nfs_open()
					--&gt;nfs_fscache_set_inode_cookie()
					nfs_fscache_inode_lock()
					nfs_fscache_disable_inode_cookie()
					--&gt;__fscache_relinquish_cookie()
	--&gt;__fscache_uncache_page(cookie)
	&lt;crash&gt;
					&lt;--__fscache_relinquish_cookie()
					nfs_inode-&gt;fscache = NULL
					&lt;--nfs_fscache_set_inode_cookie()

What is needed is something to prevent process #2 from reacquiring the cookie
- and I think checking i_writecount should do the trick.

It's also possible to have a two-way race on this if the file is opened
O_TRUNC|O_RDONLY instead.

Reported-by: Mark Moseley &lt;moseleymark@gmail.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
</feed>
