<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/fscache, branch v3.11</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>FS-Cache: Don't use spin_is_locked() in assertions</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-05-24T11:45:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=dcfae32f892f03dee9896b19d1960c1ecd3f0583'/>
<id>dcfae32f892f03dee9896b19d1960c1ecd3f0583</id>
<content type='text'>
Under certain circumstances, spin_is_locked() is hardwired to 0 - even when the
code would normally be in a locked section where it should return 1.  This
means it cannot be used for an assertion that checks that a spinlock is locked.

Remove such usages from FS-Cache.

The following oops might otherwise be observed:

FS-Cache: Assertion failed
BUG: failure at fs/fscache/operation.c:270/fscache_start_operations()!
Kernel panic - not syncing: BUG!
CPU: 0 PID: 10 Comm: kworker/u2:1 Not tainted 3.10.0-rc1-00133-ge7ebb75 #2
Workqueue: fscache_operation fscache_op_work_func [fscache]
7f091c48 603c8947 7f090000 7f9b1361 7f25f080 00000001 7f26d440 7f091c90
60299eb8 7f091d90 602951c5 7f26d440 3000000008 7f091da0 7f091cc0 7f091cd0
00000007 00000007 00000006 7f091ae0 00000010 0000010e 7f9af330 7f091ae0
Call Trace:
7f091c88: [&lt;60299eb8&gt;] dump_stack+0x17/0x19
7f091c98: [&lt;602951c5&gt;] panic+0xf4/0x1e9
7f091d38: [&lt;6002b10e&gt;] set_signals+0x1e/0x40
7f091d58: [&lt;6005b89e&gt;] __wake_up+0x4e/0x70
7f091d98: [&lt;7f9aa003&gt;] fscache_start_operations+0x43/0x50 [fscache]
7f091da8: [&lt;7f9aa1e3&gt;] fscache_op_complete+0x1d3/0x220 [fscache]
7f091db8: [&lt;60082985&gt;] unlock_page+0x55/0x60
7f091de8: [&lt;7fb25bb0&gt;] cachefiles_read_copier+0x250/0x330 [cachefiles]
7f091e58: [&lt;7f9ab03c&gt;] fscache_op_work_func+0xac/0x120 [fscache]
7f091e88: [&lt;6004d5b0&gt;] process_one_work+0x250/0x3a0
7f091ef8: [&lt;6004edc7&gt;] worker_thread+0x177/0x2a0
7f091f38: [&lt;6004ec50&gt;] worker_thread+0x0/0x2a0
7f091f58: [&lt;60054418&gt;] kthread+0xd8/0xe0
7f091f68: [&lt;6005bb27&gt;] finish_task_switch.isra.64+0x37/0xa0
7f091fd8: [&lt;600185cf&gt;] new_thread_handler+0x8f/0xb0

Reported-by: Milosz Tanski &lt;milosz@adfin.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-and-tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Under certain circumstances, spin_is_locked() is hardwired to 0 - even when the
code would normally be in a locked section where it should return 1.  This
means it cannot be used for an assertion that checks that a spinlock is locked.

Remove such usages from FS-Cache.

The following oops might otherwise be observed:

FS-Cache: Assertion failed
BUG: failure at fs/fscache/operation.c:270/fscache_start_operations()!
Kernel panic - not syncing: BUG!
CPU: 0 PID: 10 Comm: kworker/u2:1 Not tainted 3.10.0-rc1-00133-ge7ebb75 #2
Workqueue: fscache_operation fscache_op_work_func [fscache]
7f091c48 603c8947 7f090000 7f9b1361 7f25f080 00000001 7f26d440 7f091c90
60299eb8 7f091d90 602951c5 7f26d440 3000000008 7f091da0 7f091cc0 7f091cd0
00000007 00000007 00000006 7f091ae0 00000010 0000010e 7f9af330 7f091ae0
Call Trace:
7f091c88: [&lt;60299eb8&gt;] dump_stack+0x17/0x19
7f091c98: [&lt;602951c5&gt;] panic+0xf4/0x1e9
7f091d38: [&lt;6002b10e&gt;] set_signals+0x1e/0x40
7f091d58: [&lt;6005b89e&gt;] __wake_up+0x4e/0x70
7f091d98: [&lt;7f9aa003&gt;] fscache_start_operations+0x43/0x50 [fscache]
7f091da8: [&lt;7f9aa1e3&gt;] fscache_op_complete+0x1d3/0x220 [fscache]
7f091db8: [&lt;60082985&gt;] unlock_page+0x55/0x60
7f091de8: [&lt;7fb25bb0&gt;] cachefiles_read_copier+0x250/0x330 [cachefiles]
7f091e58: [&lt;7f9ab03c&gt;] fscache_op_work_func+0xac/0x120 [fscache]
7f091e88: [&lt;6004d5b0&gt;] process_one_work+0x250/0x3a0
7f091ef8: [&lt;6004edc7&gt;] worker_thread+0x177/0x2a0
7f091f38: [&lt;6004ec50&gt;] worker_thread+0x0/0x2a0
7f091f58: [&lt;60054418&gt;] kthread+0xd8/0xe0
7f091f68: [&lt;6005bb27&gt;] finish_task_switch.isra.64+0x37/0xa0
7f091fd8: [&lt;600185cf&gt;] new_thread_handler+0x8f/0xb0

Reported-by: Milosz Tanski &lt;milosz@adfin.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-and-tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>FS-Cache: The retrieval remaining-pages counter needs to be atomic_t</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-05-21T12:44:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=1bb4b7f98f361132ea322834515334d95b93c184'/>
<id>1bb4b7f98f361132ea322834515334d95b93c184</id>
<content type='text'>
struct fscache_retrieval contains a count of the number of pages that still
need some processing (n_pages).  This is decremented as the pages are
processed.

However, this needs to be atomic as fscache_retrieval_complete() (I think) just
occasionally may be called from cachefiles_read_backing_file() and
cachefiles_read_copier() simultaneously.

This happens when an fscache_read_or_alloc_pages() request containing a lot of
pages (say a couple of hundred) is being processed.  The read on each backing
page is dispatched individually because we need to insert a monitor into the
waitqueue to catch when the read completes.  However, under low-memory
conditions, we might be forced to wait in the allocator - and this gives the
I/O on the backing page a chance to complete first.

When the I/O completes, fscache_enqueue_retrieval() chucks the retrieval onto
the workqueue without waiting for the operation to finish the initial I/O
dispatch (we want to release any pages we can as soon as we can), thus both can
end up running simultaneously and potentially attempting to partially complete
the retrieval simultaneously (ENOMEM may occur, backing pages may already be in
the page cache).

This was demonstrated by parallelling the non-atomic counter with an atomic
counter and printing both of them when the assertion fails.  At this point, the
atomic counter has reached zero, but the non-atomic counter has not.

To fix this, make the counter an atomic_t.

This results in the following bug appearing

	FS-Cache: Assertion failed
	3 == 5 is false
	------------[ cut here ]------------
	kernel BUG at fs/fscache/operation.c:421!

or

	FS-Cache: Assertion failed
	3 == 5 is false
	------------[ cut here ]------------
	kernel BUG at fs/fscache/operation.c:414!

With a backtrace like the following:

RIP: 0010:[&lt;ffffffffa0211b1d&gt;] fscache_put_operation+0x1ad/0x240 [fscache]
Call Trace:
 [&lt;ffffffffa0213185&gt;] fscache_retrieval_work+0x55/0x270 [fscache]
 [&lt;ffffffffa0213130&gt;] ? fscache_retrieval_work+0x0/0x270 [fscache]
 [&lt;ffffffff81090b10&gt;] worker_thread+0x170/0x2a0
 [&lt;ffffffff81096d10&gt;] ? autoremove_wake_function+0x0/0x40
 [&lt;ffffffff810909a0&gt;] ? worker_thread+0x0/0x2a0
 [&lt;ffffffff81096966&gt;] kthread+0x96/0xa0
 [&lt;ffffffff8100c0ca&gt;] child_rip+0xa/0x20
 [&lt;ffffffff810968d0&gt;] ? kthread+0x0/0xa0
 [&lt;ffffffff8100c0c0&gt;] ? child_rip+0x0/0x20

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-and-tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
struct fscache_retrieval contains a count of the number of pages that still
need some processing (n_pages).  This is decremented as the pages are
processed.

However, this needs to be atomic as fscache_retrieval_complete() (I think) just
occasionally may be called from cachefiles_read_backing_file() and
cachefiles_read_copier() simultaneously.

This happens when an fscache_read_or_alloc_pages() request containing a lot of
pages (say a couple of hundred) is being processed.  The read on each backing
page is dispatched individually because we need to insert a monitor into the
waitqueue to catch when the read completes.  However, under low-memory
conditions, we might be forced to wait in the allocator - and this gives the
I/O on the backing page a chance to complete first.

When the I/O completes, fscache_enqueue_retrieval() chucks the retrieval onto
the workqueue without waiting for the operation to finish the initial I/O
dispatch (we want to release any pages we can as soon as we can), thus both can
end up running simultaneously and potentially attempting to partially complete
the retrieval simultaneously (ENOMEM may occur, backing pages may already be in
the page cache).

This was demonstrated by parallelling the non-atomic counter with an atomic
counter and printing both of them when the assertion fails.  At this point, the
atomic counter has reached zero, but the non-atomic counter has not.

To fix this, make the counter an atomic_t.

This results in the following bug appearing

	FS-Cache: Assertion failed
	3 == 5 is false
	------------[ cut here ]------------
	kernel BUG at fs/fscache/operation.c:421!

or

	FS-Cache: Assertion failed
	3 == 5 is false
	------------[ cut here ]------------
	kernel BUG at fs/fscache/operation.c:414!

With a backtrace like the following:

RIP: 0010:[&lt;ffffffffa0211b1d&gt;] fscache_put_operation+0x1ad/0x240 [fscache]
Call Trace:
 [&lt;ffffffffa0213185&gt;] fscache_retrieval_work+0x55/0x270 [fscache]
 [&lt;ffffffffa0213130&gt;] ? fscache_retrieval_work+0x0/0x270 [fscache]
 [&lt;ffffffff81090b10&gt;] worker_thread+0x170/0x2a0
 [&lt;ffffffff81096d10&gt;] ? autoremove_wake_function+0x0/0x40
 [&lt;ffffffff810909a0&gt;] ? worker_thread+0x0/0x2a0
 [&lt;ffffffff81096966&gt;] kthread+0x96/0xa0
 [&lt;ffffffff8100c0ca&gt;] child_rip+0xa/0x20
 [&lt;ffffffff810968d0&gt;] ? kthread+0x0/0xa0
 [&lt;ffffffff8100c0c0&gt;] ? child_rip+0x0/0x20

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Reviewed-and-tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>FS-Cache: Simplify cookie retention for fscache_objects, fixing oops</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-05-10T18:50:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=1362729b169b7903c7e739dbe7904994b0d8c47f'/>
<id>1362729b169b7903c7e739dbe7904994b0d8c47f</id>
<content type='text'>
Simplify the way fscache cache objects retain their cookie.  The way I
implemented the cookie storage handling made synchronisation a pain (ie. the
object state machine can't rely on the cookie actually still being there).

Instead of the the object being detached from the cookie and the cookie being
freed in __fscache_relinquish_cookie(), we defer both operations:

 (*) The detachment of the object from the list in the cookie now takes place
     in fscache_drop_object() and is thus governed by the object state machine
     (fscache_detach_from_cookie() has been removed).

 (*) The release of the cookie is now in fscache_object_destroy() - which is
     called by the cache backend just before it frees the object.

This means that the fscache_cookie struct is now available to the cache all the
way through from -&gt;alloc_object() to -&gt;drop_object() and -&gt;put_object() -
meaning that it's no longer necessary to take object-&gt;lock to guarantee access.

However, __fscache_relinquish_cookie() doesn't wait for the object to go all
the way through to destruction before letting the netfs proceed.  That would
massively slow down the netfs.  Since __fscache_relinquish_cookie() leaves the
cookie around, in must therefore break all attachments to the netfs - which
includes -&gt;def, -&gt;netfs_data and any outstanding page read/writes.

To handle this, struct fscache_cookie now has an n_active counter:

 (1) This starts off initialised to 1.

 (2) Any time the cache needs to get at the netfs data, it calls
     fscache_use_cookie() to increment it - if it is not zero.  If it was zero,
     then access is not permitted.

 (3) When the cache has finished with the data, it calls fscache_unuse_cookie()
     to decrement it.  This does a wake-up on it if it reaches 0.

 (4) __fscache_relinquish_cookie() decrements n_active and then waits for it to
     reach 0.  The initialisation to 1 in step (1) ensures that we only get
     wake ups when we're trying to get rid of the cookie.

This leaves __fscache_relinquish_cookie() a lot simpler.


***
This fixes a problem in the current code whereby if fscache_invalidate() is
followed sufficiently quickly by fscache_relinquish_cookie() then it is
possible for __fscache_relinquish_cookie() to have detached the cookie from the
object and cleared the pointer before a thread is dispatched to process the
invalidation state in the object state machine.

Since the pending write clearance was deferred to the invalidation state to
make it asynchronous, we need to either wait in relinquishment for the stores
tree to be cleared in the invalidation state or we need to handle the clearance
in relinquishment.

Further, if the relinquishment code does clear the tree, then the invalidation
state need to make the clearance contingent on still having the cookie to hand
(since that's where the tree is rooted) and we have to prevent the cookie from
disappearing for the duration.

This can lead to an oops like the following:

BUG: unable to handle kernel NULL pointer dereference at 000000000000000c
...
RIP: 0010:[&lt;ffffffff8151023e&gt;] _spin_lock+0xe/0x30
...
CR2: 000000000000000c ...
...
Process kslowd002 (...)
....
Call Trace:
 [&lt;ffffffffa01c3278&gt;] fscache_invalidate_writes+0x38/0xd0 [fscache]
 [&lt;ffffffff810096f0&gt;] ? __switch_to+0xd0/0x320
 [&lt;ffffffff8105e759&gt;] ? find_busiest_queue+0x69/0x150
 [&lt;ffffffff8110ddd4&gt;] ? slow_work_enqueue+0x104/0x180
 [&lt;ffffffffa01c1303&gt;] fscache_object_slow_work_execute+0x5e3/0x9d0 [fscache]
 [&lt;ffffffff81096b67&gt;] ? bit_waitqueue+0x17/0xd0
 [&lt;ffffffff8110e233&gt;] slow_work_execute+0x233/0x310
 [&lt;ffffffff8110e515&gt;] slow_work_thread+0x205/0x360
 [&lt;ffffffff81096ca0&gt;] ? autoremove_wake_function+0x0/0x40
 [&lt;ffffffff8110e310&gt;] ? slow_work_thread+0x0/0x360
 [&lt;ffffffff81096936&gt;] kthread+0x96/0xa0
 [&lt;ffffffff8100c0ca&gt;] child_rip+0xa/0x20
 [&lt;ffffffff810968a0&gt;] ? kthread+0x0/0xa0
 [&lt;ffffffff8100c0c0&gt;] ? child_rip+0x0/0x20

The parameter to fscache_invalidate_writes() was object-&gt;cookie which is NULL.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Simplify the way fscache cache objects retain their cookie.  The way I
implemented the cookie storage handling made synchronisation a pain (ie. the
object state machine can't rely on the cookie actually still being there).

Instead of the the object being detached from the cookie and the cookie being
freed in __fscache_relinquish_cookie(), we defer both operations:

 (*) The detachment of the object from the list in the cookie now takes place
     in fscache_drop_object() and is thus governed by the object state machine
     (fscache_detach_from_cookie() has been removed).

 (*) The release of the cookie is now in fscache_object_destroy() - which is
     called by the cache backend just before it frees the object.

This means that the fscache_cookie struct is now available to the cache all the
way through from -&gt;alloc_object() to -&gt;drop_object() and -&gt;put_object() -
meaning that it's no longer necessary to take object-&gt;lock to guarantee access.

However, __fscache_relinquish_cookie() doesn't wait for the object to go all
the way through to destruction before letting the netfs proceed.  That would
massively slow down the netfs.  Since __fscache_relinquish_cookie() leaves the
cookie around, in must therefore break all attachments to the netfs - which
includes -&gt;def, -&gt;netfs_data and any outstanding page read/writes.

To handle this, struct fscache_cookie now has an n_active counter:

 (1) This starts off initialised to 1.

 (2) Any time the cache needs to get at the netfs data, it calls
     fscache_use_cookie() to increment it - if it is not zero.  If it was zero,
     then access is not permitted.

 (3) When the cache has finished with the data, it calls fscache_unuse_cookie()
     to decrement it.  This does a wake-up on it if it reaches 0.

 (4) __fscache_relinquish_cookie() decrements n_active and then waits for it to
     reach 0.  The initialisation to 1 in step (1) ensures that we only get
     wake ups when we're trying to get rid of the cookie.

This leaves __fscache_relinquish_cookie() a lot simpler.


***
This fixes a problem in the current code whereby if fscache_invalidate() is
followed sufficiently quickly by fscache_relinquish_cookie() then it is
possible for __fscache_relinquish_cookie() to have detached the cookie from the
object and cleared the pointer before a thread is dispatched to process the
invalidation state in the object state machine.

Since the pending write clearance was deferred to the invalidation state to
make it asynchronous, we need to either wait in relinquishment for the stores
tree to be cleared in the invalidation state or we need to handle the clearance
in relinquishment.

Further, if the relinquishment code does clear the tree, then the invalidation
state need to make the clearance contingent on still having the cookie to hand
(since that's where the tree is rooted) and we have to prevent the cookie from
disappearing for the duration.

This can lead to an oops like the following:

BUG: unable to handle kernel NULL pointer dereference at 000000000000000c
...
RIP: 0010:[&lt;ffffffff8151023e&gt;] _spin_lock+0xe/0x30
...
CR2: 000000000000000c ...
...
Process kslowd002 (...)
....
Call Trace:
 [&lt;ffffffffa01c3278&gt;] fscache_invalidate_writes+0x38/0xd0 [fscache]
 [&lt;ffffffff810096f0&gt;] ? __switch_to+0xd0/0x320
 [&lt;ffffffff8105e759&gt;] ? find_busiest_queue+0x69/0x150
 [&lt;ffffffff8110ddd4&gt;] ? slow_work_enqueue+0x104/0x180
 [&lt;ffffffffa01c1303&gt;] fscache_object_slow_work_execute+0x5e3/0x9d0 [fscache]
 [&lt;ffffffff81096b67&gt;] ? bit_waitqueue+0x17/0xd0
 [&lt;ffffffff8110e233&gt;] slow_work_execute+0x233/0x310
 [&lt;ffffffff8110e515&gt;] slow_work_thread+0x205/0x360
 [&lt;ffffffff81096ca0&gt;] ? autoremove_wake_function+0x0/0x40
 [&lt;ffffffff8110e310&gt;] ? slow_work_thread+0x0/0x360
 [&lt;ffffffff81096936&gt;] kthread+0x96/0xa0
 [&lt;ffffffff8100c0ca&gt;] child_rip+0xa/0x20
 [&lt;ffffffff810968a0&gt;] ? kthread+0x0/0xa0
 [&lt;ffffffff8100c0c0&gt;] ? child_rip+0x0/0x20

The parameter to fscache_invalidate_writes() was object-&gt;cookie which is NULL.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>FS-Cache: Fix object state machine to have separate work and wait states</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-05-10T18:50:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=caaef6900befb45689b1d1831ce3c7e7fb5b504f'/>
<id>caaef6900befb45689b1d1831ce3c7e7fb5b504f</id>
<content type='text'>
Fix object state machine to have separate work and wait states as that makes
it easier to envision.

There are now three kinds of state:

 (1) Work state.  This is an execution state.  No event processing is performed
     by a work state.  The function attached to a work state returns a pointer
     indicating the next state to which the OSM should transition.  Returning
     NO_TRANSIT repeats the current state, but goes back to the scheduler
     first.

 (2) Wait state.  This is an event processing state.  No execution is
     performed by a wait state.  Wait states are just tables of "if event X
     occurs, clear it and transition to state Y".  The dispatcher returns to
     the scheduler if none of the events in which the wait state has an
     interest are currently pending.

 (3) Out-of-band state.  This is a special work state.  Transitions to normal
     states can be overridden when an unexpected event occurs (eg. I/O error).
     Instead the dispatcher disables and clears the OOB event and transits to
     the specified work state.  This then acts as an ordinary work state,
     though object-&gt;state points to the overridden destination.  Returning
     NO_TRANSIT resumes the overridden transition.

In addition, the states have names in their definitions, so there's no need for
tables of state names.  Further, the EV_REQUEUE event is no longer necessary as
that is automatic for work states.

Since the states are now separate structs rather than values in an enum, it's
not possible to use comparisons other than (non-)equality between them, so use
some object-&gt;flags to indicate what phase an object is in.

The EV_RELEASE, EV_RETIRE and EV_WITHDRAW events have been squished into one
(EV_KILL).  An object flag now carries the information about retirement.

Similarly, the RELEASING, RECYCLING and WITHDRAWING states have been merged
into an KILL_OBJECT state and additional states have been added for handling
waiting dependent objects (JUMPSTART_DEPS and KILL_DEPENDENTS).

A state has also been added for synchronising with parent object initialisation
(WAIT_FOR_PARENT) and another for initiating look up (PARENT_READY).

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix object state machine to have separate work and wait states as that makes
it easier to envision.

There are now three kinds of state:

 (1) Work state.  This is an execution state.  No event processing is performed
     by a work state.  The function attached to a work state returns a pointer
     indicating the next state to which the OSM should transition.  Returning
     NO_TRANSIT repeats the current state, but goes back to the scheduler
     first.

 (2) Wait state.  This is an event processing state.  No execution is
     performed by a wait state.  Wait states are just tables of "if event X
     occurs, clear it and transition to state Y".  The dispatcher returns to
     the scheduler if none of the events in which the wait state has an
     interest are currently pending.

 (3) Out-of-band state.  This is a special work state.  Transitions to normal
     states can be overridden when an unexpected event occurs (eg. I/O error).
     Instead the dispatcher disables and clears the OOB event and transits to
     the specified work state.  This then acts as an ordinary work state,
     though object-&gt;state points to the overridden destination.  Returning
     NO_TRANSIT resumes the overridden transition.

In addition, the states have names in their definitions, so there's no need for
tables of state names.  Further, the EV_REQUEUE event is no longer necessary as
that is automatic for work states.

Since the states are now separate structs rather than values in an enum, it's
not possible to use comparisons other than (non-)equality between them, so use
some object-&gt;flags to indicate what phase an object is in.

The EV_RELEASE, EV_RETIRE and EV_WITHDRAW events have been squished into one
(EV_KILL).  An object flag now carries the information about retirement.

Similarly, the RELEASING, RECYCLING and WITHDRAWING states have been merged
into an KILL_OBJECT state and additional states have been added for handling
waiting dependent objects (JUMPSTART_DEPS and KILL_DEPENDENTS).

A state has also been added for synchronising with parent object initialisation
(WAIT_FOR_PARENT) and another for initiating look up (PARENT_READY).

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>FS-Cache: Wrap checks on object state</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-05-10T18:50:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=493f7bc11457bc1f6fbf25a4b2bdf215ebaf050f'/>
<id>493f7bc11457bc1f6fbf25a4b2bdf215ebaf050f</id>
<content type='text'>
Wrap checks on object state (mostly outside of fs/fscache/object.c) with
inline functions so that the mechanism can be replaced.

Some of the state checks within object.c are left as-is as they will be
replaced.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Wrap checks on object state (mostly outside of fs/fscache/object.c) with
inline functions so that the mechanism can be replaced.

Some of the state checks within object.c are left as-is as they will be
replaced.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>FS-Cache: Uninline fscache_object_init()</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-05-10T18:50:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=610be24ee434aa89197f06f30fef02be83c006a5'/>
<id>610be24ee434aa89197f06f30fef02be83c006a5</id>
<content type='text'>
Uninline fscache_object_init() so as not to expose some of the FS-Cache
internals to the cache backend.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Uninline fscache_object_init() so as not to expose some of the FS-Cache
internals to the cache backend.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>FS-Cache: Don't sleep in page release if __GFP_FS is not set</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2013-05-10T18:50:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=0c59a95d90081e5d840649d4f872027123e3420c'/>
<id>0c59a95d90081e5d840649d4f872027123e3420c</id>
<content type='text'>
Don't sleep in __fscache_maybe_release_page() if __GFP_FS is not set.  This
goes some way towards mitigating fscache deadlocking against ext4 by way of
the allocator, eg:

INFO: task flush-8:0:24427 blocked for more than 120 seconds.
"echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
flush-8:0       D ffff88003e2b9fd8     0 24427      2 0x00000000
 ffff88003e2b9138 0000000000000046 ffff880012e3a040 ffff88003e2b9fd8
 0000000000011c80 ffff88003e2b9fd8 ffffffff81a10400 ffff880012e3a040
 0000000000000002 ffff880012e3a040 ffff88003e2b9098 ffffffff8106dcf5
Call Trace:
 [&lt;ffffffff8106dcf5&gt;] ? __lock_is_held+0x31/0x53
 [&lt;ffffffff81219b61&gt;] ? radix_tree_lookup_element+0xf4/0x12a
 [&lt;ffffffff81454bed&gt;] schedule+0x60/0x62
 [&lt;ffffffffa01d349c&gt;] __fscache_wait_on_page_write+0x8b/0xa5 [fscache]
 [&lt;ffffffff810498a8&gt;] ? __init_waitqueue_head+0x4d/0x4d
 [&lt;ffffffffa01d393a&gt;] __fscache_maybe_release_page+0x30c/0x324 [fscache]
 [&lt;ffffffffa01d369a&gt;] ? __fscache_maybe_release_page+0x6c/0x324 [fscache]
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffffa01fd7b2&gt;] nfs_fscache_release_page+0x68/0x94 [nfs]
 [&lt;ffffffffa01ef73e&gt;] nfs_release_page+0x7e/0x86 [nfs]
 [&lt;ffffffff810aa553&gt;] try_to_release_page+0x32/0x3b
 [&lt;ffffffff810b6c70&gt;] shrink_page_list+0x535/0x71a
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffff810b7352&gt;] shrink_inactive_list+0x20a/0x2dd
 [&lt;ffffffff81071a13&gt;] ? mark_held_locks+0xbe/0xea
 [&lt;ffffffff810b7a65&gt;] shrink_lruvec+0x34c/0x3eb
 [&lt;ffffffff810b7bd3&gt;] do_try_to_free_pages+0xcf/0x355
 [&lt;ffffffff810b7fc8&gt;] try_to_free_pages+0x9a/0xa1
 [&lt;ffffffff810b08d2&gt;] __alloc_pages_nodemask+0x494/0x6f7
 [&lt;ffffffff810d9a07&gt;] kmem_getpages+0x58/0x155
 [&lt;ffffffff810dc002&gt;] fallback_alloc+0x120/0x1f3
 [&lt;ffffffff8106db23&gt;] ? trace_hardirqs_off+0xd/0xf
 [&lt;ffffffff810dbed3&gt;] ____cache_alloc_node+0x177/0x186
 [&lt;ffffffff81162a6c&gt;] ? ext4_init_io_end+0x1c/0x37
 [&lt;ffffffff810dc403&gt;] kmem_cache_alloc+0xf1/0x176
 [&lt;ffffffff810b17ac&gt;] ? test_set_page_writeback+0x101/0x113
 [&lt;ffffffff81162a6c&gt;] ext4_init_io_end+0x1c/0x37
 [&lt;ffffffff81162ce4&gt;] ext4_bio_write_page+0x20f/0x3af
 [&lt;ffffffff8115cc02&gt;] mpage_da_submit_io+0x26e/0x2f6
 [&lt;ffffffff811088e5&gt;] ? __find_get_block_slow+0x38/0x133
 [&lt;ffffffff81161348&gt;] mpage_da_map_and_submit+0x3a7/0x3bd
 [&lt;ffffffff81161a60&gt;] ext4_da_writepages+0x30d/0x426
 [&lt;ffffffff810b3359&gt;] do_writepages+0x1c/0x2a
 [&lt;ffffffff81102f4d&gt;] __writeback_single_inode+0x3e/0xe5
 [&lt;ffffffff81103995&gt;] writeback_sb_inodes+0x1bd/0x2f4
 [&lt;ffffffff81103b3b&gt;] __writeback_inodes_wb+0x6f/0xb4
 [&lt;ffffffff81103c81&gt;] wb_writeback+0x101/0x195
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffff811043aa&gt;] ? wb_do_writeback+0xaa/0x173
 [&lt;ffffffff8110434a&gt;] wb_do_writeback+0x4a/0x173
 [&lt;ffffffff81071bbc&gt;] ? trace_hardirqs_on+0xd/0xf
 [&lt;ffffffff81038554&gt;] ? del_timer+0x4b/0x5b
 [&lt;ffffffff811044e0&gt;] bdi_writeback_thread+0x6d/0x147
 [&lt;ffffffff81104473&gt;] ? wb_do_writeback+0x173/0x173
 [&lt;ffffffff81048fbc&gt;] kthread+0xd0/0xd8
 [&lt;ffffffff81455eb2&gt;] ? _raw_spin_unlock_irq+0x29/0x3e
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
 [&lt;ffffffff81456aac&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
2 locks held by flush-8:0/24427:
 #0:  (&amp;type-&gt;s_umount_key#41){.+.+..}, at: [&lt;ffffffff810e3b73&gt;] grab_super_passive+0x4c/0x76
 #1:  (jbd2_handle){+.+...}, at: [&lt;ffffffff81190d81&gt;] start_this_handle+0x475/0x4ea


The problem here is that another thread, which is attempting to write the
to-be-stored NFS page to the on-ext4 cache file is waiting for the journal
lock, eg:

INFO: task kworker/u:2:24437 blocked for more than 120 seconds.
"echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kworker/u:2     D ffff880039589768     0 24437      2 0x00000000
 ffff8800395896d8 0000000000000046 ffff8800283bf040 ffff880039589fd8
 0000000000011c80 ffff880039589fd8 ffff880039f0b040 ffff8800283bf040
 0000000000000006 ffff8800283bf6b8 ffff880039589658 ffffffff81071a13
Call Trace:
 [&lt;ffffffff81071a13&gt;] ? mark_held_locks+0xbe/0xea
 [&lt;ffffffff81455e73&gt;] ? _raw_spin_unlock_irqrestore+0x3a/0x50
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffff81071bbc&gt;] ? trace_hardirqs_on+0xd/0xf
 [&lt;ffffffff81454bed&gt;] schedule+0x60/0x62
 [&lt;ffffffff81190c23&gt;] start_this_handle+0x317/0x4ea
 [&lt;ffffffff810498a8&gt;] ? __init_waitqueue_head+0x4d/0x4d
 [&lt;ffffffff81190fcc&gt;] jbd2__journal_start+0xb3/0x12e
 [&lt;ffffffff81176606&gt;] __ext4_journal_start_sb+0xb2/0xc6
 [&lt;ffffffff8115f137&gt;] ext4_da_write_begin+0x109/0x233
 [&lt;ffffffff810a964d&gt;] generic_file_buffered_write+0x11a/0x264
 [&lt;ffffffff811032cf&gt;] ? __mark_inode_dirty+0x2d/0x1ee
 [&lt;ffffffff810ab1ab&gt;] __generic_file_aio_write+0x2a5/0x2d5
 [&lt;ffffffff810ab24a&gt;] generic_file_aio_write+0x6f/0xd0
 [&lt;ffffffff81159a2c&gt;] ext4_file_write+0x38c/0x3c4
 [&lt;ffffffff810e0915&gt;] do_sync_write+0x91/0xd1
 [&lt;ffffffffa00a17f0&gt;] cachefiles_write_page+0x26f/0x310 [cachefiles]
 [&lt;ffffffffa01d470b&gt;] fscache_write_op+0x21e/0x37a [fscache]
 [&lt;ffffffff81455eb2&gt;] ? _raw_spin_unlock_irq+0x29/0x3e
 [&lt;ffffffffa01d2479&gt;] fscache_op_work_func+0x78/0xd7 [fscache]
 [&lt;ffffffff8104455a&gt;] process_one_work+0x232/0x3a8
 [&lt;ffffffff810444ff&gt;] ? process_one_work+0x1d7/0x3a8
 [&lt;ffffffff81044ee0&gt;] worker_thread+0x214/0x303
 [&lt;ffffffff81044ccc&gt;] ? manage_workers+0x245/0x245
 [&lt;ffffffff81048fbc&gt;] kthread+0xd0/0xd8
 [&lt;ffffffff81455eb2&gt;] ? _raw_spin_unlock_irq+0x29/0x3e
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
 [&lt;ffffffff81456aac&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
4 locks held by kworker/u:2/24437:
 #0:  (fscache_operation){.+.+.+}, at: [&lt;ffffffff810444ff&gt;] process_one_work+0x1d7/0x3a8
 #1:  ((&amp;op-&gt;work)){+.+.+.}, at: [&lt;ffffffff810444ff&gt;] process_one_work+0x1d7/0x3a8
 #2:  (sb_writers#14){.+.+.+}, at: [&lt;ffffffff810ab22c&gt;] generic_file_aio_write+0x51/0xd0
 #3:  (&amp;sb-&gt;s_type-&gt;i_mutex_key#19){+.+.+.}, at: [&lt;ffffffff810ab236&gt;] generic_file_aio_write+0x5b/0x

fscache already tries to cancel pending stores, but it can't cancel a write
for which I/O is already in progress.

An alternative would be to accept writing garbage to the cache under extreme
circumstances and to kill the afflicted cache object if we have to do this.
However, we really need to know how strapped the allocator is before deciding
to do that.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Don't sleep in __fscache_maybe_release_page() if __GFP_FS is not set.  This
goes some way towards mitigating fscache deadlocking against ext4 by way of
the allocator, eg:

INFO: task flush-8:0:24427 blocked for more than 120 seconds.
"echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
flush-8:0       D ffff88003e2b9fd8     0 24427      2 0x00000000
 ffff88003e2b9138 0000000000000046 ffff880012e3a040 ffff88003e2b9fd8
 0000000000011c80 ffff88003e2b9fd8 ffffffff81a10400 ffff880012e3a040
 0000000000000002 ffff880012e3a040 ffff88003e2b9098 ffffffff8106dcf5
Call Trace:
 [&lt;ffffffff8106dcf5&gt;] ? __lock_is_held+0x31/0x53
 [&lt;ffffffff81219b61&gt;] ? radix_tree_lookup_element+0xf4/0x12a
 [&lt;ffffffff81454bed&gt;] schedule+0x60/0x62
 [&lt;ffffffffa01d349c&gt;] __fscache_wait_on_page_write+0x8b/0xa5 [fscache]
 [&lt;ffffffff810498a8&gt;] ? __init_waitqueue_head+0x4d/0x4d
 [&lt;ffffffffa01d393a&gt;] __fscache_maybe_release_page+0x30c/0x324 [fscache]
 [&lt;ffffffffa01d369a&gt;] ? __fscache_maybe_release_page+0x6c/0x324 [fscache]
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffffa01fd7b2&gt;] nfs_fscache_release_page+0x68/0x94 [nfs]
 [&lt;ffffffffa01ef73e&gt;] nfs_release_page+0x7e/0x86 [nfs]
 [&lt;ffffffff810aa553&gt;] try_to_release_page+0x32/0x3b
 [&lt;ffffffff810b6c70&gt;] shrink_page_list+0x535/0x71a
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffff810b7352&gt;] shrink_inactive_list+0x20a/0x2dd
 [&lt;ffffffff81071a13&gt;] ? mark_held_locks+0xbe/0xea
 [&lt;ffffffff810b7a65&gt;] shrink_lruvec+0x34c/0x3eb
 [&lt;ffffffff810b7bd3&gt;] do_try_to_free_pages+0xcf/0x355
 [&lt;ffffffff810b7fc8&gt;] try_to_free_pages+0x9a/0xa1
 [&lt;ffffffff810b08d2&gt;] __alloc_pages_nodemask+0x494/0x6f7
 [&lt;ffffffff810d9a07&gt;] kmem_getpages+0x58/0x155
 [&lt;ffffffff810dc002&gt;] fallback_alloc+0x120/0x1f3
 [&lt;ffffffff8106db23&gt;] ? trace_hardirqs_off+0xd/0xf
 [&lt;ffffffff810dbed3&gt;] ____cache_alloc_node+0x177/0x186
 [&lt;ffffffff81162a6c&gt;] ? ext4_init_io_end+0x1c/0x37
 [&lt;ffffffff810dc403&gt;] kmem_cache_alloc+0xf1/0x176
 [&lt;ffffffff810b17ac&gt;] ? test_set_page_writeback+0x101/0x113
 [&lt;ffffffff81162a6c&gt;] ext4_init_io_end+0x1c/0x37
 [&lt;ffffffff81162ce4&gt;] ext4_bio_write_page+0x20f/0x3af
 [&lt;ffffffff8115cc02&gt;] mpage_da_submit_io+0x26e/0x2f6
 [&lt;ffffffff811088e5&gt;] ? __find_get_block_slow+0x38/0x133
 [&lt;ffffffff81161348&gt;] mpage_da_map_and_submit+0x3a7/0x3bd
 [&lt;ffffffff81161a60&gt;] ext4_da_writepages+0x30d/0x426
 [&lt;ffffffff810b3359&gt;] do_writepages+0x1c/0x2a
 [&lt;ffffffff81102f4d&gt;] __writeback_single_inode+0x3e/0xe5
 [&lt;ffffffff81103995&gt;] writeback_sb_inodes+0x1bd/0x2f4
 [&lt;ffffffff81103b3b&gt;] __writeback_inodes_wb+0x6f/0xb4
 [&lt;ffffffff81103c81&gt;] wb_writeback+0x101/0x195
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffff811043aa&gt;] ? wb_do_writeback+0xaa/0x173
 [&lt;ffffffff8110434a&gt;] wb_do_writeback+0x4a/0x173
 [&lt;ffffffff81071bbc&gt;] ? trace_hardirqs_on+0xd/0xf
 [&lt;ffffffff81038554&gt;] ? del_timer+0x4b/0x5b
 [&lt;ffffffff811044e0&gt;] bdi_writeback_thread+0x6d/0x147
 [&lt;ffffffff81104473&gt;] ? wb_do_writeback+0x173/0x173
 [&lt;ffffffff81048fbc&gt;] kthread+0xd0/0xd8
 [&lt;ffffffff81455eb2&gt;] ? _raw_spin_unlock_irq+0x29/0x3e
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
 [&lt;ffffffff81456aac&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
2 locks held by flush-8:0/24427:
 #0:  (&amp;type-&gt;s_umount_key#41){.+.+..}, at: [&lt;ffffffff810e3b73&gt;] grab_super_passive+0x4c/0x76
 #1:  (jbd2_handle){+.+...}, at: [&lt;ffffffff81190d81&gt;] start_this_handle+0x475/0x4ea


The problem here is that another thread, which is attempting to write the
to-be-stored NFS page to the on-ext4 cache file is waiting for the journal
lock, eg:

INFO: task kworker/u:2:24437 blocked for more than 120 seconds.
"echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
kworker/u:2     D ffff880039589768     0 24437      2 0x00000000
 ffff8800395896d8 0000000000000046 ffff8800283bf040 ffff880039589fd8
 0000000000011c80 ffff880039589fd8 ffff880039f0b040 ffff8800283bf040
 0000000000000006 ffff8800283bf6b8 ffff880039589658 ffffffff81071a13
Call Trace:
 [&lt;ffffffff81071a13&gt;] ? mark_held_locks+0xbe/0xea
 [&lt;ffffffff81455e73&gt;] ? _raw_spin_unlock_irqrestore+0x3a/0x50
 [&lt;ffffffff81071b53&gt;] ? trace_hardirqs_on_caller+0x114/0x170
 [&lt;ffffffff81071bbc&gt;] ? trace_hardirqs_on+0xd/0xf
 [&lt;ffffffff81454bed&gt;] schedule+0x60/0x62
 [&lt;ffffffff81190c23&gt;] start_this_handle+0x317/0x4ea
 [&lt;ffffffff810498a8&gt;] ? __init_waitqueue_head+0x4d/0x4d
 [&lt;ffffffff81190fcc&gt;] jbd2__journal_start+0xb3/0x12e
 [&lt;ffffffff81176606&gt;] __ext4_journal_start_sb+0xb2/0xc6
 [&lt;ffffffff8115f137&gt;] ext4_da_write_begin+0x109/0x233
 [&lt;ffffffff810a964d&gt;] generic_file_buffered_write+0x11a/0x264
 [&lt;ffffffff811032cf&gt;] ? __mark_inode_dirty+0x2d/0x1ee
 [&lt;ffffffff810ab1ab&gt;] __generic_file_aio_write+0x2a5/0x2d5
 [&lt;ffffffff810ab24a&gt;] generic_file_aio_write+0x6f/0xd0
 [&lt;ffffffff81159a2c&gt;] ext4_file_write+0x38c/0x3c4
 [&lt;ffffffff810e0915&gt;] do_sync_write+0x91/0xd1
 [&lt;ffffffffa00a17f0&gt;] cachefiles_write_page+0x26f/0x310 [cachefiles]
 [&lt;ffffffffa01d470b&gt;] fscache_write_op+0x21e/0x37a [fscache]
 [&lt;ffffffff81455eb2&gt;] ? _raw_spin_unlock_irq+0x29/0x3e
 [&lt;ffffffffa01d2479&gt;] fscache_op_work_func+0x78/0xd7 [fscache]
 [&lt;ffffffff8104455a&gt;] process_one_work+0x232/0x3a8
 [&lt;ffffffff810444ff&gt;] ? process_one_work+0x1d7/0x3a8
 [&lt;ffffffff81044ee0&gt;] worker_thread+0x214/0x303
 [&lt;ffffffff81044ccc&gt;] ? manage_workers+0x245/0x245
 [&lt;ffffffff81048fbc&gt;] kthread+0xd0/0xd8
 [&lt;ffffffff81455eb2&gt;] ? _raw_spin_unlock_irq+0x29/0x3e
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
 [&lt;ffffffff81456aac&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff81048eec&gt;] ? __init_kthread_worker+0x55/0x55
4 locks held by kworker/u:2/24437:
 #0:  (fscache_operation){.+.+.+}, at: [&lt;ffffffff810444ff&gt;] process_one_work+0x1d7/0x3a8
 #1:  ((&amp;op-&gt;work)){+.+.+.}, at: [&lt;ffffffff810444ff&gt;] process_one_work+0x1d7/0x3a8
 #2:  (sb_writers#14){.+.+.+}, at: [&lt;ffffffff810ab22c&gt;] generic_file_aio_write+0x51/0xd0
 #3:  (&amp;sb-&gt;s_type-&gt;i_mutex_key#19){+.+.+.}, at: [&lt;ffffffff810ab236&gt;] generic_file_aio_write+0x5b/0x

fscache already tries to cancel pending stores, but it can't cancel a write
for which I/O is already in progress.

An alternative would be to accept writing garbage to the cache under extreme
circumstances and to kill the afflicted cache object if we have to do this.
However, we really need to know how strapped the allocator is before deciding
to do that.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fscache: remove spin_lock() from the condition in while()</title>
<updated>2013-06-19T13:16:47+00:00</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>bigeasy@linutronix.de</email>
</author>
<published>2013-05-10T18:50:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=ee8be57bc331f00d520c4c8a78ffa9590ed41c2c'/>
<id>ee8be57bc331f00d520c4c8a78ffa9590ed41c2c</id>
<content type='text'>
The spinlock() within the condition in while() will cause a compile error
if it is not a function. This is not a problem on mainline but it does not
look pretty and there is no reason to do it that way.
That patch writes it a little differently and avoids the double condition.

Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The spinlock() within the condition in while() will cause a compile error
if it is not a function. This is not a problem on mainline but it does not
look pretty and there is no reason to do it that way.
That patch writes it a little differently and avoids the double condition.

Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Tested-By: Milosz Tanski &lt;milosz@adfin.com&gt;
Acked-by: Jeff Layton &lt;jlayton@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fscache/stats.c: fix memory leak</title>
<updated>2013-04-29T22:54:27+00:00</updated>
<author>
<name>Anurup m</name>
<email>anurup.m@huawei.com</email>
</author>
<published>2013-04-29T22:05:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=ec686c9239b4d472052a271c505d04dae84214cc'/>
<id>ec686c9239b4d472052a271c505d04dae84214cc</id>
<content type='text'>
There is a kernel memory leak observed when the proc file
/proc/fs/fscache/stats is read.

The reason is that in fscache_stats_open, single_open is called and the
respective release function is not called during release.  Hence fix
with correct release function - single_release().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=57101

Signed-off-by: Anurup m &lt;anurup.m@huawei.com&gt;
Cc: shyju pv &lt;shyju.pv@huawei.com&gt;
Cc: Sanil kumar &lt;sanil.kumar@huawei.com&gt;
Cc: Nataraj m &lt;nataraj.m@huawei.com&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There is a kernel memory leak observed when the proc file
/proc/fs/fscache/stats is read.

The reason is that in fscache_stats_open, single_open is called and the
respective release function is not called during release.  Hence fix
with correct release function - single_release().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=57101

Signed-off-by: Anurup m &lt;anurup.m@huawei.com&gt;
Cc: shyju pv &lt;shyju.pv@huawei.com&gt;
Cc: Sanil kumar &lt;sanil.kumar@huawei.com&gt;
Cc: Nataraj m &lt;nataraj.m@huawei.com&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hlist: drop the node parameter from iterators</title>
<updated>2013-02-28T03:10:24+00:00</updated>
<author>
<name>Sasha Levin</name>
<email>sasha.levin@oracle.com</email>
</author>
<published>2013-02-28T01:06:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=b67bfe0d42cac56c512dd5da4b1b347a23f4b70a'/>
<id>b67bfe0d42cac56c512dd5da4b1b347a23f4b70a</id>
<content type='text'>
I'm not sure why, but the hlist for each entry iterators were conceived

        list_for_each_entry(pos, head, member)

The hlist ones were greedy and wanted an extra parameter:

        hlist_for_each_entry(tpos, pos, head, member)

Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.

Besides the semantic patch, there was some manual work required:

 - Fix up the actual hlist iterators in linux/list.h
 - Fix up the declaration of other iterators based on the hlist ones.
 - A very small amount of places were using the 'node' parameter, this
 was modified to use 'obj-&gt;member' instead.
 - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
 properly, so those had to be fixed up manually.

The semantic patch which is mostly the work of Peter Senna Tschudin is here:

@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

type T;
expression a,c,d,e;
identifier b;
statement S;
@@

-T b;
    &lt;+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
    ...+&gt;

[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin &lt;peter.senna@gmail.com&gt;
Acked-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Cc: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Cc: Marcelo Tosatti &lt;mtosatti@redhat.com&gt;
Cc: Gleb Natapov &lt;gleb@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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I'm not sure why, but the hlist for each entry iterators were conceived

        list_for_each_entry(pos, head, member)

The hlist ones were greedy and wanted an extra parameter:

        hlist_for_each_entry(tpos, pos, head, member)

Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.

Besides the semantic patch, there was some manual work required:

 - Fix up the actual hlist iterators in linux/list.h
 - Fix up the declaration of other iterators based on the hlist ones.
 - A very small amount of places were using the 'node' parameter, this
 was modified to use 'obj-&gt;member' instead.
 - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
 properly, so those had to be fixed up manually.

The semantic patch which is mostly the work of Peter Senna Tschudin is here:

@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

type T;
expression a,c,d,e;
identifier b;
statement S;
@@

-T b;
    &lt;+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
    ...+&gt;

[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin &lt;peter.senna@gmail.com&gt;
Acked-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Cc: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Cc: Marcelo Tosatti &lt;mtosatti@redhat.com&gt;
Cc: Gleb Natapov &lt;gleb@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;
</pre>
</div>
</content>
</entry>
</feed>
