From: Filipe Manana <redacted>
A small set of changes, mostly cleanups, a fix for an error that is not
being returned, and adding a couple lockdep assertions.
Filipe Manana (4):
btrfs: stop checking for NULL return from btrfs_get_extent()
btrfs: fix lost error return value when reading a data page
btrfs: remove no longer used counter when reading data page
btrfs: assert we have a write lock when removing and replacing extent
maps
fs/btrfs/extent_io.c | 12 +++++-------
fs/btrfs/extent_map.c | 4 ++++
fs/btrfs/inode.c | 9 +++++++--
fs/btrfs/tests/extent-map-tests.c | 2 ++
4 files changed, 18 insertions(+), 9 deletions(-)
--
2.33.0
From: Filipe Manana <redacted>
At extent_io.c, in the read page and write page code paths, we are testing
if the return value from btrfs_get_extent() can be NULL. However that is
not possible, as btrfs_get_extent() always returns either an error pointer
or a (non-NULL) pointer to an extent map structure.
Eveywhere else outside extent_io.c we never check for NULL, we always
treat any returned value as a non-NULL pointer if it does not encode an
error.
So check only for the IS_ERR() case at extent_io.c.
Signed-off-by: Filipe Manana <redacted>
---
fs/btrfs/extent_io.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: Filipe Manana <redacted>
At btrfs_do_readpage(), if we get an error when trying to lookup for an
extent map, we end up marking the page with the error bit, clearing
the uptodate bit on it, and doing everything else that should be done.
However we return success (0) to the caller, when we should return the
error encoded in the extent map pointer. So fix that by returning the
error encoded in the pointer.
Signed-off-by: Filipe Manana <redacted>
---
fs/btrfs/extent_io.c | 1 +
fs/btrfs/inode.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
From: Filipe Manana <redacted>
Removing or replacing an extent map requires holding a write lock on the
extent map's tree. We currently do that everywhere, except in one of the
self tests, where it's harmless since there's no concurrency.
In order to catch possible races in the future, assert that we are holding
a write lock on the extent map tree before removing or replacing an extent
map in the tree, and update the self test to obtain a write lock before
removing extent maps.
Signed-off-by: Filipe Manana <redacted>
---
fs/btrfs/extent_map.c | 4 ++++
fs/btrfs/tests/extent-map-tests.c | 2 ++
2 files changed, 6 insertions(+)
From: Filipe Manana <redacted>
After commit 92082d40976ed0 ("btrfs: integrate page status update for
data read path into begin/end_page_read"), the 'nr' counter at
btrfs_do_readpage() is no longer used, we increment it but we never
read from it. So just remove it.
Signed-off-by: Filipe Manana <redacted>
---
fs/btrfs/extent_io.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
From: Johannes Thumshirn <hidden> Date: 2022-02-04 08:19:12
On 03/02/2022 16:37, fdmanana@kernel.org wrote:
From: Filipe Manana <redacted>
At extent_io.c, in the read page and write page code paths, we are testing
if the return value from btrfs_get_extent() can be NULL. However that is
not possible, as btrfs_get_extent() always returns either an error pointer
or a (non-NULL) pointer to an extent map structure.
Eveywhere else outside extent_io.c we never check for NULL, we always
treat any returned value as a non-NULL pointer if it does not encode an
error.
So check only for the IS_ERR() case at extent_io.c.
Isn't the same true for btrfs_get_extent_fiemap()? In get_extent_skip_holes()
we're also checking for IS_ERR_OR_NULL() but AFAICS btrfs_get_extent_fiemap()
will never return NULL only a valid em or an error pointer.
Anyways for this patch:
Reviewed-by: Johannes Thumshirn <redacted>
From: Johannes Thumshirn <hidden> Date: 2022-02-04 08:25:07
On 03/02/2022 16:36, fdmanana@kernel.org wrote:
From: Filipe Manana <redacted>
A small set of changes, mostly cleanups, a fix for an error that is not
being returned, and adding a couple lockdep assertions.
Filipe Manana (4):
btrfs: stop checking for NULL return from btrfs_get_extent()
btrfs: fix lost error return value when reading a data page
btrfs: remove no longer used counter when reading data page
btrfs: assert we have a write lock when removing and replacing extent
maps
fs/btrfs/extent_io.c | 12 +++++-------
fs/btrfs/extent_map.c | 4 ++++
fs/btrfs/inode.c | 9 +++++++--
fs/btrfs/tests/extent-map-tests.c | 2 ++
4 files changed, 18 insertions(+), 9 deletions(-)
For the whole series
Reviewed-by: Johannes Thumshirn <redacted>
From: Filipe Manana <fdmanana@kernel.org> Date: 2022-02-04 11:18:05
On Fri, Feb 04, 2022 at 08:19:08AM +0000, Johannes Thumshirn wrote:
On 03/02/2022 16:37, fdmanana@kernel.org wrote:
quoted
From: Filipe Manana <redacted>
At extent_io.c, in the read page and write page code paths, we are testing
if the return value from btrfs_get_extent() can be NULL. However that is
not possible, as btrfs_get_extent() always returns either an error pointer
or a (non-NULL) pointer to an extent map structure.
Eveywhere else outside extent_io.c we never check for NULL, we always
treat any returned value as a non-NULL pointer if it does not encode an
error.
So check only for the IS_ERR() case at extent_io.c.
Isn't the same true for btrfs_get_extent_fiemap()? In get_extent_skip_holes()
we're also checking for IS_ERR_OR_NULL() but AFAICS btrfs_get_extent_fiemap()
will never return NULL only a valid em or an error pointer.
Yep.
I was focused on the read and write page paths, due to the next change, so I
missed that one.
I can send another patch to fix that one, or if you want to do it yourself,
please go ahead.
Thanks.
Anyways for this patch:
Reviewed-by: Johannes Thumshirn <redacted>
From: David Sterba <hidden> Date: 2022-02-04 16:36:15
On Thu, Feb 03, 2022 at 03:36:41PM +0000, fdmanana@kernel.org wrote:
From: Filipe Manana <redacted>
A small set of changes, mostly cleanups, a fix for an error that is not
being returned, and adding a couple lockdep assertions.
Filipe Manana (4):
btrfs: stop checking for NULL return from btrfs_get_extent()
btrfs: fix lost error return value when reading a data page
btrfs: remove no longer used counter when reading data page
btrfs: assert we have a write lock when removing and replacing extent
maps
From: David Sterba <hidden> Date: 2022-02-08 15:49:27
On Fri, Feb 04, 2022 at 05:35:27PM +0100, David Sterba wrote:
On Thu, Feb 03, 2022 at 03:36:41PM +0000, fdmanana@kernel.org wrote:
quoted
From: Filipe Manana <redacted>
A small set of changes, mostly cleanups, a fix for an error that is not
being returned, and adding a couple lockdep assertions.
Filipe Manana (4):
btrfs: stop checking for NULL return from btrfs_get_extent()
btrfs: fix lost error return value when reading a data page
btrfs: remove no longer used counter when reading data page
btrfs: assert we have a write lock when removing and replacing extent
maps