<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/fs, branch v3.15.4</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>reiserfs: call truncate_setsize under tailpack mutex</title>
<updated>2014-07-07T01:59:12+00:00</updated>
<author>
<name>Jeff Mahoney</name>
<email>jeffm@suse.com</email>
</author>
<published>2014-05-21T17:28:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=3d8e24ef90f331379ab066b7f9d0889be5e3e8d1'/>
<id>3d8e24ef90f331379ab066b7f9d0889be5e3e8d1</id>
<content type='text'>
commit 22e7478ddbcb670e33fab72d0bbe7c394c3a2c84 upstream.

Prior to commit 0e4f6a791b1e (Fix reiserfs_file_release()), reiserfs
truncates serialized on i_mutex. They mostly still do, with the exception
of reiserfs_file_release. That blocks out other writers via the tailpack
mutex and the inode openers counter adjusted in reiserfs_file_open.

However, NFS will call reiserfs_setattr without having called -&gt;open, so
we end up with a race when nfs is calling -&gt;setattr while another
process is releasing the file. Ultimately, it triggers the
BUG_ON(inode-&gt;i_size != new_file_size) check in maybe_indirect_to_direct.

The solution is to pull the lock into reiserfs_setattr to encompass the
truncate_setsize call as well.

Signed-off-by: Jeff Mahoney &lt;jeffm@suse.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 22e7478ddbcb670e33fab72d0bbe7c394c3a2c84 upstream.

Prior to commit 0e4f6a791b1e (Fix reiserfs_file_release()), reiserfs
truncates serialized on i_mutex. They mostly still do, with the exception
of reiserfs_file_release. That blocks out other writers via the tailpack
mutex and the inode openers counter adjusted in reiserfs_file_open.

However, NFS will call reiserfs_setattr without having called -&gt;open, so
we end up with a race when nfs is calling -&gt;setattr while another
process is releasing the file. Ultimately, it triggers the
BUG_ON(inode-&gt;i_size != new_file_size) check in maybe_indirect_to_direct.

The solution is to pull the lock into reiserfs_setattr to encompass the
truncate_setsize call as well.

Signed-off-by: Jeff Mahoney &lt;jeffm@suse.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>xfs: xfs_readsb needs to check for magic numbers</title>
<updated>2014-07-07T01:59:11+00:00</updated>
<author>
<name>Dave Chinner</name>
<email>dchinner@redhat.com</email>
</author>
<published>2014-06-06T06:00:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=008643fecc2f65accbaccc2f1b97cc56cb5bd42a'/>
<id>008643fecc2f65accbaccc2f1b97cc56cb5bd42a</id>
<content type='text'>
commit 556b8883cfac3d3203557e161ea8005f8b5479b2 upstream.

Commit daba542 ("xfs: skip verification on initial "guess"
superblock read") dropped the use of a verifier for the initial
superblock read so we can probe the sector size of the filesystem
stored in the superblock. It, however, now fails to validate that
what was read initially is actually an XFS superblock and hence will
fail the sector size check and return ENOSYS.

This causes probe-based mounts to fail because it expects XFS to
return EINVAL when it doesn't recognise the superblock format.

Reported-by: Plamen Petrov &lt;plamen.sisi@gmail.com&gt;
Tested-by: Plamen Petrov &lt;plamen.sisi@gmail.com&gt;
Signed-off-by: Dave Chinner &lt;dchinner@redhat.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Dave Chinner &lt;david@fromorbit.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 556b8883cfac3d3203557e161ea8005f8b5479b2 upstream.

Commit daba542 ("xfs: skip verification on initial "guess"
superblock read") dropped the use of a verifier for the initial
superblock read so we can probe the sector size of the filesystem
stored in the superblock. It, however, now fails to validate that
what was read initially is actually an XFS superblock and hence will
fail the sector size check and return ENOSYS.

This causes probe-based mounts to fail because it expects XFS to
return EINVAL when it doesn't recognise the superblock format.

Reported-by: Plamen Petrov &lt;plamen.sisi@gmail.com&gt;
Tested-by: Plamen Petrov &lt;plamen.sisi@gmail.com&gt;
Signed-off-by: Dave Chinner &lt;dchinner@redhat.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Dave Chinner &lt;david@fromorbit.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>nfs: Fix cache_validity check in nfs_write_pageuptodate()</title>
<updated>2014-07-07T01:59:11+00:00</updated>
<author>
<name>Scott Mayhew</name>
<email>smayhew@redhat.com</email>
</author>
<published>2014-06-20T12:44:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=716f02ac00a77c14cdf18de2e75e49e68e46e1e8'/>
<id>716f02ac00a77c14cdf18de2e75e49e68e46e1e8</id>
<content type='text'>
commit 18dd78c427513fb0f89365138be66e6ee8700d1b upstream.

NFS_INO_INVALID_DATA cannot be ignored, even if we have a delegation.

We're still having some problems with data corruption when multiple
clients are appending to a file and those clients are being granted
write delegations on open.

To reproduce:

Client A:
vi /mnt/`hostname -s`
while :; do echo "XXXXXXXXXXXXXXX" &gt;&gt;/mnt/file; sleep $(( $RANDOM % 5 )); done

Client B:
vi /mnt/`hostname -s`
while :; do echo "YYYYYYYYYYYYYYY" &gt;&gt;/mnt/file; sleep $(( $RANDOM % 5 )); done

What's happening is that in nfs_update_inode() we're recognizing that
the file size has changed and we're setting NFS_INO_INVALID_DATA
accordingly, but then we ignore the cache_validity flags in
nfs_write_pageuptodate() because we have a delegation.  As a result,
in nfs_updatepage() we're extending the write to cover the full page
even though we've not read in the data to begin with.

Signed-off-by: Scott Mayhew &lt;smayhew@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 18dd78c427513fb0f89365138be66e6ee8700d1b upstream.

NFS_INO_INVALID_DATA cannot be ignored, even if we have a delegation.

We're still having some problems with data corruption when multiple
clients are appending to a file and those clients are being granted
write delegations on open.

To reproduce:

Client A:
vi /mnt/`hostname -s`
while :; do echo "XXXXXXXXXXXXXXX" &gt;&gt;/mnt/file; sleep $(( $RANDOM % 5 )); done

Client B:
vi /mnt/`hostname -s`
while :; do echo "YYYYYYYYYYYYYYY" &gt;&gt;/mnt/file; sleep $(( $RANDOM % 5 )); done

What's happening is that in nfs_update_inode() we're recognizing that
the file size has changed and we're setting NFS_INO_INVALID_DATA
accordingly, but then we ignore the cache_validity flags in
nfs_write_pageuptodate() because we have a delegation.  As a result,
in nfs_updatepage() we're extending the write to cover the full page
even though we've not read in the data to begin with.

Signed-off-by: Scott Mayhew &lt;smayhew@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>NFS: populate -&gt;net in mount data when remounting</title>
<updated>2014-07-07T01:59:11+00:00</updated>
<author>
<name>Mateusz Guzik</name>
<email>mguzik@redhat.com</email>
</author>
<published>2014-06-10T10:44:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=ff177fb44d47f46567543127e3ad42936b31c71f'/>
<id>ff177fb44d47f46567543127e3ad42936b31c71f</id>
<content type='text'>
commit a914722f333b3359d2f4f12919380a334176bb89 upstream.

Otherwise the kernel oopses when remounting with IPv6 server because
net is dereferenced in dev_get_by_name.

Use net ns of current thread so that dev_get_by_name does not operate on
foreign ns. Changing the address is prohibited anyway so this should not
affect anything.

Signed-off-by: Mateusz Guzik &lt;mguzik@redhat.com&gt;
Cc: linux-nfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit a914722f333b3359d2f4f12919380a334176bb89 upstream.

Otherwise the kernel oopses when remounting with IPv6 server because
net is dereferenced in dev_get_by_name.

Use net ns of current thread so that dev_get_by_name does not operate on
foreign ns. Changing the address is prohibited anyway so this should not
affect anything.

Signed-off-by: Mateusz Guzik &lt;mguzik@redhat.com&gt;
Cc: linux-nfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>NFS: Use raw_write_seqcount_begin/end int nfs4_reclaim_open_state</title>
<updated>2014-07-07T01:59:10+00:00</updated>
<author>
<name>Trond Myklebust</name>
<email>trond.myklebust@primarydata.com</email>
</author>
<published>2014-06-05T14:42:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=ca3fd5c679515e152f2e7feb980ebe8c444d5b18'/>
<id>ca3fd5c679515e152f2e7feb980ebe8c444d5b18</id>
<content type='text'>
commit abbec2da13f0e4c5d9b78b7e2c025a3e617228ba upstream.

The addition of lockdep code to write_seqcount_begin/end has lead to
a bunch of false positive claims of ABBA deadlocks with the so_lock
spinlock. Audits show that this simply cannot happen because the
read side code does not spin while holding so_lock.

Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit abbec2da13f0e4c5d9b78b7e2c025a3e617228ba upstream.

The addition of lockdep code to write_seqcount_begin/end has lead to
a bunch of false positive claims of ABBA deadlocks with the so_lock
spinlock. Audits show that this simply cannot happen because the
read side code does not spin while holding so_lock.

Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>NFS: Don't declare inode uptodate unless all attributes were checked</title>
<updated>2014-07-07T01:59:10+00:00</updated>
<author>
<name>Trond Myklebust</name>
<email>trond.myklebust@primarydata.com</email>
</author>
<published>2014-04-15T14:07:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7b2ffd05bdc009f6671a638138348c82fdc0267a'/>
<id>7b2ffd05bdc009f6671a638138348c82fdc0267a</id>
<content type='text'>
commit 43b6535e717d2f656f71d9bd16022136b781c934 upstream.

Fix a bug, whereby nfs_update_inode() was declaring the inode to be
up to date despite not having checked all the attributes.
The bug occurs because the temporary variable in which we cache
the validity information is 'sanitised' before reapplying to
nfsi-&gt;cache_validity.

Reported-by: Kinglong Mee &lt;kinglongmee@gmail.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 43b6535e717d2f656f71d9bd16022136b781c934 upstream.

Fix a bug, whereby nfs_update_inode() was declaring the inode to be
up to date despite not having checked all the attributes.
The bug occurs because the temporary variable in which we cache
the validity information is 'sanitised' before reapplying to
nfsi-&gt;cache_validity.

Reported-by: Kinglong Mee &lt;kinglongmee@gmail.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>nfsd: getattr for FATTR4_WORD0_FILES_AVAIL needs the statfs buffer</title>
<updated>2014-07-07T01:59:10+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2014-05-28T08:46:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=9024c373998c6742a2fec0889d791fccc3e5efa0'/>
<id>9024c373998c6742a2fec0889d791fccc3e5efa0</id>
<content type='text'>
commit 12337901d654415d9f764b5f5ba50052e9700f37 upstream.

Note nobody's ever noticed because the typical client probably never
requests FILES_AVAIL without also requesting something else on the list.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 12337901d654415d9f764b5f5ba50052e9700f37 upstream.

Note nobody's ever noticed because the typical client probably never
requests FILES_AVAIL without also requesting something else on the list.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>nfsd4: fix FREE_STATEID lockowner leak</title>
<updated>2014-07-07T01:59:10+00:00</updated>
<author>
<name>J. Bruce Fields</name>
<email>bfields@redhat.com</email>
</author>
<published>2014-05-27T15:14:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7e2f54792d45ff623ddaf424fbaf17d20e3e4246'/>
<id>7e2f54792d45ff623ddaf424fbaf17d20e3e4246</id>
<content type='text'>
commit 48385408b45523d9a432c66292d47ef43efcbb94 upstream.

27b11428b7de ("nfsd4: remove lockowner when removing lock stateid")
introduced a memory leak.

Reported-by: Jeff Layton &lt;jeff.layton@primarydata.com&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 48385408b45523d9a432c66292d47ef43efcbb94 upstream.

27b11428b7de ("nfsd4: remove lockowner when removing lock stateid")
introduced a memory leak.

Reported-by: Jeff Layton &lt;jeff.layton@primarydata.com&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>pNFS: Handle allocation errors correctly in filelayout_alloc_layout_hdr()</title>
<updated>2014-07-07T01:59:10+00:00</updated>
<author>
<name>Trond Myklebust</name>
<email>trond.myklebust@primarydata.com</email>
</author>
<published>2014-05-30T00:06:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a01b18de19cdb51dc0389ccc54120735c3a46d1b'/>
<id>a01b18de19cdb51dc0389ccc54120735c3a46d1b</id>
<content type='text'>
commit 6df200f5d5191bdde4d2e408215383890f956781 upstream.

Return the NULL pointer when the allocation fails.

Reported-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 6df200f5d5191bdde4d2e408215383890f956781 upstream.

Return the NULL pointer when the allocation fails.

Reported-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@primarydata.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>UBIFS: Remove incorrect assertion in shrink_tnc()</title>
<updated>2014-07-07T01:59:09+00:00</updated>
<author>
<name>hujianyang</name>
<email>hujianyang@huawei.com</email>
</author>
<published>2014-05-31T03:39:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=b03a0751eb1039340c843411cd2f09859531a385'/>
<id>b03a0751eb1039340c843411cd2f09859531a385</id>
<content type='text'>
commit 72abc8f4b4e8574318189886de627a2bfe6cd0da upstream.

I hit the same assert failed as Dolev Raviv reported in Kernel v3.10
shows like this:

[ 9641.164028] UBIFS assert failed in shrink_tnc at 131 (pid 13297)
[ 9641.234078] CPU: 1 PID: 13297 Comm: mmap.test Tainted: G           O 3.10.40 #1
[ 9641.234116] [&lt;c0011a6c&gt;] (unwind_backtrace+0x0/0x12c) from [&lt;c000d0b0&gt;] (show_stack+0x20/0x24)
[ 9641.234137] [&lt;c000d0b0&gt;] (show_stack+0x20/0x24) from [&lt;c0311134&gt;] (dump_stack+0x20/0x28)
[ 9641.234188] [&lt;c0311134&gt;] (dump_stack+0x20/0x28) from [&lt;bf22425c&gt;] (shrink_tnc_trees+0x25c/0x350 [ubifs])
[ 9641.234265] [&lt;bf22425c&gt;] (shrink_tnc_trees+0x25c/0x350 [ubifs]) from [&lt;bf2245ac&gt;] (ubifs_shrinker+0x25c/0x310 [ubifs])
[ 9641.234307] [&lt;bf2245ac&gt;] (ubifs_shrinker+0x25c/0x310 [ubifs]) from [&lt;c00cdad8&gt;] (shrink_slab+0x1d4/0x2f8)
[ 9641.234327] [&lt;c00cdad8&gt;] (shrink_slab+0x1d4/0x2f8) from [&lt;c00d03d0&gt;] (do_try_to_free_pages+0x300/0x544)
[ 9641.234344] [&lt;c00d03d0&gt;] (do_try_to_free_pages+0x300/0x544) from [&lt;c00d0a44&gt;] (try_to_free_pages+0x2d0/0x398)
[ 9641.234363] [&lt;c00d0a44&gt;] (try_to_free_pages+0x2d0/0x398) from [&lt;c00c6a60&gt;] (__alloc_pages_nodemask+0x494/0x7e8)
[ 9641.234382] [&lt;c00c6a60&gt;] (__alloc_pages_nodemask+0x494/0x7e8) from [&lt;c00f62d8&gt;] (new_slab+0x78/0x238)
[ 9641.234400] [&lt;c00f62d8&gt;] (new_slab+0x78/0x238) from [&lt;c031081c&gt;] (__slab_alloc.constprop.42+0x1a4/0x50c)
[ 9641.234419] [&lt;c031081c&gt;] (__slab_alloc.constprop.42+0x1a4/0x50c) from [&lt;c00f80e8&gt;] (kmem_cache_alloc_trace+0x54/0x188)
[ 9641.234459] [&lt;c00f80e8&gt;] (kmem_cache_alloc_trace+0x54/0x188) from [&lt;bf227908&gt;] (do_readpage+0x168/0x468 [ubifs])
[ 9641.234553] [&lt;bf227908&gt;] (do_readpage+0x168/0x468 [ubifs]) from [&lt;bf2296a0&gt;] (ubifs_readpage+0x424/0x464 [ubifs])
[ 9641.234606] [&lt;bf2296a0&gt;] (ubifs_readpage+0x424/0x464 [ubifs]) from [&lt;c00c17c0&gt;] (filemap_fault+0x304/0x418)
[ 9641.234638] [&lt;c00c17c0&gt;] (filemap_fault+0x304/0x418) from [&lt;c00de694&gt;] (__do_fault+0xd4/0x530)
[ 9641.234665] [&lt;c00de694&gt;] (__do_fault+0xd4/0x530) from [&lt;c00e10c0&gt;] (handle_pte_fault+0x480/0xf54)
[ 9641.234690] [&lt;c00e10c0&gt;] (handle_pte_fault+0x480/0xf54) from [&lt;c00e2bf8&gt;] (handle_mm_fault+0x140/0x184)
[ 9641.234716] [&lt;c00e2bf8&gt;] (handle_mm_fault+0x140/0x184) from [&lt;c0316688&gt;] (do_page_fault+0x150/0x3ac)
[ 9641.234737] [&lt;c0316688&gt;] (do_page_fault+0x150/0x3ac) from [&lt;c000842c&gt;] (do_DataAbort+0x3c/0xa0)
[ 9641.234759] [&lt;c000842c&gt;] (do_DataAbort+0x3c/0xa0) from [&lt;c0314e38&gt;] (__dabt_usr+0x38/0x40)

After analyzing the code, I found a condition that may cause this failed
in correct operations. Thus, I think this assertion is wrong and should be
removed.

Suppose there are two clean znodes and one dirty znode in TNC. So the
per-filesystem atomic_t @clean_zn_cnt is (2). If commit start, dirty_znode
is set to COW_ZNODE in get_znodes_to_commit() in case of potentially ops
on this znode. We clear COW bit and DIRTY bit in write_index() without
@tnc_mutex locked. We don't increase @clean_zn_cnt in this place. As the
comments in write_index() shows, if another process hold @tnc_mutex and
dirty this znode after we clean it, @clean_zn_cnt would be decreased to (1).
We will increase @clean_zn_cnt to (2) with @tnc_mutex locked in
free_obsolete_znodes() to keep it right.

If shrink_tnc() performs between decrease and increase, it will release
other 2 clean znodes it holds and found @clean_zn_cnt is less than zero
(1 - 2 = -1), then hit the assertion. Because free_obsolete_znodes() will
soon correct @clean_zn_cnt and no harm to fs in this case, I think this
assertion could be removed.

2 clean zondes and 1 dirty znode, @clean_zn_cnt == 2

Thread A (commit)         Thread B (write or others)       Thread C (shrinker)
-&gt;write_index
   -&gt;clear_bit(DIRTY_NODE)
   -&gt;clear_bit(COW_ZNODE)

            @clean_zn_cnt == 2
                          -&gt;mutex_locked(&amp;tnc_mutex)
                          -&gt;dirty_cow_znode
                              -&gt;!ubifs_zn_cow(znode)
                              -&gt;!test_and_set_bit(DIRTY_NODE)
                              -&gt;atomic_dec(&amp;clean_zn_cnt)
                          -&gt;mutex_unlocked(&amp;tnc_mutex)

            @clean_zn_cnt == 1
                                                           -&gt;mutex_locked(&amp;tnc_mutex)
                                                           -&gt;shrink_tnc
                                                             -&gt;destroy_tnc_subtree
                                                             -&gt;atomic_sub(&amp;clean_zn_cnt, 2)
                                                             -&gt;ubifs_assert  &lt;- hit
                                                           -&gt;mutex_unlocked(&amp;tnc_mutex)

            @clean_zn_cnt == -1
-&gt;mutex_lock(&amp;tnc_mutex)
-&gt;free_obsolete_znodes
   -&gt;atomic_inc(&amp;clean_zn_cnt)
-&gt;mutux_unlock(&amp;tnc_mutex)

            @clean_zn_cnt == 0 (correct after shrink)

Signed-off-by: hujianyang &lt;hujianyang@huawei.com&gt;
Signed-off-by: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 72abc8f4b4e8574318189886de627a2bfe6cd0da upstream.

I hit the same assert failed as Dolev Raviv reported in Kernel v3.10
shows like this:

[ 9641.164028] UBIFS assert failed in shrink_tnc at 131 (pid 13297)
[ 9641.234078] CPU: 1 PID: 13297 Comm: mmap.test Tainted: G           O 3.10.40 #1
[ 9641.234116] [&lt;c0011a6c&gt;] (unwind_backtrace+0x0/0x12c) from [&lt;c000d0b0&gt;] (show_stack+0x20/0x24)
[ 9641.234137] [&lt;c000d0b0&gt;] (show_stack+0x20/0x24) from [&lt;c0311134&gt;] (dump_stack+0x20/0x28)
[ 9641.234188] [&lt;c0311134&gt;] (dump_stack+0x20/0x28) from [&lt;bf22425c&gt;] (shrink_tnc_trees+0x25c/0x350 [ubifs])
[ 9641.234265] [&lt;bf22425c&gt;] (shrink_tnc_trees+0x25c/0x350 [ubifs]) from [&lt;bf2245ac&gt;] (ubifs_shrinker+0x25c/0x310 [ubifs])
[ 9641.234307] [&lt;bf2245ac&gt;] (ubifs_shrinker+0x25c/0x310 [ubifs]) from [&lt;c00cdad8&gt;] (shrink_slab+0x1d4/0x2f8)
[ 9641.234327] [&lt;c00cdad8&gt;] (shrink_slab+0x1d4/0x2f8) from [&lt;c00d03d0&gt;] (do_try_to_free_pages+0x300/0x544)
[ 9641.234344] [&lt;c00d03d0&gt;] (do_try_to_free_pages+0x300/0x544) from [&lt;c00d0a44&gt;] (try_to_free_pages+0x2d0/0x398)
[ 9641.234363] [&lt;c00d0a44&gt;] (try_to_free_pages+0x2d0/0x398) from [&lt;c00c6a60&gt;] (__alloc_pages_nodemask+0x494/0x7e8)
[ 9641.234382] [&lt;c00c6a60&gt;] (__alloc_pages_nodemask+0x494/0x7e8) from [&lt;c00f62d8&gt;] (new_slab+0x78/0x238)
[ 9641.234400] [&lt;c00f62d8&gt;] (new_slab+0x78/0x238) from [&lt;c031081c&gt;] (__slab_alloc.constprop.42+0x1a4/0x50c)
[ 9641.234419] [&lt;c031081c&gt;] (__slab_alloc.constprop.42+0x1a4/0x50c) from [&lt;c00f80e8&gt;] (kmem_cache_alloc_trace+0x54/0x188)
[ 9641.234459] [&lt;c00f80e8&gt;] (kmem_cache_alloc_trace+0x54/0x188) from [&lt;bf227908&gt;] (do_readpage+0x168/0x468 [ubifs])
[ 9641.234553] [&lt;bf227908&gt;] (do_readpage+0x168/0x468 [ubifs]) from [&lt;bf2296a0&gt;] (ubifs_readpage+0x424/0x464 [ubifs])
[ 9641.234606] [&lt;bf2296a0&gt;] (ubifs_readpage+0x424/0x464 [ubifs]) from [&lt;c00c17c0&gt;] (filemap_fault+0x304/0x418)
[ 9641.234638] [&lt;c00c17c0&gt;] (filemap_fault+0x304/0x418) from [&lt;c00de694&gt;] (__do_fault+0xd4/0x530)
[ 9641.234665] [&lt;c00de694&gt;] (__do_fault+0xd4/0x530) from [&lt;c00e10c0&gt;] (handle_pte_fault+0x480/0xf54)
[ 9641.234690] [&lt;c00e10c0&gt;] (handle_pte_fault+0x480/0xf54) from [&lt;c00e2bf8&gt;] (handle_mm_fault+0x140/0x184)
[ 9641.234716] [&lt;c00e2bf8&gt;] (handle_mm_fault+0x140/0x184) from [&lt;c0316688&gt;] (do_page_fault+0x150/0x3ac)
[ 9641.234737] [&lt;c0316688&gt;] (do_page_fault+0x150/0x3ac) from [&lt;c000842c&gt;] (do_DataAbort+0x3c/0xa0)
[ 9641.234759] [&lt;c000842c&gt;] (do_DataAbort+0x3c/0xa0) from [&lt;c0314e38&gt;] (__dabt_usr+0x38/0x40)

After analyzing the code, I found a condition that may cause this failed
in correct operations. Thus, I think this assertion is wrong and should be
removed.

Suppose there are two clean znodes and one dirty znode in TNC. So the
per-filesystem atomic_t @clean_zn_cnt is (2). If commit start, dirty_znode
is set to COW_ZNODE in get_znodes_to_commit() in case of potentially ops
on this znode. We clear COW bit and DIRTY bit in write_index() without
@tnc_mutex locked. We don't increase @clean_zn_cnt in this place. As the
comments in write_index() shows, if another process hold @tnc_mutex and
dirty this znode after we clean it, @clean_zn_cnt would be decreased to (1).
We will increase @clean_zn_cnt to (2) with @tnc_mutex locked in
free_obsolete_znodes() to keep it right.

If shrink_tnc() performs between decrease and increase, it will release
other 2 clean znodes it holds and found @clean_zn_cnt is less than zero
(1 - 2 = -1), then hit the assertion. Because free_obsolete_znodes() will
soon correct @clean_zn_cnt and no harm to fs in this case, I think this
assertion could be removed.

2 clean zondes and 1 dirty znode, @clean_zn_cnt == 2

Thread A (commit)         Thread B (write or others)       Thread C (shrinker)
-&gt;write_index
   -&gt;clear_bit(DIRTY_NODE)
   -&gt;clear_bit(COW_ZNODE)

            @clean_zn_cnt == 2
                          -&gt;mutex_locked(&amp;tnc_mutex)
                          -&gt;dirty_cow_znode
                              -&gt;!ubifs_zn_cow(znode)
                              -&gt;!test_and_set_bit(DIRTY_NODE)
                              -&gt;atomic_dec(&amp;clean_zn_cnt)
                          -&gt;mutex_unlocked(&amp;tnc_mutex)

            @clean_zn_cnt == 1
                                                           -&gt;mutex_locked(&amp;tnc_mutex)
                                                           -&gt;shrink_tnc
                                                             -&gt;destroy_tnc_subtree
                                                             -&gt;atomic_sub(&amp;clean_zn_cnt, 2)
                                                             -&gt;ubifs_assert  &lt;- hit
                                                           -&gt;mutex_unlocked(&amp;tnc_mutex)

            @clean_zn_cnt == -1
-&gt;mutex_lock(&amp;tnc_mutex)
-&gt;free_obsolete_znodes
   -&gt;atomic_inc(&amp;clean_zn_cnt)
-&gt;mutux_unlock(&amp;tnc_mutex)

            @clean_zn_cnt == 0 (correct after shrink)

Signed-off-by: hujianyang &lt;hujianyang@huawei.com&gt;
Signed-off-by: Artem Bityutskiy &lt;artem.bityutskiy@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
</feed>
