btrfs: fix a bug in the direct IO write path for COW writes
cover btrfs: fix a bug in the direct IO write path for COW writes
From: Filipe Manana <[email protected]>
Fix a bug in an error path for direct IO writes in COW mode, which can make a subsequent fsync log invalid extent items (pointing to unwritten data). The second patch is just a cleanup. Details in the change logs.
Filipe Manana (2):
btrfs: drop extent maps after failed COW dio write
btrfs: refactor btrfs_dio_submit_io() for less nesting and indentation
fs/btrfs/inode.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 btrfs: drop extent maps after failed COW dio write
From: Filipe Manana <[email protected]>
During a COW direct IO write if the call to btrfs_extract_ordered_extent() fails, we don't submit any bios, cleanup the ordered extent but we leave the extent maps we created for the write around.
These extent maps point to locations on disk that were not written to, since we haven't submitted a bio for them, and they are new an in the list of modified extents.
This means that if we fsync the file after, we log file extent items based on those extent maps, which are invalid since they point to unwritten locations. If a power failure happens after the fsync, on log replay we get a corrupted file range.
Fix this by dropping the extent maps if btrfs_extract_ordered_extent() failed.
--- fs/btrfs/inode.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
fs/btrfs/inode.c +19 -2
@@ -7888,11 +7888,28 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,* remaining pages is blocked on the outstanding ordered extent. */ if (iter->flags &IOMAP_WRITE ) { +struct btrfs_ordered_extent *oe = dio_data->ordered;int ret; - ret =btrfs_extract_ordered_extent (bbio, dio_data->ordered); + ret =btrfs_extract_ordered_extent (bbio, oe);if (ret) { -btrfs_finish_ordered_extent (dio_data->ordered,NULL , +/* +* If this is a COW write it means we created new extent +* maps for the range and they point to an unwritten +* location since we got an error and we don't submit +* a bio. We must drop any extent maps within the range, +* otherwise a fast fsync would log them and after a +* crash and log replay we would have file extent items +* that point to unwritten locations (garbage). +*/ +if (!test_bit (BTRFS_ORDERED_NOCOW , &oe->flags)) { +const u64 start = oe->file_offset; +const u64 end = start + oe->num_bytes -1 ; + +btrfs_drop_extent_map_range (bbio->inode, start, end, false); + } + +btrfs_finish_ordered_extent (oe,NULL , file_offset, dip->bytes, !ret); bio->bi_status =errno_to_blk_status (ret);
Signature · 1 line
2.43.0
Re: [PATCH 1/2] btrfs: drop extent maps after failed COW dio write
Quoted 15 lines · 在 2024/5/14 23:53, [email protected] 写道:
From: Filipe Manana <[email protected]>
During a COW direct IO write if the call to
btrfs_extract_ordered_extent()fails, we don't submit any bios, cleanup the ordered extent but we leave the extent maps we created for the write around.These extent maps point to locations on disk that were not written to, since we haven't submitted a bio for them, and they are new an in the list of modified extents.
This means that if we fsync the file after, we log file extent items based on those extent maps, which are invalid since they point to unwritten locations. If a power failure happens after the fsync, on log replay we get a corrupted file range.
Quoted 5 lines
Fix this by dropping the extent maps if
btrfs_extract_ordered_extent()failed.Fixes b73a6fd1b1ef ("btrfs: split partial dio bios before submit")Signed-off-by Filipe Manana <[email protected]>
Just a small question inlined below.
Quoted 18 lines
--- fs/btrfs/inode.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)fs/btrfs/inode.c +2
-1@@ -7888,11 +7888,28 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,* remaining pages is blocked on the outstanding ordered extent. */ if (iter->flags &IOMAP_WRITE ) { +struct btrfs_ordered_extent *oe = dio_data->ordered;int ret; - ret =btrfs_extract_ordered_extent (bbio, dio_data->ordered); + ret =btrfs_extract_ordered_extent (bbio, oe);if (ret) {
fs/btrfs/inode.c static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio, · line 7904
Quoted 10 lines
fs/btrfs/inode.c +9
-1- btrfs_finish_ordered_extent(dio_data->ordered, NULL, +/* +* If this is a COW write it means we created new extent +* maps for the range and they point to an unwritten +* location since we got an error and we don't submit +* a bio. We must drop any extent maps within the range, +* otherwise a fast fsync would log them and after a +* crash and log replay we would have file extent items +* that point to unwritten locations (garbage). +*/
Is regular read also being affected?
Since the em is already inserted, and we're doing DIO, there should be no page cache for the whole dio range (as long as we didn't fallback to buffered IO).
In that case, the problem is not only limited to fsync, but also any read.
Thanks,
Qu
Quoted 11 lines
fs/btrfs/inode.c +8
-0+if (!test_bit (BTRFS_ORDERED_NOCOW , &oe->flags)) { +const u64 start = oe->file_offset; +const u64 end = start + oe->num_bytes -1 ; + +btrfs_drop_extent_map_range (bbio->inode, start, end, false); + } + +btrfs_finish_ordered_extent (oe,NULL , file_offset, dip->bytes, !ret); bio->bi_status =errno_to_blk_status (ret);
Re: [PATCH 1/2] btrfs: drop extent maps after failed COW dio write
Quoted 43 lines · Qu Wenruo
Quoted 15 lines · 在 2024/5/14 23:53, [email protected] 写道:
From: Filipe Manana <[email protected]>
During a COW direct IO write if the call to
btrfs_extract_ordered_extent()fails, we don't submit any bios, cleanup the ordered extent but we leave the extent maps we created for the write around.These extent maps point to locations on disk that were not written to, since we haven't submitted a bio for them, and they are new an in the list of modified extents.
This means that if we fsync the file after, we log file extent items based on those extent maps, which are invalid since they point to unwritten locations. If a power failure happens after the fsync, on log replay we get a corrupted file range.
Quoted 5 lines
Fix this by dropping the extent maps if
btrfs_extract_ordered_extent()failed.Fixes b73a6fd1b1ef ("btrfs: split partial dio bios before submit")Signed-off-by Filipe Manana <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Just a small question inlined below.
Quoted 15 lines
--- fs/btrfs/inode.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)fs/btrfs/inode.c +1
-0@@ -7888,11 +7888,28 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,* remaining pages is blocked on the outstanding ordered extent. */ if (iter->flags &IOMAP_WRITE ) { +struct btrfs_ordered_extent *oe = dio_data->ordered;int ret;
Quoted 15 lines
fs/btrfs/inode.c static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio, · line 7904
Quoted 13 lines
fs/btrfs/inode.c +10
-2- ret =btrfs_extract_ordered_extent (bbio, dio_data->ordered); + ret =btrfs_extract_ordered_extent (bbio, oe);if (ret) { - btrfs_finish_ordered_extent(dio_data->ordered, NULL, +/* +* If this is a COW write it means we created new extent +* maps for the range and they point to an unwritten +* location since we got an error and we don't submit +* a bio. We must drop any extent maps within the range, +* otherwise a fast fsync would log them and after a +* crash and log replay we would have file extent items +* that point to unwritten locations (garbage). +*/ Is regular read also being affected?
No, it isn't, I'll explain below.
Quoted 6 lines
Since the em is already inserted, and we're doing DIO, there should be no page cache for the whole dio range (as long as we didn't fallback to buffered IO).
In that case, the problem is not only limited to fsync, but also any read.
Nop, it has nothing to do with not being buffered IO.
So what happens in this particular error path is that on error we call btrfs_finish_ordered_extent() with "uptodate" false.
This sets the IO_ERR flag on the ordered extent and then queues the ordered extent completion,
which results in executing btrfs_finish_one_ordered() in a work queue.
There we check the error flag on the ordered extent, and in fact we drop extent maps in range - exactly what this patch is doing.
The problem is that once we unlock the inode in the dio write path, another task can call fsync.
If the fsync is a "fast fsync", it does not wait for ordered extents to complete before going over new extent maps.
So if the work queue job only finishes after the fsync logs extent maps, we get the corruption - a log tree with file extent items pointing to unwritten extents.
For the read path this doesn't happen.
Because for reads, when they start we lock the extent range and wait for any ordered extents in the range to complete (we call btrfs_lock_and_flush_ordered_range()),
which will result in dropping the extent maps in the range when the ordered extents complete.
These are probably a lot of non-obvious details.
So I'll send a v2 with these details in the changelog and comment.
I also noticed there's at least one more error path with the same problem, so I'll move the call to drop extent maps to btrfs_finish_ordered_extent().
I'm giving a full fstests run with that updated version and sending it out later.
Thanks.
Quoted 14 lines
Thanks,
QuQuoted 11 lines
fs/btrfs/inode.c +8
-0+if (!test_bit (BTRFS_ORDERED_NOCOW , &oe->flags)) { +const u64 start = oe->file_offset; +const u64 end = start + oe->num_bytes -1 ; + +btrfs_drop_extent_map_range (bbio->inode, start, end, false); + } + +btrfs_finish_ordered_extent (oe,NULL , file_offset, dip->bytes, !ret); bio->bi_status =errno_to_blk_status (ret);
PATCH 2/2 btrfs: refactor btrfs_dio_submit_io() for less nesting and indentation
In reply to [email protected]From: Filipe Manana <[email protected]>
Refactor btrfs_dio_submit_io() to avoid so much nesting and the need to split long lines, making it a bit easier to read.
--- fs/btrfs/inode.c | 52 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 27 deletions(-)
fs/btrfs/inode.c +25 -27
@@ -7869,6 +7869,8 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,struct btrfs_dio_private *dip = container_of(bbio, struct btrfs_dio_private, bbio);struct btrfs_dio_data *dio_data = iter->private; +struct btrfs_ordered_extent *oe = dio_data->ordered; +int ret;btrfs_bio_init (bbio,BTRFS_I (iter->inode)->root->fs_info, btrfs_dio_end_io, bio->bi_private);
@@ -7880,6 +7882,8 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio, dio_data->submitted += bio->bi_iter.bi_size; +if (!(iter->flags &IOMAP_WRITE )) + goto submit_bio;/* * Check if we are doing a partial write. If we are, we need to split * the ordered extent to match the submitted bio. Hang on to the
@@ -7887,37 +7891,31 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,* cancelled in iomap_end to avoid a deadlock wherein faulting the * remaining pages is blocked on the outstanding ordered extent. */ -if (iter->flags &IOMAP_WRITE ) { -struct btrfs_ordered_extent *oe = dio_data->ordered; -int ret; - - ret =btrfs_extract_ordered_extent (bbio, oe); -if (ret) { -/* -* If this is a COW write it means we created new extent -* maps for the range and they point to an unwritten -* location since we got an error and we don't submit -* a bio. We must drop any extent maps within the range, -* otherwise a fast fsync would log them and after a -* crash and log replay we would have file extent items -* that point to unwritten locations (garbage). -*/ -if (!test_bit (BTRFS_ORDERED_NOCOW , &oe->flags)) { -const u64 start = oe->file_offset; -const u64 end = start + oe->num_bytes -1 ; + ret =btrfs_extract_ordered_extent (bbio, oe); +if (!ret) + goto submit_bio; -btrfs_drop_extent_map_range (bbio->inode, start, end, false); - } +/* +* If this is a COW write it means we created new extent maps for the +* range and they point to an unwritten location since we got an error +* and we don't submit a bio. We must drop any extent maps within the +* range, otherwise a fast fsync would log them and after a crash and +* log replay we would have file extent items that point to unwritten +* locations (garbage). +*/ +if (!test_bit (BTRFS_ORDERED_NOCOW , &oe->flags)) { +const u64 start = oe->file_offset; +const u64 end = start + oe->num_bytes -1 ; -btrfs_finish_ordered_extent (oe,NULL , - file_offset, dip->bytes, - !ret); - bio->bi_status =errno_to_blk_status (ret); -iomap_dio_bio_end_io (bio); -return ; - } +btrfs_drop_extent_map_range (bbio->inode, start, end, false); } +btrfs_finish_ordered_extent (oe,NULL , file_offset, dip->bytes, false); + bio->bi_status =errno_to_blk_status (ret); +iomap_dio_bio_end_io (bio); +return ; + +submit_bio:btrfs_submit_bio (bbio,0 ); }
Signature · 1 line
2.43.0
Re: [PATCH 2/2] btrfs: refactor btrfs_dio_submit_io() for less nesting and indentation
Quoted 6 lines · 在 2024/5/14 23:53, [email protected] 写道:
From: Filipe Manana <[email protected]>
Refactor
btrfs_dio_submit_io()to avoid so much nesting and the need to split long lines, making it a bit easier to read.Signed-off-by Filipe Manana <[email protected]>
Thanks,
Qu
Quoted 85 lines
--- fs/btrfs/inode.c | 52 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 27 deletions(-)fs/btrfs/inode.c +25
-27@@ -7869,6 +7869,8 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,struct btrfs_dio_private *dip = container_of(bbio, struct btrfs_dio_private, bbio);struct btrfs_dio_data *dio_data = iter->private; +struct btrfs_ordered_extent *oe = dio_data->ordered; +int ret;btrfs_bio_init (bbio,BTRFS_I (iter->inode)->root->fs_info, btrfs_dio_end_io, bio->bi_private);@@ -7880,6 +7882,8 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio, dio_data->submitted += bio->bi_iter.bi_size; +if (!(iter->flags &IOMAP_WRITE )) + goto submit_bio;/* * Check if we are doing a partial write. If we are, we need to split * the ordered extent to match the submitted bio. Hang on to the @@ -7887,37 +7891,31 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,* cancelled in iomap_end to avoid a deadlock wherein faulting the * remaining pages is blocked on the outstanding ordered extent. */ -if (iter->flags &IOMAP_WRITE ) { -struct btrfs_ordered_extent *oe = dio_data->ordered; -int ret; - - ret =btrfs_extract_ordered_extent (bbio, oe); -if (ret) { -/* -* If this is a COW write it means we created new extent -* maps for the range and they point to an unwritten -* location since we got an error and we don't submit -* a bio. We must drop any extent maps within the range, -* otherwise a fast fsync would log them and after a -* crash and log replay we would have file extent items -* that point to unwritten locations (garbage). -*/ -if (!test_bit (BTRFS_ORDERED_NOCOW , &oe->flags)) { -const u64 start = oe->file_offset; -const u64 end = start + oe->num_bytes -1 ; + ret =btrfs_extract_ordered_extent (bbio, oe); +if (!ret) + goto submit_bio; -btrfs_drop_extent_map_range (bbio->inode, start, end, false); - } +/* +* If this is a COW write it means we created new extent maps for the +* range and they point to an unwritten location since we got an error +* and we don't submit a bio. We must drop any extent maps within the +* range, otherwise a fast fsync would log them and after a crash and +* log replay we would have file extent items that point to unwritten +* locations (garbage). +*/ +if (!test_bit (BTRFS_ORDERED_NOCOW , &oe->flags)) { +const u64 start = oe->file_offset; +const u64 end = start + oe->num_bytes -1 ; -btrfs_finish_ordered_extent (oe,NULL , - file_offset, dip->bytes, - !ret); - bio->bi_status =errno_to_blk_status (ret); -iomap_dio_bio_end_io (bio); -return ; - } +btrfs_drop_extent_map_range (bbio->inode, start, end, false); } +btrfs_finish_ordered_extent (oe,NULL , file_offset, dip->bytes, false); + bio->bi_status =errno_to_blk_status (ret); +iomap_dio_bio_end_io (bio); +return ; + +submit_bio:btrfs_submit_bio (bbio,0 ); }
v2 cover btrfs: fix a bug in the direct IO write path for COW writes
In reply to [email protected]From: Filipe Manana <[email protected]>
Fix a bug in an error path for direct IO writes in COW mode, which can make a subsequent fsync log invalid extent items (pointing to unwritten data). The second patch is just a cleanup. Details in the change logs.
V2: Rework solution since other error paths caused the same problem, make
it more generic.
Added more details to change log and comment about what's going on, and why reads aren't affected.
Filipe Manana (2):
btrfs: immediately drop extent maps after failed COW write
btrfs: make btrfs_finish_ordered_extent() return void
fs/btrfs/ordered-data.c | 30 ++++++++++++++++++++++++++++-- fs/btrfs/ordered-data.h | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 btrfs: immediately drop extent maps after failed COW write
From: Filipe Manana <[email protected]>
If a write path in COW mode fails, either before submitting a bio for the new extents or an actual IO error happens, we can end up allowing a fast fsync to log file extent items that point to unwritten extents.
This is because the ordered extent completion for a failed write is executed in a work queue. This means that once the write path unlocks the inode, a fast fsync can come and log the extent maps created by the write attempt before the work queue completes the ordered extent.
For example consider a direct IO write, in COW mode, that fails at btrfs_dio_submit_io() because btrfs_extract_ordered_extent() returned an error:
1) We call btrfs_finish_ordered_extent() with the 'uptodate' parameter set to false, meaning an error happened;
2) That results in marking the ordered extent with the BTRFS_ORDERED_IOERR flag;
3) btrfs_finish_ordered_extent() queues the completion of the ordered extent - so that btrfs_finish_one_ordered() will be executed later in a work queue. That function will drop extents maps in the range when it's executed, since the extent maps point to unwritten locations (signaled by the BTRFS_ORDERED_IOERR flag);
4) After calling btrfs_finish_ordered_extent() we keep going down the write path and unlock the inode;
5) After that a fast fsync starts and locks the inode;
6) Before the work queue executes btrfs_finish_one_ordered(), the fsync task sees the extent maps that point to the unwritten locations and logs file extent items based on them - it does not know they are unwritten, and the fast fsync path does not wait for ordered extents to complete in order to reduce latency.
So to fix this make btrfs_finish_ordered_extent() drop the extent maps in the range if an error happened for a COW write.
Note that this issues of using extent maps that point to unwritten locations can not happen for reads, because in read paths we start by locking the extent range and wait for any ordered extents in the range to complete before looking for extent maps.
--- fs/btrfs/ordered-data.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
fs/btrfs/ordered-data.c +27 -0
@@ -388,6 +388,33 @@ bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, ret =can_finish_ordered_extent (ordered, page, file_offset, len, uptodate);spin_unlock_irqrestore (&inode->ordered_tree_lock, flags); +/* +* If this is a COW write it means we created new extent maps for the +* range and they point to an unwritten location if we got an error +* either before submitting a bio or during IO. +* +* We have marked the ordered extent with BTRFS_ORDERED_IOERR, and we +* are queuing its completion below. During completion, at +* btrfs_finish_one_ordered(), we will drop the extent maps for the +* unwritten extents. +* +* However because completion runs in a work queue we can end up +* unlocking the inode before the ordered extent is completed. +* +* That means that a fast fsync can happen before the work queue +* executes the completion of the ordered extent, and in that case +* the fsync will use the extent maps that point to unwritten extents, +* resulting in logging file extent items that point to unwritten +* locations. Unlike read paths, a fast fsync doesn't wait for ordered +* extent completion before proceeding (intentional to reduce latency). +* +* To be safe drop the new extent maps in the range (if are doing COW) +* right here before we unlock the inode and allow a fsync to run. +*/ +if (!uptodate && !test_bit (BTRFS_ORDERED_NOCOW , &ordered->flags)) +btrfs_drop_extent_map_range (inode, file_offset, + file_offset + len -1 , false); +if (ret)btrfs_queue_ordered_fn (ordered);return ret;
Signature · 1 line
2.43.0
Re: [PATCH v2 1/2] btrfs: immediately drop extent maps after failed COW write
Quoted 41 lines · 在 2024/5/16 04:21, [email protected] 写道:
From: Filipe Manana <[email protected]>
If a write path in COW mode fails, either before submitting a bio for the new extents or an actual IO error happens, we can end up allowing a fast fsync to log file extent items that point to unwritten extents.
This is because the ordered extent completion for a failed write is executed in a work queue. This means that once the write path unlocks the inode, a fast fsync can come and log the extent maps created by the write attempt before the work queue completes the ordered extent.
For example consider a direct IO write, in COW mode, that fails at
btrfs_dio_submit_io()becausebtrfs_extract_ordered_extent()returned an error:1) We call
btrfs_finish_ordered_extent()with the 'uptodate' parameterset to false, meaning an error happened;2) That results in marking the ordered extent with the
BTRFS_ORDERED_IOERRflag;3)
btrfs_finish_ordered_extent()queues the completion of the ordered extent - so thatbtrfs_finish_one_ordered()will be executed later in a work queue. That function will drop extents maps in the range when it's executed, since the extent maps point to unwritten locations (signaled by theBTRFS_ORDERED_IOERRflag);4) After calling
btrfs_finish_ordered_extent()we keep going down thewrite path and unlock the inode;5) After that a fast fsync starts and locks the inode;
6) Before the work queue executes
btrfs_finish_one_ordered(), the fsync task sees the extent maps that point to the unwritten locations and logs file extent items based on them - it does not know they are unwritten, and the fast fsync path does not wait for ordered extents to complete in order to reduce latency.So to fix this make
btrfs_finish_ordered_extent()drop the extent maps in the range if an error happened for a COW write.
Quoted 6 lines
Note that this issues of using extent maps that point to unwritten locations can not happen for reads, because in read paths we start by locking the extent range and wait for any ordered extents in the range to complete before looking for extent maps.
Signed-off-by Filipe Manana <[email protected]>
Thanks for the detailed explanation on the issue.
Thanks,
Qu
Quoted 42 lines
--- fs/btrfs/ordered-data.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)fs/btrfs/ordered-data.c +27
-0@@ -388,6 +388,33 @@ bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, ret =can_finish_ordered_extent (ordered, page, file_offset, len, uptodate);spin_unlock_irqrestore (&inode->ordered_tree_lock, flags); +/* +* If this is a COW write it means we created new extent maps for the +* range and they point to an unwritten location if we got an error +* either before submitting a bio or during IO. +* +* We have marked the ordered extent with BTRFS_ORDERED_IOERR, and we +* are queuing its completion below. During completion, at +* btrfs_finish_one_ordered(), we will drop the extent maps for the +* unwritten extents. +* +* However because completion runs in a work queue we can end up +* unlocking the inode before the ordered extent is completed. +* +* That means that a fast fsync can happen before the work queue +* executes the completion of the ordered extent, and in that case +* the fsync will use the extent maps that point to unwritten extents, +* resulting in logging file extent items that point to unwritten +* locations. Unlike read paths, a fast fsync doesn't wait for ordered +* extent completion before proceeding (intentional to reduce latency). +* +* To be safe drop the new extent maps in the range (if are doing COW) +* right here before we unlock the inode and allow a fsync to run. +*/ +if (!uptodate && !test_bit (BTRFS_ORDERED_NOCOW , &ordered->flags)) +btrfs_drop_extent_map_range (inode, file_offset, + file_offset + len -1 , false); +if (ret)btrfs_queue_ordered_fn (ordered);return ret;
PATCH v2 2/2 btrfs: make btrfs_finish_ordered_extent() return void
In reply to [email protected]From: Filipe Manana <[email protected]>
Currently btrfs_finish_ordered_extent() returns a boolean indicating if the ordered extent was added to the work queue for completion, but none of its callers cares about it, so make it return void.
--- fs/btrfs/ordered-data.c | 3 +-- fs/btrfs/ordered-data.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/ordered-data.c +1 -2
@@ -374,7 +374,7 @@ static void btrfs_queue_ordered_fn(struct btrfs_ordered_extent *ordered)btrfs_queue_work (wq, &ordered->work); } -bool btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered, +void btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered,struct page *page,u64 file_offset,u64 len,bool uptodate) {
@@ -417,7 +417,6 @@ bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered,if (ret)btrfs_queue_ordered_fn (ordered); -return ret; }/*
fs/btrfs/ordered-data.h +1 -1
@@ -162,7 +162,7 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);void btrfs_put_ordered_extent (struct btrfs_ordered_extent *entry);void btrfs_remove_ordered_extent (struct btrfs_inode *btrfs_inode,struct btrfs_ordered_extent *entry); -bool btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered, +void btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered,struct page *page,u64 file_offset,u64 len,bool uptodate); void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode,
Signature · 1 line
2.43.0
Re: [PATCH v2 2/2] btrfs: make btrfs_finish_ordered_extent() return void
Quoted 7 lines · 在 2024/5/16 04:21, [email protected] 写道:
From: Filipe Manana <[email protected]>
Currently
btrfs_finish_ordered_extent()returns a boolean indicating if the ordered extent was added to the work queue for completion, but none of its callers cares about it, so make it return void.Signed-off-by Filipe Manana <[email protected]>
Thanks,
Qu
Quoted 39 lines
--- fs/btrfs/ordered-data.c | 3 +-- fs/btrfs/ordered-data.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)fs/btrfs/ordered-data.c +1
-2@@ -374,7 +374,7 @@ static void btrfs_queue_ordered_fn(struct btrfs_ordered_extent *ordered)btrfs_queue_work (wq, &ordered->work); } -bool btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered, +void btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered,struct page *page,u64 file_offset,u64 len,bool uptodate) {@@ -417,7 +417,6 @@ bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered,if (ret)btrfs_queue_ordered_fn (ordered); -return ret; }/* fs/btrfs/ordered-data.h +1
-1@@ -162,7 +162,7 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);void btrfs_put_ordered_extent (struct btrfs_ordered_extent *entry);void btrfs_remove_ordered_extent (struct btrfs_inode *btrfs_inode,struct btrfs_ordered_extent *entry); -bool btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered, +void btrfs_finish_ordered_extent (struct btrfs_ordered_extent *ordered,struct page *page,u64 file_offset,u64 len,bool uptodate); void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode,
Quoted 6 lines · On Wed, May 15, 2024 at 07:51:45PM +0100, [email protected] wrote:
From: Filipe Manana <[email protected]>
Fix a bug in an error path for direct IO writes in COW mode, which can make a subsequent fsync log invalid extent items (pointing to unwritten data). The second patch is just a cleanup. Details in the change logs.
Quoted 8 lines
V2: Rework solution since other error paths caused the same problem, make
it more generic.
Added more details to change log and comment about what's going on, and why reads aren't affected.Filipe Manana (2):
btrfs: immediately drop extent maps after failed COW write
btrfs: makebtrfs_finish_ordered_extent()return void
For the record, patches have been removed from for-next as the new code does NOFS allocation in irq context (reproduced by btrfs/146 and btrfs/160).
Quoted 13 lines · David Sterba
Quoted 11 lines · On Wed, May 15, 2024 at 07:51:45PM +0100, [email protected] wrote:
From: Filipe Manana <[email protected]>
Fix a bug in an error path for direct IO writes in COW mode, which can make a subsequent fsync log invalid extent items (pointing to unwritten data). The second patch is just a cleanup. Details in the change logs.
V2: Rework solution since other error paths caused the same problem, make
it more generic.
Added more details to change log and comment about what's going on, and why reads aren't affected.
Quoted 7 lines
Quoted 3 lines
Filipe Manana (2):
btrfs: immediately drop extent maps after failed COW write
btrfs: makebtrfs_finish_ordered_extent()return voidFor the record, patches have been removed from for-next as the new code does NOFS allocation in irq context (reproduced by btrfs/146 and btrfs/160).
Superseded by:
https://lore.kernel.org/linux-btrfs/[email protected]/