<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/fs/cachefiles/interface.c, branch v4.9.162</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.162</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.162'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2016-09-27T22:31:29Z</updated>
<entry>
<title>cachefiles: Fix attempt to read i_blocks after deleting file [ver #2]</title>
<updated>2016-09-27T22:31:29Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2016-08-09T16:41:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a818101d7b92e76db2f9a597e4830734767473b9'/>
<id>urn:sha1:a818101d7b92e76db2f9a597e4830734767473b9</id>
<content type='text'>
An NULL-pointer dereference happens in cachefiles_mark_object_inactive()
when it tries to read i_blocks so that it can tell the cachefilesd daemon
how much space it's making available.

The problem is that cachefiles_drop_object() calls
cachefiles_mark_object_inactive() after calling cachefiles_delete_object()
because the object being marked active staves off attempts to (re-)use the
file at that filename until after it has been deleted.  This means that
d_inode is NULL by the time we come to try to access it.

To fix the problem, have the caller of cachefiles_mark_object_inactive()
supply the number of blocks freed up.

Without this, the following oops may occur:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
IP: [&lt;ffffffffa06c5cc1&gt;] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
...
CPU: 11 PID: 527 Comm: kworker/u64:4 Tainted: G          I    ------------   3.10.0-470.el7.x86_64 #1
Hardware name: Hewlett-Packard HP Z600 Workstation/0B54h, BIOS 786G4 v03.19 03/11/2011
Workqueue: fscache_object fscache_object_work_func [fscache]
task: ffff880035edaf10 ti: ffff8800b77c0000 task.ti: ffff8800b77c0000
RIP: 0010:[&lt;ffffffffa06c5cc1&gt;] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
RSP: 0018:ffff8800b77c3d70  EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff8800bf6cc400 RCX: 0000000000000034
RDX: 0000000000000000 RSI: ffff880090ffc710 RDI: ffff8800bf761ef8
RBP: ffff8800b77c3d88 R08: 2000000000000000 R09: 0090ffc710000000
R10: ff51005d2ff1c400 R11: 0000000000000000 R12: ffff880090ffc600
R13: ffff8800bf6cc520 R14: ffff8800bf6cc400 R15: ffff8800bf6cc498
FS:  0000000000000000(0000) GS:ffff8800bb8c0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000098 CR3: 00000000019ba000 CR4: 00000000000007e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
 ffff880090ffc600 ffff8800bf6cc400 ffff8800867df140 ffff8800b77c3db0
 ffffffffa06c48cb ffff880090ffc600 ffff880090ffc180 ffff880090ffc658
 ffff8800b77c3df0 ffffffffa085d846 ffff8800a96b8150 ffff880090ffc600
Call Trace:
 [&lt;ffffffffa06c48cb&gt;] cachefiles_drop_object+0x6b/0xf0 [cachefiles]
 [&lt;ffffffffa085d846&gt;] fscache_drop_object+0xd6/0x1e0 [fscache]
 [&lt;ffffffffa085d615&gt;] fscache_object_work_func+0xa5/0x200 [fscache]
 [&lt;ffffffff810a605b&gt;] process_one_work+0x17b/0x470
 [&lt;ffffffff810a6e96&gt;] worker_thread+0x126/0x410
 [&lt;ffffffff810a6d70&gt;] ? rescuer_thread+0x460/0x460
 [&lt;ffffffff810ae64f&gt;] kthread+0xcf/0xe0
 [&lt;ffffffff810ae580&gt;] ? kthread_create_on_node+0x140/0x140
 [&lt;ffffffff81695418&gt;] ret_from_fork+0x58/0x90
 [&lt;ffffffff810ae580&gt;] ? kthread_create_on_node+0x140/0x140

The oopsing code shows:

	callq  0xffffffff810af6a0 &lt;wake_up_bit&gt;
	mov    0xf8(%r12),%rax
	mov    0x30(%rax),%rax
	mov    0x98(%rax),%rax   &lt;---- oops here
	lock add %rax,0x130(%rbx)

where this is:

	d_backing_inode(object-&gt;dentry)-&gt;i_blocks

Fixes: a5b3a80b899bda0f456f1246c4c5a1191ea01519 (CacheFiles: Provide read-and-reset release counters for cachefilesd)
Reported-by: Jianhong Yin &lt;jiyin@redhat.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-by: Jeff Layton &lt;jlayton@redhat.com&gt;
Reviewed-by: Steve Dickson &lt;steved@redhat.com&gt;
cc: stable@vger.kernel.org
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>FS-Cache: make check_consistency callback return int</title>
<updated>2016-06-01T08:29:39Z</updated>
<author>
<name>Yan, Zheng</name>
<email>zyan@redhat.com</email>
</author>
<published>2016-05-20T10:32:31Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=480ce08a70e4179f34808a3bdbfe6627f624cf54'/>
<id>urn:sha1:480ce08a70e4179f34808a3bdbfe6627f624cf54</id>
<content type='text'>
__fscache_check_consistency() calls check_consistency() callback
and return the callback's return value. But the return type of
check_consistency() is bool. So __fscache_check_consistency()
return 1 if the cache is inconsistent. This is inconsistent with
the document.

Signed-off-by: Yan, Zheng &lt;zyan@redhat.com&gt;
Acked-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
<entry>
<title>CacheFiles: Provide read-and-reset release counters for cachefilesd</title>
<updated>2016-02-01T17:30:10Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2016-02-01T16:43:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a5b3a80b899bda0f456f1246c4c5a1191ea01519'/>
<id>urn:sha1:a5b3a80b899bda0f456f1246c4c5a1191ea01519</id>
<content type='text'>
Provide read-and-reset objects- and blocks-released counters for cachefilesd
to use to work out whether there's anything new that can be culled.

One of the problems cachefilesd has is that if all the objects in the cache
are pinned by inodes lying dormant in the kernel inode cache, there isn't
anything for it to cull.  In such a case, it just spins around walking the
filesystem tree and scanning for something to cull.  This eats up a lot of
CPU time.

By telling cachefilesd if there have been any releases, the daemon can
sleep until there is the possibility of something to do.

cachefilesd finds this information by the following means:

 (1) When the control fd is read, the kernel presents a list of values of
     interest.  "freleased=N" and "breleased=N" are added to this list to
     indicate the number of files released and number of blocks released
     since the last read call.  At this point the counters are reset.

 (2) POLLIN is signalled if the number of files released becomes greater
     than 0.

Note that by 'released' it just means that the kernel has released its
interest in those files for the moment, not necessarily that the files
should be deleted from the cache.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-by: Steve Dickson &lt;steved@redhat.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>wrappers for -&gt;i_mutex access</title>
<updated>2016-01-22T23:04:28Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2016-01-22T20:40:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5955102c9984fa081b2d570cfac75c97eecf8f3b'/>
<id>urn:sha1:5955102c9984fa081b2d570cfac75c97eecf8f3b</id>
<content type='text'>
parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
inode_foo(inode) being mutex_foo(&amp;inode-&gt;i_mutex).

Please, use those for access to -&gt;i_mutex; over the coming cycle
-&gt;i_mutex will become rwsem, with -&gt;lookup() done with it held
only shared.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>VFS: fs/cachefiles: d_backing_inode() annotations</title>
<updated>2015-04-15T19:06:59Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2015-03-17T22:26:21Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=466b77bc954c23c5741ea7dd02f20212a72acdb2'/>
<id>urn:sha1:466b77bc954c23c5741ea7dd02f20212a72acdb2</id>
<content type='text'>
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>VFS: Cachefiles should perform fs modifications on the top layer only</title>
<updated>2015-04-15T19:06:54Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2015-03-06T14:08:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5153bc817cdbed826a18938393cc1f81ebbbd898'/>
<id>urn:sha1:5153bc817cdbed826a18938393cc1f81ebbbd898</id>
<content type='text'>
Cachefiles should perform fs modifications (eg. vfs_unlink()) on the top layer
only and should not attempt to alter the lower layer.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions</title>
<updated>2015-02-22T16:38:41Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2015-01-29T12:02:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ce40fa78ef8f0e813392903c96de65b947298d16'/>
<id>urn:sha1:ce40fa78ef8f0e813392903c96de65b947298d16</id>
<content type='text'>
Fix up the following scripted S_ISDIR/S_ISREG/S_ISLNK conversions (or lack
thereof) in cachefiles:

 (1) Cachefiles mostly wants to use d_can_lookup() rather than d_is_dir() as
     it doesn't want to deal with automounts in its cache.

 (2) Coccinelle didn't find S_IS* expressions in ASSERT() statements in
     cachefiles.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>CacheFiles: Handle object being killed before being set up</title>
<updated>2014-09-30T13:50:28Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2014-09-30T13:50:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a3b7c00484e1177e7eb9b047c46cac571b82442f'/>
<id>urn:sha1:a3b7c00484e1177e7eb9b047c46cac571b82442f</id>
<content type='text'>
If a cache object gets killed whilst in the process of being set up - for
instance if the netfs relinquishes the cookie that the object is associated
with - then the object's state machine will transit to the DROP_OBJECT state
without necessarily going through the LOOKUP_OBJECT or CREATE_OBJECT states.

This is a problem for CacheFiles because cachefiles_drop_object() assumes that
object-&gt;dentry will be set upon reaching the DROP_OBJECT state and has an
ASSERT() to that effect (see the oops below) - but object-&gt;dentry doesn't get
set until the LOOKUP_OBJECT or CREATE_OBJECT states (and not always then if
they fail).

To fix this, just make the dentry cleanup in cachefiles_drop_object()
conditional on the dentry actually being set and remove the assertion.

	CacheFiles: Assertion failed
	------------[ cut here ]------------
	kernel BUG at .../fs/cachefiles/namei.c:425!
	...
	Workqueue: fscache_object fscache_object_work_func [fscache]
	...
	RIP: ... cachefiles_delete_object+0xcd/0x110 [cachefiles]
	...
	Call Trace:
	 [&lt;ffffffffa043280f&gt;] ? cachefiles_drop_object+0xff/0x130 [cachefiles]
	 [&lt;ffffffffa02ac511&gt;] ? fscache_drop_object+0xd1/0x1d0 [fscache]
	 [&lt;ffffffffa02ac697&gt;] ? fscache_object_work_func+0x87/0x210 [fscache]
	 [&lt;ffffffff81080635&gt;] ? process_one_work+0x155/0x450
	 [&lt;ffffffff81081c44&gt;] ? worker_thread+0x114/0x370
	 [&lt;ffffffff81081b30&gt;] ? manage_workers.isra.21+0x2c0/0x2c0
	 [&lt;ffffffff81087fcc&gt;] ? kthread+0xbc/0xe0
	 [&lt;ffffffff81087f10&gt;] ? flush_kthread_worker+0xa0/0xa0
	 [&lt;ffffffff8150638c&gt;] ? ret_from_fork+0x7c/0xb0
	 [&lt;ffffffff81087f10&gt;] ? flush_kthread_worker+0xa0/0xa0

Reported-by: Manuel Schölling &lt;manuel.schoelling@gmx.de&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Acked-by: Steve Dickson &lt;steved@redhat.com&gt;
</content>
</entry>
<entry>
<title>fs/cachefiles: replace kerror by pr_err</title>
<updated>2014-06-06T23:08:14Z</updated>
<author>
<name>Fabian Frederick</name>
<email>fabf@skynet.be</email>
</author>
<published>2014-06-06T21:37:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0227d6abb378454e10d385da6a0f8b79a5b02c27'/>
<id>urn:sha1:0227d6abb378454e10d385da6a0f8b79a5b02c27</id>
<content type='text'>
Also add pr_fmt in internal.h

Signed-off-by: Fabian Frederick &lt;fabf@skynet.be&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
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>FS/CACHEFILES: convert printk to pr_foo()</title>
<updated>2014-06-06T23:08:14Z</updated>
<author>
<name>Fabian Frederick</name>
<email>fabf@skynet.be</email>
</author>
<published>2014-06-06T21:37:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4e1eb88305135248ad0e927449e457df95d8d9b3'/>
<id>urn:sha1:4e1eb88305135248ad0e927449e457df95d8d9b3</id>
<content type='text'>
Signed-off-by: Fabian Frederick &lt;fabf@skynet.be&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
