<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/xfs/libxfs, branch linux-5.8.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.8.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.8.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-10-29T09:07:54Z</updated>
<entry>
<title>xfs: fix high key handling in the rt allocator's query_range function</title>
<updated>2020-10-29T09:07:54Z</updated>
<author>
<name>Darrick J. Wong</name>
</author>
<published>2020-10-13T15:46:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=929cdbcce02f5584f78a8488efac6e8e6b7fc57c'/>
<id>urn:sha1:929cdbcce02f5584f78a8488efac6e8e6b7fc57c</id>
<content type='text'>
[ Upstream commit d88850bd5516a77c6f727e8b6cefb64e0cc929c7 ]

Fix some off-by-one errors in xfs_rtalloc_query_range.  The highest key
in the realtime bitmap is always one less than the number of rt extents,
which means that the key clamp at the start of the function is wrong.
The 4th argument to xfs_rtfind_forw is the highest rt extent that we
want to probe, which means that passing 1 less than the high key is
wrong.  Finally, drop the rem variable that controls the loop because we
can compare the iteration point (rtstart) against the high key directly.

The sordid history of this function is that the original commit (fb3c3)
incorrectly passed (high_rec-&gt;ar_startblock - 1) as the 'limit' parameter
to xfs_rtfind_forw.  This was wrong because the "high key" is supposed
to be the largest key for which the caller wants result rows, not the
key for the first row that could possibly be outside the range that the
caller wants to see.

A subsequent attempt (8ad56) to strengthen the parameter checking added
incorrect clamping of the parameters to the number of rt blocks in the
system (despite the bitmap functions all taking units of rt extents) to
avoid querying ranges past the end of rt bitmap file but failed to fix
the incorrect _rtfind_forw parameter.  The original _rtfind_forw
parameter error then survived the conversion of the startblock and
blockcount fields to rt extents (a0e5c), and the most recent off-by-one
fix (a3a37) thought it was patching a problem when the end of the rt
volume is not in use, but none of these fixes actually solved the
original problem that the author was confused about the "limit" argument
to xfs_rtfind_forw.

Sadly, all four of these patches were written by this author and even
his own usage of this function and rt testing were inadequate to get
this fixed quickly.

Original-problem: fb3c3de2f65c ("xfs: add a couple of queries to iterate free extents in the rtbitmap")
Not-fixed-by: 8ad560d2565e ("xfs: strengthen rtalloc query range checks")
Not-fixed-by: a0e5c435babd ("xfs: fix xfs_rtalloc_rec units")
Fixes: a3a374bf1889 ("xfs: fix off-by-one error in xfs_rtalloc_query_range")
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Reviewed-by: Chandan Babu R &lt;chandanrlinux@gmail.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: initialize the shortform attr header padding entry</title>
<updated>2020-09-17T11:55:34Z</updated>
<author>
<name>Darrick J. Wong</name>
</author>
<published>2020-08-26T21:12:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=74e4b9ae64a2749bd95fed1e700d44c36e7aadeb'/>
<id>urn:sha1:74e4b9ae64a2749bd95fed1e700d44c36e7aadeb</id>
<content type='text'>
[ Upstream commit 125eac243806e021f33a1fdea3687eccbb9f7636 ]

Don't leak kernel memory contents into the shortform attr fork.

Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Reviewed-by: Eric Sandeen &lt;sandeen@redhat.com&gt;
Reviewed-by: Dave Chinner &lt;dchinner@redhat.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: fix off-by-one in inode alloc block reservation calculation</title>
<updated>2020-09-17T11:55:33Z</updated>
<author>
<name>Brian Foster</name>
</author>
<published>2020-08-26T21:08:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d910490078ac70ba4223af4c22d7404737d85425'/>
<id>urn:sha1:d910490078ac70ba4223af4c22d7404737d85425</id>
<content type='text'>
[ Upstream commit 657f101930bc6c5b41bd7d6c22565c4302a80d33 ]

The inode chunk allocation transaction reserves inobt_maxlevels-1
blocks to accommodate a full split of the inode btree. A full split
requires an allocation for every existing level and a new root
block, which means inobt_maxlevels is the worst case block
requirement for a transaction that inserts to the inobt. This can
lead to a transaction block reservation overrun when tmpfile
creation allocates an inode chunk and expands the inobt to its
maximum depth. This problem has been observed in conjunction with
overlayfs, which makes frequent use of tmpfiles internally.

The existing reservation code goes back as far as the Linux git repo
history (v2.6.12). It was likely never observed as a problem because
the traditional file/directory creation transactions also include
worst case block reservation for directory modifications, which most
likely is able to make up for a single block deficiency in the inode
allocation portion of the calculation. tmpfile support is relatively
more recent (v3.15), less heavily used, and only includes the inode
allocation block reservation as tmpfiles aren't linked into the
directory tree on creation.

Fix up the inode alloc block reservation macro and a couple of the
block allocator minleft parameters that enforce an allocation to
leave enough free blocks in the AG for a full inobt split.

Signed-off-by: Brian Foster &lt;bfoster@redhat.com&gt;
Reviewed-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: fix xfs_bmap_validate_extent_raw when checking attr fork of rt files</title>
<updated>2020-09-09T17:14:22Z</updated>
<author>
<name>Darrick J. Wong</name>
</author>
<published>2020-09-02T17:47:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=62a5784285bf6705b8d459cd60dc26e71f962f3c'/>
<id>urn:sha1:62a5784285bf6705b8d459cd60dc26e71f962f3c</id>
<content type='text'>
[ Upstream commit d0c20d38af135b2b4b90aa59df7878ef0c8fbef4 ]

The realtime flag only applies to the data fork, so don't use the
realtime block number checks on the attr fork of a realtime file.

Fixes: 30b0984d9117 ("xfs: refactor bmap record validation")
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Reviewed-by: Eric Sandeen &lt;sandeen@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: fix boundary test in xfs_attr_shortform_verify</title>
<updated>2020-09-09T17:14:17Z</updated>
<author>
<name>Eric Sandeen</name>
</author>
<published>2020-08-26T21:11:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=531c6cb9ad1e7de98e09e9b7d23aaca0e3f5babd'/>
<id>urn:sha1:531c6cb9ad1e7de98e09e9b7d23aaca0e3f5babd</id>
<content type='text'>
[ Upstream commit f4020438fab05364018c91f7e02ebdd192085933 ]

The boundary test for the fixed-offset parts of xfs_attr_sf_entry in
xfs_attr_shortform_verify is off by one, because the variable array
at the end is defined as nameval[1] not nameval[].
Hence we need to subtract 1 from the calculation.

This can be shown by:

# touch file
# setfattr -n root.a file

and verifications will fail when it's written to disk.

This only matters for a last attribute which has a single-byte name
and no value, otherwise the combination of namelen &amp; valuelen will
push endp further out and this test won't fail.

Fixes: 1e1bbd8e7ee06 ("xfs: create structure verifier function for shortform xattrs")
Signed-off-by: Eric Sandeen &lt;sandeen@redhat.com&gt;
Reviewed-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: Don't allow logging of XFS_ISTALE inodes</title>
<updated>2020-09-03T09:29:18Z</updated>
<author>
<name>Dave Chinner</name>
</author>
<published>2020-06-29T21:48:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bce0f660a06ad2e25b14a18a17bbe6ef0af6f79d'/>
<id>urn:sha1:bce0f660a06ad2e25b14a18a17bbe6ef0af6f79d</id>
<content type='text'>
[ Upstream commit 96355d5a1f0ee6dcc182c37db4894ec0c29f1692 ]

In tracking down a problem in this patchset, I discovered we are
reclaiming dirty stale inodes. This wasn't discovered until inodes
were always attached to the cluster buffer and then the rcu callback
that freed inodes was assert failing because the inode still had an
active pointer to the cluster buffer after it had been reclaimed.

Debugging the issue indicated that this was a pre-existing issue
resulting from the way the inodes are handled in xfs_inactive_ifree.
When we free a cluster buffer from xfs_ifree_cluster, all the inodes
in cache are marked XFS_ISTALE. Those that are clean have nothing
else done to them and so eventually get cleaned up by background
reclaim. i.e. it is assumed we'll never dirty/relog an inode marked
XFS_ISTALE.

On journal commit dirty stale inodes as are handled by both
buffer and inode log items to run though xfs_istale_done() and
removed from the AIL (buffer log item commit) or the log item will
simply unpin it because the buffer log item will clean it. What happens
to any specific inode is entirely dependent on which log item wins
the commit race, but the result is the same - stale inodes are
clean, not attached to the cluster buffer, and not in the AIL. Hence
inode reclaim can just free these inodes without further care.

However, if the stale inode is relogged, it gets dirtied again and
relogged into the CIL. Most of the time this isn't an issue, because
relogging simply changes the inode's location in the current
checkpoint. Problems arise, however, when the CIL checkpoints
between two transactions in the xfs_inactive_ifree() deferops
processing. This results in the XFS_ISTALE inode being redirtied
and inserted into the CIL without any of the other stale cluster
buffer infrastructure being in place.

Hence on journal commit, it simply gets unpinned, so it remains
dirty in memory. Everything in inode writeback avoids XFS_ISTALE
inodes so it can't be written back, and it is not tracked in the AIL
so there's not even a trigger to attempt to clean the inode. Hence
the inode just sits dirty in memory until inode reclaim comes along,
sees that it is XFS_ISTALE, and goes to reclaim it. This reclaiming
of a dirty inode caused use after free, list corruptions and other
nasty issues later in this patchset.

Hence this patch addresses a violation of the "never log XFS_ISTALE
inodes" caused by the deferops processing rolling a transaction
and relogging a stale inode in xfs_inactive_free. It also adds a
bunch of asserts to catch this problem in debug kernels so that
we don't reintroduce this problem in future.

Reproducer for this issue was generic/558 on a v4 filesystem.

Signed-off-by: Dave Chinner &lt;dchinner@redhat.com&gt;
Reviewed-by: Brian Foster &lt;bfoster@redhat.com&gt;
Reviewed-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: fix inode allocation block res calculation precedence</title>
<updated>2020-08-19T06:26:47Z</updated>
<author>
<name>Brian Foster</name>
</author>
<published>2020-07-16T01:44:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5db458a8589217b9411e131811f19f9d9ff47951'/>
<id>urn:sha1:5db458a8589217b9411e131811f19f9d9ff47951</id>
<content type='text'>
[ Upstream commit b2a8864728683443f34a9fd33a2b78b860934cc1 ]

The block reservation calculation for inode allocation is supposed
to consist of the blocks required for the inode chunk plus
(maxlevels-1) of the inode btree multiplied by the number of inode
btrees in the fs (2 when finobt is enabled, 1 otherwise).

Instead, the macro returns (ialloc_blocks + 2) due to a precedence
error in the calculation logic. This leads to block reservation
overruns via generic/531 on small block filesystems with finobt
enabled. Add braces to fix the calculation and reserve the
appropriate number of blocks.

Fixes: 9d43b180af67 ("xfs: update inode allocation/free transaction reservations for finobt")
Signed-off-by: Brian Foster &lt;bfoster@redhat.com&gt;
Reviewed-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: preserve rmapbt swapext block reservation from freed blocks</title>
<updated>2020-08-19T06:26:32Z</updated>
<author>
<name>Brian Foster</name>
</author>
<published>2020-06-29T21:44:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9ff3281d903fd2bcbeea707a83cf0c5e3612422d'/>
<id>urn:sha1:9ff3281d903fd2bcbeea707a83cf0c5e3612422d</id>
<content type='text'>
[ Upstream commit f74681ba2006434be195402e0b15fc5763cddd7e ]

The rmapbt extent swap algorithm remaps individual extents between
the source inode and the target to trigger reverse mapping metadata
updates. If either inode straddles a format or other bmap allocation
boundary, the individual unmap and map cycles can trigger repeated
bmap block allocations and frees as the extent count bounces back
and forth across the boundary. While net block usage is bound across
the swap operation, this behavior can prematurely exhaust the
transaction block reservation because it continuously drains as the
transaction rolls. Each allocation accounts against the reservation
and each free returns to global free space on transaction roll.

The previous workaround to this problem attempted to detect this
boundary condition and provide surplus block reservation to
acommodate it. This is insufficient because more remaps can occur
than implied by the extent counts; if start offset boundaries are
not aligned between the two inodes, for example.

To address this problem more generically and dynamically, add a
transaction accounting mode that returns freed blocks to the
transaction reservation instead of the superblock counters on
transaction roll and use it when the rmapbt based algorithm is
active. This allows the chain of remap transactions to preserve the
block reservation based own its own frees and prevent premature
exhaustion regardless of the remap pattern. Note that this is only
safe for superblocks with lazy sb accounting, but the latter is
required for v5 supers and the rmap feature depends on v5.

Fixes: b3fed434822d0 ("xfs: account format bouncing into rmapbt swapext tx reservation")
Root-caused-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Brian Foster &lt;bfoster@redhat.com&gt;
Reviewed-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>xfs: more lockdep whackamole with kmem_alloc*</title>
<updated>2020-05-27T15:49:28Z</updated>
<author>
<name>Darrick J. Wong</name>
</author>
<published>2020-05-26T16:33:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6dcde60efd946e38fac8d276a6ca47492103e856'/>
<id>urn:sha1:6dcde60efd946e38fac8d276a6ca47492103e856</id>
<content type='text'>
Dave Airlie reported the following lockdep complaint:

&gt;  ======================================================
&gt;  WARNING: possible circular locking dependency detected
&gt;  5.7.0-0.rc5.20200515git1ae7efb38854.1.fc33.x86_64 #1 Not tainted
&gt;  ------------------------------------------------------
&gt;  kswapd0/159 is trying to acquire lock:
&gt;  ffff9b38d01a4470 (&amp;xfs_nondir_ilock_class){++++}-{3:3},
&gt;  at: xfs_ilock+0xde/0x2c0 [xfs]
&gt;
&gt;  but task is already holding lock:
&gt;  ffffffffbbb8bd00 (fs_reclaim){+.+.}-{0:0}, at:
&gt;  __fs_reclaim_acquire+0x5/0x30
&gt;
&gt;  which lock already depends on the new lock.
&gt;
&gt;
&gt;  the existing dependency chain (in reverse order) is:
&gt;
&gt;  -&gt; #1 (fs_reclaim){+.+.}-{0:0}:
&gt;         fs_reclaim_acquire+0x34/0x40
&gt;         __kmalloc+0x4f/0x270
&gt;         kmem_alloc+0x93/0x1d0 [xfs]
&gt;         kmem_alloc_large+0x4c/0x130 [xfs]
&gt;         xfs_attr_copy_value+0x74/0xa0 [xfs]
&gt;         xfs_attr_get+0x9d/0xc0 [xfs]
&gt;         xfs_get_acl+0xb6/0x200 [xfs]
&gt;         get_acl+0x81/0x160
&gt;         posix_acl_xattr_get+0x3f/0xd0
&gt;         vfs_getxattr+0x148/0x170
&gt;         getxattr+0xa7/0x240
&gt;         path_getxattr+0x52/0x80
&gt;         do_syscall_64+0x5c/0xa0
&gt;         entry_SYSCALL_64_after_hwframe+0x49/0xb3
&gt;
&gt;  -&gt; #0 (&amp;xfs_nondir_ilock_class){++++}-{3:3}:
&gt;         __lock_acquire+0x1257/0x20d0
&gt;         lock_acquire+0xb0/0x310
&gt;         down_write_nested+0x49/0x120
&gt;         xfs_ilock+0xde/0x2c0 [xfs]
&gt;         xfs_reclaim_inode+0x3f/0x400 [xfs]
&gt;         xfs_reclaim_inodes_ag+0x20b/0x410 [xfs]
&gt;         xfs_reclaim_inodes_nr+0x31/0x40 [xfs]
&gt;         super_cache_scan+0x190/0x1e0
&gt;         do_shrink_slab+0x184/0x420
&gt;         shrink_slab+0x182/0x290
&gt;         shrink_node+0x174/0x680
&gt;         balance_pgdat+0x2d0/0x5f0
&gt;         kswapd+0x21f/0x510
&gt;         kthread+0x131/0x150
&gt;         ret_from_fork+0x3a/0x50
&gt;
&gt;  other info that might help us debug this:
&gt;
&gt;   Possible unsafe locking scenario:
&gt;
&gt;         CPU0                    CPU1
&gt;         ----                    ----
&gt;    lock(fs_reclaim);
&gt;                                 lock(&amp;xfs_nondir_ilock_class);
&gt;                                 lock(fs_reclaim);
&gt;    lock(&amp;xfs_nondir_ilock_class);
&gt;
&gt;   *** DEADLOCK ***
&gt;
&gt;  4 locks held by kswapd0/159:
&gt;   #0: ffffffffbbb8bd00 (fs_reclaim){+.+.}-{0:0}, at:
&gt;  __fs_reclaim_acquire+0x5/0x30
&gt;   #1: ffffffffbbb7cef8 (shrinker_rwsem){++++}-{3:3}, at:
&gt;  shrink_slab+0x115/0x290
&gt;   #2: ffff9b39f07a50e8
&gt;  (&amp;type-&gt;s_umount_key#56){++++}-{3:3}, at: super_cache_scan+0x38/0x1e0
&gt;   #3: ffff9b39f077f258
&gt;  (&amp;pag-&gt;pag_ici_reclaim_lock){+.+.}-{3:3}, at:
&gt;  xfs_reclaim_inodes_ag+0x82/0x410 [xfs]

This is a known false positive because inodes cannot simultaneously be
getting reclaimed and the target of a getxattr operation, but lockdep
doesn't know that.  We can (selectively) shut up lockdep until either
it gets smarter or we change inode reclaim not to require the ILOCK by
applying a stupid GFP_NOLOCKDEP bandaid.

Reported-by: Dave Airlie &lt;airlied@gmail.com&gt;
Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Tested-by: Dave Airlie &lt;airlied@gmail.com&gt;
Reviewed-by: Brian Foster &lt;bfoster@redhat.com&gt;
</content>
</entry>
<entry>
<title>xfs: force writes to delalloc regions to unwritten</title>
<updated>2020-05-27T15:49:28Z</updated>
<author>
<name>Darrick J. Wong</name>
</author>
<published>2020-05-23T16:43:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a5949d3faedf492fa7863b914da408047ab46eb0'/>
<id>urn:sha1:a5949d3faedf492fa7863b914da408047ab46eb0</id>
<content type='text'>
When writing to a delalloc region in the data fork, commit the new
allocations (of the da reservation) as unwritten so that the mappings
are only marked written once writeback completes successfully.  This
fixes the problem of stale data exposure if the system goes down during
targeted writeback of a specific region of a file, as tested by
generic/042.

Signed-off-by: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Brian Foster &lt;bfoster@redhat.com&gt;
</content>
</entry>
</feed>
